@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
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
import { Argv } from 'yargs';
|
|
9
|
+
import { CommandContext, CommandModule, CommandModuleImplementation } from '../command-module';
|
|
10
|
+
export declare const demandCommandFailureMessage = "You need to specify a command before moving on. Use '--help' to view the available commands.";
|
|
11
|
+
export declare function addCommandModuleToYargs<T, U extends Partial<CommandModuleImplementation> & {
|
|
12
|
+
new (context: CommandContext): Partial<CommandModuleImplementation> & CommandModule;
|
|
13
|
+
}>(localYargs: Argv<T>, commandModule: U, context: CommandContext): Argv<T>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.addCommandModuleToYargs = exports.demandCommandFailureMessage = void 0;
|
|
11
|
+
exports.demandCommandFailureMessage = `You need to specify a command before moving on. Use '--help' to view the available commands.`;
|
|
12
|
+
function addCommandModuleToYargs(localYargs, commandModule, context) {
|
|
13
|
+
const cmd = new commandModule(context);
|
|
14
|
+
const describe = context.args.options.jsonHelp ? cmd.fullDescribe : cmd.describe;
|
|
15
|
+
return localYargs.command({
|
|
16
|
+
command: cmd.command,
|
|
17
|
+
aliases: cmd.aliases,
|
|
18
|
+
describe:
|
|
19
|
+
// We cannot add custom fields in help, such as long command description which is used in AIO.
|
|
20
|
+
// Therefore, we get around this by adding a complex object as a string which we later parse when generating the help files.
|
|
21
|
+
typeof describe === 'object' ? JSON.stringify(describe) : describe,
|
|
22
|
+
deprecated: cmd.deprecated,
|
|
23
|
+
builder: (argv) => cmd.builder(argv),
|
|
24
|
+
handler: (args) => cmd.handler(args),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
exports.addCommandModuleToYargs = addCommandModuleToYargs;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
interface JsonHelpOption {
|
|
9
|
+
name: string;
|
|
10
|
+
type?: string;
|
|
11
|
+
deprecated: boolean | string;
|
|
12
|
+
aliases?: string[];
|
|
13
|
+
default?: string;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
positional?: number;
|
|
16
|
+
enum?: string[];
|
|
17
|
+
description?: string;
|
|
18
|
+
}
|
|
19
|
+
interface JsonHelpDescription {
|
|
20
|
+
shortDescription?: string;
|
|
21
|
+
longDescription?: string;
|
|
22
|
+
longDescriptionRelativePath?: string;
|
|
23
|
+
}
|
|
24
|
+
interface JsonHelpSubcommand extends JsonHelpDescription {
|
|
25
|
+
name: string;
|
|
26
|
+
aliases: string[];
|
|
27
|
+
deprecated: string | boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface JsonHelp extends JsonHelpDescription {
|
|
30
|
+
name: string;
|
|
31
|
+
command: string;
|
|
32
|
+
options: JsonHelpOption[];
|
|
33
|
+
subcommands?: JsonHelpSubcommand[];
|
|
34
|
+
}
|
|
35
|
+
export declare function jsonHelpUsage(): string;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.jsonHelpUsage = void 0;
|
|
14
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
15
|
+
const yargsDefaultCommandRegExp = /^\$0|\*/;
|
|
16
|
+
function jsonHelpUsage() {
|
|
17
|
+
var _a, _b, _c, _d, _e;
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
+
const localYargs = yargs_1.default;
|
|
20
|
+
const { deprecatedOptions, alias: aliases, array, string, boolean, number, choices, demandedOptions, default: defaultVal, hiddenOptions = [], } = localYargs.getOptions();
|
|
21
|
+
const internalMethods = localYargs.getInternalMethods();
|
|
22
|
+
const usageInstance = internalMethods.getUsageInstance();
|
|
23
|
+
const context = internalMethods.getContext();
|
|
24
|
+
const descriptions = usageInstance.getDescriptions();
|
|
25
|
+
const groups = localYargs.getGroups();
|
|
26
|
+
const positional = groups[usageInstance.getPositionalGroupName()];
|
|
27
|
+
const hidden = new Set(hiddenOptions);
|
|
28
|
+
const normalizeOptions = [];
|
|
29
|
+
const allAliases = new Set([...Object.values(aliases).flat()]);
|
|
30
|
+
for (const [names, type] of [
|
|
31
|
+
[array, 'array'],
|
|
32
|
+
[string, 'string'],
|
|
33
|
+
[boolean, 'boolean'],
|
|
34
|
+
[number, 'number'],
|
|
35
|
+
]) {
|
|
36
|
+
for (const name of names) {
|
|
37
|
+
if (allAliases.has(name) || hidden.has(name)) {
|
|
38
|
+
// Ignore hidden, aliases and already visited option.
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const positionalIndex = (_a = positional === null || positional === void 0 ? void 0 : positional.indexOf(name)) !== null && _a !== void 0 ? _a : -1;
|
|
42
|
+
const alias = aliases[name];
|
|
43
|
+
normalizeOptions.push({
|
|
44
|
+
name,
|
|
45
|
+
type,
|
|
46
|
+
deprecated: deprecatedOptions[name],
|
|
47
|
+
aliases: (alias === null || alias === void 0 ? void 0 : alias.length) > 0 ? alias : undefined,
|
|
48
|
+
default: defaultVal[name],
|
|
49
|
+
required: demandedOptions[name],
|
|
50
|
+
enum: choices[name],
|
|
51
|
+
description: (_b = descriptions[name]) === null || _b === void 0 ? void 0 : _b.replace('__yargsString__:', ''),
|
|
52
|
+
positional: positionalIndex >= 0 ? positionalIndex : undefined,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// https://github.com/yargs/yargs/blob/00e4ebbe3acd438e73fdb101e75b4f879eb6d345/lib/usage.ts#L124
|
|
57
|
+
const subcommands = usageInstance.getCommands()
|
|
58
|
+
.map(([name, rawDescription, isDefault, aliases, deprecated]) => ({
|
|
59
|
+
name: name.split(' ', 1)[0].replace(yargsDefaultCommandRegExp, ''),
|
|
60
|
+
command: name.replace(yargsDefaultCommandRegExp, ''),
|
|
61
|
+
default: isDefault || undefined,
|
|
62
|
+
...parseDescription(rawDescription),
|
|
63
|
+
aliases,
|
|
64
|
+
deprecated,
|
|
65
|
+
}))
|
|
66
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
67
|
+
const [command, rawDescription] = (_c = usageInstance.getUsage()[0]) !== null && _c !== void 0 ? _c : [];
|
|
68
|
+
const defaultSubCommand = (_e = (_d = subcommands.find((x) => x.default)) === null || _d === void 0 ? void 0 : _d.command) !== null && _e !== void 0 ? _e : '';
|
|
69
|
+
const otherSubcommands = subcommands.filter((s) => !s.default);
|
|
70
|
+
const output = {
|
|
71
|
+
name: [...context.commands].pop(),
|
|
72
|
+
command: `${command === null || command === void 0 ? void 0 : command.replace(yargsDefaultCommandRegExp, localYargs['$0'])}${defaultSubCommand}`,
|
|
73
|
+
...parseDescription(rawDescription),
|
|
74
|
+
options: normalizeOptions.sort((a, b) => a.name.localeCompare(b.name)),
|
|
75
|
+
subcommands: otherSubcommands.length ? otherSubcommands : undefined,
|
|
76
|
+
};
|
|
77
|
+
return JSON.stringify(output, undefined, 2);
|
|
78
|
+
}
|
|
79
|
+
exports.jsonHelpUsage = jsonHelpUsage;
|
|
80
|
+
function parseDescription(rawDescription) {
|
|
81
|
+
try {
|
|
82
|
+
const { longDescription, describe: shortDescription, longDescriptionRelativePath, } = JSON.parse(rawDescription);
|
|
83
|
+
return {
|
|
84
|
+
shortDescription,
|
|
85
|
+
longDescriptionRelativePath,
|
|
86
|
+
longDescription,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return {
|
|
91
|
+
shortDescription: rawDescription,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
import { json } from '@angular-devkit/core';
|
|
9
|
+
import yargs from 'yargs';
|
|
10
|
+
/**
|
|
11
|
+
* An option description.
|
|
12
|
+
*/
|
|
13
|
+
export interface Option extends yargs.Options {
|
|
14
|
+
/**
|
|
15
|
+
* The name of the option.
|
|
16
|
+
*/
|
|
17
|
+
name: string;
|
|
18
|
+
/**
|
|
19
|
+
* Whether this option is required or not.
|
|
20
|
+
*/
|
|
21
|
+
required?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Format field of this option.
|
|
24
|
+
*/
|
|
25
|
+
format?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Whether this option should be hidden from the help output. It will still show up in JSON help.
|
|
28
|
+
*/
|
|
29
|
+
hidden?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* If this option can be used as an argument, the position of the argument. Otherwise omitted.
|
|
32
|
+
*/
|
|
33
|
+
positional?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Whether or not to report this option to the Angular Team, and which custom field to use.
|
|
36
|
+
* If this is falsey, do not report this option.
|
|
37
|
+
*/
|
|
38
|
+
userAnalytics?: number;
|
|
39
|
+
}
|
|
40
|
+
export declare function parseJsonSchemaToOptions(registry: json.schema.SchemaRegistry, schema: json.JsonObject, interactive?: boolean): Promise<Option[]>;
|
|
@@ -7,102 +7,9 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.parseJsonSchemaToOptions =
|
|
10
|
+
exports.parseJsonSchemaToOptions = void 0;
|
|
11
11
|
const core_1 = require("@angular-devkit/core");
|
|
12
|
-
|
|
13
|
-
const fs_1 = require("fs");
|
|
14
|
-
const path_1 = require("path");
|
|
15
|
-
const interface_1 = require("../models/interface");
|
|
16
|
-
class CommandJsonPathException extends core_1.BaseException {
|
|
17
|
-
constructor(path, name) {
|
|
18
|
-
super(`File ${path} was not found while constructing the subcommand ${name}.`);
|
|
19
|
-
this.path = path;
|
|
20
|
-
this.name = name;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.CommandJsonPathException = CommandJsonPathException;
|
|
24
|
-
function _getEnumFromValue(value, enumeration, defaultValue) {
|
|
25
|
-
if (typeof value !== 'string') {
|
|
26
|
-
return defaultValue;
|
|
27
|
-
}
|
|
28
|
-
if (Object.values(enumeration).includes(value)) {
|
|
29
|
-
return value;
|
|
30
|
-
}
|
|
31
|
-
return defaultValue;
|
|
32
|
-
}
|
|
33
|
-
async function parseJsonSchemaToSubCommandDescription(name, jsonPath, registry, schema) {
|
|
34
|
-
const options = await parseJsonSchemaToOptions(registry, schema);
|
|
35
|
-
const aliases = [];
|
|
36
|
-
if (core_1.json.isJsonArray(schema.$aliases)) {
|
|
37
|
-
schema.$aliases.forEach((value) => {
|
|
38
|
-
if (typeof value == 'string') {
|
|
39
|
-
aliases.push(value);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
if (core_1.json.isJsonArray(schema.aliases)) {
|
|
44
|
-
schema.aliases.forEach((value) => {
|
|
45
|
-
if (typeof value == 'string') {
|
|
46
|
-
aliases.push(value);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
if (typeof schema.alias == 'string') {
|
|
51
|
-
aliases.push(schema.alias);
|
|
52
|
-
}
|
|
53
|
-
let longDescription = '';
|
|
54
|
-
if (typeof schema.$longDescription == 'string' && schema.$longDescription) {
|
|
55
|
-
const ldPath = (0, path_1.resolve)((0, path_1.dirname)(jsonPath), schema.$longDescription);
|
|
56
|
-
try {
|
|
57
|
-
longDescription = (0, fs_1.readFileSync)(ldPath, 'utf-8');
|
|
58
|
-
}
|
|
59
|
-
catch (e) {
|
|
60
|
-
throw new CommandJsonPathException(ldPath, name);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
let usageNotes = '';
|
|
64
|
-
if (typeof schema.$usageNotes == 'string' && schema.$usageNotes) {
|
|
65
|
-
const unPath = (0, path_1.resolve)((0, path_1.dirname)(jsonPath), schema.$usageNotes);
|
|
66
|
-
try {
|
|
67
|
-
usageNotes = (0, fs_1.readFileSync)(unPath, 'utf-8');
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
70
|
-
throw new CommandJsonPathException(unPath, name);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
const description = '' + (schema.description === undefined ? '' : schema.description);
|
|
74
|
-
return {
|
|
75
|
-
name,
|
|
76
|
-
description,
|
|
77
|
-
...(longDescription ? { longDescription } : {}),
|
|
78
|
-
...(usageNotes ? { usageNotes } : {}),
|
|
79
|
-
options,
|
|
80
|
-
aliases,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
exports.parseJsonSchemaToSubCommandDescription = parseJsonSchemaToSubCommandDescription;
|
|
84
|
-
async function parseJsonSchemaToCommandDescription(name, jsonPath, registry, schema) {
|
|
85
|
-
const subcommand = await parseJsonSchemaToSubCommandDescription(name, jsonPath, registry, schema);
|
|
86
|
-
// Before doing any work, let's validate the implementation.
|
|
87
|
-
if (typeof schema.$impl != 'string') {
|
|
88
|
-
throw new Error(`Command ${name} has an invalid implementation.`);
|
|
89
|
-
}
|
|
90
|
-
const ref = new tools_1.ExportStringRef(schema.$impl, (0, path_1.dirname)(jsonPath));
|
|
91
|
-
const impl = ref.ref;
|
|
92
|
-
if (impl === undefined || typeof impl !== 'function') {
|
|
93
|
-
throw new Error(`Command ${name} has an invalid implementation.`);
|
|
94
|
-
}
|
|
95
|
-
const scope = _getEnumFromValue(schema.$scope, interface_1.CommandScope, interface_1.CommandScope.Default);
|
|
96
|
-
const hidden = !!schema.$hidden;
|
|
97
|
-
return {
|
|
98
|
-
...subcommand,
|
|
99
|
-
scope,
|
|
100
|
-
hidden,
|
|
101
|
-
impl,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
exports.parseJsonSchemaToCommandDescription = parseJsonSchemaToCommandDescription;
|
|
105
|
-
async function parseJsonSchemaToOptions(registry, schema) {
|
|
12
|
+
async function parseJsonSchemaToOptions(registry, schema, interactive = true) {
|
|
106
13
|
const options = [];
|
|
107
14
|
function visitor(current, pointer, parentSchema) {
|
|
108
15
|
if (!parentSchema) {
|
|
@@ -131,8 +38,7 @@ async function parseJsonSchemaToOptions(registry, schema) {
|
|
|
131
38
|
throw new Error('Cannot find type of schema.');
|
|
132
39
|
}
|
|
133
40
|
// We only support number, string or boolean (or array of those), so remove everything else.
|
|
134
|
-
const types = [...typeSet]
|
|
135
|
-
.filter((x) => {
|
|
41
|
+
const types = [...typeSet].filter((x) => {
|
|
136
42
|
switch (x) {
|
|
137
43
|
case 'boolean':
|
|
138
44
|
case 'number':
|
|
@@ -149,8 +55,7 @@ async function parseJsonSchemaToOptions(registry, schema) {
|
|
|
149
55
|
default:
|
|
150
56
|
return false;
|
|
151
57
|
}
|
|
152
|
-
})
|
|
153
|
-
.map((x) => _getEnumFromValue(x, interface_1.OptionType, interface_1.OptionType.String));
|
|
58
|
+
});
|
|
154
59
|
if (types.length == 0) {
|
|
155
60
|
// This means it's not usable on the command line. e.g. an Object.
|
|
156
61
|
return;
|
|
@@ -190,10 +95,11 @@ async function parseJsonSchemaToOptions(registry, schema) {
|
|
|
190
95
|
const $default = current.$default;
|
|
191
96
|
const $defaultIndex = core_1.json.isJsonObject($default) && $default['$source'] == 'argv' ? $default['index'] : undefined;
|
|
192
97
|
const positional = typeof $defaultIndex == 'number' ? $defaultIndex : undefined;
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
98
|
+
let required = core_1.json.isJsonArray(schema.required) ? schema.required.includes(name) : false;
|
|
99
|
+
if (required && interactive && current['x-prompt']) {
|
|
100
|
+
required = false;
|
|
101
|
+
}
|
|
102
|
+
const alias = core_1.json.isJsonArray(current.aliases)
|
|
197
103
|
? [...current.aliases].map((x) => '' + x)
|
|
198
104
|
: current.alias
|
|
199
105
|
? ['' + current.alias]
|
|
@@ -209,37 +115,30 @@ async function parseJsonSchemaToOptions(registry, schema) {
|
|
|
209
115
|
const option = {
|
|
210
116
|
name,
|
|
211
117
|
description: '' + (current.description === undefined ? '' : current.description),
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
118
|
+
type,
|
|
119
|
+
default: defaultValue,
|
|
120
|
+
choices: enumValues.length ? enumValues : undefined,
|
|
215
121
|
required,
|
|
216
|
-
|
|
217
|
-
|
|
122
|
+
alias,
|
|
123
|
+
format,
|
|
218
124
|
hidden,
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
125
|
+
userAnalytics,
|
|
126
|
+
deprecated,
|
|
127
|
+
positional,
|
|
222
128
|
};
|
|
223
129
|
options.push(option);
|
|
224
130
|
}
|
|
225
131
|
const flattenedSchema = await registry.flatten(schema).toPromise();
|
|
226
132
|
core_1.json.schema.visitJsonSchema(flattenedSchema, visitor);
|
|
227
|
-
// Sort by positional.
|
|
133
|
+
// Sort by positional and name.
|
|
228
134
|
return options.sort((a, b) => {
|
|
229
135
|
if (a.positional) {
|
|
230
|
-
|
|
231
|
-
return a.positional - b.positional;
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
return 1;
|
|
235
|
-
}
|
|
136
|
+
return b.positional ? a.positional - b.positional : a.name.localeCompare(b.name);
|
|
236
137
|
}
|
|
237
138
|
else if (b.positional) {
|
|
238
139
|
return -1;
|
|
239
140
|
}
|
|
240
|
-
|
|
241
|
-
return 0;
|
|
242
|
-
}
|
|
141
|
+
return a.name.localeCompare(b.name);
|
|
243
142
|
});
|
|
244
143
|
}
|
|
245
144
|
exports.parseJsonSchemaToOptions = parseJsonSchemaToOptions;
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
import { logging } from '@angular-devkit/core';
|
|
9
|
+
import { NodeWorkflow } from '@angular-devkit/schematics/tools';
|
|
10
|
+
export declare function subscribeToWorkflow(workflow: NodeWorkflow, logger: logging.LoggerApi): {
|
|
11
|
+
files: Set<string>;
|
|
12
|
+
error: boolean;
|
|
13
|
+
unsubscribe: () => void;
|
|
14
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.subscribeToWorkflow = void 0;
|
|
11
|
+
const core_1 = require("@angular-devkit/core");
|
|
12
|
+
const color_1 = require("../../utilities/color");
|
|
13
|
+
function subscribeToWorkflow(workflow, logger) {
|
|
14
|
+
const files = new Set();
|
|
15
|
+
let error = false;
|
|
16
|
+
let logs = [];
|
|
17
|
+
const reporterSubscription = workflow.reporter.subscribe((event) => {
|
|
18
|
+
// Strip leading slash to prevent confusion.
|
|
19
|
+
const eventPath = event.path.charAt(0) === '/' ? event.path.substring(1) : event.path;
|
|
20
|
+
switch (event.kind) {
|
|
21
|
+
case 'error':
|
|
22
|
+
error = true;
|
|
23
|
+
const desc = event.description == 'alreadyExist' ? 'already exists' : 'does not exist';
|
|
24
|
+
logger.error(`ERROR! ${eventPath} ${desc}.`);
|
|
25
|
+
break;
|
|
26
|
+
case 'update':
|
|
27
|
+
logs.push(core_1.tags.oneLine `
|
|
28
|
+
${color_1.colors.cyan('UPDATE')} ${eventPath} (${event.content.length} bytes)
|
|
29
|
+
`);
|
|
30
|
+
files.add(eventPath);
|
|
31
|
+
break;
|
|
32
|
+
case 'create':
|
|
33
|
+
logs.push(core_1.tags.oneLine `
|
|
34
|
+
${color_1.colors.green('CREATE')} ${eventPath} (${event.content.length} bytes)
|
|
35
|
+
`);
|
|
36
|
+
files.add(eventPath);
|
|
37
|
+
break;
|
|
38
|
+
case 'delete':
|
|
39
|
+
logs.push(`${color_1.colors.yellow('DELETE')} ${eventPath}`);
|
|
40
|
+
files.add(eventPath);
|
|
41
|
+
break;
|
|
42
|
+
case 'rename':
|
|
43
|
+
const eventToPath = event.to.charAt(0) === '/' ? event.to.substring(1) : event.to;
|
|
44
|
+
logs.push(`${color_1.colors.blue('RENAME')} ${eventPath} => ${eventToPath}`);
|
|
45
|
+
files.add(eventPath);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const lifecycleSubscription = workflow.lifeCycle.subscribe((event) => {
|
|
50
|
+
if (event.kind == 'end' || event.kind == 'post-tasks-start') {
|
|
51
|
+
if (!error) {
|
|
52
|
+
// Output the logging queue, no error happened.
|
|
53
|
+
logs.forEach((log) => logger.info(log));
|
|
54
|
+
}
|
|
55
|
+
logs = [];
|
|
56
|
+
error = false;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return {
|
|
60
|
+
files,
|
|
61
|
+
error,
|
|
62
|
+
unsubscribe: () => {
|
|
63
|
+
reporterSubscription.unsubscribe();
|
|
64
|
+
lifecycleSubscription.unsubscribe();
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
exports.subscribeToWorkflow = subscribeToWorkflow;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
import { Argv } from 'yargs';
|
|
9
|
+
import { CommandModuleImplementation, Options, OtherOptions } from '../../command-builder/command-module';
|
|
10
|
+
import { SchematicsCommandArgs, SchematicsCommandModule } from '../../command-builder/schematics-command-module';
|
|
11
|
+
interface AddCommandArgs extends SchematicsCommandArgs {
|
|
12
|
+
collection: string;
|
|
13
|
+
verbose?: boolean;
|
|
14
|
+
registry?: string;
|
|
15
|
+
'skip-confirmation'?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare class AddCommandModule extends SchematicsCommandModule implements CommandModuleImplementation<AddCommandArgs> {
|
|
18
|
+
command: string;
|
|
19
|
+
describe: string;
|
|
20
|
+
longDescriptionPath: string;
|
|
21
|
+
protected allowPrivateSchematics: boolean;
|
|
22
|
+
private readonly schematicName;
|
|
23
|
+
builder(argv: Argv): Promise<Argv<AddCommandArgs>>;
|
|
24
|
+
run(options: Options<AddCommandArgs> & OtherOptions): Promise<number | void>;
|
|
25
|
+
private isProjectVersionValid;
|
|
26
|
+
reportAnalytics(options: OtherOptions, paths: string[]): Promise<void>;
|
|
27
|
+
private getCollectionName;
|
|
28
|
+
private isPackageInstalled;
|
|
29
|
+
private executeSchematic;
|
|
30
|
+
private findProjectVersion;
|
|
31
|
+
private hasMismatchedPeer;
|
|
32
|
+
}
|
|
33
|
+
export {};
|