@unisphere/nx 1.1.3 → 1.1.5

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.
Files changed (57) hide show
  1. package/README.md +7 -21
  2. package/dist/generators/add-application/templates/default/.eslintrc.json +5 -1
  3. package/dist/generators/add-application/templates/interactive-playground/.eslintrc.json +5 -1
  4. package/dist/generators/add-application/templates/interactive-playground/src/app/app.tsx.template +1 -1
  5. package/dist/generators/add-application/templates/interactive-playground/src/app/components/settings-form.tsx +7 -3
  6. package/dist/generators/add-package/add-package.d.ts.map +1 -1
  7. package/dist/generators/add-package/add-package.js +9 -3
  8. package/dist/generators/add-package/templates/new-package/.eslintrc.json +5 -1
  9. package/dist/generators/add-runtime/templates/new-runtime/.eslintrc.json +5 -1
  10. package/dist/generators/migrate-to-1-1-5/migrate-to-1-1-5.d.ts +3 -0
  11. package/dist/generators/migrate-to-1-1-5/migrate-to-1-1-5.d.ts.map +1 -0
  12. package/dist/generators/migrate-to-1-1-5/migrate-to-1-1-5.js +49 -0
  13. package/dist/generators/migrate-to-1-1-5/run-locally.md +9 -0
  14. package/dist/generators/migrate-to-1-1-5/schema.d.ts +1 -0
  15. package/dist/generators/migrate-to-1-1-5/schema.json +10 -0
  16. package/dist/generators/migrate-to-1-1-5/update-packages.d.ts +3 -0
  17. package/dist/generators/migrate-to-1-1-5/update-packages.d.ts.map +1 -0
  18. package/dist/generators/migrate-to-1-1-5/update-packages.js +205 -0
  19. package/dist/generators/test-migration-locally/generator.d.ts +16 -0
  20. package/dist/generators/test-migration-locally/generator.d.ts.map +1 -0
  21. package/dist/generators/test-migration-locally/generator.js +112 -0
  22. package/dist/generators/test-migration-locally/run-locally.md +9 -0
  23. package/dist/generators/test-migration-locally/schema.json +10 -0
  24. package/dist/migrations/update-1-1-5/_update-languages.d.ts +3 -0
  25. package/dist/migrations/update-1-1-5/_update-languages.d.ts.map +1 -0
  26. package/dist/migrations/update-1-1-5/_update-languages.js +130 -0
  27. package/dist/migrations/update-1-1-5/check-nx-version.d.ts +3 -0
  28. package/dist/migrations/update-1-1-5/check-nx-version.d.ts.map +1 -0
  29. package/dist/migrations/update-1-1-5/check-nx-version.js +20 -0
  30. package/dist/migrations/update-1-1-5/fix-dependency-versions.d.ts +3 -0
  31. package/dist/migrations/update-1-1-5/fix-dependency-versions.d.ts.map +1 -0
  32. package/dist/migrations/update-1-1-5/fix-dependency-versions.js +76 -0
  33. package/dist/migrations/update-1-1-5/fix-playground-apps.d.ts +3 -0
  34. package/dist/migrations/update-1-1-5/fix-playground-apps.d.ts.map +1 -0
  35. package/dist/migrations/update-1-1-5/fix-playground-apps.js +86 -0
  36. package/dist/migrations/update-1-1-5/move-runtime-info-to-core.d.ts +3 -0
  37. package/dist/migrations/update-1-1-5/move-runtime-info-to-core.d.ts.map +1 -0
  38. package/dist/migrations/update-1-1-5/move-runtime-info-to-core.js +217 -0
  39. package/dist/migrations/update-1-1-5/rename-widgetname-to-widgetname.d.ts +3 -0
  40. package/dist/migrations/update-1-1-5/rename-widgetname-to-widgetname.d.ts.map +1 -0
  41. package/dist/migrations/update-1-1-5/rename-widgetname-to-widgetname.js +38 -0
  42. package/dist/migrations/update-1-1-5/sync-package-json-files.d.ts +3 -0
  43. package/dist/migrations/update-1-1-5/sync-package-json-files.d.ts.map +1 -0
  44. package/dist/migrations/update-1-1-5/sync-package-json-files.js +68 -0
  45. package/dist/migrations/update-1-1-5/templates/cicd.template +55 -0
  46. package/dist/migrations/update-1-1-5/update-github-workflow.d.ts +3 -0
  47. package/dist/migrations/update-1-1-5/update-github-workflow.d.ts.map +1 -0
  48. package/dist/migrations/update-1-1-5/update-github-workflow.js +35 -0
  49. package/dist/migrations/update-1-1-5/update-npmrc.d.ts +3 -0
  50. package/dist/migrations/update-1-1-5/update-npmrc.d.ts.map +1 -0
  51. package/dist/migrations/update-1-1-5/update-npmrc.js +48 -0
  52. package/dist/migrations/update-1-1-5/update-nvmrc.d.ts +3 -0
  53. package/dist/migrations/update-1-1-5/update-nvmrc.d.ts.map +1 -0
  54. package/dist/migrations/update-1-1-5/update-nvmrc.js +26 -0
  55. package/generators.json +11 -0
  56. package/migrations.json +164 -0
  57. package/package.json +7 -3
