adminforth 1.5.8-next.1 → 1.5.8-next.3

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.
Files changed (2) hide show
  1. package/commands/utils.js +17 -2
  2. package/package.json +1 -1
package/commands/utils.js CHANGED
@@ -58,7 +58,7 @@ export const findInstance = (fileContent) => {
58
58
 
59
59
  export async function getInstance(file, currentDirectory) {
60
60
  const initialFilePath = path.join(currentDirectory, file);
61
- let filePath = path.join(currentDirectory, file);
61
+ let filePath = initialFilePath;
62
62
 
63
63
  if (file.endsWith(".ts")) {
64
64
  console.log(`Compiling TypeScript file: ${file}`);
@@ -76,11 +76,26 @@ export async function getInstance(file, currentDirectory) {
76
76
  filePath = filePath
77
77
  .replace(".ts", ".js")
78
78
  .replace(currentDirectory, path.join(currentDirectory, "dist"));
79
+
80
+ try {
81
+ const compiledContent = fs.readFileSync(filePath, "utf-8");
82
+ const updatedContent = compiledContent.replace(
83
+ /import (.+?) from ["'](.+?)["'];/g,
84
+ (match, imports, modulePath) => {
85
+ if (!modulePath.endsWith(".js") && (modulePath.startsWith("./") || modulePath.startsWith("../"))) {
86
+ return `import ${imports} from "${modulePath}.js";`; // Append .js to local imports
87
+ }
88
+ return match;
89
+ }
90
+ );
91
+ fs.writeFileSync(filePath, updatedContent, "utf-8");
92
+ } catch (error) {
93
+ console.error("Error during post-processing:", error);
94
+ }
79
95
  }
80
96
 
81
97
  const fileContent = fs.readFileSync(initialFilePath, "utf-8");
82
98
  const instanceName = findInstance(fileContent);
83
-
84
99
  if (instanceName) {
85
100
  try {
86
101
  const module = await import(`file://${filePath}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "1.5.8-next.1",
3
+ "version": "1.5.8-next.3",
4
4
  "description": "OpenSource Vue3 powered forth-generation admin panel",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",