@ng-annotate/angular 0.1.5 → 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,30 +69,21 @@ 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
74
|
const projectRoot = process.cwd().replace(/\\/g, '/');
|
|
75
75
|
const env = { NG_ANNOTATE_PROJECT_ROOT: projectRoot };
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const
|
|
76
|
+
const isWindows = process.platform === 'win32';
|
|
77
|
+
const { aiTool } = options;
|
|
78
|
+
if (aiTool === 'other') {
|
|
79
|
+
const claudeConfig = JSON.stringify({
|
|
80
80
|
mcpServers: {
|
|
81
81
|
'ng-annotate': isWindows
|
|
82
82
|
? { command: 'cmd', args: ['/c', 'npx', '-y', '@ng-annotate/mcp-server'], env }
|
|
83
83
|
: { command: 'npx', args: ['-y', '@ng-annotate/mcp-server'], env },
|
|
84
84
|
},
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
context.logger.info('✅ Created .mcp.json');
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
context.logger.info('.mcp.json already exists, skipping.');
|
|
91
|
-
}
|
|
92
|
-
// .vscode/mcp.json — VS Code Copilot (handles npx.cmd natively on Windows)
|
|
93
|
-
const vscodeMcpPath = '.vscode/mcp.json';
|
|
94
|
-
if (!tree.exists(vscodeMcpPath)) {
|
|
95
|
-
const vscodeMcpConfig = {
|
|
85
|
+
}, null, 2);
|
|
86
|
+
const vscodeConfig = JSON.stringify({
|
|
96
87
|
servers: {
|
|
97
88
|
'ng-annotate': {
|
|
98
89
|
type: 'stdio',
|
|
@@ -101,12 +92,53 @@ function addMcpConfig() {
|
|
|
101
92
|
env,
|
|
102
93
|
},
|
|
103
94
|
},
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
|
|
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;
|
|
107
104
|
}
|
|
108
|
-
|
|
109
|
-
|
|
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
|
+
}
|
|
110
142
|
}
|
|
111
143
|
};
|
|
112
144
|
}
|
|
@@ -134,9 +166,15 @@ function addDevDependency() {
|
|
|
134
166
|
}
|
|
135
167
|
};
|
|
136
168
|
}
|
|
137
|
-
function default_1() {
|
|
169
|
+
function default_1(options) {
|
|
138
170
|
return (tree, context) => {
|
|
139
171
|
context.logger.info('Setting up @ng-annotate...');
|
|
140
|
-
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);
|
|
141
179
|
};
|
|
142
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,44 +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
109
|
const projectRoot = process.cwd().replace(/\\/g, '/');
|
|
106
110
|
const env = { NG_ANNOTATE_PROJECT_ROOT: projectRoot };
|
|
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
|
+
},
|
|
122
|
+
},
|
|
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
|
+
}
|
|
107
151
|
|
|
108
152
|
// .mcp.json — Claude Code (needs cmd /c on Windows to invoke npx.cmd)
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
+
}
|
|
122
167
|
}
|
|
123
168
|
|
|
124
|
-
// .vscode/mcp.json — VS Code Copilot
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
169
|
+
// .vscode/mcp.json — VS Code Copilot
|
|
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
|
+
},
|
|
134
181
|
},
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
+
}
|
|
141
188
|
}
|
|
142
189
|
};
|
|
143
190
|
}
|
|
@@ -174,12 +221,15 @@ function addDevDependency(): Rule {
|
|
|
174
221
|
};
|
|
175
222
|
}
|
|
176
223
|
|
|
177
|
-
export default function (): Rule {
|
|
224
|
+
export default function (options: Options): Rule {
|
|
178
225
|
return (tree: Tree, context: SchematicContext) => {
|
|
179
226
|
context.logger.info('Setting up @ng-annotate...');
|
|
180
|
-
return chain([
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
227
|
+
return chain([
|
|
228
|
+
checkAngularVersion(),
|
|
229
|
+
addDevDependency(),
|
|
230
|
+
addVitePlugin(),
|
|
231
|
+
addProviders(),
|
|
232
|
+
addMcpConfig(options),
|
|
233
|
+
])(tree, context);
|
|
184
234
|
};
|
|
185
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
|
+
}
|