@unisphere/nx 1.13.0 โ 1.18.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.
- package/dist/generators/add-package/add-package.js +1 -1
- package/dist/generators/add-runtime/add-runtime.d.ts.map +1 -1
- package/dist/generators/add-runtime/add-runtime.js +12 -14
- package/dist/generators/add-runtime/schema.d.ts +1 -1
- package/dist/generators/add-runtime/schema.json +9 -16
- package/dist/generators/add-runtime/templates/core-templates/__runtimeName__-runtime/runtime-types.ts.template +2 -2
- package/dist/generators/rename-package/rename-package.d.ts +18 -0
- package/dist/generators/rename-package/rename-package.d.ts.map +1 -0
- package/dist/generators/rename-package/rename-package.js +274 -0
- package/dist/generators/rename-package/schema.d.ts +4 -0
- package/dist/generators/rename-package/schema.json +23 -0
- package/generators.json +5 -0
- package/package.json +1 -1
|
@@ -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;
|
|
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;AAwCrD,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,yBAAyB,uBAqHnC;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -5,7 +5,6 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const path = tslib_1.__importStar(require("path"));
|
|
7
7
|
const utils_1 = require("../utils");
|
|
8
|
-
const add_package_1 = require("../add-package/add-package");
|
|
9
8
|
const add_application_1 = require("../add-application/add-application");
|
|
10
9
|
function updateCoreIndexExport(tree, runtimeName) {
|
|
11
10
|
const coreIndexPath = 'unisphere/packages/core/src/index.ts';
|
|
@@ -69,17 +68,17 @@ async function addRuntimeGenerator(tree, options) {
|
|
|
69
68
|
const runtimePathKey = `unisphere-runtime-${userInputRuntimeName}`;
|
|
70
69
|
const runtimePathValue = `unisphere/runtimes/${userInputRuntimeName}/src/index.ts`;
|
|
71
70
|
(0, utils_1.updateTsConfigPaths)(tree, runtimePathKey, runtimePathValue);
|
|
72
|
-
// Create a package with the same name as the runtime and distribution set to none
|
|
73
|
-
const packageResult = await
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
77
|
-
// Execute the package generation callback if it exists
|
|
78
|
-
if (packageResult && typeof packageResult === 'function') {
|
|
79
|
-
|
|
80
|
-
}
|
|
71
|
+
// // Create a package with the same name as the runtime and distribution set to none
|
|
72
|
+
// const packageResult = await addPackageGenerator(tree, {
|
|
73
|
+
// packageName: userInputRuntimeName,
|
|
74
|
+
// scope: 'none',
|
|
75
|
+
// });
|
|
76
|
+
// // Execute the package generation callback if it exists
|
|
77
|
+
// if (packageResult && typeof packageResult === 'function') {
|
|
78
|
+
// packageResult();
|
|
79
|
+
// }
|
|
81
80
|
// Handle loadedByExternalHost usage - create package and expo application
|
|
82
|
-
if (options.
|
|
81
|
+
if (options.standalone === true) {
|
|
83
82
|
// Create an expo application without prompts
|
|
84
83
|
const applicationResult = await (0, add_application_1.addApplicationGenerator)(tree, {
|
|
85
84
|
name: `${userInputRuntimeName}-expo`,
|
|
@@ -99,11 +98,10 @@ async function addRuntimeGenerator(tree, options) {
|
|
|
99
98
|
devkit_1.logger.info('');
|
|
100
99
|
devkit_1.logger.info(`๐ Runtime Name: ${userInputRuntimeName}`);
|
|
101
100
|
devkit_1.logger.info(`๐ Location: ${projectRoot}`);
|
|
102
|
-
devkit_1.logger.info(`๐ง
|
|
103
|
-
if (options.
|
|
101
|
+
devkit_1.logger.info(`๐ง Standalone: ${options.standalone ? 'Yes' : 'No'}`);
|
|
102
|
+
if (options.standalone === true) {
|
|
104
103
|
devkit_1.logger.info('');
|
|
105
104
|
devkit_1.logger.info('๐ฆ Additional components created:');
|
|
106
|
-
devkit_1.logger.info(` โข Package: ${userInputRuntimeName} (scope: none)`);
|
|
107
105
|
devkit_1.logger.info(` โข Expo Application: ${userInputRuntimeName}-expo`);
|
|
108
106
|
}
|
|
109
107
|
devkit_1.logger.info('');
|
|
@@ -10,24 +10,17 @@
|
|
|
10
10
|
"pattern": "^[a-zA-Z][a-zA-Z0-9\\-\\s]*$",
|
|
11
11
|
"x-prompt": "What's the runtime name? (letters, numbers, dashes and spaces allowed)"
|
|
12
12
|
},
|
|
13
|
-
"
|
|
14
|
-
"type": "
|
|
15
|
-
"description": "
|
|
13
|
+
"standalone": {
|
|
14
|
+
"type": "boolean",
|
|
15
|
+
"description": "Is this experience being loaded by the host application, or by another experience (not this one)?",
|
|
16
16
|
"x-prompt": {
|
|
17
|
-
"message": "
|
|
18
|
-
"type": "
|
|
19
|
-
"items": [
|
|
20
|
-
{
|
|
21
|
-
"value": "loadedByExternalHost",
|
|
22
|
-
"label": "Independent experience used as an entry point (loaded by host or another experience)"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"value": "composedIntoAnotherRuntime",
|
|
26
|
-
"label": "Composed into another runtime of this experience (not used as an entry point)"
|
|
27
|
-
}
|
|
28
|
-
]
|
|
17
|
+
"message": "Is this experience being loaded by the host application, or by another experience (not this one)?",
|
|
18
|
+
"type": "confirmation"
|
|
29
19
|
}
|
|
30
20
|
}
|
|
31
21
|
},
|
|
32
|
-
"required": [
|
|
22
|
+
"required": [
|
|
23
|
+
"name",
|
|
24
|
+
"standalone"
|
|
25
|
+
]
|
|
33
26
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ValidatorSchema } from '@unisphere/core';
|
|
2
2
|
import { UnisphereRuntimeBaseType } from '@unisphere/runtime';
|
|
3
|
-
import {
|
|
3
|
+
import { widgetName } from '../widget-types';
|
|
4
4
|
|
|
5
5
|
export const <%= runtimeName__pascalCase %>RuntimeName = '<%= runtimeName__lowerDashCase %>' as const;
|
|
6
6
|
|
|
7
7
|
export type <%= runtimeName__pascalCase %>Runtime = UnisphereRuntimeBaseType<<%= runtimeName__pascalCase %>RuntimeSettings> & {
|
|
8
|
-
readonly widgetName: typeof
|
|
8
|
+
readonly widgetName: typeof widgetName;
|
|
9
9
|
readonly runtimeName: typeof <%= runtimeName__pascalCase %>RuntimeName;
|
|
10
10
|
};
|
|
11
11
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rename Package Generator
|
|
3
|
+
*
|
|
4
|
+
* This generator renames a Unisphere package by:
|
|
5
|
+
* 1. Using Nx's built-in move generator to handle:
|
|
6
|
+
* - Directory and file moves
|
|
7
|
+
* - Import statement updates across the workspace
|
|
8
|
+
* - TypeScript path mappings in tsconfig.base.json
|
|
9
|
+
* 2. Performing Unisphere-specific cleanup:
|
|
10
|
+
* - Updating .unisphere configuration
|
|
11
|
+
* - Ensuring package.json name matches Unisphere conventions
|
|
12
|
+
* - Updating package-lock.json path keys (Nx doesn't handle this)
|
|
13
|
+
*/
|
|
14
|
+
import { Tree } from '@nx/devkit';
|
|
15
|
+
import { RenamePackageGeneratorSchema } from './schema';
|
|
16
|
+
export declare function renamePackageGenerator(tree: Tree, options: RenamePackageGeneratorSchema): Promise<() => void>;
|
|
17
|
+
export default renamePackageGenerator;
|
|
18
|
+
//# sourceMappingURL=rename-package.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-package.d.ts","sourceRoot":"","sources":["../../../src/generators/rename-package/rename-package.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,IAAI,EAKL,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAyPxD,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,4BAA4B,uBAsGtC;AAED,eAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Rename Package Generator
|
|
4
|
+
*
|
|
5
|
+
* This generator renames a Unisphere package by:
|
|
6
|
+
* 1. Using Nx's built-in move generator to handle:
|
|
7
|
+
* - Directory and file moves
|
|
8
|
+
* - Import statement updates across the workspace
|
|
9
|
+
* - TypeScript path mappings in tsconfig.base.json
|
|
10
|
+
* 2. Performing Unisphere-specific cleanup:
|
|
11
|
+
* - Updating .unisphere configuration
|
|
12
|
+
* - Ensuring package.json name matches Unisphere conventions
|
|
13
|
+
* - Updating package-lock.json path keys (Nx doesn't handle this)
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.renamePackageGenerator = renamePackageGenerator;
|
|
17
|
+
const devkit_1 = require("@nx/devkit");
|
|
18
|
+
const generators_1 = require("@nx/workspace/generators");
|
|
19
|
+
const child_process_1 = require("child_process");
|
|
20
|
+
const utils_1 = require("../utils");
|
|
21
|
+
/**
|
|
22
|
+
* Validates that the old package exists in .unisphere configuration
|
|
23
|
+
*/
|
|
24
|
+
function validateOldPackageExists(tree, oldPackageName) {
|
|
25
|
+
const unisphereConfig = (0, devkit_1.readJson)(tree, '.unisphere');
|
|
26
|
+
const normalizedOldName = (0, devkit_1.names)(oldPackageName).fileName;
|
|
27
|
+
if (!unisphereConfig.elements?.packages?.[normalizedOldName]) {
|
|
28
|
+
throw new Error(`Package "${normalizedOldName}" not found in .unisphere configuration.\n` +
|
|
29
|
+
'Available packages: ' +
|
|
30
|
+
Object.keys(unisphereConfig.elements?.packages || {}).join(', '));
|
|
31
|
+
}
|
|
32
|
+
const packageConfig = unisphereConfig.elements.packages[normalizedOldName];
|
|
33
|
+
const oldPath = `unisphere/packages/${normalizedOldName}`;
|
|
34
|
+
// Verify the directory exists
|
|
35
|
+
if (!tree.exists(oldPath)) {
|
|
36
|
+
throw new Error(`Package directory not found at ${oldPath}.\n` +
|
|
37
|
+
'The .unisphere configuration references a package that does not exist.');
|
|
38
|
+
}
|
|
39
|
+
// Read the package.json to get the current package name
|
|
40
|
+
const packageJsonPath = `${oldPath}/package.json`;
|
|
41
|
+
if (!tree.exists(packageJsonPath)) {
|
|
42
|
+
throw new Error(`package.json not found at ${packageJsonPath}.\n` +
|
|
43
|
+
'The package directory exists but is missing package.json.');
|
|
44
|
+
}
|
|
45
|
+
const packageJson = (0, devkit_1.readJson)(tree, packageJsonPath);
|
|
46
|
+
const packageJsonName = packageJson.name;
|
|
47
|
+
return {
|
|
48
|
+
packageJsonName,
|
|
49
|
+
distributionChannel: packageConfig.distributionChannel || 'none',
|
|
50
|
+
scope: packageConfig.scope || 'widget',
|
|
51
|
+
sourceRoot: packageConfig.sourceRoot,
|
|
52
|
+
oldPath,
|
|
53
|
+
newPath: `unisphere/packages/${normalizedOldName}`,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Validates that the new package name doesn't already exist
|
|
58
|
+
*/
|
|
59
|
+
function validateNewPackageDoesNotExist(tree, newPackageName) {
|
|
60
|
+
const unisphereConfig = (0, devkit_1.readJson)(tree, '.unisphere');
|
|
61
|
+
const normalizedNewName = (0, devkit_1.names)(newPackageName).fileName;
|
|
62
|
+
if (unisphereConfig.elements?.packages?.[normalizedNewName]) {
|
|
63
|
+
throw new Error(`Package "${normalizedNewName}" already exists in .unisphere configuration.\n` +
|
|
64
|
+
'Please choose a different package name.');
|
|
65
|
+
}
|
|
66
|
+
const newPath = `unisphere/packages/${normalizedNewName}`;
|
|
67
|
+
if (tree.exists(newPath)) {
|
|
68
|
+
throw new Error(`Package directory already exists at ${newPath}.\n` +
|
|
69
|
+
'Please choose a different package name or remove the existing directory.');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Calculate the new package.json name based on scope and experience name
|
|
74
|
+
*/
|
|
75
|
+
function calculateNewPackageJsonName(tree, newPackageName, oldPackageJsonName) {
|
|
76
|
+
const unisphereConfig = (0, utils_1.validateUnisphereConfig)(tree);
|
|
77
|
+
const experienceName = unisphereConfig.name;
|
|
78
|
+
const normalizedNewName = (0, devkit_1.names)(newPackageName).fileName;
|
|
79
|
+
// Determine the prefix from the old package name
|
|
80
|
+
let prefix;
|
|
81
|
+
if (oldPackageJsonName.startsWith('@unisphere/')) {
|
|
82
|
+
prefix = '@unisphere/';
|
|
83
|
+
}
|
|
84
|
+
else if (oldPackageJsonName.startsWith('@kaltura/unisphere-')) {
|
|
85
|
+
prefix = '@kaltura/unisphere-';
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
// Private package, no prefix
|
|
89
|
+
return normalizedNewName;
|
|
90
|
+
}
|
|
91
|
+
// Calculate new package name
|
|
92
|
+
let packageJsonName;
|
|
93
|
+
if (experienceName === normalizedNewName) {
|
|
94
|
+
packageJsonName = normalizedNewName;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
packageJsonName = `${experienceName}-${normalizedNewName}`;
|
|
98
|
+
}
|
|
99
|
+
return prefix + packageJsonName;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Update .unisphere configuration
|
|
103
|
+
*/
|
|
104
|
+
function updateUnisphereConfiguration(tree, oldPackageName, newPackageName, packageInfo) {
|
|
105
|
+
const unisphereConfig = (0, devkit_1.readJson)(tree, '.unisphere');
|
|
106
|
+
const normalizedNewName = (0, devkit_1.names)(newPackageName).fileName;
|
|
107
|
+
const normalizedOldName = (0, devkit_1.names)(oldPackageName).fileName;
|
|
108
|
+
// Get the old package config
|
|
109
|
+
const oldPackageConfig = unisphereConfig.elements.packages[normalizedOldName];
|
|
110
|
+
// Update sourceRoot
|
|
111
|
+
const newSourceRoot = `unisphere/packages/${normalizedNewName}`;
|
|
112
|
+
// Preserve package order by rebuilding the packages object
|
|
113
|
+
const newPackages = {};
|
|
114
|
+
Object.keys(unisphereConfig.elements.packages).forEach((key) => {
|
|
115
|
+
if (key === normalizedOldName) {
|
|
116
|
+
// Replace old package with new one at the same position
|
|
117
|
+
newPackages[normalizedNewName] = {
|
|
118
|
+
...oldPackageConfig,
|
|
119
|
+
sourceRoot: newSourceRoot,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
newPackages[key] = unisphereConfig.elements.packages[key];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
unisphereConfig.elements.packages = newPackages;
|
|
127
|
+
(0, devkit_1.writeJson)(tree, '.unisphere', unisphereConfig);
|
|
128
|
+
devkit_1.logger.info(`โ
Updated .unisphere configuration`);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Update package.json name to ensure it matches Unisphere naming conventions
|
|
132
|
+
* Nx move generator sets the package name, but we verify it matches our conventions
|
|
133
|
+
*/
|
|
134
|
+
function updatePackageJson(tree, packagePath, newPackageJsonName) {
|
|
135
|
+
const packageJsonPath = `${packagePath}/package.json`;
|
|
136
|
+
if (!tree.exists(packageJsonPath)) {
|
|
137
|
+
devkit_1.logger.warn(`โ ๏ธ package.json not found at ${packageJsonPath}`);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const packageJson = (0, devkit_1.readJson)(tree, packageJsonPath);
|
|
141
|
+
// Only update if Nx didn't set it to our expected name
|
|
142
|
+
if (packageJson.name !== newPackageJsonName) {
|
|
143
|
+
packageJson.name = newPackageJsonName;
|
|
144
|
+
(0, devkit_1.writeJson)(tree, packageJsonPath, packageJson);
|
|
145
|
+
devkit_1.logger.info(`โ
Updated package.json name to "${newPackageJsonName}"`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Update package-lock.json to rename the package path keys
|
|
150
|
+
* Nx's move generator doesn't handle package-lock.json updates
|
|
151
|
+
*/
|
|
152
|
+
function updatePackageLock(tree, oldPackageName, newPackageName) {
|
|
153
|
+
const packageLockPath = 'package-lock.json';
|
|
154
|
+
if (!tree.exists(packageLockPath)) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const packageLock = (0, devkit_1.readJson)(tree, packageLockPath);
|
|
158
|
+
const normalizedOldName = (0, devkit_1.names)(oldPackageName).fileName;
|
|
159
|
+
const normalizedNewName = (0, devkit_1.names)(newPackageName).fileName;
|
|
160
|
+
const oldPath = `unisphere/packages/${normalizedOldName}`;
|
|
161
|
+
const newPath = `unisphere/packages/${normalizedNewName}`;
|
|
162
|
+
let updated = false;
|
|
163
|
+
if (packageLock.packages) {
|
|
164
|
+
const packagesEntries = Object.entries(packageLock.packages);
|
|
165
|
+
const newPackages = {};
|
|
166
|
+
for (const [key, value] of packagesEntries) {
|
|
167
|
+
// Check if this key is exactly the old package path
|
|
168
|
+
if (key === oldPath) {
|
|
169
|
+
newPackages[newPath] = value;
|
|
170
|
+
updated = true;
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
newPackages[key] = value;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
packageLock.packages = newPackages;
|
|
177
|
+
}
|
|
178
|
+
// Update resolved paths if they exist
|
|
179
|
+
if (packageLock.packages) {
|
|
180
|
+
for (const [, value] of Object.entries(packageLock.packages)) {
|
|
181
|
+
if (value && typeof value === 'object' && 'resolved' in value) {
|
|
182
|
+
const pkg = value;
|
|
183
|
+
if (pkg.resolved === oldPath) {
|
|
184
|
+
pkg.resolved = newPath;
|
|
185
|
+
updated = true;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (updated) {
|
|
191
|
+
(0, devkit_1.writeJson)(tree, packageLockPath, packageLock);
|
|
192
|
+
devkit_1.logger.info(`โ
Updated package-lock.json path keys`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
async function renamePackageGenerator(tree, options) {
|
|
196
|
+
devkit_1.logger.info('');
|
|
197
|
+
devkit_1.logger.info('๐ Starting package rename...');
|
|
198
|
+
devkit_1.logger.info('');
|
|
199
|
+
// Validate .unisphere exists
|
|
200
|
+
(0, utils_1.validateUnisphereConfig)(tree);
|
|
201
|
+
// Normalize package names
|
|
202
|
+
const normalizedOldName = (0, devkit_1.names)(options.oldPackageName).fileName;
|
|
203
|
+
const normalizedNewName = (0, devkit_1.names)(options.newPackageName).fileName;
|
|
204
|
+
// Validate old package exists
|
|
205
|
+
const packageInfo = validateOldPackageExists(tree, normalizedOldName);
|
|
206
|
+
// Validate new package doesn't exist
|
|
207
|
+
validateNewPackageDoesNotExist(tree, normalizedNewName);
|
|
208
|
+
// Calculate new package.json name
|
|
209
|
+
const newPackageJsonName = calculateNewPackageJsonName(tree, normalizedNewName, packageInfo.packageJsonName);
|
|
210
|
+
const oldNxProjectName = `unisphere-package-${normalizedOldName}`;
|
|
211
|
+
const newNxProjectName = `unisphere-package-${normalizedNewName}`;
|
|
212
|
+
const newPath = `unisphere/packages/${normalizedNewName}`;
|
|
213
|
+
devkit_1.logger.info(`๐ฆ Old package name: ${normalizedOldName}`);
|
|
214
|
+
devkit_1.logger.info(`๐ฆ New package name: ${normalizedNewName}`);
|
|
215
|
+
devkit_1.logger.info(`๐ท๏ธ Old package.json name: ${packageInfo.packageJsonName}`);
|
|
216
|
+
devkit_1.logger.info(`๐ท๏ธ New package.json name: ${newPackageJsonName}`);
|
|
217
|
+
devkit_1.logger.info(`๐ท๏ธ Nx project name: ${oldNxProjectName} โ ${newNxProjectName}`);
|
|
218
|
+
devkit_1.logger.info('');
|
|
219
|
+
// Step 1: Run Nx's built-in move generator
|
|
220
|
+
devkit_1.logger.info('๐ง Running Nx move generator...');
|
|
221
|
+
try {
|
|
222
|
+
await (0, generators_1.moveGenerator)(tree, {
|
|
223
|
+
projectName: oldNxProjectName,
|
|
224
|
+
destination: newPath,
|
|
225
|
+
newProjectName: newNxProjectName,
|
|
226
|
+
importPath: newPackageJsonName,
|
|
227
|
+
updateImportPath: true,
|
|
228
|
+
skipFormat: false,
|
|
229
|
+
});
|
|
230
|
+
devkit_1.logger.info(`โ
Nx moved project from ${packageInfo.oldPath} to ${newPath}`);
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
devkit_1.logger.error(`โ Failed to move project with Nx: ${error}`);
|
|
234
|
+
throw error;
|
|
235
|
+
}
|
|
236
|
+
devkit_1.logger.info('');
|
|
237
|
+
devkit_1.logger.info('๐งน Performing Unisphere-specific cleanup...');
|
|
238
|
+
// Step 2: Update .unisphere configuration (Unisphere-specific)
|
|
239
|
+
updateUnisphereConfiguration(tree, normalizedOldName, normalizedNewName, packageInfo);
|
|
240
|
+
// Step 3: Update package.json name to match Unisphere conventions
|
|
241
|
+
updatePackageJson(tree, newPath, newPackageJsonName);
|
|
242
|
+
// Step 4: Update package-lock.json path keys (Nx doesn't handle this)
|
|
243
|
+
updatePackageLock(tree, normalizedOldName, normalizedNewName);
|
|
244
|
+
devkit_1.logger.info('');
|
|
245
|
+
devkit_1.logger.info('โ
Package renamed successfully!');
|
|
246
|
+
devkit_1.logger.info('');
|
|
247
|
+
devkit_1.logger.info('๐ Summary:');
|
|
248
|
+
devkit_1.logger.info(` โข Old name: ${normalizedOldName}`);
|
|
249
|
+
devkit_1.logger.info(` โข New name: ${normalizedNewName}`);
|
|
250
|
+
devkit_1.logger.info(` โข Old location: ${packageInfo.oldPath}`);
|
|
251
|
+
devkit_1.logger.info(` โข New location: ${newPath}`);
|
|
252
|
+
devkit_1.logger.info(` โข Package.json name: ${newPackageJsonName}`);
|
|
253
|
+
devkit_1.logger.info('');
|
|
254
|
+
devkit_1.logger.info('๐ Next steps:');
|
|
255
|
+
devkit_1.logger.info(' 1. Review the changes: git status');
|
|
256
|
+
devkit_1.logger.info(' 2. Stage all changes: git add -A');
|
|
257
|
+
devkit_1.logger.info(' Git will detect the directory move as a rename (preserving history)');
|
|
258
|
+
devkit_1.logger.info(' 3. Run: npm install (to update package-lock.json)');
|
|
259
|
+
devkit_1.logger.info(' 4. Run: npm run build (to verify everything builds)');
|
|
260
|
+
devkit_1.logger.info(' 5. Commit the changes: git commit -m "Rename package..."');
|
|
261
|
+
devkit_1.logger.info('');
|
|
262
|
+
return () => {
|
|
263
|
+
// This function runs after all changes are applied
|
|
264
|
+
try {
|
|
265
|
+
// Auto-stage changes to help Git detect renames
|
|
266
|
+
(0, child_process_1.execSync)('git add -A', { stdio: 'ignore' });
|
|
267
|
+
devkit_1.logger.info('โ
Automatically staged changes to help Git detect renames');
|
|
268
|
+
}
|
|
269
|
+
catch (e) {
|
|
270
|
+
// Ignore errors if git is not available or not a git repo
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
exports.default = renamePackageGenerator;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "RenamePackage",
|
|
4
|
+
"title": "Rename Package Generator",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"oldPackageName": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The current name of the package to rename",
|
|
10
|
+
"x-prompt": "What is the current package name?"
|
|
11
|
+
},
|
|
12
|
+
"newPackageName": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"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)"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"required": [
|
|
20
|
+
"oldPackageName",
|
|
21
|
+
"newPackageName"
|
|
22
|
+
]
|
|
23
|
+
}
|
package/generators.json
CHANGED
|
@@ -25,6 +25,11 @@
|
|
|
25
25
|
"schema": "./dist/generators/unisphere-migrate/schema.json",
|
|
26
26
|
"description": "Manually run all Unisphere migrations from migrations.json",
|
|
27
27
|
"hidden": false
|
|
28
|
+
},
|
|
29
|
+
"rename-package": {
|
|
30
|
+
"factory": "./dist/generators/rename-package/rename-package",
|
|
31
|
+
"schema": "./dist/generators/rename-package/schema.json",
|
|
32
|
+
"description": "Rename a unisphere package and update all references"
|
|
28
33
|
}
|
|
29
34
|
}
|
|
30
35
|
}
|