@zityhub/check-updates 2.1.0 → 3.1.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.
|
@@ -33,15 +33,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
return result;
|
|
34
34
|
};
|
|
35
35
|
})();
|
|
36
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
37
|
const npm_check_updates_1 = require("npm-check-updates");
|
|
47
38
|
const process = __importStar(require("node:process"));
|
|
@@ -63,33 +54,32 @@ const parseArguments = (args) => {
|
|
|
63
54
|
const hasVersion = (version) => {
|
|
64
55
|
return version !== undefined && version !== null;
|
|
65
56
|
};
|
|
66
|
-
const packagesToUpdate = () =>
|
|
67
|
-
const upgraded = (
|
|
57
|
+
const packagesToUpdate = async () => {
|
|
58
|
+
const upgraded = (await (0, npm_check_updates_1.run)({
|
|
68
59
|
filterResults: (packageName, { currentVersionSemver, upgradedVersionSemver }) => {
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
const upgradedMajor = parseInt(upgradedVersionSemver === null || upgradedVersionSemver === void 0 ? void 0 : upgradedVersionSemver.major, 10);
|
|
60
|
+
const currentMajor = parseInt(currentVersionSemver[0]?.major, 10);
|
|
61
|
+
const upgradedMajor = parseInt(upgradedVersionSemver?.major, 10);
|
|
72
62
|
if (hasVersion(currentMajor) && hasVersion(upgradedMajor))
|
|
73
63
|
return currentMajor !== upgradedMajor;
|
|
74
64
|
return true;
|
|
75
65
|
}
|
|
76
66
|
}));
|
|
77
67
|
return Object.keys(upgraded);
|
|
78
|
-
}
|
|
79
|
-
const main = (exclude) =>
|
|
80
|
-
const packages =
|
|
68
|
+
};
|
|
69
|
+
const main = async (exclude) => {
|
|
70
|
+
const packages = await packagesToUpdate();
|
|
81
71
|
const toUpdate = packages.filter((packageName) => !exclude.includes(packageName));
|
|
82
72
|
const message = `Major update available for: ${packages.join(',')}`;
|
|
83
73
|
if (toUpdate.length)
|
|
84
74
|
return Promise.reject(message);
|
|
85
75
|
return Promise.resolve(packages.length ? message : undefined);
|
|
86
|
-
}
|
|
76
|
+
};
|
|
87
77
|
main(parseArguments(process.argv.slice(2)))
|
|
88
78
|
.then((message) => {
|
|
89
79
|
info('Job check-updates finished success', {
|
|
90
80
|
type: {
|
|
91
81
|
name: 'job',
|
|
92
|
-
data:
|
|
82
|
+
data: { jobName: 'check-updates', ...(message && { message }) }
|
|
93
83
|
}
|
|
94
84
|
});
|
|
95
85
|
process.exit(0);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { run } from 'npm-check-updates';
|
|
3
|
+
import * as process from 'node:process';
|
|
4
|
+
const info = (title, message) => {
|
|
5
|
+
process.stdout.write(`${new Date().toISOString()} \x1b[102mINFO\x1b[0m \x1b[34m${title}\x1b[0m\n${JSON.stringify(message, null, 2)}\n`);
|
|
6
|
+
};
|
|
7
|
+
const error = (title, message) => {
|
|
8
|
+
process.stderr.write(`${new Date().toISOString()} \x1b[41mERROR\x1b[0m \x1b[34m${title}\x1b[0m\n${JSON.stringify(message, null, 2)}\n`);
|
|
9
|
+
};
|
|
10
|
+
const parseArguments = (args) => {
|
|
11
|
+
const exclude = [];
|
|
12
|
+
args.forEach((arg) => {
|
|
13
|
+
const [key, value] = arg.split('=');
|
|
14
|
+
if (key.startsWith('--exclude') && value)
|
|
15
|
+
exclude.push(value);
|
|
16
|
+
});
|
|
17
|
+
return exclude;
|
|
18
|
+
};
|
|
19
|
+
const hasVersion = (version) => {
|
|
20
|
+
return version !== undefined && version !== null;
|
|
21
|
+
};
|
|
22
|
+
const packagesToUpdate = async () => {
|
|
23
|
+
const upgraded = (await run({
|
|
24
|
+
filterResults: (packageName, { currentVersionSemver, upgradedVersionSemver }) => {
|
|
25
|
+
const currentMajor = parseInt(currentVersionSemver[0]?.major, 10);
|
|
26
|
+
const upgradedMajor = parseInt(upgradedVersionSemver?.major, 10);
|
|
27
|
+
if (hasVersion(currentMajor) && hasVersion(upgradedMajor))
|
|
28
|
+
return currentMajor !== upgradedMajor;
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
}));
|
|
32
|
+
return Object.keys(upgraded);
|
|
33
|
+
};
|
|
34
|
+
const main = async (exclude) => {
|
|
35
|
+
const packages = await packagesToUpdate();
|
|
36
|
+
const toUpdate = packages.filter((packageName) => !exclude.includes(packageName));
|
|
37
|
+
const message = `Major update available for: ${packages.join(',')}`;
|
|
38
|
+
if (toUpdate.length)
|
|
39
|
+
return Promise.reject(message);
|
|
40
|
+
return Promise.resolve(packages.length ? message : undefined);
|
|
41
|
+
};
|
|
42
|
+
main(parseArguments(process.argv.slice(2)))
|
|
43
|
+
.then((message) => {
|
|
44
|
+
info('Job check-updates finished success', {
|
|
45
|
+
type: {
|
|
46
|
+
name: 'job',
|
|
47
|
+
data: { jobName: 'check-updates', ...(message && { message }) }
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
process.exit(0);
|
|
51
|
+
})
|
|
52
|
+
.catch((err) => {
|
|
53
|
+
error('Job check-updates finished failed', {
|
|
54
|
+
type: {
|
|
55
|
+
name: 'job',
|
|
56
|
+
data: { jobName: 'check-updates', message: err }
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
process.exit(1);
|
|
60
|
+
});
|
package/package.json
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zityhub/check-updates",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"author": "Zityhub",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Project that checks if your project has any dependencies that have been updated with a major version.",
|
|
7
|
-
"
|
|
8
|
-
"node": ">=22.13.0",
|
|
9
|
-
"npm": ">=10.9.2"
|
|
10
|
-
},
|
|
11
|
-
"packageManager": "pnpm@10.11.0",
|
|
7
|
+
"packageManager": "pnpm@10.30.3",
|
|
12
8
|
"keywords": [
|
|
13
9
|
"dependencies",
|
|
14
10
|
"npm",
|
|
@@ -17,37 +13,53 @@
|
|
|
17
13
|
"upgrade",
|
|
18
14
|
"versions"
|
|
19
15
|
],
|
|
20
|
-
"main": "dist/index.
|
|
21
|
-
"
|
|
16
|
+
"main": "dist/cjs/index.cjs",
|
|
17
|
+
"module": "dist/esm/index.js",
|
|
18
|
+
"types": "dist/types/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"import": "./dist/esm/index.js",
|
|
22
|
+
"require": "./dist/cjs/index.cjs",
|
|
23
|
+
"types": "./dist/types/index.d.ts"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
22
26
|
"files": [
|
|
23
27
|
"dist"
|
|
24
28
|
],
|
|
25
29
|
"bin": {
|
|
26
|
-
"check-updates": "./dist/index.
|
|
30
|
+
"check-updates": "./dist/cjs/index.cjs"
|
|
27
31
|
},
|
|
28
32
|
"repository": {
|
|
29
33
|
"type": "git",
|
|
30
34
|
"url": "https://github.com/zityhub/check-updates"
|
|
31
35
|
},
|
|
32
36
|
"scripts": {
|
|
33
|
-
"build": "
|
|
37
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
38
|
+
"build:no-emit": "tsc -p tsconfig.esm.json --noEmit",
|
|
39
|
+
"build:cjs": "tsc -p tsconfig.cjs.json && mv dist/cjs/index.js dist/cjs/index.cjs",
|
|
40
|
+
"build": "rimraf dist && npm run build:esm && npm run build:cjs",
|
|
34
41
|
"dev": "tsx index.ts",
|
|
35
42
|
"format": "prettier . --write",
|
|
36
43
|
"lint": "eslint . --fix"
|
|
37
44
|
},
|
|
38
45
|
"dependencies": {
|
|
39
|
-
"npm-check-updates": "^
|
|
46
|
+
"npm-check-updates": "^19.6.3"
|
|
40
47
|
},
|
|
41
48
|
"devDependencies": {
|
|
42
|
-
"@eslint/js": "^
|
|
43
|
-
"@types/node": "^
|
|
44
|
-
"eslint": "^9.
|
|
45
|
-
"eslint-config-prettier": "^
|
|
46
|
-
"globals": "^
|
|
47
|
-
"prettier": "^3.
|
|
48
|
-
"rimraf": "^6.
|
|
49
|
-
"tsx": "^4.
|
|
50
|
-
"typescript": "^5.
|
|
51
|
-
"typescript-eslint": "^8.
|
|
49
|
+
"@eslint/js": "^10.0.1",
|
|
50
|
+
"@types/node": "^25.3.3",
|
|
51
|
+
"eslint": "^9.39.3",
|
|
52
|
+
"eslint-config-prettier": "^10.1.8",
|
|
53
|
+
"globals": "^17.4.0",
|
|
54
|
+
"prettier": "^3.8.1",
|
|
55
|
+
"rimraf": "^6.1.3",
|
|
56
|
+
"tsx": "^4.21.0",
|
|
57
|
+
"typescript": "^5.9.3",
|
|
58
|
+
"typescript-eslint": "^8.56.1"
|
|
59
|
+
},
|
|
60
|
+
"pnpm": {
|
|
61
|
+
"onlyBuiltDependencies": [
|
|
62
|
+
"esbuild"
|
|
63
|
+
]
|
|
52
64
|
}
|
|
53
65
|
}
|
|
File without changes
|