@sukujs/cli 0.0.0-stage → 0.3.0
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/LICENSE +21 -0
- package/README.md +49 -2
- package/dist/bin.d.mts +1 -0
- package/dist/bin.mjs +9 -0
- package/dist/bin.mjs.map +1 -0
- package/dist/index.d.mts +173 -0
- package/dist/index.mjs +3 -0
- package/dist/src-DP9MVAe3.mjs +1387 -0
- package/dist/src-DP9MVAe3.mjs.map +1 -0
- package/package.json +52 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Suku Authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,50 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @sukujs/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The command line for [Suku](https://github.com/sukujs/sukujs): create a project, generate
|
|
4
|
+
features, routes and services, and run, build and start your app.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
bunx @sukujs/cli new my-api
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
`suku new` asks for the production runtime, the package manager (Bun by default), deployment
|
|
11
|
+
targets (Docker, PM2, systemd, Cloudflare Workers, Vercel), whether to initialise git, and
|
|
12
|
+
whether to install. Every question has a flag, and `--yes` takes the defaults.
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
suku new my-api --runtime bun --deploy docker,cloudflare --yes
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Commands
|
|
19
|
+
|
|
20
|
+
| Command | What it does |
|
|
21
|
+
| ---------------------------------- | ------------------------------------------------ |
|
|
22
|
+
| `suku new [name]` | Create a project |
|
|
23
|
+
| `suku generate <schematic> <name>` | Generate code and register it (alias `g`) |
|
|
24
|
+
| `suku dev` | Run the app with Bun and restart on change |
|
|
25
|
+
| `suku build` | Bundle the app and its dependencies into `dist/` |
|
|
26
|
+
| `suku start` | Run the built app with Node or Bun |
|
|
27
|
+
| `suku info` | Print versions, for bug reports |
|
|
28
|
+
|
|
29
|
+
## Schematics
|
|
30
|
+
|
|
31
|
+
| Schematic | Alias | Creates |
|
|
32
|
+
| ------------ | ----- | ------------------------------------------------------ |
|
|
33
|
+
| `resource` | `res` | A CRUD feature: routes, service, schemas and a test |
|
|
34
|
+
| `feature` | `f` | A feature |
|
|
35
|
+
| `routes` | `r` | A `@Routes` class, or `route.group` with `--classless` |
|
|
36
|
+
| `service` | `s` | A `@Service` class, or `service()` with `--classless` |
|
|
37
|
+
| `middleware` | `mw` | A middleware |
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
suku g resource products
|
|
41
|
+
suku g routes billing --classless
|
|
42
|
+
suku g service admin/reports --dry-run
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Generated features are added to your root feature, and routes and services to the feature in
|
|
46
|
+
their folder. Nothing is overwritten without `--force`.
|
|
47
|
+
|
|
48
|
+
`suku dev` and `suku build` need [Bun](https://bun.sh). The built app runs on Node 22+ or Bun.
|
|
49
|
+
|
|
50
|
+
Full reference: the CLI page of the Suku documentation.
|
package/dist/bin.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/bin.mjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { n as Prompter, t as run } from "./src-DP9MVAe3.mjs";
|
|
3
|
+
|
|
4
|
+
// src/bin.ts
|
|
5
|
+
const interactive = process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
6
|
+
process.exitCode = await run(process.argv.slice(2), interactive ? { prompter: new Prompter() } : {});
|
|
7
|
+
|
|
8
|
+
export { };
|
|
9
|
+
//# sourceMappingURL=bin.mjs.map
|
package/dist/bin.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.mjs","names":[],"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Prompter, run } from './index.js';\n\n// Ask questions only when a person is at a terminal. Piped or scripted runs take defaults.\nconst interactive = process.stdin.isTTY === true && process.stdout.isTTY === true;\nprocess.exitCode = await run(\n process.argv.slice(2),\n interactive ? { prompter: new Prompter() } : {},\n);\n"],"mappings":";;;;AAIA,MAAM,cAAc,QAAQ,MAAM,UAAU,QAAQ,QAAQ,OAAO,UAAU;AAC7E,QAAQ,WAAW,MAAM,IACvB,QAAQ,KAAK,MAAM,CAAC,GACpB,cAAc,EAAE,UAAU,IAAI,SAAS,EAAE,IAAI,CAAC,CAChD"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
interface Choice<T> {
|
|
2
|
+
value: T;
|
|
3
|
+
label: string;
|
|
4
|
+
hint?: string;
|
|
5
|
+
}
|
|
6
|
+
type Input = NodeJS.ReadableStream & {
|
|
7
|
+
setRawMode?: (mode: boolean) => unknown;
|
|
8
|
+
isTTY?: boolean;
|
|
9
|
+
};
|
|
10
|
+
type Output = {
|
|
11
|
+
write: (text: string) => unknown;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Questions for the terminal: arrow keys to move, space to toggle, enter to confirm. It has
|
|
15
|
+
* no dependencies and reads keys from any stream, which is how the tests drive it.
|
|
16
|
+
*/
|
|
17
|
+
export declare class Prompter {
|
|
18
|
+
private readonly input;
|
|
19
|
+
private readonly output;
|
|
20
|
+
constructor(input?: Input, output?: Output);
|
|
21
|
+
/** Runs one question: draws it, feeds it keys until it returns a value, then tidies up. */
|
|
22
|
+
private ask;
|
|
23
|
+
/** Free text. Enter with nothing typed accepts the default. */
|
|
24
|
+
text(question: string, fallback?: string): Promise<string>;
|
|
25
|
+
/** Yes or no. */
|
|
26
|
+
confirm(question: string, fallback?: boolean): Promise<boolean>;
|
|
27
|
+
/** Pick one. The first choice is the default. */
|
|
28
|
+
select<T>(question: string, choices: Choice<T>[]): Promise<T>;
|
|
29
|
+
/** Pick any number, including none. */
|
|
30
|
+
multiselect<T>(question: string, choices: Choice<T>[]): Promise<T[]>;
|
|
31
|
+
}
|
|
32
|
+
interface Change {
|
|
33
|
+
action: 'CREATE' | 'UPDATE';
|
|
34
|
+
/** Relative to the plan's root, with forward slashes. */
|
|
35
|
+
path: string;
|
|
36
|
+
content: string;
|
|
37
|
+
}
|
|
38
|
+
interface CommitOptions {
|
|
39
|
+
dryRun?: boolean;
|
|
40
|
+
force?: boolean;
|
|
41
|
+
log?: (line: string) => void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Collects every file a command wants to write, then writes them together. Nothing touches
|
|
45
|
+
* the disk until `commit`, so a command either does all of its work or none of it.
|
|
46
|
+
*/
|
|
47
|
+
export declare class Plan {
|
|
48
|
+
readonly root: string;
|
|
49
|
+
readonly changes: Change[];
|
|
50
|
+
readonly notes: string[];
|
|
51
|
+
constructor(root: string);
|
|
52
|
+
private key;
|
|
53
|
+
exists(path: string): boolean;
|
|
54
|
+
/** The planned content of a file if this plan changes it, otherwise what is on disk. */
|
|
55
|
+
read(path: string): string | undefined;
|
|
56
|
+
create(path: string, content: string): void;
|
|
57
|
+
update(path: string, content: string): void;
|
|
58
|
+
note(message: string): void;
|
|
59
|
+
commit(options?: CommitOptions): void;
|
|
60
|
+
}
|
|
61
|
+
type Runtime = 'node' | 'bun';
|
|
62
|
+
interface Project {
|
|
63
|
+
root: string;
|
|
64
|
+
/** Folder that holds the source, relative to the root. Default `src`. */
|
|
65
|
+
sourceRoot: string;
|
|
66
|
+
/** File the app starts from, relative to the root. Default `src/main.ts`. */
|
|
67
|
+
entry: string;
|
|
68
|
+
/** What runs the built app in production. Default `node`. */
|
|
69
|
+
runtime: Runtime;
|
|
70
|
+
/** `.js` when the project writes relative imports with an extension, otherwise empty. */
|
|
71
|
+
importExtension: '' | '.js';
|
|
72
|
+
dependencies: Record<string, string>;
|
|
73
|
+
}
|
|
74
|
+
/** Reads the project in `cwd`. Settings come from the `suku` field of its `package.json`. */
|
|
75
|
+
export declare function loadProject(cwd: string): Project;
|
|
76
|
+
interface GenerateOptions {
|
|
77
|
+
/** Functions instead of classes: `route.group` and `service()`. */
|
|
78
|
+
classless?: boolean;
|
|
79
|
+
/** Do not create a folder named after the thing. */
|
|
80
|
+
flat?: boolean;
|
|
81
|
+
/** Do not edit other files to register what was generated. */
|
|
82
|
+
skipImport?: boolean;
|
|
83
|
+
/** `resource` only: do not generate a test file. */
|
|
84
|
+
skipTests?: boolean;
|
|
85
|
+
}
|
|
86
|
+
export declare const SCHEMATICS: {
|
|
87
|
+
readonly feature: {
|
|
88
|
+
readonly alias: 'f';
|
|
89
|
+
readonly description: 'A feature: a named group of routes and services';
|
|
90
|
+
};
|
|
91
|
+
readonly routes: {
|
|
92
|
+
readonly alias: 'r';
|
|
93
|
+
readonly description: 'A routes class (or a route group with --classless)';
|
|
94
|
+
};
|
|
95
|
+
readonly service: {
|
|
96
|
+
readonly alias: 's';
|
|
97
|
+
readonly description: 'A service class (or service() with --classless)';
|
|
98
|
+
};
|
|
99
|
+
readonly middleware: {
|
|
100
|
+
readonly alias: 'mw';
|
|
101
|
+
readonly description: 'A middleware';
|
|
102
|
+
};
|
|
103
|
+
readonly resource: {
|
|
104
|
+
readonly alias: 'res';
|
|
105
|
+
readonly description: 'A CRUD feature: routes, service, schemas and a test';
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
type Schematic = keyof typeof SCHEMATICS;
|
|
109
|
+
/** Adds the files for one schematic to `plan`, and the edits that register them. */
|
|
110
|
+
export declare function generate(plan: Plan, project: Project, schematic: Schematic, input: string, options?: GenerateOptions): void;
|
|
111
|
+
interface Io {
|
|
112
|
+
cwd: string;
|
|
113
|
+
log: (line: string) => void;
|
|
114
|
+
/** Present when questions can be asked: a terminal is attached. */
|
|
115
|
+
prompter?: Prompter;
|
|
116
|
+
}
|
|
117
|
+
export declare const DEPLOY_TARGETS: {
|
|
118
|
+
readonly docker: {
|
|
119
|
+
readonly label: 'Docker';
|
|
120
|
+
readonly hint: 'Dockerfile and docker-compose.yml';
|
|
121
|
+
};
|
|
122
|
+
readonly pm2: {
|
|
123
|
+
readonly label: 'VPS with PM2';
|
|
124
|
+
readonly hint: 'ecosystem.config.cjs';
|
|
125
|
+
};
|
|
126
|
+
readonly systemd: {
|
|
127
|
+
readonly label: 'VPS with systemd';
|
|
128
|
+
readonly hint: 'a unit file';
|
|
129
|
+
};
|
|
130
|
+
readonly cloudflare: {
|
|
131
|
+
readonly label: 'Cloudflare Workers';
|
|
132
|
+
readonly hint: 'src/worker.ts and wrangler.jsonc';
|
|
133
|
+
};
|
|
134
|
+
readonly vercel: {
|
|
135
|
+
readonly label: 'Vercel';
|
|
136
|
+
readonly hint: 'api/index.ts and vercel.json';
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
type DeployTarget = keyof typeof DEPLOY_TARGETS;
|
|
140
|
+
/** A mistake in how the CLI was used. Printed without a stack trace, exit code 1. */
|
|
141
|
+
export declare class CliError extends Error {
|
|
142
|
+
readonly name = "CliError";
|
|
143
|
+
}
|
|
144
|
+
interface Names {
|
|
145
|
+
/** `user-profiles`: file and folder names, URL prefixes. */
|
|
146
|
+
kebab: string;
|
|
147
|
+
/** `UserProfiles`: classes and exported features. */
|
|
148
|
+
pascal: string;
|
|
149
|
+
/** `userProfiles`: variables. */
|
|
150
|
+
camel: string;
|
|
151
|
+
}
|
|
152
|
+
/** Turns any spelling (`userProfiles`, `user_profiles`, `User Profiles`) into every casing. */
|
|
153
|
+
export declare function names(input: string): Names;
|
|
154
|
+
interface StarterOptions {
|
|
155
|
+
/** The package name, already validated. */
|
|
156
|
+
name: string;
|
|
157
|
+
runtime: Runtime;
|
|
158
|
+
/** The Suku version every `@sukujs/*` dependency is pinned to. */
|
|
159
|
+
version: string;
|
|
160
|
+
/** Used in the README's commands. Default `bun`. */
|
|
161
|
+
packageManager?: string;
|
|
162
|
+
/** Deployment targets to add files for. */
|
|
163
|
+
deploy?: DeployTarget[];
|
|
164
|
+
}
|
|
165
|
+
/** The files of a new project, keyed by path. */
|
|
166
|
+
export declare function starter(options: StarterOptions): Record<string, string>;
|
|
167
|
+
/**
|
|
168
|
+
* Runs the CLI with `argv` (without `node` and the script path) and resolves with the exit
|
|
169
|
+
* code. Usage mistakes are printed and return `1`; they do not throw. Questions are asked
|
|
170
|
+
* only when `io.prompter` is given.
|
|
171
|
+
*/
|
|
172
|
+
export declare function run(argv: string[], io?: Partial<Io>): Promise<number>;
|
|
173
|
+
export type { Change, Choice, DeployTarget, GenerateOptions, Names, Project, Runtime, Schematic };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as generate, c as names, i as SCHEMATICS, l as DEPLOY_TARGETS, n as Prompter, o as loadProject, r as starter, s as Plan, t as run, u as CliError } from "./src-DP9MVAe3.mjs";
|
|
2
|
+
|
|
3
|
+
export { CliError, DEPLOY_TARGETS, Plan, Prompter, SCHEMATICS, generate, loadProject, names, run, starter };
|