beaver-build 1.0.6 → 1.0.7

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 (3) hide show
  1. package/README.md +237 -237
  2. package/dist/index.js +1378 -488
  3. package/package.json +57 -52
package/README.md CHANGED
@@ -1,237 +1,237 @@
1
- <div align="center"><img width="400" height="225" alt="Beaver CLI" src="https://raw.githubusercontent.com/hd1008-lang/beaver/main/media/beaver.gif" /></div>
2
-
3
- # Beaver
4
-
5
- An interactive CLI tool for scaffolding modern web projects. Select your project type, configure your stack through a guided menu, and get a production-ready project generated on disk with pinned library versions.
6
-
7
- ## Getting Started
8
-
9
- ### Prerequisites
10
-
11
- - Node.js 18+
12
- - npm
13
-
14
- ### Installation
15
-
16
- **Option 1: Install globally** (recommended for frequent use)
17
-
18
- ```bash
19
- npm install -g beaver-build
20
- beaver
21
- ```
22
-
23
- **Option 2: Use directly with npx** (no installation needed)
24
-
25
- ```bash
26
- npx beaver
27
- ```
28
-
29
- ### Usage
30
-
31
- Simply run the command and follow the interactive prompts:
32
-
33
- ```bash
34
- beaver
35
- ```
36
-
37
- The CLI will guide you through:
38
-
39
- 1. **Project Type** — Choose React + Vite or Chrome Extension
40
- 2. **Project Name** — Enter your project directory name
41
- 3. **Configuration** — Select your preferred stack (layout, router, state management, styling, linter)
42
-
43
- After answering all prompts, your production-ready project will be generated in the specified directory with:
44
-
45
- - All dependencies pinned to stable versions
46
- - GitHub Copilot custom instructions for your chosen stack
47
- - Ready to run with `npm install && npm run dev`
48
-
49
- ---
50
-
51
- ## Development (Contributing)
52
-
53
- To contribute or develop locally:
54
-
55
- ```bash
56
- npm install
57
- npm run dev # Run CLI in development mode
58
- npm run build # Compile for distribution
59
- ```
60
-
61
- ---
62
-
63
- ## Project Types
64
-
65
- | Type | Status |
66
- |---|---|
67
- | React + Vite | Available |
68
- | Chrome Extension | Available |
69
- | Next.js | Upcoming |
70
- | Nuxt | Upcoming |
71
-
72
- ---
73
-
74
- ## React + Vite
75
-
76
- The CLI walks you through the following choices:
77
-
78
- ### 1. Project Name
79
-
80
- Validated to allow only letters, numbers, hyphens, and underscores (`[a-zA-Z0-9_-]`).
81
-
82
- ### 2. Layout
83
-
84
- | Option | Description |
85
- |---|---|
86
- | FSD | Feature Slice Design |
87
- | BPR | Bulletproof React |
88
-
89
- ### 3. Router
90
-
91
- | Option | Version |
92
- |---|---|
93
- | Not Using | — |
94
- | TanStack Router | v1.144.0 |
95
-
96
- ### 4. State Management
97
-
98
- | Option | Version |
99
- |---|---|
100
- | Not Using | — |
101
- | Zustand | v5.0.5 |
102
-
103
- ### 5. Data Fetching
104
-
105
- | Option | Version |
106
- |---|---|
107
- | Not Using | — |
108
- | TanStack Query | v5.74.4 |
109
-
110
- ### 6. CSS / Styling
111
-
112
- | Option | Version |
113
- |---|---|
114
- | Not Using | — |
115
- | Tailwind CSS | v4.1.3 |
116
-
117
- ### 7. Linter / Formatter
118
-
119
- | Option | Version | Notes |
120
- |---|---|---|
121
- | Not Using | — | — |
122
- | Biome | v1.9.4 | All-in-one lint + format |
123
- | ESLint | v9.39.4 | Flat config + typescript-eslint |
124
-
125
- ---
126
-
127
- ## Generated Project — Copilot Instructions
128
-
129
- Every scaffolded project includes a set of GitHub Copilot custom instructions so that AI-assisted coding inside the project follows the conventions of the chosen stack. The files are layout-aware — the `applyTo` glob patterns and placement rules change between FSD and BPR.
130
-
131
- Files emitted in the generated project:
132
-
133
- | File | Scope | Emitted when |
134
- |---|---|---|
135
- | `.github/copilot-instructions.md` | Repo-wide overview — stack, naming, architecture | Always |
136
- | `.github/instructions/components.instructions.md` | Component file paths per layout | Always |
137
- | `.github/instructions/hooks.instructions.md` | Hook file paths per layout | Always |
138
- | `.github/instructions/tanstack-router.instructions.md` | `src/routes/**/*.tsx` | Router = TanStack Router |
139
- | `.github/instructions/zustand.instructions.md` | Store file paths per layout | State = Zustand |
140
- | `.github/instructions/tanstack-query.instructions.md` | API/query file paths per layout | Query = TanStack Query |
141
- | `.github/instructions/biome.instructions.md` or `eslint.instructions.md` | `**` | Linter ≠ none |
142
-
143
- The format follows GitHub's [path-specific custom instructions](https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions#creating-path-specific-custom-instructions) spec (`applyTo` frontmatter).
144
-
145
- **Rule for contributors:** every new option added to the CLI (new router, new state library, new UI framework, etc.) must ship with its own instruction template in `src/scaffold/react-vite/templates/copilot-instructions.ts`. See [Adding a New Option to React + Vite](#adding-a-new-option-to-react--vite) below.
146
-
147
- ---
148
-
149
- ## Generated Project — Pinned Dependencies
150
-
151
- | Package | Version |
152
- |---|---|
153
- | react | 19.1.0 |
154
- | react-dom | 19.1.0 |
155
- | vite | 6.4.3 |
156
- | @vitejs/plugin-react | 4.4.1 |
157
- | typescript | 5.8.3 |
158
- | @types/react | 19.1.1 |
159
- | @types/react-dom | 19.1.1 |
160
- | @tanstack/react-router | 1.144.0 |
161
- | @tanstack/router-devtools | 1.144.0 |
162
- | @tanstack/router-vite-plugin | 1.144.0 |
163
- | zustand | 5.0.5 |
164
- | @tanstack/react-query | 5.74.4 |
165
- | @tanstack/react-query-devtools | 5.74.4 |
166
- | @biomejs/biome | 1.9.4 |
167
- | eslint | 9.39.4 |
168
- | @eslint/js | 9.39.4 |
169
- | typescript-eslint | 8.26.0 |
170
- | eslint-plugin-react-hooks | 5.2.0 |
171
- | eslint-plugin-react-refresh | 0.4.19 |
172
- | globals | 15.15.0 |
173
-
174
- ---
175
-
176
- ## Project Structure
177
-
178
- ```
179
- src/
180
- index.ts Entry point — greeting, menu, error handling
181
- types/index.ts Cart, ProjectType, ReactViteCore, NextJSCore
182
- constants/index.ts Top-level menu options
183
- options/
184
- index.ts Top-level project type selection
185
- react-vite/
186
- index.ts React + Vite menu flow
187
- constants/index.ts Menu option definitions
188
- types/index.ts MenuOptions type
189
- scaffold/
190
- errors.ts ScaffoldError, isNodeError
191
- utils.ts FileMap, dirExists(), writeProjectFile()
192
- react-vite/
193
- index.ts Scaffold orchestrator
194
- templates/
195
- package-json.ts packageJsonTemplate(cart)
196
- vite-config.ts viteConfigTemplate(cart)
197
- tsconfig.ts tsconfigTemplate(), tsconfigNodeTemplate()
198
- index-html.ts indexHtmlTemplate(projectName)
199
- main-tsx.ts mainTsxTemplate(layout)
200
- app-tsx.ts appTsxFsdTemplate(), appTsxBprTemplate()
201
- router.ts rootRouteTemplate(), indexRouteTemplate()
202
- zustand.ts zustandStoreTemplate()
203
- query.ts queryProviderBprTemplate()
204
- linter.ts biomeConfigTemplate(), eslintConfigTemplate()
205
- gitignore.ts gitignoreTemplate()
206
- copilot-instructions.ts getCopilotInstructionFiles(cart) — Copilot instruction set
207
- fsd-layout.ts getFsdFileMap(cart)
208
- bpr-layout.ts getBprFileMap(cart)
209
- utils/
210
- animation.ts typeWriter effect
211
- user.ts getUserName() from git config
212
- index.ts sleep()
213
- ```
214
-
215
- ---
216
-
217
- ## Adding a New Project Type
218
-
219
- 1. Set `disabled: false` in `src/constants/index.ts`
220
- 2. Create `src/options/<project-name>/` with constants, types, and flow functions
221
- 3. Handle the new type in `src/options/index.ts`
222
- 4. Add the interface to `src/types/index.ts` and include it in the `Cart` union
223
- 5. Create `src/scaffold/<project-name>/` with templates and an orchestrator
224
-
225
- ## Adding a New Option to React + Vite
226
-
227
- 1. Add the constant to `src/options/react-vite/constants/index.ts`
228
- 2. Export the value type from `src/types/index.ts` and add the field to `ReactViteCore`
229
- 3. Add a `menu<OptionName>` function in `src/options/react-vite/index.ts`
230
- 4. Call it in `flowReactVite`
231
- 5. Update `getFsdFileMap` and `getBprFileMap` to handle the new option
232
- 6. **Add a Copilot instruction template** in `src/scaffold/react-vite/templates/copilot-instructions.ts`:
233
- - Write a new template function (e.g. `newOptionTemplate(cart)`) returning a markdown string that starts with an `applyTo` frontmatter block scoped to the right paths for both FSD and BPR (use `FSD_PATHS` / `BPR_PATHS`)
234
- - Register it inside `getCopilotInstructionFiles` under a conditional block keyed by the new cart field
235
- - If the new option introduces a new kind of file path, extend the `Paths` type and both `FSD_PATHS` / `BPR_PATHS` maps so every path-specific rule stays layout-aware
236
-
237
- This step is mandatory — any user who scaffolds a project with the new option must get a matching Copilot instruction file automatically.
1
+ <div align="center"><img width="400" height="225" alt="Beaver CLI" src="https://raw.githubusercontent.com/hd1008-lang/beaver/main/media/beaver.gif" /></div>
2
+
3
+ # Beaver
4
+
5
+ An interactive CLI tool for scaffolding modern web projects. Select your project type, configure your stack through a guided menu, and get a production-ready project generated on disk with pinned library versions.
6
+
7
+ ## Getting Started
8
+
9
+ ### Prerequisites
10
+
11
+ - Node.js 18+
12
+ - npm
13
+
14
+ ### Installation
15
+
16
+ **Option 1: Install globally** (recommended for frequent use)
17
+
18
+ ```bash
19
+ npm install -g beaver-build
20
+ beaver
21
+ ```
22
+
23
+ **Option 2: Use directly with npx** (no installation needed)
24
+
25
+ ```bash
26
+ npx beaver
27
+ ```
28
+
29
+ ### Usage
30
+
31
+ Simply run the command and follow the interactive prompts:
32
+
33
+ ```bash
34
+ beaver
35
+ ```
36
+
37
+ The CLI will guide you through:
38
+
39
+ 1. **Project Type** — Choose React + Vite or Chrome Extension
40
+ 2. **Project Name** — Enter your project directory name
41
+ 3. **Configuration** — Select your preferred stack (layout, router, state management, styling, linter)
42
+
43
+ After answering all prompts, your production-ready project will be generated in the specified directory with:
44
+
45
+ - All dependencies pinned to stable versions
46
+ - GitHub Copilot custom instructions for your chosen stack
47
+ - Ready to run with `npm install && npm run dev`
48
+
49
+ ---
50
+
51
+ ## Development (Contributing)
52
+
53
+ To contribute or develop locally:
54
+
55
+ ```bash
56
+ npm install
57
+ npm run dev # Run CLI in development mode
58
+ npm run build # Compile for distribution
59
+ ```
60
+
61
+ ---
62
+
63
+ ## Project Types
64
+
65
+ | Type | Status |
66
+ |---|---|
67
+ | React + Vite | Available |
68
+ | Chrome Extension | Available |
69
+ | Next.js | Upcoming |
70
+ | Nuxt | Upcoming |
71
+
72
+ ---
73
+
74
+ ## React + Vite
75
+
76
+ The CLI walks you through the following choices:
77
+
78
+ ### 1. Project Name
79
+
80
+ Validated to allow only letters, numbers, hyphens, and underscores (`[a-zA-Z0-9_-]`).
81
+
82
+ ### 2. Layout
83
+
84
+ | Option | Description |
85
+ |---|---|
86
+ | FSD | Feature Slice Design |
87
+ | BPR | Bulletproof React |
88
+
89
+ ### 3. Router
90
+
91
+ | Option | Version |
92
+ |---|---|
93
+ | Not Using | — |
94
+ | TanStack Router | v1.144.0 |
95
+
96
+ ### 4. State Management
97
+
98
+ | Option | Version |
99
+ |---|---|
100
+ | Not Using | — |
101
+ | Zustand | v5.0.5 |
102
+
103
+ ### 5. Data Fetching
104
+
105
+ | Option | Version |
106
+ |---|---|
107
+ | Not Using | — |
108
+ | TanStack Query | v5.74.4 |
109
+
110
+ ### 6. CSS / Styling
111
+
112
+ | Option | Version |
113
+ |---|---|
114
+ | Not Using | — |
115
+ | Tailwind CSS | v4.1.3 |
116
+
117
+ ### 7. Linter / Formatter
118
+
119
+ | Option | Version | Notes |
120
+ |---|---|---|
121
+ | Not Using | — | — |
122
+ | Biome | v1.9.4 | All-in-one lint + format |
123
+ | ESLint | v9.39.4 | Flat config + typescript-eslint |
124
+
125
+ ---
126
+
127
+ ## Generated Project — Copilot Instructions
128
+
129
+ Every scaffolded project includes a set of GitHub Copilot custom instructions so that AI-assisted coding inside the project follows the conventions of the chosen stack. The files are layout-aware — the `applyTo` glob patterns and placement rules change between FSD and BPR.
130
+
131
+ Files emitted in the generated project:
132
+
133
+ | File | Scope | Emitted when |
134
+ |---|---|---|
135
+ | `.github/copilot-instructions.md` | Repo-wide overview — stack, naming, architecture | Always |
136
+ | `.github/instructions/components.instructions.md` | Component file paths per layout | Always |
137
+ | `.github/instructions/hooks.instructions.md` | Hook file paths per layout | Always |
138
+ | `.github/instructions/tanstack-router.instructions.md` | `src/routes/**/*.tsx` | Router = TanStack Router |
139
+ | `.github/instructions/zustand.instructions.md` | Store file paths per layout | State = Zustand |
140
+ | `.github/instructions/tanstack-query.instructions.md` | API/query file paths per layout | Query = TanStack Query |
141
+ | `.github/instructions/biome.instructions.md` or `eslint.instructions.md` | `**` | Linter ≠ none |
142
+
143
+ The format follows GitHub's [path-specific custom instructions](https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions#creating-path-specific-custom-instructions) spec (`applyTo` frontmatter).
144
+
145
+ **Rule for contributors:** every new option added to the CLI (new router, new state library, new UI framework, etc.) must ship with its own instruction template in `src/scaffold/react-vite/templates/copilot-instructions.ts`. See [Adding a New Option to React + Vite](#adding-a-new-option-to-react--vite) below.
146
+
147
+ ---
148
+
149
+ ## Generated Project — Pinned Dependencies
150
+
151
+ | Package | Version |
152
+ |---|---|
153
+ | react | 19.1.0 |
154
+ | react-dom | 19.1.0 |
155
+ | vite | 6.4.3 |
156
+ | @vitejs/plugin-react | 4.4.1 |
157
+ | typescript | 5.8.3 |
158
+ | @types/react | 19.1.1 |
159
+ | @types/react-dom | 19.1.1 |
160
+ | @tanstack/react-router | 1.144.0 |
161
+ | @tanstack/router-devtools | 1.144.0 |
162
+ | @tanstack/router-vite-plugin | 1.144.0 |
163
+ | zustand | 5.0.5 |
164
+ | @tanstack/react-query | 5.74.4 |
165
+ | @tanstack/react-query-devtools | 5.74.4 |
166
+ | @biomejs/biome | 1.9.4 |
167
+ | eslint | 9.39.4 |
168
+ | @eslint/js | 9.39.4 |
169
+ | typescript-eslint | 8.26.0 |
170
+ | eslint-plugin-react-hooks | 5.2.0 |
171
+ | eslint-plugin-react-refresh | 0.4.19 |
172
+ | globals | 15.15.0 |
173
+
174
+ ---
175
+
176
+ ## Project Structure
177
+
178
+ ```
179
+ src/
180
+ index.ts Entry point — greeting, menu, error handling
181
+ types/index.ts Cart, ProjectType, ReactViteCore, NextJSCore
182
+ constants/index.ts Top-level menu options
183
+ options/
184
+ index.ts Top-level project type selection
185
+ react-vite/
186
+ index.ts React + Vite menu flow
187
+ constants/index.ts Menu option definitions
188
+ types/index.ts MenuOptions type
189
+ scaffold/
190
+ errors.ts ScaffoldError, isNodeError
191
+ utils.ts FileMap, dirExists(), writeProjectFile()
192
+ react-vite/
193
+ index.ts Scaffold orchestrator
194
+ templates/
195
+ package-json.ts packageJsonTemplate(cart)
196
+ vite-config.ts viteConfigTemplate(cart)
197
+ tsconfig.ts tsconfigTemplate(), tsconfigNodeTemplate()
198
+ index-html.ts indexHtmlTemplate(projectName)
199
+ main-tsx.ts mainTsxTemplate(layout)
200
+ app-tsx.ts appTsxFsdTemplate(), appTsxBprTemplate()
201
+ router.ts rootRouteTemplate(), indexRouteTemplate()
202
+ zustand.ts zustandStoreTemplate()
203
+ query.ts queryProviderBprTemplate()
204
+ linter.ts biomeConfigTemplate(), eslintConfigTemplate()
205
+ gitignore.ts gitignoreTemplate()
206
+ copilot-instructions.ts getCopilotInstructionFiles(cart) — Copilot instruction set
207
+ fsd-layout.ts getFsdFileMap(cart)
208
+ bpr-layout.ts getBprFileMap(cart)
209
+ utils/
210
+ animation.ts typeWriter effect
211
+ user.ts getUserName() from git config
212
+ index.ts sleep()
213
+ ```
214
+
215
+ ---
216
+
217
+ ## Adding a New Project Type
218
+
219
+ 1. Set `disabled: false` in `src/constants/index.ts`
220
+ 2. Create `src/options/<project-name>/` with constants, types, and flow functions
221
+ 3. Handle the new type in `src/options/index.ts`
222
+ 4. Add the interface to `src/types/index.ts` and include it in the `Cart` union
223
+ 5. Create `src/scaffold/<project-name>/` with templates and an orchestrator
224
+
225
+ ## Adding a New Option to React + Vite
226
+
227
+ 1. Add the constant to `src/options/react-vite/constants/index.ts`
228
+ 2. Export the value type from `src/types/index.ts` and add the field to `ReactViteCore`
229
+ 3. Add a `menu<OptionName>` function in `src/options/react-vite/index.ts`
230
+ 4. Call it in `flowReactVite`
231
+ 5. Update `getFsdFileMap` and `getBprFileMap` to handle the new option
232
+ 6. **Add a Copilot instruction template** in `src/scaffold/react-vite/templates/copilot-instructions.ts`:
233
+ - Write a new template function (e.g. `newOptionTemplate(cart)`) returning a markdown string that starts with an `applyTo` frontmatter block scoped to the right paths for both FSD and BPR (use `FSD_PATHS` / `BPR_PATHS`)
234
+ - Register it inside `getCopilotInstructionFiles` under a conditional block keyed by the new cart field
235
+ - If the new option introduces a new kind of file path, extend the `Paths` type and both `FSD_PATHS` / `BPR_PATHS` maps so every path-specific rule stays layout-aware
236
+
237
+ This step is mandatory — any user who scaffolds a project with the new option must get a matching Copilot instruction file automatically.