@astryxdesign/cli 0.6.5-canary.d6fa1d6 → 0.6.5-canary.eb0010b
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 +2 -2
- package/api/build/_adapter.d.mts +0 -14
- package/api/build/_adapter.mjs +1 -58
- package/api/build/build.test.mjs +1 -74
- package/api/build/kit/kit.mjs +7 -39
- package/api/build/kit/rank.d.mts +0 -8
- package/api/build/kit/rank.mjs +0 -14
- package/api/docs/docs.d.mts +0 -6
- package/api/docs/docs.doc.mjs +2 -31
- package/api/docs/docs.mjs +1 -44
- package/api/docs/docs.type.d.mts +1 -38
- package/api/docs/docs.type.mjs +1 -18
- package/api/docs/node/node.d.mts +3 -28
- package/api/docs/node/node.mjs +23 -146
- package/api/gap-report/gap-report.d.mts +1 -3
- package/api/gap-report/gap-report.mjs +2 -12
- package/api/gap-report/gap-report.test.mjs +0 -106
- package/api/hook/list/list.d.mts +1 -1
- package/api/integration/add-theme.mjs +3 -93
- package/api/integration/add-theme.test.mjs +0 -100
- package/api/integration/integrationAddTheme.doc.mjs +1 -1
- package/api/search/search.d.mts +5 -12
- package/api/search/search.doc.mjs +4 -4
- package/api/search/search.mjs +53 -123
- package/api/search/search.test.mjs +8 -123
- package/api/search/search.type.d.mts +5 -5
- package/api/search/search.type.mjs +5 -5
- package/api/theme/build/build.mjs +69 -146
- package/api/theme/build/build.test.mjs +1 -190
- package/api/theme/themeBuild.doc.d.mts +1 -4
- package/api/theme/themeBuild.doc.mjs +3 -14
- package/assets/docs/theme.doc.mjs +1 -2
- package/assets/docs/tree/add-a-theme.doc.mjs +0 -4
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
- package/clients/cli/commands/build-theme.mjs +2 -8
- package/clients/cli/commands/discover.mjs +1 -29
- package/clients/cli/commands/docs.doc.mjs +2 -15
- package/clients/cli/commands/docs.mjs +5 -222
- package/clients/cli/commands/gap-report.mjs +0 -12
- package/clients/cli/commands/gap-report.test.mjs +0 -63
- package/clients/cli/commands/integration-add.doc.mjs +1 -1
- package/clients/cli/commands/search.doc.mjs +4 -5
- package/clients/cli/commands/search.mjs +6 -30
- package/clients/cli/commands/search.test.mjs +16 -60
- package/foundation/agent-docs/agent-docs.mjs +1 -2
- package/foundation/agent-docs/agent-docs.test.mjs +0 -8
- package/foundation/discovery/theme-discovery.d.mts +0 -6
- package/foundation/discovery/theme-discovery.mjs +0 -9
- package/foundation/doc-compiler/doc-loads.test.mjs +1 -1
- package/package.json +9 -9
- package/api/build/kit/weights.d.mts +0 -82
- package/api/build/kit/weights.json +0 -1
- package/api/build/kit/weights.mjs +0 -305
- package/api/build/kit/weights.test.mjs +0 -190
- package/api/docs/docs.depth.test.mjs +0 -132
- package/api/theme/build/build.icon-lineage.test.mjs +0 -117
- package/api/theme/build/build.icon-preservation.test.mjs +0 -639
- package/api/theme/build/icon-imports.d.mts +0 -47
- package/api/theme/build/icon-imports.mjs +0 -691
- package/clients/cli/commands/discover.no-source.test.mjs +0 -75
- package/clients/cli/commands/docs.depth.test.mjs +0 -219
- package/clients/cli/commands/theme-list.behavior.test.mjs +0 -41
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file `astryx discover` when no discover source is configured and no
|
|
5
|
-
* integration provides one.
|
|
6
|
-
*
|
|
7
|
-
* In a fresh public app with no integrations, `discover --available` used to
|
|
8
|
-
* print "No integrations configured. Add integration package names..." — a
|
|
9
|
-
* message that told users to add names they had no way to find. These tests
|
|
10
|
-
* pin the honest replacement.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
14
|
-
import * as fs from 'node:fs';
|
|
15
|
-
import * as path from 'node:path';
|
|
16
|
-
import * as os from 'node:os';
|
|
17
|
-
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
18
|
-
|
|
19
|
-
let tmpDir;
|
|
20
|
-
let project;
|
|
21
|
-
|
|
22
|
-
beforeEach(() => {
|
|
23
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-discover-nosource-'));
|
|
24
|
-
project = path.join(tmpDir, 'project');
|
|
25
|
-
fs.mkdirSync(project, {recursive: true});
|
|
26
|
-
fs.writeFileSync(
|
|
27
|
-
path.join(project, 'package.json'),
|
|
28
|
-
JSON.stringify({name: 'my-app', version: '1.0.0'}),
|
|
29
|
-
);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
afterEach(() => {
|
|
33
|
-
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
describe('astryx discover --available with no source', () => {
|
|
37
|
-
it('explains what discover sources are and where to find packages', async () => {
|
|
38
|
-
const {status, stdout} = await runCli(['discover', '--available'], {
|
|
39
|
-
cwd: project,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
expect(status).toBe(0);
|
|
43
|
-
expect(stdout).toContain('No discover source is configured.');
|
|
44
|
-
expect(stdout).toContain('discover sources');
|
|
45
|
-
expect(stdout).toContain('npm search @astryxdesign');
|
|
46
|
-
expect(stdout).toContain('docs cli/integrations');
|
|
47
|
-
// Must not show the old misleading message
|
|
48
|
-
expect(stdout).not.toContain('Add integration package names');
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('returns an empty list with configured=false in --json', async () => {
|
|
52
|
-
const {status, stdout} = await runCli(
|
|
53
|
-
['discover', '--available', '--json'],
|
|
54
|
-
{cwd: project},
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
expect(status).toBe(0);
|
|
58
|
-
const result = JSON.parse(stdout);
|
|
59
|
-
expect(result.type).toBe('discover.list');
|
|
60
|
-
expect(result.data).toEqual([]);
|
|
61
|
-
expect(result.meta).toEqual({configured: false});
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
describe('astryx discover with nothing configured', () => {
|
|
66
|
-
it('shows the config snippet and a pointer to npm and docs', async () => {
|
|
67
|
-
const {status, stdout} = await runCli(['discover'], {cwd: project});
|
|
68
|
-
|
|
69
|
-
expect(status).toBe(0);
|
|
70
|
-
expect(stdout).toContain('No integrations configured.');
|
|
71
|
-
expect(stdout).toContain("integrations: ['@scope/your-integration']");
|
|
72
|
-
expect(stdout).toContain('npm search @astryxdesign');
|
|
73
|
-
expect(stdout).toContain('docs cli/integrations');
|
|
74
|
-
});
|
|
75
|
-
});
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
import * as fs from 'node:fs';
|
|
4
|
-
import * as path from 'node:path';
|
|
5
|
-
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
6
|
-
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
7
|
-
|
|
8
|
-
const SLOW = 60_000;
|
|
9
|
-
|
|
10
|
-
/** @type {string} */
|
|
11
|
-
let tmpDir;
|
|
12
|
-
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
tmpDir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-docs-depth-test-'));
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
afterEach(() => {
|
|
18
|
-
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
/** An app with an integration that places one guide under its namespace. */
|
|
22
|
-
function scaffoldGuide() {
|
|
23
|
-
fs.writeFileSync(
|
|
24
|
-
path.join(tmpDir, 'package.json'),
|
|
25
|
-
JSON.stringify({name: 'consumer'}),
|
|
26
|
-
);
|
|
27
|
-
fs.writeFileSync(
|
|
28
|
-
path.join(tmpDir, 'astryx.config.mjs'),
|
|
29
|
-
"export default {integrations: ['@acme/kit']};\n",
|
|
30
|
-
);
|
|
31
|
-
const packageDir = path.join(tmpDir, 'node_modules', '@acme', 'kit');
|
|
32
|
-
fs.mkdirSync(path.join(packageDir, 'docs'), {recursive: true});
|
|
33
|
-
fs.writeFileSync(
|
|
34
|
-
path.join(packageDir, 'package.json'),
|
|
35
|
-
JSON.stringify({name: '@acme/kit', version: '1.0.0'}),
|
|
36
|
-
);
|
|
37
|
-
fs.writeFileSync(
|
|
38
|
-
path.join(packageDir, 'astryx.integration.mjs'),
|
|
39
|
-
"export default {docs: './docs'};\n",
|
|
40
|
-
);
|
|
41
|
-
const namespace = {
|
|
42
|
-
type: 'namespace',
|
|
43
|
-
name: 'acme',
|
|
44
|
-
title: 'Acme docs',
|
|
45
|
-
summary: 'Build with the Acme kit.',
|
|
46
|
-
slots: {guides: {title: 'Guides', accepts: {kinds: ['generic']}}},
|
|
47
|
-
};
|
|
48
|
-
const guide = {
|
|
49
|
-
type: 'generic',
|
|
50
|
-
name: 'themes',
|
|
51
|
-
title: 'Theme building',
|
|
52
|
-
description: 'Build an Acme theme.',
|
|
53
|
-
placement: {parent: 'namespace:acme', slot: 'guides'},
|
|
54
|
-
sections: [
|
|
55
|
-
{
|
|
56
|
-
title: 'Create the theme',
|
|
57
|
-
content: [
|
|
58
|
-
{
|
|
59
|
-
type: 'prose',
|
|
60
|
-
text: 'Child guide body marker: compile the ocean palette.',
|
|
61
|
-
},
|
|
62
|
-
{type: 'code', lang: 'bash', code: 'npx acme theme build ocean'},
|
|
63
|
-
],
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
};
|
|
67
|
-
for (const [file, doc] of [
|
|
68
|
-
['acme.doc.mjs', namespace],
|
|
69
|
-
['themes.doc.mjs', guide],
|
|
70
|
-
]) {
|
|
71
|
-
fs.writeFileSync(
|
|
72
|
-
path.join(packageDir, 'docs', file),
|
|
73
|
-
`export const docs = ${JSON.stringify(doc, null, 2)};\n`,
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
describe('astryx docs --depth', () => {
|
|
79
|
-
it(
|
|
80
|
-
'lists every doc below a namespace, one line each, by where it sits',
|
|
81
|
-
async () => {
|
|
82
|
-
const result = await runCli(['docs', 'cli/api', '--depth', 'all']);
|
|
83
|
-
expect(result.status).toBe(0);
|
|
84
|
-
expect(result.stdout).toMatch(/^functions\s+\S/m);
|
|
85
|
-
expect(result.stdout).toMatch(/^functions\/search\s+search\(\): /m);
|
|
86
|
-
expect(result.stdout).toContain('Open one: ');
|
|
87
|
-
expect(result.stdout).toContain('docs cli/api/<name>');
|
|
88
|
-
// One line each: no doc's body.
|
|
89
|
-
expect(result.stdout).not.toContain('`astryx search` runs it.');
|
|
90
|
-
},
|
|
91
|
-
SLOW,
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
it(
|
|
95
|
-
'says how many docs sit below where the read stops',
|
|
96
|
-
async () => {
|
|
97
|
-
const zero = await runCli(['docs', 'cli/api', '--depth', '0']);
|
|
98
|
-
expect(zero.status).toBe(0);
|
|
99
|
-
expect(zero.stdout).toMatch(
|
|
100
|
-
/^\d+ docs below\. Read them: .*docs cli\/api --depth 1$/m,
|
|
101
|
-
);
|
|
102
|
-
expect(zero.stdout).not.toMatch(/^functions\s/m);
|
|
103
|
-
|
|
104
|
-
const one = await runCli(['docs', 'cli/api', '--depth', '1']);
|
|
105
|
-
expect(one.status).toBe(0);
|
|
106
|
-
expect(one.stdout).toMatch(/^functions\s+.*\(\d+ docs below\)$/m);
|
|
107
|
-
expect(one.stdout).not.toMatch(/^functions\/search\s/m);
|
|
108
|
-
},
|
|
109
|
-
SLOW,
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
it(
|
|
113
|
-
'prints each doc below whole with --detail full, and drops code at compact',
|
|
114
|
-
async () => {
|
|
115
|
-
scaffoldGuide();
|
|
116
|
-
const full = await runCli(
|
|
117
|
-
['docs', 'acme', '--depth', 'all', '--detail', 'full'],
|
|
118
|
-
tmpDir,
|
|
119
|
-
);
|
|
120
|
-
expect(full.status).toBe(0);
|
|
121
|
-
expect(full.stdout).toMatch(/^## Theme building \(themes\)$/m);
|
|
122
|
-
expect(full.stdout).toMatch(/^### Create the theme$/m);
|
|
123
|
-
expect(full.stdout).toContain(
|
|
124
|
-
'Child guide body marker: compile the ocean palette.',
|
|
125
|
-
);
|
|
126
|
-
expect(full.stdout).toContain('npx acme theme build ocean');
|
|
127
|
-
|
|
128
|
-
const compact = await runCli(
|
|
129
|
-
['docs', 'acme', '--depth', '1', '--detail', 'compact'],
|
|
130
|
-
tmpDir,
|
|
131
|
-
);
|
|
132
|
-
expect(compact.status).toBe(0);
|
|
133
|
-
expect(compact.stdout).toContain('Child guide body marker');
|
|
134
|
-
expect(compact.stdout).not.toContain('npx acme theme build ocean');
|
|
135
|
-
|
|
136
|
-
// Without --depth, the namespace still lists the guide by one line.
|
|
137
|
-
const plain = await runCli(['docs', 'acme'], tmpDir);
|
|
138
|
-
expect(plain.status).toBe(0);
|
|
139
|
-
expect(plain.stdout).toMatch(/^themes\s+Build an Acme theme\./m);
|
|
140
|
-
expect(plain.stdout).not.toContain('Child guide body marker');
|
|
141
|
-
},
|
|
142
|
-
SLOW,
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
it(
|
|
146
|
-
'returns the same tree as JSON, with text only when --detail asks',
|
|
147
|
-
async () => {
|
|
148
|
-
const brief = await runCli(['--json', 'docs', 'cli/api', '--depth', '2']);
|
|
149
|
-
expect(brief.status).toBe(0);
|
|
150
|
-
const briefData = JSON.parse(brief.stdout);
|
|
151
|
-
expect(briefData.type).toBe('docs.node');
|
|
152
|
-
const functions = briefData.data.slots
|
|
153
|
-
.flatMap((/** @type {any} */ slot) => slot.children)
|
|
154
|
-
.find(
|
|
155
|
-
(/** @type {any} */ child) => child.route === 'cli/api/functions',
|
|
156
|
-
);
|
|
157
|
-
const search = functions.slots
|
|
158
|
-
.flatMap((/** @type {any} */ slot) => slot.children)
|
|
159
|
-
.find(
|
|
160
|
-
(/** @type {any} */ child) =>
|
|
161
|
-
child.route === 'cli/api/functions/search',
|
|
162
|
-
);
|
|
163
|
-
expect(search).not.toHaveProperty('content');
|
|
164
|
-
|
|
165
|
-
const full = await runCli([
|
|
166
|
-
'--json',
|
|
167
|
-
'docs',
|
|
168
|
-
'cli/api',
|
|
169
|
-
'--depth',
|
|
170
|
-
'2',
|
|
171
|
-
'--detail',
|
|
172
|
-
'full',
|
|
173
|
-
]);
|
|
174
|
-
expect(full.status).toBe(0);
|
|
175
|
-
expect(full.stdout).toContain('`astryx search` runs it.');
|
|
176
|
-
},
|
|
177
|
-
SLOW,
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
it(
|
|
181
|
-
'composes with --index and --full, and leaves a topic read as it was',
|
|
182
|
-
async () => {
|
|
183
|
-
const depth = await runCli(['docs', 'cli/api', '--depth', '1']);
|
|
184
|
-
expect(depth.status).toBe(0);
|
|
185
|
-
for (const flag of ['--index', '--full']) {
|
|
186
|
-
const both = await runCli(['docs', 'cli/api', '--depth', '1', flag]);
|
|
187
|
-
expect(both.status).toBe(0);
|
|
188
|
-
expect(both.stdout).toBe(depth.stdout);
|
|
189
|
-
}
|
|
190
|
-
for (const args of [
|
|
191
|
-
['docs', 'theme'],
|
|
192
|
-
['docs', 'theme', '--index'],
|
|
193
|
-
['docs', 'theme', '--full'],
|
|
194
|
-
]) {
|
|
195
|
-
const plain = await runCli(args);
|
|
196
|
-
const withDepth = await runCli([...args, '--depth', '2']);
|
|
197
|
-
expect(withDepth.status).toBe(plain.status);
|
|
198
|
-
expect(withDepth.stdout).toBe(plain.stdout);
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
SLOW,
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
it(
|
|
205
|
-
'refuses a depth that is not a number of levels',
|
|
206
|
-
async () => {
|
|
207
|
-
const result = await runCli([
|
|
208
|
-
'--json',
|
|
209
|
-
'docs',
|
|
210
|
-
'cli/api',
|
|
211
|
-
'--depth',
|
|
212
|
-
'deep',
|
|
213
|
-
]);
|
|
214
|
-
expect(result.status).toBe(1);
|
|
215
|
-
expect(JSON.parse(result.stdout).code).toBe('ERR_INVALID_ARGUMENT');
|
|
216
|
-
},
|
|
217
|
-
SLOW,
|
|
218
|
-
);
|
|
219
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file CLI behavior for `astryx theme list`.
|
|
5
|
-
*
|
|
6
|
-
* `theme list` shows the themes this project can add now. Themes in packages
|
|
7
|
-
* it has not installed are `discover`'s, so the list ends by pointing there:
|
|
8
|
-
* an agent that never learns `discover` exists searches the registry instead.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
12
|
-
import * as fs from 'node:fs';
|
|
13
|
-
import * as path from 'node:path';
|
|
14
|
-
import * as os from 'node:os';
|
|
15
|
-
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
16
|
-
|
|
17
|
-
let tmpDir;
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-cli-theme-list-'));
|
|
20
|
-
});
|
|
21
|
-
afterEach(() => {
|
|
22
|
-
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe('astryx theme list', () => {
|
|
26
|
-
it('lists the bundled themes and points at discover for more', async () => {
|
|
27
|
-
const {status, stdout} = await runCli(['theme', 'list'], {cwd: tmpDir});
|
|
28
|
-
|
|
29
|
-
expect(status).toBe(0);
|
|
30
|
-
expect(stdout).toMatch(/^- neutral \(maintained, @astryxdesign\/cli\)/m);
|
|
31
|
-
expect(stdout).toMatch(/More themes in packages you could add: .*discover theme$/m);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('keeps the JSON envelope free of the hint', async () => {
|
|
35
|
-
const {status, stdout} = await runCli(['--json', 'theme', 'list'], {cwd: tmpDir});
|
|
36
|
-
|
|
37
|
-
expect(status).toBe(0);
|
|
38
|
-
expect(stdout).not.toContain('discover');
|
|
39
|
-
expect(JSON.parse(stdout).type).toBe('theme.list');
|
|
40
|
-
});
|
|
41
|
-
});
|