@unisphere/nx 2.2.1 → 3.2.3

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 (135) hide show
  1. package/dist/generators/add-application/add-application.d.ts.map +1 -1
  2. package/dist/generators/add-application/add-application.js +77 -55
  3. package/dist/generators/add-application/schema.d.ts +3 -1
  4. package/dist/generators/add-application/schema.json +4 -8
  5. package/dist/generators/add-application/templates/default/.env-template +6 -0
  6. package/dist/generators/add-application/templates/default/.eslintrc.json +1 -1
  7. package/dist/generators/add-application/templates/default/jest.config.ts +3 -3
  8. package/dist/generators/add-application/templates/default/project.json.template +2 -2
  9. package/dist/generators/add-application/templates/default/readme.md.template +11 -0
  10. package/dist/generators/add-application/templates/default/src/app/app.tsx.template +77 -77
  11. package/dist/generators/add-application/templates/default/tsconfig.json +1 -1
  12. package/dist/generators/add-application/templates/default/webpack.config.js.template +6 -1
  13. package/dist/generators/add-package/README.md +2 -2
  14. package/dist/generators/add-package/add-package.d.ts.map +1 -1
  15. package/dist/generators/add-package/add-package.js +11 -23
  16. package/dist/generators/add-package/schema.d.ts +1 -1
  17. package/dist/generators/add-package/schema.json +27 -19
  18. package/dist/generators/add-package/templates/new-package/.eslintrc.json +1 -1
  19. package/dist/generators/add-package/templates/new-package/package.json.template +0 -1
  20. package/dist/generators/add-package/templates/new-package/project.json.template +4 -4
  21. package/dist/generators/add-package/templates/new-package/rollup.config.js +1 -1
  22. package/dist/generators/add-package/templates/new-package/tsconfig.json +1 -1
  23. package/dist/generators/add-package/templates/new-package/tsconfig.lib.json.template +1 -1
  24. package/dist/generators/add-package/templates/new-package/tsconfig.spec.json +1 -1
  25. package/dist/generators/add-runtime/add-runtime.d.ts.map +1 -1
  26. package/dist/generators/add-runtime/add-runtime.js +62 -9
  27. package/dist/generators/add-runtime/schema.d.ts +1 -0
  28. package/dist/generators/add-runtime/schema.json +1 -9
  29. package/dist/generators/add-runtime/templates/new-runtime/src/lib/create-factory.tsx.template +4 -4
  30. package/dist/generators/add-runtime/templates/new-runtime/src/lib/runtime.tsx.template +26 -2
  31. package/dist/generators/add-visual/add-visual.d.ts +1 -1
  32. package/dist/generators/add-visual/add-visual.d.ts.map +1 -1
  33. package/dist/generators/add-visual/add-visual.js +108 -15
  34. package/dist/generators/add-visual/schema.d.ts +3 -3
  35. package/dist/generators/add-visual/schema.json +2 -24
  36. package/dist/generators/dependency-config.d.ts.map +1 -1
  37. package/dist/generators/dependency-config.js +1 -0
  38. package/dist/generators/internal-dev-runner/generator.d.ts +3 -0
  39. package/dist/generators/internal-dev-runner/generator.d.ts.map +1 -0
  40. package/dist/generators/internal-dev-runner/generator.js +45 -0
  41. package/dist/generators/internal-dev-runner/schema.json +9 -0
  42. package/dist/generators/remove/remove.d.ts +19 -0
  43. package/dist/generators/remove/remove.d.ts.map +1 -0
  44. package/dist/generators/remove/remove.js +270 -0
  45. package/dist/generators/remove/schema.d.ts +4 -0
  46. package/dist/generators/remove/schema.json +38 -0
  47. package/dist/generators/rename-package/rename-package.d.ts +3 -0
  48. package/dist/generators/rename-package/rename-package.d.ts.map +1 -1
  49. package/dist/generators/rename-package/rename-package.js +139 -20
  50. package/dist/generators/utils.d.ts +30 -1
  51. package/dist/generators/utils.d.ts.map +1 -1
  52. package/dist/generators/utils.js +258 -7
  53. package/dist/migrations/1-22-0/patches/@changesets+cli+2.29.7.patch +36 -4
  54. package/dist/migrations/1-22-2/templates/_publish-artifacts.template +5 -5
  55. package/dist/migrations/1-24-2/templates/_publish-artifacts.template +5 -5
  56. package/dist/migrations/2-1-0/replace-readme-md.d.ts.map +1 -1
  57. package/dist/migrations/2-1-0/replace-readme-md.js +2 -3
  58. package/dist/migrations/2-2-0/templates/_publish-artifacts.template +5 -5
  59. package/dist/migrations/3-0-0/add-define-plugin-to-webpack.d.ts +3 -0
  60. package/dist/migrations/3-0-0/add-define-plugin-to-webpack.d.ts.map +1 -0
  61. package/dist/migrations/3-0-0/add-define-plugin-to-webpack.js +233 -0
  62. package/dist/migrations/3-0-0/add-env-to-application-gitignore.d.ts +3 -0
  63. package/dist/migrations/3-0-0/add-env-to-application-gitignore.d.ts.map +1 -0
  64. package/dist/migrations/3-0-0/add-env-to-application-gitignore.js +117 -0
  65. package/dist/migrations/3-0-0/fix-vite-config-cache-paths.d.ts +10 -0
  66. package/dist/migrations/3-0-0/fix-vite-config-cache-paths.d.ts.map +1 -0
  67. package/dist/migrations/3-0-0/fix-vite-config-cache-paths.js +66 -0
  68. package/dist/migrations/3-0-0/patches/@changesets+cli+2.29.7.patch +88 -0
  69. package/dist/migrations/3-0-0/post-cleanup-empty-directories.d.ts +12 -0
  70. package/dist/migrations/3-0-0/post-cleanup-empty-directories.d.ts.map +1 -0
  71. package/dist/migrations/3-0-0/post-cleanup-empty-directories.js +62 -0
  72. package/dist/migrations/3-0-0/pre-cleanup-empty-directories.d.ts +14 -0
  73. package/dist/migrations/3-0-0/pre-cleanup-empty-directories.d.ts.map +1 -0
  74. package/dist/migrations/3-0-0/pre-cleanup-empty-directories.js +105 -0
  75. package/dist/migrations/3-0-0/remove-kaltura-tools-to-pre-install.d.ts +3 -0
  76. package/dist/migrations/3-0-0/remove-kaltura-tools-to-pre-install.d.ts.map +1 -0
  77. package/dist/migrations/3-0-0/remove-kaltura-tools-to-pre-install.js +21 -0
  78. package/dist/migrations/3-0-0/remove-private-from-applications-and-runtimes.d.ts +9 -0
  79. package/dist/migrations/3-0-0/remove-private-from-applications-and-runtimes.d.ts.map +1 -0
  80. package/dist/migrations/3-0-0/remove-private-from-applications-and-runtimes.js +88 -0
  81. package/dist/migrations/3-0-0/remove-publish-config-from-packages.d.ts +9 -0
  82. package/dist/migrations/3-0-0/remove-publish-config-from-packages.d.ts.map +1 -0
  83. package/dist/migrations/3-0-0/remove-publish-config-from-packages.js +45 -0
  84. package/dist/migrations/3-0-0/reorganize-applications-by-distribution-channel.d.ts +15 -0
  85. package/dist/migrations/3-0-0/reorganize-applications-by-distribution-channel.d.ts.map +1 -0
  86. package/dist/migrations/3-0-0/reorganize-applications-by-distribution-channel.js +563 -0
  87. package/dist/migrations/3-0-0/reorganize-packages-by-distribution-channel.d.ts +23 -0
  88. package/dist/migrations/3-0-0/reorganize-packages-by-distribution-channel.d.ts.map +1 -0
  89. package/dist/migrations/3-0-0/reorganize-packages-by-distribution-channel.js +645 -0
  90. package/dist/migrations/3-0-0/replace-github-workflow.d.ts +3 -0
  91. package/dist/migrations/3-0-0/replace-github-workflow.d.ts.map +1 -0
  92. package/dist/migrations/3-0-0/replace-github-workflow.js +48 -0
  93. package/dist/migrations/3-0-0/sync-package-lock.d.ts +10 -0
  94. package/dist/migrations/3-0-0/sync-package-lock.d.ts.map +1 -0
  95. package/dist/migrations/3-0-0/sync-package-lock.js +26 -0
  96. package/dist/migrations/3-0-0/templates/_publish-artifacts.template +363 -0
  97. package/dist/migrations/3-0-0/templates/cicd.template +89 -0
  98. package/dist/migrations/3-0-0/update-changeset-patch.d.ts +3 -0
  99. package/dist/migrations/3-0-0/update-changeset-patch.d.ts.map +1 -0
  100. package/dist/migrations/3-0-0/update-changeset-patch.js +31 -0
  101. package/dist/migrations/3-0-0/upgrade-schema-to-2-0-0.d.ts +21 -0
  102. package/dist/migrations/3-0-0/upgrade-schema-to-2-0-0.d.ts.map +1 -0
  103. package/dist/migrations/3-0-0/upgrade-schema-to-2-0-0.js +105 -0
  104. package/dist/migrations/utils/has-react-dependency.d.ts +14 -0
  105. package/dist/migrations/utils/has-react-dependency.d.ts.map +1 -0
  106. package/dist/migrations/utils/has-react-dependency.js +72 -0
  107. package/dist/shared.d.ts +6 -0
  108. package/dist/shared.d.ts.map +1 -0
  109. package/dist/shared.js +9 -0
  110. package/generators.json +12 -1
  111. package/migrations.json +117 -0
  112. package/package.json +3 -2
  113. package/dist/generators/add-application/templates/local-dev-playground/.babelrc +0 -11
  114. package/dist/generators/add-application/templates/local-dev-playground/.eslintrc.json +0 -22
  115. package/dist/generators/add-application/templates/local-dev-playground/jest.config.ts +0 -11
  116. package/dist/generators/add-application/templates/local-dev-playground/package.json +0 -6
  117. package/dist/generators/add-application/templates/local-dev-playground/project.json +0 -9
  118. package/dist/generators/add-application/templates/local-dev-playground/src/app/app.tsx.template +0 -212
  119. package/dist/generators/add-application/templates/local-dev-playground/src/app/components/header.tsx.template +0 -123
  120. package/dist/generators/add-application/templates/local-dev-playground/src/app/components/settings-buttons.tsx +0 -57
  121. package/dist/generators/add-application/templates/local-dev-playground/src/app/components/settings-form.tsx +0 -108
  122. package/dist/generators/add-application/templates/local-dev-playground/src/app/components/settings.tsx +0 -74
  123. package/dist/generators/add-application/templates/local-dev-playground/src/app/configuration-provider.tsx +0 -163
  124. package/dist/generators/add-application/templates/local-dev-playground/src/app/definitions.ts +0 -25
  125. package/dist/generators/add-application/templates/local-dev-playground/src/app/utils/merge-deep.ts +0 -31
  126. package/dist/generators/add-application/templates/local-dev-playground/src/favicon.ico +0 -0
  127. package/dist/generators/add-application/templates/local-dev-playground/src/index.html +0 -17
  128. package/dist/generators/add-application/templates/local-dev-playground/src/main.tsx +0 -13
  129. package/dist/generators/add-application/templates/local-dev-playground/src/styles.css +0 -0
  130. package/dist/generators/add-application/templates/local-dev-playground/tsconfig.app.json +0 -24
  131. package/dist/generators/add-application/templates/local-dev-playground/tsconfig.json +0 -20
  132. package/dist/generators/add-application/templates/local-dev-playground/tsconfig.spec.json +0 -25
  133. package/dist/generators/add-application/templates/local-dev-playground/webpack.config.js +0 -33
  134. /package/dist/generators/add-runtime/templates/{core-templates → types-templates}/__runtimeName__-runtime/index.ts.template +0 -0
  135. /package/dist/generators/add-runtime/templates/{core-templates → types-templates}/__runtimeName__-runtime/runtime-types.ts.template +0 -0
