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