@unisphere/nx 1.22.8 → 2.1.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/README.md +1 -164
- package/dist/generators/add-application/add-application.js +1 -1
- package/dist/generators/add-application/templates/default/package.json.template +2 -5
- package/dist/generators/add-application/templates/local-dev-playground/package.json +1 -0
- package/dist/generators/add-package/add-package.d.ts.map +1 -1
- package/dist/generators/add-package/add-package.js +0 -83
- package/dist/generators/add-package/templates/new-package/package.json.template +1 -10
- package/dist/generators/add-package/templates/new-package/src/index.ts.template +0 -1
- package/dist/generators/add-package/templates/new-package/src/lib/.keep +0 -0
- package/dist/generators/add-runtime/add-runtime.d.ts.map +1 -1
- package/dist/generators/add-runtime/add-runtime.js +6 -16
- package/dist/generators/add-runtime/schema.d.ts +1 -1
- package/dist/generators/add-runtime/schema.json +9 -9
- package/dist/migrations/1-22-0/check-nx-version.js +1 -1
- package/dist/migrations/1-22-2/templates/cicd.template +1 -1
- package/dist/migrations/1-22-4/summary.js +1 -2
- package/dist/migrations/2-0-0/fix-playground-apps.d.ts +3 -0
- package/dist/migrations/2-0-0/fix-playground-apps.d.ts.map +1 -0
- package/dist/migrations/2-0-0/fix-playground-apps.js +86 -0
- package/dist/migrations/2-0-0/move-runtime-info-to-core.d.ts +3 -0
- package/dist/migrations/2-0-0/move-runtime-info-to-core.d.ts.map +1 -0
- package/dist/migrations/2-0-0/move-runtime-info-to-core.js +217 -0
- package/dist/migrations/2-0-0/patches/@nx+rollup+22.1.3.patch +27 -0
- package/dist/migrations/2-0-0/rename-widgetname-to-widgetname.d.ts +3 -0
- package/dist/migrations/2-0-0/rename-widgetname-to-widgetname.d.ts.map +1 -0
- package/dist/migrations/2-0-0/rename-widgetname-to-widgetname.js +38 -0
- package/dist/migrations/{1-22-7/update-git-ignore.d.ts → 2-0-0/replace-patches.d.ts} +1 -1
- package/dist/migrations/2-0-0/replace-patches.d.ts.map +1 -0
- package/dist/migrations/2-0-0/replace-patches.js +56 -0
- package/dist/migrations/2-0-0/summary.d.ts +2 -0
- package/dist/migrations/2-0-0/summary.d.ts.map +1 -0
- package/dist/migrations/2-0-0/summary.js +12 -0
- package/dist/migrations/2-0-0/sync-package-json-files.d.ts +3 -0
- package/dist/migrations/2-0-0/sync-package-json-files.d.ts.map +1 -0
- package/dist/migrations/2-0-0/sync-package-json-files.js +68 -0
- package/dist/migrations/2-0-0/update-npmrc.d.ts +3 -0
- package/dist/migrations/2-0-0/update-npmrc.d.ts.map +1 -0
- package/dist/migrations/2-0-0/update-npmrc.js +48 -0
- package/dist/migrations/2-0-0/update-nvmrc.d.ts +3 -0
- package/dist/migrations/2-0-0/update-nvmrc.d.ts.map +1 -0
- package/dist/migrations/2-0-0/update-nvmrc.js +26 -0
- package/dist/migrations/2-1-0/remove-react-overrides.d.ts +3 -0
- package/dist/migrations/2-1-0/remove-react-overrides.d.ts.map +1 -0
- package/dist/migrations/2-1-0/remove-react-overrides.js +59 -0
- package/dist/migrations/2-1-0/remove-rollup-plugin-node-builtins.d.ts +3 -0
- package/dist/migrations/2-1-0/remove-rollup-plugin-node-builtins.d.ts.map +1 -0
- package/dist/migrations/2-1-0/remove-rollup-plugin-node-builtins.js +54 -0
- package/dist/migrations/2-1-0/remove-storybook.d.ts.map +1 -0
- package/dist/migrations/{1-22-7 → 2-1-0}/remove-storybook.js +1 -27
- package/dist/migrations/2-1-0/replace-readme-md.d.ts +3 -0
- package/dist/migrations/2-1-0/replace-readme-md.d.ts.map +1 -0
- package/dist/migrations/2-1-0/replace-readme-md.js +50 -0
- package/dist/migrations/2-1-0/templates/readme.md.template +134 -0
- package/generators.json +20 -0
- package/migrations.json +163 -8
- package/package.json +1 -1
- package/dist/migrations/1-22-7/remove-storybook.d.ts.map +0 -1
- package/dist/migrations/1-22-7/update-git-ignore.d.ts.map +0 -1
- package/dist/migrations/1-22-7/update-git-ignore.js +0 -55
- /package/dist/migrations/{1-22-7 → 2-1-0}/remove-storybook.d.ts +0 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = update;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
// Ensure these are installed in your project: npm install ts-morph --save-dev
|
|
6
|
+
const ts_morph_1 = require("ts-morph");
|
|
7
|
+
const utils_1 = require("../../generators/utils");
|
|
8
|
+
/**
|
|
9
|
+
* Finds runtimes that have both runtime-information.ts and runtime-settings.ts files
|
|
10
|
+
* in their src/ or src/lib/ directory.
|
|
11
|
+
* @param tree The file system tree.
|
|
12
|
+
* @returns An array of RuntimeInfo objects.
|
|
13
|
+
*/
|
|
14
|
+
function findRuntimesWithInformationAndSettingsFiles(tree) {
|
|
15
|
+
const runtimes = new Map();
|
|
16
|
+
const runtimesDir = 'unisphere/runtimes';
|
|
17
|
+
// Only traverse the runtimes directory
|
|
18
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, runtimesDir, (filePath) => {
|
|
19
|
+
// Look for runtime-information.ts or runtime-settings.ts files in src/ or src/lib/
|
|
20
|
+
const runtimeMatch = filePath.match(/unisphere\/runtimes\/([^\/]+)\/src(?:\/lib)?\/(runtime-information|runtime-settings)\.ts$/);
|
|
21
|
+
if (runtimeMatch) {
|
|
22
|
+
const runtimeName = runtimeMatch[1];
|
|
23
|
+
const fileType = runtimeMatch[2];
|
|
24
|
+
if (!runtimes.has(runtimeName)) {
|
|
25
|
+
runtimes.set(runtimeName, {
|
|
26
|
+
name: runtimeName,
|
|
27
|
+
path: `unisphere/runtimes/${runtimeName}`,
|
|
28
|
+
hasInformation: false,
|
|
29
|
+
hasSettings: false,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const runtime = runtimes.get(runtimeName);
|
|
33
|
+
if (fileType === 'runtime-information') {
|
|
34
|
+
runtime.hasInformation = true;
|
|
35
|
+
runtime.informationPath = filePath;
|
|
36
|
+
}
|
|
37
|
+
else if (fileType === 'runtime-settings') {
|
|
38
|
+
runtime.hasSettings = true;
|
|
39
|
+
runtime.settingsPath = filePath;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
let res = Array.from(runtimes.values()).filter((r) => r.hasInformation && r.hasSettings);
|
|
44
|
+
return res;
|
|
45
|
+
}
|
|
46
|
+
// ------------------------------------------------------------
|
|
47
|
+
async function update(tree) {
|
|
48
|
+
devkit_1.logger.info('🔄 Starting runtime info migration to core...');
|
|
49
|
+
const runtimes = findRuntimesWithInformationAndSettingsFiles(tree);
|
|
50
|
+
if (runtimes.length === 0) {
|
|
51
|
+
devkit_1.logger.info('ℹ️ No runtimes found with local runtime-information.ts or runtime-settings.ts files.');
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
devkit_1.logger.info(`📦 Found ${runtimes.length} runtime(s) to migrate`);
|
|
55
|
+
let migratedCount = 0;
|
|
56
|
+
// Initialize the ts-morph Project once
|
|
57
|
+
const project = new ts_morph_1.Project({
|
|
58
|
+
manipulationSettings: {
|
|
59
|
+
quoteKind: ts_morph_1.QuoteKind.Single,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
for (const runtime of runtimes) {
|
|
63
|
+
devkit_1.logger.info(`\n🔄 Migrating runtime: ${runtime.name}`);
|
|
64
|
+
const nameTransforms = (0, utils_1.createNameTransforms)(runtime.name, 'runtimeName');
|
|
65
|
+
const pascalName = nameTransforms['runtimeName__pascalCase'];
|
|
66
|
+
const dashName = nameTransforms['runtimeName__lowerDashCase'];
|
|
67
|
+
const camelName = nameTransforms['runtimeName__camelCase'];
|
|
68
|
+
const corePath = `unisphere/packages/core/src/lib/${runtime.name}-runtime`;
|
|
69
|
+
const runtimeTypesPath = `${corePath}/runtime-types.ts`;
|
|
70
|
+
const indexPath = `${corePath}/index.ts`;
|
|
71
|
+
// 1. Create core runtime-types.ts file
|
|
72
|
+
let settingsContentRaw = runtime.settingsPath && tree.exists(runtime.settingsPath)
|
|
73
|
+
? tree.read(runtime.settingsPath, 'utf-8') || ''
|
|
74
|
+
: '';
|
|
75
|
+
if (settingsContentRaw) {
|
|
76
|
+
// Rename types in the content to be globally unique
|
|
77
|
+
settingsContentRaw = settingsContentRaw.replace(/\bRuntimeSettings\b/g, `${pascalName}RuntimeSettings`);
|
|
78
|
+
settingsContentRaw = settingsContentRaw.replace(/\bruntimeSettingsSchema\b/g, `${camelName}RuntimeSettingsSchema`);
|
|
79
|
+
}
|
|
80
|
+
// Export the new RuntimeName
|
|
81
|
+
const runtimeTypesContent = `${settingsContentRaw}\n\nexport const ${pascalName}RuntimeName = '${dashName}' as const;`;
|
|
82
|
+
tree.write(runtimeTypesPath, runtimeTypesContent);
|
|
83
|
+
tree.write(indexPath, `export * from './runtime-types';\n`);
|
|
84
|
+
devkit_1.logger.info(` ✅ Created runtime types in ${corePath}`);
|
|
85
|
+
// 2. Update core index.ts to export the new runtime types
|
|
86
|
+
const coreIndexPath = 'unisphere/packages/core/src/index.ts';
|
|
87
|
+
if (tree.exists(coreIndexPath)) {
|
|
88
|
+
const coreIndexContent = tree.read(coreIndexPath, 'utf-8') || '';
|
|
89
|
+
const exportLine = `export * from './lib/${runtime.name}-runtime';`;
|
|
90
|
+
if (!coreIndexContent.includes(exportLine)) {
|
|
91
|
+
const updatedCoreIndex = coreIndexContent.trimEnd() + '\n' + exportLine + '\n';
|
|
92
|
+
tree.write(coreIndexPath, updatedCoreIndex);
|
|
93
|
+
devkit_1.logger.info(` 🔗 Updated core index exports`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
devkit_1.logger.error(` ⚠️ Core index.ts not found at ${coreIndexPath}`);
|
|
98
|
+
}
|
|
99
|
+
// 3. Update runtime.tsx to import from core alias and rename usages (using ts-morph)
|
|
100
|
+
const runtimeTsxPath = `${runtime.path}/src/lib/runtime.tsx`;
|
|
101
|
+
if (tree.exists(runtimeTsxPath)) {
|
|
102
|
+
try {
|
|
103
|
+
const coreAlias = (0, utils_1.findCorePackageAlias)(tree);
|
|
104
|
+
const runtimeTsxContent = tree.read(runtimeTsxPath, 'utf-8') || '';
|
|
105
|
+
// Create a temporary in-memory SourceFile for ts-morph to parse and modify
|
|
106
|
+
const sourceFile = project.createSourceFile(runtimeTsxPath, runtimeTsxContent, { overwrite: true });
|
|
107
|
+
// Define the new, standardized names
|
|
108
|
+
const newWidgetName = `WidgetName`;
|
|
109
|
+
const newRuntimeName = `${pascalName}RuntimeName`;
|
|
110
|
+
// Define all named imports we are responsible for consolidating/adding
|
|
111
|
+
const newNamedImports = [
|
|
112
|
+
`${pascalName}RuntimeSettings`,
|
|
113
|
+
`${camelName}RuntimeSettingsSchema`,
|
|
114
|
+
newRuntimeName,
|
|
115
|
+
newWidgetName,
|
|
116
|
+
];
|
|
117
|
+
// --- A. Remove old local imports ---
|
|
118
|
+
const localImportSpecifiers = [
|
|
119
|
+
'./runtime-information',
|
|
120
|
+
'./runtime-settings',
|
|
121
|
+
'../runtime-information',
|
|
122
|
+
'../runtime-settings',
|
|
123
|
+
];
|
|
124
|
+
sourceFile.getImportDeclarations().forEach(importDeclaration => {
|
|
125
|
+
const moduleSpecifier = importDeclaration.getModuleSpecifierValue().replace(/\.ts$/, '');
|
|
126
|
+
if (localImportSpecifiers.includes(moduleSpecifier)) {
|
|
127
|
+
importDeclaration.remove();
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
// --- B. Rename usages of old identifiers to new, unique names ---
|
|
131
|
+
const identifierRenames = new Map([
|
|
132
|
+
// Base types/schemas
|
|
133
|
+
['RuntimeSettings', `${pascalName}RuntimeSettings`],
|
|
134
|
+
['runtimeSettingsSchema', `${camelName}RuntimeSettingsSchema`],
|
|
135
|
+
// Constants (Original -> New Core Name)
|
|
136
|
+
['unisphereWidgetName', newWidgetName],
|
|
137
|
+
['unisphereRuntimeName', newRuntimeName],
|
|
138
|
+
]);
|
|
139
|
+
// This loop performs the renaming in the file
|
|
140
|
+
sourceFile.forEachDescendant(node => {
|
|
141
|
+
if (node.isKind(ts_morph_1.SyntaxKind.Identifier)) {
|
|
142
|
+
const nodeText = node.getText();
|
|
143
|
+
const newText = identifierRenames.get(nodeText);
|
|
144
|
+
if (newText) {
|
|
145
|
+
node.replaceWithText(newText);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
// --- C. Add new core imports (SAFELY) ---
|
|
150
|
+
let coreImportDeclaration = sourceFile.getImportDeclaration((decl) => decl.getModuleSpecifierValue() === coreAlias);
|
|
151
|
+
// 1. Remove ONLY the specific named imports we are consolidating from any existing core imports
|
|
152
|
+
sourceFile.getImportDeclarations().forEach(importDeclaration => {
|
|
153
|
+
const specifier = importDeclaration.getModuleSpecifierValue();
|
|
154
|
+
// If it's the root core alias, remove only the named imports that we will re-add.
|
|
155
|
+
if (specifier === coreAlias) {
|
|
156
|
+
importDeclaration.getNamedImports().forEach(namedImport => {
|
|
157
|
+
const importName = namedImport.getName();
|
|
158
|
+
if (newNamedImports.includes(importName)) {
|
|
159
|
+
namedImport.remove();
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
// If the declaration is now empty, remove it completely.
|
|
163
|
+
if (importDeclaration.getNamedImports().length === 0 && !importDeclaration.getDefaultImport()) {
|
|
164
|
+
importDeclaration.remove();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
// 2. Add the new combined import for runtime types and names
|
|
169
|
+
// If the core import line was removed, we need to recreate it.
|
|
170
|
+
coreImportDeclaration = sourceFile.getImportDeclaration((decl) => decl.getModuleSpecifierValue() === coreAlias);
|
|
171
|
+
if (!coreImportDeclaration) {
|
|
172
|
+
// If it doesn't exist (i.e., was just deleted or never existed), add a new one.
|
|
173
|
+
sourceFile.addImportDeclaration({
|
|
174
|
+
moduleSpecifier: `${coreAlias}`,
|
|
175
|
+
namedImports: newNamedImports,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
// If it still exists (meaning it had other imports), just add the new ones to the existing declaration.
|
|
180
|
+
coreImportDeclaration.addNamedImports(newNamedImports);
|
|
181
|
+
}
|
|
182
|
+
// --- D. Write content back to the Tree ---
|
|
183
|
+
// Ensure the tree.write gets the updated text after all replacements
|
|
184
|
+
tree.write(runtimeTsxPath, sourceFile.getFullText());
|
|
185
|
+
devkit_1.logger.info(` 🔁 Updated imports, runtime, and widget usages using ts-morph in ${runtimeTsxPath}`);
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
devkit_1.logger.error(` ❌ Failed to update ${runtimeTsxPath} with ts-morph: ${error}`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
devkit_1.logger.warn(` ⚠️ Runtime file not found at ${runtimeTsxPath}`);
|
|
193
|
+
}
|
|
194
|
+
// 4. Delete old files
|
|
195
|
+
if (runtime.informationPath && tree.exists(runtime.informationPath)) {
|
|
196
|
+
tree.delete(runtime.informationPath);
|
|
197
|
+
devkit_1.logger.info(` 🗑️ Deleted ${runtime.informationPath}`);
|
|
198
|
+
}
|
|
199
|
+
if (runtime.settingsPath && tree.exists(runtime.settingsPath)) {
|
|
200
|
+
tree.delete(runtime.settingsPath);
|
|
201
|
+
devkit_1.logger.info(` 🗑️ Deleted ${runtime.settingsPath}`);
|
|
202
|
+
}
|
|
203
|
+
migratedCount++;
|
|
204
|
+
devkit_1.logger.info(` ✅ Successfully migrated ${runtime.name}`);
|
|
205
|
+
}
|
|
206
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
207
|
+
devkit_1.logger.info('');
|
|
208
|
+
devkit_1.logger.warn('═══════════════════════════════════════════════════════════════');
|
|
209
|
+
devkit_1.logger.warn(`✅ Migrated ${migratedCount} runtime(s) to use core package!`);
|
|
210
|
+
devkit_1.logger.warn('═══════════════════════════════════════════════════════════════');
|
|
211
|
+
devkit_1.logger.warn('');
|
|
212
|
+
devkit_1.logger.warn('⚠️ Summary of changes:');
|
|
213
|
+
devkit_1.logger.warn(' • Runtime settings/information types were moved to core and renamed.');
|
|
214
|
+
devkit_1.logger.warn(' • **unisphereWidgetName was renamed to WidgetName, imported from core, and usages were fixed.**');
|
|
215
|
+
devkit_1.logger.warn('');
|
|
216
|
+
devkit_1.logger.warn('═══════════════════════════════════════════════════════════════');
|
|
217
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
diff --git a/node_modules/@nx/rollup/src/plugins/with-nx/with-nx.js b/node_modules/@nx/rollup/src/plugins/with-nx/with-nx.js
|
|
2
|
+
index 1135bba..4762053 100644
|
|
3
|
+
--- a/node_modules/@nx/rollup/src/plugins/with-nx/with-nx.js
|
|
4
|
+
+++ b/node_modules/@nx/rollup/src/plugins/with-nx/with-nx.js
|
|
5
|
+
@@ -149,7 +149,13 @@ dependencies) {
|
|
6
|
+
else {
|
|
7
|
+
options.generatePackageJson ??= true;
|
|
8
|
+
}
|
|
9
|
+
- const compilerOptions = createTsCompilerOptions(projectRoot, tsConfig, options, dependencies);
|
|
10
|
+
+ let compilerOptionsInterceptor = ((config) => config);
|
|
11
|
+
+ if (rollupConfig.unisphere?.interceptors?.compilerOptions) {
|
|
12
|
+
+ console.log(`[unisphere.nx.rollup] using monkey patched interceptor for TS compiler options`);
|
|
13
|
+
+ compilerOptionsInterceptor = rollupConfig.unisphere?.interceptors?.compilerOptions;
|
|
14
|
+
+ }
|
|
15
|
+
+
|
|
16
|
+
+ const compilerOptions = compilerOptionsInterceptor(createTsCompilerOptions(projectRoot, tsConfig, options, dependencies));
|
|
17
|
+
compilerOptions.outDir = Array.isArray(finalConfig.output)
|
|
18
|
+
? finalConfig.output[0].dir
|
|
19
|
+
: finalConfig.output.dir;
|
|
20
|
+
@@ -170,6 +176,7 @@ dependencies) {
|
|
21
|
+
return require('rollup-plugin-typescript2')({
|
|
22
|
+
check: !options.skipTypeCheck,
|
|
23
|
+
tsconfig: tsConfigPath,
|
|
24
|
+
+ exclude: ['**/*.stories.ts', '**/*.stories.tsx'],
|
|
25
|
+
tsconfigOverride: {
|
|
26
|
+
compilerOptions,
|
|
27
|
+
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-widgetname-to-widgetname.d.ts","sourceRoot":"","sources":["../../../src/migrations/2-0-0/rename-widgetname-to-widgetname.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAIL,MAAM,YAAY,CAAC;AAEpB,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,iBAwC9C"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = update;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
async function update(tree) {
|
|
6
|
+
devkit_1.logger.info('🔄 Starting WidgetName to widgetName migration...');
|
|
7
|
+
let filesUpdated = 0;
|
|
8
|
+
// Update TypeScript and TSX files in the workspace
|
|
9
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, '.', (filePath) => {
|
|
10
|
+
// Only process TypeScript and TSX files in unisphere directories
|
|
11
|
+
if ((!filePath.endsWith('.ts') && !filePath.endsWith('.tsx')) ||
|
|
12
|
+
!filePath.includes('unisphere/')) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const content = tree.read(filePath, 'utf-8');
|
|
16
|
+
if (!content)
|
|
17
|
+
return;
|
|
18
|
+
let hasChanges = false;
|
|
19
|
+
let updatedContent = content;
|
|
20
|
+
// Simple global replacement: WidgetName -> widgetName
|
|
21
|
+
if (content.includes('WidgetName')) {
|
|
22
|
+
updatedContent = updatedContent.replace(/WidgetName/g, 'widgetName');
|
|
23
|
+
hasChanges = true;
|
|
24
|
+
}
|
|
25
|
+
if (hasChanges) {
|
|
26
|
+
tree.write(filePath, updatedContent);
|
|
27
|
+
filesUpdated++;
|
|
28
|
+
devkit_1.logger.info(`✅ Updated WidgetName references in ${filePath}`);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
if (filesUpdated > 0) {
|
|
32
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
33
|
+
devkit_1.logger.info(`✅ WidgetName to widgetName migration completed. Updated ${filesUpdated} files.`);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
devkit_1.logger.info('ℹ️ No WidgetName references found to migrate.');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replace-patches.d.ts","sourceRoot":"","sources":["../../../src/migrations/2-0-0/replace-patches.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAmC,MAAM,YAAY,CAAC;AAQnE,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAwD9D"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = update;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const removePatchList = ['nx+rollup+'];
|
|
7
|
+
const forcePatchVersions = {
|
|
8
|
+
'@nx/rollup': '22.1.3'
|
|
9
|
+
};
|
|
10
|
+
async function update(tree) {
|
|
11
|
+
devkit_1.logger.info('🔄 Creating patches');
|
|
12
|
+
try {
|
|
13
|
+
// Check @nx/rollup version
|
|
14
|
+
if (Object.keys(forcePatchVersions).length !== 0) {
|
|
15
|
+
devkit_1.logger.info('removing patches of older versions');
|
|
16
|
+
const pkg = (0, devkit_1.readJson)(tree, 'package.json');
|
|
17
|
+
Object.keys(forcePatchVersions).forEach(key => {
|
|
18
|
+
const version = pkg.devDependencies?.[key] || pkg.dependencies?.[key];
|
|
19
|
+
if (version !== forcePatchVersions[key]) {
|
|
20
|
+
devkit_1.logger.error(`❌ ${key} version must be exactly ${forcePatchVersions[key]}`);
|
|
21
|
+
throw new Error(`${key} version must be exactly ${forcePatchVersions[key]}. did you migrate nx to other version?`);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
// Create patches
|
|
26
|
+
const patchesPath = 'patches';
|
|
27
|
+
const patchesTemplatePath = (0, path_1.join)(__dirname, 'patches');
|
|
28
|
+
// Delete existing patches folder content if it exists
|
|
29
|
+
if (tree.exists(patchesPath)) {
|
|
30
|
+
const existingFiles = tree.children(patchesPath);
|
|
31
|
+
for (const file of existingFiles) {
|
|
32
|
+
if (removePatchList.some(patch => file.includes(patch))) {
|
|
33
|
+
devkit_1.logger.info(`🗑️ Removing existing patch: ${file}`);
|
|
34
|
+
tree.delete((0, path_1.join)(patchesPath, file));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
devkit_1.logger.info(`✅ Patch: ${file} is up to date`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
devkit_1.logger.info(`🧹 Cleaned up existing patches folder`);
|
|
41
|
+
}
|
|
42
|
+
// Copy all patch files using generateFiles
|
|
43
|
+
(0, devkit_1.generateFiles)(tree, patchesTemplatePath, `./${patchesPath}`, {});
|
|
44
|
+
// Log created patches
|
|
45
|
+
const createdPatches = tree.children(patchesPath);
|
|
46
|
+
for (const patchFile of createdPatches) {
|
|
47
|
+
devkit_1.logger.info(`✅ Created patch: ${patchFile}`);
|
|
48
|
+
}
|
|
49
|
+
// Always log that patches were created
|
|
50
|
+
devkit_1.logger.info(`✅ All patches created successfully`);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
devkit_1.logger.error(`❌ Failed to create patches: ${error?.message || 'Unknown error'}`);
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../../src/migrations/2-0-0/summary.ts"],"names":[],"mappings":"AAEA,0CAOC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
async function default_1() {
|
|
6
|
+
devkit_1.logger.info('');
|
|
7
|
+
devkit_1.logger.info('🎉 Migration to @unisphere/nx 2.0.0 finished successfully!');
|
|
8
|
+
devkit_1.logger.info('');
|
|
9
|
+
devkit_1.logger.info('📋 Full details:');
|
|
10
|
+
devkit_1.logger.info('https://unisphere.kaltura.com/docs/create/changelog/2-0-0-changelog');
|
|
11
|
+
devkit_1.logger.info('');
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-package-json-files.d.ts","sourceRoot":"","sources":["../../../src/migrations/2-0-0/sync-package-json-files.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,IAAI,EAIL,MAAM,YAAY,CAAC;AAEtB,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM,EAAE,CAAC,CAsEzE"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = update;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
async function update(tree) {
|
|
6
|
+
devkit_1.logger.info('🔄 Sync package json files deps...');
|
|
7
|
+
let filesUpdated = 0;
|
|
8
|
+
// Read the root package.json to get the target versions
|
|
9
|
+
const rootPackageJson = tree.read('package.json', 'utf-8');
|
|
10
|
+
if (!rootPackageJson) {
|
|
11
|
+
devkit_1.logger.error('❌ Could not read root package.json');
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const rootPackage = JSON.parse(rootPackageJson);
|
|
15
|
+
const targetVersions = {
|
|
16
|
+
...rootPackage.dependencies,
|
|
17
|
+
...rootPackage.devDependencies
|
|
18
|
+
};
|
|
19
|
+
devkit_1.logger.info(`📦 Found ${Object.keys(targetVersions).length} dependencies to sync`);
|
|
20
|
+
// Find all package.json files in packages directory
|
|
21
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, '.', (filePath) => {
|
|
22
|
+
if (filePath.endsWith('package.json')) {
|
|
23
|
+
const content = tree.read(filePath, 'utf-8');
|
|
24
|
+
if (content) {
|
|
25
|
+
try {
|
|
26
|
+
const packageJson = JSON.parse(content);
|
|
27
|
+
let hasChanges = false;
|
|
28
|
+
// Sync dependencies
|
|
29
|
+
if (packageJson.dependencies) {
|
|
30
|
+
for (const [depName, currentVersion] of Object.entries(packageJson.dependencies)) {
|
|
31
|
+
if (targetVersions[depName] && currentVersion !== targetVersions[depName]) {
|
|
32
|
+
devkit_1.logger.info(`🔄 Updating ${depName} from ${currentVersion} to ${targetVersions[depName]} in ${filePath}`);
|
|
33
|
+
packageJson.dependencies[depName] = targetVersions[depName];
|
|
34
|
+
hasChanges = true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Sync devDependencies
|
|
39
|
+
if (packageJson.devDependencies) {
|
|
40
|
+
for (const [depName, currentVersion] of Object.entries(packageJson.devDependencies)) {
|
|
41
|
+
if (targetVersions[depName] && currentVersion !== targetVersions[depName]) {
|
|
42
|
+
devkit_1.logger.info(`🔄 Updating ${depName} from ${currentVersion} to ${targetVersions[depName]} in ${filePath}`);
|
|
43
|
+
packageJson.devDependencies[depName] = targetVersions[depName];
|
|
44
|
+
hasChanges = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (hasChanges) {
|
|
49
|
+
// Write the updated package.json back
|
|
50
|
+
const updatedContent = JSON.stringify(packageJson, null, 2) + '\n';
|
|
51
|
+
tree.write(filePath, updatedContent);
|
|
52
|
+
filesUpdated++;
|
|
53
|
+
devkit_1.logger.info(`✅ Updated ${filePath}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
devkit_1.logger.error(`❌ Error parsing ${filePath}: ${error}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
if (filesUpdated > 0) {
|
|
63
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
devkit_1.logger.info('ℹ️ No package.json files needed updating.');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-npmrc.d.ts","sourceRoot":"","sources":["../../../src/migrations/2-0-0/update-npmrc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAA6C,MAAM,YAAY,CAAC;AAE7E,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM,EAAE,CAAC,CAgDzE"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = update;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
async function update(tree) {
|
|
6
|
+
devkit_1.logger.info('🔄 Checking .npmrc for legacy-peer-deps=true...');
|
|
7
|
+
let filesScanned = 0;
|
|
8
|
+
let filesUpdated = 0;
|
|
9
|
+
const updateContent = (content) => {
|
|
10
|
+
const re = /(\blegacy-peer-deps\b\s*=\s*)true(\b|\s*)/gi;
|
|
11
|
+
if (re.test(content)) {
|
|
12
|
+
// Replace only the value while preserving whitespace and formatting
|
|
13
|
+
const replaced = content.replace(re, '$1false$2');
|
|
14
|
+
return replaced;
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
};
|
|
18
|
+
// Prefer root .npmrc, but scan workspace to be safe
|
|
19
|
+
const tryUpdateFile = (filePath) => {
|
|
20
|
+
const content = tree.read(filePath, 'utf-8');
|
|
21
|
+
if (!content)
|
|
22
|
+
return;
|
|
23
|
+
filesScanned++;
|
|
24
|
+
const updated = updateContent(content);
|
|
25
|
+
if (updated && updated !== content) {
|
|
26
|
+
tree.write(filePath, updated);
|
|
27
|
+
filesUpdated++;
|
|
28
|
+
devkit_1.logger.info(`✅ Updated ${filePath}: legacy-peer-deps=false`);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
if (tree.exists('.npmrc')) {
|
|
32
|
+
tryUpdateFile('.npmrc');
|
|
33
|
+
}
|
|
34
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, '.', (p) => {
|
|
35
|
+
if (p.endsWith('/.npmrc') || p === '.npmrc') {
|
|
36
|
+
if (p !== '.npmrc') {
|
|
37
|
+
tryUpdateFile(p);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
42
|
+
if (filesUpdated === 0) {
|
|
43
|
+
devkit_1.logger.info('ℹ️ No .npmrc files required changes.');
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
devkit_1.logger.warn(`✅ Updated ${filesUpdated} .npmrc file(s).`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-nvmrc.d.ts","sourceRoot":"","sources":["../../../src/migrations/2-0-0/update-nvmrc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAuB,MAAM,YAAY,CAAC;AAEvD,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CA0B9D"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = update;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
async function update(tree) {
|
|
6
|
+
devkit_1.logger.info('🔄 Updating .nvmrc to Node 24...');
|
|
7
|
+
const nvmrcPath = '.nvmrc';
|
|
8
|
+
const targetNodeVersion = '24';
|
|
9
|
+
if (tree.exists(nvmrcPath)) {
|
|
10
|
+
const currentContent = tree.read(nvmrcPath, 'utf-8');
|
|
11
|
+
if (currentContent) {
|
|
12
|
+
const currentVersion = currentContent.trim();
|
|
13
|
+
if (currentVersion === targetNodeVersion) {
|
|
14
|
+
devkit_1.logger.info('ℹ️ .nvmrc already set to Node 24.');
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
tree.write(nvmrcPath, targetNodeVersion);
|
|
18
|
+
devkit_1.logger.info(`✅ Updated .nvmrc from ${currentVersion} to ${targetNodeVersion}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
tree.write(nvmrcPath, targetNodeVersion);
|
|
23
|
+
devkit_1.logger.info(`✅ Created .nvmrc with Node ${targetNodeVersion}`);
|
|
24
|
+
}
|
|
25
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-react-overrides.d.ts","sourceRoot":"","sources":["../../../src/migrations/2-1-0/remove-react-overrides.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAsB,MAAM,YAAY,CAAC;AAEtD,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CA+D9D"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = update;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
async function update(tree) {
|
|
6
|
+
devkit_1.logger.info('🔄 Removing React overrides from package.json...');
|
|
7
|
+
const packageJsonPath = 'package.json';
|
|
8
|
+
if (!tree.exists(packageJsonPath)) {
|
|
9
|
+
devkit_1.logger.warn('⚠️ package.json not found');
|
|
10
|
+
throw new Error('package.json not found');
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
(0, devkit_1.updateJson)(tree, packageJsonPath, (packageJson) => {
|
|
14
|
+
let overridesRemoved = 0;
|
|
15
|
+
if (packageJson.overrides) {
|
|
16
|
+
// Find overrides that contain React-related dependencies
|
|
17
|
+
const overridesToRemove = Object.keys(packageJson.overrides).filter(key => {
|
|
18
|
+
const override = packageJson.overrides[key];
|
|
19
|
+
// Check if the override contains React-related dependencies
|
|
20
|
+
if (typeof override === 'object' && override !== null) {
|
|
21
|
+
return Object.entries(override).some(([dep, version]) => (dep === 'react' ||
|
|
22
|
+
dep.startsWith('react-') ||
|
|
23
|
+
dep.startsWith('@types/react')) && (typeof version === 'string' && (version.startsWith('18') || version.startsWith('^18'))));
|
|
24
|
+
}
|
|
25
|
+
// Check if the key itself is React-related
|
|
26
|
+
return key === 'react' ||
|
|
27
|
+
key.startsWith('react-') ||
|
|
28
|
+
key.startsWith('@types/react');
|
|
29
|
+
});
|
|
30
|
+
// Remove the identified overrides
|
|
31
|
+
overridesToRemove.forEach(key => {
|
|
32
|
+
delete packageJson.overrides[key];
|
|
33
|
+
overridesRemoved++;
|
|
34
|
+
});
|
|
35
|
+
// If overrides object is now empty, remove it entirely
|
|
36
|
+
if (Object.keys(packageJson.overrides).length === 0) {
|
|
37
|
+
delete packageJson.overrides;
|
|
38
|
+
devkit_1.logger.info('📦 Removed empty overrides object');
|
|
39
|
+
}
|
|
40
|
+
if (overridesRemoved > 0) {
|
|
41
|
+
devkit_1.logger.info(`📦 Removed ${overridesRemoved} React-related overrides from package.json`);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
devkit_1.logger.info('ℹ️ No React-related overrides found to remove');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
devkit_1.logger.info('ℹ️ No overrides section found in package.json');
|
|
49
|
+
}
|
|
50
|
+
return packageJson;
|
|
51
|
+
});
|
|
52
|
+
devkit_1.logger.info('✅ Successfully processed React overrides removal');
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
56
|
+
devkit_1.logger.error(`❌ Could not update package.json: ${errorMessage}`);
|
|
57
|
+
throw new Error(`Could not update package.json: ${errorMessage}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-rollup-plugin-node-builtins.d.ts","sourceRoot":"","sources":["../../../src/migrations/2-1-0/remove-rollup-plugin-node-builtins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAsB,MAAM,YAAY,CAAC;AAEtD,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAwD9D"}
|