@astralkit/cli 3.1.0 → 4.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/bin/index.js +155 -156
- package/package.json +42 -48
- package/src/commands/add.js +155 -479
- package/src/commands/diff.js +57 -107
- package/src/commands/init.js +108 -148
- package/src/commands/list.js +46 -186
- package/src/commands/login.js +133 -157
- package/src/commands/remove.js +42 -118
- package/src/commands/search.js +58 -156
- package/src/commands/update.js +90 -120
- package/src/lib/ai-rules.js +49 -50
- package/src/lib/api.js +152 -197
- package/src/lib/auth.js +98 -142
- package/src/lib/config.js +127 -163
- package/src/lib/pkg-manager.js +25 -65
- package/src/lib/validators.js +50 -87
package/bin/index.js
CHANGED
|
@@ -1,156 +1,155 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
.
|
|
29
|
-
.
|
|
30
|
-
.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
.
|
|
37
|
-
.
|
|
38
|
-
.option('--
|
|
39
|
-
.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
.
|
|
44
|
-
.
|
|
45
|
-
.option('--
|
|
46
|
-
.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
.
|
|
51
|
-
.
|
|
52
|
-
.option('--
|
|
53
|
-
.action(
|
|
54
|
-
|
|
55
|
-
// ───
|
|
56
|
-
program
|
|
57
|
-
.command('
|
|
58
|
-
.description('
|
|
59
|
-
.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
.
|
|
65
|
-
.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
.
|
|
80
|
-
.
|
|
81
|
-
.action(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
program.parse();
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import pc from 'picocolors';
|
|
5
|
+
import { createRequire } from 'module';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
import { dirname, join } from 'path';
|
|
8
|
+
|
|
9
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
11
|
+
const pkg = require(join(__dirname, '..', 'package.json'));
|
|
12
|
+
|
|
13
|
+
import { initCommand } from '../src/commands/init.js';
|
|
14
|
+
import { addCommand } from '../src/commands/add.js';
|
|
15
|
+
import { removeCommand } from '../src/commands/remove.js';
|
|
16
|
+
import { loginCommand } from '../src/commands/login.js';
|
|
17
|
+
import { listCommand } from '../src/commands/list.js';
|
|
18
|
+
import { searchCommand } from '../src/commands/search.js';
|
|
19
|
+
import { diffCommand } from '../src/commands/diff.js';
|
|
20
|
+
import { updateCommand } from '../src/commands/update.js';
|
|
21
|
+
import { getAuth } from '../src/lib/auth.js';
|
|
22
|
+
import { verifyAuth } from '../src/lib/api.js';
|
|
23
|
+
import { clearToken } from '../src/lib/auth.js';
|
|
24
|
+
|
|
25
|
+
const program = new Command();
|
|
26
|
+
|
|
27
|
+
program
|
|
28
|
+
.name('astralkit')
|
|
29
|
+
.description('AstralKit CLI — Install and manage UI components, boosters, and workflows')
|
|
30
|
+
.version(pkg.version);
|
|
31
|
+
|
|
32
|
+
// ─── init ────────────────────────────────────────────
|
|
33
|
+
program
|
|
34
|
+
.command('init')
|
|
35
|
+
.description('Initialize AstralKit in your project')
|
|
36
|
+
.option('--api-key <key>', 'Your API key (from astralkit.com/account)')
|
|
37
|
+
.option('--framework <framework>', 'Framework to use (auto-detected if omitted)')
|
|
38
|
+
.option('--dir <directory>', 'Component output directory', 'src/components/ui')
|
|
39
|
+
.action(initCommand);
|
|
40
|
+
|
|
41
|
+
// ─── add ─────────────────────────────────────────────
|
|
42
|
+
program
|
|
43
|
+
.command('add <name>')
|
|
44
|
+
.description('Add a component, booster, or workflow to your project')
|
|
45
|
+
.option('--api-key <key>', 'Your API key')
|
|
46
|
+
.option('-f, --framework <framework>', 'Framework version (html, react, nextjs)')
|
|
47
|
+
.option('--dir <directory>', 'Override output directory')
|
|
48
|
+
.option('--overwrite', 'Overwrite existing files', false)
|
|
49
|
+
.option('--booster', 'Install a booster (feature module)')
|
|
50
|
+
.option('--workflow', 'Scaffold a workflow (complete app template)')
|
|
51
|
+
.option('--overlay', 'Merge workflow into current project')
|
|
52
|
+
.option('--dry-run', 'Preview what will be installed without writing files', false)
|
|
53
|
+
.action(addCommand);
|
|
54
|
+
|
|
55
|
+
// ─── remove ──────────────────────────────────────────
|
|
56
|
+
program
|
|
57
|
+
.command('remove <name>')
|
|
58
|
+
.description('Remove a previously installed component, booster, or workflow')
|
|
59
|
+
.option('--force', 'Skip confirmation prompt', false)
|
|
60
|
+
.action(removeCommand);
|
|
61
|
+
|
|
62
|
+
// ─── login ───────────────────────────────────────────
|
|
63
|
+
program
|
|
64
|
+
.command('login')
|
|
65
|
+
.description('Authenticate with AstralKit for premium content')
|
|
66
|
+
.action(loginCommand);
|
|
67
|
+
|
|
68
|
+
// ─── logout ──────────────────────────────────────────
|
|
69
|
+
program
|
|
70
|
+
.command('logout')
|
|
71
|
+
.description('Remove stored authentication')
|
|
72
|
+
.action(async () => {
|
|
73
|
+
clearToken();
|
|
74
|
+
console.log(pc.green('Logged out successfully.'));
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// ─── whoami ──────────────────────────────────────────
|
|
78
|
+
program
|
|
79
|
+
.command('whoami')
|
|
80
|
+
.description('Show current authentication status and plan')
|
|
81
|
+
.action(async () => {
|
|
82
|
+
const ora = (await import('ora')).default;
|
|
83
|
+
const auth = getAuth();
|
|
84
|
+
|
|
85
|
+
if (!auth.token) {
|
|
86
|
+
if (auth.expired) {
|
|
87
|
+
console.log(pc.yellow('Session expired.'));
|
|
88
|
+
console.log(pc.gray('Run') + ' ' + pc.cyan('astralkit login') + ' ' + pc.gray('to re-authenticate.'));
|
|
89
|
+
} else {
|
|
90
|
+
console.log(pc.yellow('Not authenticated.'));
|
|
91
|
+
console.log(pc.gray('Run') + ' ' + pc.cyan('astralkit login') + ' ' + pc.gray('to authenticate.'));
|
|
92
|
+
}
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const spinner = ora('Verifying authentication...').start();
|
|
97
|
+
try {
|
|
98
|
+
const data = await verifyAuth();
|
|
99
|
+
spinner.stop();
|
|
100
|
+
console.log(pc.green('Authenticated as:'), data.email || 'unknown');
|
|
101
|
+
console.log(pc.gray('Plan:'), data.plan || 'free');
|
|
102
|
+
if (auth.source === 'env') {
|
|
103
|
+
console.log(pc.gray('Source: ASTRALKIT_TOKEN environment variable'));
|
|
104
|
+
}
|
|
105
|
+
} catch (err) {
|
|
106
|
+
spinner.stop();
|
|
107
|
+
if (err.code === 'AUTH_REQUIRED') {
|
|
108
|
+
console.log(pc.yellow('Token is invalid or expired.'));
|
|
109
|
+
console.log(pc.gray('Run') + ' ' + pc.cyan('astralkit login') + ' ' + pc.gray('to re-authenticate.'));
|
|
110
|
+
} else {
|
|
111
|
+
console.log(pc.green('Authenticated as:'), auth.email || 'unknown');
|
|
112
|
+
console.log(pc.gray('Plan:'), auth.plan || 'unknown', pc.gray('(cached — unable to verify)'));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// ─── list ────────────────────────────────────────────
|
|
118
|
+
program
|
|
119
|
+
.command('list')
|
|
120
|
+
.description('List available components, boosters, or workflows')
|
|
121
|
+
.option('-c, --category <category>', 'Filter by category')
|
|
122
|
+
.option('--framework <framework>', 'Filter by framework')
|
|
123
|
+
.option('--pro', 'Show only pro items', false)
|
|
124
|
+
.option('--free', 'Show only free items', false)
|
|
125
|
+
.option('--boosters', 'List boosters')
|
|
126
|
+
.option('--workflows', 'List workflows')
|
|
127
|
+
.action(listCommand);
|
|
128
|
+
|
|
129
|
+
// ─── search ──────────────────────────────────────────
|
|
130
|
+
program
|
|
131
|
+
.command('search <query>')
|
|
132
|
+
.description('Search for components, boosters, or workflows')
|
|
133
|
+
.option('--framework <framework>', 'Filter by framework')
|
|
134
|
+
.option('--boosters', 'Search boosters only')
|
|
135
|
+
.option('--workflows', 'Search workflows only')
|
|
136
|
+
.action(searchCommand);
|
|
137
|
+
|
|
138
|
+
// ─── diff ────────────────────────────────────────────
|
|
139
|
+
program
|
|
140
|
+
.command('diff <component>')
|
|
141
|
+
.description('Show differences between local and remote component')
|
|
142
|
+
.option('-f, --framework <framework>', 'Framework version')
|
|
143
|
+
.option('--dir <directory>', 'Override component directory')
|
|
144
|
+
.action(diffCommand);
|
|
145
|
+
|
|
146
|
+
// ─── update ──────────────────────────────────────────
|
|
147
|
+
program
|
|
148
|
+
.command('update <component>')
|
|
149
|
+
.description('Update a component to the latest version')
|
|
150
|
+
.option('-f, --framework <framework>', 'Framework version')
|
|
151
|
+
.option('--dir <directory>', 'Override component directory')
|
|
152
|
+
.option('--force', 'Skip confirmation prompt', false)
|
|
153
|
+
.action(updateCommand);
|
|
154
|
+
|
|
155
|
+
program.parse();
|
package/package.json
CHANGED
|
@@ -1,48 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@astralkit/cli",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "AstralKit CLI — Install and manage UI components in your project",
|
|
5
|
-
"
|
|
6
|
-
"bin": {
|
|
7
|
-
"astralkit": "bin/index.js"
|
|
8
|
-
},
|
|
9
|
-
"files": [
|
|
10
|
-
"bin",
|
|
11
|
-
"src",
|
|
12
|
-
"LICENSE"
|
|
13
|
-
],
|
|
14
|
-
"engines": {
|
|
15
|
-
"node": ">=18.0.0"
|
|
16
|
-
},
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"chalk": "^4.1.2",
|
|
44
|
-
"ora": "^5.4.1",
|
|
45
|
-
"inquirer": "^8.2.6",
|
|
46
|
-
"open": "^8.4.2"
|
|
47
|
-
}
|
|
48
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@astralkit/cli",
|
|
3
|
+
"version": "4.1.0",
|
|
4
|
+
"description": "AstralKit CLI — Install and manage UI components in your project",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"astralkit": "bin/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"src",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=18.0.0"
|
|
16
|
+
},
|
|
17
|
+
"keywords": ["astralkit", "ui", "components", "tailwind", "cli", "react", "nextjs"],
|
|
18
|
+
"homepage": "https://astralkit.com",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/astral-kit/cli.git"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/astral-kit/cli/issues"
|
|
25
|
+
},
|
|
26
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public",
|
|
29
|
+
"registry": "https://registry.npmjs.org"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"prepublishOnly": "node -e \"import('./package.json', { with: { type: 'json' } }).then(m => console.log('v' + m.default.version))\""
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@clack/prompts": "^0.9.1",
|
|
36
|
+
"commander": "^12.0.0",
|
|
37
|
+
"execa": "^9.0.0",
|
|
38
|
+
"open": "^10.0.0",
|
|
39
|
+
"ora": "^8.0.0",
|
|
40
|
+
"picocolors": "^1.1.0"
|
|
41
|
+
}
|
|
42
|
+
}
|