@comet/upgrade 1.4.0 → 1.5.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 +24 -3
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -40,6 +40,10 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
40
40
|
const path_1 = __importDefault(require("path"));
|
|
41
41
|
const semver_1 = __importDefault(require("semver"));
|
|
42
42
|
const VERSION_NUMBER = /^v?\d+$/;
|
|
43
|
+
const microservices = ["api", "admin", "site"];
|
|
44
|
+
function microserviceExists(microservice) {
|
|
45
|
+
return fs_1.default.existsSync(`${microservice}/package.json`);
|
|
46
|
+
}
|
|
43
47
|
function main() {
|
|
44
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
49
|
let targetVersionArg = process.argv[2];
|
|
@@ -66,11 +70,12 @@ function main() {
|
|
|
66
70
|
console.info("Updating dependencies");
|
|
67
71
|
yield updateDependencies(targetVersion);
|
|
68
72
|
yield runUpgradeScripts(targetVersion);
|
|
73
|
+
yield runEslintFix();
|
|
69
74
|
});
|
|
70
75
|
}
|
|
71
76
|
function getCurrentVersion() {
|
|
72
77
|
var _a;
|
|
73
|
-
if (!
|
|
78
|
+
if (!microserviceExists("admin")) {
|
|
74
79
|
console.error(`File 'admin/package.json' doesn't exist. Make sure to call the script in the root of your project`);
|
|
75
80
|
process.exit(-1);
|
|
76
81
|
}
|
|
@@ -91,7 +96,6 @@ function getCurrentVersion() {
|
|
|
91
96
|
}
|
|
92
97
|
function updateDependencies(targetVersion) {
|
|
93
98
|
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
const microservices = ["api", "admin", "site"];
|
|
95
99
|
const packages = {
|
|
96
100
|
api: ["@comet/blocks-api", "@comet/cms-api"],
|
|
97
101
|
admin: [
|
|
@@ -108,7 +112,7 @@ function updateDependencies(targetVersion) {
|
|
|
108
112
|
site: ["@comet/cms-site"],
|
|
109
113
|
};
|
|
110
114
|
for (const microservice of microservices) {
|
|
111
|
-
if (!
|
|
115
|
+
if (!microserviceExists(microservice)) {
|
|
112
116
|
console.warn(`File '${microservice}/package.json' doesn't exist. Skipping microservice`);
|
|
113
117
|
continue;
|
|
114
118
|
}
|
|
@@ -163,6 +167,23 @@ function runUpgradeScripts(targetVersion) {
|
|
|
163
167
|
}
|
|
164
168
|
});
|
|
165
169
|
}
|
|
170
|
+
function runEslintFix() {
|
|
171
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
+
console.info("Fixing ESLint errors");
|
|
173
|
+
for (const microservice of microservices) {
|
|
174
|
+
if (!microserviceExists(microservice)) {
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
178
|
+
yield executeCommand("npm", ["run", "--prefix", microservice, "--no-audit", "--loglevel", "error", "lint:eslint", "--", "--fix"]);
|
|
179
|
+
}
|
|
180
|
+
catch (err) {
|
|
181
|
+
console.error(`Failed to fix ESLint errors in ${microservice}. See original error below`);
|
|
182
|
+
console.error(err);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
166
187
|
function listTargetVersions() {
|
|
167
188
|
console.info("Available target versions");
|
|
168
189
|
const targetVersions = fs_1.default.readdirSync(__dirname).filter((entry) => entry.startsWith("v"));
|