genrex 0.2.0 → 0.2.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.
package/README.md CHANGED
@@ -11,95 +11,200 @@
11
11
  </p>
12
12
 
13
13
  <p align="center">
14
- <img src="https://img.shields.io/badge/version-0.2.0-blue?style=flat-square" alt="Version" />
14
+ <a href="https://www.npmjs.com/package/genrex"><img src="https://img.shields.io/npm/v/genrex?style=flat-square&color=cb3837" alt="npm version" /></a>
15
15
  <img src="https://img.shields.io/badge/license-MIT-green?style=flat-square" alt="License" />
16
+ <img src="https://img.shields.io/badge/node-%3E%3D20-brightgreen?style=flat-square" alt="Node version" />
16
17
  </p>
17
18
 
18
19
  > **Forge production-ready projects from configurable blueprints.**
19
20
 
20
- `genrex` is a modern, lightweight project scaffolding CLI engine. Rather than copying generic boilerplates, it generates strongly-typed, coherent software projects with Biome, Vitest, CI/CD, and Docker support tailored to your stack.
21
+ `genrex` is a modern, lightweight CLI scaffolding engine. Rather than copying bare-bones or obsolete boilerplates, it generates strictly-typed, coherent software projects equipped with modern standards: **Biome**, **Vitest**, native ESM, **GitHub Actions CI**, and multi-stage **Dockerfiles**.
21
22
 
22
23
  ---
23
24
 
24
- ## Tech Stack & Ecosystem
25
+ ## ⚡ Installation & Execution
25
26
 
26
- - **Language & Runtime:** TypeScript (Strict, Native ESM), Node.js (>=20)
27
- - **Code Quality & Testing:** Biome (Format/Lint), Vitest
28
- - **API Framework:** Fastify + `tsx` hot-reload
29
- - **DevOps & Containers:** Multi-stage Docker, GitHub Actions CI
30
- - **Package Managers:** `pnpm`, `npm`, `yarn`, `bun`
27
+ You have two ways to run `genrex`:
31
28
 
32
- ---
33
-
34
- ## Quick Start
29
+ ### 1. One-Time Run (Recommended — No Install Needed)
35
30
 
36
- Run directly with `npx`:
31
+ Run the latest version instantly using `npx`:
37
32
 
38
33
  ```bash
39
- npx genrex create my-api --blueprint node-api
34
+ npx genrex create
40
35
  ```
41
36
 
42
- Preview what will be generated without writing to disk:
37
+ Or target a specific name directly:
43
38
 
44
39
  ```bash
45
- npx genrex create my-cli --dry-run
40
+ npx genrex create my-app
46
41
  ```
47
42
 
48
43
  ---
49
44
 
50
- ## Blueprints
45
+ ### 2. Global Installation
51
46
 
52
- | Blueprint | ID | Description |
53
- |---|---|---|
54
- | **TypeScript CLI** | `ts-cli` | Standalone CLI binary, ESM, Biome formatting, Vitest |
55
- | **Node.js API** | `node-api` | Fastify REST API, hot-reload (`tsx`), healthchecks |
56
- | **TypeScript Library** | `ts-lib` | Publishable library with dual ESM exports and `.d.ts` declaration maps |
47
+ If you frequently scaffold new projects, install `genrex` globally:
48
+
49
+ ```bash
50
+ # Using npm
51
+ npm install -g genrex
52
+
53
+ # Using pnpm
54
+ pnpm add -g genrex
55
+
56
+ # Using yarn
57
+ yarn global add genrex
58
+
59
+ # Using bun
60
+ bun add -g genrex
61
+ ```
57
62
 
58
- View all blueprints anytime:
63
+ Once installed, use the `genrex` command anywhere:
59
64
 
60
65
  ```bash
61
- genrex list
62
- genrex info ts-cli
66
+ genrex create
63
67
  ```
64
68
 
65
69
  ---
66
70
 
67
- ## Commands & Usage
71
+ ## 🎯 Interactive Wizard Mode
68
72
 
69
- ### 1. Create a Project
73
+ Running `genrex create` without options launches an interactive step-by-step setup wizard:
70
74
 
