@astralkit/cli 4.7.0 → 4.7.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/CHANGELOG.md +12 -0
- package/package.json +1 -1
- package/src/commands/add.js +18 -4
- package/src/commands/list.js +8 -5
- package/src/commands/search.js +18 -6
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,18 @@ All notable changes to the `@astralkit/cli` package.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [4.7.2] (2026-11-30)
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- **`astralkit search` and `astralkit list` work again.** `search <anything>` stopped with "(components.value || []).map is not a function", and `list` (also with `--boosters` or `--workflows`) answered "No components found." Both read the registry's answer as a bare list; it is an object holding the list. `add` was not affected.
|
|
12
|
+
- When the registry holds more than it returns in one answer, the heading says so ("Showing 50 of 636 components available") instead of giving the number shown as the whole library.
|
|
13
|
+
|
|
14
|
+
## [4.7.1] (2026-11-30)
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- **The free components install without a key.** `astralkit add button` stopped with "No API key found" before it had asked for anything, so nobody without a key could install even the free set. A component is now asked for first; the registry says when one is premium, and the CLI then gives the three ways to sign in (`astralkit login`, `astralkit init --api-key`, or the `ASTRALKIT_API_KEY` environment variable). Boosters and workflows still need a key.
|
|
18
|
+
- **A name that is not found ends with exit code 1.** `astralkit add no-such-thing` printed "not found" and exited 0, so a script or an agent took it for installed.
|
|
19
|
+
|
|
8
20
|
## [4.7.0] (2026-11-30)
|
|
9
21
|
|
|
10
22
|
### Added
|
package/package.json
CHANGED
package/src/commands/add.js
CHANGED
|
@@ -71,10 +71,13 @@ async function addOne(nameOrSlug, options) {
|
|
|
71
71
|
saveApiKey(options.apiKey);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
//
|
|
75
|
-
//
|
|
74
|
+
// A component needs no key to be asked for (2026-11-30): the free components install for everyone, and the
|
|
75
|
+
// registry itself says when one is premium (handleAddError then tells how to sign in). The CLI used to stop here
|
|
76
|
+
// with "No API key found" before asking, so nobody without a key could install even the free set.
|
|
77
|
+
// Boosters and workflows are for paid plans: they still need a key, unless read from a local registry
|
|
78
|
+
// (the developer's own disk, no account needed).
|
|
76
79
|
const localBoosterInstall = LOCAL_REGISTRY_DIR && (options.booster || options.workflow);
|
|
77
|
-
if (!getApiKey() && !localBoosterInstall) {
|
|
80
|
+
if ((options.booster || options.workflow) && !getApiKey() && !localBoosterInstall) {
|
|
78
81
|
const auth = getAuth();
|
|
79
82
|
if (!auth.token) {
|
|
80
83
|
p.log.warn('No API key found. Run ' + pc.cyan('astralkit init --api-key <key>') + ' first.');
|
|
@@ -141,6 +144,8 @@ async function addOne(nameOrSlug, options) {
|
|
|
141
144
|
p.log.error(`"${nameOrSlug}" not found in any registry.`);
|
|
142
145
|
p.log.info('Run ' + pc.cyan('astralkit search "' + nameOrSlug + '"') + ' to browse available content.');
|
|
143
146
|
}
|
|
147
|
+
// nothing was installed: a script or an agent must be able to tell (the exit code was 0)
|
|
148
|
+
process.exitCode = 1;
|
|
144
149
|
return;
|
|
145
150
|
}
|
|
146
151
|
|
|
@@ -820,7 +825,16 @@ async function addWorkflow(slug, options) {
|
|
|
820
825
|
|
|
821
826
|
function handleAddError(err, slug, framework) {
|
|
822
827
|
if (err.code === 'AUTH_REQUIRED') {
|
|
823
|
-
|
|
828
|
+
if (!getApiKey() && !getAuth().token) {
|
|
829
|
+
// no key at all: say what the component is and the three ways to give one
|
|
830
|
+
p.log.warn(`${pc.cyan(slug)} is a premium component: it needs your AstralKit API key.`);
|
|
831
|
+
console.log(pc.gray(' Sign in once: ') + pc.cyan('astralkit login'));
|
|
832
|
+
console.log(pc.gray(' Or save a key: ') + pc.cyan('astralkit init --api-key <key>'));
|
|
833
|
+
console.log(pc.gray(' Or for this run: set the ASTRALKIT_API_KEY environment variable'));
|
|
834
|
+
console.log(pc.gray(' Your key is at ') + pc.cyan('https://astralkit.com/account') + pc.gray('. The free components install without one: ') + pc.cyan('astralkit list --free'));
|
|
835
|
+
} else {
|
|
836
|
+
p.log.warn(err.message);
|
|
837
|
+
}
|
|
824
838
|
} else if (err.code === 'PRO_REQUIRED') {
|
|
825
839
|
p.log.warn(`${FRAMEWORK_LABELS[framework] || framework} version requires a Pro subscription.`);
|
|
826
840
|
console.log(pc.gray(' Upgrade at ') + pc.cyan('https://astralkit.com/pricing'));
|
package/src/commands/list.js
CHANGED
|
@@ -15,12 +15,15 @@ export async function listCommand(options) {
|
|
|
15
15
|
const spinner = ora(`Fetching ${type}...`).start();
|
|
16
16
|
|
|
17
17
|
try {
|
|
18
|
-
let items;
|
|
19
18
|
const filters = { framework: options.framework, pro: options.pro, free: options.free, category: options.category };
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
else
|
|
20
|
+
let res;
|
|
21
|
+
if (options.boosters) res = await listBoosters(filters);
|
|
22
|
+
else if (options.workflows) res = await listWorkflows(filters);
|
|
23
|
+
else res = await listComponents(filters);
|
|
24
|
+
// The API answers { components: [...], pagination, total } (or boosters / workflows). Older answers were a bare list.
|
|
25
|
+
const items = Array.isArray(res) ? res : res?.[type] || res?.data || [];
|
|
26
|
+
const total = res?.pagination?.total ?? items.length;
|
|
24
27
|
|
|
25
28
|
spinner.stop();
|
|
26
29
|
|
|
@@ -30,7 +33,7 @@ export async function listCommand(options) {
|
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
console.log();
|
|
33
|
-
console.log(pc.bold(` ${items.length} ${type} available\n`));
|
|
36
|
+
console.log(pc.bold(` ${total > items.length ? `Showing ${items.length} of ${total}` : items.length} ${type} available\n`));
|
|
34
37
|
|
|
35
38
|
for (const item of items) {
|
|
36
39
|
const proTag = item.is_pro ? pc.magenta(' [PRO]') : pc.green(' [FREE]');
|
package/src/commands/search.js
CHANGED
|
@@ -7,6 +7,10 @@ const s = (v) => sanitizeForTerminal(v || '');
|
|
|
7
7
|
|
|
8
8
|
const FRAMEWORK_LABELS = { nextjs: 'Next.js', react: 'React', html: 'HTML' };
|
|
9
9
|
|
|
10
|
+
// The API answers { components: [...], pagination, total } (or boosters / workflows). Older answers were a bare list.
|
|
11
|
+
const itemsOf = (res, key) => (Array.isArray(res) ? res : res?.[key] || res?.data || []);
|
|
12
|
+
const totalOf = (res, shown) => res?.pagination?.total ?? shown;
|
|
13
|
+
|
|
10
14
|
export async function searchCommand(query, options) {
|
|
11
15
|
const ora = (await import('ora')).default;
|
|
12
16
|
const spinner = ora(`Searching for "${pc.cyan(query)}"...`).start();
|
|
@@ -14,11 +18,16 @@ export async function searchCommand(query, options) {
|
|
|
14
18
|
try {
|
|
15
19
|
const filters = { search: query, framework: options.framework };
|
|
16
20
|
let results = [];
|
|
21
|
+
let total = 0;
|
|
17
22
|
|
|
18
23
|
if (options.boosters) {
|
|
19
|
-
|
|
24
|
+
const res = await listBoosters(filters);
|
|
25
|
+
results = itemsOf(res, 'boosters');
|
|
26
|
+
total = totalOf(res, results.length);
|
|
20
27
|
} else if (options.workflows) {
|
|
21
|
-
|
|
28
|
+
const res = await listWorkflows(filters);
|
|
29
|
+
results = itemsOf(res, 'workflows');
|
|
30
|
+
total = totalOf(res, results.length);
|
|
22
31
|
} else {
|
|
23
32
|
// Search all three in parallel
|
|
24
33
|
const [components, boosters, workflows] = await Promise.allSettled([
|
|
@@ -26,9 +35,12 @@ export async function searchCommand(query, options) {
|
|
|
26
35
|
listBoosters(filters),
|
|
27
36
|
listWorkflows(filters),
|
|
28
37
|
]);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
38
|
+
for (const [settled, key, type] of [[components, 'components', 'component'], [boosters, 'boosters', 'booster'], [workflows, 'workflows', 'workflow']]) {
|
|
39
|
+
if (settled.status !== 'fulfilled') continue;
|
|
40
|
+
const items = itemsOf(settled.value, key);
|
|
41
|
+
results.push(...items.map(i => ({ ...i, _type: type })));
|
|
42
|
+
total += totalOf(settled.value, items.length);
|
|
43
|
+
}
|
|
32
44
|
}
|
|
33
45
|
|
|
34
46
|
spinner.stop();
|
|
@@ -39,7 +51,7 @@ export async function searchCommand(query, options) {
|
|
|
39
51
|
}
|
|
40
52
|
|
|
41
53
|
console.log();
|
|
42
|
-
console.log(pc.bold(` ${results.length} result(s) for "${query}"\n`));
|
|
54
|
+
console.log(pc.bold(` ${total > results.length ? `Showing ${results.length} of ${total}` : results.length} result(s) for "${query}"\n`));
|
|
43
55
|
|
|
44
56
|
for (const item of results) {
|
|
45
57
|
const typeLabel = item._type ? pc.gray(` [${item._type}]`) : '';
|