@depup/angular__cli 21.2.7-depup.0 → 22.0.7-depup.0
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/README.md +12 -9
- package/bin/ng.js +10 -7
- package/changes.json +28 -16
- package/lib/cli/index.js +3 -5
- package/lib/cli/index.js.map +1 -1
- package/lib/config/schema.json +18 -392
- package/lib/config/workspace-schema.d.ts +5 -1
- package/lib/config/workspace-schema.js +1 -1
- package/lib/config/workspace-schema.js.map +1 -1
- package/package.json +64 -53
- package/src/command-builder/command-module.js +9 -2
- package/src/command-builder/command-module.js.map +1 -1
- package/src/commands/add/cli.d.ts +3 -0
- package/src/commands/add/cli.js +121 -50
- package/src/commands/add/cli.js.map +1 -1
- package/src/commands/mcp/cli.js +0 -4
- package/src/commands/mcp/cli.js.map +1 -1
- package/src/commands/mcp/devserver.d.ts +1 -1
- package/src/commands/mcp/devserver.js +5 -8
- package/src/commands/mcp/devserver.js.map +1 -1
- package/src/commands/mcp/host.d.ts +14 -12
- package/src/commands/mcp/host.js +139 -9
- package/src/commands/mcp/host.js.map +1 -1
- package/src/commands/mcp/mcp-server.d.ts +2 -160
- package/src/commands/mcp/mcp-server.js +56 -36
- package/src/commands/mcp/mcp-server.js.map +1 -1
- package/src/commands/mcp/resources/ai-tutor.md +5 -7
- package/src/commands/mcp/resources/best-practices.md +4 -2
- package/src/commands/mcp/tools/best-practices.js +9 -17
- package/src/commands/mcp/tools/best-practices.js.map +1 -1
- package/src/commands/mcp/tools/devserver/devserver-start.js +1 -0
- package/src/commands/mcp/tools/devserver/devserver-start.js.map +1 -1
- package/src/commands/mcp/tools/devserver/devserver-stop.js +1 -0
- package/src/commands/mcp/tools/devserver/devserver-stop.js.map +1 -1
- package/src/commands/mcp/tools/devserver/devserver-wait-for-build.js +1 -0
- package/src/commands/mcp/tools/devserver/devserver-wait-for-build.js.map +1 -1
- package/src/commands/mcp/tools/doc-search.js +11 -33
- package/src/commands/mcp/tools/doc-search.js.map +1 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-single-file.d.ts +2 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-single-file.js +5 -8
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-single-file.js.map +1 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-test-file.d.ts +3 -2
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-test-file.js +8 -8
- package/src/commands/mcp/tools/onpush-zoneless-migration/migrate-test-file.js.map +1 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/prompts.js +4 -4
- package/src/commands/mcp/tools/onpush-zoneless-migration/ts-utils.d.ts +2 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/ts-utils.js +2 -3
- package/src/commands/mcp/tools/onpush-zoneless-migration/ts-utils.js.map +1 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.d.ts +2 -1
- package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.js +31 -44
- package/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.js.map +1 -1
- package/src/commands/mcp/tools/projects.d.ts +1 -0
- package/src/commands/mcp/tools/projects.js +37 -19
- package/src/commands/mcp/tools/projects.js.map +1 -1
- package/src/commands/mcp/tools/run-target/build-target-strategy.d.ts +14 -0
- package/src/commands/mcp/tools/run-target/build-target-strategy.js +53 -0
- package/src/commands/mcp/tools/run-target/build-target-strategy.js.map +1 -0
- package/src/commands/mcp/tools/run-target/generic-target-strategy.d.ts +14 -0
- package/src/commands/mcp/tools/run-target/generic-target-strategy.js +63 -0
- package/src/commands/mcp/tools/run-target/generic-target-strategy.js.map +1 -0
- package/src/commands/mcp/tools/run-target/options-serializer.d.ts +13 -0
- package/src/commands/mcp/tools/run-target/options-serializer.js +41 -0
- package/src/commands/mcp/tools/run-target/options-serializer.js.map +1 -0
- package/src/commands/mcp/tools/run-target/run-target.d.ts +34 -0
- package/src/commands/mcp/tools/run-target/run-target.js +69 -0
- package/src/commands/mcp/tools/run-target/run-target.js.map +1 -0
- package/src/commands/mcp/tools/run-target/strategy.d.ts +15 -0
- package/src/commands/mcp/tools/run-target/strategy.js +10 -0
- package/src/commands/mcp/tools/run-target/strategy.js.map +1 -0
- package/src/commands/mcp/tools/run-target/types.d.ts +39 -0
- package/src/commands/mcp/tools/run-target/types.js +41 -0
- package/src/commands/mcp/tools/run-target/types.js.map +1 -0
- package/src/commands/mcp/tools/run-target/unit-test-strategy.d.ts +14 -0
- package/src/commands/mcp/tools/run-target/unit-test-strategy.js +56 -0
- package/src/commands/mcp/tools/run-target/unit-test-strategy.js.map +1 -0
- package/src/commands/mcp/workspace-utils.d.ts +2 -1
- package/src/commands/mcp/workspace-utils.js +45 -3
- package/src/commands/mcp/workspace-utils.js.map +1 -1
- package/src/commands/update/cli.js +4 -3
- package/src/commands/update/cli.js.map +1 -1
- package/src/commands/update/schematic/index.js +262 -92
- package/src/commands/update/schematic/index.js.map +1 -1
- package/src/commands/update/schematic/schema.d.ts +4 -0
- package/src/commands/update/schematic/schema.js.map +1 -1
- package/src/commands/update/schematic/schema.json +4 -0
- package/src/commands/update/utilities/cli-version.js +1 -1
- package/src/commands/update/utilities/cli-version.js.map +1 -1
- package/src/commands/update/utilities/migration.js +5 -2
- package/src/commands/update/utilities/migration.js.map +1 -1
- package/src/commands/version/version-info.js +2 -8
- package/src/commands/version/version-info.js.map +1 -1
- package/src/package-managers/package-manager-descriptor.d.ts +15 -1
- package/src/package-managers/package-manager-descriptor.js +29 -0
- package/src/package-managers/package-manager-descriptor.js.map +1 -1
- package/src/package-managers/package-manager.d.ts +4 -0
- package/src/package-managers/package-manager.js +218 -36
- package/src/package-managers/package-manager.js.map +1 -1
- package/src/package-managers/parsers.d.ts +3 -21
- package/src/package-managers/parsers.js +83 -33
- package/src/package-managers/parsers.js.map +1 -1
- package/src/utilities/completion.js +1 -1
- package/src/utilities/completion.js.map +1 -1
- package/src/utilities/config.js +1 -2
- package/src/utilities/config.js.map +1 -1
- package/src/utilities/node-version.d.ts +21 -0
- package/src/utilities/node-version.js +65 -0
- package/src/utilities/node-version.js.map +1 -0
- package/src/utilities/package-metadata.d.ts +0 -10
- package/src/utilities/package-metadata.js +0 -62
- package/src/utilities/package-metadata.js.map +1 -1
- package/src/utilities/prompt.js +1 -1
- package/src/utilities/prompt.js.map +1 -1
- package/src/utilities/version.js +1 -1
- package/lib/code-examples.db +0 -0
- package/src/commands/mcp/tools/build.d.ts +0 -37
- package/src/commands/mcp/tools/build.js +0 -89
- package/src/commands/mcp/tools/build.js.map +0 -1
- package/src/commands/mcp/tools/e2e.d.ts +0 -44
- package/src/commands/mcp/tools/e2e.js +0 -87
- package/src/commands/mcp/tools/e2e.js.map +0 -1
- package/src/commands/mcp/tools/examples/database-discovery.d.ts +0 -34
- package/src/commands/mcp/tools/examples/database-discovery.js +0 -87
- package/src/commands/mcp/tools/examples/database-discovery.js.map +0 -1
- package/src/commands/mcp/tools/examples/database.d.ts +0 -35
- package/src/commands/mcp/tools/examples/database.js +0 -125
- package/src/commands/mcp/tools/examples/database.js.map +0 -1
- package/src/commands/mcp/tools/examples/index.d.ts +0 -26
- package/src/commands/mcp/tools/examples/index.js +0 -149
- package/src/commands/mcp/tools/examples/index.js.map +0 -1
- package/src/commands/mcp/tools/examples/query-escaper.d.ts +0 -20
- package/src/commands/mcp/tools/examples/query-escaper.js +0 -68
- package/src/commands/mcp/tools/examples/query-escaper.js.map +0 -1
- package/src/commands/mcp/tools/examples/runtime-database.d.ts +0 -10
- package/src/commands/mcp/tools/examples/runtime-database.js +0 -192
- package/src/commands/mcp/tools/examples/runtime-database.js.map +0 -1
- package/src/commands/mcp/tools/examples/schemas.d.ts +0 -29
- package/src/commands/mcp/tools/examples/schemas.js +0 -101
- package/src/commands/mcp/tools/examples/schemas.js.map +0 -1
- package/src/commands/mcp/tools/examples/utils.d.ts +0 -14
- package/src/commands/mcp/tools/examples/utils.js +0 -31
- package/src/commands/mcp/tools/examples/utils.js.map +0 -1
- package/src/commands/mcp/tools/modernize.d.ts +0 -43
- package/src/commands/mcp/tools/modernize.js +0 -165
- package/src/commands/mcp/tools/modernize.js.map +0 -1
- package/src/commands/mcp/tools/test.d.ts +0 -35
- package/src/commands/mcp/tools/test.js +0 -79
- package/src/commands/mcp/tools/test.js.map +0 -1
|
@@ -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.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import type { McpToolContext } from '../tool-registry';
|
|
9
|
+
import type { TargetStrategy } from './strategy';
|
|
10
|
+
import type { RunTargetOutput, StrategyExecutionContext } from './types';
|
|
11
|
+
export declare class GenericTargetStrategy implements TargetStrategy {
|
|
12
|
+
canHandle(targetName: string, builder?: string): boolean;
|
|
13
|
+
execute(input: StrategyExecutionContext, context: McpToolContext): Promise<RunTargetOutput>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
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.GenericTargetStrategy = void 0;
|
|
11
|
+
const utils_1 = require("../../utils");
|
|
12
|
+
const options_serializer_1 = require("./options-serializer");
|
|
13
|
+
const BUILT_IN_COMMANDS = new Set([
|
|
14
|
+
'build',
|
|
15
|
+
'test',
|
|
16
|
+
'e2e',
|
|
17
|
+
'serve',
|
|
18
|
+
'deploy',
|
|
19
|
+
'extract-i18n',
|
|
20
|
+
'lint',
|
|
21
|
+
]);
|
|
22
|
+
class GenericTargetStrategy {
|
|
23
|
+
canHandle(targetName, builder) {
|
|
24
|
+
return true; // Universal fallback strategy
|
|
25
|
+
}
|
|
26
|
+
async execute(input, context) {
|
|
27
|
+
if (input.targetName === 'serve' || input.options?.['watch'] === true) {
|
|
28
|
+
throw new Error(`Watch mode execution (serve target or watch option) is not yet supported by 'run_target'. ` +
|
|
29
|
+
`Please use the legacy 'devserver.start' / 'devserver.wait_for_build' tools instead.`);
|
|
30
|
+
}
|
|
31
|
+
const args = [];
|
|
32
|
+
if (BUILT_IN_COMMANDS.has(input.targetName)) {
|
|
33
|
+
args.push(input.targetName, input.projectName);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
args.push('run', `${input.projectName}:${input.targetName}`);
|
|
37
|
+
}
|
|
38
|
+
if (input.configuration) {
|
|
39
|
+
args.push('-c', input.configuration);
|
|
40
|
+
}
|
|
41
|
+
let options = input.options;
|
|
42
|
+
if (input.targetName === 'test') {
|
|
43
|
+
options = {
|
|
44
|
+
...options,
|
|
45
|
+
watch: false,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
args.push(...(0, options_serializer_1.serializeOptions)(options));
|
|
49
|
+
let status = 'success';
|
|
50
|
+
let logs;
|
|
51
|
+
try {
|
|
52
|
+
const result = await context.host.executeNgCommand(args, { cwd: input.workspacePath });
|
|
53
|
+
logs = result.logs;
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
status = 'failure';
|
|
57
|
+
logs = (0, utils_1.getCommandErrorLogs)(e);
|
|
58
|
+
}
|
|
59
|
+
return { status, logs };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.GenericTargetStrategy = GenericTargetStrategy;
|
|
63
|
+
//# sourceMappingURL=generic-target-strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic-target-strategy.js","sourceRoot":"","sources":["generic-target-strategy.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,uCAA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CAAC,CAAC;QAExC,IAAI,MAAM,GAA0B,SAAS,CAAC;QAC9C,IAAI,IAAc,CAAC;QAEnB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC;YACvF,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACrB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,GAAG,SAAS,CAAC;YACnB,IAAI,GAAG,IAAA,2BAAmB,EAAC,CAAC,CAAC,CAAC;QAChC,CAAC;QAED,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC1B,CAAC;CACF;AAlDD,sDAkDC"}
|
|
@@ -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.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import type { OptionValue } from './types';
|
|
9
|
+
/**
|
|
10
|
+
* Serializes a Zod-validated options record into standard CLI argument flags.
|
|
11
|
+
* Enforces strict regex validation on option keys to prevent flag manipulation.
|
|
12
|
+
*/
|
|
13
|
+
export declare function serializeOptions(options: Record<string, OptionValue> | undefined, excludeKeys?: Set<string>): string[];
|
|
@@ -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.serializeOptions = serializeOptions;
|
|
11
|
+
/**
|
|
12
|
+
* Serializes a Zod-validated options record into standard CLI argument flags.
|
|
13
|
+
* Enforces strict regex validation on option keys to prevent flag manipulation.
|
|
14
|
+
*/
|
|
15
|
+
function serializeOptions(options, excludeKeys = new Set()) {
|
|
16
|
+
const args = [];
|
|
17
|
+
if (!options) {
|
|
18
|
+
return args;
|
|
19
|
+
}
|
|
20
|
+
for (const [key, value] of Object.entries(options)) {
|
|
21
|
+
if (excludeKeys.has(key)) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (!/^[a-zA-Z0-9-_]+$/.test(key)) {
|
|
25
|
+
throw new Error(`Invalid option key: '${key}'. Option keys must be alphanumeric, hyphens, or underscores.`);
|
|
26
|
+
}
|
|
27
|
+
if (typeof value === 'boolean') {
|
|
28
|
+
args.push(value ? `--${key}` : `--no-${key}`);
|
|
29
|
+
}
|
|
30
|
+
else if (Array.isArray(value)) {
|
|
31
|
+
for (const item of value) {
|
|
32
|
+
args.push(`--${key}=${item}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else if (value !== null && value !== undefined) {
|
|
36
|
+
args.push(`--${key}=${value}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return args;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=options-serializer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options-serializer.js","sourceRoot":"","sources":["options-serializer.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAQH,4CAgCC;AApCD;;;GAGG;AACH,SAAgB,gBAAgB,CAC9B,OAAgD,EAChD,cAA2B,IAAI,GAAG,EAAE;IAEpC,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,IAAI,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACzB,SAAS;QACX,CAAC;QAED,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CACb,wBAAwB,GAAG,+DAA+D,CAC3F,CAAC;QACJ,CAAC;QAED,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;YAC/B,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC;QAChD,CAAC;aAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAChC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;aAAM,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACjD,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 { type McpToolContext } from '../tool-registry';
|
|
9
|
+
import { type RunTargetInput } from './types';
|
|
10
|
+
export declare function runTarget(input: RunTargetInput, context: McpToolContext): Promise<{
|
|
11
|
+
content: {
|
|
12
|
+
type: "text";
|
|
13
|
+
text: string;
|
|
14
|
+
}[];
|
|
15
|
+
structuredContent: {
|
|
16
|
+
status: "success" | "failure";
|
|
17
|
+
logs: string[];
|
|
18
|
+
extensions?: Record<string, unknown> | undefined;
|
|
19
|
+
};
|
|
20
|
+
}>;
|
|
21
|
+
export declare const RUN_TARGET_TOOL: import("../tool-registry").McpToolDeclaration<{
|
|
22
|
+
target: import("zod").ZodString;
|
|
23
|
+
configuration: import("zod").ZodOptional<import("zod").ZodString>;
|
|
24
|
+
options: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber, import("zod").ZodBoolean, import("zod").ZodArray<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber]>>]>>>;
|
|
25
|
+
workspace: import("zod").ZodOptional<import("zod").ZodString>;
|
|
26
|
+
project: import("zod").ZodOptional<import("zod").ZodString>;
|
|
27
|
+
}, {
|
|
28
|
+
status: import("zod").ZodEnum<{
|
|
29
|
+
success: "success";
|
|
30
|
+
failure: "failure";
|
|
31
|
+
}>;
|
|
32
|
+
logs: import("zod").ZodArray<import("zod").ZodString>;
|
|
33
|
+
extensions: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
34
|
+
}>;
|
|
@@ -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.RUN_TARGET_TOOL = void 0;
|
|
11
|
+
exports.runTarget = runTarget;
|
|
12
|
+
const utils_1 = require("../../utils");
|
|
13
|
+
const workspace_utils_1 = require("../../workspace-utils");
|
|
14
|
+
const tool_registry_1 = require("../tool-registry");
|
|
15
|
+
const build_target_strategy_1 = require("./build-target-strategy");
|
|
16
|
+
const generic_target_strategy_1 = require("./generic-target-strategy");
|
|
17
|
+
const types_1 = require("./types");
|
|
18
|
+
const unit_test_strategy_1 = require("./unit-test-strategy");
|
|
19
|
+
const FALLBACK_STRATEGY = new generic_target_strategy_1.GenericTargetStrategy();
|
|
20
|
+
const STRATEGIES = [new build_target_strategy_1.BuildTargetStrategy(), new unit_test_strategy_1.UnitTestTargetStrategy()];
|
|
21
|
+
async function runTarget(input, context) {
|
|
22
|
+
const { workspace, workspacePath, projectName } = await (0, workspace_utils_1.resolveWorkspaceAndProject)({
|
|
23
|
+
host: context.host,
|
|
24
|
+
server: context.server,
|
|
25
|
+
workspacePathInput: input.workspace,
|
|
26
|
+
projectNameInput: input.project,
|
|
27
|
+
mcpWorkspace: context.workspace,
|
|
28
|
+
});
|
|
29
|
+
const targetDefinition = workspace.projects.get(projectName)?.targets.get(input.target);
|
|
30
|
+
const builder = targetDefinition?.builder;
|
|
31
|
+
const strategy = STRATEGIES.find((s) => s.canHandle(input.target, builder)) ?? FALLBACK_STRATEGY;
|
|
32
|
+
const result = await strategy.execute({
|
|
33
|
+
workspacePath,
|
|
34
|
+
projectName,
|
|
35
|
+
targetName: input.target,
|
|
36
|
+
targetDefinition,
|
|
37
|
+
configuration: input.configuration,
|
|
38
|
+
options: input.options,
|
|
39
|
+
}, context);
|
|
40
|
+
return (0, utils_1.createStructuredContentOutput)(result);
|
|
41
|
+
}
|
|
42
|
+
exports.RUN_TARGET_TOOL = (0, tool_registry_1.declareTool)({
|
|
43
|
+
name: 'run_target',
|
|
44
|
+
title: 'Run Project Target',
|
|
45
|
+
description: `
|
|
46
|
+
<Purpose>
|
|
47
|
+
Executes a configured target (such as build, test, lint, e2e) for an Angular project.
|
|
48
|
+
This is the single, unified interface for executing all project tasks natively.
|
|
49
|
+
</Purpose>
|
|
50
|
+
<Use Cases>
|
|
51
|
+
* Building an application or library.
|
|
52
|
+
* Running unit tests, E2E tests, or linters.
|
|
53
|
+
* Deploying or running custom workspace targets discovered via 'list_projects'.
|
|
54
|
+
</Use Cases>
|
|
55
|
+
<Operational Notes>
|
|
56
|
+
* Mandatory Discovery: You MUST discover available project targets by calling 'list_projects' first.
|
|
57
|
+
* Headless Testing: For official builders, the test target automatically runs in headless mode
|
|
58
|
+
and disables watch mode to guarantee clean execution.
|
|
59
|
+
* Output Paths: For official builders, successful builds return the build directory in 'outputPath' under the extensions metadata.
|
|
60
|
+
* Watch mode (serve target or watch options) is NOT yet supported in this version of run_target.
|
|
61
|
+
You MUST use the legacy 'devserver.*' tools for background server lifecycles.
|
|
62
|
+
</Operational Notes>`,
|
|
63
|
+
isReadOnly: false,
|
|
64
|
+
isLocalOnly: true,
|
|
65
|
+
inputSchema: types_1.runTargetInputSchema.shape,
|
|
66
|
+
outputSchema: types_1.runTargetOutputSchema.shape,
|
|
67
|
+
factory: (context) => (input) => runTarget(input, context),
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=run-target.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-target.js","sourceRoot":"","sources":["run-target.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAcH,8BA2BC;AAvCD,uCAA4D;AAC5D,2DAAmE;AACnE,oDAAoE;AACpE,mEAA8D;AAC9D,uEAAkE;AAElE,mCAA2F;AAC3F,6DAA8D;AAE9D,MAAM,iBAAiB,GAAG,IAAI,+CAAqB,EAAE,CAAC;AACtD,MAAM,UAAU,GAAqB,CAAC,IAAI,2CAAmB,EAAE,EAAE,IAAI,2CAAsB,EAAE,CAAC,CAAC;AAExF,KAAK,UAAU,SAAS,CAAC,KAAqB,EAAE,OAAuB;IAC5E,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,MAAM,IAAA,4CAA0B,EAAC;QACjF,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,kBAAkB,EAAE,KAAK,CAAC,SAAS;QACnC,gBAAgB,EAAE,KAAK,CAA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* 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 type { McpToolContext } from '../tool-registry';
|
|
9
|
+
import type { RunTargetOutput, StrategyExecutionContext } from './types';
|
|
10
|
+
export interface TargetStrategy {
|
|
11
|
+
/** Whether this strategy is responsible for handling the given target/builder */
|
|
12
|
+
canHandle(targetName: string, builder?: string): boolean;
|
|
13
|
+
/** Executes the target using this strategy */
|
|
14
|
+
execute(input: StrategyExecutionContext, context: McpToolContext): Promise<RunTargetOutput>;
|
|
15
|
+
}
|
|
@@ -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=strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy.js","sourceRoot":"","sources":["strategy.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,39 @@
|
|
|
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 { z } from 'zod';
|
|
9
|
+
export declare const optionValueSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>]>;
|
|
10
|
+
export type OptionValue = z.infer<typeof optionValueSchema>;
|
|
11
|
+
export declare const runTargetInputSchema: z.ZodObject<{
|
|
12
|
+
target: z.ZodString;
|
|
13
|
+
configuration: z.ZodOptional<z.ZodString>;
|
|
14
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>]>>>;
|
|
15
|
+
workspace: z.ZodOptional<z.ZodString>;
|
|
16
|
+
project: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
export type RunTargetInput = z.infer<typeof runTargetInputSchema>;
|
|
19
|
+
export declare const runTargetOutputSchema: z.ZodObject<{
|
|
20
|
+
status: z.ZodEnum<{
|
|
21
|
+
success: "success";
|
|
22
|
+
failure: "failure";
|
|
23
|
+
}>;
|
|
24
|
+
logs: z.ZodArray<z.ZodString>;
|
|
25
|
+
extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
export type RunTargetOutput = z.infer<typeof runTargetOutputSchema>;
|
|
28
|
+
export interface StrategyExecutionContext {
|
|
29
|
+
workspacePath: string;
|
|
30
|
+
projectName: string;
|
|
31
|
+
targetName: string;
|
|
32
|
+
targetDefinition?: {
|
|
33
|
+
builder: string;
|
|
34
|
+
options?: Record<string, unknown>;
|
|
35
|
+
configurations?: Record<string, Record<string, unknown> | undefined>;
|
|
36
|
+
};
|
|
37
|
+
configuration?: string;
|
|
38
|
+
options?: Record<string, OptionValue>;
|
|
39
|
+
}
|
|
@@ -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.runTargetOutputSchema = exports.runTargetInputSchema = exports.optionValueSchema = void 0;
|
|
11
|
+
const zod_1 = require("zod");
|
|
12
|
+
const shared_options_1 = require("../../shared-options");
|
|
13
|
+
exports.optionValueSchema = zod_1.z.union([
|
|
14
|
+
zod_1.z.string(),
|
|
15
|
+
zod_1.z.number(),
|
|
16
|
+
zod_1.z.boolean(),
|
|
17
|
+
zod_1.z.array(zod_1.z.union([zod_1.z.string(), zod_1.z.number()])),
|
|
18
|
+
]);
|
|
19
|
+
exports.runTargetInputSchema = zod_1.z.object({
|
|
20
|
+
...shared_options_1.workspaceAndProjectOptions,
|
|
21
|
+
target: zod_1.z
|
|
22
|
+
.string()
|
|
23
|
+
.describe('The project target to execute (e.g., "build", "test", "lint", "e2e", "deploy").'),
|
|
24
|
+
configuration: zod_1.z
|
|
25
|
+
.string()
|
|
26
|
+
.optional()
|
|
27
|
+
.describe('Target configuration (e.g., "development", "production").'),
|
|
28
|
+
options: zod_1.z
|
|
29
|
+
.record(zod_1.z.string(), exports.optionValueSchema)
|
|
30
|
+
.optional()
|
|
31
|
+
.describe('Optional key-value options to override the configured target options.'),
|
|
32
|
+
});
|
|
33
|
+
exports.runTargetOutputSchema = zod_1.z.object({
|
|
34
|
+
status: zod_1.z.enum(['success', 'failure']).describe('Execution status.'),
|
|
35
|
+
logs: zod_1.z.array(zod_1.z.string()).describe('Clean, line-buffered output logs from execution.'),
|
|
36
|
+
extensions: zod_1.z
|
|
37
|
+
.record(zod_1.z.string(), zod_1.z.unknown())
|
|
38
|
+
.optional()
|
|
39
|
+
.describe('Specialized metadata populated by specific target strategies.'),
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,6BAAwB;AACxB,yDAAkE;AAErD,QAAA,iBAAiB,GAAG,OAAC,CAAC,KAAK,CAAC;IACvC,OAAC,CAAC,MAAM,EAAE;IACV,OAAC,CAAC,MAAM,EAAE;IACV,OAAC,CAAC,OAAO,EAAE;IACX,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;CAC3C,CAAC,CAAC;AAIU,QAAA,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3C,GAAG,2CAA0B;IAC7B,MAAM,EAAE,OAAC;SACN,MAAM,EAAE;SACR,QAAQ,CAAC,iFAAiF,CAAC;IAC9F,aAAa,EAAE,OAAC;SACb,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,2DAA2D,CAAC;IACxE,OAAO,EAAE,OAAC;SACP,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,yBAAiB,CAAC;SACrC,QAAQ,EAAE;SACV,QAAQ,CAAC,uEAAuE,CAAC;CACrF,CAAC,CAAC;AAIU,QAAA,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,MAAM,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,mBAAmB,CAAC;IACpE,IAAI,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,kDAAkD,CAAC;IACtF,UAAU,EAAE,OAAC;SACV,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC;SAC/B,QAAQ,EAAE;SACV,QAAQ,CAAC,+DAA+D,CAAC;CAC7E,CAAC,CAAC"}
|
|
@@ -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.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import type { McpToolContext } from '../tool-registry';
|
|
9
|
+
import type { TargetStrategy } from './strategy';
|
|
10
|
+
import type { RunTargetOutput, StrategyExecutionContext } from './types';
|
|
11
|
+
export declare class UnitTestTargetStrategy implements TargetStrategy {
|
|
12
|
+
canHandle(targetName: string, builder?: string): boolean;
|
|
13
|
+
execute(input: StrategyExecutionContext, context: McpToolContext): Promise<RunTargetOutput>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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.UnitTestTargetStrategy = void 0;
|
|
11
|
+
const utils_1 = require("../../utils");
|
|
12
|
+
const options_serializer_1 = require("./options-serializer");
|
|
13
|
+
class UnitTestTargetStrategy {
|
|
14
|
+
canHandle(targetName, builder) {
|
|
15
|
+
return (targetName === 'test' &&
|
|
16
|
+
(builder === '@angular-devkit/build-angular:karma' ||
|
|
17
|
+
builder === '@angular/build:karma' ||
|
|
18
|
+
builder === '@angular/build:unit-test'));
|
|
19
|
+
}
|
|
20
|
+
async execute(input, context) {
|
|
21
|
+
const args = ['test', input.projectName];
|
|
22
|
+
if (input.configuration) {
|
|
23
|
+
args.push('-c', input.configuration);
|
|
24
|
+
}
|
|
25
|
+
const builder = input.targetDefinition?.builder;
|
|
26
|
+
if (builder === '@angular/build:unit-test') {
|
|
27
|
+
const isKarma = input.targetDefinition?.options?.['runner'] === 'karma';
|
|
28
|
+
if (isKarma) {
|
|
29
|
+
args.push('--browsers', 'ChromeHeadless');
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
args.push('--headless', 'true');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
// Default Karma-based builders require explicit ChromeHeadless
|
|
37
|
+
args.push('--browsers', 'ChromeHeadless');
|
|
38
|
+
}
|
|
39
|
+
// Force non-interactive one-off execution
|
|
40
|
+
args.push('--watch', 'false');
|
|
41
|
+
args.push(...(0, options_serializer_1.serializeOptions)(input.options, new Set(['watch'])));
|
|
42
|
+
let status = 'success';
|
|
43
|
+
let logs;
|
|
44
|
+
try {
|
|
45
|
+
const result = await context.host.executeNgCommand(args, { cwd: input.workspacePath });
|
|
46
|
+
logs = result.logs;
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
status = 'failure';
|
|
50
|
+
logs = (0, utils_1.getCommandErrorLogs)(e);
|
|
51
|
+
}
|
|
52
|
+
return { status, logs };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.UnitTestTargetStrategy = UnitTestTargetStrategy;
|
|
56
|
+
//# sourceMappingURL=unit-test-strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unit-test-strategy.js","sourceRoot":"","sources":["unit-test-strategy.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,uCAAkD;AAElD,6DAAwD;AAIxD,MAAa,sBAAsB;IACjC,SAAS,CAAC,UAAkB,EAAE,OAAgB;QAC5C,OAAO,CACL,UAAU,KAAK,MAAM;YACrB,CAAC,OAAO,KAAK,qCAAqC;gBAChD,OAAO,KAAK,sBAAsB;gBAClC,OAAO,KAAK,0BAA0B,CAAC,CAC1C,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO,CACX,KAA+B,EAC/B,OAAuB;QAEvB,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;QACzC,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;YACxB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC,C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@@ -41,8 +41,9 @@ export declare function getDefaultProjectName(workspace: AngularWorkspace | unde
|
|
|
41
41
|
* current directory as the workspace.
|
|
42
42
|
* If `projectNameInput` is absent, uses the default project in the workspace.
|
|
43
43
|
*/
|
|
44
|
-
export declare function resolveWorkspaceAndProject({ host, workspacePathInput, projectNameInput, mcpWorkspace, }: {
|
|
44
|
+
export declare function resolveWorkspaceAndProject({ host, server, workspacePathInput, projectNameInput, mcpWorkspace, }: {
|
|
45
45
|
host: Host;
|
|
46
|
+
server?: McpToolContext['server'];
|
|
46
47
|
workspacePathInput?: string;
|
|
47
48
|
projectNameInput?: string;
|
|
48
49
|
mcpWorkspace?: AngularWorkspace;
|
|
@@ -11,7 +11,9 @@ exports.findAngularJsonDir = findAngularJsonDir;
|
|
|
11
11
|
exports.getProject = getProject;
|
|
12
12
|
exports.getDefaultProjectName = getDefaultProjectName;
|
|
13
13
|
exports.resolveWorkspaceAndProject = resolveWorkspaceAndProject;
|
|
14
|
+
const node_fs_1 = require("node:fs");
|
|
14
15
|
const node_path_1 = require("node:path");
|
|
16
|
+
const node_url_1 = require("node:url");
|
|
15
17
|
const config_1 = require("../../utilities/config");
|
|
16
18
|
const host_1 = require("./host");
|
|
17
19
|
/**
|
|
@@ -71,6 +73,36 @@ function getDefaultProjectName(workspace) {
|
|
|
71
73
|
}
|
|
72
74
|
return undefined;
|
|
73
75
|
}
|
|
76
|
+
function isWithinAllowedRoot(root, targetPath) {
|
|
77
|
+
const rel = (0, node_path_1.relative)(root, targetPath);
|
|
78
|
+
return !rel.startsWith('..') && !(0, node_path_1.isAbsolute)(rel);
|
|
79
|
+
}
|
|
80
|
+
async function getAllowedWorkspaceRoots(server) {
|
|
81
|
+
let roots;
|
|
82
|
+
const clientCapabilities = server.server.getClientCapabilities();
|
|
83
|
+
if (clientCapabilities?.roots) {
|
|
84
|
+
const { roots: clientRoots } = await server.server.listRoots();
|
|
85
|
+
roots = clientRoots?.map((root) => (0, node_url_1.fileURLToPath)(root.uri)) ?? [];
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
roots = [process.cwd()];
|
|
89
|
+
}
|
|
90
|
+
return roots
|
|
91
|
+
.map((root) => {
|
|
92
|
+
try {
|
|
93
|
+
return (0, node_fs_1.realpathSync)(root);
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
.filter((root) => root !== null);
|
|
100
|
+
}
|
|
101
|
+
async function isAllowedWorkspacePath(server, workspacePath) {
|
|
102
|
+
const allowedRoots = await getAllowedWorkspaceRoots(server);
|
|
103
|
+
const resolvedWorkspacePath = (0, node_fs_1.realpathSync)(workspacePath);
|
|
104
|
+
return allowedRoots.some((root) => isWithinAllowedRoot(root, resolvedWorkspacePath));
|
|
105
|
+
}
|
|
74
106
|
/**
|
|
75
107
|
* Resolves workspace and project for tools to operate on.
|
|
76
108
|
*
|
|
@@ -78,7 +110,7 @@ function getDefaultProjectName(workspace) {
|
|
|
78
110
|
* current directory as the workspace.
|
|
79
111
|
* If `projectNameInput` is absent, uses the default project in the workspace.
|
|
80
112
|
*/
|
|
81
|
-
async function resolveWorkspaceAndProject({ host, workspacePathInput, projectNameInput, mcpWorkspace, }) {
|
|
113
|
+
async function resolveWorkspaceAndProject({ host, server, workspacePathInput, projectNameInput, mcpWorkspace, }) {
|
|
82
114
|
let workspacePath;
|
|
83
115
|
let workspace;
|
|
84
116
|
if (workspacePathInput) {
|
|
@@ -90,13 +122,19 @@ async function resolveWorkspaceAndProject({ host, workspacePathInput, projectNam
|
|
|
90
122
|
throw new Error(`No angular.json found at ${workspacePathInput}. ` +
|
|
91
123
|
"You can use 'list_projects' to find available workspaces.");
|
|
92
124
|
}
|
|
125
|
+
if (server) {
|
|
126
|
+
if (!(await isAllowedWorkspacePath(server, workspacePathInput))) {
|
|
127
|
+
throw new Error(`Workspace path is outside the allowed MCP roots: ${workspacePathInput}. ` +
|
|
128
|
+
"You can use 'list_projects' to find available workspaces.");
|
|
129
|
+
}
|
|
130
|
+
}
|
|
93
131
|
workspacePath = workspacePathInput;
|
|
94
132
|
const configPath = (0, node_path_1.join)(workspacePath, 'angular.json');
|
|
95
133
|
try {
|
|
96
134
|
workspace = await config_1.AngularWorkspace.load(configPath);
|
|
97
135
|
}
|
|
98
136
|
catch (e) {
|
|
99
|
-
throw new Error(`Failed to load workspace configuration at ${configPath}
|
|
137
|
+
throw new Error(`Failed to load workspace configuration at ${configPath}`, { cause: e });
|
|
100
138
|
}
|
|
101
139
|
}
|
|
102
140
|
else if (mcpWorkspace) {
|
|
@@ -109,13 +147,17 @@ async function resolveWorkspaceAndProject({ host, workspacePathInput, projectNam
|
|
|
109
147
|
throw new Error('Could not find an Angular workspace (angular.json) in the current directory. ' +
|
|
110
148
|
"You can use 'list_projects' to find available workspaces.");
|
|
111
149
|
}
|
|
150
|
+
if (server && !(await isAllowedWorkspacePath(server, found))) {
|
|
151
|
+
throw new Error(`The current directory resolves to a workspace outside the allowed MCP roots: ${found}. ` +
|
|
152
|
+
"You can use 'list_projects' to find available workspaces.");
|
|
153
|
+
}
|
|
112
154
|
workspacePath = found;
|
|
113
155
|
const configPath = (0, node_path_1.join)(workspacePath, 'angular.json');
|
|
114
156
|
try {
|
|
115
157
|
workspace = await config_1.AngularWorkspace.load(configPath);
|
|
116
158
|
}
|
|
117
159
|
catch (e) {
|
|
118
|
-
throw new Error(`Failed to load workspace configuration at ${configPath}
|
|
160
|
+
throw new Error(`Failed to load workspace configuration at ${configPath}.`, { cause: e });
|
|
119
161
|
}
|
|
120
162
|
}
|
|
121
163
|
let projectName = projectNameInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-utils.js","sourceRoot":"","sources":["workspace-utils.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;
|
|
1
|
+
{"version":3,"file":"workspace-utils.js","sourceRoot":"","sources":["workspace-utils.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAuBH,gDA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,YAAY,WAAW,iCAAiC,aAAa,IAAI;gBACvE,yDAAyD,CAC5D,CAAC;QACJ,CAAC;IACH,CAAC;SAAM,CAAC;QACN,WAAW,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CACb,2EAA2E,aAAa,IAAI;YAC1F,0EAA0E;YAC1E,yDAAyD,CAC5D,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC;AACnD,CAAC"}
|
|
@@ -214,6 +214,7 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
214
214
|
verbose: options.verbose,
|
|
215
215
|
packageManager: packageManager.name,
|
|
216
216
|
packages: [],
|
|
217
|
+
workspaceRoot: this.context.root,
|
|
217
218
|
});
|
|
218
219
|
return success ? 0 : 1;
|
|
219
220
|
}
|
|
@@ -223,13 +224,12 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
223
224
|
}
|
|
224
225
|
async migrateOnly(workflow, packageName, rootDependencies, options, packageManager) {
|
|
225
226
|
const { logger } = this.context;
|
|
226
|
-
|
|
227
|
+
const packageDependency = rootDependencies.get(packageName);
|
|
227
228
|
let packagePath = packageDependency?.path;
|
|
228
229
|
let packageNode;
|
|
229
230
|
if (!packageDependency) {
|
|
230
231
|
const installed = await packageManager.getInstalledPackage(packageName);
|
|
231
232
|
if (installed) {
|
|
232
|
-
packageDependency = installed;
|
|
233
233
|
packagePath = installed.path;
|
|
234
234
|
}
|
|
235
235
|
}
|
|
@@ -333,7 +333,7 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
333
333
|
const packagesToUpdate = [];
|
|
334
334
|
for (const { identifier: requestIdentifier, node } of requests) {
|
|
335
335
|
const packageName = requestIdentifier.name;
|
|
336
|
-
let manifest
|
|
336
|
+
let manifest;
|
|
337
337
|
try {
|
|
338
338
|
manifest = await packageManager.getManifest(requestIdentifier);
|
|
339
339
|
}
|
|
@@ -383,6 +383,7 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
383
383
|
next: options.next,
|
|
384
384
|
packageManager: this.context.packageManager.name,
|
|
385
385
|
packages: packagesToUpdate,
|
|
386
|
+
workspaceRoot: this.context.root,
|
|
386
387
|
});
|
|
387
388
|
if (success) {
|
|
388
389
|
const { root: commandRoot } = this.context;
|