@unisphere/nx 3.23.0 → 4.0.0

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 (63) hide show
  1. package/README.md +195 -0
  2. package/dist/generators/add-application/add-application.d.ts.map +1 -1
  3. package/dist/generators/add-application/add-application.js +29 -0
  4. package/dist/generators/add-application/schema.json +7 -24
  5. package/dist/generators/add-documentation/add-documentation.d.ts.map +1 -1
  6. package/dist/generators/add-documentation/add-documentation.js +27 -24
  7. package/dist/generators/add-documentation/templates/package.json.template +4 -3
  8. package/dist/generators/add-documentation/templates/src/theme/Navbar/Content/index.tsx +0 -8
  9. package/dist/generators/add-documentation/templates/static/homepage/divider.svg +5 -0
  10. package/dist/generators/add-documentation/templates/static/homepage/icons/Architecture.svg +4 -0
  11. package/dist/generators/add-documentation/templates/static/homepage/icons/Cost.svg +4 -0
  12. package/dist/generators/add-documentation/templates/static/homepage/icons/ExternalLink.svg +3 -0
  13. package/dist/generators/add-documentation/templates/static/homepage/icons/Infra.svg +8 -0
  14. package/dist/generators/add-documentation/templates/static/homepage/icons/Redundancies.svg +6 -0
  15. package/dist/generators/add-documentation/templates/static/homepage/icons/Speed.svg +6 -0
  16. package/dist/generators/add-documentation/templates/static/homepage/icons/Standards.svg +4 -0
  17. package/dist/generators/add-documentation/templates/static/homepage/icons/Unified.svg +12 -0
  18. package/dist/generators/add-documentation/templates/static/homepage/services/custo.jpg +0 -0
  19. package/dist/generators/add-documentation/templates/static/homepage/services/flame.jpg +0 -0
  20. package/dist/generators/add-documentation/templates/static/homepage/services/keepr.jpg +0 -0
  21. package/dist/generators/add-documentation/templates/static/homepage/services/loggi.jpg +0 -0
  22. package/dist/generators/add-documentation/templates/static/homepage/services/palleto.jpg +0 -0
  23. package/dist/generators/add-documentation/templates/static/homepage/services/publi.jpg +0 -0
  24. package/dist/generators/add-documentation/templates/static/homepage/services/tinker.jpg +0 -0
  25. package/dist/generators/add-package/add-package.d.ts.map +1 -1
  26. package/dist/generators/add-package/add-package.js +37 -0
  27. package/dist/generators/add-package/schema.json +4 -53
  28. package/dist/generators/add-runtime/add-runtime.d.ts.map +1 -1
  29. package/dist/generators/add-runtime/add-runtime.js +33 -70
  30. package/dist/generators/add-runtime/schema.d.ts +1 -1
  31. package/dist/generators/add-runtime/schema.json +9 -34
  32. package/dist/generators/add-runtime/templates/new-runtime/src/lib/runtime.tsx.template +1 -1
  33. package/dist/generators/add-visual/add-visual.d.ts.map +1 -1
  34. package/dist/generators/add-visual/add-visual.js +41 -49
  35. package/dist/generators/add-visual/schema.json +18 -2
  36. package/dist/generators/change-package-scope/change-package-scope.d.ts.map +1 -1
  37. package/dist/generators/change-package-scope/change-package-scope.js +29 -0
  38. package/dist/generators/change-package-scope/schema.json +2 -4
  39. package/dist/generators/remove/remove.d.ts.map +1 -1
  40. package/dist/generators/remove/remove.js +11 -0
  41. package/dist/generators/remove/schema.json +1 -2
  42. package/dist/generators/rename-package/rename-package.d.ts.map +1 -1
  43. package/dist/generators/rename-package/rename-package.js +23 -0
  44. package/dist/generators/rename-package/schema.json +2 -4
  45. package/dist/generators/utils/index.d.ts +2 -0
  46. package/dist/generators/utils/index.d.ts.map +1 -0
  47. package/dist/generators/utils/index.js +4 -0
  48. package/dist/generators/utils/validation.d.ts +9 -0
  49. package/dist/generators/utils/validation.d.ts.map +1 -0
  50. package/dist/generators/utils/validation.js +38 -0
  51. package/dist/migrations/3-23-0/update-documentation-typedoc-plugins.d.ts.map +1 -1
  52. package/dist/migrations/3-23-0/update-documentation-typedoc-plugins.js +19 -4
  53. package/dist/migrations/3-24-0/add-server-runtimes-setup.d.ts +11 -0
  54. package/dist/migrations/3-24-0/add-server-runtimes-setup.d.ts.map +1 -0
  55. package/dist/migrations/3-24-0/add-server-runtimes-setup.js +160 -0
  56. package/dist/migrations/3-24-0/remove-runtime-js-patch.d.ts +9 -0
  57. package/dist/migrations/3-24-0/remove-runtime-js-patch.d.ts.map +1 -0
  58. package/dist/migrations/3-24-0/remove-runtime-js-patch.js +29 -0
  59. package/dist/migrations/3-24-0/update-runtime-logger-call.d.ts +9 -0
  60. package/dist/migrations/3-24-0/update-runtime-logger-call.d.ts.map +1 -0
  61. package/dist/migrations/3-24-0/update-runtime-logger-call.js +44 -0
  62. package/migrations.json +24 -0
  63. package/package.json +1 -1
