@reliverse/dler 2.2.17 → 2.3.1
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 +190 -55
- package/dist/cli.js +5 -2
- package/dist/cmds/biome/cmd.d.ts +5 -1
- package/dist/cmds/biome/cmd.js +20 -29
- package/dist/cmds/biome/impl.js +26 -21
- package/dist/cmds/build/cmd.d.ts +91 -1
- package/dist/cmds/build/cmd.js +289 -580
- package/dist/cmds/clean/cmd.d.ts +14 -1
- package/dist/cmds/clean/cmd.js +61 -112
- package/dist/cmds/clean/impl.js +61 -76
- package/dist/cmds/clean/presets.js +2 -9
- package/dist/cmds/init/cmd.d.ts +9 -0
- package/dist/cmds/init/cmd.js +87 -0
- package/dist/cmds/publish/cmd.d.ts +32 -1
- package/dist/cmds/publish/cmd.js +125 -165
- package/dist/cmds/senv/cmd.d.ts +7 -1
- package/dist/cmds/senv/cmd.js +41 -80
- package/dist/cmds/test/cmd.d.ts +9 -0
- package/dist/cmds/test/cmd.js +157 -0
- package/dist/cmds/tsc/cache.d.ts +2 -2
- package/dist/cmds/tsc/cache.js +37 -19
- package/dist/cmds/tsc/cmd.d.ts +14 -1
- package/dist/cmds/tsc/cmd.js +44 -80
- package/dist/cmds/tsc/impl.js +42 -92
- package/dist/cmds/update/cmd.d.ts +11 -1
- package/dist/cmds/update/cmd.js +57 -81
- package/dist/cmds/update/impl.js +16 -30
- package/dist/cmds/update/utils.js +116 -82
- package/dist/mod.d.ts +3 -0
- package/dist/mod.js +6 -0
- package/dist/utils/find-entry.d.ts +1 -0
- package/dist/utils/find-entry.js +46 -0
- package/package.json +53 -30
- package/src/cli.ts +9 -0
- package/LICENSE +0 -21
- /package/dist/{cmds/const.d.ts → const.d.ts} +0 -0
- /package/dist/{cmds/const.js → const.js} +0 -0
package/dist/cmds/clean/cmd.d.ts
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("@reliverse/rempts-core").Command<{
|
|
2
|
+
filter: import("@reliverse/rempts-core").CLIOption<import("arktype").BaseType<string | undefined, {}>>;
|
|
3
|
+
ignore: import("@reliverse/rempts-core").CLIOption<import("arktype").BaseType<string | undefined, {}>>;
|
|
4
|
+
presets: import("@reliverse/rempts-core").CLIOption<import("arktype").BaseType<string | undefined, {}>>;
|
|
5
|
+
custom: import("@reliverse/rempts-core").CLIOption<import("arktype").BaseType<string | undefined, {}>>;
|
|
6
|
+
cwd: import("@reliverse/rempts-core").CLIOption<import("arktype").BaseType<string | undefined, {}>>;
|
|
7
|
+
subdirs: import("@reliverse/rempts-core").CLIOption<import("arktype").BaseType<boolean | undefined, {}>>;
|
|
8
|
+
dryRun: import("@reliverse/rempts-core").CLIOption<import("arktype").BaseType<boolean | undefined, {}>>;
|
|
9
|
+
force: import("@reliverse/rempts-core").CLIOption<import("arktype").BaseType<boolean | undefined, {}>>;
|
|
10
|
+
verbose: import("@reliverse/rempts-core").CLIOption<import("arktype").BaseType<boolean | undefined, {}>>;
|
|
11
|
+
deleteLockFiles: import("@reliverse/rempts-core").CLIOption<import("arktype").BaseType<boolean | undefined, {}>>;
|
|
12
|
+
replaceExports: import("@reliverse/rempts-core").CLIOption<import("arktype").BaseType<boolean | undefined, {}>>;
|
|
13
|
+
replaceExportsIgnorePackages: import("@reliverse/rempts-core").CLIOption<import("arktype").BaseType<string | undefined, {}>>;
|
|
14
|
+
}, {}, string>;
|
|
2
15
|
export default _default;
|
package/dist/cmds/clean/cmd.js
CHANGED
|
@@ -1,144 +1,93 @@
|
|
|
1
1
|
import { replaceExportsInPackages } from "@reliverse/helpers";
|
|
2
2
|
import { logger } from "@reliverse/relinka";
|
|
3
|
-
import {
|
|
3
|
+
import { defineCommand, option } from "@reliverse/rempts-core";
|
|
4
|
+
import { type } from "arktype";
|
|
4
5
|
import { runCleanOnAllPackages } from "./impl.js";
|
|
6
|
+
const _CleanPreset = type(
|
|
7
|
+
"'build' | 'db' | 'cms' | 'frontend' | 'docs' | 'email' | 'build-tools' | 'deps' | 'all'"
|
|
8
|
+
);
|
|
5
9
|
export default defineCommand({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"dler clean --presets build --custom '*.tmp'",
|
|
13
|
-
"dler clean --presets all --force",
|
|
14
|
-
"dler clean --presets db,frontend --dry-run",
|
|
15
|
-
"dler clean --presets deps --deleteLockFiles",
|
|
16
|
-
"dler clean --subdirs --presets build-tools",
|
|
17
|
-
'dler clean --filter "@reliverse/rempts,@reliverse/build"',
|
|
18
|
-
'dler clean --filter "@reliverse/dler-*"',
|
|
19
|
-
"dler clean --filter cli,packages/build",
|
|
20
|
-
"dler clean --ignore '@reliverse/*'",
|
|
21
|
-
"dler clean --presets frontend --verbose",
|
|
22
|
-
"dler clean --presets all --dry-run --verbose",
|
|
23
|
-
"",
|
|
24
|
-
"# Preset Examples:",
|
|
25
|
-
"dler clean --presets build # Clean dist/, dev-dist/, target/",
|
|
26
|
-
"dler clean --presets db # Clean _generated/",
|
|
27
|
-
"dler clean --presets cms # Clean .basehub/",
|
|
28
|
-
"dler clean --presets frontend # Clean .next/, .expo/, routeTree.gen.ts",
|
|
29
|
-
"dler clean --presets docs # Clean .source/",
|
|
30
|
-
"dler clean --presets email # Clean .react-email/",
|
|
31
|
-
"dler clean --presets build-tools # Clean .turbo/, .vercel/, .wrangler/",
|
|
32
|
-
"dler clean --presets deps # Clean node_modules/",
|
|
33
|
-
"dler clean --presets all # Clean everything",
|
|
34
|
-
"",
|
|
35
|
-
"# Custom Pattern Examples:",
|
|
36
|
-
"dler clean --custom 'dist/,*.log' # Clean dist/ and log files",
|
|
37
|
-
"dler clean --custom '*.tmp,*.cache' # Clean temporary and cache files",
|
|
38
|
-
"dler clean --custom 'build/,coverage/' # Clean build and coverage directories",
|
|
39
|
-
"dler clean --presets build --custom '*.log' # Combine presets and custom patterns",
|
|
40
|
-
"",
|
|
41
|
-
"# Filter Examples:",
|
|
42
|
-
'dler clean --filter "@reliverse/dler-*" --presets build # Clean build artifacts in matching packages',
|
|
43
|
-
"dler clean --filter cli,packages/build --presets all # Clean all artifacts in specific packages",
|
|
44
|
-
'dler clean --filter "@reliverse/rempts" --custom "*.log" # Clean log files in specific package',
|
|
45
|
-
"",
|
|
46
|
-
"# Monorepo Examples:",
|
|
47
|
-
"dler clean # Clean dist/ in all packages",
|
|
48
|
-
"dler clean --presets frontend # Clean frontend artifacts in all packages",
|
|
49
|
-
"dler clean --ignore '@reliverse/*' # Skip packages matching pattern",
|
|
50
|
-
"dler clean --presets all --force # Clean everything without confirmation",
|
|
51
|
-
"",
|
|
52
|
-
"# Single-repo Examples:",
|
|
53
|
-
"dler clean --subdirs # Search recursively in subdirectories",
|
|
54
|
-
"dler clean --subdirs --presets all # Clean everything recursively",
|
|
55
|
-
"",
|
|
56
|
-
"# Safety Examples:",
|
|
57
|
-
"dler clean --dry-run # Preview what would be deleted",
|
|
58
|
-
"dler clean --presets deps --dry-run # Preview dependency cleanup",
|
|
59
|
-
"dler clean --verbose # Show detailed progress",
|
|
60
|
-
"",
|
|
61
|
-
"# Advanced Examples:",
|
|
62
|
-
"dler clean --presets deps --deleteLockFiles # Include lock files",
|
|
63
|
-
"dler clean --presets all --force --verbose # Clean everything with details",
|
|
64
|
-
"dler clean --cwd /path/to/project --presets build"
|
|
65
|
-
]
|
|
66
|
-
},
|
|
67
|
-
args: defineArgs({
|
|
68
|
-
filter: {
|
|
69
|
-
type: "string",
|
|
70
|
-
description: "Package(s) to include (supports wildcards and comma-separated values like '@reliverse/rempts,@reliverse/build'). Takes precedence over --ignore when both are provided."
|
|
71
|
-
},
|
|
72
|
-
ignore: {
|
|
73
|
-
type: "string",
|
|
10
|
+
description: "Clean build artifacts and generated files from workspace packages. Supports presets for different types of files. Works in both monorepo and single-repo modes.",
|
|
11
|
+
options: {
|
|
12
|
+
filter: option(type("string | undefined"), {
|
|
13
|
+
description: "Package(s) to include (supports wildcards and comma-separated values like 'rempts,@reliverse/build'). Takes precedence over --ignore when both are provided."
|
|
14
|
+
}),
|
|
15
|
+
ignore: option(type("string | undefined"), {
|
|
74
16
|
description: "Package(s) to ignore (supports wildcards like @reliverse/*)"
|
|
75
|
-
},
|
|
76
|
-
presets: {
|
|
77
|
-
type: "string",
|
|
17
|
+
}),
|
|
18
|
+
presets: option(type("string | undefined"), {
|
|
78
19
|
description: "Comma-separated presets to clean: build,db,cms,frontend,docs,email,build-tools,deps,all"
|
|
79
|
-
},
|
|
80
|
-
custom: {
|
|
81
|
-
type: "string",
|
|
20
|
+
}),
|
|
21
|
+
custom: option(type("string | undefined"), {
|
|
82
22
|
description: "Comma-separated custom patterns to clean (e.g., 'dist/,*.log,node_modules/')"
|
|
83
|
-
},
|
|
84
|
-
cwd: {
|
|
85
|
-
type: "string",
|
|
23
|
+
}),
|
|
24
|
+
cwd: option(type("string | undefined"), {
|
|
86
25
|
description: "Working directory (monorepo root)"
|
|
87
|
-
},
|
|
88
|
-
subdirs: {
|
|
89
|
-
type: "boolean",
|
|
26
|
+
}),
|
|
27
|
+
subdirs: option(type("boolean | undefined"), {
|
|
90
28
|
description: "Search recursively in subdirectories (single-repo mode only)"
|
|
91
|
-
},
|
|
92
|
-
dryRun: {
|
|
93
|
-
type: "boolean",
|
|
29
|
+
}),
|
|
30
|
+
dryRun: option(type("boolean | undefined"), {
|
|
94
31
|
description: "Preview what would be deleted without actually deleting"
|
|
95
|
-
},
|
|
96
|
-
force: {
|
|
97
|
-
type: "boolean",
|
|
32
|
+
}),
|
|
33
|
+
force: option(type("boolean | undefined"), {
|
|
98
34
|
description: "Required flag to proceed with deletion (no prompts, args-only)"
|
|
99
|
-
},
|
|
100
|
-
verbose: {
|
|
101
|
-
type: "boolean",
|
|
35
|
+
}),
|
|
36
|
+
verbose: option(type("boolean | undefined"), {
|
|
102
37
|
description: "Verbose mode with detailed logging"
|
|
103
|
-
},
|
|
104
|
-
deleteLockFiles: {
|
|
105
|
-
type: "boolean",
|
|
38
|
+
}),
|
|
39
|
+
deleteLockFiles: option(type("boolean | undefined"), {
|
|
106
40
|
description: "Include lock files (bun.lock, package-lock.json, etc.) when using deps preset"
|
|
107
|
-
},
|
|
108
|
-
replaceExports: {
|
|
109
|
-
type: "boolean",
|
|
41
|
+
}),
|
|
42
|
+
replaceExports: option(type("boolean | undefined"), {
|
|
110
43
|
description: "Replace exports from ./src/*.ts to ./dist/*.js before cleaning (default: true)"
|
|
111
|
-
},
|
|
112
|
-
replaceExportsIgnorePackages: {
|
|
113
|
-
type: "string",
|
|
44
|
+
}),
|
|
45
|
+
replaceExportsIgnorePackages: option(type("string | undefined"), {
|
|
114
46
|
description: "Packages to ignore when replacing exports (supports glob patterns like @reliverse/*)"
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
47
|
+
})
|
|
48
|
+
},
|
|
49
|
+
handler: async ({ flags }) => {
|
|
118
50
|
try {
|
|
119
51
|
if (typeof process.versions.bun === "undefined") {
|
|
120
52
|
logger.error("\u274C This command requires Bun runtime. Sorry.");
|
|
121
53
|
process.exit(1);
|
|
122
54
|
}
|
|
123
|
-
const
|
|
55
|
+
const subdirs = flags.subdirs ?? false;
|
|
56
|
+
const dryRun = flags.dryRun ?? false;
|
|
57
|
+
const force = flags.force ?? false;
|
|
58
|
+
const verbose = flags.verbose ?? false;
|
|
59
|
+
const deleteLockFiles = flags.deleteLockFiles ?? false;
|
|
60
|
+
const replaceExports = flags.replaceExports ?? true;
|
|
61
|
+
const shouldReplaceExports = replaceExports !== false;
|
|
124
62
|
if (shouldReplaceExports) {
|
|
125
|
-
if (
|
|
126
|
-
logger.info(
|
|
127
|
-
"\u{1F4DD} Replacing exports from ./dist/*.js to ./src/*.ts before cleaning..."
|
|
128
|
-
);
|
|
63
|
+
if (verbose) {
|
|
64
|
+
logger.info("\u{1F4DD} Replacing exports from ./dist/*.js to ./src/*.ts before cleaning...");
|
|
129
65
|
}
|
|
130
66
|
await replaceExportsInPackages({
|
|
131
67
|
direction: "js-to-ts",
|
|
132
|
-
cwd:
|
|
133
|
-
ignorePackages:
|
|
134
|
-
verbose
|
|
68
|
+
cwd: flags.cwd || process.cwd(),
|
|
69
|
+
ignorePackages: flags.replaceExportsIgnorePackages || [],
|
|
70
|
+
verbose
|
|
135
71
|
});
|
|
136
72
|
}
|
|
137
|
-
const results = await runCleanOnAllPackages(
|
|
73
|
+
const results = await runCleanOnAllPackages(flags.ignore || "", flags.cwd || process.cwd(), {
|
|
74
|
+
presets: flags.presets || "",
|
|
75
|
+
custom: flags.custom || "",
|
|
76
|
+
filter: flags.filter || "",
|
|
77
|
+
ignore: flags.ignore || "",
|
|
78
|
+
cwd: flags.cwd || process.cwd(),
|
|
79
|
+
replaceExportsIgnorePackages: flags.replaceExportsIgnorePackages || "",
|
|
80
|
+
subdirs,
|
|
81
|
+
dryRun,
|
|
82
|
+
force,
|
|
83
|
+
verbose,
|
|
84
|
+
deleteLockFiles,
|
|
85
|
+
replaceExports
|
|
86
|
+
});
|
|
138
87
|
if (results.hasErrors) {
|
|
139
88
|
process.exit(1);
|
|
140
89
|
}
|
|
141
|
-
if (
|
|
90
|
+
if (flags.dryRun) {
|
|
142
91
|
logger.success("\n\u2705 Clean preview completed!");
|
|
143
92
|
} else {
|
|
144
93
|
logger.success("\n\u2705 Clean completed successfully!");
|
package/dist/cmds/clean/impl.js
CHANGED
|
@@ -3,11 +3,7 @@ import { join, resolve } from "node:path";
|
|
|
3
3
|
import pMap from "@reliverse/mapkit";
|
|
4
4
|
import { createIgnoreFilter, normalizePatterns } from "@reliverse/matcha";
|
|
5
5
|
import { logger } from "@reliverse/relinka";
|
|
6
|
-
import {
|
|
7
|
-
getWorkspacePatterns,
|
|
8
|
-
hasWorkspaces,
|
|
9
|
-
readPackageJSON
|
|
10
|
-
} from "@reliverse/typerso";
|
|
6
|
+
import { getWorkspacePatterns, hasWorkspaces, readPackageJSON } from "@reliverse/typerso";
|
|
11
7
|
import {
|
|
12
8
|
LOCK_FILE_PATTERNS,
|
|
13
9
|
mergePatterns,
|
|
@@ -37,7 +33,9 @@ const findMonorepoRoot = async (startDir, useCwd = false) => {
|
|
|
37
33
|
}
|
|
38
34
|
}
|
|
39
35
|
const parentDir = resolve(currentDir, "..");
|
|
40
|
-
if (parentDir === currentDir)
|
|
36
|
+
if (parentDir === currentDir) {
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
41
39
|
currentDir = parentDir;
|
|
42
40
|
}
|
|
43
41
|
return null;
|
|
@@ -90,7 +88,9 @@ const getWorkspacePackages = async (cwd, useCwd = false) => {
|
|
|
90
88
|
const matches = glob.scanSync({ cwd: monorepoRoot, onlyFiles: false });
|
|
91
89
|
for (const match of matches) {
|
|
92
90
|
const packagePath = resolve(monorepoRoot, match);
|
|
93
|
-
if (seenPaths.has(packagePath))
|
|
91
|
+
if (seenPaths.has(packagePath)) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
94
|
seenPaths.add(packagePath);
|
|
95
95
|
const pkgInfo = await resolvePackageInfo(packagePath, false);
|
|
96
96
|
if (pkgInfo) {
|
|
@@ -99,7 +99,9 @@ const getWorkspacePackages = async (cwd, useCwd = false) => {
|
|
|
99
99
|
}
|
|
100
100
|
} else {
|
|
101
101
|
const packagePath = resolve(monorepoRoot, pattern);
|
|
102
|
-
if (seenPaths.has(packagePath))
|
|
102
|
+
if (seenPaths.has(packagePath)) {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
103
105
|
seenPaths.add(packagePath);
|
|
104
106
|
const pkgInfo = await resolvePackageInfo(packagePath, false);
|
|
105
107
|
if (pkgInfo) {
|
|
@@ -131,9 +133,7 @@ const calculateSize = (path) => {
|
|
|
131
133
|
const calculateDirectorySize = (dirPath) => {
|
|
132
134
|
try {
|
|
133
135
|
let totalSize = 0;
|
|
134
|
-
const entries = existsSync(dirPath) && statSync(dirPath).isDirectory() ? Array.from(
|
|
135
|
-
new Bun.Glob("**/*").scanSync({ cwd: dirPath, onlyFiles: true })
|
|
136
|
-
) : [];
|
|
136
|
+
const entries = existsSync(dirPath) && statSync(dirPath).isDirectory() ? Array.from(new Bun.Glob("**/*").scanSync({ cwd: dirPath, onlyFiles: true })) : [];
|
|
137
137
|
for (const entry of entries) {
|
|
138
138
|
try {
|
|
139
139
|
const fullPath = join(dirPath, entry);
|
|
@@ -197,15 +197,30 @@ const findMatchingFiles = (targetDir, patterns, subdirs = false) => {
|
|
|
197
197
|
return matches;
|
|
198
198
|
};
|
|
199
199
|
const getCategoryForPattern = (pattern) => {
|
|
200
|
-
if (pattern.includes("dist"))
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
if (pattern.includes("
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
if (pattern.includes(".
|
|
200
|
+
if (pattern.includes("dist")) {
|
|
201
|
+
return "build";
|
|
202
|
+
}
|
|
203
|
+
if (pattern.includes("_generated")) {
|
|
204
|
+
return "db";
|
|
205
|
+
}
|
|
206
|
+
if (pattern.includes(".basehub")) {
|
|
207
|
+
return "cms";
|
|
208
|
+
}
|
|
209
|
+
if (pattern.includes(".next") || pattern.includes(".expo")) {
|
|
210
|
+
return "frontend";
|
|
211
|
+
}
|
|
212
|
+
if (pattern.includes(".source")) {
|
|
213
|
+
return "docs";
|
|
214
|
+
}
|
|
215
|
+
if (pattern.includes(".react-email")) {
|
|
216
|
+
return "email";
|
|
217
|
+
}
|
|
218
|
+
if (pattern.includes(".turbo") || pattern.includes(".vercel") || pattern.includes(".wrangler")) {
|
|
207
219
|
return "build-tools";
|
|
208
|
-
|
|
220
|
+
}
|
|
221
|
+
if (pattern.includes("node_modules")) {
|
|
222
|
+
return "deps";
|
|
223
|
+
}
|
|
209
224
|
return "other";
|
|
210
225
|
};
|
|
211
226
|
const deleteFile = (filePath) => {
|
|
@@ -267,15 +282,10 @@ const cleanPackage = async (pkg, patterns, options) => {
|
|
|
267
282
|
if (verbose && files.length > 0) {
|
|
268
283
|
logger.info(` Found ${files.length} files/directories to clean`);
|
|
269
284
|
}
|
|
270
|
-
const { deletedCount, deletedSize, errors } = await deleteFiles(
|
|
271
|
-
files,
|
|
272
|
-
dryRun
|
|
273
|
-
);
|
|
285
|
+
const { deletedCount, deletedSize, errors } = await deleteFiles(files, dryRun);
|
|
274
286
|
if (verbose) {
|
|
275
287
|
const status = errors.length === 0 ? "\u2705" : "\u26A0\uFE0F";
|
|
276
|
-
logger.log(
|
|
277
|
-
`${status} ${pkg.name}: ${deletedCount} deleted, ${errors.length} errors`
|
|
278
|
-
);
|
|
288
|
+
logger.log(`${status} ${pkg.name}: ${deletedCount} deleted, ${errors.length} errors`);
|
|
279
289
|
}
|
|
280
290
|
return {
|
|
281
291
|
package: pkg,
|
|
@@ -305,11 +315,13 @@ const cleanLockFiles = async (rootDir, deleteLockFiles, dryRun = false) => {
|
|
|
305
315
|
return deleteFiles(lockFiles, dryRun);
|
|
306
316
|
};
|
|
307
317
|
const formatBytes = (bytes) => {
|
|
308
|
-
if (bytes === 0)
|
|
318
|
+
if (bytes === 0) {
|
|
319
|
+
return "0 B";
|
|
320
|
+
}
|
|
309
321
|
const k = 1024;
|
|
310
322
|
const sizes = ["B", "KB", "MB", "GB"];
|
|
311
323
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
312
|
-
return `${parseFloat((bytes / k ** i).toFixed(1))} ${sizes[i]}`;
|
|
324
|
+
return `${Number.parseFloat((bytes / k ** i).toFixed(1))} ${sizes[i]}`;
|
|
313
325
|
};
|
|
314
326
|
const displayPreview = (results, lockFilesResult) => {
|
|
315
327
|
logger.log("\u2501".repeat(60));
|
|
@@ -318,14 +330,16 @@ const displayPreview = (results, lockFilesResult) => {
|
|
|
318
330
|
let totalFiles = 0;
|
|
319
331
|
let totalSize = 0;
|
|
320
332
|
for (const result of results) {
|
|
321
|
-
if (result.files.length === 0)
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
333
|
+
if (result.files.length === 0) {
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
logger.log(`
|
|
337
|
+
\u{1F4E6} ${result.package.name}${result.package.isRoot ? " (root)" : ""}:`);
|
|
326
338
|
const byCategory = result.files.reduce(
|
|
327
339
|
(acc, file) => {
|
|
328
|
-
if (!acc[file.category])
|
|
340
|
+
if (!acc[file.category]) {
|
|
341
|
+
acc[file.category] = [];
|
|
342
|
+
}
|
|
329
343
|
acc[file.category]?.push(file);
|
|
330
344
|
return acc;
|
|
331
345
|
},
|
|
@@ -333,9 +347,7 @@ const displayPreview = (results, lockFilesResult) => {
|
|
|
333
347
|
);
|
|
334
348
|
for (const [category, files] of Object.entries(byCategory)) {
|
|
335
349
|
const categorySize = files.reduce((sum, file) => sum + file.size, 0);
|
|
336
|
-
logger.log(
|
|
337
|
-
` ${category}: ${files.length} files (${formatBytes(categorySize)})`
|
|
338
|
-
);
|
|
350
|
+
logger.log(` ${category}: ${files.length} files (${formatBytes(categorySize)})`);
|
|
339
351
|
if (files.length <= 5) {
|
|
340
352
|
for (const file of files) {
|
|
341
353
|
const relativePath = file.path.replace(`${result.package.path}/`, "");
|
|
@@ -362,9 +374,7 @@ const displayPreview = (results, lockFilesResult) => {
|
|
|
362
374
|
};
|
|
363
375
|
const checkForceFlag = (force) => {
|
|
364
376
|
if (!force) {
|
|
365
|
-
throw new Error(
|
|
366
|
-
"\u274C Deletion requires --force flag. Use --force to proceed with deletion."
|
|
367
|
-
);
|
|
377
|
+
throw new Error("\u274C Deletion requires --force flag. Use --force to proceed with deletion.");
|
|
368
378
|
}
|
|
369
379
|
};
|
|
370
380
|
export const runCleanOnAllPackages = async (ignore, cwd, options = {}) => {
|
|
@@ -380,16 +390,14 @@ export const runCleanOnAllPackages = async (ignore, cwd, options = {}) => {
|
|
|
380
390
|
const customPatterns = parseCustomPatterns(customString);
|
|
381
391
|
validatePatterns(presets, customPatterns);
|
|
382
392
|
const patterns = mergePatterns(presets, customPatterns);
|
|
383
|
-
const hasAbsolutePaths = customPatterns.some(
|
|
384
|
-
(pattern) => isAbsolutePath(pattern)
|
|
385
|
-
);
|
|
393
|
+
const hasAbsolutePaths = customPatterns.some((pattern) => isAbsolutePath(pattern));
|
|
386
394
|
if (verbose) {
|
|
387
395
|
logger.info("\u{1F50D} Discovering files to clean...");
|
|
388
396
|
}
|
|
389
397
|
const result = await (async () => {
|
|
390
398
|
if (hasAbsolutePaths && presets.length === 0 && customPatterns.every((pattern) => isAbsolutePath(pattern))) {
|
|
391
399
|
if (verbose) {
|
|
392
|
-
logger.info(
|
|
400
|
+
logger.info(" Processing absolute paths directly");
|
|
393
401
|
}
|
|
394
402
|
const files = [];
|
|
395
403
|
for (const pattern of patterns) {
|
|
@@ -418,10 +426,7 @@ export const runCleanOnAllPackages = async (ignore, cwd, options = {}) => {
|
|
|
418
426
|
);
|
|
419
427
|
if (!dryRun) {
|
|
420
428
|
checkForceFlag(force);
|
|
421
|
-
const { deletedCount, deletedSize: deletedSize2, errors } = await deleteFiles(
|
|
422
|
-
files,
|
|
423
|
-
dryRun
|
|
424
|
-
);
|
|
429
|
+
const { deletedCount, deletedSize: deletedSize2, errors } = await deleteFiles(files, dryRun);
|
|
425
430
|
const summary2 = {
|
|
426
431
|
totalPackages: 1,
|
|
427
432
|
processedPackages: 1,
|
|
@@ -444,9 +449,7 @@ export const runCleanOnAllPackages = async (ignore, cwd, options = {}) => {
|
|
|
444
449
|
logger.log(`
|
|
445
450
|
${"\u2501".repeat(60)}`);
|
|
446
451
|
logger.log("\u{1F4CA} Clean Summary:");
|
|
447
|
-
logger.log(
|
|
448
|
-
` Files ${dryRun ? "would be" : ""} deleted: ${summary2.deletedFiles}`
|
|
449
|
-
);
|
|
452
|
+
logger.log(` Files ${dryRun ? "would be" : ""} deleted: ${summary2.deletedFiles}`);
|
|
450
453
|
logger.log(
|
|
451
454
|
` Size ${dryRun ? "would be" : ""} freed: ${formatBytes(summary2.deletedSize)}`
|
|
452
455
|
);
|
|
@@ -484,9 +487,7 @@ ${"\u2501".repeat(60)}`);
|
|
|
484
487
|
${"\u2501".repeat(60)}`);
|
|
485
488
|
logger.log("\u{1F4CA} Clean Summary:");
|
|
486
489
|
logger.log(` Files would be deleted: ${summary2.deletedFiles}`);
|
|
487
|
-
logger.log(
|
|
488
|
-
` Size would be freed: ${formatBytes(summary2.deletedSize)}`
|
|
489
|
-
);
|
|
490
|
+
logger.log(` Size would be freed: ${formatBytes(summary2.deletedSize)}`);
|
|
490
491
|
logger.log("\u2501".repeat(60));
|
|
491
492
|
return summary2;
|
|
492
493
|
}
|
|
@@ -512,9 +513,7 @@ ${"\u2501".repeat(60)}`);
|
|
|
512
513
|
const ignoredCount = packages.length - filteredPackages.length;
|
|
513
514
|
if (ignoredCount > 0) {
|
|
514
515
|
const patterns2 = normalizePatterns(ignore);
|
|
515
|
-
logger.info(
|
|
516
|
-
` Ignoring ${ignoredCount} packages matching: ${patterns2.join(", ")}`
|
|
517
|
-
);
|
|
516
|
+
logger.info(` Ignoring ${ignoredCount} packages matching: ${patterns2.join(", ")}`);
|
|
518
517
|
}
|
|
519
518
|
packages = filteredPackages;
|
|
520
519
|
}
|
|
@@ -527,11 +526,7 @@ ${"\u2501".repeat(60)}`);
|
|
|
527
526
|
}
|
|
528
527
|
);
|
|
529
528
|
const rootDir = cwd ?? process.cwd();
|
|
530
|
-
const lockFilesResult = await cleanLockFiles(
|
|
531
|
-
rootDir,
|
|
532
|
-
deleteLockFiles,
|
|
533
|
-
dryRun
|
|
534
|
-
);
|
|
529
|
+
const lockFilesResult = await cleanLockFiles(rootDir, deleteLockFiles, dryRun);
|
|
535
530
|
displayPreview(results, lockFilesResult);
|
|
536
531
|
if (!dryRun) {
|
|
537
532
|
checkForceFlag(force);
|
|
@@ -547,10 +542,7 @@ ${"\u2501".repeat(60)}`);
|
|
|
547
542
|
await cleanLockFiles(rootDir, true, false);
|
|
548
543
|
}
|
|
549
544
|
const totalFiles2 = cleanedResults.reduce((sum, r) => sum + r.files.length, 0) + lockFilesResult.deletedCount;
|
|
550
|
-
const totalSize2 = cleanedResults.reduce(
|
|
551
|
-
(sum, r) => sum + r.files.reduce((s, f) => s + f.size, 0),
|
|
552
|
-
0
|
|
553
|
-
) + lockFilesResult.deletedSize;
|
|
545
|
+
const totalSize2 = cleanedResults.reduce((sum, r) => sum + r.files.reduce((s, f) => s + f.size, 0), 0) + lockFilesResult.deletedSize;
|
|
554
546
|
const deletedFiles2 = cleanedResults.reduce((sum, r) => sum + r.deletedCount, 0) + lockFilesResult.deletedCount;
|
|
555
547
|
const deletedSize2 = cleanedResults.reduce((sum, r) => sum + r.deletedSize, 0) + lockFilesResult.deletedSize;
|
|
556
548
|
const allErrors2 = cleanedResults.flatMap((r) => r.errors);
|
|
@@ -569,12 +561,8 @@ ${"\u2501".repeat(60)}`);
|
|
|
569
561
|
${"\u2501".repeat(60)}`);
|
|
570
562
|
logger.log("\u{1F4CA} Clean Summary:");
|
|
571
563
|
logger.log(` Packages processed: ${summary2.processedPackages}`);
|
|
572
|
-
logger.log(
|
|
573
|
-
|
|
574
|
-
);
|
|
575
|
-
logger.log(
|
|
576
|
-
` Size ${dryRun ? "would be" : ""} freed: ${formatBytes(summary2.deletedSize)}`
|
|
577
|
-
);
|
|
564
|
+
logger.log(` Files ${dryRun ? "would be" : ""} deleted: ${summary2.deletedFiles}`);
|
|
565
|
+
logger.log(` Size ${dryRun ? "would be" : ""} freed: ${formatBytes(summary2.deletedSize)}`);
|
|
578
566
|
if (summary2.hasErrors) {
|
|
579
567
|
logger.log(` Errors: ${summary2.errors.length}`);
|
|
580
568
|
logger.error("\n\u274C Errors occurred during cleanup:");
|
|
@@ -586,10 +574,7 @@ ${"\u2501".repeat(60)}`);
|
|
|
586
574
|
return summary2;
|
|
587
575
|
}
|
|
588
576
|
const totalFiles = results.reduce((sum, r) => sum + r.files.length, 0) + lockFilesResult.deletedCount;
|
|
589
|
-
const totalSize = results.reduce(
|
|
590
|
-
(sum, r) => sum + r.files.reduce((s, f) => s + f.size, 0),
|
|
591
|
-
0
|
|
592
|
-
) + lockFilesResult.deletedSize;
|
|
577
|
+
const totalSize = results.reduce((sum, r) => sum + r.files.reduce((s, f) => s + f.size, 0), 0) + lockFilesResult.deletedSize;
|
|
593
578
|
const deletedFiles = totalFiles;
|
|
594
579
|
const deletedSize = totalSize;
|
|
595
580
|
const allErrors = results.flatMap((r) => r.errors);
|
|
@@ -56,12 +56,7 @@ export const PRESET_CATEGORIES = {
|
|
|
56
56
|
order: 10
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
|
-
export const LOCK_FILE_PATTERNS = [
|
|
60
|
-
"bun.lock",
|
|
61
|
-
"yarn.lock",
|
|
62
|
-
"package-lock.json",
|
|
63
|
-
"pnpm-lock.yaml"
|
|
64
|
-
];
|
|
59
|
+
export const LOCK_FILE_PATTERNS = ["bun.lock", "yarn.lock", "package-lock.json", "pnpm-lock.yaml"];
|
|
65
60
|
export const parsePresets = (presetsString) => {
|
|
66
61
|
if (!presetsString) {
|
|
67
62
|
return [];
|
|
@@ -105,8 +100,6 @@ export const mergePatterns = (presets, customPatterns) => {
|
|
|
105
100
|
};
|
|
106
101
|
export const validatePatterns = (presets, customPatterns) => {
|
|
107
102
|
if (presets.length === 0 && customPatterns.length === 0) {
|
|
108
|
-
throw new Error(
|
|
109
|
-
"\u274C At least one of --presets or --custom must be provided"
|
|
110
|
-
);
|
|
103
|
+
throw new Error("\u274C At least one of --presets or --custom must be provided");
|
|
111
104
|
}
|
|
112
105
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const _default: import("@reliverse/rempts-core").Command<{
|
|
2
|
+
name: import("@reliverse/rempts-core").CLIOption<import("arktype").BaseType<string | undefined, {}>>;
|
|
3
|
+
template: import("@reliverse/rempts-core").CLIOption<import("arktype/out/variants/string").StringType<"basic" | "advanced" | "monorepo", {}>>;
|
|
4
|
+
dir: import("@reliverse/rempts-core").CLIOption<import("arktype").BaseType<string | undefined, {}>>;
|
|
5
|
+
git: import("@reliverse/rempts-core").CLIOption<import("arktype").BaseType<boolean | undefined, {}>>;
|
|
6
|
+
install: import("@reliverse/rempts-core").CLIOption<import("arktype").BaseType<boolean | undefined, {}>>;
|
|
7
|
+
"package-manager": import("@reliverse/rempts-core").CLIOption<import("arktype/out/variants/string").StringType<"npm" | "bun" | "pnpm" | "yarn", {}>>;
|
|
8
|
+
}, {}, string>;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { relico } from "@reliverse/relico";
|
|
3
|
+
import { defineCommand, option } from "@reliverse/rempts-core";
|
|
4
|
+
import { type } from "arktype";
|
|
5
|
+
export default defineCommand({
|
|
6
|
+
description: "Initialize a new Rempts CLI project",
|
|
7
|
+
alias: "i",
|
|
8
|
+
options: {
|
|
9
|
+
name: option(type("string | undefined"), {
|
|
10
|
+
short: "n",
|
|
11
|
+
description: "Project name"
|
|
12
|
+
}),
|
|
13
|
+
template: option(type("'basic'|'advanced'|'monorepo'"), {
|
|
14
|
+
short: "t",
|
|
15
|
+
description: "Project template"
|
|
16
|
+
}),
|
|
17
|
+
dir: option(type("string | undefined"), {
|
|
18
|
+
short: "d",
|
|
19
|
+
description: "Directory to create project in"
|
|
20
|
+
}),
|
|
21
|
+
git: option(type("boolean | undefined"), {
|
|
22
|
+
short: "g",
|
|
23
|
+
description: "Initialize git repository"
|
|
24
|
+
}),
|
|
25
|
+
install: option(type("boolean | undefined"), { description: "Install dependencies" }),
|
|
26
|
+
"package-manager": option(type("'bun'|'pnpm'|'yarn'|'npm'"), {
|
|
27
|
+
short: "p",
|
|
28
|
+
description: "Package manager to use"
|
|
29
|
+
})
|
|
30
|
+
},
|
|
31
|
+
handler: async ({ flags, positional }) => {
|
|
32
|
+
const template = flags.template || "basic";
|
|
33
|
+
const git = flags.git ?? true;
|
|
34
|
+
const install = flags.install ?? true;
|
|
35
|
+
const packageManager = flags["package-manager"] || "bun";
|
|
36
|
+
console.log(relico.cyan("\u{1F680} Creating new Rempts CLI project..."));
|
|
37
|
+
console.log();
|
|
38
|
+
const args = ["rempts"];
|
|
39
|
+
if (positional[0]) {
|
|
40
|
+
args.push(positional[0]);
|
|
41
|
+
} else if (flags.name) {
|
|
42
|
+
args.push(flags.name);
|
|
43
|
+
}
|
|
44
|
+
if (template !== "basic") {
|
|
45
|
+
args.push("--template", template);
|
|
46
|
+
}
|
|
47
|
+
if (flags.dir) {
|
|
48
|
+
args.push("--dir", flags.dir);
|
|
49
|
+
}
|
|
50
|
+
if (!git) {
|
|
51
|
+
args.push("--no-git");
|
|
52
|
+
}
|
|
53
|
+
if (!install) {
|
|
54
|
+
args.push("--no-install");
|
|
55
|
+
}
|
|
56
|
+
if (packageManager !== "bun") {
|
|
57
|
+
args.push("--package-manager", packageManager);
|
|
58
|
+
}
|
|
59
|
+
console.log(relico.dim(`> bunx ${args.join(" ")}`));
|
|
60
|
+
console.log();
|
|
61
|
+
const proc = spawn("bunx", args, {
|
|
62
|
+
stdio: "inherit",
|
|
63
|
+
env: process.env
|
|
64
|
+
});
|
|
65
|
+
proc.on("exit", (code) => {
|
|
66
|
+
if (code === 0) {
|
|
67
|
+
console.log();
|
|
68
|
+
console.log(relico.green("\u{1F389} Project created successfully!"));
|
|
69
|
+
console.log();
|
|
70
|
+
console.log("Next steps:");
|
|
71
|
+
const projectName = positional[0] || flags.name || "your-project";
|
|
72
|
+
console.log(relico.gray(` cd ${projectName}`));
|
|
73
|
+
console.log(relico.gray(" @reliverse/rempts dev"));
|
|
74
|
+
} else {
|
|
75
|
+
console.error(relico.red("Failed to create project"));
|
|
76
|
+
process.exit(code || 1);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
proc.on("error", (error) => {
|
|
80
|
+
console.error(relico.red("Failed to run rempts:"), error.message);
|
|
81
|
+
console.log();
|
|
82
|
+
console.log("Make sure @reliverse/rempts is available:");
|
|
83
|
+
console.log(relico.gray(" bunx @reliverse/rempts --help"));
|
|
84
|
+
process.exit(1);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
});
|