Skip to content

Commit

Permalink
feat: Optimize file IO and add max-depth option (#67)
Browse files Browse the repository at this point in the history
* Convert file IO to use more optimized functions

* Max depth and pagination fix

* Update cli args
  • Loading branch information
bcanfield committed Aug 17, 2023
1 parent 139e309 commit 540af5a
Show file tree
Hide file tree
Showing 7 changed files with 1,368 additions and 1,258 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ npx prisma generate
| output | Path to output directory | nexquikApp | false |
| include | Comma-separated list of model names to include from the top-level of the generated app | | false |
| exclude | Comma-separated list of model names to exclude from the top-level of the generated app (NOTE: If the 'include' option is used, this exclusion list will be ignored) | | false |
| depth | Maximum recursion depth for your models. (Changing this for large data models is not recommended, unless you filter down your models with the 'include' or 'exclude' flags also.) | 5 | false |


## Examples
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dev": "nodemon",
"dev:1": "npm run build",
"dev:2": "rm -f ./nexquik.tgz && rm -rf devNexquikApp",
"dev:3": "npm pack --silent",
"dev:3": "npm pack",
"dev:4": "mv \"$(ls *.tgz)\" \"nexquik.tgz\"",
"dev:5": "npm i && npm i --save-dev ./nexquik.tgz ",
"dev:6": "nexquik -output ./devNexquikApp -schema ./prisma/schema.prisma",
Expand Down
1,400 changes: 700 additions & 700 deletions prisma_large/massiveSchema.prisma

Large diffs are not rendered by default.

17 changes: 11 additions & 6 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ export async function run(options?: GeneratorOptions) {
"Comma-separated list of model names to include from the top-level of the generated app.",
""
)
.option(
"-depth <value>",
"Maximum recursion depth for your models. (Changing this for large data models is not recommended, unless you filter down your models with the 'include' or 'exclude' flags also.)",
"5"
)
.parse(process.argv);

const cliArgs = program.opts();
Expand All @@ -58,6 +63,8 @@ export async function run(options?: GeneratorOptions) {
: options?.generator.config.include
? String(options.generator.config.include).split(",")
: [];
const maxDepth = parseInt(options?.generator.config.depth || cliArgs.Depth);

const excludedModels =
includedModels.length > 0
? []
Expand All @@ -76,13 +83,11 @@ export async function run(options?: GeneratorOptions) {
prismaSchemaPath,
outputDirectory,
excludedModels,
includedModels
includedModels,
maxDepth
);
const spinner = ora(
`${chalk.blue.bold("Linting and Formatting Generated Files...")}\n`
).start();
await formatDirectory(outputDirectory);
spinner.succeed(chalk.green.bold(`Linted and Formatted Generated Files`));

// await formatDirectory(outputDirectory);

console.log(
`${chalk.green.bold(
Expand Down
Loading

0 comments on commit 540af5a

Please sign in to comment.