@angular/cli 14.0.0-next.3 → 14.0.0-next.6
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/bin/ng.js +3 -5
- package/bin/postinstall/analytics-prompt.js +3 -3
- package/lib/cli/index.d.ts +1 -1
- package/lib/cli/index.js +16 -18
- package/lib/config/schema.json +8 -12
- package/lib/config/workspace-schema.d.ts +1 -1
- package/lib/init.js +8 -4
- package/package.json +17 -16
- package/{models → src/analytics}/analytics-collector.d.ts +0 -0
- package/{models → src/analytics}/analytics-collector.js +6 -2
- package/src/analytics/analytics-environment-options.d.ts +9 -0
- package/src/analytics/analytics-environment-options.js +20 -0
- package/src/analytics/analytics.d.ts +47 -0
- package/src/analytics/analytics.js +303 -0
- package/src/command-builder/architect-base-command-module.d.ts +23 -0
- package/src/command-builder/architect-base-command-module.js +103 -0
- package/src/command-builder/architect-command-module.d.ts +22 -0
- package/src/command-builder/architect-command-module.js +108 -0
- package/src/command-builder/command-module.d.ts +88 -0
- package/src/command-builder/command-module.js +191 -0
- package/src/command-builder/command-runner.d.ts +10 -0
- package/src/command-builder/command-runner.js +135 -0
- package/src/command-builder/schematics-command-module.d.ts +44 -0
- package/src/command-builder/schematics-command-module.js +295 -0
- package/src/command-builder/utilities/command.d.ts +13 -0
- package/src/command-builder/utilities/command.js +27 -0
- package/src/command-builder/utilities/json-help.d.ts +36 -0
- package/src/command-builder/utilities/json-help.js +94 -0
- package/src/command-builder/utilities/json-schema.d.ts +40 -0
- package/{utilities → src/command-builder/utilities}/json-schema.js +20 -121
- package/{models → src/command-builder/utilities}/schematic-engine-host.d.ts +0 -0
- package/{models → src/command-builder/utilities}/schematic-engine-host.js +0 -0
- package/src/command-builder/utilities/schematic-workflow.d.ts +14 -0
- package/src/command-builder/utilities/schematic-workflow.js +68 -0
- package/src/commands/add/cli.d.ts +33 -0
- package/{commands/add-impl.js → src/commands/add/cli.js} +100 -72
- package/{commands/add.md → src/commands/add/long-description.md} +0 -0
- package/src/commands/analytics/cli.d.ts +16 -0
- package/src/commands/analytics/cli.js +35 -0
- package/src/commands/analytics/info/cli.d.ts +16 -0
- package/src/commands/analytics/info/cli.js +26 -0
- package/src/commands/analytics/settings/cli.d.ts +35 -0
- package/src/commands/analytics/settings/cli.js +61 -0
- package/src/commands/build/cli.d.ts +16 -0
- package/src/commands/build/cli.js +23 -0
- package/{commands/build-long.md → src/commands/build/long-description.md} +0 -0
- package/src/commands/config/cli.d.ts +24 -0
- package/{commands/config-impl.js → src/commands/config/cli.js} +102 -89
- package/{commands/config-long.md → src/commands/config/long-description.md} +2 -2
- package/src/commands/deploy/cli.d.ts +16 -0
- package/src/commands/deploy/cli.js +35 -0
- package/{commands/deploy-long.md → src/commands/deploy/long-description.md} +0 -0
- package/src/commands/doc/cli.d.ts +23 -0
- package/{commands/doc-impl.js → src/commands/doc/cli.js} +41 -12
- package/src/commands/e2e/cli.d.ts +17 -0
- package/src/commands/e2e/cli.js +34 -0
- package/src/commands/extract-i18n/cli.d.ts +15 -0
- package/src/commands/extract-i18n/cli.js +20 -0
- package/src/commands/generate/cli.d.ts +29 -0
- package/src/commands/generate/cli.js +114 -0
- package/src/commands/lint/cli.d.ts +16 -0
- package/src/commands/lint/cli.js +31 -0
- package/{commands/lint-long.md → src/commands/lint/long-description.md} +0 -0
- package/src/commands/make-this-awesome/cli.d.ts +17 -0
- package/{commands/easter-egg-impl.js → src/commands/make-this-awesome/cli.js} +17 -10
- package/src/commands/new/cli.d.ts +25 -0
- package/src/commands/new/cli.js +66 -0
- package/src/commands/run/cli.d.ts +23 -0
- package/src/commands/run/cli.js +59 -0
- package/{commands/run-long.md → src/commands/run/long-description.md} +0 -0
- package/src/commands/serve/cli.d.ts +16 -0
- package/src/commands/serve/cli.js +21 -0
- package/src/commands/test/cli.d.ts +16 -0
- package/src/commands/test/cli.js +23 -0
- package/{commands/test-long.md → src/commands/test/long-description.md} +0 -0
- package/{commands/update-impl.d.ts → src/commands/update/cli.d.ts} +25 -9
- package/{commands/update-impl.js → src/commands/update/cli.js} +323 -306
- package/{commands/update-long.md → src/commands/update/long-description.md} +0 -0
- package/src/commands/update/schematic/index.js +6 -2
- package/src/commands/version/cli.d.ts +19 -0
- package/{commands/version-impl.js → src/commands/version/cli.js} +57 -56
- package/src/typings.d.ts +2 -2
- package/{utilities → src/utilities}/color.d.ts +0 -0
- package/{utilities → src/utilities}/color.js +5 -1
- package/{utilities → src/utilities}/config.d.ts +2 -1
- package/{utilities → src/utilities}/config.js +38 -7
- package/{utilities → src/utilities}/find-up.d.ts +0 -0
- package/{utilities → src/utilities}/find-up.js +5 -1
- package/{utilities → src/utilities}/install-package.d.ts +2 -2
- package/{utilities → src/utilities}/install-package.js +1 -1
- package/{utilities → src/utilities}/json-file.d.ts +0 -0
- package/{utilities → src/utilities}/json-file.js +0 -0
- package/{utilities → src/utilities}/log-file.d.ts +0 -0
- package/{utilities → src/utilities}/log-file.js +0 -0
- package/{utilities → src/utilities}/package-json.d.ts +0 -0
- package/{utilities → src/utilities}/package-json.js +0 -0
- package/{utilities → src/utilities}/package-manager.d.ts +1 -1
- package/{utilities → src/utilities}/package-manager.js +1 -1
- package/{utilities → src/utilities}/package-metadata.d.ts +0 -0
- package/{utilities → src/utilities}/package-metadata.js +5 -1
- package/{utilities → src/utilities}/package-tree.d.ts +0 -0
- package/{utilities → src/utilities}/package-tree.js +5 -1
- package/{utilities → src/utilities}/project.d.ts +0 -0
- package/{utilities → src/utilities}/project.js +5 -1
- package/{utilities → src/utilities}/prompt.d.ts +0 -0
- package/{utilities → src/utilities}/prompt.js +5 -1
- package/{utilities → src/utilities}/spinner.d.ts +0 -0
- package/{utilities → src/utilities}/spinner.js +0 -0
- package/{utilities → src/utilities}/tty.d.ts +0 -0
- package/{utilities → src/utilities}/tty.js +0 -0
- package/{models → src/utilities}/version.d.ts +2 -1
- package/{models → src/utilities}/version.js +6 -6
- package/commands/add-impl.d.ts +0 -21
- package/commands/add.d.ts +0 -42
- package/commands/add.js +0 -10
- package/commands/add.json +0 -54
- package/commands/analytics-impl.d.ts +0 -13
- package/commands/analytics-impl.js +0 -80
- package/commands/analytics-long.md +0 -8
- package/commands/analytics.d.ts +0 -46
- package/commands/analytics.js +0 -31
- package/commands/analytics.json +0 -37
- package/commands/build-impl.d.ts +0 -14
- package/commands/build-impl.js +0 -21
- package/commands/build.d.ts +0 -30
- package/commands/build.js +0 -10
- package/commands/build.json +0 -16
- package/commands/config-impl.d.ts +0 -15
- package/commands/config.d.ts +0 -34
- package/commands/config.js +0 -10
- package/commands/config.json +0 -43
- package/commands/definitions.json +0 -66
- package/commands/deploy-impl.d.ts +0 -15
- package/commands/deploy-impl.js +0 -36
- package/commands/deploy.d.ts +0 -30
- package/commands/deploy.js +0 -10
- package/commands/deploy.json +0 -34
- package/commands/doc-impl.d.ts +0 -13
- package/commands/doc.d.ts +0 -39
- package/commands/doc.js +0 -14
- package/commands/doc.json +0 -46
- package/commands/e2e-impl.d.ts +0 -16
- package/commands/e2e-impl.js +0 -36
- package/commands/e2e-long.md +0 -4
- package/commands/e2e.d.ts +0 -29
- package/commands/e2e.js +0 -10
- package/commands/e2e.json +0 -17
- package/commands/easter-egg-impl.d.ts +0 -12
- package/commands/easter-egg.d.ts +0 -14
- package/commands/easter-egg.js +0 -10
- package/commands/easter-egg.json +0 -12
- package/commands/extract-i18n-impl.d.ts +0 -14
- package/commands/extract-i18n-impl.js +0 -21
- package/commands/extract-i18n.d.ts +0 -29
- package/commands/extract-i18n.js +0 -10
- package/commands/extract-i18n.json +0 -15
- package/commands/generate-impl.d.ts +0 -18
- package/commands/generate-impl.js +0 -89
- package/commands/generate.d.ts +0 -37
- package/commands/generate.js +0 -10
- package/commands/generate.json +0 -31
- package/commands/help-impl.d.ts +0 -12
- package/commands/help-impl.js +0 -26
- package/commands/help-long.md +0 -7
- package/commands/help.d.ts +0 -17
- package/commands/help.js +0 -10
- package/commands/help.json +0 -13
- package/commands/lint-impl.d.ts +0 -16
- package/commands/lint-impl.js +0 -69
- package/commands/lint.d.ts +0 -29
- package/commands/lint.js +0 -10
- package/commands/lint.json +0 -36
- package/commands/new-impl.d.ts +0 -16
- package/commands/new-impl.js +0 -37
- package/commands/new.d.ts +0 -41
- package/commands/new.js +0 -10
- package/commands/new.json +0 -34
- package/commands/new.md +0 -16
- package/commands/run-impl.d.ts +0 -13
- package/commands/run-impl.js +0 -22
- package/commands/run.d.ts +0 -30
- package/commands/run.js +0 -10
- package/commands/run.json +0 -36
- package/commands/serve-impl.d.ts +0 -15
- package/commands/serve-impl.js +0 -24
- package/commands/serve.d.ts +0 -29
- package/commands/serve.js +0 -10
- package/commands/serve.json +0 -17
- package/commands/test-impl.d.ts +0 -15
- package/commands/test-impl.js +0 -22
- package/commands/test.d.ts +0 -29
- package/commands/test.js +0 -10
- package/commands/test.json +0 -17
- package/commands/update.d.ts +0 -61
- package/commands/update.js +0 -10
- package/commands/update.json +0 -78
- package/commands/version-impl.d.ts +0 -17
- package/commands/version.d.ts +0 -17
- package/commands/version.js +0 -10
- package/commands/version.json +0 -13
- package/commands.json +0 -20
- package/models/analytics.d.ts +0 -58
- package/models/analytics.js +0 -358
- package/models/architect-command.d.ts +0 -35
- package/models/architect-command.js +0 -364
- package/models/command-runner.d.ts +0 -24
- package/models/command-runner.js +0 -241
- package/models/command.d.ts +0 -34
- package/models/command.js +0 -143
- package/models/interface.d.ts +0 -196
- package/models/interface.js +0 -31
- package/models/parser.d.ts +0 -39
- package/models/parser.js +0 -349
- package/models/schematic-command.d.ts +0 -55
- package/models/schematic-command.js +0 -485
- package/utilities/INITIAL_COMMIT_MESSAGE.txt +0 -8
- package/utilities/json-schema.d.ts +0 -17
|
@@ -8,7 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
|
-
Object.
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
12
16
|
}) : (function(o, m, k, k2) {
|
|
13
17
|
if (k2 === undefined) k2 = k;
|
|
14
18
|
o[k2] = m[k];
|
|
@@ -29,26 +33,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
29
33
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
34
|
};
|
|
31
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.
|
|
36
|
+
exports.UpdateCommandModule = void 0;
|
|
33
37
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
34
38
|
const tools_1 = require("@angular-devkit/schematics/tools");
|
|
35
39
|
const child_process_1 = require("child_process");
|
|
36
|
-
const
|
|
40
|
+
const fs_1 = require("fs");
|
|
37
41
|
const npm_package_arg_1 = __importDefault(require("npm-package-arg"));
|
|
38
42
|
const npm_pick_manifest_1 = __importDefault(require("npm-pick-manifest"));
|
|
39
43
|
const path = __importStar(require("path"));
|
|
44
|
+
const path_1 = require("path");
|
|
40
45
|
const semver = __importStar(require("semver"));
|
|
41
|
-
const workspace_schema_1 = require("
|
|
42
|
-
const
|
|
43
|
-
const schematic_engine_host_1 = require("
|
|
44
|
-
const
|
|
45
|
-
const color_1 = require("
|
|
46
|
-
const install_package_1 = require("
|
|
47
|
-
const log_file_1 = require("
|
|
48
|
-
const package_manager_1 = require("
|
|
49
|
-
const package_metadata_1 = require("
|
|
50
|
-
const package_tree_1 = require("
|
|
51
|
-
const
|
|
46
|
+
const workspace_schema_1 = require("../../../lib/config/workspace-schema");
|
|
47
|
+
const command_module_1 = require("../../command-builder/command-module");
|
|
48
|
+
const schematic_engine_host_1 = require("../../command-builder/utilities/schematic-engine-host");
|
|
49
|
+
const schematic_workflow_1 = require("../../command-builder/utilities/schematic-workflow");
|
|
50
|
+
const color_1 = require("../../utilities/color");
|
|
51
|
+
const install_package_1 = require("../../utilities/install-package");
|
|
52
|
+
const log_file_1 = require("../../utilities/log-file");
|
|
53
|
+
const package_manager_1 = require("../../utilities/package-manager");
|
|
54
|
+
const package_metadata_1 = require("../../utilities/package-metadata");
|
|
55
|
+
const package_tree_1 = require("../../utilities/package-tree");
|
|
56
|
+
const version_1 = require("../../utilities/version");
|
|
52
57
|
/**
|
|
53
58
|
* Disable CLI version mismatch checks and forces usage of the invoked CLI
|
|
54
59
|
* instead of invoking the local installed version.
|
|
@@ -58,16 +63,142 @@ const disableVersionCheck = disableVersionCheckEnv !== undefined &&
|
|
|
58
63
|
disableVersionCheckEnv !== '0' &&
|
|
59
64
|
disableVersionCheckEnv.toLowerCase() !== 'false';
|
|
60
65
|
const ANGULAR_PACKAGES_REGEXP = /^@(?:angular|nguniversal)\//;
|
|
61
|
-
|
|
66
|
+
const UPDATE_SCHEMATIC_COLLECTION = path.join(__dirname, 'schematic/collection.json');
|
|
67
|
+
class UpdateCommandModule extends command_module_1.CommandModule {
|
|
62
68
|
constructor() {
|
|
63
69
|
super(...arguments);
|
|
64
|
-
this.
|
|
65
|
-
this.
|
|
70
|
+
this.shouldReportAnalytics = false;
|
|
71
|
+
this.command = 'update [packages..]';
|
|
72
|
+
this.describe = 'Updates your workspace and its dependencies. See https://update.angular.io/.';
|
|
73
|
+
this.longDescriptionPath = (0, path_1.join)(__dirname, 'long-description.md');
|
|
66
74
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
75
|
+
builder(localYargs) {
|
|
76
|
+
return localYargs
|
|
77
|
+
.positional('packages', {
|
|
78
|
+
description: 'The names of package(s) to update.',
|
|
79
|
+
coerce: (value) => (typeof value === 'string' ? [value] : value),
|
|
80
|
+
})
|
|
81
|
+
.option('force', {
|
|
82
|
+
description: 'Ignore peer dependency version mismatches. ' +
|
|
83
|
+
`Passes the '--force' flag to the package manager when installing packages.`,
|
|
84
|
+
type: 'boolean',
|
|
85
|
+
default: false,
|
|
86
|
+
})
|
|
87
|
+
.option('next', {
|
|
88
|
+
description: 'Use the prerelease version, including beta and RCs.',
|
|
89
|
+
type: 'boolean',
|
|
90
|
+
default: false,
|
|
91
|
+
})
|
|
92
|
+
.option('migrate-only', {
|
|
93
|
+
description: 'Only perform a migration, do not update the installed version.',
|
|
94
|
+
type: 'boolean',
|
|
95
|
+
})
|
|
96
|
+
.option('name', {
|
|
97
|
+
description: 'The name of the migration to run. ' +
|
|
98
|
+
`Only available with a single package being updated, and only with 'migrate-only' option.`,
|
|
99
|
+
type: 'string',
|
|
100
|
+
implies: ['migrate-only'],
|
|
101
|
+
conflicts: ['to', 'from'],
|
|
102
|
+
})
|
|
103
|
+
.option('from', {
|
|
104
|
+
description: 'Version from which to migrate from. ' +
|
|
105
|
+
`Only available with a single package being updated, and only with 'migrate-only'.`,
|
|
106
|
+
type: 'string',
|
|
107
|
+
implies: ['to', 'migrate-only'],
|
|
108
|
+
conflicts: ['name'],
|
|
109
|
+
})
|
|
110
|
+
.option('to', {
|
|
111
|
+
describe: 'Version up to which to apply migrations. Only available with a single package being updated, ' +
|
|
112
|
+
`and only with 'migrate-only' option. Requires 'from' to be specified. Default to the installed version detected.`,
|
|
113
|
+
type: 'string',
|
|
114
|
+
implies: ['from', 'migrate-only'],
|
|
115
|
+
conflicts: ['name'],
|
|
116
|
+
})
|
|
117
|
+
.option('allow-dirty', {
|
|
118
|
+
describe: 'Whether to allow updating when the repository contains modified or untracked files.',
|
|
119
|
+
type: 'boolean',
|
|
120
|
+
default: false,
|
|
121
|
+
})
|
|
122
|
+
.option('verbose', {
|
|
123
|
+
describe: 'Display additional details about internal operations during execution.',
|
|
124
|
+
type: 'boolean',
|
|
125
|
+
default: false,
|
|
126
|
+
})
|
|
127
|
+
.option('create-commits', {
|
|
128
|
+
describe: 'Create source control commits for updates and migrations.',
|
|
129
|
+
type: 'boolean',
|
|
130
|
+
alias: ['C'],
|
|
131
|
+
default: false,
|
|
132
|
+
})
|
|
133
|
+
.check(({ packages, next, 'allow-dirty': allowDirty, 'migrate-only': migrateOnly }) => {
|
|
134
|
+
const { logger } = this.context;
|
|
135
|
+
// This allows the user to easily reset any changes from the update.
|
|
136
|
+
if ((packages === null || packages === void 0 ? void 0 : packages.length) && !this.checkCleanGit()) {
|
|
137
|
+
if (allowDirty) {
|
|
138
|
+
logger.warn('Repository is not clean. Update changes will be mixed with pre-existing changes.');
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
throw new command_module_1.CommandModuleError('Repository is not clean. Please commit or stash any changes before updating.');
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (migrateOnly) {
|
|
145
|
+
if ((packages === null || packages === void 0 ? void 0 : packages.length) !== 1) {
|
|
146
|
+
throw new command_module_1.CommandModuleError(`A single package must be specified when using the 'migrate-only' option.`);
|
|
147
|
+
}
|
|
148
|
+
if (next) {
|
|
149
|
+
logger.warn(`'next' option has no effect when using 'migrate-only' option.`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return true;
|
|
153
|
+
})
|
|
154
|
+
.strict();
|
|
155
|
+
}
|
|
156
|
+
async run(options) {
|
|
157
|
+
var _a, _b;
|
|
158
|
+
const { logger, packageManager } = this.context;
|
|
159
|
+
await (0, package_manager_1.ensureCompatibleNpm)(this.context.root);
|
|
160
|
+
// Check if the current installed CLI version is older than the latest compatible version.
|
|
161
|
+
if (!disableVersionCheck) {
|
|
162
|
+
const cliVersionToInstall = await this.checkCLIVersion(options.packages, options.verbose, options.next);
|
|
163
|
+
if (cliVersionToInstall) {
|
|
164
|
+
logger.warn('The installed Angular CLI version is outdated.\n' +
|
|
165
|
+
`Installing a temporary Angular CLI versioned ${cliVersionToInstall} to perform the update.`);
|
|
166
|
+
return (0, install_package_1.runTempPackageBin)(`@angular/cli@${cliVersionToInstall}`, packageManager, process.argv.slice(2));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const packages = [];
|
|
170
|
+
for (const request of (_a = options.packages) !== null && _a !== void 0 ? _a : []) {
|
|
171
|
+
try {
|
|
172
|
+
const packageIdentifier = (0, npm_package_arg_1.default)(request);
|
|
173
|
+
// only registry identifiers are supported
|
|
174
|
+
if (!packageIdentifier.registry) {
|
|
175
|
+
logger.error(`Package '${request}' is not a registry package identifer.`);
|
|
176
|
+
return 1;
|
|
177
|
+
}
|
|
178
|
+
if (packages.some((v) => v.name === packageIdentifier.name)) {
|
|
179
|
+
logger.error(`Duplicate package '${packageIdentifier.name}' specified.`);
|
|
180
|
+
return 1;
|
|
181
|
+
}
|
|
182
|
+
if (options.migrateOnly && packageIdentifier.rawSpec) {
|
|
183
|
+
logger.warn('Package specifier has no effect when using "migrate-only" option.');
|
|
184
|
+
}
|
|
185
|
+
// If next option is used and no specifier supplied, use next tag
|
|
186
|
+
if (options.next && !packageIdentifier.rawSpec) {
|
|
187
|
+
packageIdentifier.fetchSpec = 'next';
|
|
188
|
+
}
|
|
189
|
+
packages.push(packageIdentifier);
|
|
190
|
+
}
|
|
191
|
+
catch (e) {
|
|
192
|
+
logger.error(e.message);
|
|
193
|
+
return 1;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
logger.info(`Using package manager: '${packageManager}'`);
|
|
197
|
+
logger.info('Collecting installed dependencies...');
|
|
198
|
+
const rootDependencies = await (0, package_tree_1.getProjectDependencies)(this.context.root);
|
|
199
|
+
logger.info(`Found ${rootDependencies.size} dependencies.`);
|
|
200
|
+
const workflow = new tools_1.NodeWorkflow(this.context.root, {
|
|
201
|
+
packageManager: this.context.packageManager,
|
|
71
202
|
packageManagerForce: options.force,
|
|
72
203
|
// __dirname -> favor @schematics/update from this package
|
|
73
204
|
// Otherwise, use packages from the active workspace (migrations)
|
|
@@ -75,99 +206,77 @@ class UpdateCommand extends command_1.Command {
|
|
|
75
206
|
schemaValidation: true,
|
|
76
207
|
engineHostCreator: (options) => new schematic_engine_host_1.SchematicEngineHost(options.resolvePaths),
|
|
77
208
|
});
|
|
209
|
+
if (packages.length === 0) {
|
|
210
|
+
// Show status
|
|
211
|
+
const { success } = await this.executeSchematic(workflow, UPDATE_SCHEMATIC_COLLECTION, 'update', {
|
|
212
|
+
force: options.force,
|
|
213
|
+
next: options.next,
|
|
214
|
+
verbose: options.verbose,
|
|
215
|
+
packageManager,
|
|
216
|
+
packages: [],
|
|
217
|
+
});
|
|
218
|
+
return success ? 0 : 1;
|
|
219
|
+
}
|
|
220
|
+
return options.migrateOnly
|
|
221
|
+
? this.migrateOnly(workflow, ((_b = options.packages) !== null && _b !== void 0 ? _b : [])[0], rootDependencies, options)
|
|
222
|
+
: this.updatePackagesAndMigrate(workflow, rootDependencies, options, packages);
|
|
78
223
|
}
|
|
79
|
-
async executeSchematic(collection, schematic, options = {}) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const files = new Set();
|
|
83
|
-
const reporterSubscription = this.workflow.reporter.subscribe((event) => {
|
|
84
|
-
// Strip leading slash to prevent confusion.
|
|
85
|
-
const eventPath = event.path.startsWith('/') ? event.path.substr(1) : event.path;
|
|
86
|
-
switch (event.kind) {
|
|
87
|
-
case 'error':
|
|
88
|
-
error = true;
|
|
89
|
-
const desc = event.description == 'alreadyExist' ? 'already exists' : 'does not exist.';
|
|
90
|
-
this.logger.error(`ERROR! ${eventPath} ${desc}.`);
|
|
91
|
-
break;
|
|
92
|
-
case 'update':
|
|
93
|
-
logs.push(`${color_1.colors.cyan('UPDATE')} ${eventPath} (${event.content.length} bytes)`);
|
|
94
|
-
files.add(eventPath);
|
|
95
|
-
break;
|
|
96
|
-
case 'create':
|
|
97
|
-
logs.push(`${color_1.colors.green('CREATE')} ${eventPath} (${event.content.length} bytes)`);
|
|
98
|
-
files.add(eventPath);
|
|
99
|
-
break;
|
|
100
|
-
case 'delete':
|
|
101
|
-
logs.push(`${color_1.colors.yellow('DELETE')} ${eventPath}`);
|
|
102
|
-
files.add(eventPath);
|
|
103
|
-
break;
|
|
104
|
-
case 'rename':
|
|
105
|
-
const eventToPath = event.to.startsWith('/') ? event.to.substr(1) : event.to;
|
|
106
|
-
logs.push(`${color_1.colors.blue('RENAME')} ${eventPath} => ${eventToPath}`);
|
|
107
|
-
files.add(eventPath);
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
const lifecycleSubscription = this.workflow.lifeCycle.subscribe((event) => {
|
|
112
|
-
if (event.kind == 'end' || event.kind == 'post-tasks-start') {
|
|
113
|
-
if (!error) {
|
|
114
|
-
// Output the logging queue, no error happened.
|
|
115
|
-
logs.forEach((log) => this.logger.info(` ${log}`));
|
|
116
|
-
logs = [];
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
});
|
|
224
|
+
async executeSchematic(workflow, collection, schematic, options = {}) {
|
|
225
|
+
const { logger } = this.context;
|
|
226
|
+
const workflowSubscription = (0, schematic_workflow_1.subscribeToWorkflow)(workflow, logger);
|
|
120
227
|
// TODO: Allow passing a schematic instance directly
|
|
121
228
|
try {
|
|
122
|
-
await
|
|
229
|
+
await workflow
|
|
123
230
|
.execute({
|
|
124
231
|
collection,
|
|
125
232
|
schematic,
|
|
126
233
|
options,
|
|
127
|
-
logger
|
|
234
|
+
logger,
|
|
128
235
|
})
|
|
129
236
|
.toPromise();
|
|
130
|
-
|
|
131
|
-
lifecycleSubscription.unsubscribe();
|
|
132
|
-
return { success: !error, files };
|
|
237
|
+
return { success: !workflowSubscription.error, files: workflowSubscription.files };
|
|
133
238
|
}
|
|
134
239
|
catch (e) {
|
|
135
240
|
if (e instanceof schematics_1.UnsuccessfulWorkflowExecution) {
|
|
136
|
-
|
|
241
|
+
logger.error(`${color_1.colors.symbols.cross} Migration failed. See above for further details.\n`);
|
|
137
242
|
}
|
|
138
243
|
else {
|
|
139
244
|
const logPath = (0, log_file_1.writeErrorToLogFile)(e);
|
|
140
|
-
|
|
245
|
+
logger.fatal(`${color_1.colors.symbols.cross} Migration failed: ${e.message}\n` +
|
|
141
246
|
` See "${logPath}" for further details.\n`);
|
|
142
247
|
}
|
|
143
|
-
return { success: false, files };
|
|
248
|
+
return { success: false, files: workflowSubscription.files };
|
|
249
|
+
}
|
|
250
|
+
finally {
|
|
251
|
+
workflowSubscription.unsubscribe();
|
|
144
252
|
}
|
|
145
253
|
}
|
|
146
254
|
/**
|
|
147
255
|
* @return Whether or not the migration was performed successfully.
|
|
148
256
|
*/
|
|
149
|
-
async executeMigration(packageName, collectionPath, migrationName, commit) {
|
|
150
|
-
const
|
|
257
|
+
async executeMigration(workflow, packageName, collectionPath, migrationName, commit) {
|
|
258
|
+
const { logger } = this.context;
|
|
259
|
+
const collection = workflow.engine.createCollection(collectionPath);
|
|
151
260
|
const name = collection.listSchematicNames().find((name) => name === migrationName);
|
|
152
261
|
if (!name) {
|
|
153
|
-
|
|
154
|
-
return
|
|
262
|
+
logger.error(`Cannot find migration '${migrationName}' in '${packageName}'.`);
|
|
263
|
+
return 1;
|
|
155
264
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
return this.executePackageMigrations([schematic.description], packageName, commit);
|
|
265
|
+
logger.info(color_1.colors.cyan(`** Executing '${migrationName}' of package '${packageName}' **\n`));
|
|
266
|
+
const schematic = workflow.engine.createSchematic(name, collection);
|
|
267
|
+
return this.executePackageMigrations(workflow, [schematic.description], packageName, commit);
|
|
159
268
|
}
|
|
160
269
|
/**
|
|
161
270
|
* @return Whether or not the migrations were performed successfully.
|
|
162
271
|
*/
|
|
163
|
-
async executeMigrations(packageName, collectionPath, from, to, commit) {
|
|
164
|
-
const collection =
|
|
272
|
+
async executeMigrations(workflow, packageName, collectionPath, from, to, commit) {
|
|
273
|
+
const collection = workflow.engine.createCollection(collectionPath);
|
|
165
274
|
const migrationRange = new semver.Range('>' + (semver.prerelease(from) ? from.split('-')[0] + '-0' : from) + ' <=' + to.split('-')[0]);
|
|
166
275
|
const migrations = [];
|
|
167
276
|
for (const name of collection.listSchematicNames()) {
|
|
168
|
-
const schematic =
|
|
277
|
+
const schematic = workflow.engine.createSchematic(name, collection);
|
|
169
278
|
const description = schematic.description;
|
|
170
|
-
description.version = coerceVersionNumber(description.version)
|
|
279
|
+
description.version = coerceVersionNumber(description.version);
|
|
171
280
|
if (!description.version) {
|
|
172
281
|
continue;
|
|
173
282
|
}
|
|
@@ -175,27 +284,28 @@ class UpdateCommand extends command_1.Command {
|
|
|
175
284
|
migrations.push(description);
|
|
176
285
|
}
|
|
177
286
|
}
|
|
178
|
-
migrations.sort((a, b) => semver.compare(a.version, b.version) || a.name.localeCompare(b.name));
|
|
179
287
|
if (migrations.length === 0) {
|
|
180
|
-
return
|
|
288
|
+
return 0;
|
|
181
289
|
}
|
|
182
|
-
|
|
183
|
-
|
|
290
|
+
migrations.sort((a, b) => semver.compare(a.version, b.version) || a.name.localeCompare(b.name));
|
|
291
|
+
this.context.logger.info(color_1.colors.cyan(`** Executing migrations of package '${packageName}' **\n`));
|
|
292
|
+
return this.executePackageMigrations(workflow, migrations, packageName, commit);
|
|
184
293
|
}
|
|
185
|
-
async executePackageMigrations(migrations, packageName, commit = false) {
|
|
294
|
+
async executePackageMigrations(workflow, migrations, packageName, commit = false) {
|
|
295
|
+
const { logger } = this.context;
|
|
186
296
|
for (const migration of migrations) {
|
|
187
297
|
const [title, ...description] = migration.description.split('. ');
|
|
188
|
-
|
|
298
|
+
logger.info(color_1.colors.cyan(color_1.colors.symbols.pointer) +
|
|
189
299
|
' ' +
|
|
190
300
|
color_1.colors.bold(title.endsWith('.') ? title : title + '.'));
|
|
191
301
|
if (description.length) {
|
|
192
|
-
|
|
302
|
+
logger.info(' ' + description.join('.\n '));
|
|
193
303
|
}
|
|
194
|
-
const result = await this.executeSchematic(migration.collection.name, migration.name);
|
|
304
|
+
const result = await this.executeSchematic(workflow, migration.collection.name, migration.name);
|
|
195
305
|
if (!result.success) {
|
|
196
|
-
return
|
|
306
|
+
return 1;
|
|
197
307
|
}
|
|
198
|
-
|
|
308
|
+
logger.info(' Migration completed.');
|
|
199
309
|
// Commit migration
|
|
200
310
|
if (commit) {
|
|
201
311
|
const commitPrefix = `${packageName} migration - ${migration.name}`;
|
|
@@ -205,188 +315,107 @@ class UpdateCommand extends command_1.Command {
|
|
|
205
315
|
const committed = this.commit(commitMessage);
|
|
206
316
|
if (!committed) {
|
|
207
317
|
// Failed to commit, something went wrong. Abort the update.
|
|
208
|
-
return
|
|
318
|
+
return 1;
|
|
209
319
|
}
|
|
210
320
|
}
|
|
211
|
-
|
|
321
|
+
logger.info(''); // Extra trailing newline.
|
|
212
322
|
}
|
|
213
|
-
return
|
|
323
|
+
return 0;
|
|
214
324
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
if (!
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
this.logger.warn('The installed Angular CLI version is outdated.\n' +
|
|
224
|
-
`Installing a temporary Angular CLI versioned ${cliVersionToInstall} to perform the update.`);
|
|
225
|
-
return (0, install_package_1.runTempPackageBin)(`@angular/cli@${cliVersionToInstall}`, this.packageManager, process.argv.slice(2));
|
|
226
|
-
}
|
|
325
|
+
async migrateOnly(workflow, packageName, rootDependencies, options) {
|
|
326
|
+
const { logger } = this.context;
|
|
327
|
+
const packageDependency = rootDependencies.get(packageName);
|
|
328
|
+
let packagePath = packageDependency === null || packageDependency === void 0 ? void 0 : packageDependency.path;
|
|
329
|
+
let packageNode = packageDependency === null || packageDependency === void 0 ? void 0 : packageDependency.package;
|
|
330
|
+
if (packageDependency && !packageNode) {
|
|
331
|
+
logger.error('Package found in package.json but is not installed.');
|
|
332
|
+
return 1;
|
|
227
333
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
const packageIdentifier = (0, npm_package_arg_1.default)(request);
|
|
237
|
-
// only registry identifiers are supported
|
|
238
|
-
if (!packageIdentifier.registry) {
|
|
239
|
-
this.logger.error(`Package '${request}' is not a registry package identifer.`);
|
|
240
|
-
return 1;
|
|
241
|
-
}
|
|
242
|
-
if (packages.some((v) => v.name === packageIdentifier.name)) {
|
|
243
|
-
this.logger.error(`Duplicate package '${packageIdentifier.name}' specified.`);
|
|
244
|
-
return 1;
|
|
245
|
-
}
|
|
246
|
-
if (options.migrateOnly && packageIdentifier.rawSpec) {
|
|
247
|
-
this.logger.warn('Package specifier has no effect when using "migrate-only" option.');
|
|
248
|
-
}
|
|
249
|
-
// If next option is used and no specifier supplied, use next tag
|
|
250
|
-
if (options.next && !packageIdentifier.rawSpec) {
|
|
251
|
-
packageIdentifier.fetchSpec = 'next';
|
|
252
|
-
}
|
|
253
|
-
packages.push(packageIdentifier);
|
|
254
|
-
}
|
|
255
|
-
catch (e) {
|
|
256
|
-
this.logger.error(e.message);
|
|
257
|
-
return 1;
|
|
334
|
+
else if (!packageDependency) {
|
|
335
|
+
// Allow running migrations on transitively installed dependencies
|
|
336
|
+
// There can technically be nested multiple versions
|
|
337
|
+
// TODO: If multiple, this should find all versions and ask which one to use
|
|
338
|
+
const packageJson = (0, package_tree_1.findPackageJson)(this.context.root, packageName);
|
|
339
|
+
if (packageJson) {
|
|
340
|
+
packagePath = path.dirname(packageJson);
|
|
341
|
+
packageNode = await (0, package_tree_1.readPackageJson)(packageJson);
|
|
258
342
|
}
|
|
259
343
|
}
|
|
260
|
-
if (!
|
|
261
|
-
|
|
344
|
+
if (!packageNode || !packagePath) {
|
|
345
|
+
logger.error('Package is not installed.');
|
|
262
346
|
return 1;
|
|
263
347
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
if (
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}
|
|
270
|
-
else {
|
|
271
|
-
this.logger.error('Repository is not clean. Please commit or stash any changes before updating.');
|
|
272
|
-
return 2;
|
|
273
|
-
}
|
|
348
|
+
const updateMetadata = packageNode['ng-update'];
|
|
349
|
+
let migrations = updateMetadata === null || updateMetadata === void 0 ? void 0 : updateMetadata.migrations;
|
|
350
|
+
if (migrations === undefined) {
|
|
351
|
+
logger.error('Package does not provide migrations.');
|
|
352
|
+
return 1;
|
|
274
353
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
this.logger.info(`Found ${rootDependencies.size} dependencies.`);
|
|
279
|
-
if (packages.length === 0) {
|
|
280
|
-
// Show status
|
|
281
|
-
const { success } = await this.executeSchematic(UPDATE_SCHEMATIC_COLLECTION, 'update', {
|
|
282
|
-
force: options.force || false,
|
|
283
|
-
next: options.next || false,
|
|
284
|
-
verbose: options.verbose || false,
|
|
285
|
-
packageManager: this.packageManager,
|
|
286
|
-
packages: [],
|
|
287
|
-
});
|
|
288
|
-
return success ? 0 : 1;
|
|
354
|
+
else if (typeof migrations !== 'string') {
|
|
355
|
+
logger.error('Package contains a malformed migrations field.');
|
|
356
|
+
return 1;
|
|
289
357
|
}
|
|
290
|
-
if (
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
else if (!packageDependency) {
|
|
311
|
-
// Allow running migrations on transitively installed dependencies
|
|
312
|
-
// There can technically be nested multiple versions
|
|
313
|
-
// TODO: If multiple, this should find all versions and ask which one to use
|
|
314
|
-
const packageJson = (0, package_tree_1.findPackageJson)(this.context.root, packageName);
|
|
315
|
-
if (packageJson) {
|
|
316
|
-
packagePath = path.dirname(packageJson);
|
|
317
|
-
packageNode = await (0, package_tree_1.readPackageJson)(packageJson);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
if (!packageNode || !packagePath) {
|
|
321
|
-
this.logger.error('Package is not installed.');
|
|
322
|
-
return 1;
|
|
323
|
-
}
|
|
324
|
-
const updateMetadata = packageNode['ng-update'];
|
|
325
|
-
let migrations = updateMetadata === null || updateMetadata === void 0 ? void 0 : updateMetadata.migrations;
|
|
326
|
-
if (migrations === undefined) {
|
|
327
|
-
this.logger.error('Package does not provide migrations.');
|
|
328
|
-
return 1;
|
|
329
|
-
}
|
|
330
|
-
else if (typeof migrations !== 'string') {
|
|
331
|
-
this.logger.error('Package contains a malformed migrations field.');
|
|
332
|
-
return 1;
|
|
333
|
-
}
|
|
334
|
-
else if (path.posix.isAbsolute(migrations) || path.win32.isAbsolute(migrations)) {
|
|
335
|
-
this.logger.error('Package contains an invalid migrations field. Absolute paths are not permitted.');
|
|
336
|
-
return 1;
|
|
337
|
-
}
|
|
338
|
-
// Normalize slashes
|
|
339
|
-
migrations = migrations.replace(/\\/g, '/');
|
|
340
|
-
if (migrations.startsWith('../')) {
|
|
341
|
-
this.logger.error('Package contains an invalid migrations field. Paths outside the package root are not permitted.');
|
|
342
|
-
return 1;
|
|
343
|
-
}
|
|
344
|
-
// Check if it is a package-local location
|
|
345
|
-
const localMigrations = path.join(packagePath, migrations);
|
|
346
|
-
if (fs.existsSync(localMigrations)) {
|
|
347
|
-
migrations = localMigrations;
|
|
358
|
+
else if (path.posix.isAbsolute(migrations) || path.win32.isAbsolute(migrations)) {
|
|
359
|
+
logger.error('Package contains an invalid migrations field. Absolute paths are not permitted.');
|
|
360
|
+
return 1;
|
|
361
|
+
}
|
|
362
|
+
// Normalize slashes
|
|
363
|
+
migrations = migrations.replace(/\\/g, '/');
|
|
364
|
+
if (migrations.startsWith('../')) {
|
|
365
|
+
logger.error('Package contains an invalid migrations field. Paths outside the package root are not permitted.');
|
|
366
|
+
return 1;
|
|
367
|
+
}
|
|
368
|
+
// Check if it is a package-local location
|
|
369
|
+
const localMigrations = path.join(packagePath, migrations);
|
|
370
|
+
if ((0, fs_1.existsSync)(localMigrations)) {
|
|
371
|
+
migrations = localMigrations;
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
// Try to resolve from package location.
|
|
375
|
+
// This avoids issues with package hoisting.
|
|
376
|
+
try {
|
|
377
|
+
migrations = require.resolve(migrations, { paths: [packagePath] });
|
|
348
378
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
try {
|
|
353
|
-
migrations = require.resolve(migrations, { paths: [packagePath] });
|
|
354
|
-
}
|
|
355
|
-
catch (e) {
|
|
356
|
-
if (e.code === 'MODULE_NOT_FOUND') {
|
|
357
|
-
this.logger.error('Migrations for package were not found.');
|
|
358
|
-
}
|
|
359
|
-
else {
|
|
360
|
-
this.logger.error(`Unable to resolve migrations for package. [${e.message}]`);
|
|
361
|
-
}
|
|
362
|
-
return 1;
|
|
379
|
+
catch (e) {
|
|
380
|
+
if (e.code === 'MODULE_NOT_FOUND') {
|
|
381
|
+
logger.error('Migrations for package were not found.');
|
|
363
382
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
if (typeof options.migrateOnly == 'string') {
|
|
367
|
-
result = await this.executeMigration(packageName, migrations, options.migrateOnly, options.createCommits);
|
|
368
|
-
}
|
|
369
|
-
else {
|
|
370
|
-
const from = coerceVersionNumber(options.from);
|
|
371
|
-
if (!from) {
|
|
372
|
-
this.logger.error(`"from" value [${options.from}] is not a valid version.`);
|
|
373
|
-
return 1;
|
|
383
|
+
else {
|
|
384
|
+
logger.error(`Unable to resolve migrations for package. [${e.message}]`);
|
|
374
385
|
}
|
|
375
|
-
|
|
386
|
+
return 1;
|
|
376
387
|
}
|
|
377
|
-
return result ? 0 : 1;
|
|
378
388
|
}
|
|
389
|
+
if (options.name) {
|
|
390
|
+
return this.executeMigration(workflow, packageName, migrations, options.name, options.createCommits);
|
|
391
|
+
}
|
|
392
|
+
const from = coerceVersionNumber(options.from);
|
|
393
|
+
if (!from) {
|
|
394
|
+
logger.error(`"from" value [${options.from}] is not a valid version.`);
|
|
395
|
+
return 1;
|
|
396
|
+
}
|
|
397
|
+
return this.executeMigrations(workflow, packageName, migrations, from, options.to || packageNode.version, options.createCommits);
|
|
398
|
+
}
|
|
399
|
+
// eslint-disable-next-line max-lines-per-function
|
|
400
|
+
async updatePackagesAndMigrate(workflow, rootDependencies, options, packages) {
|
|
401
|
+
var _a;
|
|
402
|
+
const { logger } = this.context;
|
|
403
|
+
const logVerbose = (message) => {
|
|
404
|
+
if (options.verbose) {
|
|
405
|
+
logger.info(message);
|
|
406
|
+
}
|
|
407
|
+
};
|
|
379
408
|
const requests = [];
|
|
380
409
|
// Validate packages actually are part of the workspace
|
|
381
410
|
for (const pkg of packages) {
|
|
382
411
|
const node = rootDependencies.get(pkg.name);
|
|
383
412
|
if (!(node === null || node === void 0 ? void 0 : node.package)) {
|
|
384
|
-
|
|
413
|
+
logger.error(`Package '${pkg.name}' is not a dependency.`);
|
|
385
414
|
return 1;
|
|
386
415
|
}
|
|
387
416
|
// If a specific version is requested and matches the installed version, skip.
|
|
388
417
|
if (pkg.type === 'version' && node.package.version === pkg.fetchSpec) {
|
|
389
|
-
|
|
418
|
+
logger.info(`Package '${pkg.name}' is already at '${pkg.fetchSpec}'.`);
|
|
390
419
|
continue;
|
|
391
420
|
}
|
|
392
421
|
requests.push({ identifier: pkg, node });
|
|
@@ -394,20 +423,20 @@ class UpdateCommand extends command_1.Command {
|
|
|
394
423
|
if (requests.length === 0) {
|
|
395
424
|
return 0;
|
|
396
425
|
}
|
|
426
|
+
logger.info('Fetching dependency metadata from registry...');
|
|
397
427
|
const packagesToUpdate = [];
|
|
398
|
-
this.logger.info('Fetching dependency metadata from registry...');
|
|
399
428
|
for (const { identifier: requestIdentifier, node } of requests) {
|
|
400
429
|
const packageName = requestIdentifier.name;
|
|
401
430
|
let metadata;
|
|
402
431
|
try {
|
|
403
432
|
// Metadata requests are internally cached; multiple requests for same name
|
|
404
433
|
// does not result in additional network traffic
|
|
405
|
-
metadata = await (0, package_metadata_1.fetchPackageMetadata)(packageName,
|
|
434
|
+
metadata = await (0, package_metadata_1.fetchPackageMetadata)(packageName, logger, {
|
|
406
435
|
verbose: options.verbose,
|
|
407
436
|
});
|
|
408
437
|
}
|
|
409
438
|
catch (e) {
|
|
410
|
-
|
|
439
|
+
logger.error(`Error fetching metadata for '${packageName}': ` + e.message);
|
|
411
440
|
return 1;
|
|
412
441
|
}
|
|
413
442
|
// Try to find a package version based on the user requested package specifier
|
|
@@ -442,11 +471,11 @@ class UpdateCommand extends command_1.Command {
|
|
|
442
471
|
}
|
|
443
472
|
}
|
|
444
473
|
if (!manifest) {
|
|
445
|
-
|
|
474
|
+
logger.error(`Package specified by '${requestIdentifier.raw}' does not exist within the registry.`);
|
|
446
475
|
return 1;
|
|
447
476
|
}
|
|
448
477
|
if (manifest.version === ((_a = node.package) === null || _a === void 0 ? void 0 : _a.version)) {
|
|
449
|
-
|
|
478
|
+
logger.info(`Package '${packageName}' is already up to date.`);
|
|
450
479
|
continue;
|
|
451
480
|
}
|
|
452
481
|
if (node.package && ANGULAR_PACKAGES_REGEXP.test(node.package.name)) {
|
|
@@ -458,12 +487,12 @@ class UpdateCommand extends command_1.Command {
|
|
|
458
487
|
if (currentMajorVersion < 6) {
|
|
459
488
|
// Before version 6, the major versions were not always sequential.
|
|
460
489
|
// Example @angular/core skipped version 3, @angular/cli skipped versions 2-5.
|
|
461
|
-
|
|
490
|
+
logger.error(`Updating multiple major versions of '${name}' at once is not supported. Please migrate each major version individually.\n` +
|
|
462
491
|
`For more information about the update process, see https://update.angular.io/.`);
|
|
463
492
|
}
|
|
464
493
|
else {
|
|
465
494
|
const nextMajorVersionFromCurrent = currentMajorVersion + 1;
|
|
466
|
-
|
|
495
|
+
logger.error(`Updating multiple major versions of '${name}' at once is not supported. Please migrate each major version individually.\n` +
|
|
467
496
|
`Run 'ng update ${name}@${nextMajorVersionFromCurrent}' in your workspace directory ` +
|
|
468
497
|
`to update to latest '${nextMajorVersionFromCurrent}.x' version of '${name}'.\n\n` +
|
|
469
498
|
`For more information about the update process, see https://update.angular.io/?v=${currentMajorVersion}.0-${nextMajorVersionFromCurrent}.0`);
|
|
@@ -476,42 +505,29 @@ class UpdateCommand extends command_1.Command {
|
|
|
476
505
|
if (packagesToUpdate.length === 0) {
|
|
477
506
|
return 0;
|
|
478
507
|
}
|
|
479
|
-
const { success } = await this.executeSchematic(UPDATE_SCHEMATIC_COLLECTION, 'update', {
|
|
480
|
-
verbose: options.verbose
|
|
481
|
-
force: options.force
|
|
482
|
-
next:
|
|
483
|
-
packageManager: this.packageManager,
|
|
508
|
+
const { success } = await this.executeSchematic(workflow, UPDATE_SCHEMATIC_COLLECTION, 'update', {
|
|
509
|
+
verbose: options.verbose,
|
|
510
|
+
force: options.force,
|
|
511
|
+
next: options.next,
|
|
512
|
+
packageManager: this.context.packageManager,
|
|
484
513
|
packages: packagesToUpdate,
|
|
485
514
|
});
|
|
486
515
|
if (success) {
|
|
487
516
|
try {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
await rm(path.join(this.context.root, 'node_modules'), {
|
|
494
|
-
force: true,
|
|
495
|
-
recursive: true,
|
|
496
|
-
maxRetries: 3,
|
|
497
|
-
});
|
|
498
|
-
}
|
|
499
|
-
else {
|
|
500
|
-
await rmdir(path.join(this.context.root, 'node_modules'), {
|
|
501
|
-
recursive: true,
|
|
502
|
-
maxRetries: 3,
|
|
503
|
-
});
|
|
504
|
-
}
|
|
517
|
+
await fs_1.promises.rm(path.join(this.context.root, 'node_modules'), {
|
|
518
|
+
force: true,
|
|
519
|
+
recursive: true,
|
|
520
|
+
maxRetries: 3,
|
|
521
|
+
});
|
|
505
522
|
}
|
|
506
523
|
catch { }
|
|
507
|
-
const result = await (0, install_package_1.installAllPackages)(this.packageManager, options.force ? ['--force'] : [], this.context.root);
|
|
524
|
+
const result = await (0, install_package_1.installAllPackages)(this.context.packageManager, options.force ? ['--force'] : [], this.context.root);
|
|
508
525
|
if (result !== 0) {
|
|
509
526
|
return result;
|
|
510
527
|
}
|
|
511
528
|
}
|
|
512
529
|
if (success && options.createCommits) {
|
|
513
|
-
|
|
514
|
-
if (!committed) {
|
|
530
|
+
if (!this.commit(`Angular CLI update for packages - ${packagesToUpdate.join(', ')}`)) {
|
|
515
531
|
return 1;
|
|
516
532
|
}
|
|
517
533
|
}
|
|
@@ -545,18 +561,18 @@ class UpdateCommand extends command_1.Command {
|
|
|
545
561
|
catch (e) {
|
|
546
562
|
if (e.code === 'MODULE_NOT_FOUND') {
|
|
547
563
|
logVerbose(e.toString());
|
|
548
|
-
|
|
564
|
+
logger.error(`Migrations for package (${migration.package}) were not found.` +
|
|
549
565
|
' The package could not be found in the workspace.');
|
|
550
566
|
}
|
|
551
567
|
else {
|
|
552
|
-
|
|
568
|
+
logger.error(`Unable to resolve migrations for package (${migration.package}). [${e.message}]`);
|
|
553
569
|
}
|
|
554
570
|
return 1;
|
|
555
571
|
}
|
|
556
572
|
let migrations;
|
|
557
573
|
// Check if it is a package-local location
|
|
558
574
|
const localMigrations = path.join(packagePath, migration.collection);
|
|
559
|
-
if (
|
|
575
|
+
if ((0, fs_1.existsSync)(localMigrations)) {
|
|
560
576
|
migrations = localMigrations;
|
|
561
577
|
}
|
|
562
578
|
else {
|
|
@@ -567,15 +583,15 @@ class UpdateCommand extends command_1.Command {
|
|
|
567
583
|
}
|
|
568
584
|
catch (e) {
|
|
569
585
|
if (e.code === 'MODULE_NOT_FOUND') {
|
|
570
|
-
|
|
586
|
+
logger.error(`Migrations for package (${migration.package}) were not found.`);
|
|
571
587
|
}
|
|
572
588
|
else {
|
|
573
|
-
|
|
589
|
+
logger.error(`Unable to resolve migrations for package (${migration.package}). [${e.message}]`);
|
|
574
590
|
}
|
|
575
591
|
return 1;
|
|
576
592
|
}
|
|
577
593
|
}
|
|
578
|
-
const result = await this.executeMigrations(migration.package, migrations, migration.from, migration.to, options.createCommits);
|
|
594
|
+
const result = await this.executeMigrations(workflow, migration.package, migrations, migration.from, migration.to, options.createCommits);
|
|
579
595
|
if (!result) {
|
|
580
596
|
return 0;
|
|
581
597
|
}
|
|
@@ -587,17 +603,18 @@ class UpdateCommand extends command_1.Command {
|
|
|
587
603
|
* @return Whether or not the commit was successful.
|
|
588
604
|
*/
|
|
589
605
|
commit(message) {
|
|
606
|
+
const { logger } = this.context;
|
|
590
607
|
// Check if a commit is needed.
|
|
591
608
|
let commitNeeded;
|
|
592
609
|
try {
|
|
593
610
|
commitNeeded = hasChangesToCommit();
|
|
594
611
|
}
|
|
595
612
|
catch (err) {
|
|
596
|
-
|
|
613
|
+
logger.error(` Failed to read Git tree:\n${err.stderr}`);
|
|
597
614
|
return false;
|
|
598
615
|
}
|
|
599
616
|
if (!commitNeeded) {
|
|
600
|
-
|
|
617
|
+
logger.info(' No changes to commit after migration.');
|
|
601
618
|
return true;
|
|
602
619
|
}
|
|
603
620
|
// Commit changes and abort on error.
|
|
@@ -605,20 +622,20 @@ class UpdateCommand extends command_1.Command {
|
|
|
605
622
|
createCommit(message);
|
|
606
623
|
}
|
|
607
624
|
catch (err) {
|
|
608
|
-
|
|
625
|
+
logger.error(`Failed to commit update (${message}):\n${err.stderr}`);
|
|
609
626
|
return false;
|
|
610
627
|
}
|
|
611
628
|
// Notify user of the commit.
|
|
612
629
|
const hash = findCurrentGitSha();
|
|
613
630
|
const shortMessage = message.split('\n')[0];
|
|
614
631
|
if (hash) {
|
|
615
|
-
|
|
632
|
+
logger.info(` Committed migration step (${getShortHash(hash)}): ${shortMessage}.`);
|
|
616
633
|
}
|
|
617
634
|
else {
|
|
618
635
|
// Commit was successful, but reading the hash was not. Something weird happened,
|
|
619
636
|
// but nothing that would stop the update. Just log the weirdness and continue.
|
|
620
|
-
|
|
621
|
-
|
|
637
|
+
logger.info(` Committed migration step: ${shortMessage}.`);
|
|
638
|
+
logger.warn(' Failed to look up hash of most recent commit, continuing anyways.');
|
|
622
639
|
}
|
|
623
640
|
return true;
|
|
624
641
|
}
|
|
@@ -648,9 +665,9 @@ class UpdateCommand extends command_1.Command {
|
|
|
648
665
|
* @returns the version to install or null when there is no update to install.
|
|
649
666
|
*/
|
|
650
667
|
async checkCLIVersion(packagesToUpdate, verbose = false, next = false) {
|
|
651
|
-
const { version } = await (0, package_metadata_1.fetchPackageManifest)(`@angular/cli@${this.getCLIUpdateRunnerVersion(packagesToUpdate, next)}`, this.logger, {
|
|
668
|
+
const { version } = await (0, package_metadata_1.fetchPackageManifest)(`@angular/cli@${this.getCLIUpdateRunnerVersion(typeof packagesToUpdate === 'string' ? [packagesToUpdate] : packagesToUpdate, next)}`, this.context.logger, {
|
|
652
669
|
verbose,
|
|
653
|
-
usingYarn: this.packageManager === workspace_schema_1.PackageManager.Yarn,
|
|
670
|
+
usingYarn: this.context.packageManager === workspace_schema_1.PackageManager.Yarn,
|
|
654
671
|
});
|
|
655
672
|
return version_1.VERSION.full === version ? null : version;
|
|
656
673
|
}
|
|
@@ -678,15 +695,15 @@ class UpdateCommand extends command_1.Command {
|
|
|
678
695
|
return version_1.VERSION.major;
|
|
679
696
|
}
|
|
680
697
|
}
|
|
681
|
-
exports.
|
|
698
|
+
exports.UpdateCommandModule = UpdateCommandModule;
|
|
699
|
+
UpdateCommandModule.scope = command_module_1.CommandScope.In;
|
|
682
700
|
/**
|
|
683
701
|
* @return Whether or not the working directory has Git changes to commit.
|
|
684
702
|
*/
|
|
685
703
|
function hasChangesToCommit() {
|
|
686
704
|
// List all modified files not covered by .gitignore.
|
|
687
|
-
const files = (0, child_process_1.execSync)('git ls-files -m -d -o --exclude-standard').toString();
|
|
688
705
|
// If any files are returned, then there must be something to commit.
|
|
689
|
-
return files !== '';
|
|
706
|
+
return (0, child_process_1.execSync)('git ls-files -m -d -o --exclude-standard').toString() !== '';
|
|
690
707
|
}
|
|
691
708
|
/**
|
|
692
709
|
* Precondition: Must have pending changes to commit, they do not need to be staged.
|
|
@@ -704,8 +721,7 @@ function createCommit(message) {
|
|
|
704
721
|
*/
|
|
705
722
|
function findCurrentGitSha() {
|
|
706
723
|
try {
|
|
707
|
-
|
|
708
|
-
return hash.trim();
|
|
724
|
+
return (0, child_process_1.execSync)('git rev-parse HEAD', { encoding: 'utf8', stdio: 'pipe' }).trim();
|
|
709
725
|
}
|
|
710
726
|
catch {
|
|
711
727
|
return null;
|
|
@@ -715,23 +731,24 @@ function getShortHash(commitHash) {
|
|
|
715
731
|
return commitHash.slice(0, 9);
|
|
716
732
|
}
|
|
717
733
|
function coerceVersionNumber(version) {
|
|
734
|
+
var _a;
|
|
718
735
|
if (!version) {
|
|
719
|
-
return
|
|
736
|
+
return undefined;
|
|
720
737
|
}
|
|
721
|
-
if (
|
|
738
|
+
if (!/^\d{1,30}\.\d{1,30}\.\d{1,30}/.test(version)) {
|
|
722
739
|
const match = version.match(/^\d{1,30}(\.\d{1,30})*/);
|
|
723
740
|
if (!match) {
|
|
724
|
-
return
|
|
741
|
+
return undefined;
|
|
725
742
|
}
|
|
726
743
|
if (!match[1]) {
|
|
727
|
-
version = version.
|
|
744
|
+
version = version.substring(0, match[0].length) + '.0.0' + version.substring(match[0].length);
|
|
728
745
|
}
|
|
729
746
|
else if (!match[2]) {
|
|
730
|
-
version = version.
|
|
747
|
+
version = version.substring(0, match[0].length) + '.0' + version.substring(match[0].length);
|
|
731
748
|
}
|
|
732
749
|
else {
|
|
733
|
-
return
|
|
750
|
+
return undefined;
|
|
734
751
|
}
|
|
735
752
|
}
|
|
736
|
-
return semver.valid(version);
|
|
753
|
+
return (_a = semver.valid(version)) !== null && _a !== void 0 ? _a : undefined;
|
|
737
754
|
}
|