@@ -7,43 +7,13 @@
7
7
  "packageName": {
8
8
  "type": "string",
9
9
  "description": "The name of the package to create",
10
- "pattern": "^[a-zA-Z][a-zA-Z0-9\\-\\s]*$",
11
- "x-prompt": "What is the package name? (alphanumeric with dashes and spaces allowed)"
10
+ "pattern": "^[a-zA-Z][a-zA-Z0-9\\-\\s]*$"
12
11
  },
13
12
  "scope": {
14
13
  "type": "string",
15
14
  "description": "The distribution scope of the package",
16
- "default": "local",
17
- "x-prompt": {
18
- "message": "What scope should this package have? If you're unsure, choose Local.",
19
- "type": "list",
20
- "items": [
21
- {
22
- "value": "local",
23
- "label": "Local – This repository only (not published to npm)"
24
- },
25
- {
26
- "value": "kaltura-corp",
27
- "label": "Kaltura Corp – For Kaltura repositories only (jfrog scope: @kaltura-corp/...)"
28
- },
29
- {
30
- "value": "unisphere",
31
- "label": "Unisphere – For all Unisphere workspace consumers (npm scope: @unisphere/...)"
32
- },
33
- {
34
- "value": "kaltura-ui",
35
- "label": "Kaltura UI – UI components for standalone use (npm scope: @kaltura-ui/...)"
36
- },
37
- {
38
- "value": "kaltura-apps",
39
- "label": "Kaltura Apps – Application packages for standalone use (npm scope: @kaltura-apps/...)"
40
- },
41
- {
42
- "value": "kaltura-sdk",
43
- "label": "Kaltura SDK – SDK packages for standalone use (npm scope: @kaltura-sdk/...)"
44
- }
45
- ]
46
- }
15
+ "enum": ["local", "kaltura-corp", "unisphere", "kaltura-ui", "kaltura-apps", "kaltura-sdk"],
16
+ "default": "local"
47
17
  },
48
18
  "dependencies": {
49
19
  "type": "array",
@@ -56,26 +26,7 @@
56
26
  "mui"
57
27
  ]
58
28
  },
59
- "default": [],
60
- "x-prompt": {
61
- "message": "Select dependencies to install (use space to select, enter to confirm):",
62
- "type": "list",
63
- "multiselect": true,
64
- "items": [
65
- {
66
- "value": "react",
67
- "label": "React - UI library for building components"
68
- },
69
- {
70
- "value": "ds",
71
- "label": "Kaltura DS - Design System (requires GIT_TOKEN)"
72
- },
73
- {
74
- "value": "mui",
75
- "label": "Material UI - Component library"
76
- }
77
- ]
78
- }
29
+ "default": []
79
30
  }
80
31
  },
