@nexusts/cli 0.7.0 → 0.7.2
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.
- package/README.md +2 -2
- package/dist/commands/config.d.ts +43 -0
- package/dist/commands/db-generate.d.ts +19 -0
- package/dist/commands/db-migrate.d.ts +32 -0
- package/dist/commands/db-seed.d.ts +42 -0
- package/dist/commands/index.d.ts +10 -0
- package/dist/commands/info.d.ts +10 -0
- package/dist/commands/init.d.ts +37 -0
- package/dist/commands/make-auth.d.ts +16 -0
- package/dist/commands/make-controller.d.ts +15 -0
- package/dist/commands/make-crud.d.ts +27 -0
- package/dist/commands/make-listener.d.ts +14 -0
- package/dist/commands/make-middleware.d.ts +6 -0
- package/dist/commands/make-migration.d.ts +20 -0
- package/dist/commands/make-model.d.ts +21 -0
- package/dist/commands/make-module.d.ts +10 -0
- package/dist/commands/make-queue.d.ts +16 -0
- package/dist/commands/make-schedule.d.ts +16 -0
- package/dist/commands/make-service.d.ts +6 -0
- package/dist/commands/make-session.d.ts +14 -0
- package/dist/commands/make-validator.d.ts +6 -0
- package/dist/commands/new.d.ts +13 -0
- package/dist/commands/repl.d.ts +41 -0
- package/dist/commands/route-list.d.ts +11 -0
- package/dist/core/args.d.ts +28 -0
- package/dist/core/config.d.ts +136 -0
- package/dist/core/fs.d.ts +37 -0
- package/dist/core/index.d.ts +42 -0
- package/dist/core/logger.d.ts +45 -0
- package/dist/core/loose-json.d.ts +25 -0
- package/dist/core/prompts.d.ts +21 -0
- package/dist/core/template.d.ts +25 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +1290 -1091
- package/dist/index.js.map +37 -33
- package/dist/templates/controller/adonis.d.ts +9 -0
- package/dist/templates/controller/functional.d.ts +8 -0
- package/dist/templates/controller/nest.d.ts +16 -0
- package/dist/templates/crud/controller.d.ts +7 -0
- package/dist/templates/crud/dto.d.ts +7 -0
- package/dist/templates/crud/module.d.ts +5 -0
- package/dist/templates/crud/test.d.ts +9 -0
- package/dist/templates/index.d.ts +38 -0
- package/dist/templates/middleware/middleware.d.ts +7 -0
- package/dist/templates/migration/drizzle.d.ts +11 -0
- package/dist/templates/migration/sql.d.ts +9 -0
- package/dist/templates/model/drizzle-dialect.d.ts +28 -0
- package/dist/templates/model/drizzle.d.ts +13 -0
- package/dist/templates/model/kysely.d.ts +11 -0
- package/dist/templates/model/prisma.d.ts +11 -0
- package/dist/templates/module/module.d.ts +15 -0
- package/dist/templates/project/drizzle.config.d.ts +11 -0
- package/dist/templates/project/nx.config.d.ts +6 -0
- package/dist/templates/repository/repository.d.ts +12 -0
- package/dist/templates/service/service.d.ts +11 -0
- package/dist/templates/validator/validator.d.ts +7 -0
- package/package.json +5 -2
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filesystem helpers for the CLI.
|
|
3
|
+
*/
|
|
4
|
+
export interface WriteOptions {
|
|
5
|
+
/** Skip writing if the file exists. Default `false` (overwrite OK). */
|
|
6
|
+
skipIfExists?: boolean;
|
|
7
|
+
/** Make the path absolute relative to this directory. Default cwd. */
|
|
8
|
+
base?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Write a file, creating parent directories as needed.
|
|
12
|
+
* Throws if `skipIfExists` is `true` and the file already exists.
|
|
13
|
+
*/
|
|
14
|
+
export declare function writeFile(path: string, contents: string, opts?: WriteOptions): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Read a file, or return `undefined` if missing.
|
|
17
|
+
*/
|
|
18
|
+
export declare function readFile(path: string): string | undefined;
|
|
19
|
+
/** True if a file exists at the given path. */
|
|
20
|
+
export declare function fileExists(path: string): boolean;
|
|
21
|
+
/** True if a directory exists at the given path. */
|
|
22
|
+
export declare function directoryExists(path: string): boolean;
|
|
23
|
+
/** Compute a project-relative path. */
|
|
24
|
+
export declare function relativePath(from: string, to: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Convert a name like "User", "user", "users", "user_profile" into a
|
|
27
|
+
* consistent set of variants used by templates.
|
|
28
|
+
*/
|
|
29
|
+
export declare function nameVariants(input: string): {
|
|
30
|
+
pascal: string;
|
|
31
|
+
camel: string;
|
|
32
|
+
snake: string;
|
|
33
|
+
kebab: string;
|
|
34
|
+
plural: string;
|
|
35
|
+
pluralSnake: string;
|
|
36
|
+
pluralKebab: string;
|
|
37
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports for the CLI core.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./args.js";
|
|
5
|
+
export * from "./config.js";
|
|
6
|
+
export * from "./fs.js";
|
|
7
|
+
export * from "./logger.js";
|
|
8
|
+
export * from "./loose-json.js";
|
|
9
|
+
export * from "./prompts.js";
|
|
10
|
+
export * from "./template.js";
|
|
11
|
+
/**
|
|
12
|
+
* The CLI command contract. Every command module exports a default
|
|
13
|
+
* `Command` object that the entry point dispatches against.
|
|
14
|
+
*/
|
|
15
|
+
export interface Command {
|
|
16
|
+
/** Primary command name, e.g. `"make:controller"`. */
|
|
17
|
+
name: string;
|
|
18
|
+
/** Aliases (`"mc"` for `make:controller`). */
|
|
19
|
+
aliases?: string[];
|
|
20
|
+
/** One-line summary for `nx help`. */
|
|
21
|
+
summary: string;
|
|
22
|
+
/** Detailed description for `nx help <command>`. */
|
|
23
|
+
description?: string;
|
|
24
|
+
/** Example invocations. */
|
|
25
|
+
examples?: string[];
|
|
26
|
+
/** Flag schema (used for `nx help <command>` rendering). */
|
|
27
|
+
flags?: Array<{
|
|
28
|
+
name: string;
|
|
29
|
+
short?: string;
|
|
30
|
+
description: string;
|
|
31
|
+
default?: string | boolean;
|
|
32
|
+
required?: boolean;
|
|
33
|
+
}>;
|
|
34
|
+
/** The handler. Receives parsed args + cwd + loaded config. */
|
|
35
|
+
run(ctx: CommandContext): Promise<number>;
|
|
36
|
+
}
|
|
37
|
+
export interface CommandContext {
|
|
38
|
+
cwd: string;
|
|
39
|
+
config: import("./config.js").NxConfig;
|
|
40
|
+
positional: string[];
|
|
41
|
+
flags: Record<string, string | boolean | string[]>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Colored logger for the `nx` CLI.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the look-and-feel of Adonis ACE / Rails:
|
|
5
|
+
* - info → cyan
|
|
6
|
+
* - success → green
|
|
7
|
+
* - warn → yellow
|
|
8
|
+
* - error → red
|
|
9
|
+
* - debug → dim gray
|
|
10
|
+
*
|
|
11
|
+
* Honors the `NO_COLOR` env var and disables color when stdout is not a
|
|
12
|
+
* TTY (so logs piped into a file don't contain escape codes).
|
|
13
|
+
*/
|
|
14
|
+
export type LoggerLevel = "info" | "success" | "warn" | "error" | "debug";
|
|
15
|
+
export declare class Logger {
|
|
16
|
+
private verbose;
|
|
17
|
+
setVerbose(v: boolean): void;
|
|
18
|
+
info(message: string): void;
|
|
19
|
+
success(message: string): void;
|
|
20
|
+
warn(message: string): void;
|
|
21
|
+
error(message: string): void;
|
|
22
|
+
debug(message: string): void;
|
|
23
|
+
finger(message: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* Render a small table. `rows` is an array of `[label, value]`
|
|
26
|
+
* tuples; the label column is dimmed.
|
|
27
|
+
*/
|
|
28
|
+
table(rows: Array<[string, string]>): void;
|
|
29
|
+
heading(text: string): void;
|
|
30
|
+
blank(): void;
|
|
31
|
+
}
|
|
32
|
+
export declare const logger: Logger;
|
|
33
|
+
/** ANSI helpers (exported for templates that want colored output). */
|
|
34
|
+
export declare const colors: {
|
|
35
|
+
reset: (s: string) => string;
|
|
36
|
+
bold: (s: string) => string;
|
|
37
|
+
dim: (s: string) => string;
|
|
38
|
+
red: (s: string) => string;
|
|
39
|
+
green: (s: string) => string;
|
|
40
|
+
yellow: (s: string) => string;
|
|
41
|
+
blue: (s: string) => string;
|
|
42
|
+
magenta: (s: string) => string;
|
|
43
|
+
cyan: (s: string) => string;
|
|
44
|
+
gray: (s: string) => string;
|
|
45
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lenient JSON parser.
|
|
3
|
+
*
|
|
4
|
+
* Standard `JSON.parse` rejects three things that show up regularly
|
|
5
|
+
* in hand-edited `package.json` / `tsconfig.json` files:
|
|
6
|
+
*
|
|
7
|
+
* 1. Line comments: `// like this`
|
|
8
|
+
* 2. Block comments: `/* like this *\/`
|
|
9
|
+
* 3. Trailing commas: `\{ "a": 1, \}` or `[ 1, 2, ]`
|
|
10
|
+
*
|
|
11
|
+
* `bun init` and several other generators emit files with at least
|
|
12
|
+
* some of these (the user's `package.json` had `//` comments and
|
|
13
|
+
* tripped the CLI with `Unrecognized token '/'`).
|
|
14
|
+
*
|
|
15
|
+
* Bun has full JSON5 support built in (`Bun.JSON5.parse()`,
|
|
16
|
+
* `Bun.JSON5.stringify()` — see
|
|
17
|
+
* https://bun.sh/docs/runtime/json5#bun-json5-parse), so this
|
|
18
|
+
* module is a thin pass-through rather than a reimplementation.
|
|
19
|
+
* The CLI runs in Bun >= 1.1.0 (see `engines` in package.json).
|
|
20
|
+
*
|
|
21
|
+
* Use this anywhere the CLI reads a user-owned `package.json` or
|
|
22
|
+
* `tsconfig.json`. For framework-owned files (like the templates
|
|
23
|
+
* we render), use plain `JSON.parse` — they're always strict.
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseJsonLoose<T = Record<string, unknown>>(text: string): T;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight interactive prompts.
|
|
3
|
+
*
|
|
4
|
+
* Avoids a runtime dependency on a TTY prompt library — we only need
|
|
5
|
+
* confirm / select / text prompts, all of which can be done with
|
|
6
|
+
* `readline` and a fallback to defaults when stdin is not a TTY.
|
|
7
|
+
*
|
|
8
|
+
* Every prompt can be skipped with `--no-interaction` or by passing the
|
|
9
|
+
* answer via flags. This mirrors Adonis ACE and Symfony Console.
|
|
10
|
+
*/
|
|
11
|
+
export interface PromptOptions {
|
|
12
|
+
/** Default value when the user just presses enter. */
|
|
13
|
+
default?: string;
|
|
14
|
+
/** Choices for select. The first one is the default. */
|
|
15
|
+
choices?: string[];
|
|
16
|
+
/** When false, stdin must be a TTY — otherwise the default is used. */
|
|
17
|
+
interactive?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function prompt(message: string, options?: PromptOptions): Promise<string>;
|
|
20
|
+
export declare function confirm(message: string, defaultYes?: boolean, options?: PromptOptions): Promise<boolean>;
|
|
21
|
+
export declare function select(message: string, choices: string[], options?: PromptOptions): Promise<string>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal template engine for code generation.
|
|
3
|
+
*
|
|
4
|
+
* Supports:
|
|
5
|
+
* - `{{ key }}` substitution
|
|
6
|
+
* - `{{ key | filter }}` filters (upper/lower/pascal/camel/snake/kebab/plural/singular)
|
|
7
|
+
* - `{{# flag }} ... {{/ flag }}` truthy sections (include if `flag` is truthy)
|
|
8
|
+
* - `{{^ flag }} ... {{/ flag }}` falsy sections (include if `flag` is falsy)
|
|
9
|
+
* - dotted lookup (`{{ user.name }}`)
|
|
10
|
+
*
|
|
11
|
+
* Multi-line templates are fine; placeholders can span any whitespace.
|
|
12
|
+
*/
|
|
13
|
+
export type Filter = "raw" | "upper" | "lower" | "pascal" | "camel" | "snake" | "kebab" | "plural" | "singular";
|
|
14
|
+
export interface RenderObject {
|
|
15
|
+
[key: string]: RenderValue;
|
|
16
|
+
}
|
|
17
|
+
export type RenderValue = string | number | boolean | undefined | null | RenderObject | RenderValue[];
|
|
18
|
+
export type RenderContext = RenderObject;
|
|
19
|
+
export declare function render(template: string, context: RenderContext): string;
|
|
20
|
+
export declare function toPascal(s: string): string;
|
|
21
|
+
export declare function toCamel(s: string): string;
|
|
22
|
+
export declare function toSnake(s: string): string;
|
|
23
|
+
export declare function toKebab(s: string): string;
|
|
24
|
+
export declare function pluralize(s: string): string;
|
|
25
|
+
export declare function singularize(s: string): string;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* `nx` — the Nexus CLI entry point.
|
|
4
|
+
*
|
|
5
|
+
* Invocation:
|
|
6
|
+
* bunx nx <command> [args...]
|
|
7
|
+
* bunx nx help
|
|
8
|
+
* bunx nx help <command>
|
|
9
|
+
*
|
|
10
|
+
* Resembles Adonis ACE / Rails generators:
|
|
11
|
+
* nx make:controller User
|
|
12
|
+
* nx make:crud Post --no-views
|
|
13
|
+
* nx make:migration create_users_table --columns "name:text,email:text"
|
|
14
|
+
* nx info
|
|
15
|
+
* nx route:list
|
|
16
|
+
* nx init --style nest --view inertia --orm drizzle
|
|
17
|
+
*
|
|
18
|
+
* The CLI loads `nx.config.ts` (or `nx.config.js` / `.nxrc.json`) and
|
|
19
|
+
* passes the resolved config + parsed flags to each command.
|
|
20
|
+
*/
|
|
21
|
+
export {};
|