@reliverse/dler 1.7.140 → 1.7.142
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 +1 -1
- package/bin/impl/config/constants.d.ts +1 -1
- package/bin/impl/config/constants.js +1 -1
- package/bin/impl/update/impl.d.ts +9 -35
- package/bin/impl/update/impl.js +39 -344
- package/bin/impl/update/utils.d.ts +8 -55
- package/bin/impl/update/utils.js +214 -669
- package/bin/mod.d.ts +3 -3
- package/bin/mod.js +3 -31
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Visit [docs.reliverse.org/libraries/dler](https://docs.reliverse.org/libraries/d
|
|
|
10
10
|
|
|
11
11
|
## Stand With Ukraine
|
|
12
12
|
|
|
13
|
-
- 💙 Please help fund drones, medkits, and victory. [Donate now](https://u24.gov.ua), it matters.
|
|
13
|
+
- 💙 Please help fund drones, medkits, and victory. [Donate now](https://u24.gov.ua), please, it matters.
|
|
14
14
|
- 💛 Every dollar helps stop [russia's war crimes](https://war.ukraine.ua/russia-war-crimes) and saves lives.
|
|
15
15
|
|
|
16
16
|
## Stand With Reliverse
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const PROJECT_ROOT: string;
|
|
2
|
-
export declare const cliVersion = "1.7.
|
|
2
|
+
export declare const cliVersion = "1.7.142";
|
|
3
3
|
export declare const cliName = "@reliverse/rse";
|
|
4
4
|
export declare const rseName = "@reliverse/rse";
|
|
5
5
|
export declare const dlerName = "@reliverse/dler";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import os from "node:os";
|
|
2
2
|
import path from "@reliverse/pathkit";
|
|
3
3
|
export const PROJECT_ROOT = path.resolve(process.cwd());
|
|
4
|
-
const version = "1.7.
|
|
4
|
+
const version = "1.7.142";
|
|
5
5
|
export const cliVersion = version;
|
|
6
6
|
export const cliName = "@reliverse/rse";
|
|
7
7
|
export const rseName = "@reliverse/rse";
|
|
@@ -1,49 +1,23 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type UpdateResult } from "./utils";
|
|
2
2
|
interface UpdateArgs {
|
|
3
|
+
ci?: boolean;
|
|
4
|
+
cwd?: string;
|
|
3
5
|
name?: string[];
|
|
4
6
|
ignore?: string[];
|
|
5
|
-
devOnly?: boolean;
|
|
6
|
-
prodOnly?: boolean;
|
|
7
|
-
peerOnly?: boolean;
|
|
8
|
-
optionalOnly?: boolean;
|
|
9
|
-
catalogsOnly?: boolean;
|
|
10
7
|
dryRun?: boolean;
|
|
11
|
-
|
|
12
|
-
withCheckScript?: boolean;
|
|
13
|
-
linker?: string;
|
|
14
|
-
withInstall?: boolean;
|
|
15
|
-
global?: boolean;
|
|
16
|
-
interactive?: boolean;
|
|
17
|
-
filter?: string[];
|
|
18
|
-
allWorkspaces?: boolean;
|
|
19
|
-
rootOnly?: boolean;
|
|
20
|
-
recursive?: boolean;
|
|
21
|
-
savePrefix?: string;
|
|
8
|
+
install?: boolean;
|
|
22
9
|
allowMajor?: boolean;
|
|
10
|
+
concurrency?: number;
|
|
11
|
+
ignoreFields?: string[];
|
|
23
12
|
}
|
|
24
|
-
export declare function validateUpdateArgs(args: UpdateArgs): Promise<void>;
|
|
25
|
-
export declare function handleCatalogOnlyUpdate(args: UpdateArgs): Promise<boolean>;
|
|
26
13
|
export declare function validatePackageJson(): Promise<string>;
|
|
27
|
-
export declare function getEffectiveLinker(args: UpdateArgs): Promise<{
|
|
28
|
-
effectiveLinker: string;
|
|
29
|
-
linkerSource: string;
|
|
30
|
-
}>;
|
|
31
|
-
export declare function prepareUpdateCandidates(args: UpdateArgs): Promise<{
|
|
32
|
-
candidates: string[];
|
|
33
|
-
allDepsMap: Record<string, any>;
|
|
34
|
-
}>;
|
|
35
14
|
export declare function prepareAllUpdateCandidates(args: UpdateArgs): Promise<{
|
|
36
15
|
candidates: string[];
|
|
37
16
|
allDepsMap: Record<string, any>;
|
|
38
17
|
packageJsonFiles: string[];
|
|
18
|
+
fileDepsMap: Map<string, Record<string, any>>;
|
|
39
19
|
}>;
|
|
40
20
|
export declare function checkPackageUpdates(candidates: string[], allDepsMap: Record<string, any>, args: UpdateArgs): Promise<UpdateResult[]>;
|
|
41
|
-
export declare function
|
|
42
|
-
export declare function
|
|
43
|
-
export declare function updateAllPackageJsonFiles(packageJsonFiles: string[], toUpdate: UpdateResult[], savePrefix: string): Promise<number>;
|
|
44
|
-
export declare function handleRecursiveUpdates(args: UpdateArgs, options: PackageCheckOptions): Promise<number>;
|
|
45
|
-
export declare function handleWorkspaceUpdates(args: UpdateArgs, options: PackageCheckOptions): Promise<number>;
|
|
46
|
-
export declare function displayUpdateSummary(totalUpdated: number, args: UpdateArgs, isMonorepoProject: boolean, shouldUpdateWorkspaces: boolean): void;
|
|
47
|
-
export declare function handleInstallation(args: UpdateArgs, effectiveLinker: string, packageJson: any): Promise<void>;
|
|
48
|
-
export declare function handleToolUpgrades(args: any): Promise<void>;
|
|
21
|
+
export declare function updateAllPackageJsonFiles(packageJsonFiles: string[], toUpdate: UpdateResult[], savePrefix: string, fieldsToIgnore?: string[]): Promise<number>;
|
|
22
|
+
export declare function handleInstallation(): Promise<void>;
|
|
49
23
|
export {};
|
package/bin/impl/update/impl.js
CHANGED
|
@@ -1,80 +1,16 @@
|
|
|
1
1
|
import path from "@reliverse/pathkit";
|
|
2
|
-
import { re } from "@reliverse/relico";
|
|
3
2
|
import fs from "@reliverse/relifso";
|
|
4
3
|
import { relinka } from "@reliverse/relinka";
|
|
5
|
-
import { multiselectPrompt } from "@reliverse/rempts";
|
|
6
|
-
import { $ } from "bun";
|
|
7
4
|
import pMap from "p-map";
|
|
8
|
-
import {
|
|
9
|
-
import { getConfigBunfig } from "../config/load.js";
|
|
10
|
-
import { isCatalogSupported, updateCatalogs } from "../utils/pm/pm-catalog.js";
|
|
5
|
+
import { glob } from "tinyglobby";
|
|
11
6
|
import { detectPackageManager } from "../utils/pm/pm-detect.js";
|
|
12
7
|
import {
|
|
13
8
|
checkPackageUpdate,
|
|
14
9
|
collectTargetDependencies,
|
|
15
|
-
findAllPackageJsons,
|
|
16
|
-
findWorkspacePackageJsons,
|
|
17
|
-
isMonorepo,
|
|
18
10
|
prepareDependenciesForUpdate,
|
|
19
11
|
runInstallCommand,
|
|
20
|
-
|
|
21
|
-
updatePackageJsonFile,
|
|
22
|
-
updateWorkspacePackages,
|
|
23
|
-
upgradeBun,
|
|
24
|
-
upgradeDlerGlobal,
|
|
25
|
-
upgradeDlerLocal,
|
|
26
|
-
upgradeGit,
|
|
27
|
-
upgradeNode,
|
|
28
|
-
upgradeNpm,
|
|
29
|
-
upgradePnpm,
|
|
30
|
-
upgradeYarn
|
|
12
|
+
updatePackageJsonFile
|
|
31
13
|
} from "./utils.js";
|
|
32
|
-
export async function validateUpdateArgs(args) {
|
|
33
|
-
const exclusiveFlags = [
|
|
34
|
-
args["devOnly"],
|
|
35
|
-
args["prodOnly"],
|
|
36
|
-
args["peerOnly"],
|
|
37
|
-
args["optionalOnly"],
|
|
38
|
-
args["catalogsOnly"]
|
|
39
|
-
];
|
|
40
|
-
if (exclusiveFlags.filter(Boolean).length > 1) {
|
|
41
|
-
relinka(
|
|
42
|
-
"error",
|
|
43
|
-
"Cannot specify multiple exclusive flags (--dev-only, --prod-only, --peer-only, --optional-only, --catalogs-only)"
|
|
44
|
-
);
|
|
45
|
-
process.exit(1);
|
|
46
|
-
}
|
|
47
|
-
if (args["allWorkspaces"] && args["rootOnly"]) {
|
|
48
|
-
relinka("error", "Cannot specify both --all-workspaces and --root-only flags");
|
|
49
|
-
process.exit(1);
|
|
50
|
-
}
|
|
51
|
-
if (args.recursive && (args["allWorkspaces"] || args["rootOnly"])) {
|
|
52
|
-
relinka(
|
|
53
|
-
"error",
|
|
54
|
-
"Cannot use --recursive with --all-workspaces or --root-only flags. Use --no-recursive to disable recursive mode."
|
|
55
|
-
);
|
|
56
|
-
process.exit(1);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
export async function handleCatalogOnlyUpdate(args) {
|
|
60
|
-
if (!args["catalogsOnly"]) {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
const packageManager = await detectPackageManager(process.cwd());
|
|
64
|
-
if (!packageManager) {
|
|
65
|
-
relinka("error", "Could not detect package manager");
|
|
66
|
-
process.exit(1);
|
|
67
|
-
}
|
|
68
|
-
if (!isCatalogSupported(packageManager)) {
|
|
69
|
-
relinka(
|
|
70
|
-
"error",
|
|
71
|
-
`Catalogs are not supported by ${packageManager.name}. Only Bun supports catalogs.`
|
|
72
|
-
);
|
|
73
|
-
process.exit(1);
|
|
74
|
-
}
|
|
75
|
-
await updateCatalogs(process.cwd());
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
14
|
export async function validatePackageJson() {
|
|
79
15
|
const packageJsonPath = path.resolve(process.cwd(), "package.json");
|
|
80
16
|
if (!await fs.pathExists(packageJsonPath)) {
|
|
@@ -83,47 +19,37 @@ export async function validatePackageJson() {
|
|
|
83
19
|
}
|
|
84
20
|
return packageJsonPath;
|
|
85
21
|
}
|
|
86
|
-
export async function getEffectiveLinker(args) {
|
|
87
|
-
let effectiveLinker = args.linker || "hoisted";
|
|
88
|
-
let linkerSource = "CLI default";
|
|
89
|
-
if (typeof Bun !== "undefined") {
|
|
90
|
-
const bunfigConfig = await getConfigBunfig();
|
|
91
|
-
const bunfigLinker = bunfigConfig?.install?.linker;
|
|
92
|
-
if (bunfigLinker && ["isolated", "hoisted"].includes(bunfigLinker) && args.linker === "hoisted") {
|
|
93
|
-
effectiveLinker = bunfigLinker;
|
|
94
|
-
linkerSource = bunfigLinker === "hoisted" ? "bunfig.toml (same as default)" : "bunfig.toml";
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (args.linker !== "hoisted") {
|
|
98
|
-
effectiveLinker = args.linker;
|
|
99
|
-
linkerSource = "CLI override";
|
|
100
|
-
}
|
|
101
|
-
relinka("verbose", `Using linker strategy: ${effectiveLinker} (from ${linkerSource})`);
|
|
102
|
-
return { effectiveLinker, linkerSource };
|
|
103
|
-
}
|
|
104
|
-
export async function prepareUpdateCandidates(args) {
|
|
105
|
-
const packageJson = await readPackageJSON();
|
|
106
|
-
const { map: allDepsMap } = collectTargetDependencies(packageJson, args);
|
|
107
|
-
const candidates = prepareDependenciesForUpdate(allDepsMap, args);
|
|
108
|
-
if (candidates.length === 0) {
|
|
109
|
-
relinka("warn", "No dependencies to update based on provided filters");
|
|
110
|
-
return { candidates: [], allDepsMap };
|
|
111
|
-
}
|
|
112
|
-
return { candidates, allDepsMap };
|
|
113
|
-
}
|
|
114
22
|
export async function prepareAllUpdateCandidates(args) {
|
|
115
|
-
const packageJsonFiles = await
|
|
23
|
+
const packageJsonFiles = await glob("**/package.json", {
|
|
24
|
+
cwd: process.cwd(),
|
|
25
|
+
absolute: true,
|
|
26
|
+
ignore: [
|
|
27
|
+
"**/node_modules/**",
|
|
28
|
+
"**/dist/**",
|
|
29
|
+
"**/build/**",
|
|
30
|
+
"**/.git/**",
|
|
31
|
+
"**/coverage/**",
|
|
32
|
+
"**/.next/**",
|
|
33
|
+
"**/.nuxt/**",
|
|
34
|
+
"**/out/**",
|
|
35
|
+
"**/target/**",
|
|
36
|
+
"**/.turbo/**"
|
|
37
|
+
]
|
|
38
|
+
});
|
|
116
39
|
if (packageJsonFiles.length === 0) {
|
|
117
|
-
relinka("warn", "No package.json files found
|
|
118
|
-
return { candidates: [], allDepsMap: {}, packageJsonFiles: [] };
|
|
40
|
+
relinka("warn", "No package.json files found");
|
|
41
|
+
return { candidates: [], allDepsMap: {}, packageJsonFiles: [], fileDepsMap: /* @__PURE__ */ new Map() };
|
|
119
42
|
}
|
|
43
|
+
relinka("verbose", `Found ${packageJsonFiles.length} package.json files`);
|
|
120
44
|
const allDepsMap = {};
|
|
121
45
|
const allCandidates = /* @__PURE__ */ new Set();
|
|
46
|
+
const fileDepsMap = /* @__PURE__ */ new Map();
|
|
122
47
|
for (const packageJsonPath of packageJsonFiles) {
|
|
123
48
|
try {
|
|
124
49
|
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf8"));
|
|
125
|
-
const { map } = collectTargetDependencies(packageJson
|
|
50
|
+
const { map } = collectTargetDependencies(packageJson);
|
|
126
51
|
const candidates2 = prepareDependenciesForUpdate(map, args);
|
|
52
|
+
fileDepsMap.set(packageJsonPath, map);
|
|
127
53
|
for (const [dep, info] of Object.entries(map)) {
|
|
128
54
|
if (!allDepsMap[dep]) {
|
|
129
55
|
allDepsMap[dep] = { ...info, locations: new Set(info.locations) };
|
|
@@ -146,41 +72,17 @@ export async function prepareAllUpdateCandidates(args) {
|
|
|
146
72
|
}
|
|
147
73
|
const candidates = Array.from(allCandidates);
|
|
148
74
|
if (candidates.length === 0) {
|
|
149
|
-
relinka(
|
|
150
|
-
|
|
151
|
-
"No dependencies to update based on provided filters across all package.json files"
|
|
152
|
-
);
|
|
153
|
-
return { candidates: [], allDepsMap: {}, packageJsonFiles };
|
|
75
|
+
relinka("warn", "No dependencies to update");
|
|
76
|
+
return { candidates: [], allDepsMap: {}, packageJsonFiles, fileDepsMap };
|
|
154
77
|
}
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
async function determinePackageJsonFiles(args) {
|
|
158
|
-
const cwd = process.cwd();
|
|
159
|
-
const rootPackageJsonPath = path.resolve(cwd, "package.json");
|
|
160
|
-
const packageJsonFiles = [];
|
|
161
|
-
if (await fs.pathExists(rootPackageJsonPath)) {
|
|
162
|
-
packageJsonFiles.push(rootPackageJsonPath);
|
|
163
|
-
}
|
|
164
|
-
if (args.recursive) {
|
|
165
|
-
const allPackageJsons = await findAllPackageJsons(cwd);
|
|
166
|
-
const otherPackageJsons = allPackageJsons.filter((p) => p !== rootPackageJsonPath);
|
|
167
|
-
packageJsonFiles.push(...otherPackageJsons);
|
|
168
|
-
return packageJsonFiles;
|
|
169
|
-
}
|
|
170
|
-
const isMonorepoProject = await isMonorepo(cwd);
|
|
171
|
-
if (args.allWorkspaces) {
|
|
172
|
-
const workspacePkgJsons = await findWorkspacePackageJsons(cwd);
|
|
173
|
-
packageJsonFiles.push(...workspacePkgJsons);
|
|
174
|
-
} else if (!args.rootOnly && isMonorepoProject) {
|
|
175
|
-
const workspacePkgJsons = await findWorkspacePackageJsons(cwd);
|
|
176
|
-
packageJsonFiles.push(...workspacePkgJsons);
|
|
177
|
-
}
|
|
178
|
-
return packageJsonFiles;
|
|
78
|
+
relinka("verbose", `Processing ${packageJsonFiles.length} package.json files`);
|
|
79
|
+
return { candidates, allDepsMap, packageJsonFiles, fileDepsMap };
|
|
179
80
|
}
|
|
180
81
|
export async function checkPackageUpdates(candidates, allDepsMap, args) {
|
|
181
82
|
const options = {
|
|
182
|
-
allowMajor: !!args
|
|
183
|
-
savePrefix:
|
|
83
|
+
allowMajor: !!args.allowMajor,
|
|
84
|
+
savePrefix: "^",
|
|
85
|
+
// Use default prefix
|
|
184
86
|
concurrency: args.concurrency || 5
|
|
185
87
|
};
|
|
186
88
|
return await pMap(
|
|
@@ -195,7 +97,7 @@ export async function checkPackageUpdates(candidates, allDepsMap, args) {
|
|
|
195
97
|
updated: false,
|
|
196
98
|
error: "Current version not found",
|
|
197
99
|
semverCompatible: false,
|
|
198
|
-
location:
|
|
100
|
+
location: "unknown"
|
|
199
101
|
};
|
|
200
102
|
}
|
|
201
103
|
return checkPackageUpdate(dep, depInfo.versionSpec, depInfo.locations, options);
|
|
@@ -203,62 +105,7 @@ export async function checkPackageUpdates(candidates, allDepsMap, args) {
|
|
|
203
105
|
{ concurrency: args.concurrency || 5 }
|
|
204
106
|
);
|
|
205
107
|
}
|
|
206
|
-
export async function
|
|
207
|
-
const toUpdate = results.filter((r) => r.updated && !r.error);
|
|
208
|
-
const errors = results.filter((r) => r.error);
|
|
209
|
-
const upToDate = results.filter((r) => !r.updated && !r.error && r.semverCompatible);
|
|
210
|
-
const allPackages = [
|
|
211
|
-
...toUpdate.map((pkg) => ({
|
|
212
|
-
...pkg,
|
|
213
|
-
canUpdate: true,
|
|
214
|
-
isUpToDate: false,
|
|
215
|
-
hasError: false
|
|
216
|
-
})),
|
|
217
|
-
...upToDate.map((pkg) => ({
|
|
218
|
-
...pkg,
|
|
219
|
-
canUpdate: false,
|
|
220
|
-
isUpToDate: true,
|
|
221
|
-
hasError: false
|
|
222
|
-
})),
|
|
223
|
-
...errors.map((pkg) => ({ ...pkg, canUpdate: false, isUpToDate: false, hasError: true }))
|
|
224
|
-
];
|
|
225
|
-
const selectedPackages = await multiselectPrompt({
|
|
226
|
-
title: "Select dependencies to update",
|
|
227
|
-
options: [
|
|
228
|
-
{ label: "Exit", value: "exit" },
|
|
229
|
-
...allPackages.map((pkg) => {
|
|
230
|
-
let label = `${pkg.package} (${pkg.location})`;
|
|
231
|
-
if (pkg.canUpdate) {
|
|
232
|
-
label += `: ${pkg.currentVersion} \u2192 ${pkg.latestVersion}`;
|
|
233
|
-
} else if (pkg.isUpToDate) {
|
|
234
|
-
label += `: ${pkg.currentVersion} (up-to-date)`;
|
|
235
|
-
} else if (pkg.hasError) {
|
|
236
|
-
label += `: ${pkg.currentVersion} (has errors)`;
|
|
237
|
-
}
|
|
238
|
-
return {
|
|
239
|
-
label,
|
|
240
|
-
value: pkg.package,
|
|
241
|
-
disabled: !pkg.canUpdate,
|
|
242
|
-
hint: pkg.hasError ? pkg.error : void 0
|
|
243
|
-
};
|
|
244
|
-
})
|
|
245
|
-
]
|
|
246
|
-
});
|
|
247
|
-
if (selectedPackages.length === 0 || selectedPackages.includes("exit")) {
|
|
248
|
-
relinka("log", "Exiting update process");
|
|
249
|
-
return [];
|
|
250
|
-
}
|
|
251
|
-
const actualSelectedPackages = selectedPackages.filter((pkg) => pkg !== "exit");
|
|
252
|
-
const filteredToUpdate = toUpdate.filter(
|
|
253
|
-
(update) => actualSelectedPackages.includes(update.package)
|
|
254
|
-
);
|
|
255
|
-
relinka("log", `Updating ${actualSelectedPackages.length} selected dependencies...`);
|
|
256
|
-
return filteredToUpdate;
|
|
257
|
-
}
|
|
258
|
-
export async function updateRootPackageJson(packageJsonPath, allDepsMap, toUpdate, savePrefix) {
|
|
259
|
-
return await updatePackageJsonFile(packageJsonPath, allDepsMap, toUpdate, savePrefix);
|
|
260
|
-
}
|
|
261
|
-
export async function updateAllPackageJsonFiles(packageJsonFiles, toUpdate, savePrefix) {
|
|
108
|
+
export async function updateAllPackageJsonFiles(packageJsonFiles, toUpdate, savePrefix, fieldsToIgnore = []) {
|
|
262
109
|
if (packageJsonFiles.length === 0 || toUpdate.length === 0) {
|
|
263
110
|
return 0;
|
|
264
111
|
}
|
|
@@ -266,14 +113,15 @@ export async function updateAllPackageJsonFiles(packageJsonFiles, toUpdate, save
|
|
|
266
113
|
for (const packageJsonPath of packageJsonFiles) {
|
|
267
114
|
try {
|
|
268
115
|
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf8"));
|
|
269
|
-
const { map: fileDepsMap } = collectTargetDependencies(packageJson
|
|
116
|
+
const { map: fileDepsMap } = collectTargetDependencies(packageJson);
|
|
270
117
|
const fileSpecificUpdates = toUpdate.filter((update) => fileDepsMap[update.package]);
|
|
271
118
|
if (fileSpecificUpdates.length > 0) {
|
|
272
119
|
const updated = await updatePackageJsonFile(
|
|
273
120
|
packageJsonPath,
|
|
274
121
|
fileDepsMap,
|
|
275
122
|
fileSpecificUpdates,
|
|
276
|
-
savePrefix
|
|
123
|
+
savePrefix,
|
|
124
|
+
fieldsToIgnore
|
|
277
125
|
);
|
|
278
126
|
totalUpdated += updated;
|
|
279
127
|
if (updated > 0) {
|
|
@@ -290,170 +138,17 @@ export async function updateAllPackageJsonFiles(packageJsonFiles, toUpdate, save
|
|
|
290
138
|
}
|
|
291
139
|
return totalUpdated;
|
|
292
140
|
}
|
|
293
|
-
export async function
|
|
294
|
-
const allPackageJsons = await findAllPackageJsons(process.cwd());
|
|
295
|
-
const rootPackageJsonPath = path.resolve(process.cwd(), "package.json");
|
|
296
|
-
const otherPackageJsons = allPackageJsons.filter((p) => p !== rootPackageJsonPath);
|
|
297
|
-
if (otherPackageJsons.length > 0) {
|
|
298
|
-
relinka(
|
|
299
|
-
"verbose",
|
|
300
|
-
`Found ${otherPackageJsons.length} additional package.json files to update recursively`
|
|
301
|
-
);
|
|
302
|
-
return await updateWorkspacePackages(otherPackageJsons, args, options);
|
|
303
|
-
}
|
|
304
|
-
return 0;
|
|
305
|
-
}
|
|
306
|
-
export async function handleWorkspaceUpdates(args, options) {
|
|
307
|
-
const isMonorepoProject = await isMonorepo(process.cwd());
|
|
308
|
-
const shouldUpdateWorkspaces = args["allWorkspaces"] || !args["rootOnly"] && isMonorepoProject;
|
|
309
|
-
if (shouldUpdateWorkspaces) {
|
|
310
|
-
const workspacePkgJsons = await findWorkspacePackageJsons(process.cwd());
|
|
311
|
-
if (workspacePkgJsons.length > 0) {
|
|
312
|
-
return await updateWorkspacePackages(workspacePkgJsons, args, options);
|
|
313
|
-
} else if (args["allWorkspaces"]) {
|
|
314
|
-
relinka("warn", "No workspace packages found but --all-workspaces flag was provided");
|
|
315
|
-
}
|
|
316
|
-
} else if (isMonorepoProject) {
|
|
317
|
-
relinka("log", "Skipping workspace packages due to --root-only flag");
|
|
318
|
-
}
|
|
319
|
-
return 0;
|
|
320
|
-
}
|
|
321
|
-
export function displayUpdateSummary(totalUpdated, args, isMonorepoProject, shouldUpdateWorkspaces) {
|
|
322
|
-
if (args.recursive) {
|
|
323
|
-
relinka("log", `Updated ${totalUpdated} dependencies across all package.json files`);
|
|
324
|
-
} else {
|
|
325
|
-
if (isMonorepoProject && shouldUpdateWorkspaces) {
|
|
326
|
-
relinka("log", `Updated ${totalUpdated} dependencies across workspace (root + workspaces)`);
|
|
327
|
-
} else if (isMonorepoProject) {
|
|
328
|
-
relinka("log", `Updated ${totalUpdated} dependencies in root package.json only`);
|
|
329
|
-
} else {
|
|
330
|
-
relinka("log", `Updated ${totalUpdated} dependencies`);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
export async function handleInstallation(args, effectiveLinker, packageJson) {
|
|
335
|
-
if (!args["withInstall"]) {
|
|
336
|
-
const packageManager2 = await detectPackageManager(process.cwd());
|
|
337
|
-
const installCommand = packageManager2?.command || "your package manager";
|
|
338
|
-
relinka(
|
|
339
|
-
"log",
|
|
340
|
-
`Install step is skipped by default. Run '${installCommand} install' manually to apply the changes.`
|
|
341
|
-
);
|
|
342
|
-
relinka(
|
|
343
|
-
"log",
|
|
344
|
-
`(experimental) Next time you can try --withInstall flag to run it automatically.`
|
|
345
|
-
);
|
|
346
|
-
return;
|
|
347
|
-
}
|
|
141
|
+
export async function handleInstallation() {
|
|
348
142
|
const packageManager = await detectPackageManager(process.cwd());
|
|
349
143
|
if (!packageManager) {
|
|
350
144
|
relinka("warn", "Could not detect package manager. Please run install manually.");
|
|
351
145
|
return;
|
|
352
146
|
}
|
|
353
147
|
try {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
await runInstallCommandWithFilter(packageManager, effectiveLinker, filterArgs);
|
|
357
|
-
} else {
|
|
358
|
-
await runInstallCommand(packageManager, effectiveLinker);
|
|
359
|
-
}
|
|
360
|
-
if (packageManager.name === "bun" && packageJson.scripts?.check && args["withCheckScript"]) {
|
|
361
|
-
await $`bun check`;
|
|
362
|
-
}
|
|
148
|
+
await runInstallCommand(packageManager);
|
|
149
|
+
relinka("log", "Installation completed successfully");
|
|
363
150
|
} catch (error) {
|
|
364
151
|
relinka("warn", `Install failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
365
152
|
relinka("log", `Run '${packageManager.command} install' manually to apply the changes`);
|
|
366
153
|
}
|
|
367
154
|
}
|
|
368
|
-
export async function handleToolUpgrades(args) {
|
|
369
|
-
const toolUpgradeFunctions = [
|
|
370
|
-
{ name: "dler (local)", fn: upgradeDlerLocal },
|
|
371
|
-
{ name: "dler (global)", fn: upgradeDlerGlobal },
|
|
372
|
-
{ name: "git", fn: upgradeGit },
|
|
373
|
-
{ name: "node.js", fn: upgradeNode },
|
|
374
|
-
{ name: "npm", fn: upgradeNpm },
|
|
375
|
-
{ name: "bun", fn: upgradeBun },
|
|
376
|
-
{ name: "yarn", fn: upgradeYarn },
|
|
377
|
-
{ name: "pnpm", fn: upgradePnpm }
|
|
378
|
-
];
|
|
379
|
-
let results = [];
|
|
380
|
-
if (args["upgrade-interactive"]) {
|
|
381
|
-
const preliminaryResults = await Promise.all(
|
|
382
|
-
toolUpgradeFunctions.map(async ({ fn }) => await fn())
|
|
383
|
-
);
|
|
384
|
-
const availableTools = toolUpgradeFunctions.map((tool, index) => ({
|
|
385
|
-
...tool,
|
|
386
|
-
result: preliminaryResults[index]
|
|
387
|
-
})).filter(({ result }) => result && result.status !== "not-found");
|
|
388
|
-
if (availableTools.length === 0) {
|
|
389
|
-
relinka("warn", "No tools available for upgrade");
|
|
390
|
-
return;
|
|
391
|
-
}
|
|
392
|
-
const selectedTools = await multiselectPrompt({
|
|
393
|
-
title: "Select tools to upgrade",
|
|
394
|
-
displayInstructions: true,
|
|
395
|
-
options: [
|
|
396
|
-
{ label: "Exit", value: "exit" },
|
|
397
|
-
...availableTools.map(({ name, result }) => {
|
|
398
|
-
const isUpToDate = result && result.status === "up-to-date";
|
|
399
|
-
const hasErrors = result && result.status === "error";
|
|
400
|
-
const canUpgrade = result && result.status === "upgraded";
|
|
401
|
-
let label = name;
|
|
402
|
-
if (isUpToDate) {
|
|
403
|
-
label += " (up-to-date)";
|
|
404
|
-
} else if (hasErrors) {
|
|
405
|
-
label += " (has errors)";
|
|
406
|
-
} else if (canUpgrade) {
|
|
407
|
-
label += " (can be upgraded)";
|
|
408
|
-
}
|
|
409
|
-
return {
|
|
410
|
-
label: isUpToDate || hasErrors ? re.gray(label) : label,
|
|
411
|
-
value: name,
|
|
412
|
-
disabled: isUpToDate || hasErrors,
|
|
413
|
-
hint: hasErrors ? result.message : void 0
|
|
414
|
-
};
|
|
415
|
-
})
|
|
416
|
-
]
|
|
417
|
-
});
|
|
418
|
-
if (selectedTools.length === 0 || selectedTools.includes("exit")) {
|
|
419
|
-
relinka("info", "Exiting upgrade process");
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
const actualSelectedTools = selectedTools.filter((tool) => tool !== "exit");
|
|
423
|
-
relinka("info", `Upgrading ${actualSelectedTools.length} selected tools...`);
|
|
424
|
-
for (const toolName of actualSelectedTools) {
|
|
425
|
-
const tool = availableTools.find((t) => t.name === toolName);
|
|
426
|
-
if (tool) {
|
|
427
|
-
const result = await tool.fn();
|
|
428
|
-
results.push(result);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
} else {
|
|
432
|
-
results = await Promise.all(toolUpgradeFunctions.map(async ({ fn }) => await fn()));
|
|
433
|
-
}
|
|
434
|
-
const upgraded = results.filter((r) => r.status === "upgraded");
|
|
435
|
-
const upToDate = results.filter((r) => r.status === "up-to-date");
|
|
436
|
-
const notFound = results.filter((r) => r.status === "not-found");
|
|
437
|
-
const errors = results.filter((r) => r.status === "error");
|
|
438
|
-
if (upgraded.length > 0) {
|
|
439
|
-
relinka("success", `Upgraded ${upgraded.length} tools:`);
|
|
440
|
-
upgraded.forEach(
|
|
441
|
-
(r) => relinka("verbose", ` \u2713 ${r.tool}${r.message ? ` - ${r.message}` : ""}`)
|
|
442
|
-
);
|
|
443
|
-
}
|
|
444
|
-
if (upToDate.length > 0) {
|
|
445
|
-
relinka("info", `${upToDate.length} tools already up-to-date:`);
|
|
446
|
-
upToDate.forEach(
|
|
447
|
-
(r) => relinka("verbose", ` \u2022 ${r.tool}${r.message ? ` - ${r.message}` : ""}`)
|
|
448
|
-
);
|
|
449
|
-
}
|
|
450
|
-
if (notFound.length > 0) {
|
|
451
|
-
relinka("warn", `${notFound.length} tools not installed (skipped):`);
|
|
452
|
-
notFound.forEach((r) => relinka("verbose", ` - ${r.tool}`));
|
|
453
|
-
}
|
|
454
|
-
if (errors.length > 0) {
|
|
455
|
-
relinka("error", `${errors.length} tools had errors:`);
|
|
456
|
-
errors.forEach((r) => relinka("verbose", ` \u2717 ${r.tool}${r.message ? ` - ${r.message}` : ""}`));
|
|
457
|
-
}
|
|
458
|
-
relinka("success", "Upgrade check completed!");
|
|
459
|
-
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { type PackageManager } from "../utils/dependencies/getUserPkgManager.js";
|
|
2
|
-
export interface UpgradeResult {
|
|
3
|
-
tool: string;
|
|
4
|
-
status: "upgraded" | "up-to-date" | "not-found" | "error";
|
|
5
|
-
message?: string;
|
|
6
|
-
}
|
|
7
2
|
export interface UpdateResult {
|
|
8
3
|
package: string;
|
|
9
4
|
currentVersion: string;
|
|
@@ -22,11 +17,6 @@ export interface PackageCheckOptions {
|
|
|
22
17
|
savePrefix: string;
|
|
23
18
|
concurrency: number;
|
|
24
19
|
}
|
|
25
|
-
export declare const versionCache: Map<string, {
|
|
26
|
-
version: string;
|
|
27
|
-
timestamp: number;
|
|
28
|
-
}>;
|
|
29
|
-
export declare const CACHE_TTL: number;
|
|
30
20
|
/**
|
|
31
21
|
* Check if a dependency is an npm alias (e.g., "npm:package-name@version")
|
|
32
22
|
*/
|
|
@@ -43,31 +33,22 @@ export declare function isNonSemverSpecifier(versionSpec: string): boolean;
|
|
|
43
33
|
*/
|
|
44
34
|
export declare function isSemverCompatible(currentVersionRange: string, latestVersion: string): boolean;
|
|
45
35
|
/**
|
|
46
|
-
* Collect dependencies from package.json
|
|
36
|
+
* Collect ALL dependencies from package.json.
|
|
47
37
|
* Returns a map of dependency name to its version and all locations where it appears.
|
|
48
38
|
*/
|
|
49
|
-
export declare function collectTargetDependencies(pkg: any
|
|
39
|
+
export declare function collectTargetDependencies(pkg: any): {
|
|
50
40
|
map: Record<string, DependencyInfo>;
|
|
51
41
|
};
|
|
52
42
|
/**
|
|
53
43
|
* Apply a version update into all relevant places in package.json for a dependency.
|
|
54
44
|
*/
|
|
55
45
|
export declare function applyVersionUpdate(pkg: any, depName: string, newVersion: string, locations: Set<string>): void;
|
|
56
|
-
export declare function findWorkspacePackageJsons(cwd: string): Promise<string[]>;
|
|
57
|
-
/**
|
|
58
|
-
* Check if we're in a monorepo by detecting workspace configuration
|
|
59
|
-
*/
|
|
60
|
-
export declare function isMonorepo(cwd: string): Promise<boolean>;
|
|
61
|
-
/**
|
|
62
|
-
* Recursively find ALL package.json files in the directory tree
|
|
63
|
-
*/
|
|
64
|
-
export declare function findAllPackageJsons(cwd: string): Promise<string[]>;
|
|
65
46
|
/**
|
|
66
47
|
* Fallback function to fetch package version directly from npm registry
|
|
67
48
|
*/
|
|
68
49
|
export declare function fetchVersionFromRegistry(packageName: string): Promise<string>;
|
|
69
50
|
/**
|
|
70
|
-
* Get latest version
|
|
51
|
+
* Get latest version of a package
|
|
71
52
|
*/
|
|
72
53
|
export declare function getLatestVersion(packageName: string): Promise<string>;
|
|
73
54
|
/**
|
|
@@ -81,41 +62,21 @@ export declare function getLatestVersion(packageName: string): Promise<string>;
|
|
|
81
62
|
*/
|
|
82
63
|
export declare function checkPackageUpdate(packageName: string, versionSpec: string, locations: Set<string>, options: PackageCheckOptions): Promise<UpdateResult>;
|
|
83
64
|
/**
|
|
84
|
-
* Filter and prepare dependencies for updating
|
|
65
|
+
* Filter and prepare dependencies for updating with glob pattern support
|
|
85
66
|
*/
|
|
86
67
|
export declare function prepareDependenciesForUpdate(allDepsMap: Record<string, DependencyInfo>, args: any): string[];
|
|
87
68
|
/**
|
|
88
69
|
* Update a single package.json file with new dependency versions
|
|
89
70
|
*/
|
|
90
|
-
export declare function updatePackageJsonFile(packageJsonPath: string, dependencies: Record<string, DependencyInfo>, updatesToApply: UpdateResult[], savePrefix: string): Promise<number>;
|
|
91
|
-
/**
|
|
92
|
-
* Update dependencies across all workspace packages
|
|
93
|
-
*/
|
|
94
|
-
export declare function updateWorkspacePackages(workspacePaths: string[], args: any, options: PackageCheckOptions): Promise<number>;
|
|
71
|
+
export declare function updatePackageJsonFile(packageJsonPath: string, dependencies: Record<string, DependencyInfo>, updatesToApply: UpdateResult[], savePrefix: string, fieldsToIgnore?: string[]): Promise<number>;
|
|
95
72
|
/**
|
|
96
|
-
* Display update results in a
|
|
73
|
+
* Display update results in a structured, file-by-file format
|
|
97
74
|
*/
|
|
98
|
-
export declare function
|
|
99
|
-
/**
|
|
100
|
-
* Get globally installed packages for different package managers
|
|
101
|
-
*/
|
|
102
|
-
export declare function getGlobalPackages(packageManager: string): Promise<Record<string, string>>;
|
|
75
|
+
export declare function displayStructuredUpdateResults(results: UpdateResult[], packageJsonFiles: string[], fileDepsMap: Map<string, Record<string, any>>, showDetails?: boolean): void;
|
|
103
76
|
/**
|
|
104
77
|
* Run install command for the detected package manager
|
|
105
78
|
*/
|
|
106
|
-
export declare function runInstallCommand(packageManager: any
|
|
107
|
-
/**
|
|
108
|
-
* Run install command with filter arguments for monorepo support
|
|
109
|
-
*/
|
|
110
|
-
export declare function runInstallCommandWithFilter(packageManager: any, linker?: string, filterArgs?: string[]): Promise<void>;
|
|
111
|
-
/**
|
|
112
|
-
* Update global packages for different package managers
|
|
113
|
-
*/
|
|
114
|
-
export declare function updateGlobalPackage(packageManager: string, packageName: string): Promise<boolean>;
|
|
115
|
-
/**
|
|
116
|
-
* Handle global package updates
|
|
117
|
-
*/
|
|
118
|
-
export declare function handleGlobalUpdates(args: any): Promise<void>;
|
|
79
|
+
export declare function runInstallCommand(packageManager: any): Promise<void>;
|
|
119
80
|
export declare function getPmOptions(): Promise<{
|
|
120
81
|
pmOptions: {
|
|
121
82
|
label: string;
|
|
@@ -124,11 +85,3 @@ export declare function getPmOptions(): Promise<{
|
|
|
124
85
|
}[];
|
|
125
86
|
defaultValue: any;
|
|
126
87
|
}>;
|
|
127
|
-
export declare function upgradeDlerLocal(): Promise<UpgradeResult>;
|
|
128
|
-
export declare function upgradeDlerGlobal(): Promise<UpgradeResult>;
|
|
129
|
-
export declare function upgradeGit(): Promise<UpgradeResult>;
|
|
130
|
-
export declare function upgradeNode(): Promise<UpgradeResult>;
|
|
131
|
-
export declare function upgradeNpm(): Promise<UpgradeResult>;
|
|
132
|
-
export declare function upgradeBun(): Promise<UpgradeResult>;
|
|
133
|
-
export declare function upgradeYarn(): Promise<UpgradeResult>;
|
|
134
|
-
export declare function upgradePnpm(): Promise<UpgradeResult>;
|