Skip to content

Commit

Permalink
Merge branch 'master' into fix/caching_issue_with_multiple_outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
agdimech committed Jul 20, 2023
2 parents b54dc20 + c2c06c1 commit abae52e
Show file tree
Hide file tree
Showing 66 changed files with 2,354 additions and 2,317 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"error",
{
"enforceBuildableLibDependency": true,
"checkDynamicDependenciesExceptions": [".*"],
"allow": [],
"depConstraints": [
{
Expand Down
5 changes: 5 additions & 0 deletions community/approved-plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
"description": "An nx plugin for the aws-cdk v2.",
"url": "https://github.com/adrian-goe/nx-aws-cdk-v2"
},
{
"name": "@berenddeboer/nx-sst",
"description": "Nx plugin to generate an SST stack and execute all SST commands.",
"url": "https://github.com/berenddeboer/nx-plugins/tree/main/packages/nx-sst"
},
{
"name": "@rxap/plugin-localazy",
"description": "An Nx plugin for localazy.com upload and download tasks.",
Expand Down
4 changes: 2 additions & 2 deletions docs/generated/cli/show.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Show only projects that have a specific target

### project

Show a list of targets in the workspace.
Shows resolved project configuration for a given project.

```shell
nx show project <projectName>
Expand All @@ -177,7 +177,7 @@ Show help

Type: `string`

Show targets for the given project
Which project should be viewed?

##### version

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ We use the version numbers of the installed packages when checking whether the v

## Usage

You can use the `dependency-checks` rule by adding it to your ESLint rules configuration:
Library generators from `@nx` packages will configure this rule automatically when you opt-in for bundler/build setup. This rule is intended for publishable/buildable libraries, so it will only run if a `build` target is detected in the configuration (this name can be modified - see [options](#options)).

```jsonc {% fileName=".eslintrc.json" %}
### Manual setup

To set it up manually for existing libraries, you need to add the `dependency-checks` rule to your project's ESLint configuration:

```jsonc {% fileName="<your-project-root>/.eslintrc.json" %}
{
// ... more ESLint config here
"overrides": [
Expand All @@ -26,9 +30,9 @@ You can use the `dependency-checks` rule by adding it to your ESLint rules confi
}
```

Linting `JSON` files is not enabled by default, so you will also need to add `package.json` to the `lintFilePatterns`:
Additionally, you need to adjust your `lintFilePatterns` to include the project's `package.json` file::

```jsonc {% fileName="project.json" %}
```jsonc {% fileName="<your-project-root>/project.json" %}
{
// ... project.json config
"targets": {
Expand All @@ -47,14 +51,20 @@ Linting `JSON` files is not enabled by default, so you will also need to add `pa
}
```

### Overriding defaults

Sometimes we intentionally want to add or remove a dependency from our `package.json` despite what the rule suggests. We can use the rule's options to override default behavior:

```jsonc {% fileName=".eslintrc.json" %}
{
"@nx/dependency-checks": [
"error",
{
// for available options check below
"buildTargets": ["build", "custom-build"], // add non standard build target names
"ignoredDependencies": ["lodash"], // these libs will be omitted from checks
"checkMissingDependencies": true, // toggle to disable
"checkObsoleteDependencies": true, // toggle to disable
"checkVersionMismatches": true // toggle to disable
}
]
}
Expand Down
4 changes: 2 additions & 2 deletions docs/generated/packages/nx/documents/show.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Show only projects that have a specific target

### project

Show a list of targets in the workspace.
Shows resolved project configuration for a given project.

```shell
nx show project <projectName>
Expand All @@ -177,7 +177,7 @@ Show help

Type: `string`

Show targets for the given project
Which project should be viewed?

##### version

Expand Down
5 changes: 5 additions & 0 deletions docs/shared/core-features/automate-updating-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ The `nx migrate` command helps by automating the process of updating:

## How does it work?

{% youtube
src="https://www.youtube.com/embed/3CIv-_hTTY4"
title="How Automated Code Migrations Work"
width="100%" /%}

Nx knows where its configuration files are and can therefore make sure they match the expected format. This automated update process, commonly referred to as "migration," becomes even more powerful when you leverage [Nx plugins](/packages). Nx plugins, which are NPM packages with a range of capabilities (code generation, task automation...), offer targeted updates based on their specific areas of responsibility.

For example, the [Nx ESLint plugin](/packages/linter) excels at configuring linting in your workspace. With its understanding of the configuration file locations, this plugin can provide precise migration scripts to update ESLint packages in your `package.json` and corresponding configuration files in your workspace when a new version is released.
Expand Down
20 changes: 15 additions & 5 deletions docs/shared/packages/linter/dependency-checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ We use the version numbers of the installed packages when checking whether the v

## Usage

You can use the `dependency-checks` rule by adding it to your ESLint rules configuration:
Library generators from `@nx` packages will configure this rule automatically when you opt-in for bundler/build setup. This rule is intended for publishable/buildable libraries, so it will only run if a `build` target is detected in the configuration (this name can be modified - see [options](#options)).

```jsonc {% fileName=".eslintrc.json" %}
### Manual setup

To set it up manually for existing libraries, you need to add the `dependency-checks` rule to your project's ESLint configuration:

```jsonc {% fileName="<your-project-root>/.eslintrc.json" %}
{
// ... more ESLint config here
"overrides": [
Expand All @@ -26,9 +30,9 @@ You can use the `dependency-checks` rule by adding it to your ESLint rules confi
}
```

Linting `JSON` files is not enabled by default, so you will also need to add `package.json` to the `lintFilePatterns`:
Additionally, you need to adjust your `lintFilePatterns` to include the project's `package.json` file::

```jsonc {% fileName="project.json" %}
```jsonc {% fileName="<your-project-root>/project.json" %}
{
// ... project.json config
"targets": {
Expand All @@ -47,14 +51,20 @@ Linting `JSON` files is not enabled by default, so you will also need to add `pa
}
```

### Overriding defaults

Sometimes we intentionally want to add or remove a dependency from our `package.json` despite what the rule suggests. We can use the rule's options to override default behavior:

```jsonc {% fileName=".eslintrc.json" %}
{
"@nx/dependency-checks": [
"error",
{
// for available options check below
"buildTargets": ["build", "custom-build"], // add non standard build target names
"ignoredDependencies": ["lodash"], // these libs will be omitted from checks
"checkMissingDependencies": true, // toggle to disable
"checkObsoleteDependencies": true, // toggle to disable
"checkVersionMismatches": true // toggle to disable
}
]
}
Expand Down
4 changes: 2 additions & 2 deletions docs/shared/reference/project-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,13 @@ Sometimes, multiple targets might write to the same directory. When possible it
}
```

But if the above is not possible, globs (parsed with the [minimatch](https://github.com/isaacs/minimatch) library) can be specified as outputs to only cache a set of files rather than the whole directory.
But if the above is not possible, globs (parsed by the [GlobSet](https://docs.rs/globset/0.4.5/globset/#syntax) Rust library) can be specified as outputs to only cache a set of files rather than the whole directory.

```json
{
"targets": {
"build-js": {
"outputs": ["{workspaceRoot}/dist/libs/mylib/**/*.js"]
"outputs": ["{workspaceRoot}/dist/libs/mylib/**/*.{js,map}"]
},
"build-css": {
"outputs": ["{workspaceRoot}/dist/libs/mylib/**/*.css"]
Expand Down
11 changes: 11 additions & 0 deletions e2e/expo/src/expo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
runCommandUntil,
uniq,
updateFile,
updateJson,
} from '@nx/e2e/utils';
import { join } from 'path';

Expand All @@ -24,6 +25,16 @@ describe('expo', () => {

beforeAll(() => {
proj = newProject();
// we create empty preset above which skips creation of `production` named input
updateJson('nx.json', (nxJson) => {
nxJson.namedInputs = {
default: ['{projectRoot}/**/*', 'sharedGlobals'],
production: ['default'],
sharedGlobals: [],
};
nxJson.targetDefaults.build.inputs = ['production', '^production'];
return nxJson;
});
runCLI(`generate @nx/expo:application ${appName} --no-interactive`);
runCLI(
`generate @nx/expo:library ${libName} --buildable --publishable --importPath=${proj}/${libName}`
Expand Down
4 changes: 2 additions & 2 deletions e2e/linter/src/linter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,12 +478,12 @@ describe('Linter', () => {
content.replace(/return .*;/, `return names(${mylib}).className;`)
);

// output should now report missing dependencies section
// output should now report missing dependency
out = runCLI(`lint ${mylib}`, { silenceError: true });
expect(out).toContain('they are missing');
expect(out).toContain('@nx/devkit');

// should fix the missing section issue
// should fix the missing dependency issue
out = runCLI(`lint ${mylib} --fix`, { silenceError: true });
expect(out).toContain(
`Successfully ran target lint for project ${mylib}`
Expand Down
6 changes: 5 additions & 1 deletion e2e/nx-misc/src/workspace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
getPackageManagerCommand,
getSelectedPackageManager,
runCommand,
runCreateWorkspace,
} from '@nx/e2e/utils';

let proj: string;
Expand Down Expand Up @@ -176,6 +175,7 @@ describe('Workspace Tests', () => {
expect(project.sourceRoot).toBe(`${newPath}/src`);
expect(project.targets.lint.options.lintFilePatterns).toEqual([
`libs/shared/${lib1}/data-access/**/*.ts`,
`libs/shared/${lib1}/data-access/package.json`,
]);

/**
Expand Down Expand Up @@ -306,6 +306,7 @@ describe('Workspace Tests', () => {

expect(project.targets.lint.options.lintFilePatterns).toEqual([
`libs/shared/${lib1}/data-access/**/*.ts`,
`libs/shared/${lib1}/data-access/package.json`,
]);

/**
Expand Down Expand Up @@ -434,6 +435,7 @@ describe('Workspace Tests', () => {
expect(project.sourceRoot).toBe(`${newPath}/src`);
expect(project.targets.lint.options.lintFilePatterns).toEqual([
`packages/shared/${lib1}/data-access/**/*.ts`,
`packages/shared/${lib1}/data-access/package.json`,
]);
expect(project.tags).toEqual([]);

Expand Down Expand Up @@ -569,6 +571,7 @@ describe('Workspace Tests', () => {
expect(project.sourceRoot).toBe(`${newPath}/src`);
expect(project.targets.lint.options.lintFilePatterns).toEqual([
`libs/${lib1}/data-access/**/*.ts`,
`libs/${lib1}/data-access/package.json`,
]);

/**
Expand Down Expand Up @@ -682,6 +685,7 @@ describe('Workspace Tests', () => {
expect(project.sourceRoot).toBe(`${newPath}/src`);
expect(project.targets.lint.options.lintFilePatterns).toEqual([
`libs/shared/${lib1}/data-access/**/*.ts`,
`libs/shared/${lib1}/data-access/package.json`,
]);

/**
Expand Down
14 changes: 9 additions & 5 deletions e2e/nx-run/src/cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ describe('cache', () => {
updateProjectConfig(mylib, (c) => {
c.targets.build = {
executor: 'nx:run-commands',
outputs: ['{workspaceRoot}/dist/*.txt'],
outputs: ['{workspaceRoot}/dist/*.{txt,md}'],
options: {
commands: [
'rm -rf dist',
Expand All @@ -167,7 +167,8 @@ describe('cache', () => {
'echo c > dist/c.txt',
'echo d > dist/d.txt',
'echo e > dist/e.txt',
'echo f > dist/f.txt',
'echo f > dist/f.md',
'echo g > dist/g.html',
],
parallel: false,
},
Expand All @@ -188,7 +189,8 @@ describe('cache', () => {
expect(outputsWithUntouchedOutputs).toContain('c.txt');
expect(outputsWithUntouchedOutputs).toContain('d.txt');
expect(outputsWithUntouchedOutputs).toContain('e.txt');
expect(outputsWithUntouchedOutputs).toContain('f.txt');
expect(outputsWithUntouchedOutputs).toContain('f.md');
expect(outputsWithUntouchedOutputs).toContain('g.html');

// Create a file in the dist that does not match output glob
updateFile('dist/c.ts', '');
Expand All @@ -202,7 +204,8 @@ describe('cache', () => {
expect(outputsAfterAddingUntouchedFileAndRerunning).toContain('c.txt');
expect(outputsAfterAddingUntouchedFileAndRerunning).toContain('d.txt');
expect(outputsAfterAddingUntouchedFileAndRerunning).toContain('e.txt');
expect(outputsAfterAddingUntouchedFileAndRerunning).toContain('f.txt');
expect(outputsAfterAddingUntouchedFileAndRerunning).toContain('f.md');
expect(outputsAfterAddingUntouchedFileAndRerunning).toContain('g.html');
expect(outputsAfterAddingUntouchedFileAndRerunning).toContain('c.ts');

// Clear Dist
Expand All @@ -217,8 +220,9 @@ describe('cache', () => {
expect(outputsWithoutOutputs).toContain('c.txt');
expect(outputsWithoutOutputs).toContain('d.txt');
expect(outputsWithoutOutputs).toContain('e.txt');
expect(outputsWithoutOutputs).toContain('f.txt');
expect(outputsWithoutOutputs).toContain('f.md');
expect(outputsWithoutOutputs).not.toContain('c.ts');
expect(outputsWithoutOutputs).not.toContain('g.html');
});

it('should use consider filesets when hashing', async () => {
Expand Down
11 changes: 11 additions & 0 deletions e2e/react-native/src/react-native.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
runCommandUntil,
uniq,
updateFile,
updateJson,
} from '@nx/e2e/utils';
import { ChildProcess } from 'child_process';
import { join } from 'path';
Expand All @@ -25,6 +26,16 @@ describe('react native', () => {

beforeAll(() => {
proj = newProject();
// we create empty preset above which skips creation of `production` named input
updateJson('nx.json', (nxJson) => {
nxJson.namedInputs = {
default: ['{projectRoot}/**/*', 'sharedGlobals'],
production: ['default'],
sharedGlobals: [],
};
nxJson.targetDefaults.build.inputs = ['production', '^production'];
return nxJson;
});
runCLI(
`generate @nx/react-native:application ${appName} --install=false --no-interactive`
);
Expand Down
7 changes: 6 additions & 1 deletion graph/client/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,10 @@ module.exports = {
translate: ['group-hover'],
},
},
plugins: [require('@tailwindcss/typography')],
plugins: [
require('@tailwindcss/typography'),
require('@tailwindcss/forms')({
strategy: 'class',
}),
],
};
2 changes: 1 addition & 1 deletion graph/ui-components/src/lib/dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function Dropdown(props: DropdownProps) {
const { className, children, ...rest } = props;
return (
<select
className={`flex items-center rounded-md rounded-md border border-slate-300 bg-white px-4 py-2 text-sm font-medium text-slate-700 shadow-sm hover:bg-slate-50 dark:border-slate-600 dark:bg-slate-800 dark:text-slate-300 hover:dark:bg-slate-700 ${className}`}
className={`form-select flex items-center rounded-md rounded-md border border-slate-300 bg-white pl-4 pr-8 py-2 text-sm font-medium text-slate-700 shadow-sm hover:bg-slate-50 dark:border-slate-600 dark:bg-slate-800 dark:text-slate-300 hover:dark:bg-slate-700 ${className}`}
{...rest}
>
{children}
Expand Down
Loading

0 comments on commit abae52e

Please sign in to comment.