@unisphere/cli 1.21.1 → 1.22.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/bundler/package/rollup.js +4 -4
- package/bundler/{context → runtime}/rollup.js +6 -6
- package/package.json +4 -6
- package/src/lib/commands/check/command.js +27 -27
- package/src/lib/commands/create/command.d.ts +0 -2
- package/src/lib/commands/create/command.js +134 -84
- package/src/lib/commands/create/command.js.map +1 -1
- package/src/lib/commands/how-to/command.js +15 -15
- package/src/lib/commands/info/command.js +6 -6
- package/src/lib/commands/local/list/command.js +22 -13
- package/src/lib/commands/local/list/command.js.map +1 -1
- package/src/lib/commands/package/publish/publish.js +1 -1
- package/src/lib/commands/{context → runtime}/build-command.js +12 -12
- package/src/lib/commands/{context → runtime}/build-command.js.map +1 -1
- package/src/lib/commands/runtime/command.js +17 -0
- package/src/lib/commands/runtime/command.js.map +1 -0
- package/src/lib/commands/{context → runtime}/publish/command.js +5 -5
- package/src/lib/commands/{context → runtime}/publish/command.js.map +1 -1
- package/src/lib/commands/{context → runtime}/publish/execute/execute.js +10 -10
- package/src/lib/commands/{context → runtime}/publish/execute/execute.js.map +1 -1
- package/src/lib/commands/{context → runtime}/publish/execute/sync-element.js.map +1 -1
- package/src/lib/commands/{context → runtime}/publish/prepare/build-nx-runtimes.d.ts +2 -2
- package/src/lib/commands/{context → runtime}/publish/prepare/build-nx-runtimes.js +14 -14
- package/src/lib/commands/{context → runtime}/publish/prepare/build-nx-runtimes.js.map +1 -1
- package/src/lib/commands/{context → runtime}/publish/prepare/prepare.js +14 -14
- package/src/lib/commands/{context → runtime}/publish/prepare/prepare.js.map +1 -1
- package/src/lib/commands/runtime/publish/types.js.map +1 -0
- package/src/lib/commands/runtime/serve-command.js +168 -0
- package/src/lib/commands/runtime/serve-command.js.map +1 -0
- package/src/lib/commands/{runtime → runtime-json}/activate/check-element-runtime-availability.d.ts +2 -2
- package/src/lib/commands/{runtime → runtime-json}/activate/check-element-runtime-availability.js +2 -2
- package/src/lib/commands/runtime-json/activate/check-element-runtime-availability.js.map +1 -0
- package/src/lib/commands/runtime-json/activate/command.js +16 -0
- package/src/lib/commands/runtime-json/activate/command.js.map +1 -0
- package/src/lib/commands/{runtime → runtime-json}/activate/loader/command.js +1 -1
- package/src/lib/commands/runtime-json/activate/loader/command.js.map +1 -0
- package/src/lib/commands/runtime-json/activate/runtime/command.d.ts +2 -0
- package/src/lib/commands/{runtime/activate/context → runtime-json/activate/runtime}/command.js +13 -13
- package/src/lib/commands/runtime-json/activate/runtime/command.js.map +1 -0
- package/src/lib/commands/{runtime → runtime-json}/activate/update-element-runtime-version.d.ts +4 -4
- package/src/lib/commands/{runtime → runtime-json}/activate/update-element-runtime-version.js +14 -12
- package/src/lib/commands/runtime-json/activate/update-element-runtime-version.js.map +1 -0
- package/src/lib/commands/{runtime → runtime-json}/activate/workspace/command.js +1 -1
- package/src/lib/commands/runtime-json/activate/workspace/command.js.map +1 -0
- package/src/lib/commands/runtime-json/command.d.ts +2 -0
- package/src/lib/commands/runtime-json/command.js +15 -0
- package/src/lib/commands/runtime-json/command.js.map +1 -0
- package/src/lib/commands/runtime-json/replace-command.d.ts +2 -0
- package/src/lib/commands/{runtime/replace-json-command.js → runtime-json/replace-command.js} +5 -5
- package/src/lib/commands/runtime-json/replace-command.js.map +1 -0
- package/src/lib/commands/{runtime → runtime-json}/unisphere-runtime-json-v1.d.ts +2 -2
- package/src/lib/commands/runtime-json/unisphere-runtime-json-v1.js.map +1 -0
- package/src/lib/commands/{runtime → runtime-json}/unisphere-runtime-json-v2.d.ts +11 -9
- package/src/lib/commands/{runtime → runtime-json}/unisphere-runtime-json-v2.js +26 -28
- package/src/lib/commands/runtime-json/unisphere-runtime-json-v2.js.map +1 -0
- package/src/lib/commands/runtime-json/verify-env-readiness.js.map +1 -0
- package/src/lib/unisphere.js +6 -6
- package/src/lib/unisphere.js.map +1 -1
- package/src/lib/utils/unisphere/augment-workspace-config.js +7 -8
- package/src/lib/utils/unisphere/augment-workspace-config.js.map +1 -1
- package/src/lib/utils/unisphere/build-unisphere-elements.d.ts +3 -3
- package/src/lib/utils/unisphere/build-unisphere-elements.js +5 -5
- package/src/lib/utils/unisphere/reset-env.js +3 -3
- package/src/lib/utils/unisphere/types.d.ts +11 -11
- package/src/lib/utils/unisphere/types.js +2 -2
- package/src/lib/utils/unisphere-utils.d.ts +1 -1
- package/src/lib/utils/unisphere-utils.js +4 -4
- package/src/lib/utils/unisphere-utils.js.map +1 -1
- package/src/lib/utils/utils.d.ts +1 -1
- package/src/lib/utils/utils.js +3 -3
- package/src/lib/commands/context/context-commands.d.ts +0 -2
- package/src/lib/commands/context/context-commands.js +0 -17
- package/src/lib/commands/context/context-commands.js.map +0 -1
- package/src/lib/commands/context/publish/types.js.map +0 -1
- package/src/lib/commands/context/serve-command.js +0 -98
- package/src/lib/commands/context/serve-command.js.map +0 -1
- package/src/lib/commands/runtime/activate/check-element-runtime-availability.js.map +0 -1
- package/src/lib/commands/runtime/activate/command.js +0 -16
- package/src/lib/commands/runtime/activate/command.js.map +0 -1
- package/src/lib/commands/runtime/activate/context/command.d.ts +0 -2
- package/src/lib/commands/runtime/activate/context/command.js.map +0 -1
- package/src/lib/commands/runtime/activate/loader/command.js.map +0 -1
- package/src/lib/commands/runtime/activate/update-element-runtime-version.js.map +0 -1
- package/src/lib/commands/runtime/activate/workspace/command.js.map +0 -1
- package/src/lib/commands/runtime/migrate/command.d.ts +0 -0
- package/src/lib/commands/runtime/migrate/command.js +0 -49
- package/src/lib/commands/runtime/migrate/command.js.map +0 -1
- package/src/lib/commands/runtime/replace-json-command.d.ts +0 -2
- package/src/lib/commands/runtime/replace-json-command.js.map +0 -1
- package/src/lib/commands/runtime/runtime-commands.js +0 -15
- package/src/lib/commands/runtime/runtime-commands.js.map +0 -1
- package/src/lib/commands/runtime/unisphere-runtime-json-v1.js.map +0 -1
- package/src/lib/commands/runtime/unisphere-runtime-json-v2.js.map +0 -1
- package/src/lib/commands/runtime/verify-env-readiness.js.map +0 -1
- /package/src/lib/commands/{context → runtime}/build-command.d.ts +0 -0
- /package/src/lib/commands/runtime/{runtime-commands.d.ts → command.d.ts} +0 -0
- /package/src/lib/commands/{context → runtime}/publish/command.d.ts +0 -0
- /package/src/lib/commands/{context → runtime}/publish/execute/execute.d.ts +0 -0
- /package/src/lib/commands/{context → runtime}/publish/execute/sync-element.d.ts +0 -0
- /package/src/lib/commands/{context → runtime}/publish/execute/sync-element.js +0 -0
- /package/src/lib/commands/{context → runtime}/publish/prepare/prepare.d.ts +0 -0
- /package/src/lib/commands/{context → runtime}/publish/types.d.ts +0 -0
- /package/src/lib/commands/{context → runtime}/publish/types.js +0 -0
- /package/src/lib/commands/{context → runtime}/serve-command.d.ts +0 -0
- /package/src/lib/commands/{runtime → runtime-json}/activate/command.d.ts +0 -0
- /package/src/lib/commands/{runtime → runtime-json}/activate/loader/command.d.ts +0 -0
- /package/src/lib/commands/{runtime → runtime-json}/activate/workspace/command.d.ts +0 -0
- /package/src/lib/commands/{runtime → runtime-json}/unisphere-runtime-json-v1.js +0 -0
- /package/src/lib/commands/{runtime → runtime-json}/verify-env-readiness.d.ts +0 -0
- /package/src/lib/commands/{runtime → runtime-json}/verify-env-readiness.js +0 -0
|
@@ -12,14 +12,14 @@ const { envVariables, isUnisphereEnvironment } = getEnvVariables();
|
|
|
12
12
|
|
|
13
13
|
if (!isUnisphereEnvironment) {
|
|
14
14
|
console.warn(
|
|
15
|
-
'WARNING: Building or linting unisphere elements from outside the unisphere cli will not handle
|
|
15
|
+
'WARNING: Building or linting unisphere elements from outside the unisphere cli will not handle runtimes.'
|
|
16
16
|
);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
console.log('[unisphere] Helpful Tip: When running a build if it is using outdated rollup file, you should clear the nx cache by running `rm -rf node_modules/.cache/nx && npx nx reset`.');
|
|
20
20
|
|
|
21
|
-
const
|
|
22
|
-
console.log(`Building the package in '${
|
|
21
|
+
const isDeployingRuntime = envVariables.UNISPHERE_MODE === 'runtime';
|
|
22
|
+
console.log(`Building the package in '${isDeployingRuntime ? 'runtime' : 'package'}' mode`);
|
|
23
23
|
|
|
24
24
|
const withUnisphere = (config) => {
|
|
25
25
|
console.log('[unisphere] removing unisphere config used to monkey patch @nw/rollup');
|
|
@@ -35,7 +35,7 @@ const withUnisphere = (config) => {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
const externalFn = config.external;
|
|
38
|
-
if (
|
|
38
|
+
if (isDeployingRuntime) {
|
|
39
39
|
config.external = (id, parent) => {
|
|
40
40
|
if (id.includes(`node_modules`)) {
|
|
41
41
|
return true;
|
|
@@ -16,10 +16,10 @@ const { envVariables, isUnisphereEnvironment } = getEnvVariables();
|
|
|
16
16
|
|
|
17
17
|
if (!isUnisphereEnvironment) {
|
|
18
18
|
console.warn(
|
|
19
|
-
'WARNING: Building or linting unisphere elements from outside the unisphere cli will not handle
|
|
19
|
+
'WARNING: Building or linting unisphere elements from outside the unisphere cli will not handle runtimes.'
|
|
20
20
|
);
|
|
21
21
|
}
|
|
22
|
-
const
|
|
22
|
+
const isDeployingRuntime = envVariables.UNISPHERE_MODE === 'runtime';
|
|
23
23
|
|
|
24
24
|
const isProduction = envVariables.UNISPHERE_ENV === 'production';
|
|
25
25
|
|
|
@@ -30,7 +30,7 @@ const getUnisphereTSInterceptorsConfig = (unispherePackagesDistList) => {
|
|
|
30
30
|
return {
|
|
31
31
|
interceptors: {
|
|
32
32
|
compilerOptions : (options) => {
|
|
33
|
-
// Monkey patch TS paths for shared libraries to be consumed by
|
|
33
|
+
// Monkey patch TS paths for shared libraries to be consumed by runtimes from dist like other dependencies
|
|
34
34
|
const projectPackages = unispherePackagesDistList.reduce((acc, item) => {
|
|
35
35
|
acc[item.packageName] = [item.distPath];
|
|
36
36
|
return acc;
|
|
@@ -81,7 +81,7 @@ const getWithNx = (unisphereConfig) => {
|
|
|
81
81
|
]
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
if (
|
|
84
|
+
if (isDeployingRuntime) {
|
|
85
85
|
const unispherePackagesDistList = getUnispherePackagesDistList(unisphereConfig.workspaceConfiguration.cwd);
|
|
86
86
|
|
|
87
87
|
secondArgument.unisphere = getUnisphereTSInterceptorsConfig(unispherePackagesDistList);
|
|
@@ -185,10 +185,10 @@ module.exports = (unisphereConfig) => {
|
|
|
185
185
|
const projectJson = JSON.parse(fs.readFileSync(projectJsonPath, 'utf8'));
|
|
186
186
|
const sourcePath = projectJson.sourceRoot.replace(/\/src$/, '').split('/');
|
|
187
187
|
|
|
188
|
-
const expectedType = (unisphereConfig.allowedType || '
|
|
188
|
+
const expectedType = (unisphereConfig.allowedType || 'runtimes');
|
|
189
189
|
const pathCheck = unisphereConfig.bypassPathHierarchyCheck ? true : (sourcePath.length === 3);
|
|
190
190
|
if (!pathCheck || sourcePath[0] !== 'unisphere' || sourcePath[1] !== expectedType) {
|
|
191
|
-
throw new Error(`sourcePath must follow pattern unisphere/${expectedType}/<
|
|
191
|
+
throw new Error(`sourcePath must follow pattern unisphere/${expectedType}/<runtime-name>, got ${sourcePath.join('/')}`)
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
// todo can improve code readability by moving the calculation of the 'outputPath' here instead of in getWithNx
|
package/package.json
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unisphere/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.1",
|
|
4
4
|
"bin": {
|
|
5
5
|
"unisphere": "./src/index.js"
|
|
6
6
|
},
|
|
7
|
-
"scripts": {
|
|
8
|
-
"postinstall": "node ./src/index.js reset --verbose --cwd=\"${INIT_CWD:-%INIT_CWD%}\" --only-rollup > reset.log 2>&1"
|
|
9
|
-
},
|
|
7
|
+
"scripts": {},
|
|
10
8
|
"private": false,
|
|
11
9
|
"publishConfig": {
|
|
12
10
|
"access": "public"
|
|
@@ -38,9 +36,9 @@
|
|
|
38
36
|
"listr2": "8.2.5",
|
|
39
37
|
"colorette": "2.0.20",
|
|
40
38
|
"cli-table3": "0.6.5",
|
|
41
|
-
"fs-extra": "10.1.0",
|
|
42
|
-
"execa": "5.1.1",
|
|
43
39
|
"@octokit/rest": "19.0.5",
|
|
40
|
+
"execa": "5.1.1",
|
|
41
|
+
"fs-extra": "10.1.0",
|
|
44
42
|
"@aws-sdk/client-s3": "3.216.0",
|
|
45
43
|
"@aws-sdk/client-sts": "3.216.0",
|
|
46
44
|
"sisteransi": "1.0.5",
|
|
@@ -61,7 +61,7 @@ const createCheckCommand = () => {
|
|
|
61
61
|
tasks.add({
|
|
62
62
|
title: `Checking workspace`,
|
|
63
63
|
task: (ctx, task) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
-
return (0, build_unisphere_elements_1.
|
|
64
|
+
return (0, build_unisphere_elements_1.createListrForBuildingUnisphereRuntime)({
|
|
65
65
|
cwd,
|
|
66
66
|
nxProjectName: ctx.workspace.config.elements.workspace.nxProjectName,
|
|
67
67
|
parentTask: task,
|
|
@@ -73,7 +73,7 @@ const createCheckCommand = () => {
|
|
|
73
73
|
// type: 'workspace',
|
|
74
74
|
// name: 'workspace',
|
|
75
75
|
// command:
|
|
76
|
-
// 'npx unisphere
|
|
76
|
+
// 'npx unisphere runtime build workspace --verbose',
|
|
77
77
|
// status: false,
|
|
78
78
|
// },
|
|
79
79
|
// },
|
|
@@ -82,7 +82,7 @@ const createCheckCommand = () => {
|
|
|
82
82
|
task: () => {
|
|
83
83
|
ctx.report.workspace = {
|
|
84
84
|
name: 'workspace',
|
|
85
|
-
command: 'npx unisphere
|
|
85
|
+
command: 'npx unisphere runtime build workspace --verbose',
|
|
86
86
|
status: true,
|
|
87
87
|
operation: 'lint & build',
|
|
88
88
|
};
|
|
@@ -96,7 +96,7 @@ const createCheckCommand = () => {
|
|
|
96
96
|
tasks.add({
|
|
97
97
|
title: `Checking loader`,
|
|
98
98
|
task: (ctx, task) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
99
|
-
return (0, build_unisphere_elements_1.
|
|
99
|
+
return (0, build_unisphere_elements_1.createListrForBuildingUnisphereRuntime)({
|
|
100
100
|
cwd,
|
|
101
101
|
nxProjectName: ctx.workspace.config.elements.loader.nxProjectName,
|
|
102
102
|
parentTask: task,
|
|
@@ -108,7 +108,7 @@ const createCheckCommand = () => {
|
|
|
108
108
|
// type: 'loader',
|
|
109
109
|
// name: 'loader',
|
|
110
110
|
// command:
|
|
111
|
-
// 'npx unisphere
|
|
111
|
+
// 'npx unisphere runtime build loader --verbose',
|
|
112
112
|
// status: false,
|
|
113
113
|
// },
|
|
114
114
|
// },
|
|
@@ -117,7 +117,7 @@ const createCheckCommand = () => {
|
|
|
117
117
|
task: () => {
|
|
118
118
|
ctx.report.loader = {
|
|
119
119
|
name: 'loader',
|
|
120
|
-
command: 'npx unisphere
|
|
120
|
+
command: 'npx unisphere runtime build loader --verbose',
|
|
121
121
|
status: true,
|
|
122
122
|
operation: 'lint & build',
|
|
123
123
|
};
|
|
@@ -182,9 +182,9 @@ const createCheckCommand = () => {
|
|
|
182
182
|
},
|
|
183
183
|
},
|
|
184
184
|
{
|
|
185
|
-
title: `Checking
|
|
185
|
+
title: `Checking runtimes elements readiness`,
|
|
186
186
|
skip: (ctx) => {
|
|
187
|
-
return (Object.keys(ctx.workspace.config.elements.
|
|
187
|
+
return (Object.keys(ctx.workspace.config.elements.runtimes || {})
|
|
188
188
|
.length === 0);
|
|
189
189
|
},
|
|
190
190
|
task: (ctx, task) => {
|
|
@@ -192,32 +192,32 @@ const createCheckCommand = () => {
|
|
|
192
192
|
concurrent: false,
|
|
193
193
|
exitOnError: false,
|
|
194
194
|
});
|
|
195
|
-
if (ctx.workspace.config.elements.
|
|
196
|
-
for (const [
|
|
195
|
+
if (ctx.workspace.config.elements.runtimes) {
|
|
196
|
+
for (const [runtimeName, runtimeConfig] of Object.entries(ctx.workspace.config.elements.runtimes)) {
|
|
197
197
|
tasks.add({
|
|
198
|
-
title: `Checking
|
|
198
|
+
title: `Checking runtime '${runtimeName}'`,
|
|
199
199
|
task: (ctx, task) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
200
|
-
return (0, build_unisphere_elements_1.
|
|
200
|
+
return (0, build_unisphere_elements_1.createListrForBuildingUnisphereRuntime)({
|
|
201
201
|
cwd,
|
|
202
|
-
nxProjectName:
|
|
202
|
+
nxProjectName: runtimeConfig.nxProjectName,
|
|
203
203
|
parentTask: task,
|
|
204
204
|
production: options.production,
|
|
205
205
|
lint: false,
|
|
206
206
|
verbose: options.verbose,
|
|
207
207
|
// ctx: {
|
|
208
208
|
// failure: {
|
|
209
|
-
// type: '
|
|
210
|
-
// name:
|
|
211
|
-
// command: `npx unisphere
|
|
209
|
+
// type: 'runtime',
|
|
210
|
+
// name: runtimeName,
|
|
211
|
+
// command: `npx unisphere runtime build ${runtimeName} --verbose`,
|
|
212
212
|
// status: false,
|
|
213
213
|
// },
|
|
214
214
|
// },
|
|
215
215
|
postTask: {
|
|
216
216
|
title: 'Reporting success',
|
|
217
217
|
task: () => {
|
|
218
|
-
ctx.report.
|
|
219
|
-
name:
|
|
220
|
-
command: `npx unisphere
|
|
218
|
+
ctx.report.runtimes.push({
|
|
219
|
+
name: runtimeName,
|
|
220
|
+
command: `npx unisphere runtime build ${runtimeName} --verbose`,
|
|
221
221
|
status: true,
|
|
222
222
|
operation: 'lint & build',
|
|
223
223
|
});
|
|
@@ -245,7 +245,7 @@ const createCheckCommand = () => {
|
|
|
245
245
|
.split(' ');
|
|
246
246
|
const operation = error.path[2].replace(/^Running (.*?)$/, '$1');
|
|
247
247
|
const resolveElementType = ['workspace', 'loader'].includes(elementType || '')
|
|
248
|
-
? '
|
|
248
|
+
? 'runtime'
|
|
249
249
|
: elementType;
|
|
250
250
|
const failure = {
|
|
251
251
|
name: elementName || error.path[1],
|
|
@@ -265,8 +265,8 @@ const createCheckCommand = () => {
|
|
|
265
265
|
case 'loader':
|
|
266
266
|
ctx.report.loader = failure;
|
|
267
267
|
break;
|
|
268
|
-
case '
|
|
269
|
-
ctx.report.
|
|
268
|
+
case 'runtime':
|
|
269
|
+
ctx.report.runtimes.push(failure);
|
|
270
270
|
break;
|
|
271
271
|
case 'package':
|
|
272
272
|
ctx.report.packages.push(failure);
|
|
@@ -339,19 +339,19 @@ const createCheckCommand = () => {
|
|
|
339
339
|
]);
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
|
-
if (ctx.report.
|
|
342
|
+
if (ctx.report.runtimes.length > 0) {
|
|
343
343
|
table.push([
|
|
344
344
|
{
|
|
345
345
|
hAlign: 'center',
|
|
346
346
|
colSpan: 4,
|
|
347
|
-
content: (0, colorette_1.bold)((0, colorette_1.green)('
|
|
347
|
+
content: (0, colorette_1.bold)((0, colorette_1.green)('Runtimes')),
|
|
348
348
|
},
|
|
349
349
|
]);
|
|
350
350
|
for (const { operation, name, command, status } of ctx.report
|
|
351
|
-
.
|
|
351
|
+
.runtimes) {
|
|
352
352
|
table.push([
|
|
353
353
|
(0, colorette_1.bold)(name),
|
|
354
|
-
'
|
|
354
|
+
'Runtime',
|
|
355
355
|
status
|
|
356
356
|
? (0, colorette_1.green)('OK')
|
|
357
357
|
: (0, colorette_1.red)(`${operation.toUpperCase()} FAILED`),
|
|
@@ -396,7 +396,7 @@ const createCheckCommand = () => {
|
|
|
396
396
|
workspace: null,
|
|
397
397
|
loader: null,
|
|
398
398
|
packages: [],
|
|
399
|
-
|
|
399
|
+
runtimes: [],
|
|
400
400
|
unknown: [],
|
|
401
401
|
},
|
|
402
402
|
workspace: null,
|
|
@@ -1,85 +1,135 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
1
|
+
// import { Command } from 'commander';
|
|
2
|
+
// import Debug from 'debug';
|
|
3
|
+
// import { Listr, ListrTask } from 'listr2';
|
|
4
|
+
// import { printVerboseHook } from '../../utils/utils';
|
|
5
|
+
// import { getDefaultListrOptions } from '../../utils/listr2/defaults';
|
|
6
|
+
// import { resolve, join, basename, dirname } from 'path';
|
|
7
|
+
// import {
|
|
8
|
+
// existsSync,
|
|
9
|
+
// mkdirSync,
|
|
10
|
+
// readdirSync,
|
|
11
|
+
// readFileSync,
|
|
12
|
+
// writeFileSync,
|
|
13
|
+
// } from 'fs';
|
|
14
|
+
// import { compile } from 'handlebars';
|
|
15
|
+
// const debug = Debug('unisphere:create');
|
|
16
|
+
// const ignoreFiles = ['.DS_Store'];
|
|
17
|
+
// function processTemplate(content: string, data: any): string {
|
|
18
|
+
// const template = compile(content);
|
|
19
|
+
// return template(data);
|
|
20
|
+
// }
|
|
21
|
+
// function processFileName(fileName: string, data: any): string {
|
|
22
|
+
// if (fileName.includes('{{')) {
|
|
23
|
+
// return processTemplate(fileName, data);
|
|
24
|
+
// }
|
|
25
|
+
// return fileName;
|
|
26
|
+
// }
|
|
27
|
+
// function copyTemplateDirectory(
|
|
28
|
+
// sourcePath: string,
|
|
29
|
+
// targetPath: string,
|
|
30
|
+
// data: any
|
|
31
|
+
// ) {
|
|
32
|
+
// if (!existsSync(sourcePath)) {
|
|
33
|
+
// throw new Error(`Template directory "${sourcePath}" does not exist.`);
|
|
34
|
+
// }
|
|
35
|
+
// if (!existsSync(targetPath)) {
|
|
36
|
+
// debug(`Creating target directory: ${targetPath}`);
|
|
37
|
+
// mkdirSync(targetPath, { recursive: true });
|
|
38
|
+
// }
|
|
39
|
+
// const files = readdirSync(sourcePath, { withFileTypes: true });
|
|
40
|
+
// for (const file of files) {
|
|
41
|
+
// if (ignoreFiles.includes(file.name)) {
|
|
42
|
+
// debug(`Skipping file: ${file.name}`);
|
|
43
|
+
// continue;
|
|
44
|
+
// }
|
|
45
|
+
// const sourceFilePath = join(sourcePath, file.name);
|
|
46
|
+
// const processedFileName = processFileName(file.name, data);
|
|
47
|
+
// const targetFilePath = join(targetPath, processedFileName);
|
|
48
|
+
// if (file.isDirectory()) {
|
|
49
|
+
// debug(`Processing directory: ${file.name}`);
|
|
50
|
+
// copyTemplateDirectory(sourceFilePath, targetFilePath, data);
|
|
51
|
+
// } else {
|
|
52
|
+
// debug(`Processing file: ${file.name}`);
|
|
53
|
+
// const content = readFileSync(sourceFilePath, 'utf-8');
|
|
54
|
+
// const processedContent = processTemplate(content, data);
|
|
55
|
+
// writeFileSync(targetFilePath, processedContent);
|
|
56
|
+
// }
|
|
57
|
+
// }
|
|
58
|
+
// }
|
|
59
|
+
// export const createCreateCommand = (): Command => {
|
|
60
|
+
// const command = new Command('create');
|
|
61
|
+
// command
|
|
62
|
+
// .description('create a new unisphere project')
|
|
63
|
+
// .argument('<widget-name>', 'The name of the widget project')
|
|
64
|
+
// .option('--cwd <path>', 'The working directory', process.cwd())
|
|
65
|
+
// .option(
|
|
66
|
+
// '--templates-path <path>',
|
|
67
|
+
// 'The path to the templates directory',
|
|
68
|
+
// resolve(process.cwd(), '_templates')
|
|
69
|
+
// )
|
|
70
|
+
// .option('--verbose', 'Output debug logs', false)
|
|
71
|
+
// .hook('preAction', printVerboseHook)
|
|
72
|
+
// .action(async (widgetName, options) => {
|
|
73
|
+
// const cwd = resolve(options.cwd || process.cwd());
|
|
74
|
+
// const formattedWidgetName = widgetName
|
|
75
|
+
// .replace(/[\s-_]+/g, '') // Normalize widget name
|
|
76
|
+
// .replace(/^./, (char) => char.toLowerCase()); // Lowercase first letter
|
|
77
|
+
// const widgetPath = resolve(cwd, formattedWidgetName);
|
|
78
|
+
// const templatesPath = options.templatesPath;
|
|
79
|
+
// debug(`Using templates from: ${templatesPath}`);
|
|
80
|
+
// const tasks: ListrTask[] = [
|
|
81
|
+
// {
|
|
82
|
+
// title: 'Check if the working directory exists',
|
|
83
|
+
// task: () => {
|
|
84
|
+
// if (!existsSync(cwd)) {
|
|
85
|
+
// throw new Error(`Working directory "${cwd}" does not exist.`);
|
|
86
|
+
// }
|
|
87
|
+
// },
|
|
88
|
+
// },
|
|
89
|
+
// {
|
|
90
|
+
// title: 'Check if widget path exists',
|
|
91
|
+
// task: () => {
|
|
92
|
+
// if (existsSync(widgetPath)) {
|
|
93
|
+
// throw new Error(`Path "${widgetPath}" already exists.`);
|
|
94
|
+
// }
|
|
95
|
+
// },
|
|
96
|
+
// },
|
|
97
|
+
// {
|
|
98
|
+
// title: 'Create project folder',
|
|
99
|
+
// task: () => {
|
|
100
|
+
// mkdirSync(widgetPath, { recursive: true });
|
|
101
|
+
// debug(`Created project folder: ${widgetPath}`);
|
|
102
|
+
// },
|
|
103
|
+
// },
|
|
104
|
+
// {
|
|
105
|
+
// title: 'Generate project from templates',
|
|
106
|
+
// task: () => {
|
|
107
|
+
// const templateDir = resolve(templatesPath, 'new-project');
|
|
108
|
+
// const templateData = {
|
|
109
|
+
// widgetName: formattedWidgetName,
|
|
110
|
+
// WidgetName:
|
|
111
|
+
// formattedWidgetName.charAt(0).toUpperCase() +
|
|
112
|
+
// formattedWidgetName.slice(1),
|
|
113
|
+
// };
|
|
114
|
+
// debug(`Copying templates from: ${templateDir} to ${widgetPath}`);
|
|
115
|
+
// copyTemplateDirectory(templateDir, widgetPath, templateData);
|
|
116
|
+
// },
|
|
117
|
+
// },
|
|
118
|
+
// // {
|
|
119
|
+
// // title: 'Run npm install',
|
|
120
|
+
// // task: () => {
|
|
121
|
+
// // try {
|
|
122
|
+
// // execSync('npm install', { cwd: widgetPath, stdio: 'inherit' });
|
|
123
|
+
// // debug('Dependencies installed successfully.');
|
|
124
|
+
// // } catch (error) {
|
|
125
|
+
// // throw new Error(`npm install failed: ${error.message}`);
|
|
126
|
+
// // }
|
|
127
|
+
// // },
|
|
128
|
+
// // },
|
|
129
|
+
// ];
|
|
130
|
+
// const taskRunner = new Listr(tasks, getDefaultListrOptions());
|
|
131
|
+
// await taskRunner.run();
|
|
132
|
+
// });
|
|
133
|
+
// return command;
|
|
134
|
+
// };
|
|
85
135
|
//# sourceMappingURL=command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../../../../../packages/unisphere-cli/src/lib/commands/create/command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../../../../../packages/unisphere-cli/src/lib/commands/create/command.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,6BAA6B;AAC7B,6CAA6C;AAC7C,wDAAwD;AACxD,wEAAwE;AACxE,2DAA2D;AAC3D,WAAW;AACX,gBAAgB;AAChB,eAAe;AACf,iBAAiB;AACjB,kBAAkB;AAClB,mBAAmB;AACnB,eAAe;AACf,wCAAwC;AAExC,2CAA2C;AAE3C,qCAAqC;AACrC,iEAAiE;AACjE,uCAAuC;AACvC,2BAA2B;AAC3B,IAAI;AAEJ,kEAAkE;AAClE,mCAAmC;AACnC,8CAA8C;AAC9C,MAAM;AACN,qBAAqB;AACrB,IAAI;AAEJ,kCAAkC;AAClC,wBAAwB;AACxB,wBAAwB;AACxB,cAAc;AACd,MAAM;AACN,mCAAmC;AACnC,6EAA6E;AAC7E,MAAM;AAEN,mCAAmC;AACnC,yDAAyD;AACzD,kDAAkD;AAClD,MAAM;AAEN,oEAAoE;AAEpE,gCAAgC;AAChC,6CAA6C;AAC7C,8CAA8C;AAC9C,kBAAkB;AAClB,QAAQ;AAER,0DAA0D;AAC1D,kEAAkE;AAClE,kEAAkE;AAElE,gCAAgC;AAChC,qDAAqD;AACrD,qEAAqE;AACrE,eAAe;AACf,gDAAgD;AAChD,+DAA+D;AAC/D,iEAAiE;AACjE,yDAAyD;AACzD,QAAQ;AACR,MAAM;AACN,IAAI;AAEJ,sDAAsD;AACtD,2CAA2C;AAE3C,YAAY;AACZ,qDAAqD;AACrD,mEAAmE;AACnE,sEAAsE;AACtE,eAAe;AACf,mCAAmC;AACnC,+CAA+C;AAC/C,6CAA6C;AAC7C,QAAQ;AACR,uDAAuD;AACvD,2CAA2C;AAC3C,+CAA+C;AAC/C,2DAA2D;AAC3D,+CAA+C;AAC/C,4DAA4D;AAC5D,kFAAkF;AAElF,8DAA8D;AAC9D,qDAAqD;AAErD,yDAAyD;AAEzD,qCAAqC;AACrC,YAAY;AACZ,4DAA4D;AAC5D,0BAA0B;AAC1B,sCAAsC;AACtC,+EAA+E;AAC/E,gBAAgB;AAChB,eAAe;AACf,aAAa;AACb,YAAY;AACZ,kDAAkD;AAClD,0BAA0B;AAC1B,4CAA4C;AAC5C,yEAAyE;AACzE,gBAAgB;AAChB,eAAe;AACf,aAAa;AACb,YAAY;AACZ,4CAA4C;AAC5C,0BAA0B;AAC1B,0DAA0D;AAC1D,8DAA8D;AAC9D,eAAe;AACf,aAAa;AACb,YAAY;AACZ,sDAAsD;AACtD,0BAA0B;AAC1B,yEAAyE;AACzE,qCAAqC;AACrC,iDAAiD;AACjD,4BAA4B;AAC5B,gEAAgE;AAChE,gDAAgD;AAChD,iBAAiB;AAEjB,gFAAgF;AAChF,4EAA4E;AAC5E,eAAe;AACf,aAAa;AACb,eAAe;AACf,yCAAyC;AACzC,6BAA6B;AAC7B,uBAAuB;AACvB,mFAAmF;AACnF,kEAAkE;AAClE,mCAAmC;AACnC,4EAA4E;AAC5E,mBAAmB;AACnB,kBAAkB;AAClB,gBAAgB;AAChB,WAAW;AAEX,uEAAuE;AACvE,gCAAgC;AAChC,UAAU;AAEV,oBAAoB;AACpB,KAAK"}
|
|
@@ -105,7 +105,7 @@ in the target project directory and then choose the desired package command`),
|
|
|
105
105
|
table.push([
|
|
106
106
|
(0, colorette_1.bold)('Build'),
|
|
107
107
|
'Build the workspace',
|
|
108
|
-
'npx unisphere
|
|
108
|
+
'npx unisphere runtime build workspace',
|
|
109
109
|
]);
|
|
110
110
|
table.push([
|
|
111
111
|
(0, colorette_1.bold)('Lint'),
|
|
@@ -115,12 +115,12 @@ in the target project directory and then choose the desired package command`),
|
|
|
115
115
|
table.push([
|
|
116
116
|
(0, colorette_1.bold)('Serve'),
|
|
117
117
|
'Serve the workspace',
|
|
118
|
-
'npx unisphere
|
|
118
|
+
'npx unisphere runtime serve workspace',
|
|
119
119
|
]);
|
|
120
120
|
table.push([
|
|
121
121
|
(0, colorette_1.bold)('Serve (custom port)'),
|
|
122
122
|
'Serve the workspace with a specific port (e.g. 8080)',
|
|
123
|
-
'npx unisphere
|
|
123
|
+
'npx unisphere runtime serve workspace --port 8080',
|
|
124
124
|
]);
|
|
125
125
|
}
|
|
126
126
|
if (ctx.workspace.config.elements.loader) {
|
|
@@ -134,7 +134,7 @@ in the target project directory and then choose the desired package command`),
|
|
|
134
134
|
table.push([
|
|
135
135
|
(0, colorette_1.bold)('Build'),
|
|
136
136
|
'Build the loader',
|
|
137
|
-
'npx unisphere
|
|
137
|
+
'npx unisphere runtime build loader',
|
|
138
138
|
]);
|
|
139
139
|
table.push([
|
|
140
140
|
(0, colorette_1.bold)('Lint'),
|
|
@@ -144,12 +144,12 @@ in the target project directory and then choose the desired package command`),
|
|
|
144
144
|
table.push([
|
|
145
145
|
(0, colorette_1.bold)('Serve'),
|
|
146
146
|
'Serve the loader',
|
|
147
|
-
'npx unisphere
|
|
147
|
+
'npx unisphere runtime serve loader',
|
|
148
148
|
]);
|
|
149
149
|
table.push([
|
|
150
150
|
(0, colorette_1.bold)('Serve with port'),
|
|
151
151
|
'Serve the loader with a specific port',
|
|
152
|
-
'npx unisphere
|
|
152
|
+
'npx unisphere runtime serve loader --port 8080',
|
|
153
153
|
]);
|
|
154
154
|
}
|
|
155
155
|
if (Object.keys(ctx.workspace.config.elements.packages || {})
|
|
@@ -175,30 +175,30 @@ in the target project directory and then choose the desired package command`),
|
|
|
175
175
|
]);
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
if (Object.keys(ctx.workspace.config.elements.
|
|
178
|
+
if (Object.keys(ctx.workspace.config.elements.runtimes || {})
|
|
179
179
|
.length > 0) {
|
|
180
|
-
for (const [name, { distributionChannel, version },] of Object.entries(ctx.workspace.config.elements.
|
|
180
|
+
for (const [name, { distributionChannel, version },] of Object.entries(ctx.workspace.config.elements.runtimes)) {
|
|
181
181
|
table.push([
|
|
182
182
|
{
|
|
183
183
|
colSpan: 3,
|
|
184
184
|
hAlign: 'center',
|
|
185
|
-
content: (0, colorette_1.bold)((0, colorette_1.green)(`
|
|
185
|
+
content: (0, colorette_1.bold)((0, colorette_1.green)(`Runtime ${name} Commands`)),
|
|
186
186
|
},
|
|
187
187
|
]);
|
|
188
188
|
table.push([
|
|
189
189
|
(0, colorette_1.bold)('Build'),
|
|
190
|
-
'Build the
|
|
191
|
-
`npx unisphere
|
|
190
|
+
'Build the runtime',
|
|
191
|
+
`npx unisphere runtime build ${name}`,
|
|
192
192
|
]);
|
|
193
193
|
table.push([
|
|
194
194
|
(0, colorette_1.bold)('Serve'),
|
|
195
|
-
'Serve the
|
|
196
|
-
`npx unisphere
|
|
195
|
+
'Serve the runtime (default port is 8300)',
|
|
196
|
+
`npx unisphere runtime serve ${name}`,
|
|
197
197
|
]);
|
|
198
198
|
table.push([
|
|
199
199
|
(0, colorette_1.bold)('Serve (custom port)'),
|
|
200
|
-
'Serve the
|
|
201
|
-
`npx unisphere
|
|
200
|
+
'Serve the runtime with a specific port (e.g. 8320)',
|
|
201
|
+
`npx unisphere runtime serve ${name} --port 8320`,
|
|
202
202
|
]);
|
|
203
203
|
}
|
|
204
204
|
}
|