81
32
  "required": [
@@ -1 +1 @@
1
- {"version":3,"file":"add-runtime.d.ts","sourceRoot":"","sources":["../../../src/generators/add-runtime/add-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,IAAI,EAAsC,MAAM,YAAY,CAAC;AAElG,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAqFrD,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,yBAAyB,uBA6InC;AAED,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"add-runtime.d.ts","sourceRoot":"","sources":["../../../src/generators/add-runtime/add-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,IAAI,EAAsC,MAAM,YAAY,CAAC;AAElG,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAgFrD,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,yBAAyB,uBA+GnC;AAED,eAAe,mBAAmB,CAAC"}
@@ -6,41 +6,31 @@ const devkit_1 = require("@nx/devkit");
6
6
  const path = tslib_1.__importStar(require("path"));
7
7
  const utils_1 = require("../utils");
8
8
  const dependency_config_1 = require("../dependency-config");
9
- const add_application_1 = require("../add-application/add-application");
10
- const add_visual_1 = require("../add-visual/add-visual");
11
- async function getEnquirerPrompt() {
12
- const enquirer = await import('enquirer');
13
- // Handle both CommonJS and ESM exports
14
- return enquirer.prompt || enquirer.default?.prompt || enquirer;
15
- }
16
- async function promptForAddVisual() {
17
- const prompt = await getEnquirerPrompt();
18
- const response = await prompt({
19
- type: 'confirm',
20
- name: 'addVisual',
21
- message: 'Would you like to add a visual to this runtime?',
22
- initial: true,
23
- });
24
- return response.addVisual;
25
- }
26
- async function promptForAnalyticsAppId(existingValue) {
27
- if (existingValue !== undefined) {
28
- return existingValue;
9
+ function validateOptions(options) {
10
+ if (!options.name || options.name.trim() === '') {
11
+ throw new Error(`Missing required option: 'name'\n` +
12
+ ` Description: The name of the runtime to create\n` +
13
+ ` Type: string\n` +
14
+ ` Pattern: ^[a-zA-Z][a-zA-Z0-9\\-\\s]*$\n` +
15
+ ` Example: nx g @unisphere/nx:add-runtime --name=my-runtime --consumer=external`);
16
+ }
17
+ const namePattern = /^[a-zA-Z][a-zA-Z0-9\-\s]*$/;
18
+ if (!namePattern.test(options.name)) {
19
+ throw new Error(`Invalid value '${options.name}' for option 'name'\n` +
20
+ ` Pattern: ^[a-zA-Z][a-zA-Z0-9\\-\\s]*$\n` +
21
+ ` Received: ${options.name}`);
22
+ }
23
+ if (!options.consumer) {
24
+ throw new Error(`Missing required option: 'consumer'\n` +
25
+ ` Description: Is this runtime loaded from within the same experience or by an external consumer?\n` +
26
+ ` Allowed values: external, internal\n` +
27
+ ` Example: nx g @unisphere/nx:add-runtime --name=my-runtime --consumer=external`);
28
+ }
29
+ if (!['external', 'internal'].includes(options.consumer)) {
30
+ throw new Error(`Invalid value '${options.consumer}' for option 'consumer'\n` +
31
+ ` Allowed values: external, internal\n` +
32
+ ` Received: ${options.consumer}`);
29
33
  }
30
- const prompt = await getEnquirerPrompt();
31
- const response = await prompt({
32
- type: 'input',
33
- name: 'analyticsAppId',
34
- message: 'Provide the analytics app id (number). If you are not certain, leave it empty and later update the runtime constructor.',
35
- validate: (input) => {
36
- if (input === '')
37
- return true; // Allow empty
38
- const num = Number(input);
39
- return !isNaN(num) && Number.isInteger(num) ? true : 'Please enter a valid integer or leave empty';
40
- },
41
- });
42
- const value = response.analyticsAppId;
43
- return value === '' ? undefined : Number(value);
44
34
  }
45
35
  function updateTypesIndexExport(tree, runtimeName, basePath) {
46
36
  const indexPath = `${basePath}/src/index.ts`;
@@ -61,6 +51,7 @@ function updateTypesIndexExport(tree, runtimeName, basePath) {
61
51
  tree.write(indexPath, updatedContent);
62
52
  }
63
53
  async function addRuntimeGenerator(tree, options) {
54
+ validateOptions(options);
64
55
  // Normalize consumer option - Nx list prompts may return string labels instead of boolean values
65
56
  let isExternal = options?.consumer === 'external' ? true : false;
66
57
  // Validate and read .unisphere configuration
@@ -74,10 +65,7 @@ async function addRuntimeGenerator(tree, options) {
74
65
  let userInputRuntimeName = (0, devkit_1.names)(options.name).fileName;
75
66
  // Find types package (or fallback to core)
76
67
  const typesPackageInfo = (0, utils_1.findTypesOrCorePackageInfo)(tree);
77
- // Prompt for analyticsAppId only if isExternal is true
78
- const analyticsAppId = isExternal
79
- ? await promptForAnalyticsAppId(options.analyticsAppId)
80
- : options.analyticsAppId;
68
+ const analyticsAppId = options.analyticsAppId;
81
69
  // Prepare template variables
82
70
  const templateVariables = {
83
71
  companyName,
@@ -116,31 +104,6 @@ async function addRuntimeGenerator(tree, options) {
116
104
  const runtimePathKey = `unisphere-runtime-${userInputRuntimeName}`;
117
105
  const runtimePathValue = `unisphere/runtimes/${userInputRuntimeName}/src/index.ts`;
118
106
  (0, utils_1.updateTsConfigPaths)(tree, runtimePathKey, runtimePathValue);
119
- // Prompt to add a visual to the new runtime
120
- const shouldAddVisual = await promptForAddVisual();
121
- let visualName = '';
122
- if (shouldAddVisual) {
123
- const visualTask = await (0, add_visual_1.addVisualGenerator)(tree, {
124
- runtimeName: userInputRuntimeName,
125
- });
126
- const visualResponse = await visualTask();
127
- visualName = visualResponse.visualName;
128
- }
129
- let applicationScriptName = '';
130
- // Handle internal usage - create dev application
131
- if (!!isExternal) {
132
- // Create a dev application without prompts
133
- const appTask = await (0, add_application_1.addApplicationGenerator)(tree, {
134
- name: `${userInputRuntimeName}-dev`,
135
- servingType: 'local-dev-playground',
136
- runtimeName: userInputRuntimeName,
137
- visualName,
138
- skipDynamicRuntimeVisualPrompt: true, // Skip the runtime/visual selection prompts since we already have the info
139
- dependencies: selectedDependencies, // Pass same dependencies as runtime
140
- });
141
- applicationScriptName = `serve:${userInputRuntimeName}-dev`;
142
- await appTask();
143
- }
144
107
  // Install selected dependencies
145
108
  (0, dependency_config_1.installSelectedDependencies)(tree, selectedDependencies);
146
109
  await (0, devkit_1.formatFiles)(tree);
@@ -152,14 +115,14 @@ async function addRuntimeGenerator(tree, options) {
152
115
  devkit_1.logger.info('');
153
116
  devkit_1.logger.info(`🚀 Runtime Name: ${userInputRuntimeName}`);
154
117
  devkit_1.logger.info(`📁 Location: ${projectRoot}`);
155
- devkit_1.logger.info(`Analytics App ID: ${analyticsAppId}`);
156
- devkit_1.logger.info(`🔧 Consumer: ${isExternal ? 'External' : 'Internal'}`);
157
- if (applicationScriptName) {
158
- devkit_1.logger.info('');
159
- devkit_1.logger.info('📦 Additional components created:');
160
- devkit_1.logger.info(` • Dev Application: ${userInputRuntimeName}-dev`);
161
- devkit_1.logger.info(`. 📜 To run the dev application locally: npm run ${applicationScriptName}`);
118
+ if (analyticsAppId) {
119
+ devkit_1.logger.info(`📊 Analytics App ID: ${analyticsAppId}`);
162
120
  }
121
+ devkit_1.logger.info(`🔧 Consumer: ${isExternal ? 'External' : 'Internal'}`);
122
+ devkit_1.logger.info('');
123
+ devkit_1.logger.info('📝 Next steps:');
124
+ devkit_1.logger.info(` 1. Add a visual: nx g @unisphere/nx:add-visual --runtimeName=${userInputRuntimeName}`);
125
+ devkit_1.logger.info(` 2. Add a dev app: nx g @unisphere/nx:add-application --name=${userInputRuntimeName}-dev --runtimeName=${userInputRuntimeName}`);
163
126
  devkit_1.logger.info('');
164
127
  };
165
128
  }
@@ -1,6 +1,6 @@
1
1
  export interface AddRuntimeGeneratorSchema {
2
2
  name: string;
3
- consumer: string;
3
+ consumer: 'external' | 'internal';
4
4
  dependencies?: string[];
5
5
  analyticsAppId?: number;
6
6
  }
@@ -7,50 +7,25 @@
7
7
  "name": {
8
8
  "type": "string",
9
9
  "description": "The name of the runtime to create",
10
- "pattern": "^[a-zA-Z][a-zA-Z0-9\\-\\s]*$",
11
- "x-prompt": "What's the runtime name? (letters, numbers, dashes and spaces allowed)"
10
+ "pattern": "^[a-zA-Z][a-zA-Z0-9\\-\\s]*$"
12
11
  },
13
12
  "consumer": {
14
13
  "type": "string",
15
14
  "description": "Is this runtime loaded from within the same experience or by an external consumer?",
16
- "x-prompt": {
17
- "message": "Is this runtime loaded from within the same experience or by an external consumer?",
18
- "type": "list",
19
- "items": [
20
- {
21
- "value": "external",
22
- "label": "Loaded by an external consumer"
23
- },
24
- {
25
- "value": "internal",
26
- "label": "Loaded by another runtime or application within this experience"
27
- }
28
- ]
29
- }
15
+ "enum": ["external", "internal"]
30
16
  },
31
17
  "dependencies": {
32
18
  "type": "array",
33
- "description": "Select packages to install (use space to select, enter to confirm)",
19
+ "description": "Packages to install (react, ds, or mui)",
34
20
  "items": {
35
21
  "type": "string",
36
- "enum": [
37
- "react",
38
- "ds",
39
- "mui"
40
- ]
22
+ "enum": ["react", "ds", "mui"]
41
23
  },
42
- "default": [],
43
- "x-prompt": {
44
- "message": "Select dependencies to install (use space to select, enter to confirm):",
45
- "type": "list",
46
- "multiselect": true,
47
- "items": [
48
- {
49
- "value": "react",
50
- "label": "React - UI library for building components"
51
- }
52
- ]
53
- }
24
+ "default": []
25
+ },
26
+ "analyticsAppId": {
27
+ "type": "number",
28
+ "description": "Analytics app ID (optional, can be set later in runtime constructor)"
54
29
  }
55
30
  },
56
31
  "required": [
@@ -46,7 +46,7 @@ export class Runtime
46
46
 
47
47
  const analyticsAppId: null | number = <%= analyticsAppId ? analyticsAppId : 'null' %>;
48
48
  if (!analyticsAppId) {
49
- this._logger.warn(`missing kaltura analytics app id, cannot register application to analytics service`)
49
+ this._logger.log(`missing kaltura analytics app id, skip application registration to analytics service`)
50
50
  } else {
51
51
  const service = this._options
52
52
  .getWorkspace()
@@ -1 +1 @@
1
- {"version":3,"file":"add-visual.d.ts","sourceRoot":"","sources":["../../../src/generators/add-visual/add-visual.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,IAAI,EAAE,MAAM,YAAY,CAAC;AAsB9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAwbpD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,GAAG,CAAC,CAoFd;AAED,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"add-visual.d.ts","sourceRoot":"","sources":["../../../src/generators/add-visual/add-visual.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,IAAI,EAAE,MAAM,YAAY,CAAC;AAsB9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAmapD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,GAAG,CAAC,CA2Fd;AAED,eAAe,kBAAkB,CAAC"}
@@ -7,53 +7,37 @@ const path = tslib_1.__importStar(require("path"));
7
7
  const ts_morph_1 = require("ts-morph");
8
8
  const utils_1 = require("../utils");
9
9
  const visual_utils_1 = require("./visual-utils");
10
- async function getEnquirerPrompt() {
11
- const enquirer = await import('enquirer');
12
- // Handle both CommonJS and ESM exports
13
- return enquirer.prompt || enquirer.default?.prompt || enquirer;
14
- }
15
- async function promptForRuntimeName(availableRuntimes, existingRuntimeName) {
16
- if (existingRuntimeName) {
17
- return existingRuntimeName;
10
+ function validateOptions(options) {
11
+ if (!options.runtimeName || options.runtimeName.trim() === '') {
12
+ throw new Error(`Missing required option: 'runtimeName'\n` +
13
+ ` Description: The name of the runtime to add the visual to\n` +
14
+ ` Type: string\n` +
15
+ ` Pattern: ^[a-zA-Z][a-zA-Z0-9\\-\\s]*$\n` +
16
+ ` Example: nx g @unisphere/nx:add-visual --runtimeName=my-runtime --visualName=my-visual`);
18
17
  }
19
- const prompt = await getEnquirerPrompt();
20
- const runtimeNames = Object.keys(availableRuntimes);
21
- if (runtimeNames.length === 0) {
22
- throw new Error('No runtimes found in .unisphere configuration.\n' +
23
- 'Please create a runtime first using: nx generate @unisphere/nx:add-runtime');
18
+ const namePattern = /^[a-zA-Z][a-zA-Z0-9\-\s]*$/;
19
+ if (!namePattern.test(options.runtimeName)) {
20
+ throw new Error(`Invalid value '${options.runtimeName}' for option 'runtimeName'\n` +
21
+ ` Pattern: ^[a-zA-Z][a-zA-Z0-9\\-\\s]*$\n` +
22
+ ` Received: ${options.runtimeName}`);
24
23
  }
25
- const runtimeChoices = runtimeNames.map(name => ({ name, message: name }));
26
- const response = await prompt({
27
- type: 'select',
28
- name: 'runtimeName',
29
- message: 'Select a runtime to add the visual to:',
30
- choices: runtimeChoices,
31
- });
32
- return response.runtimeName;
33
- }
34
- async function promptForVisualName(existingVisualName) {
35
- if (existingVisualName) {
36
- return existingVisualName;
24
+ if (!options.visualName || options.visualName.trim() === '') {
25
+ throw new Error(`Missing required option: 'visualName'\n` +
26
+ ` Description: The name of the visual to create\n` +
27
+ ` Type: string\n` +
28
+ ` Pattern: ^[a-zA-Z][a-zA-Z0-9\\-\\s]*$\n` +
29
+ ` Example: nx g @unisphere/nx:add-visual --runtimeName=my-runtime --visualName=my-visual`);
37
30
  }
38
- const prompt = await getEnquirerPrompt();
39
- const response = await prompt({
40
- type: 'input',
41
- name: 'visualName',
42
- message: 'What is the visual name?',
43
- });
44
- return response.visualName;
45
- }
46
- async function promptForIsSingleOccurrence(existingValue) {
47
- if (existingValue !== undefined) {
48
- return existingValue;
31
+ if (!namePattern.test(options.visualName)) {
32
+ throw new Error(`Invalid value '${options.visualName}' for option 'visualName'\n` +
33
+ ` Pattern: ^[a-zA-Z][a-zA-Z0-9\\-\\s]*$\n` +
34
+ ` Received: ${options.visualName}`);
35
+ }
36
+ if (options.isSingleOccurrence !== undefined && typeof options.isSingleOccurrence !== 'boolean') {
37
+ throw new Error(`Invalid value for option 'isSingleOccurrence'\n` +
38
+ ` Type: boolean\n` +
39
+ ` Received: ${options.isSingleOccurrence}`);
49
40
  }
50
- const prompt = await getEnquirerPrompt();
51
- const response = await prompt({
52
- type: 'confirm',
53
- name: 'isSingleOccurrence',
54
- message: 'Is this visual limited to single occurrence?',
55
- });
56
- return response.isSingleOccurrence;
57
41
  }
58
42
  /**
59
43
  * Adds necessary imports (runtimeVisualSettings, runtimeVisualSchema) to the runtime file.
@@ -285,14 +269,22 @@ export const ${schemaName}: ValidatorSchema = {
285
269
  * Nx generator to create a new visual within a specified runtime.
286
270
  */
287
271
  async function addVisualGenerator(tree, options) {
272
+ validateOptions(options);
288
273
  // Validate and read .unisphere configuration first
289
274
  const unisphereConfig = (0, utils_1.validateUnisphereConfig)(tree);
290
- // Prompt for runtime if not provided
291
- const runtimeName = await promptForRuntimeName(unisphereConfig.runtimes, options.runtimeName);
292
- // Prompt for visual name if not provided
293
- const visualName = await promptForVisualName(options.visualName);
294
- // Prompt for isSingleOccurrence if not provided
295
- const isSingleOccurrence = await promptForIsSingleOccurrence(options.isSingleOccurrence);
275
+ // After validation, these are guaranteed to be strings
276
+ const runtimeName = options.runtimeName;
277
+ const visualName = options.visualName;
278
+ // Validate that the runtime exists
279
+ if (!unisphereConfig.runtimes[runtimeName]) {
280
+ const availableRuntimes = Object.keys(unisphereConfig.runtimes);
281
+ throw new Error(`Runtime '${runtimeName}' not found in .unisphere configuration.\n` +
282
+ (availableRuntimes.length > 0
283
+ ? ` Available runtimes: ${availableRuntimes.join(', ')}\n`
284
+ : ` No runtimes found. Please create a runtime first using: nx generate @unisphere/nx:add-runtime\n`) +
285
+ ` Example: nx g @unisphere/nx:add-visual --runtimeName=${availableRuntimes[0] || 'my-runtime'} --visualName=my-visual`);
286
+ }
287
+ const isSingleOccurrence = options.isSingleOccurrence ?? false;
296
288
  // Extract environment variables
297
289
  const widgetName = unisphereConfig.name;
298
290
  // Validate runtime existence and get source root path.
@@ -3,6 +3,22 @@
3
3
  "$id": "AddVisual",
4
4
  "title": "Add Visual Generator",
5
5
  "type": "object",
6
- "properties": {},
7
- "required": []
6
+ "properties": {
7
+ "runtimeName": {
8
+ "type": "string",
9
+ "description": "The name of the runtime to add the visual to",
10
+ "pattern": "^[a-zA-Z][a-zA-Z0-9\\-\\s]*$"
11
+ },
12
+ "visualName": {
13
+ "type": "string",
14
+ "description": "The name of the visual to create",
15
+ "pattern": "^[a-zA-Z][a-zA-Z0-9\\-\\s]*$"
16
+ },
17
+ "isSingleOccurrence": {
18
+ "type": "boolean",
19
+ "description": "Whether this visual is limited to single occurrence",
20
+ "default": false
21
+ }
22
+ },
23
+ "required": ["runtimeName", "visualName"]
8
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"change-package-scope.d.ts","sourceRoot":"","sources":["../../../src/generators/change-package-scope/change-package-scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,IAAI,EAIL,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,iCAAiC,EAAE,MAAM,UAAU,CAAC;AAiW7D,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,iCAAiC,iBAoH3C;AAED,eAAe,2BAA2B,CAAC"}
1
+ {"version":3,"file":"change-package-scope.d.ts","sourceRoot":"","sources":["../../../src/generators/change-package-scope/change-package-scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,IAAI,EAIL,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,iCAAiC,EAAE,MAAM,UAAU,CAAC;AAwY7D,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,iCAAiC,iBAuH3C;AAED,eAAe,2BAA2B,CAAC"}
@@ -23,6 +23,33 @@ const devkit_1 = require("@nx/devkit");
23
23
  const generators_1 = require("@nx/workspace/generators");
24
24
  const utils_1 = require("../utils");
25
25
  const utils_2 = require("./utils");
26
+ function validateOptions(options) {
27
+ if (!options.packageJsonName || options.packageJsonName.trim() === '') {
28
+ throw new Error(`Missing required option: 'packageJsonName'\n` +
29
+ ` Description: The full package.json name\n` +
30
+ ` Type: string\n` +
31
+ ` Pattern: ^@[a-z0-9-]+/[a-z0-9-]+$\n` +
32
+ ` Example: nx g @unisphere/nx:change-package-scope --packageJsonName=@kaltura-corp/unisphere-my-package --newScope=kaltura-sdk`);
33
+ }
34
+ const namePattern = /^@[a-z0-9-]+\/[a-z0-9-]+$/;
35
+ if (!namePattern.test(options.packageJsonName)) {
36
+ throw new Error(`Invalid value '${options.packageJsonName}' for option 'packageJsonName'\n` +
37
+ ` Pattern: ^@[a-z0-9-]+/[a-z0-9-]+$\n` +
38
+ ` Received: ${options.packageJsonName}`);
39
+ }
40
+ if (!options.newScope) {
41
+ throw new Error(`Missing required option: 'newScope'\n` +
42
+ ` Description: The target scope for the package\n` +
43
+ ` Allowed values: unisphere, kaltura-corp, kaltura-sdk, kaltura-apps, kaltura-ui, local\n` +
44
+ ` Example: nx g @unisphere/nx:change-package-scope --packageJsonName=@kaltura-corp/unisphere-my-package --newScope=kaltura-sdk`);
45
+ }
46
+ const allowedScopes = ['unisphere', 'kaltura-corp', 'kaltura-sdk', 'kaltura-apps', 'kaltura-ui', 'local'];
47
+ if (!allowedScopes.includes(options.newScope)) {
48
+ throw new Error(`Invalid value '${options.newScope}' for option 'newScope'\n` +
49
+ ` Allowed values: ${allowedScopes.join(', ')}\n` +
50
+ ` Received: ${options.newScope}`);
51
+ }
52
+ }
26
53
  /**
27
54
  * Finds a package in .unisphere config by matching the package.json name.
28
55
  * Extracts package information needed for scope change.
@@ -256,6 +283,8 @@ function escapeRegExp(string) {
256
283
  return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
257
284
  }
258
285
  async function changePackageScopeGenerator(tree, options) {
286
+ // Validate options
287
+ validateOptions(options);
259
288
  devkit_1.logger.info('');
260
289
  devkit_1.logger.info('🔄 Starting package scope change...');
261
290
  devkit_1.logger.info('');
@@ -7,14 +7,12 @@
7
7
  "packageJsonName": {
8
8
  "type": "string",
9
9
  "description": "The full package.json name (e.g., @kaltura-corp/unisphere-rtc-avatar)",
10
- "pattern": "^@[a-z0-9-]+/[a-z0-9-]+$",
11
- "x-prompt": "What is the full package.json name? (from the package's package.json)"
10
+ "pattern": "^@[a-z0-9-]+/[a-z0-9-]+$"
12
11
  },
13
12
  "newScope": {
14
13
  "type": "string",
15
14
  "description": "The target scope for the package",
16
- "enum": ["unisphere", "kaltura-corp", "kaltura-sdk", "kaltura-apps", "kaltura-ui", "local"],
17
- "x-prompt": "What scope should the package move to?"
15
+ "enum": ["unisphere", "kaltura-corp", "kaltura-sdk", "kaltura-apps", "kaltura-ui", "local"]
18
16
  }
19
17
  },
20
18
  "required": [
@@ -1 +1 @@
1
- {"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../../src/generators/remove/remove.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,IAAI,EAKL,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAiRjD,wBAAsB,eAAe,CACnC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,qBAAqB,iBAqF/B;AAED,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../../src/generators/remove/remove.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,IAAI,EAKL,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AA6RjD,wBAAsB,eAAe,CACnC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,qBAAqB,iBAwF/B;AAED,eAAe,eAAe,CAAC"}
@@ -20,6 +20,15 @@ const generators_1 = require("@nx/workspace/generators");
20
20
  const utils_1 = require("../utils");
21
21
  const remove_utils_1 = require("./remove-utils");
22
22
  const VALID_ELEMENT_TYPES = ['package', 'runtime', 'application'];
23
+ function validateOptions(options) {
24
+ if (!options.element || options.element.trim() === '') {
25
+ throw new Error(`Missing required option: 'element'\n` +
26
+ ` Description: The element to remove in format 'type:name'\n` +
27
+ ` Type: string\n` +
28
+ ` Format: type:name (e.g., runtime:admin, package:shared, application:my-app)\n` +
29
+ ` Example: nx g @unisphere/nx:remove runtime:admin`);
30
+ }
31
+ }
23
32
  /**
24
33
  * Parse the element string in format "type:name"
25
34
  */
@@ -214,6 +223,8 @@ function removeFromPackageLock(tree, sourceRoot) {
214
223
  }
215
224
  }
216
225
  async function removeGenerator(tree, options) {
226
+ // Validate options
227
+ validateOptions(options);
217
228
  // Validate .unisphere exists
218
229
  (0, utils_1.validateUnisphereConfig)(tree);
219
230
  // Parse element string (format: "type:name")
@@ -25,8 +25,7 @@
25
25
  "$default": {
26
26
  "$source": "argv",
27
27
  "index": 0
28
- },
29
- "x-prompt": "Enter element to remove (format: type:name, e.g., runtime:admin):"
28
+ }
30
29
  },
31
30
  "forceRemove": {
32
31
  "type": "boolean",
@@ -1 +1 @@
1
- {"version":3,"file":"rename-package.d.ts","sourceRoot":"","sources":["../../../src/generators/rename-package/rename-package.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,IAAI,EAKL,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AA6axD,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,4BAA4B,iBA2GtC;AAED,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"rename-package.d.ts","sourceRoot":"","sources":["../../../src/generators/rename-package/rename-package.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,IAAI,EAKL,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AA2cxD,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,4BAA4B,iBA8GtC;AAED,eAAe,sBAAsB,CAAC"}
@@ -20,6 +20,27 @@ exports.renamePackageGenerator = renamePackageGenerator;
20
20
  const devkit_1 = require("@nx/devkit");
21
21
  const generators_1 = require("@nx/workspace/generators");
22
22
  const utils_1 = require("../utils");
23
+ function validateOptions(options) {
24
+ if (!options.oldPackageName || options.oldPackageName.trim() === '') {
25
+ throw new Error(`Missing required option: 'oldPackageName'\n` +
26
+ ` Description: The current name of the package to rename\n` +
27
+ ` Type: string\n` +
28
+ ` Example: nx g @unisphere/nx:rename-package --oldPackageName=old-name --newPackageName=new-name`);
29
+ }
30
+ if (!options.newPackageName || options.newPackageName.trim() === '') {
31
+ throw new Error(`Missing required option: 'newPackageName'\n` +
32
+ ` Description: The new name for the package\n` +
33
+ ` Type: string\n` +
34
+ ` Pattern: ^[a-zA-Z][a-zA-Z0-9\\-\\s]*$\n` +
35
+ ` Example: nx g @unisphere/nx:rename-package --oldPackageName=old-name --newPackageName=new-name`);
36
+ }
37
+ const namePattern = /^[a-zA-Z][a-zA-Z0-9\-\s]*$/;
38
+ if (!namePattern.test(options.newPackageName)) {
39
+ throw new Error(`Invalid value '${options.newPackageName}' for option 'newPackageName'\n` +
40
+ ` Pattern: ^[a-zA-Z][a-zA-Z0-9\\-\\s]*$\n` +
41
+ ` Received: ${options.newPackageName}`);
42
+ }
43
+ }
23
44
  /**
24
45
  * Reserved package names that cannot be renamed.
25
46
  * These packages have special meaning in Unisphere and renaming them would break functionality.
@@ -330,6 +351,8 @@ function updatePackageLock(tree, oldPath, newPath) {
330
351
  }
331
352
  }
332
353
  async function renamePackageGenerator(tree, options) {
354
+ // Validate options
355
+ validateOptions(options);
333
356
  devkit_1.logger.info('');
334
357
  devkit_1.logger.info('🔄 Starting package rename...');
335
358
  devkit_1.logger.info('');
@@ -6,14 +6,12 @@
6
6
  "properties": {
7
7
  "oldPackageName": {
8
8
  "type": "string",
9
- "description": "The current name of the package to rename",
10
- "x-prompt": "What is the current package name?"
9
+ "description": "The current name of the package to rename"
11
10
  },
12
11
  "newPackageName": {
13
12
  "type": "string",
14
13
  "description": "The new name for the package",
15
- "pattern": "^[a-zA-Z][a-zA-Z0-9\\-\\s]*$",
16
- "x-prompt": "What should the new package name be? (alphanumeric with dashes and spaces allowed)"
14
+ "pattern": "^[a-zA-Z][a-zA-Z0-9\\-\\s]*$"
17
15
  }
18
16
  },
19
17
  "required": [
@@ -0,0 +1,2 @@
1
+ export * from './validation';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generators/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./validation"), exports);
@@ -0,0 +1,9 @@
1
+ export interface ValidationConfig {
2
+ name: string;
3
+ description: string;
4
+ allowedValues?: string[];
5
+ pattern?: string;
6
+ type?: string;
7
+ }
8
+ export declare function validateRequired(options: Record<string, any>, config: ValidationConfig): void;
9
+ //# sourceMappingURL=validation.d.ts.map