Replies: 1 comment 1 reply
-
|
The schema generator currently does not add blank lines between column declarations. This is not configurable via a flag. The simplest fix is to run Prettier (or your formatter of choice) on the generated file after generation: node ace generate:schema
npx prettier --write app/models/schema.tsIf you want the blank lines between columns specifically, Prettier alone will not add them — it only handles indentation and line length. But you can use a quick sed/script to insert them: # Add a blank line before every @column decorator
sed -i '/@column/i\\' app/models/schema.tsOr in a more robust way with a small Node script: import { readFile, writeFile } from "fs/promises";
const content = await readFile("app/models/schema.ts", "utf-8");
const formatted = content.replace(/(\n)( @column)/g, "$1\n$2");
await writeFile("app/models/schema.ts", formatted);You could add this as a post-generation hook in your {
"scripts": {
"schema": "node ace generate:schema && node scripts/format-schema.mjs"
}
}Agreed this would be a nice quality-of-life improvement in the generator itself — the docs show it with blank lines, so the output should match. Might be worth opening a PR for it if you are up for it; it would likely be a small change in the code generation template. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a very minor issue, but it bothers and maybe it's possible.
I generated the schema.ts file with
node ace migration:runAnd when looking into it I find it hard to read because there is no line break in the models between the columns, eg:
Which is funny because in the documentation the line break is present https://lucid.adonisjs.com/docs/schema-classes#step-3-examine-the-generated-schema-class
Is there a flag to do that ? Maybe with prettier ?
This is minor but since we're going to read and use this file over and over this could be a nice benefit over time.
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions