Skip to content

Commit 06d5775

Browse files
committed
fix: clean up resource import paths in injectResourceIntoIndex function
1 parent c5f659f commit 06d5775

3 files changed

Lines changed: 5 additions & 7 deletions

File tree

adminforth/commands/createApp/templates/index.ts.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ export const admin = new AdminForth({
5555
},
5656
],
5757
resources: [
58-
usersResource
58+
usersResource,
5959
],
6060
menu: [
6161
{ type: 'heading', label: 'SYSTEM' },
6262
{
6363
label: 'Users',
6464
icon: 'flowbite:user-solid',
6565
resourceId: 'adminuser'
66-
}
66+
},
6767
],
6868
});
6969

adminforth/commands/createResource/generateResourceFile.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ async function syncResourceColumns(filePath, content, discoveredColumns) {
159159
tabWidth: 2,
160160
useTabs: false,
161161
trailingComma: true,
162-
wrapColumn: 1,
163162
}).code;
164163

165164
await fs.writeFile(filePath, newContent, "utf-8");

adminforth/commands/createResource/injectResourceIntoIndex.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ export async function injectResourceIntoIndex({
2323
let code = await fs.readFile(indexFilePath, "utf-8");
2424
const ast = recast.parse(code, { parser });
2525

26-
const importLine = `import ${resourceId}Resource from "./resources/${table}";`;
26+
const resourceImportPath = `./resources/${table}.js`;
2727
let alreadyImported = false;
2828

2929
recast.visit(ast, {
3030
visitImportDeclaration(path) {
3131
const { node } = path;
3232
if (
3333
n.ImportDeclaration.check(node) &&
34-
node.source.value === `./resources/${table}`
34+
node.source.value === resourceImportPath
3535
) {
3636
alreadyImported = true;
3737
return false;
@@ -49,7 +49,7 @@ export async function injectResourceIntoIndex({
4949
ast.program.body.unshift(
5050
b.importDeclaration(
5151
[b.importDefaultSpecifier(b.identifier(`${resourceId}Resource`))],
52-
b.stringLiteral(`./resources/${table}`)
52+
b.stringLiteral(resourceImportPath)
5353
)
5454
);
5555

@@ -104,7 +104,6 @@ export async function injectResourceIntoIndex({
104104
tabWidth: 2,
105105
useTabs: false,
106106
trailingComma: true,
107-
wrapColumn: 1
108107
}).code;
109108
await fs.writeFile(indexFilePath, newCode, "utf-8");
110109
console.log(`✅ Injected resource "${resourceId}" into index`);

0 commit comments

Comments
 (0)