@unisphere/nx 2.2.2 → 3.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generators/add-application/add-application.d.ts.map +1 -1
- package/dist/generators/add-application/add-application.js +76 -59
- package/dist/generators/add-application/schema.d.ts +3 -1
- package/dist/generators/add-application/schema.json +4 -8
- package/dist/generators/add-application/templates/default/.env-template +6 -0
- package/dist/generators/add-application/templates/default/.eslintrc.json +1 -1
- package/dist/generators/add-application/templates/default/jest.config.ts +3 -3
- package/dist/generators/add-application/templates/default/project.json.template +2 -2
- package/dist/generators/add-application/templates/default/readme.md.template +11 -0
- package/dist/generators/add-application/templates/default/src/app/app.tsx.template +77 -77
- package/dist/generators/add-application/templates/default/tsconfig.json +1 -1
- package/dist/generators/add-application/templates/default/webpack.config.js.template +6 -1
- package/dist/generators/add-package/README.md +2 -2
- package/dist/generators/add-package/add-package.d.ts.map +1 -1
- package/dist/generators/add-package/add-package.js +11 -23
- package/dist/generators/add-package/schema.d.ts +1 -1
- package/dist/generators/add-package/schema.json +27 -19
- package/dist/generators/add-package/templates/new-package/.eslintrc.json +1 -1
- package/dist/generators/add-package/templates/new-package/package.json.template +0 -1
- package/dist/generators/add-package/templates/new-package/project.json.template +4 -4
- package/dist/generators/add-package/templates/new-package/rollup.config.js +1 -1
- package/dist/generators/add-package/templates/new-package/tsconfig.json +1 -1
- package/dist/generators/add-package/templates/new-package/tsconfig.lib.json.template +1 -1
- package/dist/generators/add-package/templates/new-package/tsconfig.spec.json +1 -1
- package/dist/generators/add-runtime/add-runtime.d.ts.map +1 -1
- package/dist/generators/add-runtime/add-runtime.js +62 -9
- package/dist/generators/add-runtime/schema.d.ts +1 -0
- package/dist/generators/add-runtime/schema.json +1 -9
- package/dist/generators/add-runtime/templates/new-runtime/src/lib/create-factory.tsx.template +4 -4
- package/dist/generators/add-runtime/templates/new-runtime/src/lib/runtime.tsx.template +26 -2
- package/dist/generators/add-visual/add-visual.d.ts +1 -1
- package/dist/generators/add-visual/add-visual.d.ts.map +1 -1
- package/dist/generators/add-visual/add-visual.js +108 -15
- package/dist/generators/add-visual/schema.d.ts +3 -3
- package/dist/generators/add-visual/schema.json +2 -24
- package/dist/generators/dependency-config.d.ts.map +1 -1
- package/dist/generators/dependency-config.js +1 -0
- package/dist/generators/internal-dev-runner/generator.d.ts +3 -0
- package/dist/generators/internal-dev-runner/generator.d.ts.map +1 -0
- package/dist/generators/internal-dev-runner/generator.js +45 -0
- package/dist/generators/internal-dev-runner/schema.json +9 -0
- package/dist/generators/remove/remove.d.ts +19 -0
- package/dist/generators/remove/remove.d.ts.map +1 -0
- package/dist/generators/remove/remove.js +270 -0
- package/dist/generators/remove/schema.d.ts +4 -0
- package/dist/generators/remove/schema.json +38 -0
- package/dist/generators/rename-package/rename-package.d.ts +3 -0
- package/dist/generators/rename-package/rename-package.d.ts.map +1 -1
- package/dist/generators/rename-package/rename-package.js +139 -20
- package/dist/generators/utils.d.ts +30 -1
- package/dist/generators/utils.d.ts.map +1 -1
- package/dist/generators/utils.js +258 -7
- package/dist/migrations/1-22-0/patches/@changesets+cli+2.29.7.patch +36 -4
- package/dist/migrations/3-0-0/add-define-plugin-to-webpack.d.ts +3 -0
- package/dist/migrations/3-0-0/add-define-plugin-to-webpack.d.ts.map +1 -0
- package/dist/migrations/3-0-0/add-define-plugin-to-webpack.js +233 -0
- package/dist/migrations/3-0-0/add-env-to-application-gitignore.d.ts +3 -0
- package/dist/migrations/3-0-0/add-env-to-application-gitignore.d.ts.map +1 -0
- package/dist/migrations/3-0-0/add-env-to-application-gitignore.js +117 -0
- package/dist/migrations/3-0-0/fix-vite-config-cache-paths.d.ts +10 -0
- package/dist/migrations/3-0-0/fix-vite-config-cache-paths.d.ts.map +1 -0
- package/dist/migrations/3-0-0/fix-vite-config-cache-paths.js +66 -0
- package/dist/migrations/3-0-0/patches/@changesets+cli+2.29.7.patch +88 -0
- package/dist/migrations/3-0-0/post-cleanup-empty-directories.d.ts +12 -0
- package/dist/migrations/3-0-0/post-cleanup-empty-directories.d.ts.map +1 -0
- package/dist/migrations/3-0-0/post-cleanup-empty-directories.js +62 -0
- package/dist/migrations/3-0-0/pre-cleanup-empty-directories.d.ts +14 -0
- package/dist/migrations/3-0-0/pre-cleanup-empty-directories.d.ts.map +1 -0
- package/dist/migrations/3-0-0/pre-cleanup-empty-directories.js +105 -0
- package/dist/migrations/3-0-0/remove-kaltura-tools-to-pre-install.d.ts +3 -0
- package/dist/migrations/3-0-0/remove-kaltura-tools-to-pre-install.d.ts.map +1 -0
- package/dist/migrations/3-0-0/remove-kaltura-tools-to-pre-install.js +21 -0
- package/dist/migrations/3-0-0/remove-private-from-applications-and-runtimes.d.ts +9 -0
- package/dist/migrations/3-0-0/remove-private-from-applications-and-runtimes.d.ts.map +1 -0
- package/dist/migrations/3-0-0/remove-private-from-applications-and-runtimes.js +88 -0
- package/dist/migrations/3-0-0/remove-publish-config-from-packages.d.ts +9 -0
- package/dist/migrations/3-0-0/remove-publish-config-from-packages.d.ts.map +1 -0
- package/dist/migrations/3-0-0/remove-publish-config-from-packages.js +45 -0
- package/dist/migrations/3-0-0/reorganize-applications-by-distribution-channel.d.ts +15 -0
- package/dist/migrations/3-0-0/reorganize-applications-by-distribution-channel.d.ts.map +1 -0
- package/dist/migrations/3-0-0/reorganize-applications-by-distribution-channel.js +563 -0
- package/dist/migrations/3-0-0/reorganize-packages-by-distribution-channel.d.ts +23 -0
- package/dist/migrations/3-0-0/reorganize-packages-by-distribution-channel.d.ts.map +1 -0
- package/dist/migrations/3-0-0/reorganize-packages-by-distribution-channel.js +645 -0
- package/dist/migrations/3-0-0/replace-github-workflow.d.ts +3 -0
- package/dist/migrations/3-0-0/replace-github-workflow.d.ts.map +1 -0
- package/dist/migrations/3-0-0/replace-github-workflow.js +48 -0
- package/dist/migrations/3-0-0/sync-package-lock.d.ts +10 -0
- package/dist/migrations/3-0-0/sync-package-lock.d.ts.map +1 -0
- package/dist/migrations/3-0-0/sync-package-lock.js +26 -0
- package/dist/migrations/3-0-0/templates/_publish-artifacts.template +363 -0
- package/dist/migrations/3-0-0/templates/cicd.template +89 -0
- package/dist/migrations/3-0-0/update-changeset-patch.d.ts +3 -0
- package/dist/migrations/3-0-0/update-changeset-patch.d.ts.map +1 -0
- package/dist/migrations/3-0-0/update-changeset-patch.js +31 -0
- package/dist/migrations/3-0-0/upgrade-schema-to-2-0-0.d.ts +21 -0
- package/dist/migrations/3-0-0/upgrade-schema-to-2-0-0.d.ts.map +1 -0
- package/dist/migrations/3-0-0/upgrade-schema-to-2-0-0.js +105 -0
- package/dist/migrations/utils/has-react-dependency.d.ts +14 -0
- package/dist/migrations/utils/has-react-dependency.d.ts.map +1 -0
- package/dist/migrations/utils/has-react-dependency.js +72 -0
- package/dist/shared.d.ts +6 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +9 -0
- package/generators.json +12 -1
- package/migrations.json +117 -0
- package/package.json +3 -2
- package/dist/generators/add-application/templates/local-dev-playground/.babelrc +0 -11
- package/dist/generators/add-application/templates/local-dev-playground/.eslintrc.json +0 -22
- package/dist/generators/add-application/templates/local-dev-playground/jest.config.ts +0 -11
- package/dist/generators/add-application/templates/local-dev-playground/package.json +0 -6
- package/dist/generators/add-application/templates/local-dev-playground/project.json +0 -9
- package/dist/generators/add-application/templates/local-dev-playground/src/app/app.tsx.template +0 -212
- package/dist/generators/add-application/templates/local-dev-playground/src/app/components/header.tsx.template +0 -123
- package/dist/generators/add-application/templates/local-dev-playground/src/app/components/settings-buttons.tsx +0 -57
- package/dist/generators/add-application/templates/local-dev-playground/src/app/components/settings-form.tsx +0 -108
- package/dist/generators/add-application/templates/local-dev-playground/src/app/components/settings.tsx +0 -74
- package/dist/generators/add-application/templates/local-dev-playground/src/app/configuration-provider.tsx +0 -163
- package/dist/generators/add-application/templates/local-dev-playground/src/app/definitions.ts +0 -25
- package/dist/generators/add-application/templates/local-dev-playground/src/app/utils/merge-deep.ts +0 -31
- package/dist/generators/add-application/templates/local-dev-playground/src/favicon.ico +0 -0
- package/dist/generators/add-application/templates/local-dev-playground/src/index.html +0 -17
- package/dist/generators/add-application/templates/local-dev-playground/src/main.tsx +0 -13
- package/dist/generators/add-application/templates/local-dev-playground/src/styles.css +0 -0
- package/dist/generators/add-application/templates/local-dev-playground/tsconfig.app.json +0 -24
- package/dist/generators/add-application/templates/local-dev-playground/tsconfig.json +0 -20
- package/dist/generators/add-application/templates/local-dev-playground/tsconfig.spec.json +0 -25
- package/dist/generators/add-application/templates/local-dev-playground/webpack.config.js +0 -33
- /package/dist/generators/add-runtime/templates/{core-templates → types-templates}/__runtimeName__-runtime/index.ts.template +0 -0
- /package/dist/generators/add-runtime/templates/{core-templates → types-templates}/__runtimeName__-runtime/runtime-types.ts.template +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-application.d.ts","sourceRoot":"","sources":["../../../src/generators/add-application/add-application.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,IAAI,
|
|
1
|
+
{"version":3,"file":"add-application.d.ts","sourceRoot":"","sources":["../../../src/generators/add-application/add-application.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,IAAI,EAAsC,MAAM,YAAY,CAAC;AAElG,OAAO,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAkHzD,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,6BAA6B,uBAoIvC;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -11,14 +11,45 @@ async function getEnquirerPrompt() {
|
|
|
11
11
|
// Handle both CommonJS and ESM exports
|
|
12
12
|
return enquirer.prompt || enquirer.default?.prompt || enquirer;
|
|
13
13
|
}
|
|
14
|
-
async function promptForRuntimeName() {
|
|
14
|
+
async function promptForRuntimeName(availableRuntimes, existingRuntimeName, existingVisualName, skipDynamicRuntimeVisualPrompt) {
|
|
15
15
|
const prompt = await getEnquirerPrompt();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
16
|
+
let runtimeName = existingRuntimeName;
|
|
17
|
+
let visualName = existingVisualName;
|
|
18
|
+
if (skipDynamicRuntimeVisualPrompt) {
|
|
19
|
+
return { runtimeName, visualName };
|
|
20
|
+
}
|
|
21
|
+
if (!runtimeName) {
|
|
22
|
+
const runtimeChoices = [
|
|
23
|
+
{ value: '', name: '(none)' },
|
|
24
|
+
...Object.keys(availableRuntimes).map(name => ({ name, value: name }))
|
|
25
|
+
];
|
|
26
|
+
const response = await prompt({
|
|
27
|
+
type: 'select',
|
|
28
|
+
name: 'runtimeName',
|
|
29
|
+
message: 'Select a runtime for this application (optional):',
|
|
30
|
+
choices: runtimeChoices,
|
|
31
|
+
});
|
|
32
|
+
runtimeName = response.runtimeName;
|
|
33
|
+
runtimeName = runtimeName === '(none)' ? '' : runtimeName;
|
|
34
|
+
}
|
|
35
|
+
if (!visualName && runtimeName && availableRuntimes[runtimeName]) {
|
|
36
|
+
const availableVisuals = availableRuntimes[runtimeName].visuals;
|
|
37
|
+
if (availableVisuals.length > 0) {
|
|
38
|
+
const visualChoices = [
|
|
39
|
+
{ value: '', name: '(none)' },
|
|
40
|
+
...availableVisuals.map(name => ({ name, value: name }))
|
|
41
|
+
];
|
|
42
|
+
const response = await prompt({
|
|
43
|
+
type: 'select',
|
|
44
|
+
name: 'visualName',
|
|
45
|
+
message: 'Select a visual type to mount (optional):',
|
|
46
|
+
choices: visualChoices,
|
|
47
|
+
});
|
|
48
|
+
visualName = response.visualName;
|
|
49
|
+
visualName = visualName === '(none)' ? '' : visualName;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return { runtimeName, visualName };
|
|
22
53
|
}
|
|
23
54
|
async function promptForHtmlPageTitle() {
|
|
24
55
|
const prompt = await getEnquirerPrompt();
|
|
@@ -33,12 +64,7 @@ async function promptForDependencies(isPlayground) {
|
|
|
33
64
|
const prompt = await getEnquirerPrompt();
|
|
34
65
|
const choices = [
|
|
35
66
|
{ value: 'ds', label: 'Kaltura DS - Design System (requires GIT_TOKEN)' },
|
|
36
|
-
{ value: 'react-hook-form', label: 'React Hook Form - Form management' },
|
|
37
67
|
];
|
|
38
|
-
// Only show mui option for local-dev-playground
|
|
39
|
-
if (isPlayground) {
|
|
40
|
-
choices.splice(1, 0, { value: 'mui', label: 'Material UI - Component library' });
|
|
41
|
-
}
|
|
42
68
|
const response = await prompt({
|
|
43
69
|
type: 'multiselect',
|
|
44
70
|
name: 'dependencies',
|
|
@@ -53,97 +79,88 @@ async function addApplicationGenerator(tree, options) {
|
|
|
53
79
|
throw new Error('iframe-with-post-messages serving type is not currently supported. Please choose a different serving type.');
|
|
54
80
|
}
|
|
55
81
|
const isPlayground = options.servingType === 'local-dev-playground';
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
82
|
+
// Validate and read .unisphere configuration
|
|
83
|
+
const unisphereConfig = (0, utils_1.validateUnisphereConfig)(tree);
|
|
84
|
+
const { runtimeName, visualName } = await promptForRuntimeName(unisphereConfig.runtimes, options.runtimeName || '', options.visualName || '', options.skipDynamicRuntimeVisualPrompt || false);
|
|
60
85
|
if (!isPlayground && !options.htmlPageTitle) {
|
|
61
|
-
options.htmlPageTitle = await promptForHtmlPageTitle();
|
|
86
|
+
options.htmlPageTitle = options.htmlPageTitle || await promptForHtmlPageTitle();
|
|
62
87
|
}
|
|
63
88
|
if (options.dependencies === undefined) {
|
|
64
89
|
options.dependencies = await promptForDependencies(isPlayground);
|
|
65
90
|
}
|
|
66
|
-
// Validate and read .unisphere configuration
|
|
67
|
-
const unisphereConfig = (0, utils_1.validateUnisphereConfig)(tree);
|
|
68
|
-
// Validate dependencies - always include react, add mui and react-hook-form for local-dev-playground
|
|
69
91
|
const baseDependencies = ['react'];
|
|
70
|
-
if (options.servingType === 'local-dev-playground') {
|
|
71
|
-
baseDependencies.push('mui', 'react-hook-form');
|
|
72
|
-
}
|
|
73
92
|
const selectedDependencies = [...baseDependencies, ...(options.dependencies || [])];
|
|
74
|
-
(0, dependency_config_1.validateGitToken)(selectedDependencies);
|
|
75
93
|
// Validate runtime exists if runtimeName is provided
|
|
76
|
-
if (
|
|
77
|
-
if (!(0, utils_1.checkIfRuntimeExists)(tree,
|
|
78
|
-
throw new Error(`Runtime "${
|
|
94
|
+
if (runtimeName) {
|
|
95
|
+
if (!(0, utils_1.checkIfRuntimeExists)(tree, runtimeName)) {
|
|
96
|
+
throw new Error(`Runtime "${runtimeName}" does not exist, please check the available runtimes under 'unisphere/runtimes'`);
|
|
79
97
|
}
|
|
80
98
|
}
|
|
81
99
|
// Extract environment variables
|
|
82
100
|
const widgetName = unisphereConfig.name;
|
|
83
|
-
|
|
84
|
-
if (options.
|
|
85
|
-
|
|
86
|
-
? userInputApplicationName
|
|
87
|
-
: `${userInputApplicationName}-dev`;
|
|
101
|
+
let applicationName = options.name;
|
|
102
|
+
if (isPlayground && !options.name.endsWith('-dev')) {
|
|
103
|
+
applicationName += '-dev';
|
|
88
104
|
}
|
|
89
|
-
|
|
90
|
-
const hasDs = selectedDependencies.includes('ds');
|
|
91
|
-
const hasMui = selectedDependencies.includes('mui') || hasDs;
|
|
105
|
+
const applicationNameAsLowerDashCase = (0, devkit_1.names)(applicationName).fileName;
|
|
92
106
|
// Find types package (or fallback to core)
|
|
93
107
|
const typesPackageInfo = (0, utils_1.findTypesOrCorePackageInfo)(tree);
|
|
108
|
+
// Determine subdirectory based on serving type
|
|
109
|
+
// local-dev-playground -> local/, other types -> server/
|
|
110
|
+
const subdirectory = isPlayground ? 'local' : 'server';
|
|
111
|
+
const projectRoot = `unisphere/applications/${subdirectory}/${applicationNameAsLowerDashCase}`;
|
|
112
|
+
const hasDs = selectedDependencies.includes('ds');
|
|
94
113
|
const templateVariables = {
|
|
95
114
|
htmlPageTitle: options.servingType === 'local-dev-playground'
|
|
96
|
-
? `${
|
|
115
|
+
? `${runtimeName || 'Runtime'} - Local Dev Application`
|
|
97
116
|
: options.htmlPageTitle,
|
|
98
117
|
servingType: options.servingType,
|
|
99
118
|
hasDs,
|
|
100
|
-
|
|
101
|
-
...(0, utils_1.createNameTransforms)(userInputApplicationName, 'applicationName'),
|
|
119
|
+
...(0, utils_1.createNameTransforms)(applicationNameAsLowerDashCase, 'applicationName'),
|
|
102
120
|
...(0, utils_1.createNameTransforms)(widgetName, 'widgetName'),
|
|
103
|
-
...(0, utils_1.createNameTransforms)(
|
|
121
|
+
...(0, utils_1.createNameTransforms)(runtimeName, 'runtimeName'),
|
|
122
|
+
...(0, utils_1.createNameTransforms)(visualName, 'visualName'),
|
|
104
123
|
tmpl: '',
|
|
105
124
|
typesAlias: typesPackageInfo.alias,
|
|
125
|
+
subdirectory,
|
|
126
|
+
projectRoot,
|
|
106
127
|
};
|
|
107
|
-
const projectRoot = `unisphere/applications/${userInputApplicationName}`;
|
|
108
128
|
// Check if the application already exists
|
|
109
129
|
if (tree.exists(projectRoot)) {
|
|
110
|
-
throw new Error(`Application "${
|
|
130
|
+
throw new Error(`Application "${applicationNameAsLowerDashCase}" already exists at ${projectRoot}.\n` +
|
|
111
131
|
'Please choose a different application name or remove the existing application first.');
|
|
112
132
|
}
|
|
113
133
|
// Choose template based on serving type
|
|
114
|
-
const templatePath =
|
|
115
|
-
? 'templates/local-dev-playground'
|
|
116
|
-
: 'templates/default';
|
|
134
|
+
const templatePath = 'templates/default';
|
|
117
135
|
// Generate files from templates
|
|
118
136
|
(0, devkit_1.generateFiles)(tree, path.join(__dirname, templatePath), projectRoot, templateVariables);
|
|
119
137
|
// Install selected dependencies
|
|
120
138
|
(0, dependency_config_1.installSelectedDependencies)(tree, selectedDependencies);
|
|
121
|
-
const distributionChannel = options.servingType === 'local-dev-playground' ? 'none' : 'unisphere';
|
|
122
139
|
// Update .unisphere configuration
|
|
123
|
-
(0, utils_1.updateUnisphereConfig)(tree, 'applications',
|
|
124
|
-
sourceRoot:
|
|
125
|
-
distributionChannel: distributionChannel,
|
|
140
|
+
(0, utils_1.updateUnisphereConfig)(tree, 'applications', applicationNameAsLowerDashCase, {
|
|
141
|
+
sourceRoot: projectRoot,
|
|
126
142
|
});
|
|
127
143
|
// Update tsconfig.base.json with path mapping
|
|
128
|
-
const applicationPathKey = `unisphere-application-${
|
|
129
|
-
const applicationPathValue =
|
|
144
|
+
const applicationPathKey = `unisphere-application-${applicationNameAsLowerDashCase}`;
|
|
145
|
+
const applicationPathValue = `${projectRoot}/src/index.ts`;
|
|
130
146
|
(0, utils_1.updateTsConfigPaths)(tree, applicationPathKey, applicationPathValue);
|
|
147
|
+
const scriptName = `serve:${applicationNameAsLowerDashCase}`;
|
|
148
|
+
const scriptCommand = runtimeName ?
|
|
149
|
+
`concurrently "npx unisphere runtime serve ${runtimeName} --port 8400" "npx unisphere application serve ${applicationNameAsLowerDashCase} --port 4002"`
|
|
150
|
+
: `npx unisphere application serve ${applicationNameAsLowerDashCase} --port 4002`;
|
|
151
|
+
(0, utils_1.addScriptToRootPackageJson)(tree, scriptName, scriptCommand);
|
|
131
152
|
await (0, devkit_1.formatFiles)(tree);
|
|
132
153
|
// Return a function that will be executed after all file operations are complete
|
|
133
154
|
return () => {
|
|
155
|
+
(0, devkit_1.installPackagesTask)(tree, true);
|
|
134
156
|
devkit_1.logger.info('');
|
|
135
157
|
devkit_1.logger.info('✅ Application generated successfully!');
|
|
136
158
|
devkit_1.logger.info('');
|
|
137
|
-
devkit_1.logger.info(`🚀 Application Name: ${
|
|
138
|
-
devkit_1.logger.info(`📁 Location: ${projectRoot}`);
|
|
139
|
-
if (options.servingType === 'local-dev-playground') {
|
|
140
|
-
devkit_1.logger.info(`🎮 Runtime Name: ${options.runtimeName}`);
|
|
141
|
-
devkit_1.logger.info(`📄 HTML Page Title: ${options.runtimeName} - Local Dev Application`);
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
devkit_1.logger.info(`📄 HTML Page Title: ${options.htmlPageTitle}`);
|
|
145
|
-
}
|
|
159
|
+
devkit_1.logger.info(`🚀 Application Name: ${applicationNameAsLowerDashCase}`);
|
|
146
160
|
devkit_1.logger.info(`🔧 Serving Type: ${options.servingType}`);
|
|
161
|
+
devkit_1.logger.info(`📁 Location: ${projectRoot}`);
|
|
162
|
+
devkit_1.logger.info('');
|
|
163
|
+
devkit_1.logger.info(`📜 To run the application locally: npm run ${scriptName}`);
|
|
147
164
|
devkit_1.logger.info('');
|
|
148
165
|
};
|
|
149
166
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export interface AddApplicationGeneratorSchema {
|
|
2
2
|
name: string;
|
|
3
3
|
htmlPageTitle?: string;
|
|
4
|
-
servingType: 'local-dev-playground' | 'self-hosted' | 'iframe-with-
|
|
4
|
+
servingType: 'local-dev-playground' | 'self-hosted' | 'iframe-with-post-messages';
|
|
5
5
|
runtimeName?: string;
|
|
6
|
+
visualName?: string;
|
|
7
|
+
skipDynamicRuntimeVisualPrompt?: boolean; // Internal option to skip the dynamic prompt for visual when runtime is selected
|
|
6
8
|
dependencies?: string[];
|
|
7
9
|
}
|
|
@@ -17,22 +17,18 @@
|
|
|
17
17
|
"servingType": {
|
|
18
18
|
"type": "string",
|
|
19
19
|
"description": "How should this app be served?",
|
|
20
|
-
"default": "
|
|
20
|
+
"default": "local-dev-playground",
|
|
21
21
|
"x-prompt": {
|
|
22
22
|
"message": "Which serving type do you want?",
|
|
23
23
|
"type": "list",
|
|
24
24
|
"items": [
|
|
25
25
|
{
|
|
26
26
|
"value": "local-dev-playground",
|
|
27
|
-
"label": "
|
|
27
|
+
"label": "Runtime Dev Playground (for development purposes)"
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
30
|
"value": "self-hosted",
|
|
31
|
-
"label": "
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"value": "iframe-with-query-params",
|
|
35
|
-
"label": "Iframe + Query Params (suitible to applications that gets required configuration from URL query parameters)"
|
|
31
|
+
"label": "Standalone Application"
|
|
36
32
|
},
|
|
37
33
|
{
|
|
38
34
|
"value": "iframe-with-post-messages",
|
|
@@ -66,4 +62,4 @@
|
|
|
66
62
|
"name",
|
|
67
63
|
"servingType"
|
|
68
64
|
]
|
|
69
|
-
}
|
|
65
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
export default {
|
|
3
|
-
displayName: '
|
|
4
|
-
preset: '
|
|
3
|
+
displayName: '<%= applicationName__lowerDashCase %>',
|
|
4
|
+
preset: '../../../../jest.preset.js',
|
|
5
5
|
transform: {
|
|
6
6
|
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
|
|
7
7
|
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }],
|
|
8
8
|
},
|
|
9
9
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
|
|
10
|
-
coverageDirectory: '
|
|
10
|
+
coverageDirectory: '../../../../coverage/<%= projectRoot %>',
|
|
11
11
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unisphere-application-<%= applicationName__lowerDashCase %>",
|
|
3
|
-
"$schema": "
|
|
4
|
-
"sourceRoot": "
|
|
3
|
+
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "<%= projectRoot %>/src",
|
|
5
5
|
"projectType": "application",
|
|
6
6
|
"tags": [],
|
|
7
7
|
"// targets": "to see all targets run: nx show project unisphere-application-<%= applicationName__lowerDashCase %> --web",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# <%= applicationName__pascalCase %> Application
|
|
2
|
+
|
|
3
|
+
## Develop Locally
|
|
4
|
+
|
|
5
|
+
> Copy the .env file from `/<%= projectRoot %>/.env-template` to `/<%= projectRoot %>/.env` and update settings
|
|
6
|
+
|
|
7
|
+
1. run `npx unisphere application serve <%= applicationName__lowerDashCase %> --port 4002`
|
|
8
|
+
2. open the browser in http://localhost:4002/
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## Overview section
|
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<% if (servingType === 'iframe-with-query-params') { %>
|
|
1
|
+
import { useMemo, useState } from 'react';
|
|
2
|
+
import { getQueryParam } from '@unisphere/runtime-js';
|
|
3
|
+
import { UnisphereProvider } from '@unisphere/runtime-react';
|
|
4
|
+
import { UnisphereWorkspaceType } from '@unisphere/runtime';
|
|
5
|
+
<% if (runtimeName) { %>import { <%= runtimeName__pascalCase %>RuntimeSettings, <%= runtimeName__pascalCase %>Runtime } from '<%= typesAlias %>';<% } %>
|
|
6
|
+
<% if (visualName) { %>import { <%= runtimeName__pascalCase %>Runtime<%= visualName__pascalCase %>VisualSettings } from '<%= typesAlias %>';<% } %>
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const appId = ''; // Provide your application id
|
|
9
|
+
const appVersion = ''; // Provide your application version
|
|
10
|
+
|
|
11
|
+
export function App() {
|
|
12
|
+
<% if (runtimeName) { %>
|
|
13
|
+
const [runtime, setRuntime] = useState<<%= runtimeName__pascalCase %>Runtime | null>(null);
|
|
14
|
+
<% } %>
|
|
15
|
+
const env = useMemo(() => {
|
|
12
16
|
const envMatch = window.location.hostname.match(/unisphere\.(.+?)\.ovp\./);
|
|
13
17
|
let env = '';
|
|
18
|
+
const isLocalhost = window.location.hostname.startsWith('localhost');
|
|
19
|
+
const isDev = getQueryParam('debugIsDev') === 'true';
|
|
14
20
|
|
|
15
|
-
if (
|
|
16
|
-
|
|
21
|
+
if (isDev) {
|
|
22
|
+
return 'nvq2';
|
|
23
|
+
}
|
|
24
|
+
else if (envMatch) {
|
|
17
25
|
env = envMatch[1];
|
|
18
|
-
} else if (
|
|
19
|
-
console.log(
|
|
20
|
-
'no env match found in hostname and got isDev query param, assuming nvq2'
|
|
21
|
-
);
|
|
26
|
+
} else if (isLocalhost) {
|
|
22
27
|
env = 'nvq2';
|
|
23
28
|
} else {
|
|
24
|
-
console.log('no env match found in hostname, assuming nvp1');
|
|
25
29
|
env = 'nvp1';
|
|
26
30
|
}
|
|
31
|
+
return env;
|
|
32
|
+
}, []);
|
|
27
33
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (ks && env) {
|
|
32
|
-
return null; // TODO initiate here the actual adapter
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
console.warn('Missing required query params: ks');
|
|
36
|
-
return null;
|
|
37
|
-
<% } else { %>
|
|
38
|
-
|
|
39
|
-
return null;
|
|
40
|
-
<% } %>
|
|
41
|
-
|
|
34
|
+
<% if (runtimeName) { %>
|
|
35
|
+
const [runtimeSettings] = useState<<%= runtimeName__pascalCase %>RuntimeSettings | null>(() => {
|
|
36
|
+
return {};
|
|
42
37
|
});
|
|
43
|
-
|
|
44
|
-
<% if (servingType === 'iframe-with-post-messages') { %>
|
|
45
|
-
// TODO should get the configuration from post message event
|
|
46
|
-
<% } %>
|
|
47
|
-
|
|
48
|
-
<% if (servingType === 'self-hosted') { %>
|
|
49
|
-
// TODO self hosted logic if needed
|
|
50
38
|
<% } %>
|
|
51
39
|
|
|
52
40
|
<% if (hasDs) { %>
|
|
53
|
-
const
|
|
54
|
-
return 'light' as
|
|
55
|
-
});
|
|
41
|
+
const themeMode = useMemo(() => {
|
|
42
|
+
return (process.env.THEME_MODE || 'light') as 'light' | 'dark';
|
|
43
|
+
}, []);
|
|
56
44
|
<% } %>
|
|
45
|
+
|
|
46
|
+
const onWorkspaceLoaded = (_workspace: UnisphereWorkspaceType) => {
|
|
47
|
+
<% if (runtimeName) { %>
|
|
48
|
+
setRuntime(_workspace.getRuntime<<%= runtimeName__pascalCase %>Runtime>('unisphere.widget.<%= widgetName__lowerDashCase %>', '<%= runtimeName__lowerDashCase %>'));
|
|
49
|
+
<% } %>
|
|
50
|
+
};
|
|
57
51
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
<% } %>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
overrides={{
|
|
81
|
-
mode: themeMode,
|
|
82
|
-
}}
|
|
83
|
-
>
|
|
84
|
-
{adapter ? <div> <%= applicationName__lowerDashCase %> </div> : <div></div>}
|
|
85
|
-
</HostThemeProvider>
|
|
86
|
-
<% } else { %>
|
|
87
|
-
{adapter ? <div> <%= applicationName__lowerDashCase %> </div> : <div></div>}
|
|
88
|
-
<% } %>
|
|
89
|
-
<% if (hasMui) { %>
|
|
90
|
-
</Box>
|
|
91
|
-
<% } else { %>
|
|
92
|
-
</div>
|
|
52
|
+
|
|
53
|
+
return <UnisphereProvider
|
|
54
|
+
onWorkspaceLoaded={onWorkspaceLoaded}
|
|
55
|
+
themeMode={<% if (hasDs) { %>themeMode<% } else { %>'light'<% } %>}
|
|
56
|
+
initialConfiguration={{
|
|
57
|
+
appId,
|
|
58
|
+
appVersion,
|
|
59
|
+
serverUrl: `https://unisphere.${env}.ovp.kaltura.com/v1`,
|
|
60
|
+
runtimes: [
|
|
61
|
+
<% if (runtimeName) { %>
|
|
62
|
+
{
|
|
63
|
+
widgetName: 'unisphere.widget.<%= widgetName__lowerDashCase %>',
|
|
64
|
+
runtimeName: '<%= runtimeName__lowerDashCase %>',
|
|
65
|
+
settings: runtimeSettings,
|
|
66
|
+
visuals: [
|
|
67
|
+
<% if (!visualName) { %>/*<% } %>{
|
|
68
|
+
type: '<%= visualName ? visualName__camelCase : "~~provide-the-visual-name-to-mount-here~~" %>',
|
|
69
|
+
target: 'mainContainer',
|
|
70
|
+
settings: {}<% if (visualName) { %> as <%= runtimeName__pascalCase %>Runtime<%= visualName__pascalCase %>VisualSettings<% } %>
|
|
71
|
+
}<% if (!visualName) { %>*/<% } %>
|
|
72
|
+
],
|
|
73
|
+
},
|
|
93
74
|
<% } %>
|
|
94
|
-
|
|
75
|
+
],
|
|
76
|
+
ui: {
|
|
77
|
+
theme: <% if (hasDs) { %>themeMode<% } else { %>'light'<% } %>,
|
|
78
|
+
language: 'en'
|
|
79
|
+
}
|
|
80
|
+
}}
|
|
81
|
+
>
|
|
82
|
+
<div id='mainContainer'></div>
|
|
83
|
+
</UnisphereProvider>;
|
|
95
84
|
}
|
|
96
85
|
|
|
97
86
|
export default App;
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
const { NxAppWebpackPlugin } = require('@nx/webpack/app-plugin');
|
|
2
2
|
const { NxReactWebpackPlugin } = require('@nx/react/webpack-plugin');
|
|
3
|
+
const { DefinePlugin } = require('webpack');
|
|
3
4
|
const { join } = require('path');
|
|
4
5
|
|
|
5
6
|
const baseHref = process.env.UNISPHERE_BASE_HREF || '/';
|
|
6
7
|
|
|
7
8
|
module.exports = {
|
|
8
9
|
output: {
|
|
9
|
-
path: join(__dirname, '
|
|
10
|
+
path: join(__dirname, '../../../../dist/<%= projectRoot %>'),
|
|
10
11
|
publicPath: baseHref
|
|
11
12
|
},
|
|
12
13
|
devServer: {
|
|
13
14
|
port: 4200,
|
|
14
15
|
},
|
|
15
16
|
plugins: [
|
|
17
|
+
new DefinePlugin({
|
|
18
|
+
// Add your environment variables here
|
|
19
|
+
// Example: 'process.env.API_URL': JSON.stringify(process.env.API_URL),
|
|
20
|
+
}),
|
|
16
21
|
new NxAppWebpackPlugin({
|
|
17
22
|
tsConfig: './tsconfig.app.json',
|
|
18
23
|
compiler: 'babel',
|
|
@@ -21,8 +21,8 @@ The generator will prompt you for the following information:
|
|
|
21
21
|
- Example: `core`, `notification-service`, `user management`
|
|
22
22
|
|
|
23
23
|
2. **scope** (required, defaults to 'internal')
|
|
24
|
-
- **public**:
|
|
25
|
-
- **internal**:
|
|
24
|
+
- **public**: server to npm with `@unisphere/` prefix
|
|
25
|
+
- **internal**: server to GitHub packages with `@kaltura-corp/unisphere-` prefix
|
|
26
26
|
- **none**: Private repository only, no scope prefix
|
|
27
27
|
|
|
28
28
|
## Local Development & Distribution
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"add-package.d.ts","sourceRoot":"","sources":["../../../src/generators/add-package/add-package.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,IAAI,EAAgD,MAAM,YAAY,CAAC;AAE5G,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AA4DrD,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,yBAAyB,uBAiHnC;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -56,23 +56,11 @@ async function addPackageGenerator(tree, options) {
|
|
|
56
56
|
else {
|
|
57
57
|
packageJsonName = experienceName + `-${userInputPackageName}`;
|
|
58
58
|
}
|
|
59
|
-
const prefix = options.scope === 'public' ? '@unisphere/' :
|
|
59
|
+
const prefix = options.scope === 'public' ? '@unisphere/' :
|
|
60
|
+
options.scope === 'internal' ? '@kaltura-corp/unisphere-' :
|
|
61
|
+
options.scope === 'kaltura-ai' ? '@kaltura-ai/' :
|
|
62
|
+
'@local/';
|
|
60
63
|
packageJsonName = prefix + packageJsonName;
|
|
61
|
-
const repositoryPrivate = options.scope === 'none';
|
|
62
|
-
// Calculate distributionChannel
|
|
63
|
-
let distributionChannel;
|
|
64
|
-
switch (options.scope) {
|
|
65
|
-
case 'public':
|
|
66
|
-
distributionChannel = 'npm';
|
|
67
|
-
break;
|
|
68
|
-
case 'none':
|
|
69
|
-
distributionChannel = 'none';
|
|
70
|
-
break;
|
|
71
|
-
case 'internal':
|
|
72
|
-
default:
|
|
73
|
-
distributionChannel = 'github';
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
64
|
const transformedPackageName = (0, devkit_1.names)(userInputPackageName);
|
|
77
65
|
const githubUrl = `https://github.com/${companyName}/${experienceName}`;
|
|
78
66
|
// Resolve @unisphere/runtime version from workspace package.json
|
|
@@ -80,23 +68,24 @@ async function addPackageGenerator(tree, options) {
|
|
|
80
68
|
// Determine which dependencies are selected
|
|
81
69
|
const hasDs = selectedDependencies.includes('ds');
|
|
82
70
|
const hasReact = selectedDependencies.includes('react') || hasDs;
|
|
71
|
+
// Determine subdirectory based on scope (schema v2.0.0+)
|
|
72
|
+
const subdirectory = (0, utils_1.getSubdirectoryFromScope)(options.scope);
|
|
73
|
+
const projectRoot = `unisphere/packages/${subdirectory}/${userInputPackageName}`;
|
|
83
74
|
// Prepare template variables
|
|
84
75
|
const templateVariables = {
|
|
85
76
|
scope: options.scope,
|
|
86
|
-
repositoryPrivate,
|
|
87
|
-
distributionChannel,
|
|
88
77
|
githubUrl,
|
|
89
78
|
companyName,
|
|
90
79
|
unisphereRuntimeVersion,
|
|
91
80
|
hasDs,
|
|
92
81
|
hasReact,
|
|
82
|
+
subdirectory,
|
|
93
83
|
...(0, utils_1.createNameTransforms)(userInputPackageName, 'packageName'),
|
|
94
84
|
...(0, utils_1.createNameTransforms)(experienceName, 'experienceName'),
|
|
95
85
|
...(0, utils_1.createNameTransforms)(packageJsonName, 'packageJsonName'),
|
|
96
86
|
...transformedPackageName,
|
|
97
87
|
tmpl: '',
|
|
98
88
|
};
|
|
99
|
-
const projectRoot = `unisphere/packages/${userInputPackageName}`;
|
|
100
89
|
// Check if the project already exists
|
|
101
90
|
if (tree.exists(projectRoot)) {
|
|
102
91
|
throw new Error(`Package "${userInputPackageName}" already exists at ${projectRoot}.\n` +
|
|
@@ -106,17 +95,17 @@ async function addPackageGenerator(tree, options) {
|
|
|
106
95
|
(0, devkit_1.generateFiles)(tree, path.join(__dirname, 'templates/new-package'), projectRoot, templateVariables);
|
|
107
96
|
// Update .unisphere configuration
|
|
108
97
|
(0, utils_1.updateUnisphereConfig)(tree, 'packages', userInputPackageName, {
|
|
109
|
-
sourceRoot: `unisphere/packages/${userInputPackageName}`,
|
|
110
|
-
distributionChannel: distributionChannel,
|
|
98
|
+
sourceRoot: `unisphere/packages/${subdirectory}/${userInputPackageName}`,
|
|
111
99
|
scope: 'widget',
|
|
112
100
|
});
|
|
113
101
|
// Update tsconfig.base.json with path mapping
|
|
114
|
-
(0, utils_1.updateTsConfigPaths)(tree, packageJsonName, `unisphere/packages/${userInputPackageName}/src/index.ts`);
|
|
102
|
+
(0, utils_1.updateTsConfigPaths)(tree, packageJsonName, `unisphere/packages/${subdirectory}/${userInputPackageName}/src/index.ts`);
|
|
115
103
|
// Install selected dependencies
|
|
116
104
|
(0, dependency_config_1.installSelectedDependencies)(tree, selectedDependencies);
|
|
117
105
|
await (0, devkit_1.formatFiles)(tree);
|
|
118
106
|
// Return a function that will be executed after all file operations are complete
|
|
119
107
|
return () => {
|
|
108
|
+
(0, devkit_1.installPackagesTask)(tree, true);
|
|
120
109
|
devkit_1.logger.info('');
|
|
121
110
|
devkit_1.logger.info('✅ Package generated successfully!');
|
|
122
111
|
devkit_1.logger.info('');
|
|
@@ -124,7 +113,6 @@ async function addPackageGenerator(tree, options) {
|
|
|
124
113
|
devkit_1.logger.info(`🏷️ Full Package Name: ${packageJsonName}`);
|
|
125
114
|
devkit_1.logger.info(`📁 Location: ${projectRoot}`);
|
|
126
115
|
devkit_1.logger.info(`🔧 Scope: ${options.scope}`);
|
|
127
|
-
devkit_1.logger.info(`📤 Distribution Channel: ${distributionChannel}`);
|
|
128
116
|
devkit_1.logger.info('');
|
|
129
117
|
};
|
|
130
118
|
}
|