@dhruvinjs/appinit 1.0.0 → 1.0.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 (2) hide show
  1. package/README.md +128 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,128 @@
1
+ # @dhruvinjs/appinit
2
+
3
+ Backend project generator CLI.
4
+
5
+ This package creates an Express-based backend starter with optional WebSocket support (`ws` or `socket.io`), optional DB setup (`mongo` or `postgresql_prisma`), and optional Dockerfile generation.
6
+
7
+ ## Install and run
8
+
9
+ ```bash
10
+ npx @dhruvinjs/appinit my-app
11
+ ```
12
+
13
+ or install globally:
14
+
15
+ ```bash
16
+ npm i -g @dhruvinjs/appinit
17
+ appinit my-app
18
+ ```
19
+
20
+ ## What this CLI actually does
21
+
22
+ Source entrypoint: `src/index.ts`.
23
+
24
+ 1. Parses flags with `commander`.
25
+ 2. Prompts with `inquirer` for missing options.
26
+ 3. Validates project name/path safety.
27
+ 4. Creates project directory and runs package-manager init.
28
+ 5. Installs runtime dependencies.
29
+ 6. Installs dev dependencies (and TypeScript setup if selected).
30
+ 7. Runs `npx prisma init` for PostgreSQL + Prisma.
31
+ 8. Optionally installs `ws` or `socket.io`.
32
+ 9. Renders EJS templates from `appinit-templates` package into your new project.
33
+ 10. Optionally initializes git.
34
+
35
+ Core implementation files:
36
+
37
+ - `src/index.ts`: CLI flags, prompts, and config assembly.
38
+ - `src/generator/shell.ts`: project setup flow and command execution.
39
+ - `src/generator/template_engine.ts`: template rendering and file mapping.
40
+ - `src/utils/utils.ts`: safety checks, package.json/tsconfig updates, cleanup.
41
+ - `src/constants.ts`: dependency lists and allowed options.
42
+
43
+ ## Templates and publishing model
44
+
45
+ This CLI resolves templates at runtime from the separate package `appinit-templates`:
46
+
47
+ - `template_engine.ts` uses `require.resolve("appinit-templates/package.json")`.
48
+ - Because of this, `appinit-templates` must be available when users install this CLI.
49
+
50
+ ## Commands this CLI runs on your machine
51
+
52
+ Depending on options, it may run:
53
+
54
+ - `<pm> init` (or `npm init -y`)
55
+ - `<pm> pkg set name=<project-name>`
56
+ - `<pm> install ...`
57
+ - `<pm> install -D ...`
58
+ - `npx tsc --init` (TypeScript path)
59
+ - `npx prisma init` (PostgreSQL + Prisma path)
60
+ - `git init` (unless `--no-git`)
61
+
62
+ It also writes files into the generated project folder and may remove that folder on setup failure/cancel.
63
+
64
+ ## Flags
65
+
66
+ Preset flags:
67
+
68
+ - `--ts`, `--js`
69
+ - `--ts-rest`, `--js-rest`
70
+ - `--ts-ws`, `--js-ws`
71
+ - `--ts-io`, `--js-io`
72
+
73
+ Granular flags:
74
+
75
+ - `--template <rest_api|websocket+rest_api>`
76
+ - `--lang <js|ts>`
77
+ - `--db <none|mongo|postgresql_prisma>`
78
+ - `--ws <ws|socket.io>`
79
+ - `--docker` / `--no-docker`
80
+ - `--pm <npm|pnpm|yarn>`
81
+ - `--no-git`
82
+
83
+ ## Dependencies and why they exist
84
+
85
+ Runtime dependencies in this package:
86
+
87
+ - `commander`: CLI argument parsing.
88
+ - `inquirer`: interactive prompts.
89
+ - `execa`: safe process spawning for package manager/git/prisma commands.
90
+ - `ora`: spinner/progress output.
91
+ - `chalk`: colored terminal output.
92
+ - `fs-extra`: file operations for templates/config updates/cleanup.
93
+ - `ejs`: template rendering engine.
94
+ - `unique-names-generator`: default project name generation.
95
+ - `appinit-templates`: source of boilerplate templates.
96
+
97
+ Direct dependencies currently listed but not used directly by CLI source:
98
+
99
+ - `express`
100
+ - `cors`
101
+ - `helmet`
102
+ - `jsonwebtoken`
103
+
104
+ These libraries are generated-project dependencies. They are installed into created apps from `src/constants.ts`, not used as runtime imports by this CLI itself.
105
+
106
+ ## Trust and safety notes
107
+
108
+ - No telemetry/analytics calls are implemented in this package.
109
+ - It executes local shell commands and installs packages from your configured registry.
110
+ - It validates project names and blocks path traversal-style names.
111
+ - On failure or Ctrl+C/Ctrl+D, it tries to clean up the generated directory.
112
+ - It warns when git/docker tools are missing (generation still continues where possible).
113
+
114
+ ## Known behavior to be aware of
115
+
116
+ - Environment check currently always verifies `npm` and `npx` are present, even if you choose `pnpm` or `yarn`.
117
+ - Template resolution requires the `appinit-templates` package to be installable.
118
+
119
+ ## Develop locally
120
+
121
+ ```bash
122
+ pnpm --filter @dhruvinjs/appinit run build
123
+ pnpm --filter @dhruvinjs/appinit run dev
124
+ ```
125
+
126
+ ## License
127
+
128
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhruvinjs/appinit",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",