adminforth 1.11.5-next.10 → 1.11.5-next.11
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/commands/utils.js +18 -8
- package/package.json +1 -1
package/commands/utils.js
CHANGED
|
@@ -56,18 +56,20 @@ export const findInstance = (fileContent) => {
|
|
|
56
56
|
return matches[0][2];
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function processJsFilesInDir(directory) {
|
|
60
60
|
const files = fs.readdirSync(directory);
|
|
61
61
|
|
|
62
62
|
files.forEach((file) => {
|
|
63
63
|
const filePath = path.join(directory, file);
|
|
64
64
|
|
|
65
65
|
if (fs.statSync(filePath).isDirectory()) {
|
|
66
|
-
|
|
66
|
+
processJsFilesInDir(filePath);
|
|
67
67
|
} else if (file.endsWith(".js")) {
|
|
68
68
|
try {
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
let fileContent = fs.readFileSync(filePath, "utf-8");
|
|
70
|
+
|
|
71
|
+
// Add .js to relative imports if missing
|
|
72
|
+
fileContent = fileContent.replace(
|
|
71
73
|
/import (.+?) from ["'](.+?)["'];/g,
|
|
72
74
|
(match, imports, modulePath) => {
|
|
73
75
|
if (
|
|
@@ -79,7 +81,16 @@ function processAllJsFilesInDir(directory) {
|
|
|
79
81
|
return match;
|
|
80
82
|
}
|
|
81
83
|
);
|
|
82
|
-
|
|
84
|
+
|
|
85
|
+
// Remove /index.js from imports
|
|
86
|
+
fileContent = fileContent.replace(
|
|
87
|
+
/import (.+?) from ["'](.+?)\/index\.js["'];/g,
|
|
88
|
+
(match, imports, modulePath) => {
|
|
89
|
+
return `import ${imports} from "${modulePath}";`;
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
fs.writeFileSync(filePath, fileContent, "utf-8");
|
|
83
94
|
} catch (error) {
|
|
84
95
|
console.error(`Error processing file '${filePath}':`, error);
|
|
85
96
|
}
|
|
@@ -101,11 +112,10 @@ export async function getInstance(file, currentDirectory) {
|
|
|
101
112
|
}
|
|
102
113
|
);
|
|
103
114
|
} catch (error) {
|
|
104
|
-
console.log(`Error: Could not compile TypeScript file '${file}'`);
|
|
115
|
+
//console.log(`Error: Could not compile TypeScript file '${file}'`);
|
|
105
116
|
}
|
|
106
|
-
|
|
107
117
|
const distDir = path.join(currentDirectory, "dist");
|
|
108
|
-
|
|
118
|
+
processJsFilesInDir(distDir);
|
|
109
119
|
|
|
110
120
|
filePath = filePath
|
|
111
121
|
.replace(".ts", ".js")
|