stackinit 0.1.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/.editorconfig +18 -0
- package/.env.example +11 -0
- package/.eslintrc.json +30 -0
- package/.github/workflows/ci.yml +36 -0
- package/.prettierignore +11 -0
- package/.prettierrc.json +10 -0
- package/CONTRIBUTING.md +272 -0
- package/Dockerfile +36 -0
- package/LICENSE +22 -0
- package/README.md +202 -0
- package/dist/banner.d.ts +2 -0
- package/dist/banner.d.ts.map +1 -0
- package/dist/banner.js +16 -0
- package/dist/banner.js.map +1 -0
- package/dist/ci.d.ts +3 -0
- package/dist/ci.d.ts.map +1 -0
- package/dist/ci.js +83 -0
- package/dist/ci.js.map +1 -0
- package/dist/dependencies.d.ts +3 -0
- package/dist/dependencies.d.ts.map +1 -0
- package/dist/dependencies.js +102 -0
- package/dist/dependencies.js.map +1 -0
- package/dist/detect.d.ts +3 -0
- package/dist/detect.d.ts.map +1 -0
- package/dist/detect.js +125 -0
- package/dist/detect.js.map +1 -0
- package/dist/docker.d.ts +3 -0
- package/dist/docker.d.ts.map +1 -0
- package/dist/docker.js +100 -0
- package/dist/docker.js.map +1 -0
- package/dist/generate.d.ts +3 -0
- package/dist/generate.d.ts.map +1 -0
- package/dist/generate.js +71 -0
- package/dist/generate.js.map +1 -0
- package/dist/husky.d.ts +3 -0
- package/dist/husky.d.ts.map +1 -0
- package/dist/husky.js +92 -0
- package/dist/husky.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +128 -0
- package/dist/index.js.map +1 -0
- package/dist/templates.d.ts +11 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +209 -0
- package/dist/templates.js.map +1 -0
- package/dist/types.d.ts +16 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/docker-compose.yml +15 -0
- package/package.json +60 -0
- package/src/banner.ts +15 -0
- package/src/ci.ts +94 -0
- package/src/dependencies.ts +120 -0
- package/src/detect.ts +132 -0
- package/src/docker.ts +107 -0
- package/src/generate.ts +81 -0
- package/src/husky.ts +107 -0
- package/src/index.ts +145 -0
- package/src/templates.ts +244 -0
- package/src/types.ts +18 -0
- package/tsconfig.json +26 -0
package/.editorconfig
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
root = true
|
|
2
|
+
|
|
3
|
+
[*]
|
|
4
|
+
charset = utf-8
|
|
5
|
+
end_of_line = lf
|
|
6
|
+
indent_style = space
|
|
7
|
+
indent_size = 2
|
|
8
|
+
insert_final_newline = true
|
|
9
|
+
trim_trailing_whitespace = true
|
|
10
|
+
|
|
11
|
+
[*.md]
|
|
12
|
+
trim_trailing_whitespace = false
|
|
13
|
+
|
|
14
|
+
[*.{yml,yaml}]
|
|
15
|
+
indent_size = 2
|
|
16
|
+
|
|
17
|
+
[Makefile]
|
|
18
|
+
indent_style = tab
|
package/.env.example
ADDED
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"root": true,
|
|
3
|
+
"env": {
|
|
4
|
+
"node": true,
|
|
5
|
+
"es2022": true
|
|
6
|
+
},
|
|
7
|
+
"extends": [
|
|
8
|
+
"eslint:recommended",
|
|
9
|
+
"plugin:@typescript-eslint/recommended"
|
|
10
|
+
],
|
|
11
|
+
"parserOptions": {
|
|
12
|
+
"ecmaVersion": 2022,
|
|
13
|
+
"sourceType": "module",
|
|
14
|
+
"project": "./tsconfig.json"
|
|
15
|
+
},
|
|
16
|
+
"rules": {
|
|
17
|
+
"no-console": "warn",
|
|
18
|
+
"no-debugger": "warn",
|
|
19
|
+
"no-unused-vars": "warn",
|
|
20
|
+
"prefer-const": "error",
|
|
21
|
+
"no-var": "error",
|
|
22
|
+
"@typescript-eslint/no-unused-vars": "warn",
|
|
23
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
24
|
+
"@typescript-eslint/no-explicit-any": "warn"
|
|
25
|
+
},
|
|
26
|
+
"parser": "@typescript-eslint/parser",
|
|
27
|
+
"plugins": [
|
|
28
|
+
"@typescript-eslint"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, master, develop]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main, master, develop]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
ci:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- name: Checkout code
|
|
15
|
+
uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Setup Node.js
|
|
18
|
+
uses: actions/setup-node@v4
|
|
19
|
+
with:
|
|
20
|
+
node-version: '20'
|
|
21
|
+
cache: 'npm'
|
|
22
|
+
|
|
23
|
+
- name: Install dependencies
|
|
24
|
+
run: npm ci
|
|
25
|
+
|
|
26
|
+
- name: Lint
|
|
27
|
+
run: npm run lint
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
- name: Type check
|
|
31
|
+
run: npm run type-check
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
- name: Run tests
|
|
35
|
+
run: npm test
|
|
36
|
+
continue-on-error: true
|
package/.prettierignore
ADDED
package/.prettierrc.json
ADDED
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# Contributing to stackinit
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to stackinit! This document provides guidelines and instructions for contributing to the project.
|
|
4
|
+
|
|
5
|
+
## Code of Conduct
|
|
6
|
+
|
|
7
|
+
By participating in this project, you agree to maintain a respectful and inclusive environment for all contributors.
|
|
8
|
+
|
|
9
|
+
## How to Contribute
|
|
10
|
+
|
|
11
|
+
### Reporting Bugs
|
|
12
|
+
|
|
13
|
+
Before reporting a bug, please:
|
|
14
|
+
|
|
15
|
+
1. Check if the issue has already been reported in the [Issues](https://github.com/yourusername/stackinit/issues) section
|
|
16
|
+
2. Verify that the bug still exists in the latest version
|
|
17
|
+
3. Collect relevant information:
|
|
18
|
+
- Node.js version
|
|
19
|
+
- Operating system
|
|
20
|
+
- Steps to reproduce
|
|
21
|
+
- Expected behavior
|
|
22
|
+
- Actual behavior
|
|
23
|
+
- Error messages (if any)
|
|
24
|
+
|
|
25
|
+
When creating a bug report, please use the bug report template and include as much detail as possible.
|
|
26
|
+
|
|
27
|
+
### Suggesting Features
|
|
28
|
+
|
|
29
|
+
We welcome feature suggestions! Please:
|
|
30
|
+
|
|
31
|
+
1. Check if the feature has already been suggested
|
|
32
|
+
2. Open an issue with the "enhancement" label
|
|
33
|
+
3. Clearly describe:
|
|
34
|
+
- The problem the feature would solve
|
|
35
|
+
- How the feature would work
|
|
36
|
+
- Why it would be useful
|
|
37
|
+
|
|
38
|
+
### Pull Requests
|
|
39
|
+
|
|
40
|
+
We love pull requests! Here's how to submit one:
|
|
41
|
+
|
|
42
|
+
1. **Fork the repository**
|
|
43
|
+
```bash
|
|
44
|
+
git clone https://github.com/yourusername/stackinit.git
|
|
45
|
+
cd stackinit
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
2. **Create a branch**
|
|
49
|
+
```bash
|
|
50
|
+
git checkout -b feature/your-feature-name
|
|
51
|
+
# or
|
|
52
|
+
git checkout -b fix/your-bug-fix
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
3. **Set up the development environment**
|
|
56
|
+
```bash
|
|
57
|
+
npm install
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
4. **Make your changes**
|
|
61
|
+
- Write clean, maintainable code
|
|
62
|
+
- Follow the existing code style
|
|
63
|
+
- Add tests if applicable
|
|
64
|
+
- Update documentation as needed
|
|
65
|
+
|
|
66
|
+
5. **Test your changes**
|
|
67
|
+
```bash
|
|
68
|
+
# Development mode (no build needed)
|
|
69
|
+
npm run dev
|
|
70
|
+
|
|
71
|
+
# Or build and test
|
|
72
|
+
npm run build
|
|
73
|
+
npm start
|
|
74
|
+
|
|
75
|
+
# Test with options
|
|
76
|
+
npm run dev -- --dry-run
|
|
77
|
+
npm run dev -- --strict --docker
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Test in a real project:**
|
|
81
|
+
```bash
|
|
82
|
+
# Create test project
|
|
83
|
+
mkdir test-project && cd test-project
|
|
84
|
+
npm init -y
|
|
85
|
+
|
|
86
|
+
# Use npm link (from stackinit directory)
|
|
87
|
+
npm link
|
|
88
|
+
|
|
89
|
+
# Now test from test-project
|
|
90
|
+
stackinit --dry-run
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
6. **Commit your changes**
|
|
94
|
+
```bash
|
|
95
|
+
git add .
|
|
96
|
+
git commit -m "feat: add your feature description"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
We follow [Conventional Commits](https://www.conventionalcommits.org/):
|
|
100
|
+
- `feat:` for new features
|
|
101
|
+
- `fix:` for bug fixes
|
|
102
|
+
- `docs:` for documentation changes
|
|
103
|
+
- `style:` for code style changes (formatting, etc.)
|
|
104
|
+
- `refactor:` for code refactoring
|
|
105
|
+
- `test:` for adding or updating tests
|
|
106
|
+
- `chore:` for maintenance tasks
|
|
107
|
+
|
|
108
|
+
7. **Push and create a Pull Request**
|
|
109
|
+
```bash
|
|
110
|
+
git push origin feature/your-feature-name
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
8. **Open a Pull Request**
|
|
114
|
+
- Provide a clear description of your changes
|
|
115
|
+
- Reference any related issues
|
|
116
|
+
- Wait for review and address feedback
|
|
117
|
+
|
|
118
|
+
## Development Setup
|
|
119
|
+
|
|
120
|
+
### Prerequisites
|
|
121
|
+
|
|
122
|
+
- Node.js >= 18.0.0
|
|
123
|
+
- npm, yarn, or pnpm
|
|
124
|
+
|
|
125
|
+
### Installation
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Clone the repository
|
|
129
|
+
git clone https://github.com/yourusername/stackinit.git
|
|
130
|
+
cd stackinit
|
|
131
|
+
|
|
132
|
+
# Install dependencies
|
|
133
|
+
npm install
|
|
134
|
+
|
|
135
|
+
# Build the project
|
|
136
|
+
npm run build
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Development Workflow
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# Run in development mode (with tsx)
|
|
143
|
+
npm run dev
|
|
144
|
+
|
|
145
|
+
# Build TypeScript
|
|
146
|
+
npm run build
|
|
147
|
+
|
|
148
|
+
# Run the built CLI
|
|
149
|
+
npm start
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Testing Your Changes
|
|
153
|
+
|
|
154
|
+
To test your changes locally:
|
|
155
|
+
|
|
156
|
+
1. Build the project:
|
|
157
|
+
```bash
|
|
158
|
+
npm run build
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
2. Create a test project directory:
|
|
162
|
+
```bash
|
|
163
|
+
mkdir test-project
|
|
164
|
+
cd test-project
|
|
165
|
+
npm init -y
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
3. Run stackinit from the built dist:
|
|
169
|
+
```bash
|
|
170
|
+
node ../stackinit/dist/index.js
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Or use `npm link` for easier testing:
|
|
174
|
+
```bash
|
|
175
|
+
# From stackinit directory
|
|
176
|
+
npm link
|
|
177
|
+
|
|
178
|
+
# From test project directory
|
|
179
|
+
npx stackinit
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Code Style Guidelines
|
|
183
|
+
|
|
184
|
+
### TypeScript
|
|
185
|
+
|
|
186
|
+
- Use TypeScript strict mode
|
|
187
|
+
- Prefer explicit types over `any`
|
|
188
|
+
- Use meaningful variable and function names
|
|
189
|
+
- Keep functions focused and small
|
|
190
|
+
- Add JSDoc comments for public APIs
|
|
191
|
+
|
|
192
|
+
### Code Organization
|
|
193
|
+
|
|
194
|
+
- Keep modules focused on a single responsibility
|
|
195
|
+
- Use descriptive file and directory names
|
|
196
|
+
- Group related functionality together
|
|
197
|
+
- Export only what's necessary
|
|
198
|
+
|
|
199
|
+
### Formatting
|
|
200
|
+
|
|
201
|
+
The project uses Prettier for code formatting. Before committing:
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
npm run format
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Linting
|
|
208
|
+
|
|
209
|
+
We use ESLint for code quality. Check for linting errors:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
npm run lint
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Fix auto-fixable issues:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
npm run lint:fix
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Project Structure
|
|
222
|
+
|
|
223
|
+
```
|
|
224
|
+
stackinit/
|
|
225
|
+
├── src/
|
|
226
|
+
│ ├── index.ts # CLI entry point
|
|
227
|
+
│ ├── detect.ts # Project detection logic
|
|
228
|
+
│ ├── generate.ts # File generation
|
|
229
|
+
│ ├── templates.ts # Template content
|
|
230
|
+
│ ├── husky.ts # Husky setup
|
|
231
|
+
│ ├── ci.ts # CI generation
|
|
232
|
+
│ ├── docker.ts # Docker generation
|
|
233
|
+
│ └── types.ts # Type definitions
|
|
234
|
+
├── dist/ # Compiled output (gitignored)
|
|
235
|
+
└── ...
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Areas for Contribution
|
|
239
|
+
|
|
240
|
+
We welcome contributions in these areas:
|
|
241
|
+
|
|
242
|
+
- **Bug fixes**: Fix issues reported in the issue tracker
|
|
243
|
+
- **New features**: Add support for new project types or tools
|
|
244
|
+
- **Documentation**: Improve README, add examples, write guides
|
|
245
|
+
- **Testing**: Add tests to improve code coverage
|
|
246
|
+
- **Performance**: Optimize detection or generation logic
|
|
247
|
+
- **DX improvements**: Better error messages, more helpful output
|
|
248
|
+
|
|
249
|
+
## Review Process
|
|
250
|
+
|
|
251
|
+
1. All pull requests require at least one review
|
|
252
|
+
2. Maintainers will review your PR and may request changes
|
|
253
|
+
3. Once approved, a maintainer will merge your PR
|
|
254
|
+
4. Be patient and responsive to feedback
|
|
255
|
+
|
|
256
|
+
## Questions?
|
|
257
|
+
|
|
258
|
+
If you have questions about contributing:
|
|
259
|
+
|
|
260
|
+
- Open an issue with the "question" label
|
|
261
|
+
- Check existing issues and discussions
|
|
262
|
+
- Review the README for project overview
|
|
263
|
+
|
|
264
|
+
## Recognition
|
|
265
|
+
|
|
266
|
+
Contributors will be recognized in:
|
|
267
|
+
- The project's README (if applicable)
|
|
268
|
+
- Release notes for significant contributions
|
|
269
|
+
- GitHub contributors page
|
|
270
|
+
|
|
271
|
+
Thank you for contributing to stackinit! 🎉
|
|
272
|
+
|
package/Dockerfile
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Build stage
|
|
2
|
+
FROM node:20-alpine AS builder
|
|
3
|
+
|
|
4
|
+
WORKDIR /app
|
|
5
|
+
|
|
6
|
+
# Copy package files
|
|
7
|
+
COPY package.json COPY package-lock.json .
|
|
8
|
+
|
|
9
|
+
RUN npm ci
|
|
10
|
+
|
|
11
|
+
# Copy source files
|
|
12
|
+
COPY . .
|
|
13
|
+
|
|
14
|
+
# Build the application (adjust as needed)
|
|
15
|
+
RUN npm run build
|
|
16
|
+
|
|
17
|
+
# Production stage
|
|
18
|
+
FROM node:20-alpine AS production
|
|
19
|
+
|
|
20
|
+
WORKDIR /app
|
|
21
|
+
|
|
22
|
+
# Copy package files
|
|
23
|
+
COPY package.json COPY package-lock.json .
|
|
24
|
+
|
|
25
|
+
# Install production dependencies only
|
|
26
|
+
RUN npm ci --only=production
|
|
27
|
+
|
|
28
|
+
# Copy built application from builder
|
|
29
|
+
COPY --from=builder /app/dist ./dist
|
|
30
|
+
COPY --from=builder /app/public ./public 2>/dev/null || true
|
|
31
|
+
|
|
32
|
+
# Expose port (adjust as needed)
|
|
33
|
+
EXPOSE 3000
|
|
34
|
+
|
|
35
|
+
# Start the application
|
|
36
|
+
CMD ["node", "dist/index.js"]
|
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 stackinit
|
|
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.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# stackinit
|
|
2
|
+
|
|
3
|
+
> Initialize a consistent development environment for Node-based projects with a single command.
|
|
4
|
+
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
## Philosophy
|
|
8
|
+
|
|
9
|
+
`stackinit` is an opinionated CLI tool that sets up a production-ready development environment for Node.js projects. It follows these principles:
|
|
10
|
+
|
|
11
|
+
- **Zero configuration by default**: Sensible defaults that work for most projects
|
|
12
|
+
- **Non-destructive**: Never overwrites existing files
|
|
13
|
+
- **TypeScript-first**: Optimized for TypeScript projects but works with JavaScript
|
|
14
|
+
- **No interactive prompts**: Everything is configurable via flags
|
|
15
|
+
- **Production-ready**: Includes CI/CD, linting, formatting, and git hooks out of the box
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx stackinit
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Or install globally:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install -g stackinit
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
### Basic Usage
|
|
32
|
+
|
|
33
|
+
Run `stackinit` in your project directory:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx stackinit
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
This will:
|
|
40
|
+
- Auto-detect your project type (Node, React, Next.js, Vite)
|
|
41
|
+
- Detect your package manager (npm, yarn, pnpm)
|
|
42
|
+
- Generate configuration files (ESLint, Prettier, .gitignore, etc.)
|
|
43
|
+
- Set up Husky git hooks with lint-staged
|
|
44
|
+
- Create GitHub Actions CI workflow
|
|
45
|
+
|
|
46
|
+
### Options
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npx stackinit [options]
|
|
50
|
+
|
|
51
|
+
Options:
|
|
52
|
+
--strict Enable stricter lint rules and CI failure on warnings
|
|
53
|
+
--docker Generate Dockerfile and docker-compose.yml
|
|
54
|
+
--ci-only Generate only GitHub Actions workflow
|
|
55
|
+
--dry-run Show what files would be created without writing
|
|
56
|
+
-h, --help Display help for command
|
|
57
|
+
-V, --version Display version number
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Examples
|
|
61
|
+
|
|
62
|
+
**Strict mode with Docker:**
|
|
63
|
+
```bash
|
|
64
|
+
npx stackinit --strict --docker
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**CI-only (for existing projects):**
|
|
68
|
+
```bash
|
|
69
|
+
npx stackinit --ci-only
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Dry run to preview changes:**
|
|
73
|
+
```bash
|
|
74
|
+
npx stackinit --dry-run
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## What Gets Generated
|
|
78
|
+
|
|
79
|
+
### Configuration Files
|
|
80
|
+
|
|
81
|
+
- **`.eslintrc.json`** - ESLint configuration (TypeScript-aware, React-aware)
|
|
82
|
+
- **`.prettierrc.json`** - Prettier configuration
|
|
83
|
+
- **`.prettierignore`** - Prettier ignore patterns
|
|
84
|
+
- **`.gitignore`** - Comprehensive .gitignore for Node.js projects
|
|
85
|
+
- **`.editorconfig`** - EditorConfig for consistent coding styles
|
|
86
|
+
- **`.env.example`** - Environment variables template
|
|
87
|
+
|
|
88
|
+
### Git Hooks (Husky)
|
|
89
|
+
|
|
90
|
+
- **pre-commit** - Runs lint-staged to lint and format staged files
|
|
91
|
+
- **commit-msg** - Runs commitlint (only in strict mode)
|
|
92
|
+
|
|
93
|
+
### CI/CD
|
|
94
|
+
|
|
95
|
+
- **`.github/workflows/ci.yml`** - GitHub Actions workflow that:
|
|
96
|
+
- Installs dependencies
|
|
97
|
+
- Runs linting
|
|
98
|
+
- Runs type checking (if TypeScript)
|
|
99
|
+
- Runs tests (if present)
|
|
100
|
+
|
|
101
|
+
### Docker (optional)
|
|
102
|
+
|
|
103
|
+
- **`Dockerfile`** - Multi-stage Docker build
|
|
104
|
+
- **`docker-compose.yml`** - Docker Compose configuration
|
|
105
|
+
|
|
106
|
+
### Package.json Scripts
|
|
107
|
+
|
|
108
|
+
The following scripts are added to your `package.json` (only if they don't already exist):
|
|
109
|
+
|
|
110
|
+
- `lint` - Run ESLint
|
|
111
|
+
- `lint:fix` - Run ESLint with auto-fix
|
|
112
|
+
- `format` - Format code with Prettier
|
|
113
|
+
- `format:check` - Check code formatting
|
|
114
|
+
- `type-check` - TypeScript type checking (if TypeScript is detected)
|
|
115
|
+
- `prepare` - Husky install hook
|
|
116
|
+
|
|
117
|
+
## Project Detection
|
|
118
|
+
|
|
119
|
+
`stackinit` automatically detects:
|
|
120
|
+
|
|
121
|
+
- **Project Type**: Node backend, React, Next.js, Vite
|
|
122
|
+
- **Package Manager**: npm, yarn, pnpm (via lock files or package.json)
|
|
123
|
+
- **TypeScript**: Checks for `tsconfig.json` or TypeScript in dependencies
|
|
124
|
+
- **Monorepo**: Detects pnpm workspaces, Lerna, Nx, Turborepo, Rush
|
|
125
|
+
|
|
126
|
+
## Features
|
|
127
|
+
|
|
128
|
+
### Auto-Detection
|
|
129
|
+
|
|
130
|
+
The tool intelligently detects your project setup and generates appropriate configurations:
|
|
131
|
+
|
|
132
|
+
- **React projects**: Adds React ESLint plugins
|
|
133
|
+
- **Next.js projects**: Adds Next.js ESLint config
|
|
134
|
+
- **TypeScript projects**: Configures TypeScript ESLint parser
|
|
135
|
+
- **Monorepos**: Adapts configurations for monorepo structures
|
|
136
|
+
|
|
137
|
+
### Non-Destructive
|
|
138
|
+
|
|
139
|
+
`stackinit` never overwrites existing files. If a file already exists, it will be skipped with a warning.
|
|
140
|
+
|
|
141
|
+
### Strict Mode
|
|
142
|
+
|
|
143
|
+
When using `--strict`:
|
|
144
|
+
|
|
145
|
+
- Stricter ESLint rules
|
|
146
|
+
- CI fails on warnings (not just errors)
|
|
147
|
+
- Commitlint enabled for conventional commits
|
|
148
|
+
- More aggressive TypeScript checks
|
|
149
|
+
|
|
150
|
+
## Requirements
|
|
151
|
+
|
|
152
|
+
- Node.js >= 18.0.0
|
|
153
|
+
- Git repository (for Husky setup)
|
|
154
|
+
|
|
155
|
+
## After Running
|
|
156
|
+
|
|
157
|
+
`stackinit` automatically:
|
|
158
|
+
|
|
159
|
+
- ✅ Installs all required dependencies (ESLint, Prettier, Husky, lint-staged, etc.)
|
|
160
|
+
- ✅ Detects and installs TypeScript ESLint plugins if TypeScript is detected
|
|
161
|
+
- ✅ Detects and installs React plugins if React is detected
|
|
162
|
+
- ✅ Installs commitlint if `--strict` mode is enabled
|
|
163
|
+
- ✅ Initializes Husky git hooks (if in a git repository)
|
|
164
|
+
|
|
165
|
+
**That's it!** You're ready to start developing. The tool handles everything automatically based on your project setup.
|
|
166
|
+
|
|
167
|
+
## Development
|
|
168
|
+
|
|
169
|
+
### Testing Locally
|
|
170
|
+
|
|
171
|
+
To test `stackinit` locally during development:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
# Install dependencies
|
|
175
|
+
npm install
|
|
176
|
+
|
|
177
|
+
# Development mode (runs TypeScript directly)
|
|
178
|
+
npm run dev
|
|
179
|
+
|
|
180
|
+
# Or build and test
|
|
181
|
+
npm run build
|
|
182
|
+
npm start
|
|
183
|
+
|
|
184
|
+
# Test with options (note: use -- to pass flags to the script)
|
|
185
|
+
npm run dev -- --dry-run
|
|
186
|
+
npm run dev -- --strict
|
|
187
|
+
npm run dev -- --docker
|
|
188
|
+
npm run dev -- --strict --docker
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Important:** When using npm scripts, use `--` to pass flags to the underlying command. For example: `npm run dev -- --docker`
|
|
192
|
+
|
|
193
|
+
For detailed development and testing instructions, see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
194
|
+
|
|
195
|
+
## Contributing
|
|
196
|
+
|
|
197
|
+
Contributions are welcome! Please read our [Contributing Guidelines](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.
|
|
198
|
+
|
|
199
|
+
## License
|
|
200
|
+
|
|
201
|
+
MIT
|
|
202
|
+
|
package/dist/banner.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../src/banner.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,IAAI,IAAI,CAclC"}
|
package/dist/banner.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function printBanner() {
|
|
2
|
+
const banner = `
|
|
3
|
+
╔═══════════════════════════════════════════════════════════════════════╗
|
|
4
|
+
║ ║
|
|
5
|
+
║ ║
|
|
6
|
+
║ S T A C K I N I T ║
|
|
7
|
+
║ ║
|
|
8
|
+
║ ║
|
|
9
|
+
║ Initialize your development environment ║
|
|
10
|
+
║ ║
|
|
11
|
+
║ ║
|
|
12
|
+
╚═══════════════════════════════════════════════════════════════════════╝
|
|
13
|
+
`;
|
|
14
|
+
console.log(banner);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=banner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banner.js","sourceRoot":"","sources":["../src/banner.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW;IACzB,MAAM,MAAM,GAAG;;;;;;;;;;;CAWhB,CAAC;IACA,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC"}
|
package/dist/ci.d.ts
ADDED
package/dist/ci.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ci.d.ts","sourceRoot":"","sources":["../src/ci.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEvD,wBAAsB,UAAU,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB1F"}
|