71
- ```bash
72
- genrex create <project-name> [options]
75
+ ```text
76
+ genrex — Project Blueprint Engine
77
+
78
+ ? Project name: my-fastify-api
79
+
80
+ ? Choose a blueprint:
81
+ 1) TypeScript CLI (ts-cli)
82
+ 2) Node.js API (node-api)
83
+ 3) TypeScript Library (ts-lib)
84
+ Select [1-3] (1): 2
85
+
86
+ ? Package manager:
87
+ 1) pnpm
88
+ 2) npm
89
+ 3) yarn
90
+ 4) bun
91
+ Select [1-4] (1): 1
92
+
93
+ ? Initialize Git? (Y/n): y
94
+ ? Add GitHub Actions CI? (y/N): y
95
+ ? Add Docker? (y/N): y
96
+
97
+ ✓ Project scaffolded in /path/to/my-fastify-api
98
+ Installing dependencies using pnpm...
99
+ ✓ Dependencies installed
100
+ Initializing Git repository...
101
+ ✓ Git repository initialized
102
+
103
+ Done. Next steps:
104
+ cd my-fastify-api
105
+ pnpm run dev
106
+ pnpm test
73
107
  ```
74
108
 
75
- **Options:**
109
+ ---
110
+
111
+ ## 📖 Complete Command Reference
112
+
113
+ | Command | Description |
114
+ |---|---|
115
+ | `genrex create [name]` | Scaffold a new project (interactive wizard by default) |
116
+ | `genrex list` | Show all available blueprints and descriptions |
117
+ | `genrex info <id>` | Inspect detailed metadata & capabilities of a blueprint |
118
+ | `genrex doctor` | Audit local development environment tools and versions |
119
+ | `genrex -v, --version` | Output current CLI version |
120
+ | `genrex -h, --help` | Display command usage and option flags |
121
+
122
+ ---
123
+
124
+ ### 1. `genrex create [name] [options]`
125
+
126
+ Scaffold a project. You can skip interactive prompts entirely using flags (ideal for CI/automation scripts).
127
+
128
+ #### Command Flags:
76
129
 
77
130
  | Flag | Description | Default |
78
131
  |---|---|---|
79
- | `--blueprint <id>` | Blueprint template (`ts-cli`, `node-api`, `ts-lib`) | `ts-cli` |
132
+ | `-i, --interactive` | Force interactive wizard even if name is supplied | `false` |
133
+ | `--blueprint <id>` | Target blueprint: `ts-cli`, `node-api`, or `ts-lib` | `ts-cli` |
80
134
  | `--package-manager <pm>` | `npm`, `pnpm`, `yarn`, or `bun` | `pnpm` |
81
135
  | `--git` | Initialize empty Git repository | `false` |
82
- | `--github-actions` | Generate GitHub Actions CI test/lint workflow | `false` |
83
- | `--docker` | Generate optimized multi-stage Dockerfile | `false` |
84
- | `--dry-run` | Preview file tree and dependencies without writing files | `false` |
85
- | `--skip-install` | Scaffold files without running package installation | `false` |
136
+ | `--github-actions` | Generate `.github/workflows/ci.yml` CI workflow | `false` |
137
+ | `--docker` | Generate multi-stage `Dockerfile` and `.dockerignore` | `false` |
138
+ | `--dry-run` | Preview files and packages without writing to disk | `false` |
139
+ | `--skip-install` | Scaffold files without executing package manager install | `false` |
86
140
 
87
- **Full-fledged Example:**
141
+ #### Non-Interactive Examples:
88
142
 
89
143
  ```bash
