-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): add migrations to remove root
- Loading branch information
1 parent
b1594dc
commit f2c5396
Showing
13 changed files
with
386 additions
and
76 deletions.
There are no files selected for viewing
230 changes: 230 additions & 0 deletions
230
packages/angular/src/generators/ng-add/__snapshots__/migrate-from-angular-cli.spec.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,230 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`workspace --preserve-angular-cli-layout should create nx.json 1`] = ` | ||
Object { | ||
"affected": Object { | ||
"defaultBase": "main", | ||
}, | ||
"implicitDependencies": Object { | ||
".eslintrc.json": "*", | ||
"package.json": Object { | ||
"dependencies": "*", | ||
"devDependencies": "*", | ||
}, | ||
}, | ||
"npmScope": "my-scope", | ||
"targetDependencies": Object { | ||
"build": Array [ | ||
Object { | ||
"projects": "dependencies", | ||
"target": "build", | ||
}, | ||
], | ||
}, | ||
"tasksRunnerOptions": Object { | ||
"default": Object { | ||
"options": Object { | ||
"cacheableOperations": Array [ | ||
"build", | ||
"lint", | ||
"test", | ||
"e2e", | ||
], | ||
}, | ||
"runner": "nx/tasks-runners/default", | ||
}, | ||
}, | ||
"workspaceLayout": Object { | ||
"appsDir": "", | ||
"libsDir": "", | ||
}, | ||
} | ||
`; | ||
|
||
exports[`workspace --preserve-angular-cli-layout should support multiple projects 1`] = ` | ||
Object { | ||
"affected": Object { | ||
"defaultBase": "main", | ||
}, | ||
"implicitDependencies": Object { | ||
".eslintrc.json": "*", | ||
"package.json": Object { | ||
"dependencies": "*", | ||
"devDependencies": "*", | ||
}, | ||
}, | ||
"npmScope": "my-scope", | ||
"targetDependencies": Object { | ||
"build": Array [ | ||
Object { | ||
"projects": "dependencies", | ||
"target": "build", | ||
}, | ||
], | ||
}, | ||
"tasksRunnerOptions": Object { | ||
"default": Object { | ||
"options": Object { | ||
"cacheableOperations": Array [ | ||
"build", | ||
"lint", | ||
"test", | ||
"e2e", | ||
], | ||
}, | ||
"runner": "nx/tasks-runners/default", | ||
}, | ||
}, | ||
"workspaceLayout": Object { | ||
"appsDir": "projects", | ||
"libsDir": "projects", | ||
}, | ||
} | ||
`; | ||
|
||
exports[`workspace move to nx layout should create a root eslint config 1`] = ` | ||
Object { | ||
"ignorePatterns": Array [ | ||
"**/*", | ||
], | ||
"overrides": Array [ | ||
Object { | ||
"extends": Array [ | ||
"plugin:@angular-eslint/recommended", | ||
"plugin:@angular-eslint/template/process-inline-templates", | ||
], | ||
"files": Array [ | ||
"*.ts", | ||
], | ||
"parserOptions": Object { | ||
"createDefaultProgram": true, | ||
}, | ||
"rules": Object { | ||
"@angular-eslint/component-selector": Array [ | ||
"error", | ||
Object { | ||
"prefix": "app", | ||
"style": "kebab-case", | ||
"type": "element", | ||
}, | ||
], | ||
"@angular-eslint/directive-selector": Array [ | ||
"error", | ||
Object { | ||
"prefix": "app", | ||
"style": "camelCase", | ||
"type": "attribute", | ||
}, | ||
], | ||
}, | ||
}, | ||
Object { | ||
"extends": Array [ | ||
"plugin:@angular-eslint/template/recommended", | ||
], | ||
"files": Array [ | ||
"*.html", | ||
], | ||
"rules": Object {}, | ||
}, | ||
Object { | ||
"files": Array [ | ||
"*.ts", | ||
"*.tsx", | ||
"*.js", | ||
"*.jsx", | ||
], | ||
"rules": Object { | ||
"@nrwl/nx/enforce-module-boundaries": Array [ | ||
"error", | ||
Object { | ||
"allow": Array [], | ||
"depConstraints": Array [ | ||
Object { | ||
"onlyDependOnLibsWithTags": Array [ | ||
"*", | ||
], | ||
"sourceTag": "*", | ||
}, | ||
], | ||
"enforceBuildableLibDependency": true, | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
"plugins": Array [ | ||
"@nrwl/nx", | ||
], | ||
"root": true, | ||
} | ||
`; | ||
|
||
exports[`workspace move to nx layout should create nx.json 1`] = ` | ||
Object { | ||
"affected": Object { | ||
"defaultBase": "main", | ||
}, | ||
"cli": Object { | ||
"defaultCollection": "@nrwl/angular", | ||
}, | ||
"defaultProject": "myApp", | ||
"implicitDependencies": Object { | ||
".eslintrc.json": "*", | ||
"package.json": Object { | ||
"dependencies": "*", | ||
"devDependencies": "*", | ||
}, | ||
}, | ||
"npmScope": "my-org", | ||
"targetDependencies": Object { | ||
"build": Array [ | ||
Object { | ||
"projects": "dependencies", | ||
"target": "build", | ||
}, | ||
], | ||
}, | ||
"tasksRunnerOptions": Object { | ||
"default": Object { | ||
"options": Object { | ||
"cacheableOperations": Array [ | ||
"build", | ||
"lint", | ||
"test", | ||
"e2e", | ||
], | ||
}, | ||
"runner": "nx/tasks-runners/default", | ||
}, | ||
}, | ||
} | ||
`; | ||
|
||
exports[`workspace move to nx layout should update tsconfig.base.json if present 1`] = ` | ||
Object { | ||
"compilerOptions": Object { | ||
"baseUrl": ".", | ||
"paths": Object {}, | ||
"rootDir": ".", | ||
}, | ||
"exclude": Array [ | ||
"node_modules", | ||
"tmp", | ||
], | ||
} | ||
`; | ||
|
||
exports[`workspace move to nx layout should work if angular-cli workspace had tsconfig.base.json 1`] = ` | ||
Object { | ||
"compilerOptions": Object { | ||
"baseUrl": ".", | ||
"paths": Object {}, | ||
"rootDir": ".", | ||
}, | ||
"exclude": Array [ | ||
"node_modules", | ||
"tmp", | ||
], | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
{ | ||
"migrations": {} | ||
"generators": { | ||
"14-0-4-remove-root": { | ||
"cli": "nx", | ||
"version": "14.0.4", | ||
"description": "Remove root property from project.json files", | ||
"factory": "./src/migrations/update-14-0-4/remove-roots" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import path = require('path'); | ||
import json = require('./migrations.json'); | ||
|
||
describe('Node migrations', () => { | ||
it('should have valid paths', () => { | ||
Object.values(json.generators).forEach((m) => { | ||
expect(() => | ||
require.resolve(path.join(__dirname, `${m.factory}.ts`)) | ||
).not.toThrow(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
packages/nx/src/migrations/update-14-0-4/remove-roots.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Tree } from '../../generators/tree'; | ||
import { createTreeWithEmptyWorkspace } from '../../generators/testing-utils/create-tree-with-empty-workspace'; | ||
import { addProjectConfiguration } from '../../generators/utils/project-configuration'; | ||
import { readJson, updateJson } from '../../generators/utils/json'; | ||
import removeRoots from './remove-roots'; | ||
|
||
describe('remove-roots >', () => { | ||
let tree: Tree; | ||
|
||
describe('projects with project.json configs', () => { | ||
beforeEach(() => { | ||
tree = createTreeWithEmptyWorkspace(2); | ||
}); | ||
|
||
it('should remove the root property', async () => { | ||
addProjectConfiguration(tree, 'proj1', { | ||
root: 'proj1', | ||
}); | ||
|
||
updateJson(tree, 'proj1/project.json', (config) => ({ | ||
...config, | ||
root: 'proj1', | ||
})); | ||
|
||
await removeRoots(tree); | ||
|
||
expect(readJson(tree, 'proj1/project.json').root).toBeUndefined(); | ||
}); | ||
}); | ||
|
||
describe('projects with project.json configs', () => { | ||
beforeEach(() => { | ||
tree = createTreeWithEmptyWorkspace(1); | ||
}); | ||
|
||
it('should remove the root property', async () => { | ||
addProjectConfiguration(tree, 'proj1', { | ||
root: 'proj1', | ||
}); | ||
|
||
await removeRoots(tree); | ||
|
||
expect(readJson(tree, 'workspace.json').projects.proj1.root).toEqual( | ||
'proj1' | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Tree } from '../../generators/tree'; | ||
import { | ||
getProjects, | ||
updateProjectConfiguration, | ||
} from '../../generators/utils/project-configuration'; | ||
import { formatChangedFilesWithPrettierIfAvailable } from '../../generators/internal-utils/format-changed-files-with-prettier-if-available'; | ||
|
||
export default async function (tree: Tree) { | ||
// This looks like it does nothing, but this will actually effectively migrate over all the configs that need to be moved over, but won't touch configs that don't need to be moved | ||
for (const [projName, projConfig] of getProjects(tree)) { | ||
updateProjectConfiguration(tree, projName, projConfig); | ||
} | ||
|
||
await formatChangedFilesWithPrettierIfAvailable(tree); | ||
} |
Oops, something went wrong.