@reliverse/dler 2.2.5 → 2.2.10
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 +14 -14
- package/dist/cli.js +1 -1
- package/dist/cmds/biome/cmd.js +58 -0
- package/dist/cmds/biome/impl.d.ts +26 -0
- package/dist/cmds/biome/impl.js +272 -0
- package/dist/cmds/build/cmd.js +18 -10
- package/dist/cmds/clean/cmd.js +6 -6
- package/dist/cmds/clean/impl.js +16 -12
- package/dist/cmds/clean/presets.js +2 -2
- package/dist/cmds/publish/cmd.js +7 -7
- package/dist/cmds/senv/cmd.js +13 -15
- package/dist/cmds/tsc/cache.js +1 -1
- package/dist/cmds/tsc/cmd.js +11 -8
- package/dist/cmds/tsc/impl.js +132 -17
- package/dist/cmds/update/cmd.js +11 -10
- package/dist/cmds/update/impl.d.ts +4 -4
- package/dist/cmds/update/impl.js +10 -11
- package/dist/cmds/update/utils.d.ts +23 -4
- package/dist/cmds/update/utils.js +22 -16
- package/package.json +16 -13
- package/dist/cmds/perf/analysis/bundle.d.ts +0 -20
- package/dist/cmds/perf/analysis/bundle.js +0 -225
- package/dist/cmds/perf/analysis/filesystem.d.ts +0 -27
- package/dist/cmds/perf/analysis/filesystem.js +0 -245
- package/dist/cmds/perf/analysis/monorepo.d.ts +0 -30
- package/dist/cmds/perf/analysis/monorepo.js +0 -345
- package/dist/cmds/perf/benchmarks/command.d.ts +0 -21
- package/dist/cmds/perf/benchmarks/command.js +0 -162
- package/dist/cmds/perf/benchmarks/memory.d.ts +0 -41
- package/dist/cmds/perf/benchmarks/memory.js +0 -169
- package/dist/cmds/perf/benchmarks/runner.d.ts +0 -22
- package/dist/cmds/perf/benchmarks/runner.js +0 -157
- package/dist/cmds/perf/cmd.js +0 -240
- package/dist/cmds/perf/impl.d.ts +0 -24
- package/dist/cmds/perf/impl.js +0 -297
- package/dist/cmds/perf/reporters/console.d.ts +0 -12
- package/dist/cmds/perf/reporters/console.js +0 -257
- package/dist/cmds/perf/reporters/html.d.ts +0 -27
- package/dist/cmds/perf/reporters/html.js +0 -881
- package/dist/cmds/perf/reporters/json.d.ts +0 -9
- package/dist/cmds/perf/reporters/json.js +0 -32
- package/dist/cmds/perf/types.d.ts +0 -184
- package/dist/cmds/perf/types.js +0 -0
- package/dist/cmds/perf/utils/cache.d.ts +0 -23
- package/dist/cmds/perf/utils/cache.js +0 -172
- package/dist/cmds/perf/utils/formatter.d.ts +0 -17
- package/dist/cmds/perf/utils/formatter.js +0 -134
- package/dist/cmds/perf/utils/stats.d.ts +0 -15
- package/dist/cmds/perf/utils/stats.js +0 -101
- package/dist/cmds/port/cmd.d.ts +0 -2
- package/dist/cmds/port/cmd.js +0 -58
- package/dist/cmds/port/impl.d.ts +0 -5
- package/dist/cmds/port/impl.js +0 -280
- package/dist/cmds/shell/cmd.d.ts +0 -2
- package/dist/cmds/shell/cmd.js +0 -46
- /package/dist/cmds/{perf → biome}/cmd.d.ts +0 -0
package/dist/cmds/senv/cmd.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { logger } from "@reliverse/
|
|
3
|
-
import
|
|
4
|
-
const isWindows = () =>
|
|
1
|
+
import fs from "@reliverse/relifso";
|
|
2
|
+
import { logger } from "@reliverse/relinka";
|
|
3
|
+
import { defineArgs, defineCommand } from "@reliverse/rempts";
|
|
4
|
+
const isWindows = () => {
|
|
5
|
+
const bun = globalThis;
|
|
6
|
+
return bun.Bun?.platform?.() === "win32" || process.platform === "win32";
|
|
7
|
+
};
|
|
5
8
|
const fileExists = async (path) => {
|
|
6
|
-
|
|
7
|
-
await fs.access(path);
|
|
8
|
-
return true;
|
|
9
|
-
} catch {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
9
|
+
return await fs.pathExists(path);
|
|
12
10
|
};
|
|
13
11
|
const normalizePathEntries = (raw) => {
|
|
14
12
|
const sep = isWindows() ? ";" : ":";
|
|
@@ -44,7 +42,7 @@ const backupFile = async (path) => {
|
|
|
44
42
|
const now = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
45
43
|
const random = Math.random().toString(36).substring(2, 8);
|
|
46
44
|
const bak = `${path}.bak.${now}.${random}`;
|
|
47
|
-
await fs.
|
|
45
|
+
await fs.copy(path, bak);
|
|
48
46
|
logger.info(`Backup created: ${bak}`);
|
|
49
47
|
} catch (error) {
|
|
50
48
|
logger.warn(`Failed to create backup for ${path}: ${error}`);
|
|
@@ -105,8 +103,8 @@ export ${name}="${value}"
|
|
|
105
103
|
return;
|
|
106
104
|
}
|
|
107
105
|
await backupFile(profile);
|
|
108
|
-
const content = await fs.readFile(profile, "utf8");
|
|
109
|
-
const newContent = re.test(content) ? content.replace(re, `export ${name}="${value}"`) : content
|
|
106
|
+
const content = await fs.readFile(profile, { encoding: "utf8" });
|
|
107
|
+
const newContent = re.test(content) ? content.replace(re, `export ${name}="${value}"`) : `${content}
|
|
110
108
|
# added by dler senv
|
|
111
109
|
export ${name}="${value}"
|
|
112
110
|
`;
|
|
@@ -128,7 +126,7 @@ const persistPosixEditPath = async (name, entry, action) => {
|
|
|
128
126
|
const re = new RegExp(`^\\s*export\\s+${escapedName}=["']?(.*)["']?$`, "m");
|
|
129
127
|
await backupFile(profile);
|
|
130
128
|
const exists = await fileExists(profile);
|
|
131
|
-
const content = exists ? await fs.readFile(profile, "utf8") : "";
|
|
129
|
+
const content = exists ? await fs.readFile(profile, { encoding: "utf8" }) : "";
|
|
132
130
|
const match = content.match(re);
|
|
133
131
|
const current = match ? match[1] : process.env[name] || "";
|
|
134
132
|
let entries = normalizePathEntries(current || "").map(normalizeEntry);
|
|
@@ -145,7 +143,7 @@ const persistPosixEditPath = async (name, entry, action) => {
|
|
|
145
143
|
}
|
|
146
144
|
entries = uniqueByComparable(entries);
|
|
147
145
|
const newVal = joinPathEntries(entries);
|
|
148
|
-
const next = re.test(content) ? content.replace(re, `export ${name}="${newVal}"`) : content
|
|
146
|
+
const next = re.test(content) ? content.replace(re, `export ${name}="${newVal}"`) : `${content}
|
|
149
147
|
# added by dler senv
|
|
150
148
|
export ${name}="${newVal}"
|
|
151
149
|
`;
|
package/dist/cmds/tsc/cache.js
CHANGED
package/dist/cmds/tsc/cmd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { logger } from "@reliverse/relinka";
|
|
2
|
+
import { defineArgs, defineCommand } from "@reliverse/rempts";
|
|
3
3
|
import { runTscOnAllPackages } from "./impl.js";
|
|
4
4
|
export default defineCommand({
|
|
5
5
|
meta: {
|
|
@@ -7,10 +7,10 @@ export default defineCommand({
|
|
|
7
7
|
description: "Run TypeScript type checking on all workspace packages",
|
|
8
8
|
examples: [
|
|
9
9
|
"dler tsc",
|
|
10
|
-
'dler tsc --filter "@reliverse/
|
|
10
|
+
'dler tsc --filter "@reliverse/rempts,@reliverse/build"',
|
|
11
11
|
'dler tsc --ignore "@reliverse/*"',
|
|
12
|
-
'dler tsc --ignore "@reliverse/
|
|
13
|
-
'dler tsc --ignore "@reliverse/
|
|
12
|
+
'dler tsc --ignore "@reliverse/relico" --ignore "@reliverse/dler-v1"',
|
|
13
|
+
'dler tsc --ignore "@reliverse/relico @reliverse/dler-v1"',
|
|
14
14
|
"dler tsc --cwd /path/to/monorepo",
|
|
15
15
|
"dler tsc --cwd /path/to/monorepo --ignore @reliverse/*",
|
|
16
16
|
"dler tsc --concurrency 8",
|
|
@@ -32,7 +32,7 @@ export default defineCommand({
|
|
|
32
32
|
args: defineArgs({
|
|
33
33
|
filter: {
|
|
34
34
|
type: "string",
|
|
35
|
-
description: "Package(s) to include (supports wildcards and comma-separated values like '@reliverse/
|
|
35
|
+
description: "Package(s) to include (supports wildcards and comma-separated values like '@reliverse/rempts,@reliverse/build'). Takes precedence over --ignore when both are provided.",
|
|
36
36
|
positional: true
|
|
37
37
|
},
|
|
38
38
|
ignore: {
|
|
@@ -57,7 +57,8 @@ export default defineCommand({
|
|
|
57
57
|
},
|
|
58
58
|
copyLogs: {
|
|
59
59
|
type: "boolean",
|
|
60
|
-
description: "Copy failed package logs to clipboard (default:
|
|
60
|
+
description: "Copy failed package logs to clipboard (default: true, skipped in CI)",
|
|
61
|
+
default: true
|
|
61
62
|
},
|
|
62
63
|
cache: {
|
|
63
64
|
type: "boolean",
|
|
@@ -86,12 +87,14 @@ export default defineCommand({
|
|
|
86
87
|
logger.error("\u274C This command requires Bun runtime. Sorry.");
|
|
87
88
|
process.exit(1);
|
|
88
89
|
}
|
|
90
|
+
const isCI = process.env.CI === "true" || !process.stdout.isTTY;
|
|
91
|
+
const shouldCopyLogs = args.copyLogs !== false && !isCI;
|
|
89
92
|
const results = await runTscOnAllPackages(args.ignore, args.cwd, {
|
|
90
93
|
filter: args.filter,
|
|
91
94
|
concurrency: args.concurrency,
|
|
92
95
|
stopOnError: args.stopOnError,
|
|
93
96
|
verbose: args.verbose,
|
|
94
|
-
copyLogs:
|
|
97
|
+
copyLogs: shouldCopyLogs,
|
|
95
98
|
cache: args.cache,
|
|
96
99
|
incremental: args.incremental,
|
|
97
100
|
autoConcurrency: args.autoConcurrency,
|
package/dist/cmds/tsc/impl.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { cpus } from "node:os";
|
|
3
3
|
import { join, relative, resolve } from "node:path";
|
|
4
|
-
import { writeErrorLines } from "@reliverse/
|
|
5
|
-
import
|
|
6
|
-
import pMap from "@reliverse/dler-mapper";
|
|
4
|
+
import { writeErrorLines } from "@reliverse/helpers";
|
|
5
|
+
import pMap from "@reliverse/mapkit";
|
|
7
6
|
import {
|
|
8
7
|
createIgnoreFilter,
|
|
9
8
|
createIncludeFilter,
|
|
10
9
|
normalizePatterns
|
|
11
|
-
} from "@reliverse/
|
|
10
|
+
} from "@reliverse/matcha";
|
|
11
|
+
import { logger } from "@reliverse/relinka";
|
|
12
12
|
import {
|
|
13
13
|
getWorkspacePatterns,
|
|
14
14
|
hasWorkspaces,
|
|
15
15
|
readPackageJSON
|
|
16
|
-
} from "@reliverse/
|
|
16
|
+
} from "@reliverse/typerso";
|
|
17
17
|
import clipboard from "clipboardy";
|
|
18
|
+
import { lookpath } from "lookpath";
|
|
18
19
|
import { TscCache } from "./cache.js";
|
|
19
20
|
const DEFAULT_CONCURRENCY = Math.max(4, cpus().length);
|
|
20
21
|
const DISCOVERY_CONCURRENCY = 10;
|
|
@@ -113,7 +114,9 @@ const getWorkspacePackages = async (cwd) => {
|
|
|
113
114
|
},
|
|
114
115
|
{ concurrency: DISCOVERY_CONCURRENCY }
|
|
115
116
|
);
|
|
116
|
-
const packages = packageResults.filter(
|
|
117
|
+
const packages = packageResults.filter(
|
|
118
|
+
(result) => result.pkgInfo !== null
|
|
119
|
+
).map((result) => result.pkgInfo);
|
|
117
120
|
const filteredPackages = packages.filter((pkg) => {
|
|
118
121
|
const normalizedPkgPath = resolve(pkg.path);
|
|
119
122
|
const normalizedRootPath = resolve(monorepoRoot);
|
|
@@ -150,17 +153,48 @@ const hasProjectReferences = async (packagePath) => {
|
|
|
150
153
|
return false;
|
|
151
154
|
}
|
|
152
155
|
};
|
|
156
|
+
const findTscExecutable = async (packagePath) => {
|
|
157
|
+
const localTscPath = join(packagePath, "node_modules", ".bin", "tsc");
|
|
158
|
+
if (existsSync(localTscPath)) {
|
|
159
|
+
return localTscPath;
|
|
160
|
+
}
|
|
161
|
+
let currentDir = resolve(packagePath, "..");
|
|
162
|
+
while (currentDir !== "/") {
|
|
163
|
+
const parentLocalTscPath = join(currentDir, "node_modules", ".bin", "tsc");
|
|
164
|
+
if (existsSync(parentLocalTscPath)) {
|
|
165
|
+
return parentLocalTscPath;
|
|
166
|
+
}
|
|
167
|
+
const parentDir = resolve(currentDir, "..");
|
|
168
|
+
if (parentDir === currentDir) break;
|
|
169
|
+
currentDir = parentDir;
|
|
170
|
+
}
|
|
171
|
+
const globalTscPath = await lookpath("tsc");
|
|
172
|
+
if (globalTscPath) {
|
|
173
|
+
return globalTscPath;
|
|
174
|
+
}
|
|
175
|
+
return null;
|
|
176
|
+
};
|
|
153
177
|
const runTscCommand = async (packagePath, options = {}) => {
|
|
154
178
|
try {
|
|
155
|
-
const {
|
|
179
|
+
const {
|
|
180
|
+
incremental = true,
|
|
181
|
+
buildMode = false,
|
|
182
|
+
tscExecutable: providedTsc
|
|
183
|
+
} = options;
|
|
184
|
+
const tscExecutable = providedTsc ?? await findTscExecutable(packagePath);
|
|
185
|
+
if (!tscExecutable) {
|
|
186
|
+
throw new Error(
|
|
187
|
+
"TypeScript not found. Skipping package (install typescript locally or globally to enable type checking)."
|
|
188
|
+
);
|
|
189
|
+
}
|
|
156
190
|
let args;
|
|
157
191
|
if (buildMode && await hasProjectReferences(packagePath)) {
|
|
158
|
-
args = [
|
|
192
|
+
args = [tscExecutable, "--build"];
|
|
159
193
|
if (incremental) {
|
|
160
194
|
args.push("--incremental");
|
|
161
195
|
}
|
|
162
196
|
} else {
|
|
163
|
-
args = [
|
|
197
|
+
args = [tscExecutable, "--noEmit"];
|
|
164
198
|
if (incremental) {
|
|
165
199
|
args.push("--incremental");
|
|
166
200
|
const tsBuildInfoPath = join(
|
|
@@ -213,7 +247,7 @@ const filterOutputLines = (output, packagePath, monorepoRoot) => {
|
|
|
213
247
|
continue;
|
|
214
248
|
}
|
|
215
249
|
const match = line.match(/^(.+?)\(/);
|
|
216
|
-
if (match
|
|
250
|
+
if (match?.[1]) {
|
|
217
251
|
const relativePath = match[1];
|
|
218
252
|
const fullPath = resolve(packagePath, relativePath);
|
|
219
253
|
const normalizedFilePath = resolve(fullPath);
|
|
@@ -235,6 +269,21 @@ const filterOutputLines = (output, packagePath, monorepoRoot) => {
|
|
|
235
269
|
}
|
|
236
270
|
return filtered.join("\n");
|
|
237
271
|
};
|
|
272
|
+
const checkRequiredDependencies = async (packagePath) => {
|
|
273
|
+
try {
|
|
274
|
+
const pkg = await readPackageJSON(packagePath);
|
|
275
|
+
if (!pkg) {
|
|
276
|
+
return { hasTypeScript: false, hasTypesBun: false };
|
|
277
|
+
}
|
|
278
|
+
const deps = pkg.dependencies && typeof pkg.dependencies === "object" ? pkg.dependencies : {};
|
|
279
|
+
const devDeps = pkg.devDependencies && typeof pkg.devDependencies === "object" ? pkg.devDependencies : {};
|
|
280
|
+
const hasTypeScript = "typescript" in deps || "typescript" in devDeps;
|
|
281
|
+
const hasTypesBun = "@types/bun" in deps || "@types/bun" in devDeps;
|
|
282
|
+
return { hasTypeScript, hasTypesBun };
|
|
283
|
+
} catch {
|
|
284
|
+
return { hasTypeScript: false, hasTypesBun: false };
|
|
285
|
+
}
|
|
286
|
+
};
|
|
238
287
|
const runTscOnPackage = async (pkg, monorepoRoot, options = {}) => {
|
|
239
288
|
const {
|
|
240
289
|
verbose = false,
|
|
@@ -261,6 +310,21 @@ const runTscOnPackage = async (pkg, monorepoRoot, options = {}) => {
|
|
|
261
310
|
executionTime: Date.now() - startTime
|
|
262
311
|
};
|
|
263
312
|
}
|
|
313
|
+
const { hasTypeScript, hasTypesBun } = await checkRequiredDependencies(
|
|
314
|
+
pkg.path
|
|
315
|
+
);
|
|
316
|
+
if (!hasTypeScript || !hasTypesBun) {
|
|
317
|
+
const missing = [];
|
|
318
|
+
if (!hasTypeScript) {
|
|
319
|
+
missing.push("typescript");
|
|
320
|
+
}
|
|
321
|
+
if (!hasTypesBun) {
|
|
322
|
+
missing.push("@types/bun");
|
|
323
|
+
}
|
|
324
|
+
throw new Error(
|
|
325
|
+
`Package ${pkg.name} has tsconfig.json but ${missing.join(" and ")} ${missing.length === 1 ? "is" : "are"} not listed in dependencies or devDependencies. Please add ${missing.join(" and ")} to this package's package.json (then run bun install).`
|
|
326
|
+
);
|
|
327
|
+
}
|
|
264
328
|
if (cache) {
|
|
265
329
|
const shouldSkip = await cache.shouldSkipPackage(pkg);
|
|
266
330
|
if (shouldSkip) {
|
|
@@ -287,7 +351,39 @@ const runTscOnPackage = async (pkg, monorepoRoot, options = {}) => {
|
|
|
287
351
|
logger.info(`\u{1F50D} Checking ${pkg.name}...`);
|
|
288
352
|
}
|
|
289
353
|
try {
|
|
290
|
-
const
|
|
354
|
+
const tscExecutable = await findTscExecutable(pkg.path);
|
|
355
|
+
if (!tscExecutable) {
|
|
356
|
+
throw new Error(
|
|
357
|
+
"TypeScript not found. Skipping package (install typescript locally or globally to enable type checking)."
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
if (verbose) {
|
|
361
|
+
const normalizedTscPath = resolve(tscExecutable);
|
|
362
|
+
const normalizedPackagePath = resolve(pkg.path);
|
|
363
|
+
const normalizedMonorepoRoot = resolve(monorepoRoot);
|
|
364
|
+
const relativeToPackage = relative(
|
|
365
|
+
normalizedPackagePath,
|
|
366
|
+
normalizedTscPath
|
|
367
|
+
);
|
|
368
|
+
const relativeToMonorepo = relative(
|
|
369
|
+
normalizedMonorepoRoot,
|
|
370
|
+
normalizedTscPath
|
|
371
|
+
);
|
|
372
|
+
let source;
|
|
373
|
+
if (normalizedTscPath.startsWith(normalizedPackagePath)) {
|
|
374
|
+
source = `local (${relativeToPackage})`;
|
|
375
|
+
} else if (normalizedTscPath.startsWith(normalizedMonorepoRoot)) {
|
|
376
|
+
source = `monorepo root (${relativeToMonorepo})`;
|
|
377
|
+
} else {
|
|
378
|
+
source = `global (${tscExecutable})`;
|
|
379
|
+
}
|
|
380
|
+
logger.info(` Using tsc: ${source}`);
|
|
381
|
+
}
|
|
382
|
+
const result = await runTscCommand(pkg.path, {
|
|
383
|
+
incremental,
|
|
384
|
+
buildMode,
|
|
385
|
+
tscExecutable
|
|
386
|
+
});
|
|
291
387
|
const output = result.stdout + result.stderr;
|
|
292
388
|
const filteredOutput = filterOutputLines(output, pkg.path, monorepoRoot);
|
|
293
389
|
const totalCounts = countErrorsAndWarnings(output);
|
|
@@ -322,9 +418,28 @@ const runTscOnPackage = async (pkg, monorepoRoot, options = {}) => {
|
|
|
322
418
|
}
|
|
323
419
|
return tscResult;
|
|
324
420
|
} catch (error) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
421
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
422
|
+
if (errorMessage.includes("TypeScript not found") || errorMessage.includes("Executable not found")) {
|
|
423
|
+
if (verbose) {
|
|
424
|
+
logger.info(
|
|
425
|
+
`\u23ED\uFE0F Skipping ${pkg.name} (TypeScript not installed in this package)`
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
return {
|
|
429
|
+
package: pkg,
|
|
430
|
+
success: true,
|
|
431
|
+
skipped: true,
|
|
432
|
+
cached: false,
|
|
433
|
+
totalErrors: 0,
|
|
434
|
+
totalWarnings: 0,
|
|
435
|
+
filteredErrors: 0,
|
|
436
|
+
filteredWarnings: 0,
|
|
437
|
+
output: "",
|
|
438
|
+
filteredOutput: "",
|
|
439
|
+
executionTime: Date.now() - startTime
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
logger.error(`\u274C ${pkg.name}: Failed to run tsc - ${errorMessage}`);
|
|
328
443
|
return {
|
|
329
444
|
package: pkg,
|
|
330
445
|
success: false,
|
|
@@ -334,8 +449,8 @@ const runTscOnPackage = async (pkg, monorepoRoot, options = {}) => {
|
|
|
334
449
|
totalWarnings: 0,
|
|
335
450
|
filteredErrors: 1,
|
|
336
451
|
filteredWarnings: 0,
|
|
337
|
-
output:
|
|
338
|
-
filteredOutput:
|
|
452
|
+
output: errorMessage,
|
|
453
|
+
filteredOutput: errorMessage,
|
|
339
454
|
executionTime: Date.now() - startTime
|
|
340
455
|
};
|
|
341
456
|
}
|
|
@@ -465,7 +580,7 @@ const collectFailedPackageLogs = (summary) => {
|
|
|
465
580
|
logs.push(
|
|
466
581
|
` Errors: ${result.filteredErrors}, Warnings: ${result.filteredWarnings}`
|
|
467
582
|
);
|
|
468
|
-
logs.push(
|
|
583
|
+
logs.push(` ${"\u2500".repeat(30)}`);
|
|
469
584
|
if (result.filteredOutput.trim()) {
|
|
470
585
|
const lines = result.filteredOutput.trim().split("\n").map((line) => ` ${line}`);
|
|
471
586
|
logs.push(...lines);
|
package/dist/cmds/update/cmd.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getCurrentWorkingDirectory } from "@reliverse/
|
|
2
|
-
import
|
|
3
|
-
import { logger } from "@reliverse/
|
|
4
|
-
import
|
|
1
|
+
import { getCurrentWorkingDirectory } from "@reliverse/helpers";
|
|
2
|
+
import path from "@reliverse/pathkit";
|
|
3
|
+
import { logger } from "@reliverse/relinka";
|
|
4
|
+
import { defineArgs, defineCommand } from "@reliverse/rempts";
|
|
5
5
|
import { msgs } from "../const.js";
|
|
6
6
|
import {
|
|
7
7
|
checkPackageUpdatesForFile,
|
|
@@ -17,15 +17,15 @@ export default defineCommand({
|
|
|
17
17
|
description: "Update all dependencies to their latest versions across all package.json files. Supports selective updates with glob patterns and comprehensive filtering options.",
|
|
18
18
|
examples: [
|
|
19
19
|
"dler update",
|
|
20
|
-
"dler update --install",
|
|
20
|
+
"dler update --no-install",
|
|
21
21
|
"dler update --dryRun",
|
|
22
22
|
"dler update --name @types/* --name react*",
|
|
23
23
|
'dler update --ignore "eslint-*" --ignore "@babel/*"',
|
|
24
24
|
"dler update --no-allowMajor",
|
|
25
25
|
"dler update --details",
|
|
26
26
|
"dler update --ignoreFields peerDependencies",
|
|
27
|
-
"dler update --dryRun --install",
|
|
28
|
-
"dler update --name react --name react-dom
|
|
27
|
+
"dler update --dryRun --no-install",
|
|
28
|
+
"dler update --name react --name react-dom",
|
|
29
29
|
"dler update --ignore @types/* --allowMajor"
|
|
30
30
|
]
|
|
31
31
|
},
|
|
@@ -33,7 +33,7 @@ export default defineCommand({
|
|
|
33
33
|
ci: {
|
|
34
34
|
type: "boolean",
|
|
35
35
|
description: msgs.args.ci,
|
|
36
|
-
default: !process.stdout.isTTY || !!process.env
|
|
36
|
+
default: !process.stdout.isTTY || !!process.env.CI
|
|
37
37
|
},
|
|
38
38
|
cwd: {
|
|
39
39
|
type: "string",
|
|
@@ -54,7 +54,8 @@ export default defineCommand({
|
|
|
54
54
|
},
|
|
55
55
|
install: {
|
|
56
56
|
type: "boolean",
|
|
57
|
-
description: "Run install after updating",
|
|
57
|
+
description: "Run install after updating (default: true)",
|
|
58
|
+
default: true,
|
|
58
59
|
aliases: ["i"]
|
|
59
60
|
},
|
|
60
61
|
allowMajor: {
|
|
@@ -151,7 +152,7 @@ export default defineCommand({
|
|
|
151
152
|
await handleInstallation();
|
|
152
153
|
} else {
|
|
153
154
|
logger.log(
|
|
154
|
-
"Run 'bun install' to apply the changes (use --install to
|
|
155
|
+
"Run 'bun install' to apply the changes (use --no-install to skip automatic installation)"
|
|
155
156
|
);
|
|
156
157
|
}
|
|
157
158
|
} catch (error) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type UpdateResult } from "./utils.js";
|
|
1
|
+
import { type DependencyInfo, type UpdateResult } from "./utils.js";
|
|
2
2
|
interface UpdateArgs {
|
|
3
3
|
ci?: boolean;
|
|
4
4
|
cwd?: string;
|
|
@@ -13,9 +13,9 @@ interface UpdateArgs {
|
|
|
13
13
|
export declare function validatePackageJson(): Promise<string>;
|
|
14
14
|
export declare function prepareAllUpdateCandidates(): Promise<{
|
|
15
15
|
packageJsonFiles: string[];
|
|
16
|
-
fileDepsMap: Map<string, Record<string,
|
|
16
|
+
fileDepsMap: Map<string, Record<string, DependencyInfo>>;
|
|
17
17
|
}>;
|
|
18
|
-
export declare function checkPackageUpdatesForFile(fileDepsMap: Record<string,
|
|
19
|
-
export declare function updatePackageJsonFileDirectly(packageJsonPath: string, fileDepsMap: Record<string,
|
|
18
|
+
export declare function checkPackageUpdatesForFile(fileDepsMap: Record<string, DependencyInfo>, args: UpdateArgs): Promise<UpdateResult[]>;
|
|
19
|
+
export declare function updatePackageJsonFileDirectly(packageJsonPath: string, fileDepsMap: Record<string, DependencyInfo>, updatesToApply: UpdateResult[], savePrefix: string, fieldsToIgnore?: string[]): Promise<number>;
|
|
20
20
|
export declare function handleInstallation(): Promise<void>;
|
|
21
21
|
export {};
|
package/dist/cmds/update/impl.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import pMap from "@reliverse/mapkit";
|
|
2
|
+
import path from "@reliverse/pathkit";
|
|
3
|
+
import fs from "@reliverse/relifso";
|
|
4
|
+
import { logger } from "@reliverse/relinka";
|
|
3
5
|
import { Glob } from "bun";
|
|
4
|
-
import fs from "fs/promises";
|
|
5
|
-
import path from "path";
|
|
6
6
|
import {
|
|
7
7
|
applyVersionUpdate,
|
|
8
8
|
checkPackageUpdate,
|
|
@@ -12,9 +12,7 @@ import {
|
|
|
12
12
|
} from "./utils.js";
|
|
13
13
|
export async function validatePackageJson() {
|
|
14
14
|
const packageJsonPath = path.resolve(process.cwd(), "package.json");
|
|
15
|
-
|
|
16
|
-
await fs.access(packageJsonPath);
|
|
17
|
-
} catch {
|
|
15
|
+
if (!await fs.pathExists(packageJsonPath)) {
|
|
18
16
|
logger.error("No package.json found in current directory");
|
|
19
17
|
process.exit(1);
|
|
20
18
|
}
|
|
@@ -41,7 +39,7 @@ export async function prepareAllUpdateCandidates() {
|
|
|
41
39
|
for (const packageJsonPath of packageJsonFiles) {
|
|
42
40
|
try {
|
|
43
41
|
const packageJson = JSON.parse(
|
|
44
|
-
await fs.readFile(packageJsonPath, "utf8")
|
|
42
|
+
await fs.readFile(packageJsonPath, { encoding: "utf8" })
|
|
45
43
|
);
|
|
46
44
|
const { map } = collectTargetDependencies(packageJson);
|
|
47
45
|
fileDepsMap.set(packageJsonPath, map);
|
|
@@ -94,7 +92,7 @@ export async function updatePackageJsonFileDirectly(packageJsonPath, fileDepsMap
|
|
|
94
92
|
if (updatesToApply.length === 0) return 0;
|
|
95
93
|
try {
|
|
96
94
|
const packageJson = JSON.parse(
|
|
97
|
-
await fs.readFile(packageJsonPath, "utf8")
|
|
95
|
+
await fs.readFile(packageJsonPath, { encoding: "utf8" })
|
|
98
96
|
);
|
|
99
97
|
const updatedPackageJson = { ...packageJson };
|
|
100
98
|
for (const update of updatesToApply) {
|
|
@@ -129,8 +127,9 @@ export async function updatePackageJsonFileDirectly(packageJsonPath, fileDepsMap
|
|
|
129
127
|
}
|
|
130
128
|
await fs.writeFile(
|
|
131
129
|
packageJsonPath,
|
|
132
|
-
JSON.stringify(updatedPackageJson, null, 2)
|
|
133
|
-
|
|
130
|
+
`${JSON.stringify(updatedPackageJson, null, 2)}
|
|
131
|
+
`,
|
|
132
|
+
{ encoding: "utf8" }
|
|
134
133
|
);
|
|
135
134
|
return updatesToApply.length;
|
|
136
135
|
} catch (error) {
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
import type { PackageJson } from "@reliverse/typerso";
|
|
2
|
+
interface PackageJsonWithCatalogs extends PackageJson {
|
|
3
|
+
dependencies?: Record<string, string>;
|
|
4
|
+
devDependencies?: Record<string, string>;
|
|
5
|
+
peerDependencies?: Record<string, string>;
|
|
6
|
+
optionalDependencies?: Record<string, string>;
|
|
7
|
+
workspaces?: {
|
|
8
|
+
packages?: string[];
|
|
9
|
+
catalog?: Record<string, string>;
|
|
10
|
+
catalogs?: Record<string, Record<string, string>>;
|
|
11
|
+
};
|
|
12
|
+
catalog?: Record<string, string>;
|
|
13
|
+
catalogs?: Record<string, Record<string, string>>;
|
|
14
|
+
}
|
|
1
15
|
export interface UpdateResult {
|
|
2
16
|
package: string;
|
|
3
17
|
currentVersion: string;
|
|
@@ -35,13 +49,13 @@ export declare function isSemverCompatible(currentVersionRange: string, latestVe
|
|
|
35
49
|
* Collect ALL dependencies from package.json.
|
|
36
50
|
* Returns a map of dependency name to its version and all locations where it appears.
|
|
37
51
|
*/
|
|
38
|
-
export declare function collectTargetDependencies(pkg:
|
|
52
|
+
export declare function collectTargetDependencies(pkg: PackageJsonWithCatalogs): {
|
|
39
53
|
map: Record<string, DependencyInfo>;
|
|
40
54
|
};
|
|
41
55
|
/**
|
|
42
56
|
* Apply a version update into all relevant places in package.json for a dependency.
|
|
43
57
|
*/
|
|
44
|
-
export declare function applyVersionUpdate(pkg:
|
|
58
|
+
export declare function applyVersionUpdate(pkg: PackageJsonWithCatalogs, depName: string, newVersion: string, locations: Set<string>): void;
|
|
45
59
|
/**
|
|
46
60
|
* Fallback function to fetch package version directly from npm registry
|
|
47
61
|
*/
|
|
@@ -63,7 +77,11 @@ export declare function checkPackageUpdate(packageName: string, versionSpec: str
|
|
|
63
77
|
/**
|
|
64
78
|
* Filter and prepare dependencies for updating with glob pattern support
|
|
65
79
|
*/
|
|
66
|
-
export declare function prepareDependenciesForUpdate(allDepsMap: Record<string, DependencyInfo>, args:
|
|
80
|
+
export declare function prepareDependenciesForUpdate(allDepsMap: Record<string, DependencyInfo>, args: {
|
|
81
|
+
name?: string[];
|
|
82
|
+
ignore?: string[];
|
|
83
|
+
ignoreFields?: string[];
|
|
84
|
+
}): string[];
|
|
67
85
|
/**
|
|
68
86
|
* Update a single package.json file with new dependency versions
|
|
69
87
|
*/
|
|
@@ -71,8 +89,9 @@ export declare function updatePackageJsonFile(packageJsonPath: string, dependenc
|
|
|
71
89
|
/**
|
|
72
90
|
* Display update results in a structured, file-by-file format
|
|
73
91
|
*/
|
|
74
|
-
export declare function displayStructuredUpdateResults(results: UpdateResult[], packageJsonFiles: string[], fileDepsMap: Map<string, Record<string,
|
|
92
|
+
export declare function displayStructuredUpdateResults(results: UpdateResult[], packageJsonFiles: string[], fileDepsMap: Map<string, Record<string, DependencyInfo>>, showDetails?: boolean): void;
|
|
75
93
|
/**
|
|
76
94
|
* Run Bun install command
|
|
77
95
|
*/
|
|
78
96
|
export declare function runInstallCommand(): Promise<void>;
|
|
97
|
+
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import zeptomatch from "@reliverse/matcha";
|
|
2
|
+
import path from "@reliverse/pathkit";
|
|
3
|
+
import fs from "@reliverse/relifso";
|
|
4
|
+
import { logger } from "@reliverse/relinka";
|
|
3
5
|
import { $ } from "bun";
|
|
4
|
-
import fs from "fs/promises";
|
|
5
|
-
import path from "path";
|
|
6
6
|
import semver from "semver";
|
|
7
7
|
export function isNpmAlias(versionSpec) {
|
|
8
8
|
return versionSpec.startsWith("npm:");
|
|
@@ -128,8 +128,11 @@ export function applyVersionUpdate(pkg, depName, newVersion, locations) {
|
|
|
128
128
|
};
|
|
129
129
|
if (locations.has("catalog")) {
|
|
130
130
|
ensureWorkspaces();
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
const workspaces = pkg.workspaces;
|
|
132
|
+
if (workspaces) {
|
|
133
|
+
if (!workspaces.catalog) workspaces.catalog = {};
|
|
134
|
+
workspaces.catalog[depName] = newVersion;
|
|
135
|
+
}
|
|
133
136
|
if (pkg.catalog) pkg.catalog[depName] = newVersion;
|
|
134
137
|
}
|
|
135
138
|
for (const loc of locations) {
|
|
@@ -138,12 +141,14 @@ export function applyVersionUpdate(pkg, depName, newVersion, locations) {
|
|
|
138
141
|
const catalogName = match[1] ?? "";
|
|
139
142
|
if (!catalogName) continue;
|
|
140
143
|
ensureWorkspaces();
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
const workspaces = pkg.workspaces;
|
|
145
|
+
if (workspaces) {
|
|
146
|
+
if (!workspaces.catalogs) workspaces.catalogs = {};
|
|
147
|
+
if (!workspaces.catalogs[catalogName])
|
|
148
|
+
workspaces.catalogs[catalogName] = {};
|
|
149
|
+
workspaces.catalogs[catalogName][depName] = newVersion;
|
|
150
|
+
}
|
|
151
|
+
if (pkg.catalogs?.[catalogName]) {
|
|
147
152
|
pkg.catalogs[catalogName][depName] = newVersion;
|
|
148
153
|
}
|
|
149
154
|
}
|
|
@@ -267,7 +272,7 @@ export async function updatePackageJsonFile(packageJsonPath, dependencies, updat
|
|
|
267
272
|
if (updatesToApply.length === 0) return 0;
|
|
268
273
|
try {
|
|
269
274
|
const packageJson = JSON.parse(
|
|
270
|
-
await fs.readFile(packageJsonPath, "utf8")
|
|
275
|
+
await fs.readFile(packageJsonPath, { encoding: "utf8" })
|
|
271
276
|
);
|
|
272
277
|
const updatedPackageJson = { ...packageJson };
|
|
273
278
|
for (const update of updatesToApply) {
|
|
@@ -300,8 +305,9 @@ export async function updatePackageJsonFile(packageJsonPath, dependencies, updat
|
|
|
300
305
|
}
|
|
301
306
|
await fs.writeFile(
|
|
302
307
|
packageJsonPath,
|
|
303
|
-
JSON.stringify(updatedPackageJson, null, 2)
|
|
304
|
-
|
|
308
|
+
`${JSON.stringify(updatedPackageJson, null, 2)}
|
|
309
|
+
`,
|
|
310
|
+
{ encoding: "utf8" }
|
|
305
311
|
);
|
|
306
312
|
return updatesToApply.length;
|
|
307
313
|
} catch (error) {
|
|
@@ -360,7 +366,7 @@ export function displayStructuredUpdateResults(results, packageJsonFiles, fileDe
|
|
|
360
366
|
if (!byCategory.has(category)) {
|
|
361
367
|
byCategory.set(category, []);
|
|
362
368
|
}
|
|
363
|
-
byCategory.get(category)
|
|
369
|
+
byCategory.get(category)?.push(result);
|
|
364
370
|
}
|
|
365
371
|
const upToDateInFile = fileResults.filter(
|
|
366
372
|
(r) => !r.updated && !r.error && r.semverCompatible
|