@astralkit/cli 4.7.2 → 4.7.3
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 +5 -0
- package/package.json +1 -1
- package/src/commands/list.js +2 -2
- package/src/commands/search.js +2 -2
- package/src/lib/validators.js +22 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,11 @@ 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.3] (2026-12-01)
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- **`search` and `list` print one sentence per result.** Each result showed its whole description, a paragraph for most components, so fifty results ran to several screens. Now it is the first sentence, cut at 160 characters with an ellipsis when that sentence is longer. The full description is on the component's page at astralkit.com.
|
|
12
|
+
|
|
8
13
|
## [4.7.2] (2026-11-30)
|
|
9
14
|
|
|
10
15
|
### Fixed
|
package/package.json
CHANGED
package/src/commands/list.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import pc from 'picocolors';
|
|
2
2
|
import * as p from '@clack/prompts';
|
|
3
3
|
import { listComponents, listBoosters, listWorkflows } from '../lib/api.js';
|
|
4
|
-
import { sanitizeForTerminal } from '../lib/validators.js';
|
|
4
|
+
import { sanitizeForTerminal, firstSentence } from '../lib/validators.js';
|
|
5
5
|
|
|
6
6
|
// Server-supplied string passthrough protection — strips ANSI/control sequences
|
|
7
7
|
// before printing. Prevents a malicious API from rewriting the terminal.
|
|
@@ -39,7 +39,7 @@ export async function listCommand(options) {
|
|
|
39
39
|
const proTag = item.is_pro ? pc.magenta(' [PRO]') : pc.green(' [FREE]');
|
|
40
40
|
const fw = item.frameworks?.map(f => FRAMEWORK_LABELS[f] || f).join(', ') || '';
|
|
41
41
|
console.log(` ${pc.cyan(s(item.slug || item.name))}${proTag}`);
|
|
42
|
-
if (item.description) console.log(pc.gray(` ${
|
|
42
|
+
if (item.description) console.log(pc.gray(` ${firstSentence(item.description)}`));
|
|
43
43
|
if (fw) console.log(pc.gray(` Frameworks: ${s(fw)}`));
|
|
44
44
|
console.log();
|
|
45
45
|
}
|
package/src/commands/search.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import pc from 'picocolors';
|
|
2
2
|
import * as p from '@clack/prompts';
|
|
3
3
|
import { listComponents, listBoosters, listWorkflows } from '../lib/api.js';
|
|
4
|
-
import { sanitizeForTerminal } from '../lib/validators.js';
|
|
4
|
+
import { sanitizeForTerminal, firstSentence } from '../lib/validators.js';
|
|
5
5
|
|
|
6
6
|
const s = (v) => sanitizeForTerminal(v || '');
|
|
7
7
|
|
|
@@ -58,7 +58,7 @@ export async function searchCommand(query, options) {
|
|
|
58
58
|
const proTag = item.is_pro ? pc.magenta(' [PRO]') : pc.green(' [FREE]');
|
|
59
59
|
const fw = item.frameworks?.map(f => FRAMEWORK_LABELS[f] || f).join(', ') || '';
|
|
60
60
|
console.log(` ${pc.cyan(s(item.slug || item.name))}${typeLabel}${proTag}`);
|
|
61
|
-
if (item.description) console.log(pc.gray(` ${
|
|
61
|
+
if (item.description) console.log(pc.gray(` ${firstSentence(item.description)}`));
|
|
62
62
|
if (fw) console.log(pc.gray(` Frameworks: ${s(fw)}`));
|
|
63
63
|
console.log();
|
|
64
64
|
}
|
package/src/lib/validators.js
CHANGED
|
@@ -58,6 +58,28 @@ export function sanitizeForTerminal(str) {
|
|
|
58
58
|
return str.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g, '');
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* The first sentence of a description, for one-line listings (`search`, `list`). A registry description runs to a
|
|
63
|
+
* paragraph: printed whole, fifty results fill the terminal many times over.
|
|
64
|
+
* A sentence ends at . ! or ? followed by a space and a capital, a digit or an opening mark, so "audit.log(",
|
|
65
|
+
* "Next.js" and "e.g. this" do not end one. A first sentence longer than `max` is cut at a word, with an ellipsis.
|
|
66
|
+
*/
|
|
67
|
+
export function firstSentence(str, max = 160) {
|
|
68
|
+
const text = sanitizeForTerminal(str).replace(/\s+/g, ' ').trim();
|
|
69
|
+
if (!text) return '';
|
|
70
|
+
let sentence = text;
|
|
71
|
+
const end = /[.!?](?=\s+[A-Z0-9<`"'(\[])/g;
|
|
72
|
+
for (let hit = end.exec(text); hit; hit = end.exec(text)) {
|
|
73
|
+
const before = text.slice(0, hit.index);
|
|
74
|
+
if (/(?:\b(?:e\.g|i\.e|vs|etc|approx|incl)|\b[A-Z])$/.test(before)) continue; // an abbreviation or an initial
|
|
75
|
+
sentence = text.slice(0, hit.index + 1);
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
if (sentence.length <= max) return sentence;
|
|
79
|
+
const cut = sentence.slice(0, max);
|
|
80
|
+
return `${cut.slice(0, Math.max(cut.lastIndexOf(' '), max - 30)).replace(/[\s,;:(\p{Pd}]+$/u, '')}…`;
|
|
81
|
+
}
|
|
82
|
+
|
|
61
83
|
export function validateFramework(framework) {
|
|
62
84
|
if (!framework) return true;
|
|
63
85
|
if (VALID_FRAMEWORKS.includes(framework)) return true;
|