package/README.md CHANGED
@@ -2,13 +2,16 @@
2
2
 
3
3
  > This is a temporary documentation to the @unisphere/nx plugin until the official documentation is available.
4
4
 
5
+ > ⚠️ **This generator is currently available only to Kaltura developers.**
6
+ > It depends on internal resources such as CI/CD templates, design systems, and private NPM packages. External support for Kaltura customers is on our roadmap.
7
+
5
8
  Unisphere is Kaltura’s frontend framework for building dynamic, composable experiences. A **Unisphere project** is a structured repository that allows developers to create and organize **applications**, **runtimes**, and **packages** under a single cohesive experience. This setup encourages healthy module separation, runtime decoupling, reusability, and clean ownership boundaries — all key ingredients for scaling product development in a multi-team environment.
6
9
 
7
10
  Whether you're building a full application like _Content Lab_ or a lightweight widget like _Chat_, Unisphere gives you the tooling and conventions to do it the right way from the start.
8
11
 
9
- ---
12
+ ## Step 1 - Create a New Unisphere Project
10
13
 
11
- ## Create a New Unisphere Project
14
+ Before creating a new Unisphere project, make sure you have a valid `GITHUB_TOKEN` exported in your environment. This is required for GitHub operations during setup.
12
15
 
13
16
  To scaffold a new project you can use [create-unisphere-project](https://www.npmjs.com/package/create-unisphere-project) npm package with all necessary tooling and structure, run:
14
17
 
@@ -16,13 +19,6 @@ To scaffold a new project you can use [create-unisphere-project](https://www.npm
16
19
  npm create unisphere-project@latest
17
20
  ```
18
21
 
19
- > ⚠️ **This generator is currently available only to Kaltura developers.**
20
- > It depends on internal resources such as CI/CD templates, design systems, and private NPM packages. External support for Kaltura customers is on our roadmap.
21
-
22
- **Before running the command**, make sure you have a valid `GITHUB_TOKEN` exported in your environment. This is required for GitHub operations during setup.
23
-
24
- ---
25
-
26
22
  ### Set Up the GitHub Repository
27
23
 
28
24
  Once the project is generated locally, you’ll need to create a new GitHub repository so that CI/CD can operate correctly and your team has proper access.
@@ -36,7 +32,7 @@ Please contact **Eran Sakal** or **Omri Ceisler** to provision the repository. T
36
32
  unisphere-{friendly-experience-name}
37
33
  ```
38
34
 
39
- > The friendly name is derived from your declared experience name (e.g., `unisphere.widget.reactions` → `reactions` → `unisphere-reactions` as the repository name).
35
+ The friendly name is derived from your declared experience name (e.g., `unisphere.widget.reactions` → `reactions` → `unisphere-reactions` as the repository name).
40
36
 
41
37
  2. **Team Access Configuration**
42
38
  The appropriate GitHub teams will be granted access to the repository to match the experience's ownership and collaboration needs.
@@ -48,7 +44,7 @@ Once created, you can push your local project into the new repository and begin
48
44
 
49
45
  ---
50
46
 
51
- ## Use the `@unisphere/nx` Plugin
47
+ ## Step 2 - Use the `@unisphere/nx` Plugin
52
48
 
53
49
  After your project is set up, you’ll use the `@unisphere/nx` plugin to generate and manage your project’s core elements. All generators are interactive and designed to enforce Unisphere best practices and conventions.
54
50
 
@@ -91,8 +87,6 @@ npx nx g @unisphere/nx:add-runtime
91
87
 
92
88
  - Assume it is developed using a playground expo application of another runtime in the project
93
89
 
94
- ---
95
-
96
90
  ### 🎨 `add-visual`
97
91
 
98
92
  Creates a **visual component** within a runtime — the building blocks of your UI.
@@ -108,8 +102,6 @@ npx nx g @unisphere/nx:add-visual
108
102
  - **Is this visual limited to a single occurrence?**
109
103
  Choose `Yes` for singleton visuals (e.g., when the visual represent a container that can only have one instance), otherwise `No`.
110
104
 
111
- ---
112
-
113
105
  ### 📱 `add-application`
114
106
 
115
107
  Creates an **application** that acts as a host for your runtime(s). These apps can be used for development, standalone deployments, or iframe integrations. The application can be used as a playground for developing and simulating a host environment without the need to deploy the experience to a customer, or it can be an additional entry point for the experience and use the Unisphere ci/cd to be publically available in multi region environments.
@@ -133,8 +125,6 @@ npx nx g @unisphere/nx:add-application
133
125
 
134
126
  - **HTML page title** (if not using Playground)
135
127
 
136
- ---
137
-
138
128
  ### 📦 `add-package`
139
129
 
140
130
  Creates a shared **package** for separating concerns within an experience. Most of the actual code in a Unisphere project lives in packages — not in runtimes — making it easier to reuse components, services, and logic across multiple entry points. These packages are usually not distributed externally but serve as internal modules consumed by runtimes.
@@ -161,8 +151,6 @@ npx nx g @unisphere/nx:add-package
161
151
  - **Internal** - Published to GitHub packages (`@kaltura/unisphere-<experience-name>-<package-name>`)
162
152
  - **Public** - Published to npm (`@unisphere/<experience-name>-<package-name>`)
163
153
 
164
- ---
165
-
166
154
  ## Best Practices
167
155
 
168
156
  🧠 Use descriptive names that reflect the purpose of the runtime or visual. For example, use `player-plugin` for a runtime that integrates into a video player, or `container` for visual that represent a container that can only have one instance, or `drawer` if it is a drawer runtime.
@@ -173,8 +161,6 @@ npx nx g @unisphere/nx:add-package
173
161
 
174
162
  🔍 Use the interactive CLI mode to generate all project elements. This ensures naming consistency, correct scaffolding, and alignment with Unisphere conventions.
175
163
 
176
- ---
177
-
178
164
  ## What’s Next?
179
165
 
180
166
  Stay tuned for full documentation on each concept and tool at
@@ -1,6 +1,10 @@
1
1
  {
2
2
  "extends": ["plugin:@nx/react", "../../../.eslintrc.json"],
3
- "ignorePatterns": ["!**/*"],
3
+ "ignorePatterns": [
4
+ "!**/*",
5
+ "**/vite.config.*.timestamp*",
6
+ "**/vitest.config.*.timestamp*"
7
+ ],
4
8
  "overrides": [
5
9
  {
6
10
  "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
@@ -1,6 +1,10 @@
1
1
  {
2
2
  "extends": ["plugin:@nx/react", "../../../.eslintrc.json"],
3
- "ignorePatterns": ["!**/*"],
3
+ "ignorePatterns": [
4
+ "!**/*",
5
+ "**/vite.config.*.timestamp*",
6
+ "**/vitest.config.*.timestamp*"
7
+ ],
4
8
  "overrides": [
5
9
  {
6
10
  "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
@@ -5,7 +5,7 @@ import { ConfigurationContext } from './configuration-provider';
5
5
  import { isConfigurationValid } from './definitions';
6
6
  import { Header } from './components/header';
7
7
  import { ConfigurationProvider } from './configuration-provider';
8
- import { UnisphereProvider } from '@unisphere/runtime-react';
8
+ import { UnisphereProvider, UnisphereRuntimeVisual } from '@unisphere/runtime-react';
9
9
  import { UnisphereWorkspaceConfig } from '@unisphere/runtime';
10
10
  import { UnisphereWorkspaceType } from '@unisphere/runtime';
11
11
  import { <%= runtimeName__pascalCase %>Runtime } from '<%= coreAlias %>';
@@ -92,11 +92,15 @@ export const SettingsForm: React.FC = () => {
92
92
  name={'settings'}
93
93
  fullWidth
94
94
  inputProps={{
95
- ...register('settings', { required: true }),
95
+ ...register('settings', {
96
+ required: `To pass empty settings, type "{}". Otherwise: (1) manually type valid JSON. (2) `,
97
+ }),
96
98
  }}
97
99
  label={'Unisphere Settings'}
98
- helperText={`Easily copy settings from Unisphere by entering a workable host in NVQ2 and then do: Unisphere cmd+k > Manage Workspace Runtimes > show ... (actions) of desired runtime > copy settings`}
99
- error={!!errors?.settings}
100
+ helperText={`${
101
+ errors?.settings?.message || ''
102
+ }Easily copy settings from Unisphere by entering a workable host in NVQ2 and then do: Unisphere cmd+k > Manage Workspace Runtimes > show ... (actions) of desired runtime > copy settings`}
103
+ error={!!errors?.settings?.message}
100
104
  />
101
105
  </FormCard>
102
106
  </Stack>
@@ -1 +1 @@
1
- {"version":3,"file":"add-package.d.ts","sourceRoot":"","sources":["../../../src/generators/add-package/add-package.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,IAAI,EAAiB,MAAM,YAAY,CAAC;AAE7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAuGrD,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,yBAAyB,uBAyGnC;AAED,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"add-package.d.ts","sourceRoot":"","sources":["../../../src/generators/add-package/add-package.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,IAAI,EAAiB,MAAM,YAAY,CAAC;AAE7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AA+GrD,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,yBAAyB,uBAyGnC;AAED,eAAe,mBAAmB,CAAC"}
@@ -11,7 +11,9 @@ function generateDemoComponent(tree, projectRoot, vars) {
11
11
  // component and logger names
12
12
  const loggerName = `${vars['packageName__lowerDashCase']}-demo`;
13
13
  const demoName = `${vars['packageName__pascalCase']}Demo`;
14
- const content = `import { useContext, useEffect } from 'react';
14
+ let content;
15
+ if (demoName.includes('react')) {
16
+ content = `import { useContext, useEffect } from 'react';
15
17
  import {
16
18
  ScopedUnisphereWorkspaceContext,
17
19
  useGetScopedWorkspaceLogger,
@@ -63,9 +65,9 @@ export const ${demoName} = () => {
63
65
 
64
66
  useEffect(() => {
65
67
  // example only - feel free to remove
66
- logger.log('${loggerName} mounted');
68
+ logger?.log('${loggerName} mounted');
67
69
  return () => {
68
- logger.log('${loggerName} unmounted');
70
+ logger?.log('${loggerName} unmounted');
69
71
  };
70
72
  }, []);
71
73
 
@@ -79,6 +81,10 @@ export const ${demoName} = () => {
79
81
  return <Hihi />;
80
82
  };
81
83
  `;
84
+ }
85
+ else {
86
+ content = `export const ${demoName} = () => {}`;
87
+ }
82
88
  tree.write(targetPath, content);
83
89
  }
84
90
  async function addPackageGenerator(tree, options) {
@@ -1,6 +1,10 @@
1
1
  {
2
2
  "extends": ["plugin:@nx/react", "../../../.eslintrc.json"],
3
- "ignorePatterns": ["!**/*"],
3
+ "ignorePatterns": [
4
+ "!**/*",
5
+ "**/vite.config.*.timestamp*",
6
+ "**/vitest.config.*.timestamp*"
7
+ ],
4
8
  "overrides": [
5
9
  {
6
10
  "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
@@ -1,6 +1,10 @@
1
1
  {
2
2
  "extends": ["plugin:@nx/react", "../../../.eslintrc.json"],
3
- "ignorePatterns": ["!**/*"],
3
+ "ignorePatterns": [
4
+ "!**/*",
5
+ "**/vite.config.*.timestamp*",
6
+ "**/vitest.config.*.timestamp*"
7
+ ],
4
8
  "overrides": [
5
9
  {
6
10
  "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export default function migrateGenerator(tree: Tree): Promise<void>;
3
+ //# sourceMappingURL=migrate-to-1-1-5.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-to-1-1-5.d.ts","sourceRoot":"","sources":["../../../src/generators/migrate-to-1-1-5/migrate-to-1-1-5.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAU,MAAM,YAAY,CAAC;AAiB1C,wBAA8B,gBAAgB,CAAC,IAAI,EAAE,IAAI,iBA4CxD"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = migrateGenerator;
4
+ const tslib_1 = require("tslib");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const update_packages_1 = tslib_1.__importDefault(require("./update-packages"));
7
+ const rename_widgetname_to_widgetname_1 = tslib_1.__importDefault(require("../../migrations/update-1-1-5/rename-widgetname-to-widgetname"));
8
+ const fix_playground_apps_1 = tslib_1.__importDefault(require("../../migrations/update-1-1-5/fix-playground-apps"));
9
+ const sync_package_json_files_1 = tslib_1.__importDefault(require("../../migrations/update-1-1-5/sync-package-json-files"));
10
+ const move_runtime_info_to_core_1 = tslib_1.__importDefault(require("../../migrations/update-1-1-5/move-runtime-info-to-core"));
11
+ // import updateLanguagesMigration from '../../migrations/update-1-1-5/_update-languages';
12
+ const update_npmrc_1 = tslib_1.__importDefault(require("../../migrations/update-1-1-5/update-npmrc"));
13
+ const check_nx_version_1 = tslib_1.__importDefault(require("../../migrations/update-1-1-5/check-nx-version"));
14
+ const update_nvmrc_1 = tslib_1.__importDefault(require("../../migrations/update-1-1-5/update-nvmrc"));
15
+ const fix_dependency_versions_1 = tslib_1.__importDefault(require("../../migrations/update-1-1-5/fix-dependency-versions"));
16
+ const update_github_workflow_1 = tslib_1.__importDefault(require("../../migrations/update-1-1-5/update-github-workflow"));
17
+ async function migrateGenerator(tree) {
18
+ try {
19
+ (0, check_nx_version_1.default)(tree);
20
+ await (0, update_packages_1.default)(tree);
21
+ await (0, update_nvmrc_1.default)(tree);
22
+ await (0, fix_dependency_versions_1.default)(tree);
23
+ await (0, update_github_workflow_1.default)(tree);
24
+ await (0, rename_widgetname_to_widgetname_1.default)(tree);
25
+ await (0, fix_playground_apps_1.default)(tree);
26
+ await (0, move_runtime_info_to_core_1.default)(tree);
27
+ // await updateLanguagesMigration(tree);
28
+ await (0, update_npmrc_1.default)(tree);
29
+ await (0, sync_package_json_files_1.default)(tree);
30
+ devkit_1.logger.info('');
31
+ devkit_1.logger.warn('═══════════════════════════════════════════════════════════════');
32
+ devkit_1.logger.warn('✅ Migrations completed!');
33
+ devkit_1.logger.warn('═══════════════════════════════════════════════════════════════');
34
+ devkit_1.logger.warn('');
35
+ devkit_1.logger.warn('📋 Next steps:');
36
+ devkit_1.logger.warn('1. Review the changes made to package.json files');
37
+ devkit_1.logger.warn('2. Remove node_modules: rm -rf node_modules');
38
+ devkit_1.logger.warn('3. Install dependencies: npm install');
39
+ devkit_1.logger.warn('4. Update old react code manually or run the codemod:');
40
+ devkit_1.logger.warn(' npx codemod@latest react/19/migration-recipe --target ./src');
41
+ devkit_1.logger.warn('5. Run npm run check to see if there are any errors');
42
+ devkit_1.logger.warn('');
43
+ devkit_1.logger.warn('═══════════════════════════════════════════════════════════════');
44
+ }
45
+ catch (error) {
46
+ devkit_1.logger.error(`❌ Migration failed: ${error?.message || 'Unknown error'}`);
47
+ throw error;
48
+ }
49
+ }
@@ -0,0 +1,9 @@
1
+ To run the migration locally
2
+
3
+ `
4
+ npx nx generate {path-to-repo}/unisphere-nx-workspace-plugin/packages/nx:migrate-to-1-1-5
5
+ `
6
+
7
+
8
+ npx nx generate /home/tokomeno/kaltura/unisphere/pl/unisphere-nx-workspace-plugin/packages/nx:migrate-to-1-1-5
9
+
@@ -0,0 +1 @@
1
+ export interface MigrateTo115GeneratorSchema {}
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "cli": "nx",
4
+ "$id": "migrate-to-1-1-5",
5
+ "title": "Migrate to @unisphere/nx v1.1.5",
6
+ "description": "Migrates your project to @unisphere/nx v1.1.5 with package updates, WidgetName renaming, and React 19 preparation",
7
+ "type": "object",
8
+ "properties": {},
9
+ "additionalProperties": false
10
+ }
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export default function updatePackages(tree: Tree): Promise<void>;
3
+ //# sourceMappingURL=update-packages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-packages.d.ts","sourceRoot":"","sources":["../../../src/generators/migrate-to-1-1-5/update-packages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAU,MAAM,YAAY,CAAC;AAqBvD,wBAA8B,cAAc,CAAC,IAAI,EAAE,IAAI,iBA2GtD"}
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = updatePackages;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const child_process_1 = require("child_process");
6
+ /**
7
+ * Fetches the latest version of a package from npm registry
8
+ */
9
+ async function getLatestVersion(packageName) {
10
+ try {
11
+ const result = (0, child_process_1.execSync)(`npm view ${packageName} version`, {
12
+ encoding: 'utf8',
13
+ stdio: ['pipe', 'pipe', 'pipe'],
14
+ });
15
+ return result.trim();
16
+ }
17
+ catch (error) {
18
+ devkit_1.logger.warn(`Failed to fetch latest version for ${packageName}, keeping 'latest'`);
19
+ return 'latest';
20
+ }
21
+ }
22
+ async function updatePackages(tree) {
23
+ // Read the current package.json
24
+ const packageJsonContent = tree.read('package.json', 'utf-8');
25
+ if (!packageJsonContent) {
26
+ devkit_1.logger.error('No package.json found');
27
+ return;
28
+ }
29
+ const packageJson = JSON.parse(packageJsonContent);
30
+ // Get the 1.1.5 package updates
31
+ devkit_1.logger.info('Fetching latest versions from npm registry...');
32
+ // Resolve all 'latest' versions to actual version numbers
33
+ const resolvedPackageUpdates = { ...packageUpdates };
34
+ for (const [packageName, config] of Object.entries(packageUpdates.packages)) {
35
+ if (config.version === 'latest') {
36
+ const latestVersion = await getLatestVersion(packageName);
37
+ resolvedPackageUpdates.packages[packageName] = {
38
+ ...config,
39
+ version: `^${latestVersion}`, // Add ^ prefix to latest versions
40
+ };
41
+ }
42
+ }
43
+ devkit_1.logger.info('Updating packages based on migrations.json...');
44
+ let hasChanges = false;
45
+ // Process each package update
46
+ for (const [packageName, updateConfig] of Object.entries(resolvedPackageUpdates.packages)) {
47
+ const { version, alwaysAddToPackageJson, addToPackageJson } = updateConfig;
48
+ // Check if package exists in any dependency type
49
+ const existsInDependencies = packageJson.dependencies && packageJson.dependencies[packageName];
50
+ const existsInDevDependencies = packageJson.devDependencies && packageJson.devDependencies[packageName];
51
+ const existsInOptionalDependencies = packageJson.optionalDependencies &&
52
+ packageJson.optionalDependencies[packageName];
53
+ const existsInPeerDependencies = packageJson.peerDependencies && packageJson.peerDependencies[packageName];
54
+ const packageExists = existsInDependencies ||
55
+ existsInDevDependencies ||
56
+ existsInOptionalDependencies ||
57
+ existsInPeerDependencies;
58
+ // If alwaysAddToPackageJson is false, only update if package already exists
59
+ if (alwaysAddToPackageJson === false && !packageExists) {
60
+ devkit_1.logger.info(`Skipping ${packageName} (not installed, alwaysAddToPackageJson: false)`);
61
+ continue;
62
+ }
63
+ // Update existing packages in their current location
64
+ if (existsInDependencies) {
65
+ devkit_1.logger.info(`Updating ${packageName} to ${version} in dependencies`);
66
+ packageJson.dependencies[packageName] = version;
67
+ hasChanges = true;
68
+ }
69
+ else if (existsInDevDependencies) {
70
+ devkit_1.logger.info(`Updating ${packageName} to ${version} in devDependencies`);
71
+ packageJson.devDependencies[packageName] = version;
72
+ hasChanges = true;
73
+ }
74
+ else if (existsInOptionalDependencies) {
75
+ devkit_1.logger.info(`Updating ${packageName} to ${version} in optionalDependencies`);
76
+ packageJson.optionalDependencies[packageName] = version;
77
+ hasChanges = true;
78
+ }
79
+ else if (existsInPeerDependencies) {
80
+ devkit_1.logger.info(`Updating ${packageName} to ${version} in peerDependencies`);
81
+ packageJson.peerDependencies[packageName] = version;
82
+ hasChanges = true;
83
+ }
84
+ else if (alwaysAddToPackageJson !== false && addToPackageJson) {
85
+ // Add new package to specified location if alwaysAddToPackageJson is not false
86
+ const targetDeps = addToPackageJson;
87
+ if (!packageJson[targetDeps]) {
88
+ packageJson[targetDeps] = {};
89
+ }
90
+ devkit_1.logger.info(`Adding ${packageName} to ${version} in ${targetDeps}`);
91
+ packageJson[targetDeps][packageName] = version;
92
+ hasChanges = true;
93
+ }
94
+ }
95
+ if (hasChanges) {
96
+ // Write the updated package.json
97
+ tree.write('package.json', JSON.stringify(packageJson, null, 2) + '\n');
98
+ devkit_1.logger.info('✅ Package.json updated successfully!');
99
+ devkit_1.logger.info('');
100
+ devkit_1.logger.info('📦 Updated packages based on migrations.json packageJsonUpdates->1.1.5');
101
+ devkit_1.logger.info('');
102
+ devkit_1.logger.info('🔄 Run "npm install" to install the updated packages');
103
+ }
104
+ else {
105
+ devkit_1.logger.info('No packages needed to be updated');
106
+ }
107
+ await (0, devkit_1.formatFiles)(tree);
108
+ }
109
+ var packageUpdates = {
110
+ packages: {
111
+ '@kaltura/ds-react-bits': {
112
+ version: 'latest',
113
+ alwaysAddToPackageJson: false,
114
+ },
115
+ '@kaltura/ds-react-icons': {
116
+ version: 'latest',
117
+ alwaysAddToPackageJson: false,
118
+ },
119
+ '@kaltura/ds-react-theme': {
120
+ version: 'latest',
121
+ alwaysAddToPackageJson: false,
122
+ },
123
+ '@kaltura/ds-react-utils': {
124
+ version: 'latest',
125
+ alwaysAddToPackageJson: false,
126
+ },
127
+ '@unisphere/cli': {
128
+ version: 'latest',
129
+ alwaysAddToPackageJson: false,
130
+ },
131
+ '@unisphere/core': {
132
+ version: 'latest',
133
+ alwaysAddToPackageJson: false,
134
+ },
135
+ '@unisphere/notifications-core': {
136
+ version: 'latest',
137
+ alwaysAddToPackageJson: false,
138
+ },
139
+ '@unisphere/notifications-runtime-react': {
140
+ version: 'latest',
141
+ alwaysAddToPackageJson: false,
142
+ },
143
+ '@unisphere/nx': {
144
+ version: 'latest',
145
+ alwaysAddToPackageJson: false,
146
+ },
147
+ '@unisphere/runtime': {
148
+ version: 'latest',
149
+ alwaysAddToPackageJson: false,
150
+ },
151
+ '@unisphere/runtime-js': {
152
+ version: 'latest',
153
+ alwaysAddToPackageJson: false,
154
+ },
155
+ '@unisphere/runtime-react': {
156
+ version: 'latest',
157
+ alwaysAddToPackageJson: false,
158
+ },
159
+ '@unisphere/ui-i18n-react': {
160
+ version: 'latest',
161
+ alwaysAddToPackageJson: false,
162
+ },
163
+ react: {
164
+ version: '^19.0.0',
165
+ alwaysAddToPackageJson: false,
166
+ },
167
+ 'react-dom': {
168
+ version: '^19.0.0',
169
+ alwaysAddToPackageJson: false,
170
+ },
171
+ '@types/node': {
172
+ version: '^20.19.1',
173
+ alwaysAddToPackageJson: false,
174
+ },
175
+ '@types/react': {
176
+ version: '^19.0.0',
177
+ alwaysAddToPackageJson: false,
178
+ },
179
+ '@types/react-dom': {
180
+ version: '^19.0.0',
181
+ alwaysAddToPackageJson: false,
182
+ },
183
+ '@swc/helpers': {
184
+ version: '~0.5.17',
185
+ alwaysAddToPackageJson: false,
186
+ },
187
+ 'react-codemod': {
188
+ version: '^5.4.4',
189
+ alwaysAddToPackageJson: false,
190
+ },
191
+ '@nx/nx-linux-x64-gnu': {
192
+ version: '22.0.1',
193
+ addToPackageJson: 'optionalDependencies',
194
+ alwaysAddToPackageJson: false,
195
+ },
196
+ '@emotion/react': {
197
+ version: '11.14.0',
198
+ alwaysAddToPackageJson: false,
199
+ },
200
+ '@emotion/styled': {
201
+ version: '11.14.1',
202
+ alwaysAddToPackageJson: false,
203
+ },
204
+ },
205
+ };
@@ -0,0 +1,16 @@
1
+ import { Tree } from '@nx/devkit';
2
+ /**
3
+ * Test Migration Locally Generator
4
+ *
5
+ * This generator mimics the full `nx migrate` flow for local testing.
6
+ * It reads migrations.json and executes everything in the correct order,
7
+ * including showing post-upgrade messages.
8
+ *
9
+ * Usage:
10
+ * npx nx g @unisphere/nx:test-migration-locally
11
+ *
12
+ * Or with local path:
13
+ * npx nx g ./packages/nx:test-migration-locally
14
+ */
15
+ export default function testMigrationLocally(tree: Tree): Promise<void>;
16
+ //# sourceMappingURL=generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generators/test-migration-locally/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAuB,MAAM,YAAY,CAAC;AAIvD;;;;;;;;;;;;GAYG;AACH,wBAA8B,oBAAoB,CAAC,IAAI,EAAE,IAAI,iBA+G5D"}
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = testMigrationLocally;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const fs_1 = require("fs");
6
+ const path_1 = require("path");
7
+ /**
8
+ * Test Migration Locally Generator
9
+ *
10
+ * This generator mimics the full `nx migrate` flow for local testing.
11
+ * It reads migrations.json and executes everything in the correct order,
12
+ * including showing post-upgrade messages.
13
+ *
14
+ * Usage:
15
+ * npx nx g @unisphere/nx:test-migration-locally
16
+ *
17
+ * Or with local path:
18
+ * npx nx g ./packages/nx:test-migration-locally
19
+ */
20
+ async function testMigrationLocally(tree) {
21
+ devkit_1.logger.info('');
22
+ devkit_1.logger.info('🧪 TESTING MIGRATIONS LOCALLY');
23
+ devkit_1.logger.info('='.repeat(70));
24
+ devkit_1.logger.info('This simulates the full `nx migrate` flow for testing purposes.');
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.1.5'];
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
+ .replace(/\.js$/, '');
55
+ // Import and run the migration
56
+ const migrationModule = await import(migrationPath);
57
+ const migrationFn = migrationModule.default;
58
+ if (typeof migrationFn !== 'function') {
59
+ throw new Error(`Migration ${migrationName} does not export a default function`);
60
+ }
61
+ // Execute the migration
62
+ await migrationFn(tree);
63
+ // Show post-upgrade message if it exists
64
+ if (migrationConfig.cli?.postUpgradeMessage) {
65
+ devkit_1.logger.info('');
66
+ devkit_1.logger.info(migrationConfig.cli.postUpgradeMessage);
67
+ }
68
+ devkit_1.logger.info('');
69
+ }
70
+ catch (error) {
71
+ devkit_1.logger.error(`❌ Migration "${migrationName}" failed!`);
72
+ devkit_1.logger.error(` Error: ${error.message}`);
73
+ devkit_1.logger.error('');
74
+ devkit_1.logger.error('Stack trace:');
75
+ devkit_1.logger.error(error.stack);
76
+ throw error;
77
+ }
78
+ }
79
+ // Step 2: Format files
80
+ await (0, devkit_1.formatFiles)(tree);
81
+ // Step 3: Show final summary message
82
+ devkit_1.logger.info('');
83
+ devkit_1.logger.info('='.repeat(70));
84
+ devkit_1.logger.info('✅ ALL MIGRATIONS COMPLETED');
85
+ devkit_1.logger.info('='.repeat(70));
86
+ if (packageUpdates?.postUpdateMessage) {
87
+ devkit_1.logger.info(packageUpdates.postUpdateMessage);
88
+ }
89
+ devkit_1.logger.info('');
90
+ devkit_1.logger.info('📊 Summary:');
91
+ devkit_1.logger.info(` Total migrations run: ${totalMigrations}`);
92
+ devkit_1.logger.info(` All migrations: ✅ Success`);
93
+ devkit_1.logger.info('');
94
+ devkit_1.logger.info('🔍 Review the changes:');
95
+ devkit_1.logger.info(' git status');
96
+ devkit_1.logger.info(' git diff');
97
+ devkit_1.logger.info('');
98
+ devkit_1.logger.info('♻️ To revert all changes:');
99
+ devkit_1.logger.info(' git checkout .');
100
+ devkit_1.logger.info(' git clean -fd');
101
+ devkit_1.logger.info('');
102
+ }
103
+ catch (error) {
104
+ devkit_1.logger.error('');
105
+ devkit_1.logger.error('='.repeat(70));
106
+ devkit_1.logger.error('❌ MIGRATION FLOW FAILED');
107
+ devkit_1.logger.error('='.repeat(70));
108
+ devkit_1.logger.error(`Error: ${error?.message || 'Unknown error'}`);
109
+ devkit_1.logger.error('');
110
+ throw error;
111
+ }
112
+ }