@@ -12,33 +12,41 @@
12
12
  },
13
13
  "scope": {
14
14
  "type": "string",
15
- "description": "The distribution scope of the package",
15
+ "description": "The distribution scope of the package",
16
16
  "default": "none",
17
17
  "x-prompt": {
18
- "message": "What scope should this package have? If youre unsure, choose Private.",
19
- "type": "list",
20
- "items": [
21
- {
22
- "value": "none",
23
- "label": "Private – only for this Unisphere experience (not published externally)"
24
- },
25
- {
26
- "value": "internal",
27
- "label": "Kaltura – published as a GitHub package (@kaltura/unisphere-… for Kaltura teams)"
28
- },
29
- {
30
- "value": "public",
31
- "label": "Public – published to npm (@unisphere/… available to everyone)"
18
+ "message": "What scope should this package have? If you're unsure, choose Private.",
19
+ "type": "list",
20
+ "items": [
21
+ {
22
+ "value": "none",
23
+ "label": "Private – This repository only (not published to npm)"
24
+ },
25
+ {
26
+ "value": "internal",
27
+ "label": "Kaltura Internal For Kaltura repositories only (jfrog scope: @kaltura-corp/...)"
28
+ },
29
+ {
30
+ "value": "public",
31
+ "label": "Unisphere Public – For all Unisphere workspace consumers (npm scope: @unisphere/...)"
32
+ },
33
+ {
34
+ "value": "kaltura-ai",
35
+ "label": "Kaltura AI Lab – Experimental packages for standalone use (npm scope: @kaltura-ai/...)"
36
+ }
37
+ ]
32
38
  }
33
- ]
34
- }
35
39
  },
