@unisphere/nx 1.21.2 → 1.22.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/migrations/1-22-0/check-nx-version.d.ts.map +1 -0
- package/dist/migrations/1-22-0/fix-dependency-versions.d.ts.map +1 -0
- package/dist/migrations/{update-1-1-5/update-nvmrc.d.ts → 1-22-0/replace-npmrc.d.ts} +1 -1
- package/dist/migrations/1-22-0/replace-npmrc.d.ts.map +1 -0
- package/dist/migrations/1-22-0/replace-npmrc.js +27 -0
- package/dist/migrations/{update-1-1-5/fix-playground-apps.d.ts → 1-22-0/replace-patches.d.ts} +1 -1
- package/dist/migrations/1-22-0/replace-patches.d.ts.map +1 -0
- package/dist/migrations/1-22-0/replace-patches.js +42 -0
- package/dist/migrations/1-22-0/summary.d.ts +2 -0
- package/dist/migrations/1-22-0/summary.d.ts.map +1 -0
- package/dist/migrations/1-22-0/summary.js +12 -0
- package/dist/migrations/1-22-0/templates/.npmrc.template +5 -0
- package/dist/migrations/{update-1-1-5 → 1-22-0}/templates/_publish-artifacts.template +76 -44
- package/dist/migrations/{update-1-1-5 → 1-22-0}/templates/cicd.template +28 -14
- package/dist/migrations/1-22-0/templates/patches/@changesets+cli+2.29.7.patch +56 -0
- package/dist/migrations/1-22-0/templates/patches/@nx+rollup+22.1.3.patch +27 -0
- package/dist/migrations/1-22-0/update-github-workflow.d.ts.map +1 -0
- package/dist/migrations/{update-1-1-5 → 1-22-0}/update-github-workflow.js +8 -6
- package/dist/migrations.json +45 -124
- package/generators.json +1 -27
- package/migrations.json +45 -124
- package/package.json +1 -1
- package/dist/generators/unisphere-migrate/generator.d.ts +0 -15
- package/dist/generators/unisphere-migrate/generator.d.ts.map +0 -1
- package/dist/generators/unisphere-migrate/generator.js +0 -169
- package/dist/generators/unisphere-migrate/run-locally.md +0 -21
- package/dist/generators/unisphere-migrate/schema.json +0 -10
- package/dist/generators/unisphere-migrate/upgrade-guide.md +0 -108
- package/dist/migrations/update-1-1-5/_update-languages.d.ts +0 -3
- package/dist/migrations/update-1-1-5/_update-languages.d.ts.map +0 -1
- package/dist/migrations/update-1-1-5/_update-languages.js +0 -130
- package/dist/migrations/update-1-1-5/check-nx-version.d.ts.map +0 -1
- package/dist/migrations/update-1-1-5/fix-dependency-versions.d.ts.map +0 -1
- package/dist/migrations/update-1-1-5/fix-playground-apps.d.ts.map +0 -1
- package/dist/migrations/update-1-1-5/fix-playground-apps.js +0 -86
- package/dist/migrations/update-1-1-5/move-runtime-info-to-core.d.ts +0 -3
- package/dist/migrations/update-1-1-5/move-runtime-info-to-core.d.ts.map +0 -1
- package/dist/migrations/update-1-1-5/move-runtime-info-to-core.js +0 -217
- package/dist/migrations/update-1-1-5/rename-widgetname-to-widgetname.d.ts +0 -3
- package/dist/migrations/update-1-1-5/rename-widgetname-to-widgetname.d.ts.map +0 -1
- package/dist/migrations/update-1-1-5/rename-widgetname-to-widgetname.js +0 -38
- package/dist/migrations/update-1-1-5/sync-package-json-files.d.ts +0 -3
- package/dist/migrations/update-1-1-5/sync-package-json-files.d.ts.map +0 -1
- package/dist/migrations/update-1-1-5/sync-package-json-files.js +0 -68
- package/dist/migrations/update-1-1-5/update-github-workflow.d.ts.map +0 -1
- package/dist/migrations/update-1-1-5/update-npmrc.d.ts +0 -3
- package/dist/migrations/update-1-1-5/update-npmrc.d.ts.map +0 -1
- package/dist/migrations/update-1-1-5/update-npmrc.js +0 -48
- package/dist/migrations/update-1-1-5/update-nvmrc.d.ts.map +0 -1
- package/dist/migrations/update-1-1-5/update-nvmrc.js +0 -26
- /package/dist/migrations/{update-1-1-5 → 1-22-0}/check-nx-version.d.ts +0 -0
- /package/dist/migrations/{update-1-1-5 → 1-22-0}/check-nx-version.js +0 -0
- /package/dist/migrations/{update-1-1-5 → 1-22-0}/fix-dependency-versions.d.ts +0 -0
- /package/dist/migrations/{update-1-1-5 → 1-22-0}/fix-dependency-versions.js +0 -0
- /package/dist/migrations/{update-1-1-5 → 1-22-0}/update-github-workflow.d.ts +0 -0
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = unisphereManualMigrate;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const fs_1 = require("fs");
|
|
6
|
-
const path_1 = require("path");
|
|
7
|
-
const child_process_1 = require("child_process");
|
|
8
|
-
/**
|
|
9
|
-
* Unisphere Migrate Generator
|
|
10
|
-
*
|
|
11
|
-
* This generator runs all migrations manually from migrations.json.
|
|
12
|
-
* Use this to force-run migrations locally or when nx migrate isn't detecting them.
|
|
13
|
-
*
|
|
14
|
-
* Usage:
|
|
15
|
-
* npx nx g @unisphere/nx:unisphere-migrate
|
|
16
|
-
*
|
|
17
|
-
* Or with local path:
|
|
18
|
-
* npx nx g /path/to/packages/nx:unisphere-migrate
|
|
19
|
-
*/
|
|
20
|
-
async function unisphereManualMigrate(tree) {
|
|
21
|
-
devkit_1.logger.info('');
|
|
22
|
-
devkit_1.logger.info('🔄 RUNNING UNISPHERE MIGRATIONS MANUALLY');
|
|
23
|
-
devkit_1.logger.info('='.repeat(70));
|
|
24
|
-
devkit_1.logger.info('This runs all migrations from migrations.json.');
|
|
25
|
-
devkit_1.logger.info('='.repeat(70));
|
|
26
|
-
devkit_1.logger.info('');
|
|
27
|
-
try {
|
|
28
|
-
// Read migrations.json
|
|
29
|
-
const migrationsJsonPath = (0, path_1.join)(__dirname, '../../../migrations.json');
|
|
30
|
-
const migrationsJson = JSON.parse((0, fs_1.readFileSync)(migrationsJsonPath, 'utf-8'));
|
|
31
|
-
const migrations = migrationsJson.migrations;
|
|
32
|
-
const packageUpdates = migrationsJson.packageJsonUpdates?.['1.9.0'];
|
|
33
|
-
// Show what will be run
|
|
34
|
-
devkit_1.logger.info(`📋 Migrations to run: ${Object.keys(migrations).length}`);
|
|
35
|
-
Object.entries(migrations).forEach(([name, config]) => {
|
|
36
|
-
devkit_1.logger.info(` • ${name}: ${config.description}`);
|
|
37
|
-
});
|
|
38
|
-
devkit_1.logger.info('');
|
|
39
|
-
// Step 1: Run migrations in order
|
|
40
|
-
devkit_1.logger.info('🚀 Starting migrations...');
|
|
41
|
-
devkit_1.logger.info('');
|
|
42
|
-
let migrationCount = 0;
|
|
43
|
-
const totalMigrations = Object.keys(migrations).length;
|
|
44
|
-
for (const [migrationName, migrationConfig] of Object.entries(migrations)) {
|
|
45
|
-
migrationCount++;
|
|
46
|
-
devkit_1.logger.info('─'.repeat(70));
|
|
47
|
-
devkit_1.logger.info(`📦 [${migrationCount}/${totalMigrations}] ${migrationName}`);
|
|
48
|
-
devkit_1.logger.info(` ${migrationConfig.description}`);
|
|
49
|
-
devkit_1.logger.info('─'.repeat(70));
|
|
50
|
-
try {
|
|
51
|
-
// Construct the migration path
|
|
52
|
-
const migrationPath = migrationConfig.implementation
|
|
53
|
-
.replace('./dist/migrations/', '../../migrations/');
|
|
54
|
-
// Import and run the migration
|
|
55
|
-
// Using eval to bypass TypeScript restrictions on require in ESM
|
|
56
|
-
const absolutePath = (0, path_1.join)(__dirname, migrationPath);
|
|
57
|
-
const requireFn = eval('require');
|
|
58
|
-
const migrationModule = requireFn(absolutePath);
|
|
59
|
-
const migrationFn = migrationModule.default || migrationModule;
|
|
60
|
-
if (typeof migrationFn !== 'function') {
|
|
61
|
-
throw new Error(`Migration ${migrationName} does not export a default function`);
|
|
62
|
-
}
|
|
63
|
-
// Execute the migration
|
|
64
|
-
await migrationFn(tree);
|
|
65
|
-
// Show post-upgrade message if it exists
|
|
66
|
-
if (migrationConfig.cli?.postUpgradeMessage) {
|
|
67
|
-
devkit_1.logger.info('');
|
|
68
|
-
devkit_1.logger.info(migrationConfig.cli.postUpgradeMessage);
|
|
69
|
-
}
|
|
70
|
-
devkit_1.logger.info('');
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
devkit_1.logger.error(`❌ Migration "${migrationName}" failed!`);
|
|
74
|
-
devkit_1.logger.error(` Error: ${error.message}`);
|
|
75
|
-
devkit_1.logger.error('');
|
|
76
|
-
devkit_1.logger.error('Stack trace:');
|
|
77
|
-
devkit_1.logger.error(error.stack);
|
|
78
|
-
throw error;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
// Step 2: Apply package.json updates
|
|
82
|
-
if (packageUpdates?.packages && Object.keys(packageUpdates.packages).length > 0) {
|
|
83
|
-
devkit_1.logger.info('');
|
|
84
|
-
devkit_1.logger.info('='.repeat(70));
|
|
85
|
-
devkit_1.logger.info('📦 APPLYING PACKAGE UPDATES');
|
|
86
|
-
devkit_1.logger.info('='.repeat(70));
|
|
87
|
-
devkit_1.logger.info('');
|
|
88
|
-
// Resolve "latest" versions to actual version with ^
|
|
89
|
-
const resolvedVersions = {};
|
|
90
|
-
const packagesToResolve = Object.entries(packageUpdates.packages)
|
|
91
|
-
.filter(([, config]) => config.version === 'latest')
|
|
92
|
-
.map(([pkgName]) => pkgName);
|
|
93
|
-
if (packagesToResolve.length > 0) {
|
|
94
|
-
devkit_1.logger.info('🔍 Resolving "latest" versions...');
|
|
95
|
-
for (const pkgName of packagesToResolve) {
|
|
96
|
-
try {
|
|
97
|
-
const result = (0, child_process_1.execSync)(`npm view ${pkgName} version`, { encoding: 'utf-8' });
|
|
98
|
-
const latestVersion = result.trim();
|
|
99
|
-
resolvedVersions[pkgName] = `^${latestVersion}`;
|
|
100
|
-
devkit_1.logger.info(` • ${pkgName}: latest → ^${latestVersion}`);
|
|
101
|
-
}
|
|
102
|
-
catch (error) {
|
|
103
|
-
devkit_1.logger.warn(` ⚠️ Could not resolve latest version for ${pkgName}, keeping "latest"`);
|
|
104
|
-
resolvedVersions[pkgName] = 'latest';
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
devkit_1.logger.info('');
|
|
108
|
-
}
|
|
109
|
-
(0, devkit_1.updateJson)(tree, 'package.json', (json) => {
|
|
110
|
-
const deps = json.dependencies || {};
|
|
111
|
-
const devDeps = json.devDependencies || {};
|
|
112
|
-
Object.entries(packageUpdates.packages).forEach(([pkgName, config]) => {
|
|
113
|
-
// Use resolved version for "latest", otherwise use as-is
|
|
114
|
-
const version = resolvedVersions[pkgName] || config.version;
|
|
115
|
-
const alwaysAdd = config.alwaysAddToPackageJson !== false;
|
|
116
|
-
if (deps[pkgName]) {
|
|
117
|
-
deps[pkgName] = version;
|
|
118
|
-
devkit_1.logger.info(` ✅ Updated ${pkgName} to ${version} (dependencies)`);
|
|
119
|
-
}
|
|
120
|
-
else if (devDeps[pkgName]) {
|
|
121
|
-
devDeps[pkgName] = version;
|
|
122
|
-
devkit_1.logger.info(` ✅ Updated ${pkgName} to ${version} (devDependencies)`);
|
|
123
|
-
}
|
|
124
|
-
else if (alwaysAdd) {
|
|
125
|
-
deps[pkgName] = version;
|
|
126
|
-
devkit_1.logger.info(` ➕ Added ${pkgName}@${version} (dependencies)`);
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
return json;
|
|
130
|
-
});
|
|
131
|
-
devkit_1.logger.info('');
|
|
132
|
-
devkit_1.logger.info('✅ Package updates applied');
|
|
133
|
-
devkit_1.logger.info('⚠️ Run "npm install" to install updated packages');
|
|
134
|
-
devkit_1.logger.info('');
|
|
135
|
-
}
|
|
136
|
-
// Step 3: Format files
|
|
137
|
-
await (0, devkit_1.formatFiles)(tree);
|
|
138
|
-
// Step 4: Show final summary message
|
|
139
|
-
devkit_1.logger.info('');
|
|
140
|
-
devkit_1.logger.info('='.repeat(70));
|
|
141
|
-
devkit_1.logger.info('✅ ALL MIGRATIONS COMPLETED');
|
|
142
|
-
devkit_1.logger.info('='.repeat(70));
|
|
143
|
-
if (packageUpdates?.postUpdateMessage) {
|
|
144
|
-
devkit_1.logger.info(packageUpdates.postUpdateMessage);
|
|
145
|
-
}
|
|
146
|
-
devkit_1.logger.info('');
|
|
147
|
-
devkit_1.logger.info('📊 Summary:');
|
|
148
|
-
devkit_1.logger.info(` Total migrations run: ${totalMigrations}`);
|
|
149
|
-
devkit_1.logger.info(` All migrations: ✅ Success`);
|
|
150
|
-
devkit_1.logger.info('');
|
|
151
|
-
devkit_1.logger.info('🔍 Review the changes:');
|
|
152
|
-
devkit_1.logger.info(' git status');
|
|
153
|
-
devkit_1.logger.info(' git diff');
|
|
154
|
-
devkit_1.logger.info('');
|
|
155
|
-
devkit_1.logger.info('♻️ To revert all changes:');
|
|
156
|
-
devkit_1.logger.info(' git checkout .');
|
|
157
|
-
devkit_1.logger.info(' git clean -fd');
|
|
158
|
-
devkit_1.logger.info('');
|
|
159
|
-
}
|
|
160
|
-
catch (error) {
|
|
161
|
-
devkit_1.logger.error('');
|
|
162
|
-
devkit_1.logger.error('='.repeat(70));
|
|
163
|
-
devkit_1.logger.error('❌ MIGRATION FLOW FAILED');
|
|
164
|
-
devkit_1.logger.error('='.repeat(70));
|
|
165
|
-
devkit_1.logger.error(`Error: ${error?.message || 'Unknown error'}`);
|
|
166
|
-
devkit_1.logger.error('');
|
|
167
|
-
throw error;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
## Run Unisphere migrations manually
|
|
2
|
-
|
|
3
|
-
From the consumer project root:
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
npx nx g @unisphere/nx:unisphere-migrate
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
Or using the local path:
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npx nx g {path}/unisphere-nx-workspace-plugin/packages/nx:unisphere-migrate
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
This will run ALL migrations defined in migrations.json manually.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
npx nx g /home/tokomeno/kaltura/unisphere/unisphere-nx-workspace-plugin/packages/nx:unisphere-migrate
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
npx nx g /home/tokomeno/kaltura/unisphere/unisphere-nx-workspace-plugin/packages/nx:add-application
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"cli": "nx",
|
|
4
|
-
"$id": "UnisphereMigrate",
|
|
5
|
-
"title": "Unisphere Manual Migrate",
|
|
6
|
-
"description": "Manually run all Unisphere migrations from migrations.json",
|
|
7
|
-
"type": "object",
|
|
8
|
-
"properties": {},
|
|
9
|
-
"required": []
|
|
10
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
### Unisphere-migrate
|
|
3
|
-
|
|
4
|
-
**Purpose:** A comprehensive migration guide and generator for upgrading Unisphere workspaces to the latest tech stack.
|
|
5
|
-
|
|
6
|
-
**What It Does:**
|
|
7
|
-
- Guides developers through a major version upgrade of their Unisphere workspace
|
|
8
|
-
- Automates code transformations for breaking changes across:
|
|
9
|
-
- React 18 → 19 (breaking changes in types and patterns)
|
|
10
|
-
- MUI v5/v6 → v7 (breaking API changes)
|
|
11
|
-
- Node.js version upgrades
|
|
12
|
-
- All @unisphere and @kaltura packages
|
|
13
|
-
- Sequences upgrade steps in the correct order (Nx first, then Unisphere)
|
|
14
|
-
- Provides safety measures (git commits, clean installs, verification steps)
|
|
15
|
-
|
|
16
|
-
**Key Features:**
|
|
17
|
-
- User-facing documentation for manual steps (environment setup, Node.js switching)
|
|
18
|
-
- Automated migration generator for code transformations
|
|
19
|
-
- Handles dependencies across multiple major version bumps
|
|
20
|
-
- Verification steps to ensure successful upgrade
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
# Unisphere Nx Workspace Upgrade Guide
|
|
24
|
-
|
|
25
|
-
This guide walks you through upgrading your Unisphere workspace to the latest version with Nx 22, React 19, MUI v7, and Node.js 24.
|
|
26
|
-
|
|
27
|
-
## Prerequisites
|
|
28
|
-
|
|
29
|
-
### Upgrade to Nx 22 First
|
|
30
|
-
|
|
31
|
-
Before running Unisphere migrations, upgrade your workspace to Nx 22:
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
npx nx migrate latest
|
|
35
|
-
npx nx migrate --run-migrations
|
|
36
|
-
npm install
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
Verify the upgrade works:
|
|
40
|
-
```bash
|
|
41
|
-
npm run check
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
For detailed Nx upgrade instructions, see the [official Nx migration guide](https://nx.dev/recipes/tips-n-tricks/advanced-update).
|
|
45
|
-
|
|
46
|
-
### Other Prerequisites
|
|
47
|
-
|
|
48
|
-
- Ensure you have Node.js 24.x installed (check with `nvm list` or install via `nvm install 24`)
|
|
49
|
-
- Ensure your workspace is committed to git before starting
|
|
50
|
-
|
|
51
|
-
## Upgrade Steps
|
|
52
|
-
|
|
53
|
-
### Step 1: Install latest @unisphere/nx
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
npm i @unisphere/nx@latest
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### Step 2: Run all migrations
|
|
60
|
-
|
|
61
|
-
This will upgrade MUI to v7, update configurations, fix dependencies, and apply all necessary changes:
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
npx nx g @unisphere/nx:unisphere-migrate
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### Step 3: Clean node_modules
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
rm -rf node_modules
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### Step 4: Verify Node.js 24 is installed
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
node -v # Should show v24.x.x
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
If not installed, run:
|
|
80
|
-
```bash
|
|
81
|
-
nvm install 24
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### Step 5: Switch to Node.js 24
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
nvm use
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Step 6: Fresh install with Node.js 24
|
|
91
|
-
|
|
92
|
-
```bash
|
|
93
|
-
npm i
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### Step 7: Fix React-related issues (if any)
|
|
97
|
-
|
|
98
|
-
If you encounter React 19 compatibility issues, you may need to:
|
|
99
|
-
- Run `react-codemod` for automatic fixes
|
|
100
|
-
- Fix TypeScript type issues manually
|
|
101
|
-
- Update component patterns that changed in React 19
|
|
102
|
-
|
|
103
|
-
### Step 8: Verify everything builds
|
|
104
|
-
|
|
105
|
-
```bash
|
|
106
|
-
npm run check
|
|
107
|
-
```
|
|
108
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_update-languages.d.ts","sourceRoot":"","sources":["../../../src/migrations/update-1-1-5/_update-languages.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAML,MAAM,YAAY,CAAC;AAUpB,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM,EAAE,CAAC,CAmIzE"}
|
|
@@ -1,130 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,86 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|