Skip to content

Commit a45ec7e

Browse files
authored
fix(core): restore older nx core migrations for repair (#31254)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> These migrations should not have been removed as part of the Nx 21 update ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> The migrations are restored ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
1 parent e724eed commit a45ec7e

22 files changed

+1165
-0
lines changed

docs/generated/manifests/nx-api.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3503,6 +3503,66 @@
35033503
"originalFilePath": "/packages/nx",
35043504
"path": "/nx-api/nx/migrations/19-2-0-move-graph-cache-directory",
35053505
"type": "migration"
3506+
},
3507+
"/nx-api/nx/migrations/move-default-base-to-nx-json-root": {
3508+
"description": "Moves affected.defaultBase to defaultBase in `nx.json`",
3509+
"file": "generated/packages/nx/migrations/move-default-base-to-nx-json-root.json",
3510+
"hidden": false,
3511+
"name": "move-default-base-to-nx-json-root",
3512+
"version": "18.1.0-beta.3",
3513+
"originalFilePath": "/packages/nx",
3514+
"path": "/nx-api/nx/migrations/move-default-base-to-nx-json-root",
3515+
"type": "migration"
3516+
},
3517+
"/nx-api/nx/migrations/18.0.0-disable-adding-plugins-for-existing-workspaces": {
3518+
"description": "Updates nx.json to disabled adding plugins when generating projects in an existing Nx workspace",
3519+
"file": "generated/packages/nx/migrations/18.0.0-disable-adding-plugins-for-existing-workspaces.json",
3520+
"hidden": false,
3521+
"name": "18.0.0-disable-adding-plugins-for-existing-workspaces",
3522+
"version": "18.0.0-beta.2",
3523+
"originalFilePath": "/packages/nx",
3524+
"path": "/nx-api/nx/migrations/18.0.0-disable-adding-plugins-for-existing-workspaces",
3525+
"type": "migration"
3526+
},
3527+
"/nx-api/nx/migrations/17.3.0-update-nx-wrapper": {
3528+
"description": "Updates the nx wrapper.",
3529+
"file": "generated/packages/nx/migrations/17.3.0-update-nx-wrapper.json",
3530+
"hidden": false,
3531+
"name": "17.3.0-update-nx-wrapper",
3532+
"version": "17.3.0-beta.6",
3533+
"originalFilePath": "/packages/nx",
3534+
"path": "/nx-api/nx/migrations/17.3.0-update-nx-wrapper",
3535+
"type": "migration"
3536+
},
3537+
"/nx-api/nx/migrations/rm-default-collection-npm-scope": {
3538+
"description": "Migration for v17.0.0-rc.1",
3539+
"file": "generated/packages/nx/migrations/rm-default-collection-npm-scope.json",
3540+
"hidden": false,
3541+
"name": "rm-default-collection-npm-scope",
3542+
"version": "17.0.0-rc.1",
3543+
"originalFilePath": "/packages/nx",
3544+
"path": "/nx-api/nx/migrations/rm-default-collection-npm-scope",
3545+
"type": "migration"
3546+
},
3547+
"/nx-api/nx/migrations/17.0.0-use-minimal-config-for-tasks-runner-options": {
3548+
"description": "Use minimal config for tasksRunnerOptions",
3549+
"file": "generated/packages/nx/migrations/17.0.0-use-minimal-config-for-tasks-runner-options.json",
3550+
"hidden": false,
3551+
"name": "17.0.0-use-minimal-config-for-tasks-runner-options",
3552+
"version": "17.0.0-beta.3",
3553+
"originalFilePath": "/packages/nx",
3554+
"path": "/nx-api/nx/migrations/17.0.0-use-minimal-config-for-tasks-runner-options",
3555+
"type": "migration"
3556+
},
3557+
"/nx-api/nx/migrations/17.0.0-move-cache-directory": {
3558+
"description": "Updates the default cache directory to .nx/cache",
3559+
"file": "generated/packages/nx/migrations/17.0.0-move-cache-directory.json",
3560+
"hidden": false,
3561+
"name": "17.0.0-move-cache-directory",
3562+
"version": "17.0.0-beta.1",
3563+
"originalFilePath": "/packages/nx",
3564+
"path": "/nx-api/nx/migrations/17.0.0-move-cache-directory",
3565+
"type": "migration"
35063566
}
35073567
},
35083568
"path": "/nx-api/nx"

