@ng-annotate/angular 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -69,48 +69,76 @@ function addProviders() {
|
|
|
69
69
|
context.logger.info(`✅ Added provideNgAnnotate() to ${appConfigPath}`);
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
-
function addMcpConfig() {
|
|
72
|
+
function addMcpConfig(options) {
|
|
73
73
|
return (tree, context) => {
|
|
74
|
-
// The project root at ng-add time — used to build stable absolute paths.
|
|
75
|
-
// MCP hosts (VS Code Copilot, Claude Code) may spawn the server with a
|
|
76
|
-
// different cwd, so we bake in the paths rather than relying on cwd.
|
|
77
74
|
const projectRoot = process.cwd().replace(/\\/g, '/');
|
|
78
|
-
const serverEntry = `${projectRoot}/node_modules/@ng-annotate/mcp-server/dist/index.js`;
|
|
79
75
|
const env = { NG_ANNOTATE_PROJECT_ROOT: projectRoot };
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const
|
|
76
|
+
const isWindows = process.platform === 'win32';
|
|
77
|
+
const { aiTool } = options;
|
|
78
|
+
if (aiTool === 'other') {
|
|
79
|
+
const claudeConfig = JSON.stringify({
|
|
84
80
|
mcpServers: {
|
|
85
81
|
'ng-annotate': isWindows
|
|
86
|
-
? { command: 'cmd', args: ['/c', '
|
|
87
|
-
: { command: '
|
|
82
|
+
? { command: 'cmd', args: ['/c', 'npx', '-y', '@ng-annotate/mcp-server'], env }
|
|
83
|
+
: { command: 'npx', args: ['-y', '@ng-annotate/mcp-server'], env },
|
|
88
84
|
},
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
context.logger.info('✅ Created .mcp.json');
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
context.logger.info('.mcp.json already exists, skipping.');
|
|
95
|
-
}
|
|
96
|
-
// .vscode/mcp.json — VS Code Copilot
|
|
97
|
-
const vscodeMcpPath = '.vscode/mcp.json';
|
|
98
|
-
if (!tree.exists(vscodeMcpPath)) {
|
|
99
|
-
const vscodeMcpConfig = {
|
|
85
|
+
}, null, 2);
|
|
86
|
+
const vscodeConfig = JSON.stringify({
|
|
100
87
|
servers: {
|
|
101
88
|
'ng-annotate': {
|
|
102
89
|
type: 'stdio',
|
|
103
|
-
command: '
|
|
104
|
-
args: [
|
|
90
|
+
command: 'npx',
|
|
91
|
+
args: ['-y', '@ng-annotate/mcp-server'],
|
|
105
92
|
env,
|
|
106
93
|
},
|
|
107
94
|
},
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
|
|
95
|
+
}, null, 2);
|
|
96
|
+
context.logger.info('\n⚙️ Manual MCP configuration:\n\n' +
|
|
97
|
+
'For Claude Code (.mcp.json):\n' +
|
|
98
|
+
claudeConfig +
|
|
99
|
+
'\n\n' +
|
|
100
|
+
'For VS Code Copilot (.vscode/mcp.json):\n' +
|
|
101
|
+
vscodeConfig +
|
|
102
|
+
'\n');
|
|
103
|
+
return;
|
|
111
104
|
}
|
|
112
|
-
|
|
113
|
-
|
|
105
|
+
// .mcp.json — Claude Code (needs cmd /c on Windows to invoke npx.cmd)
|
|
106
|
+
if (aiTool === 'claude-code' || aiTool === 'both') {
|
|
107
|
+
if (!tree.exists('.mcp.json')) {
|
|
108
|
+
const mcpConfig = {
|
|
109
|
+
mcpServers: {
|
|
110
|
+
'ng-annotate': isWindows
|
|
111
|
+
? { command: 'cmd', args: ['/c', 'npx', '-y', '@ng-annotate/mcp-server'], env }
|
|
112
|
+
: { command: 'npx', args: ['-y', '@ng-annotate/mcp-server'], env },
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
tree.create('.mcp.json', JSON.stringify(mcpConfig, null, 2) + '\n');
|
|
116
|
+
context.logger.info('✅ Created .mcp.json');
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
context.logger.info('.mcp.json already exists, skipping.');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// .vscode/mcp.json — VS Code Copilot
|
|
123
|
+
if (aiTool === 'vscode' || aiTool === 'both') {
|
|
124
|
+
const vscodeMcpPath = '.vscode/mcp.json';
|
|
125
|
+
if (!tree.exists(vscodeMcpPath)) {
|
|
126
|
+
const vscodeMcpConfig = {
|
|
127
|
+
servers: {
|
|
128
|
+
'ng-annotate': {
|
|
129
|
+
type: 'stdio',
|
|
130
|
+
command: 'npx',
|
|
131
|
+
args: ['-y', '@ng-annotate/mcp-server'],
|
|
132
|
+
env,
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
tree.create(vscodeMcpPath, JSON.stringify(vscodeMcpConfig, null, 2) + '\n');
|
|
137
|
+
context.logger.info('✅ Created .vscode/mcp.json');
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
context.logger.info('.vscode/mcp.json already exists, skipping.');
|
|
141
|
+
}
|
|
114
142
|
}
|
|
115
143
|
};
|
|
116
144
|
}
|
|
@@ -138,9 +166,15 @@ function addDevDependency() {
|
|
|
138
166
|
}
|
|
139
167
|
};
|
|
140
168
|
}
|
|
141
|
-
function default_1() {
|
|
169
|
+
function default_1(options) {
|
|
142
170
|
return (tree, context) => {
|
|
143
171
|
context.logger.info('Setting up @ng-annotate...');
|
|
144
|
-
return (0, schematics_1.chain)([
|
|
172
|
+
return (0, schematics_1.chain)([
|
|
173
|
+
checkAngularVersion(),
|
|
174
|
+
addDevDependency(),
|
|
175
|
+
addVitePlugin(),
|
|
176
|
+
addProviders(),
|
|
177
|
+
addMcpConfig(options),
|
|
178
|
+
])(tree, context);
|
|
145
179
|
};
|
|
146
180
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { Rule, SchematicContext, Tree, chain, SchematicsException } from '@angular-devkit/schematics';
|
|
2
2
|
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
|
|
3
3
|
|
|
4
|
+
interface Options {
|
|
5
|
+
aiTool: 'claude-code' | 'vscode' | 'both' | 'other';
|
|
6
|
+
}
|
|
7
|
+
|
|
4
8
|
const MIN_ANGULAR_MAJOR = 21;
|
|
5
9
|
|
|
6
10
|
function checkAngularVersion(): Rule {
|
|
@@ -100,48 +104,87 @@ function addProviders(): Rule {
|
|
|
100
104
|
};
|
|
101
105
|
}
|
|
102
106
|
|
|
103
|
-
function addMcpConfig(): Rule {
|
|
107
|
+
function addMcpConfig(options: Options): Rule {
|
|
104
108
|
return (tree: Tree, context: SchematicContext) => {
|
|
105
|
-
// The project root at ng-add time — used to build stable absolute paths.
|
|
106
|
-
// MCP hosts (VS Code Copilot, Claude Code) may spawn the server with a
|
|
107
|
-
// different cwd, so we bake in the paths rather than relying on cwd.
|
|
108
109
|
const projectRoot = process.cwd().replace(/\\/g, '/');
|
|
109
|
-
const serverEntry = `${projectRoot}/node_modules/@ng-annotate/mcp-server/dist/index.js`;
|
|
110
110
|
const env = { NG_ANNOTATE_PROJECT_ROOT: projectRoot };
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
111
|
+
const isWindows = process.platform === 'win32';
|
|
112
|
+
const { aiTool } = options;
|
|
113
|
+
|
|
114
|
+
if (aiTool === 'other') {
|
|
115
|
+
const claudeConfig = JSON.stringify(
|
|
116
|
+
{
|
|
117
|
+
mcpServers: {
|
|
118
|
+
'ng-annotate': isWindows
|
|
119
|
+
? { command: 'cmd', args: ['/c', 'npx', '-y', '@ng-annotate/mcp-server'], env }
|
|
120
|
+
: { command: 'npx', args: ['-y', '@ng-annotate/mcp-server'], env },
|
|
121
|
+
},
|
|
120
122
|
},
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
null,
|
|
124
|
+
2,
|
|
125
|
+
);
|
|
126
|
+
const vscodeConfig = JSON.stringify(
|
|
127
|
+
{
|
|
128
|
+
servers: {
|
|
129
|
+
'ng-annotate': {
|
|
130
|
+
type: 'stdio',
|
|
131
|
+
command: 'npx',
|
|
132
|
+
args: ['-y', '@ng-annotate/mcp-server'],
|
|
133
|
+
env,
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
null,
|
|
138
|
+
2,
|
|
139
|
+
);
|
|
140
|
+
context.logger.info(
|
|
141
|
+
'\n⚙️ Manual MCP configuration:\n\n' +
|
|
142
|
+
'For Claude Code (.mcp.json):\n' +
|
|
143
|
+
claudeConfig +
|
|
144
|
+
'\n\n' +
|
|
145
|
+
'For VS Code Copilot (.vscode/mcp.json):\n' +
|
|
146
|
+
vscodeConfig +
|
|
147
|
+
'\n',
|
|
148
|
+
);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// .mcp.json — Claude Code (needs cmd /c on Windows to invoke npx.cmd)
|
|
153
|
+
if (aiTool === 'claude-code' || aiTool === 'both') {
|
|
154
|
+
if (!tree.exists('.mcp.json')) {
|
|
155
|
+
const mcpConfig = {
|
|
156
|
+
mcpServers: {
|
|
157
|
+
'ng-annotate': isWindows
|
|
158
|
+
? { command: 'cmd', args: ['/c', 'npx', '-y', '@ng-annotate/mcp-server'], env }
|
|
159
|
+
: { command: 'npx', args: ['-y', '@ng-annotate/mcp-server'], env },
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
tree.create('.mcp.json', JSON.stringify(mcpConfig, null, 2) + '\n');
|
|
163
|
+
context.logger.info('✅ Created .mcp.json');
|
|
164
|
+
} else {
|
|
165
|
+
context.logger.info('.mcp.json already exists, skipping.');
|
|
166
|
+
}
|
|
126
167
|
}
|
|
127
168
|
|
|
128
169
|
// .vscode/mcp.json — VS Code Copilot
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
170
|
+
if (aiTool === 'vscode' || aiTool === 'both') {
|
|
171
|
+
const vscodeMcpPath = '.vscode/mcp.json';
|
|
172
|
+
if (!tree.exists(vscodeMcpPath)) {
|
|
173
|
+
const vscodeMcpConfig = {
|
|
174
|
+
servers: {
|
|
175
|
+
'ng-annotate': {
|
|
176
|
+
type: 'stdio',
|
|
177
|
+
command: 'npx',
|
|
178
|
+
args: ['-y', '@ng-annotate/mcp-server'],
|
|
179
|
+
env,
|
|
180
|
+
},
|
|
138
181
|
},
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
182
|
+
};
|
|
183
|
+
tree.create(vscodeMcpPath, JSON.stringify(vscodeMcpConfig, null, 2) + '\n');
|
|
184
|
+
context.logger.info('✅ Created .vscode/mcp.json');
|
|
185
|
+
} else {
|
|
186
|
+
context.logger.info('.vscode/mcp.json already exists, skipping.');
|
|
187
|
+
}
|
|
145
188
|
}
|
|
146
189
|
};
|
|
147
190
|
}
|
|
@@ -178,12 +221,15 @@ function addDevDependency(): Rule {
|
|
|
178
221
|
};
|
|
179
222
|
}
|
|
180
223
|
|
|
181
|
-
export default function (): Rule {
|
|
224
|
+
export default function (options: Options): Rule {
|
|
182
225
|
return (tree: Tree, context: SchematicContext) => {
|
|
183
226
|
context.logger.info('Setting up @ng-annotate...');
|
|
184
|
-
return chain([
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
227
|
+
return chain([
|
|
228
|
+
checkAngularVersion(),
|
|
229
|
+
addDevDependency(),
|
|
230
|
+
addVitePlugin(),
|
|
231
|
+
addProviders(),
|
|
232
|
+
addMcpConfig(options),
|
|
233
|
+
])(tree, context);
|
|
188
234
|
};
|
|
189
235
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "SchematicsNgAnnotateNgAdd",
|
|
4
|
+
"title": "ng-annotate ng-add options",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"description": "Adds @ng-annotate/angular to an Angular project",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {
|
|
9
|
+
"aiTool": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "Which AI tool will use the MCP server?",
|
|
12
|
+
"enum": ["claude-code", "vscode", "both", "other"],
|
|
13
|
+
"x-prompt": {
|
|
14
|
+
"message": "Which AI tool will use the ng-annotate MCP server?",
|
|
15
|
+
"type": "list",
|
|
16
|
+
"items": [
|
|
17
|
+
{ "value": "claude-code", "label": "Claude Code (generates .mcp.json)" },
|
|
18
|
+
{ "value": "vscode", "label": "VS Code Copilot (generates .vscode/mcp.json)" },
|
|
19
|
+
{ "value": "both", "label": "Both" },
|
|
20
|
+
{ "value": "other", "label": "Other — show manual config instructions" }
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"required": ["aiTool"]
|
|
26
|
+
}
|