@angular/cli 21.0.0-next.0 → 21.0.0-next.10
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/lib/cli/index.js +1 -0
- package/lib/cli/index.js.map +1 -0
- package/lib/code-examples.db +0 -0
- package/lib/config/schema.json +276 -51
- package/lib/config/workspace-schema.d.ts +57 -2
- package/lib/config/workspace-schema.js +23 -2
- package/lib/config/workspace-schema.js.map +1 -0
- package/lib/init.js +1 -0
- package/lib/init.js.map +1 -0
- package/package.json +24 -23
- package/src/analytics/analytics-collector.js +1 -0
- package/src/analytics/analytics-collector.js.map +1 -0
- package/src/analytics/analytics-parameters.js +1 -0
- package/src/analytics/analytics-parameters.js.map +1 -0
- package/src/analytics/analytics.js +1 -0
- package/src/analytics/analytics.js.map +1 -0
- package/src/command-builder/architect-base-command-module.js +1 -0
- package/src/command-builder/architect-base-command-module.js.map +1 -0
- package/src/command-builder/architect-command-module.js +21 -7
- package/src/command-builder/architect-command-module.js.map +1 -0
- package/src/command-builder/command-module.js +1 -0
- package/src/command-builder/command-module.js.map +1 -0
- package/src/command-builder/command-runner.js +2 -2
- package/src/command-builder/command-runner.js.map +1 -0
- package/src/command-builder/schematics-command-module.js +8 -2
- package/src/command-builder/schematics-command-module.js.map +1 -0
- package/src/command-builder/utilities/command.js +1 -0
- package/src/command-builder/utilities/command.js.map +1 -0
- package/src/command-builder/utilities/json-help.js +1 -0
- package/src/command-builder/utilities/json-help.js.map +1 -0
- package/src/command-builder/utilities/json-schema.d.ts +13 -1
- package/src/command-builder/utilities/json-schema.js +180 -96
- package/src/command-builder/utilities/json-schema.js.map +1 -0
- package/src/command-builder/utilities/normalize-options-middleware.js +1 -0
- package/src/command-builder/utilities/normalize-options-middleware.js.map +1 -0
- package/src/command-builder/utilities/schematic-engine-host.js +5 -6
- package/src/command-builder/utilities/schematic-engine-host.js.map +1 -0
- package/src/command-builder/utilities/schematic-workflow.js +1 -0
- package/src/command-builder/utilities/schematic-workflow.js.map +1 -0
- package/src/commands/add/cli.d.ts +2 -1
- package/src/commands/add/cli.js +179 -94
- package/src/commands/add/cli.js.map +1 -0
- package/src/commands/analytics/cli.js +1 -0
- package/src/commands/analytics/cli.js.map +1 -0
- package/src/commands/analytics/info/cli.js +1 -0
- package/src/commands/analytics/info/cli.js.map +1 -0
- package/src/commands/analytics/settings/cli.js +1 -0
- package/src/commands/analytics/settings/cli.js.map +1 -0
- package/src/commands/build/cli.js +1 -0
- package/src/commands/build/cli.js.map +1 -0
- package/src/commands/cache/clean/cli.js +1 -0
- package/src/commands/cache/clean/cli.js.map +1 -0
- package/src/commands/cache/cli.js +1 -0
- package/src/commands/cache/cli.js.map +1 -0
- package/src/commands/cache/info/cli.js +36 -11
- package/src/commands/cache/info/cli.js.map +1 -0
- package/src/commands/cache/settings/cli.js +1 -0
- package/src/commands/cache/settings/cli.js.map +1 -0
- package/src/commands/cache/utilities.js +1 -0
- package/src/commands/cache/utilities.js.map +1 -0
- package/src/commands/command-config.js +1 -0
- package/src/commands/command-config.js.map +1 -0
- package/src/commands/completion/cli.js +1 -0
- package/src/commands/completion/cli.js.map +1 -0
- package/src/commands/config/cli.js +1 -0
- package/src/commands/config/cli.js.map +1 -0
- package/src/commands/deploy/cli.js +1 -0
- package/src/commands/deploy/cli.js.map +1 -0
- package/src/commands/e2e/cli.js +1 -0
- package/src/commands/e2e/cli.js.map +1 -0
- package/src/commands/extract-i18n/cli.js +1 -0
- package/src/commands/extract-i18n/cli.js.map +1 -0
- package/src/commands/generate/cli.js +1 -0
- package/src/commands/generate/cli.js.map +1 -0
- package/src/commands/lint/cli.js +1 -0
- package/src/commands/lint/cli.js.map +1 -0
- package/src/commands/make-this-awesome/cli.js +1 -0
- package/src/commands/make-this-awesome/cli.js.map +1 -0
- package/src/commands/mcp/cli.js +1 -0
- package/src/commands/mcp/cli.js.map +1 -0
- package/src/commands/mcp/constants.d.ts +1 -1
- package/src/commands/mcp/constants.js +2 -1
- package/src/commands/mcp/constants.js.map +1 -0
- package/src/commands/mcp/mcp-server.d.ts +3 -3
- package/src/commands/mcp/mcp-server.js +40 -4
- package/src/commands/mcp/mcp-server.js.map +1 -0
- package/src/commands/mcp/resources/ai-tutor.md +627 -0
- package/src/commands/mcp/resources/instructions.js +1 -0
- package/src/commands/mcp/resources/instructions.js.map +1 -0
- package/src/commands/mcp/tools/ai-tutor.d.ts +8 -0
- package/src/commands/mcp/tools/ai-tutor.js +62 -0
- package/src/commands/mcp/tools/ai-tutor.js.map +1 -0
- package/src/commands/mcp/tools/best-practices.d.ts +4 -1
- package/src/commands/mcp/tools/best-practices.js +167 -22
- package/src/commands/mcp/tools/best-practices.js.map +1 -0
- package/src/commands/mcp/tools/doc-search.d.ts +20 -1
- package/src/commands/mcp/tools/doc-search.js +186 -67
- package/src/commands/mcp/tools/doc-search.js.map +1 -0
- package/src/commands/mcp/tools/examples.d.ts +35 -1
- package/src/commands/mcp/tools/examples.js +414 -56
- package/src/commands/mcp/tools/examples.js.map +1 -0
- package/src/commands/mcp/tools/modernize.js +29 -27
- package/src/commands/mcp/tools/modernize.js.map +1 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/analyze_for_unsupported_zone_uses.d.ts +17 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/analyze_for_unsupported_zone_uses.js +62 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/analyze_for_unsupported_zone_uses.js.map +1 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate_single_file.d.ts +12 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate_single_file.js +73 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate_single_file.js.map +1 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate_test_file.d.ts +11 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate_test_file.js +106 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate_test_file.js.map +1 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/prompts.d.ts +15 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/prompts.js +238 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/prompts.js.map +1 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/send_debug_message.d.ts +10 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/send_debug_message.js +20 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/send_debug_message.js.map +1 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/ts_utils.d.ts +36 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/ts_utils.js +136 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/ts_utils.js.map +1 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/types.d.ts +13 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/types.js +10 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/types.js.map +1 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.d.ts +14 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.js +228 -0
- package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.js.map +1 -0
- package/src/commands/mcp/tools/projects.d.ts +75 -16
- package/src/commands/mcp/tools/projects.js +427 -30
- package/src/commands/mcp/tools/projects.js.map +1 -0
- package/src/commands/mcp/tools/tool-registry.d.ts +2 -1
- package/src/commands/mcp/tools/tool-registry.js +4 -2
- package/src/commands/mcp/tools/tool-registry.js.map +1 -0
- package/src/commands/new/cli.js +2 -0
- package/src/commands/new/cli.js.map +1 -0
- package/src/commands/run/cli.js +1 -0
- package/src/commands/run/cli.js.map +1 -0
- package/src/commands/serve/cli.js +1 -0
- package/src/commands/serve/cli.js.map +1 -0
- package/src/commands/test/cli.js +1 -0
- package/src/commands/test/cli.js.map +1 -0
- package/src/commands/update/cli.js +1 -0
- package/src/commands/update/cli.js.map +1 -0
- package/src/commands/update/schematic/index.js +1 -0
- package/src/commands/update/schematic/index.js.map +1 -0
- package/src/commands/update/schematic/schema.d.ts +0 -1
- package/src/commands/update/schematic/schema.js +1 -1
- package/src/commands/update/schematic/schema.js.map +1 -0
- package/src/commands/update/schematic/schema.json +1 -1
- package/src/commands/version/cli.d.ts +3 -7
- package/src/commands/version/cli.js +50 -49
- package/src/commands/version/cli.js.map +1 -0
- package/src/commands/version/version-info.d.ts +28 -10
- package/src/commands/version/version-info.js +34 -50
- package/src/commands/version/version-info.js.map +1 -0
- package/src/package-managers/discovery.d.ts +23 -0
- package/src/package-managers/discovery.js +110 -0
- package/src/package-managers/discovery.js.map +1 -0
- package/src/package-managers/error.d.ts +31 -0
- package/src/package-managers/error.js +41 -0
- package/src/package-managers/error.js.map +1 -0
- package/src/package-managers/factory.d.ts +25 -0
- package/src/package-managers/factory.js +123 -0
- package/src/package-managers/factory.js.map +1 -0
- package/src/package-managers/host.d.ts +64 -0
- package/src/package-managers/host.js +69 -0
- package/src/package-managers/host.js.map +1 -0
- package/src/package-managers/index.d.ts +12 -0
- package/src/package-managers/index.js +15 -0
- package/src/package-managers/index.js.map +1 -0
- package/src/package-managers/logger.d.ts +27 -0
- package/src/package-managers/logger.js +10 -0
- package/src/package-managers/logger.js.map +1 -0
- package/src/package-managers/package-manager-descriptor.d.ts +204 -0
- package/src/package-managers/package-manager-descriptor.js +147 -0
- package/src/package-managers/package-manager-descriptor.js.map +1 -0
- package/src/package-managers/package-manager.d.ts +144 -0
- package/src/package-managers/package-manager.js +304 -0
- package/src/package-managers/package-manager.js.map +1 -0
- package/src/package-managers/package-metadata.d.ts +87 -0
- package/src/package-managers/package-metadata.js +10 -0
- package/src/package-managers/package-metadata.js.map +1 -0
- package/src/package-managers/package-tree.d.ts +23 -0
- package/src/package-managers/package-tree.js +10 -0
- package/src/package-managers/package-tree.js.map +1 -0
- package/src/package-managers/parsers.d.ts +92 -0
- package/src/package-managers/parsers.js +234 -0
- package/src/package-managers/parsers.js.map +1 -0
- package/src/package-managers/testing/mock-host.d.ts +26 -0
- package/src/package-managers/testing/mock-host.js +53 -0
- package/src/package-managers/testing/mock-host.js.map +1 -0
- package/src/utilities/color.js +1 -0
- package/src/utilities/color.js.map +1 -0
- package/src/utilities/completion.js +1 -0
- package/src/utilities/completion.js.map +1 -0
- package/src/utilities/config.js +1 -0
- package/src/utilities/config.js.map +1 -0
- package/src/utilities/environment-options.js +1 -0
- package/src/utilities/environment-options.js.map +1 -0
- package/src/utilities/eol.js +1 -0
- package/src/utilities/eol.js.map +1 -0
- package/src/utilities/error.js +1 -0
- package/src/utilities/error.js.map +1 -0
- package/src/utilities/find-up.js +1 -0
- package/src/utilities/find-up.js.map +1 -0
- package/src/utilities/json-file.js +1 -0
- package/src/utilities/json-file.js.map +1 -0
- package/src/utilities/log-file.js +1 -0
- package/src/utilities/log-file.js.map +1 -0
- package/src/utilities/memoize.js +1 -0
- package/src/utilities/memoize.js.map +1 -0
- package/src/utilities/package-manager.d.ts +12 -0
- package/src/utilities/package-manager.js +52 -35
- package/src/utilities/package-manager.js.map +1 -0
- package/src/utilities/package-metadata.js +1 -0
- package/src/utilities/package-metadata.js.map +1 -0
- package/src/utilities/package-tree.js +1 -0
- package/src/utilities/package-tree.js.map +1 -0
- package/src/utilities/project.js +1 -0
- package/src/utilities/project.js.map +1 -0
- package/src/utilities/prompt.js +1 -0
- package/src/utilities/prompt.js.map +1 -0
- package/src/utilities/tty.js +1 -0
- package/src/utilities/tty.js.map +1 -0
- package/src/utilities/version.js +2 -1
- package/src/utilities/version.js.map +1 -0
|
@@ -0,0 +1,110 @@
|
|
|
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.dev/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.discover = discover;
|
|
11
|
+
/**
|
|
12
|
+
* @fileoverview This file contains the logic for discovering the package manager
|
|
13
|
+
* used in a project by searching for lockfiles. It is designed to be efficient
|
|
14
|
+
* and to correctly handle monorepo structures.
|
|
15
|
+
*/
|
|
16
|
+
const node_path_1 = require("node:path");
|
|
17
|
+
const package_manager_descriptor_1 = require("./package-manager-descriptor");
|
|
18
|
+
/**
|
|
19
|
+
* A map from lockfile names to their corresponding package manager.
|
|
20
|
+
* This is a performance optimization to avoid iterating over all possible
|
|
21
|
+
* lockfiles in every directory.
|
|
22
|
+
*/
|
|
23
|
+
const LOCKFILE_TO_PACKAGE_MANAGER = new Map();
|
|
24
|
+
for (const [name, descriptor] of Object.entries(package_manager_descriptor_1.SUPPORTED_PACKAGE_MANAGERS)) {
|
|
25
|
+
for (const lockfile of descriptor.lockfiles) {
|
|
26
|
+
LOCKFILE_TO_PACKAGE_MANAGER.set(lockfile, name);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Searches a directory for lockfiles and returns a set of package managers that correspond to them.
|
|
31
|
+
* @param host A `Host` instance for interacting with the file system.
|
|
32
|
+
* @param directory The directory to search.
|
|
33
|
+
* @param logger An optional logger instance.
|
|
34
|
+
* @returns A promise that resolves to a set of package manager names.
|
|
35
|
+
*/
|
|
36
|
+
async function findLockfiles(host, directory, logger) {
|
|
37
|
+
logger?.debug(`Searching for lockfiles in '${directory}'...`);
|
|
38
|
+
try {
|
|
39
|
+
const files = await host.readdir(directory);
|
|
40
|
+
const foundPackageManagers = new Set();
|
|
41
|
+
for (const file of files) {
|
|
42
|
+
const packageManager = LOCKFILE_TO_PACKAGE_MANAGER.get(file);
|
|
43
|
+
if (packageManager) {
|
|
44
|
+
logger?.debug(` Found '${file}'.`);
|
|
45
|
+
foundPackageManagers.add(packageManager);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return foundPackageManagers;
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
logger?.debug(` Failed to read directory: ${e}`);
|
|
52
|
+
// Ignore directories that don't exist or can't be read.
|
|
53
|
+
return new Set();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Checks if a given path is a directory.
|
|
58
|
+
* @param host A `Host` instance for interacting with the file system.
|
|
59
|
+
* @param path The path to check.
|
|
60
|
+
* @returns A promise that resolves to true if the path is a directory, false otherwise.
|
|
61
|
+
*/
|
|
62
|
+
async function isDirectory(host, path) {
|
|
63
|
+
try {
|
|
64
|
+
return (await host.stat(path)).isDirectory();
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Discovers the package manager used in a project by searching for lockfiles.
|
|
72
|
+
*
|
|
73
|
+
* This function searches for lockfiles in the given directory and its ancestors.
|
|
74
|
+
* If multiple lockfiles are found, it uses the precedence array to determine
|
|
75
|
+
* which package manager to use. The search is bounded by the git repository root.
|
|
76
|
+
*
|
|
77
|
+
* @param host A `Host` instance for interacting with the file system.
|
|
78
|
+
* @param startDir The directory to start the search from.
|
|
79
|
+
* @param logger An optional logger instance.
|
|
80
|
+
* @returns A promise that resolves to the name of the discovered package manager, or null if none is found.
|
|
81
|
+
*/
|
|
82
|
+
async function discover(host, startDir, logger) {
|
|
83
|
+
logger?.debug(`Starting package manager discovery in '${startDir}'...`);
|
|
84
|
+
let currentDir = startDir;
|
|
85
|
+
while (true) {
|
|
86
|
+
const found = await findLockfiles(host, currentDir, logger);
|
|
87
|
+
if (found.size > 0) {
|
|
88
|
+
logger?.debug(`Found lockfile(s): [${[...found].join(', ')}]. Applying precedence...`);
|
|
89
|
+
for (const packageManager of package_manager_descriptor_1.PACKAGE_MANAGER_PRECEDENCE) {
|
|
90
|
+
if (found.has(packageManager)) {
|
|
91
|
+
logger?.debug(`Selected '${packageManager}' based on precedence.`);
|
|
92
|
+
return packageManager;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// Stop searching if we reach the git repository root.
|
|
97
|
+
if (await isDirectory(host, (0, node_path_1.join)(currentDir, '.git'))) {
|
|
98
|
+
logger?.debug(`Reached repository root at '${currentDir}'. Stopping search.`);
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
const parentDir = (0, node_path_1.dirname)(currentDir);
|
|
102
|
+
if (parentDir === currentDir) {
|
|
103
|
+
// We have reached the filesystem root.
|
|
104
|
+
logger?.debug('Reached filesystem root. No lockfile found.');
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
currentDir = parentDir;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["discovery.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AA0FH,4BAuCC;AA/HD;;;;GAIG;AAEH,yCAA0C;AAG1C,6EAIsC;AAEtC;;;;GAIG;AACH,MAAM,2BAA2B,GAAG,IAAI,GAAG,EAA8B,CAAC;AAC1E,KAAK,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,uDAA0B,CAAC,EAAE,CAAC;IAC5E,KAAK,MAAM,QAAQ,IAAI,UAAU,CAAC,SAAS,EAAE,CAAC;QAC5C,2BAA2B,CAAC,GAAG,CAAC,QAAQ,EAAE,IAA0B,CAAC,CAAC;IACxE,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,KAAK,UAAU,aAAa,CAC1B,IAAU,EACV,SAAiB,EACjB,MAAe;IAEf,MAAM,EAAE,KAAK,CAAC,+BAA+B,SAAS,MAAM,CAAC,CAAC;IAE9D,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC5C,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAsB,CAAC;QAE3D,KAAK,MAAM,IAAI,IAAI,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AAI,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;oBAC9B,MAAM,EAAE,KAAK,CAAC,aAAa,cAAc,wBAAwB,CAAC,CAAC;oBAEnE,OAAO,cAAc,CAAC;gBACxB,CAAC;YACH,CAAC;QACH,CAAC;QAED,sDAAsD;QACtD,IAAI,MAAM,WAAW,CAAC,IAAI,EAAE,IAAA,gBAAI,EAAC,UAAU,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;YACtD,MAAM,EAAE,KAAK,CAAC,+BAA+B,UAAU,qBAAqB,CAAC,CAAC;YAE9E,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,SAAS,GAAG,IAAA,mBAAO,EAAC,UAAU,CAAC,CAAC;QACtC,IAAI,SAAS,KAAK,UAAU,EAAE,CAAC;YAC7B,uCAAuC;YACvC,MAAM,EAAE,KAAK,CAAC,6CAA6C,CAAC,CAAC;YAE7D,OAAO,IAAI,CAAC;QACd,CAAC;QAED,UAAU,GAAG,SAAS,CAAC;IACzB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
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.dev/license
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @fileoverview This file defines a custom error class for the package manager
|
|
10
|
+
* abstraction. This allows for structured error handling and provides consumers
|
|
11
|
+
* with detailed information about the process failure.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* A custom error class for package manager-related errors.
|
|
15
|
+
*
|
|
16
|
+
* This error class provides structured data about the failed process,
|
|
17
|
+
* including stdout, stderr, and the exit code.
|
|
18
|
+
*/
|
|
19
|
+
export declare class PackageManagerError extends Error {
|
|
20
|
+
readonly stdout: string;
|
|
21
|
+
readonly stderr: string;
|
|
22
|
+
readonly exitCode: number | null;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new `PackageManagerError` instance.
|
|
25
|
+
* @param message The error message.
|
|
26
|
+
* @param stdout The standard output of the failed process.
|
|
27
|
+
* @param stderr The standard error of the failed process.
|
|
28
|
+
* @param exitCode The exit code of the failed process.
|
|
29
|
+
*/
|
|
30
|
+
constructor(message: string, stdout: string, stderr: string, exitCode: number | null);
|
|
31
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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.dev/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.PackageManagerError = void 0;
|
|
11
|
+
/**
|
|
12
|
+
* @fileoverview This file defines a custom error class for the package manager
|
|
13
|
+
* abstraction. This allows for structured error handling and provides consumers
|
|
14
|
+
* with detailed information about the process failure.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* A custom error class for package manager-related errors.
|
|
18
|
+
*
|
|
19
|
+
* This error class provides structured data about the failed process,
|
|
20
|
+
* including stdout, stderr, and the exit code.
|
|
21
|
+
*/
|
|
22
|
+
class PackageManagerError extends Error {
|
|
23
|
+
stdout;
|
|
24
|
+
stderr;
|
|
25
|
+
exitCode;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new `PackageManagerError` instance.
|
|
28
|
+
* @param message The error message.
|
|
29
|
+
* @param stdout The standard output of the failed process.
|
|
30
|
+
* @param stderr The standard error of the failed process.
|
|
31
|
+
* @param exitCode The exit code of the failed process.
|
|
32
|
+
*/
|
|
33
|
+
constructor(message, stdout, stderr, exitCode) {
|
|
34
|
+
super(message);
|
|
35
|
+
this.stdout = stdout;
|
|
36
|
+
this.stderr = stderr;
|
|
37
|
+
this.exitCode = exitCode;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.PackageManagerError = PackageManagerError;
|
|
41
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["error.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH;;;;GAIG;AAEH;;;;;GAKG;AACH,MAAa,mBAAoB,SAAQ,KAAK;IAU1B;IACA;IACA;IAXlB;;;;;;OAMG;IACH,YACE,OAAe,EACC,MAAc,EACd,MAAc,EACd,QAAuB;QAEvC,KAAK,CAAC,OAAO,CAAC,CAAC;QAJC,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAQ;QACd,aAAQ,GAAR,QAAQ,CAAe;IAGzC,CAAC;CACF;AAhBD,kDAgBC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
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.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import { Logger } from './logger';
|
|
9
|
+
import { PackageManager } from './package-manager';
|
|
10
|
+
import { PackageManagerName } from './package-manager-descriptor';
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new `PackageManager` instance for a given project.
|
|
13
|
+
*
|
|
14
|
+
* This function is the main entry point for the package manager abstraction.
|
|
15
|
+
* It will determine, verify, and instantiate the correct package manager.
|
|
16
|
+
*
|
|
17
|
+
* @param options An object containing the options for creating the package manager.
|
|
18
|
+
* @returns A promise that resolves to a new `PackageManager` instance.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createPackageManager(options: {
|
|
21
|
+
cwd: string;
|
|
22
|
+
configuredPackageManager?: PackageManagerName;
|
|
23
|
+
logger?: Logger;
|
|
24
|
+
dryRun?: boolean;
|
|
25
|
+
}): Promise<PackageManager>;
|
|
@@ -0,0 +1,123 @@
|
|
|
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.dev/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.createPackageManager = createPackageManager;
|
|
11
|
+
const semver_1 = require("semver");
|
|
12
|
+
const discovery_1 = require("./discovery");
|
|
13
|
+
const host_1 = require("./host");
|
|
14
|
+
const package_manager_1 = require("./package-manager");
|
|
15
|
+
const package_manager_descriptor_1 = require("./package-manager-descriptor");
|
|
16
|
+
/**
|
|
17
|
+
* The default package manager to use when none is discovered or configured.
|
|
18
|
+
*/
|
|
19
|
+
const DEFAULT_PACKAGE_MANAGER = 'npm';
|
|
20
|
+
/**
|
|
21
|
+
* Gets the version of yarn installed on the system.
|
|
22
|
+
* @param host A `Host` instance for running commands.
|
|
23
|
+
* @param cwd The absolute path to the working directory.
|
|
24
|
+
* @param logger An optional logger instance.
|
|
25
|
+
* @returns A promise that resolves to the yarn version string, or null if yarn is not installed.
|
|
26
|
+
*/
|
|
27
|
+
async function getYarnVersion(host, cwd, logger) {
|
|
28
|
+
logger?.debug(`Getting yarn version...`);
|
|
29
|
+
try {
|
|
30
|
+
const { stdout } = await host.runCommand('yarn', ['--version'], { cwd });
|
|
31
|
+
const version = stdout.trim();
|
|
32
|
+
logger?.debug(`Yarn version is '${version}'.`);
|
|
33
|
+
return version;
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
logger?.debug('Failed to get yarn version.');
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Determines the package manager to use for a given project.
|
|
42
|
+
*
|
|
43
|
+
* This function will determine the package manager by checking for a configured
|
|
44
|
+
* package manager, discovering the package manager from lockfiles, or falling
|
|
45
|
+
* back to a default. It also handles differentiation between yarn classic and modern.
|
|
46
|
+
*
|
|
47
|
+
* @param host A `Host` instance for interacting with the file system and running commands.
|
|
48
|
+
* @param cwd The directory to start the search from.
|
|
49
|
+
* @param configured An optional, explicitly configured package manager.
|
|
50
|
+
* @param logger An optional logger instance.
|
|
51
|
+
* @returns A promise that resolves to an object containing the name and source of the package manager.
|
|
52
|
+
*/
|
|
53
|
+
async function determinePackageManager(host, cwd, configured, logger, dryRun) {
|
|
54
|
+
let name;
|
|
55
|
+
let source;
|
|
56
|
+
if (configured) {
|
|
57
|
+
name = configured;
|
|
58
|
+
source = 'configured';
|
|
59
|
+
logger?.debug(`Using configured package manager: '${name}'.`);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const discovered = await (0, discovery_1.discover)(host, cwd, logger);
|
|
63
|
+
if (discovered) {
|
|
64
|
+
name = discovered;
|
|
65
|
+
source = 'discovered';
|
|
66
|
+
logger?.debug(`Discovered package manager: '${name}'.`);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
name = DEFAULT_PACKAGE_MANAGER;
|
|
70
|
+
source = 'default';
|
|
71
|
+
logger?.debug(`No lockfile found. Using default package manager: '${DEFAULT_PACKAGE_MANAGER}'.`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (name === 'yarn' && !dryRun) {
|
|
75
|
+
const version = await getYarnVersion(host, cwd, logger);
|
|
76
|
+
if (version && (0, semver_1.major)(version) < 2) {
|
|
77
|
+
name = 'yarn-classic';
|
|
78
|
+
logger?.debug(`Detected yarn classic. Using 'yarn-classic'.`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else if (name === 'yarn') {
|
|
82
|
+
logger?.debug('Skipping yarn version check due to dry run. Assuming modern yarn.');
|
|
83
|
+
}
|
|
84
|
+
return { name, source };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Creates a new `PackageManager` instance for a given project.
|
|
88
|
+
*
|
|
89
|
+
* This function is the main entry point for the package manager abstraction.
|
|
90
|
+
* It will determine, verify, and instantiate the correct package manager.
|
|
91
|
+
*
|
|
92
|
+
* @param options An object containing the options for creating the package manager.
|
|
93
|
+
* @returns A promise that resolves to a new `PackageManager` instance.
|
|
94
|
+
*/
|
|
95
|
+
async function createPackageManager(options) {
|
|
96
|
+
const { cwd, configuredPackageManager, logger, dryRun } = options;
|
|
97
|
+
const host = host_1.NodeJS_HOST;
|
|
98
|
+
const { name, source } = await determinePackageManager(host, cwd, configuredPackageManager, logger, dryRun);
|
|
99
|
+
const descriptor = package_manager_descriptor_1.SUPPORTED_PACKAGE_MANAGERS[name];
|
|
100
|
+
if (!descriptor) {
|
|
101
|
+
throw new Error(`Unsupported package manager: "${name}"`);
|
|
102
|
+
}
|
|
103
|
+
const packageManager = new package_manager_1.PackageManager(host, cwd, descriptor, { dryRun, logger });
|
|
104
|
+
// Do not verify if the package manager is installed during a dry run.
|
|
105
|
+
if (!dryRun) {
|
|
106
|
+
try {
|
|
107
|
+
await packageManager.getVersion();
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
if (source === 'default') {
|
|
111
|
+
throw new Error(`'${DEFAULT_PACKAGE_MANAGER}' was selected as the default package manager, but it is not installed or` +
|
|
112
|
+
` cannot be found in the PATH. Please install '${DEFAULT_PACKAGE_MANAGER}' to continue.`);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
throw new Error(`The project is configured to use '${name}', but it is not installed or cannot be` +
|
|
116
|
+
` found in the PATH. Please install '${name}' to continue.`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
logger?.debug(`Successfully created PackageManager for '${name}'.`);
|
|
121
|
+
return packageManager;
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["factory.ts"],"names":[],"m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ED,MAAM,cAAc,GAAG,IAAI,gCAAc,CAAC,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAErF,sEAAsE;IACtE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,IAAI,CAAC;YACH,MAAM,cAAc,CAAC,UAAU,EAAE,CAAC;QACpC,CAAC;QAAC,MAAM,CAAC;YACP,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CACb,IAAI,uBAAuB,2EAA2E;oBACpG,iDAAiD,uBAAuB,gBAAgB,CAC3F,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CACb,qCAAqC,IAAI,yCAAyC;oBAChF,uCAAuC,IAAI,gBAAgB,CAC9D,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,EAAE,KAAK,CAAC,4CAA4C,IAAI,IAAI,CAAC,CAAC;IAEpE,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
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.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import { Stats } from 'node:fs';
|
|
9
|
+
/**
|
|
10
|
+
* An abstraction layer for side-effectful operations.
|
|
11
|
+
*/
|
|
12
|
+
export interface Host {
|
|
13
|
+
/**
|
|
14
|
+
* Gets the stats of a file or directory.
|
|
15
|
+
* @param path The path to the file or directory.
|
|
16
|
+
* @returns A promise that resolves to the stats.
|
|
17
|
+
*/
|
|
18
|
+
stat(path: string): Promise<Stats>;
|
|
19
|
+
/**
|
|
20
|
+
* Reads the contents of a directory.
|
|
21
|
+
* @param path The path to the directory.
|
|
22
|
+
* @returns A promise that resolves to an array of file and directory names.
|
|
23
|
+
*/
|
|
24
|
+
readdir(path: string): Promise<string[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new, unique temporary directory.
|
|
27
|
+
* @returns A promise that resolves to the absolute path of the created directory.
|
|
28
|
+
*/
|
|
29
|
+
createTempDirectory(): Promise<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Deletes a directory recursively.
|
|
32
|
+
* @param path The path to the directory to delete.
|
|
33
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
34
|
+
*/
|
|
35
|
+
deleteDirectory(path: string): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Writes content to a file.
|
|
38
|
+
* @param path The path to the file.
|
|
39
|
+
* @param content The content to write.
|
|
40
|
+
* @returns A promise that resolves when the write is complete.
|
|
41
|
+
*/
|
|
42
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Spawns a child process and returns a promise that resolves with the process's
|
|
45
|
+
* output or rejects with a structured error.
|
|
46
|
+
* @param command The command to run.
|
|
47
|
+
* @param args The arguments to pass to the command.
|
|
48
|
+
* @param options Options for the child process.
|
|
49
|
+
* @returns A promise that resolves with the standard output and standard error of the command.
|
|
50
|
+
*/
|
|
51
|
+
runCommand(command: string, args: readonly string[], options?: {
|
|
52
|
+
timeout?: number;
|
|
53
|
+
stdio?: 'pipe' | 'ignore';
|
|
54
|
+
cwd?: string;
|
|
55
|
+
env?: Record<string, string>;
|
|
56
|
+
}): Promise<{
|
|
57
|
+
stdout: string;
|
|
58
|
+
stderr: string;
|
|
59
|
+
}>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A concrete implementation of the `Host` interface that uses the Node.js APIs.
|
|
63
|
+
*/
|
|
64
|
+
export declare const NodeJS_HOST: Host;
|
|
@@ -0,0 +1,69 @@
|
|
|
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.dev/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.NodeJS_HOST = void 0;
|
|
11
|
+
/**
|
|
12
|
+
* @fileoverview
|
|
13
|
+
* This file defines an abstraction layer for side-effectful operations, such as
|
|
14
|
+
* file system access and command execution. This allows for easier testing by
|
|
15
|
+
* enabling the injection of mock or test-specific implementations.
|
|
16
|
+
*/
|
|
17
|
+
const node_child_process_1 = require("node:child_process");
|
|
18
|
+
const promises_1 = require("node:fs/promises");
|
|
19
|
+
const node_os_1 = require("node:os");
|
|
20
|
+
const node_path_1 = require("node:path");
|
|
21
|
+
const error_1 = require("./error");
|
|
22
|
+
/**
|
|
23
|
+
* A concrete implementation of the `Host` interface that uses the Node.js APIs.
|
|
24
|
+
*/
|
|
25
|
+
exports.NodeJS_HOST = {
|
|
26
|
+
stat: promises_1.stat,
|
|
27
|
+
readdir: promises_1.readdir,
|
|
28
|
+
writeFile: promises_1.writeFile,
|
|
29
|
+
createTempDirectory: () => (0, promises_1.mkdtemp)((0, node_path_1.join)((0, node_os_1.tmpdir)(), 'angular-cli-')),
|
|
30
|
+
deleteDirectory: (path) => (0, promises_1.rm)(path, { recursive: true, force: true }),
|
|
31
|
+
runCommand: async (command, args, options = {}) => {
|
|
32
|
+
const signal = options.timeout ? AbortSignal.timeout(options.timeout) : undefined;
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
const childProcess = (0, node_child_process_1.spawn)(command, args, {
|
|
35
|
+
shell: false,
|
|
36
|
+
stdio: options.stdio ?? 'pipe',
|
|
37
|
+
signal,
|
|
38
|
+
cwd: options.cwd,
|
|
39
|
+
env: {
|
|
40
|
+
...process.env,
|
|
41
|
+
...options.env,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
let stdout = '';
|
|
45
|
+
childProcess.stdout?.on('data', (data) => (stdout += data.toString()));
|
|
46
|
+
let stderr = '';
|
|
47
|
+
childProcess.stderr?.on('data', (data) => (stderr += data.toString()));
|
|
48
|
+
childProcess.on('close', (code) => {
|
|
49
|
+
if (code === 0) {
|
|
50
|
+
resolve({ stdout, stderr });
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const message = `Process exited with code ${code}.`;
|
|
54
|
+
reject(new error_1.PackageManagerError(message, stdout, stderr, code));
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
childProcess.on('error', (err) => {
|
|
58
|
+
if (err.name === 'AbortError') {
|
|
59
|
+
const message = `Process timed out.`;
|
|
60
|
+
reject(new error_1.PackageManagerError(message, stdout, stderr, null));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const message = `Process failed with error: ${err.message}`;
|
|
64
|
+
reject(new error_1.PackageManagerError(message, stdout, stderr, null));
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["host.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH;;;;;GAKG;AAEH,2DAA2C;AAE3C,+CAAyE;AACzE,qCAAiC;AACjC,yCAAiC;AACjC,mCAA8C;AA6D9C;;GAEG;AACU,QAAA,WAAW,GAAS;IAC/B,IAAI,EAAJ,eAAI;IACJ,OAAO,EAAP,kBAAO;IACP,SAAS,EAAT,oBAAS;IACT,mBAAmB,EAAE,GAAG,EAAE,CAAC,IAAA,kBAAO,EAAC,IAAA,gBAAI,EAAC,IAAA,gBAAM,GAAE,EAAE,cAAc,CAAC,CAAC;IAClE,eAAe,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAA,aAAE,EAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAC7E,UAAU,EAAE,KAAK,E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AM,EAAE,IAAI,CAAC,CAAC,CAAC;gBACjE,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;gBAC/B,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;oBAC9B,MAAM,OAAO,GAAG,oBAAoB,CAAC;oBACrC,MAAM,CAAC,IAAI,2BAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;oBAE/D,OAAO;gBACT,CAAC;gBACD,MAAM,OAAO,GAAG,8BAA8B,GAAG,CAAC,OAAO,EAAE,CAAC;gBAC5D,MAAM,CAAC,IAAI,2BAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;YACjE,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
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.dev/license
|
|
7
|
+
*/
|
|
8
|
+
export { createPackageManager } from './factory';
|
|
9
|
+
export type { PackageManagerName } from './package-manager-descriptor';
|
|
10
|
+
export { PackageManager } from './package-manager';
|
|
11
|
+
export type * from './package-metadata';
|
|
12
|
+
export type { InstalledPackage } from './package-tree';
|
|
@@ -0,0 +1,15 @@
|
|
|
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.dev/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.PackageManager = exports.createPackageManager = void 0;
|
|
11
|
+
var factory_1 = require("./factory");
|
|
12
|
+
Object.defineProperty(exports, "createPackageManager", { enumerable: true, get: function () { return factory_1.createPackageManager; } });
|
|
13
|
+
var package_manager_1 = require("./package-manager");
|
|
14
|
+
Object.defineProperty(exports, "PackageManager", { enumerable: true, get: function () { return package_manager_1.PackageManager; } });
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,qCAAiD;AAAxC,+GAAA,oBAAoB,OAAA;AAE7B,qDAAmD;AAA1C,iHAAA,cAAc,OAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
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.dev/license
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @fileoverview This file defines a basic logger interface that is used by
|
|
10
|
+
* the package manager abstraction. This allows the abstraction to be decoupled
|
|
11
|
+
* from any specific logging implementation.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* A basic logger interface for the package manager abstraction.
|
|
15
|
+
*/
|
|
16
|
+
export interface Logger {
|
|
17
|
+
/**
|
|
18
|
+
* Logs a debug message.
|
|
19
|
+
* @param message The message to log.
|
|
20
|
+
*/
|
|
21
|
+
debug(message: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Logs an informational message.
|
|
24
|
+
* @param message The message to log.
|
|
25
|
+
*/
|
|
26
|
+
info(message: string): void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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.dev/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["logger.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
|