create-nx-workspace 24.0.6 → 24.0.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.
|
@@ -17,6 +17,7 @@ const output_1 = require("./utils/output");
|
|
|
17
17
|
const get_third_party_preset_1 = require("./utils/preset/get-third-party-preset");
|
|
18
18
|
const preset_1 = require("./utils/preset/preset");
|
|
19
19
|
const download_template_1 = require("./utils/template/download-template");
|
|
20
|
+
const remove_template_ai_agents_1 = require("./utils/template/remove-template-ai-agents");
|
|
20
21
|
const update_readme_1 = require("./utils/template/update-readme");
|
|
21
22
|
const child_process_utils_1 = require("./utils/child-process-utils");
|
|
22
23
|
const package_manager_1 = require("./utils/package-manager");
|
|
@@ -73,6 +74,9 @@ async function createWorkspace(preset, options, rawArgs) {
|
|
|
73
74
|
if ((0, node_fs_1.existsSync)(npmLockPath)) {
|
|
74
75
|
(0, node_fs_1.unlinkSync)(npmLockPath);
|
|
75
76
|
}
|
|
77
|
+
if ((0, remove_template_ai_agents_1.shouldRemoveTemplateAiAgents)(options, rawArgs)) {
|
|
78
|
+
(0, remove_template_ai_agents_1.removeTemplateAiAgents)(directory);
|
|
79
|
+
}
|
|
76
80
|
// Generate package manager specific files (e.g., .yarnrc.yml for Yarn Berry)
|
|
77
81
|
(0, package_manager_1.generatePackageManagerFiles)(directory, packageManager);
|
|
78
82
|
const packageJsonPath = (0, path_1.join)(directory, 'package.json');
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shouldRemoveTemplateAiAgents = shouldRemoveTemplateAiAgents;
|
|
4
|
+
exports.removeTemplateAiAgents = removeTemplateAiAgents;
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const AGENT_DIRECTORIES = [
|
|
8
|
+
'.agents',
|
|
9
|
+
'.claude',
|
|
10
|
+
'.codex',
|
|
11
|
+
'.cursor',
|
|
12
|
+
'.gemini',
|
|
13
|
+
'.opencode',
|
|
14
|
+
];
|
|
15
|
+
// Copilot files sit beside CI workflows under `.github`. Drop the agent
|
|
16
|
+
// directories and leave `workflows/` in place.
|
|
17
|
+
const GITHUB_AGENT_DIRECTORIES = [
|
|
18
|
+
'.github/agents',
|
|
19
|
+
'.github/prompts',
|
|
20
|
+
'.github/skills',
|
|
21
|
+
'.github/instructions',
|
|
22
|
+
];
|
|
23
|
+
const AGENT_FILES = ['CLAUDE.md', 'GEMINI.md', 'opencode.json'];
|
|
24
|
+
const GITIGNORE_ENTRIES = new Set([
|
|
25
|
+
'.cursor/rules/nx-rules.mdc',
|
|
26
|
+
'.github/instructions/nx.instructions.md',
|
|
27
|
+
'.claude/worktrees',
|
|
28
|
+
'.claude/settings.local.json',
|
|
29
|
+
]);
|
|
30
|
+
const NX_RULES_START = '<!-- nx configuration start-->';
|
|
31
|
+
const NX_RULES_END = '<!-- nx configuration end-->';
|
|
32
|
+
// Normalized options.aiAgents is empty for both `--aiAgents=none` and an
|
|
33
|
+
// omitted flag. Only an explicit `none` removes files the template ships.
|
|
34
|
+
function shouldRemoveTemplateAiAgents(options, rawArgs) {
|
|
35
|
+
if (rawArgs) {
|
|
36
|
+
const requested = rawArgs.aiAgents;
|
|
37
|
+
return (!!requested &&
|
|
38
|
+
requested.length > 0 &&
|
|
39
|
+
requested.every((agent) => agent === 'none'));
|
|
40
|
+
}
|
|
41
|
+
return !!options.aiAgents && options.aiAgents.length === 0;
|
|
42
|
+
}
|
|
43
|
+
function removeTemplateAiAgents(directory) {
|
|
44
|
+
for (const relativePath of [
|
|
45
|
+
...AGENT_DIRECTORIES,
|
|
46
|
+
...GITHUB_AGENT_DIRECTORIES,
|
|
47
|
+
]) {
|
|
48
|
+
(0, node_fs_1.rmSync)((0, node_path_1.join)(directory, relativePath), { recursive: true, force: true });
|
|
49
|
+
}
|
|
50
|
+
removeIfEmpty((0, node_path_1.join)(directory, '.github'));
|
|
51
|
+
for (const relativePath of AGENT_FILES) {
|
|
52
|
+
(0, node_fs_1.rmSync)((0, node_path_1.join)(directory, relativePath), { force: true });
|
|
53
|
+
}
|
|
54
|
+
stripNxConfiguration((0, node_path_1.join)(directory, 'AGENTS.md'));
|
|
55
|
+
stripGitignoreEntries((0, node_path_1.join)(directory, '.gitignore'));
|
|
56
|
+
}
|
|
57
|
+
function removeIfEmpty(directory) {
|
|
58
|
+
if (!(0, node_fs_1.existsSync)(directory) || !(0, node_fs_1.statSync)(directory).isDirectory())
|
|
59
|
+
return;
|
|
60
|
+
if ((0, node_fs_1.readdirSync)(directory).length === 0) {
|
|
61
|
+
(0, node_fs_1.rmSync)(directory, { recursive: true, force: true });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function stripNxConfiguration(path) {
|
|
65
|
+
if (!(0, node_fs_1.existsSync)(path))
|
|
66
|
+
return;
|
|
67
|
+
const original = (0, node_fs_1.readFileSync)(path, 'utf-8');
|
|
68
|
+
if (!original.includes(NX_RULES_START))
|
|
69
|
+
return;
|
|
70
|
+
const nxRulesRegex = new RegExp(`${NX_RULES_START}[\\s\\S]*?${NX_RULES_END}`, 'g');
|
|
71
|
+
const updated = original
|
|
72
|
+
.replace(nxRulesRegex, '')
|
|
73
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
74
|
+
.trim();
|
|
75
|
+
if (!updated) {
|
|
76
|
+
(0, node_fs_1.rmSync)(path, { force: true });
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
(0, node_fs_1.writeFileSync)(path, updated + '\n');
|
|
80
|
+
}
|
|
81
|
+
function stripGitignoreEntries(path) {
|
|
82
|
+
if (!(0, node_fs_1.existsSync)(path))
|
|
83
|
+
return;
|
|
84
|
+
const original = (0, node_fs_1.readFileSync)(path, 'utf-8');
|
|
85
|
+
const endsWithNewline = original.endsWith('\n');
|
|
86
|
+
const filtered = original
|
|
87
|
+
.split('\n')
|
|
88
|
+
.filter((line) => !GITIGNORE_ENTRIES.has(line.trim()));
|
|
89
|
+
let next = filtered.join('\n').replace(/\n{3,}/g, '\n\n');
|
|
90
|
+
if (endsWithNewline && !next.endsWith('\n')) {
|
|
91
|
+
next += '\n';
|
|
92
|
+
}
|
|
93
|
+
if (next !== original) {
|
|
94
|
+
(0, node_fs_1.writeFileSync)(path, next);
|
|
95
|
+
}
|
|
96
|
+
}
|