forked from serwist/serwist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathncu.js
60 lines (54 loc) · 1.43 KB
/
ncu.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import fg from "fast-glob";
import { run } from "npm-check-updates";
/**
* Update and then log updated dependencies.
*
* @param {import("npm-check-updates").RunOptions} runOptions
*/
const updateAndLog = async (runOptions) => {
const upgraded = await run(runOptions);
console.log(`Upgraded dependencies for ${runOptions.packageFile ?? "./package.json"}:`, upgraded);
};
const packageJsonList = await fg("**/package.json", {
ignore: ["examples/**", "**/node_modules/**"],
});
const examplesPackageJsonList = await fg("examples/*/package.json", {
ignore: ["**/node_modules/**"],
});
const excludePackages = ["glob", "rimraf", "typescript"];
/**
* @type {Promise<any>[]}
*/
const updatePromise = [];
for (const packageFile of packageJsonList) {
updatePromise.push(
updateAndLog({
packageFile,
upgrade: true,
filter(packageName) {
return !excludePackages.includes(packageName);
},
target(dep) {
if (/^react(-dom)?$/.test(dep)) {
return "@latest";
}
if (dep === "tailwindcss" || dep === "@tailwindcss/vite") {
return "@next";
}
return "latest";
},
}),
);
}
for (const packageFile of examplesPackageJsonList) {
updatePromise.push(
updateAndLog({
packageFile,
upgrade: true,
filter(packageName) {
return !excludePackages.includes(packageName);
},
}),
);
}
await Promise.all(updatePromise);