@unisphere/nx 2.2.2 → 3.2.4
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 +186 -63
- package/dist/generators/add-application/schema.d.ts +3 -1
- package/dist/generators/add-application/schema.json +8 -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 +47 -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/3-1-0/fix-workspaces-pattern.d.ts +23 -0
- package/dist/migrations/3-1-0/fix-workspaces-pattern.d.ts.map +1 -0
- package/dist/migrations/3-1-0/fix-workspaces-pattern.js +72 -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 +125 -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;AAIlG,OAAO,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAkHzD,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,6BAA6B,uBAgQvC;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -4,6 +4,8 @@ exports.addApplicationGenerator = addApplicationGenerator;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const path = tslib_1.__importStar(require("path"));
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
7
9
|
const utils_1 = require("../utils");
|
|
8
10
|
const dependency_config_1 = require("../dependency-config");
|
|
9
11
|
async function getEnquirerPrompt() {
|
|
@@ -11,14 +13,45 @@ async function getEnquirerPrompt() {
|
|
|
11
13
|
// Handle both CommonJS and ESM exports
|
|
12
14
|
return enquirer.prompt || enquirer.default?.prompt || enquirer;
|
|
13
15
|
}
|
|
14
|
-
async function promptForRuntimeName() {
|
|
16
|
+
async function promptForRuntimeName(availableRuntimes, existingRuntimeName, existingVisualName, skipDynamicRuntimeVisualPrompt) {
|
|
15
17
|
const prompt = await getEnquirerPrompt();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
18
|
+
let runtimeName = existingRuntimeName;
|
|
19
|
+
let visualName = existingVisualName;
|
|
20
|
+
if (skipDynamicRuntimeVisualPrompt) {
|
|
21
|
+
return { runtimeName, visualName };
|
|
22
|
+
}
|
|
23
|
+
if (!runtimeName) {
|
|
24
|
+
const runtimeChoices = [
|
|
25
|
+
{ value: '', name: '(none)' },
|
|
26
|
+
...Object.keys(availableRuntimes).map(name => ({ name, value: name }))
|
|
27
|
+
];
|
|
28
|
+
const response = await prompt({
|
|
29
|
+
type: 'select',
|
|
30
|
+
name: 'runtimeName',
|
|
31
|
+
message: 'Select a runtime for this application (optional):',
|
|
32
|
+
choices: runtimeChoices,
|
|
33
|
+
});
|
|
34
|
+
runtimeName = response.runtimeName;
|
|
35
|
+
runtimeName = runtimeName === '(none)' ? '' : runtimeName;
|
|
36
|
+
}
|
|
37
|
+
if (!visualName && runtimeName && availableRuntimes[runtimeName]) {
|
|
38
|
+
const availableVisuals = availableRuntimes[runtimeName].visuals;
|
|
39
|
+
if (availableVisuals.length > 0) {
|
|
40
|
+
const visualChoices = [
|
|
41
|
+
{ value: '', name: '(none)' },
|
|
42
|
+
...availableVisuals.map(name => ({ name, value: name }))
|
|
43
|
+
];
|
|
44
|
+
const response = await prompt({
|
|
45
|
+
type: 'select',
|
|
46
|
+
name: 'visualName',
|
|
47
|
+
message: 'Select a visual type to mount (optional):',
|
|
48
|
+
choices: visualChoices,
|
|
49
|
+
});
|
|
50
|
+
visualName = response.visualName;
|
|
51
|
+
visualName = visualName === '(none)' ? '' : visualName;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return { runtimeName, visualName };
|
|
22
55
|
}
|
|
23
56
|
async function promptForHtmlPageTitle() {
|
|
24
57
|
const prompt = await getEnquirerPrompt();
|
|
@@ -33,12 +66,7 @@ async function promptForDependencies(isPlayground) {
|
|
|
33
66
|
const prompt = await getEnquirerPrompt();
|
|
34
67
|
const choices = [
|
|
35
68
|
{ value: 'ds', label: 'Kaltura DS - Design System (requires GIT_TOKEN)' },
|
|
36
|
-
{ value: 'react-hook-form', label: 'React Hook Form - Form management' },
|
|
37
69
|
];
|
|
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
70
|
const response = await prompt({
|
|
43
71
|
type: 'multiselect',
|
|
44
72
|
name: 'dependencies',
|
|
@@ -53,97 +81,192 @@ async function addApplicationGenerator(tree, options) {
|
|
|
53
81
|
throw new Error('iframe-with-post-messages serving type is not currently supported. Please choose a different serving type.');
|
|
54
82
|
}
|
|
55
83
|
const isPlayground = options.servingType === 'local-dev-playground';
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
84
|
+
const isDocumentation = options.servingType === 'documentation';
|
|
85
|
+
// Check workspace pattern for documentation apps
|
|
86
|
+
if (isDocumentation) {
|
|
87
|
+
const rootPackageJsonPath = 'package.json';
|
|
88
|
+
if (tree.exists(rootPackageJsonPath)) {
|
|
89
|
+
const packageJson = JSON.parse(tree.read(rootPackageJsonPath, 'utf-8') || '{}');
|
|
90
|
+
const workspaces = packageJson.workspaces || [];
|
|
91
|
+
// Check if using the old catch-all pattern that doesn't work with documentation apps
|
|
92
|
+
const hasCatchAllPattern = workspaces.includes('unisphere/**');
|
|
93
|
+
const hasNegationPattern = workspaces.some((pattern) => pattern.startsWith('!'));
|
|
94
|
+
if (hasCatchAllPattern || hasNegationPattern) {
|
|
95
|
+
throw new Error('Documentation applications require @unisphere/nx version 3.1.0 or higher.\n\n' +
|
|
96
|
+
'Your workspace is using an old npm workspaces pattern that prevents documentation apps ' +
|
|
97
|
+
'from having their own node_modules.\n\n' +
|
|
98
|
+
'Please upgrade by running:\n' +
|
|
99
|
+
' npx nx migrate @unisphere/nx@latest\n' +
|
|
100
|
+
' npx nx migrate --run-migrations\n\n' +
|
|
101
|
+
'This will update your workspace pattern to support documentation apps.');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
65
104
|
}
|
|
66
105
|
// Validate and read .unisphere configuration
|
|
67
106
|
const unisphereConfig = (0, utils_1.validateUnisphereConfig)(tree);
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
107
|
+
// Skip runtime/visual prompts for documentation sites
|
|
108
|
+
let runtimeName = '';
|
|
109
|
+
let visualName = '';
|
|
110
|
+
if (!isDocumentation) {
|
|
111
|
+
const promptResult = await promptForRuntimeName(unisphereConfig.runtimes, options.runtimeName || '', options.visualName || '', options.skipDynamicRuntimeVisualPrompt || false);
|
|
112
|
+
runtimeName = promptResult.runtimeName;
|
|
113
|
+
visualName = promptResult.visualName;
|
|
114
|
+
}
|
|
115
|
+
// Skip HTML page title prompt for documentation (Docusaurus has its own config)
|
|
116
|
+
if (!isPlayground && !isDocumentation && !options.htmlPageTitle) {
|
|
117
|
+
options.htmlPageTitle = options.htmlPageTitle || await promptForHtmlPageTitle();
|
|
118
|
+
}
|
|
119
|
+
// Skip dependencies prompt for documentation (Docusaurus has its own)
|
|
120
|
+
let selectedDependencies = [];
|
|
121
|
+
if (!isDocumentation) {
|
|
122
|
+
if (options.dependencies === undefined) {
|
|
123
|
+
options.dependencies = await promptForDependencies(isPlayground);
|
|
124
|
+
}
|
|
125
|
+
const baseDependencies = ['react'];
|
|
126
|
+
selectedDependencies = [...baseDependencies, ...(options.dependencies || [])];
|
|
72
127
|
}
|
|
73
|
-
const selectedDependencies = [...baseDependencies, ...(options.dependencies || [])];
|
|
74
|
-
(0, dependency_config_1.validateGitToken)(selectedDependencies);
|
|
75
128
|
// Validate runtime exists if runtimeName is provided
|
|
76
|
-
if (
|
|
77
|
-
if (!(0, utils_1.checkIfRuntimeExists)(tree,
|
|
78
|
-
throw new Error(`Runtime "${
|
|
129
|
+
if (runtimeName) {
|
|
130
|
+
if (!(0, utils_1.checkIfRuntimeExists)(tree, runtimeName)) {
|
|
131
|
+
throw new Error(`Runtime "${runtimeName}" does not exist, please check the available runtimes under 'unisphere/runtimes'`);
|
|
79
132
|
}
|
|
80
133
|
}
|
|
81
134
|
// Extract environment variables
|
|
82
135
|
const widgetName = unisphereConfig.name;
|
|
83
|
-
|
|
84
|
-
if (options.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
136
|
+
let applicationName = options.name;
|
|
137
|
+
if (isPlayground && !options.name.endsWith('-dev')) {
|
|
138
|
+
applicationName += '-dev';
|
|
139
|
+
}
|
|
140
|
+
const applicationNameAsLowerDashCase = (0, devkit_1.names)(applicationName).fileName;
|
|
141
|
+
// Find types package (or fallback to core) - skip for documentation
|
|
142
|
+
const typesPackageInfo = isDocumentation ? null : (0, utils_1.findTypesOrCorePackageInfo)(tree);
|
|
143
|
+
// Determine subdirectory based on serving type
|
|
144
|
+
// local-dev-playground -> local/, documentation -> documentation/, other types -> server/
|
|
145
|
+
const subdirectory = isPlayground ? 'local' : isDocumentation ? 'documentation' : 'server';
|
|
146
|
+
const projectRoot = `unisphere/applications/${subdirectory}/${applicationNameAsLowerDashCase}`;
|
|
147
|
+
// Handle documentation type separately
|
|
148
|
+
if (isDocumentation) {
|
|
149
|
+
// Check if the application already exists
|
|
150
|
+
if (tree.exists(projectRoot)) {
|
|
151
|
+
throw new Error(`Application "${applicationNameAsLowerDashCase}" already exists at ${projectRoot}.\n` +
|
|
152
|
+
'Please choose a different application name or remove the existing application first.');
|
|
153
|
+
}
|
|
154
|
+
// Update .unisphere configuration (applicationType is derived from folder path)
|
|
155
|
+
(0, utils_1.updateUnisphereConfig)(tree, 'applications', applicationNameAsLowerDashCase, {
|
|
156
|
+
sourceRoot: projectRoot,
|
|
157
|
+
});
|
|
158
|
+
// Add documentation folder to .nxignore to prevent NX from scanning it
|
|
159
|
+
// Docusaurus has its own node_modules which can slow down NX
|
|
160
|
+
const nxIgnorePath = '.nxignore';
|
|
161
|
+
const ignoreEntry = `${projectRoot}/node_modules`;
|
|
162
|
+
let nxIgnoreContent = '';
|
|
163
|
+
if (tree.exists(nxIgnorePath)) {
|
|
164
|
+
nxIgnoreContent = tree.read(nxIgnorePath, 'utf-8') || '';
|
|
165
|
+
}
|
|
166
|
+
if (!nxIgnoreContent.includes(ignoreEntry)) {
|
|
167
|
+
const newContent = nxIgnoreContent
|
|
168
|
+
? `${nxIgnoreContent.trimEnd()}\n\n# Documentation site (Docusaurus) - has its own node_modules\n${ignoreEntry}\n`
|
|
169
|
+
: `# Documentation site (Docusaurus) - has its own node_modules\n${ignoreEntry}\n`;
|
|
170
|
+
tree.write(nxIgnorePath, newContent);
|
|
171
|
+
}
|
|
172
|
+
// Documentation folders are automatically excluded from npm workspaces
|
|
173
|
+
// because the root package.json uses explicit workspace patterns that don't include
|
|
174
|
+
// unisphere/applications/documentation/**
|
|
175
|
+
// This allows documentation sites (like Docusaurus) to have their own node_modules
|
|
176
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
177
|
+
// Return a function that will be executed after all file operations are complete
|
|
178
|
+
return () => {
|
|
179
|
+
const workspaceRoot = process.cwd();
|
|
180
|
+
const fullProjectPath = path.join(workspaceRoot, projectRoot);
|
|
181
|
+
devkit_1.logger.info('');
|
|
182
|
+
devkit_1.logger.info('📚 Setting up Docusaurus documentation site...');
|
|
183
|
+
devkit_1.logger.info('');
|
|
184
|
+
try {
|
|
185
|
+
// Create the parent directory if it doesn't exist
|
|
186
|
+
const parentDir = path.dirname(fullProjectPath);
|
|
187
|
+
if (!fs.existsSync(parentDir)) {
|
|
188
|
+
fs.mkdirSync(parentDir, { recursive: true });
|
|
189
|
+
}
|
|
190
|
+
// Run Docusaurus CLI to scaffold the project
|
|
191
|
+
// Docusaurus creates a self-contained project with its own package.json
|
|
192
|
+
// No NX integration needed - we just delegate to Docusaurus CLI for serve/build
|
|
193
|
+
// Use public npm registry explicitly (workspaces may have private registry configured)
|
|
194
|
+
devkit_1.logger.info('Running Docusaurus CLI...');
|
|
195
|
+
(0, child_process_1.execSync)(`npx --yes --registry https://registry.npmjs.org create-docusaurus@3 "${fullProjectPath}" classic --typescript`, {
|
|
196
|
+
stdio: 'inherit',
|
|
197
|
+
cwd: workspaceRoot,
|
|
198
|
+
});
|
|
199
|
+
devkit_1.logger.info('');
|
|
200
|
+
devkit_1.logger.info('✅ Documentation site generated successfully!');
|
|
201
|
+
devkit_1.logger.info('');
|
|
202
|
+
devkit_1.logger.info(`📚 Application Name: ${applicationNameAsLowerDashCase}`);
|
|
203
|
+
devkit_1.logger.info(`🔧 Type: Documentation Site (Docusaurus)`);
|
|
204
|
+
devkit_1.logger.info(`📁 Location: ${projectRoot}`);
|
|
205
|
+
devkit_1.logger.info('');
|
|
206
|
+
devkit_1.logger.info(`📜 To serve: npx unisphere application serve ${applicationNameAsLowerDashCase}`);
|
|
207
|
+
devkit_1.logger.info(`📦 To build: npx unisphere application build ${applicationNameAsLowerDashCase}`);
|
|
208
|
+
devkit_1.logger.info('');
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
devkit_1.logger.error('Failed to create Docusaurus project:');
|
|
212
|
+
devkit_1.logger.error(error instanceof Error ? error.message : String(error));
|
|
213
|
+
throw error;
|
|
214
|
+
}
|
|
215
|
+
};
|
|
88
216
|
}
|
|
89
|
-
//
|
|
217
|
+
// Standard application flow (non-documentation)
|
|
90
218
|
const hasDs = selectedDependencies.includes('ds');
|
|
91
|
-
const hasMui = selectedDependencies.includes('mui') || hasDs;
|
|
92
|
-
// Find types package (or fallback to core)
|
|
93
|
-
const typesPackageInfo = (0, utils_1.findTypesOrCorePackageInfo)(tree);
|
|
94
219
|
const templateVariables = {
|
|
95
220
|
htmlPageTitle: options.servingType === 'local-dev-playground'
|
|
96
|
-
? `${
|
|
221
|
+
? `${runtimeName || 'Runtime'} - Local Dev Application`
|
|
97
222
|
: options.htmlPageTitle,
|
|
98
223
|
servingType: options.servingType,
|
|
99
224
|
hasDs,
|
|
100
|
-
|
|
101
|
-
...(0, utils_1.createNameTransforms)(userInputApplicationName, 'applicationName'),
|
|
225
|
+
...(0, utils_1.createNameTransforms)(applicationNameAsLowerDashCase, 'applicationName'),
|
|
102
226
|
...(0, utils_1.createNameTransforms)(widgetName, 'widgetName'),
|
|
103
|
-
...(0, utils_1.createNameTransforms)(
|
|
227
|
+
...(0, utils_1.createNameTransforms)(runtimeName, 'runtimeName'),
|
|
228
|
+
...(0, utils_1.createNameTransforms)(visualName, 'visualName'),
|
|
104
229
|
tmpl: '',
|
|
105
230
|
typesAlias: typesPackageInfo.alias,
|
|
231
|
+
subdirectory,
|
|
232
|
+
projectRoot,
|
|
106
233
|
};
|
|
107
|
-
const projectRoot = `unisphere/applications/${userInputApplicationName}`;
|
|
108
234
|
// Check if the application already exists
|
|
109
235
|
if (tree.exists(projectRoot)) {
|
|
110
|
-
throw new Error(`Application "${
|
|
236
|
+
throw new Error(`Application "${applicationNameAsLowerDashCase}" already exists at ${projectRoot}.\n` +
|
|
111
237
|
'Please choose a different application name or remove the existing application first.');
|
|
112
238
|
}
|
|
113
239
|
// Choose template based on serving type
|
|
114
|
-
const templatePath =
|
|
115
|
-
? 'templates/local-dev-playground'
|
|
116
|
-
: 'templates/default';
|
|
240
|
+
const templatePath = 'templates/default';
|
|
117
241
|
// Generate files from templates
|
|
118
242
|
(0, devkit_1.generateFiles)(tree, path.join(__dirname, templatePath), projectRoot, templateVariables);
|
|
119
243
|
// Install selected dependencies
|
|
120
244
|
(0, dependency_config_1.installSelectedDependencies)(tree, selectedDependencies);
|
|
121
|
-
const distributionChannel = options.servingType === 'local-dev-playground' ? 'none' : 'unisphere';
|
|
122
245
|
// Update .unisphere configuration
|
|
123
|
-
(0, utils_1.updateUnisphereConfig)(tree, 'applications',
|
|
124
|
-
sourceRoot:
|
|
125
|
-
distributionChannel: distributionChannel,
|
|
246
|
+
(0, utils_1.updateUnisphereConfig)(tree, 'applications', applicationNameAsLowerDashCase, {
|
|
247
|
+
sourceRoot: projectRoot,
|
|
126
248
|
});
|
|
127
249
|
// Update tsconfig.base.json with path mapping
|
|
128
|
-
const applicationPathKey = `unisphere-application-${
|
|
129
|
-
const applicationPathValue =
|
|
250
|
+
const applicationPathKey = `unisphere-application-${applicationNameAsLowerDashCase}`;
|
|
251
|
+
const applicationPathValue = `${projectRoot}/src/index.ts`;
|
|
130
252
|
(0, utils_1.updateTsConfigPaths)(tree, applicationPathKey, applicationPathValue);
|
|
253
|
+
const scriptName = `serve:${applicationNameAsLowerDashCase}`;
|
|
254
|
+
const scriptCommand = runtimeName ?
|
|
255
|
+
`concurrently "npx unisphere runtime serve ${runtimeName} --port 8400" "npx unisphere application serve ${applicationNameAsLowerDashCase} --port 4002"`
|
|
256
|
+
: `npx unisphere application serve ${applicationNameAsLowerDashCase} --port 4002`;
|
|
257
|
+
(0, utils_1.addScriptToRootPackageJson)(tree, scriptName, scriptCommand);
|
|
131
258
|
await (0, devkit_1.formatFiles)(tree);
|
|
132
259
|
// Return a function that will be executed after all file operations are complete
|
|
133
260
|
return () => {
|
|
261
|
+
(0, devkit_1.installPackagesTask)(tree, true);
|
|
134
262
|
devkit_1.logger.info('');
|
|
135
263
|
devkit_1.logger.info('✅ Application generated successfully!');
|
|
136
264
|
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
|
-
}
|
|
265
|
+
devkit_1.logger.info(`🚀 Application Name: ${applicationNameAsLowerDashCase}`);
|
|
146
266
|
devkit_1.logger.info(`🔧 Serving Type: ${options.servingType}`);
|
|
267
|
+
devkit_1.logger.info(`📁 Location: ${projectRoot}`);
|
|
268
|
+
devkit_1.logger.info('');
|
|
269
|
+
devkit_1.logger.info(`📜 To run the application locally: npm run ${scriptName}`);
|
|
147
270
|
devkit_1.logger.info('');
|
|
148
271
|
};
|
|
149
272
|
}
|
|
@@ -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' | 'documentation';
|
|
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,26 +17,26 @@
|
|
|
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",
|
|
39
35
|
"label": "Iframe + Post Messages (suitible to applications that gets required configuration from post messages)"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"value": "documentation",
|
|
39
|
+
"label": "Documentation Site (Docusaurus)"
|
|
40
40
|
}
|
|
41
41
|
]
|
|
42
42
|
}
|
|
@@ -66,4 +66,4 @@
|
|
|
66
66
|
"name",
|
|
67
67
|
"servingType"
|
|
68
68
|
]
|
|
69
|
-
}
|
|
69
|
+
}
|
|
@@ -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',
|