@ng-annotate/angular 0.5.5 → 0.5.7
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 +1 -1
- package/schematics/ng-add/index.js +33 -7
- package/schematics/ng-add/index.ts +37 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-annotate/angular",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.7",
|
|
4
4
|
"schematics": "./schematics/collection.json",
|
|
5
5
|
"builders": "./builders.json",
|
|
6
6
|
"description": "Angular library for ng-annotate-mcp — browser overlay for annotating components and routing instructions to an AI agent",
|
|
@@ -268,22 +268,48 @@ function addDevDependency() {
|
|
|
268
268
|
}
|
|
269
269
|
};
|
|
270
270
|
}
|
|
271
|
+
/** Append a gitignore entry to a file on the real filesystem (outside the schematic Tree). */
|
|
272
|
+
function addEntryToGitignoreOutsideTree(absPath, entry, context) {
|
|
273
|
+
if (fs.existsSync(absPath)) {
|
|
274
|
+
const content = fs.readFileSync(absPath, 'utf-8');
|
|
275
|
+
if (content.includes(entry)) {
|
|
276
|
+
context.logger.info(`${entry} already in root .gitignore, skipping.`);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
fs.writeFileSync(absPath, content.trimEnd() + '\n\n' + entry + '\n', 'utf-8');
|
|
280
|
+
context.logger.info(`✅ Added ${entry} to root .gitignore`);
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
fs.writeFileSync(absPath, entry + '\n', 'utf-8');
|
|
284
|
+
context.logger.info(`✅ Created .gitignore with ${entry} at repository root`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
271
287
|
function addGitignore() {
|
|
272
288
|
return (tree, context) => {
|
|
273
289
|
const entry = '.ng-annotate/';
|
|
290
|
+
const projectRoot = process.cwd();
|
|
291
|
+
const gitRoot = findGitRoot(projectRoot);
|
|
292
|
+
const isSubproject = gitRoot !== null && path.resolve(gitRoot) !== path.resolve(projectRoot);
|
|
293
|
+
// Always update the Angular project's .gitignore via the Tree (supports --dry-run).
|
|
274
294
|
const gitignorePath = '.gitignore';
|
|
275
295
|
if (!tree.exists(gitignorePath)) {
|
|
276
296
|
tree.create(gitignorePath, entry + '\n');
|
|
277
297
|
context.logger.info('✅ Created .gitignore with .ng-annotate/');
|
|
278
|
-
return;
|
|
279
298
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
299
|
+
else {
|
|
300
|
+
const content = tree.read(gitignorePath).toString('utf-8');
|
|
301
|
+
if (content.includes(entry)) {
|
|
302
|
+
context.logger.info('.ng-annotate/ already in .gitignore, skipping.');
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
tree.overwrite(gitignorePath, content.trimEnd() + '\n\n' + entry + '\n');
|
|
306
|
+
context.logger.info('✅ Added .ng-annotate/ to .gitignore');
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
// For monorepos: the store lives at the git root, so also add the entry there.
|
|
310
|
+
if (isSubproject) {
|
|
311
|
+
addEntryToGitignoreOutsideTree(path.join(gitRoot, '.gitignore'), entry, context);
|
|
284
312
|
}
|
|
285
|
-
tree.overwrite(gitignorePath, content.trimEnd() + '\n\n' + entry + '\n');
|
|
286
|
-
context.logger.info('✅ Added .ng-annotate/ to .gitignore');
|
|
287
313
|
};
|
|
288
314
|
}
|
|
289
315
|
function default_1(options) {
|
|
@@ -303,25 +303,53 @@ function addDevDependency(): Rule {
|
|
|
303
303
|
};
|
|
304
304
|
}
|
|
305
305
|
|
|
306
|
+
/** Append a gitignore entry to a file on the real filesystem (outside the schematic Tree). */
|
|
307
|
+
function addEntryToGitignoreOutsideTree(
|
|
308
|
+
absPath: string,
|
|
309
|
+
entry: string,
|
|
310
|
+
context: SchematicContext,
|
|
311
|
+
): void {
|
|
312
|
+
if (fs.existsSync(absPath)) {
|
|
313
|
+
const content = fs.readFileSync(absPath, 'utf-8');
|
|
314
|
+
if (content.includes(entry)) {
|
|
315
|
+
context.logger.info(`${entry} already in root .gitignore, skipping.`);
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
fs.writeFileSync(absPath, content.trimEnd() + '\n\n' + entry + '\n', 'utf-8');
|
|
319
|
+
context.logger.info(`✅ Added ${entry} to root .gitignore`);
|
|
320
|
+
} else {
|
|
321
|
+
fs.writeFileSync(absPath, entry + '\n', 'utf-8');
|
|
322
|
+
context.logger.info(`✅ Created .gitignore with ${entry} at repository root`);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
306
326
|
function addGitignore(): Rule {
|
|
307
327
|
return (tree: Tree, context: SchematicContext) => {
|
|
308
328
|
const entry = '.ng-annotate/';
|
|
309
|
-
const
|
|
329
|
+
const projectRoot = process.cwd();
|
|
330
|
+
const gitRoot = findGitRoot(projectRoot);
|
|
331
|
+
const isSubproject =
|
|
332
|
+
gitRoot !== null && path.resolve(gitRoot) !== path.resolve(projectRoot);
|
|
310
333
|
|
|
334
|
+
// Always update the Angular project's .gitignore via the Tree (supports --dry-run).
|
|
335
|
+
const gitignorePath = '.gitignore';
|
|
311
336
|
if (!tree.exists(gitignorePath)) {
|
|
312
337
|
tree.create(gitignorePath, entry + '\n');
|
|
313
338
|
context.logger.info('✅ Created .gitignore with .ng-annotate/');
|
|
314
|
-
|
|
339
|
+
} else {
|
|
340
|
+
const content = tree.read(gitignorePath)!.toString('utf-8');
|
|
341
|
+
if (content.includes(entry)) {
|
|
342
|
+
context.logger.info('.ng-annotate/ already in .gitignore, skipping.');
|
|
343
|
+
} else {
|
|
344
|
+
tree.overwrite(gitignorePath, content.trimEnd() + '\n\n' + entry + '\n');
|
|
345
|
+
context.logger.info('✅ Added .ng-annotate/ to .gitignore');
|
|
346
|
+
}
|
|
315
347
|
}
|
|
316
348
|
|
|
317
|
-
|
|
318
|
-
if (
|
|
319
|
-
|
|
320
|
-
return;
|
|
349
|
+
// For monorepos: the store lives at the git root, so also add the entry there.
|
|
350
|
+
if (isSubproject) {
|
|
351
|
+
addEntryToGitignoreOutsideTree(path.join(gitRoot!, '.gitignore'), entry, context);
|
|
321
352
|
}
|
|
322
|
-
|
|
323
|
-
tree.overwrite(gitignorePath, content.trimEnd() + '\n\n' + entry + '\n');
|
|
324
|
-
context.logger.info('✅ Added .ng-annotate/ to .gitignore');
|
|
325
353
|
};
|
|
326
354
|
}
|
|
327
355
|
|