@comet/upgrade 1.3.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/README.md CHANGED
@@ -19,7 +19,7 @@ npx @comet/upgrade v4
19
19
  1. Start the development process:
20
20
 
21
21
  ```sh
22
- yarn start
22
+ npm start
23
23
  ```
24
24
 
25
25
  2. Add a new script for the version you want to upgrade to, for instance, `src/v4/change-something.ts`.
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 (!fs_1.default.existsSync("admin/package.json")) {
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 (!fs_1.default.existsSync(`${microservice}/package.json`)) {
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"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comet/upgrade",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "description": "Upgrade scripts for Comet DXP",
5
5
  "homepage": "https://github.com/vivid-planet/comet-upgrade#readme",
6
6
  "bugs": {
@@ -19,13 +19,13 @@
19
19
  "lib/**/*.js"
20
20
  ],
21
21
  "scripts": {
22
- "build": "yarn clean && tsc",
22
+ "build": "npm run clean && tsc",
23
23
  "clean": "rimraf lib/",
24
24
  "lint": "run-p lint:eslint lint:tsc",
25
25
  "lint:eslint": "eslint --max-warnings 0 src/",
26
26
  "lint:tsc": "tsc --noEmit",
27
27
  "prepare": "husky install",
28
- "start": "yarn clean && tsc --watch"
28
+ "start": "npm run clean && tsc --watch"
29
29
  },
30
30
  "dependencies": {
31
31
  "eslint": "^8.56.0",
@@ -40,14 +40,12 @@
40
40
  "@types/semver": "^7.3.13",
41
41
  "husky": "^8.0.2",
42
42
  "lint-staged": "^13.1.0",
43
+ "npm-run-all": "^4.1.5",
43
44
  "rimraf": "^3.0.2",
44
- "typescript": "^4.9.4",
45
- "yarn-run-all": "^3.1.1"
45
+ "typescript": "^4.9.4"
46
46
  },
47
- "packageManager": "yarn@3.3.0",
48
47
  "engines": {
49
- "node": "20",
50
- "yarn": "3"
48
+ "node": "20"
51
49
  },
52
50
  "publishConfig": {
53
51
  "access": "public",