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