@reliverse/dler 1.5.3 → 1.5.5
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/relifso/rename/cmd.js +41 -11
- package/bin/init/info.js +1 -1
- package/package.json +1 -1
|
@@ -41,6 +41,7 @@ async function getAllFilesAsync(dir, baseDir = dir, recursive = true) {
|
|
|
41
41
|
return fileList;
|
|
42
42
|
}
|
|
43
43
|
async function prepareCLIFiles(revert = false, recursive = true, useDtsTxtForPrepareMyCLI = false) {
|
|
44
|
+
relinka("log", "Starting CLI file preparation...");
|
|
44
45
|
const configPath = ".config/dler.ts";
|
|
45
46
|
let srcDir = "src";
|
|
46
47
|
if (existsSync(configPath)) {
|
|
@@ -54,36 +55,65 @@ async function prepareCLIFiles(revert = false, recursive = true, useDtsTxtForPre
|
|
|
54
55
|
throw new Error(`Source directory not found: ${srcDir}`);
|
|
55
56
|
}
|
|
56
57
|
const files = await getAllFilesAsync(srcDir, srcDir, recursive);
|
|
58
|
+
relinka("log", `Found ${files.length} files to process.`);
|
|
59
|
+
let renamedCount = 0;
|
|
57
60
|
for (const file of files) {
|
|
58
61
|
const fullPath = join(srcDir, file);
|
|
59
62
|
if (!await fileExists(fullPath)) continue;
|
|
60
63
|
const ext = extname(file);
|
|
64
|
+
const fileName = basename(file);
|
|
61
65
|
const baseName = basename(file, ext);
|
|
62
66
|
const dir = dirname(fullPath);
|
|
67
|
+
relinka("log", `Processing file: ${fullPath}`);
|
|
63
68
|
if (revert) {
|
|
64
69
|
if (file.endsWith(".json.json")) {
|
|
65
|
-
|
|
70
|
+
const originalName = join(dir, fileName.replace(".json.json", ".json"));
|
|
71
|
+
relinka("log", `Reverting ${fullPath} to ${originalName}`);
|
|
72
|
+
await safeRename(fullPath, originalName);
|
|
73
|
+
renamedCount++;
|
|
66
74
|
} else if (file.endsWith(".d.ts.txt") && useDtsTxtForPrepareMyCLI) {
|
|
67
|
-
|
|
75
|
+
const originalName = join(dir, fileName.replace(".d.ts.txt", ".d.ts"));
|
|
76
|
+
relinka("log", `Reverting ${fullPath} to ${originalName}`);
|
|
77
|
+
await safeRename(fullPath, originalName);
|
|
78
|
+
renamedCount++;
|
|
68
79
|
} else if (file.endsWith(".cjs")) {
|
|
69
|
-
|
|
80
|
+
const originalName = join(dir, `${baseName}.js`);
|
|
81
|
+
relinka("log", `Reverting ${fullPath} to ${originalName}`);
|
|
82
|
+
await safeRename(fullPath, originalName);
|
|
83
|
+
renamedCount++;
|
|
70
84
|
}
|
|
71
85
|
} else {
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
await safeRename(fullPath,
|
|
76
|
-
|
|
86
|
+
if (fileName === "tsconfig.json" && !fileName.endsWith(".json.json")) {
|
|
87
|
+
const newName = join(dir, "tsconfig.json.json");
|
|
88
|
+
relinka("log", `Renaming ${fullPath} to ${newName}`);
|
|
89
|
+
await safeRename(fullPath, newName);
|
|
90
|
+
renamedCount++;
|
|
91
|
+
} else if (fileName === "package.json" && !fileName.endsWith(".json.json")) {
|
|
92
|
+
const newName = join(dir, "package.json.json");
|
|
93
|
+
relinka("log", `Renaming ${fullPath} to ${newName}`);
|
|
94
|
+
await safeRename(fullPath, newName);
|
|
95
|
+
renamedCount++;
|
|
96
|
+
} else if (fileName.endsWith(".d.ts") && !fileName.endsWith(".d.ts.txt") && useDtsTxtForPrepareMyCLI) {
|
|
77
97
|
const baseWithoutD = baseName.slice(0, -2);
|
|
78
|
-
|
|
79
|
-
|
|
98
|
+
const newName = join(dir, `${baseWithoutD}.d.ts.txt`);
|
|
99
|
+
relinka("log", `Renaming ${fullPath} to ${newName}`);
|
|
100
|
+
await safeRename(fullPath, newName);
|
|
101
|
+
renamedCount++;
|
|
102
|
+
} else if (fileName.endsWith(".js") && !fileName.endsWith(".cjs")) {
|
|
80
103
|
const content = readFileSync(fullPath, "utf-8");
|
|
81
104
|
if (isCommonJSFile(content)) {
|
|
82
|
-
|
|
105
|
+
const newName = join(dir, `${baseName}.cjs`);
|
|
106
|
+
relinka("log", `Renaming ${fullPath} to ${newName}`);
|
|
107
|
+
await safeRename(fullPath, newName);
|
|
108
|
+
renamedCount++;
|
|
83
109
|
}
|
|
84
110
|
}
|
|
85
111
|
}
|
|
86
112
|
}
|
|
113
|
+
relinka(
|
|
114
|
+
"log",
|
|
115
|
+
`CLI file preparation completed. Renamed ${renamedCount} files.`
|
|
116
|
+
);
|
|
87
117
|
}
|
|
88
118
|
export default defineCommand({
|
|
89
119
|
meta: {
|
package/bin/init/info.js
CHANGED