@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.
Files changed (110) hide show
  1. package/bundler/package/rollup.js +4 -4
  2. package/bundler/{context → runtime}/rollup.js +6 -6
  3. package/package.json +4 -6
  4. package/src/lib/commands/check/command.js +27 -27
  5. package/src/lib/commands/create/command.d.ts +0 -2
  6. package/src/lib/commands/create/command.js +134 -84
  7. package/src/lib/commands/create/command.js.map +1 -1
  8. package/src/lib/commands/how-to/command.js +15 -15
  9. package/src/lib/commands/info/command.js +6 -6
  10. package/src/lib/commands/local/list/command.js +22 -13
  11. package/src/lib/commands/local/list/command.js.map +1 -1
  12. package/src/lib/commands/package/publish/publish.js +1 -1
  13. package/src/lib/commands/{context → runtime}/build-command.js +12 -12
  14. package/src/lib/commands/{context → runtime}/build-command.js.map +1 -1
  15. package/src/lib/commands/runtime/command.js +17 -0
  16. package/src/lib/commands/runtime/command.js.map +1 -0
  17. package/src/lib/commands/{context → runtime}/publish/command.js +5 -5
  18. package/src/lib/commands/{context → runtime}/publish/command.js.map +1 -1
  19. package/src/lib/commands/{context → runtime}/publish/execute/execute.js +10 -10
  20. package/src/lib/commands/{context → runtime}/publish/execute/execute.js.map +1 -1
  21. package/src/lib/commands/{context → runtime}/publish/execute/sync-element.js.map +1 -1
  22. package/src/lib/commands/{context → runtime}/publish/prepare/build-nx-runtimes.d.ts +2 -2
  23. package/src/lib/commands/{context → runtime}/publish/prepare/build-nx-runtimes.js +14 -14
  24. package/src/lib/commands/{context → runtime}/publish/prepare/build-nx-runtimes.js.map +1 -1
  25. package/src/lib/commands/{context → runtime}/publish/prepare/prepare.js +14 -14
  26. package/src/lib/commands/{context → runtime}/publish/prepare/prepare.js.map +1 -1
  27. package/src/lib/commands/runtime/publish/types.js.map +1 -0
  28. package/src/lib/commands/runtime/serve-command.js +168 -0
  29. package/src/lib/commands/runtime/serve-command.js.map +1 -0
  30. package/src/lib/commands/{runtime → runtime-json}/activate/check-element-runtime-availability.d.ts +2 -2
  31. package/src/lib/commands/{runtime → runtime-json}/activate/check-element-runtime-availability.js +2 -2
  32. package/src/lib/commands/runtime-json/activate/check-element-runtime-availability.js.map +1 -0
  33. package/src/lib/commands/runtime-json/activate/command.js +16 -0
  34. package/src/lib/commands/runtime-json/activate/command.js.map +1 -0
  35. package/src/lib/commands/{runtime → runtime-json}/activate/loader/command.js +1 -1
  36. package/src/lib/commands/runtime-json/activate/loader/command.js.map +1 -0
  37. package/src/lib/commands/runtime-json/activate/runtime/command.d.ts +2 -0
  38. package/src/lib/commands/{runtime/activate/context → runtime-json/activate/runtime}/command.js +13 -13
  39. package/src/lib/commands/runtime-json/activate/runtime/command.js.map +1 -0
  40. package/src/lib/commands/{runtime → runtime-json}/activate/update-element-runtime-version.d.ts +4 -4
  41. package/src/lib/commands/{runtime → runtime-json}/activate/update-element-runtime-version.js +14 -12
  42. package/src/lib/commands/runtime-json/activate/update-element-runtime-version.js.map +1 -0
  43. package/src/lib/commands/{runtime → runtime-json}/activate/workspace/command.js +1 -1
  44. package/src/lib/commands/runtime-json/activate/workspace/command.js.map +1 -0
  45. package/src/lib/commands/runtime-json/command.d.ts +2 -0
  46. package/src/lib/commands/runtime-json/command.js +15 -0
  47. package/src/lib/commands/runtime-json/command.js.map +1 -0
  48. package/src/lib/commands/runtime-json/replace-command.d.ts +2 -0
  49. package/src/lib/commands/{runtime/replace-json-command.js → runtime-json/replace-command.js} +5 -5
  50. package/src/lib/commands/runtime-json/replace-command.js.map +1 -0
  51. package/src/lib/commands/{runtime → runtime-json}/unisphere-runtime-json-v1.d.ts +2 -2
  52. package/src/lib/commands/runtime-json/unisphere-runtime-json-v1.js.map +1 -0
  53. package/src/lib/commands/{runtime → runtime-json}/unisphere-runtime-json-v2.d.ts +11 -9
  54. package/src/lib/commands/{runtime → runtime-json}/unisphere-runtime-json-v2.js +26 -28
  55. package/src/lib/commands/runtime-json/unisphere-runtime-json-v2.js.map +1 -0
  56. package/src/lib/commands/runtime-json/verify-env-readiness.js.map +1 -0
  57. package/src/lib/unisphere.js +6 -6
  58. package/src/lib/unisphere.js.map +1 -1
  59. package/src/lib/utils/unisphere/augment-workspace-config.js +7 -8
  60. package/src/lib/utils/unisphere/augment-workspace-config.js.map +1 -1
  61. package/src/lib/utils/unisphere/build-unisphere-elements.d.ts +3 -3
  62. package/src/lib/utils/unisphere/build-unisphere-elements.js +5 -5
  63. package/src/lib/utils/unisphere/reset-env.js +3 -3
  64. package/src/lib/utils/unisphere/types.d.ts +11 -11
  65. package/src/lib/utils/unisphere/types.js +2 -2
  66. package/src/lib/utils/unisphere-utils.d.ts +1 -1
  67. package/src/lib/utils/unisphere-utils.js +4 -4
  68. package/src/lib/utils/unisphere-utils.js.map +1 -1
  69. package/src/lib/utils/utils.d.ts +1 -1
  70. package/src/lib/utils/utils.js +3 -3
  71. package/src/lib/commands/context/context-commands.d.ts +0 -2
  72. package/src/lib/commands/context/context-commands.js +0 -17
  73. package/src/lib/commands/context/context-commands.js.map +0 -1
  74. package/src/lib/commands/context/publish/types.js.map +0 -1
  75. package/src/lib/commands/context/serve-command.js +0 -98
  76. package/src/lib/commands/context/serve-command.js.map +0 -1
  77. package/src/lib/commands/runtime/activate/check-element-runtime-availability.js.map +0 -1
  78. package/src/lib/commands/runtime/activate/command.js +0 -16
  79. package/src/lib/commands/runtime/activate/command.js.map +0 -1
  80. package/src/lib/commands/runtime/activate/context/command.d.ts +0 -2
  81. package/src/lib/commands/runtime/activate/context/command.js.map +0 -1
  82. package/src/lib/commands/runtime/activate/loader/command.js.map +0 -1
  83. package/src/lib/commands/runtime/activate/update-element-runtime-version.js.map +0 -1
  84. package/src/lib/commands/runtime/activate/workspace/command.js.map +0 -1
  85. package/src/lib/commands/runtime/migrate/command.d.ts +0 -0
  86. package/src/lib/commands/runtime/migrate/command.js +0 -49
  87. package/src/lib/commands/runtime/migrate/command.js.map +0 -1
  88. package/src/lib/commands/runtime/replace-json-command.d.ts +0 -2
  89. package/src/lib/commands/runtime/replace-json-command.js.map +0 -1
  90. package/src/lib/commands/runtime/runtime-commands.js +0 -15
  91. package/src/lib/commands/runtime/runtime-commands.js.map +0 -1
  92. package/src/lib/commands/runtime/unisphere-runtime-json-v1.js.map +0 -1
  93. package/src/lib/commands/runtime/unisphere-runtime-json-v2.js.map +0 -1
  94. package/src/lib/commands/runtime/verify-env-readiness.js.map +0 -1
  95. /package/src/lib/commands/{context → runtime}/build-command.d.ts +0 -0
  96. /package/src/lib/commands/runtime/{runtime-commands.d.ts → command.d.ts} +0 -0
  97. /package/src/lib/commands/{context → runtime}/publish/command.d.ts +0 -0
  98. /package/src/lib/commands/{context → runtime}/publish/execute/execute.d.ts +0 -0
  99. /package/src/lib/commands/{context → runtime}/publish/execute/sync-element.d.ts +0 -0
  100. /package/src/lib/commands/{context → runtime}/publish/execute/sync-element.js +0 -0
  101. /package/src/lib/commands/{context → runtime}/publish/prepare/prepare.d.ts +0 -0
  102. /package/src/lib/commands/{context → runtime}/publish/types.d.ts +0 -0
  103. /package/src/lib/commands/{context → runtime}/publish/types.js +0 -0
  104. /package/src/lib/commands/{context → runtime}/serve-command.d.ts +0 -0
  105. /package/src/lib/commands/{runtime → runtime-json}/activate/command.d.ts +0 -0
  106. /package/src/lib/commands/{runtime → runtime-json}/activate/loader/command.d.ts +0 -0
  107. /package/src/lib/commands/{runtime → runtime-json}/activate/workspace/command.d.ts +0 -0
  108. /package/src/lib/commands/{runtime → runtime-json}/unisphere-runtime-json-v1.js +0 -0
  109. /package/src/lib/commands/{runtime → runtime-json}/verify-env-readiness.d.ts +0 -0
  110. /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 contexts.'
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 isDeployingContext = envVariables.UNISPHERE_MODE === 'context';
22
- console.log(`Building the package in '${isDeployingContext ? 'context' : 'package'}' mode`);
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 (isDeployingContext) {
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 contexts.'
19
+ 'WARNING: Building or linting unisphere elements from outside the unisphere cli will not handle runtimes.'
20
20
  );
