Skip to content

Node 24, non-interactive mode, sdk v21.2.0, pages generation#118

Open
writepavel wants to merge 3 commits intonuxtus:mainfrom
resultcrafter:feat/upstream-package-refresh-and-sdk-v21
Open

Node 24, non-interactive mode, sdk v21.2.0, pages generation#118
writepavel wants to merge 3 commits intonuxtus:mainfrom
resultcrafter:feat/upstream-package-refresh-and-sdk-v21

Conversation

@writepavel
Copy link
Copy Markdown

@writepavel writepavel commented Apr 30, 2026

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

- 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
@writepavel writepavel force-pushed the feat/upstream-package-refresh-and-sdk-v21 branch from 2ad99ee to d92836d Compare May 1, 2026 08:36
@craigharman craigharman requested a review from Copilot May 5, 2026 01:27
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 --collection and types --quiet, plus explicit process exits for command actions.
  • Harden command flows by awaiting type generation and avoiding .env edits 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 thread src/cli.ts
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 thread src/cli.ts
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 thread src/cli.ts
Comment on lines +55 to +57
return create(chalk, undefined, opts.collection)
.then(() => process.exit(0))
.catch(() => process.exit(1))
Comment thread src/cli.ts
clear()
console.info(chalk.green(figlet.textSync("nuxtus-cli", { horizontalLayout: "full" })))
}
return types(chalk).then(() => process.exit(0)).catch(() => process.exit(1))
Comment thread src/commands/create.ts
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 thread src/commands/create.ts
Comment on lines +100 to +102
if (requestedCollections && requestedCollections.length > 0) {
await createPages(requestedCollections, filteredCollections, nuxtus, localChalk)
return
Comment thread src/commands/token.ts
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 thread src/commands/token.ts
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 thread src/commands/create.ts
Comment on lines +73 to +76
const collectionData: any = await nuxtus.getCollections()
const allCollections = Array.isArray(collectionData)
? collectionData
: (collectionData.data || [])
Comment thread src/cli.ts
"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)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants