@nexusts/cli 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +2 -2
  2. package/dist/commands/config.d.ts +43 -0
  3. package/dist/commands/db-generate.d.ts +19 -0
  4. package/dist/commands/db-migrate.d.ts +32 -0
  5. package/dist/commands/db-seed.d.ts +42 -0
  6. package/dist/commands/index.d.ts +10 -0
  7. package/dist/commands/info.d.ts +10 -0
  8. package/dist/commands/init.d.ts +37 -0
  9. package/dist/commands/make-auth.d.ts +16 -0
  10. package/dist/commands/make-controller.d.ts +15 -0
  11. package/dist/commands/make-crud.d.ts +27 -0
  12. package/dist/commands/make-listener.d.ts +14 -0
  13. package/dist/commands/make-middleware.d.ts +6 -0
  14. package/dist/commands/make-migration.d.ts +20 -0
  15. package/dist/commands/make-model.d.ts +21 -0
  16. package/dist/commands/make-module.d.ts +10 -0
  17. package/dist/commands/make-queue.d.ts +16 -0
  18. package/dist/commands/make-schedule.d.ts +16 -0
  19. package/dist/commands/make-service.d.ts +6 -0
  20. package/dist/commands/make-session.d.ts +14 -0
  21. package/dist/commands/make-validator.d.ts +6 -0
  22. package/dist/commands/new.d.ts +13 -0
  23. package/dist/commands/repl.d.ts +41 -0
  24. package/dist/commands/route-list.d.ts +11 -0
  25. package/dist/core/args.d.ts +28 -0
  26. package/dist/core/config.d.ts +136 -0
  27. package/dist/core/fs.d.ts +37 -0
  28. package/dist/core/index.d.ts +42 -0
  29. package/dist/core/logger.d.ts +45 -0
  30. package/dist/core/loose-json.d.ts +25 -0
  31. package/dist/core/prompts.d.ts +21 -0
  32. package/dist/core/template.d.ts +25 -0
  33. package/dist/index.d.ts +21 -0
  34. package/dist/index.js +1290 -1091
  35. package/dist/index.js.map +37 -33
  36. package/dist/templates/controller/adonis.d.ts +9 -0
  37. package/dist/templates/controller/functional.d.ts +8 -0
  38. package/dist/templates/controller/nest.d.ts +16 -0
  39. package/dist/templates/crud/controller.d.ts +7 -0
  40. package/dist/templates/crud/dto.d.ts +7 -0
  41. package/dist/templates/crud/module.d.ts +5 -0
  42. package/dist/templates/crud/test.d.ts +9 -0
  43. package/dist/templates/index.d.ts +38 -0
  44. package/dist/templates/middleware/middleware.d.ts +7 -0
  45. package/dist/templates/migration/drizzle.d.ts +11 -0
  46. package/dist/templates/migration/sql.d.ts +9 -0
  47. package/dist/templates/model/drizzle-dialect.d.ts +28 -0
  48. package/dist/templates/model/drizzle.d.ts +13 -0
  49. package/dist/templates/model/kysely.d.ts +11 -0
  50. package/dist/templates/model/prisma.d.ts +11 -0
  51. package/dist/templates/module/module.d.ts +15 -0
  52. package/dist/templates/project/drizzle.config.d.ts +11 -0
  53. package/dist/templates/project/nx.config.d.ts +6 -0
  54. package/dist/templates/repository/repository.d.ts +12 -0
  55. package/dist/templates/service/service.d.ts +11 -0
  56. package/dist/templates/validator/validator.d.ts +7 -0
  57. package/package.json +6 -11
package/README.md CHANGED
@@ -15,7 +15,7 @@ This module is part of the NexusTS monorepo. Each module is published as its own
15
15
  Most apps start with just the core:
16
16
 
17
17
  ```bash
18
- bun add @nexusts/core reflect-metadata zod hono
18
+ bun add @nexusts/core
19
19
  ```
20
20
 
21
21
  Then add this module only if you need it:
@@ -26,7 +26,7 @@ bun add @nexusts/cli
26
26
 
27
27
  ## Peer dependencies
28
28
 
29
- None. This module is fully self-contained.
29
+ **None.** No external dependencies. The `nx` binary is bundled with `@nexusts/core`.
30
30
 
31
31
  ## Usage
32
32
 
@@ -0,0 +1,43 @@
1
+ /**
2
+ * `nx config` — update or create nx.config.ts (+ drizzle.config.ts
3
+ * if Drizzle is selected).
4
+ *
5
+ * Companion to `nx init`:
6
+ * - `nx init` → scaffold the whole project (config + src/app + README)
7
+ * - `nx config` → only the config files; idempotent
8
+ *
9
+ * Behaviour:
10
+ * - If nx.config.ts exists, parses the current values, merges
11
+ * with any flag values (flags win), and re-renders.
12
+ * - If it does not exist, creates it from scratch with the
13
+ * provided (or prompted) values.
14
+ * - If ORM is `drizzle`, also writes drizzle.config.ts.
15
+ * - If ORM is NOT `drizzle`, an existing drizzle.config.ts is
16
+ * left alone (the user may have it intentionally).
17
+ *
18
+ * Typical use cases:
19
+ * - "I want to switch from bun-sqlite to postgres"
20
+ * → nx config --db postgres
21
+ * - "I want to add Drizzle to an existing project"
22
+ * → nx config --orm drizzle
23
+ * - "I want to change the Inertia frontend from React to Vue"
24
+ * → nx config --frontend vue
25
+ * - "I haven't decided yet, just show me the prompts"
26
+ * → nx config --no-interaction=false
27
+ *
28
+ * Flags:
29
+ * --target <dir> Target directory (default: cwd)
30
+ * --style <name> Routing style (nest|adonis|functional)
31
+ * --view <name> View engine (rendu|edge|inertia|none)
32
+ * --orm <name> ORM driver (drizzle|prisma|kysely|none)
33
+ * --db <name> Database driver
34
+ * --db-url <url> Database URL (used when DATABASE_URL is unset)
35
+ * --frontend <name> Inertia frontend (react|vue|svelte|solid)
36
+ * --ssr Enable Inertia SSR
37
+ * --no-ssr Disable Inertia SSR
38
+ * --force Overwrite even if file already exists
39
+ * --no-interaction Skip interactive prompts
40
+ */
41
+ import type { Command } from "../core/index.js";
42
+ export declare const configCommand: Command;
43
+ export default configCommand;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * `nx db:generate <name>` — generate a new migration file from schema changes.
3
+ *
4
+ * Wraps `drizzle-kit generate` with the project's config, so you
5
+ * don't need to pass `--config` every time.
6
+ *
7
+ * Examples:
8
+ * nx db:generate add_users_table
9
+ * nx db:generate add_posts_table --dialect postgres
10
+ * nx db:generate --sql # raw SQL file (no drizzle-kit)
11
+ *
12
+ * See also:
13
+ * nx db:migrate — apply pending migrations
14
+ * nx db:seed — run database seeds
15
+ * nx make:migration — scaffold an empty migration file
16
+ */
17
+ import type { Command } from "../core/index.js";
18
+ export declare const dbGenerateCommand: Command;
19
+ export default dbGenerateCommand;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * `nx db:migrate` — apply pending database migrations.
3
+ *
4
+ * Two modes:
5
+ *
6
+ * 1. **Default**: scan the project's `nx.config.ts` for
7
+ * `paths.migrations` and run every pending file through the
8
+ * drizzle-kit-equivalent migrator path.
9
+ *
10
+ * Implementation: spawns `bunx drizzle-kit migrate` if the
11
+ * drizzle-kit binary is on PATH; otherwise runs an in-process
12
+ * migration script that uses `nexusjs/drizzle`'s
13
+ * `db.migrate(folder)` directly.
14
+ *
15
+ * 2. **`--status`**: list applied migrations + pending count.
16
+ *
17
+ * 3. **`--generate "<name>"`**: wrapper around `drizzle-kit
18
+ * generate` — useful when you want to commit a migration file
19
+ * but prefer the `nx` alias over the bare command.
20
+ *
21
+ * Examples:
22
+ * nx db:migrate
23
+ * nx db:migrate --status
24
+ * nx db:migrate --generate "add_user_email"
25
+ * nx db:migrate --folder ./drizzle --dialect postgres
26
+ *
27
+ * See also: `nx db:seed` for inserting fixture data.
28
+ */
29
+ import type { Command } from "../core/index.js";
30
+ export declare const dbMigrateCommand: Command;
31
+ export declare function runDrizzleKit(cwd: string, args: string[]): Promise<number>;
32
+ export default dbMigrateCommand;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * `nx db:seed` — run database seed scripts.
3
+ *
4
+ * Seeds are TypeScript (or JavaScript) files that populate the
5
+ * database with fixture data. The command:
6
+ *
7
+ * 1. Scans the configured `seeds` directory (default
8
+ * `./db/seeds` — overridable via `paths.seeds` in
9
+ * `nx.config.ts`).
10
+ * 2. Loads every `*.ts` (or `*.js` / `*.mjs`) file in
11
+ * alphabetical order.
12
+ * 3. Invokes the default export as an async function, passing
13
+ * a `SeedContext` that exposes the active DrizzleService,
14
+ * logger, and a few helpers (see below).
15
+ *
16
+ * Examples:
17
+ * nx db:seed # run all seeds in db/seeds/
18
+ * nx db:seed --file 01_users # run a single seed
19
+ * nx db:seed --reset # clear all tables first (DESTRUCTIVE)
20
+ * nx db:seed --create users # scaffold a new seed file
21
+ * nx db:seed --folder ./seeds # custom folder
22
+ *
23
+ * Seed file example:
24
+ *
25
+ * // db/seeds/01_users.ts
26
+ * import type { SeedContext } from "@nexusts/cli";
27
+ *
28
+ * export default async function seed(ctx: SeedContext) {
29
+ * await ctx.db.insert(users).values([
30
+ * { email: "alice@example.com" },
31
+ * { email: "bob@example.com" },
32
+ * ]);
33
+ * ctx.logger.info(`Inserted 2 users`);
34
+ * }
35
+ *
36
+ * The "01_users.ts" naming convention (zero-padded numbers as
37
+ * prefixes) is recommended but not required — alphabetical
38
+ * ordering is the only rule.
39
+ */
40
+ import type { Command } from "../core/index.js";
41
+ export declare const dbSeedCommand: Command;
42
+ export default dbSeedCommand;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * CLI command registry. Imported by `src/cli/index.ts`.
3
+ *
4
+ * Each command is a `Command` object (see `core/index.ts`). The order
5
+ * here is the order commands appear in `nx help`.
6
+ */
7
+ import type { Command } from "../core/index.js";
8
+ export declare const commands: Command[];
9
+ /** Look up a command by primary name OR by any alias. */
10
+ export declare function findCommand(name: string): Command | undefined;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * `nx info` — print the resolved project configuration.
3
+ *
4
+ * Useful for debugging the config layer: shows which `nx.config.ts`
5
+ * file was loaded, the resolved config (with env overrides), and the
6
+ * current environment values that affect the CLI.
7
+ */
8
+ import type { Command } from "../core/index.js";
9
+ export declare const infoCommand: Command;
10
+ export default infoCommand;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * `nx init [dir]` — scaffold NexusTS into the current (or target) directory.
3
+ *
4
+ * Unlike `nx new <name>` — which requires a fresh, empty directory —
5
+ * `nx init` is non-destructive: it skips files that already exist,
6
+ * preserves the user's existing `package.json` (only adding the
7
+ * `nexusjs` dependency if missing), and merges its `tsconfig.json`
8
+ * additions into the user's existing config.
9
+ *
10
+ * The matching pattern from other ecosystems:
11
+ * - `bun init` / `npm init` → init in the current directory
12
+ * - `cargo init` → init in the current directory
13
+ * - `nx new <name>` → create a fresh project in a new dir
14
+ *
15
+ * Typical use case: the user already ran `bun init` (or has an
16
+ * existing app) and now wants to add NexusTS to it without losing
17
+ * their existing setup.
18
+ *
19
+ * $ bun init
20
+ * $ bun add nexusjs
21
+ * $ nx init
22
+ * $ bun run dev
23
+ *
24
+ * Flags:
25
+ * --target <dir> Scaffold into <dir> instead of the cwd
26
+ * --style <name> Routing style (nest|adonis|functional)
27
+ * --view <name> View engine (rendu|edge|eta|inertia|none)
28
+ * --orm <name> ORM driver (drizzle|prisma|kysely|none)
29
+ * --db <name> Database driver (bun-sqlite|node-sqlite|libsql|postgres|mysql|none)
30
+ * --frontend <name> Inertia frontend (react|vue|svelte|solid)
31
+ * --no-ssr Disable Inertia SSR
32
+ * --force Overwrite existing files
33
+ * --no-interaction Disable interactive prompts
34
+ */
35
+ import type { Command } from "../core/index.js";
36
+ export declare const initCommand: Command;
37
+ export default initCommand;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * `nx make:auth` — scaffold an auth module.
3
+ *
4
+ * Generates:
5
+ * - app/auth/auth.ts — better-auth instance
6
+ * - app/auth/auth.module.ts — NexusTS module (or copy if exists)
7
+ * - app/auth/.env.example — BETTER_AUTH_SECRET / URL placeholders
8
+ * - patches nx.config.ts to include the `auth` section (with --update-config)
9
+ *
10
+ * Usage:
11
+ * nx make:auth --provider github,google --jwt --passkey
12
+ * nx make:auth --provider github --jwt --no-passkey
13
+ */
14
+ import type { Command } from "../core/index.js";
15
+ export declare const makeAuthCommand: Command;
16
+ export default makeAuthCommand;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * `nx make:controller <Name>` — generate a controller file.
3
+ *
4
+ * The template is chosen from `nx.config.ts`'s `routing` field:
5
+ * - `nest` → @Controller / @Get / @Post class
6
+ * - `adonis` → plain class with methods (registered via route table)
7
+ * - `functional` → object of Hono-native handlers
8
+ *
9
+ * Usage:
10
+ * nx make:controller User
11
+ * nx make:controller Post --style nest --no-service
12
+ */
13
+ import type { Command } from "../core/index.js";
14
+ export declare const makeControllerCommand: Command;
15
+ export default makeControllerCommand;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * `nx make:crud <Name>` — generate a full CRUD scaffold for a resource.
3
+ *
4
+ * Mirrors Ruby on Rails' `rails generate scaffold`:
5
+ *
6
+ * nx make:crud Post
7
+ *
8
+ * Produces (under app/):
9
+ *
10
+ * controllers/post.controller.ts — RESTful routes (Nest/Adonis/Functional)
11
+ * services/post.service.ts — business logic
12
+ * repositories/post.repository.ts — DB access (only if orm !== 'none')
13
+ * models/post.model.ts — table schema (only if orm !== 'none')
14
+ * dto/post.dto.ts — Zod validation schemas
15
+ * modules/post.module.ts — @Module({...}) wiring
16
+ * tests/post.test.ts — Vitest integration test
17
+ *
18
+ * The output adapts to `nx.config.ts`:
19
+ * - routing → controller template
20
+ * - view → emits Inertia render() when 'inertia', otherwise plain JSON
21
+ * - orm → Drizzle/Prisma/Kysely template selection
22
+ *
23
+ * Use `--no-views` to skip view-aware parts even when `view === 'inertia'`.
24
+ */
25
+ import type { Command } from "../core/index.js";
26
+ export declare const makeCrudCommand: Command;
27
+ export default makeCrudCommand;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * `nx make:listener <Name>` — scaffold an event listener class.
3
+ *
4
+ * Generates:
5
+ * - app/events/listeners/<name>.listener.ts
6
+ * — an @Injectable class with example @OnEvent handlers
7
+ *
8
+ * Usage:
9
+ * nx make:listener UserEvents
10
+ * nx make:listener OrderEvents --pattern "order.*"
11
+ */
12
+ import type { Command } from "../core/index.js";
13
+ export declare const makeListenerCommand: Command;
14
+ export default makeListenerCommand;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * `nx make:middleware <Name>` — generate a middleware class.
3
+ */
4
+ import type { Command } from "../core/index.js";
5
+ export declare const makeMiddlewareCommand: Command;
6
+ export default makeMiddlewareCommand;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * `nx make:migration <Name>` — generate a database migration.
3
+ *
4
+ * Filename pattern: `YYYYMMDD_HHmmss_<snake>.sql` (or `.ts` for
5
+ * Drizzle). The file is placed under the configured `paths.migrations`
6
+ * directory.
7
+ *
8
+ * Drizzle dialect is chosen via `--dialect` (postgres | mysql | sqlite
9
+ * | bun-sqlite | d1) or `nx.config.ts`'s `dialect` field. Default: bun-sqlite.
10
+ *
11
+ * Drizzle migrations are TypeScript files that export a `pgTable` /
12
+ * `mysqlTable` / `sqliteTable` definition — the same shape as
13
+ * `nx make:model` — and are loaded by the Drizzle migrator at runtime.
14
+ *
15
+ * Plain SQL migrations work for any dialect that uses Drizzle's
16
+ * migrator (postgres-js / node-postgres / mysql2 / better-sqlite3).
17
+ */
18
+ import type { Command } from "../core/index.js";
19
+ export declare const makeMigrationCommand: Command;
20
+ export default makeMigrationCommand;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * `nx make:model <Name>` — generate a model (table schema).
3
+ *
4
+ * Supports three ORMs via `nx.config.ts`'s `orm` field:
5
+ * - drizzle → Drizzle table definition (dialect-aware)
6
+ * - prisma → schema.prisma block + typed repository
7
+ * - kysely → table interface + typed repository
8
+ *
9
+ * For Drizzle, the `--dialect` flag selects the right import path and
10
+ * column types: postgres | mysql | sqlite | bun-sqlite | d1. Default
11
+ * is `bun-sqlite` (the typical Bun + local-dev setup).
12
+ *
13
+ * Columns are read from the optional `--columns` flag as a comma-separated
14
+ * list of `name:type` pairs:
15
+ *
16
+ * nx make:model User --columns "name:text,email:text,bio:text"
17
+ * nx make:model Post --orm drizzle --dialect postgres --columns "title:text,body:text,published:boolean"
18
+ */
19
+ import type { Command } from "../core/index.js";
20
+ export declare const makeModelCommand: Command;
21
+ export default makeModelCommand;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * `nx make:module <Name>` — generate a feature module.
3
+ *
4
+ * A module aggregates a controller, service, and (optionally) a
5
+ * repository under a single `@Module({ controllers, providers, exports })`
6
+ * class.
7
+ */
8
+ import type { Command } from "../core/index.js";
9
+ export declare const makeModuleCommand: Command;
10
+ export default makeModuleCommand;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * `nx make:queue <Name>` — scaffold a queue worker.
3
+ *
4
+ * Generates:
5
+ * - app/queue/workers/<name>.worker.ts — @OnQueueReady handler class
6
+ * - app/queue/jobs/<name>.job.ts — a `enqueue*` helper for callers
7
+ * - prints wiring instructions
8
+ *
9
+ * Usage:
10
+ * nx make:queue send-welcome-email --backend bullmq
11
+ * nx make:queue process-image --backend cloudflare
12
+ * nx make:queue notify --backend memory
13
+ */
14
+ import type { Command } from "../core/index.js";
15
+ export declare const makeQueueCommand: Command;
16
+ export default makeQueueCommand;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * `nx make:schedule <Name>` — scaffold a scheduled task class.
3
+ *
4
+ * Generates:
5
+ * - app/schedule/tasks/<name>.task.ts
6
+ * — an @Injectable class with example @Cron / @Interval /
7
+ * @Timeout handlers
8
+ *
9
+ * Usage:
10
+ * nx make:schedule HourlyCleanup
11
+ * nx make:schedule DailyDigest --cron "@daily"
12
+ * nx make:schedule Heartbeat --interval 30000
13
+ */
14
+ import type { Command } from "../core/index.js";
15
+ export declare const makeScheduleCommand: Command;
16
+ export default makeScheduleCommand;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * `nx make:service <Name>` — generate a service class.
3
+ */
4
+ import type { Command } from "../core/index.js";
5
+ export declare const makeServiceCommand: Command;
6
+ export default makeServiceCommand;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * `nx make:session <Name>` — scaffold a session helper class.
3
+ *
4
+ * Generates:
5
+ * - app/session/services/<name>.session.ts
6
+ * — an @Injectable class with example session helpers
7
+ *
8
+ * Usage:
9
+ * nx make:session Cart
10
+ * nx make:session Flash --data "message: string"
11
+ */
12
+ import type { Command } from "../core/index.js";
13
+ export declare const makeSessionCommand: Command;
14
+ export default makeSessionCommand;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * `nx make:validator <Name>` — generate a Zod validation schema (DTO).
3
+ */
4
+ import type { Command } from "../core/index.js";
5
+ export declare const makeValidatorCommand: Command;
6
+ export default makeValidatorCommand;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * `nx new <name>` — scaffold a new project.
3
+ *
4
+ * Creates a fresh directory with `nx.config.ts`, `package.json`,
5
+ * `tsconfig.json`, `app/main.ts`, and a README. Useful as a
6
+ * starting point for kicking off a new app without `bun create`.
7
+ *
8
+ * This is intentionally minimal — it does not run `bun install`. After
9
+ * generation, the user runs `bun install` themselves.
10
+ */
11
+ import type { Command } from "../core/index.js";
12
+ export declare const newCommand: Command;
13
+ export default newCommand;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * `nx repl` — interactive REPL with the app's services loaded.
3
+ *
4
+ * Boots the user's `AppModule` and drops you into a REPL with
5
+ * `app`, `container`, `db`, `logger`, `cfg`, `cache`, and `events`
6
+ * pre-loaded. Useful for debugging, exploring data, and trying
7
+ * out queries without writing a throwaway script.
8
+ *
9
+ * Usage:
10
+ * nx repl # default: ./app/app.module.ts
11
+ * nx repl --module app/app.module.ts
12
+ * nx repl --no-boot # vanilla REPL
13
+ * nx repl --history /tmp/nx-history # custom history file
14
+ *
15
+ * Once inside the REPL:
16
+ * ❯ await db.select().from(users).all()
17
+ * ❯ logger.info("hello from REPL")
18
+ * ❯ .services
19
+ * ❯ .routes
20
+ * ❯ .help
21
+ * ❯ .exit
22
+ *
23
+ * Multi-line input is detected by a bracket-matcher — an
24
+ * expression with an unclosed `{}`, `[]`, or `()` keeps the
25
+ * prompt in `...` continuation mode.
26
+ *
27
+ * History is persisted to `.nx-repl-history` (or the path
28
+ * given by `--history`).
29
+ */
30
+ import type { Command } from "../core/index.js";
31
+ export declare const replCommand: Command;
32
+ export declare function preloadService(env: Record<string, unknown>, app: {
33
+ container: {
34
+ resolve: (t: unknown) => unknown;
35
+ };
36
+ }, name: string, path: string, className: string): Promise<void>;
37
+ export declare function listServices(container: unknown): string[];
38
+ export declare function isIncomplete(code: string): boolean;
39
+ export declare function formatResult(r: unknown): string;
40
+ export declare function formatError(e: Error): string;
41
+ export default replCommand;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * `nx route:list` — list every registered HTTP route.
3
+ *
4
+ * Walks the project's controllers (under paths.controllers) and reads
5
+ * the `@Controller(prefix)` + `@Get/@Post/...` metadata via reflection.
6
+ * For modules that don't use the decorator style, this command emits
7
+ * an informational message instead of failing.
8
+ */
9
+ import type { Command } from "../core/index.js";
10
+ export declare const routeListCommand: Command;
11
+ export default routeListCommand;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Minimal argv parser for the `nx` CLI.
3
+ *
4
+ * Supports:
5
+ * - positional args
6
+ * - short flags (-v, -p 3000)
7
+ * - long flags (--verbose, --port=3000, --port 3000)
8
+ * - boolean toggles (--no-color / --color)
9
+ * - `--` end-of-options marker
10
+ *
11
+ * Usage:
12
+ * const { command, positional, flags } = parseArgs(process.argv.slice(2));
13
+ */
14
+ export interface ParsedArgs {
15
+ /** Subcommand name (first positional arg, e.g. `make:controller`). */
16
+ command: string | undefined;
17
+ /** Remaining positional args after the command. */
18
+ positional: string[];
19
+ /** Flag map: long → string | boolean | string[]. */
20
+ flags: Record<string, string | boolean | string[]>;
21
+ }
22
+ export declare function parseArgs(argv: string[]): ParsedArgs;
23
+ /** Coerce a flag value to string with a default. */
24
+ export declare function flagString(flags: Record<string, string | boolean | string[]>, name: string, fallback?: string): string | undefined;
25
+ /** Coerce a flag value to boolean with a default. */
26
+ export declare function flagBool(flags: Record<string, string | boolean | string[]>, name: string, fallback?: boolean): boolean;
27
+ /** Read a flag list (each occurrence appends). */
28
+ export declare function flagList(flags: Record<string, string | boolean | string[]>, name: string): string[];
@@ -0,0 +1,136 @@
1
+ /**
2
+ * `nx.config.ts` loader.
3
+ *
4
+ * Reads the project's `nx.config.ts` (or `.nxrc.json`) and merges it
5
+ * with environment overrides (`NX_ROUTING`, `NX_VIEW`, `NX_ORM`,
6
+ * `NX_DATABASE_URL`, etc.).
7
+ *
8
+ * The config file is dynamically imported so users can write it in
9
+ * TypeScript with full type checking.
10
+ */
11
+ export type RoutingStyle = "nest" | "adonis" | "functional" | "mixed";
12
+ export type ViewEngine = "rendu" | "edge" | "inertia" | "none";
13
+ export type OrmDriver = "drizzle" | "prisma" | "kysely" | "none";
14
+ export type InertiaFrontend = "react" | "vue" | "svelte" | "solid";
15
+ export type DatabaseDriver = "bun-sqlite" | "node-sqlite" | "libsql" | "postgres" | "mysql" | "none";
16
+ export type QueueBackendKind = "bullmq" | "cloudflare" | "memory";
17
+ /** Authentication surface. Mirrors `src/auth/types.ts` (kept inline so
18
+ * the CLI doesn't depend on the auth module). */
19
+ export interface NxAuthConfig {
20
+ /** Mount path for better-auth handler. Default: `/api/auth`. */
21
+ basePath?: string;
22
+ /** Email + password authentication. */
23
+ emailAndPassword?: {
24
+ enabled?: boolean;
25
+ requireEmailVerification?: boolean;
26
+ minPasswordLength?: number;
27
+ maxPasswordLength?: number;
28
+ };
29
+ /** Social providers keyed by name (github, google, discord, ...). */
30
+ socialProviders?: Record<string, {
31
+ clientId: string;
32
+ clientSecret: string;
33
+ scope?: string[];
34
+ redirectURI?: string;
35
+ }>;
36
+ /** JWT plugin (token + JWKS endpoint). */
37
+ jwt?: {
38
+ enabled: boolean;
39
+ jwksPath?: string;
40
+ issuer?: string;
41
+ audience?: string;
42
+ expiresIn?: number;
43
+ };
44
+ /** Passkey plugin (WebAuthn). */
45
+ passkey?: {
46
+ enabled: boolean;
47
+ rpName: string;
48
+ rpId: string;
49
+ origin: string | string[];
50
+ };
51
+ /** Session TTL in seconds. Default: 7 days. */
52
+ sessionExpiresInSeconds?: number;
53
+ /** Cookie domain for subdomains. */
54
+ cookieDomain?: string;
55
+ /** Cross-subdomain cookies. */
56
+ crossSubDomainCookies?: {
57
+ enabled: boolean;
58
+ domain?: string;
59
+ };
60
+ /** Cookie `SameSite` attribute. */
61
+ cookieSameSite?: "lax" | "strict" | "none";
62
+ /** Cookie `Secure` flag. Default: true in production. */
63
+ cookieSecure?: boolean;
64
+ }
65
+ export interface NxConfig {
66
+ /** Routing style for `make:controller` templates. */
67
+ routing: RoutingStyle;
68
+ /** View engine for view templates. */
69
+ view: ViewEngine;
70
+ /** ORM driver. */
71
+ orm: OrmDriver;
72
+ /** Drizzle dialect (when `orm === 'drizzle'`). */
73
+ dialect?: "postgres" | "mysql" | "sqlite" | "bun-sqlite" | "d1";
74
+ /** Database driver. */
75
+ database: {
76
+ driver: DatabaseDriver;
77
+ url: string;
78
+ };
79
+ /** Inertia-specific config (only consulted when `view === 'inertia'`). */
80
+ inertia: {
81
+ frontend: InertiaFrontend;
82
+ ssr: boolean;
83
+ version: string;
84
+ };
85
+ /** Where to scaffold files. */
86
+ paths: {
87
+ app: string;
88
+ controllers: string;
89
+ services: string;
90
+ modules: string;
91
+ models: string;
92
+ migrations: string;
93
+ seeds?: string;
94
+ middleware: string;
95
+ dto: string;
96
+ };
97
+ /** Names that get auto-included in `@Module({ controllers: [...] })`. */
98
+ moduleStyle: "nest" | "adonis";
99
+ /** Authentication (better-auth) configuration. Optional. */
100
+ auth?: NxAuthConfig;
101
+ /** Queue (BullMQ / Cloudflare Queues) configuration. Optional. */
102
+ queue?: {
103
+ backend: QueueBackendKind;
104
+ bullmq?: {
105
+ connection: string | {
106
+ host: string;
107
+ port: number;
108
+ password?: string;
109
+ };
110
+ prefix?: string;
111
+ };
112
+ cloudflare?: {
113
+ /** Name of the Queue binding on the Worker (e.g. 'MY_QUEUE'). */
114
+ bindingName: string;
115
+ queueName?: string;
116
+ };
117
+ defaults?: {
118
+ delaySeconds?: number;
119
+ attempts?: number;
120
+ backoff?: {
121
+ type: "fixed" | "exponential";
122
+ delayMs: number;
123
+ };
124
+ };
125
+ };
126
+ }
127
+ export declare const DEFAULT_CONFIG: NxConfig;
128
+ /**
129
+ * Load the project's nx.config file, falling back to defaults.
130
+ * Merges with environment overrides.
131
+ *
132
+ * Missing / unloadable config files are not fatal — we log a debug
133
+ * message and use defaults so the CLI works in fresh projects where
134
+ * `nexusjs` hasn't been installed yet.
135
+ */
136
+ export declare function loadConfig(cwd?: string): Promise<NxConfig>;