@reliverse/dler 1.7.140 → 1.7.141
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/bin/impl/auth/impl/init.d.ts +4 -4
- package/bin/impl/config/constants.d.ts +1 -1
- package/bin/impl/config/constants.js +1 -1
- package/bin/impl/providers/better-t-stack/types.d.ts +7 -7
- package/bin/impl/update/impl.d.ts +5 -33
- package/bin/impl/update/impl.js +30 -338
- package/bin/impl/update/utils.d.ts +5 -52
- package/bin/impl/update/utils.js +97 -655
- package/bin/mod.d.ts +3 -3
- package/bin/mod.js +2 -30
- package/package.json +2 -1
|
@@ -146,17 +146,17 @@ export declare const optionsSchema: z.ZodObject<{
|
|
|
146
146
|
cwd: z.ZodString;
|
|
147
147
|
config: z.ZodOptional<z.ZodString>;
|
|
148
148
|
database: z.ZodOptional<z.ZodEnum<{
|
|
149
|
-
sqlite: "sqlite";
|
|
150
149
|
mysql: "mysql";
|
|
151
|
-
|
|
150
|
+
sqlite: "sqlite";
|
|
151
|
+
mongodb: "mongodb";
|
|
152
152
|
postgres: "postgres";
|
|
153
|
+
mssql: "mssql";
|
|
153
154
|
"drizzle:pg": "drizzle:pg";
|
|
154
155
|
"drizzle:mysql": "drizzle:mysql";
|
|
155
156
|
"drizzle:sqlite": "drizzle:sqlite";
|
|
156
157
|
"prisma:postgresql": "prisma:postgresql";
|
|
157
158
|
"prisma:mysql": "prisma:mysql";
|
|
158
159
|
"prisma:sqlite": "prisma:sqlite";
|
|
159
|
-
mongodb: "mongodb";
|
|
160
160
|
}>>;
|
|
161
161
|
"skip-db": z.ZodOptional<z.ZodBoolean>;
|
|
162
162
|
"skip-plugins": z.ZodOptional<z.ZodBoolean>;
|
|
@@ -165,7 +165,7 @@ export declare const optionsSchema: z.ZodObject<{
|
|
|
165
165
|
}, z.core.$strip>;
|
|
166
166
|
export declare const outroText = "\uD83E\uDD73 All Done, Happy Hacking!";
|
|
167
167
|
export declare function getLatestNpmVersion(packageName: string): Promise<string>;
|
|
168
|
-
export declare function getPackageManager(): Promise<"
|
|
168
|
+
export declare function getPackageManager(): Promise<"npm" | "pnpm" | "yarn" | "bun">;
|
|
169
169
|
export declare function getEnvFiles(cwd: string): Promise<string[]>;
|
|
170
170
|
export declare function updateEnvs({ envs, files, isCommented, }: {
|
|
171
171
|
/**
|
|
@@ -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.141";
|
|
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.141";
|
|
5
5
|
export const cliVersion = version;
|
|
6
6
|
export const cliName = "@reliverse/rse";
|
|
7
7
|
export const rseName = "@reliverse/rse";
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const DatabaseSchema: z.ZodEnum<{
|
|
3
3
|
none: "none";
|
|
4
|
-
sqlite: "sqlite";
|
|
5
4
|
mysql: "mysql";
|
|
6
|
-
|
|
5
|
+
sqlite: "sqlite";
|
|
7
6
|
mongodb: "mongodb";
|
|
7
|
+
postgres: "postgres";
|
|
8
8
|
}>;
|
|
9
9
|
export type Database = z.infer<typeof DatabaseSchema>;
|
|
10
10
|
export declare const ORMSchema: z.ZodEnum<{
|
|
11
11
|
none: "none";
|
|
12
|
-
prisma: "prisma";
|
|
13
12
|
drizzle: "drizzle";
|
|
14
13
|
mongoose: "mongoose";
|
|
14
|
+
prisma: "prisma";
|
|
15
15
|
}>;
|
|
16
16
|
export type ORM = z.infer<typeof ORMSchema>;
|
|
17
17
|
export declare const BackendSchema: z.ZodEnum<{
|
|
18
18
|
none: "none";
|
|
19
19
|
hono: "hono";
|
|
20
20
|
next: "next";
|
|
21
|
+
convex: "convex";
|
|
21
22
|
express: "express";
|
|
22
23
|
fastify: "fastify";
|
|
23
24
|
elysia: "elysia";
|
|
24
|
-
convex: "convex";
|
|
25
25
|
}>;
|
|
26
26
|
export type Backend = z.infer<typeof BackendSchema>;
|
|
27
27
|
export declare const RuntimeSchema: z.ZodEnum<{
|
|
@@ -34,8 +34,8 @@ export type Runtime = z.infer<typeof RuntimeSchema>;
|
|
|
34
34
|
export declare const FrontendSchema: z.ZodEnum<{
|
|
35
35
|
none: "none";
|
|
36
36
|
svelte: "svelte";
|
|
37
|
-
solid: "solid";
|
|
38
37
|
nuxt: "nuxt";
|
|
38
|
+
solid: "solid";
|
|
39
39
|
next: "next";
|
|
40
40
|
"react-router": "react-router";
|
|
41
41
|
"tanstack-router": "tanstack-router";
|
|
@@ -55,15 +55,15 @@ export declare const AddonsSchema: z.ZodEnum<{
|
|
|
55
55
|
}>;
|
|
56
56
|
export type Addons = z.infer<typeof AddonsSchema>;
|
|
57
57
|
export declare const ExamplesSchema: z.ZodEnum<{
|
|
58
|
-
ai: "ai";
|
|
59
58
|
none: "none";
|
|
59
|
+
ai: "ai";
|
|
60
60
|
todo: "todo";
|
|
61
61
|
}>;
|
|
62
62
|
export type Examples = z.infer<typeof ExamplesSchema>;
|
|
63
63
|
export declare const PackageManagerSchema: z.ZodEnum<{
|
|
64
|
+
npm: "npm";
|
|
64
65
|
pnpm: "pnpm";
|
|
65
66
|
bun: "bun";
|
|
66
|
-
npm: "npm";
|
|
67
67
|
}>;
|
|
68
68
|
export type PackageManager = z.infer<typeof PackageManagerSchema>;
|
|
69
69
|
export declare const DatabaseSetupSchema: z.ZodEnum<{
|
|
@@ -1,49 +1,21 @@
|
|
|
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
|
-
concurrency?: number;
|
|
12
|
-
withCheckScript?: boolean;
|
|
13
|
-
linker?: string;
|
|
14
8
|
withInstall?: boolean;
|
|
15
|
-
global?: boolean;
|
|
16
|
-
interactive?: boolean;
|
|
17
|
-
filter?: string[];
|
|
18
|
-
allWorkspaces?: boolean;
|
|
19
|
-
rootOnly?: boolean;
|
|
20
|
-
recursive?: boolean;
|
|
21
|
-
savePrefix?: string;
|
|
22
9
|
allowMajor?: boolean;
|
|
10
|
+
concurrency?: number;
|
|
23
11
|
}
|
|
24
|
-
export declare function validateUpdateArgs(args: UpdateArgs): Promise<void>;
|
|
25
|
-
export declare function handleCatalogOnlyUpdate(args: UpdateArgs): Promise<boolean>;
|
|
26
12
|
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
13
|
export declare function prepareAllUpdateCandidates(args: UpdateArgs): Promise<{
|
|
36
14
|
candidates: string[];
|
|
37
15
|
allDepsMap: Record<string, any>;
|
|
38
16
|
packageJsonFiles: string[];
|
|
39
17
|
}>;
|
|
40
18
|
export declare function checkPackageUpdates(candidates: string[], allDepsMap: Record<string, any>, args: UpdateArgs): Promise<UpdateResult[]>;
|
|
41
|
-
export declare function handleInteractiveSelection(results: UpdateResult[]): Promise<UpdateResult[]>;
|
|
42
|
-
export declare function updateRootPackageJson(packageJsonPath: string, allDepsMap: Record<string, any>, toUpdate: UpdateResult[], savePrefix: string): Promise<number>;
|
|
43
19
|
export declare function updateAllPackageJsonFiles(packageJsonFiles: string[], toUpdate: UpdateResult[], savePrefix: string): Promise<number>;
|
|
44
|
-
export declare function
|
|
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>;
|
|
20
|
+
export declare function handleInstallation(): Promise<void>;
|
|
49
21
|
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,46 +19,34 @@ 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
|
|
40
|
+
relinka("warn", "No package.json files found");
|
|
118
41
|
return { candidates: [], allDepsMap: {}, packageJsonFiles: [] };
|
|
119
42
|
}
|
|
43
|
+
relinka("verbose", `Found ${packageJsonFiles.length} package.json files`);
|
|
120
44
|
const allDepsMap = {};
|
|
121
45
|
const allCandidates = /* @__PURE__ */ new Set();
|
|
122
46
|
for (const packageJsonPath of packageJsonFiles) {
|
|
123
47
|
try {
|
|
124
48
|
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf8"));
|
|
125
|
-
const { map } = collectTargetDependencies(packageJson
|
|
49
|
+
const { map } = collectTargetDependencies(packageJson);
|
|
126
50
|
const candidates2 = prepareDependenciesForUpdate(map, args);
|
|
127
51
|
for (const [dep, info] of Object.entries(map)) {
|
|
128
52
|
if (!allDepsMap[dep]) {
|
|
@@ -146,41 +70,17 @@ export async function prepareAllUpdateCandidates(args) {
|
|
|
146
70
|
}
|
|
147
71
|
const candidates = Array.from(allCandidates);
|
|
148
72
|
if (candidates.length === 0) {
|
|
149
|
-
relinka(
|
|
150
|
-
"warn",
|
|
151
|
-
"No dependencies to update based on provided filters across all package.json files"
|
|
152
|
-
);
|
|
73
|
+
relinka("warn", "No dependencies to update");
|
|
153
74
|
return { candidates: [], allDepsMap: {}, packageJsonFiles };
|
|
154
75
|
}
|
|
76
|
+
relinka("verbose", `Processing ${packageJsonFiles.length} package.json files`);
|
|
155
77
|
return { candidates, allDepsMap, packageJsonFiles };
|
|
156
78
|
}
|
|
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;
|
|
179
|
-
}
|
|
180
79
|
export async function checkPackageUpdates(candidates, allDepsMap, args) {
|
|
181
80
|
const options = {
|
|
182
|
-
allowMajor: !!args
|
|
183
|
-
savePrefix:
|
|
81
|
+
allowMajor: !!args.allowMajor,
|
|
82
|
+
savePrefix: "^",
|
|
83
|
+
// Use default prefix
|
|
184
84
|
concurrency: args.concurrency || 5
|
|
185
85
|
};
|
|
186
86
|
return await pMap(
|
|
@@ -203,61 +103,6 @@ export async function checkPackageUpdates(candidates, allDepsMap, args) {
|
|
|
203
103
|
{ concurrency: args.concurrency || 5 }
|
|
204
104
|
);
|
|
205
105
|
}
|
|
206
|
-
export async function handleInteractiveSelection(results) {
|
|
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
106
|
export async function updateAllPackageJsonFiles(packageJsonFiles, toUpdate, savePrefix) {
|
|
262
107
|
if (packageJsonFiles.length === 0 || toUpdate.length === 0) {
|
|
263
108
|
return 0;
|
|
@@ -266,7 +111,7 @@ export async function updateAllPackageJsonFiles(packageJsonFiles, toUpdate, save
|
|
|
266
111
|
for (const packageJsonPath of packageJsonFiles) {
|
|
267
112
|
try {
|
|
268
113
|
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf8"));
|
|
269
|
-
const { map: fileDepsMap } = collectTargetDependencies(packageJson
|
|
114
|
+
const { map: fileDepsMap } = collectTargetDependencies(packageJson);
|
|
270
115
|
const fileSpecificUpdates = toUpdate.filter((update) => fileDepsMap[update.package]);
|
|
271
116
|
if (fileSpecificUpdates.length > 0) {
|
|
272
117
|
const updated = await updatePackageJsonFile(
|
|
@@ -290,170 +135,17 @@ export async function updateAllPackageJsonFiles(packageJsonFiles, toUpdate, save
|
|
|
290
135
|
}
|
|
291
136
|
return totalUpdated;
|
|
292
137
|
}
|
|
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
|
-
}
|
|
138
|
+
export async function handleInstallation() {
|
|
348
139
|
const packageManager = await detectPackageManager(process.cwd());
|
|
349
140
|
if (!packageManager) {
|
|
350
141
|
relinka("warn", "Could not detect package manager. Please run install manually.");
|
|
351
142
|
return;
|
|
352
143
|
}
|
|
353
144
|
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
|
-
}
|
|
145
|
+
await runInstallCommand(packageManager);
|
|
146
|
+
relinka("log", "Installation completed successfully");
|
|
363
147
|
} catch (error) {
|
|
364
148
|
relinka("warn", `Install failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
365
149
|
relinka("log", `Run '${packageManager.command} install' manually to apply the changes`);
|
|
366
150
|
}
|
|
367
151
|
}
|
|
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
|
-
}
|