@unisphere/nx 1.22.8 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -164
- package/dist/generators/add-application/add-application.js +1 -1
- package/dist/generators/add-application/templates/default/package.json.template +2 -5
- package/dist/generators/add-application/templates/local-dev-playground/package.json +1 -0
- package/dist/generators/add-package/add-package.d.ts.map +1 -1
- package/dist/generators/add-package/add-package.js +0 -83
- package/dist/generators/add-package/templates/new-package/package.json.template +1 -10
- package/dist/generators/add-package/templates/new-package/src/index.ts.template +0 -1
- package/dist/generators/add-package/templates/new-package/src/lib/.keep +0 -0
- package/dist/generators/add-runtime/add-runtime.d.ts.map +1 -1
- package/dist/generators/add-runtime/add-runtime.js +6 -16
- package/dist/generators/add-runtime/schema.d.ts +1 -1
- package/dist/generators/add-runtime/schema.json +9 -9
- package/dist/migrations/1-22-0/check-nx-version.js +1 -1
- package/dist/migrations/1-22-2/templates/cicd.template +1 -1
- package/dist/migrations/1-22-4/summary.js +1 -2
- package/dist/migrations/2-0-0/fix-playground-apps.d.ts +3 -0
- package/dist/migrations/2-0-0/fix-playground-apps.d.ts.map +1 -0
- package/dist/migrations/2-0-0/fix-playground-apps.js +86 -0
- package/dist/migrations/2-0-0/move-runtime-info-to-core.d.ts +3 -0
- package/dist/migrations/2-0-0/move-runtime-info-to-core.d.ts.map +1 -0
- package/dist/migrations/2-0-0/move-runtime-info-to-core.js +217 -0
- package/dist/migrations/2-0-0/patches/@nx+rollup+22.1.3.patch +27 -0
- package/dist/migrations/2-0-0/rename-widgetname-to-widgetname.d.ts +3 -0
- package/dist/migrations/2-0-0/rename-widgetname-to-widgetname.d.ts.map +1 -0
- package/dist/migrations/2-0-0/rename-widgetname-to-widgetname.js +38 -0
- package/dist/migrations/{1-22-7/update-git-ignore.d.ts → 2-0-0/replace-patches.d.ts} +1 -1
- package/dist/migrations/2-0-0/replace-patches.d.ts.map +1 -0
- package/dist/migrations/2-0-0/replace-patches.js +56 -0
- package/dist/migrations/2-0-0/summary.d.ts +2 -0
- package/dist/migrations/2-0-0/summary.d.ts.map +1 -0
- package/dist/migrations/2-0-0/summary.js +12 -0
- package/dist/migrations/2-0-0/sync-package-json-files.d.ts +3 -0
- package/dist/migrations/2-0-0/sync-package-json-files.d.ts.map +1 -0
- package/dist/migrations/2-0-0/sync-package-json-files.js +68 -0
- package/dist/migrations/2-0-0/update-npmrc.d.ts +3 -0
- package/dist/migrations/2-0-0/update-npmrc.d.ts.map +1 -0
- package/dist/migrations/2-0-0/update-npmrc.js +48 -0
- package/dist/migrations/2-0-0/update-nvmrc.d.ts +3 -0
- package/dist/migrations/2-0-0/update-nvmrc.d.ts.map +1 -0
- package/dist/migrations/2-0-0/update-nvmrc.js +26 -0
- package/dist/migrations/2-1-0/remove-react-overrides.d.ts +3 -0
- package/dist/migrations/2-1-0/remove-react-overrides.d.ts.map +1 -0
- package/dist/migrations/2-1-0/remove-react-overrides.js +59 -0
- package/dist/migrations/2-1-0/remove-rollup-plugin-node-builtins.d.ts +3 -0
- package/dist/migrations/2-1-0/remove-rollup-plugin-node-builtins.d.ts.map +1 -0
- package/dist/migrations/2-1-0/remove-rollup-plugin-node-builtins.js +54 -0
- package/dist/migrations/2-1-0/remove-storybook.d.ts.map +1 -0
- package/dist/migrations/{1-22-7 → 2-1-0}/remove-storybook.js +1 -27
- package/dist/migrations/2-1-0/replace-readme-md.d.ts +3 -0
- package/dist/migrations/2-1-0/replace-readme-md.d.ts.map +1 -0
- package/dist/migrations/2-1-0/replace-readme-md.js +50 -0
- package/dist/migrations/2-1-0/templates/readme.md.template +134 -0
- package/generators.json +20 -0
- package/migrations.json +163 -8
- package/package.json +1 -1
- package/dist/migrations/1-22-7/remove-storybook.d.ts.map +0 -1
- package/dist/migrations/1-22-7/update-git-ignore.d.ts.map +0 -1
- package/dist/migrations/1-22-7/update-git-ignore.js +0 -55
- /package/dist/migrations/{1-22-7 → 2-1-0}/remove-storybook.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,167 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Unisphere Workspace NX Plugin
|
|
2
2
|
|
|
3
|
-
> This is a temporary documentation to the @unisphere/nx plugin until the official documentation is available.
|
|
4
3
|
|
|
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
4
|
|
|
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.
|
|
9
|
-
|
|
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.
|
|
11
|
-
|
|
12
|
-
## Step 1 - Create a New Unisphere Project
|
|
13
|
-
|
|
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.
|
|
15
|
-
|
|
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:
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
npm create unisphere-project@latest
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
### Set Up the GitHub Repository
|
|
23
|
-
|
|
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.
|
|
25
|
-
|
|
26
|
-
Please contact **Eran Sakal** or **Omri Ceisler** to provision the repository. The following steps will be completed as part of this process:
|
|
27
|
-
|
|
28
|
-
1. **Repository Creation**
|
|
29
|
-
The new repo will be created with **internal scope** and named according to this convention:
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
unisphere-{friendly-experience-name}
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
The friendly name is derived from your declared experience name (e.g., `unisphere.widget.reactions` → `reactions` → `unisphere-reactions` as the repository name).
|
|
36
|
-
|
|
37
|
-
2. **Team Access Configuration**
|
|
38
|
-
The appropriate GitHub teams will be granted access to the repository to match the experience's ownership and collaboration needs.
|
|
39
|
-
|
|
40
|
-
3. **CI/CD Enablement**
|
|
41
|
-
These steps are required to ensure that CI/CD workflows are automatically triggered for builds, deployments, versioning, and testing.
|
|
42
|
-
|
|
43
|
-
Once created, you can push your local project into the new repository and begin active development.
|
|
44
|
-
|
|
45
|
-
---
|
|
46
|
-
|
|
47
|
-
## Step 2 - Use the `@unisphere/nx` Plugin
|
|
48
|
-
|
|
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.
|
|
50
|
-
|
|
51
|
-
All generators support interactive usage through `nx g` and prompt you for the correct configuration.
|
|
52
|
-
|
|
53
|
-
### 🧹 `add-runtime`
|
|
54
|
-
|
|
55
|
-
Creates a new **runtime**, one of the possible entry points into an experience. Runtimes define **where** and **how** a specific part of the experience is used.
|
|
56
|
-
|
|
57
|
-
For example, in the **Genie experience**, there's a runtime called **page** used when the host injects the experience into the main body of a site, and another called **player-plugin** for injecting it into a player drawer. We have additional runtimes, one for each tool that is used by the experience, e.g **flashcards-tool**, **source-tool**, **follow-up-tool** etc.
|
|
58
|
-
|
|
59
|
-
Naming your runtime based on its integration point helps communicate its purpose and role clearly.
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
npx nx g @unisphere/nx:add-runtime
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
#### Prompts
|
|
66
|
-
|
|
67
|
-
- **Runtime name** – e.g., `page`, `player-plugin`, `flashcards-tool`, `source-tool`, `follow-up-tool`, `content-lab-drawer`.
|
|
68
|
-
|
|
69
|
-
- **How will this runtime be used?**
|
|
70
|
-
|
|
71
|
-
- **Loaded by External Host**u
|
|
72
|
-
|
|
73
|
-
- Deployed independently and loaded at runtime
|
|
74
|
-
|
|
75
|
-
- **Embedded in Widget Playground**
|
|
76
|
-
- Composed by other runtimes, no standalone deployment
|
|
77
|
-
|
|
78
|
-
- **How will this runtime be used?**
|
|
79
|
-
|
|
80
|
-
- **Independent experience used as an entry point (loaded by host or another experience)**
|
|
81
|
-
|
|
82
|
-
- Includes an Dev playground application for developing and simulating a host environment
|
|
83
|
-
|
|
84
|
-
- **Composed into another runtime of this experience (not used as an entry point)**
|
|
85
|
-
|
|
86
|
-
- Composed by another runtime within the same experience
|
|
87
|
-
|
|
88
|
-
- Assume it is developed using a playground dev application of another runtime in the project
|
|
89
|
-
|
|
90
|
-
### 🎨 `add-visual`
|
|
91
|
-
|
|
92
|
-
Creates a **visual component** within a runtime — the building blocks of your UI.
|
|
93
|
-
|
|
94
|
-
```bash
|
|
95
|
-
npx nx g @unisphere/nx:add-visual
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
#### Prompts
|
|
99
|
-
|
|
100
|
-
- **Runtime name** – Where this visual belongs
|
|
101
|
-
- **Visual name** – e.g., `card`, `toolbar`, `timeline-visual`
|
|
102
|
-
- **Is this visual limited to a single occurrence?**
|
|
103
|
-
Choose `Yes` for singleton visuals (e.g., when the visual represent a container that can only have one instance), otherwise `No`.
|
|
104
|
-
|
|
105
|
-
### 📱 `add-application`
|
|
106
|
-
|
|
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.
|
|
108
|
-
|
|
109
|
-
```bash
|
|
110
|
-
npx nx g @unisphere/nx:add-application
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
#### Prompts
|
|
114
|
-
|
|
115
|
-
- **Application name**
|
|
116
|
-
|
|
117
|
-
- **Serving type**
|
|
118
|
-
|
|
119
|
-
- **Local Dev Playground** – Local development playground (for development and testing)
|
|
120
|
-
- **Self-Hosted** – Standalone deployment with routing/auth (used for publically available applications)
|
|
121
|
-
- **Iframe + Query Params** – Embedded apps with config in URL (used for embedding into other applications like Kaltura Admin or KMC)
|
|
122
|
-
- **Iframe + Post Messages** – Embedded apps using `postMessage` API (used for embedding into other applications like Kaltura Admin or KMC) - this will replace eventually the query param method to be more secure and reliable but is not yet available.
|
|
123
|
-
|
|
124
|
-
- **Runtime to load in playground** (if Playground selected)
|
|
125
|
-
|
|
126
|
-
- **HTML page title** (if not using Playground)
|
|
127
|
-
|
|
128
|
-
### 📦 `add-package`
|
|
129
|
-
|
|
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.
|
|
131
|
-
|
|
132
|
-
By using packages this way, you can introduce multiple runtimes (e.g., page, player-plugin, admin-panel) that share the same functionality while remaining decoupled.
|
|
133
|
-
|
|
134
|
-
Some packages, however, are designed for external consumption. For example:
|
|
135
|
-
|
|
136
|
-
- Each experience has a `Core` package expose the types needed for runtime integration.
|
|
137
|
-
- Differetn `kit` packages act as extendable, design-system-driven building blocks that allow other teams to plug into your experience in a consistent and styled way.
|
|
138
|
-
|
|
139
|
-
Packages can be published to GitHub or npm, but in most cases, they serve as a clean internal abstraction layer inside the experience repository without being deployed.
|
|
140
|
-
|
|
141
|
-
```bash
|
|
142
|
-
npx nx g @unisphere/nx:add-package
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
#### Prompts
|
|
146
|
-
|
|
147
|
-
- **Package name**
|
|
148
|
-
- **Package scope**
|
|
149
|
-
|
|
150
|
-
- **None (no scope)** - Used only internally by the experience runtimes.
|
|
151
|
-
- **Internal** - Published to GitHub packages (`@kaltura/unisphere-<experience-name>-<package-name>`)
|
|
152
|
-
- **Public** - Published to npm (`@unisphere/<experience-name>-<package-name>`)
|
|
153
|
-
|
|
154
|
-
## Best Practices
|
|
155
|
-
|
|
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.
|
|
157
|
-
|
|
158
|
-
🎯 Select the correct runtime type depending on the deployment context. Choose "Independent experience" if the runtime will be loaded by a host or standalone app, and "Composed into another runtime" if it will only exist as part of a larger experience.
|
|
159
|
-
|
|
160
|
-
♻️ Share logic and components using packages. Most Unisphere code lives in packages rather than runtimes. This promotes reusability and modularity — for instance, content-lab-drawer and content-lab-modal runtimes may reuse the same internal package. Use the non scoped package if you are not sure what to choose.
|
|
161
|
-
|
|
162
|
-
🔍 Use the interactive CLI mode to generate all project elements. This ensures naming consistency, correct scaffolding, and alignment with Unisphere conventions.
|
|
163
|
-
|
|
164
|
-
## What’s Next?
|
|
165
|
-
|
|
166
|
-
Stay tuned for full documentation on each concept and tool at
|
|
167
|
-
**[unisphere.kaltura.com](https://unisphere.kaltura.com)** _(coming soon)_
|
|
@@ -113,7 +113,7 @@ async function addApplicationGenerator(tree, options) {
|
|
|
113
113
|
(0, devkit_1.generateFiles)(tree, path.join(__dirname, templatePath), projectRoot, templateVariables);
|
|
114
114
|
// Install selected dependencies
|
|
115
115
|
(0, dependency_config_1.installSelectedDependencies)(tree, selectedDependencies);
|
|
116
|
-
const distributionChannel = options.servingType
|
|
116
|
+
const distributionChannel = options.servingType === 'local-dev-playground' ? 'none' : 'unisphere';
|
|
117
117
|
// Update .unisphere configuration
|
|
118
118
|
(0, utils_1.updateUnisphereConfig)(tree, 'applications', userInputApplicationName, {
|
|
119
119
|
sourceRoot: `unisphere/applications/${userInputApplicationName}`,
|
|
@@ -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,EAA2B,MAAM,YAAY,CAAC;AAEvF,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"add-package.d.ts","sourceRoot":"","sources":["../../../src/generators/add-package/add-package.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,IAAI,EAA2B,MAAM,YAAY,CAAC;AAEvF,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AA6DrD,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,yBAAyB,uBA8HnC;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -36,88 +36,6 @@ function resolveUnisphereRuntimeVersion(tree) {
|
|
|
36
36
|
return defaultVersion;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
function generateDemoComponent(tree, projectRoot, vars) {
|
|
40
|
-
// path: packages/<pkg>/src/lib/panel-demo.tsx
|
|
41
|
-
const targetPath = `${projectRoot}/src/lib/${vars['packageName__lowerDashCase']}-demo.tsx`;
|
|
42
|
-
// component and logger names
|
|
43
|
-
const loggerName = `${vars['packageName__lowerDashCase']}-demo`;
|
|
44
|
-
const demoName = `${vars['packageName__pascalCase']}Demo`;
|
|
45
|
-
let content;
|
|
46
|
-
if (demoName.includes('react')) {
|
|
47
|
-
content = `import { useContext, useEffect } from 'react';
|
|
48
|
-
import {
|
|
49
|
-
ScopedUnisphereWorkspaceContext,
|
|
50
|
-
useGetScopedWorkspaceLogger,
|
|
51
|
-
} from '@unisphere/runtime-react';
|
|
52
|
-
|
|
53
|
-
const Hihi = () => {
|
|
54
|
-
return (
|
|
55
|
-
<div
|
|
56
|
-
style={{
|
|
57
|
-
border: '2px dashed #888',
|
|
58
|
-
borderRadius: '8px',
|
|
59
|
-
padding: '2rem',
|
|
60
|
-
margin: '2rem auto',
|
|
61
|
-
maxWidth: '500px',
|
|
62
|
-
textAlign: 'center',
|
|
63
|
-
fontFamily: 'sans-serif',
|
|
64
|
-
color: '#444',
|
|
65
|
-
backgroundColor: '#fcfcfc',
|
|
66
|
-
}}
|
|
67
|
-
>
|
|
68
|
-
<h2
|
|
69
|
-
style={{
|
|
70
|
-
marginBottom: '1rem',
|
|
71
|
-
fontSize: '1.25rem',
|
|
72
|
-
fontWeight: 500,
|
|
73
|
-
}}
|
|
74
|
-
>
|
|
75
|
-
Hihi :)
|
|
76
|
-
</h2>
|
|
77
|
-
<p
|
|
78
|
-
style={{
|
|
79
|
-
lineHeight: 1.5,
|
|
80
|
-
marginBottom: '1.5rem',
|
|
81
|
-
fontSize: '1rem',
|
|
82
|
-
}}
|
|
83
|
-
>
|
|
84
|
-
This '${demoName}' component shows you how to connect with the Unisphere workspace and set up a scoped logger.
|
|
85
|
-
</p>
|
|
86
|
-
</div>
|
|
87
|
-
);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
export const ${demoName} = () => {
|
|
91
|
-
const { unisphereWorkspace } = useContext(ScopedUnisphereWorkspaceContext);
|
|
92
|
-
const logger = useGetScopedWorkspaceLogger({
|
|
93
|
-
type: 'react',
|
|
94
|
-
name: '${loggerName}',
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
useEffect(() => {
|
|
98
|
-
// example only - feel free to remove
|
|
99
|
-
logger?.log('${loggerName} mounted');
|
|
100
|
-
return () => {
|
|
101
|
-
logger?.log('${loggerName} unmounted');
|
|
102
|
-
};
|
|
103
|
-
}, []);
|
|
104
|
-
|
|
105
|
-
useEffect(() => {
|
|
106
|
-
if (!unisphereWorkspace) return;
|
|
107
|
-
|
|
108
|
-
// you can access the unisphere workspace that renders the runtime this component is mounted in
|
|
109
|
-
}, [unisphereWorkspace]);
|
|
110
|
-
|
|
111
|
-
// render your visual
|
|
112
|
-
return <Hihi />;
|
|
113
|
-
};
|
|
114
|
-
`;
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
content = `export const ${demoName} = {}`;
|
|
118
|
-
}
|
|
119
|
-
tree.write(targetPath, content);
|
|
120
|
-
}
|
|
121
39
|
async function addPackageGenerator(tree, options) {
|
|
122
40
|
// Validate and read .unisphere configuration
|
|
123
41
|
const unisphereConfig = (0, utils_1.validateUnisphereConfig)(tree);
|
|
@@ -194,7 +112,6 @@ async function addPackageGenerator(tree, options) {
|
|
|
194
112
|
});
|
|
195
113
|
// Update tsconfig.base.json with path mapping
|
|
196
114
|
(0, utils_1.updateTsConfigPaths)(tree, packageJsonName, `unisphere/packages/${userInputPackageName}/src/index.ts`);
|
|
197
|
-
generateDemoComponent(tree, projectRoot, templateVariables);
|
|
198
115
|
// Install selected dependencies
|
|
199
116
|
(0, dependency_config_1.installSelectedDependencies)(tree, selectedDependencies);
|
|
200
117
|
await (0, devkit_1.formatFiles)(tree);
|
|
@@ -9,14 +9,5 @@
|
|
|
9
9
|
"url": "<%= githubUrl %>"
|
|
10
10
|
},
|
|
11
11
|
"types": "./index.esm.d.ts",
|
|
12
|
-
"dependencies": {
|
|
13
|
-
"@unisphere/runtime": "<%= unisphereRuntimeVersion %>"
|
|
14
|
-
},
|
|
15
|
-
"publishConfig": {
|
|
16
|
-
<% if (distributionChannel === 'github') { %>
|
|
17
|
-
"registry": "https://npm.pkg.github.com"
|
|
18
|
-
<% } else if (distributionChannel === 'npm') { %>
|
|
19
|
-
"registry": "https://registry.npmjs.org"
|
|
20
|
-
<% } %>
|
|
21
|
-
}
|
|
12
|
+
"dependencies": {}
|
|
22
13
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './lib/<%= packageName__lowerDashCase %>-demo';
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-runtime.d.ts","sourceRoot":"","sources":["../../../src/generators/add-runtime/add-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,IAAI,EAAiB,MAAM,YAAY,CAAC;AAE7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"add-runtime.d.ts","sourceRoot":"","sources":["../../../src/generators/add-runtime/add-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,IAAI,EAAiB,MAAM,YAAY,CAAC;AAE7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AA4CrD,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,yBAAyB,uBAyHnC;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -26,8 +26,8 @@ function updateTypesIndexExport(tree, runtimeName, basePath) {
|
|
|
26
26
|
tree.write(indexPath, updatedContent);
|
|
27
27
|
}
|
|
28
28
|
async function addRuntimeGenerator(tree, options) {
|
|
29
|
-
// Normalize
|
|
30
|
-
let
|
|
29
|
+
// Normalize consumer option - Nx list prompts may return string labels instead of boolean values
|
|
30
|
+
let isExternal = options?.consumer === 'external' ? true : false;
|
|
31
31
|
// Validate and read .unisphere configuration
|
|
32
32
|
const unisphereConfig = (0, utils_1.validateUnisphereConfig)(tree);
|
|
33
33
|
// Validate dependencies
|
|
@@ -38,7 +38,6 @@ async function addRuntimeGenerator(tree, options) {
|
|
|
38
38
|
const widgetName = unisphereConfig.name;
|
|
39
39
|
// Validate and correct runtime naming for React/DS dependencies
|
|
40
40
|
let userInputRuntimeName = (0, devkit_1.names)(options.name).fileName;
|
|
41
|
-
userInputRuntimeName = (0, dependency_config_1.validateReactNaming)(userInputRuntimeName, selectedDependencies);
|
|
42
41
|
// Find types package (or fallback to core)
|
|
43
42
|
const typesPackageInfo = (0, utils_1.findTypesOrCorePackageInfo)(tree);
|
|
44
43
|
// Prepare template variables
|
|
@@ -78,17 +77,8 @@ async function addRuntimeGenerator(tree, options) {
|
|
|
78
77
|
const runtimePathKey = `unisphere-runtime-${userInputRuntimeName}`;
|
|
79
78
|
const runtimePathValue = `unisphere/runtimes/${userInputRuntimeName}/src/index.ts`;
|
|
80
79
|
(0, utils_1.updateTsConfigPaths)(tree, runtimePathKey, runtimePathValue);
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
// packageName: userInputRuntimeName,
|
|
84
|
-
// scope: 'none',
|
|
85
|
-
// });
|
|
86
|
-
// // Execute the package generation callback if it exists
|
|
87
|
-
// if (packageResult && typeof packageResult === 'function') {
|
|
88
|
-
// packageResult();
|
|
89
|
-
// }
|
|
90
|
-
// Handle standalone usage - create dev application
|
|
91
|
-
if (isStandalone === true) {
|
|
80
|
+
// Handle internal usage - create dev application
|
|
81
|
+
if (!!isExternal) {
|
|
92
82
|
// Create a dev application without prompts
|
|
93
83
|
const applicationResult = await (0, add_application_1.addApplicationGenerator)(tree, {
|
|
94
84
|
name: `${userInputRuntimeName}-dev`,
|
|
@@ -111,8 +101,8 @@ async function addRuntimeGenerator(tree, options) {
|
|
|
111
101
|
devkit_1.logger.info('');
|
|
112
102
|
devkit_1.logger.info(`🚀 Runtime Name: ${userInputRuntimeName}`);
|
|
113
103
|
devkit_1.logger.info(`📁 Location: ${projectRoot}`);
|
|
114
|
-
devkit_1.logger.info(`🔧
|
|
115
|
-
if (
|
|
104
|
+
devkit_1.logger.info(`🔧 Consumer: ${isExternal ? 'External' : 'Internal'}`);
|
|
105
|
+
if (isExternal === true) {
|
|
116
106
|
devkit_1.logger.info('');
|
|
117
107
|
devkit_1.logger.info('📦 Additional components created:');
|
|
118
108
|
devkit_1.logger.info(` • Dev Application: ${userInputRuntimeName}-dev`);
|
|
@@ -10,20 +10,20 @@
|
|
|
10
10
|
"pattern": "^[a-zA-Z][a-zA-Z0-9\\-\\s]*$",
|
|
11
11
|
"x-prompt": "What's the runtime name? (letters, numbers, dashes and spaces allowed)"
|
|
12
12
|
},
|
|
13
|
-
"
|
|
13
|
+
"consumer": {
|
|
14
14
|
"type": "string",
|
|
15
|
-
"description": "Is this
|
|
15
|
+
"description": "Is this runtime loaded from within the same experience or by an external consumer?",
|
|
16
16
|
"x-prompt": {
|
|
17
|
-
"message": "Is this
|
|
17
|
+
"message": "Is this runtime loaded from within the same experience or by an external consumer?",
|
|
18
18
|
"type": "list",
|
|
19
19
|
"items": [
|
|
20
20
|
{
|
|
21
|
-
"value": "
|
|
22
|
-
"label": "
|
|
21
|
+
"value": "external",
|
|
22
|
+
"label": "Loaded by an external consumer"
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
|
-
"value": "
|
|
26
|
-
"label": "
|
|
25
|
+
"value": "internal",
|
|
26
|
+
"label": "Loaded by another runtime or application within this experience"
|
|
27
27
|
}
|
|
28
28
|
]
|
|
29
29
|
}
|
|
@@ -63,6 +63,6 @@
|
|
|
63
63
|
},
|
|
64
64
|
"required": [
|
|
65
65
|
"name",
|
|
66
|
-
"
|
|
66
|
+
"consumer"
|
|
67
67
|
]
|
|
68
|
-
}
|
|
68
|
+
}
|
|
@@ -12,7 +12,7 @@ function checkNxVersion(tree) {
|
|
|
12
12
|
}
|
|
13
13
|
const majorVersion = parseInt(nxVersion.match(/\d+/)?.[0] ?? '0');
|
|
14
14
|
if (majorVersion < 22) {
|
|
15
|
-
const errorMessage = `❌ This migration requires Nx 22 or higher. read https://unisphere.kaltura.com/docs/create/changelog/1-22-
|
|
15
|
+
const errorMessage = `❌ This migration requires Nx 22 or higher. read https://unisphere.kaltura.com/docs/create/changelog/1-22-6-changelog`;
|
|
16
16
|
devkit_1.logger.error(errorMessage);
|
|
17
17
|
throw new Error(errorMessage);
|
|
18
18
|
}
|
|
@@ -7,6 +7,5 @@ async function default_1() {
|
|
|
7
7
|
devkit_1.logger.info('🎉 Migration to @unisphere/nx 1.22.4 finished successfully!');
|
|
8
8
|
devkit_1.logger.info('');
|
|
9
9
|
devkit_1.logger.info('📋 Full details:');
|
|
10
|
-
devkit_1.logger.info('https://unisphere.kaltura.com/docs/create/changelog/1-22-
|
|
11
|
-
devkit_1.logger.info('');
|
|
10
|
+
devkit_1.logger.info('https://unisphere.kaltura.com/docs/create/changelog/1-22-6-changelog');
|
|
12
11
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix-playground-apps.d.ts","sourceRoot":"","sources":["../../../src/migrations/2-0-0/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/2-0-0/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"}
|