@astralkit/cli 2.1.0 → 3.0.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/README.md CHANGED
@@ -1,267 +1,362 @@
1
- # @astralkit/cli
2
-
3
- Install and manage AstralKit UI components, boosters, and workflows in your project.
4
-
5
- ## Quick Start
6
-
7
- ```bash
8
- # Initialize AstralKit in your project
9
- npx @astralkit/cli init
10
-
11
- # Add a component
12
- npx @astralkit/cli add button-sizes
13
-
14
- # Add a booster (feature module)
15
- npx @astralkit/cli add stripe-payments --booster
16
-
17
- # Scaffold a workflow (complete app)
18
- npx @astralkit/cli add saas-starter --workflow
19
-
20
- # Search for components
21
- npx @astralkit/cli search "pricing table"
22
- ```
23
-
24
- ## Content Types
25
-
26
- AstralKit distributes three types of content:
27
-
28
- | Type | Description | Example |
29
- |------|-------------|---------|
30
- | **Components** | Single UI elements with framework variants | Button, Card, Data Table |
31
- | **Boosters** | Drop-in feature modules (core logic + framework adapters) | Stripe Payments, Auth System |
32
- | **Workflows** | Complete application scaffolds | SaaS Starter, CRM, Admin Dashboard |
33
-
34
- ## Commands
35
-
36
- ### `astralkit init`
37
-
38
- Initialize AstralKit in your project. Detects your framework and creates `astralkit.config.json`.
39
-
40
- ```bash
41
- astralkit init
42
- astralkit init --framework=react
43
- astralkit init --dir=src/components/ui
44
- ```
45
-
46
- ### `astralkit add <name>`
47
-
48
- Add a component, booster, or workflow to your project.
49
-
50
- #### Adding Components
51
-
52
- ```bash
53
- astralkit add avatar-variants
54
- astralkit add pricing-table --framework=react
55
- astralkit add data-table --overwrite
56
- ```
57
-
58
- #### Adding Boosters
59
-
60
- Boosters install framework-agnostic core files (API routes, webhooks, utilities) and framework-specific adapter files (UI components, hooks).
61
-
62
- ```bash
63
- astralkit add stripe-payments --booster
64
- astralkit add auth-system --booster --framework=nextjs
65
- astralkit add stripe-payments --booster --overwrite
66
- ```
67
-
68
- Core files are written to `src/lib/<booster-slug>/` and adapter files to `src/components/<booster-slug>/` by default. Boosters may specify custom install paths.
69
-
70
- #### Adding Workflows
71
-
72
- Workflows scaffold a complete application. By default, files are created in a new `./<slug>/` directory.
73
-
74
- ```bash
75
- astralkit add saas-starter --workflow
76
- astralkit add crm --workflow --framework=nextjs
77
- ```
78
-
79
- Use `--overlay` to merge workflow files into your current project instead of creating a new directory:
80
-
81
- ```bash
82
- astralkit add saas-starter --workflow --overlay
83
- astralkit add saas-starter --workflow --overlay --overwrite
84
- ```
85
-
86
- #### Options
87
-
88
- - `-f, --framework` — Framework version (html, react, vue, nextjs, angular, svelte, astro)
89
- - `--dir` — Override output directory
90
- - `--overwrite` — Overwrite existing files
91
- - `--booster` — Install a booster (feature module)
92
- - `--workflow` — Scaffold a workflow (complete app template)
93
- - `--overlay` — Merge workflow into current project (workflow only)
94
-
95
- ### `astralkit list`
96
-
97
- List available content.
98
-
99
- ```bash
100
- astralkit list # List components
101
- astralkit list --boosters # List boosters
102
- astralkit list --workflows # List workflows
103
- astralkit list --category=forms
104
- astralkit list --framework=react
105
- astralkit list --pro
106
- astralkit list --free
107
- ```
108
-
109
- ### `astralkit search <query>`
110
-
111
- Search by name or description.
112
-
113
- ```bash
114
- astralkit search "data table"
115
- astralkit search "pricing" --framework=react
116
- astralkit search "stripe" --boosters
117
- astralkit search "crm" --workflows
118
- ```
119
-
120
- ### `astralkit diff <component>`
121
-
122
- Show differences between your local component and the latest version.
123
-
124
- ```bash
125
- astralkit diff button-sizes
126
- ```
127
-
128
- ### `astralkit update <component>`
129
-
130
- Update a component to the latest version from AstralKit.
131
-
132
- ```bash
133
- astralkit update button-sizes
134
- astralkit update button-sizes --force
135
- ```
136
-
137
- ### `astralkit login`
138
-
139
- Authenticate with AstralKit to access premium content. Opens your browser for secure login.
140
-
141
- ```bash
142
- astralkit login
143
- ```
144
-
145
- ### `astralkit logout`
146
-
147
- Remove stored authentication.
148
-
149
- ### `astralkit whoami`
150
-
151
- Show current authentication status and subscription plan. Verifies your token with the server.
152
-
153
- ## Premium Content
154
-
155
- Some components, boosters, and workflows require a Pro subscription. When you try to add pro content without authentication:
156
-
157
- ```bash
158
- $ astralkit add pro-data-table
159
- ✖ Failed to add component.
160
- Authentication required. Run `astralkit login` to authenticate.
161
- ```
162
-
163
- After logging in, pro content installs normally:
164
-
165
- ```bash
166
- $ astralkit login
167
- ✔ Authenticated successfully!
168
- Email: you@example.com
169
- Plan: pro
170
-
171
- $ astralkit add stripe-payments --booster
172
- ✔ Added booster Stripe Payments (nextjs)
173
- Core files → src/lib/stripe-payments/
174
- lib/stripe.ts
175
- api/webhooks/stripe/route.ts
176
- Adapter files → src/components/stripe-payments/
177
- components/checkout-button.tsx
178
- hooks/use-subscription.ts
179
-
180
- Install required dependencies:
181
- npm install stripe @stripe/stripe-js
182
-
183
- Add these environment variables to your .env:
184
- STRIPE_SECRET_KEY=
185
- STRIPE_PUBLISHABLE_KEY=
186
- STRIPE_WEBHOOK_SECRET=
187
- ```
188
-
189
- ## Configuration
190
-
191
- ### `astralkit.config.json`
192
-
193
- Created by `astralkit init` in your project root:
194
-
195
- ```json
196
- {
197
- "$schema": "https://astralkit.com/schema/config.json",
198
- "framework": "nextjs",
199
- "componentsDir": "src/components/ui",
200
- "tokensImport": "@astralkit/tokens/css"
201
- }
202
- ```
203
-
204
- ### `~/.astralkit/config.json`
205
-
206
- Stores your authentication token (created by `astralkit login`). This file is created with restricted permissions (owner read/write only).
207
-
208
- ## CI/CD Usage
209
-
210
- For automated environments (CI/CD pipelines, Docker builds), set the `ASTRALKIT_TOKEN` environment variable instead of using browser login:
211
-
212
- ```bash
213
- # Set token from your AstralKit dashboard
214
- export ASTRALKIT_TOKEN="your-api-token"
215
-
216
- # Commands automatically use the env var
217
- astralkit add button-sizes
218
- astralkit add stripe-payments --booster
219
- astralkit whoami
220
- ```
221
-
222
- ## Environment Variables
223
-
224
- | Variable | Description |
225
- |----------|-------------|
226
- | `ASTRALKIT_TOKEN` | API token for CI/CD (skips browser login) |
227
- | `ASTRALKIT_API_URL` | Override API base URL (development only) |
228
- | `ASTRALKIT_LOGIN_PORT` | Override callback port for login (default: 9876) |
229
-
230
- ## Security
231
-
232
- - Authentication tokens are stored at `~/.astralkit/config.json` with `0600` permissions (owner read/write only)
233
- - The config directory is created with `0700` permissions
234
- - Browser login uses CSRF state tokens to prevent cross-site attacks
235
- - CORS is restricted to `astralkit.com` during authentication
236
- - All API requests use HTTPS with 30-second timeouts
237
- - No tokens, secrets, or credentials are ever hardcoded in the package
238
-
239
- ## Troubleshooting
240
-
241
- ### Port 9876 is in use
242
-
243
- If `astralkit login` fails because the port is busy:
244
-
245
- ```bash
246
- # Use a different port
247
- ASTRALKIT_LOGIN_PORT=9877 astralkit login
248
- ```
249
-
250
- ### Token expired
251
-
252
- If you see "Session expired", run `astralkit login` again to get a fresh token.
253
-
254
- ### Network errors
255
-
256
- If you see timeout or connection errors, check your internet connection. The CLI requires access to `astralkit.com`.
257
-
258
- ## Requirements
259
-
260
- - Node.js 18+
261
- - An AstralKit account for premium content
262
-
263
- ## Links
264
-
265
- - [AstralKit](https://astralkit.com)
266
- - [Documentation](https://astralkit.com/docs)
267
- - [Pricing](https://astralkit.com/pricing)
1
+ # @astralkit/cli
2
+
3
+ Install and manage AstralKit UI components, boosters, and workflows in your project.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ # Initialize AstralKit in your project
9
+ npx @astralkit/cli init
10
+
11
+ # Add a component (auto-detects framework)
12
+ npx @astralkit/cli add button-sizes
13
+
14
+ # Add a booster — the CLI will prompt if flags are omitted
15
+ npx @astralkit/cli add auth-system
16
+
17
+ # Scaffold a workflow
18
+ npx @astralkit/cli add saas-starter
19
+
20
+ # Search for content
21
+ npx @astralkit/cli search "pricing table"
22
+ ```
23
+
24
+ No flags needed — the CLI auto-detects what you're installing and which framework you're using.
25
+
26
+ ## Content Types
27
+
28
+ AstralKit distributes three types of content:
29
+
30
+ | Type | Description | Example |
31
+ |------|-------------|---------|
32
+ | **Components** | Single UI elements with framework variants | Button, Card, Data Table |
33
+ | **Boosters** | Drop-in feature modules (core logic + framework adapters) | Auth System, Stripe Billing, File Upload |
34
+ | **Workflows** | Complete application scaffolds | AI SaaS Starter, CRM, Admin Dashboard |
35
+
36
+ ## Commands
37
+
38
+ ### `astralkit add <name>`
39
+
40
+ Add a component, booster, or workflow to your project. The CLI is fully interactive — when you omit flags, it prompts you with arrow-key selections.
41
+
42
+ #### Smart Auto-Detection
43
+
44
+ The CLI automatically:
45
+ - **Detects what you're installing** — searches components, boosters, and workflows for the slug. If found in multiple, prompts you to choose.
46
+ - **Detects your framework** — checks for `next.config.js` (Next.js), `react` in package.json (React), or prompts if unsure.
47
+ - **Detects your package manager** — reads lockfiles (`bun.lockb`, `pnpm-lock.yaml`, `yarn.lock`) and uses the right one.
48
+
49
+ ```bash
50
+ # Fully interactive — no flags needed
51
+ astralkit add auth-system
52
+
53
+ ? What are you installing?
54
+ ❯ Booster (feature module)
55
+ Component (UI element)
56
+ Workflow (complete app)
57
+
58
+ ? Detected Next.js project. Which framework? (nextjs)
59
+
60
+ ✔ Added booster Authentication System (Next.js)
61
+ ```
62
+
63
+ #### Adding Components
64
+
65
+ ```bash
66
+ astralkit add avatar-variants
67
+ astralkit add pricing-table --framework=react
68
+ astralkit add data-table --overwrite
69
+ ```
70
+
71
+ #### Adding Boosters
72
+
73
+ Boosters install framework-agnostic core files and framework-specific adapter files.
74
+
75
+ ```bash
76
+ astralkit add auth-system --booster
77
+ astralkit add stripe-billing --booster --framework=nextjs
78
+ ```
79
+
80
+ Core files go to `src/lib/<slug>/` and adapter files to `src/components/<slug>/` by default.
81
+
82
+ After installing, the CLI offers to install npm dependencies automatically:
83
+
84
+ ```bash
85
+ ✔ Added booster Stripe Billing (Next.js)
86
+ Core files → src/lib/stripe-billing/
87
+ stripe.ts
88
+ webhooks.ts
89
+ Adapter files → src/components/stripe-billing/
90
+ CheckoutButton.tsx
91
+ PricingTable.tsx
92
+
93
+ ? Install dependencies? (stripe, @stripe/stripe-js) (Y/n)
94
+ ✔ Dependencies installed
95
+
96
+ ✅ Stripe Billing installed successfully!
97
+ ```
98
+
99
+ #### Adding Workflows
100
+
101
+ Workflows scaffold a complete application in a new directory.
102
+
103
+ ```bash
104
+ astralkit add ai-saas-starter --workflow
105
+ astralkit add crm --workflow --framework=nextjs
106
+ ```
107
+
108
+ The CLI offers to install dependencies and shows clear next steps:
109
+
110
+ ```bash
111
+ ✔ Scaffolded workflow AI SaaS Starter (Next.js) → ai-saas-starter/
112
+ 24 files written to ai-saas-starter/
113
+
114
+ ? Install dependencies with npm? (Y/n)
115
+ ✔ Dependencies installed
116
+
117
+ ✅ Ready to go!
118
+
119
+ cd ai-saas-starter
120
+ npm run dev
121
+ ```
122
+
123
+ Use `--overlay` to merge workflow files into your current project:
124
+
125
+ ```bash
126
+ astralkit add saas-starter --workflow --overlay
127
+ ```
128
+
129
+ #### Preview Before Installing
130
+
131
+ Use `--dry-run` to see what files will be created without writing anything:
132
+
133
+ ```bash
134
+ astralkit add auth-system --booster --dry-run
135
+
136
+ 📋 Dry run — no files will be written:
137
+
138
+ Core → src/lib/auth-system/
139
+ + create auth.ts
140
+ + create session.ts
141
+ + create middleware.ts
142
+ Adapter → src/components/auth-system/
143
+ + create LoginForm.tsx
144
+ + create SignupForm.tsx
145
+
146
+ Dependencies: better-auth
147
+ ```
148
+
149
+ #### Options
150
+
151
+ | Flag | Description |
152
+ |------|-------------|
153
+ | `-f, --framework` | Framework version (html, react, nextjs) — auto-detected if omitted |
154
+ | `--dir` | Override output directory |
155
+ | `--overwrite` | Overwrite existing files |
156
+ | `--booster` | Install a booster (skip type auto-detection) |
157
+ | `--workflow` | Scaffold a workflow (skip type auto-detection) |
158
+ | `--overlay` | Merge workflow into current project (workflow only) |
159
+ | `--dry-run` | Preview what will be installed without writing files |
160
+
161
+ ### `astralkit remove <name>`
162
+
163
+ Remove a previously installed component, booster, or workflow. Shows what will be deleted and asks for confirmation.
164
+
165
+ ```bash
166
+ astralkit remove auth-system
167
+
168
+ Found files for "auth-system":
169
+
170
+ Booster (core): src/lib/auth-system/
171
+ auth.ts
172
+ session.ts
173
+ Booster (adapter): src/components/auth-system/
174
+ LoginForm.tsx
175
+ SignupForm.tsx
176
+
177
+ ? Remove 2 item(s)? (y/N)
178
+ ✓ Removed src/lib/auth-system/
179
+ ✓ Removed src/components/auth-system/
180
+ ```
181
+
182
+ Use `--force` to skip the confirmation prompt (for scripts/CI).
183
+
184
+ ### `astralkit init`
185
+
186
+ Initialize AstralKit in your project:
187
+
188
+ 1. Installs the `astralkit` npm package (design tokens, utilities, `cn()` helper)
189
+ 2. Adds required CSS imports to your stylesheet
190
+ 3. Creates `astralkit.config.json`
191
+
192
+ ```bash
193
+ astralkit init
194
+ astralkit init --framework=react
195
+ astralkit init --dir=src/components/ui
196
+ ```
197
+
198
+ ### `astralkit list`
199
+
200
+ List available content.
201
+
202
+ ```bash
203
+ astralkit list # List components
204
+ astralkit list --boosters # List boosters
205
+ astralkit list --workflows # List workflows
206
+ astralkit list --category=forms
207
+ astralkit list --framework=react
208
+ astralkit list --pro
209
+ astralkit list --free
210
+ ```
211
+
212
+ ### `astralkit search <query>`
213
+
214
+ Search by name or description.
215
+
216
+ ```bash
217
+ astralkit search "data table"
218
+ astralkit search "pricing" --framework=react
219
+ astralkit search "stripe" --boosters
220
+ astralkit search "crm" --workflows
221
+ ```
222
+
223
+ ### `astralkit diff <component>`
224
+
225
+ Show differences between your local component and the latest version.
226
+
227
+ ```bash
228
+ astralkit diff button-sizes
229
+ ```
230
+
231
+ ### `astralkit update <component>`
232
+
233
+ Update a component to the latest version.
234
+
235
+ ```bash
236
+ astralkit update button-sizes
237
+ astralkit update button-sizes --force
238
+ ```
239
+
240
+ ### `astralkit login` / `astralkit logout` / `astralkit whoami`
241
+
242
+ Manage authentication for premium content.
243
+
244
+ ```bash
245
+ astralkit login # Opens browser for secure login
246
+ astralkit logout # Remove stored token
247
+ astralkit whoami # Show auth status and plan
248
+ ```
249
+
250
+ ## Premium Content
251
+
252
+ Some content requires a Pro subscription:
253
+
254
+ ```bash
255
+ $ astralkit add stripe-billing --booster
256
+ ✖ Pro subscription required for this component.
257
+ Visit https://astralkit.com/pricing
258
+
259
+ $ astralkit login
260
+ ✔ Authenticated successfully!
261
+ Email: you@example.com
262
+ Plan: pro
263
+
264
+ $ astralkit add stripe-billing --booster
265
+ ✔ Added booster Stripe Billing (Next.js)
266
+ ✨ Pro booster — thank you for your subscription!
267
+ ```
268
+
269
+ ## Configuration
270
+
271
+ ### `astralkit.config.json`
272
+
273
+ Created by `astralkit init` in your project root:
274
+
275
+ ```json
276
+ {
277
+ "$schema": "https://astralkit.com/schema/config.json",
278
+ "framework": "nextjs",
279
+ "componentsDir": "src/components/ui"
280
+ }
281
+ ```
282
+
283
+ ### `~/.astralkit/config.json`
284
+
285
+ Stores your authentication token (created by `astralkit login`). This file has restricted permissions (owner read/write only).
286
+
287
+ ## CI/CD Usage
288
+
289
+ For automated environments, set the `ASTRALKIT_TOKEN` environment variable:
290
+
291
+ ```bash
292
+ export ASTRALKIT_TOKEN="your-api-token"
293
+ astralkit add button-sizes
294
+ astralkit add stripe-billing --booster
295
+ ```
296
+
297
+ ## Package Manager Support
298
+
299
+ The CLI auto-detects your package manager from lockfiles:
300
+
301
+ | Lockfile | Package Manager |
302
+ |----------|----------------|
303
+ | `bun.lockb` / `bun.lock` | bun |
304
+ | `pnpm-lock.yaml` | pnpm |
305
+ | `yarn.lock` | yarn |
306
+ | (default) | npm |
307
+
308
+ All install commands, dependency installs, and run commands use the detected package manager automatically.
309
+
310
+ ## Environment Variables
311
+
312
+ | Variable | Description |
313
+ |----------|-------------|
314
+ | `ASTRALKIT_TOKEN` | API token for CI/CD (skips browser login) |
315
+ | `ASTRALKIT_API_URL` | Override API base URL (development only) |
316
+ | `ASTRALKIT_LOGIN_PORT` | Override callback port for login (default: 9876) |
317
+
318
+ ## Security
319
+
320
+ - Tokens stored at `~/.astralkit/config.json` with `0600` permissions
321
+ - Browser login uses CSRF state tokens
322
+ - All API requests use HTTPS with 30-second timeouts
323
+ - No credentials are hardcoded in the package
324
+
325
+ ## Troubleshooting
326
+
327
+ ### Port 9876 is in use
328
+
329
+ ```bash
330
+ ASTRALKIT_LOGIN_PORT=9877 astralkit login
331
+ ```
332
+
333
+ ### Token expired
334
+
335
+ Run `astralkit login` again.
336
+
337
+ ### Dependency conflicts (ERESOLVE)
338
+
339
+ The CLI handles most dependency conflicts automatically. If you see an error, try:
340
+
341
+ ```bash
342
+ # npm
343
+ npm install <package> --legacy-peer-deps
344
+
345
+ # pnpm
346
+ pnpm add <package> --force
347
+ ```
348
+
349
+ ### Network errors
350
+
351
+ Check your internet connection. The CLI requires access to `astralkit.com`.
352
+
353
+ ## Requirements
354
+
355
+ - Node.js 18+
356
+ - An AstralKit account for premium content
357
+
358
+ ## Links
359
+
360
+ - [AstralKit](https://astralkit.com)
361
+ - [Documentation](https://astralkit.com/docs)
362
+ - [Pricing](https://astralkit.com/pricing)
package/bin/index.js CHANGED
@@ -8,6 +8,7 @@ const pkg = require(path.join(__dirname, '..', 'package.json'));
8
8
 
9
9
  const { initCommand } = require('../src/commands/init');
10
10
  const { addCommand } = require('../src/commands/add');
11
+ const { removeCommand } = require('../src/commands/remove');
11
12
  const { loginCommand } = require('../src/commands/login');
12
13
  const { listCommand } = require('../src/commands/list');
13
14
  const { searchCommand } = require('../src/commands/search');
@@ -33,14 +34,22 @@ program
33
34
  program
34
35
  .command('add <name>')
35
36
  .description('Add a component, booster, or workflow to your project')
36
- .option('-f, --framework <framework>', 'Framework version (html, react, vue, nextjs)')
37
+ .option('-f, --framework <framework>', 'Framework version (html, react, nextjs)')
37
38
  .option('--dir <directory>', 'Override output directory')
38
39
  .option('--overwrite', 'Overwrite existing files', false)
39
40
  .option('--booster', 'Install a booster (feature module)')
40
41
  .option('--workflow', 'Scaffold a workflow (complete app template)')
41
42
  .option('--overlay', 'Merge workflow into current project (workflow only)')
43
+ .option('--dry-run', 'Preview what will be installed without writing files', false)
42
44
  .action(addCommand);
43
45
 
46
+ // ─── remove ──────────────────────────────────────────
47
+ program
48
+ .command('remove <name>')
49
+ .description('Remove a previously installed component, booster, or workflow')
50
+ .option('--force', 'Skip confirmation prompt', false)
51
+ .action(removeCommand);
52
+
44
53
  // ─── login ───────────────────────────────────────────
45
54
  program
46
55
  .command('login')