@reliverse/dler 1.7.60 → 1.7.62
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/LICENSES +3 -0
- package/README.md +12 -7
- package/bin/app/build/prebuild.js +1 -2
- package/bin/app/{copy → fs}/cmd.d.ts +33 -2
- package/bin/app/fs/cmd.js +302 -0
- package/bin/app/x/cmd.d.ts +92 -0
- package/bin/app/x/cmd.js +270 -0
- package/bin/libs/cfg/cfg-impl/rse-config/rse-impl/rse-create.js +1 -1
- package/bin/libs/cfg/cfg-impl/rse-config/rse-impl/rse-define.d.ts +14 -14
- package/bin/libs/sdk/sdk-impl/config/info.js +1 -1
- package/bin/libs/sdk/sdk-impl/utils/exec/exec-enoent.d.ts +15 -0
- package/bin/libs/sdk/sdk-impl/utils/exec/exec-enoent.js +38 -0
- package/bin/libs/sdk/sdk-impl/utils/exec/exec-env.d.ts +6 -0
- package/bin/libs/sdk/sdk-impl/utils/exec/exec-env.js +34 -0
- package/bin/libs/sdk/sdk-impl/utils/exec/exec-error.d.ts +7 -0
- package/bin/libs/sdk/sdk-impl/utils/exec/exec-error.js +15 -0
- package/bin/libs/sdk/sdk-impl/utils/exec/exec-escape.d.ts +2 -0
- package/bin/libs/sdk/sdk-impl/utils/exec/exec-escape.js +15 -0
- package/bin/libs/sdk/sdk-impl/utils/exec/exec-mod.d.ts +58 -0
- package/bin/libs/sdk/sdk-impl/utils/exec/exec-mod.js +231 -0
- package/bin/libs/sdk/sdk-impl/utils/exec/exec-parse.d.ts +2 -0
- package/bin/libs/sdk/sdk-impl/utils/exec/exec-parse.js +56 -0
- package/bin/libs/sdk/sdk-impl/utils/exec/exec-resolve.d.ts +2 -0
- package/bin/libs/sdk/sdk-impl/utils/exec/exec-resolve.js +39 -0
- package/bin/libs/sdk/sdk-impl/utils/exec/exec-shebang.d.ts +1 -0
- package/bin/libs/sdk/sdk-impl/utils/exec/exec-shebang.js +14 -0
- package/bin/libs/sdk/sdk-impl/utils/exec/exec-spawn.d.ts +3 -0
- package/bin/libs/sdk/sdk-impl/utils/exec/exec-spawn.js +18 -0
- package/bin/libs/sdk/sdk-impl/utils/exec/exec-stream.d.ts +4 -0
- package/bin/libs/sdk/sdk-impl/utils/exec/exec-stream.js +20 -0
- package/bin/libs/sdk/sdk-impl/utils/exec/exec-types.d.ts +13 -0
- package/bin/libs/sdk/sdk-impl/utils/exec/exec-types.js +9 -0
- package/bin/libs/sdk/sdk-impl/utils/fs-rename.d.ts +2 -0
- package/bin/libs/sdk/sdk-impl/utils/fs-rename.js +108 -0
- package/bin/libs/sdk/sdk-impl/utils/pm/pm-api.d.ts +85 -0
- package/bin/libs/sdk/sdk-impl/utils/pm/pm-api.js +168 -0
- package/bin/libs/sdk/sdk-impl/utils/pm/pm-detect.d.ts +12 -0
- package/bin/libs/sdk/sdk-impl/utils/pm/pm-detect.js +99 -0
- package/bin/libs/sdk/sdk-impl/utils/pm/pm-parse.d.ts +8 -0
- package/bin/libs/sdk/sdk-impl/utils/pm/pm-parse.js +29 -0
- package/bin/libs/sdk/sdk-impl/utils/pm/pm-types.d.ts +43 -0
- package/bin/libs/sdk/sdk-impl/utils/pm/pm-types.js +0 -0
- package/bin/libs/sdk/sdk-impl/utils/pm/pm-utils.d.ts +12 -0
- package/bin/libs/sdk/sdk-impl/utils/pm/pm-utils.js +86 -0
- package/bin/libs/sdk/sdk-mod.d.ts +24 -0
- package/bin/libs/sdk/sdk-mod.js +53 -0
- package/package.json +9 -8
- package/bin/app/copy/cmd.js +0 -186
- package/bin/app/init/cmd.d.ts +0 -29
- package/bin/app/init/cmd.js +0 -82
- package/bin/app/rename/cmd.d.ts +0 -32
- package/bin/app/rename/cmd.js +0 -182
- package/bin/app/rm/cmd.d.ts +0 -13
- package/bin/app/rm/cmd.js +0 -70
- /package/bin/{app → libs/sdk/sdk-impl/utils}/init/init-const.d.ts +0 -0
- /package/bin/{app → libs/sdk/sdk-impl/utils}/init/init-const.js +0 -0
- /package/bin/{app → libs/sdk/sdk-impl/utils}/init/init-impl.d.ts +0 -0
- /package/bin/{app → libs/sdk/sdk-impl/utils}/init/init-impl.js +0 -0
- /package/bin/{app → libs/sdk/sdk-impl/utils}/init/init-tmpl.d.ts +0 -0
- /package/bin/{app → libs/sdk/sdk-impl/utils}/init/init-tmpl.js +0 -0
- /package/bin/{app → libs/sdk/sdk-impl/utils}/init/init-types.d.ts +0 -0
- /package/bin/{app → libs/sdk/sdk-impl/utils}/init/init-types.js +0 -0
package/LICENSES
CHANGED
|
@@ -13,5 +13,8 @@ See LICENSE file for full license text.
|
|
|
13
13
|
NOTICES
|
|
14
14
|
|
|
15
15
|
Some parts of this project are based on and significantly adapt:
|
|
16
|
+
- https://github.com/unjs/nypm/tree/b13ca2f – MIT © Pooya Parsa (pi0)
|
|
16
17
|
- https://github.com/unjs/unbuild/tree/a6570a5 – MIT © Pooya Parsa (pi0)
|
|
17
18
|
- https://github.com/unjs/mkdist/tree/a7f029d – MIT © Pooya Parsa (pi0), Daniel Roe (danielroe)
|
|
19
|
+
- https://github.com/moxystudio/node-cross-spawn/tree/77cd97f – MIT © MOXY (hello@moxy.studio)
|
|
20
|
+
- https://github.com/tinylibs/tinyexec/tree/daa2945 – MIT © Tinylibs
|
package/README.md
CHANGED
|
@@ -156,7 +156,7 @@ if you run just `dler` — it will display a list of commands which you can laun
|
|
|
156
156
|
|
|
157
157
|
## **available commands**
|
|
158
158
|
|
|
159
|
-
[build](#1-build) — [pub](#2-pub) — [agg](#3-agg) — [check](#4-check) — [conv](#5-conv) — [
|
|
159
|
+
[build](#1-build) — [pub](#2-pub) — [agg](#3-agg) — [check](#4-check) — [conv](#5-conv) — [fs](#6-fs) — [init](#7-init) — [inject](#8-inject) — [libs](#9-libs) — [merge](#10-merge) — [migrate](#11-migrate) — [rempts](#12-rempts) — [x](#13-x) — [spell](#14-magic) — [split](#15-split) — [pack](#16-pack)
|
|
160
160
|
|
|
161
161
|
### 1. `build`
|
|
162
162
|
|
|
@@ -187,7 +187,7 @@ dler > "agg"
|
|
|
187
187
|
dler agg --input <dir> --out <file> [options]
|
|
188
188
|
```
|
|
189
189
|
|
|
190
|
-
**usage example**: if you're exploring the example [playground](#playground), you can try the following:
|
|
190
|
+
**usage example**: if you're exploring the example [playground](#0-try-the-playground), you can try the following:
|
|
191
191
|
|
|
192
192
|
1. open [src/libs/sdk/sdk-mod.ts](https://github.com/reliverse/dler/blob/main/src/libs/sdk/sdk-mod.ts) in your ide.
|
|
193
193
|
2. press `ctrl+a`, then `backspace`. run the command below and watch the magic happen:
|
|
@@ -322,14 +322,17 @@ deep imports like `dep/some/file` or `@org/dep/some/thing` are always resolved t
|
|
|
322
322
|
|
|
323
323
|
not yet documented.
|
|
324
324
|
|
|
325
|
-
### 6. `
|
|
325
|
+
### 6. `fs`
|
|
326
326
|
|
|
327
327
|
```bash
|
|
328
328
|
# simple example:
|
|
329
|
-
bun dler copy --s "src/**/*.ts" --d "dist"
|
|
329
|
+
bun dler fs --mode copy --s "src/**/*.ts" --d "dist"
|
|
330
|
+
bun dler fs --mode rm --target "node_modules"
|
|
331
|
+
bun dler fs --mode rename --source "index.ts" --destination "index.ts.bak"
|
|
330
332
|
|
|
331
333
|
# advanced example:
|
|
332
|
-
bun dler copy --s ".temp/packages/*/lib/**/*" --d "src/libs/sdk/sdk-impl/rules/external"
|
|
334
|
+
bun dler fs --mode copy --s ".temp/packages/*/lib/**/*" --d "src/libs/sdk/sdk-impl/rules/external"
|
|
335
|
+
bun dler fs --mode rm --target "**/node_modules"
|
|
333
336
|
```
|
|
334
337
|
|
|
335
338
|
### 7. `init`
|
|
@@ -623,10 +626,12 @@ bun dler rempts
|
|
|
623
626
|
bun dler rempts --init cmd1 cmd2
|
|
624
627
|
```
|
|
625
628
|
|
|
626
|
-
### 13. `
|
|
629
|
+
### 13. `x`
|
|
630
|
+
|
|
631
|
+
`dler x` — your package manager — refined.
|
|
627
632
|
|
|
628
633
|
```bash
|
|
629
|
-
bun dler
|
|
634
|
+
bun dler x ...
|
|
630
635
|
```
|
|
631
636
|
|
|
632
637
|
### 14. `magic`
|
|
@@ -26,8 +26,7 @@ const createToolRunner = () => ({
|
|
|
26
26
|
"dler-check": {
|
|
27
27
|
name: "Dler Check",
|
|
28
28
|
async run() {
|
|
29
|
-
|
|
30
|
-
await runCmd(checkCmd, ["--no-exit", "--no-progress"]);
|
|
29
|
+
await runCmd(await getCheckCmd(), ["--no-exit", "--no-progress"]);
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
});
|
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
declare const _default: import("@reliverse/rempts").Command<{
|
|
2
|
-
|
|
2
|
+
mode: {
|
|
3
3
|
type: "string";
|
|
4
4
|
description: string;
|
|
5
|
+
allowed: string[];
|
|
6
|
+
required: true;
|
|
5
7
|
};
|
|
6
|
-
|
|
8
|
+
target: {
|
|
7
9
|
type: "string";
|
|
8
10
|
description: string;
|
|
11
|
+
required: true;
|
|
12
|
+
alias: string;
|
|
13
|
+
};
|
|
14
|
+
nonInteractive: {
|
|
15
|
+
type: "boolean";
|
|
16
|
+
description: string;
|
|
17
|
+
default: false;
|
|
18
|
+
};
|
|
19
|
+
source: {
|
|
20
|
+
type: "string";
|
|
21
|
+
description: string;
|
|
22
|
+
alias: string;
|
|
23
|
+
};
|
|
24
|
+
destination: {
|
|
25
|
+
type: "string";
|
|
26
|
+
description: string;
|
|
27
|
+
alias: string;
|
|
9
28
|
};
|
|
10
29
|
recursive: {
|
|
11
30
|
type: "boolean";
|
|
@@ -32,5 +51,17 @@ declare const _default: import("@reliverse/rempts").Command<{
|
|
|
32
51
|
description: string;
|
|
33
52
|
default: false;
|
|
34
53
|
};
|
|
54
|
+
prepareMyCLI: {
|
|
55
|
+
type: "boolean";
|
|
56
|
+
description: string;
|
|
57
|
+
};
|
|
58
|
+
revert: {
|
|
59
|
+
type: "boolean";
|
|
60
|
+
description: string;
|
|
61
|
+
};
|
|
62
|
+
useDtsTxtForPrepareMyCLI: {
|
|
63
|
+
type: "boolean";
|
|
64
|
+
description: string;
|
|
65
|
+
};
|
|
35
66
|
}>;
|
|
36
67
|
export default _default;
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import path from "@reliverse/pathkit";
|
|
2
|
+
import fs from "@reliverse/relifso";
|
|
3
|
+
import { relinka } from "@reliverse/relinka";
|
|
4
|
+
import { defineArgs, defineCommand, inputPrompt, selectPrompt } from "@reliverse/rempts";
|
|
5
|
+
import pMap from "p-map";
|
|
6
|
+
import prettyMilliseconds from "pretty-ms";
|
|
7
|
+
import { glob } from "tinyglobby";
|
|
8
|
+
import { prepareCLIFiles, safeRename } from "../../libs/sdk/sdk-impl/utils/fs-rename.js";
|
|
9
|
+
import { createPerfTimer, getElapsedPerfTime } from "../../libs/sdk/sdk-mod.js";
|
|
10
|
+
async function fileExists(path2) {
|
|
11
|
+
try {
|
|
12
|
+
await fs.access(path2);
|
|
13
|
+
return true;
|
|
14
|
+
} catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
async function ensureDir(path2) {
|
|
19
|
+
try {
|
|
20
|
+
await fs.access(path2);
|
|
21
|
+
} catch {
|
|
22
|
+
await fs.mkdir(path2, { recursive: true });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export default defineCommand({
|
|
26
|
+
meta: {
|
|
27
|
+
name: "rm",
|
|
28
|
+
version: "1.1.0",
|
|
29
|
+
description: "COPY or REMOVE or RENAME a file, directory, or glob pattern recursively. Usage example: `dler fs --mode rm --target '**/node_modules'`"
|
|
30
|
+
},
|
|
31
|
+
args: defineArgs({
|
|
32
|
+
mode: {
|
|
33
|
+
type: "string",
|
|
34
|
+
description: "Mode to use: copy, rm, rename",
|
|
35
|
+
allowed: ["copy", "rm", "rename"],
|
|
36
|
+
required: true
|
|
37
|
+
},
|
|
38
|
+
target: {
|
|
39
|
+
type: "string",
|
|
40
|
+
description: "Path or glob pattern to the file(s) or directory(ies) to complete the operation.",
|
|
41
|
+
required: true,
|
|
42
|
+
alias: "t"
|
|
43
|
+
},
|
|
44
|
+
nonInteractive: {
|
|
45
|
+
type: "boolean",
|
|
46
|
+
description: "Disable interactive prompts and require all arguments to be provided via flags.",
|
|
47
|
+
default: false
|
|
48
|
+
},
|
|
49
|
+
source: {
|
|
50
|
+
type: "string",
|
|
51
|
+
description: "Source file or directory to complete the operation (supports glob patterns)",
|
|
52
|
+
alias: "s"
|
|
53
|
+
},
|
|
54
|
+
destination: {
|
|
55
|
+
type: "string",
|
|
56
|
+
description: "Destination path for the operation",
|
|
57
|
+
alias: "d"
|
|
58
|
+
},
|
|
59
|
+
recursive: {
|
|
60
|
+
type: "boolean",
|
|
61
|
+
description: "Recursively process all files in subdirectories (default: true)",
|
|
62
|
+
default: true
|
|
63
|
+
},
|
|
64
|
+
preserveStructure: {
|
|
65
|
+
type: "boolean",
|
|
66
|
+
description: "Preserve source directory structure in destination (default: true)",
|
|
67
|
+
default: true
|
|
68
|
+
},
|
|
69
|
+
increment: {
|
|
70
|
+
type: "boolean",
|
|
71
|
+
description: "Attach an incrementing index to each destination filename before the extension if set (default: true)",
|
|
72
|
+
default: true
|
|
73
|
+
},
|
|
74
|
+
concurrency: {
|
|
75
|
+
type: "number",
|
|
76
|
+
description: "Number of concurrent copy operations (default: 8)",
|
|
77
|
+
default: 8
|
|
78
|
+
},
|
|
79
|
+
gitignore: {
|
|
80
|
+
type: "boolean",
|
|
81
|
+
description: "Ignore files and directories specified in .gitignore",
|
|
82
|
+
default: false
|
|
83
|
+
},
|
|
84
|
+
prepareMyCLI: {
|
|
85
|
+
type: "boolean",
|
|
86
|
+
description: "Prepare CLI by renaming files"
|
|
87
|
+
},
|
|
88
|
+
revert: {
|
|
89
|
+
type: "boolean",
|
|
90
|
+
description: "Revert renamed files back to original names"
|
|
91
|
+
},
|
|
92
|
+
useDtsTxtForPrepareMyCLI: {
|
|
93
|
+
type: "boolean",
|
|
94
|
+
description: "Use .d.ts.txt extension for .d.ts files in prepareMyCLI mode (default: false)"
|
|
95
|
+
}
|
|
96
|
+
}),
|
|
97
|
+
async run({ args }) {
|
|
98
|
+
const {
|
|
99
|
+
mode,
|
|
100
|
+
nonInteractive,
|
|
101
|
+
source,
|
|
102
|
+
destination,
|
|
103
|
+
recursive = true,
|
|
104
|
+
preserveStructure = true,
|
|
105
|
+
increment = false,
|
|
106
|
+
concurrency = 8,
|
|
107
|
+
gitignore = false,
|
|
108
|
+
prepareMyCLI,
|
|
109
|
+
revert,
|
|
110
|
+
useDtsTxtForPrepareMyCLI = false
|
|
111
|
+
} = args;
|
|
112
|
+
let { target } = args;
|
|
113
|
+
if (mode === "rm") {
|
|
114
|
+
if (!target && !nonInteractive) {
|
|
115
|
+
target = await inputPrompt({
|
|
116
|
+
title: "Enter the path or glob pattern to remove:",
|
|
117
|
+
defaultValue: ""
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
if (!target) {
|
|
121
|
+
relinka("error", "No target path or pattern provided for removal.");
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
let matches = [];
|
|
125
|
+
try {
|
|
126
|
+
matches = await glob(target, { dot: true });
|
|
127
|
+
} catch (error) {
|
|
128
|
+
relinka("error", `Invalid glob pattern: ${target}`);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (matches.length === 0) {
|
|
132
|
+
relinka("error", `No files or directories matched: ${target}`);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
matches.sort((a, b) => b.split(path.sep).length - a.split(path.sep).length);
|
|
136
|
+
let removedCount = 0;
|
|
137
|
+
const concurrency2 = 8;
|
|
138
|
+
await pMap(
|
|
139
|
+
matches,
|
|
140
|
+
async (match) => {
|
|
141
|
+
const resolvedPath = path.resolve(match);
|
|
142
|
+
try {
|
|
143
|
+
if (!await fs.pathExists(resolvedPath)) {
|
|
144
|
+
relinka("warn", `Target does not exist: ${resolvedPath}`);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
await fs.remove(resolvedPath);
|
|
148
|
+
relinka("log", `Removed: ${resolvedPath}`);
|
|
149
|
+
removedCount++;
|
|
150
|
+
} catch (error) {
|
|
151
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
152
|
+
relinka("error", `Failed to remove '${resolvedPath}': ${errorMessage}`);
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
{ concurrency: concurrency2 }
|
|
156
|
+
);
|
|
157
|
+
if (removedCount > 0) {
|
|
158
|
+
relinka("log", `Successfully removed ${removedCount} item(s) matching: ${target}`);
|
|
159
|
+
} else {
|
|
160
|
+
relinka("warn", `No items were removed for pattern: ${target}`);
|
|
161
|
+
}
|
|
162
|
+
} else if (mode === "copy") {
|
|
163
|
+
let finalSource = source;
|
|
164
|
+
let finalDestination = destination;
|
|
165
|
+
if (!finalSource) {
|
|
166
|
+
finalSource = await inputPrompt({
|
|
167
|
+
title: "Enter source file or directory (supports glob patterns)",
|
|
168
|
+
placeholder: "e.g., putout/packages/*/lib/**/*"
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
if (!finalDestination) {
|
|
172
|
+
finalDestination = await inputPrompt({
|
|
173
|
+
title: "Enter destination path",
|
|
174
|
+
placeholder: "e.g., src/libs/sdk/sdk-impl/rules/putout"
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
if (!finalSource || !finalDestination) {
|
|
178
|
+
relinka("error", "Usage: dler copy --s <source> --d <destination>");
|
|
179
|
+
process.exit(1);
|
|
180
|
+
}
|
|
181
|
+
let ignorePatterns = recursive ? [] : ["**/*"];
|
|
182
|
+
if (gitignore) {
|
|
183
|
+
try {
|
|
184
|
+
const gitignoreContent = await fs.readFile(".gitignore", "utf8");
|
|
185
|
+
ignorePatterns = ignorePatterns.concat(
|
|
186
|
+
gitignoreContent.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#"))
|
|
187
|
+
);
|
|
188
|
+
} catch (err) {
|
|
189
|
+
relinka("error", ".gitignore not found or unreadable, but --gitignore was specified.");
|
|
190
|
+
process.exit(1);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
try {
|
|
194
|
+
const files = await glob(finalSource, {
|
|
195
|
+
dot: true,
|
|
196
|
+
ignore: ignorePatterns
|
|
197
|
+
});
|
|
198
|
+
if (files.length === 0) {
|
|
199
|
+
relinka("error", `No files found matching pattern: ${finalSource}`);
|
|
200
|
+
process.exit(1);
|
|
201
|
+
}
|
|
202
|
+
if (files.length > 1) {
|
|
203
|
+
const confirm = await selectPrompt({
|
|
204
|
+
title: `Found ${files.length} files to copy. Proceed?`,
|
|
205
|
+
options: [
|
|
206
|
+
{ label: "Yes", value: "yes" },
|
|
207
|
+
{ label: "No", value: "no" }
|
|
208
|
+
]
|
|
209
|
+
});
|
|
210
|
+
if (confirm === "no") {
|
|
211
|
+
relinka("log", "Operation cancelled by user");
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const timer = createPerfTimer();
|
|
216
|
+
const fileNameCounts = /* @__PURE__ */ new Map();
|
|
217
|
+
await pMap(
|
|
218
|
+
files,
|
|
219
|
+
async (file) => {
|
|
220
|
+
let destPath;
|
|
221
|
+
if (preserveStructure) {
|
|
222
|
+
const match = file.match(/packages\/([^/]+)\/lib\/(.*)/);
|
|
223
|
+
if (match?.[1] && match?.[2]) {
|
|
224
|
+
const packageName = match[1];
|
|
225
|
+
const relativePath = match[2];
|
|
226
|
+
destPath = path.join(finalDestination, packageName, relativePath);
|
|
227
|
+
} else {
|
|
228
|
+
destPath = path.join(finalDestination, file);
|
|
229
|
+
}
|
|
230
|
+
} else {
|
|
231
|
+
destPath = path.join(finalDestination, path.basename(file));
|
|
232
|
+
}
|
|
233
|
+
if (increment) {
|
|
234
|
+
const dir = path.dirname(destPath);
|
|
235
|
+
const base = path.basename(destPath);
|
|
236
|
+
let dirMap = fileNameCounts.get(dir);
|
|
237
|
+
if (!dirMap) {
|
|
238
|
+
dirMap = /* @__PURE__ */ new Map();
|
|
239
|
+
fileNameCounts.set(dir, dirMap);
|
|
240
|
+
}
|
|
241
|
+
const count = dirMap.get(base) || 0;
|
|
242
|
+
if (count > 0) {
|
|
243
|
+
const extMatch = base.match(/(.*)(\.[^./\\]+)$/);
|
|
244
|
+
let newBase;
|
|
245
|
+
if (extMatch) {
|
|
246
|
+
newBase = `${extMatch[1]}-${count + 1}${extMatch[2]}`;
|
|
247
|
+
} else {
|
|
248
|
+
newBase = `${base}-${count + 1}`;
|
|
249
|
+
}
|
|
250
|
+
destPath = path.join(dir, newBase);
|
|
251
|
+
}
|
|
252
|
+
dirMap.set(base, count + 1);
|
|
253
|
+
}
|
|
254
|
+
await ensureDir(path.dirname(destPath));
|
|
255
|
+
if (await fileExists(destPath)) {
|
|
256
|
+
throw new Error(`Destination file already exists: ${destPath}`);
|
|
257
|
+
}
|
|
258
|
+
await fs.copyFile(file, destPath);
|
|
259
|
+
relinka("log", `Copied '${file}' to '${destPath}'`);
|
|
260
|
+
},
|
|
261
|
+
{ concurrency, stopOnError: true }
|
|
262
|
+
);
|
|
263
|
+
const elapsed = getElapsedPerfTime(timer);
|
|
264
|
+
relinka(
|
|
265
|
+
"log",
|
|
266
|
+
`Successfully copied ${files.length} file(s) in ${prettyMilliseconds(elapsed)}`
|
|
267
|
+
);
|
|
268
|
+
} catch (error) {
|
|
269
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
270
|
+
relinka("error", `Error during copy operation: ${errorMessage}`);
|
|
271
|
+
process.exit(1);
|
|
272
|
+
}
|
|
273
|
+
} else if (mode === "rename") {
|
|
274
|
+
if (prepareMyCLI === true) {
|
|
275
|
+
try {
|
|
276
|
+
await prepareCLIFiles(revert === true, recursive, useDtsTxtForPrepareMyCLI);
|
|
277
|
+
relinka("log", "Successfully prepared CLI files");
|
|
278
|
+
} catch (error) {
|
|
279
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
280
|
+
relinka("error", `Error preparing CLI: ${errorMessage}`);
|
|
281
|
+
process.exit(1);
|
|
282
|
+
}
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
if (!source || !destination) {
|
|
286
|
+
relinka(
|
|
287
|
+
"error",
|
|
288
|
+
"Usage: dler fs --mode rename --source <source> --destination <destination>"
|
|
289
|
+
);
|
|
290
|
+
process.exit(1);
|
|
291
|
+
}
|
|
292
|
+
try {
|
|
293
|
+
await safeRename(source, destination);
|
|
294
|
+
relinka("log", `Successfully renamed '${source}' to '${destination}'`);
|
|
295
|
+
} catch (error) {
|
|
296
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
297
|
+
relinka("error", `Error renaming: ${errorMessage}`);
|
|
298
|
+
process.exit(1);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* USAGE EXAMPLES:
|
|
3
|
+
* - dler x install package-name - installs a package
|
|
4
|
+
* - dler x remove package-name - removes a package
|
|
5
|
+
* - dler x detect - detects the package manager
|
|
6
|
+
* - dler x dedupe - deduplicates dependencies
|
|
7
|
+
* - dler x run script-name - runs a script
|
|
8
|
+
* - dler x exec --target 'bun run build' - executes a command
|
|
9
|
+
*/
|
|
10
|
+
declare const _default: import("@reliverse/rempts").Command<{
|
|
11
|
+
action: {
|
|
12
|
+
type: "string";
|
|
13
|
+
description: string;
|
|
14
|
+
required: true;
|
|
15
|
+
};
|
|
16
|
+
name: {
|
|
17
|
+
type: "positional";
|
|
18
|
+
description: string;
|
|
19
|
+
required: false;
|
|
20
|
+
};
|
|
21
|
+
dev: {
|
|
22
|
+
type: "boolean";
|
|
23
|
+
alias: string;
|
|
24
|
+
description: string;
|
|
25
|
+
};
|
|
26
|
+
global: {
|
|
27
|
+
type: "boolean";
|
|
28
|
+
alias: string;
|
|
29
|
+
description: string;
|
|
30
|
+
};
|
|
31
|
+
"frozen-lockfile": {
|
|
32
|
+
type: "boolean";
|
|
33
|
+
description: string;
|
|
34
|
+
};
|
|
35
|
+
cwd: {
|
|
36
|
+
type: "string";
|
|
37
|
+
description: string;
|
|
38
|
+
};
|
|
39
|
+
workspace: {
|
|
40
|
+
type: "boolean";
|
|
41
|
+
description: string;
|
|
42
|
+
};
|
|
43
|
+
silent: {
|
|
44
|
+
type: "boolean";
|
|
45
|
+
description: string;
|
|
46
|
+
};
|
|
47
|
+
recreateLockFile: {
|
|
48
|
+
type: "boolean";
|
|
49
|
+
description: string;
|
|
50
|
+
};
|
|
51
|
+
target: {
|
|
52
|
+
type: "string";
|
|
53
|
+
description: string;
|
|
54
|
+
};
|
|
55
|
+
timeout: {
|
|
56
|
+
type: "number";
|
|
57
|
+
description: string;
|
|
58
|
+
};
|
|
59
|
+
throwOnError: {
|
|
60
|
+
type: "boolean";
|
|
61
|
+
description: string;
|
|
62
|
+
default: true;
|
|
63
|
+
};
|
|
64
|
+
fileType: {
|
|
65
|
+
type: "string";
|
|
66
|
+
description: string;
|
|
67
|
+
};
|
|
68
|
+
destDir: {
|
|
69
|
+
type: "string";
|
|
70
|
+
description: string;
|
|
71
|
+
default: string;
|
|
72
|
+
};
|
|
73
|
+
multiple: {
|
|
74
|
+
type: "boolean";
|
|
75
|
+
description: string;
|
|
76
|
+
};
|
|
77
|
+
parallel: {
|
|
78
|
+
type: "boolean";
|
|
79
|
+
description: string;
|
|
80
|
+
};
|
|
81
|
+
concurrency: {
|
|
82
|
+
type: "string";
|
|
83
|
+
description: string;
|
|
84
|
+
default: string;
|
|
85
|
+
};
|
|
86
|
+
linter: {
|
|
87
|
+
type: "boolean";
|
|
88
|
+
description: string;
|
|
89
|
+
default: false;
|
|
90
|
+
};
|
|
91
|
+
}>;
|
|
92
|
+
export default _default;
|