@astryxdesign/cli 0.7.3-canary.cbe384c → 0.7.3-canary.ea68606
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 +68 -68
- package/api/build/blocks/blocks.d.mts +6 -4
- package/api/build/blocks/blocks.mjs +103 -20
- package/api/build/blocks/blocks.test.mjs +126 -13
- package/api/build/blocks/blocks.weights.json +1 -1
- package/api/build/kit/answer.d.mts +5 -4
- package/api/build/kit/answer.mjs +114 -12
- package/api/build/kit/answer.test.mjs +73 -3
- package/api/build/kit/signals.d.mts +8 -0
- package/api/build/kit/signals.mjs +10 -0
- package/api/build/tree.test.mjs +19 -11
- package/api/component/component-replacement.test.mjs +1 -0
- package/api/component/component.mjs +17 -3
- package/api/component/component.test.mjs +15 -0
- package/api/component/doc-links.test.mjs +2 -2
- package/api/docs/_adapter.d.mts +2 -2
- package/api/docs/_adapter.mjs +61 -18
- package/api/docs/docs-homes.test.mjs +127 -0
- package/api/docs/docs.doc.mjs +3 -3
- package/api/docs/docs.test.mjs +28 -18
- package/api/docs/integration-tree.test.mjs +20 -20
- package/api/docs/integrationDocs.test.mjs +1 -1
- package/api/docs/namespace-section.test.mjs +6 -6
- package/api/docs/reference-blocks.test.mjs +2 -2
- package/api/doctor/doctor.mjs +16 -12
- package/api/doctor/doctor.test.mjs +37 -12
- package/api/hook/hook.mjs +1 -1
- package/api/integration/_adapter.d.mts +8 -0
- package/api/integration/_adapter.mjs +21 -1
- package/api/integration/authoring-checks.test.mjs +220 -0
- package/api/integration/validate-integration-fixes.test.mjs +6 -5
- package/api/integration/validate-integration-gaps.test.mjs +9 -1
- package/api/integration/validate-integration.d.mts +6 -1
- package/api/integration/validate-integration.mjs +45 -5
- package/api/integration/validate-integration.type.d.mts +33 -3
- package/api/integration/validate-integration.type.mjs +24 -4
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/_adapter.d.mts +16 -0
- package/api/search/_adapter.mjs +39 -0
- package/api/search/_adapter.test.mjs +173 -0
- package/api/search/_candidate-score.mjs +1 -1
- package/api/search/_entries.mjs +57 -1
- package/api/search/_gather-docs.mjs +3 -3
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.mjs +6 -2
- package/api/search/search.test.mjs +14 -14
- package/api/upgrade/_adapter.d.mts +57 -3
- package/api/upgrade/_adapter.mjs +149 -27
- package/api/upgrade/registry/registry.d.mts +10 -4
- package/api/upgrade/registry/registry.mjs +33 -16
- package/api/upgrade/registry/registry.test.mjs +85 -0
- package/api/upgrade/run/run.d.mts +4 -2
- package/api/upgrade/run/run.mjs +13 -2
- package/api/upgrade/run/run.test.mjs +417 -3
- package/api/upgrade/upgrade.doc.mjs +10 -5
- package/api/upgrade/upgrade.mjs +13 -2
- package/api/upgrade/upgrade.type.d.mts +5 -3
- package/api/upgrade/upgrade.type.mjs +8 -6
- package/assets/docs/author-a-theme.doc.mjs +2 -2
- package/assets/docs/tree/add-a-component.doc.mjs +1 -1
- package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
- package/assets/docs/tree/add-a-topic.doc.mjs +2 -2
- package/assets/docs/tree/agent-guidance.doc.mjs +1 -1
- package/assets/docs/tree/{integrations.doc.mjs → authoring.doc.mjs} +15 -6
- package/assets/docs/tree/block-template.doc.mjs +1 -1
- package/assets/docs/tree/build-the-template.doc.mjs +1 -1
- package/assets/docs/tree/building-blocks.doc.mjs +2 -2
- package/assets/docs/tree/check-the-props.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
- package/assets/docs/tree/checks.doc.mjs +3 -3
- package/assets/docs/tree/cli-command.doc.mjs +1 -1
- package/assets/docs/tree/cli.doc.mjs +1 -1
- package/assets/docs/tree/codemods.doc.mjs +1 -1
- package/assets/docs/tree/component-family.doc.mjs +1 -1
- package/assets/docs/tree/component-imports.doc.mjs +1 -1
- package/assets/docs/tree/components.doc.mjs +1 -1
- package/assets/docs/tree/configuration.doc.mjs +1 -1
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
- package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
- package/assets/docs/tree/docs.doc.mjs +1 -1
- package/assets/docs/tree/document-the-template.doc.mjs +1 -1
- package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
- package/assets/docs/tree/extend-or-replace.doc.mjs +1 -1
- package/assets/docs/{authoring.doc.mjs → tree/field-reference.doc.mjs} +4 -3
- package/assets/docs/tree/fonts-and-assets.doc.mjs +1 -1
- package/assets/docs/tree/generate-a-palette.doc.mjs +1 -1
- package/assets/docs/tree/global-integrations.doc.mjs +2 -2
- package/assets/docs/tree/grade-template-with-agent.doc.mjs +4 -4
- package/assets/docs/tree/help.doc.mjs +2 -2
- package/assets/docs/tree/links.doc.mjs +1 -1
- package/assets/docs/tree/package-and-test.doc.mjs +1 -1
- package/assets/docs/tree/page-template.doc.mjs +1 -1
- package/assets/docs/tree/publishing.doc.mjs +1 -1
- package/assets/docs/tree/quick-start.doc.mjs +1 -1
- package/assets/docs/tree/replace-a-core-component.doc.mjs +1 -1
- package/assets/docs/tree/replace-a-core-template.doc.mjs +1 -1
- package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/ship.doc.mjs +2 -2
- package/assets/docs/tree/short-and-findable.doc.mjs +1 -1
- package/assets/docs/tree/single-component.doc.mjs +1 -1
- package/assets/docs/tree/start-a-template.doc.mjs +1 -1
- package/assets/docs/tree/subcomponent.doc.mjs +1 -1
- package/assets/docs/tree/template-assets.doc.mjs +1 -1
- package/assets/docs/tree/template-doc-overview.doc.mjs +2 -2
- package/assets/docs/tree/template-fonts.doc.mjs +1 -1
- package/assets/docs/tree/template-grading-rubric.doc.mjs +1 -1
- package/assets/docs/tree/template-icons.doc.mjs +1 -1
- package/assets/docs/tree/template-images-media.doc.mjs +1 -1
- package/assets/docs/tree/template-styles.doc.mjs +1 -1
- package/assets/docs/tree/templates.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
- package/assets/docs/tree/themes.doc.mjs +1 -1
- package/assets/docs/tree/troubleshooting.doc.mjs +1 -1
- package/assets/docs/tree/upgrading.doc.mjs +1 -1
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
- package/assets/docs/tree/versioning.doc.mjs +1 -1
- package/assets/docs/tree/write-good-templates.doc.mjs +1 -1
- package/assets/docs/tree/write-the-template-file.doc.mjs +1 -1
- package/assets/docs/use-integrations.doc.mjs +120 -0
- package/assets/templates/themes/butter/butterTheme.ts +4 -2
- package/assets/templates/themes/stone/stoneTheme.ts +4 -2
- package/assets/templates/themes/y2k/y2kTheme.ts +4 -2
- package/authoring/doctypes/schema/schema.doc.mjs +1 -1
- package/authoring/integration/integration.doc.mjs +1 -1
- package/authoring/integration/type.ts +1 -1
- package/clients/cli/command-result-coverage.test.mjs +6 -5
- package/clients/cli/commands/build-theme.color-scheme.test.mjs +1 -1
- package/clients/cli/commands/{component/index.mjs → component.mjs} +37 -37
- package/clients/cli/commands/component.test.mjs +6 -6
- package/clients/cli/commands/docs.doc.mjs +2 -2
- package/clients/cli/commands/docs.mjs +1 -1
- package/clients/cli/commands/docs.test.mjs +14 -14
- package/clients/cli/commands/doctor-integration.test.mjs +49 -1
- package/clients/cli/commands/doctor.mjs +10 -0
- package/clients/cli/commands/{hook/index.mjs → hook.mjs} +22 -22
- package/clients/cli/commands/import-hint-correctness.test.mjs +1 -1
- package/clients/cli/commands/integration-check.test.mjs +48 -0
- package/clients/cli/commands/integration.doc.mjs +1 -1
- package/clients/cli/commands/manifest.doc.mjs +1 -1
- package/clients/cli/commands/manifest.mjs +67 -0
- package/clients/cli/commands/postinstall.doc.mjs +23 -0
- package/clients/cli/commands/postinstall.mjs +31 -0
- package/clients/cli/commands/{build-theme.mjs → theme.mjs} +1 -1
- package/clients/cli/commands/upgrade.doc.mjs +4 -2
- package/clients/cli/commands/upgrade.mjs +9 -2
- package/clients/cli/commands/upgrade.subfolder-path.test.mjs +97 -0
- package/clients/cli/index.mjs +10 -85
- package/clients/cli/lib/component-format.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +12 -7
- package/clients/cli/lib/exit-codes.test.mjs +5 -0
- package/clients/cli/lib/manifest.test.mjs +12 -0
- package/clients/cli/lib/welcome-box.mjs +50 -0
- package/foundation/agent-docs/agent-docs.mjs +2 -1
- package/foundation/agent-docs/agent-docs.test.mjs +5 -4
- package/foundation/config/project.mjs +5 -20
- package/foundation/config/project.test.mjs +30 -0
- package/foundation/discovery/authoring-self-docs.d.mts +7 -0
- package/foundation/discovery/authoring-self-docs.mjs +16 -4
- package/foundation/discovery/authoring-self-docs.test.mjs +15 -3
- package/foundation/discovery/authoring-surface.d.mts +1 -1
- package/foundation/discovery/authoring-surface.mjs +2 -2
- package/foundation/discovery/authoring-surface.test.mjs +1 -1
- package/foundation/discovery/cli-self-docs.d.mts +2 -1
- package/foundation/discovery/cli-self-docs.mjs +4 -3
- package/foundation/discovery/cli-self-docs.test.mjs +2 -2
- package/foundation/discovery/runner-allowlist.d.mts +2 -4
- package/foundation/discovery/runner-allowlist.mjs +2 -4
- package/foundation/discovery/runner-commands.d.mts +77 -0
- package/foundation/discovery/runner-commands.mjs +294 -0
- package/foundation/discovery/runner-commands.test.mjs +128 -0
- package/foundation/discovery/stray-pointers.test.mjs +1 -1
- package/foundation/discovery/template-needs.mjs +1 -44
- package/foundation/doc-compiler/doc-loads.test.mjs +25 -9
- package/foundation/doc-compiler/split-topic-keywords.test.mjs +3 -2
- package/foundation/doc-compiler/tree.d.mts +32 -6
- package/foundation/doc-compiler/tree.mjs +77 -43
- package/foundation/doc-compiler/tree.test.mjs +7 -7
- package/foundation/fs/paths.d.mts +70 -8
- package/foundation/fs/paths.mjs +526 -35
- package/foundation/fs/paths.test.mjs +430 -54
- package/foundation/fs/read-record.d.mts +18 -0
- package/foundation/fs/read-record.mjs +131 -0
- package/foundation/fs/read-record.test.mjs +77 -0
- package/foundation/integrations/autolink.d.mts +2 -1
- package/foundation/integrations/autolink.mjs +4 -13
- package/foundation/integrations/exports-subpaths.d.mts +57 -0
- package/foundation/integrations/exports-subpaths.mjs +113 -0
- package/foundation/integrations/integrations.d.mts +11 -0
- package/foundation/integrations/integrations.mjs +21 -1
- package/foundation/integrations/public-imports.d.mts +81 -0
- package/foundation/integrations/public-imports.mjs +976 -0
- package/foundation/integrations/public-imports.test.mjs +868 -0
- package/foundation/response/response-types.doc.mjs +1 -1
- package/package.json +9 -9
package/api/hook/hook.mjs
CHANGED
|
@@ -43,7 +43,7 @@ export async function hook(name, options = {}) {
|
|
|
43
43
|
zh = false,
|
|
44
44
|
} = options;
|
|
45
45
|
|
|
46
|
-
// Default detail level mirrors the CLI (see commands/hook
|
|
46
|
+
// Default detail level mirrors the CLI (see commands/hook.mjs):
|
|
47
47
|
// single-hook views default to 'full', list-style views (--list,
|
|
48
48
|
// --category, or no name) default to 'brief' (scannable name lists).
|
|
49
49
|
// Keeping this in sync with the CLI is what the API↔CLI parity test checks.
|
|
@@ -40,6 +40,14 @@ export function integrationFluff(discovered: Parameters<typeof findFluff>[0]): P
|
|
|
40
40
|
* read too
|
|
41
41
|
*/
|
|
42
42
|
export function integrationStrayPointers(discovered: Parameters<typeof findStrayPointers>[0], integration?: any): Promise<import("./authoring-checks.type.mjs").StrayPointer[]>;
|
|
43
|
+
/**
|
|
44
|
+
* Each Astryx command a package's topics write with a package runner. A
|
|
45
|
+
* package whose topics cannot be discovered has none here: the other checks
|
|
46
|
+
* report topics that do not load.
|
|
47
|
+
* @param {any} integration a loaded integration
|
|
48
|
+
* @returns {Promise<import('../../foundation/discovery/runner-commands.mjs').RunnerCommand[]>}
|
|
49
|
+
*/
|
|
50
|
+
export function integrationRunnerCommands(integration: any): Promise<import("../../foundation/discovery/runner-commands.mjs").RunnerCommand[]>;
|
|
43
51
|
import { findCopiedPassages } from '../../foundation/discovery/copied-passages.mjs';
|
|
44
52
|
import { findFluff } from '../../foundation/discovery/doc-fluff.mjs';
|
|
45
53
|
import { findStrayPointers } from '../../foundation/discovery/stray-pointers.mjs';
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file The integration subject's access to the environment (INV21): reading
|
|
5
|
-
* one package's component docs and sources with the project's own TypeScript
|
|
5
|
+
* one package's component docs and sources with the project's own TypeScript,
|
|
6
|
+
* and its topics.
|
|
6
7
|
*
|
|
7
8
|
* @input a loaded integration and the directory the command runs in
|
|
8
9
|
* @output the reports the integration checks attach to their results
|
|
@@ -14,9 +15,11 @@ import {
|
|
|
14
15
|
forEachIntegrationDoc,
|
|
15
16
|
integrationSourceForDoc,
|
|
16
17
|
} from '../../foundation/discovery/component-discovery.mjs';
|
|
18
|
+
import {discoverIntegrationDocs} from '../../foundation/discovery/docs-discovery.mjs';
|
|
17
19
|
import {comparePropDocs} from '../../foundation/discovery/prop-drift.mjs';
|
|
18
20
|
import {findCopiedPassages} from '../../foundation/discovery/copied-passages.mjs';
|
|
19
21
|
import {findFluff} from '../../foundation/discovery/doc-fluff.mjs';
|
|
22
|
+
import {findRunnerCommands} from '../../foundation/discovery/runner-commands.mjs';
|
|
20
23
|
import {findStrayPointers} from '../../foundation/discovery/stray-pointers.mjs';
|
|
21
24
|
|
|
22
25
|
/**
|
|
@@ -110,3 +113,20 @@ export async function integrationStrayPointers(discovered, integration) {
|
|
|
110
113
|
}
|
|
111
114
|
return findStrayPointers({...discovered, components});
|
|
112
115
|
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Each Astryx command a package's topics write with a package runner. A
|
|
119
|
+
* package whose topics cannot be discovered has none here: the other checks
|
|
120
|
+
* report topics that do not load.
|
|
121
|
+
* @param {any} integration a loaded integration
|
|
122
|
+
* @returns {Promise<import('../../foundation/discovery/runner-commands.mjs').RunnerCommand[]>}
|
|
123
|
+
*/
|
|
124
|
+
export async function integrationRunnerCommands(integration) {
|
|
125
|
+
let discovered;
|
|
126
|
+
try {
|
|
127
|
+
discovered = await discoverIntegrationDocs(integration);
|
|
128
|
+
} catch {
|
|
129
|
+
return [];
|
|
130
|
+
}
|
|
131
|
+
return findRunnerCommands(discovered);
|
|
132
|
+
}
|
|
@@ -14,6 +14,7 @@ vi.mock('../../foundation/discovery/template-conflict-release.mjs', () => ({
|
|
|
14
14
|
}));
|
|
15
15
|
import * as fs from 'node:fs';
|
|
16
16
|
import * as path from 'node:path';
|
|
17
|
+
import {validateIntegration} from './validate-integration.mjs';
|
|
17
18
|
import {discoverCoreTemplates} from '../../foundation/discovery/template-adapter.mjs';
|
|
18
19
|
import {discoverOwnedComponents} from '../../foundation/discovery/component-discovery.mjs';
|
|
19
20
|
import {discoverBuiltinTopics} from '../../foundation/discovery/docs-discovery.mjs';
|
|
@@ -1331,3 +1332,222 @@ describe('links in component docs and topic descriptions', () => {
|
|
|
1331
1332
|
]);
|
|
1332
1333
|
});
|
|
1333
1334
|
});
|
|
1335
|
+
|
|
1336
|
+
describe('validateIntegration runner-command notes', () => {
|
|
1337
|
+
/** The runner-command notes, read back into their parts. */
|
|
1338
|
+
async function runnerNotes() {
|
|
1339
|
+
const {data} = await validateIntegration(undefined, {cwd: tmpDir});
|
|
1340
|
+
const notes = (data.notes ?? [])
|
|
1341
|
+
.filter((/** @type {any} */ note) => note.code === 'runner_command')
|
|
1342
|
+
.map((/** @type {any} */ note) => {
|
|
1343
|
+
const m =
|
|
1344
|
+
/^(\S+): "([^"]+)"(?: \(section "([^"]+)"\))? writes `([^`]+)`(?: \(line (\d+)\))?\./.exec(
|
|
1345
|
+
note.message,
|
|
1346
|
+
);
|
|
1347
|
+
return {
|
|
1348
|
+
file: m?.[1],
|
|
1349
|
+
topic: m?.[2],
|
|
1350
|
+
section: m?.[3] ?? null,
|
|
1351
|
+
command: m?.[4],
|
|
1352
|
+
line: m?.[5] ? Number(m[5]) : null,
|
|
1353
|
+
message: note.message,
|
|
1354
|
+
};
|
|
1355
|
+
});
|
|
1356
|
+
return {data, notes};
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
function writeTopic(/** @type {string} */ text) {
|
|
1360
|
+
fs.writeFileSync(
|
|
1361
|
+
path.join(tmpDir, 'package.json'),
|
|
1362
|
+
JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
|
|
1363
|
+
);
|
|
1364
|
+
fs.writeFileSync(
|
|
1365
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
1366
|
+
`export default {docs: './docs'};\n`,
|
|
1367
|
+
);
|
|
1368
|
+
fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
|
|
1369
|
+
const doc = {
|
|
1370
|
+
type: 'generic',
|
|
1371
|
+
name: 'acme-setup',
|
|
1372
|
+
title: 'Fixture',
|
|
1373
|
+
description: 'Fixture topic.',
|
|
1374
|
+
sections: [
|
|
1375
|
+
{
|
|
1376
|
+
title: 'Overview',
|
|
1377
|
+
content: [
|
|
1378
|
+
{type: 'prose', text},
|
|
1379
|
+
{type: 'code', lang: 'bash', code: 'npx @astryxdesign/cli init'},
|
|
1380
|
+
],
|
|
1381
|
+
},
|
|
1382
|
+
],
|
|
1383
|
+
};
|
|
1384
|
+
fs.writeFileSync(
|
|
1385
|
+
path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
|
|
1386
|
+
`export default ${JSON.stringify(doc)};\n`,
|
|
1387
|
+
);
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
it('lists a runner command with its line and fix, and raises no issue', async () => {
|
|
1391
|
+
writeTopic('Check it with `pnpm exec astryx doctor` first.');
|
|
1392
|
+
|
|
1393
|
+
const {data, notes} = await runnerNotes();
|
|
1394
|
+
const [hit, ...rest] = notes;
|
|
1395
|
+
|
|
1396
|
+
expect(rest).toEqual([]);
|
|
1397
|
+
expect(hit).toMatchObject({
|
|
1398
|
+
topic: 'acme-setup',
|
|
1399
|
+
section: 'Overview',
|
|
1400
|
+
file: 'docs/acme-setup.doc.mjs',
|
|
1401
|
+
line: 1,
|
|
1402
|
+
command: 'pnpm exec astryx doctor',
|
|
1403
|
+
});
|
|
1404
|
+
expect(hit.message).toContain('Write `astryx doctor`');
|
|
1405
|
+
// A note only: no issue, so no exit changes on it.
|
|
1406
|
+
expect(
|
|
1407
|
+
data.issues.map((/** @type {any} */ issue) => issue.code),
|
|
1408
|
+
).not.toContain('runner_command');
|
|
1409
|
+
});
|
|
1410
|
+
|
|
1411
|
+
it('puts each copy of a repeated command on its own line', async () => {
|
|
1412
|
+
fs.writeFileSync(
|
|
1413
|
+
path.join(tmpDir, 'package.json'),
|
|
1414
|
+
JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
|
|
1415
|
+
);
|
|
1416
|
+
fs.writeFileSync(
|
|
1417
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
1418
|
+
`export default {docs: './docs'};\n`,
|
|
1419
|
+
);
|
|
1420
|
+
fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
|
|
1421
|
+
const doc = {
|
|
1422
|
+
type: 'generic',
|
|
1423
|
+
name: 'acme-setup',
|
|
1424
|
+
title: 'Fixture',
|
|
1425
|
+
description: 'Fixture topic.',
|
|
1426
|
+
sections: [
|
|
1427
|
+
{
|
|
1428
|
+
title: 'First',
|
|
1429
|
+
content: [{type: 'prose', text: 'Run `npx astryx doctor`.'}],
|
|
1430
|
+
},
|
|
1431
|
+
{
|
|
1432
|
+
title: 'Second',
|
|
1433
|
+
content: [{type: 'prose', text: 'Run `npx astryx doctor` again.'}],
|
|
1434
|
+
},
|
|
1435
|
+
{
|
|
1436
|
+
title: 'Third',
|
|
1437
|
+
content: [{type: 'prose', text: 'Or plain `npx astryx`.'}],
|
|
1438
|
+
},
|
|
1439
|
+
],
|
|
1440
|
+
};
|
|
1441
|
+
fs.writeFileSync(
|
|
1442
|
+
path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
|
|
1443
|
+
`export default ${JSON.stringify(doc, null, 2)};\n`,
|
|
1444
|
+
);
|
|
1445
|
+
const lines = fs
|
|
1446
|
+
.readFileSync(path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'), 'utf8')
|
|
1447
|
+
.split('\n');
|
|
1448
|
+
const lineHolding = (/** @type {string} */ text) =>
|
|
1449
|
+
lines.findIndex(line => line.includes(text)) + 1;
|
|
1450
|
+
|
|
1451
|
+
const {notes} = await runnerNotes();
|
|
1452
|
+
|
|
1453
|
+
expect(
|
|
1454
|
+
notes.map((/** @type {any} */ each) => [
|
|
1455
|
+
each.section,
|
|
1456
|
+
each.line,
|
|
1457
|
+
each.command,
|
|
1458
|
+
]),
|
|
1459
|
+
).toEqual([
|
|
1460
|
+
['First', lineHolding('Run `npx astryx doctor`.'), 'npx astryx doctor'],
|
|
1461
|
+
['Second', lineHolding('again.'), 'npx astryx doctor'],
|
|
1462
|
+
['Third', lineHolding('Or plain'), 'npx astryx'],
|
|
1463
|
+
]);
|
|
1464
|
+
});
|
|
1465
|
+
|
|
1466
|
+
it('puts each copy of an identical one-line string on its own line', async () => {
|
|
1467
|
+
fs.writeFileSync(
|
|
1468
|
+
path.join(tmpDir, 'package.json'),
|
|
1469
|
+
JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
|
|
1470
|
+
);
|
|
1471
|
+
fs.writeFileSync(
|
|
1472
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
1473
|
+
`export default {docs: './docs'};\n`,
|
|
1474
|
+
);
|
|
1475
|
+
fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
|
|
1476
|
+
const block = {type: 'code', lang: 'bash', code: 'npx astryx doctor'};
|
|
1477
|
+
const doc = {
|
|
1478
|
+
type: 'generic',
|
|
1479
|
+
name: 'acme-setup',
|
|
1480
|
+
title: 'Fixture',
|
|
1481
|
+
description: 'Fixture topic.',
|
|
1482
|
+
sections: [
|
|
1483
|
+
{title: 'First', content: [block]},
|
|
1484
|
+
{title: 'Second', content: [block]},
|
|
1485
|
+
],
|
|
1486
|
+
};
|
|
1487
|
+
fs.writeFileSync(
|
|
1488
|
+
path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
|
|
1489
|
+
`export default ${JSON.stringify(doc, null, 2)};\n`,
|
|
1490
|
+
);
|
|
1491
|
+
const lines = fs
|
|
1492
|
+
.readFileSync(path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'), 'utf8')
|
|
1493
|
+
.split('\n');
|
|
1494
|
+
const copies = lines.flatMap((line, at) =>
|
|
1495
|
+
line.includes('"npx astryx doctor"') ? [at + 1] : [],
|
|
1496
|
+
);
|
|
1497
|
+
|
|
1498
|
+
const {notes} = await runnerNotes();
|
|
1499
|
+
|
|
1500
|
+
expect(copies).toHaveLength(2);
|
|
1501
|
+
expect(
|
|
1502
|
+
notes.map((/** @type {any} */ each) => [each.section, each.line]),
|
|
1503
|
+
).toEqual([
|
|
1504
|
+
['First', copies[0]],
|
|
1505
|
+
['Second', copies[1]],
|
|
1506
|
+
]);
|
|
1507
|
+
});
|
|
1508
|
+
|
|
1509
|
+
it("places a section's command on its own line when the section sits in a constant above the doc", async () => {
|
|
1510
|
+
fs.writeFileSync(
|
|
1511
|
+
path.join(tmpDir, 'package.json'),
|
|
1512
|
+
JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
|
|
1513
|
+
);
|
|
1514
|
+
fs.writeFileSync(
|
|
1515
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
1516
|
+
`export default {docs: './docs'};\n`,
|
|
1517
|
+
);
|
|
1518
|
+
fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
|
|
1519
|
+
fs.writeFileSync(
|
|
1520
|
+
path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
|
|
1521
|
+
[
|
|
1522
|
+
"const install = {title: 'Install', content: [{type: 'prose', text: 'Run `npx astryx doctor`.'}]};",
|
|
1523
|
+
'',
|
|
1524
|
+
'export default {',
|
|
1525
|
+
" type: 'generic',",
|
|
1526
|
+
" name: 'acme-setup',",
|
|
1527
|
+
" title: 'Fixture',",
|
|
1528
|
+
" description: 'Install first: `npx astryx doctor`.',",
|
|
1529
|
+
' sections: [install],',
|
|
1530
|
+
'};',
|
|
1531
|
+
'',
|
|
1532
|
+
].join('\n'),
|
|
1533
|
+
);
|
|
1534
|
+
|
|
1535
|
+
const {notes} = await runnerNotes();
|
|
1536
|
+
|
|
1537
|
+
expect(
|
|
1538
|
+
notes.map((/** @type {any} */ each) => [each.section, each.line]),
|
|
1539
|
+
).toEqual(
|
|
1540
|
+
expect.arrayContaining([
|
|
1541
|
+
[null, 7],
|
|
1542
|
+
['Install', 1],
|
|
1543
|
+
]),
|
|
1544
|
+
);
|
|
1545
|
+
});
|
|
1546
|
+
|
|
1547
|
+
it('lists nothing for bare commands and the scoped install step', async () => {
|
|
1548
|
+
writeTopic('Check it with `astryx doctor` first.');
|
|
1549
|
+
|
|
1550
|
+
const {notes} = await runnerNotes();
|
|
1551
|
+
expect((await runnerNotes()).notes).toEqual([]);
|
|
1552
|
+
});
|
|
1553
|
+
});
|
|
@@ -37,6 +37,7 @@ const componentDoc = name =>
|
|
|
37
37
|
`export default {type: 'component', name: '${name}', displayName: '${name}', usage: {description: '${name}.'}, props: []};\n`;
|
|
38
38
|
/** @param {string} name */
|
|
39
39
|
const componentSource = name => `export function ${name}() { return null; }\n`;
|
|
40
|
+
/** @param {string} name */
|
|
40
41
|
const templateSource = name =>
|
|
41
42
|
`export default function ${name}() { return null; }\n`;
|
|
42
43
|
/** @param {string} name */
|
|
@@ -398,9 +399,9 @@ describe('unreachable_contribution fixes hold when followed', () => {
|
|
|
398
399
|
const dir = writePackage({
|
|
399
400
|
[MANIFEST]: manifest({templates: './templates'}),
|
|
400
401
|
'templates/hero.doc.mjs': `export default {type: 'page', name: 'hero', displayName: 'Hero'};\n`,
|
|
401
|
-
'templates/hero.tsx':
|
|
402
|
+
'templates/hero.tsx': templateSource('Hero'),
|
|
402
403
|
'src/blocks/Carousel.doc.mjs': `export default {type: 'block', name: 'Carousel', displayName: 'Carousel', aspectRatio: 1};\n`,
|
|
403
|
-
'src/blocks/Carousel.tsx':
|
|
404
|
+
'src/blocks/Carousel.tsx': templateSource('Carousel'),
|
|
404
405
|
});
|
|
405
406
|
|
|
406
407
|
const message = only(await issuesOf(dir), 'unreachable_contribution');
|
|
@@ -423,7 +424,7 @@ describe('unreachable_contribution fixes hold when followed', () => {
|
|
|
423
424
|
[MANIFEST]: manifest({templates: './templates'}),
|
|
424
425
|
'templates/.keep': '',
|
|
425
426
|
'src/blocks/Carousel.doc.mjs': `export default {type: 'block', name: 'Carousel', displayName: 'Carousel', aspectRatio: 1};\n`,
|
|
426
|
-
'src/blocks/Carousel.tsx':
|
|
427
|
+
'src/blocks/Carousel.tsx': templateSource('Carousel'),
|
|
427
428
|
});
|
|
428
429
|
|
|
429
430
|
const message = only(await issuesOf(dir), 'unreachable_contribution');
|
|
@@ -687,9 +688,9 @@ describe('fixes never move a contribution onto a name its root already has', ()
|
|
|
687
688
|
const dir = writePackage({
|
|
688
689
|
[MANIFEST]: manifest({templates: './templates'}),
|
|
689
690
|
'templates/hero.doc.mjs': `export default {type: 'page', name: 'hero', displayName: 'Hero'};\n`,
|
|
690
|
-
'templates/hero.tsx':
|
|
691
|
+
'templates/hero.tsx': templateSource('Hero'),
|
|
691
692
|
'extra/hero.doc.mjs': `export default {type: 'page', name: 'hero', displayName: 'Hero'};\n`,
|
|
692
|
-
'extra/hero.tsx':
|
|
693
|
+
'extra/hero.tsx': templateSource('Hero'),
|
|
693
694
|
});
|
|
694
695
|
|
|
695
696
|
const message = only(await issuesOf(dir), 'unreachable_contribution');
|
|
@@ -169,6 +169,7 @@ const writeNamed = files =>
|
|
|
169
169
|
version: '1.0.0',
|
|
170
170
|
exports: {
|
|
171
171
|
'./components/*': './components/*.tsx',
|
|
172
|
+
'./templates/*': './templates/*.tsx',
|
|
172
173
|
'.': './index.ts',
|
|
173
174
|
},
|
|
174
175
|
});
|
|
@@ -534,7 +535,14 @@ describe('block component names', () => {
|
|
|
534
535
|
'export function Panel() { return null; }\nexport const UI = {};\nexport const Lib = {};\nexport function pick() { return null; }\n',
|
|
535
536
|
...files,
|
|
536
537
|
},
|
|
537
|
-
{
|
|
538
|
+
{
|
|
539
|
+
name: '@acme/kit',
|
|
540
|
+
version: '1.0.0',
|
|
541
|
+
exports: {
|
|
542
|
+
'.': './index.tsx',
|
|
543
|
+
'./templates/*': './templates/*.tsx',
|
|
544
|
+
},
|
|
545
|
+
},
|
|
538
546
|
);
|
|
539
547
|
/** @param {string} extra */
|
|
540
548
|
const block = extra =>
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export function validateLocalIntegration(cwd?: string): Promise<ValidateResult>;
|
|
12
12
|
/**
|
|
13
|
-
* Validate an INSTALLED integration package
|
|
13
|
+
* Validate an INSTALLED integration package: the nearest `node_modules/<spec>`
|
|
14
|
+
* at or above `cwd`, resolved the way the project loads it.
|
|
14
15
|
* @param {string} spec package name
|
|
15
16
|
* @param {string} [cwd]
|
|
16
17
|
* @returns {Promise<ValidateResult>}
|
|
@@ -82,6 +83,10 @@ export type ValidateResult = {
|
|
|
82
83
|
*/
|
|
83
84
|
listed?: import("../../foundation/integrations/issue").AstryxIntegrationIssue[] | undefined;
|
|
84
85
|
integration?: import("../../foundation/integrations/integrations.mjs").LoadedIntegration | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* what the public-import check could not judge
|
|
88
|
+
*/
|
|
89
|
+
publicImports?: import("./validate-integration.type.mjs").PublicImportsReport | undefined;
|
|
85
90
|
};
|
|
86
91
|
import { validateLoadedIntegration } from '../../foundation/integrations/validate-contributions.mjs';
|
|
87
92
|
import { isListedIssue } from '../../foundation/integrations/validate-contributions.mjs';
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* - validateLocalIntegration(cwd) — the package rooted at `cwd` (nearest
|
|
13
13
|
* package.json + sibling astryx.integration.{ts,mjs,js}).
|
|
14
14
|
* - validateInstalledIntegration(spec, cwd) — an installed package resolved
|
|
15
|
-
* from `cwd
|
|
15
|
+
* from the node_modules chain at or above `cwd`.
|
|
16
16
|
*
|
|
17
17
|
* Both return a { found, name, version, manifestFile, issues } result. `found`
|
|
18
18
|
* is false only for the no-manifest local case, which is guidance (not an
|
|
@@ -37,6 +37,7 @@ import {assertWithin} from '../../foundation/fs/path-safety.mjs';
|
|
|
37
37
|
import {normalizeProviderId} from '../../foundation/identity/provider-identity.mjs';
|
|
38
38
|
import {integrationDocTypes} from '../docs/_adapter.mjs';
|
|
39
39
|
import {integrationDocConsistency} from '../../foundation/discovery/doc-consistency.mjs';
|
|
40
|
+
import {integrationRunnerCommands} from './_adapter.mjs';
|
|
40
41
|
import {
|
|
41
42
|
THEME_SLUG_RE,
|
|
42
43
|
unreadThemeFolders,
|
|
@@ -52,7 +53,7 @@ import {
|
|
|
52
53
|
import {
|
|
53
54
|
findManifestPaths,
|
|
54
55
|
loadManifest,
|
|
55
|
-
|
|
56
|
+
resolveInstalledIntegrationDir,
|
|
56
57
|
} from '../../foundation/integrations/integrations.mjs';
|
|
57
58
|
// The on-disk contribution validators live in foundation: Project and
|
|
58
59
|
// integration-warnings need them too, and foundation must not depend on api.
|
|
@@ -69,6 +70,7 @@ import {
|
|
|
69
70
|
rootProblem,
|
|
70
71
|
} from '../../foundation/integrations/validate-contributions.mjs';
|
|
71
72
|
import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
|
|
73
|
+
import {publicImportIssues} from '../../foundation/integrations/public-imports.mjs';
|
|
72
74
|
|
|
73
75
|
export {validateLoadedIntegration, isListedIssue};
|
|
74
76
|
|
|
@@ -91,6 +93,8 @@ export {validateLoadedIntegration, isListedIssue};
|
|
|
91
93
|
* may not fail `--strict` until the next (architecture:cli-surface INV35);
|
|
92
94
|
* `integration verify` still fails on a package.json npm cannot pack.
|
|
93
95
|
* @property {import('../../foundation/integrations/integrations.mjs').LoadedIntegration} [integration]
|
|
96
|
+
* @property {import('./validate-integration.type.mjs').PublicImportsReport} [publicImports]
|
|
97
|
+
* what the public-import check could not judge
|
|
94
98
|
*/
|
|
95
99
|
|
|
96
100
|
/**
|
|
@@ -443,6 +447,14 @@ async function validateAtPackageDir(
|
|
|
443
447
|
packageDir,
|
|
444
448
|
)),
|
|
445
449
|
);
|
|
450
|
+
// What the package tells apps to import, read from source: package.json
|
|
451
|
+
// `exports`, docs, examples and template imports.
|
|
452
|
+
const publicImports = await publicImportIssues(packageDir, loaded);
|
|
453
|
+
issues.push(...publicImports.issues);
|
|
454
|
+
// Each finding is a note until the next minor makes it a warning.
|
|
455
|
+
if (publicImports.notes.length > 0)
|
|
456
|
+
(result.notes ??= []).push(...publicImports.notes);
|
|
457
|
+
result.publicImports = publicImports.report;
|
|
446
458
|
if (scanUnreachable) {
|
|
447
459
|
issues.push(
|
|
448
460
|
...(await findUnreachableContributionIssues(
|
|
@@ -595,20 +607,21 @@ function packageJsonFieldIssues(pkg, pkgJsonPath) {
|
|
|
595
607
|
}
|
|
596
608
|
|
|
597
609
|
/**
|
|
598
|
-
* Validate an INSTALLED integration package
|
|
610
|
+
* Validate an INSTALLED integration package: the nearest `node_modules/<spec>`
|
|
611
|
+
* at or above `cwd`, resolved the way the project loads it.
|
|
599
612
|
* @param {string} spec package name
|
|
600
613
|
* @param {string} [cwd]
|
|
601
614
|
* @returns {Promise<ValidateResult>}
|
|
602
615
|
*/
|
|
603
616
|
export async function validateInstalledIntegration(spec, cwd = process.cwd()) {
|
|
604
|
-
//
|
|
617
|
+
// The resolver throws (path-safety guard) on a spec with path segments,
|
|
605
618
|
// `..`, or an absolute path. Every other malformed input to this command
|
|
606
619
|
// degrades into a diagnostic — so catch it here and return an issue instead
|
|
607
620
|
// of letting the throw escape to a raw stack (human) / generic ERR_UNKNOWN
|
|
608
621
|
// (--json).
|
|
609
622
|
let packageDir;
|
|
610
623
|
try {
|
|
611
|
-
packageDir =
|
|
624
|
+
packageDir = resolveInstalledIntegrationDir(spec, cwd);
|
|
612
625
|
} catch (err) {
|
|
613
626
|
return {
|
|
614
627
|
found: true,
|
|
@@ -646,6 +659,24 @@ export async function validateInstalledIntegration(spec, cwd = process.cwd()) {
|
|
|
646
659
|
});
|
|
647
660
|
}
|
|
648
661
|
|
|
662
|
+
/**
|
|
663
|
+
* The runner-command notes for a package's topics: each Astryx command a topic
|
|
664
|
+
* writes with a package runner, where the doc file is, and the bare command to
|
|
665
|
+
* write.
|
|
666
|
+
* @param {any} integration a loaded integration
|
|
667
|
+
* @returns {Promise<Array<{code: string, message: string}>>}
|
|
668
|
+
*/
|
|
669
|
+
async function runnerCommandNotes(integration) {
|
|
670
|
+
const packageDir = integration.__packageDir;
|
|
671
|
+
return (await integrationRunnerCommands(integration)).map(each => ({
|
|
672
|
+
code: 'runner_command',
|
|
673
|
+
message:
|
|
674
|
+
typeof packageDir === 'string'
|
|
675
|
+
? `${path.relative(packageDir, each.file).split(path.sep).join('/')}: ${each.message}`
|
|
676
|
+
: each.message,
|
|
677
|
+
}));
|
|
678
|
+
}
|
|
679
|
+
|
|
649
680
|
/**
|
|
650
681
|
* Unified entry: validate the LOCAL integration (no `pkg`) or an INSTALLED one
|
|
651
682
|
* (`pkg` given) and return the `integration.validate` envelope. The no-manifest
|
|
@@ -696,6 +727,11 @@ export async function validateIntegration(pkg, options = {}) {
|
|
|
696
727
|
...(names ?? []).flatMap(each => each.notes),
|
|
697
728
|
]
|
|
698
729
|
: [];
|
|
730
|
+
// Each Astryx command a topic writes with a package runner, as a
|
|
731
|
+
// `runner_command` note with its fix, the same way.
|
|
732
|
+
if (integration?.docs) {
|
|
733
|
+
notes.push(...(await runnerCommandNotes(integration)));
|
|
734
|
+
}
|
|
699
735
|
return {
|
|
700
736
|
type: 'integration.validate',
|
|
701
737
|
data: {
|
|
@@ -719,6 +755,10 @@ export async function validateIntegration(pkg, options = {}) {
|
|
|
719
755
|
...(docTypes ? {docTypes} : {}),
|
|
720
756
|
...(docNames ? {docNames} : {}),
|
|
721
757
|
...(blockComponents ? {blockComponents} : {}),
|
|
758
|
+
// What the public-import check could not judge: listed, never failed on.
|
|
759
|
+
...(result.found && result.publicImports
|
|
760
|
+
? {publicImports: result.publicImports}
|
|
761
|
+
: {}),
|
|
722
762
|
},
|
|
723
763
|
};
|
|
724
764
|
}
|
|
@@ -45,9 +45,11 @@ export type ValidateIntegrationResponse = {
|
|
|
45
45
|
* (`unreadable_file`), a package.json without `name` or `version`
|
|
46
46
|
* (`invalid_package_json`), no provider ID (`no_provider_id`), and a doc
|
|
47
47
|
* whose file name differs from its source only in letter case where the two
|
|
48
|
-
* still pair (`source_without_component_doc`);
|
|
49
|
-
* `unknown_block_component` (see `docNames` and `blockComponents`);
|
|
50
|
-
* become warnings in the next
|
|
48
|
+
* still pair (`source_without_component_doc`); `doc_name_mismatch` and
|
|
49
|
+
* `unknown_block_component` (see `docNames` and `blockComponents`); and
|
|
50
|
+
* since 0.7.3 each public-import finding; they become warnings in the next
|
|
51
|
+
* minor release; and `runner_command`, an Astryx command a topic writes
|
|
52
|
+
* with a package runner
|
|
51
53
|
*/
|
|
52
54
|
data: {
|
|
53
55
|
validated: boolean;
|
|
@@ -61,6 +63,7 @@ export type ValidateIntegrationResponse = {
|
|
|
61
63
|
docTypes?: DocTypesReport;
|
|
62
64
|
docNames?: DocNamesReport;
|
|
63
65
|
blockComponents?: BlockComponentsReport;
|
|
66
|
+
publicImports?: PublicImportsReport;
|
|
64
67
|
};
|
|
65
68
|
};
|
|
66
69
|
/**
|
|
@@ -114,3 +117,30 @@ export type BlockComponentsReport = {
|
|
|
114
117
|
reason: string;
|
|
115
118
|
}>;
|
|
116
119
|
};
|
|
120
|
+
/**
|
|
121
|
+
* An import the public-import check could not judge.
|
|
122
|
+
*/
|
|
123
|
+
export type PublicImportUnchecked = {
|
|
124
|
+
/**
|
|
125
|
+
* package-relative file that names it
|
|
126
|
+
*/
|
|
127
|
+
file: string;
|
|
128
|
+
/**
|
|
129
|
+
* the import specifier
|
|
130
|
+
*/
|
|
131
|
+
specifier: string;
|
|
132
|
+
/**
|
|
133
|
+
* why it was not checked
|
|
134
|
+
*/
|
|
135
|
+
reason: string;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* The public-import check's report on validate's result: `unchecked` lists
|
|
139
|
+
* what it could not judge, never counted or failed on. Its findings are
|
|
140
|
+
* notes on the result (`data.notes`), so `findings` stays empty.
|
|
141
|
+
*/
|
|
142
|
+
export type PublicImportsReport = {
|
|
143
|
+
status: "checked";
|
|
144
|
+
findings: never[];
|
|
145
|
+
unchecked: PublicImportUnchecked[];
|
|
146
|
+
};
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
* "healthy" — the two are otherwise byte-identical.
|
|
40
40
|
* @typedef {object} ValidateIntegrationResponse
|
|
41
41
|
* @property {'integration.validate'} type
|
|
42
|
-
* @property {{validated: boolean, name: string | null, version: string | null, issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[], notes?: Array<{code: string, message: string}>, docTypes?: DocTypesReport, docNames?: DocNamesReport, blockComponents?: BlockComponentsReport}} data
|
|
42
|
+
* @property {{validated: boolean, name: string | null, version: string | null, issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[], notes?: Array<{code: string, message: string}>, docTypes?: DocTypesReport, docNames?: DocNamesReport, blockComponents?: BlockComponentsReport, publicImports?: PublicImportsReport}} data
|
|
43
43
|
* `notes`: information beside the issues that fails nothing, such as
|
|
44
44
|
* `invalid_cli_command`, a `cliCommand` that was ignored as malformed, and
|
|
45
45
|
* the package layout findings added after the last minor release, each with
|
|
@@ -49,9 +49,11 @@
|
|
|
49
49
|
* (`unreadable_file`), a package.json without `name` or `version`
|
|
50
50
|
* (`invalid_package_json`), no provider ID (`no_provider_id`), and a doc
|
|
51
51
|
* whose file name differs from its source only in letter case where the two
|
|
52
|
-
* still pair (`source_without_component_doc`);
|
|
53
|
-
* `unknown_block_component` (see `docNames` and `blockComponents`);
|
|
54
|
-
* become warnings in the next
|
|
52
|
+
* still pair (`source_without_component_doc`); `doc_name_mismatch` and
|
|
53
|
+
* `unknown_block_component` (see `docNames` and `blockComponents`); and
|
|
54
|
+
* since 0.7.3 each public-import finding; they become warnings in the next
|
|
55
|
+
* minor release; and `runner_command`, an Astryx command a topic writes
|
|
56
|
+
* with a package runner
|
|
55
57
|
*/
|
|
56
58
|
|
|
57
59
|
/**
|
|
@@ -98,3 +100,21 @@
|
|
|
98
100
|
*/
|
|
99
101
|
|
|
100
102
|
export {};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* An import the public-import check could not judge.
|
|
106
|
+
* @typedef {object} PublicImportUnchecked
|
|
107
|
+
* @property {string} file package-relative file that names it
|
|
108
|
+
* @property {string} specifier the import specifier
|
|
109
|
+
* @property {string} reason why it was not checked
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The public-import check's report on validate's result: `unchecked` lists
|
|
114
|
+
* what it could not judge, never counted or failed on. Its findings are
|
|
115
|
+
* notes on the result (`data.notes`), so `findings` stays empty.
|
|
116
|
+
* @typedef {object} PublicImportsReport
|
|
117
|
+
* @property {'checked'} status
|
|
118
|
+
* @property {never[]} findings
|
|
119
|
+
* @property {PublicImportUnchecked[]} unchecked
|
|
120
|
+
*/
|
|
@@ -62,7 +62,7 @@ export const doc = {
|
|
|
62
62
|
{
|
|
63
63
|
type: 'integration.validate',
|
|
64
64
|
description:
|
|
65
|
-
'The result envelope: `data.validated`, false when nothing was validated — with no `package.json` at all, `data.issues` carries one `no_package` error-severity issue so the command exits 1; with a `package.json` but no integration manifest, `data.issues` is empty, which means "not looked at", not "healthy"; `data.name` and `data.version` of the validated package (both null when `data.validated` is false; `data.name` is `(local package)` when the local package.json has no readable name), plus `data.issues`, an AstryxIntegrationIssue[] of {code, severity: `warning` | `error`, message, fix?, file?, line?}: `fix` is the change that resolves the issue, and `file` and `line` where it is, relative to the package, when the check knows them; and `data.notes` when there are any: {code, message} information that fails nothing, such as `invalid_cli_command` for a `cliCommand` that was ignored as malformed, and the package layout findings added after the last minor release, each with its fix in the message: `duplicate_component_doc`, `symlinked_root`, `unreadable_file`, `invalid_package_json` (no `name` or `version`), `no_provider_id`, and `source_without_component_doc` for a doc whose file name differs from its source only in letter case where the two still pair; and `doc_name_mismatch` and `unknown_block_component` (see `docNames` and `blockComponents`); they become warnings in the next minor release. When the manifest loads, `data.docTypes` holds the doc type check: `status` (`checked` | `skipped`), `reason` when skipped, `typescript`, `docs` (doc values checked), `findings` ({doc, line, export, type, field, problem: `unknown_field` | `missing_field` | `wrong_type`, severity: `warning`, message, fix}), `unchecked` ({doc, reason}: a doc that could not be fully checked, or a root its reader cannot read), and `fixtures` when the components or docs root holds test fixture docs under `__tests__`: how many, none of them checked. When the manifest loads, `data.docNames` lists the component doc names it could not judge: `status` (`checked`), `findings` (always empty; a doc name the module its import names provably does not export is a `doc_name_mismatch` note, with its fix in the message) and `unchecked` ({file, name, reason}: a doc whose `name` differs from the name it is listed under and whose source exports cannot all be read, such as a re-export from another package). When the manifest loads, `data.blockComponents` lists the component names templates give in `exampleFor` or `componentsUsed` that could not be judged: `status` (`checked`), `findings` (always empty; a name neither the package nor Core has, and the template does not import, is an `unknown_block_component` note, with its fix in the message) and `unchecked` ({file, name, reason}: a name the template may reach through anything other than named imports and re-exports from Core, React, StyleX, local helpers or the entry of the package itself, such as an import from another package, a default or namespace import, an alias of or member read off an imported binding, require() or a dynamic import(), or a local module that cannot be read, or any name Core would have to resolve when Core is not installed).',
|
|
65
|
+
'The result envelope: `data.validated`, false when nothing was validated — with no `package.json` at all, `data.issues` carries one `no_package` error-severity issue so the command exits 1; with a `package.json` but no integration manifest, `data.issues` is empty, which means "not looked at", not "healthy"; `data.name` and `data.version` of the validated package (both null when `data.validated` is false; `data.name` is `(local package)` when the local package.json has no readable name), plus `data.issues`, an AstryxIntegrationIssue[] of {code, severity: `warning` | `error`, message, fix?, file?, line?}: `fix` is the change that resolves the issue, and `file` and `line` where it is, relative to the package, when the check knows them; and `data.notes` when there are any: {code, message} information that fails nothing, such as `invalid_cli_command` for a `cliCommand` that was ignored as malformed, and the package layout findings added after the last minor release, each with its fix in the message: `duplicate_component_doc`, `symlinked_root`, `unreadable_file`, `invalid_package_json` (no `name` or `version`), `no_provider_id`, and `source_without_component_doc` for a doc whose file name differs from its source only in letter case where the two still pair; and `doc_name_mismatch` and `unknown_block_component` (see `docNames` and `blockComponents`); they become warnings in the next minor release. A `runner_command` note lists each Astryx command a topic writes with a package runner, with its file, line and the bare command to write. When the manifest loads, `data.docTypes` holds the doc type check: `status` (`checked` | `skipped`), `reason` when skipped, `typescript`, `docs` (doc values checked), `findings` ({doc, line, export, type, field, problem: `unknown_field` | `missing_field` | `wrong_type`, severity: `warning`, message, fix}), `unchecked` ({doc, reason}: a doc that could not be fully checked, or a root its reader cannot read), and `fixtures` when the components or docs root holds test fixture docs under `__tests__`: how many, none of them checked. When the manifest loads, `data.docNames` lists the component doc names it could not judge: `status` (`checked`), `findings` (always empty; a doc name the module its import names provably does not export is a `doc_name_mismatch` note, with its fix in the message) and `unchecked` ({file, name, reason}: a doc whose `name` differs from the name it is listed under and whose source exports cannot all be read, such as a re-export from another package). When the manifest loads, `data.blockComponents` lists the component names templates give in `exampleFor` or `componentsUsed` that could not be judged: `status` (`checked`), `findings` (always empty; a name neither the package nor Core has, and the template does not import, is an `unknown_block_component` note, with its fix in the message) and `unchecked` ({file, name, reason}: a name the template may reach through anything other than named imports and re-exports from Core, React, StyleX, local helpers or the entry of the package itself, such as an import from another package, a default or namespace import, an alias of or member read off an imported binding, require() or a dynamic import(), or a local module that cannot be read, or any name Core would have to resolve when Core is not installed). Since 0.7.3 each import apps cannot use is a note in `data.notes`, its fix inside the message, listed only: it does not fail this command or `integration check --strict`, and fails `--strict` from the next minor release. The codes are `component_import_not_exported`, `component_import_other_package`, `example_import_not_exported`, `template_import_not_exported`, `template_import_outside_root` and `template_private_import`. When the manifest loads, `data.publicImports` is `{status: \'checked\', findings: [], unchecked}`: `unchecked` lists each import the check could not judge, as {file, specifier, reason}, the reason starting `example <label>:` for an import in a component example: a deep path into build output not built yet in a package with no `exports`; a template import of Core when `@astryxdesign/core` is not installed beside the package (a `packages/core` of the workspace under another name does not count); every import of the package\'s own name when package.json has no `name` or a `name` that is not a bare package name; one entry for the whole check when package.json cannot be read; and an import of a subpath whose `exports` entry has only a `types` target, unless it is `import type`, every binding is an inline `type`, or every name it imports is a type its types file declares: a value import of a name that file does not declare as a type, a namespace or side-effect import, or any import when the types file cannot be read (it may be build output). `integration check` counts the unchecked as not compared; they never fail it.',
|
|
66
66
|
},
|
|
67
67
|
],
|
|
68
68
|
examples: [
|
|
@@ -26,6 +26,21 @@ export function gatherCandidates(options: {
|
|
|
26
26
|
outside: boolean;
|
|
27
27
|
coreSkipped: string | null;
|
|
28
28
|
}>;
|
|
29
|
+
/**
|
|
30
|
+
* gatherCandidates, reused within one process: a later search in the same
|
|
31
|
+
* folder, for the same `type`, ranks the candidates an earlier search
|
|
32
|
+
* gathered when none of the files that gather read, and none of the folders
|
|
33
|
+
* it listed or probed, changed since (each is checked by its change time and
|
|
34
|
+
* size, so an edited doc in a linked package is seen on the next call). A
|
|
35
|
+
* long-running caller (a docs site's search, an agent harness) then pays the
|
|
36
|
+
* gather once. A one-shot `astryx search` gathers once, as before.
|
|
37
|
+
* @param {{cwd?: string, type?: string}} options
|
|
38
|
+
* @returns {Promise<Gathered>}
|
|
39
|
+
*/
|
|
40
|
+
export function gatherCandidatesReused(options: {
|
|
41
|
+
cwd?: string;
|
|
42
|
+
type?: string;
|
|
43
|
+
}): Promise<Gathered>;
|
|
29
44
|
/**
|
|
30
45
|
* The search tree's static data, read once: the entry cards and each node's
|
|
31
46
|
* weights file.
|
|
@@ -38,6 +53,7 @@ export function gatherCandidates(options: {
|
|
|
38
53
|
export function loadSearchData(): SearchData;
|
|
39
54
|
export { componentKeywords } from "./_gather-components.mjs";
|
|
40
55
|
export type Candidate = import("./_lexical.mjs").Candidate;
|
|
56
|
+
export type Gathered = Awaited<ReturnType<typeof gatherCandidates>>;
|
|
41
57
|
export type SearcherWeights = {
|
|
42
58
|
w: number[];
|
|
43
59
|
mu: number[];
|