@unisphere/nx 3.9.0 → 3.11.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.
@@ -19,8 +19,8 @@ import { Tree } from '@nx/devkit';
19
19
  * This automatically excludes unisphere/applications/documentation/** without
20
20
  * needing a negation pattern.
21
21
  *
22
- * Returns a callback to run npm install after changes are written to disk,
23
- * ensuring package-lock.json stays in sync with the new workspaces pattern.
22
+ * After updating workspaces, runs npm install to sync package-lock.json.
23
+ * Note: Nx migrations don't execute callbacks, so we flush changes and run npm install directly.
24
24
  */
25
- export default function update(tree: Tree): Promise<void | (() => void)>;
25
+ export default function update(tree: Tree): Promise<string[]>;
26
26
  //# sourceMappingURL=fix-workspaces-pattern.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fix-workspaces-pattern.d.ts","sourceRoot":"","sources":["../../../src/migrations/3-1-0/fix-workspaces-pattern.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAA+B,MAAM,YAAY,CAAC;AAG/D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CA2E7E"}
1
+ {"version":3,"file":"fix-workspaces-pattern.d.ts","sourceRoot":"","sources":["../../../src/migrations/3-1-0/fix-workspaces-pattern.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAA+B,MAAM,YAAY,CAAC;AAI/D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA+ElE"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = update;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const tree_1 = require("nx/src/generators/tree");
5
6
  const child_process_1 = require("child_process");
6
7
  /**
7
8
  * Migration: Fix npm workspaces pattern to use explicit includes
@@ -23,20 +24,20 @@ const child_process_1 = require("child_process");
23
24
  * This automatically excludes unisphere/applications/documentation/** without
24
25
  * needing a negation pattern.
25
26
  *
26
- * Returns a callback to run npm install after changes are written to disk,
27
- * ensuring package-lock.json stays in sync with the new workspaces pattern.
27
+ * After updating workspaces, runs npm install to sync package-lock.json.
28
+ * Note: Nx migrations don't execute callbacks, so we flush changes and run npm install directly.
28
29
  */
29
30
  async function update(tree) {
30
31
  devkit_1.logger.info('🔄 Fixing npm workspaces pattern to use explicit includes');
31
32
  const packageJsonPath = 'package.json';
32
33
  if (!tree.exists(packageJsonPath)) {
33
34
  devkit_1.logger.warn('No package.json found, skipping migration');
34
- return;
35
+ return [];
35
36
  }
36
37
  const packageJson = (0, devkit_1.readJson)(tree, packageJsonPath);
37
38
  if (!packageJson.workspaces || !Array.isArray(packageJson.workspaces)) {
38
39
  devkit_1.logger.warn('No workspaces array found in package.json, skipping migration');
39
- return;
40
+ return [];
40
41
  }
41
42
  const oldWorkspaces = packageJson.workspaces;
42
43
  // Check if using the old catch-all pattern
@@ -54,7 +55,7 @@ async function update(tree) {
54
55
  const hasAllExpectedPatterns = expectedPatterns.every(pattern => oldWorkspaces.includes(pattern));
55
56
  if (hasAllExpectedPatterns) {
56
57
  devkit_1.logger.info('Workspaces already using explicit patterns, skipping migration');
57
- return;
58
+ return [];
58
59
  }
59
60
  }
60
61
  // Replace with explicit patterns
@@ -73,17 +74,19 @@ async function update(tree) {
73
74
  devkit_1.logger.info(` ${JSON.stringify(newWorkspaces)}`);
74
75
  devkit_1.logger.info('');
75
76
  devkit_1.logger.info('This allows documentation apps (like Docusaurus) to have their own node_modules.');
76
- // Return callback to run npm install after tree changes are written to disk
77
- return () => {
78
- devkit_1.logger.info('');
79
- devkit_1.logger.info('Syncing package-lock.json after workspaces update...');
80
- try {
81
- (0, child_process_1.execSync)('npm install', { stdio: 'inherit' });
82
- devkit_1.logger.info('✅ package-lock.json synced successfully');
83
- }
84
- catch (error) {
85
- devkit_1.logger.error(`Failed to sync package-lock.json: ${error}`);
86
- throw error;
87
- }
88
- };
77
+ // Flush tree changes to disk before running npm install
78
+ // Note: Nx doesn't execute callbacks from migrations, so we must flush and run directly
79
+ const changes = tree.listChanges();
80
+ (0, tree_1.flushChanges)(tree.root, changes);
81
+ devkit_1.logger.info('');
82
+ devkit_1.logger.info('Syncing package-lock.json after workspaces update...');
83
+ try {
84
+ (0, child_process_1.execSync)('npm install', { stdio: 'inherit', cwd: tree.root });
85
+ devkit_1.logger.info('✅ package-lock.json synced successfully');
86
+ }
87
+ catch (error) {
88
+ devkit_1.logger.error(`Failed to sync package-lock.json: ${error}`);
89
+ devkit_1.logger.warn('⚠️ Please run "npm install" manually to sync package-lock.json');
90
+ }
91
+ return [];
89
92
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unisphere/nx",
3
- "version": "3.9.0",
3
+ "version": "3.11.0",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",