36
40
  "dependencies": {
37
41
  "type": "array",
38
42
  "description": "Select packages to install (use space to select, enter to confirm)",
39
43
  "items": {
40
44
  "type": "string",
41
- "enum": ["react", "ds", "mui"]
45
+ "enum": [
46
+ "react",
47
+ "ds",
48
+ "mui"
49
+ ]
42
50
  },
43
51
  "default": [],
44
52
  "x-prompt": {
@@ -66,4 +74,4 @@
66
74
  "packageName",
67
75
  "scope"
68
76
  ]
69
- }
77
+ }
@@ -1,5 +1,5 @@
1
1
  {
2
- "extends": ["plugin:@nx/react", "../../../.eslintrc.json"],
2
+ "extends": ["plugin:@nx/react", "../../../../.eslintrc.json"],
3
3
  "ignorePatterns": [
4
4
  "!**/*",
5
5
  "**/vite.config.*.timestamp*",
@@ -2,7 +2,6 @@
2
2
  "name": "<%= packageJsonName %>",
3
3
  "version": "1.0.0",
4
4
  "author": "kaltura",
5
- "private": <%= repositoryPrivate %>,
6
5
  "license": "AGPL-3.0",
7
6
  "repository": {
8
7
  "type": "git",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unisphere-package-<%= packageName__lowerDashCase %>",
3
- "$schema": "../../../node_modules/nx/schemas/project-schema.json",
4
- "sourceRoot": "unisphere/packages/<%= packageName__lowerDashCase %>/src",
3
+ "$schema": "../../../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "unisphere/packages/<%= subdirectory %>/<%= packageName__lowerDashCase %>/src",
5
5
  "projectType": "library",
6
6
  "tags": [],
7
7
  "// targets": "to see all targets run: nx show project unisphere-package-<%= packageName__lowerDashCase %> --web",
@@ -13,8 +13,8 @@
13
13
  ],
14
14
  "options": {
15
15
  "lintFilePatterns": [
16
- "unisphere/packages/<%= packageName__lowerDashCase %>/src/**/*.{ts,tsx,js,jsx}",
17
- "unisphere/packages/<%= packageName__lowerDashCase %>/package.json"
16
+ "unisphere/packages/<%= subdirectory %>/<%= packageName__lowerDashCase %>/src/**/*.{ts,tsx,js,jsx}",
17
+ "unisphere/packages/<%= subdirectory %>/<%= packageName__lowerDashCase %>/package.json"
18
18
  ]
19
19
  }
20
20
  }
@@ -1,4 +1,4 @@
1
- const createUnisphereWithNX = require('../../../node_modules/@unisphere/cli/bundler/package/rollup.js');
1
+ const createUnisphereWithNX = require('../../../../node_modules/@unisphere/cli/bundler/package/rollup.js');
2
2
 
3
3
 
4
4
  module.exports = createUnisphereWithNX({
@@ -16,5 +16,5 @@
16
16
  "path": "./tsconfig.spec.json"
17
17
  }
18
18
  ],
19
- "extends": "../../../tsconfig.base.json"
19
+ "extends": "../../../../tsconfig.base.json"
20
20
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "extends": "./tsconfig.json",
3
3
  "compilerOptions": {
4
- "outDir": "../../../dist/out-tsc",
4
+ "outDir": "../../../../dist/out-tsc",
5
5
  "types": [
6
6
  "node"<% if (hasDs) { %>,
7
7
  "@kaltura/ds-react-theme/src/lib/theme.d.ts"<% } %><% if (hasReact) { %>,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "extends": "./tsconfig.json",
3
3
  "compilerOptions": {
4
- "outDir": "../../../dist/out-tsc",
4
+ "outDir": "../../../../dist/out-tsc",
5
5
  "types": [
6
6
  "vitest/globals",
7
7
  "vitest/importMeta",
@@ -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,EAAiB,MAAM,YAAY,CAAC;AAE7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AA4CrD,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,yBAAyB,uBAyHnC;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;AAqFrD,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,yBAAyB,uBA6InC;AAED,eAAe,mBAAmB,CAAC"}
@@ -7,6 +7,41 @@ const path = tslib_1.__importStar(require("path"));
7
7
  const utils_1 = require("../utils");
8
8
  const dependency_config_1 = require("../dependency-config");
9
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;
29
+ }
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
+ }
10
45
  function updateTypesIndexExport(tree, runtimeName, basePath) {
11
46
  const indexPath = `${basePath}/src/index.ts`;
12
47
  if (!tree.exists(indexPath)) {
@@ -32,7 +67,6 @@ async function addRuntimeGenerator(tree, options) {
32
67
  const unisphereConfig = (0, utils_1.validateUnisphereConfig)(tree);
33
68
  // Validate dependencies
34
69
  const selectedDependencies = options.dependencies || [];
35
- (0, dependency_config_1.validateGitToken)(selectedDependencies);
36
70
  // Extract environment variables
37
71
  const companyName = unisphereConfig.company;
38
72
  const widgetName = unisphereConfig.name;
@@ -40,9 +74,14 @@ async function addRuntimeGenerator(tree, options) {
40
74
  let userInputRuntimeName = (0, devkit_1.names)(options.name).fileName;
41
75
  // Find types package (or fallback to core)
42
76
  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;
43
81
  // Prepare template variables
44
82
  const templateVariables = {
45
83
  companyName,
84
+ analyticsAppId,
46
85
  typesAlias: typesPackageInfo.alias,
47
86
  // Add all name transformations
48
87
  ...(0, utils_1.createNameTransforms)(userInputRuntimeName, 'runtimeName'),
@@ -65,8 +104,8 @@ async function addRuntimeGenerator(tree, options) {
65
104
  // Generate files from templates for the runtime
66
105
  (0, devkit_1.generateFiles)(tree, path.join(__dirname, 'templates/new-runtime'), projectRoot, templateVariables);
67
106
  // Generate the runtime types file in the types/core package using template
68
- (0, devkit_1.generateFiles)(tree, path.join(__dirname, 'templates/core-templates'), `${typesPackageInfo.basePath}/src/lib`, templateVariables);
69
- // Update types/core index.ts to export the new runtime types
107
+ (0, devkit_1.generateFiles)(tree, path.join(__dirname, 'templates/types-templates'), `${typesPackageInfo.basePath}/src/lib`, templateVariables);
108
+ // Update types package index.ts to export the new runtime types
70
109
  updateTypesIndexExport(tree, userInputRuntimeName, typesPackageInfo.basePath);
71
110
  // Update .unisphere configuration
72
111
  (0, utils_1.updateUnisphereConfig)(tree, 'runtimes', userInputRuntimeName, {
@@ -77,35 +116,49 @@ async function addRuntimeGenerator(tree, options) {
77
116
  const runtimePathKey = `unisphere-runtime-${userInputRuntimeName}`;
78
117
  const runtimePathValue = `unisphere/runtimes/${userInputRuntimeName}/src/index.ts`;
79
118
  (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 = '';
80
130
  // Handle internal usage - create dev application
81
131
  if (!!isExternal) {
82
132
  // Create a dev application without prompts
83
- const applicationResult = await (0, add_application_1.addApplicationGenerator)(tree, {
133
+ const appTask = await (0, add_application_1.addApplicationGenerator)(tree, {
84
134
  name: `${userInputRuntimeName}-dev`,
85
135
  servingType: 'local-dev-playground',
86
136
  runtimeName: userInputRuntimeName,
137
+ visualName,
138
+ skipDynamicRuntimeVisualPrompt: true, // Skip the runtime/visual selection prompts since we already have the info
87
139
  dependencies: selectedDependencies, // Pass same dependencies as runtime
88
140
  });
89
- // Execute the application generation callback if it exists
90
- if (applicationResult && typeof applicationResult === 'function') {
91
- applicationResult();
92
- }
141
+ applicationScriptName = `serve:${userInputRuntimeName}-dev`;
142
+ await appTask();
93
143
  }
94
144
  // Install selected dependencies
95
145
  (0, dependency_config_1.installSelectedDependencies)(tree, selectedDependencies);
96
146
  await (0, devkit_1.formatFiles)(tree);
97
147
  // Return a function that will be executed after all file operations are complete
98
148
  return () => {
149
+ (0, devkit_1.installPackagesTask)(tree, true);
99
150
  devkit_1.logger.info('');
100
151
  devkit_1.logger.info('✅ Runtime generated successfully!');
101
152
  devkit_1.logger.info('');
102
153
  devkit_1.logger.info(`🚀 Runtime Name: ${userInputRuntimeName}`);
103
154
  devkit_1.logger.info(`📁 Location: ${projectRoot}`);
155
+ devkit_1.logger.info(`Analytics App ID: ${analyticsAppId}`);
104
156
  devkit_1.logger.info(`🔧 Consumer: ${isExternal ? 'External' : 'Internal'}`);
105
- if (isExternal === true) {
157
+ if (applicationScriptName) {
106
158
  devkit_1.logger.info('');
107
159
  devkit_1.logger.info('📦 Additional components created:');
108
160
  devkit_1.logger.info(` • Dev Application: ${userInputRuntimeName}-dev`);
161
+ devkit_1.logger.info(`. 📜 To run the dev application locally: npm run ${applicationScriptName}`);
109
162
  }
110
163
  devkit_1.logger.info('');
111
164
  };
@@ -2,4 +2,5 @@ export interface AddRuntimeGeneratorSchema {
2
2
  name: string;
3
3
  consumer: string;
4
4
  dependencies?: string[];
5
+ analyticsAppId?: number;
5
6
  }
@@ -48,15 +48,7 @@
48
48
  {
49
49
  "value": "react",
50
50
  "label": "React - UI library for building components"
51
- },
52
- {
53
- "value": "ds",
54
- "label": "Kaltura DS - Design System (requires GIT_TOKEN)"
55
- },
56
- {
57
- "value": "mui",
58
- "label": "Material UI - Component library"
59
- }
51
+ }
60
52
  ]
61
53
  }
62
54
  }
@@ -6,10 +6,10 @@ import {
6
6
  import { Root } from 'react-dom/client';
7
7
  import { Runtime } from './runtime';
8
8
 
9
- class ContextFactory extends UnisphereElementFactory<Record<string, any>, Root> {
10
- create<T extends Record<string, any>>(
11
- options: CreateElementOptions<T>
12
- ): UnisphereElementBase<T, Root> {
9
+ class ContextFactory extends UnisphereElementFactory<any, Root> {
10
+ create(
11
+ options: CreateElementOptions<any>
12
+ ): UnisphereElementBase<any, Root> {
13
13
  switch (options.flavor) {
14
14
  default:
15
15
  return new Runtime(options) as any;
@@ -10,7 +10,7 @@ import {
10
10
  <%= runtimeName__pascalCase %>RuntimeSettings,
11
11
  <%= runtimeName__camelCase %>RuntimeSettingsSchema,
12
12
  } from '<%= typesAlias %>';
13
- import { HtmlDomRuntimeVisual } from '@unisphere/runtime';
13
+ import { HtmlDomRuntimeVisual, KalturaAnalyticsServiceType } from '@unisphere/runtime';
14
14
  import { widgetName } from '<%= typesAlias %>'
15
15
 
16
16
  export class Runtime
@@ -42,6 +42,28 @@ export class Runtime
42
42
  runtimeName: this.runtimeName,
43
43
  },
44
44
  });
45
+
46
+
47
+ const analyticsAppId: null | number = <%= analyticsAppId ? analyticsAppId : 'null' %>;
48
+ if (!analyticsAppId) {
49
+ this._logger.warn(`missing kaltura analytics app id, cannot register application to analytics service`)
50
+ } else {
51
+ const service = this._options
52
+ .getWorkspace()
53
+ .getService<KalturaAnalyticsServiceType>(
54
+ 'unisphere.service.kaltura-analytics'
55
+ );
56
+
57
+ if (service) {
58
+ service.registerUnisphereApp({
59
+ analyticsAppId,
60
+ appVersion: this._options.runtimeVersion,
61
+ mode: process.env.NODE_ENV === 'production' ? undefined : 'dryRun',
62
+ });
63
+ } else {
64
+ this._logger.warn('missing kaltura analytics service, cannot register analytics application id <%= analyticsAppId %>')
65
+ }
66
+ }
45
67
  }
46
68
 
47
69
  override _createVisualContainer(htmlElement: HTMLElement): Root {
@@ -60,6 +82,8 @@ export class Runtime
60
82
  }
61
83
 
62
84
  protected _onSettingsUpdated(settings: <%= runtimeName__pascalCase %>RuntimeSettings) {
63
- // remove if not needed
85
+ // use this method to react to settings changes. for example:
86
+ // this._reMountVisualByType('your-visual-type');
87
+ // this._reMountAllVisuals();
64
88
  }
65
89
  }
@@ -3,6 +3,6 @@ import { AddVisualGeneratorSchema } from './schema';
3
3
  /**
4
4
  * Nx generator to create a new visual within a specified runtime.
5
5
  */
6
- export declare function addVisualGenerator(tree: Tree, options: AddVisualGeneratorSchema): Promise<void>;
6
+ export declare function addVisualGenerator(tree: Tree, options: AddVisualGeneratorSchema): Promise<any>;
7
7
  export default addVisualGenerator;
8
8
  //# sourceMappingURL=add-visual.d.ts.map
@@ -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;AAuUpD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,IAAI,CAAC,CAoEf;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;AAwbpD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,GAAG,CAAC,CAoFd;AAED,eAAe,kBAAkB,CAAC"}
@@ -7,6 +7,54 @@ 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;
18
+ }
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');
24
+ }
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;
37
+ }
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;
49
+ }
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
+ }
10
58
  /**
11
59
  * Adds necessary imports (runtimeVisualSettings, runtimeVisualSchema) to the runtime file.
12
60
  */
@@ -121,11 +169,61 @@ function addRenderMethod(sourceFilePath, tree, vars, project, typesPackageInfo)
121
169
  const sourceFile = (0, visual_utils_1.loadSourceFile)(tree, sourceFilePath, project);
122
170
  const methodName = `_render${vars.visualName__pascalCase}`;
123
171
  const clazz = (0, visual_utils_1.findFirstClass)(sourceFile);
172
+ // Always check and add required imports first (even if method exists)
173
+ let importsModified = false;
174
+ // Check if ThemeProvider import exists, add if missing
175
+ const themeProviderImportExists = sourceFile
176
+ .getImportDeclarations()
177
+ .some((decl) => decl.getModuleSpecifier().getLiteralValue() ===
178
+ '@kaltura/ds-react-theme' &&
179
+ decl.getNamedImports().some((imp) => imp.getName() === 'ThemeProvider'));
180
+ if (!themeProviderImportExists) {
181
+ sourceFile.addImportDeclaration({
182
+ kind: ts_morph_1.StructureKind.ImportDeclaration,
183
+ namedImports: ['ThemeProvider'],
184
+ moduleSpecifier: '@kaltura/ds-react-theme',
185
+ });
186
+ console.log(`✅ Added ThemeProvider import to ${sourceFilePath}`);
187
+ importsModified = true;
188
+ }
189
+ // Check if ScopedUnisphereWorkspaceProvider import exists, add if missing
190
+ const scopedProviderImportExists = sourceFile
191
+ .getImportDeclarations()
192
+ .some((decl) => decl.getModuleSpecifier().getLiteralValue() ===
193
+ '@unisphere/runtime-react' &&
194
+ decl
195
+ .getNamedImports()
196
+ .some((imp) => imp.getName() === 'ScopedUnisphereWorkspaceProvider'));
197
+ if (!scopedProviderImportExists) {
198
+ // Check if there's already an import from @unisphere/runtime-react
199
+ const existingRuntimeReactImport = sourceFile
200
+ .getImportDeclarations()
201
+ .find((decl) => decl.getModuleSpecifier().getLiteralValue() ===
202
+ '@unisphere/runtime-react');
203
+ if (existingRuntimeReactImport) {
204
+ // Add to existing import
205
+ existingRuntimeReactImport.addNamedImport('ScopedUnisphereWorkspaceProvider');
206
+ }
207
+ else {
208
+ // Create new import
209
+ sourceFile.addImportDeclaration({
210
+ kind: ts_morph_1.StructureKind.ImportDeclaration,
211
+ namedImports: ['ScopedUnisphereWorkspaceProvider'],
212
+ moduleSpecifier: '@unisphere/runtime-react',
213
+ });
214
+ }
215
+ console.log(`✅ Added ScopedUnisphereWorkspaceProvider import to ${sourceFilePath}`);
216
+ importsModified = true;
217
+ }
124
218
  // Check if method already exists.
125
219
  const exists = clazz
126
220
  .getInstanceMethods()
127
221
  .some((m) => m.getName() === methodName);
128
222
  if (exists) {
223
+ // Save imports if they were modified, even though method exists
224
+ if (importsModified) {
225
+ (0, visual_utils_1.saveSourceFile)(tree, sourceFilePath, sourceFile.getFullText());
226
+ }
129
227
  console.log(`⚠️ Method ${methodName} already exists.`);
130
228
  return;
131
229
  }
@@ -147,20 +245,6 @@ function addRenderMethod(sourceFilePath, tree, vars, project, typesPackageInfo)
147
245
  statements: processedContent,
148
246
  scope: ts_morph_1.Scope.Private,
149
247
  });
150
- // Check if ThemeProvider import exists, add if missing
151
- const themeProviderImportExists = sourceFile
152
- .getImportDeclarations()
153
- .some((decl) => decl.getModuleSpecifier().getLiteralValue() ===
154
- '@kaltura/ds-react-theme' &&
155
- decl.getNamedImports().some((imp) => imp.getName() === 'ThemeProvider'));
156
- if (!themeProviderImportExists) {
157
- sourceFile.addImportDeclaration({
158
- kind: ts_morph_1.StructureKind.ImportDeclaration,
159
- namedImports: ['ThemeProvider'],
160
- moduleSpecifier: '@kaltura/ds-react-theme',
161
- });
162
- console.log(`✅ Added ThemeProvider import to ${sourceFilePath}`);
163
- }
164
248
  (0, visual_utils_1.saveSourceFile)(tree, sourceFilePath, sourceFile.getFullText());
165
249
  console.log(`✅ Added render method ${methodName}.`);
166
250
  }
@@ -201,8 +285,14 @@ export const ${schemaName}: ValidatorSchema = {
201
285
  * Nx generator to create a new visual within a specified runtime.
202
286
  */
203
287
  async function addVisualGenerator(tree, options) {
204
- const { runtimeName, visualName, isSingleOccurrence } = options;
288
+ // Validate and read .unisphere configuration first
205
289
  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);
206
296
  // Extract environment variables
207
297
  const widgetName = unisphereConfig.name;
208
298
  // Validate runtime existence and get source root path.
@@ -249,5 +339,8 @@ async function addVisualGenerator(tree, options) {
249
339
  console.log(` Visual: ${visualName}`);
250
340
  console.log(` Single occurrence: ${isSingleOccurrence ? 'Yes' : 'No'}`);
251
341
  console.log(` Modified file: ${runtimeTSxPath}`);
342
+ return () => {
343
+ return { visualName };
344
+ };
252
345
  }
253
346
  exports.default = addVisualGenerator;
@@ -1,5 +1,5 @@
1
1
  export interface AddVisualGeneratorSchema {
2
- runtimeName: string;
3
- visualName: string;
4
- isSingleOccurrence: boolean;
2
+ runtimeName?: string;
3
+ visualName?: string;
4
+ isSingleOccurrence?: boolean;
5
5
  }
@@ -3,28 +3,6 @@
3
3
  "$id": "AddVisual",
4
4
  "title": "Add Visual Generator",
5
5
  "type": "object",
6
- "properties": {
7
- "runtimeName": {
8
- "type": "string",
9
- "description": "Name of the runtime",
10
- "x-prompt": "What is the runtime name?"
11
- },
12
- "visualName": {
13
- "type": "string",
14
- "description": "Name of the visual",
15
- "x-prompt": "What is the visual name?"
16
- },
17
- "isSingleOccurrence": {
18
- "type": "boolean",
19
- "description": "Is this visual limited to single occurrence?",
20
- "x-prompt": {
21
- "message": "Is this visual limited to single occurrence?",
22
- "type": "confirmation"
23
- }
24
- }
25
- },
26
- "required": [
27
- "runtimeName",
28
- "isSingleOccurrence"
29
- ]
6
+ "properties": {},
7
+ "required": []
30
8
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dependency-config.d.ts","sourceRoot":"","sources":["../../src/generators/dependency-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAU,MAAM,YAAY,CAAC;AAI1C;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,MAAM,EACN;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAgDjE,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,oBAAoB,EAAE,MAAM,EAAE,GAAG,IAAI,CAkBrE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,oBAAoB,EAAE,MAAM,EAAE,GAC7B,MAAM,CAiBR;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,IAAI,EACV,oBAAoB,EAAE,MAAM,EAAE,GAC7B,IAAI,CA4EN"}
1
+ {"version":3,"file":"dependency-config.d.ts","sourceRoot":"","sources":["../../src/generators/dependency-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAU,MAAM,YAAY,CAAC;AAI1C;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,MAAM,EACN;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAgDjE,CAAC;AAGF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,oBAAoB,EAAE,MAAM,EAAE,GAAG,IAAI,CAkBrE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,oBAAoB,EAAE,MAAM,EAAE,GAC7B,MAAM,CAiBR;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,IAAI,EACV,oBAAoB,EAAE,MAAM,EAAE,GAC7B,IAAI,CA4EN"}
@@ -58,6 +58,7 @@ exports.DEPENDENCY_MAP = {
58
58
  },
59
59
  },
60
60
  };
61
+ // TODO: change it to validate as --jfrogToken??
61
62
  /**
62
63
  * Validates that GIT_TOKEN environment variable exists when Kaltura DS is selected
63
64
  * @throws Error if GIT_TOKEN is not found
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export default function testMigrationGenerator(tree: Tree): Promise<void>;
3
+ //# sourceMappingURL=generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generators/internal-dev-runner/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAalC,wBAA8B,sBAAsB,CAAC,IAAI,EAAE,IAAI,iBAsC9D"}