docs/generated/packages-metadata.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3479,6 +3479,66 @@
34793479
"originalFilePath": "/packages/nx",
34803480
"path": "nx/migrations/19-2-0-move-graph-cache-directory",
34813481
"type": "migration"
3482+
},
3483+
{
3484+
"description": "Moves affected.defaultBase to defaultBase in `nx.json`",
3485+
"file": "generated/packages/nx/migrations/move-default-base-to-nx-json-root.json",
3486+
"hidden": false,
3487+
"name": "move-default-base-to-nx-json-root",
3488+
"version": "18.1.0-beta.3",
3489+
"originalFilePath": "/packages/nx",
3490+
"path": "nx/migrations/move-default-base-to-nx-json-root",
3491+
"type": "migration"
3492+
},
3493+
{
3494+
"description": "Updates nx.json to disabled adding plugins when generating projects in an existing Nx workspace",
3495+
"file": "generated/packages/nx/migrations/18.0.0-disable-adding-plugins-for-existing-workspaces.json",
3496+
"hidden": false,
3497+
"name": "18.0.0-disable-adding-plugins-for-existing-workspaces",
3498+
"version": "18.0.0-beta.2",
3499+
"originalFilePath": "/packages/nx",
3500+
"path": "nx/migrations/18.0.0-disable-adding-plugins-for-existing-workspaces",
3501+
"type": "migration"
3502+
},
3503+
{
3504+
"description": "Updates the nx wrapper.",
3505+
"file": "generated/packages/nx/migrations/17.3.0-update-nx-wrapper.json",
3506+
"hidden": false,
3507+
"name": "17.3.0-update-nx-wrapper",
3508+
"version": "17.3.0-beta.6",
3509+
"originalFilePath": "/packages/nx",
3510+
"path": "nx/migrations/17.3.0-update-nx-wrapper",
3511+
"type": "migration"
3512+
},
3513+
{
3514+
"description": "Migration for v17.0.0-rc.1",
3515+
"file": "generated/packages/nx/migrations/rm-default-collection-npm-scope.json",
3516+
"hidden": false,
3517+
"name": "rm-default-collection-npm-scope",
3518+
"version": "17.0.0-rc.1",
3519+
"originalFilePath": "/packages/nx",
3520+
"path": "nx/migrations/rm-default-collection-npm-scope",
3521+
"type": "migration"
3522+
},
3523+
{
3524+
"description": "Use minimal config for tasksRunnerOptions",
3525+
"file": "generated/packages/nx/migrations/17.0.0-use-minimal-config-for-tasks-runner-options.json",
3526+
"hidden": false,
3527+
"name": "17.0.0-use-minimal-config-for-tasks-runner-options",
3528+
"version": "17.0.0-beta.3",
3529+
"originalFilePath": "/packages/nx",
3530+
"path": "nx/migrations/17.0.0-use-minimal-config-for-tasks-runner-options",
3531+
"type": "migration"
3532+
},
3533+
{
3534+
"description": "Updates the default cache directory to .nx/cache",
3535+
"file": "generated/packages/nx/migrations/17.0.0-move-cache-directory.json",
3536+
"hidden": false,
3537+
"name": "17.0.0-move-cache-directory",
3538+
"version": "17.0.0-beta.1",
3539+
"originalFilePath": "/packages/nx",
3540+
"path": "nx/migrations/17.0.0-move-cache-directory",
3541+
"type": "migration"
34823542
}
34833543
],
34843544
"githubRoot": "https://github.com/nrwl/nx/blob/master",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "17.0.0-move-cache-directory",
3+
"cli": "nx",
4+
"version": "17.0.0-beta.1",
5+
"description": "Updates the default cache directory to .nx/cache",
6+
"implementation": "/packages/nx/src/migrations/update-17-0-0/move-cache-directory.ts",
7+
"aliases": [],
8+
"hidden": false,
9+
"path": "/packages/nx",
10+
"schema": null,
11+
"type": "migration",
12+
"examplesFile": "#### Sample Code Changes\n\nAdd `.nx/cache` to the `.gitignore` file.\n\n{% tabs %}\n{% tab label=\"Before\" %}\n\n```{% fileName=\".gitignore\" %}\nnode_modules\n```\n\n{% /tab %}\n{% tab label=\"After\" %}\n\n```{% highlightLines=[2] fileName=\".gitignore\" %}\nnode_modules\n.nx/cache\n```\n\n{% /tab %}\n{% /tabs %}\n\nAdd `.nx/cache` to the `.prettierignore` file.\n\n{% tabs %}\n{% tab label=\"Before\" %}\n\n```ts {% fileName=\".prettierignore\" %}\n/dist\n```\n\n{% /tab %}\n{% tab label=\"After\" %}\n\n```ts {% highlightLines=[2] fileName=\".prettierignore\" %}\n/dist\n.nx/cache\n```\n\n{% /tab %}\n{% /tabs %}\n"
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "17.0.0-use-minimal-config-for-tasks-runner-options",
3+
"cli": "nx",
4+
"version": "17.0.0-beta.3",
5+
"description": "Use minimal config for tasksRunnerOptions",
6+
"implementation": "/packages/nx/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.ts",
7+
"aliases": [],
8+
"hidden": false,
9+
"path": "/packages/nx",
10+
"schema": null,
11+
"type": "migration",
12+
"examplesFile": ""
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "17.3.0-update-nx-wrapper",
3+
"cli": "nx",
4+
"version": "17.3.0-beta.6",
5+
"description": "Updates the nx wrapper.",
6+
"implementation": "/packages/nx/src/migrations/update-17-3-0/update-nxw.ts",
7+
"aliases": [],
8+
"hidden": false,
9+
"path": "/packages/nx",
10+
"schema": null,
11+
"type": "migration",
12+
"examplesFile": ""
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "18.0.0-disable-adding-plugins-for-existing-workspaces",
3+
"cli": "nx",
4+
"version": "18.0.0-beta.2",
5+
"description": "Updates nx.json to disabled adding plugins when generating projects in an existing Nx workspace",
6+
"implementation": "/packages/nx/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.ts",
7+
"x-repair-skip": true,
8+
"aliases": [],
9+
"hidden": false,
10+
"path": "/packages/nx",
11+
"schema": null,
12+
"type": "migration",
13+
"examplesFile": ""
14+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "move-default-base-to-nx-json-root",
3+
"version": "18.1.0-beta.3",
4+
"description": "Moves affected.defaultBase to defaultBase in `nx.json`",
5+
"implementation": "/packages/nx/src/migrations/update-17-2-0/move-default-base.ts",
6+
"aliases": [],
7+
"hidden": false,
8+
"path": "/packages/nx",
9+
"schema": null,
10+
"type": "migration",
11+
"examplesFile": ""
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "rm-default-collection-npm-scope",
3+
"version": "17.0.0-rc.1",
4+
"description": "Migration for v17.0.0-rc.1",
5+
"implementation": "/packages/nx/src/migrations/update-17-0-0/rm-default-collection-npm-scope.ts",
6+
"aliases": [],
7+
"hidden": false,
8+
"path": "/packages/nx",
9+
"schema": null,
10+
"type": "migration",
11+
"examplesFile": ""
12+
}

