@unisphere/nx 3.2.4 → 3.4.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"add-application.d.ts","sourceRoot":"","sources":["../../../src/generators/add-application/add-application.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,IAAI,EAAsC,MAAM,YAAY,CAAC;AAIlG,OAAO,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAkHzD,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,6BAA6B,uBAgQvC;AAED,eAAe,uBAAuB,CAAC"}
1
+ {"version":3,"file":"add-application.d.ts","sourceRoot":"","sources":["../../../src/generators/add-application/add-application.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,IAAI,EAAsC,MAAM,YAAY,CAAC;AAElG,OAAO,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAkHzD,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,6BAA6B,uBAiIvC;AAED,eAAe,uBAAuB,CAAC"}
@@ -4,8 +4,6 @@ exports.addApplicationGenerator = addApplicationGenerator;
4
4
  const tslib_1 = require("tslib");
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const path = tslib_1.__importStar(require("path"));
7
- const child_process_1 = require("child_process");
8
- const fs = tslib_1.__importStar(require("fs"));
9
7
  const utils_1 = require("../utils");
10
8
  const dependency_config_1 = require("../dependency-config");
11
9
  async function getEnquirerPrompt() {
@@ -62,7 +60,7 @@ async function promptForHtmlPageTitle() {
62
60
  });
63
61
  return response.htmlPageTitle;
64
62
  }
