@angular/cli 20.2.0-next.1 → 20.2.0-next.2
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/code-examples.db +0 -0
- package/package.json +16 -17
- package/src/commands/mcp/cli.js +1 -1
- package/src/commands/mcp/instructions/best-practices.md +9 -1
- package/src/commands/mcp/mcp-server.d.ts +2 -0
- package/src/commands/mcp/mcp-server.js +18 -2
- package/src/commands/mcp/tools/examples.d.ts +31 -0
- package/src/commands/mcp/tools/examples.js +190 -0
- package/src/commands/update/cli.js +36 -31
- package/src/utilities/version.js +1 -1
- package/src/typings.d.ts +0 -15
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/cli",
|
|
3
|
-
"version": "20.2.0-next.
|
|
3
|
+
"version": "20.2.0-next.2",
|
|
4
4
|
"description": "CLI tool for Angular",
|
|
5
5
|
"main": "lib/cli/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -25,20 +25,19 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://github.com/angular/angular-cli",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@angular-devkit/architect": "0.2002.0-next.
|
|
29
|
-
"@angular-devkit/core": "20.2.0-next.
|
|
30
|
-
"@angular-devkit/schematics": "20.2.0-next.
|
|
28
|
+
"@angular-devkit/architect": "0.2002.0-next.2",
|
|
29
|
+
"@angular-devkit/core": "20.2.0-next.2",
|
|
30
|
+
"@angular-devkit/schematics": "20.2.0-next.2",
|
|
31
31
|
"@inquirer/prompts": "7.7.1",
|
|
32
32
|
"@listr2/prompt-adapter-inquirer": "3.0.1",
|
|
33
|
-
"@modelcontextprotocol/sdk": "1.
|
|
34
|
-
"@schematics/angular": "20.2.0-next.
|
|
33
|
+
"@modelcontextprotocol/sdk": "1.17.0",
|
|
34
|
+
"@schematics/angular": "20.2.0-next.2",
|
|
35
35
|
"@yarnpkg/lockfile": "1.1.0",
|
|
36
|
-
"algoliasearch": "5.34.
|
|
36
|
+
"algoliasearch": "5.34.1",
|
|
37
37
|
"ini": "5.0.0",
|
|
38
38
|
"jsonc-parser": "3.3.1",
|
|
39
39
|
"listr2": "9.0.1",
|
|
40
|
-
"npm-package-arg": "
|
|
41
|
-
"npm-pick-manifest": "10.0.0",
|
|
40
|
+
"npm-package-arg": "13.0.0",
|
|
42
41
|
"pacote": "21.0.0",
|
|
43
42
|
"resolve": "1.22.10",
|
|
44
43
|
"semver": "7.7.2",
|
|
@@ -48,14 +47,14 @@
|
|
|
48
47
|
"ng-update": {
|
|
49
48
|
"migrations": "@schematics/angular/migrations/migration-collection.json",
|
|
50
49
|
"packageGroup": {
|
|
51
|
-
"@angular/cli": "20.2.0-next.
|
|
52
|
-
"@angular/build": "20.2.0-next.
|
|
53
|
-
"@angular/ssr": "20.2.0-next.
|
|
54
|
-
"@angular-devkit/architect": "0.2002.0-next.
|
|
55
|
-
"@angular-devkit/build-angular": "20.2.0-next.
|
|
56
|
-
"@angular-devkit/build-webpack": "0.2002.0-next.
|
|
57
|
-
"@angular-devkit/core": "20.2.0-next.
|
|
58
|
-
"@angular-devkit/schematics": "20.2.0-next.
|
|
50
|
+
"@angular/cli": "20.2.0-next.2",
|
|
51
|
+
"@angular/build": "20.2.0-next.2",
|
|
52
|
+
"@angular/ssr": "20.2.0-next.2",
|
|
53
|
+
"@angular-devkit/architect": "0.2002.0-next.2",
|
|
54
|
+
"@angular-devkit/build-angular": "20.2.0-next.2",
|
|
55
|
+
"@angular-devkit/build-webpack": "0.2002.0-next.2",
|
|
56
|
+
"@angular-devkit/core": "20.2.0-next.2",
|
|
57
|
+
"@angular-devkit/schematics": "20.2.0-next.2"
|
|
59
58
|
}
|
|
60
59
|
},
|
|
61
60
|
"packageManager": "pnpm@9.15.9",
|
package/src/commands/mcp/cli.js
CHANGED
|
@@ -37,7 +37,7 @@ class McpCommandModule extends command_module_1.CommandModule {
|
|
|
37
37
|
this.context.logger.info(INTERACTIVE_MESSAGE);
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
const server = await (0, mcp_server_1.createMcpServer)({ workspace: this.context.workspace });
|
|
40
|
+
const server = await (0, mcp_server_1.createMcpServer)({ workspace: this.context.workspace }, this.context.logger);
|
|
41
41
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
42
42
|
await server.connect(transport);
|
|
43
43
|
}
|
|
@@ -9,10 +9,12 @@ You are an expert in TypeScript, Angular, and scalable web application developme
|
|
|
9
9
|
## Angular Best Practices
|
|
10
10
|
|
|
11
11
|
- Always use standalone components over NgModules
|
|
12
|
-
-
|
|
12
|
+
- Must NOT set `standalone: true` inside Angular decorators. It's the default.
|
|
13
13
|
- Use signals for state management
|
|
14
14
|
- Implement lazy loading for feature routes
|
|
15
|
+
- Do NOT use the `@HostBinding` and `@HostListener` decorators. Put host bindings inside the `host` object of the `@Component` or `@Directive` decorator instead
|
|
15
16
|
- Use `NgOptimizedImage` for all static images.
|
|
17
|
+
- `NgOptimizedImage` does not work for inline base64 images.
|
|
16
18
|
|
|
17
19
|
## Components
|
|
18
20
|
|
|
@@ -30,6 +32,7 @@ You are an expert in TypeScript, Angular, and scalable web application developme
|
|
|
30
32
|
- Use signals for local component state
|
|
31
33
|
- Use `computed()` for derived state
|
|
32
34
|
- Keep state transformations pure and predictable
|
|
35
|
+
- Do NOT use `mutate` on signals, use `update` or `set` instead
|
|
33
36
|
|
|
34
37
|
## Templates
|
|
35
38
|
|
|
@@ -42,3 +45,8 @@ You are an expert in TypeScript, Angular, and scalable web application developme
|
|
|
42
45
|
- Design services around a single responsibility
|
|
43
46
|
- Use the `providedIn: 'root'` option for singleton services
|
|
44
47
|
- Use the `inject()` function instead of constructor injection
|
|
48
|
+
|
|
49
|
+
## Common pitfalls
|
|
50
|
+
|
|
51
|
+
- Control flow (`@if`):
|
|
52
|
+
- You cannot use `as` expressions in `@else if (...)`. E.g. invalid code: `@else if (bla(); as x)`.
|
|
@@ -9,4 +9,6 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
9
9
|
import type { AngularWorkspace } from '../../utilities/config';
|
|
10
10
|
export declare function createMcpServer(context: {
|
|
11
11
|
workspace?: AngularWorkspace;
|
|
12
|
+
}, logger: {
|
|
13
|
+
warn(text: string): void;
|
|
12
14
|
}): Promise<McpServer>;
|
|
@@ -17,8 +17,9 @@ const node_path_1 = __importDefault(require("node:path"));
|
|
|
17
17
|
const version_1 = require("../../utilities/version");
|
|
18
18
|
const best_practices_1 = require("./tools/best-practices");
|
|
19
19
|
const doc_search_1 = require("./tools/doc-search");
|
|
20
|
+
const examples_1 = require("./tools/examples");
|
|
20
21
|
const projects_1 = require("./tools/projects");
|
|
21
|
-
async function createMcpServer(context) {
|
|
22
|
+
async function createMcpServer(context, logger) {
|
|
22
23
|
const server = new mcp_js_1.McpServer({
|
|
23
24
|
name: 'angular-cli-server',
|
|
24
25
|
version: version_1.VERSION.full,
|
|
@@ -39,7 +40,22 @@ async function createMcpServer(context) {
|
|
|
39
40
|
return { contents: [{ uri: 'instructions://best-practices', text }] };
|
|
40
41
|
});
|
|
41
42
|
(0, best_practices_1.registerBestPracticesTool)(server);
|
|
42
|
-
(
|
|
43
|
+
// If run outside an Angular workspace (e.g., globally) skip the workspace specific tools.
|
|
44
|
+
// Currently only the `list_projects` tool.
|
|
45
|
+
if (!context.workspace) {
|
|
46
|
+
(0, projects_1.registerListProjectsTool)(server, context);
|
|
47
|
+
}
|
|
43
48
|
await (0, doc_search_1.registerDocSearchTool)(server);
|
|
49
|
+
if (process.env['NG_MCP_CODE_EXAMPLES'] === '1') {
|
|
50
|
+
// sqlite database support requires Node.js 22.16+
|
|
51
|
+
const [nodeMajor, nodeMinor] = process.versions.node.split('.', 2).map(Number);
|
|
52
|
+
if (nodeMajor < 22 || (nodeMajor === 22 && nodeMinor < 16)) {
|
|
53
|
+
logger.warn(`MCP tool 'find_examples' requires Node.js 22.16 (or higher). ` +
|
|
54
|
+
' Registration of this tool has been skipped.');
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
(0, examples_1.registerFindExampleTool)(server, node_path_1.default.join(__dirname, '../../../lib/code-examples.db'));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
44
60
|
return server;
|
|
45
61
|
}
|
|
@@ -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
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
9
|
+
/**
|
|
10
|
+
* Registers the `find_examples` tool with the MCP server.
|
|
11
|
+
*
|
|
12
|
+
* This tool allows users to search for best-practice Angular code examples
|
|
13
|
+
* from a local SQLite database.
|
|
14
|
+
*
|
|
15
|
+
* @param server The MCP server instance.
|
|
16
|
+
* @param exampleDatabasePath The path to the SQLite database file containing the examples.
|
|
17
|
+
*/
|
|
18
|
+
export declare function registerFindExampleTool(server: McpServer, exampleDatabasePath: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* Escapes a search query for FTS5 by tokenizing and quoting terms.
|
|
21
|
+
*
|
|
22
|
+
* This function processes a raw search string and prepares it for an FTS5 full-text search.
|
|
23
|
+
* It correctly handles quoted phrases, logical operators (AND, OR, NOT), parentheses,
|
|
24
|
+
* and prefix searches (ending with an asterisk), ensuring that individual search
|
|
25
|
+
* terms are properly quoted to be treated as literals by the search engine.
|
|
26
|
+
* This is primarily intended to avoid unintentional usage of FTS5 query syntax by consumers.
|
|
27
|
+
*
|
|
28
|
+
* @param query The raw search query string.
|
|
29
|
+
* @returns A sanitized query string suitable for FTS5.
|
|
30
|
+
*/
|
|
31
|
+
export declare function escapeSearchQuery(query: string): string;
|
|
@@ -0,0 +1,190 @@
|
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.registerFindExampleTool = registerFindExampleTool;
|
|
44
|
+
exports.escapeSearchQuery = escapeSearchQuery;
|
|
45
|
+
const zod_1 = require("zod");
|
|
46
|
+
/**
|
|
47
|
+
* Registers the `find_examples` tool with the MCP server.
|
|
48
|
+
*
|
|
49
|
+
* This tool allows users to search for best-practice Angular code examples
|
|
50
|
+
* from a local SQLite database.
|
|
51
|
+
*
|
|
52
|
+
* @param server The MCP server instance.
|
|
53
|
+
* @param exampleDatabasePath The path to the SQLite database file containing the examples.
|
|
54
|
+
*/
|
|
55
|
+
function registerFindExampleTool(server, exampleDatabasePath) {
|
|
56
|
+
let db;
|
|
57
|
+
let queryStatement;
|
|
58
|
+
server.registerTool('find_examples', {
|
|
59
|
+
title: 'Find Angular Code Examples',
|
|
60
|
+
description: 'Before writing or modifying any Angular code including templates, ' +
|
|
61
|
+
'**ALWAYS** use this tool to find current best-practice examples. ' +
|
|
62
|
+
'This is critical for ensuring code quality and adherence to modern Angular standards. ' +
|
|
63
|
+
'This tool searches a curated database of approved Angular code examples and returns the most relevant results for your query. ' +
|
|
64
|
+
'Example Use Cases: ' +
|
|
65
|
+
"1) Creating new components, directives, or services (e.g., query: 'standalone component' or 'signal input'). " +
|
|
66
|
+
"2) Implementing core features (e.g., query: 'lazy load route', 'httpinterceptor', or 'route guard'). " +
|
|
67
|
+
"3) Refactoring existing code to use modern patterns (e.g., query: 'ngfor trackby' or 'form validation').",
|
|
68
|
+
inputSchema: {
|
|
69
|
+
query: zod_1.z.string().describe(`Performs a full-text search using FTS5 syntax. The query should target relevant Angular concepts.
|
|
70
|
+
|
|
71
|
+
Key Syntax Features (see https://www.sqlite.org/fts5.html for full documentation):
|
|
72
|
+
- AND (default): Space-separated terms are combined with AND.
|
|
73
|
+
- Example: 'standalone component' (finds results with both "standalone" and "component")
|
|
74
|
+
- OR: Use the OR operator to find results with either term.
|
|
75
|
+
- Example: 'validation OR validator'
|
|
76
|
+
- NOT: Use the NOT operator to exclude terms.
|
|
77
|
+
- Example: 'forms NOT reactive'
|
|
78
|
+
- Grouping: Use parentheses () to group expressions.
|
|
79
|
+
- Example: '(validation OR validator) AND forms'
|
|
80
|
+
- Phrase Search: Use double quotes "" for exact phrases.
|
|
81
|
+
- Example: '"template-driven forms"'
|
|
82
|
+
- Prefix Search: Use an asterisk * for prefix matching.
|
|
83
|
+
- Example: 'rout*' (matches "route", "router", "routing")
|
|
84
|
+
|
|
85
|
+
Examples of queries:
|
|
86
|
+
- Find standalone components: 'standalone component'
|
|
87
|
+
- Find ngFor with trackBy: 'ngFor trackBy'
|
|
88
|
+
- Find signal inputs: 'signal input'
|
|
89
|
+
- Find lazy loading a route: 'lazy load route'
|
|
90
|
+
- Find forms with validation: 'form AND (validation OR validator)'`),
|
|
91
|
+
},
|
|
92
|
+
annotations: {
|
|
93
|
+
readOnlyHint: true,
|
|
94
|
+
openWorldHint: false,
|
|
95
|
+
},
|
|
96
|
+
}, async ({ query }) => {
|
|
97
|
+
if (!db || !queryStatement) {
|
|
98
|
+
suppressSqliteWarning();
|
|
99
|
+
const { DatabaseSync } = await Promise.resolve().then(() => __importStar(require('node:sqlite')));
|
|
100
|
+
db = new DatabaseSync(exampleDatabasePath, { readOnly: true });
|
|
101
|
+
queryStatement = db.prepare('SELECT * from examples WHERE examples MATCH ? ORDER BY rank;');
|
|
102
|
+
}
|
|
103
|
+
const sanitizedQuery = escapeSearchQuery(query);
|
|
104
|
+
// Query database and return results as text content
|
|
105
|
+
const content = [];
|
|
106
|
+
for (const exampleRecord of queryStatement.all(sanitizedQuery)) {
|
|
107
|
+
content.push({ type: 'text', text: exampleRecord['content'] });
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
content,
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Escapes a search query for FTS5 by tokenizing and quoting terms.
|
|
116
|
+
*
|
|
117
|
+
* This function processes a raw search string and prepares it for an FTS5 full-text search.
|
|
118
|
+
* It correctly handles quoted phrases, logical operators (AND, OR, NOT), parentheses,
|
|
119
|
+
* and prefix searches (ending with an asterisk), ensuring that individual search
|
|
120
|
+
* terms are properly quoted to be treated as literals by the search engine.
|
|
121
|
+
* This is primarily intended to avoid unintentional usage of FTS5 query syntax by consumers.
|
|
122
|
+
*
|
|
123
|
+
* @param query The raw search query string.
|
|
124
|
+
* @returns A sanitized query string suitable for FTS5.
|
|
125
|
+
*/
|
|
126
|
+
function escapeSearchQuery(query) {
|
|
127
|
+
// This regex tokenizes the query string into parts:
|
|
128
|
+
// 1. Quoted phrases (e.g., "foo bar")
|
|
129
|
+
// 2. Parentheses ( and )
|
|
130
|
+
// 3. FTS5 operators (AND, OR, NOT, NEAR)
|
|
131
|
+
// 4. Words, which can include a trailing asterisk for prefix search (e.g., foo*)
|
|
132
|
+
const tokenizer = /"([^"]*)"|([()])|\b(AND|OR|NOT|NEAR)\b|([^\s()]+)/g;
|
|
133
|
+
let match;
|
|
134
|
+
const result = [];
|
|
135
|
+
let lastIndex = 0;
|
|
136
|
+
while ((match = tokenizer.exec(query)) !== null) {
|
|
137
|
+
// Add any whitespace or other characters between tokens
|
|
138
|
+
if (match.index > lastIndex) {
|
|
139
|
+
result.push(query.substring(lastIndex, match.index));
|
|
140
|
+
}
|
|
141
|
+
const [, quoted, parenthesis, operator, term] = match;
|
|
142
|
+
if (quoted !== undefined) {
|
|
143
|
+
// It's a quoted phrase, keep it as is.
|
|
144
|
+
result.push(`"${quoted}"`);
|
|
145
|
+
}
|
|
146
|
+
else if (parenthesis) {
|
|
147
|
+
// It's a parenthesis, keep it as is.
|
|
148
|
+
result.push(parenthesis);
|
|
149
|
+
}
|
|
150
|
+
else if (operator) {
|
|
151
|
+
// It's an operator, keep it as is.
|
|
152
|
+
result.push(operator);
|
|
153
|
+
}
|
|
154
|
+
else if (term) {
|
|
155
|
+
// It's a term that needs to be quoted.
|
|
156
|
+
if (term.endsWith('*')) {
|
|
157
|
+
result.push(`"${term.slice(0, -1)}"*`);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
result.push(`"${term}"`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
lastIndex = tokenizer.lastIndex;
|
|
164
|
+
}
|
|
165
|
+
// Add any remaining part of the string
|
|
166
|
+
if (lastIndex < query.length) {
|
|
167
|
+
result.push(query.substring(lastIndex));
|
|
168
|
+
}
|
|
169
|
+
return result.join('');
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Suppresses the experimental warning emitted by Node.js for the `node:sqlite` module.
|
|
173
|
+
*
|
|
174
|
+
* This is a workaround to prevent the console from being cluttered with warnings
|
|
175
|
+
* about the experimental status of the SQLite module, which is used by this tool.
|
|
176
|
+
*/
|
|
177
|
+
function suppressSqliteWarning() {
|
|
178
|
+
const originalProcessEmit = process.emit;
|
|
179
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
180
|
+
process.emit = function (event, error) {
|
|
181
|
+
if (event === 'warning' &&
|
|
182
|
+
error instanceof Error &&
|
|
183
|
+
error.name === 'ExperimentalWarning' &&
|
|
184
|
+
error.message.includes('SQLite')) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, prefer-rest-params
|
|
188
|
+
return originalProcessEmit.apply(process, arguments);
|
|
189
|
+
};
|
|
190
|
+
}
|
|
@@ -52,7 +52,6 @@ const node_module_1 = require("node:module");
|
|
|
52
52
|
const path = __importStar(require("node:path"));
|
|
53
53
|
const node_path_1 = require("node:path");
|
|
54
54
|
const npm_package_arg_1 = __importDefault(require("npm-package-arg"));
|
|
55
|
-
const npm_pick_manifest_1 = __importDefault(require("npm-pick-manifest"));
|
|
56
55
|
const semver = __importStar(require("semver"));
|
|
57
56
|
const workspace_schema_1 = require("../../../lib/config/workspace-schema");
|
|
58
57
|
const command_module_1 = require("../../command-builder/command-module");
|
|
@@ -189,9 +188,11 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
189
188
|
if (options.migrateOnly && packageIdentifier.rawSpec !== '*') {
|
|
190
189
|
logger.warn('Package specifier has no effect when using "migrate-only" option.');
|
|
191
190
|
}
|
|
192
|
-
//
|
|
193
|
-
if
|
|
194
|
-
|
|
191
|
+
// Wildcard uses the next tag if next option is used otherwise use latest tag.
|
|
192
|
+
// Wildcard is present if no selector is provided on the command line.
|
|
193
|
+
if (packageIdentifier.rawSpec === '*') {
|
|
194
|
+
packageIdentifier.fetchSpec = options.next ? 'next' : 'latest';
|
|
195
|
+
packageIdentifier.type = 'tag';
|
|
195
196
|
}
|
|
196
197
|
packages.push(packageIdentifier);
|
|
197
198
|
}
|
|
@@ -480,35 +481,39 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
480
481
|
// Try to find a package version based on the user requested package specifier
|
|
481
482
|
// registry specifier types are either version, range, or tag
|
|
482
483
|
let manifest;
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
// If not found and next was used and user did not provide a specifier, try latest.
|
|
493
|
-
// Package may not have a next tag.
|
|
494
|
-
if (requestIdentifier.type === 'tag' &&
|
|
495
|
-
requestIdentifier.fetchSpec === 'next' &&
|
|
496
|
-
!requestIdentifier.rawSpec) {
|
|
497
|
-
try {
|
|
498
|
-
manifest = (0, npm_pick_manifest_1.default)(metadata, 'latest');
|
|
499
|
-
}
|
|
500
|
-
catch (e) {
|
|
501
|
-
(0, error_1.assertIsError)(e);
|
|
502
|
-
if (e.code !== 'ETARGET' && e.code !== 'ENOVERSIONS') {
|
|
503
|
-
throw e;
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
}
|
|
484
|
+
switch (requestIdentifier.type) {
|
|
485
|
+
case 'tag':
|
|
486
|
+
manifest = metadata.tags[requestIdentifier.fetchSpec];
|
|
487
|
+
// If not found and next option was used and user did not provide a specifier, try latest.
|
|
488
|
+
// Package may not have a next tag.
|
|
489
|
+
if (!manifest &&
|
|
490
|
+
requestIdentifier.fetchSpec === 'next' &&
|
|
491
|
+
requestIdentifier.rawSpec === '*') {
|
|
492
|
+
manifest = metadata.tags['latest'];
|
|
507
493
|
}
|
|
508
|
-
|
|
509
|
-
|
|
494
|
+
break;
|
|
495
|
+
case 'version':
|
|
496
|
+
manifest = metadata.versions[requestIdentifier.fetchSpec];
|
|
497
|
+
break;
|
|
498
|
+
case 'range':
|
|
499
|
+
for (const potentialManifest of Object.values(metadata.versions)) {
|
|
500
|
+
// Ignore deprecated package versions
|
|
501
|
+
if (potentialManifest.deprecated) {
|
|
502
|
+
continue;
|
|
503
|
+
}
|
|
504
|
+
// Only consider versions that are within the range
|
|
505
|
+
if (!semver.satisfies(potentialManifest.version, requestIdentifier.fetchSpec, {
|
|
506
|
+
loose: true,
|
|
507
|
+
})) {
|
|
508
|
+
continue;
|
|
509
|
+
}
|
|
510
|
+
// Update the used manifest if current potential is newer than existing or there is not one yet
|
|
511
|
+
if (!manifest ||
|
|
512
|
+
semver.gt(potentialManifest.version, manifest.version, { loose: true })) {
|
|
513
|
+
manifest = potentialManifest;
|
|
514
|
+
}
|
|
510
515
|
}
|
|
511
|
-
|
|
516
|
+
break;
|
|
512
517
|
}
|
|
513
518
|
if (!manifest) {
|
|
514
519
|
logger.error(`Package specified by '${requestIdentifier.raw}' does not exist within the registry.`);
|
package/src/utilities/version.js
CHANGED
package/src/typings.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
declare module 'npm-pick-manifest' {
|
|
10
|
-
function pickManifest(
|
|
11
|
-
metadata: import('./utilities/package-metadata').PackageMetadata,
|
|
12
|
-
selector: string,
|
|
13
|
-
): import('./utilities/package-metadata').PackageManifest;
|
|
14
|
-
export = pickManifest;
|
|
15
|
-
}
|