component-gen-cli 1.0.1 → 1.0.2
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 +139 -65
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,138 +1,212 @@
|
|
|
1
|
-
# component-gen-cli
|
|
1
|
+
# component-gen-cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/component-gen-cli)
|
|
4
|
+
[](https://www.npmjs.com/package/component-gen-cli)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
**CLI to scaffold starter components** for **[React](https://react.dev/)**, **[Vue 3](https://vuejs.org/)**, **[Angular](https://angular.dev/)**, **[Svelte](https://svelte.dev/)**, **[SolidJS](https://solidjs.com/)**, and **[Next.js](https://nextjs.org/)**. Use JavaScript or TypeScript via a single flag.
|
|
7
|
+
|
|
8
|
+
Binaries installed from this package:
|
|
9
|
+
|
|
10
|
+
| Command | Purpose |
|
|
11
|
+
|---------|---------|
|
|
12
|
+
| **`cg`** | Short default (shown in docs below) |
|
|
13
|
+
| **`component-gen`** | Same CLI, longer name |
|
|
6
14
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
| `vue` | Single-file `.vue` (Vue 3, `<script setup>`) |
|
|
11
|
-
| `angular` | Standalone Angular component (`ts` + `.html` + `.css`/`.scss`) |
|
|
12
|
-
| `svelte` | `.svelte` file |
|
|
13
|
-
| `solid` | Solid JSX component |
|
|
14
|
-
| `next` | Next.js-ready React file; `--client` adds `'use client'` |
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Requirements
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
- **Node.js ≥ 18**
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
- Optionally **authenticated npm** (`npm login`) — only if publishing this package yourself
|
|
21
|
+
---
|
|
20
22
|
|
|
21
23
|
## Install
|
|
22
24
|
|
|
23
|
-
**
|
|
25
|
+
**Run once (no global install)**
|
|
24
26
|
|
|
25
27
|
```bash
|
|
26
|
-
npx component-gen-cli@latest
|
|
28
|
+
npx component-gen-cli@latest
|
|
27
29
|
```
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
Opens the built-in help and examples.
|
|
32
|
+
|
|
33
|
+
**Globally**
|
|
30
34
|
|
|
31
35
|
```bash
|
|
32
36
|
npm install -g component-gen-cli
|
|
33
37
|
cg --help
|
|
34
38
|
```
|
|
35
39
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
---
|
|
39
|
-
|
|
40
|
-
## Commands
|
|
40
|
+
**As a dev tool in another project**
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
```bash
|
|
43
|
+
npm install --save-dev component-gen-cli
|
|
44
|
+
npx cg --help
|
|
45
|
+
```
|
|
43
46
|
|
|
44
|
-
|
|
47
|
+
---
|
|
45
48
|
|
|
46
|
-
|
|
49
|
+
## Quick start
|
|
47
50
|
|
|
48
51
|
```bash
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
# React + TypeScript into ./src/components
|
|
53
|
+
npx component-gen-cli@latest generate ProductCard -f react --typescript --out ./src/components
|
|
54
|
+
|
|
55
|
+
# Same, short form
|
|
56
|
+
cg g ProductCard -f react --ts -o ./src/components
|
|
51
57
|
```
|
|
52
58
|
|
|
53
|
-
|
|
54
|
-
|--------|--------|
|
|
55
|
-
| `-o`, `--out <dir>` | Output folder (default: `.`) |
|
|
56
|
-
| `--typescript`, `--ts` | TypeScript where applicable |
|
|
57
|
-
| `--scss` | Angular: use `.scss` instead of `.css` |
|
|
58
|
-
| `--client` | Next.js: add `"use client"` |
|
|
59
|
+
Run **`cg`** with **no arguments** to print the full help block (same examples as **`cg examples`**).
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
---
|
|
61
62
|
|
|
62
|
-
|
|
63
|
-
cg generate --help
|
|
64
|
-
cg g -h
|
|
65
|
-
```
|
|
63
|
+
## Supported frameworks
|
|
66
64
|
|
|
67
|
-
|
|
65
|
+
Use **`-f`** or **`--framework`** with exactly one value:
|
|
68
66
|
|
|
69
|
-
|
|
67
|
+
| Value | Typical output |
|
|
68
|
+
|-------|----------------|
|
|
69
|
+
| **`react`** | `<Name>.jsx` or `<Name>.tsx` |
|
|
70
|
+
| **`vue`** | `<Name>.vue` (Vue 3 `<script setup>`) |
|
|
71
|
+
| **`angular`** | `<kebab>/<kebab>.component.ts` plus `.html` and `.css` or `.scss` |
|
|
72
|
+
| **`svelte`** | `<Name>.svelte` |
|
|
73
|
+
| **`solid`** | `<Name>.jsx` / `<Name>.tsx` (JSX component) |
|
|
74
|
+
| **`next`** | `<Name>.jsx` / `<Name>.tsx` (Next-compatible React; optional `'use client'`) |
|
|
70
75
|
|
|
71
|
-
|
|
76
|
+
Angular uses a **standalone** component and **selector** `app-<kebab>` (from your component name).
|
|
72
77
|
|
|
73
|
-
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## CLI reference
|
|
74
81
|
|
|
75
|
-
###
|
|
82
|
+
### Discover commands
|
|
76
83
|
|
|
77
84
|
```bash
|
|
78
|
-
cg
|
|
85
|
+
cg # Help + examples
|
|
86
|
+
cg frameworks # List targets (aliases: cg fw, cg targets)
|
|
87
|
+
cg examples # Examples only (alias: cg guide)
|
|
88
|
+
cg generate --help # All flags for generate (alias: cg g -h)
|
|
79
89
|
cg help generate
|
|
80
|
-
cg --
|
|
81
|
-
|
|
90
|
+
cg --version # Published version
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### `generate` / `g`
|
|
94
|
+
|
|
95
|
+
```text
|
|
96
|
+
cg generate <ComponentName> -f <framework> [options]
|
|
97
|
+
cg g <ComponentName> -f <framework> [options]
|
|
82
98
|
```
|
|
83
99
|
|
|
100
|
+
`<ComponentName>` can be PascalCase (`UserCard`), kebab-case (`user-card`), or spaced words (`user card`). Names are normalized to PascalCase for file symbols and sensible paths.
|
|
101
|
+
|
|
102
|
+
| Option | Description |
|
|
103
|
+
|--------|--------------|
|
|
104
|
+
| **`-f, --framework <fw>`** | **Required.** `react`, `vue`, `angular`, `svelte`, `solid`, or `next`. |
|
|
105
|
+
| **`-o, --out <dir>`** | Destination folder (default: current directory `.`). Parent folders are created as needed. |
|
|
106
|
+
| **`--typescript`, `--ts`** | TypeScript dialect (`.tsx`, `<script lang="ts">`, etc.). Omit for plain JS where supported. Angular component class is **always `.ts`**; this flag aligns other TS-related choices where relevant. |
|
|
107
|
+
| **`--scss`** | **Angular only:** use **`*.component.scss`** instead of **`.css`**. |
|
|
108
|
+
| **`--client`** | **Next.js only:** insert **`'use client'`** at top of file (client boundary). |
|
|
109
|
+
|
|
84
110
|
---
|
|
85
111
|
|
|
86
|
-
##
|
|
112
|
+
## Examples by stack
|
|
87
113
|
|
|
88
|
-
|
|
114
|
+
<details>
|
|
115
|
+
<summary><strong>React</strong></summary>
|
|
89
116
|
|
|
90
117
|
```bash
|
|
91
|
-
|
|
118
|
+
cg g Avatar -f react --ts --out ./src/components
|
|
119
|
+
cg g Avatar -f react --out ./src/components
|
|
92
120
|
```
|
|
93
121
|
|
|
94
|
-
|
|
122
|
+
Creates `Avatar.tsx` or `Avatar.jsx`.
|
|
123
|
+
|
|
124
|
+
</details>
|
|
125
|
+
|
|
126
|
+
<details>
|
|
127
|
+
<summary><strong>Vue 3</strong></summary>
|
|
95
128
|
|
|
96
129
|
```bash
|
|
97
|
-
cg g
|
|
130
|
+
cg g SearchBar -f vue --ts --out ./components
|
|
131
|
+
cg g SearchBar -f vue --out ./components
|
|
98
132
|
```
|
|
99
133
|
|
|
100
|
-
|
|
134
|
+
Creates `SearchBar.vue`.
|
|
135
|
+
|
|
136
|
+
</details>
|
|
137
|
+
|
|
138
|
+
<details>
|
|
139
|
+
<summary><strong>Angular</strong></summary>
|
|
101
140
|
|
|
102
141
|
```bash
|
|
103
|
-
cg g
|
|
142
|
+
cg g MetricsTile -f angular --out ./src/app/widgets
|
|
143
|
+
cg g MetricsTile -f angular --scss --out ./src/app/widgets
|
|
104
144
|
```
|
|
105
145
|
|
|
106
|
-
|
|
146
|
+
Creates `<kebab>/` containing `*.component.ts`, `*.component.html`, and `*.component.css` or `*.scss`.
|
|
147
|
+
|
|
148
|
+
</details>
|
|
149
|
+
|
|
150
|
+
<details>
|
|
151
|
+
<summary><strong>Svelte</strong></summary>
|
|
107
152
|
|
|
108
153
|
```bash
|
|
109
|
-
cg g
|
|
154
|
+
cg g Toast -f svelte --ts --out ./lib
|
|
110
155
|
```
|
|
111
156
|
|
|
112
|
-
|
|
157
|
+
Creates `Toast.svelte`.
|
|
158
|
+
|
|
159
|
+
</details>
|
|
160
|
+
|
|
161
|
+
<details>
|
|
162
|
+
<summary><strong>SolidJS</strong></summary>
|
|
113
163
|
|
|
114
164
|
```bash
|
|
115
|
-
cg g
|
|
165
|
+
cg g Counter -f solid --ts --out ./src/ui
|
|
116
166
|
```
|
|
117
167
|
|
|
118
|
-
|
|
168
|
+
Creates `Counter.tsx` / `Counter.jsx`.
|
|
169
|
+
|
|
170
|
+
</details>
|
|
171
|
+
|
|
172
|
+
<details>
|
|
173
|
+
<summary><strong>Next.js</strong></summary>
|
|
119
174
|
|
|
120
175
|
```bash
|
|
121
|
-
cg g
|
|
176
|
+
cg g Sidebar -f next --ts --out ./components
|
|
177
|
+
cg g Sidebar -f next --ts --client --out ./components
|
|
122
178
|
```
|
|
123
179
|
|
|
124
|
-
|
|
180
|
+
Creates `Sidebar.tsx` or `Sidebar.jsx`. Use **`--client`** when the scaffold uses hooks or browser-only APIs in the App Router.
|
|
125
181
|
|
|
126
|
-
|
|
127
|
-
|
|
182
|
+
</details>
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Programmatic use (advanced)
|
|
187
|
+
|
|
188
|
+
Published entry is ESM **`src/index.js`**. You may import (**after** resolving from `node_modules` in your toolchain):
|
|
189
|
+
|
|
190
|
+
```js
|
|
191
|
+
import { generateComponent, FRAMEWORKS } from "component-gen-cli";
|
|
128
192
|
```
|
|
129
193
|
|
|
194
|
+
Typical callers run the **`cg`** CLI instead.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## How the npm readme is updated
|
|
199
|
+
|
|
200
|
+
The page at **npmjs.com** shows **`README.md` from your package tarball**. After you edit this file **at the repo root**:
|
|
201
|
+
|
|
202
|
+
1. Bump **`version`** in **`package.json`** (required for each new publish unless you unpublished).
|
|
203
|
+
2. Run **`npm publish --access public`** (add **`--otp <code>`** if npm asks).
|
|
204
|
+
|
|
130
205
|
---
|
|
131
206
|
|
|
132
|
-
##
|
|
207
|
+
## Contributing & issues
|
|
133
208
|
|
|
134
|
-
|
|
135
|
-
2. `npm publish --access public` — add `--otp <code>` if npm requires 2FA.
|
|
209
|
+
Use your repository’s tracker for bugs and ideas. Pull requests improving templates or frameworks are welcome once you open a fork and keep changes focused.
|
|
136
210
|
|
|
137
211
|
---
|
|
138
212
|
|