inikit 2.0.0 → 3.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.
- package/README.md +193 -35
- package/dist/index.js +118 -76
- package/dist/inikit.config.js +95 -0
- package/dist/package.json +30 -3
- package/dist/templates/authjs/.env +4 -0
- package/dist/templates/authjs/app/api/auth/[...nextauth]/route.ts +2 -0
- package/dist/templates/authjs/auth.ts +13 -0
- package/dist/templates/authjs/components/sign-in.tsx +15 -0
- package/dist/templates/authjs/components/sign-out.tsx +14 -0
- package/dist/templates/authjs/prisma/schema.prisma +78 -0
- package/dist/templates/commitlint/commitlint.config.cjs +26 -26
- package/dist/templates/express-ts/.dockerignore +1 -0
- package/dist/templates/express-ts/.env.example +11 -0
- package/dist/templates/express-ts/.husky/commit-msg +1 -0
- package/dist/templates/express-ts/.husky/pre-commit +1 -0
- package/dist/templates/express-ts/.prettierrc +10 -0
- package/dist/templates/express-ts/README.md +0 -0
- package/dist/templates/express-ts/commitlint.config.js +23 -0
- package/dist/templates/express-ts/docker/development/Dockerfile +20 -0
- package/dist/templates/express-ts/docker/production/Dockerfile +23 -0
- package/dist/templates/express-ts/ecosystem.config.js +13 -0
- package/dist/templates/express-ts/eslint.config.mjs +21 -0
- package/dist/templates/express-ts/migrations/.gitkeep +0 -0
- package/dist/templates/express-ts/nginx/http.conf +13 -0
- package/dist/templates/express-ts/nginx/https.conf +16 -0
- package/dist/templates/express-ts/nodemon.json +4 -0
- package/dist/templates/express-ts/package-lock.json +6115 -0
- package/dist/templates/express-ts/package.json +59 -0
- package/dist/templates/express-ts/public/.gitkeep +0 -0
- package/dist/templates/express-ts/script/.gitkeep +0 -0
- package/dist/templates/express-ts/script/migration.js +54 -0
- package/dist/templates/express-ts/src/app.ts +39 -0
- package/dist/templates/express-ts/src/config/config.ts +13 -0
- package/dist/templates/express-ts/src/config/rateLimiter.ts +15 -0
- package/dist/templates/express-ts/src/constant/application.ts +4 -0
- package/dist/templates/express-ts/src/constant/responseMessage.ts +6 -0
- package/dist/templates/express-ts/src/controller/apiController.ts +28 -0
- package/dist/templates/express-ts/src/middleware/globalErrorHandler.ts +7 -0
- package/dist/templates/express-ts/src/middleware/rateLimit.ts +23 -0
- package/dist/templates/express-ts/src/model/.gitkeep +0 -0
- package/dist/templates/express-ts/src/router/apiRouter.ts +9 -0
- package/dist/templates/express-ts/src/server.ts +40 -0
- package/dist/templates/express-ts/src/service/.gitkeep +0 -0
- package/dist/templates/express-ts/src/service/databaseService.ts +13 -0
- package/dist/templates/express-ts/src/types/types.ts +24 -0
- package/dist/templates/express-ts/src/util/errorObject.ts +35 -0
- package/dist/templates/express-ts/src/util/httpError.ts +8 -0
- package/dist/templates/express-ts/src/util/httpResponse.ts +31 -0
- package/dist/templates/express-ts/src/util/logger.ts +124 -0
- package/dist/templates/express-ts/src/util/quicker.ts +22 -0
- package/dist/templates/express-ts/src/view/.gitkeep +0 -0
- package/dist/templates/express-ts/test/.gitkeep +0 -0
- package/dist/templates/express-ts/tsconfig.json +108 -0
- package/dist/templates/prisma/prisma/schema.prisma +28 -0
- package/dist/templates/prisma/prisma.config.ts +10 -0
- package/dist/templates/prisma/prisma.ts +8 -0
- package/dist/templates/shadcn-vite/tsconfig.app.json +34 -0
- package/dist/templates/shadcn-vite/tsconfig.json +18 -0
- package/dist/templates/shadcn-vite/vite.config.ts +14 -0
- package/dist/templates/tailwind/index.css +70 -70
- package/dist/templates/tailwind/vite.config.js +8 -8
- package/dist/templates/tailwind/vite.config.ts +8 -8
- package/dist/templates/zod/lib/validator.ts +7 -0
- package/dist/templates/zustand/js/src/store/useStore.js +16 -0
- package/dist/templates/zustand/ts/src/store/useStore.ts +23 -0
- package/dist/tli.js +18 -12
- package/dist/utils.js +78 -8
- package/package.json +30 -3
package/README.md
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/inikit)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
|
-
[](https://github.com/ajaykumarn3000/inikit/issues)
|
|
8
|
+
[](https://github.com/ajaykumarn3000/inikit/stargazers)
|
|
9
|
+
[](https://github.com/ajaykumarn3000/inikit/network)
|
|
10
|
+
[](https://github.com/ajaykumarn3000/inikit/graphs/contributors)
|
|
11
11
|
|
|
12
12
|
</div>
|
|
13
13
|
|
|
@@ -45,16 +45,10 @@ Inikit solves this by providing:
|
|
|
45
45
|
|
|
46
46
|
### Using npx (Recommended)
|
|
47
47
|
|
|
48
|
-
The fastest way to scaffold a new project:
|
|
49
|
-
|
|
50
48
|
```bash
|
|
51
49
|
npx inikit@latest
|
|
52
50
|
```
|
|
53
51
|
|
|
54
|
-
### Global Installation
|
|
55
|
-
|
|
56
|
-
For repeated use, install globally:
|
|
57
|
-
|
|
58
52
|
```bash
|
|
59
53
|
npm install -g inikit
|
|
60
54
|
inikit
|
|
@@ -83,7 +77,9 @@ inikit
|
|
|
83
77
|
|
|
84
78
|
## 📋 Usage
|
|
85
79
|
|
|
86
|
-
|
|
80
|
+
### Interactive (Prompts)
|
|
81
|
+
|
|
82
|
+
When you run Inikit without flags, you'll be prompted to:
|
|
87
83
|
|
|
88
84
|
1. **Project Name**: Enter your project name (lowercase, no spaces)
|
|
89
85
|
2. **Framework**: Choose between Next.js or React
|
|
@@ -93,16 +89,167 @@ When you run Inikit, you'll be prompted to:
|
|
|
93
89
|
```bash
|
|
94
90
|
$ npx inikit@latest
|
|
95
91
|
|
|
96
|
-
Welcome to Inikit
|
|
92
|
+
Welcome to Inikit v3.0.0
|
|
97
93
|
|
|
98
94
|
✔ Enter the project name › my-awesome-app
|
|
99
95
|
✔ Select a framework › Next.js
|
|
100
96
|
✔ Do you want to use TypeScript? › Yes
|
|
101
97
|
✔ Select dev tools › Tailwind CSS, Prettier, Husky
|
|
102
98
|
|
|
103
|
-
✅ Project initialized successfully!
|
|
104
99
|
```
|
|
105
100
|
|
|
101
|
+
### Non-Interactive (Flags)
|
|
102
|
+
|
|
103
|
+
Skip all prompts by providing options via flags. This is CI-friendly and great
|
|
104
|
+
for automation.
|
|
105
|
+
|
|
106
|
+
Examples:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
|
|
110
|
+
# Next.js + TypeScript with recommended tools (Tailwind, Prettier, Commitlint)
|
|
111
|
+
npx inikit my-app --next --ts --tools
|
|
112
|
+
|
|
113
|
+
# React + JavaScript with no dev tools and no git init
|
|
114
|
+
npx inikit my-app --react --js --no-tools --no-git
|
|
115
|
+
|
|
116
|
+
# React + TypeScript with only Tailwind and Prettier
|
|
117
|
+
npx inikit my-app --react --ts --tailwind --prettier
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Note:
|
|
122
|
+
|
|
123
|
+
- Do not combine framework flags together: use either `--next` or `--react`.
|
|
124
|
+
- Do not combine language flags together: use either `--ts` or `--js`.
|
|
125
|
+
- If you don't pass `--tools`, you can choose tools individually with
|
|
126
|
+
`--tailwind`, `--prettier`, and/or `--commitlint`.
|
|
127
|
+
|
|
128
|
+
#### CLI reference
|
|
129
|
+
|
|
130
|
+
Below are the main CLI flags and options. Flags can be used together or in CI
|
|
131
|
+
scripts to skip interactive prompts.
|
|
132
|
+
|
|
133
|
+
General options
|
|
134
|
+
|
|
135
|
+
| Flag / Argument | Purpose |
|
|
136
|
+
| ----------------- | ----------------------------------------------------------------------------- |
|
|
137
|
+
| `[directory]` | Target directory or project name to create (positional). |
|
|
138
|
+
| `-v`, `--version` | Print Inikit version (from `package.json`). |
|
|
139
|
+
| `-h`, `--help` | Show help and available options. |
|
|
140
|
+
| `--no-git` | Skip initializing a Git repository in the created project. |
|
|
141
|
+
| `--tools` | Use the recommended dev tools (recommended tools are marked below). |
|
|
142
|
+
| `--no-tools` | Skip automatic dev tool setup. Useful for minimal projects or custom tooling. |
|
|
143
|
+
|
|
144
|
+
Framework / language selection
|
|
145
|
+
|
|
146
|
+
| Flag | Behavior |
|
|
147
|
+
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
148
|
+
| `--next`, `--nextjs` | Initialize a Next.js project (uses `create-next-app`). Conflicts with `--react` and `--express`. |
|
|
149
|
+
| `--react`, `--reactjs` | Initialize a React project scaffolded with Vite. Conflicts with `--next` and `--express`. |
|
|
150
|
+
| `--express`, `--expressjs` | Initialize an Express.js TypeScript template (Express currently requires TypeScript). Conflicts with `--next` and `--react`. |
|
|
151
|
+
| `--ts`, `--typescript` | Generate TypeScript-based projects (default for most flows). Conflicts with `--js`. |
|
|
152
|
+
| `--js`, `--javascript` | Generate JavaScript-based projects. Conflicts with `--ts`. |
|
|
153
|
+
|
|
154
|
+
Tool-specific flags
|
|
155
|
+
|
|
156
|
+
The CLI dynamically adds one flag per tool defined in `inikit.config.ts`. Each
|
|
157
|
+
tool has a `baseName` and sometimes an `otherName` to provide a short flag
|
|
158
|
+
alias.
|
|
159
|
+
|
|
160
|
+
Use `--<baseName>` (or `--<otherName>` when available) to enable a specific tool
|
|
161
|
+
in non-interactive mode. When enabled, the CLI will validate language/framework
|
|
162
|
+
requirements and also add any tool dependencies automatically.
|
|
163
|
+
|
|
164
|
+
### Tools reference (flags and requirements)
|
|
165
|
+
|
|
166
|
+
The following table lists each tool flag available via the CLI (these are
|
|
167
|
+
defined in `inikit.config.ts`). For tools with an `otherName`, both flags are
|
|
168
|
+
accepted (e.g. `--tailwindcss` and `--tailwind`). The `Recommended` column
|
|
169
|
+
indicates whether the tool is included when you pass `--tools`.
|
|
170
|
+
|
|
171
|
+
| Flag(s) | Description | Recommended | Languages | Frameworks | Dependencies |
|
|
172
|
+
| ----------------------------- | -------------------------------------------------------------------------------------- | ----------: | --------- | -------------------------- | ------------- |
|
|
173
|
+
| `--tailwindcss`, `--tailwind` | Adds Tailwind CSS config and styles. | Yes | js, ts | reactjs, nextjs | — |
|
|
174
|
+
| `--eslint`, `--lint` | Adds ESLint configuration. | Yes | js, ts | reactjs, nextjs, expressjs | — |
|
|
175
|
+
| `--prettier` | Adds Prettier configuration and formatting helpers. | Yes | js, ts | reactjs, nextjs, expressjs | — |
|
|
176
|
+
| `--commitlint` | Adds Commitlint and Husky hooks for conventional commits. | Yes | js, ts | reactjs, nextjs, expressjs | — |
|
|
177
|
+
| `--shadcn` | Installs shadcn UI, copies Vite config and runs `shadcn init`. (TypeScript only). | No | ts | reactjs, nextjs | `tailwindcss` |
|
|
178
|
+
| `--prisma` | Adds Prisma ORM scaffold and installs `@prisma/client`. (TypeScript + Next.js). | No | ts | nextjs | — |
|
|
179
|
+
| `--authjs`, `--auth` | Adds Auth.js (next-auth) templates and runs `npx auth secret`. (TypeScript + Next.js). | No | ts | nextjs | `prisma` |
|
|
180
|
+
| `--zod` | Adds Zod validation templates. | No | ts | reactjs, nextjs | — |
|
|
181
|
+
| `--zustand` | Adds Zustand state store templates (JS/TS variants available). | No | ts | reactjs, nextjs | — |
|
|
182
|
+
|
|
183
|
+
Notes:
|
|
184
|
+
|
|
185
|
+
- Flags will be validated at runtime — if a tool requires TypeScript or a
|
|
186
|
+
specific framework and the provided flags don't match, the CLI will exit with
|
|
187
|
+
an error explaining the missing requirement.
|
|
188
|
+
- The `--tools` meta-flag will enable the recommended tools (`tailwindcss`,
|
|
189
|
+
`eslint`, `prettier`, `commitlint`) unless you explicitly pass other tool
|
|
190
|
+
flags.
|
|
191
|
+
- `--no-tools` disables all automatic tool installs.
|
|
192
|
+
|
|
193
|
+
### Templates included
|
|
194
|
+
|
|
195
|
+
The `templates/` folder contains template files copied into generated projects
|
|
196
|
+
when tools are enabled. Major template groups:
|
|
197
|
+
|
|
198
|
+
- `commitlint/` — commitlint configuration
|
|
199
|
+
- `husky/` — pre-configured Husky hooks (`pre-commit`, `commit-msg`)
|
|
200
|
+
- `prettier/` — `.prettierrc` and `.prettierignore`
|
|
201
|
+
- `tailwind/` — `vite.config` snippets and `index.css` bootstrap
|
|
202
|
+
- `shadcn-vite/` — Vite config and tsconfig snippets to support shadcn UI
|
|
203
|
+
- `prisma/` — `prisma` config and `schema.prisma` starter
|
|
204
|
+
- `authjs/` — example Auth.js/next-auth files and `.env` example
|
|
205
|
+
- `express-ts/` — an Express TypeScript starter used when `--express` is chosen
|
|
206
|
+
- `zod/` — example `validator.ts` and helper files
|
|
207
|
+
- `zustand/` — JS and TS store example implementations
|
|
208
|
+
|
|
209
|
+
If you add new tools in `inikit.config.ts`, the CLI will automatically expose
|
|
210
|
+
`--<baseName>` flags and include them in the interactive prompt options (via
|
|
211
|
+
`tli.ts`).
|
|
212
|
+
|
|
213
|
+
## ⚙️ How the CLI works (behind the scenes)
|
|
214
|
+
|
|
215
|
+
High-level flow when running `inikit` (interactive or non-interactive):
|
|
216
|
+
|
|
217
|
+
1. Validate and parse flags (commander). Conflicting flags are rejected (e.g.
|
|
218
|
+
`--next` vs `--react`).
|
|
219
|
+
2. Validate the project name using `validateProjectName` (`utils.ts`).
|
|
220
|
+
3. If interactive, prompt for framework, language, and dev tools (`tli.ts`).
|
|
221
|
+
4. Create the base project depending on the framework:
|
|
222
|
+
|
|
223
|
+
- Next.js: runs `npx create-next-app` (with `--ts` / `--js`, `--tailwind` when
|
|
224
|
+
requested).
|
|
225
|
+
- React (Vite): runs `npx create-vite` with `react` or `react-ts` template.
|
|
226
|
+
- Express (TypeScript): copies the `templates/express-ts` starter and installs
|
|
227
|
+
its dependencies.
|
|
228
|
+
|
|
229
|
+
5. For each selected tool, run the corresponding helper in `utils.ts` which
|
|
230
|
+
usually:
|
|
231
|
+
|
|
232
|
+
- Installs npm packages (dev or runtime)
|
|
233
|
+
- Copies template files from `templates/<tool>` into the new project
|
|
234
|
+
- Runs additional CLI helpers (for example: `npx shadcn init`,
|
|
235
|
+
`npx prisma generate`, `npx auth secret`, `npx husky init`).
|
|
236
|
+
|
|
237
|
+
6. Initialize Git (unless `--no-git` was passed).
|
|
238
|
+
7. Print a success message and exit.
|
|
239
|
+
|
|
240
|
+
Notes & edge cases:
|
|
241
|
+
|
|
242
|
+
- Tools are validated against `language` and `framework` requirements defined in
|
|
243
|
+
`inikit.config.ts`. If a tool requires TypeScript or a specific framework and
|
|
244
|
+
the flags don't match, the CLI exits with a clear error.
|
|
245
|
+
- When running with `--tools`, the CLI will enable all `recommended: true` tools
|
|
246
|
+
(see `inikit.config.ts`). You can override that by passing individual tool
|
|
247
|
+
flags.
|
|
248
|
+
- Express currently relies on a TypeScript starter; the code forces `typescript`
|
|
249
|
+
for Express-created projects (see `index.ts`).
|
|
250
|
+
- The CLI uses `execa` to run external commands; these subprocesses will emit
|
|
251
|
+
output to the terminal (e.g., `npx create-next-app`, `npm install`).
|
|
252
|
+
|
|
106
253
|
## 🏗️ Local Development
|
|
107
254
|
|
|
108
255
|
Want to contribute to Inikit or test changes locally? Here's how to get started:
|
|
@@ -117,7 +264,7 @@ Want to contribute to Inikit or test changes locally? Here's how to get started:
|
|
|
117
264
|
|
|
118
265
|
```bash
|
|
119
266
|
# Clone the repository
|
|
120
|
-
git clone https://github.com/
|
|
267
|
+
git clone https://github.com/ajaykumarn3000/inikit.git
|
|
121
268
|
cd Inikit
|
|
122
269
|
|
|
123
270
|
# Install dependencies
|
|
@@ -139,28 +286,32 @@ npm unlink -g inikit
|
|
|
139
286
|
|
|
140
287
|
### Available Scripts
|
|
141
288
|
|
|
142
|
-
| Script | Description
|
|
143
|
-
| ---------------------- |
|
|
144
|
-
| `npm run dev` | Run the CLI in development mode with `tsx`
|
|
145
|
-
| `npm run build` | Build the project for production
|
|
146
|
-
| `npm run lint` | Run ESLint to check for code issues
|
|
147
|
-
| `npm run lint:fix` | Auto-fix ESLint issues where possible
|
|
148
|
-
| `npm run format` | Format code with Prettier
|
|
149
|
-
| `npm run format:check` | Check if code is properly formatted
|
|
150
|
-
| `npm run clean` | Remove the `dist` directory
|
|
151
|
-
| `npm run deploy` | Build and publish to npm (maintainers only)
|
|
289
|
+
| Script | Description |
|
|
290
|
+
| ---------------------- | -------------------------------------------------------------------- |
|
|
291
|
+
| `npm run dev` | Run the CLI in development mode with `tsx` |
|
|
292
|
+
| `npm run build` | Build the project for production |
|
|
293
|
+
| `npm run lint` | Run ESLint to check for code issues |
|
|
294
|
+
| `npm run lint:fix` | Auto-fix ESLint issues where possible |
|
|
295
|
+
| `npm run format` | Format code with Prettier |
|
|
296
|
+
| `npm run format:check` | Check if code is properly formatted |
|
|
297
|
+
| `npm run clean` | Remove the `dist` directory |
|
|
298
|
+
| `npm run deploy` | Build and publish to npm (maintainers only) |
|
|
299
|
+
| `npm run prepare` | Run `husky` prepare script to set up git hooks (used by CI/prepare). |
|
|
152
300
|
|
|
153
301
|
### Project Structure
|
|
154
302
|
|
|
155
303
|
```text
|
|
156
304
|
Inikit/
|
|
157
305
|
├── index.ts # Main CLI entry point
|
|
158
|
-
├──
|
|
306
|
+
├── tli.ts # Interactive prompt helpers
|
|
307
|
+
├── utils.ts # Core utility functions (commands to scaffold and add tools)
|
|
308
|
+
├── inikit.config.ts # Tool configuration (defines flags, requirements, and templates)
|
|
159
309
|
├── package.json # Project configuration
|
|
160
|
-
├── templates/ # Template files for different tools
|
|
310
|
+
├── templates/ # Template files for different tools (copied into generated projects)
|
|
161
311
|
│ ├── commitlint/ # Commitlint configuration
|
|
162
312
|
│ ├── husky/ # Git hooks
|
|
163
313
|
│ ├── prettier/ # Prettier configuration
|
|
314
|
+
│ ├── shadcn-vite/ # Shadcn UI Vite/TypeScript template files
|
|
164
315
|
│ └── tailwind/ # Tailwind CSS files
|
|
165
316
|
├── dist/ # Compiled output (created after build)
|
|
166
317
|
└── README.md # This file
|
|
@@ -182,19 +333,19 @@ We're here to help! If you encounter any issues or have questions:
|
|
|
182
333
|
### 🚨 Bug Reports
|
|
183
334
|
|
|
184
335
|
- **GitHub Issues**:
|
|
185
|
-
[Report bugs here](https://github.com/
|
|
336
|
+
[Report bugs here](https://github.com/ajaykumarn3000/inikit/issues)
|
|
186
337
|
- Please use our bug report template for faster resolution
|
|
187
338
|
|
|
188
339
|
### 💡 Feature Requests
|
|
189
340
|
|
|
190
341
|
- **GitHub Discussions**:
|
|
191
|
-
[Suggest new features](https://github.com/
|
|
342
|
+
[Suggest new features](https://github.com/ajaykumarn3000/inikit/discussions)
|
|
192
343
|
- Help us understand your use case and requirements
|
|
193
344
|
|
|
194
345
|
### ❓ Questions and Support
|
|
195
346
|
|
|
196
347
|
- **GitHub Discussions**:
|
|
197
|
-
[Ask questions here](https://github.com/
|
|
348
|
+
[Ask questions here](https://github.com/ajaykumarn3000/inikit/discussions)
|
|
198
349
|
- **Documentation**: Check our README for common use cases
|
|
199
350
|
- **Examples**: Look at the templates directory for configuration examples
|
|
200
351
|
|
|
@@ -229,6 +380,13 @@ report security vulnerabilities through public GitHub issues.
|
|
|
229
380
|
- **Maintained**: ✅ Actively maintained
|
|
230
381
|
- **Node.js**: 18.0+ required
|
|
231
382
|
|
|
383
|
+
### Key dependencies
|
|
384
|
+
|
|
385
|
+
- Runtime: `@clack/prompts` (interactive prompts), `chalk` (colors), `commander`
|
|
386
|
+
(CLI parsing), `execa` (shell commands), `tsx` (dev runner)
|
|
387
|
+
- Dev: `eslint`, `prettier`, `husky`, `@commitlint/cli`,
|
|
388
|
+
`@commitlint/config-conventional`, `typescript`
|
|
389
|
+
|
|
232
390
|
## 🗺️ Roadmap
|
|
233
391
|
|
|
234
392
|
We're continuously working to improve Inikit. Here's what's on our radar:
|
|
@@ -238,7 +396,7 @@ We're continuously working to improve Inikit. Here's what's on our radar:
|
|
|
238
396
|
- [ ] **Package Managers**: Yarn, pnpm support
|
|
239
397
|
- [ ] **Templates**: More starter templates
|
|
240
398
|
- [ ] **CI/CD**: GitHub Actions, GitLab CI templates
|
|
241
|
-
- [ ] **Database**:
|
|
399
|
+
- [ ] **Database**: Drizzle integration options
|
|
242
400
|
- [ ] **UI Libraries**: More component library options
|
|
243
401
|
|
|
244
402
|
Want to contribute to any of these? We'd love your help!
|
|
@@ -269,13 +427,13 @@ better and more accessible.
|
|
|
269
427
|
|
|
270
428
|
<div align="center">
|
|
271
429
|
|
|
272
|
-
**Made with ❤️ by [
|
|
430
|
+
**Made with ❤️ by [Ajaykumar Nadar](https://github.com/ajaykumarn3000/)**
|
|
273
431
|
|
|
274
432
|
_Building tools that developers love to use_
|
|
275
433
|
|
|
276
|
-
[⭐ Star on GitHub](https://github.com/
|
|
277
|
-
[🐛 Report Bug](https://github.com/
|
|
278
|
-
[💡 Request Feature](https://github.com/
|
|
279
|
-
[🤝 Contribute](https://github.com/
|
|
434
|
+
[⭐ Star on GitHub](https://github.com/ajaykumarn3000/inikit) •
|
|
435
|
+
[🐛 Report Bug](https://github.com/ajaykumarn3000/inikit/issues) •
|
|
436
|
+
[💡 Request Feature](https://github.com/ajaykumarn3000/inikit/discussions) •
|
|
437
|
+
[🤝 Contribute](https://github.com/ajaykumarn3000/inikit/blob/main/CONTRIBUTING.md)
|
|
280
438
|
|
|
281
439
|
</div>
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import * as p from '@clack/prompts';
|
|
3
3
|
import { chalkStderr } from 'chalk';
|
|
4
|
-
import { addCommitlint, addGit, addPrettier, createNextApp, createReactApp, addTailwind, titleCase, runTaskAnimation, validateProjectName, } from './utils.js';
|
|
4
|
+
import { addCommitlint, addGit, addPrettier, createNextApp, createReactApp, addTailwind, titleCase, runTaskAnimation, validateProjectName, addShadcnConfigForVite, addShadcnUi, addPrisma, addZustand, createExpressApp, addZod, addAuthJs, } from './utils.js';
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import packageJSON from './package.json' with { type: 'json' };
|
|
7
7
|
import { getDevtools, getFramework, getProjectName, getTypeScript, } from './tli.js';
|
|
8
|
-
import {
|
|
8
|
+
import { toolsConfig } from './inikit.config.js';
|
|
9
|
+
import { Command, Option } from 'commander';
|
|
9
10
|
const { green, yellow } = chalkStderr;
|
|
10
11
|
const handleSigTerm = () => process.exit(0);
|
|
11
12
|
process.on('SIGINT', handleSigTerm);
|
|
@@ -16,87 +17,128 @@ async function main() {
|
|
|
16
17
|
.argument('[directory]')
|
|
17
18
|
.usage('[directory] [options]')
|
|
18
19
|
.helpOption('-h, --help', 'Display this help message.')
|
|
19
|
-
.
|
|
20
|
-
.
|
|
21
|
-
.
|
|
22
|
-
.
|
|
23
|
-
.
|
|
24
|
-
|
|
25
|
-
.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
.
|
|
29
|
-
.
|
|
20
|
+
.addOption(new Option('--next, --nextjs', 'Initialize as a Next.js project.').conflicts(['reactjs', 'expressjs']))
|
|
21
|
+
.addOption(new Option('--react, --reactjs', 'Initialize as a React project.').conflicts(['nextjs', 'expressjs']))
|
|
22
|
+
.addOption(new Option('--express, --expressjs', 'Initialize as an Express.js project.').conflicts(['nextjs', 'reactjs']))
|
|
23
|
+
.addOption(new Option('--ts, --typescript', 'Initialize as a TypeScript project. (default)').conflicts('javascript'))
|
|
24
|
+
.addOption(new Option('--js, --javascript', 'Initialize as a JavaScript project.').conflicts('typescript'));
|
|
25
|
+
for (const tool of toolsConfig) {
|
|
26
|
+
program.addOption(new Option(`${tool.otherName ? `--${tool.otherName}, ` : ''}--${tool.baseName}`, `${tool.description}`));
|
|
27
|
+
}
|
|
28
|
+
program
|
|
29
|
+
.addOption(new Option('--no-git', 'Skip git initialization.'))
|
|
30
|
+
.addOption(new Option('--tools', 'Use recommended dev tools.'))
|
|
31
|
+
.addOption(new Option(`--no-tools`, 'Skip all dev tools setup.'))
|
|
30
32
|
.allowUnknownOption()
|
|
31
33
|
.parse(process.argv);
|
|
32
34
|
const opts = program.opts(); // Get options
|
|
33
35
|
const { args } = program; // Get positional arguments (ProjectName)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
process.exit(1);
|
|
37
|
-
}
|
|
38
|
-
if (opts.nextjs && opts.reactjs) {
|
|
39
|
-
p.log.error('Cannot use both --nextjs and --reactjs flags together.');
|
|
40
|
-
process.exit(1);
|
|
41
|
-
}
|
|
42
|
-
p.log.info(`Welcome to ${green(titleCase(packageJSON.name) + ' v' + packageJSON.version)}`);
|
|
43
|
-
const projectNameError = validateProjectName(args[0] ?? 'my-app');
|
|
44
|
-
if (typeof projectNameError === 'string') {
|
|
45
|
-
p.log.error(projectNameError);
|
|
46
|
-
process.exit(1);
|
|
47
|
-
}
|
|
48
|
-
const projectName = args[0] ?? (await getProjectName());
|
|
49
|
-
const framework = opts.nextjs
|
|
50
|
-
? 'next'
|
|
51
|
-
: opts.reactjs
|
|
52
|
-
? 'react'
|
|
53
|
-
: await getFramework();
|
|
54
|
-
const typeScript = opts.typescript
|
|
55
|
-
? true
|
|
36
|
+
const language = opts.typescript
|
|
37
|
+
? 'typescript'
|
|
56
38
|
: opts.javascript
|
|
57
|
-
?
|
|
58
|
-
:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
else {
|
|
77
|
-
devTools = await getDevtools();
|
|
78
|
-
}
|
|
79
|
-
const projectPath = path.resolve(process.cwd(), projectName);
|
|
80
|
-
if (framework === 'next') {
|
|
81
|
-
await runTaskAnimation(`Creating a new Next.js app in ${yellow(projectPath)}`, `Created ${projectName} at ${projectPath}`, () => createNextApp(projectName, typeScript, devTools.has('tailwind')));
|
|
82
|
-
}
|
|
83
|
-
else if (framework === 'react') {
|
|
84
|
-
await runTaskAnimation(`Creating a new React app in ${yellow(projectPath)}`, `Created ${projectName} at ${projectPath}`, () => createReactApp(projectName, typeScript));
|
|
85
|
-
if (devTools.has('tailwind')) {
|
|
86
|
-
await runTaskAnimation(`Adding Tailwind CSS to the project`, `Added Tailwind CSS configuration`, () => addTailwind(projectPath, typeScript));
|
|
39
|
+
? 'javascript'
|
|
40
|
+
: null;
|
|
41
|
+
const frameworkOpt = opts.nextjs
|
|
42
|
+
? 'nextjs'
|
|
43
|
+
: opts.reactjs
|
|
44
|
+
? 'reactjs'
|
|
45
|
+
: opts.expressjs
|
|
46
|
+
? 'expressjs'
|
|
47
|
+
: null;
|
|
48
|
+
for (const tool of toolsConfig) {
|
|
49
|
+
if (opts[tool.baseName]) {
|
|
50
|
+
if (language ? !tool.language.includes(language) : true) {
|
|
51
|
+
p.log.error(`--${tool.baseName} requires --${tool.language.join(' or --')} to be set.`);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
if (frameworkOpt ? !tool.frameworks.includes(frameworkOpt) : true) {
|
|
55
|
+
p.log.error(`--${tool.baseName} requires --${tool.frameworks.join(' or --')} to be set.`);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
87
58
|
}
|
|
59
|
+
p.log.info(`Welcome to ${green(titleCase(packageJSON.name) + ' v' + packageJSON.version)}`);
|
|
60
|
+
const projectNameError = validateProjectName(args[0] ?? 'my-app');
|
|
61
|
+
if (typeof projectNameError === 'string') {
|
|
62
|
+
p.log.error(projectNameError);
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
const projectName = args[0] ?? (await getProjectName());
|
|
66
|
+
const framework = opts.nextjs
|
|
67
|
+
? 'nextjs'
|
|
68
|
+
: opts.reactjs
|
|
69
|
+
? 'reactjs'
|
|
70
|
+
: opts.expressjs
|
|
71
|
+
? 'expressjs'
|
|
72
|
+
: await getFramework();
|
|
73
|
+
const projectPath = path.resolve(process.cwd(), projectName);
|
|
74
|
+
const typeScript = opts.typescript || framework === 'expressjs' // !TODO: remove this when JS support is added for express
|
|
75
|
+
? true
|
|
76
|
+
: opts.javascript
|
|
77
|
+
? false
|
|
78
|
+
: await getTypeScript();
|
|
79
|
+
let devTools = new Set();
|
|
80
|
+
if (toolsConfig.reduce((acc, tool) => acc && !opts[tool.baseName], !opts.tools)) {
|
|
81
|
+
devTools = await getDevtools(framework, typeScript);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
toolsConfig.forEach(tool => {
|
|
85
|
+
if (opts[tool.baseName]) {
|
|
86
|
+
devTools.add(tool.baseName);
|
|
87
|
+
if (tool.dependencies) {
|
|
88
|
+
tool.dependencies.forEach(dep => devTools.add(dep));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
switch (framework) {
|
|
94
|
+
case 'nextjs':
|
|
95
|
+
await runTaskAnimation(`Creating a new Next.js app in ${yellow(projectPath)}`, `Created ${projectName} at ${projectPath}`, () => createNextApp(projectName, typeScript, devTools.has('tailwindcss')));
|
|
96
|
+
break;
|
|
97
|
+
case 'reactjs':
|
|
98
|
+
await runTaskAnimation(`Creating a new React app in ${yellow(projectPath)}`, `Created ${projectName} at ${projectPath}`, () => createReactApp(projectName, typeScript));
|
|
99
|
+
if (devTools.has('tailwindcss')) {
|
|
100
|
+
await runTaskAnimation(`Adding Tailwind CSS to the project`, `Added Tailwind CSS configuration`, () => addTailwind(projectPath, typeScript));
|
|
101
|
+
}
|
|
102
|
+
break;
|
|
103
|
+
case 'expressjs':
|
|
104
|
+
await runTaskAnimation(`Creating a new Express TypeScript app in ${yellow(projectPath)}`, `Created Express TypeScript app at ${projectPath}`, () => createExpressApp(projectPath, typeScript));
|
|
105
|
+
break;
|
|
106
|
+
default:
|
|
107
|
+
p.log.error('Invalid framework selected.');
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
if (devTools.has('prettier')) {
|
|
111
|
+
await runTaskAnimation(`Adding prettier to the project`, `Added prettier configuration`, () => addPrettier(projectPath));
|
|
112
|
+
}
|
|
113
|
+
if (devTools.has('commitlint')) {
|
|
114
|
+
await runTaskAnimation(`Adding husky and commitlint to the project`, `Added husky and commitlint configuration`, () => addCommitlint(projectPath));
|
|
115
|
+
}
|
|
116
|
+
if (devTools.has('shadcn')) {
|
|
117
|
+
await runTaskAnimation(`Adding shadcn UI to the project`, `Added shadcn UI configuration`, async () => {
|
|
118
|
+
if (framework === 'reactjs') {
|
|
119
|
+
addShadcnConfigForVite(projectPath);
|
|
120
|
+
}
|
|
121
|
+
await addShadcnUi(projectPath);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
if (devTools.has('prisma')) {
|
|
125
|
+
await runTaskAnimation(`Adding Prisma ORM to the project`, `Added Prisma ORM configuration`, () => addPrisma(projectPath));
|
|
126
|
+
}
|
|
127
|
+
if (devTools.has('authjs')) {
|
|
128
|
+
await runTaskAnimation(`Adding Auth.js to the project`, `Added Auth.js configuration`, () => addAuthJs(projectPath));
|
|
129
|
+
}
|
|
130
|
+
if (devTools.has('zustand')) {
|
|
131
|
+
await runTaskAnimation(`Adding Zustand state management`, `Added Zustand configuration`, () => addZustand(projectPath, typeScript));
|
|
132
|
+
}
|
|
133
|
+
if (devTools.has('zod')) {
|
|
134
|
+
await runTaskAnimation(`Adding Zod validation library`, `Added Zod configuration`, () => addZod(projectPath));
|
|
135
|
+
}
|
|
136
|
+
if (opts.git !== false) {
|
|
137
|
+
await runTaskAnimation(`Initializing git repository`, `Initialized git repository`, () => addGit(projectPath));
|
|
138
|
+
}
|
|
139
|
+
p.outro(green(`Project initialized successfully! Happy coding!`));
|
|
140
|
+
process.exit(0);
|
|
88
141
|
}
|
|
89
|
-
if (devTools.has('prettier')) {
|
|
90
|
-
await runTaskAnimation(`Adding prettier to the project`, `Added prettier configuration`, () => addPrettier(projectPath));
|
|
91
|
-
}
|
|
92
|
-
if (devTools.has('commitlint')) {
|
|
93
|
-
await runTaskAnimation(`Adding husky and commitlint to the project`, `Added husky and commitlint configuration`, () => addCommitlint(projectPath));
|
|
94
|
-
}
|
|
95
|
-
if (opts.git !== false) {
|
|
96
|
-
await runTaskAnimation(`Initializing git repository`, `Initialized git repository`, () => addGit(projectPath));
|
|
97
|
-
}
|
|
98
|
-
p.outro(green(`Project initialized successfully! Happy coding!`));
|
|
99
|
-
process.exit(0);
|
|
100
142
|
}
|
|
101
143
|
main().catch(err => {
|
|
102
144
|
console.error(err);
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export const toolsConfig = [
|
|
2
|
+
{
|
|
3
|
+
baseName: 'tailwindcss',
|
|
4
|
+
otherName: 'tailwind',
|
|
5
|
+
description: 'A utility-first CSS framework for rapid UI development.',
|
|
6
|
+
label: 'Tailwind CSS',
|
|
7
|
+
hint: 'utility-first CSS',
|
|
8
|
+
recommended: true,
|
|
9
|
+
language: ['javascript', 'typescript'],
|
|
10
|
+
dependencies: [],
|
|
11
|
+
frameworks: ['reactjs', 'nextjs'],
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
baseName: 'eslint',
|
|
15
|
+
otherName: 'lint',
|
|
16
|
+
description: 'A pluggable linting utility for JavaScript and TypeScript.',
|
|
17
|
+
label: 'ESLint',
|
|
18
|
+
hint: 'pluggable linting',
|
|
19
|
+
recommended: true,
|
|
20
|
+
language: ['javascript', 'typescript'],
|
|
21
|
+
dependencies: [],
|
|
22
|
+
frameworks: ['reactjs', 'nextjs', 'expressjs'],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
baseName: 'prettier',
|
|
26
|
+
description: 'An opinionated code formatter for JavaScript and TypeScript.',
|
|
27
|
+
label: 'Prettier',
|
|
28
|
+
hint: 'opinionated code formatting',
|
|
29
|
+
recommended: true,
|
|
30
|
+
language: ['javascript', 'typescript'],
|
|
31
|
+
dependencies: [],
|
|
32
|
+
frameworks: ['reactjs', 'nextjs', 'expressjs'],
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
baseName: 'commitlint',
|
|
36
|
+
description: 'A linter for commit messages.',
|
|
37
|
+
label: 'Commitlint',
|
|
38
|
+
hint: 'linter for commit messages',
|
|
39
|
+
recommended: true,
|
|
40
|
+
language: ['javascript', 'typescript'],
|
|
41
|
+
dependencies: [],
|
|
42
|
+
frameworks: ['reactjs', 'nextjs', 'expressjs'],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
baseName: 'shadcn',
|
|
46
|
+
description: 'A set of UI components for React.',
|
|
47
|
+
recommended: false,
|
|
48
|
+
label: 'Shadcn',
|
|
49
|
+
hint: 'UI components for React',
|
|
50
|
+
language: ['typescript'],
|
|
51
|
+
dependencies: ['tailwindcss'],
|
|
52
|
+
frameworks: ['reactjs', 'nextjs'],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
baseName: 'prisma',
|
|
56
|
+
description: 'A next-generation ORM for Node.js and TypeScript.',
|
|
57
|
+
recommended: false,
|
|
58
|
+
label: 'Prisma',
|
|
59
|
+
hint: 'next-generation ORM',
|
|
60
|
+
language: ['typescript'],
|
|
61
|
+
dependencies: [],
|
|
62
|
+
frameworks: ['nextjs'],
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
baseName: 'authjs',
|
|
66
|
+
otherName: 'auth',
|
|
67
|
+
description: 'A simple authentication library for JavaScript.',
|
|
68
|
+
recommended: false,
|
|
69
|
+
label: 'Auth.js',
|
|
70
|
+
hint: 'authentication library (next-auth)',
|
|
71
|
+
language: ['typescript'],
|
|
72
|
+
dependencies: ['prisma'],
|
|
73
|
+
frameworks: ['nextjs'],
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
baseName: 'zod',
|
|
77
|
+
description: 'A TypeScript-first schema declaration and validation library.',
|
|
78
|
+
recommended: false,
|
|
79
|
+
label: 'Zod',
|
|
80
|
+
hint: 'TypeScript-first schema validation',
|
|
81
|
+
language: ['typescript'],
|
|
82
|
+
dependencies: [],
|
|
83
|
+
frameworks: ['reactjs', 'nextjs'],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
baseName: 'zustand',
|
|
87
|
+
description: 'A small, fast and scalable bearbones state-management solution.',
|
|
88
|
+
label: 'Zustand',
|
|
89
|
+
hint: 'lightweight state management',
|
|
90
|
+
recommended: false,
|
|
91
|
+
language: ['typescript'],
|
|
92
|
+
dependencies: [],
|
|
93
|
+
frameworks: ['reactjs', 'nextjs'],
|
|
94
|
+
},
|
|
95
|
+
];
|