90
- genrex create billing-service \
91
- --blueprint node-api \
92
- --package-manager pnpm \
93
- --git \
94
- --github-actions \
95
- --docker
144
+ # Preview what would be created without writing any files
145
+ genrex create my-tool --blueprint ts-cli --dry-run
146
+
147
+ # Node.js API with pnpm, Git, and GitHub Actions
148
+ genrex create backend-service --blueprint node-api --package-manager pnpm --git --github-actions
149
+
150
+ # Lightweight library without waiting for dependency installation
151
+ genrex create math-utils --blueprint ts-lib --skip-install
152
+
153
+ # Full-stack microservice with Docker containerization
154
+ genrex create auth-service --blueprint node-api --docker --github-actions --git
96
155
  ```
97
156
 
98
157
  ---
99
158
 
100
- ### 2. Environment Doctor
159
+ ### 2. `genrex list`
101
160
 
102
- Diagnose your environment tools in one command:
161
+ List all built-in blueprint architectures:
162
+
163
+ ```bash
164
+ genrex list
165
+ ```
166
+
167
+ ```text
168
+ Available blueprints:
169
+
170
+ ts-cli TypeScript CLI (TypeScript)
171
+ Production-ready TypeScript CLI tool.
172
+
173
+ node-api Node.js API (TypeScript)
174
+ Node.js REST API with routing and healthchecks.
175
+
176
+ ts-lib TypeScript Library (TypeScript)
177
+ Publishable TypeScript library blueprint.
178
+ ```
179
+
180
+ ---
181
+
182
+ ### 3. `genrex info <blueprint-id>`
183
+
184
+ Inspect capabilities and metadata of any blueprint:
185
+
186
+ ```bash
187
+ genrex info node-api
188
+ ```
189
+
190
+ ```text
191
+ Node.js API (node-api)
192
+ Version: 1.0.0
193
+ Language: TypeScript
194
+ Description: Node.js REST API with routing and healthchecks.
195
+ Capabilities:
196
+ - testing
197
+ - formatting
198
+ - git
199
+ - github-actions
200
+ - docker
201
+ ```
202
+
203
+ ---
204
+
205
+ ### 4. `genrex doctor`
206
+
207
+ Audit your machine's environment and ensure required developer tools are installed:
103
208
 
104
209
  ```bash
105
210
  genrex doctor
@@ -122,27 +227,86 @@ Environment is ready.
122
227
 
123
228
  ---
124
229
 
125
- ## Design Principles
230
+ ## 🏗️ Available Blueprints & Project Structures
126
231
 
127
- - **Zero Unnecessary Bloat:** Fast execution with near-zero runtime dependencies.
128
- - **Fail Safely:** Refuses to overwrite non-empty directories; pre-validates all input and tools before modifying the disk.
129
- - **Modern Standards:** Native ESM, strict TypeScript, Biome linter/formatter, and Vitest by default.
130
- - **Cross-Platform:** Works seamlessly on Windows, macOS, and Linux.
232
+ ### 1. TypeScript CLI (`ts-cli`)
233
+ Tailored for building standalone developer tools and CLI applications.
234
+ ```text
235
+ my-cli/
236
+ ├── src/
237
+ │ └── index.ts # Executable binary entry point with shebang
238
+ ├── tests/
239
+ │ └── index.test.ts # Vitest unit test suite
240
+ ├── .gitignore
241
+ ├── biome.json # High-performance linter & formatter
242
+ ├── package.json # Configured with "bin" field and ESM
243
+ ├── tsconfig.json # Strict NodeNext configuration
244
+ └── README.md
245
+ ```
246
+
247
+ ### 2. Node.js API (`node-api`)
248
+ Production-ready REST API built with Fastify.
249
+ ```text
250
+ my-api/
251
+ ├── src/
252
+ │ └── server.ts # Fastify server with /health route
253
+ ├── tests/
254
+ │ └── server.test.ts # Vitest route testing
255
+ ├── .gitignore
256
+ ├── biome.json
257
+ ├── package.json # Development with "tsx watch" hot-reload
258
+ ├── tsconfig.json
259
+ └── README.md
260
+ ```
261
+
262
+ ### 3. TypeScript Library (`ts-lib`)
263
+ Ready for distribution on npm with dual type declarations.
264
+ ```text
265
+ my-lib/
266
+ ├── src/
267
+ │ └── index.ts # Library exports
268
+ ├── tests/
269
+ │ └── index.test.ts # Vitest test suite
270
+ ├── .gitignore
271
+ ├── .npmignore # Keeps source and tests out of npm tarball
272
+ ├── biome.json
273
+ ├── package.json # "exports", "main", "types", "prepublishOnly"
274
+ ├── tsconfig.json # Generates declaration maps (.d.ts)
275
+ └── README.md
276
+ ```
131
277
 
