@comet/upgrade 1.7.0 → 1.9.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
|
@@ -35,10 +35,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
const child_process_1 = require("child_process");
|
|
39
38
|
const fs_1 = __importDefault(require("fs"));
|
|
40
39
|
const path_1 = __importDefault(require("path"));
|
|
41
40
|
const semver_1 = __importDefault(require("semver"));
|
|
41
|
+
const execute_command_util_1 = require("./util/execute-command.util");
|
|
42
42
|
const VERSION_NUMBER = /^v?\d+$/;
|
|
43
43
|
const microservices = ["api", "admin", "site"];
|
|
44
44
|
function microserviceExists(microservice) {
|
|
@@ -86,7 +86,7 @@ function getCurrentVersion() {
|
|
|
86
86
|
process.exit(-1);
|
|
87
87
|
}
|
|
88
88
|
// ^3.0.0 | ~3.0.0 | 3.0.0-canary -> 3.0.0
|
|
89
|
-
const versionMatches = versionRange.match(/\d
|
|
89
|
+
const versionMatches = versionRange.match(/\d+\.\d+\.\d+/);
|
|
90
90
|
if (versionMatches === null) {
|
|
91
91
|
console.error(`Unsupported version range '${versionRange}'. Example range: ^3.0.0`);
|
|
92
92
|
process.exit(-1);
|
|
@@ -123,7 +123,7 @@ function updateDependencies(targetVersion) {
|
|
|
123
123
|
console.warn(`Microservice '${microservice}' has no Comet DXP dependencies. Skipping install`);
|
|
124
124
|
continue;
|
|
125
125
|
}
|
|
126
|
-
yield executeCommand("npm", [
|
|
126
|
+
yield (0, execute_command_util_1.executeCommand)("npm", [
|
|
127
127
|
"install",
|
|
128
128
|
"--prefix",
|
|
129
129
|
microservice,
|
|
@@ -136,21 +136,6 @@ function updateDependencies(targetVersion) {
|
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
|
-
// Inspired by https://github.com/facebook/create-react-app/blob/main/packages/create-react-app/createReactApp.js#L383
|
|
140
|
-
function executeCommand(command, args = []) {
|
|
141
|
-
return new Promise((resolve, reject) => {
|
|
142
|
-
const child = (0, child_process_1.spawn)(command, args, { stdio: "inherit" });
|
|
143
|
-
child.on("close", (code) => {
|
|
144
|
-
if (code !== 0) {
|
|
145
|
-
reject({
|
|
146
|
-
command: `${command} ${args.join(" ")}`,
|
|
147
|
-
});
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
resolve();
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
139
|
function runUpgradeScripts(targetVersion) {
|
|
155
140
|
return __awaiter(this, void 0, void 0, function* () {
|
|
156
141
|
var _a;
|
|
@@ -175,7 +160,7 @@ function runEslintFix() {
|
|
|
175
160
|
continue;
|
|
176
161
|
}
|
|
177
162
|
try {
|
|
178
|
-
yield executeCommand("npm", ["run", "--prefix", microservice, "--no-audit", "--loglevel", "error", "lint:eslint", "--", "--fix"]);
|
|
163
|
+
yield (0, execute_command_util_1.executeCommand)("npm", ["run", "--prefix", microservice, "--no-audit", "--loglevel", "error", "lint:eslint", "--", "--fix"]);
|
|
179
164
|
}
|
|
180
165
|
catch (err) {
|
|
181
166
|
console.error(`Failed to fix ESLint errors in ${microservice}. See original error below`);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeCommand = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
// Inspired by https://github.com/facebook/create-react-app/blob/main/packages/create-react-app/createReactApp.js#L383
|
|
6
|
+
function executeCommand(command, args = []) {
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
const child = (0, child_process_1.spawn)(command, args, { stdio: "inherit" });
|
|
9
|
+
child.on("close", (code) => {
|
|
10
|
+
if (code !== 0) {
|
|
11
|
+
reject({
|
|
12
|
+
command: `${command} ${args.join(" ")}`,
|
|
13
|
+
});
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
resolve();
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
exports.executeCommand = executeCommand;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const promises_1 = require("fs/promises");
|
|
13
|
+
const execute_command_util_1 = require("../util/execute-command.util");
|
|
14
|
+
const format_code_util_1 = require("../util/format-code.util");
|
|
15
|
+
/**
|
|
16
|
+
* Replaces the old font package "Roboto" with the new "Roboto Flex"
|
|
17
|
+
*/
|
|
18
|
+
function replaceRobotoWithRobotoFlex() {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
yield replacePackageInPackageJson();
|
|
21
|
+
yield removeOldPackageImports();
|
|
22
|
+
yield addNewPackageImport();
|
|
23
|
+
yield (0, execute_command_util_1.executeCommand)("npm", ["install", "--prefix", "admin", "--no-audit", "--loglevel", "error"]);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.default = replaceRobotoWithRobotoFlex;
|
|
27
|
+
const replacePackageInPackageJson = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
const filePath = "admin/package.json";
|
|
29
|
+
let fileContent = (yield (0, promises_1.readFile)(filePath)).toString();
|
|
30
|
+
const searchString = "@fontsource/roboto";
|
|
31
|
+
const re = new RegExp(`^.*${searchString}.*$`, "gm");
|
|
32
|
+
fileContent = fileContent.replace(re, ' "@fontsource-variable/roboto-flex": "^5.0.0",');
|
|
33
|
+
yield (0, promises_1.writeFile)(filePath, yield (0, format_code_util_1.formatCode)(fileContent, filePath));
|
|
34
|
+
});
|
|
35
|
+
const removeOldPackageImports = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
const filePath = "admin/src/App.tsx";
|
|
37
|
+
let fileContent = (yield (0, promises_1.readFile)(filePath)).toString();
|
|
38
|
+
const searchString = 'import "@fontsource/roboto';
|
|
39
|
+
const re = new RegExp(`^.*${searchString}.*$`, "gm");
|
|
40
|
+
fileContent = fileContent.replace(re, "");
|
|
41
|
+
yield (0, promises_1.writeFile)(filePath, yield (0, format_code_util_1.formatCode)(fileContent, filePath));
|
|
42
|
+
});
|
|
43
|
+
const addNewPackageImport = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
+
const filePath = "admin/src/App.tsx";
|
|
45
|
+
let fileContent = (yield (0, promises_1.readFile)(filePath)).toString();
|
|
46
|
+
fileContent = `import "@fontsource-variable/roboto-flex/full.css";
|
|
47
|
+
${fileContent}`;
|
|
48
|
+
yield (0, promises_1.writeFile)(filePath, yield (0, format_code_util_1.formatCode)(fileContent, filePath));
|
|
49
|
+
});
|