Skip to content

Commit

Permalink
Merge branch 'nrwl:master' into fix-serialize-overrides-into-command-…
Browse files Browse the repository at this point in the history
…line
  • Loading branch information
lukasalphta committed Oct 12, 2022
2 parents 59be760 + 7d19df0 commit f27bc07
Show file tree
Hide file tree
Showing 124 changed files with 6,142 additions and 1,194 deletions.
2 changes: 2 additions & 0 deletions .circleci/config.yml
Expand Up @@ -107,6 +107,8 @@ commands:
steps:
- run:
command: sudo apt-get install -y ca-certificates
- node/install:
node-version: 'latest'
- run-yarn-install:
os: << parameters.os >>
- when:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/e2e-matrix.yml
Expand Up @@ -21,10 +21,8 @@ jobs:
include:
- os: ubuntu-latest
os-name: ubuntu
os-cache-dir: /tmp/nx-cache
- os: macos-latest
os-name: osx
os-cache-dir: /tmp/nx-cache
node_version:
- '16'
package_manager:
Expand Down Expand Up @@ -90,7 +88,7 @@ jobs:
name: ${{ matrix.os-name }}/${{ matrix.package_manager }} - ${{ matrix.packages }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

Expand Down Expand Up @@ -169,7 +167,7 @@ jobs:
YARN_REGISTRY: http://localhost:4872
NX_VERBOSE_LOGGING: ${{ 'true' }}
NX_E2E_SKIP_BUILD_CLEANUP: ${{ 'true' }}
NX_CACHE_DIRECTORY: ${{ matrix.os-cache-dir }}
NX_CACHE_DIRECTORY: ${{ 'tmp' }}

- name: Setup tmate session
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled && failure() }}
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/e2e-windows.yml
Expand Up @@ -40,7 +40,7 @@ jobs:
name: ${{ matrix.packages }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

Expand All @@ -64,6 +64,13 @@ jobs:
windows-node-${{ matrix.node_version }}-
windows-
- name: Cache Cypress Binary
id: cache-cypress-binary
uses: actions/cache@v2
with:
path: C:\Users\runneradmin\AppData\Local\Cypress\Cache
key: cypress-binary-${{ hashFiles('yarn.lock') }}

- name: Install packages
run: yarn install --prefer-offline --frozen-lockfile --non-interactive

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/npm-audit.yml
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Run a security audit
run: npx audit-ci --critical --report-type summary
Expand Down
20 changes: 20 additions & 0 deletions docs/README.md
Expand Up @@ -2,6 +2,26 @@

## Markdown syntax available

The default markdown syntax is supported when writing documentation.

### Front matter

Front matter is used to add metadata to your Markdown file (`title` & `description`). It is provided at the very top of the file, enclosed by three dashes `---`. The content is parsed as `YAML`.

If no Front matter is detected, the metadata will be populated with the following:

- `title`: first main title detected
- `description`: first paragraph detected

```markdown
---
title: This is a custom title
description: This is a custom description
---
```

### Custom markdown syntax

The documentation website [nx.dev](https://nx.dev) is using custom Markdown syntax to enable the authors to add functionality to its content.

#### Callouts
Expand Down
4 changes: 2 additions & 2 deletions docs/generated/devkit/index.md
Expand Up @@ -1081,7 +1081,7 @@ Prefixes project name with npm scope

### getOutputsForTargetAndConfiguration

**getOutputsForTargetAndConfiguration**(`task`, `node`): `any`
**getOutputsForTargetAndConfiguration**(`task`, `node`): `string`[]

Returns the list of outputs that will be cached.

Expand All @@ -1094,7 +1094,7 @@ Returns the list of outputs that will be cached.

#### Returns

`any`
`string`[]

---

Expand Down
46 changes: 29 additions & 17 deletions docs/generated/packages/angular.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/generated/packages/devkit.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/generated/packages/storybook.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/shared/core-features/integrate-with-editors.md
Expand Up @@ -4,7 +4,7 @@ Nx Console is the UI for Nx. It works for any generator or any architect command

## Download

### VSCode
### VSCode Plugin: Nx Console

If you are using [VSCode](https://code.visualstudio.com/), you can install the [Nx Console VSCode Plugin](https://marketplace.visualstudio.com/items?itemName=nrwl.angular-console) from Marketplace. The Nx Console VSCode Plugin is **built and maintained by the Nx team**.

Expand Down
8 changes: 4 additions & 4 deletions docs/shared/guides/storybook/angular-browser-target.md
@@ -1,10 +1,10 @@
# The `browserTarget` for Angular projects with a Storybook configuration

{% callout type="note" title="Note" %}
This documentation page contains information about the [Storybook plugin](/packages/storybook), specifically regarding [Angular projects that are using Storybook](/storybook/overview-angular).
{% /callout %}

## The `browserTarget` for Angular projects with a Storybook configuration

### Setting up `browserTarget`
## Setting up `browserTarget`

If you're using [Storybook](/packages/storybook) in your Angular project, you will notice that `browserTarget` is specified for the `storybook` and `build-storybook` targets, much like it is done for `serve` or other targets. Angular needs the `browserTarget` for Storybook in order to know which configuration to use for the build. If your project is buildable (it has a `build` target, and uses the main Angular builder - `@angular-devkit/build-angular:browser`) the `browserTarget` for Storybook will use the `build` target, if it's not buildable it will use the `build-storybook` target.
You do not have to do anything manually. Nx will create the configuration for you. Even if you are migrating from an older version of Nx, Nx will make sure to change your `package.json` Storybook targets to match the new schema.
Expand Down Expand Up @@ -35,7 +35,7 @@ Your Storybook targets in your `project.json` will look like this:

This setup instructs Nx to use the configuration under the `build` target of `my-project` when using the `storybook` and `build-storybook` executors.

### Setting up `projectBuildConfig` for Nx versions `<14.1.8`
## Setting up `projectBuildConfig` for Nx versions `<14.1.8`

**_Careful: This is for older versions of Nx - for the latest version please look at the section above, about `browserTarget`_**

Expand Down
6 changes: 3 additions & 3 deletions docs/shared/guides/storybook/angular-configuring-styles.md
@@ -1,9 +1,9 @@
# Configuring styles and preprocessor options for Angular projects with a Storybook configuration

{% callout type="note" title="Note" %}
This documentation page contains information about the [Storybook plugin](/packages/storybook), specifically regarding [Angular projects that are using Storybook](/storybook/overview-angular).
{% /callout %}

## Configuring styles and preprocessor options for Angular projects with a Storybook configuration

Angular supports including extra entry-point files for styles. Also, in case you use Sass, you can add extra base paths that will be checked for imports. In your project's `project.json` file you can use the `styles` and `stylePreprocessorOptions` properties in your `storybook` and `build-storybook` target `options`, as you would in your Storybook or your Angular configurations. If your project is an application, you can add these extra options in your `build` target. Your `storybook` and `build-storybook` `browserTarget` are going to be pointing to the `build` target, so they will pick up these styles from there. Check out the [Angular Workspace Configuration](https://angular.io/guide/workspace-config#styles-and-scripts-configuration) documentation for more information. You can also check the [official Storybook for Angular documentation](https://storybook.js.org/docs/angular/configure/styling-and-css) on working with styles and CSS.

Your Storybook targets in your `project.json` will look like this:
Expand Down Expand Up @@ -34,7 +34,7 @@ Your Storybook targets in your `project.json` will look like this:
}
```

### Using build-storybook for styles
## Using build-storybook for styles

Chances are, you will most probably need the same `styles` and `stylePreprocessorOptions` for your `storybook` and your `build-storybook` targets. Since you're using `browserTarget`, that means that Storybook will use the `options` of `build` or `build-storybook` when executing the `storybook` task (when compiling your Storybook). In that case, as explained, you _only_ need to add the `styles` or `stylePreprocessorOptions` to the corresponding target (`build` or `build-storybook`) that the `browserTarget` is pointing to. In that case, for example, the configuration shown above would look like this:

Expand Down
8 changes: 4 additions & 4 deletions docs/shared/guides/storybook/angular-storybook-compodoc.md
@@ -1,10 +1,10 @@
# Set up Compodoc for Storybook on Nx

{% callout type="note" title="Note" %}
This documentation page contains information about the [Storybook plugin](/packages/storybook), specifically regarding [Angular projects that are using Storybook](/storybook/overview-angular).
{% /callout %}

# Set up Compodoc for Storybook on Nx

{% github-repository url="https://github.com/mandarini/nx-recipes/tree/feat/storybook-compodoc/storybook-compodoc-angular" /%}
{% github-repository url="https://github.com/nrwl/nx-recipes/tree/main/storybook-compodoc-angular" /%}

## What is Compodoc

Expand All @@ -28,7 +28,7 @@ This comment would result in the following documentation in Compodoc:

![Button size `@Input` generated documentation](/shared/guides/storybook/button-size-input.png)

If we add a description and a default value to each of our component `@Input`s, we will end up with a full documentation page. See a full example of the button component [here](https://github.com/mandarini/nx-recipes/blob/feat/storybook-compodoc/storybook-compodoc-angular/apps/web/src/app/butn/butn.component.ts). The generated documentation of this example will look like this:
If we add a description and a default value to each of our component `@Input`s, we will end up with a full documentation page. See a full example of the button component [here](https://github.com/nrwl/nx-recipes/tree/main/storybook-compodoc-angular/apps/web/src/app/butn/butn.component.ts). The generated documentation of this example will look like this:

![Generated Docs page for the Button](/shared/guides/storybook/button-docs.png)

Expand Down
4 changes: 2 additions & 2 deletions docs/shared/guides/storybook/angular-storybook-targets.md
@@ -1,9 +1,9 @@
# Information about `storybook` and `build-storybook` targets for Angular projects with a Storybook configuration

{% callout type="note" title="Note" %}
This documentation page contains information about the [Storybook plugin](/packages/storybook), specifically regarding [Angular projects that are using Storybook](/storybook/overview-angular).
{% /callout %}

## Information about `storybook` and `build-storybook` targets for Angular projects with a Storybook configuration

If you are on Nx version `>=14.1.8`, the [Nx Storybook plugin for _Angular_ projects](/storybook/overview-angular) uses the original Storybook executors for Angular (`"@storybook/angular:start-storybook"` and `"@storybook/angular:build-storybook"`) to serve and build Storybook.

That means that you can use the official [Storybook for Angular documentation (expand the "Troubleshooting" section)](https://storybook.js.org/docs/angular/get-started/install#troubleshooting) to configure the options for serving and building Storybook.
Expand Down
1 change: 1 addition & 0 deletions e2e/angular-core/src/ng-add.test.ts
Expand Up @@ -148,6 +148,7 @@ describe('convert Angular CLI workspace to an Nx workspace', () => {
cli: {
packageManager: packageManager,
},
defaultProject: project,
implicitDependencies: {
'.eslintrc.json': '*',
'package.json': {
Expand Down
11 changes: 11 additions & 0 deletions e2e/js/src/js.test.ts
Expand Up @@ -317,16 +317,21 @@ export function ${lib}Wildcard() {
const buildable = uniq('buildable');
runCLI(`generate @nrwl/js:lib ${buildable}`);

const buildableTwo = uniq('buildabletwo');
runCLI(`generate @nrwl/js:lib ${buildableTwo}`);

const nonBuildable = uniq('nonbuildable');
runCLI(`generate @nrwl/js:lib ${nonBuildable} --buildable=false`);

updateFile(`libs/${parent}/src/lib/${parent}.ts`, () => {
return `
import { ${buildable} } from '@${scope}/${buildable}';
import { ${buildableTwo} } from '@${scope}/${buildableTwo}';
import { ${nonBuildable} } from '@${scope}/${nonBuildable}';
export function ${parent}() {
${buildable}();
${buildableTwo}();
${nonBuildable}();
}
`;
Expand All @@ -337,6 +342,7 @@ export function ${parent}() {
runCLI(`build ${parent} --external=all`);
checkFilesExist(
`dist/libs/${buildable}/src/index.js`, // buildable
`dist/libs/${buildableTwo}/src/index.js`, // buildable two
`dist/libs/${parent}/src/index.js`, // parent
`dist/libs/${parent}/${nonBuildable}/src/index.js` // inlined non buildable
);
Expand All @@ -350,22 +356,27 @@ export function ${parent}() {
checkFilesExist(
`dist/libs/${parent}/src/index.js`, // parent
`dist/libs/${parent}/${buildable}/src/index.js`, // inlined buildable
`dist/libs/${parent}/${buildableTwo}/src/index.js`, // inlined buildable two
`dist/libs/${parent}/${nonBuildable}/src/index.js` // inlined non buildable
);
fileContent = readFile(`dist/libs/${parent}/src/lib/${parent}.js`);
expect(fileContent).toContain(`${nonBuildable}/src`);
expect(fileContent).toContain(`${buildable}/src`);
expect(fileContent).toContain(`${buildableTwo}/src`);

// 3. external is set to an array of libs
execSync(`rm -rf dist`);
runCLI(`build ${parent} --external=${buildable}`);
checkFilesExist(
`dist/libs/${buildable}/src/index.js`, // buildable
`dist/libs/${buildableTwo}/src/index.js`, // buildable two original output should be persisted
`dist/libs/${parent}/src/index.js`, // parent
`dist/libs/${parent}/${buildableTwo}/src/index.js`, // inlined buildable two
`dist/libs/${parent}/${nonBuildable}/src/index.js` // inlined non buildable
);
fileContent = readFile(`dist/libs/${parent}/src/lib/${parent}.js`);
expect(fileContent).toContain(`${nonBuildable}/src`);
expect(fileContent).toContain(`${buildableTwo}/src`);
expect(fileContent).not.toContain(`${buildable}/src`);
},
120000
Expand Down
20 changes: 14 additions & 6 deletions e2e/nx-misc/src/workspace.test.ts
Expand Up @@ -24,9 +24,7 @@ describe('Workspace Tests', () => {
proj = newProject();
});

afterAll(() => {
cleanupProject();
});
afterAll(() => cleanupProject());

describe('@nrwl/workspace:library', () => {
it('should create a library that can be tested and linted', async () => {
Expand Down Expand Up @@ -195,6 +193,10 @@ describe('Workspace Tests', () => {
type: 'boolean',
description: 'skip changes to tsconfig',
};
json.properties['inlineprop'] = json.properties['name'];
json.required = ['inlineprop'];
delete json.properties['name'];

updateFile(
`tools/generators/${custom}/schema.json`,
JSON.stringify(json)
Expand All @@ -205,10 +207,17 @@ describe('Workspace Tests', () => {
`tools/generators/${custom}/index.ts`,
indexFile.replace(
'name: schema.name',
'name: schema.name, directory: schema.directory, skipTsConfig: schema.skipTsConfig'
'name: schema.inlineprop, directory: schema.directory, skipTsConfig: schema.skipTsConfig'
)
);

const helpOutput = runCLI(`workspace-generator ${custom} --help`);
expect(helpOutput).toContain(
`workspace-generator ${custom} [inlineprop] (options)`
);
expect(helpOutput).toContain(`--directory`);
expect(helpOutput).toContain(`--skipTsConfig`);

const workspace = uniq('workspace');
const dryRunOutput = runCLI(
`workspace-generator ${custom} ${workspace} --no-interactive --directory=dir --skipTsConfig=true -d`
Expand All @@ -218,11 +227,10 @@ describe('Workspace Tests', () => {
`CREATE libs/dir/${workspace}/src/index.ts`
);

const output = runCLI(
runCLI(
`workspace-generator ${custom} ${workspace} --no-interactive --directory=dir`
);
checkFilesExist(`libs/dir/${workspace}/src/index.ts`);
expect(output).not.toContain('UPDATE nx.json');

const jsonFailing = readJson(`tools/generators/${failing}/schema.json`);
jsonFailing.properties = {};
Expand Down
12 changes: 9 additions & 3 deletions e2e/nx-run/src/cache.test.ts
Expand Up @@ -60,7 +60,13 @@ describe('cache', () => {
expect(outputWithBuildApp2Cached).toContain(
'read the output from the cache'
);
expectMatchedOutput(outputWithBuildApp2Cached, [myapp2]);

if (process.platform != 'linux') {
// TODO(vsavkin): This should be always be matched output once you fix output watching on linux
expectMatchedOutput(outputWithBuildApp2Cached, [myapp2]);
} else {
expectCached(outputWithBuildApp2Cached, [myapp2]);
}

// touch package.json
// --------------------------------------------
Expand Down Expand Up @@ -166,7 +172,7 @@ describe('cache', () => {
updateProjectConfig(mylib, (c) => {
c.targets.build = {
executor: 'nx:run-commands',
outputs: ['dist/*.txt'],
outputs: ['{workspaceRoot}/dist/*.txt'],
options: {
commands: [
'rm -rf dist',
Expand Down Expand Up @@ -312,7 +318,7 @@ describe('cache', () => {
expectProjectMatchTaskCacheStatus(
actualOutput,
expectedMatchedOutputProjects,
'local cache'
'existing outputs match the cache'
);
}

Expand Down
2 changes: 1 addition & 1 deletion e2e/nx-run/src/run.test.ts
Expand Up @@ -300,7 +300,7 @@ describe('Nx Running Tests', () => {
];
nxJson.targetDefaults = {
prep: {
outputs: ['one.txt'],
outputs: ['{workspaceRoot}/one.txt'],
},
outside: {
dependsOn: ['prep'],
Expand Down
7 changes: 5 additions & 2 deletions e2e/react-native/src/react-native.test.ts
Expand Up @@ -141,11 +141,11 @@ describe('react native', () => {
});
// Add import for Nx to pick up
updateFile(join('apps', appName, 'src/app/App.tsx'), (content) => {
return `import { launchImageLibrary } from 'react-native-image-picker';\n${content}`;
return `import AsyncStorage from '@react-native-async-storage/async-storage';import Config from 'react-native-config';\n${content}`;
});

await runCLIAsync(
`sync-deps ${appName} --include=react-native-gesture-handler,react-native-safe-area-context`
`sync-deps ${appName} --include=react-native-gesture-handler,react-native-safe-area-context,react-native-image-picker`
);

const result = readJson(join('apps', appName, 'package.json'));
Expand All @@ -154,6 +154,9 @@ describe('react native', () => {
'react-native-image-picker': '*',
'react-native-gesture-handler': '*',
'react-native-safe-area-context': '*',
'react-native': '*',
'react-native-config': '*',
'@react-native-async-storage/async-storage': '*',
},
});
});
Expand Down
2 changes: 1 addition & 1 deletion e2e/rollup/src/rollup.test.ts
Expand Up @@ -11,7 +11,7 @@ import {

describe('Rollup Plugin', () => {
beforeEach(() => newProject());
// afterEach(() => cleanupProject());
afterEach(() => cleanupProject());

it('should be able to setup project to build node programs with rollup and different compilers', async () => {
const myPkg = uniq('my-pkg');
Expand Down

0 comments on commit f27bc07

Please sign in to comment.