132
278
  ---
133
279
 
134
- ## Development
280
+ ## 🛡️ Safety & Core Philosophy
281
+
282
+ - **Zero Accidental Overwriting:** Refuses to generate files inside non-empty folders.
283
+ - **Shell Injection Safe:** Child processes use direct executable arguments (`shell: false`) rather than concatenated shell strings.
284
+ - **Fail Fast:** Project names, blueprint availability, and Git binary presence are validated before modifying the filesystem.
285
+ - **Zero Heavy Runtime Dependencies:** Blazing fast execution using native Node.js APIs (`node:readline/promises`, `node:child_process`, `node:fs`).
286
+
287
+ ---
288
+
289
+ ## 💻 Development & Contributing
290
+
291
+ Want to add new blueprints or improve the CLI?
135
292
 
136
293
  ```bash
294
+ # Clone the repository
137
295
  git clone https://github.com/waeterr/genrex.git
138
296
  cd genrex
297
+
298
+ # Install dev dependencies
139
299
  npm install
300
+
301
+ # Run automated tests (native Node test runner + TypeScript strip)
140
302
  npm test
303
+
304
+ # Build TypeScript to dist/
141
305
  npm run build
142
306
  ```
143
307
 
144
308
  ---
145
309
 
146
- ## License
310
+ ## 📄 License
147
311
 
148
312
  MIT © [waeterr](https://github.com/waeterr)
@@ -14,7 +14,9 @@ export async function createProject(name, options) {
14
14
  let targetGit = options.git;
15
15
  let targetCi = options.githubActions;
16
16
  let targetDocker = options.docker;
17
- if ((!targetName || options.interactive) && process.stdin.isTTY) {
17
+ const shouldPrompt = Boolean(process.stdin.isTTY) &&
18
+ (!targetName || options.interactive || (!options.blueprint && !options.dryRun));
19
+ if (shouldPrompt) {
18
20
  const answers = await promptWizard(targetName);
19
21
  targetName = answers.name;
20
22
  targetBlueprint = answers.blueprint;
package/dist/src/index.js CHANGED
@@ -23,7 +23,7 @@ switch (command) {
23
23
  break;
24
24
  case "--version":
25
25
  case "-v":
26
- console.log("0.2.0");
26
+ console.log("0.2.1");
27
27
  break;
28
28
  default:
29
29
  console.error(`Unknown command: ${command}`);
package/dist/src/pm.js CHANGED
@@ -5,6 +5,6 @@ export function installDependencies(pm, cwd) {
5
5
  execFileSync(cmd, ["install"], {
6
6
  cwd,
7
7
  stdio: "inherit",
8
- shell: false,
8
+ shell: isWindows,
9
9
  });
10
10
  }
@@ -6,11 +6,16 @@ export async function promptWizard(initialName) {
6
6
  try {
7
7
  console.log("\ngenrex — Project Blueprint Engine\n");
8
8
  let name = initialName;
9
- while (!name || name.trim() === "") {
10
- const answer = await rl.question("? Project name: ");
11
- name = answer.trim();
12
- if (!name) {
13
- console.log(" Project name cannot be empty.");
9
+ if (name) {
10
+ console.log(`? Project name: ${name}`);
11
+ }
12
+ else {
13
+ while (!name || name.trim() === "") {
14
+ const answer = await rl.question("? Project name: ");
15
+ name = answer.trim();
16
+ if (!name) {
17
+ console.log(" Project name cannot be empty.");
18
+ }
14
19
  }
15
20
  }
16
21
  console.log("\n? Choose a blueprint:");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genrex",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Forge production-ready TypeScript projects from blueprints",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -38,5 +38,8 @@
38
38
  },
39
39
  "engines": {
40
40
  "node": ">=20"
41
+ },
42
+ "dependencies": {
43
+ "genrex": "^0.1.0"
41
44
  }
42
45
  }