deplift 1.1.1 → 1.2.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/dist/cjs/index.cjs +48 -9
- package/dist/esm/index.mjs +48 -9
- package/package.json +8 -6
package/dist/cjs/index.cjs
CHANGED
|
@@ -5,13 +5,11 @@ var path = require('node:path');
|
|
|
5
5
|
var promises = require('node:fs/promises');
|
|
6
6
|
var node_child_process = require('node:child_process');
|
|
7
7
|
var fg = require('fast-glob');
|
|
8
|
+
var yargs = require('yargs');
|
|
9
|
+
var helpers = require('yargs/helpers');
|
|
8
10
|
|
|
9
11
|
const defaultIgnore = ['**/node_modules/**', '**/dist/**', '**/coverage/**', '**/build/**', '**/.next/**', '**/.docusaurus/**'];
|
|
10
12
|
const depSections = ['dependencies', 'devDependencies'];
|
|
11
|
-
const args = process.argv.slice(2);
|
|
12
|
-
const dryRun = args.includes('--dry-run');
|
|
13
|
-
const noInstall = args.includes('--no-install');
|
|
14
|
-
if (dryRun) console.log('💡 Dry run enabled — no files will be changed or installed.');
|
|
15
13
|
const stripPrefix = version => version.replace(/^\D+/, '');
|
|
16
14
|
const isStableRelease = version => /^\d+\.\d+\.\d+$/.test(version);
|
|
17
15
|
const extractSemVerParts = semver => semver.split('.').map(Number);
|
|
@@ -55,7 +53,42 @@ const fetchLatestVersion = async dep => {
|
|
|
55
53
|
}
|
|
56
54
|
return dep;
|
|
57
55
|
};
|
|
56
|
+
const parseArgs = async () => {
|
|
57
|
+
const argv = await yargs(helpers.hideBin(process.argv)).option('major', {
|
|
58
|
+
type: 'array',
|
|
59
|
+
describe: 'major dep=version pairs',
|
|
60
|
+
default: [],
|
|
61
|
+
coerce: pairs => {
|
|
62
|
+
const result = {};
|
|
63
|
+
for (const pair of pairs) {
|
|
64
|
+
const idx = pair.indexOf('=');
|
|
65
|
+
if (idx === -1) {
|
|
66
|
+
throw new Error(`Invalid --major value "${pair}", expected dep=version`);
|
|
67
|
+
}
|
|
68
|
+
const key = pair.slice(0, idx);
|
|
69
|
+
const value = pair.slice(idx + 1);
|
|
70
|
+
result[key] = Number(value);
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
}).option('dry-run', {
|
|
75
|
+
type: 'boolean',
|
|
76
|
+
describe: 'Run without making changes',
|
|
77
|
+
default: false
|
|
78
|
+
}).option('install', {
|
|
79
|
+
type: 'boolean',
|
|
80
|
+
describe: 'Run npm install',
|
|
81
|
+
default: true
|
|
82
|
+
}).strict().help().parse();
|
|
83
|
+
return argv;
|
|
84
|
+
};
|
|
58
85
|
async function main() {
|
|
86
|
+
const {
|
|
87
|
+
dryRun,
|
|
88
|
+
install: runInstall,
|
|
89
|
+
major: majorCaps
|
|
90
|
+
} = await parseArgs();
|
|
91
|
+
if (dryRun) console.log('💡 Dry run enabled — no files will be changed or installed.');
|
|
59
92
|
const config = await loadConfig();
|
|
60
93
|
const ignorePatterns = Array.isArray(config.ignore) ? Array.from(new Set([...defaultIgnore, ...config.ignore])) : defaultIgnore;
|
|
61
94
|
const packageFiles = await fg.glob('**/package.json', {
|
|
@@ -109,21 +142,27 @@ async function main() {
|
|
|
109
142
|
console.log(` ⚠️ [skipped] ${pkg}: current (${current}) version is higher than the latest (${latest})`);
|
|
110
143
|
continue;
|
|
111
144
|
}
|
|
112
|
-
const [currentMajor] = extractSemVerParts(current);
|
|
113
145
|
const [latestMajor] = extractSemVerParts(latest);
|
|
146
|
+
if (latestMajor > majorCaps[pkg]) {
|
|
147
|
+
console.log(` ⚠️ [skipped] ${pkg}: ${latest} is available, but the major version is capped at v${majorCaps[pkg]}`);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
const [currentMajor] = extractSemVerParts(current);
|
|
114
151
|
console.log(` ${currentMajor === latestMajor ? '✔' : '🚨[major]'} ${pkg}(${section}): ${rawCurrent} → ^${latest}`);
|
|
115
152
|
updated = true;
|
|
116
153
|
if (!dryRun) {
|
|
117
154
|
pkgData[section][pkg] = `^${latest}`;
|
|
118
155
|
}
|
|
119
156
|
}
|
|
120
|
-
if (updated
|
|
121
|
-
|
|
122
|
-
|
|
157
|
+
if (updated) {
|
|
158
|
+
if (!dryRun) {
|
|
159
|
+
await promises.writeFile(packageJsonPath, JSON.stringify(pkgData, null, 2) + '\n');
|
|
160
|
+
console.log(` 💾 ${packageJson} updated.`);
|
|
161
|
+
}
|
|
123
162
|
} else {
|
|
124
163
|
console.log(` ✅ No changes needed for ${packageJson}.`);
|
|
125
164
|
}
|
|
126
|
-
if (
|
|
165
|
+
if (!runInstall || dryRun || !updated) continue;
|
|
127
166
|
try {
|
|
128
167
|
const targetDir = path.dirname(packageJsonPath);
|
|
129
168
|
console.log(' 📥 Installing...');
|
package/dist/esm/index.mjs
CHANGED
|
@@ -3,13 +3,11 @@ import path from 'node:path';
|
|
|
3
3
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
4
4
|
import { execSync } from 'node:child_process';
|
|
5
5
|
import fg from 'fast-glob';
|
|
6
|
+
import yargs from 'yargs';
|
|
7
|
+
import { hideBin } from 'yargs/helpers';
|
|
6
8
|
|
|
7
9
|
const defaultIgnore = ['**/node_modules/**', '**/dist/**', '**/coverage/**', '**/build/**', '**/.next/**', '**/.docusaurus/**'];
|
|
8
10
|
const depSections = ['dependencies', 'devDependencies'];
|
|
9
|
-
const args = process.argv.slice(2);
|
|
10
|
-
const dryRun = args.includes('--dry-run');
|
|
11
|
-
const noInstall = args.includes('--no-install');
|
|
12
|
-
if (dryRun) console.log('💡 Dry run enabled — no files will be changed or installed.');
|
|
13
11
|
const stripPrefix = version => version.replace(/^\D+/, '');
|
|
14
12
|
const isStableRelease = version => /^\d+\.\d+\.\d+$/.test(version);
|
|
15
13
|
const extractSemVerParts = semver => semver.split('.').map(Number);
|
|
@@ -53,7 +51,42 @@ const fetchLatestVersion = async dep => {
|
|
|
53
51
|
}
|
|
54
52
|
return dep;
|
|
55
53
|
};
|
|
54
|
+
const parseArgs = async () => {
|
|
55
|
+
const argv = await yargs(hideBin(process.argv)).option('major', {
|
|
56
|
+
type: 'array',
|
|
57
|
+
describe: 'major dep=version pairs',
|
|
58
|
+
default: [],
|
|
59
|
+
coerce: pairs => {
|
|
60
|
+
const result = {};
|
|
61
|
+
for (const pair of pairs) {
|
|
62
|
+
const idx = pair.indexOf('=');
|
|
63
|
+
if (idx === -1) {
|
|
64
|
+
throw new Error(`Invalid --major value "${pair}", expected dep=version`);
|
|
65
|
+
}
|
|
66
|
+
const key = pair.slice(0, idx);
|
|
67
|
+
const value = pair.slice(idx + 1);
|
|
68
|
+
result[key] = Number(value);
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
}).option('dry-run', {
|
|
73
|
+
type: 'boolean',
|
|
74
|
+
describe: 'Run without making changes',
|
|
75
|
+
default: false
|
|
76
|
+
}).option('install', {
|
|
77
|
+
type: 'boolean',
|
|
78
|
+
describe: 'Run npm install',
|
|
79
|
+
default: true
|
|
80
|
+
}).strict().help().parse();
|
|
81
|
+
return argv;
|
|
82
|
+
};
|
|
56
83
|
async function main() {
|
|
84
|
+
const {
|
|
85
|
+
dryRun,
|
|
86
|
+
install: runInstall,
|
|
87
|
+
major: majorCaps
|
|
88
|
+
} = await parseArgs();
|
|
89
|
+
if (dryRun) console.log('💡 Dry run enabled — no files will be changed or installed.');
|
|
57
90
|
const config = await loadConfig();
|
|
58
91
|
const ignorePatterns = Array.isArray(config.ignore) ? Array.from(new Set([...defaultIgnore, ...config.ignore])) : defaultIgnore;
|
|
59
92
|
const packageFiles = await fg.glob('**/package.json', {
|
|
@@ -107,21 +140,27 @@ async function main() {
|
|
|
107
140
|
console.log(` ⚠️ [skipped] ${pkg}: current (${current}) version is higher than the latest (${latest})`);
|
|
108
141
|
continue;
|
|
109
142
|
}
|
|
110
|
-
const [currentMajor] = extractSemVerParts(current);
|
|
111
143
|
const [latestMajor] = extractSemVerParts(latest);
|
|
144
|
+
if (latestMajor > majorCaps[pkg]) {
|
|
145
|
+
console.log(` ⚠️ [skipped] ${pkg}: ${latest} is available, but the major version is capped at v${majorCaps[pkg]}`);
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
const [currentMajor] = extractSemVerParts(current);
|
|
112
149
|
console.log(` ${currentMajor === latestMajor ? '✔' : '🚨[major]'} ${pkg}(${section}): ${rawCurrent} → ^${latest}`);
|
|
113
150
|
updated = true;
|
|
114
151
|
if (!dryRun) {
|
|
115
152
|
pkgData[section][pkg] = `^${latest}`;
|
|
116
153
|
}
|
|
117
154
|
}
|
|
118
|
-
if (updated
|
|
119
|
-
|
|
120
|
-
|
|
155
|
+
if (updated) {
|
|
156
|
+
if (!dryRun) {
|
|
157
|
+
await writeFile(packageJsonPath, JSON.stringify(pkgData, null, 2) + '\n');
|
|
158
|
+
console.log(` 💾 ${packageJson} updated.`);
|
|
159
|
+
}
|
|
121
160
|
} else {
|
|
122
161
|
console.log(` ✅ No changes needed for ${packageJson}.`);
|
|
123
162
|
}
|
|
124
|
-
if (
|
|
163
|
+
if (!runInstall || dryRun || !updated) continue;
|
|
125
164
|
try {
|
|
126
165
|
const targetDir = path.dirname(packageJsonPath);
|
|
127
166
|
console.log(' 📥 Installing...');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deplift",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "CLI to update deps in monorepos",
|
|
5
5
|
"author": "Zheng Song",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,18 +35,20 @@
|
|
|
35
35
|
"deplift:dry-run": "node ./dist/cjs/index.cjs --dry-run"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@babel/core": "^7.
|
|
39
|
-
"@babel/preset-env": "^7.
|
|
38
|
+
"@babel/core": "^7.29.0",
|
|
39
|
+
"@babel/preset-env": "^7.29.0",
|
|
40
40
|
"@babel/preset-typescript": "^7.28.5",
|
|
41
41
|
"@rollup/plugin-babel": "^6.1.0",
|
|
42
42
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
43
|
-
"@types/node": "^25.
|
|
43
|
+
"@types/node": "^25.2.2",
|
|
44
|
+
"@types/yargs": "^17.0.35",
|
|
44
45
|
"npm-run-all": "^4.1.5",
|
|
45
46
|
"prettier": "^3.8.1",
|
|
46
|
-
"rollup": "^4.
|
|
47
|
+
"rollup": "^4.57.1",
|
|
47
48
|
"typescript": "^5.9.3"
|
|
48
49
|
},
|
|
49
50
|
"dependencies": {
|
|
50
|
-
"fast-glob": "^3.3.3"
|
|
51
|
+
"fast-glob": "^3.3.3",
|
|
52
|
+
"yargs": "^18.0.0"
|
|
51
53
|
}
|
|
52
54
|
}
|