@astryxdesign/cli 0.7.2-canary.6a3ff0f → 0.7.2-canary.6c792d8
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 +62 -62
- package/api/component/_adapter.d.mts +31 -0
- package/api/component/_adapter.mjs +116 -0
- package/api/component/component.mjs +60 -10
- package/api/component/doc-links.test.mjs +386 -0
- package/api/discover/_adapter.d.mts +119 -12
- package/api/discover/_adapter.mjs +449 -10
- package/api/discover/_adapter.test.mjs +599 -17
- package/api/discover/_catalog-view.d.mts +16 -5
- package/api/discover/_catalog-view.mjs +32 -8
- package/api/discover/detail/doc/doc.mjs +9 -1
- package/api/discover/discover.d.mts +11 -0
- package/api/discover/discover.doc.mjs +7 -6
- package/api/discover/discover.mjs +107 -19
- package/api/discover/discover.type.d.mts +18 -7
- package/api/discover/discover.type.mjs +15 -7
- package/api/discover/list/list.d.mts +4 -3
- package/api/discover/list/list.mjs +17 -10
- package/api/docs/_adapter.d.mts +63 -0
- package/api/docs/_adapter.mjs +309 -16
- package/api/docs/integration-tree.test.mjs +22 -0
- package/api/docs/list/list.mjs +12 -2
- package/api/doctor/theme-checks.test.mjs +136 -0
- package/api/integration/_adapter.d.mts +33 -0
- package/api/integration/_adapter.mjs +58 -0
- package/api/integration/authoring-checks.mjs +98 -3
- package/api/integration/authoring-checks.test.mjs +769 -0
- package/api/integration/authoring-checks.type.d.mts +134 -0
- package/api/integration/authoring-checks.type.mjs +60 -1
- package/api/integration/integrationComponentConflicts.doc.mjs +3 -1
- package/api/integration/integrationDocConflicts.doc.mjs +22 -5
- package/api/integration/pack-check.mjs +296 -7
- package/api/integration/pack-check.test.mjs +367 -0
- package/api/integration/validate-integration-fixes.test.mjs +67 -0
- package/api/integration/validate-integration.mjs +28 -3
- package/api/integration/validate-integration.test.mjs +77 -8
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/search.mjs +2 -1
- package/assets/discover/official-packages.json +367 -0
- package/assets/docs/author-a-theme.doc.mjs +2 -2
- package/assets/docs/browser-support.doc.mjs +1 -1
- package/assets/docs/styling-overview.doc.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/tree/add-a-topic.doc.mjs +3 -3
- package/assets/docs/tree/check-the-props.doc.mjs +7 -2
- package/assets/docs/tree/check-your-docs.doc.mjs +15 -3
- package/assets/docs/tree/checks.doc.mjs +5 -5
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +7 -7
- package/assets/docs/tree/document-the-theme.doc.mjs +2 -2
- package/assets/docs/tree/layout-spacing.doc.mjs +2 -3
- package/assets/docs/tree/layout.doc.mjs +6 -6
- package/assets/docs/tree/migration-setup.doc.mjs +2 -2
- package/assets/docs/tree/publishing.doc.mjs +3 -3
- package/assets/docs/tree/quick-start.doc.mjs +2 -2
- package/assets/docs/tree/sections-and-placement.doc.mjs +2 -2
- package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
- package/assets/docs/tree/troubleshooting.doc.mjs +5 -5
- package/assets/docs/tree/upgrading.doc.mjs +1 -1
- package/authoring/discover/discover.doc.mjs +1 -1
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/component/type.ts +8 -0
- package/authoring/doctypes/hook/type.ts +4 -0
- package/clients/cli/commands/discover.broken-integration.test.mjs +4 -1
- package/clients/cli/commands/discover.doc.mjs +1 -1
- package/clients/cli/commands/discover.mjs +144 -93
- package/clients/cli/commands/discover.no-source.test.mjs +447 -33
- package/clients/cli/commands/discover.sources.test.mjs +20 -1
- package/clients/cli/commands/doctor-integration-components.doc.mjs +3 -2
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +19 -5
- package/clients/cli/commands/doctor-integration.test.mjs +48 -1
- package/clients/cli/commands/doctor.mjs +91 -5
- package/clients/cli/commands/integration-authoring.test.mjs +46 -0
- package/clients/cli/commands/integration-check.test.mjs +127 -0
- package/clients/cli/commands/integration.mjs +10 -4
- package/clients/cli/commands/json-contract.test.mjs +5 -1
- package/foundation/discovery/copied-passages.d.mts +216 -0
- package/foundation/discovery/copied-passages.mjs +720 -0
- package/foundation/discovery/copied-passages.test.mjs +124 -0
- package/foundation/discovery/doc-consistency.d.mts +34 -0
- package/foundation/discovery/doc-consistency.mjs +513 -0
- package/foundation/discovery/doc-consistency.test.mjs +347 -0
- package/foundation/discovery/doc-fluff.d.mts +112 -0
- package/foundation/discovery/doc-fluff.mjs +328 -0
- package/foundation/discovery/doc-fluff.test.mjs +142 -0
- package/foundation/discovery/doc-types.mjs +12 -5
- package/foundation/discovery/doc-types.test.mjs +46 -2
- package/foundation/discovery/docs-discovery.d.mts +7 -0
- package/foundation/discovery/docs-discovery.mjs +26 -2
- package/foundation/discovery/prop-drift.d.mts +25 -6
- package/foundation/discovery/prop-drift.mjs +171 -6
- package/foundation/discovery/prop-drift.test.mjs +65 -0
- package/foundation/discovery/stray-pointers.d.mts +52 -0
- package/foundation/discovery/stray-pointers.mjs +293 -0
- package/foundation/discovery/stray-pointers.test.mjs +86 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +16 -0
- package/foundation/doc-compiler/links.d.mts +32 -0
- package/foundation/doc-compiler/links.mjs +163 -26
- package/foundation/doc-compiler/links.test.mjs +97 -4
- package/foundation/doc-compiler/tree.mjs +30 -1
- package/foundation/doc-compiler/tree.test.mjs +7 -0
- package/foundation/fs/module-loader.d.mts +2 -1
- package/foundation/fs/module-loader.mjs +60 -4
- package/foundation/fs/module-loader.test.mjs +194 -0
- package/foundation/integrations/contribution-inventory.d.mts +11 -0
- package/foundation/integrations/contribution-inventory.mjs +50 -2
- package/foundation/integrations/issue.ts +6 -0
- package/foundation/integrations/validate-contributions.mjs +30 -1
- package/foundation/response/response-types.doc.mjs +5 -5
- package/package.json +11 -11
|
@@ -1,75 +1,489 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file `astryx discover`
|
|
5
|
-
*
|
|
4
|
+
* @file `astryx discover` and the official list the CLI carries
|
|
5
|
+
* (spec:AST-051 FR11), in projects with no discover source of their own.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* A fresh app sees the official Astryx packages it could add, and a declared
|
|
8
|
+
* official theme counts as installed. In a project that loads no integration
|
|
9
|
+
* and has no source of its own, every query still answers with the list (FR1);
|
|
10
|
+
* a project that loads an integration gets package pages and search, where an
|
|
11
|
+
* official theme is added at a pinned version and then with `theme add`.
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
14
|
import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
14
15
|
import * as fs from 'node:fs';
|
|
15
16
|
import * as path from 'node:path';
|
|
16
17
|
import * as os from 'node:os';
|
|
18
|
+
import {fileURLToPath} from 'node:url';
|
|
17
19
|
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
18
20
|
|
|
21
|
+
const CLI_VERSION = JSON.parse(
|
|
22
|
+
fs.readFileSync(
|
|
23
|
+
path.resolve(
|
|
24
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
25
|
+
'../../../package.json',
|
|
26
|
+
),
|
|
27
|
+
'utf8',
|
|
28
|
+
),
|
|
29
|
+
).version;
|
|
30
|
+
|
|
19
31
|
let tmpDir;
|
|
20
32
|
let project;
|
|
21
33
|
|
|
34
|
+
/** @param {object} [fields] */
|
|
35
|
+
function writeProject(fields = {}) {
|
|
36
|
+
fs.writeFileSync(
|
|
37
|
+
path.join(project, 'package.json'),
|
|
38
|
+
JSON.stringify({name: 'my-app', version: '1.0.0', ...fields}),
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** @param {string} name @param {string} version */
|
|
43
|
+
function install(name, version) {
|
|
44
|
+
const dir = path.join(project, 'node_modules', ...name.split('/'));
|
|
45
|
+
fs.mkdirSync(dir, {recursive: true});
|
|
46
|
+
fs.writeFileSync(
|
|
47
|
+
path.join(dir, 'package.json'),
|
|
48
|
+
JSON.stringify({name, version}),
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** A configured integration, so discover answers queries. */
|
|
53
|
+
function addIntegration() {
|
|
54
|
+
const pkg = path.join(project, 'node_modules', '@acme', 'ui');
|
|
55
|
+
fs.mkdirSync(path.join(pkg, 'components'), {recursive: true});
|
|
56
|
+
fs.writeFileSync(
|
|
57
|
+
path.join(pkg, 'package.json'),
|
|
58
|
+
'{"name":"@acme/ui","version":"1.0.0","type":"module"}',
|
|
59
|
+
);
|
|
60
|
+
fs.writeFileSync(
|
|
61
|
+
path.join(pkg, 'astryx.integration.mjs'),
|
|
62
|
+
"export default {components: './components'};\n",
|
|
63
|
+
);
|
|
64
|
+
fs.writeFileSync(
|
|
65
|
+
path.join(pkg, 'components', 'Widget.doc.mjs'),
|
|
66
|
+
'export const doc = {type: "component", name: "Widget", description: "A widget"};\n',
|
|
67
|
+
);
|
|
68
|
+
fs.writeFileSync(
|
|
69
|
+
path.join(pkg, 'components', 'Widget.tsx'),
|
|
70
|
+
'export function Widget() { return null; }\n',
|
|
71
|
+
);
|
|
72
|
+
writeProject({type: 'module'});
|
|
73
|
+
fs.writeFileSync(
|
|
74
|
+
path.join(project, 'astryx.config.mjs'),
|
|
75
|
+
"export default {integrations: ['@acme/ui']};\n",
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
22
79
|
beforeEach(() => {
|
|
23
80
|
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-discover-nosource-'));
|
|
24
81
|
project = path.join(tmpDir, 'project');
|
|
25
82
|
fs.mkdirSync(project, {recursive: true});
|
|
26
|
-
|
|
27
|
-
path.join(project, 'package.json'),
|
|
28
|
-
JSON.stringify({name: 'my-app', version: '1.0.0'}),
|
|
29
|
-
);
|
|
83
|
+
writeProject();
|
|
30
84
|
});
|
|
31
85
|
|
|
32
86
|
afterEach(() => {
|
|
33
87
|
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
34
88
|
});
|
|
35
89
|
|
|
36
|
-
describe('astryx discover
|
|
37
|
-
it('
|
|
38
|
-
const {status, stdout} = await runCli(['discover'
|
|
90
|
+
describe('astryx discover in a project with nothing of its own', () => {
|
|
91
|
+
it('lists the official packages it could add, each with its add command, and no query hints', async () => {
|
|
92
|
+
const {status, stdout} = await runCli(['discover'], {cwd: project});
|
|
93
|
+
|
|
94
|
+
expect(status).toBe(0);
|
|
95
|
+
expect(stdout).toMatch(/^Available$/m);
|
|
96
|
+
expect(stdout).toMatch(/^from Astryx$/m);
|
|
97
|
+
expect(stdout).toMatch(/^name:\s+@astryxdesign\/theme-neutral$/m);
|
|
98
|
+
expect(stdout).toMatch(/^source:\s+Astryx$/m);
|
|
99
|
+
expect(stdout).toMatch(
|
|
100
|
+
new RegExp(
|
|
101
|
+
`^install:\\s+.* @astryxdesign/theme-neutral@${CLI_VERSION}$`,
|
|
102
|
+
'm',
|
|
103
|
+
),
|
|
104
|
+
);
|
|
105
|
+
expect(stdout).toContain('To add a package, run its install command.');
|
|
106
|
+
expect(stdout).toMatch(/theme add <theme>, for example .*theme add \w+/);
|
|
107
|
+
// Every query here returns this list, so the list must not suggest one.
|
|
108
|
+
expect(stdout).not.toContain('Usage:');
|
|
109
|
+
expect(stdout).not.toMatch(/discover <(package|search)>/);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('keeps the list with meta.configured=false, and reports the official list in meta.sources', async () => {
|
|
113
|
+
const {status, stdout} = await runCli(['discover', '--json'], {
|
|
114
|
+
cwd: project,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
expect(status).toBe(0);
|
|
118
|
+
const result = JSON.parse(stdout);
|
|
119
|
+
expect(result.type).toBe('discover.list');
|
|
120
|
+
expect(result.data).toEqual([]);
|
|
121
|
+
expect(result.meta.configured).toBe(false);
|
|
122
|
+
expect(result.meta.sources).toEqual([
|
|
123
|
+
{
|
|
124
|
+
name: 'Astryx',
|
|
125
|
+
from: '@astryxdesign/cli',
|
|
126
|
+
status: 'fresh',
|
|
127
|
+
complete: true,
|
|
128
|
+
},
|
|
129
|
+
]);
|
|
130
|
+
expect(result.meta.available.length).toBeGreaterThan(0);
|
|
131
|
+
for (const entry of result.meta.available) {
|
|
132
|
+
expect(entry.source).toBe('Astryx');
|
|
133
|
+
expect(entry.name.startsWith('@astryxdesign/')).toBe(true);
|
|
134
|
+
}
|
|
135
|
+
expect(result.meta.available).toContainEqual(
|
|
136
|
+
expect.objectContaining({
|
|
137
|
+
name: '@astryxdesign/theme-neutral',
|
|
138
|
+
version: CLI_VERSION,
|
|
139
|
+
themes: ['neutral'],
|
|
140
|
+
}),
|
|
141
|
+
);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('answers every query with the list, and says why in text', async () => {
|
|
145
|
+
for (const query of ['gothic', '@astryxdesign/theme-gothic', ' ']) {
|
|
146
|
+
const asJson = await runCli(['discover', query, '--json'], {
|
|
147
|
+
cwd: project,
|
|
148
|
+
});
|
|
149
|
+
expect(asJson.status, query).toBe(0);
|
|
150
|
+
expect(JSON.parse(asJson.stdout).type, query).toBe('discover.list');
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const {stdout} = await runCli(['discover', 'gothic'], {cwd: project});
|
|
154
|
+
expect(stdout).toContain(
|
|
155
|
+
'This project loads no integration and has no discover source of its own, so discover lists everything instead of answering "gothic".',
|
|
156
|
+
);
|
|
157
|
+
expect(stdout).not.toContain('Usage:');
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('counts a declared official theme as installed, keeps meta.configured, and does not offer it again', async () => {
|
|
161
|
+
writeProject({dependencies: {'@astryxdesign/theme-butter': CLI_VERSION}});
|
|
162
|
+
install('@astryxdesign/theme-butter', '0.7.0');
|
|
163
|
+
|
|
164
|
+
const {status, stdout} = await runCli(['discover', '--json'], {
|
|
165
|
+
cwd: project,
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
expect(status).toBe(0);
|
|
169
|
+
const {data, meta} = JSON.parse(stdout);
|
|
170
|
+
expect(data).toEqual([
|
|
171
|
+
expect.objectContaining({
|
|
172
|
+
name: '@astryxdesign/theme-butter',
|
|
173
|
+
version: '0.7.0',
|
|
174
|
+
themes: ['butter'],
|
|
175
|
+
latest: CLI_VERSION,
|
|
176
|
+
}),
|
|
177
|
+
]);
|
|
178
|
+
expect(meta.configured).toBe(false);
|
|
179
|
+
expect(meta.available.map(entry => entry.name)).not.toContain(
|
|
180
|
+
'@astryxdesign/theme-butter',
|
|
181
|
+
);
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
describe('astryx discover and the project’s own package.json', () => {
|
|
186
|
+
it('counts a declared official theme as installed from a subfolder', async () => {
|
|
187
|
+
writeProject({dependencies: {'@astryxdesign/theme-butter': CLI_VERSION}});
|
|
188
|
+
install('@astryxdesign/theme-butter', '0.7.0');
|
|
189
|
+
const src = path.join(project, 'src', 'components');
|
|
190
|
+
fs.mkdirSync(src, {recursive: true});
|
|
191
|
+
|
|
192
|
+
const {status, stdout} = await runCli(['discover', '--json'], {cwd: src});
|
|
193
|
+
|
|
194
|
+
expect(status).toBe(0);
|
|
195
|
+
const {data, meta} = JSON.parse(stdout);
|
|
196
|
+
expect(data.map(entry => entry.name)).toEqual([
|
|
197
|
+
'@astryxdesign/theme-butter',
|
|
198
|
+
]);
|
|
199
|
+
expect(meta.available.map(entry => entry.name)).not.toContain(
|
|
200
|
+
'@astryxdesign/theme-butter',
|
|
201
|
+
);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it('pins the exact Core version a fresh clone declares, before install', async () => {
|
|
205
|
+
writeProject({dependencies: {'@astryxdesign/core': '0.6.8'}});
|
|
206
|
+
|
|
207
|
+
const {status, stdout} = await runCli(['discover', '--json'], {
|
|
208
|
+
cwd: project,
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
expect(status).toBe(0);
|
|
212
|
+
const neutral = JSON.parse(stdout).meta.available.find(
|
|
213
|
+
entry => entry.name === '@astryxdesign/theme-neutral',
|
|
214
|
+
);
|
|
215
|
+
// The entry shows the latest release and installs the declared Core's.
|
|
216
|
+
expect(neutral.version).toBe(CLI_VERSION);
|
|
217
|
+
expect(neutral.install).toMatch(/ @astryxdesign\/theme-neutral@0\.6\.8$/);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('pins the Core range a fresh clone declares, quoted for the shell', async () => {
|
|
221
|
+
writeProject({dependencies: {'@astryxdesign/core': '^0.6.8'}});
|
|
222
|
+
|
|
223
|
+
const {status, stdout} = await runCli(['discover', '--json'], {
|
|
224
|
+
cwd: project,
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
expect(status).toBe(0);
|
|
228
|
+
const neutral = JSON.parse(stdout).meta.available.find(
|
|
229
|
+
entry => entry.name === '@astryxdesign/theme-neutral',
|
|
230
|
+
);
|
|
231
|
+
expect(neutral.version).toBe(CLI_VERSION);
|
|
232
|
+
expect(neutral.install).toMatch(
|
|
233
|
+
/ "@astryxdesign\/theme-neutral@\^0\.6\.8"$/,
|
|
234
|
+
);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it('neither installs nor offers an official theme the project only peer-depends on', async () => {
|
|
238
|
+
writeProject({
|
|
239
|
+
peerDependencies: {'@astryxdesign/theme-butter': '>=0.7.0'},
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
const {stdout} = await runCli(['discover', '--json'], {cwd: project});
|
|
243
|
+
const {data, meta} = JSON.parse(stdout);
|
|
244
|
+
expect(data).toEqual([]);
|
|
245
|
+
expect(meta.available.map(entry => entry.name)).not.toContain(
|
|
246
|
+
'@astryxdesign/theme-butter',
|
|
247
|
+
);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it('recognizes an official theme installed under an npm alias', async () => {
|
|
251
|
+
writeProject({
|
|
252
|
+
dependencies: {'my-butter': 'npm:@astryxdesign/theme-butter@0.7.0'},
|
|
253
|
+
});
|
|
254
|
+
install('my-butter', '0.7.0');
|
|
255
|
+
|
|
256
|
+
const {stdout} = await runCli(['discover', '--json'], {cwd: project});
|
|
257
|
+
expect(JSON.parse(stdout).data).toEqual([
|
|
258
|
+
expect.objectContaining({
|
|
259
|
+
name: '@astryxdesign/theme-butter',
|
|
260
|
+
version: '0.7.0',
|
|
261
|
+
}),
|
|
262
|
+
]);
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
describe('astryx discover with a source that publishes an official integration under another name', () => {
|
|
267
|
+
beforeEach(() => {
|
|
268
|
+
writeProject({type: 'module'});
|
|
269
|
+
fs.writeFileSync(
|
|
270
|
+
path.join(project, 'astryx.config.mjs'),
|
|
271
|
+
`export default {
|
|
272
|
+
discover: async () => ({
|
|
273
|
+
schemaVersion: 1,
|
|
274
|
+
source: {name: 'Fork catalog', generatedAt: '2026-10-01T00:00:00Z', complete: true},
|
|
275
|
+
packages: [{
|
|
276
|
+
package: '@acme/gothic-fork',
|
|
277
|
+
integration: '@astryxdesign/theme-gothic',
|
|
278
|
+
aliases: [],
|
|
279
|
+
latest: '1.0.0',
|
|
280
|
+
versions: [{version: '1.0.0', publishedAt: null, prerelease: false, status: 'ok'}],
|
|
281
|
+
contributions: [{kind: 'theme', name: 'gothic-fork'}],
|
|
282
|
+
}],
|
|
283
|
+
}),
|
|
284
|
+
};
|
|
285
|
+
`,
|
|
286
|
+
);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it('keeps the source’s package in the list and in search', async () => {
|
|
290
|
+
const list = await runCli(['discover', '--available', '--json'], {
|
|
39
291
|
cwd: project,
|
|
40
292
|
});
|
|
293
|
+
const names = JSON.parse(list.stdout).meta.available.map(e => e.name);
|
|
294
|
+
expect(names).toContain('@acme/gothic-fork');
|
|
295
|
+
expect(names).not.toContain('@astryxdesign/theme-gothic');
|
|
41
296
|
|
|
297
|
+
const search = await runCli(['discover', 'fork', '--json'], {
|
|
298
|
+
cwd: project,
|
|
299
|
+
});
|
|
300
|
+
expect(search.status).toBe(0);
|
|
301
|
+
expect(JSON.parse(search.stdout).data.matches).toEqual(
|
|
302
|
+
expect.arrayContaining([
|
|
303
|
+
expect.objectContaining({package: '@acme/gothic-fork'}),
|
|
304
|
+
]),
|
|
305
|
+
);
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
describe('astryx discover in a project that loads an integration', () => {
|
|
310
|
+
beforeEach(addIntegration);
|
|
311
|
+
|
|
312
|
+
it('lists official packages first among what it could add', async () => {
|
|
313
|
+
const {status, stdout} = await runCli(['discover', '--json'], {
|
|
314
|
+
cwd: project,
|
|
315
|
+
});
|
|
42
316
|
expect(status).toBe(0);
|
|
43
|
-
|
|
44
|
-
expect(
|
|
45
|
-
expect(
|
|
46
|
-
expect(stdout).toContain('docs cli/integrations');
|
|
47
|
-
// Must not show the old misleading message
|
|
48
|
-
expect(stdout).not.toContain('Add integration package names');
|
|
317
|
+
const {data, meta} = JSON.parse(stdout);
|
|
318
|
+
expect(data.map(entry => entry.name)).toEqual(['@acme/ui']);
|
|
319
|
+
expect(meta.available[0].source).toBe('Astryx');
|
|
49
320
|
});
|
|
50
321
|
|
|
51
|
-
it('
|
|
322
|
+
it('adds a theme package at the version shown, then points to theme add', async () => {
|
|
52
323
|
const {status, stdout} = await runCli(
|
|
53
|
-
['discover', '
|
|
324
|
+
['discover', '@astryxdesign/theme-gothic'],
|
|
54
325
|
{cwd: project},
|
|
55
326
|
);
|
|
56
327
|
|
|
57
328
|
expect(status).toBe(0);
|
|
58
|
-
|
|
59
|
-
expect(
|
|
60
|
-
expect(
|
|
61
|
-
expect(
|
|
329
|
+
expect(stdout).toMatch(/^installed:\s+false$/m);
|
|
330
|
+
expect(stdout).toContain(`@astryxdesign/theme-gothic@${CLI_VERSION}`);
|
|
331
|
+
expect(stdout).toContain('Then use its theme:');
|
|
332
|
+
expect(stdout).toMatch(/theme add gothic$/m);
|
|
333
|
+
expect(stdout).not.toContain('Astryx loads an integration');
|
|
62
334
|
});
|
|
63
|
-
});
|
|
64
335
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
336
|
+
it("lists the latest release and the project's Core version, pins the Core version, and finds both", async () => {
|
|
337
|
+
for (const [core, latest] of [
|
|
338
|
+
['0.6.8', CLI_VERSION],
|
|
339
|
+
['99.0.0', '99.0.0'],
|
|
340
|
+
]) {
|
|
341
|
+
install('@astryxdesign/core', core);
|
|
342
|
+
|
|
343
|
+
const page = await runCli(
|
|
344
|
+
['discover', '@astryxdesign/theme-gothic', '--json'],
|
|
345
|
+
{cwd: project},
|
|
346
|
+
);
|
|
347
|
+
expect(page.status, core).toBe(0);
|
|
348
|
+
const {data} = JSON.parse(page.stdout);
|
|
349
|
+
expect(data.latest, core).toBe(latest);
|
|
350
|
+
expect(data.version, core).toBe(latest);
|
|
351
|
+
expect(data.versions.map(v => v.version).sort(), core).toEqual(
|
|
352
|
+
[...new Set([CLI_VERSION, core])].sort(),
|
|
353
|
+
);
|
|
354
|
+
expect(data.install, core).toMatch(
|
|
355
|
+
new RegExp(
|
|
356
|
+
` @astryxdesign/theme-gothic@${core.replaceAll('.', '\\.')}$`,
|
|
357
|
+
),
|
|
358
|
+
);
|
|
359
|
+
|
|
360
|
+
for (const wanted of new Set([core, CLI_VERSION])) {
|
|
361
|
+
const lookup = await runCli(
|
|
362
|
+
['discover', `@astryxdesign/theme-gothic@${wanted}`, '--json'],
|
|
363
|
+
{cwd: project},
|
|
364
|
+
);
|
|
365
|
+
expect(lookup.status, `${core} ${wanted}`).toBe(0);
|
|
366
|
+
expect(JSON.parse(lookup.stdout).data.version, wanted).toBe(wanted);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
const list = await runCli(['discover', '--json'], {cwd: project});
|
|
370
|
+
expect(
|
|
371
|
+
JSON.parse(list.stdout).meta.available.find(
|
|
372
|
+
entry => entry.name === '@astryxdesign/theme-gothic',
|
|
373
|
+
).version,
|
|
374
|
+
core,
|
|
375
|
+
).toBe(latest);
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
it('says which version its add command installs when the page shows the latest release', async () => {
|
|
380
|
+
install('@astryxdesign/core', '0.6.8');
|
|
381
|
+
|
|
382
|
+
const {status, stdout} = await runCli(
|
|
383
|
+
['discover', '@astryxdesign/theme-gothic'],
|
|
384
|
+
{cwd: project},
|
|
385
|
+
);
|
|
68
386
|
|
|
69
387
|
expect(status).toBe(0);
|
|
70
|
-
expect(stdout).
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
expect(stdout).
|
|
388
|
+
expect(stdout).toMatch(
|
|
389
|
+
new RegExp(`^latest:\\s+${CLI_VERSION.replaceAll('.', '\\.')}$`, 'm'),
|
|
390
|
+
);
|
|
391
|
+
expect(stdout).toMatch(/^- 0\.6\.8 {2}date unknown$/m);
|
|
392
|
+
// The verb follows the detected package manager.
|
|
393
|
+
expect(stdout).toMatch(/^\S+ \S+ @astryxdesign\/theme-gothic@0\.6\.8$/m);
|
|
394
|
+
expect(stdout).toContain(
|
|
395
|
+
"This installs 0.6.8, the version that matches this project's Core.",
|
|
396
|
+
);
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
it('pins the declared Core range on the page and says so', async () => {
|
|
400
|
+
writeProject({
|
|
401
|
+
type: 'module',
|
|
402
|
+
dependencies: {'@astryxdesign/core': '>=0.6.8 <0.8.0'},
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
const {status, stdout} = await runCli(
|
|
406
|
+
['discover', '@astryxdesign/theme-gothic'],
|
|
407
|
+
{cwd: project},
|
|
408
|
+
);
|
|
409
|
+
|
|
410
|
+
expect(status).toBe(0);
|
|
411
|
+
expect(stdout).toMatch(
|
|
412
|
+
/^\S+ \S+ "@astryxdesign\/theme-gothic@>=0\.6\.8 <0\.8\.0"$/m,
|
|
413
|
+
);
|
|
414
|
+
expect(stdout).toContain(
|
|
415
|
+
'This installs the newest release in >=0.6.8 <0.8.0, the Core range this project declares.',
|
|
416
|
+
);
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
it('keeps latest at the newest release for an installed official theme', async () => {
|
|
420
|
+
install('@astryxdesign/core', '0.6.8');
|
|
421
|
+
writeProject({
|
|
422
|
+
type: 'module',
|
|
423
|
+
dependencies: {'@astryxdesign/theme-butter': '0.6.8'},
|
|
424
|
+
});
|
|
425
|
+
install('@astryxdesign/theme-butter', '0.6.8');
|
|
426
|
+
|
|
427
|
+
const list = await runCli(['discover', '--json'], {cwd: project});
|
|
428
|
+
expect(
|
|
429
|
+
JSON.parse(list.stdout).data.find(
|
|
430
|
+
entry => entry.name === '@astryxdesign/theme-butter',
|
|
431
|
+
),
|
|
432
|
+
).toMatchObject({version: '0.6.8', latest: CLI_VERSION});
|
|
433
|
+
|
|
434
|
+
const page = await runCli(['discover', '@astryxdesign/theme-butter'], {
|
|
435
|
+
cwd: project,
|
|
436
|
+
});
|
|
437
|
+
expect(page.stdout).toMatch(
|
|
438
|
+
new RegExp(
|
|
439
|
+
`^- ${CLI_VERSION.replaceAll('.', '\\.')} {2}date unknown {2}latest$`,
|
|
440
|
+
'm',
|
|
441
|
+
),
|
|
442
|
+
);
|
|
443
|
+
expect(page.stdout).toMatch(/^- 0\.6\.8 {2}date unknown {2}installed$/m);
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
it('keeps the error code for a version or item of an official package it does not show', async () => {
|
|
447
|
+
for (const query of [
|
|
448
|
+
'@astryxdesign/theme-gothic@0.6.8',
|
|
449
|
+
'@astryxdesign/theme-gothic@latest',
|
|
450
|
+
'@astryxdesign/theme-gothic/nope',
|
|
451
|
+
]) {
|
|
452
|
+
const {status, stdout} = await runCli(['discover', query, '--json'], {
|
|
453
|
+
cwd: project,
|
|
454
|
+
});
|
|
455
|
+
expect(status, query).toBe(1);
|
|
456
|
+
expect(JSON.parse(stdout).code, query).toBe('ERR_UNKNOWN_PACKAGE');
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
it('points an installed theme’s page at its items, not at components', async () => {
|
|
461
|
+
writeProject({
|
|
462
|
+
type: 'module',
|
|
463
|
+
dependencies: {'@astryxdesign/theme-butter': CLI_VERSION},
|
|
464
|
+
});
|
|
465
|
+
install('@astryxdesign/theme-butter', CLI_VERSION);
|
|
466
|
+
|
|
467
|
+
const {stdout} = await runCli(['discover', '@astryxdesign/theme-butter'], {
|
|
468
|
+
cwd: project,
|
|
469
|
+
});
|
|
470
|
+
expect(stdout).toContain('discover @astryxdesign/theme-butter/<item>');
|
|
471
|
+
expect(stdout).not.toContain('<ComponentName>');
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
it('finds an official theme by name', async () => {
|
|
475
|
+
const {status, stdout} = await runCli(['discover', 'gothic', '--json'], {
|
|
476
|
+
cwd: project,
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
expect(status).toBe(0);
|
|
480
|
+
expect(JSON.parse(stdout).data.matches).toContainEqual(
|
|
481
|
+
expect.objectContaining({
|
|
482
|
+
package: '@astryxdesign/theme-gothic',
|
|
483
|
+
component: 'gothic',
|
|
484
|
+
kind: 'theme',
|
|
485
|
+
installed: false,
|
|
486
|
+
}),
|
|
487
|
+
);
|
|
74
488
|
});
|
|
75
489
|
});
|
|
@@ -145,13 +145,20 @@ describe('astryx discover with a discover source', () => {
|
|
|
145
145
|
latest: '3.2.0',
|
|
146
146
|
}),
|
|
147
147
|
]);
|
|
148
|
-
|
|
148
|
+
// The official packages come first, then what the project's source adds.
|
|
149
|
+
const official = meta.available.filter(entry => entry.source === 'Astryx');
|
|
150
|
+
expect(official.length).toBeGreaterThan(0);
|
|
151
|
+
expect(meta.available.slice(0, official.length)).toEqual(official);
|
|
152
|
+
// Each entry carries the command that adds it; a source's entry is not
|
|
153
|
+
// pinned, as on its package page.
|
|
154
|
+
expect(meta.available.slice(official.length)).toEqual([
|
|
149
155
|
{
|
|
150
156
|
name: '@test/charts',
|
|
151
157
|
components: ['Chart'],
|
|
152
158
|
version: '2.0.0',
|
|
153
159
|
templates: ['pages/Report'],
|
|
154
160
|
source: 'Test catalog',
|
|
161
|
+
install: expect.stringMatching(/ @test\/charts$/),
|
|
155
162
|
},
|
|
156
163
|
{
|
|
157
164
|
name: '@test/boards',
|
|
@@ -159,14 +166,26 @@ describe('astryx discover with a discover source', () => {
|
|
|
159
166
|
version: '1.0.0',
|
|
160
167
|
templates: ['pages/DialBoard'],
|
|
161
168
|
source: 'Test catalog',
|
|
169
|
+
install: expect.stringMatching(/ @test\/boards$/),
|
|
162
170
|
},
|
|
163
171
|
]);
|
|
172
|
+
for (const entry of official) {
|
|
173
|
+
expect(entry.install).toMatch(
|
|
174
|
+
new RegExp(` ${entry.name}@${entry.version.replaceAll('.', '\\.')}$`),
|
|
175
|
+
);
|
|
176
|
+
}
|
|
164
177
|
expect(meta.sources).toEqual([
|
|
165
178
|
expect.objectContaining({
|
|
166
179
|
name: 'Test catalog',
|
|
167
180
|
from: 'astryx.config',
|
|
168
181
|
status: 'fresh',
|
|
169
182
|
}),
|
|
183
|
+
{
|
|
184
|
+
name: 'Astryx',
|
|
185
|
+
from: '@astryxdesign/cli',
|
|
186
|
+
status: 'fresh',
|
|
187
|
+
complete: true,
|
|
188
|
+
},
|
|
170
189
|
]);
|
|
171
190
|
});
|
|
172
191
|
|
|
@@ -27,7 +27,8 @@ export const doc = {
|
|
|
27
27
|
'`required`, and a type that does not match where both sides read exactly ' +
|
|
28
28
|
'(it lists every other documented type as not compared, with the reason). ' +
|
|
29
29
|
'Without TypeScript it prints one ' +
|
|
30
|
-
'line saying the comparison was skipped.'
|
|
30
|
+
'line saying the comparison was skipped. It also warns on each `{@link}` in ' +
|
|
31
|
+
"a component doc's text that names no doc.",
|
|
31
32
|
fn: 'integrationComponentConflicts',
|
|
32
33
|
args: [
|
|
33
34
|
{
|
|
@@ -51,7 +52,7 @@ export const doc = {
|
|
|
51
52
|
exitCodes: [
|
|
52
53
|
{
|
|
53
54
|
code: 0,
|
|
54
|
-
when: 'the check completed; component name conflicts, replaces findings for a package without the CLI range,
|
|
55
|
+
when: 'the check completed; component name conflicts, replaces findings for a package without the CLI range, props that differ from the code, and links that name no doc are warnings',
|
|
55
56
|
},
|
|
56
57
|
{
|
|
57
58
|
code: 1,
|
|
@@ -8,12 +8,17 @@ export const doc = {
|
|
|
8
8
|
name: 'doctor integration docs',
|
|
9
9
|
displayName: 'astryx doctor integration docs',
|
|
10
10
|
namespace: 'cli/commands',
|
|
11
|
-
summary:
|
|
11
|
+
summary:
|
|
12
|
+
"Check an integration's docs: the docs tree they add, every link, and overlaps with Core topics",
|
|
12
13
|
description:
|
|
13
14
|
'Checks the docs tree the package adds, every link in its docs, and overlaps with Core topics. ' +
|
|
14
15
|
'Intentional replacements and extensions are information. ' +
|
|
15
16
|
'A same-name topic without `replaces` or `extends` is an accidental conflict ' +
|
|
16
|
-
'and fails until the author declares the relationship or renames it.
|
|
17
|
+
'and fails until the author declares the relationship or renames it. ' +
|
|
18
|
+
'It also lists each pair of topics (two of the package, or one of them and a Core topic other than the one it replaces) ' +
|
|
19
|
+
'that repeat 10 or more words of prose word for word, each padding phrase and low-density topic, ' +
|
|
20
|
+
'and each written `astryx docs <name>` that should be a link, ' +
|
|
21
|
+
'each as a warning (`copied_passage`, `doc_fluff`, `stray_doc_pointer`; exit 0, and `integration check --strict` fails on it). See {@link generic:check-your-docs}.',
|
|
17
22
|
fn: 'integrationDocConflicts',
|
|
18
23
|
args: [
|
|
19
24
|
{
|
|
@@ -25,15 +30,24 @@ export const doc = {
|
|
|
25
30
|
},
|
|
26
31
|
],
|
|
27
32
|
examples: [
|
|
28
|
-
{
|
|
33
|
+
{
|
|
34
|
+
label: 'Check the local integration',
|
|
35
|
+
cli: 'astryx doctor integration docs',
|
|
36
|
+
},
|
|
29
37
|
{
|
|
30
38
|
label: 'Check an installed integration',
|
|
31
39
|
cli: 'astryx doctor integration docs @acme/widgets --json',
|
|
32
40
|
},
|
|
33
41
|
],
|
|
34
42
|
exitCodes: [
|
|
35
|
-
{
|
|
36
|
-
|
|
43
|
+
{
|
|
44
|
+
code: 0,
|
|
45
|
+
when: 'all Core overlaps are explicitly declared or no overlap exists',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
code: 1,
|
|
49
|
+
when: 'an overlap is accidental, a doc is invalid, a namespace or placement fails, or a reference block cannot include what it names. A link that names no doc is a warning, and does not change the exit code',
|
|
50
|
+
},
|
|
37
51
|
],
|
|
38
52
|
related: ['doctor integration validate', 'docs'],
|
|
39
53
|
};
|