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