@unisphere/nx 1.1.4 â 1.2.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/templates/default/.eslintrc.json +5 -1
- package/dist/generators/add-application/templates/interactive-playground/.eslintrc.json +5 -1
- package/dist/generators/add-package/add-package.d.ts.map +1 -1
- package/dist/generators/add-package/add-package.js +9 -3
- package/dist/generators/add-package/templates/new-package/.eslintrc.json +5 -1
- package/dist/generators/add-runtime/templates/new-runtime/.eslintrc.json +5 -1
- package/dist/generators/migrate-to-1-1-5/migrate-to-1-1-5.d.ts +3 -0
- package/dist/generators/migrate-to-1-1-5/migrate-to-1-1-5.d.ts.map +1 -0
- package/dist/generators/migrate-to-1-1-5/migrate-to-1-1-5.js +49 -0
- package/dist/generators/migrate-to-1-1-5/run-locally.md +9 -0
- package/dist/generators/migrate-to-1-1-5/schema.d.ts +1 -0
- package/dist/generators/migrate-to-1-1-5/schema.json +10 -0
- package/dist/generators/migrate-to-1-1-5/update-packages.d.ts +3 -0
- package/dist/generators/migrate-to-1-1-5/update-packages.d.ts.map +1 -0
- package/dist/generators/migrate-to-1-1-5/update-packages.js +205 -0
- package/dist/generators/test-migration-locally/generator.d.ts +16 -0
- package/dist/generators/test-migration-locally/generator.d.ts.map +1 -0
- package/dist/generators/test-migration-locally/generator.js +112 -0
- package/dist/generators/test-migration-locally/run-locally.md +9 -0
- package/dist/generators/test-migration-locally/schema.json +10 -0
- package/dist/migrations/update-1-1-5/_update-languages.d.ts +3 -0
- package/dist/migrations/update-1-1-5/_update-languages.d.ts.map +1 -0
- package/dist/migrations/update-1-1-5/_update-languages.js +130 -0
- package/dist/migrations/update-1-1-5/check-nx-version.d.ts +3 -0
- package/dist/migrations/update-1-1-5/check-nx-version.d.ts.map +1 -0
- package/dist/migrations/update-1-1-5/check-nx-version.js +20 -0
- package/dist/migrations/update-1-1-5/fix-dependency-versions.d.ts +3 -0
- package/dist/migrations/update-1-1-5/fix-dependency-versions.d.ts.map +1 -0
- package/dist/migrations/update-1-1-5/fix-dependency-versions.js +76 -0
- package/dist/migrations/update-1-1-5/fix-playground-apps.d.ts +3 -0
- package/dist/migrations/update-1-1-5/fix-playground-apps.d.ts.map +1 -0
- package/dist/migrations/update-1-1-5/fix-playground-apps.js +86 -0
- package/dist/migrations/update-1-1-5/move-runtime-info-to-core.d.ts +3 -0
- package/dist/migrations/update-1-1-5/move-runtime-info-to-core.d.ts.map +1 -0
- package/dist/migrations/update-1-1-5/move-runtime-info-to-core.js +217 -0
- package/dist/migrations/update-1-1-5/rename-widgetname-to-widgetname.d.ts +3 -0
- package/dist/migrations/update-1-1-5/rename-widgetname-to-widgetname.d.ts.map +1 -0
- package/dist/migrations/update-1-1-5/rename-widgetname-to-widgetname.js +38 -0
- package/dist/migrations/update-1-1-5/sync-package-json-files.d.ts +3 -0
- package/dist/migrations/update-1-1-5/sync-package-json-files.d.ts.map +1 -0
- package/dist/migrations/update-1-1-5/sync-package-json-files.js +68 -0
- package/dist/migrations/update-1-1-5/templates/cicd.template +55 -0
- package/dist/migrations/update-1-1-5/update-github-workflow.d.ts +3 -0
- package/dist/migrations/update-1-1-5/update-github-workflow.d.ts.map +1 -0
- package/dist/migrations/update-1-1-5/update-github-workflow.js +35 -0
- package/dist/migrations/update-1-1-5/update-npmrc.d.ts +3 -0
- package/dist/migrations/update-1-1-5/update-npmrc.d.ts.map +1 -0
- package/dist/migrations/update-1-1-5/update-npmrc.js +48 -0
- package/dist/migrations/update-1-1-5/update-nvmrc.d.ts +3 -0
- package/dist/migrations/update-1-1-5/update-nvmrc.d.ts.map +1 -0
- package/dist/migrations/update-1-1-5/update-nvmrc.js +26 -0
- package/dist/migrations.json +164 -0
- package/generators.json +11 -0
- package/migrations.json +164 -0
- package/package.json +12 -3
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = update;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const add_package_1 = require("../../generators/add-package/add-package");
|
|
6
|
+
const ts_morph_1 = require("ts-morph");
|
|
7
|
+
function hasDep(pkg, name) {
|
|
8
|
+
return !!(pkg.dependencies?.[name] || pkg.devDependencies?.[name] || pkg.peerDependencies?.[name]);
|
|
9
|
+
}
|
|
10
|
+
async function update(tree) {
|
|
11
|
+
devkit_1.logger.info('đ Updating languages to @unisphere/ui-i18n-react...');
|
|
12
|
+
if (!tree.exists('package.json')) {
|
|
13
|
+
devkit_1.logger.warn('package.json not found, skipping.');
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const pkg = (0, devkit_1.readJson)(tree, 'package.json');
|
|
17
|
+
const usesI18next = hasDep(pkg, 'i18next') || hasDep(pkg, 'react-i18next');
|
|
18
|
+
// Detect local usage of useTranslation from ui-kit-react (custom hook)
|
|
19
|
+
let usesUiKitUseTranslation = false;
|
|
20
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, '.', (p) => {
|
|
21
|
+
if (!p.endsWith('.ts') && !p.endsWith('.tsx'))
|
|
22
|
+
return;
|
|
23
|
+
const content = tree.read(p, 'utf-8');
|
|
24
|
+
if (content && content.includes("from 'ui-kit-react/use-translation'")) {
|
|
25
|
+
usesUiKitUseTranslation = true;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
if (usesI18next && usesUiKitUseTranslation) {
|
|
29
|
+
throw new Error('â Found both i18next and ui-kit-react/use-translation. Please remove one before migrating.');
|
|
30
|
+
}
|
|
31
|
+
if (!usesI18next) {
|
|
32
|
+
devkit_1.logger.info('âšī¸ i18next not detected. Skipping migration.');
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
// Remove i18next packages
|
|
36
|
+
['i18next', 'react-i18next', 'i18next-browser-languagedetector', 'i18next-http-backend']
|
|
37
|
+
.forEach((dep) => {
|
|
38
|
+
if (pkg.dependencies?.[dep])
|
|
39
|
+
delete pkg.dependencies[dep];
|
|
40
|
+
if (pkg.devDependencies?.[dep])
|
|
41
|
+
delete pkg.devDependencies[dep];
|
|
42
|
+
if (pkg.peerDependencies?.[dep])
|
|
43
|
+
delete pkg.peerDependencies[dep];
|
|
44
|
+
});
|
|
45
|
+
// Add @unisphere/ui-i18n-react
|
|
46
|
+
pkg.dependencies = pkg.dependencies || {};
|
|
47
|
+
pkg.dependencies['@unisphere/ui-i18n-react'] = 'latest';
|
|
48
|
+
(0, devkit_1.writeJson)(tree, 'package.json', pkg);
|
|
49
|
+
// A
|
|
50
|
+
// Ensure ui-kit-react package exists with same distribution channel as core
|
|
51
|
+
try {
|
|
52
|
+
const coreConfigPath = 'unisphere/packages/core/project.json';
|
|
53
|
+
let distributionChannel = 'github';
|
|
54
|
+
// Todo get drim unisphere file
|
|
55
|
+
if (tree.exists(coreConfigPath)) {
|
|
56
|
+
const coreProjectJson = (0, devkit_1.readJson)(tree, coreConfigPath);
|
|
57
|
+
distributionChannel = coreProjectJson?.targets?.publish?.options?.distributionChannel || 'github';
|
|
58
|
+
}
|
|
59
|
+
if (!tree.exists('unisphere/packages/ui-kit-react')) {
|
|
60
|
+
await (0, add_package_1.addPackageGenerator)(tree, { packageName: 'ui-kit-react', scope: distributionChannel === 'npm' ? 'public' : distributionChannel === 'none' ? 'none' : 'internal' });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
devkit_1.logger.warn(`Could not auto-create ui-kit-react package: ${e}`);
|
|
65
|
+
}
|
|
66
|
+
// Create use-translation.ts in ui-kit-react
|
|
67
|
+
const useTranslationPath = 'unisphere/packages/ui-kit-react/src/lib/use-translation.ts';
|
|
68
|
+
if (!tree.exists(useTranslationPath)) {
|
|
69
|
+
const content = `import en from '../languages/en-US.json';
|
|
70
|
+
import { createUseTranslation } from '@unisphere/ui-i18n-react';
|
|
71
|
+
|
|
72
|
+
export const useTranslation = createUseTranslation({
|
|
73
|
+
packageName: '@kaltura/unisphere-media-manager',
|
|
74
|
+
defaultTranslations: en as any,
|
|
75
|
+
supportedLanguages: [
|
|
76
|
+
'de-DE', 'es-ES', 'fi-FI', 'fr-CA', 'fr-FR',
|
|
77
|
+
'he-IL', 'it-IT', 'ja-JP', 'ko-KR', 'nl-NL',
|
|
78
|
+
'pt-BR', 'ru-RU', 'zh-CN', 'zh-TW'
|
|
79
|
+
]
|
|
80
|
+
});
|
|
81
|
+
`;
|
|
82
|
+
tree.write(useTranslationPath, content);
|
|
83
|
+
}
|
|
84
|
+
// Update imports: react-i18next -> ui-kit-react/use-translation
|
|
85
|
+
const project = new ts_morph_1.Project({ useInMemoryFileSystem: true, skipAddingFilesFromTsConfig: true });
|
|
86
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, '.', (filePath) => {
|
|
87
|
+
if (!filePath.endsWith('.ts') && !filePath.endsWith('.tsx'))
|
|
88
|
+
return;
|
|
89
|
+
const content = tree.read(filePath, 'utf-8');
|
|
90
|
+
if (!content)
|
|
91
|
+
return;
|
|
92
|
+
if (!content.includes("from 'react-i18next'") && !content.includes("from \"react-i18next\""))
|
|
93
|
+
return;
|
|
94
|
+
const sf = project.createSourceFile(filePath, content, { overwrite: true });
|
|
95
|
+
let changed = false;
|
|
96
|
+
sf.getImportDeclarations().forEach((imp) => {
|
|
97
|
+
const spec = imp.getModuleSpecifierValue();
|
|
98
|
+
if (spec === 'react-i18next') {
|
|
99
|
+
const named = imp.getNamedImports().map((n) => n.getName());
|
|
100
|
+
if (named.includes('useTranslation')) {
|
|
101
|
+
imp.remove();
|
|
102
|
+
sf.addImportDeclaration({
|
|
103
|
+
moduleSpecifier: 'ui-kit-react/use-translation',
|
|
104
|
+
namedImports: [{ name: 'useTranslation' }],
|
|
105
|
+
});
|
|
106
|
+
changed = true;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
// Remove i18next providers usage patterns (simple pass to remove I18nextProvider/Translation)
|
|
111
|
+
let text = sf.getFullText();
|
|
112
|
+
text = text.replace(/<I18nextProvider[\s\S]*?>/g, '');
|
|
113
|
+
text = text.replace(/<\/I18nextProvider>/g, '');
|
|
114
|
+
text = text.replace(/<Suspense[\s\S]*?>/g, '<>');
|
|
115
|
+
text = text.replace(/<\/Suspense>/g, '</>');
|
|
116
|
+
if (changed || text !== sf.getFullText()) {
|
|
117
|
+
tree.write(filePath, text);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
// Ensure languages path exists relative to kit and create langs-export.yml
|
|
121
|
+
const langsYaml = 'unisphere/packages/ui-kit-react/langs-export.yml';
|
|
122
|
+
if (!tree.exists(langsYaml)) {
|
|
123
|
+
tree.write(langsYaml, `package: ui-kit-react\nexport:\n - path: src/lib/languages\n pattern: '**/*.json'\n`);
|
|
124
|
+
}
|
|
125
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
126
|
+
devkit_1.logger.warn('âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ');
|
|
127
|
+
devkit_1.logger.warn('â
Language migration prepared.');
|
|
128
|
+
devkit_1.logger.warn('Next: npm install && verify app compiles.');
|
|
129
|
+
devkit_1.logger.warn('âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ');
|
|
130
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-nx-version.d.ts","sourceRoot":"","sources":["../../../src/migrations/update-1-1-5/check-nx-version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAoB,MAAM,YAAY,CAAC;AAEpD,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAsBvD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = checkNxVersion;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
function checkNxVersion(tree) {
|
|
6
|
+
devkit_1.logger.info('đ Checking Nx version compatibility...');
|
|
7
|
+
const pkg = (0, devkit_1.readJson)(tree, 'package.json');
|
|
8
|
+
const nxVersion = pkg.devDependencies?.nx || pkg.dependencies?.nx;
|
|
9
|
+
if (!nxVersion) {
|
|
10
|
+
devkit_1.logger.error('â No Nx version found in package.json');
|
|
11
|
+
throw new Error('No Nx version found in package.json. Please install Nx first.');
|
|
12
|
+
}
|
|
13
|
+
const majorVersion = parseInt(nxVersion.match(/\d+/)?.[0] ?? '0');
|
|
14
|
+
if (majorVersion < 22) {
|
|
15
|
+
const errorMessage = `â This migration requires Nx 22 or higher. Current version: ${nxVersion}\n\nPlease upgrade Nx first by running:\n npx nx migrate nx@22\n npm install\n npx nx migrate --run-migrations`;
|
|
16
|
+
devkit_1.logger.error(errorMessage);
|
|
17
|
+
throw new Error(errorMessage);
|
|
18
|
+
}
|
|
19
|
+
devkit_1.logger.info(`â
Nx version check passed (version: ${nxVersion})`);
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix-dependency-versions.d.ts","sourceRoot":"","sources":["../../../src/migrations/update-1-1-5/fix-dependency-versions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAuB,MAAM,YAAY,CAAC;AAEvD,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CA8E9D"}
|
|
@@ -0,0 +1,76 @@
|
|
|
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('đ Fixing @changesets/cli version in root package.json...');
|
|
7
|
+
let filesUpdated = 0;
|
|
8
|
+
const targetPackage = '@changesets/cli';
|
|
9
|
+
const updatePackageJson = (filePath) => {
|
|
10
|
+
const content = tree.read(filePath, 'utf-8');
|
|
11
|
+
if (!content)
|
|
12
|
+
return;
|
|
13
|
+
try {
|
|
14
|
+
const packageJson = JSON.parse(content);
|
|
15
|
+
let modified = false;
|
|
16
|
+
// Process dependencies
|
|
17
|
+
if (packageJson.dependencies && packageJson.dependencies[targetPackage]) {
|
|
18
|
+
const version = packageJson.dependencies[targetPackage];
|
|
19
|
+
if (typeof version === 'string' && version.startsWith('^')) {
|
|
20
|
+
packageJson.dependencies[targetPackage] = version.substring(1);
|
|
21
|
+
modified = true;
|
|
22
|
+
devkit_1.logger.info(` ââ ${targetPackage}: ${version} â ${packageJson.dependencies[targetPackage]}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// Process devDependencies
|
|
26
|
+
if (packageJson.devDependencies && packageJson.devDependencies[targetPackage]) {
|
|
27
|
+
const version = packageJson.devDependencies[targetPackage];
|
|
28
|
+
if (typeof version === 'string' && version.startsWith('^')) {
|
|
29
|
+
packageJson.devDependencies[targetPackage] = version.substring(1);
|
|
30
|
+
modified = true;
|
|
31
|
+
devkit_1.logger.info(` ââ ${targetPackage}: ${version} â ${packageJson.devDependencies[targetPackage]}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// Process peerDependencies
|
|
35
|
+
if (packageJson.peerDependencies && packageJson.peerDependencies[targetPackage]) {
|
|
36
|
+
const version = packageJson.peerDependencies[targetPackage];
|
|
37
|
+
if (typeof version === 'string' && version.startsWith('^')) {
|
|
38
|
+
packageJson.peerDependencies[targetPackage] = version.substring(1);
|
|
39
|
+
modified = true;
|
|
40
|
+
devkit_1.logger.info(` ââ ${targetPackage}: ${version} â ${packageJson.peerDependencies[targetPackage]}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// Process optionalDependencies
|
|
44
|
+
if (packageJson.optionalDependencies && packageJson.optionalDependencies[targetPackage]) {
|
|
45
|
+
const version = packageJson.optionalDependencies[targetPackage];
|
|
46
|
+
if (typeof version === 'string' && version.startsWith('^')) {
|
|
47
|
+
packageJson.optionalDependencies[targetPackage] = version.substring(1);
|
|
48
|
+
modified = true;
|
|
49
|
+
devkit_1.logger.info(` ââ ${targetPackage}: ${version} â ${packageJson.optionalDependencies[targetPackage]}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (modified) {
|
|
53
|
+
tree.write(filePath, JSON.stringify(packageJson, null, 2) + '\n');
|
|
54
|
+
filesUpdated++;
|
|
55
|
+
devkit_1.logger.info(`â
Updated ${filePath}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
devkit_1.logger.warn(`â ī¸ Failed to parse ${filePath}: ${error}`);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
// Update root package.json only
|
|
63
|
+
if (tree.exists('package.json')) {
|
|
64
|
+
updatePackageJson('package.json');
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
devkit_1.logger.warn('â ī¸ No package.json found in root directory.');
|
|
68
|
+
}
|
|
69
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
70
|
+
if (filesUpdated === 0) {
|
|
71
|
+
devkit_1.logger.info('âšī¸ No changes needed in package.json.');
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
devkit_1.logger.info(`â
Fixed dependency versions in package.json.`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix-playground-apps.d.ts","sourceRoot":"","sources":["../../../src/migrations/update-1-1-5/fix-playground-apps.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,IAAI,EAIL,MAAM,YAAY,CAAC;AAGpB,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,iBAqG9C"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = update;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const ts_morph_1 = require("ts-morph");
|
|
6
|
+
async function update(tree) {
|
|
7
|
+
devkit_1.logger.info('đ Starting fix playground apps migration...');
|
|
8
|
+
let filesUpdated = 0;
|
|
9
|
+
// Create a ts-morph project
|
|
10
|
+
const project = new ts_morph_1.Project({
|
|
11
|
+
useInMemoryFileSystem: true,
|
|
12
|
+
});
|
|
13
|
+
// Find and fix settings-buttons.tsx, configuration-provider.tsx, and playground-configuration-provider.tsx files
|
|
14
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, '.', (filePath) => {
|
|
15
|
+
if (filePath.endsWith('settings-buttons.tsx') ||
|
|
16
|
+
filePath.endsWith('configuration-provider.tsx') ||
|
|
17
|
+
filePath.endsWith('playground-configuration-provider.tsx')) {
|
|
18
|
+
const content = tree.read(filePath, 'utf-8');
|
|
19
|
+
if (content) {
|
|
20
|
+
let hasChanges = false;
|
|
21
|
+
// Check if the file contains patterns we need to fix
|
|
22
|
+
const buttonsContainerPattern = /export const ButtonsContainer: React\.FC<{\s*children\?\: React\.ReactChild;\s*}>/;
|
|
23
|
+
const configProviderPattern = /const getPlaygroundConfigurationFromLocalStorage = \(\s*configurationKey: string\s*\)(?!\s*:)/;
|
|
24
|
+
const configProviderWithTypePattern = /const getPlaygroundConfigurationFromLocalStorage = \(\s*configurationKey: string\s*\):\s*PlaygroundConfiguration(?!\s*\|)/;
|
|
25
|
+
if (buttonsContainerPattern.test(content) || configProviderPattern.test(content) || configProviderWithTypePattern.test(content)) {
|
|
26
|
+
// Create a source file from the content
|
|
27
|
+
const sourceFile = project.createSourceFile(filePath, content, { overwrite: true });
|
|
28
|
+
// Replace patterns using regex
|
|
29
|
+
let updatedContent = content;
|
|
30
|
+
// Fix ButtonsContainer type definition
|
|
31
|
+
if (buttonsContainerPattern.test(content)) {
|
|
32
|
+
updatedContent = updatedContent.replace(/export const ButtonsContainer: React\.FC<{\s*children\?\: React\.ReactChild;\s*}>/, 'export const ButtonsContainer: React.FC<PropsWithChildren>');
|
|
33
|
+
}
|
|
34
|
+
// Fix getPlaygroundConfigurationFromLocalStorage return type (no return type)
|
|
35
|
+
if (configProviderPattern.test(content)) {
|
|
36
|
+
updatedContent = updatedContent.replace(/const getPlaygroundConfigurationFromLocalStorage = \(\s*configurationKey: string\s*\)(?!\s*:)/, 'const getPlaygroundConfigurationFromLocalStorage = (\n configurationKey: string\n): PlaygroundConfiguration | null');
|
|
37
|
+
}
|
|
38
|
+
// Fix getPlaygroundConfigurationFromLocalStorage return type (PlaygroundConfiguration -> PlaygroundConfiguration | null)
|
|
39
|
+
if (configProviderWithTypePattern.test(content)) {
|
|
40
|
+
updatedContent = updatedContent.replace(/const getPlaygroundConfigurationFromLocalStorage = \(\s*configurationKey: string\s*\):\s*PlaygroundConfiguration(?!\s*\|)/, 'const getPlaygroundConfigurationFromLocalStorage = (\n configurationKey: string\n): PlaygroundConfiguration | null');
|
|
41
|
+
}
|
|
42
|
+
// Update the source file with the new content
|
|
43
|
+
sourceFile.replaceWithText(updatedContent);
|
|
44
|
+
// Handle imports with ts-morph (only for settings-buttons.tsx)
|
|
45
|
+
if (filePath.endsWith('settings-buttons.tsx') && buttonsContainerPattern.test(content)) {
|
|
46
|
+
const reactImport = sourceFile.getImportDeclaration('react');
|
|
47
|
+
if (reactImport) {
|
|
48
|
+
// Check if PropsWithChildren is already imported
|
|
49
|
+
const namedImports = reactImport.getNamedImports();
|
|
50
|
+
const hasPropsWithChildren = namedImports.some(imp => imp.getName() === 'PropsWithChildren');
|
|
51
|
+
if (!hasPropsWithChildren) {
|
|
52
|
+
// Add PropsWithChildren to the existing React import
|
|
53
|
+
reactImport.addNamedImport('PropsWithChildren');
|
|
54
|
+
hasChanges = true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
// If no React import exists, create one
|
|
59
|
+
sourceFile.addImportDeclaration({
|
|
60
|
+
defaultImport: 'React',
|
|
61
|
+
namedImports: ['PropsWithChildren'],
|
|
62
|
+
moduleSpecifier: 'react'
|
|
63
|
+
});
|
|
64
|
+
hasChanges = true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// Check if any changes were made
|
|
68
|
+
if (updatedContent !== content || hasChanges) {
|
|
69
|
+
// Write the updated content back to the tree
|
|
70
|
+
const finalContent = sourceFile.getFullText();
|
|
71
|
+
tree.write(filePath, finalContent);
|
|
72
|
+
filesUpdated++;
|
|
73
|
+
devkit_1.logger.info(`â
Updated ${filePath}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
if (filesUpdated > 0) {
|
|
80
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
81
|
+
devkit_1.logger.info(`â
Fix playground apps migration completed. Updated ${filesUpdated} files.`);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
devkit_1.logger.info('âšī¸ No playground files found to migrate.');
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move-runtime-info-to-core.d.ts","sourceRoot":"","sources":["../../../src/migrations/update-1-1-5/move-runtime-info-to-core.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAIL,MAAM,YAAY,CAAC;AAiEpB,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM,EAAE,CAAC,CA+MzE"}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"rename-widgetname-to-widgetname.d.ts","sourceRoot":"","sources":["../../../src/migrations/update-1-1-5/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":"sync-package-json-files.d.ts","sourceRoot":"","sources":["../../../src/migrations/update-1-1-5/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"}
|