Node 24, non-interactive mode, sdk v21.2.0, pages generation#118
Open
writepavel wants to merge 3 commits intonuxtus:mainfrom
Open
Node 24, non-interactive mode, sdk v21.2.0, pages generation#118writepavel wants to merge 3 commits intonuxtus:mainfrom
writepavel wants to merge 3 commits intonuxtus:mainfrom
Conversation
- Change assert { type: 'json' } to with { type: 'json' } (Node 24)
- Fix CLI.default.Spinner for clui CJS/ESM interop (Node 24)
- Add process.exit() handlers to all command actions (SDK keeps connections alive)
- Add await to createTypes() call in types command
- Normalize getCollections() response for SDK v21 (flat array vs {data:[]})
- Add --collection/-c option for non-interactive page creation
- Add --quiet/-q option for banner-suppressed types generation
- Add createPages() helper with not-found error handling
- Fix token command: don't modify .env if generateStaticToken() fails
2ad99ee to
d92836d
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the CLI for newer Node/Directus compatibility and adds more script-friendly command behavior. It mainly adapts runtime interop for Node 24, normalizes collection handling for newer SDK responses, and introduces new non-interactive CLI options.
Changes:
- Update runtime compatibility details, including JSON import syntax, clui interop, and SDK-related collection handling.
- Add script-oriented CLI behavior such as
create --collectionandtypes --quiet, plus explicit process exits for command actions. - Harden command flows by awaiting type generation and avoiding
.envedits when token registration fails.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| src/commands/types.ts | Updates spinner interop and awaits type generation completion. |
| src/commands/token.ts | Changes token failure handling to avoid modifying local config on registration errors. |
| src/commands/create.ts | Adds non-interactive page generation flow and SDK response normalization. |
| src/cli.ts | Wires new CLI flags, JSON import syntax, and explicit exit handling for commands. |
| README.md | Documents the new non-interactive CLI usage. |
| package.json | Bumps package version and updates dependency ranges/SDK version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+48
to
+55
| .option('-c, --collection <name>', 'Collection name (repeatable)', collect, [] as string[]) | ||
| .action((opts: any) => { | ||
| const isNonInteractive = opts.collection && opts.collection.length > 0 | ||
| if (!isNonInteractive) { | ||
| clear() | ||
| console.info(chalk.green(figlet.textSync("nuxtus-cli", { horizontalLayout: "full" }))) | ||
| } | ||
| return create(chalk, undefined, opts.collection) |
Comment on lines
+63
to
+68
| .option('-q, --quiet', 'Suppress banner for scripted use') | ||
| .action((opts: any) => { | ||
| if (!opts.quiet) { | ||
| clear() | ||
| console.info(chalk.green(figlet.textSync("nuxtus-cli", { horizontalLayout: "full" }))) | ||
| } |
Comment on lines
+55
to
+57
| return create(chalk, undefined, opts.collection) | ||
| .then(() => process.exit(0)) | ||
| .catch(() => process.exit(1)) |
| clear() | ||
| console.info(chalk.green(figlet.textSync("nuxtus-cli", { horizontalLayout: "full" }))) | ||
| } | ||
| return types(chalk).then(() => process.exit(0)).catch(() => process.exit(1)) |
Comment on lines
+32
to
+36
| const notFound = collectionNames.filter( | ||
| (name: string) => !filteredCollections.find((o: any) => o.collection === name) | ||
| ) | ||
| if (notFound.length > 0) { | ||
| console.error(localChalk.red(`Collection(s) not found: ${notFound.join(", ")}`)) |
Comment on lines
+100
to
+102
| if (requestedCollections && requestedCollections.length > 0) { | ||
| await createPages(requestedCollections, filteredCollections, nuxtus, localChalk) | ||
| return |
| throw new Error(`Unable to save token to Directus. ${err}`) | ||
| } catch (err: any) { | ||
| console.error(chalk.red(`Unable to register token with Directus. .env not modified. ${err.message || err}`)) | ||
| return |
Comment on lines
+23
to
+25
| } catch (err: any) { | ||
| console.error(chalk.red(`Unable to register token with Directus. .env not modified. ${err.message || err}`)) | ||
| return |
Comment on lines
+73
to
+76
| const collectionData: any = await nuxtus.getCollections() | ||
| const allCollections = Array.isArray(collectionData) | ||
| ? collectionData | ||
| : (collectionData.data || []) |
| "Create static token and use for authentication instead of email/password." | ||
| ) | ||
| .action(() => token(chalk)) | ||
| .action(() => token(chalk).then(() => process.exit(0)).catch(() => process.exit(1))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change assert { type: 'json' } to with { type: 'json' } (Node 24)
Fix CLI.default.Spinner for clui CJS/ESM interop (Node 24)
Add process.exit() handlers to all command actions (SDK keeps connections alive)
Add await to createTypes() call in types command
Normalize getCollections() response for SDK v21.2.0 (flat array vs {data:[]})
Add --collection/-c option for non-interactive page creation
Add --quiet/-q option for banner-suppressed types generation
Add createPages() helper with not-found error handling
Fix token command: don't modify .env if generateStaticToken() fails