@unisphere/nx 3.18.0 → 3.19.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.
- package/dist/generators/add-application/add-application.js +1 -1
- package/dist/generators/remove/remove-utils.d.ts +21 -0
- package/dist/generators/remove/remove-utils.d.ts.map +1 -0
- package/dist/generators/remove/remove-utils.js +132 -0
- package/dist/generators/remove/remove.d.ts.map +1 -1
- package/dist/generators/remove/remove.js +8 -0
- package/dist/generators/utils.d.ts.map +1 -1
- package/dist/generators/utils.js +1 -0
- package/dist/migrations/3-17-0/add-local-runtimes-setup.js +1 -1
- package/package.json +1 -1
|
@@ -138,7 +138,7 @@ async function addApplicationGenerator(tree, options) {
|
|
|
138
138
|
// For local-dev-playground apps, generate setup-local-runtimes.ts
|
|
139
139
|
if (isPlayground) {
|
|
140
140
|
const rawConfig = (0, devkit_1.readJson)(tree, '.unisphere');
|
|
141
|
-
const experienceName =
|
|
141
|
+
const experienceName = `unisphere.${rawConfig.type}.${rawConfig.name}`;
|
|
142
142
|
const setupLocalRuntimesContent = `export function setupLocalRuntimes() {
|
|
143
143
|
if (!process.env.LOCAL_RUNTIMES) return;
|
|
144
144
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
export interface PackageJsonDependent {
|
|
3
|
+
path: string;
|
|
4
|
+
field: string;
|
|
5
|
+
}
|
|
6
|
+
export interface DependentsResult {
|
|
7
|
+
packageJsonDependents: PackageJsonDependent[];
|
|
8
|
+
importDependents: string[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Check all workspace members under unisphere/ for dependents of the given package.
|
|
12
|
+
*
|
|
13
|
+
* @param tree - Nx virtual file tree
|
|
14
|
+
* @param normalizedName - Kebab-case package name (already normalized via names().fileName)
|
|
15
|
+
*/
|
|
16
|
+
export declare function checkPackageDependents(tree: Tree, normalizedName: string): DependentsResult;
|
|
17
|
+
/**
|
|
18
|
+
* Format a human-readable error listing all dependents.
|
|
19
|
+
*/
|
|
20
|
+
export declare function formatDependentsError(packageName: string, packageJsonDependents: PackageJsonDependent[], importDependents: string[]): string;
|
|
21
|
+
//# sourceMappingURL=remove-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-utils.d.ts","sourceRoot":"","sources":["../../../src/generators/remove/remove-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAoB,MAAM,YAAY,CAAC;AAEpD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,qBAAqB,EAAE,oBAAoB,EAAE,CAAC;IAC9C,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B;AAoCD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,IAAI,EACV,cAAc,EAAE,MAAM,GACrB,gBAAgB,CAmElB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,EACnB,qBAAqB,EAAE,oBAAoB,EAAE,EAC7C,gBAAgB,EAAE,MAAM,EAAE,GACzB,MAAM,CAyBR"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkPackageDependents = checkPackageDependents;
|
|
4
|
+
exports.formatDependentsError = formatDependentsError;
|
|
5
|
+
// packages/nx/src/generators/remove/remove-utils.ts
|
|
6
|
+
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
/**
|
|
8
|
+
* Recursively collect all file paths under a directory in the Tree.
|
|
9
|
+
*/
|
|
10
|
+
function collectFiles(tree, dir) {
|
|
11
|
+
if (!tree.exists(dir))
|
|
12
|
+
return [];
|
|
13
|
+
const results = [];
|
|
14
|
+
for (const child of tree.children(dir)) {
|
|
15
|
+
const full = `${dir}/${child}`;
|
|
16
|
+
if (tree.isFile(full)) {
|
|
17
|
+
results.push(full);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
results.push(...collectFiles(tree, full));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return results;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Resolve the path alias for a package from tsconfig.base.json.
|
|
27
|
+
* Returns undefined if no matching entry found.
|
|
28
|
+
*/
|
|
29
|
+
function resolveAlias(tree, normalizedName) {
|
|
30
|
+
if (!tree.exists('tsconfig.base.json'))
|
|
31
|
+
return undefined;
|
|
32
|
+
const tsconfig = (0, devkit_1.readJson)(tree, 'tsconfig.base.json');
|
|
33
|
+
const paths = tsconfig?.compilerOptions?.paths ?? {};
|
|
34
|
+
const suffix = `/${normalizedName}/src/index.ts`;
|
|
35
|
+
for (const [alias, values] of Object.entries(paths)) {
|
|
36
|
+
if (Array.isArray(values) && values.some((v) => v.endsWith(suffix))) {
|
|
37
|
+
return alias;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Check all workspace members under unisphere/ for dependents of the given package.
|
|
44
|
+
*
|
|
45
|
+
* @param tree - Nx virtual file tree
|
|
46
|
+
* @param normalizedName - Kebab-case package name (already normalized via names().fileName)
|
|
47
|
+
*/
|
|
48
|
+
function checkPackageDependents(tree, normalizedName) {
|
|
49
|
+
const packageJsonDependents = [];
|
|
50
|
+
const importDependents = [];
|
|
51
|
+
// 1. Resolve alias
|
|
52
|
+
const alias = resolveAlias(tree, normalizedName);
|
|
53
|
+
if (!alias) {
|
|
54
|
+
devkit_1.logger.warn(`Could not resolve path alias for package '${normalizedName}' in tsconfig.base.json — import scan skipped.`);
|
|
55
|
+
}
|
|
56
|
+
// Derive sourceRoot of the package being removed (to exclude its own files)
|
|
57
|
+
const tsconfig = tree.exists('tsconfig.base.json')
|
|
58
|
+
? (0, devkit_1.readJson)(tree, 'tsconfig.base.json')
|
|
59
|
+
: {};
|
|
60
|
+
const paths = tsconfig?.compilerOptions?.paths ?? {};
|
|
61
|
+
const suffix = `/${normalizedName}/src/index.ts`;
|
|
62
|
+
let packageSourceRoot;
|
|
63
|
+
for (const values of Object.values(paths)) {
|
|
64
|
+
if (Array.isArray(values)) {
|
|
65
|
+
const match = values.find((v) => v.endsWith(suffix));
|
|
66
|
+
if (match) {
|
|
67
|
+
packageSourceRoot = match.replace('/src/index.ts', '');
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// 2. Walk all files under unisphere/
|
|
73
|
+
const allFiles = collectFiles(tree, 'unisphere');
|
|
74
|
+
const DEP_FIELDS = ['dependencies', 'devDependencies', 'peerDependencies'];
|
|
75
|
+
for (const filePath of allFiles) {
|
|
76
|
+
// Skip files within the package being removed
|
|
77
|
+
if (packageSourceRoot && filePath.startsWith(packageSourceRoot + '/')) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
// 2a. package.json scan
|
|
81
|
+
if (filePath.endsWith('/package.json') || filePath === 'package.json') {
|
|
82
|
+
if (!alias)
|
|
83
|
+
continue;
|
|
84
|
+
try {
|
|
85
|
+
const pkg = (0, devkit_1.readJson)(tree, filePath);
|
|
86
|
+
const dir = filePath.replace('/package.json', '');
|
|
87
|
+
for (const field of DEP_FIELDS) {
|
|
88
|
+
if (pkg[field]?.[alias] !== undefined) {
|
|
89
|
+
packageJsonDependents.push({ path: dir, field });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// malformed package.json — skip
|
|
95
|
+
}
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
// 2b. TypeScript import scan
|
|
99
|
+
if (alias && (filePath.endsWith('.ts') || filePath.endsWith('.tsx'))) {
|
|
100
|
+
const content = tree.read(filePath, 'utf-8');
|
|
101
|
+
if (content && content.includes(alias)) {
|
|
102
|
+
importDependents.push(filePath);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return { packageJsonDependents, importDependents };
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Format a human-readable error listing all dependents.
|
|
110
|
+
*/
|
|
111
|
+
function formatDependentsError(packageName, packageJsonDependents, importDependents) {
|
|
112
|
+
const lines = [
|
|
113
|
+
`Cannot remove package "${packageName}" — it is still in use.`,
|
|
114
|
+
'',
|
|
115
|
+
];
|
|
116
|
+
if (packageJsonDependents.length > 0) {
|
|
117
|
+
lines.push('package.json dependents:');
|
|
118
|
+
for (const dep of packageJsonDependents) {
|
|
119
|
+
lines.push(` • ${dep.path} (${dep.field})`);
|
|
120
|
+
}
|
|
121
|
+
lines.push('');
|
|
122
|
+
}
|
|
123
|
+
if (importDependents.length > 0) {
|
|
124
|
+
lines.push('Import dependents:');
|
|
125
|
+
for (const file of importDependents) {
|
|
126
|
+
lines.push(` • ${file}`);
|
|
127
|
+
}
|
|
128
|
+
lines.push('');
|
|
129
|
+
}
|
|
130
|
+
lines.push('To force removal anyway, run with --forceRemove.');
|
|
131
|
+
return lines.join('\n');
|
|
132
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../../src/generators/remove/remove.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,IAAI,EAKL,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../../src/generators/remove/remove.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,IAAI,EAKL,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAoQjD,wBAAsB,eAAe,CACnC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,qBAAqB,iBAqF/B;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -18,6 +18,7 @@ exports.removeGenerator = removeGenerator;
|
|
|
18
18
|
const devkit_1 = require("@nx/devkit");
|
|
19
19
|
const generators_1 = require("@nx/workspace/generators");
|
|
20
20
|
const utils_1 = require("../utils");
|
|
21
|
+
const remove_utils_1 = require("./remove-utils");
|
|
21
22
|
const VALID_ELEMENT_TYPES = ['package', 'runtime', 'application'];
|
|
22
23
|
/**
|
|
23
24
|
* Parse the element string in format "type:name"
|
|
@@ -210,6 +211,13 @@ async function removeGenerator(tree, options) {
|
|
|
210
211
|
const normalizedName = (0, devkit_1.names)(name).fileName;
|
|
211
212
|
// Validate element exists and get sourceRoot
|
|
212
213
|
const sourceRoot = validateElementExists(tree, elementType, normalizedName);
|
|
214
|
+
// Step 0: For packages, check for dependents before removing
|
|
215
|
+
if (elementType === 'package' && !options.forceRemove) {
|
|
216
|
+
const { packageJsonDependents, importDependents } = (0, remove_utils_1.checkPackageDependents)(tree, normalizedName);
|
|
217
|
+
if (packageJsonDependents.length > 0 || importDependents.length > 0) {
|
|
218
|
+
throw new Error((0, remove_utils_1.formatDependentsError)(normalizedName, packageJsonDependents, importDependents));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
213
221
|
// Verify the directory exists
|
|
214
222
|
if (!tree.exists(sourceRoot)) {
|
|
215
223
|
devkit_1.logger.warn(`Directory not found at ${sourceRoot}. The .unisphere configuration may be out of sync.`);
|
|
@@ -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;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,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"}
|
package/dist/generators/utils.js
CHANGED
|
@@ -230,6 +230,7 @@ function isCorePackagePath(pathValue) {
|
|
|
230
230
|
// Old pattern: unisphere/packages/core/src/index.ts
|
|
231
231
|
// New patterns with subdirectories
|
|
232
232
|
const corePatterns = [
|
|
233
|
+
'unisphere/packages/core/src/index.ts',
|
|
233
234
|
'unisphere/packages/local/core/src/index.ts',
|
|
234
235
|
'unisphere/packages/kaltura-corp/core/src/index.ts',
|
|
235
236
|
'unisphere/packages/unisphere/core/src/index.ts',
|
|
@@ -100,7 +100,7 @@ async function update(tree) {
|
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
102
|
const config = (0, devkit_1.readJson)(tree, '.unisphere');
|
|
103
|
-
const experienceName =
|
|
103
|
+
const experienceName = `unisphere.${config.type}.${config.name}`;
|
|
104
104
|
const applications = config.elements?.applications;
|
|
105
105
|
if (!applications || Object.keys(applications).length === 0) {
|
|
106
106
|
devkit_1.logger.info('ℹ️ No applications found, skipping');
|