65
- async function promptForDependencies(isPlayground) {
63
+ async function promptForDependencies(_isPlayground) {
66
64
  const prompt = await getEnquirerPrompt();
67
65
  const choices = [
68
66
  { value: 'ds', label: 'Kaltura DS - Design System (requires GIT_TOKEN)' },
@@ -81,50 +79,19 @@ async function addApplicationGenerator(tree, options) {
81
79
  throw new Error('iframe-with-post-messages serving type is not currently supported. Please choose a different serving type.');
82
80
  }
83
81
  const isPlayground = options.servingType === 'local-dev-playground';
84
- const isDocumentation = options.servingType === 'documentation';
85
- // Check workspace pattern for documentation apps
86
- if (isDocumentation) {
87
- const rootPackageJsonPath = 'package.json';
88
- if (tree.exists(rootPackageJsonPath)) {
89
- const packageJson = JSON.parse(tree.read(rootPackageJsonPath, 'utf-8') || '{}');
90
- const workspaces = packageJson.workspaces || [];
91
- // Check if using the old catch-all pattern that doesn't work with documentation apps
92
- const hasCatchAllPattern = workspaces.includes('unisphere/**');
93
- const hasNegationPattern = workspaces.some((pattern) => pattern.startsWith('!'));
94
- if (hasCatchAllPattern || hasNegationPattern) {
95
- throw new Error('Documentation applications require @unisphere/nx version 3.1.0 or higher.\n\n' +
96
- 'Your workspace is using an old npm workspaces pattern that prevents documentation apps ' +
97
- 'from having their own node_modules.\n\n' +
98
- 'Please upgrade by running:\n' +
99
- ' npx nx migrate @unisphere/nx@latest\n' +
100
- ' npx nx migrate --run-migrations\n\n' +
101
- 'This will update your workspace pattern to support documentation apps.');
102
- }
103
- }
104
- }
105
82
  // Validate and read .unisphere configuration
106
83
  const unisphereConfig = (0, utils_1.validateUnisphereConfig)(tree);
107
- // Skip runtime/visual prompts for documentation sites
108
- let runtimeName = '';
109
- let visualName = '';
110
- if (!isDocumentation) {
111
- const promptResult = await promptForRuntimeName(unisphereConfig.runtimes, options.runtimeName || '', options.visualName || '', options.skipDynamicRuntimeVisualPrompt || false);
112
- runtimeName = promptResult.runtimeName;
113
- visualName = promptResult.visualName;
114
- }
115
- // Skip HTML page title prompt for documentation (Docusaurus has its own config)
116
- if (!isPlayground && !isDocumentation && !options.htmlPageTitle) {
84
+ const promptResult = await promptForRuntimeName(unisphereConfig.runtimes, options.runtimeName || '', options.visualName || '', options.skipDynamicRuntimeVisualPrompt || false);
85
+ const runtimeName = promptResult.runtimeName;
86
+ const visualName = promptResult.visualName;
87
+ if (!isPlayground && !options.htmlPageTitle) {
117
88
  options.htmlPageTitle = options.htmlPageTitle || await promptForHtmlPageTitle();
118
89
  }
119
- // Skip dependencies prompt for documentation (Docusaurus has its own)
120
- let selectedDependencies = [];
121
- if (!isDocumentation) {
122
- if (options.dependencies === undefined) {
123
- options.dependencies = await promptForDependencies(isPlayground);
124
- }
125
- const baseDependencies = ['react'];
126
- selectedDependencies = [...baseDependencies, ...(options.dependencies || [])];
90
+ if (options.dependencies === undefined) {
91
+ options.dependencies = await promptForDependencies(isPlayground);
127
92
  }
93
+ const baseDependencies = ['react'];
94
+ const selectedDependencies = [...baseDependencies, ...(options.dependencies || [])];
128
95
  // Validate runtime exists if runtimeName is provided
129
96
  if (runtimeName) {
130
97
  if (!(0, utils_1.checkIfRuntimeExists)(tree, runtimeName)) {
@@ -138,83 +105,11 @@ async function addApplicationGenerator(tree, options) {
138
105
  applicationName += '-dev';
139
106
  }
140
107
  const applicationNameAsLowerDashCase = (0, devkit_1.names)(applicationName).fileName;
141
- // Find types package (or fallback to core) - skip for documentation
142
- const typesPackageInfo = isDocumentation ? null : (0, utils_1.findTypesOrCorePackageInfo)(tree);
108
+ const typesPackageInfo = (0, utils_1.findTypesOrCorePackageInfo)(tree);
143
109
  // Determine subdirectory based on serving type
144
- // local-dev-playground -> local/, documentation -> documentation/, other types -> server/
145
- const subdirectory = isPlayground ? 'local' : isDocumentation ? 'documentation' : 'server';
110
+ // local-dev-playground -> local/, other types -> server/
111
+ const subdirectory = isPlayground ? 'local' : 'server';
146
112
  const projectRoot = `unisphere/applications/${subdirectory}/${applicationNameAsLowerDashCase}`;
147
- // Handle documentation type separately
148
- if (isDocumentation) {
149
- // Check if the application already exists
150
- if (tree.exists(projectRoot)) {
151
- throw new Error(`Application "${applicationNameAsLowerDashCase}" already exists at ${projectRoot}.\n` +
152
- 'Please choose a different application name or remove the existing application first.');
153
- }
154
- // Update .unisphere configuration (applicationType is derived from folder path)
155
- (0, utils_1.updateUnisphereConfig)(tree, 'applications', applicationNameAsLowerDashCase, {
156
- sourceRoot: projectRoot,
157
- });
158
- // Add documentation folder to .nxignore to prevent NX from scanning it
159
- // Docusaurus has its own node_modules which can slow down NX
160
- const nxIgnorePath = '.nxignore';
161
- const ignoreEntry = `${projectRoot}/node_modules`;
162
- let nxIgnoreContent = '';
163
- if (tree.exists(nxIgnorePath)) {
164
- nxIgnoreContent = tree.read(nxIgnorePath, 'utf-8') || '';
165
- }
166
- if (!nxIgnoreContent.includes(ignoreEntry)) {
167
- const newContent = nxIgnoreContent
168
- ? `${nxIgnoreContent.trimEnd()}\n\n# Documentation site (Docusaurus) - has its own node_modules\n${ignoreEntry}\n`
169
- : `# Documentation site (Docusaurus) - has its own node_modules\n${ignoreEntry}\n`;
170
- tree.write(nxIgnorePath, newContent);
171
- }
172
- // Documentation folders are automatically excluded from npm workspaces
173
- // because the root package.json uses explicit workspace patterns that don't include
174
- // unisphere/applications/documentation/**
175
- // This allows documentation sites (like Docusaurus) to have their own node_modules
176
- await (0, devkit_1.formatFiles)(tree);
177
- // Return a function that will be executed after all file operations are complete
178
- return () => {
179
- const workspaceRoot = process.cwd();
180
- const fullProjectPath = path.join(workspaceRoot, projectRoot);
181
- devkit_1.logger.info('');
182
- devkit_1.logger.info('📚 Setting up Docusaurus documentation site...');
183
- devkit_1.logger.info('');
184
- try {
185
- // Create the parent directory if it doesn't exist
186
- const parentDir = path.dirname(fullProjectPath);
187
- if (!fs.existsSync(parentDir)) {
188
- fs.mkdirSync(parentDir, { recursive: true });
189
- }
190
- // Run Docusaurus CLI to scaffold the project
191
- // Docusaurus creates a self-contained project with its own package.json
192
- // No NX integration needed - we just delegate to Docusaurus CLI for serve/build
193
- // Use public npm registry explicitly (workspaces may have private registry configured)
194
- devkit_1.logger.info('Running Docusaurus CLI...');
195
- (0, child_process_1.execSync)(`npx --yes --registry https://registry.npmjs.org create-docusaurus@3 "${fullProjectPath}" classic --typescript`, {
196
- stdio: 'inherit',
197
- cwd: workspaceRoot,
198
- });
199
- devkit_1.logger.info('');
200
- devkit_1.logger.info('✅ Documentation site generated successfully!');
201
- devkit_1.logger.info('');
202
- devkit_1.logger.info(`📚 Application Name: ${applicationNameAsLowerDashCase}`);
203
- devkit_1.logger.info(`🔧 Type: Documentation Site (Docusaurus)`);
204
- devkit_1.logger.info(`📁 Location: ${projectRoot}`);
205
- devkit_1.logger.info('');
206
- devkit_1.logger.info(`📜 To serve: npx unisphere application serve ${applicationNameAsLowerDashCase}`);
207
- devkit_1.logger.info(`đŸ“Ļ To build: npx unisphere application build ${applicationNameAsLowerDashCase}`);
208
- devkit_1.logger.info('');
209
- }
210
- catch (error) {
211
- devkit_1.logger.error('Failed to create Docusaurus project:');
212
- devkit_1.logger.error(error instanceof Error ? error.message : String(error));
213
- throw error;
214
- }
215
- };
216
- }
217
- // Standard application flow (non-documentation)
218
113
  const hasDs = selectedDependencies.includes('ds');
219
114
  const templateVariables = {
220
115
  htmlPageTitle: options.servingType === 'local-dev-playground'
@@ -1,7 +1,7 @@
1
1
  export interface AddApplicationGeneratorSchema {
2
2
  name: string;
3
3
  htmlPageTitle?: string;
4
- servingType: 'local-dev-playground' | 'self-hosted' | 'iframe-with-post-messages' | 'documentation';
4
+ servingType: 'local-dev-playground' | 'self-hosted' | 'iframe-with-post-messages';
5
5
  runtimeName?: string;
6
6
  visualName?: string;
7
7
  skipDynamicRuntimeVisualPrompt?: boolean; // Internal option to skip the dynamic prompt for visual when runtime is selected
@@ -33,10 +33,6 @@
33
33
  {
34
34
  "value": "iframe-with-post-messages",
35
35
  "label": "Iframe + Post Messages (suitible to applications that gets required configuration from post messages)"
36
- },
37
- {
38
- "value": "documentation",
39
- "label": "Documentation Site (Docusaurus)"
40
36
  }
41
37
  ]
42
38
  }
@@ -0,0 +1,5 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { AddDocumentationGeneratorSchema } from './schema';
3
+ export declare function addDocumentationGenerator(tree: Tree, options: AddDocumentationGeneratorSchema): Promise<() => void>;
4
+ export default addDocumentationGenerator;
5
+ //# sourceMappingURL=add-documentation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-documentation.d.ts","sourceRoot":"","sources":["../../../src/generators/add-documentation/add-documentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAiB,MAAM,YAAY,CAAC;AAI9D,OAAO,EAAE,+BAA+B,EAAE,MAAM,UAAU,CAAC;AAM3D,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,+BAA+B,uBA4GzC;AAED,eAAe,yBAAyB,CAAC"}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addDocumentationGenerator = addDocumentationGenerator;
4
+ const tslib_1 = require("tslib");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const path = tslib_1.__importStar(require("path"));
7
+ const child_process_1 = require("child_process");
8
+ const fs = tslib_1.__importStar(require("fs"));
9
+ const utils_1 = require("../utils");
10
+ async function addDocumentationGenerator(tree, options) {
11
+ // Validate .unisphere configuration exists
12
+ (0, utils_1.validateUnisphereConfig)(tree);
13
+ // Check workspace pattern for documentation apps
14
+ const rootPackageJsonPath = 'package.json';
15
+ if (tree.exists(rootPackageJsonPath)) {
16
+ const packageJson = JSON.parse(tree.read(rootPackageJsonPath, 'utf-8') || '{}');
17
+ const workspaces = packageJson.workspaces || [];
18
+ // Check if using the old catch-all pattern that doesn't work with documentation apps
19
+ const hasCatchAllPattern = workspaces.includes('unisphere/**');
20
+ if (hasCatchAllPattern) {
21
+ throw new Error('Documentation sites require @unisphere/nx version 3.1.0 or higher.\n\n' +
22
+ 'Your workspace is using an old npm workspaces pattern that prevents documentation sites ' +
23
+ 'from having their own node_modules.\n\n' +
24
+ 'Please upgrade by running:\n' +
25
+ ' npx nx migrate @unisphere/nx@latest\n' +
26
+ ' npx nx migrate --run-migrations\n\n' +
27
+ 'This will update your workspace pattern to support documentation sites.');
28
+ }
29
+ }
30
+ const documentationName = options.name;
31
+ const documentationNameAsLowerDashCase = (0, devkit_1.names)(documentationName).fileName;
32
+ const projectRoot = `unisphere/documentation/${documentationNameAsLowerDashCase}`;
33
+ // Check if the documentation site already exists
34
+ if (tree.exists(projectRoot)) {
35
+ throw new Error(`Documentation site "${documentationNameAsLowerDashCase}" already exists at ${projectRoot}.\n` +
36
+ 'Please choose a different name or remove the existing documentation site first.');
37
+ }
38
+ // Update .unisphere configuration
39
+ (0, utils_1.updateUnisphereConfig)(tree, 'documentation', documentationNameAsLowerDashCase, {
40
+ sourceRoot: projectRoot,
41
+ });
42
+ // Add documentation folder to .nxignore to prevent NX from scanning it
43
+ // Docusaurus has its own node_modules which can slow down NX
44
+ const nxIgnorePath = '.nxignore';
45
+ const ignoreEntry = `${projectRoot}/node_modules`;
46
+ let nxIgnoreContent = '';
47
+ if (tree.exists(nxIgnorePath)) {
48
+ nxIgnoreContent = tree.read(nxIgnorePath, 'utf-8') || '';
49
+ }
50
+ if (!nxIgnoreContent.includes(ignoreEntry)) {
51
+ const newContent = nxIgnoreContent
52
+ ? `${nxIgnoreContent.trimEnd()}\n\n# Documentation site (Docusaurus) - has its own node_modules\n${ignoreEntry}\n`
53
+ : `# Documentation site (Docusaurus) - has its own node_modules\n${ignoreEntry}\n`;
54
+ tree.write(nxIgnorePath, newContent);
55
+ }
56
+ await (0, devkit_1.formatFiles)(tree);
57
+ // Return a function that will be executed after all file operations are complete
58
+ return () => {
59
+ const workspaceRoot = process.cwd();
60
+ const fullProjectPath = path.join(workspaceRoot, projectRoot);
61
+ devkit_1.logger.info('');
62
+ devkit_1.logger.info('Setting up Docusaurus documentation site...');
63
+ devkit_1.logger.info('');
64
+ try {
65
+ // Create the parent directory if it doesn't exist
66
+ const parentDir = path.dirname(fullProjectPath);
67
+ if (!fs.existsSync(parentDir)) {
68
+ fs.mkdirSync(parentDir, { recursive: true });
69
+ }
70
+ // Run Docusaurus CLI to scaffold the project
71
+ // Docusaurus creates a self-contained project with its own package.json
72
+ // No NX integration needed - we just delegate to Docusaurus CLI for serve/build
73
+ // Use public npm registry explicitly (workspaces may have private registry configured)
74
+ devkit_1.logger.info('Running Docusaurus CLI...');
75
+ (0, child_process_1.execSync)(`npx --yes --registry https://registry.npmjs.org create-docusaurus@3 "${fullProjectPath}" classic --typescript`, {
76
+ stdio: 'inherit',
77
+ cwd: workspaceRoot,
78
+ });
79
+ devkit_1.logger.info('');
80
+ devkit_1.logger.info('Documentation site generated successfully!');
81
+ devkit_1.logger.info('');
82
+ devkit_1.logger.info(`Name: ${documentationNameAsLowerDashCase}`);
83
+ devkit_1.logger.info(`Type: Documentation Site (Docusaurus)`);
84
+ devkit_1.logger.info(`Location: ${projectRoot}`);
85
+ devkit_1.logger.info('');
86
+ devkit_1.logger.info(`To serve: npx unisphere documentation serve ${documentationNameAsLowerDashCase}`);
87
+ devkit_1.logger.info(`To build: npx unisphere documentation build ${documentationNameAsLowerDashCase}`);
88
+ devkit_1.logger.info('');
89
+ }
90
+ catch (error) {
91
+ devkit_1.logger.error('Failed to create Docusaurus project:');
92
+ devkit_1.logger.error(error instanceof Error ? error.message : String(error));
93
+ throw error;
94
+ }
95
+ };
96
+ }
97
+ exports.default = addDocumentationGenerator;
@@ -0,0 +1,3 @@
1
+ export interface AddDocumentationGeneratorSchema {
2
+ name: string;
3
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "AddDocumentation",
4
+ "title": "Add Documentation Generator",
5
+ "type": "object",
6
+ "properties": {
7
+ "name": {
8
+ "type": "string",
9
+ "description": "The name of the documentation site to create",
10
+ "pattern": "^[a-zA-Z][a-zA-Z0-9\\-\\s]*$",
11
+ "$default": {
12
+ "$source": "argv",
13
+ "index": 0
14
+ },
15
+ "x-prompt": "What is the documentation site name? (letters, numbers, dashes and spaces allowed)"
16
+ }
17
+ },
18
+ "required": [
19
+ "name"
20
+ ]
21
+ }
@@ -9,7 +9,7 @@ export interface UnisphereConfig {
9
9
  }
10
10
  export declare function validateUnisphereConfig(tree: Tree): UnisphereConfig;
11
11
  export declare function updateTsConfigPaths(tree: Tree, pathKey: string, pathValue: string): void;
12
- export declare function updateUnisphereConfig(tree: Tree, elementType: 'packages' | 'runtimes' | 'applications', elementName: string, elementConfig: Record<string, any>): void;
12
+ export declare function updateUnisphereConfig(tree: Tree, elementType: 'packages' | 'runtimes' | 'applications' | 'documentation', elementName: string, elementConfig: Record<string, any>): void;
13
13
  export declare function validateRuntimeExists(tree: Tree, runtimeName: string): string;
14
14
  export declare function findCorePackageAlias(tree: Tree): string;
15
15
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/generators/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAKL,MAAM,YAAY,CAAC;AAGpB,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;QACvB,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,EAAE,CAAC;KACnB,CAAC,CAAC;CACJ;AA+FD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,IAAI,GAAG,eAAe,CAkEnE;AAGD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QA2BjF;AAED,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,UAAU,GAAG,UAAU,GAAG,cAAc,EACrD,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QA0BnC;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CA4C7E;AA0BD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CA6BvD;A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;GAGG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,IAAI,GAAG,gBAAgB,CA8BvE;AAGD,KAAK,mBAAmB,CAAC,MAAM,SAAS,MAAM,IAAI;KAC/C,CAAC,IACA,GAAG,MAAM,EAAE,GACX,GAAG,MAAM,iBAAiB,GAC1B,GAAG,MAAM,aAAa,GACtB,GAAG,MAAM,cAAc,GACvB,GAAG,MAAM,gBAAgB,GACzB,GAAG,MAAM,iBAAiB,GAAG,MAAM;CACtC,CAAC;AAKF,wBAAgB,oBAAoB,CAAC,MAAM,SAAS,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAwBzH;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAwBlF;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAgB7E;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,YAAY,GAAG,MAAM,CAQrG;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAWnF;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAI3E;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,GACpB,IAAI,CAyBN"}
@@ -1 +1 @@
1
- {"version":3,"file":"reorganize-applications-by-distribution-channel.d.ts","sourceRoot":"","sources":["../../../src/migrations/3-0-0/reorganize-applications-by-distribution-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;EAQE;AAEF,OAAO,EACL,IAAI,EAOL,MAAM,YAAY,CAAC;AA8oBpB;;GAEG;AACH,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAyE9D"}
1
+ {"version":3,"file":"reorganize-applications-by-distribution-channel.d.ts","sourceRoot":"","sources":["../../../src/migrations/3-0-0/reorganize-applications-by-distribution-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;EAQE;AAEF,OAAO,EACL,IAAI,EAML,MAAM,YAAY,CAAC;AAsmBpB;;GAEG;AACH,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAyE9D"}
@@ -11,49 +11,10 @@
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.default = update;
13
13
  const devkit_1 = require("@nx/devkit");
14
+ const generators_1 = require("@nx/workspace/generators");
14
15
  const child_process_1 = require("child_process");
15
- /**
16
- * Manually move all files from source to destination directory.
17
- * This avoids using moveGenerator which relies on the Nx project graph cache.
18
- * The project graph is read from disk, but during migrations the Tree (virtual FS)
19
- * may have changes that aren't flushed to disk yet, causing stale data issues.
20
- * Using manual move with Tree APIs ensures we always work with the correct state.
21
- */
22
- function moveProjectFiles(tree, sourcePath, destPath) {
23
- const filesToMove = [];
24
- // Collect all files to move
25
- (0, devkit_1.visitNotIgnoredFiles)(tree, sourcePath, (filePath) => {
26
- const relativePath = filePath.substring(sourcePath.length);
27
- const newPath = `${destPath}${relativePath}`;
28
- filesToMove.push({ source: filePath, dest: newPath });
29
- });
30
- // Move files (create at dest, delete at source)
31
- for (const { source, dest } of filesToMove) {
32
- const content = tree.read(source);
33
- if (content !== null) {
34
- tree.write(dest, content);
35
- tree.delete(source);
36
- }
37
- }
38
- devkit_1.logger.info(` Moved ${filesToMove.length} files from ${sourcePath} to ${destPath}`);
39
- }
40
- /**
41
- * Update project.json after moving to new location
42
- */
43
- function updateProjectJsonAfterMove(tree, newPath, newProjectName) {
44
- const projectJsonPath = `${newPath}/project.json`;
45
- if (!tree.exists(projectJsonPath)) {
46
- return;
47
- }
48
- const projectJson = (0, devkit_1.readJson)(tree, projectJsonPath);
49
- // Update name if different
50
- if (projectJson.name !== newProjectName) {
51
- projectJson.name = newProjectName;
52
- }
53
- // Update sourceRoot to match new location
54
- projectJson.sourceRoot = `${newPath}/src`;
55
- (0, devkit_1.writeJson)(tree, projectJsonPath, projectJson);
56
- }
16
+ const fs_1 = require("fs");
17
+ const path_1 = require("path");
57
18
  /**
58
19
  * Reset Nx cache to ensure fresh project graph
59
20
  * This is important before moving projects, as Nx caches project locations
@@ -454,22 +415,33 @@ async function migrateApplication(tree, target) {
454
415
  devkit_1.logger.warn(` Source project.json not found at ${sourceProjectJson}, skipping`);
455
416
  return;
456
417
  }
457
- // Step 1: Manually move files using Tree APIs
458
- // We avoid moveGenerator because it relies on the Nx project graph cache,
459
- // which reads from disk. During migrations, the packages migration may have
460
- // already moved packages in the Tree but those changes aren't flushed to disk
461
- // yet, causing moveGenerator to use stale project locations.
462
- // Since applications don't need import path updates (they're entry points),
463
- // manual move is safe and reliable.
418
+ // Step 0: Clean node_modules from destination on disk if present.
419
+ // npm install may create node_modules/ at the target path (e.g. for workspace
420
+ // dependency resolution). tree.delete() only records a virtual deletion and
421
+ // doesn't remove on-disk children, so moveGenerator's checkDestination
422
+ // (which uses tree.children() -> readdirSync) would see node_modules and
423
+ // throw "Path is not empty". We must remove it from the real filesystem.
424
+ const destNodeModules = (0, path_1.join)(newPath, 'node_modules');
425
+ if ((0, fs_1.existsSync)(destNodeModules)) {
426
+ devkit_1.logger.info(` Removing leftover node_modules at destination: ${destNodeModules}`);
427
+ (0, fs_1.rmSync)(destNodeModules, { recursive: true, force: true });
428
+ }
429
+ // Step 1: Use Nx moveGenerator for the heavy lifting
464
430
  try {
465
- moveProjectFiles(tree, app.currentPath, newPath);
466
- updateProjectJsonAfterMove(tree, newPath, newNxProjectName);
467
- devkit_1.logger.info(` Project moved successfully`);
431
+ await (0, generators_1.moveGenerator)(tree, {
432
+ projectName: app.currentNxProjectName,
433
+ destination: newPath,
434
+ newProjectName: newNxProjectName,
435
+ updateImportPath: false, // Applications are entry points, not libraries
436
+ skipFormat: true,
437
+ });
438
+ devkit_1.logger.info(` Nx moved project successfully`);
468
439
  // Reset Nx cache after move to ensure fresh project graph for next operations
440
+ // This is important because moveGenerator uses the project graph, and it can become stale
469
441
  resetNxCache();
470
442
  }
471
443
  catch (error) {
472
- devkit_1.logger.error(` Failed to move project: ${error}`);
444
+ devkit_1.logger.error(` Failed to move project with Nx: ${error}`);
473
445
  devkit_1.logger.error(` Source path: ${app.currentPath}`);
474
446
  devkit_1.logger.error(` Destination path: ${newPath}`);
475
447
  devkit_1.logger.error(` Project name: ${app.currentNxProjectName}`);
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Migration: Update .gitignore to exclude Claude Code local settings
3
+ *
4
+ * Adds .claude/settings.local.json to .gitignore to prevent local Claude Code
5
+ * settings from being committed to the repository.
6
+ */
7
+ import { Tree } from '@nx/devkit';
8
+ export default function update(tree: Tree): Promise<void>;
9
+ //# sourceMappingURL=update-gitignore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-gitignore.d.ts","sourceRoot":"","sources":["../../../src/migrations/3-4-0/update-gitignore.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAU,MAAM,YAAY,CAAC;AAE1C,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CA0C9D"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ /**
3
+ * Migration: Update .gitignore to exclude Claude Code local settings
4
+ *
5
+ * Adds .claude/settings.local.json to .gitignore to prevent local Claude Code
6
+ * settings from being committed to the repository.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.default = update;
10
+ const devkit_1 = require("@nx/devkit");
11
+ async function update(tree) {
12
+ devkit_1.logger.info('🔄 Updating .gitignore to exclude Claude Code local settings...');
13
+ const gitignorePath = '.gitignore';
14
+ if (!tree.exists(gitignorePath)) {
15
+ devkit_1.logger.warn('âš ī¸ .gitignore file not found, creating one');
16
+ tree.write(gitignorePath, '');
17
+ }
18
+ try {
19
+ const currentContent = tree.read(gitignorePath, 'utf-8') || '';
20
+ let updatedContent = currentContent;
21
+ // Check if .claude/settings.local.json is already in .gitignore
22
+ const claudeSettingsRegex = /^\.claude\/settings\.local\.json\s*$/gm;
23
+ if (!claudeSettingsRegex.test(updatedContent)) {
24
+ // Add Claude Code local settings section and entry
25
+ if (!updatedContent.includes('# Claude Code local settings')) {
26
+ updatedContent =
27
+ updatedContent.trim() + '\n\n# Claude Code local settings\n';
28
+ }
29
+ if (!updatedContent.includes('.claude/settings.local.json')) {
30
+ updatedContent += '.claude/settings.local.json\n';
31
+ devkit_1.logger.info('📝 Added .claude/settings.local.json to .gitignore');
32
+ }
33
+ tree.write(gitignorePath, updatedContent);
34
+ devkit_1.logger.info('✅ Successfully updated .gitignore');
35
+ }
36
+ else {
37
+ devkit_1.logger.info('â„šī¸ .claude/settings.local.json already exists in .gitignore');
38
+ }
39
+ }
40
+ catch (error) {
41
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
42
+ devkit_1.logger.error(`❌ Failed to update .gitignore: ${errorMessage}`);
43
+ throw new Error(`Failed to update .gitignore: ${errorMessage}`);
44
+ }
45
+ }
package/generators.json CHANGED
@@ -15,6 +15,11 @@
15
15
  "schema": "./dist/generators/add-application/schema.json",
16
16
  "description": "add-application generator"
17
17
  },
18
+ "add-documentation": {
19
+ "factory": "./dist/generators/add-documentation/add-documentation",
20
+ "schema": "./dist/generators/add-documentation/schema.json",
21
+ "description": "Add a documentation site (Docusaurus)"
22
+ },
18
23
  "add-visual": {
19
24
  "factory": "./dist/generators/add-visual/add-visual",
20
25
  "schema": "./dist/generators/add-visual/schema.json",
package/migrations.json CHANGED
@@ -282,6 +282,14 @@
282
282
  "cli": {
283
283
  "postUpdateMessage": "✅ npm workspaces pattern updated to use explicit includes. Documentation apps can now have their own node_modules."
284
284
  }
285
+ },
286
+ "3-4-0-update-gitignore": {
287
+ "version": "3.4.0",
288
+ "description": "Updates .gitignore to exclude Claude Code local settings",
289
+ "factory": "./dist/migrations/3-4-0/update-gitignore.js",
290
+ "cli": {
291
+ "postUpdateMessage": "✅ .gitignore updated to exclude .claude/settings.local.json"
292
+ }
285
293
  }
286
294
  },
287
295
  "packageJsonUpdates": {
@@ -439,4 +447,4 @@
439
447
  }
440
448
  }
441
449
  }
442
- }
450
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unisphere/nx",
3
- "version": "3.2.4",
3
+ "version": "3.4.0",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -91,4 +91,4 @@
91
91
  "nx-migrations": {
92
92
  "migrations": "./migrations.json"
93
93
  }
94
- }
94
+ }