21
21
  }
22
- const isDeployingContext = envVariables.UNISPHERE_MODE === 'context';
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 contexts from dist like other dependencies
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 (isDeployingContext) {
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 || 'contexts');
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}/<context-name>, got ${sourcePath.join('/')}`)
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.21.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.createListrForBuildingUnisphereContext)({
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 context build workspace --verbose',
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 context build workspace --verbose',
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.createListrForBuildingUnisphereContext)({
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 context build loader --verbose',
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 context build loader --verbose',
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 contexts elements readiness`,
185
+ title: `Checking runtimes elements readiness`,
186
186
  skip: (ctx) => {
187
- return (Object.keys(ctx.workspace.config.elements.contexts || {})
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.contexts) {
196
- for (const [contextName, contextConfig] of Object.entries(ctx.workspace.config.elements.contexts)) {
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 context '${contextName}'`,
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.createListrForBuildingUnisphereContext)({
200
+ return (0, build_unisphere_elements_1.createListrForBuildingUnisphereRuntime)({
201
201
  cwd,
202
- nxProjectName: contextConfig.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: 'context',
210
- // name: contextName,
211
- // command: `npx unisphere context build ${contextName} --verbose`,
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.contexts.push({
219
- name: contextName,
220
- command: `npx unisphere context build ${contextName} --verbose`,
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
- ? 'context'
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 'context':
269
- ctx.report.contexts.push(failure);
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.contexts.length > 0) {
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)('Contexts')),
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
- .contexts) {
351
+ .runtimes) {
352
352
  table.push([
353
353
  (0, colorette_1.bold)(name),
354
- 'Context',
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
- contexts: [],
399
+ runtimes: [],
400
400
  unknown: [],
401
401
  },
402
402
  workspace: null,
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const createCreateCommand: () => Command;
@@ -1,85 +1,135 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createCreateCommand = void 0;
4
- const tslib_1 = require("tslib");
5
- const commander_1 = require("commander");
6
- const debug_1 = require("debug");
7
- const listr2_1 = require("listr2");
8
- const utils_1 = require("../../utils/utils");
9
- const defaults_1 = require("../../utils/listr2/defaults");
10
- const path_1 = require("path");
11
- const child_process_1 = require("child_process");
12
- const fs_1 = require("fs");
13
- const debug = (0, debug_1.default)('unisphere:create');
14
- const createCreateCommand = () => {
15
- const command = new commander_1.Command('create');
16
- command
17
- .description('create a new unisphere project')
18
- .argument('<widget-name>', 'The name of the widget project')
19
- .option('--cwd <path>', 'The working directory', process.cwd())
20
- .option('--templates-path <path>', 'The path to the templates directory', (0, path_1.resolve)(process.cwd(), '_templates'))
21
- .option('--verbose', 'Output debug logs', false)
22
- .hook('preAction', utils_1.printVerboseHook)
23
- .action((widgetName, options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
24
- const cwd = (0, path_1.resolve)(options.cwd || process.cwd());
25
- const formattedWidgetName = widgetName
26
- .replace(/[\s-_]+/g, '') // Normalize widget name
27
- .replace(/^./, (char) => char.toLowerCase()); // Lowercase first letter
28
- const widgetPath = (0, path_1.resolve)(cwd, formattedWidgetName);
29
- const templatesPath = options.templatesPath;
30
- debug(`Using templates from: ${templatesPath}`);
31
- const tasks = [
32
- {
33
- title: 'Check if the working directory exists',
34
- task: () => {
35
- if (!(0, fs_1.existsSync)(cwd)) {
36
- throw new Error(`Working directory "${cwd}" does not exist.`);
37
- }
38
- },
39
- },
40
- {
41
- title: 'Check if widget path exists',
42
- task: () => {
43
- if ((0, fs_1.existsSync)(widgetPath)) {
44
- throw new Error(`Path "${widgetPath}" already exists.`);
45
- }
46
- },
47
- },
48
- {
49
- title: 'Create project folder',
50
- task: () => {
51
- (0, fs_1.mkdirSync)(widgetPath, { recursive: true });
52
- debug(`Created project folder: ${widgetPath}`);
53
- },
54
- },
55
- {
56
- title: 'Generate project using Hygen',
57
- task: () => {
58
- try {
59
- // Set HYGEN_TEMPLATES to use the custom templates directory
60
- (0, child_process_1.execSync)(`HYGEN_TEMPLATES="${templatesPath}" npx hygen kme new --widgetName "${formattedWidgetName}" --cwd "${widgetPath}" --verbose`, { stdio: 'inherit' });
61
- }
62
- catch (error) {
63
- throw new Error(`Hygen execution failed: ${error.message}`);
64
- }
65
- },
66
- },
67
- // {
68
- // title: 'Run npm install',
69
- // task: () => {
70
- // try {
71
- // execSync('npm install', { cwd: widgetPath, stdio: 'inherit' });
72
- // debug('Dependencies installed successfully.');
73
- // } catch (error) {
74
- // throw new Error(`npm install failed: ${error.message}`);
75
- // }
76
- // },
77
- // },
78
- ];
79
- const taskRunner = new listr2_1.Listr(tasks, (0, defaults_1.getDefaultListrOptions)());
80
- yield taskRunner.run();
81
- }));
82
- return command;
83
- };
84
- exports.createCreateCommand = createCreateCommand;
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":";;;;AAAA,yCAAoC;AACpC,iCAA0B;AAC1B,mCAA0C;AAC1C,6CAAqD;AACrD,0DAAqE;AACrE,+BAA+B;AAC/B,iDAAyC;AACzC,2BAA2C;AAE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}
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 context build workspace',
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 context serve workspace',
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 context serve workspace --port 8080',
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 context build loader',
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 context serve loader',
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 context serve loader --port 8080',
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.contexts || {})
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.contexts)) {
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)(`Context ${name} Commands`)),
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 context',
191
- `npx unisphere context build ${name}`,
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 context (default port is 8300)',
196
- `npx unisphere context serve ${name}`,
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 context with a specific port (e.g. 8320)',
201
- `npx unisphere context serve ${name} --port 8320`,
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
  }