@unisphere/nx 3.7.2 → 3.9.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":"reorganize-packages-by-distribution-channel.d.ts","sourceRoot":"","sources":["../../../src/migrations/3-0-0/reorganize-packages-by-distribution-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,IAAI,EAML,MAAM,YAAY,CAAC;AA+rBpB;;GAEG;AACH,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAyH9D"}
1
+ {"version":3,"file":"reorganize-packages-by-distribution-channel.d.ts","sourceRoot":"","sources":["../../../src/migrations/3-0-0/reorganize-packages-by-distribution-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,IAAI,EAML,MAAM,YAAY,CAAC;AAguBpB;;GAEG;AACH,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAyH9D"}
@@ -110,15 +110,31 @@ function calculateNewPackageJsonName(currentPackageJsonName, distributionChannel
110
110
  return `@local/${baseName}`;
111
111
  }
112
112
  }
113
+ /**
114
+ * Get the subdirectory for core/types packages.
115
+ * Special case: types packages should only go to 'unisphere' (public) or 'kaltura-corp' (internal).
116
+ * - If distributionChannel is 'npm', it's a public product -> 'unisphere'
117
+ * - Otherwise (none, github, kaltura-ai), assume internal -> 'kaltura-corp'
118
+ */
119
+ function getSubdirectoryForTypes(distributionChannel) {
120
+ if (distributionChannel === 'npm') {
121
+ return 'unisphere';
122
+ }
123
+ return 'kaltura-corp';
124
+ }
113
125
  /**
114
126
  * Check if a package has already been migrated to the new subdirectory structure.
115
127
  * Checks both regular name and name with "-react" suffix since we don't know
116
128
  * at this point if the package has React dependencies.
117
129
  */
118
130
  function isAlreadyMigrated(tree, name, distributionChannel) {
119
- const subdirectory = getSubdirectory(distributionChannel);
120
131
  // Handle core -> types rename
121
132
  const targetName = name === 'core' ? 'types' : name;
133
+ const isCoreOrTypes = name === 'core' || name === 'types';
134
+ // Special case for core/types: only allow 'unisphere' or 'kaltura-corp'
135
+ const subdirectory = isCoreOrTypes
136
+ ? getSubdirectoryForTypes(distributionChannel)
137
+ : getSubdirectory(distributionChannel);
122
138
  // Check regular path
123
139
  const newPath = `unisphere/packages/${subdirectory}/${targetName}/package.json`;
124
140
  if (tree.exists(newPath)) {
@@ -180,9 +196,13 @@ async function discoverPackages(tree) {
180
196
  }
181
197
  }
182
198
  // Calculate target path to check if package is already at the target location
183
- const subdirectory = getSubdirectory(distributionChannel);
184
199
  // Handle core -> types rename when calculating target path
185
200
  const targetName = normalizedName === 'core' ? 'types' : normalizedName;
201
+ const isCoreOrTypes = normalizedName === 'core' || normalizedName === 'types';
202
+ // Special case for core/types: only allow 'unisphere' or 'kaltura-corp'
203
+ const subdirectory = isCoreOrTypes
204
+ ? getSubdirectoryForTypes(distributionChannel)
205
+ : getSubdirectory(distributionChannel);
186
206
  const targetPath = `unisphere/packages/${subdirectory}/${targetName}`;
187
207
  // Check if package is already at the target location (sourceRoot == targetPath)
188
208
  // Also check with -react suffix since we don't know React dependency status yet
@@ -250,9 +270,12 @@ async function discoverPackages(tree) {
250
270
  * - Adding "-react" suffix for packages with React dependencies (except core/types)
251
271
  */
252
272
  function calculateMigrationTarget(pkg) {
253
- const subdirectory = getSubdirectory(pkg.distributionChannel);
254
273
  // Check if this is the core/types package (special case - no React suffix)
255
274
  const isCoreOrTypes = pkg.name === 'core' || pkg.name === 'types';
275
+ // Special case for core/types: only allow 'unisphere' or 'kaltura-corp'
276
+ const subdirectory = isCoreOrTypes
277
+ ? getSubdirectoryForTypes(pkg.distributionChannel)
278
+ : getSubdirectory(pkg.distributionChannel);
256
279
  // Step 1: Apply special case renames (core -> types)
257
280
  let newName = pkg.name === 'core' ? 'types' : pkg.name;
258
281
  // Step 2: Apply "-react" suffix if package has React dependencies
@@ -264,7 +287,12 @@ function calculateMigrationTarget(pkg) {
264
287
  const isRename = newName !== pkg.name;
265
288
  const newPath = `unisphere/packages/${subdirectory}/${newName}`;
266
289
  // Calculate new package.json name
267
- let newPackageJsonName = calculateNewPackageJsonName(pkg.currentPackageJsonName, pkg.distributionChannel);
290
+ // For core/types, use the effective distribution channel that matches the subdirectory
291
+ // (since we override the subdirectory for core/types, we need to match the package name)
292
+ const effectiveDistributionChannel = isCoreOrTypes
293
+ ? (pkg.distributionChannel === 'npm' ? 'npm' : 'github') // 'github' maps to @kaltura-corp/unisphere-
294
+ : pkg.distributionChannel;
295
+ let newPackageJsonName = calculateNewPackageJsonName(pkg.currentPackageJsonName, effectiveDistributionChannel);
268
296
  // Handle core->types rename in package.json name
269
297
  if (pkg.name === 'core') {
270
298
  newPackageJsonName = newPackageJsonName
@@ -18,6 +18,9 @@ import { Tree } from '@nx/devkit';
18
18
  *
19
19
  * This automatically excludes unisphere/applications/documentation/** without
20
20
  * needing a negation pattern.
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.
21
24
  */
22
- export default function update(tree: Tree): Promise<void>;
25
+ export default function update(tree: Tree): Promise<void | (() => void)>;
23
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;AAE/D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CA8D9D"}
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"}
@@ -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 child_process_1 = require("child_process");
5
6
  /**
6
7
  * Migration: Fix npm workspaces pattern to use explicit includes
7
8
  *
@@ -21,6 +22,9 @@ const devkit_1 = require("@nx/devkit");
21
22
  *
22
23
  * This automatically excludes unisphere/applications/documentation/** without
23
24
  * needing a negation pattern.
25
+ *
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.
24
28
  */
25
29
  async function update(tree) {
26
30
  devkit_1.logger.info('🔄 Fixing npm workspaces pattern to use explicit includes');
@@ -69,4 +73,17 @@ async function update(tree) {
69
73
  devkit_1.logger.info(` ${JSON.stringify(newWorkspaces)}`);
70
74
  devkit_1.logger.info('');
71
75
  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
+ };
72
89
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unisphere/nx",
3
- "version": "3.7.2",
3
+ "version": "3.9.0",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",