@unisphere/nx 1.0.1
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 +32 -0
- package/dist/generators/add-application/add-application.d.ts +5 -0
- package/dist/generators/add-application/add-application.d.ts.map +1 -0
- package/dist/generators/add-application/add-application.js +98 -0
- package/dist/generators/add-application/schema.d.ts +6 -0
- package/dist/generators/add-application/schema.json +92 -0
- package/dist/generators/add-application/templates/default/.babelrc +11 -0
- package/dist/generators/add-application/templates/default/.eslintrc.json +18 -0
- package/dist/generators/add-application/templates/default/jest.config.d.ts +14 -0
- package/dist/generators/add-application/templates/default/jest.config.d.ts.map +1 -0
- package/dist/generators/add-application/templates/default/jest.config.js +13 -0
- package/dist/generators/add-application/templates/default/package.json.template +7 -0
- package/dist/generators/add-application/templates/default/project.json.template +9 -0
- package/dist/generators/add-application/templates/default/src/app/app.tsx.template +76 -0
- package/dist/generators/add-application/templates/default/src/favicon.ico +0 -0
- package/dist/generators/add-application/templates/default/src/index.html.template +17 -0
- package/dist/generators/add-application/templates/default/src/main.tsx +13 -0
- package/dist/generators/add-application/templates/default/src/styles.css +0 -0
- package/dist/generators/add-application/templates/default/tsconfig.app.json +24 -0
- package/dist/generators/add-application/templates/default/tsconfig.json +20 -0
- package/dist/generators/add-application/templates/default/tsconfig.spec.json +25 -0
- package/dist/generators/add-application/templates/default/webpack.config.js.template +33 -0
- package/dist/generators/add-application/templates/interactive-playground/.babelrc +11 -0
- package/dist/generators/add-application/templates/interactive-playground/.eslintrc.json +18 -0
- package/dist/generators/add-application/templates/interactive-playground/jest.config.d.ts +14 -0
- package/dist/generators/add-application/templates/interactive-playground/jest.config.d.ts.map +1 -0
- package/dist/generators/add-application/templates/interactive-playground/jest.config.js +13 -0
- package/dist/generators/add-application/templates/interactive-playground/package.json +7 -0
- package/dist/generators/add-application/templates/interactive-playground/project.json +9 -0
- package/dist/generators/add-application/templates/interactive-playground/src/app/app.tsx.template +122 -0
- package/dist/generators/add-application/templates/interactive-playground/src/app/components/header.tsx.template +123 -0
- package/dist/generators/add-application/templates/interactive-playground/src/app/components/settings-buttons.tsx +59 -0
- package/dist/generators/add-application/templates/interactive-playground/src/app/components/settings-form.tsx +104 -0
- package/dist/generators/add-application/templates/interactive-playground/src/app/components/settings.tsx +74 -0
- package/dist/generators/add-application/templates/interactive-playground/src/app/configuration-provider.tsx +163 -0
- package/dist/generators/add-application/templates/interactive-playground/src/app/definitions.d.ts +11 -0
- package/dist/generators/add-application/templates/interactive-playground/src/app/definitions.d.ts.map +1 -0
- package/dist/generators/add-application/templates/interactive-playground/src/app/definitions.js +19 -0
- package/dist/generators/add-application/templates/interactive-playground/src/app/utils/merge-deep.d.ts +13 -0
- package/dist/generators/add-application/templates/interactive-playground/src/app/utils/merge-deep.d.ts.map +1 -0
- package/dist/generators/add-application/templates/interactive-playground/src/app/utils/merge-deep.js +35 -0
- package/dist/generators/add-application/templates/interactive-playground/src/favicon.ico +0 -0
- package/dist/generators/add-application/templates/interactive-playground/src/index.html +17 -0
- package/dist/generators/add-application/templates/interactive-playground/src/main.tsx +13 -0
- package/dist/generators/add-application/templates/interactive-playground/src/styles.css +0 -0
- package/dist/generators/add-application/templates/interactive-playground/tsconfig.app.json +24 -0
- package/dist/generators/add-application/templates/interactive-playground/tsconfig.json +20 -0
- package/dist/generators/add-application/templates/interactive-playground/tsconfig.spec.json +25 -0
- package/dist/generators/add-application/templates/interactive-playground/webpack.config.js +33 -0
- package/dist/generators/add-package/README.md +70 -0
- package/dist/generators/add-package/add-package.d.ts +5 -0
- package/dist/generators/add-package/add-package.d.ts.map +1 -0
- package/dist/generators/add-package/add-package.js +85 -0
- package/dist/generators/add-package/files/.babelrc +12 -0
- package/dist/generators/add-package/files/.eslintrc.json +18 -0
- package/dist/generators/add-package/files/README.md +1 -0
- package/dist/generators/add-package/files/package.json.template +22 -0
- package/dist/generators/add-package/files/project.json.template +22 -0
- package/dist/generators/add-package/files/rollup.config.js +6 -0
- package/dist/generators/add-package/files/src/index.ts +1 -0
- package/dist/generators/add-package/files/tsconfig.json +20 -0
- package/dist/generators/add-package/files/tsconfig.lib.json +23 -0
- package/dist/generators/add-package/files/tsconfig.spec.json +26 -0
- package/dist/generators/add-package/files/vite.config.ts +30 -0
- package/dist/generators/add-package/schema.d.ts +4 -0
- package/dist/generators/add-package/schema.json +46 -0
- package/dist/generators/add-runtime/add-runtime.d.ts +5 -0
- package/dist/generators/add-runtime/add-runtime.d.ts.map +1 -0
- package/dist/generators/add-runtime/add-runtime.js +112 -0
- package/dist/generators/add-runtime/core-templates/__runtimeName__-runtime/runtime-types.ts.template +21 -0
- package/dist/generators/add-runtime/files/.babelrc +12 -0
- package/dist/generators/add-runtime/files/.eslintrc.json +18 -0
- package/dist/generators/add-runtime/files/README.md.template +1 -0
- package/dist/generators/add-runtime/files/package.json.template +12 -0
- package/dist/generators/add-runtime/files/project.json.template +22 -0
- package/dist/generators/add-runtime/files/rollup.config.js +6 -0
- package/dist/generators/add-runtime/files/src/index.ts +1 -0
- package/dist/generators/add-runtime/files/src/lib/create-factory.tsx.template +21 -0
- package/dist/generators/add-runtime/files/src/lib/runtime.tsx.template +66 -0
- package/dist/generators/add-runtime/files/tsconfig.json +20 -0
- package/dist/generators/add-runtime/files/tsconfig.lib.json +23 -0
- package/dist/generators/add-runtime/files/tsconfig.spec.json +26 -0
- package/dist/generators/add-runtime/files/vite.config.ts +30 -0
- package/dist/generators/add-runtime/schema.d.ts +4 -0
- package/dist/generators/add-runtime/schema.json +44 -0
- package/dist/generators/add-visual/add-visual.d.ts +8 -0
- package/dist/generators/add-visual/add-visual.d.ts.map +1 -0
- package/dist/generators/add-visual/add-visual.js +236 -0
- package/dist/generators/add-visual/files/render-method.template +31 -0
- package/dist/generators/add-visual/schema.d.ts +5 -0
- package/dist/generators/add-visual/schema.json +30 -0
- package/dist/generators/add-visual/visual-utils.d.ts +42 -0
- package/dist/generators/add-visual/visual-utils.d.ts.map +1 -0
- package/dist/generators/add-visual/visual-utils.js +99 -0
- package/dist/generators/utils.d.ts +18 -0
- package/dist/generators/utils.d.ts.map +1 -0
- package/dist/generators/utils.js +198 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/generators.json +24 -0
- package/package.json +81 -0
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @unisphere/nx
|
|
2
|
+
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## Building
|
|
6
|
+
|
|
7
|
+
Run `nx build unisphere-generator` to build the library.
|
|
8
|
+
|
|
9
|
+
## Running unit tests
|
|
10
|
+
|
|
11
|
+
Run `nx test unisphere-generator` to execute the unit tests via [Jest](https://jestjs.io).
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## Run Add Package
|
|
15
|
+
|
|
16
|
+
Run `npx nx g @unisphere/nx:add-package` to build the library.
|
|
17
|
+
|
|
18
|
+
## Run Add Runtime
|
|
19
|
+
|
|
20
|
+
Run `npx nx g @unisphere/nx:add-runtime` to build the library.
|
|
21
|
+
|
|
22
|
+
## Run Add Application
|
|
23
|
+
|
|
24
|
+
Run `npx nx g @unisphere/nx:add-application` to build the library.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## Run in another folder with path of current plugin
|
|
28
|
+
|
|
29
|
+
Run `npx nx g <path-of-current-repo>packages/nx:add-application` to build the library.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { AddApplicationGeneratorSchema } from './schema';
|
|
3
|
+
export declare function addApplicationGenerator(tree: Tree, options: AddApplicationGeneratorSchema): Promise<() => void>;
|
|
4
|
+
export default addApplicationGenerator;
|
|
5
|
+
//# sourceMappingURL=add-application.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-application.d.ts","sourceRoot":"","sources":["../../../src/generators/add-application/add-application.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,IAAI,EAGL,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAezD,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,6BAA6B,uBAiHvC;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addApplicationGenerator = addApplicationGenerator;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const path = tslib_1.__importStar(require("path"));
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
const utils_1 = require("../utils");
|
|
9
|
+
async function addApplicationGenerator(tree, options) {
|
|
10
|
+
// Validate iframe-with-post-messages is not supported
|
|
11
|
+
if (options.servingType === 'iframe-with-post-messages') {
|
|
12
|
+
throw new Error('iframe-with-post-messages serving type is not currently supported. Please choose a different serving type.');
|
|
13
|
+
}
|
|
14
|
+
// Validate and read .unisphere configuration
|
|
15
|
+
const unisphereConfig = (0, utils_1.validateUnisphereConfig)(tree);
|
|
16
|
+
// Validate runtime exists if runtimeName is provided
|
|
17
|
+
if (options.runtimeName) {
|
|
18
|
+
if (!(0, utils_1.checkIfRuntimeExists)(tree, options.runtimeName)) {
|
|
19
|
+
throw new Error(`Runtime "${options.runtimeName}" does not exist`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
// Extract environment variables
|
|
23
|
+
const widgetName = unisphereConfig.name;
|
|
24
|
+
const userInputApplicationName = (0, devkit_1.names)(options.name).fileName;
|
|
25
|
+
// Prepare template variables
|
|
26
|
+
const templateVariables = {
|
|
27
|
+
htmlPageTitle: options.servingType === 'interactive-playground'
|
|
28
|
+
? `${options.runtimeName || 'Runtime'} - Interactive Expo`
|
|
29
|
+
: options.htmlPageTitle,
|
|
30
|
+
servingType: options.servingType,
|
|
31
|
+
...(0, utils_1.createNameTransforms)(userInputApplicationName, 'applicationName'),
|
|
32
|
+
...(0, utils_1.createNameTransforms)(widgetName, 'widgetName'),
|
|
33
|
+
...(0, utils_1.createNameTransforms)(options.runtimeName || 'runtime', 'runtimeName'),
|
|
34
|
+
tmpl: '',
|
|
35
|
+
};
|
|
36
|
+
const projectRoot = `unisphere/applications/${userInputApplicationName}`;
|
|
37
|
+
// Check if the application already exists
|
|
38
|
+
if (tree.exists(projectRoot)) {
|
|
39
|
+
throw new Error(`Application "${userInputApplicationName}" already exists at ${projectRoot}.\n` +
|
|
40
|
+
'Please choose a different application name or remove the existing application first.');
|
|
41
|
+
}
|
|
42
|
+
// Choose template based on serving type
|
|
43
|
+
const templatePath = options.servingType === 'interactive-playground'
|
|
44
|
+
? 'templates/interactive-playground'
|
|
45
|
+
: 'templates/default';
|
|
46
|
+
// Generate files from templates
|
|
47
|
+
(0, devkit_1.generateFiles)(tree, path.join(__dirname, templatePath), projectRoot, templateVariables);
|
|
48
|
+
// For interactive-playground, ensure react-hook-form is installed
|
|
49
|
+
if (options.servingType === 'interactive-playground') {
|
|
50
|
+
const installedVersion = (0, utils_1.isPackageInstalled)(tree, 'react-hook-form');
|
|
51
|
+
if (!installedVersion) {
|
|
52
|
+
const version = '^7.60';
|
|
53
|
+
const installCommand = `npm install react-hook-form@${version}`;
|
|
54
|
+
devkit_1.logger.info(`📦 Installing react-hook-form@${version}...`);
|
|
55
|
+
try {
|
|
56
|
+
(0, child_process_1.execSync)(installCommand, {
|
|
57
|
+
cwd: process.cwd(),
|
|
58
|
+
stdio: 'inherit',
|
|
59
|
+
});
|
|
60
|
+
devkit_1.logger.info('✅ react-hook-form installed successfully');
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
devkit_1.logger.error(`❌ Failed to install react-hook-form: ${error}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
devkit_1.logger.info(`✅ react-hook-form is already installed (version: ${installedVersion})`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Update .unisphere configuration
|
|
71
|
+
(0, utils_1.updateUnisphereConfig)(tree, 'applications', userInputApplicationName, {
|
|
72
|
+
sourceRoot: `unisphere/applications/${userInputApplicationName}`,
|
|
73
|
+
distributionChannel: 'unisphere',
|
|
74
|
+
});
|
|
75
|
+
// Update tsconfig.base.json with path mapping
|
|
76
|
+
const applicationPathKey = `unisphere-application-${userInputApplicationName}`;
|
|
77
|
+
const applicationPathValue = `unisphere/applications/${userInputApplicationName}/src/index.ts`;
|
|
78
|
+
(0, utils_1.updateTsConfigPaths)(tree, applicationPathKey, applicationPathValue);
|
|
79
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
80
|
+
// Return a function that will be executed after all file operations are complete
|
|
81
|
+
return () => {
|
|
82
|
+
devkit_1.logger.info('');
|
|
83
|
+
devkit_1.logger.info('✅ Application generated successfully!');
|
|
84
|
+
devkit_1.logger.info('');
|
|
85
|
+
devkit_1.logger.info(`🚀 Application Name: ${userInputApplicationName}`);
|
|
86
|
+
devkit_1.logger.info(`📁 Location: ${projectRoot}`);
|
|
87
|
+
if (options.servingType === 'interactive-playground') {
|
|
88
|
+
devkit_1.logger.info(`🎮 Runtime Name: ${options.runtimeName}`);
|
|
89
|
+
devkit_1.logger.info(`📄 HTML Page Title: ${options.runtimeName} - Interactive Expo`);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
devkit_1.logger.info(`📄 HTML Page Title: ${options.htmlPageTitle}`);
|
|
93
|
+
}
|
|
94
|
+
devkit_1.logger.info(`🔧 Serving Type: ${options.servingType}`);
|
|
95
|
+
devkit_1.logger.info('');
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
exports.default = addApplicationGenerator;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "AddApplication",
|
|
4
|
+
"title": "Add Application Generator",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"name": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The name of the application to create",
|
|
10
|
+
"pattern": "^[a-zA-Z][a-zA-Z0-9\\-\\s]*$",
|
|
11
|
+
"$default": {
|
|
12
|
+
"$source": "argv",
|
|
13
|
+
"index": 0
|
|
14
|
+
},
|
|
15
|
+
"x-prompt": "What is the application name? (letters, numbers, dashes and spaces allowed)"
|
|
16
|
+
},
|
|
17
|
+
"servingType": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"description": "How should this app be served?",
|
|
20
|
+
"enum": [
|
|
21
|
+
"interactive-playground",
|
|
22
|
+
"self-hosted",
|
|
23
|
+
"iframe-with-query-params",
|
|
24
|
+
"iframe-with-post-messages"
|
|
25
|
+
],
|
|
26
|
+
"default": "self-hosted",
|
|
27
|
+
"x-prompt": {
|
|
28
|
+
"message": "Which serving type do you want?",
|
|
29
|
+
"type": "list",
|
|
30
|
+
"items": [
|
|
31
|
+
{
|
|
32
|
+
"value": "interactive-playground",
|
|
33
|
+
"label": "Interactive Playground (Expo demo app for development purposes)"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"value": "self-hosted",
|
|
37
|
+
"label": "Self-Hosted (standalone, suitible to applications with login pages)"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"value": "iframe-with-query-params",
|
|
41
|
+
"label": "Iframe + Query Params (suitible to applications that gets required configuration from URL query parameters)"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"value": "iframe-with-post-messages",
|
|
45
|
+
"label": "Iframe + Post Messages (suitible to applications that gets required configuration from post messages)"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"runtimeName": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"description": "Which runtime should the playground load?",
|
|
53
|
+
"x-prompt": {
|
|
54
|
+
"message": "Enter the runtime name to load in the playground:",
|
|
55
|
+
"when": "servingType === 'interactive-playground'"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"htmlPageTitle": {
|
|
59
|
+
"type": "string",
|
|
60
|
+
"description": "The HTML page title for your app",
|
|
61
|
+
"x-prompt": {
|
|
62
|
+
"message": "What should the HTML page title be?",
|
|
63
|
+
"when": "servingType !== 'interactive-playground'"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"required": [
|
|
68
|
+
"name",
|
|
69
|
+
"servingType"
|
|
70
|
+
],
|
|
71
|
+
"allOf": [
|
|
72
|
+
{
|
|
73
|
+
"if": {
|
|
74
|
+
"properties": {
|
|
75
|
+
"servingType": {
|
|
76
|
+
"const": "interactive-playground"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"then": {
|
|
81
|
+
"required": [
|
|
82
|
+
"runtimeName"
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
"else": {
|
|
86
|
+
"required": [
|
|
87
|
+
"htmlPageTitle"
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": ["plugin:@nx/react", "../../../.eslintrc.json"],
|
|
3
|
+
"ignorePatterns": ["!**/*"],
|
|
4
|
+
"overrides": [
|
|
5
|
+
{
|
|
6
|
+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
|
7
|
+
"rules": {}
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"files": ["*.ts", "*.tsx"],
|
|
11
|
+
"rules": {}
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"files": ["*.js", "*.jsx"],
|
|
15
|
+
"rules": {}
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
displayName: string;
|
|
3
|
+
preset: string;
|
|
4
|
+
transform: {
|
|
5
|
+
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': string;
|
|
6
|
+
'^.+\\.[tj]sx?$': (string | {
|
|
7
|
+
presets: string[];
|
|
8
|
+
})[];
|
|
9
|
+
};
|
|
10
|
+
moduleFileExtensions: string[];
|
|
11
|
+
coverageDirectory: string;
|
|
12
|
+
};
|
|
13
|
+
export default _default;
|
|
14
|
+
//# sourceMappingURL=jest.config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest.config.d.ts","sourceRoot":"","sources":["../../../../../src/generators/add-application/templates/default/jest.config.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,wBASE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
exports.default = {
|
|
5
|
+
displayName: 'admin',
|
|
6
|
+
preset: '../../../jest.preset.js',
|
|
7
|
+
transform: {
|
|
8
|
+
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
|
|
9
|
+
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }],
|
|
10
|
+
},
|
|
11
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
|
|
12
|
+
coverageDirectory: '../../../coverage/unisphere/applications/admin',
|
|
13
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "unisphere-application-<%= applicationName__lowerDashCase %>",
|
|
3
|
+
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "unisphere/applications/<%= applicationName__lowerDashCase %>/src",
|
|
5
|
+
"projectType": "application",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"// targets": "to see all targets run: nx show project unisphere-application-<%= applicationName__lowerDashCase %> --web",
|
|
8
|
+
"targets": {}
|
|
9
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { HostThemeProvider } from '@kaltura/ds-react-theme';
|
|
3
|
+
import { Box } from '@mui/material';
|
|
4
|
+
|
|
5
|
+
export function App() {
|
|
6
|
+
const [adapter] = useState(() => {
|
|
7
|
+
<% if (servingType === 'iframe-with-query-params') { %>
|
|
8
|
+
|
|
9
|
+
const ks = new URLSearchParams(window.location.search).get('ks') || '';
|
|
10
|
+
const isDev =
|
|
11
|
+
new URLSearchParams(window.location.search).get('isDev') || '';
|
|
12
|
+
const envMatch = window.location.hostname.match(/unisphere\.(.+?)\.ovp\./);
|
|
13
|
+
let env = '';
|
|
14
|
+
|
|
15
|
+
if (envMatch) {
|
|
16
|
+
console.log('extracting env from hostname', envMatch[1]);
|
|
17
|
+
env = envMatch[1];
|
|
18
|
+
} else if (isDev) {
|
|
19
|
+
console.log(
|
|
20
|
+
'no env match found in hostname and got isDev query param, assuming nvq2'
|
|
21
|
+
);
|
|
22
|
+
env = 'nvq2';
|
|
23
|
+
} else {
|
|
24
|
+
console.log('no env match found in hostname, assuming nvp1');
|
|
25
|
+
env = 'nvp1';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (ks === 'demo') {
|
|
29
|
+
return null; // TODO initialize here the mock adapter
|
|
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
|
+
|
|
42
|
+
});
|
|
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
|
+
<% } %>
|
|
51
|
+
|
|
52
|
+
const [themeMode] = useState(() => {
|
|
53
|
+
return 'light' as const
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<Box
|
|
58
|
+
sx={{
|
|
59
|
+
width: '100vw',
|
|
60
|
+
height: '100vh',
|
|
61
|
+
overflow: 'hidden',
|
|
62
|
+
padding: '12px 24px',
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
65
|
+
<HostThemeProvider
|
|
66
|
+
overrides={{
|
|
67
|
+
mode: themeMode,
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
{adapter ? <div> <%= applicationName__lowerDashCase %> </div> : <div></div>}
|
|
71
|
+
</HostThemeProvider>
|
|
72
|
+
</Box>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export default App;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8" />
|
|
6
|
+
<title>
|
|
7
|
+
<%= htmlPageTitle %>
|
|
8
|
+
</title>
|
|
9
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
10
|
+
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
|
11
|
+
</head>
|
|
12
|
+
|
|
13
|
+
<body>
|
|
14
|
+
<div id="root"></div>
|
|
15
|
+
</body>
|
|
16
|
+
|
|
17
|
+
</html>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StrictMode } from 'react';
|
|
2
|
+
import * as ReactDOM from 'react-dom/client';
|
|
3
|
+
|
|
4
|
+
import App from './app/app';
|
|
5
|
+
|
|
6
|
+
const root = ReactDOM.createRoot(
|
|
7
|
+
document.getElementById('root') as HTMLElement
|
|
8
|
+
);
|
|
9
|
+
root.render(
|
|
10
|
+
<StrictMode>
|
|
11
|
+
<App />
|
|
12
|
+
</StrictMode>
|
|
13
|
+
);
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../../dist/out-tsc",
|
|
5
|
+
"types": [
|
|
6
|
+
"node",
|
|
7
|
+
|
|
8
|
+
"@nx/react/typings/cssmodule.d.ts",
|
|
9
|
+
"@nx/react/typings/image.d.ts"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"exclude": [
|
|
13
|
+
"jest.config.ts",
|
|
14
|
+
"src/**/*.spec.ts",
|
|
15
|
+
"src/**/*.test.ts",
|
|
16
|
+
"src/**/*.spec.tsx",
|
|
17
|
+
"src/**/*.test.tsx",
|
|
18
|
+
"src/**/*.spec.js",
|
|
19
|
+
"src/**/*.test.js",
|
|
20
|
+
"src/**/*.spec.jsx",
|
|
21
|
+
"src/**/*.test.jsx"
|
|
22
|
+
],
|
|
23
|
+
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
|
|
24
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"jsx": "react-jsx",
|
|
4
|
+
"allowJs": false,
|
|
5
|
+
"esModuleInterop": false,
|
|
6
|
+
"allowSyntheticDefaultImports": true,
|
|
7
|
+
"strict": true
|
|
8
|
+
},
|
|
9
|
+
"files": [],
|
|
10
|
+
"include": [],
|
|
11
|
+
"references": [
|
|
12
|
+
{
|
|
13
|
+
"path": "./tsconfig.app.json"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"path": "./tsconfig.spec.json"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"extends": "../../../tsconfig.base.json"
|
|
20
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../../dist/out-tsc",
|
|
5
|
+
"module": "commonjs",
|
|
6
|
+
"types": [
|
|
7
|
+
"jest",
|
|
8
|
+
"node",
|
|
9
|
+
"@nx/react/typings/cssmodule.d.ts",
|
|
10
|
+
"@nx/react/typings/image.d.ts"
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
"include": [
|
|
14
|
+
"jest.config.ts",
|
|
15
|
+
"src/**/*.test.ts",
|
|
16
|
+
"src/**/*.spec.ts",
|
|
17
|
+
"src/**/*.test.tsx",
|
|
18
|
+
"src/**/*.spec.tsx",
|
|
19
|
+
"src/**/*.test.js",
|
|
20
|
+
"src/**/*.spec.js",
|
|
21
|
+
"src/**/*.test.jsx",
|
|
22
|
+
"src/**/*.spec.jsx",
|
|
23
|
+
"src/**/*.d.ts"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const { NxAppWebpackPlugin } = require('@nx/webpack/app-plugin');
|
|
2
|
+
const { NxReactWebpackPlugin } = require('@nx/react/webpack-plugin');
|
|
3
|
+
const { join } = require('path');
|
|
4
|
+
|
|
5
|
+
const baseHref = process.env.UNISPHERE_BASE_HREF || '/';
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
output: {
|
|
9
|
+
path: join(__dirname, '../../../dist/unisphere/applications/<%= applicationName__lowerDashCase %>'),
|
|
10
|
+
publicPath: baseHref
|
|
11
|
+
},
|
|
12
|
+
devServer: {
|
|
13
|
+
port: 4200,
|
|
14
|
+
},
|
|
15
|
+
plugins: [
|
|
16
|
+
new NxAppWebpackPlugin({
|
|
17
|
+
tsConfig: './tsconfig.app.json',
|
|
18
|
+
compiler: 'babel',
|
|
19
|
+
main: './src/main.tsx',
|
|
20
|
+
index: './src/index.html',
|
|
21
|
+
baseHref,
|
|
22
|
+
assets: ['./src/favicon.ico'],
|
|
23
|
+
styles: ['./src/styles.css'],
|
|
24
|
+
outputHashing: process.env['NODE_ENV'] === 'production' ? 'all' : 'none',
|
|
25
|
+
optimization: process.env['NODE_ENV'] === 'production',
|
|
26
|
+
}),
|
|
27
|
+
new NxReactWebpackPlugin({
|
|
28
|
+
// Uncomment this line if you don't want to use SVGR
|
|
29
|
+
// See: https://react-svgr.com/
|
|
30
|
+
// svgr: false
|
|
31
|
+
}),
|
|
32
|
+
],
|
|
33
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": ["plugin:@nx/react", "../../../.eslintrc.json"],
|
|
3
|
+
"ignorePatterns": ["!**/*"],
|
|
4
|
+
"overrides": [
|
|
5
|
+
{
|
|
6
|
+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
|
7
|
+
"rules": {}
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"files": ["*.ts", "*.tsx"],
|
|
11
|
+
"rules": {}
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"files": ["*.js", "*.jsx"],
|
|
15
|
+
"rules": {}
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
displayName: string;
|
|
3
|
+
preset: string;
|
|
4
|
+
transform: {
|
|
5
|
+
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': string;
|
|
6
|
+
'^.+\\.[tj]sx?$': (string | {
|
|
7
|
+
presets: string[];
|
|
8
|
+
})[];
|
|
9
|
+
};
|
|
10
|
+
moduleFileExtensions: string[];
|
|
11
|
+
coverageDirectory: string;
|
|
12
|
+
};
|
|
13
|
+
export default _default;
|
|
14
|
+
//# sourceMappingURL=jest.config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest.config.d.ts","sourceRoot":"","sources":["../../../../../src/generators/add-application/templates/interactive-playground/jest.config.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,wBASE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
exports.default = {
|
|
5
|
+
displayName: 'admin',
|
|
6
|
+
preset: '../../../jest.preset.js',
|
|
7
|
+
transform: {
|
|
8
|
+
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
|
|
9
|
+
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }],
|
|
10
|
+
},
|
|
11
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
|
|
12
|
+
coverageDirectory: '../../../coverage/unisphere/applications/admin',
|
|
13
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "unisphere-application-<%= applicationName__lowerDashCase %>",
|
|
3
|
+
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "unisphere/applications/<%= applicationName__lowerDashCase %>/src",
|
|
5
|
+
"projectType": "application",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"// targets": "to see all targets run: nx show project unisphere-application-<%= applicationName__lowerDashCase %> --web",
|
|
8
|
+
"targets": {}
|
|
9
|
+
}
|