@unisphere/nx 2.2.2 → 3.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generators/add-application/add-application.d.ts.map +1 -1
- package/dist/generators/add-application/add-application.js +186 -63
- package/dist/generators/add-application/schema.d.ts +3 -1
- package/dist/generators/add-application/schema.json +8 -8
- package/dist/generators/add-application/templates/default/.env-template +6 -0
- package/dist/generators/add-application/templates/default/.eslintrc.json +1 -1
- package/dist/generators/add-application/templates/default/jest.config.ts +3 -3
- package/dist/generators/add-application/templates/default/project.json.template +2 -2
- package/dist/generators/add-application/templates/default/readme.md.template +11 -0
- package/dist/generators/add-application/templates/default/src/app/app.tsx.template +77 -77
- package/dist/generators/add-application/templates/default/tsconfig.json +1 -1
- package/dist/generators/add-application/templates/default/webpack.config.js.template +6 -1
- package/dist/generators/add-package/README.md +2 -2
- package/dist/generators/add-package/add-package.d.ts.map +1 -1
- package/dist/generators/add-package/add-package.js +11 -23
- package/dist/generators/add-package/schema.d.ts +1 -1
- package/dist/generators/add-package/schema.json +27 -19
- package/dist/generators/add-package/templates/new-package/.eslintrc.json +1 -1
- package/dist/generators/add-package/templates/new-package/package.json.template +0 -1
- package/dist/generators/add-package/templates/new-package/project.json.template +4 -4
- package/dist/generators/add-package/templates/new-package/rollup.config.js +1 -1
- package/dist/generators/add-package/templates/new-package/tsconfig.json +1 -1
- package/dist/generators/add-package/templates/new-package/tsconfig.lib.json.template +1 -1
- package/dist/generators/add-package/templates/new-package/tsconfig.spec.json +1 -1
- package/dist/generators/add-runtime/add-runtime.d.ts.map +1 -1
- package/dist/generators/add-runtime/add-runtime.js +62 -9
- package/dist/generators/add-runtime/schema.d.ts +1 -0
- package/dist/generators/add-runtime/schema.json +1 -9
- package/dist/generators/add-runtime/templates/new-runtime/src/lib/create-factory.tsx.template +4 -4
- package/dist/generators/add-runtime/templates/new-runtime/src/lib/runtime.tsx.template +26 -2
- package/dist/generators/add-visual/add-visual.d.ts +1 -1
- package/dist/generators/add-visual/add-visual.d.ts.map +1 -1
- package/dist/generators/add-visual/add-visual.js +108 -15
- package/dist/generators/add-visual/schema.d.ts +3 -3
- package/dist/generators/add-visual/schema.json +2 -24
- package/dist/generators/dependency-config.d.ts.map +1 -1
- package/dist/generators/dependency-config.js +1 -0
- package/dist/generators/internal-dev-runner/generator.d.ts +3 -0
- package/dist/generators/internal-dev-runner/generator.d.ts.map +1 -0
- package/dist/generators/internal-dev-runner/generator.js +47 -0
- package/dist/generators/internal-dev-runner/schema.json +9 -0
- package/dist/generators/remove/remove.d.ts +19 -0
- package/dist/generators/remove/remove.d.ts.map +1 -0
- package/dist/generators/remove/remove.js +270 -0
- package/dist/generators/remove/schema.d.ts +4 -0
- package/dist/generators/remove/schema.json +38 -0
- package/dist/generators/rename-package/rename-package.d.ts +3 -0
- package/dist/generators/rename-package/rename-package.d.ts.map +1 -1
- package/dist/generators/rename-package/rename-package.js +139 -20
- package/dist/generators/utils.d.ts +30 -1
- package/dist/generators/utils.d.ts.map +1 -1
- package/dist/generators/utils.js +258 -7
- package/dist/migrations/1-22-0/patches/@changesets+cli+2.29.7.patch +36 -4
- package/dist/migrations/3-0-0/add-define-plugin-to-webpack.d.ts +3 -0
- package/dist/migrations/3-0-0/add-define-plugin-to-webpack.d.ts.map +1 -0
- package/dist/migrations/3-0-0/add-define-plugin-to-webpack.js +233 -0
- package/dist/migrations/3-0-0/add-env-to-application-gitignore.d.ts +3 -0
- package/dist/migrations/3-0-0/add-env-to-application-gitignore.d.ts.map +1 -0
- package/dist/migrations/3-0-0/add-env-to-application-gitignore.js +117 -0
- package/dist/migrations/3-0-0/fix-vite-config-cache-paths.d.ts +10 -0
- package/dist/migrations/3-0-0/fix-vite-config-cache-paths.d.ts.map +1 -0
- package/dist/migrations/3-0-0/fix-vite-config-cache-paths.js +66 -0
- package/dist/migrations/3-0-0/patches/@changesets+cli+2.29.7.patch +88 -0
- package/dist/migrations/3-0-0/post-cleanup-empty-directories.d.ts +12 -0
- package/dist/migrations/3-0-0/post-cleanup-empty-directories.d.ts.map +1 -0
- package/dist/migrations/3-0-0/post-cleanup-empty-directories.js +62 -0
- package/dist/migrations/3-0-0/pre-cleanup-empty-directories.d.ts +14 -0
- package/dist/migrations/3-0-0/pre-cleanup-empty-directories.d.ts.map +1 -0
- package/dist/migrations/3-0-0/pre-cleanup-empty-directories.js +105 -0
- package/dist/migrations/3-0-0/remove-kaltura-tools-to-pre-install.d.ts +3 -0
- package/dist/migrations/3-0-0/remove-kaltura-tools-to-pre-install.d.ts.map +1 -0
- package/dist/migrations/3-0-0/remove-kaltura-tools-to-pre-install.js +21 -0
- package/dist/migrations/3-0-0/remove-private-from-applications-and-runtimes.d.ts +9 -0
- package/dist/migrations/3-0-0/remove-private-from-applications-and-runtimes.d.ts.map +1 -0
- package/dist/migrations/3-0-0/remove-private-from-applications-and-runtimes.js +88 -0
- package/dist/migrations/3-0-0/remove-publish-config-from-packages.d.ts +9 -0
- package/dist/migrations/3-0-0/remove-publish-config-from-packages.d.ts.map +1 -0
- package/dist/migrations/3-0-0/remove-publish-config-from-packages.js +45 -0
- package/dist/migrations/3-0-0/reorganize-applications-by-distribution-channel.d.ts +15 -0
- package/dist/migrations/3-0-0/reorganize-applications-by-distribution-channel.d.ts.map +1 -0
- package/dist/migrations/3-0-0/reorganize-applications-by-distribution-channel.js +563 -0
- package/dist/migrations/3-0-0/reorganize-packages-by-distribution-channel.d.ts +23 -0
- package/dist/migrations/3-0-0/reorganize-packages-by-distribution-channel.d.ts.map +1 -0
- package/dist/migrations/3-0-0/reorganize-packages-by-distribution-channel.js +645 -0
- package/dist/migrations/3-0-0/replace-github-workflow.d.ts +3 -0
- package/dist/migrations/3-0-0/replace-github-workflow.d.ts.map +1 -0
- package/dist/migrations/3-0-0/replace-github-workflow.js +48 -0
- package/dist/migrations/3-0-0/sync-package-lock.d.ts +10 -0
- package/dist/migrations/3-0-0/sync-package-lock.d.ts.map +1 -0
- package/dist/migrations/3-0-0/sync-package-lock.js +26 -0
- package/dist/migrations/3-0-0/templates/_publish-artifacts.template +363 -0
- package/dist/migrations/3-0-0/templates/cicd.template +89 -0
- package/dist/migrations/3-0-0/update-changeset-patch.d.ts +3 -0
- package/dist/migrations/3-0-0/update-changeset-patch.d.ts.map +1 -0
- package/dist/migrations/3-0-0/update-changeset-patch.js +31 -0
- package/dist/migrations/3-0-0/upgrade-schema-to-2-0-0.d.ts +21 -0
- package/dist/migrations/3-0-0/upgrade-schema-to-2-0-0.d.ts.map +1 -0
- package/dist/migrations/3-0-0/upgrade-schema-to-2-0-0.js +105 -0
- package/dist/migrations/3-1-0/fix-workspaces-pattern.d.ts +23 -0
- package/dist/migrations/3-1-0/fix-workspaces-pattern.d.ts.map +1 -0
- package/dist/migrations/3-1-0/fix-workspaces-pattern.js +72 -0
- package/dist/migrations/utils/has-react-dependency.d.ts +14 -0
- package/dist/migrations/utils/has-react-dependency.d.ts.map +1 -0
- package/dist/migrations/utils/has-react-dependency.js +72 -0
- package/dist/shared.d.ts +6 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +9 -0
- package/generators.json +12 -1
- package/migrations.json +125 -0
- package/package.json +3 -2
- package/dist/generators/add-application/templates/local-dev-playground/.babelrc +0 -11
- package/dist/generators/add-application/templates/local-dev-playground/.eslintrc.json +0 -22
- package/dist/generators/add-application/templates/local-dev-playground/jest.config.ts +0 -11
- package/dist/generators/add-application/templates/local-dev-playground/package.json +0 -6
- package/dist/generators/add-application/templates/local-dev-playground/project.json +0 -9
- package/dist/generators/add-application/templates/local-dev-playground/src/app/app.tsx.template +0 -212
- package/dist/generators/add-application/templates/local-dev-playground/src/app/components/header.tsx.template +0 -123
- package/dist/generators/add-application/templates/local-dev-playground/src/app/components/settings-buttons.tsx +0 -57
- package/dist/generators/add-application/templates/local-dev-playground/src/app/components/settings-form.tsx +0 -108
- package/dist/generators/add-application/templates/local-dev-playground/src/app/components/settings.tsx +0 -74
- package/dist/generators/add-application/templates/local-dev-playground/src/app/configuration-provider.tsx +0 -163
- package/dist/generators/add-application/templates/local-dev-playground/src/app/definitions.ts +0 -25
- package/dist/generators/add-application/templates/local-dev-playground/src/app/utils/merge-deep.ts +0 -31
- package/dist/generators/add-application/templates/local-dev-playground/src/favicon.ico +0 -0
- package/dist/generators/add-application/templates/local-dev-playground/src/index.html +0 -17
- package/dist/generators/add-application/templates/local-dev-playground/src/main.tsx +0 -13
- package/dist/generators/add-application/templates/local-dev-playground/src/styles.css +0 -0
- package/dist/generators/add-application/templates/local-dev-playground/tsconfig.app.json +0 -24
- package/dist/generators/add-application/templates/local-dev-playground/tsconfig.json +0 -20
- package/dist/generators/add-application/templates/local-dev-playground/tsconfig.spec.json +0 -25
- package/dist/generators/add-application/templates/local-dev-playground/webpack.config.js +0 -33
- /package/dist/generators/add-runtime/templates/{core-templates → types-templates}/__runtimeName__-runtime/index.ts.template +0 -0
- /package/dist/generators/add-runtime/templates/{core-templates → types-templates}/__runtimeName__-runtime/runtime-types.ts.template +0 -0
|
@@ -3,28 +3,6 @@
|
|
|
3
3
|
"$id": "AddVisual",
|
|
4
4
|
"title": "Add Visual Generator",
|
|
5
5
|
"type": "object",
|
|
6
|
-
"properties": {
|
|
7
|
-
|
|
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;
|
|
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"}
|
|
@@ -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;AAclC,wBAA8B,sBAAsB,CAAC,IAAI,EAAE,IAAI,iBAuC9D"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = testMigrationGenerator;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Import the migrations to test
|
|
6
|
+
// import addEnvToGitignore from '../../migrations/3-0-0/add-env-to-application-gitignore';
|
|
7
|
+
// import addDefinePluginToWebpack from '../../migrations/3-0-0/add-define-plugin-to-webpack';
|
|
8
|
+
// import upgradeCliToV2 from '../../migrations/3-0-0/upgrade-cli-to-v2';
|
|
9
|
+
// import preCleanupEmptyDirectories from '../../migrations/3-0-0/pre-cleanup-empty-directories';
|
|
10
|
+
// import reorganizePackagesByDistributionChannel from '../../migrations/3-0-0/reorganize-packages-by-distribution-channel';
|
|
11
|
+
// import reorganizeApplicationsByDistributionChannel from '../../migrations/3-0-0/reorganize-applications-by-distribution-channel';
|
|
12
|
+
// import upgradeSchemaTo2 from '../../migrations/3-0-0/upgrade-schema-to-2-0-0';
|
|
13
|
+
// import postCleanupEmptyDirectories from '../../migrations/3-0-0/post-cleanup-empty-directories';
|
|
14
|
+
// import removePrivateFromApplicationsAndRuntimes from '../../migrations/3-0-0/remove-private-from-applications-and-runtimes';
|
|
15
|
+
const fix_workspaces_pattern_1 = tslib_1.__importDefault(require("../../migrations/3-1-0/fix-workspaces-pattern"));
|
|
16
|
+
async function testMigrationGenerator(tree) {
|
|
17
|
+
// Collect all callbacks to run after all migrations complete
|
|
18
|
+
// const callbacks: (() => void)[] = [];
|
|
19
|
+
// Upgrade CLI to v2 first (needed for other migrations)
|
|
20
|
+
// const upgradeCliCallback = await upgradeCliToV2(tree);
|
|
21
|
+
// if (upgradeCliCallback) {
|
|
22
|
+
// callbacks.push(upgradeCliCallback);
|
|
23
|
+
// }
|
|
24
|
+
// Pre-cleanup: Remove empty directories before reorganization
|
|
25
|
+
// await preCleanupEmptyDirectories(tree);
|
|
26
|
+
// Reorganize packages by distribution channel (also handles core->types rename and -react suffix)
|
|
27
|
+
// await reorganizePackagesByDistributionChannel(tree);
|
|
28
|
+
// // Reorganize applications by distribution channel
|
|
29
|
+
// await reorganizeApplicationsByDistributionChannel(tree);
|
|
30
|
+
// Upgrade schema to 2.0.0 and remove distributionChannel from packages
|
|
31
|
+
// await upgradeSchemaTo2(tree);
|
|
32
|
+
// Remove private field from applications, runtimes, and packages
|
|
33
|
+
// await removePrivateFromApplicationsAndRuntimes(tree);
|
|
34
|
+
await (0, fix_workspaces_pattern_1.default)(tree);
|
|
35
|
+
// Post-cleanup: Remove empty directories after reorganization
|
|
36
|
+
// const postCleanupCallback = await postCleanupEmptyDirectories(tree);
|
|
37
|
+
// if (postCleanupCallback) {
|
|
38
|
+
// callbacks.push(postCleanupCallback);
|
|
39
|
+
// }
|
|
40
|
+
// Run all callbacks at the end
|
|
41
|
+
// Note: In Nx generators, Tree changes are written when the generator completes.
|
|
42
|
+
// These callbacks run after all migrations but before the generator finishes.
|
|
43
|
+
// For file system operations (like npm install), they should work correctly.
|
|
44
|
+
// for (const callback of callbacks) {
|
|
45
|
+
// callback();
|
|
46
|
+
// }
|
|
47
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remove Generator
|
|
3
|
+
*
|
|
4
|
+
* This generator removes a Unisphere element (package, runtime, or application) by:
|
|
5
|
+
* 1. Validating the element exists in .unisphere configuration
|
|
6
|
+
* 2. Using Nx's built-in remove generator to delete the project
|
|
7
|
+
* 3. Performing Unisphere-specific cleanup:
|
|
8
|
+
* - Removing from .unisphere configuration
|
|
9
|
+
* - For runtimes: removing types from types/core package and updating index.ts exports
|
|
10
|
+
* - Updating tsconfig.base.json path mappings
|
|
11
|
+
* - Updating package-lock.json
|
|
12
|
+
*
|
|
13
|
+
* Usage: nx g @unisphere/nx:remove runtime:admin
|
|
14
|
+
*/
|
|
15
|
+
import { Tree } from '@nx/devkit';
|
|
16
|
+
import { RemoveGeneratorSchema } from './schema';
|
|
17
|
+
export declare function removeGenerator(tree: Tree, options: RemoveGeneratorSchema): Promise<void>;
|
|
18
|
+
export default removeGenerator;
|
|
19
|
+
//# sourceMappingURL=remove.d.ts.map
|
|
@@ -0,0 +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;AAmQjD,wBAAsB,eAAe,CACnC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,qBAAqB,iBA6E/B;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Remove Generator
|
|
4
|
+
*
|
|
5
|
+
* This generator removes a Unisphere element (package, runtime, or application) by:
|
|
6
|
+
* 1. Validating the element exists in .unisphere configuration
|
|
7
|
+
* 2. Using Nx's built-in remove generator to delete the project
|
|
8
|
+
* 3. Performing Unisphere-specific cleanup:
|
|
9
|
+
* - Removing from .unisphere configuration
|
|
10
|
+
* - For runtimes: removing types from types/core package and updating index.ts exports
|
|
11
|
+
* - Updating tsconfig.base.json path mappings
|
|
12
|
+
* - Updating package-lock.json
|
|
13
|
+
*
|
|
14
|
+
* Usage: nx g @unisphere/nx:remove runtime:admin
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.removeGenerator = removeGenerator;
|
|
18
|
+
const devkit_1 = require("@nx/devkit");
|
|
19
|
+
const generators_1 = require("@nx/workspace/generators");
|
|
20
|
+
const utils_1 = require("../utils");
|
|
21
|
+
const VALID_ELEMENT_TYPES = ['package', 'runtime', 'application'];
|
|
22
|
+
/**
|
|
23
|
+
* Parse the element string in format "type:name"
|
|
24
|
+
*/
|
|
25
|
+
function parseElement(element) {
|
|
26
|
+
const parts = element.split(':');
|
|
27
|
+
if (parts.length !== 2) {
|
|
28
|
+
throw new Error(`Invalid element format: "${element}"\n` +
|
|
29
|
+
`Expected format: type:name (e.g., runtime:admin, package:shared, application:my-app)`);
|
|
30
|
+
}
|
|
31
|
+
const [type, name] = parts;
|
|
32
|
+
if (!VALID_ELEMENT_TYPES.includes(type)) {
|
|
33
|
+
throw new Error(`Invalid element type: "${type}"\n` +
|
|
34
|
+
`Valid types: ${VALID_ELEMENT_TYPES.join(', ')}`);
|
|
35
|
+
}
|
|
36
|
+
if (!name || name.trim() === '') {
|
|
37
|
+
throw new Error(`Element name is required.\n` +
|
|
38
|
+
`Expected format: type:name (e.g., runtime:admin)`);
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
elementType: type,
|
|
42
|
+
name: name.trim(),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get the configuration key for element type in .unisphere
|
|
47
|
+
*/
|
|
48
|
+
function getElementsConfigKey(elementType) {
|
|
49
|
+
const mapping = {
|
|
50
|
+
package: 'packages',
|
|
51
|
+
runtime: 'runtimes',
|
|
52
|
+
application: 'applications',
|
|
53
|
+
};
|
|
54
|
+
return mapping[elementType];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get the Nx project name prefix for element type
|
|
58
|
+
*/
|
|
59
|
+
function getNxProjectPrefix(elementType) {
|
|
60
|
+
const mapping = {
|
|
61
|
+
package: 'unisphere-package',
|
|
62
|
+
runtime: 'unisphere-runtime',
|
|
63
|
+
application: 'unisphere-application',
|
|
64
|
+
};
|
|
65
|
+
return mapping[elementType];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Validates that the element exists in .unisphere configuration
|
|
69
|
+
*/
|
|
70
|
+
function validateElementExists(tree, elementType, elementName) {
|
|
71
|
+
const unisphereConfig = (0, devkit_1.readJson)(tree, '.unisphere');
|
|
72
|
+
const normalizedName = (0, devkit_1.names)(elementName).fileName;
|
|
73
|
+
const configKey = getElementsConfigKey(elementType);
|
|
74
|
+
const elementConfig = unisphereConfig.elements?.[configKey]?.[normalizedName];
|
|
75
|
+
if (!elementConfig) {
|
|
76
|
+
const availableElements = Object.keys(unisphereConfig.elements?.[configKey] || {});
|
|
77
|
+
throw new Error(`${elementType.charAt(0).toUpperCase() + elementType.slice(1)} "${normalizedName}" not found in .unisphere configuration.\n` +
|
|
78
|
+
`Available ${configKey}: ${availableElements.length > 0 ? availableElements.join(', ') : '(none)'}`);
|
|
79
|
+
}
|
|
80
|
+
if (!elementConfig.sourceRoot) {
|
|
81
|
+
throw new Error(`${elementType.charAt(0).toUpperCase() + elementType.slice(1)} "${normalizedName}" exists but has no sourceRoot configured in .unisphere`);
|
|
82
|
+
}
|
|
83
|
+
return elementConfig.sourceRoot;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Remove element from .unisphere configuration
|
|
87
|
+
*/
|
|
88
|
+
function removeFromUnisphereConfig(tree, elementType, elementName) {
|
|
89
|
+
const unisphereConfig = (0, devkit_1.readJson)(tree, '.unisphere');
|
|
90
|
+
const configKey = getElementsConfigKey(elementType);
|
|
91
|
+
const normalizedName = (0, devkit_1.names)(elementName).fileName;
|
|
92
|
+
if (unisphereConfig.elements?.[configKey]?.[normalizedName]) {
|
|
93
|
+
delete unisphereConfig.elements[configKey][normalizedName];
|
|
94
|
+
(0, devkit_1.writeJson)(tree, '.unisphere', unisphereConfig);
|
|
95
|
+
devkit_1.logger.info(`Removed "${normalizedName}" from .unisphere configuration`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Remove runtime types from types/core package
|
|
100
|
+
*/
|
|
101
|
+
function removeRuntimeTypes(tree, runtimeName) {
|
|
102
|
+
const typesPackageInfo = (0, utils_1.findTypesOrCorePackageInfo)(tree);
|
|
103
|
+
const normalizedName = (0, devkit_1.names)(runtimeName).fileName;
|
|
104
|
+
// Remove the runtime types directory
|
|
105
|
+
const runtimeTypesDir = `${typesPackageInfo.basePath}/src/lib/${normalizedName}-runtime`;
|
|
106
|
+
if (tree.exists(runtimeTypesDir)) {
|
|
107
|
+
// Delete all files in the directory
|
|
108
|
+
tree.children(runtimeTypesDir).forEach(child => {
|
|
109
|
+
tree.delete(`${runtimeTypesDir}/${child}`);
|
|
110
|
+
});
|
|
111
|
+
devkit_1.logger.info(`Removed runtime types directory: ${runtimeTypesDir}`);
|
|
112
|
+
}
|
|
113
|
+
// Update the index.ts to remove the export
|
|
114
|
+
const indexPath = `${typesPackageInfo.basePath}/src/index.ts`;
|
|
115
|
+
if (tree.exists(indexPath)) {
|
|
116
|
+
const content = tree.read(indexPath, 'utf-8');
|
|
117
|
+
if (content) {
|
|
118
|
+
const exportLine = `export * from './lib/${normalizedName}-runtime';`;
|
|
119
|
+
const exportLineWithNewline = `\n${exportLine}`;
|
|
120
|
+
let updatedContent = content;
|
|
121
|
+
// Remove the export line (handle both with and without leading newline)
|
|
122
|
+
if (content.includes(exportLineWithNewline)) {
|
|
123
|
+
updatedContent = content.replace(exportLineWithNewline, '');
|
|
124
|
+
}
|
|
125
|
+
else if (content.includes(exportLine)) {
|
|
126
|
+
updatedContent = content.replace(exportLine + '\n', '');
|
|
127
|
+
updatedContent = updatedContent.replace(exportLine, '');
|
|
128
|
+
}
|
|
129
|
+
if (updatedContent !== content) {
|
|
130
|
+
tree.write(indexPath, updatedContent);
|
|
131
|
+
devkit_1.logger.info(`Removed runtime export from ${indexPath}`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Remove path mapping from tsconfig.base.json
|
|
138
|
+
*/
|
|
139
|
+
function removeTsConfigPath(tree, elementType, elementName) {
|
|
140
|
+
const tsconfigPath = 'tsconfig.base.json';
|
|
141
|
+
if (!tree.exists(tsconfigPath)) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const tsconfig = (0, devkit_1.readJson)(tree, tsconfigPath);
|
|
145
|
+
const normalizedName = (0, devkit_1.names)(elementName).fileName;
|
|
146
|
+
if (!tsconfig.compilerOptions?.paths) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
// Determine the path key based on element type
|
|
150
|
+
let pathKeyPattern;
|
|
151
|
+
switch (elementType) {
|
|
152
|
+
case 'runtime':
|
|
153
|
+
pathKeyPattern = `unisphere-runtime-${normalizedName}`;
|
|
154
|
+
break;
|
|
155
|
+
case 'package':
|
|
156
|
+
// Packages may have various path patterns, we'll search for matching paths
|
|
157
|
+
pathKeyPattern = normalizedName;
|
|
158
|
+
break;
|
|
159
|
+
case 'application':
|
|
160
|
+
pathKeyPattern = `unisphere-application-${normalizedName}`;
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
let removed = false;
|
|
164
|
+
const pathsToRemove = [];
|
|
165
|
+
// Find all matching paths
|
|
166
|
+
for (const [key, paths] of Object.entries(tsconfig.compilerOptions.paths)) {
|
|
167
|
+
if (Array.isArray(paths)) {
|
|
168
|
+
const matchesPath = paths.some((p) => p.includes(`/${normalizedName}/`) || p.includes(`/${normalizedName}-`));
|
|
169
|
+
if (key.includes(pathKeyPattern) || matchesPath) {
|
|
170
|
+
pathsToRemove.push(key);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// Remove the paths
|
|
175
|
+
for (const key of pathsToRemove) {
|
|
176
|
+
delete tsconfig.compilerOptions.paths[key];
|
|
177
|
+
removed = true;
|
|
178
|
+
}
|
|
179
|
+
if (removed) {
|
|
180
|
+
(0, devkit_1.writeJson)(tree, tsconfigPath, tsconfig);
|
|
181
|
+
devkit_1.logger.info(`Removed path mapping(s) from tsconfig.base.json`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Remove entry from package-lock.json
|
|
186
|
+
*/
|
|
187
|
+
function removeFromPackageLock(tree, sourceRoot) {
|
|
188
|
+
const packageLockPath = 'package-lock.json';
|
|
189
|
+
if (!tree.exists(packageLockPath)) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const packageLock = (0, devkit_1.readJson)(tree, packageLockPath);
|
|
193
|
+
let updated = false;
|
|
194
|
+
if (packageLock.packages) {
|
|
195
|
+
if (packageLock.packages[sourceRoot]) {
|
|
196
|
+
delete packageLock.packages[sourceRoot];
|
|
197
|
+
updated = true;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (updated) {
|
|
201
|
+
(0, devkit_1.writeJson)(tree, packageLockPath, packageLock);
|
|
202
|
+
devkit_1.logger.info(`Removed entry from package-lock.json`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
async function removeGenerator(tree, options) {
|
|
206
|
+
// Validate .unisphere exists
|
|
207
|
+
(0, utils_1.validateUnisphereConfig)(tree);
|
|
208
|
+
// Parse element string (format: "type:name")
|
|
209
|
+
const { elementType, name } = parseElement(options.element);
|
|
210
|
+
const normalizedName = (0, devkit_1.names)(name).fileName;
|
|
211
|
+
// Validate element exists and get sourceRoot
|
|
212
|
+
const sourceRoot = validateElementExists(tree, elementType, normalizedName);
|
|
213
|
+
// Verify the directory exists
|
|
214
|
+
if (!tree.exists(sourceRoot)) {
|
|
215
|
+
devkit_1.logger.warn(`Directory not found at ${sourceRoot}. The .unisphere configuration may be out of sync.`);
|
|
216
|
+
}
|
|
217
|
+
const nxProjectName = `${getNxProjectPrefix(elementType)}-${normalizedName}`;
|
|
218
|
+
devkit_1.logger.info('');
|
|
219
|
+
devkit_1.logger.info(`Removing ${elementType}: ${normalizedName}`);
|
|
220
|
+
devkit_1.logger.info(` Location: ${sourceRoot}`);
|
|
221
|
+
devkit_1.logger.info('');
|
|
222
|
+
// Step 1: For runtimes, remove types first (before directory is deleted)
|
|
223
|
+
if (elementType === 'runtime') {
|
|
224
|
+
removeRuntimeTypes(tree, normalizedName);
|
|
225
|
+
}
|
|
226
|
+
// Step 2: Run Nx's built-in remove generator
|
|
227
|
+
try {
|
|
228
|
+
await (0, generators_1.removeGenerator)(tree, {
|
|
229
|
+
projectName: nxProjectName,
|
|
230
|
+
forceRemove: options.forceRemove || false,
|
|
231
|
+
skipFormat: false,
|
|
232
|
+
});
|
|
233
|
+
devkit_1.logger.info(`Removed Nx project "${nxProjectName}"`);
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
// If Nx remove fails (e.g., project not in project.json), continue with cleanup
|
|
237
|
+
devkit_1.logger.warn(`Nx remove failed: ${error}`);
|
|
238
|
+
devkit_1.logger.info('Continuing with Unisphere cleanup...');
|
|
239
|
+
// Manually delete the directory if it exists
|
|
240
|
+
if (tree.exists(sourceRoot)) {
|
|
241
|
+
// Delete all files recursively
|
|
242
|
+
const deleteRecursively = (dirPath) => {
|
|
243
|
+
if (tree.isFile(dirPath)) {
|
|
244
|
+
tree.delete(dirPath);
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
tree.children(dirPath).forEach(child => {
|
|
248
|
+
deleteRecursively(`${dirPath}/${child}`);
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
deleteRecursively(sourceRoot);
|
|
253
|
+
devkit_1.logger.info(`Manually deleted ${sourceRoot}`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
// Step 3: Remove from .unisphere configuration
|
|
257
|
+
removeFromUnisphereConfig(tree, elementType, normalizedName);
|
|
258
|
+
// Step 4: Remove path mapping from tsconfig.base.json
|
|
259
|
+
removeTsConfigPath(tree, elementType, normalizedName);
|
|
260
|
+
// Step 5: Remove entry from package-lock.json
|
|
261
|
+
removeFromPackageLock(tree, sourceRoot);
|
|
262
|
+
devkit_1.logger.info('');
|
|
263
|
+
devkit_1.logger.info(`${elementType.charAt(0).toUpperCase() + elementType.slice(1)} "${normalizedName}" removed successfully!`);
|
|
264
|
+
devkit_1.logger.info('');
|
|
265
|
+
devkit_1.logger.info('Next steps:');
|
|
266
|
+
devkit_1.logger.info(' 1. Run: npm install');
|
|
267
|
+
devkit_1.logger.info(' 2. Run: npm run build');
|
|
268
|
+
devkit_1.logger.info('');
|
|
269
|
+
}
|
|
270
|
+
exports.default = removeGenerator;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "Remove",
|
|
4
|
+
"title": "Remove Unisphere Element",
|
|
5
|
+
"description": "Remove a Unisphere element (package, runtime, or application) from the workspace",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"examples": [
|
|
8
|
+
{
|
|
9
|
+
"command": "nx g @unisphere/nx:remove package:my-package",
|
|
10
|
+
"description": "Remove a package named 'my-package'"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"command": "nx g @unisphere/nx:remove runtime:my-runtime",
|
|
14
|
+
"description": "Remove a runtime named 'my-runtime'"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"command": "nx g @unisphere/nx:remove application:my-app",
|
|
18
|
+
"description": "Remove an application named 'my-app'"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"properties": {
|
|
22
|
+
"element": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"description": "The element to remove in format 'type:name' (e.g., runtime:admin, package:shared, application:my-app)",
|
|
25
|
+
"$default": {
|
|
26
|
+
"$source": "argv",
|
|
27
|
+
"index": 0
|
|
28
|
+
},
|
|
29
|
+
"x-prompt": "Enter element to remove (format: type:name, e.g., runtime:admin):"
|
|
30
|
+
},
|
|
31
|
+
"forceRemove": {
|
|
32
|
+
"type": "boolean",
|
|
33
|
+
"description": "Force removal even if the element is still in use",
|
|
34
|
+
"default": false
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"required": ["element"]
|
|
38
|
+
}
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
* - Updating .unisphere configuration
|
|
11
11
|
* - Ensuring package.json name matches Unisphere conventions
|
|
12
12
|
* - Updating package-lock.json path keys (Nx doesn't handle this)
|
|
13
|
+
* - Updating vite.config.ts cache directory paths
|
|
14
|
+
* - Updating project.json lintFilePatterns and comments (Nx updates root/sourceRoot but not options strings)
|
|
15
|
+
* - Updating README.md with new package name
|
|
13
16
|
*/
|
|
14
17
|
import { Tree } from '@nx/devkit';
|
|
15
18
|
import { RenamePackageGeneratorSchema } from './schema';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rename-package.d.ts","sourceRoot":"","sources":["../../../src/generators/rename-package/rename-package.ts"],"names":[],"mappings":"AAAA
|
|
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;AAGpB,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAgZxD,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,4BAA4B,uBAmHtC;AAED,eAAe,sBAAsB,CAAC"}
|