@comet/upgrade 1.55.0 → 1.56.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/lib/index.js
CHANGED
|
@@ -57,15 +57,20 @@ async function main() {
|
|
|
57
57
|
listTargetVersions();
|
|
58
58
|
process.exit(-1);
|
|
59
59
|
}
|
|
60
|
-
const
|
|
61
|
-
console.info(`Upgrading from v${
|
|
60
|
+
const currentMajorVersion = getCurrentVersion();
|
|
61
|
+
console.info(`Upgrading from v${currentMajorVersion} to v${targetVersion}`);
|
|
62
62
|
const upgradeScripts = await findUpgradeScripts(targetVersionFolder);
|
|
63
|
+
console.info("\n⚙️ Executing before install scripts\n");
|
|
63
64
|
const beforeInstallScripts = upgradeScripts.filter((script) => script.stage === "before-install");
|
|
64
65
|
await runUpgradeScripts(beforeInstallScripts);
|
|
65
|
-
console.info("
|
|
66
|
+
console.info("\n☑️ Before install scripts finished\n");
|
|
67
|
+
console.info("\n🔄 Updating dependencies\n");
|
|
66
68
|
await updateDependencies(targetVersion);
|
|
69
|
+
console.info("\n☑️ Dependency update finished\n");
|
|
70
|
+
console.info("\n🚀 Executing after install scripts\n");
|
|
67
71
|
const afterInstallScripts = upgradeScripts.filter((script) => script.stage === "after-install");
|
|
68
72
|
await runUpgradeScripts(afterInstallScripts);
|
|
73
|
+
console.info("\n☑️ After install scripts finished\n");
|
|
69
74
|
await runEslintFix();
|
|
70
75
|
}
|
|
71
76
|
function getCurrentVersion() {
|
|
@@ -151,6 +156,7 @@ async function runUpgradeScripts(scripts) {
|
|
|
151
156
|
}
|
|
152
157
|
async function runUpgradeScript(script) {
|
|
153
158
|
try {
|
|
159
|
+
console.info(`📜 Running script '${script.name}'`);
|
|
154
160
|
await script.script();
|
|
155
161
|
if (isLocalDevelopment) {
|
|
156
162
|
// run upgrade scripts twice locally to ensure that the scripts are idempotent
|
|
@@ -5,6 +5,7 @@ const child_process_1 = require("child_process");
|
|
|
5
5
|
// Inspired by https://github.com/facebook/create-react-app/blob/main/packages/create-react-app/createReactApp.js#L383
|
|
6
6
|
function executeCommand(command, args = []) {
|
|
7
7
|
return new Promise((resolve, reject) => {
|
|
8
|
+
console.debug("Executing command: ", command, args.join(" "));
|
|
8
9
|
const child = (0, child_process_1.spawn)(command, args, { stdio: "inherit" });
|
|
9
10
|
child.on("close", (code) => {
|
|
10
11
|
if (code !== 0) {
|
|
@@ -34,6 +34,12 @@ class PackageJson {
|
|
|
34
34
|
delete this.json.dependencies?.[name];
|
|
35
35
|
delete this.json.devDependencies?.[name];
|
|
36
36
|
}
|
|
37
|
+
getDependencyVersion(name) {
|
|
38
|
+
return this.json.dependencies?.[name] || this.json.devDependencies?.[name];
|
|
39
|
+
}
|
|
40
|
+
hasDependency(name) {
|
|
41
|
+
return !!(this.json.dependencies?.[name] || this.json.devDependencies?.[name]);
|
|
42
|
+
}
|
|
37
43
|
save() {
|
|
38
44
|
(0, fs_1.writeFileSync)(this.path, JSON.stringify(this.json, null, 4));
|
|
39
45
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fs_1 = require("fs");
|
|
4
|
+
const glob_1 = require("glob");
|
|
5
|
+
const ts_morph_1 = require("ts-morph");
|
|
6
|
+
async function mergeAdminThemeIntoAdmin() {
|
|
7
|
+
const project = new ts_morph_1.Project({ tsConfigFilePath: "./admin/tsconfig.json" });
|
|
8
|
+
const files = glob_1.glob.sync(["admin/src/**/*.{ts,tsx}"]);
|
|
9
|
+
for (const filePath of files) {
|
|
10
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
11
|
+
if (!sourceFile) {
|
|
12
|
+
throw new Error(`Can't get source file for ${filePath}`);
|
|
13
|
+
}
|
|
14
|
+
const themeImport = sourceFile.getImportDeclaration((declaration) => declaration.getModuleSpecifierValue() === "@comet/admin-theme");
|
|
15
|
+
if (!themeImport)
|
|
16
|
+
continue;
|
|
17
|
+
const namedImports = themeImport.getNamedImports();
|
|
18
|
+
const importStructures = namedImports.map((namedImport) => ({
|
|
19
|
+
name: namedImport.getName(),
|
|
20
|
+
alias: namedImport.getAliasNode()?.getText(),
|
|
21
|
+
}));
|
|
22
|
+
themeImport.remove();
|
|
23
|
+
const adminImport = sourceFile.getImportDeclaration((declaration) => declaration.getModuleSpecifierValue() === "@comet/admin");
|
|
24
|
+
if (adminImport) {
|
|
25
|
+
adminImport.addNamedImports(importStructures.map((importStructure) => ({
|
|
26
|
+
name: importStructure.name,
|
|
27
|
+
alias: importStructure.alias,
|
|
28
|
+
})));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
sourceFile.addImportDeclaration({
|
|
32
|
+
namedImports: importStructures.map((importStructure) => ({
|
|
33
|
+
name: importStructure.name,
|
|
34
|
+
alias: importStructure.alias,
|
|
35
|
+
})),
|
|
36
|
+
moduleSpecifier: "@comet/admin",
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
await sourceFile.save();
|
|
40
|
+
}
|
|
41
|
+
const vendorsPath = "admin/src/vendors.d.ts";
|
|
42
|
+
if ((0, fs_1.existsSync)(vendorsPath)) {
|
|
43
|
+
const content = (0, fs_1.readFileSync)(vendorsPath, "utf-8");
|
|
44
|
+
const updatedContent = content.replace('/// <reference types="@comet/admin-theme" />\n', "");
|
|
45
|
+
if (updatedContent.trim() === "") {
|
|
46
|
+
(0, fs_1.unlinkSync)(vendorsPath);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
(0, fs_1.writeFileSync)(vendorsPath, updatedContent);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.default = mergeAdminThemeIntoAdmin;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stage = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const package_json_util_1 = require("../util/package-json.util");
|
|
6
|
+
exports.stage = "before-install";
|
|
7
|
+
async function removeAdminThemePackage() {
|
|
8
|
+
if ((0, fs_1.existsSync)("admin/package.json")) {
|
|
9
|
+
const packageJson = new package_json_util_1.PackageJson("admin/package.json");
|
|
10
|
+
const themeVersion = packageJson.getDependencyVersion("@comet/admin-theme"); // for beta versions
|
|
11
|
+
packageJson.removeDependency("@comet/admin-theme");
|
|
12
|
+
if (!packageJson.hasDependency("@comet/admin")) {
|
|
13
|
+
packageJson.addDependency("@comet/admin", themeVersion ?? "^8.0.0");
|
|
14
|
+
}
|
|
15
|
+
packageJson.save();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.default = removeAdminThemePackage;
|