@nrwl/angular 13.9.3 → 13.10.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/src/runtime/nx/data-persistence.mjs +3 -3
- package/esm2020/src/runtime/nx/nx.module.mjs +4 -4
- package/executors.js +3 -3
- package/executors.js.map +1 -1
- package/fesm2015/nrwl-angular.mjs +7 -7
- package/fesm2020/nrwl-angular.mjs +7 -7
- package/generators.js +26 -26
- package/generators.js.map +1 -1
- package/generators.json +22 -2
- package/migrations.json +89 -0
- package/package.json +9 -8
- package/src/builders/webpack-browser/webpack-browser.impl.js +9 -9
- package/src/builders/webpack-browser/webpack-browser.impl.js.map +1 -1
- package/src/builders/webpack-server/lib/index.js +1 -1
- package/src/builders/webpack-server/lib/index.js.map +1 -1
- package/src/builders/webpack-server/webpack-server.impl.js +8 -8
- package/src/builders/webpack-server/webpack-server.impl.js.map +1 -1
- package/src/executors/delegate-build/delegate-build.impl.js +4 -4
- package/src/executors/delegate-build/delegate-build.impl.js.map +1 -1
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/compile-ngc.transform.js +1 -1
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/entry-point.transform.js +2 -2
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/write-package.transform.js +2 -2
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ngc/compile-source-files.js +1 -1
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/styles/stylesheet-processor.js +3 -3
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ts/cache-compiler-host.js +2 -2
- package/src/executors/ng-packagr-lite/ng-packagr-lite.impl.js +1 -1
- package/src/executors/package/ng-packagr-adjustments/ng-package/entry-point/compile-ngc.transform.js +1 -1
- package/src/executors/package/ng-packagr-adjustments/ngc/compile-source-files.js +1 -1
- package/src/executors/package/ng-packagr-adjustments/styles/stylesheet-processor.js +3 -3
- package/src/executors/package/ng-packagr-adjustments/ts/cache-compiler-host.js +2 -2
- package/src/executors/package/package.impl.js +5 -5
- package/src/executors/package/package.impl.js.map +1 -1
- package/src/generators/add-linting/add-linting.js +1 -1
- package/src/generators/application/application.js +1 -1
- package/src/generators/application/lib/add-e2e.js +1 -1
- package/src/generators/application/lib/add-linting.js +1 -1
- package/src/generators/application/lib/add-mfe.js +1 -1
- package/src/generators/application/lib/add-protractor.js +1 -1
- package/src/generators/application/lib/add-unit-test-runner.js +1 -1
- package/src/generators/application/lib/index.js +20 -20
- package/src/generators/application/lib/index.js.map +1 -1
- package/src/generators/application/lib/update-config-files.js +1 -1
- package/src/generators/application/lib/update-config-files.js.map +1 -1
- package/src/generators/component/component.compat.d.ts +2 -0
- package/src/generators/component/component.compat.js +6 -0
- package/src/generators/component/component.compat.js.map +1 -0
- package/src/generators/component/component.d.ts +4 -0
- package/src/generators/component/component.js +78 -0
- package/src/generators/component/component.js.map +1 -0
- package/src/generators/component/schema.d.ts +17 -0
- package/src/generators/component/schema.json +101 -0
- package/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint.js +4 -4
- package/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint.js.map +1 -1
- package/src/generators/downgrade-module/downgrade-module.js +1 -1
- package/src/generators/downgrade-module/lib/index.js +4 -4
- package/src/generators/downgrade-module/lib/index.js.map +1 -1
- package/src/generators/init/init.d.ts +1 -1
- package/src/generators/init/init.js +16 -2
- package/src/generators/init/init.js.map +1 -1
- package/src/generators/init/schema.d.ts +2 -2
- package/src/generators/init/schema.json +5 -0
- package/src/generators/karma-project/karma-project.js +1 -1
- package/src/generators/library/lib/update-project.js +2 -2
- package/src/generators/library/lib/update-project.js.map +1 -1
- package/src/generators/library/library.js +3 -3
- package/src/generators/library-secondary-entry-point/lib/index.js +4 -4
- package/src/generators/library-secondary-entry-point/lib/index.js.map +1 -1
- package/src/generators/library-secondary-entry-point/library-secondary-entry-point.js +1 -1
- package/src/generators/mfe-host/mfe-host.js +1 -1
- package/src/generators/mfe-remote/mfe-remote.js +1 -1
- package/src/generators/move/move.js +1 -1
- package/src/generators/ng-add/compat.d.ts +2 -0
- package/src/generators/ng-add/compat.js +6 -0
- package/src/generators/ng-add/compat.js.map +1 -0
- package/src/generators/ng-add/files/decorate-angular-cli/decorate-angular-cli.js__tmpl__ +69 -0
- package/src/generators/ng-add/files/prettier/__dot__prettierignore +1 -0
- package/src/generators/ng-add/files/root/karma.conf.js__tmpl__ +43 -0
- package/src/generators/ng-add/files/root/libs/__dot__gitkeep +0 -0
- package/src/generators/ng-add/files/root/nx.json__tmpl__ +29 -0
- package/src/generators/ng-add/files/root/tools/schematics/__dot__gitkeep +0 -0
- package/src/generators/ng-add/files/root/tools/tsconfig.tools.json__tmpl__ +12 -0
- package/src/generators/ng-add/migrate-from-angular-cli.d.ts +3 -0
- package/src/generators/ng-add/migrate-from-angular-cli.js +633 -0
- package/src/generators/ng-add/migrate-from-angular-cli.js.map +1 -0
- package/src/generators/ng-add/ng-add.d.ts +4 -0
- package/src/generators/ng-add/ng-add.js +20 -0
- package/src/generators/ng-add/ng-add.js.map +1 -0
- package/src/generators/ng-add/schema.d.ts +19 -0
- package/src/generators/ng-add/schema.json +71 -0
- package/src/generators/ngrx/ngrx.js +1 -1
- package/src/generators/scam/lib/create-module.js +1 -1
- package/src/generators/scam/lib/create-module.js.map +1 -1
- package/src/generators/scam/scam.js +4 -4
- package/src/generators/scam/scam.js.map +1 -1
- package/src/generators/scam-directive/lib/create-module.js +1 -1
- package/src/generators/scam-directive/lib/create-module.js.map +1 -1
- package/src/generators/scam-directive/scam-directive.js +4 -4
- package/src/generators/scam-directive/scam-directive.js.map +1 -1
- package/src/generators/scam-pipe/lib/create-module.js +1 -1
- package/src/generators/scam-pipe/lib/create-module.js.map +1 -1
- package/src/generators/scam-pipe/scam-pipe.js +4 -4
- package/src/generators/scam-pipe/scam-pipe.js.map +1 -1
- package/src/generators/setup-mfe/lib/index.js +10 -10
- package/src/generators/setup-mfe/lib/index.js.map +1 -1
- package/src/generators/setup-mfe/setup-mfe.js +1 -1
- package/src/generators/setup-tailwind/lib/index.js +6 -6
- package/src/generators/setup-tailwind/lib/index.js.map +1 -1
- package/src/generators/setup-tailwind/setup-tailwind.js +1 -1
- package/src/generators/storybook-configuration/lib/generate-storybook-configuration.js +1 -1
- package/src/generators/storybook-configuration/storybook-configuration.js +1 -1
- package/src/generators/storybook-migrate-stories-to-6-2/migrate-stories-to-6-2.js +1 -1
- package/src/generators/upgrade-module/lib/index.js +4 -4
- package/src/generators/upgrade-module/lib/index.js.map +1 -1
- package/src/generators/upgrade-module/upgrade-module.js +1 -1
- package/src/generators/utils/index.js +1 -1
- package/src/generators/utils/index.js.map +1 -1
- package/src/generators/utils/path.d.ts +1 -0
- package/src/generators/utils/path.js +11 -0
- package/src/generators/utils/path.js.map +1 -0
- package/src/generators/utils/testing.js +1 -1
- package/src/generators/web-worker/lib/index.js +2 -2
- package/src/generators/web-worker/lib/index.js.map +1 -1
- package/src/generators/web-worker/web-worker.js +2 -2
- package/src/generators/web-worker/web-worker.js.map +1 -1
- package/src/migrations/update-10-3-0/update-10-3-0.js +1 -1
- package/src/migrations/update-10-4-0/update-10-4-0.js +1 -1
- package/src/migrations/update-10-5-0/add-template-support-and-presets-to-eslint.js +1 -1
- package/src/migrations/update-12-3-0/convert-webpack-browser-build-target-to-delegate-build.js +3 -3
- package/src/migrations/update-12-3-0/convert-webpack-browser-build-target-to-delegate-build.js.map +1 -1
- package/src/migrations/update-12-3-0/update-angular-eslint-rules.js +1 -1
- package/src/migrations/update-12-3-0/update-storybook.js +1 -1
- package/src/migrations/update-12-3-0/update-webpack-browser-config.js +1 -1
- package/src/migrations/update-12-9-0/update-invalid-import-paths.js +1 -1
- package/src/migrations/update-13-0-0/add-postcss-packages.js +1 -1
- package/src/migrations/update-13-2-0/opt-out-testbed-teardown.js +1 -1
- package/src/migrations/update-13-2-0/update-angular-config.js +1 -1
- package/src/migrations/update-13-2-0/update-angular-jest-config.js +1 -1
- package/src/migrations/update-13-2-0/update-libraries.js +1 -1
- package/src/migrations/update-13-2-0/update-testing-imports.js +1 -1
- package/src/migrations/update-13-3-0/update-mfe-webpack-config.js +1 -1
- package/src/migrations/update-13-5-0/remove-library-generator-style-default.js +1 -1
- package/src/migrations/update-13-5-0/update-mfe-configs.js +1 -1
- package/src/migrations/update-13-8-1/add-cypress-mfe-workaround.js +1 -1
- package/src/migrations/update-13-8-4/migrate-karma-conf.js +1 -1
- package/src/migrations/update-13-9-0/set-build-libs-from-source.js +1 -1
- package/src/runtime/nx/data-persistence.js +2 -2
- package/src/runtime/nx/data-persistence.js.map +1 -1
- package/src/runtime/nx/nx.module.js +1 -1
- package/src/utils/mfe/mfe-webpack.d.ts +17 -0
- package/src/utils/{mfe-webpack.js → mfe/mfe-webpack.js} +6 -5
- package/src/utils/mfe/mfe-webpack.js.map +1 -0
- package/src/utils/mfe/with-module-federation.d.ts +9 -0
- package/src/utils/mfe/with-module-federation.js +156 -0
- package/src/utils/mfe/with-module-federation.js.map +1 -0
- package/src/utils/versions.d.ts +3 -3
- package/src/utils/versions.js +4 -4
- package/src/utils/mfe-webpack.d.ts +0 -7
- package/src/utils/mfe-webpack.js.map +0 -1
|
@@ -0,0 +1,633 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.migrateFromAngularCli = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nrwl/devkit");
|
|
6
|
+
const workspace_1 = require("@nrwl/workspace/src/generators/workspace/workspace");
|
|
7
|
+
const default_base_1 = require("@nrwl/workspace/src/utilities/default-base");
|
|
8
|
+
const prettier_1 = require("@nrwl/workspace/src/utilities/prettier");
|
|
9
|
+
const typescript_1 = require("@nrwl/workspace/src/utilities/typescript");
|
|
10
|
+
const versions_1 = require("@nrwl/workspace/src/utils/versions");
|
|
11
|
+
const path_1 = require("path");
|
|
12
|
+
const versions_2 = require("../../utils/versions");
|
|
13
|
+
function updatePackageJson(tree) {
|
|
14
|
+
(0, devkit_1.updateJson)(tree, 'package.json', (packageJson) => {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
packageJson.scripts = packageJson.scripts || {};
|
|
17
|
+
packageJson.scripts = Object.assign(Object.assign({}, packageJson.scripts), { nx: 'nx', 'affected:apps': 'nx affected:apps', 'affected:libs': 'nx affected:libs', 'affected:build': 'nx affected:build', 'affected:e2e': 'nx affected:e2e', 'affected:test': 'nx affected:test', 'affected:lint': 'nx affected:lint', 'affected:graph': 'nx affected:graph', affected: 'nx affected', format: 'nx format:write', 'format:write': 'nx format:write', 'format:check': 'nx format:check', update: 'ng update @nrwl/workspace', 'update:check': 'ng update', lint: 'nx workspace-lint && ng lint', graph: 'nx graph', 'workspace-schematic': 'nx workspace-schematic', help: 'nx help' });
|
|
18
|
+
packageJson.devDependencies = (_a = packageJson.devDependencies) !== null && _a !== void 0 ? _a : {};
|
|
19
|
+
packageJson.dependencies = (_b = packageJson.dependencies) !== null && _b !== void 0 ? _b : {};
|
|
20
|
+
if (!packageJson.dependencies['@nrwl/angular']) {
|
|
21
|
+
packageJson.dependencies['@nrwl/angular'] = versions_2.nxVersion;
|
|
22
|
+
}
|
|
23
|
+
if (!packageJson.devDependencies['@angular/cli']) {
|
|
24
|
+
packageJson.devDependencies['@angular/cli'] = versions_2.angularDevkitVersion;
|
|
25
|
+
}
|
|
26
|
+
if (!packageJson.devDependencies['@nrwl/workspace']) {
|
|
27
|
+
packageJson.devDependencies['@nrwl/workspace'] = versions_2.nxVersion;
|
|
28
|
+
}
|
|
29
|
+
if (!packageJson.devDependencies['nx']) {
|
|
30
|
+
packageJson.devDependencies['nx'] = versions_2.nxVersion;
|
|
31
|
+
}
|
|
32
|
+
if (!packageJson.devDependencies['prettier']) {
|
|
33
|
+
packageJson.devDependencies['prettier'] = versions_1.prettierVersion;
|
|
34
|
+
}
|
|
35
|
+
return packageJson;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function convertPath(name, originalPath) {
|
|
39
|
+
return `apps/${name}/${originalPath}`;
|
|
40
|
+
}
|
|
41
|
+
function updateAngularCLIJson(host, options) {
|
|
42
|
+
var _a;
|
|
43
|
+
const workspaceConfig = (0, devkit_1.readWorkspaceConfiguration)(host);
|
|
44
|
+
const appName = workspaceConfig.defaultProject;
|
|
45
|
+
const e2eName = `${appName}-e2e`;
|
|
46
|
+
const e2eRoot = (0, devkit_1.joinPathFragments)('apps', e2eName);
|
|
47
|
+
delete workspaceConfig.newProjectRoot;
|
|
48
|
+
const defaultProject = (0, devkit_1.readProjectConfiguration)(host, appName);
|
|
49
|
+
const oldSourceRoot = defaultProject.sourceRoot;
|
|
50
|
+
const newRoot = (0, devkit_1.joinPathFragments)('apps', appName);
|
|
51
|
+
defaultProject.root = newRoot;
|
|
52
|
+
defaultProject.sourceRoot = (0, devkit_1.joinPathFragments)(newRoot, 'src');
|
|
53
|
+
function convertBuildOptions(buildOptions) {
|
|
54
|
+
buildOptions.outputPath =
|
|
55
|
+
buildOptions.outputPath &&
|
|
56
|
+
(0, devkit_1.joinPathFragments)((0, devkit_1.normalizePath)('dist'), 'apps', appName);
|
|
57
|
+
buildOptions.index =
|
|
58
|
+
buildOptions.index && convertAsset(buildOptions.index);
|
|
59
|
+
buildOptions.main =
|
|
60
|
+
buildOptions.main && convertAsset(buildOptions.main);
|
|
61
|
+
buildOptions.polyfills =
|
|
62
|
+
buildOptions.polyfills && convertAsset(buildOptions.polyfills);
|
|
63
|
+
buildOptions.tsConfig =
|
|
64
|
+
buildOptions.tsConfig && (0, devkit_1.joinPathFragments)(newRoot, 'tsconfig.app.json');
|
|
65
|
+
buildOptions.assets =
|
|
66
|
+
buildOptions.assets && buildOptions.assets.map(convertAsset);
|
|
67
|
+
buildOptions.styles =
|
|
68
|
+
buildOptions.styles && buildOptions.styles.map(convertAsset);
|
|
69
|
+
buildOptions.scripts =
|
|
70
|
+
buildOptions.scripts && buildOptions.scripts.map(convertAsset);
|
|
71
|
+
buildOptions.fileReplacements =
|
|
72
|
+
buildOptions.fileReplacements &&
|
|
73
|
+
buildOptions.fileReplacements.map((replacement) => ({
|
|
74
|
+
replace: convertAsset(replacement.replace),
|
|
75
|
+
with: convertAsset(replacement.with),
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
convertBuildOptions(defaultProject.targets.build.options);
|
|
79
|
+
Object.values(defaultProject.targets.build.configurations).forEach((config) => convertBuildOptions(config));
|
|
80
|
+
if (defaultProject.targets.test) {
|
|
81
|
+
const testOptions = defaultProject.targets.test.options;
|
|
82
|
+
testOptions.main = testOptions.main && convertAsset(testOptions.main);
|
|
83
|
+
testOptions.polyfills =
|
|
84
|
+
testOptions.polyfills && convertAsset(testOptions.polyfills);
|
|
85
|
+
testOptions.tsConfig = (0, devkit_1.joinPathFragments)(newRoot, 'tsconfig.spec.json');
|
|
86
|
+
testOptions.karmaConfig = (0, devkit_1.joinPathFragments)(newRoot, 'karma.conf.js');
|
|
87
|
+
testOptions.assets =
|
|
88
|
+
testOptions.assets && testOptions.assets.map(convertAsset);
|
|
89
|
+
testOptions.styles =
|
|
90
|
+
testOptions.styles && testOptions.styles.map(convertAsset);
|
|
91
|
+
testOptions.scripts =
|
|
92
|
+
testOptions.scripts && testOptions.scripts.map(convertAsset);
|
|
93
|
+
}
|
|
94
|
+
const lintTarget = defaultProject.targets.lint;
|
|
95
|
+
if (lintTarget) {
|
|
96
|
+
lintTarget.options.tsConfig = [
|
|
97
|
+
(0, devkit_1.joinPathFragments)(newRoot, 'tsconfig.app.json'),
|
|
98
|
+
(0, devkit_1.joinPathFragments)(newRoot, 'tsconfig.spec.json'),
|
|
99
|
+
];
|
|
100
|
+
}
|
|
101
|
+
function convertServerOptions(serverOptions) {
|
|
102
|
+
serverOptions.outputPath =
|
|
103
|
+
serverOptions.outputPath &&
|
|
104
|
+
(0, devkit_1.joinPathFragments)((0, devkit_1.normalizePath)('dist'), 'apps', `${options.name}-server`);
|
|
105
|
+
serverOptions.main = serverOptions.main && convertAsset(serverOptions.main);
|
|
106
|
+
serverOptions.tsConfig =
|
|
107
|
+
serverOptions.tsConfig &&
|
|
108
|
+
(0, devkit_1.joinPathFragments)((0, devkit_1.normalizePath)('apps'), appName, 'tsconfig.server.json');
|
|
109
|
+
serverOptions.fileReplacements =
|
|
110
|
+
serverOptions.fileReplacements &&
|
|
111
|
+
serverOptions.fileReplacements.map((replacement) => ({
|
|
112
|
+
replace: convertAsset(replacement.replace),
|
|
113
|
+
with: convertAsset(replacement.with),
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
if (defaultProject.targets.server) {
|
|
117
|
+
const serverOptions = defaultProject.targets.server.options;
|
|
118
|
+
convertServerOptions(serverOptions);
|
|
119
|
+
Object.values(defaultProject.targets.server.configurations).forEach((config) => convertServerOptions(config));
|
|
120
|
+
}
|
|
121
|
+
if (defaultProject.targets.e2e) {
|
|
122
|
+
const lintTargetOptions = lintTarget ? lintTarget.options : {};
|
|
123
|
+
if (isProtractorE2eProject(defaultProject)) {
|
|
124
|
+
(0, devkit_1.addProjectConfiguration)(host, e2eName, {
|
|
125
|
+
root: e2eRoot,
|
|
126
|
+
projectType: 'application',
|
|
127
|
+
targets: {
|
|
128
|
+
e2e: Object.assign(Object.assign({}, defaultProject.targets.e2e), { options: Object.assign(Object.assign({}, defaultProject.targets.e2e.options), { protractorConfig: (0, devkit_1.joinPathFragments)(e2eRoot, 'protractor.conf.js') }) }),
|
|
129
|
+
lint: {
|
|
130
|
+
executor: '@angular-devkit/build-angular:tslint',
|
|
131
|
+
options: Object.assign(Object.assign({}, lintTargetOptions), { tsConfig: (0, devkit_1.joinPathFragments)(e2eRoot, 'tsconfig.json') }),
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
implicitDependencies: [appName],
|
|
135
|
+
tags: [],
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
else if (isCypressE2eProject(defaultProject)) {
|
|
139
|
+
const cypressConfig = (0, devkit_1.joinPathFragments)(e2eRoot, (0, path_1.basename)((_a = getCypressConfigFile(defaultProject)) !== null && _a !== void 0 ? _a : 'cypress.json'));
|
|
140
|
+
const e2eProjectConfig = {
|
|
141
|
+
root: e2eRoot,
|
|
142
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(e2eRoot, 'src'),
|
|
143
|
+
projectType: 'application',
|
|
144
|
+
targets: {
|
|
145
|
+
e2e: updateE2eCypressTarget(defaultProject.targets.e2e, cypressConfig),
|
|
146
|
+
},
|
|
147
|
+
implicitDependencies: [appName],
|
|
148
|
+
tags: [],
|
|
149
|
+
};
|
|
150
|
+
if (defaultProject.targets['cypress-run']) {
|
|
151
|
+
e2eProjectConfig.targets['cypress-run'] = updateE2eCypressTarget(defaultProject.targets['cypress-run'], cypressConfig);
|
|
152
|
+
}
|
|
153
|
+
if (defaultProject.targets['cypress-open']) {
|
|
154
|
+
e2eProjectConfig.targets['cypress-open'] = updateE2eCypressTarget(defaultProject.targets['cypress-open'], cypressConfig);
|
|
155
|
+
}
|
|
156
|
+
(0, devkit_1.addProjectConfiguration)(host, e2eName, e2eProjectConfig);
|
|
157
|
+
delete defaultProject.targets['cypress-run'];
|
|
158
|
+
delete defaultProject.targets['cypress-open'];
|
|
159
|
+
}
|
|
160
|
+
delete defaultProject.targets.e2e;
|
|
161
|
+
}
|
|
162
|
+
(0, devkit_1.updateProjectConfiguration)(host, appName, defaultProject);
|
|
163
|
+
workspaceConfig.cli = workspaceConfig.cli || {};
|
|
164
|
+
if (!workspaceConfig.cli.defaultCollection) {
|
|
165
|
+
workspaceConfig.cli.defaultCollection = '@nrwl/angular';
|
|
166
|
+
}
|
|
167
|
+
(0, devkit_1.updateWorkspaceConfiguration)(host, workspaceConfig);
|
|
168
|
+
function convertAsset(asset) {
|
|
169
|
+
if (typeof asset === 'string') {
|
|
170
|
+
return asset.startsWith(oldSourceRoot)
|
|
171
|
+
? convertPath(appName, asset.replace(oldSourceRoot, 'src'))
|
|
172
|
+
: asset;
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
return Object.assign(Object.assign({}, asset), { input: asset.input && asset.input.startsWith(oldSourceRoot)
|
|
176
|
+
? convertPath(appName, asset.input.replace(oldSourceRoot, 'src'))
|
|
177
|
+
: asset.input });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function getCypressConfigFile(e2eProject) {
|
|
182
|
+
let cypressConfig = 'cypress.json';
|
|
183
|
+
const configFileOption = e2eProject.targets.e2e.options.configFile;
|
|
184
|
+
if (configFileOption === false) {
|
|
185
|
+
cypressConfig = undefined;
|
|
186
|
+
}
|
|
187
|
+
else if (typeof configFileOption === 'string') {
|
|
188
|
+
cypressConfig = (0, path_1.basename)(configFileOption);
|
|
189
|
+
}
|
|
190
|
+
return cypressConfig;
|
|
191
|
+
}
|
|
192
|
+
function updateE2eCypressTarget(target, cypressConfig) {
|
|
193
|
+
const updatedTarget = Object.assign(Object.assign({}, target), { executor: '@nrwl/cypress:cypress', options: Object.assign(Object.assign({}, target.options), { cypressConfig }) });
|
|
194
|
+
delete updatedTarget.options.configFile;
|
|
195
|
+
delete updatedTarget.options.tsConfig;
|
|
196
|
+
if (updatedTarget.options.headless && updatedTarget.options.watch) {
|
|
197
|
+
updatedTarget.options.headed = false;
|
|
198
|
+
}
|
|
199
|
+
else if (updatedTarget.options.headless === false &&
|
|
200
|
+
!updatedTarget.options.watch) {
|
|
201
|
+
updatedTarget.options.headed = true;
|
|
202
|
+
}
|
|
203
|
+
delete updatedTarget.options.headless;
|
|
204
|
+
return updatedTarget;
|
|
205
|
+
}
|
|
206
|
+
function updateTsConfig(host) {
|
|
207
|
+
(0, devkit_1.updateJson)(host, 'nx.json', (json) => {
|
|
208
|
+
json.implicitDependencies['tsconfig.base.json'] = '*';
|
|
209
|
+
return json;
|
|
210
|
+
});
|
|
211
|
+
(0, devkit_1.writeJson)(host, 'tsconfig.base.json', setUpCompilerOptions((0, devkit_1.readJson)(host, (0, typescript_1.getRootTsConfigPathInTree)(host))));
|
|
212
|
+
if (host.exists('tsconfig.json')) {
|
|
213
|
+
host.delete('tsconfig.json');
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
function updateTsConfigsJson(host, options) {
|
|
217
|
+
const app = (0, devkit_1.readProjectConfiguration)(host, options.name);
|
|
218
|
+
const e2eProject = getE2eProject(host);
|
|
219
|
+
const tsConfigPath = (0, typescript_1.getRootTsConfigPathInTree)(host);
|
|
220
|
+
const appOffset = (0, devkit_1.offsetFromRoot)(app.root);
|
|
221
|
+
(0, devkit_1.updateJson)(host, app.targets.build.options.tsConfig, (json) => {
|
|
222
|
+
json.extends = `${appOffset}${tsConfigPath}`;
|
|
223
|
+
json.compilerOptions = json.compilerOptions || {};
|
|
224
|
+
json.compilerOptions.outDir = `${appOffset}dist/out-tsc`;
|
|
225
|
+
return json;
|
|
226
|
+
});
|
|
227
|
+
if (app.targets.test) {
|
|
228
|
+
(0, devkit_1.updateJson)(host, app.targets.test.options.tsConfig, (json) => {
|
|
229
|
+
json.extends = `${appOffset}${tsConfigPath}`;
|
|
230
|
+
json.compilerOptions = json.compilerOptions || {};
|
|
231
|
+
json.compilerOptions.outDir = `${appOffset}dist/out-tsc`;
|
|
232
|
+
return json;
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
if (app.targets.server) {
|
|
236
|
+
(0, devkit_1.updateJson)(host, app.targets.server.options.tsConfig, (json) => {
|
|
237
|
+
json.extends = `${appOffset}${tsConfigPath}`;
|
|
238
|
+
json.compilerOptions = json.compilerOptions || {};
|
|
239
|
+
json.compilerOptions.outDir = `${appOffset}dist/out-tsc`;
|
|
240
|
+
return json;
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
if (!!e2eProject) {
|
|
244
|
+
const tsConfig = isProtractorE2eProject(e2eProject)
|
|
245
|
+
? e2eProject.targets.lint.options.tsConfig
|
|
246
|
+
: (0, devkit_1.joinPathFragments)(e2eProject.root, 'tsconfig.json');
|
|
247
|
+
(0, devkit_1.updateJson)(host, tsConfig, (json) => {
|
|
248
|
+
json.extends = `${(0, devkit_1.offsetFromRoot)(e2eProject.root)}${tsConfigPath}`;
|
|
249
|
+
json.compilerOptions = Object.assign(Object.assign({}, json.compilerOptions), { outDir: `${(0, devkit_1.offsetFromRoot)(e2eProject.root)}dist/out-tsc` });
|
|
250
|
+
return json;
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
function updateTsLint(host) {
|
|
255
|
+
if (host.exists(`tslint.json`)) {
|
|
256
|
+
(0, devkit_1.updateJson)(host, 'tslint.json', (tslintJson) => {
|
|
257
|
+
[
|
|
258
|
+
'no-trailing-whitespace',
|
|
259
|
+
'one-line',
|
|
260
|
+
'quotemark',
|
|
261
|
+
'typedef-whitespace',
|
|
262
|
+
'whitespace',
|
|
263
|
+
].forEach((key) => {
|
|
264
|
+
tslintJson[key] = undefined;
|
|
265
|
+
});
|
|
266
|
+
tslintJson.rulesDirectory = tslintJson.rulesDirectory || [];
|
|
267
|
+
tslintJson.rulesDirectory.push('node_modules/@nrwl/workspace/src/tslint');
|
|
268
|
+
tslintJson.rules['nx-enforce-module-boundaries'] = [
|
|
269
|
+
true,
|
|
270
|
+
{
|
|
271
|
+
allow: [],
|
|
272
|
+
depConstraints: [{ sourceTag: '*', onlyDependOnLibsWithTags: ['*'] }],
|
|
273
|
+
},
|
|
274
|
+
];
|
|
275
|
+
return tslintJson;
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
function updateProjectTsLint(host, options) {
|
|
280
|
+
const workspaceJson = (0, devkit_1.readJson)(host, (0, devkit_1.getWorkspacePath)(host));
|
|
281
|
+
const app = workspaceJson.projects[options.name];
|
|
282
|
+
const offset = '../../';
|
|
283
|
+
if (host.exists(`${app.root}/tslint.json`)) {
|
|
284
|
+
(0, devkit_1.updateJson)(host, `${app.root}/tslint.json`, (json) => {
|
|
285
|
+
json.extends = `${offset}tslint.json`;
|
|
286
|
+
return json;
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
function setUpCompilerOptions(tsconfig) {
|
|
291
|
+
if (!tsconfig.compilerOptions.paths) {
|
|
292
|
+
tsconfig.compilerOptions.paths = {};
|
|
293
|
+
}
|
|
294
|
+
tsconfig.compilerOptions.baseUrl = '.';
|
|
295
|
+
tsconfig.compilerOptions.rootDir = '.';
|
|
296
|
+
return tsconfig;
|
|
297
|
+
}
|
|
298
|
+
function moveOutOfSrc(tree, appName, filePath, required = true) {
|
|
299
|
+
if (!filePath) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
const filename = !!filePath ? (0, path_1.basename)(filePath) : '';
|
|
303
|
+
const from = filePath;
|
|
304
|
+
const to = filename
|
|
305
|
+
? (0, devkit_1.joinPathFragments)('apps', appName, filename)
|
|
306
|
+
: (0, devkit_1.joinPathFragments)('apps', appName);
|
|
307
|
+
renameSyncInTree(tree, from, to, required);
|
|
308
|
+
}
|
|
309
|
+
function getE2eKey(host) {
|
|
310
|
+
const projects = (0, devkit_1.getProjects)(host);
|
|
311
|
+
for (const [projectName, project] of projects) {
|
|
312
|
+
if (project.targets.e2e) {
|
|
313
|
+
return projectName;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
function getE2eProject(host) {
|
|
318
|
+
const key = getE2eKey(host);
|
|
319
|
+
if (key) {
|
|
320
|
+
return (0, devkit_1.readProjectConfiguration)(host, key);
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
return null;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
function isCypressE2eProject(e2eProject) {
|
|
327
|
+
return e2eProject.targets.e2e.executor === '@cypress/schematic:cypress';
|
|
328
|
+
}
|
|
329
|
+
function isProtractorE2eProject(e2eProject) {
|
|
330
|
+
return (e2eProject.targets.e2e.executor ===
|
|
331
|
+
'@angular-devkit/build-angular:protractor');
|
|
332
|
+
}
|
|
333
|
+
function moveExistingFiles(host, options) {
|
|
334
|
+
const app = (0, devkit_1.readProjectConfiguration)(host, options.name);
|
|
335
|
+
// it is not required to have a browserslist
|
|
336
|
+
moveOutOfSrc(host, options.name, 'browserslist', false);
|
|
337
|
+
moveOutOfSrc(host, options.name, '.browserslistrc', false);
|
|
338
|
+
moveOutOfSrc(host, options.name, app.targets.build.options.tsConfig);
|
|
339
|
+
if (app.targets.test) {
|
|
340
|
+
moveOutOfSrc(host, options.name, app.targets.test.options.karmaConfig);
|
|
341
|
+
moveOutOfSrc(host, options.name, app.targets.test.options.tsConfig);
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
// there could still be a karma.conf.js file in the root
|
|
345
|
+
// so move to new location
|
|
346
|
+
if (host.exists('karma.conf.js')) {
|
|
347
|
+
console.info('No test configuration, but root Karma config file found');
|
|
348
|
+
moveOutOfSrc(host, options.name, 'karma.conf.js');
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (app.targets.server) {
|
|
352
|
+
moveOutOfSrc(host, options.name, app.targets.server.options.tsConfig);
|
|
353
|
+
}
|
|
354
|
+
const oldAppSourceRoot = app.sourceRoot;
|
|
355
|
+
const newAppSourceRoot = (0, devkit_1.joinPathFragments)('apps', options.name, 'src');
|
|
356
|
+
renameDirSyncInTree(host, oldAppSourceRoot, newAppSourceRoot);
|
|
357
|
+
moveE2eProjectFiles(host, app, options);
|
|
358
|
+
}
|
|
359
|
+
function moveE2eProjectFiles(tree, app, options) {
|
|
360
|
+
const e2eProject = getE2eProject(tree);
|
|
361
|
+
if (!e2eProject) {
|
|
362
|
+
console.warn('No e2e project was migrated because there was none declared in angular.json.');
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
if (isProtractorE2eProject(e2eProject)) {
|
|
366
|
+
const oldE2eRoot = (0, devkit_1.joinPathFragments)(app.root || '', 'e2e');
|
|
367
|
+
const newE2eRoot = (0, devkit_1.joinPathFragments)('apps', `${getE2eKey(tree)}-e2e`);
|
|
368
|
+
renameDirSyncInTree(tree, oldE2eRoot, newE2eRoot);
|
|
369
|
+
}
|
|
370
|
+
else if (isCypressE2eProject(e2eProject)) {
|
|
371
|
+
const e2eProjectName = `${options.name}-e2e`;
|
|
372
|
+
const configFile = getCypressConfigFile(e2eProject);
|
|
373
|
+
const oldE2eRoot = 'cypress';
|
|
374
|
+
const newE2eRoot = (0, devkit_1.joinPathFragments)('apps', e2eProjectName);
|
|
375
|
+
if (configFile) {
|
|
376
|
+
updateCypressConfigFilePaths(tree, configFile, oldE2eRoot, newE2eRoot);
|
|
377
|
+
moveOutOfSrc(tree, e2eProjectName, configFile);
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
tree.write((0, devkit_1.joinPathFragments)('apps', e2eProjectName, 'cypress.json'), JSON.stringify({
|
|
381
|
+
fileServerFolder: '.',
|
|
382
|
+
fixturesFolder: './src/fixtures',
|
|
383
|
+
integrationFolder: './src/integration',
|
|
384
|
+
modifyObstructiveCode: false,
|
|
385
|
+
supportFile: './src/support/index.ts',
|
|
386
|
+
pluginsFile: './src/plugins/index.ts',
|
|
387
|
+
video: true,
|
|
388
|
+
videosFolder: `../../dist/cypress/${newE2eRoot}/videos`,
|
|
389
|
+
screenshotsFolder: `../../dist/cypress/${newE2eRoot}/screenshots`,
|
|
390
|
+
chromeWebSecurity: false,
|
|
391
|
+
}));
|
|
392
|
+
}
|
|
393
|
+
moveOutOfSrc(tree, e2eProjectName, `${oldE2eRoot}/tsconfig.json`);
|
|
394
|
+
renameDirSyncInTree(tree, oldE2eRoot, (0, devkit_1.joinPathFragments)('apps', e2eProjectName, 'src'));
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
function updateCypressConfigFilePaths(tree, configFile, oldE2eRoot, newE2eRoot) {
|
|
398
|
+
const srcFoldersAndFiles = [
|
|
399
|
+
'integrationFolder',
|
|
400
|
+
'supportFile',
|
|
401
|
+
'pluginsFile',
|
|
402
|
+
'fixturesFolder',
|
|
403
|
+
];
|
|
404
|
+
const distFolders = ['videosFolder', 'screenshotsFolder'];
|
|
405
|
+
const stringOrArrayGlobs = ['ignoreTestFiles', 'testFiles'];
|
|
406
|
+
const cypressConfig = (0, devkit_1.readJson)(tree, configFile);
|
|
407
|
+
cypressConfig.fileServerFolder = '.';
|
|
408
|
+
srcFoldersAndFiles.forEach((folderOrFile) => {
|
|
409
|
+
if (cypressConfig[folderOrFile]) {
|
|
410
|
+
cypressConfig[folderOrFile] = `./src/${(0, path_1.relative)(oldE2eRoot, cypressConfig[folderOrFile])}`;
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
distFolders.forEach((folder) => {
|
|
414
|
+
if (cypressConfig[folder]) {
|
|
415
|
+
cypressConfig[folder] = `../../dist/cypress/${newE2eRoot}/${(0, path_1.relative)(oldE2eRoot, cypressConfig[folder])}`;
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
stringOrArrayGlobs.forEach((stringOrArrayGlob) => {
|
|
419
|
+
if (!cypressConfig[stringOrArrayGlob]) {
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
if (Array.isArray(cypressConfig[stringOrArrayGlob])) {
|
|
423
|
+
cypressConfig[stringOrArrayGlob] = cypressConfig[stringOrArrayGlob].map((glob) => replaceCypressGlobConfig(glob, oldE2eRoot));
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
cypressConfig[stringOrArrayGlob] = replaceCypressGlobConfig(cypressConfig[stringOrArrayGlob], oldE2eRoot);
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
(0, devkit_1.writeJson)(tree, configFile, cypressConfig);
|
|
430
|
+
}
|
|
431
|
+
function replaceCypressGlobConfig(globPattern, oldE2eRoot) {
|
|
432
|
+
return globPattern.replace(new RegExp(`^(\\.\\/|\\/)?${oldE2eRoot}\\/`), './src/');
|
|
433
|
+
}
|
|
434
|
+
function createAdditionalFiles(host) {
|
|
435
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
436
|
+
const recommendations = [
|
|
437
|
+
'nrwl.angular-console',
|
|
438
|
+
'angular.ng-template',
|
|
439
|
+
'dbaeumer.vscode-eslint',
|
|
440
|
+
'esbenp.prettier-vscode',
|
|
441
|
+
];
|
|
442
|
+
if (host.exists('.vscode/extensions.json')) {
|
|
443
|
+
(0, devkit_1.updateJson)(host, '.vscode/extensions.json', (json) => {
|
|
444
|
+
json.recommendations = json.recommendations || [];
|
|
445
|
+
recommendations.forEach((extension) => {
|
|
446
|
+
if (!json.recommendations.includes(extension)) {
|
|
447
|
+
json.recommendations.push(extension);
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
return json;
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
else {
|
|
454
|
+
(0, devkit_1.writeJson)(host, '.vscode/extensions.json', {
|
|
455
|
+
recommendations,
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
// if the user does not already have a prettier configuration
|
|
459
|
+
// of any kind, create one
|
|
460
|
+
const existingPrettierConfig = yield (0, prettier_1.resolveUserExistingPrettierConfig)();
|
|
461
|
+
if (!existingPrettierConfig) {
|
|
462
|
+
(0, devkit_1.writeJson)(host, '.prettierrc', workspace_1.DEFAULT_NRWL_PRETTIER_CONFIG);
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
function checkCanConvertToWorkspace(host) {
|
|
467
|
+
try {
|
|
468
|
+
if (!host.exists('package.json')) {
|
|
469
|
+
throw new Error('Cannot find package.json');
|
|
470
|
+
}
|
|
471
|
+
if (!host.exists('angular.json')) {
|
|
472
|
+
throw new Error('Cannot find angular.json');
|
|
473
|
+
}
|
|
474
|
+
// TODO: This restriction should be lited
|
|
475
|
+
const workspaceJson = (0, devkit_1.readJson)(host, 'angular.json');
|
|
476
|
+
const hasLibraries = Object.keys(workspaceJson.projects).find((project) => workspaceJson.projects[project].projectType &&
|
|
477
|
+
workspaceJson.projects[project].projectType !== 'application');
|
|
478
|
+
if (Object.keys(workspaceJson.projects).length > 2 || hasLibraries) {
|
|
479
|
+
throw new Error('Can only convert projects with one app');
|
|
480
|
+
}
|
|
481
|
+
const e2eKey = getE2eKey(host);
|
|
482
|
+
const e2eApp = getE2eProject(host);
|
|
483
|
+
if (!e2eApp) {
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
if (isProtractorE2eProject(e2eApp)) {
|
|
487
|
+
if (host.exists(e2eApp.targets.e2e.options.protractorConfig)) {
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
console.info(`Make sure the "${e2eKey}.architect.e2e.options.protractorConfig" is valid or the "${e2eKey}" project is removed from "angular.json".`);
|
|
491
|
+
throw new Error(`An e2e project with Protractor was found but "${e2eApp.targets.e2e.options.protractorConfig}" could not be found.`);
|
|
492
|
+
}
|
|
493
|
+
if (isCypressE2eProject(e2eApp)) {
|
|
494
|
+
const configFile = getCypressConfigFile(e2eApp);
|
|
495
|
+
if (configFile && !host.exists(configFile)) {
|
|
496
|
+
throw new Error(`An e2e project with Cypress was found but "${configFile}" could not be found.`);
|
|
497
|
+
}
|
|
498
|
+
if (!host.exists('cypress')) {
|
|
499
|
+
throw new Error(`An e2e project with Cypress was found but the "cypress" directory could not be found.`);
|
|
500
|
+
}
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
throw new Error(`An e2e project was found but it's using an unsupported executor "${e2eApp.targets.e2e.executor}".`);
|
|
504
|
+
}
|
|
505
|
+
catch (e) {
|
|
506
|
+
console.error(e.message);
|
|
507
|
+
console.error('Your workspace could not be converted into an Nx Workspace because of the above error.');
|
|
508
|
+
throw e;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
function createNxJson(host) {
|
|
512
|
+
const { projects = {}, newProjectRoot = '' } = (0, devkit_1.readJson)(host, 'angular.json');
|
|
513
|
+
const hasLibraries = Object.keys(projects).find((project) => projects[project].projectType &&
|
|
514
|
+
projects[project].projectType !== 'application');
|
|
515
|
+
if (Object.keys(projects).length !== 1 || hasLibraries) {
|
|
516
|
+
throw new Error(`The schematic can only be used with Angular CLI workspaces with a single application.`);
|
|
517
|
+
}
|
|
518
|
+
const name = Object.keys(projects)[0];
|
|
519
|
+
const tsConfigPath = (0, typescript_1.getRootTsConfigPathInTree)(host);
|
|
520
|
+
(0, devkit_1.writeJson)(host, 'nx.json', {
|
|
521
|
+
npmScope: name,
|
|
522
|
+
implicitDependencies: {
|
|
523
|
+
'package.json': {
|
|
524
|
+
dependencies: '*',
|
|
525
|
+
devDependencies: '*',
|
|
526
|
+
},
|
|
527
|
+
[tsConfigPath]: '*',
|
|
528
|
+
'.eslintrc.json': '*',
|
|
529
|
+
},
|
|
530
|
+
tasksRunnerOptions: {
|
|
531
|
+
default: {
|
|
532
|
+
runner: '@nrwl/workspace/tasks-runners/default',
|
|
533
|
+
options: {
|
|
534
|
+
cacheableOperations: ['build', 'lint', 'test', 'e2e'],
|
|
535
|
+
},
|
|
536
|
+
},
|
|
537
|
+
},
|
|
538
|
+
workspaceLayout: { appsDir: newProjectRoot, libsDir: newProjectRoot },
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
function decorateAngularCli(host) {
|
|
542
|
+
(0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, 'files', 'decorate-angular-cli'), '.', { tmpl: '' });
|
|
543
|
+
(0, devkit_1.updateJson)(host, 'package.json', (json) => {
|
|
544
|
+
if (json.scripts &&
|
|
545
|
+
json.scripts.postinstall &&
|
|
546
|
+
!json.scripts.postinstall.includes('decorate-angular-cli.js')) {
|
|
547
|
+
// if exists, add execution of this script
|
|
548
|
+
json.scripts.postinstall += ' && node ./decorate-angular-cli.js';
|
|
549
|
+
}
|
|
550
|
+
else {
|
|
551
|
+
if (!json.scripts)
|
|
552
|
+
json.scripts = {};
|
|
553
|
+
// if doesn't exist, set to execute this script
|
|
554
|
+
json.scripts.postinstall = 'node ./decorate-angular-cli.js';
|
|
555
|
+
}
|
|
556
|
+
if (json.scripts.ng) {
|
|
557
|
+
json.scripts.ng = 'nx';
|
|
558
|
+
}
|
|
559
|
+
return json;
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
function addFiles(host, options) {
|
|
563
|
+
var _a;
|
|
564
|
+
(0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files/root'), '.', {
|
|
565
|
+
tmpl: '',
|
|
566
|
+
dot: '.',
|
|
567
|
+
rootTsConfigPath: (0, typescript_1.getRootTsConfigPathInTree)(host),
|
|
568
|
+
npmScope: options.npmScope,
|
|
569
|
+
defaultBase: (_a = options.defaultBase) !== null && _a !== void 0 ? _a : (0, default_base_1.deduceDefaultBase)(),
|
|
570
|
+
});
|
|
571
|
+
if (!host.exists('.prettierignore')) {
|
|
572
|
+
(0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files/prettier'), '.', {
|
|
573
|
+
tmpl: '',
|
|
574
|
+
dot: '.',
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
function renameSyncInTree(tree, from, to, required) {
|
|
579
|
+
if (!tree.exists(from)) {
|
|
580
|
+
if (required) {
|
|
581
|
+
console.warn(`Path: ${from} does not exist`);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
else if (tree.exists(to)) {
|
|
585
|
+
if (required) {
|
|
586
|
+
console.warn(`Path: ${to} already exists`);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
else {
|
|
590
|
+
const contents = tree.read(from);
|
|
591
|
+
tree.write(to, contents);
|
|
592
|
+
tree.delete(from);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
function renameDirSyncInTree(tree, from, to) {
|
|
596
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, from, (file) => {
|
|
597
|
+
renameSyncInTree(tree, file, file.replace(from, to), true);
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
function migrateFromAngularCli(tree, schema) {
|
|
601
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
602
|
+
if (schema.preserveAngularCliLayout) {
|
|
603
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
604
|
+
nx: versions_2.nxVersion,
|
|
605
|
+
'@nrwl/workspace': versions_2.nxVersion,
|
|
606
|
+
});
|
|
607
|
+
createNxJson(tree);
|
|
608
|
+
decorateAngularCli(tree);
|
|
609
|
+
}
|
|
610
|
+
else {
|
|
611
|
+
const options = Object.assign(Object.assign({}, schema), { npmScope: (0, devkit_1.names)(schema.npmScope || schema.name).fileName });
|
|
612
|
+
checkCanConvertToWorkspace(tree);
|
|
613
|
+
moveExistingFiles(tree, options);
|
|
614
|
+
addFiles(tree, options);
|
|
615
|
+
yield createAdditionalFiles(tree);
|
|
616
|
+
updatePackageJson(tree);
|
|
617
|
+
updateAngularCLIJson(tree, options);
|
|
618
|
+
updateTsLint(tree);
|
|
619
|
+
updateProjectTsLint(tree, options);
|
|
620
|
+
updateTsConfig(tree);
|
|
621
|
+
updateTsConfigsJson(tree, options);
|
|
622
|
+
decorateAngularCli(tree);
|
|
623
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
624
|
+
}
|
|
625
|
+
if (!schema.skipInstall) {
|
|
626
|
+
return () => {
|
|
627
|
+
(0, devkit_1.installPackagesTask)(tree);
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
exports.migrateFromAngularCli = migrateFromAngularCli;
|
|
633
|
+
//# sourceMappingURL=migrate-from-angular-cli.js.map
|