@reliverse/dler 1.5.0 → 1.5.2
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/app/agg/cmd.d.ts +10 -0
- package/bin/app/agg/cmd.js +13 -1
- package/bin/app/agg/impl.d.ts +3 -1
- package/bin/app/agg/impl.js +50 -50
- package/bin/app/agg/run.js +15 -1
- package/bin/app/cmds.d.ts +51 -0
- package/bin/app/cmds.js +3 -0
- package/bin/app/relifso/cmd.js +13 -1
- package/bin/app/relifso/rename/cmd.d.ts +27 -0
- package/bin/app/relifso/rename/cmd.js +126 -0
- package/bin/init/info.js +2 -1
- package/package.json +1 -1
package/bin/app/agg/cmd.d.ts
CHANGED
|
@@ -65,5 +65,15 @@ declare const _default: import("@reliverse/rempts").Command<{
|
|
|
65
65
|
type: "string";
|
|
66
66
|
default: string;
|
|
67
67
|
};
|
|
68
|
+
separateTypesFile: {
|
|
69
|
+
description: string;
|
|
70
|
+
type: "boolean";
|
|
71
|
+
default: false;
|
|
72
|
+
};
|
|
73
|
+
typesOut: {
|
|
74
|
+
description: string;
|
|
75
|
+
type: "string";
|
|
76
|
+
required: false;
|
|
77
|
+
};
|
|
68
78
|
}>;
|
|
69
79
|
export default _default;
|
package/bin/app/agg/cmd.js
CHANGED
|
@@ -68,6 +68,16 @@ export default defineCommand({
|
|
|
68
68
|
description: "Comma-separated list of file extensions to process (default: .ts,.js,.mts,.cts,.mjs,.cjs)",
|
|
69
69
|
type: "string",
|
|
70
70
|
default: ".ts,.js,.mts,.cts,.mjs,.cjs"
|
|
71
|
+
},
|
|
72
|
+
separateTypesFile: {
|
|
73
|
+
description: "Create a separate file for type exports",
|
|
74
|
+
type: "boolean",
|
|
75
|
+
default: false
|
|
76
|
+
},
|
|
77
|
+
typesOut: {
|
|
78
|
+
description: "Output file path for types (used when separateTypesFile is true)",
|
|
79
|
+
type: "string",
|
|
80
|
+
required: false
|
|
71
81
|
}
|
|
72
82
|
}),
|
|
73
83
|
async run({ args }) {
|
|
@@ -84,7 +94,9 @@ export default defineCommand({
|
|
|
84
94
|
includeInternal: !!args.includeInternal,
|
|
85
95
|
internalMarker: args.internalMarker,
|
|
86
96
|
overrideFile: !!args.override,
|
|
87
|
-
fileExtensions: args.extensions.split(",").map((ext) => ext.trim())
|
|
97
|
+
fileExtensions: args.extensions.split(",").map((ext) => ext.trim()),
|
|
98
|
+
separateTypesFile: !!args.separateTypesFile,
|
|
99
|
+
typesOutFile: args.typesOut ? path.resolve(args.typesOut) : void 0
|
|
88
100
|
});
|
|
89
101
|
}
|
|
90
102
|
});
|
package/bin/app/agg/impl.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* - By default, updates only the auto-generated block in the aggregator file,
|
|
16
16
|
* leaving any other content intact. Pass `overrideFile: true` to rewrite the entire file.
|
|
17
17
|
*/
|
|
18
|
-
export declare function useAggregator({ inputDir, isRecursive, outFile, stripPrefix, useImport, useNamed, ignoreDirs, sortLines, headerComment, verbose, includeInternal, internalMarker, overrideFile, fileExtensions, }: {
|
|
18
|
+
export declare function useAggregator({ inputDir, isRecursive, outFile, stripPrefix, useImport, useNamed, ignoreDirs, sortLines, headerComment, verbose, includeInternal, internalMarker, overrideFile, fileExtensions, separateTypesFile, typesOutFile, }: {
|
|
19
19
|
inputDir: string;
|
|
20
20
|
isRecursive: boolean;
|
|
21
21
|
outFile: string;
|
|
@@ -30,6 +30,8 @@ export declare function useAggregator({ inputDir, isRecursive, outFile, stripPre
|
|
|
30
30
|
internalMarker?: string;
|
|
31
31
|
overrideFile?: boolean;
|
|
32
32
|
fileExtensions?: string[];
|
|
33
|
+
separateTypesFile?: boolean;
|
|
34
|
+
typesOutFile?: string;
|
|
33
35
|
}): Promise<void>;
|
|
34
36
|
/**
|
|
35
37
|
* Prints usage examples based on whether dev mode or not.
|
package/bin/app/agg/impl.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import path from "@reliverse/pathkit";
|
|
2
2
|
import fs from "@reliverse/relifso";
|
|
3
3
|
import { relinka } from "@reliverse/relinka";
|
|
4
|
-
import MagicString from "magic-string";
|
|
5
4
|
const AGGREGATOR_START = "// AUTO-GENERATED AGGREGATOR START";
|
|
6
5
|
const AGGREGATOR_END = "// AUTO-GENERATED AGGREGATOR END";
|
|
7
6
|
export async function useAggregator({
|
|
@@ -18,7 +17,9 @@ export async function useAggregator({
|
|
|
18
17
|
includeInternal = false,
|
|
19
18
|
internalMarker = "#",
|
|
20
19
|
overrideFile = false,
|
|
21
|
-
fileExtensions = [".ts", ".js", ".mts", ".cts", ".mjs", ".cjs"]
|
|
20
|
+
fileExtensions = [".ts", ".js", ".mts", ".cts", ".mjs", ".cjs"],
|
|
21
|
+
separateTypesFile = false,
|
|
22
|
+
typesOutFile
|
|
22
23
|
}) {
|
|
23
24
|
try {
|
|
24
25
|
const st = await fs.stat(inputDir).catch(() => null);
|
|
@@ -37,6 +38,19 @@ ${error}`
|
|
|
37
38
|
);
|
|
38
39
|
process.exit(1);
|
|
39
40
|
}
|
|
41
|
+
if (separateTypesFile && typesOutFile) {
|
|
42
|
+
const typesOutDir = path.dirname(typesOutFile);
|
|
43
|
+
try {
|
|
44
|
+
await fs.ensureDir(typesOutDir);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
relinka(
|
|
47
|
+
"error",
|
|
48
|
+
`Error: Cannot create types output directory: ${typesOutDir}
|
|
49
|
+
${error}`
|
|
50
|
+
);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
40
54
|
const outExt = path.extname(outFile).toLowerCase();
|
|
41
55
|
if (!fileExtensions.includes(outExt)) {
|
|
42
56
|
relinka(
|
|
@@ -98,62 +112,48 @@ ${error}`
|
|
|
98
112
|
)
|
|
99
113
|
);
|
|
100
114
|
const allLines = aggregatorLinesArrays.flat();
|
|
115
|
+
const typeLines = [];
|
|
116
|
+
const valueLines = [];
|
|
117
|
+
for (const line of allLines) {
|
|
118
|
+
if (line.includes("type {")) {
|
|
119
|
+
typeLines.push(line);
|
|
120
|
+
} else {
|
|
121
|
+
valueLines.push(line);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
101
124
|
if (sortLines) {
|
|
102
|
-
|
|
125
|
+
typeLines.sort();
|
|
126
|
+
valueLines.sort();
|
|
103
127
|
if (verbose) relinka("log", "Sorted aggregator lines alphabetically.");
|
|
104
128
|
}
|
|
105
|
-
const
|
|
106
|
-
const aggregatorBlock = `${headerComment ? `${headerComment}
|
|
129
|
+
const buildAggregatorBlock = (lines) => `${headerComment ? `${headerComment}
|
|
107
130
|
` : ""}${AGGREGATOR_START}
|
|
108
|
-
${
|
|
131
|
+
${lines.join("\n")}
|
|
109
132
|
${AGGREGATOR_END}
|
|
110
133
|
`;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
134
|
+
if (separateTypesFile && typesOutFile) {
|
|
135
|
+
const typeBlock = buildAggregatorBlock(typeLines);
|
|
136
|
+
await fs.ensureFile(typesOutFile);
|
|
137
|
+
await fs.writeFile(typesOutFile, typeBlock, "utf8");
|
|
138
|
+
const valueBlock = buildAggregatorBlock([
|
|
139
|
+
...valueLines,
|
|
140
|
+
`export * from "${path.relative(path.dirname(outFile), typesOutFile).replace(/\\/g, "/")}";`
|
|
141
|
+
]);
|
|
142
|
+
await fs.ensureFile(outFile);
|
|
143
|
+
await fs.writeFile(outFile, valueBlock, "utf8");
|
|
144
|
+
relinka(
|
|
145
|
+
"success",
|
|
146
|
+
`Aggregator done: processed ${typeLines.length} type lines in: ${typesOutFile} and ${valueLines.length} value lines in: ${outFile}`
|
|
147
|
+
);
|
|
117
148
|
} else {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (existingContent?.includes(AGGREGATOR_START) && existingContent.includes(AGGREGATOR_END)) {
|
|
126
|
-
if (verbose) {
|
|
127
|
-
relinka(
|
|
128
|
-
"log",
|
|
129
|
-
"Existing aggregator block found. Updating auto-generated section."
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
const s = new MagicString(existingContent);
|
|
133
|
-
const startIdx = existingContent.indexOf(AGGREGATOR_START);
|
|
134
|
-
const endIdx = existingContent.indexOf(AGGREGATOR_END) + AGGREGATOR_END.length;
|
|
135
|
-
s.update(startIdx, endIdx, aggregatorBlock.trim());
|
|
136
|
-
finalText = s.toString();
|
|
137
|
-
} else {
|
|
138
|
-
if (existingContent) {
|
|
139
|
-
if (verbose)
|
|
140
|
-
relinka(
|
|
141
|
-
"log",
|
|
142
|
-
"No aggregator block found. Appending auto-generated section."
|
|
143
|
-
);
|
|
144
|
-
finalText = `${existingContent.trim()}
|
|
145
|
-
${aggregatorBlock}`;
|
|
146
|
-
} else {
|
|
147
|
-
finalText = aggregatorBlock;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
149
|
+
const aggregatorBlock = buildAggregatorBlock(allLines);
|
|
150
|
+
await fs.ensureFile(outFile);
|
|
151
|
+
await fs.writeFile(outFile, aggregatorBlock, "utf8");
|
|
152
|
+
relinka(
|
|
153
|
+
"success",
|
|
154
|
+
`Aggregator done: processed ${allLines.length} lines in: ${outFile}`
|
|
155
|
+
);
|
|
150
156
|
}
|
|
151
|
-
await fs.ensureFile(outFile);
|
|
152
|
-
await fs.writeFile(outFile, finalText, "utf8");
|
|
153
|
-
relinka(
|
|
154
|
-
"success",
|
|
155
|
-
`Aggregator done: processed ${allLines.length} lines in: ${outFile}`
|
|
156
|
-
);
|
|
157
157
|
} catch (error) {
|
|
158
158
|
relinka("error", `Aggregator failed: ${error}`);
|
|
159
159
|
process.exit(1);
|
package/bin/app/agg/run.js
CHANGED
|
@@ -33,6 +33,8 @@ export async function promptAggCommand() {
|
|
|
33
33
|
let out = "";
|
|
34
34
|
let recursive = true;
|
|
35
35
|
let strip = "";
|
|
36
|
+
let separateTypesFile = false;
|
|
37
|
+
let typesOut = "";
|
|
36
38
|
if (selectedLibName && selectedLibName !== "") {
|
|
37
39
|
const libConfig = config?.libsList?.[selectedLibName];
|
|
38
40
|
if (config && libConfig) {
|
|
@@ -72,12 +74,24 @@ export async function promptAggCommand() {
|
|
|
72
74
|
defaultValue: strip
|
|
73
75
|
});
|
|
74
76
|
}
|
|
77
|
+
separateTypesFile = await confirmPrompt({
|
|
78
|
+
title: "Do you want to create a separate file for type exports?",
|
|
79
|
+
defaultValue: separateTypesFile
|
|
80
|
+
});
|
|
81
|
+
if (separateTypesFile) {
|
|
82
|
+
typesOut = await inputPrompt({
|
|
83
|
+
title: "Enter the output file for types",
|
|
84
|
+
defaultValue: out.replace(/\.(ts|js)$/, ".types.$1")
|
|
85
|
+
});
|
|
86
|
+
}
|
|
75
87
|
await runCmd(await cmdAgg(), [
|
|
76
88
|
`--imports=${imports}`,
|
|
77
89
|
`--input=${input}`,
|
|
78
90
|
`--named=${named}`,
|
|
79
91
|
`--out=${out}`,
|
|
80
92
|
`--recursive=${recursive}`,
|
|
81
|
-
`--strip=${strip}
|
|
93
|
+
`--strip=${strip}`,
|
|
94
|
+
`--separateTypesFile=${separateTypesFile}`,
|
|
95
|
+
...separateTypesFile ? [`--typesOut=${typesOut}`] : []
|
|
82
96
|
]);
|
|
83
97
|
}
|
package/bin/app/cmds.d.ts
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 👉 `dler rempts init --cmds`
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { cmdAgg } from "./cmds.js";
|
|
7
|
+
* await runCmd(await cmdAgg(), [
|
|
8
|
+
* `--imports=${imports}`,
|
|
9
|
+
* `--input=${input}`,
|
|
10
|
+
* `--named=${named}`,
|
|
11
|
+
* `--out=${out}`,
|
|
12
|
+
* `--recursive=${recursive}`,
|
|
13
|
+
* `--strip=${strip}`,
|
|
14
|
+
* ]);
|
|
15
|
+
*/
|
|
1
16
|
export declare function cmdRelifsoInit(): Promise<import("@reliverse/rempts").Command<{
|
|
2
17
|
dev: {
|
|
3
18
|
type: "boolean";
|
|
@@ -119,6 +134,16 @@ export declare function cmdAgg(): Promise<import("@reliverse/rempts").Command<{
|
|
|
119
134
|
type: "string";
|
|
120
135
|
default: string;
|
|
121
136
|
};
|
|
137
|
+
separateTypesFile: {
|
|
138
|
+
description: string;
|
|
139
|
+
type: "boolean";
|
|
140
|
+
default: false;
|
|
141
|
+
};
|
|
142
|
+
typesOut: {
|
|
143
|
+
description: string;
|
|
144
|
+
type: "string";
|
|
145
|
+
required: false;
|
|
146
|
+
};
|
|
122
147
|
}>>;
|
|
123
148
|
export declare function cmdBuild(): Promise<import("@reliverse/rempts").Command<{
|
|
124
149
|
dev: {
|
|
@@ -132,3 +157,29 @@ export declare function cmdPub(): Promise<import("@reliverse/rempts").Command<{
|
|
|
132
157
|
description: string;
|
|
133
158
|
};
|
|
134
159
|
}>>;
|
|
160
|
+
export declare function cmdRelifsoRename(): Promise<import("@reliverse/rempts").Command<{
|
|
161
|
+
dev: {
|
|
162
|
+
type: "boolean";
|
|
163
|
+
description: string;
|
|
164
|
+
};
|
|
165
|
+
prepareMyCLI: {
|
|
166
|
+
type: "boolean";
|
|
167
|
+
description: string;
|
|
168
|
+
required: false;
|
|
169
|
+
};
|
|
170
|
+
revert: {
|
|
171
|
+
type: "boolean";
|
|
172
|
+
description: string;
|
|
173
|
+
required: false;
|
|
174
|
+
};
|
|
175
|
+
source: {
|
|
176
|
+
type: "string";
|
|
177
|
+
description: string;
|
|
178
|
+
required: false;
|
|
179
|
+
};
|
|
180
|
+
destination: {
|
|
181
|
+
type: "string";
|
|
182
|
+
description: string;
|
|
183
|
+
required: false;
|
|
184
|
+
};
|
|
185
|
+
}>>;
|
package/bin/app/cmds.js
CHANGED
package/bin/app/relifso/cmd.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { relinka } from "@reliverse/relinka";
|
|
2
2
|
import { defineCommand, runCmd, selectPrompt } from "@reliverse/rempts";
|
|
3
|
-
import { cmdRelifsoInit } from "../cmds.js";
|
|
3
|
+
import { cmdRelifsoInit, cmdRelifsoRename } from "../cmds.js";
|
|
4
4
|
export default defineCommand({
|
|
5
5
|
meta: {
|
|
6
6
|
name: "relifso",
|
|
@@ -26,11 +26,23 @@ export default defineCommand({
|
|
|
26
26
|
{
|
|
27
27
|
value: "init",
|
|
28
28
|
label: "Initialize files"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
value: "rename-prepare",
|
|
32
|
+
label: "Rename files (prepare CLI)"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
value: "rename-prepare-revert",
|
|
36
|
+
label: "Rename files (prepare CLI)"
|
|
29
37
|
}
|
|
30
38
|
]
|
|
31
39
|
});
|
|
32
40
|
if (cmd === "init") {
|
|
33
41
|
await runCmd(await cmdRelifsoInit(), []);
|
|
42
|
+
} else if (cmd === "rename-prepare") {
|
|
43
|
+
await runCmd(await cmdRelifsoRename(), ["--prepareMyCLI"]);
|
|
44
|
+
} else if (cmd === "rename-prepare-revert") {
|
|
45
|
+
await runCmd(await cmdRelifsoRename(), ["--prepareMyCLI", "--revert"]);
|
|
34
46
|
}
|
|
35
47
|
}
|
|
36
48
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
declare const _default: import("@reliverse/rempts").Command<{
|
|
2
|
+
dev: {
|
|
3
|
+
type: "boolean";
|
|
4
|
+
description: string;
|
|
5
|
+
};
|
|
6
|
+
prepareMyCLI: {
|
|
7
|
+
type: "boolean";
|
|
8
|
+
description: string;
|
|
9
|
+
required: false;
|
|
10
|
+
};
|
|
11
|
+
revert: {
|
|
12
|
+
type: "boolean";
|
|
13
|
+
description: string;
|
|
14
|
+
required: false;
|
|
15
|
+
};
|
|
16
|
+
source: {
|
|
17
|
+
type: "string";
|
|
18
|
+
description: string;
|
|
19
|
+
required: false;
|
|
20
|
+
};
|
|
21
|
+
destination: {
|
|
22
|
+
type: "string";
|
|
23
|
+
description: string;
|
|
24
|
+
required: false;
|
|
25
|
+
};
|
|
26
|
+
}>;
|
|
27
|
+
export default _default;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { relinka } from "@reliverse/relinka";
|
|
2
|
+
import { defineCommand } from "@reliverse/rempts";
|
|
3
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
|
+
import { rename, access } from "node:fs/promises";
|
|
6
|
+
import { join, dirname, basename, extname } from "node:path";
|
|
7
|
+
async function fileExists(path) {
|
|
8
|
+
try {
|
|
9
|
+
await access(path);
|
|
10
|
+
return true;
|
|
11
|
+
} catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
async function safeRename(source, destination) {
|
|
16
|
+
if (await fileExists(destination)) {
|
|
17
|
+
throw new Error(`Destination file already exists: ${destination}`);
|
|
18
|
+
}
|
|
19
|
+
await rename(source, destination);
|
|
20
|
+
}
|
|
21
|
+
function isCommonJSFile(content) {
|
|
22
|
+
return content.includes("module.exports") || content.includes("require(");
|
|
23
|
+
}
|
|
24
|
+
async function prepareCLIFiles(revert = false) {
|
|
25
|
+
const configPath = ".config/dler.ts";
|
|
26
|
+
let srcDir = "src";
|
|
27
|
+
if (existsSync(configPath)) {
|
|
28
|
+
const configContent = readFileSync(configPath, "utf-8");
|
|
29
|
+
const configMatch = configContent.match(
|
|
30
|
+
/coreEntrySrcDir:\s*["']([^"']+)["']/
|
|
31
|
+
);
|
|
32
|
+
srcDir = configMatch?.[1] ?? srcDir;
|
|
33
|
+
}
|
|
34
|
+
if (!existsSync(srcDir)) {
|
|
35
|
+
throw new Error(`Source directory not found: ${srcDir}`);
|
|
36
|
+
}
|
|
37
|
+
const files = readdirSync(srcDir, { recursive: true, encoding: "utf-8" });
|
|
38
|
+
for (const file of files) {
|
|
39
|
+
const fullPath = join(srcDir, file);
|
|
40
|
+
if (!existsSync(fullPath)) continue;
|
|
41
|
+
const ext = extname(file);
|
|
42
|
+
const baseName = basename(file, ext);
|
|
43
|
+
const dir = dirname(fullPath);
|
|
44
|
+
if (revert) {
|
|
45
|
+
if (file.endsWith(".json.json")) {
|
|
46
|
+
await safeRename(fullPath, join(dir, baseName));
|
|
47
|
+
} else if (file.endsWith(".d.ts.txt")) {
|
|
48
|
+
await safeRename(fullPath, join(dir, `${baseName}.d.ts`));
|
|
49
|
+
} else if (file.endsWith(".cjs")) {
|
|
50
|
+
await safeRename(fullPath, join(dir, `${baseName}.js`));
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
if (file === "tsconfig.json" && !file.endsWith(".json.json")) {
|
|
54
|
+
await safeRename(fullPath, join(dir, "tsconfig.json.json"));
|
|
55
|
+
} else if (file === "package.json" && !file.endsWith(".json.json")) {
|
|
56
|
+
await safeRename(fullPath, join(dir, "package.json.json"));
|
|
57
|
+
} else if (file.endsWith(".d.ts") && !file.endsWith(".d.ts.txt")) {
|
|
58
|
+
await safeRename(fullPath, join(dir, `${baseName}.d.ts.txt`));
|
|
59
|
+
} else if (file.endsWith(".js") && !file.endsWith(".cjs")) {
|
|
60
|
+
const content = readFileSync(fullPath, "utf-8");
|
|
61
|
+
if (isCommonJSFile(content)) {
|
|
62
|
+
await safeRename(fullPath, join(dir, `${baseName}.cjs`));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export default defineCommand({
|
|
69
|
+
meta: {
|
|
70
|
+
name: "rename",
|
|
71
|
+
version: "1.0.0",
|
|
72
|
+
description: "Rename files for CLI preparation"
|
|
73
|
+
},
|
|
74
|
+
args: {
|
|
75
|
+
dev: {
|
|
76
|
+
type: "boolean",
|
|
77
|
+
description: "Runs the CLI in dev mode"
|
|
78
|
+
},
|
|
79
|
+
prepareMyCLI: {
|
|
80
|
+
type: "boolean",
|
|
81
|
+
description: "Prepare CLI by renaming files",
|
|
82
|
+
required: false
|
|
83
|
+
},
|
|
84
|
+
revert: {
|
|
85
|
+
type: "boolean",
|
|
86
|
+
description: "Revert renamed files back to original names",
|
|
87
|
+
required: false
|
|
88
|
+
},
|
|
89
|
+
source: {
|
|
90
|
+
type: "string",
|
|
91
|
+
description: "Source file or directory to rename",
|
|
92
|
+
required: false
|
|
93
|
+
},
|
|
94
|
+
destination: {
|
|
95
|
+
type: "string",
|
|
96
|
+
description: "Destination name for the rename operation",
|
|
97
|
+
required: false
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
async run({ args }) {
|
|
101
|
+
const { prepareMyCLI, revert, source, destination } = args;
|
|
102
|
+
if (prepareMyCLI === true) {
|
|
103
|
+
try {
|
|
104
|
+
await prepareCLIFiles(revert === true);
|
|
105
|
+
relinka("log", "Successfully prepared CLI files");
|
|
106
|
+
} catch (error) {
|
|
107
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
108
|
+
relinka("error", `Error preparing CLI: ${errorMessage}`);
|
|
109
|
+
process.exit(1);
|
|
110
|
+
}
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (!source || !destination) {
|
|
114
|
+
relinka("error", "Usage: dler relifso rename <source> <destination>");
|
|
115
|
+
process.exit(1);
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
await safeRename(source, destination);
|
|
119
|
+
relinka("log", `Successfully renamed '${source}' to '${destination}'`);
|
|
120
|
+
} catch (error) {
|
|
121
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
122
|
+
relinka("error", `Error renaming: ${errorMessage}`);
|
|
123
|
+
process.exit(1);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
package/bin/init/info.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { endPrompt, startPrompt } from "@reliverse/rempts";
|
|
2
|
+
const version = "1.5.2";
|
|
2
3
|
export async function showStartPrompt(isDev) {
|
|
3
4
|
await startPrompt({
|
|
4
5
|
titleColor: "inverse",
|
|
@@ -6,7 +7,7 @@ export async function showStartPrompt(isDev) {
|
|
|
6
7
|
// packageName: getPkgName(),
|
|
7
8
|
// packageVersion: getPkgVersion(),
|
|
8
9
|
packageName: "dler",
|
|
9
|
-
packageVersion:
|
|
10
|
+
packageVersion: version,
|
|
10
11
|
isDev
|
|
11
12
|
});
|
|
12
13
|
}
|