packages/nx/migrations.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,40 @@
11
{
22
"generators": {
3+
"17.0.0-move-cache-directory": {
4+
"cli": "nx",
5+
"version": "17.0.0-beta.1",
6+
"description": "Updates the default cache directory to .nx/cache",
7+
"implementation": "./src/migrations/update-17-0-0/move-cache-directory"
8+
},
9+
"17.0.0-use-minimal-config-for-tasks-runner-options": {
10+
"cli": "nx",
11+
"version": "17.0.0-beta.3",
12+
"description": "Use minimal config for tasksRunnerOptions",
13+
"implementation": "./src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options"
14+
},
15+
"rm-default-collection-npm-scope": {
16+
"version": "17.0.0-rc.1",
17+
"description": "Migration for v17.0.0-rc.1",
18+
"implementation": "./src/migrations/update-17-0-0/rm-default-collection-npm-scope"
19+
},
20+
"17.3.0-update-nx-wrapper": {
21+
"cli": "nx",
22+
"version": "17.3.0-beta.6",
23+
"description": "Updates the nx wrapper.",
24+
"implementation": "./src/migrations/update-17-3-0/update-nxw"
25+
},
26+
"18.0.0-disable-adding-plugins-for-existing-workspaces": {
27+
"cli": "nx",
28+
"version": "18.0.0-beta.2",
29+
"description": "Updates nx.json to disabled adding plugins when generating projects in an existing Nx workspace",
30+
"implementation": "./src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces",
31+
"x-repair-skip": true
32+
},
33+
"move-default-base-to-nx-json-root": {
34+
"version": "18.1.0-beta.3",
35+
"description": "Moves affected.defaultBase to defaultBase in `nx.json`",
36+
"implementation": "./src/migrations/update-17-2-0/move-default-base"
37+
},
338
"19-2-0-move-graph-cache-directory": {
439
"cli": "nx",
540
"version": "19.2.0-beta.2",
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#### Sample Code Changes
2+
3+
Add `.nx/cache` to the `.gitignore` file.
4+
5+
{% tabs %}
6+
{% tab label="Before" %}
7+
8+
```{% fileName=".gitignore" %}
9+
node_modules
10+
```
11+
12+
{% /tab %}
13+
{% tab label="After" %}
14+
15+
```{% highlightLines=[2] fileName=".gitignore" %}
16+
node_modules
17+
.nx/cache
18+
```
19+
20+
{% /tab %}
21+
{% /tabs %}
22+
23+
Add `.nx/cache` to the `.prettierignore` file.
24+
25+
{% tabs %}
26+
{% tab label="Before" %}
27+
28+
```ts {% fileName=".prettierignore" %}
29+
/dist
30+
```
31+
32+
{% /tab %}
33+
{% tab label="After" %}
34+
35+
```ts {% highlightLines=[2] fileName=".prettierignore" %}
36+
/dist
37+
.nx/cache
38+
```
39+
40+
{% /tab %}
41+
{% /tabs %}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import { createTree } from '../../generators/testing-utils/create-tree';
2+
import { createTreeWithEmptyWorkspace } from '../../generators/testing-utils/create-tree-with-empty-workspace';
3+
import migrate from './move-cache-directory';
4+
5+
describe('move-cache-directory', () => {
6+
it('should add .nx/cache to the gitignore', () => {
7+
const tree = createTreeWithEmptyWorkspace();
8+
tree.write('.gitignore', 'node_modules');
9+
migrate(tree);
10+
expect(tree.read('.gitignore', 'utf-8')).toMatchInlineSnapshot(`
11+
"node_modules
12+
.nx/cache"
13+
`);
14+
});
15+
16+
it('should work if .gitignore is not present', () => {
17+
const tree = createTreeWithEmptyWorkspace();
18+
tree.delete('.gitignore');
19+
migrate(tree);
20+
expect(tree.read('.gitignore', 'utf-8')).toMatchInlineSnapshot(
21+
`".nx/cache"`
22+
);
23+
});
24+
25+
it('should not change gitignore if directly ignored', () => {
26+
const tree = createTreeWithEmptyWorkspace();
27+
tree.write('.gitignore', 'node_modules\n.nx/cache');
28+
migrate(tree);
29+
expect(tree.read('.gitignore', 'utf-8')).toMatchInlineSnapshot(`
30+
"node_modules
31+
.nx/cache"
32+
`);
33+
});
34+
35+
it('should not change gitignore if ignored by another pattern', () => {
36+
const tree = createTreeWithEmptyWorkspace();
37+
tree.write('.gitignore', 'node_modules\n.*/cache');
38+
migrate(tree);
39+
expect(tree.read('.gitignore', 'utf-8')).toMatchInlineSnapshot(`
40+
"node_modules
41+
.*/cache"
42+
`);
43+
});
44+
45+
it('should not update gitignore for lerna repos without nx.json', () => {
46+
const tree = createTree();
47+
tree.write('.gitignore', 'node_modules');
48+
tree.write('lerna.json', '{}');
49+
migrate(tree);
50+
expect(tree.read('.gitignore', 'utf-8')).toMatchInlineSnapshot(
51+
`"node_modules"`
52+
);
53+
});
54+
55+
it('should handle prettierignore', () => {
56+
const tree = createTree();
57+
tree.write('.prettierignore', '/dist');
58+
migrate(tree);
59+
expect(tree.read('.prettierignore', 'utf-8')).toMatchInlineSnapshot(`
60+
"/dist
61+
/.nx/cache"
62+
`);
63+
});
64+
65+
it('should handle missing prettierignore', () => {
66+
const tree = createTree();
67+
tree.delete('.prettierignore');
68+
migrate(tree);
69+
expect(tree.exists('.prettierignore')).toBeFalsy();
70+
});
71+
});

0 commit comments

Comments
 (0)