@astryxdesign/cli 0.7.2-canary.e26723d → 0.7.2-canary.e4bdd70
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 +9 -8
- package/api/docs/_adapter.d.mts +11 -0
- package/api/docs/_adapter.mjs +37 -0
- package/api/index.d.mts +2 -0
- package/api/index.mjs +2 -0
- package/api/integration/add-contribution.mjs +1 -1
- package/api/integration/add-contribution.test.mjs +4 -2
- package/api/integration/check/check.d.mts +96 -0
- package/api/integration/check/check.mjs +357 -0
- package/api/integration/check/check.test.mjs +489 -0
- package/api/integration/integration-check.type.d.mts +118 -0
- package/api/integration/integration-check.type.mjs +84 -0
- package/api/integration/integrationCheck.doc.d.mts +10 -0
- package/api/integration/integrationCheck.doc.mjs +73 -0
- package/api/integration/integrationComponentConflicts.doc.mjs +19 -4
- package/api/integration/validate-integration.mjs +8 -0
- package/api/integration/validate-integration.type.d.mts +8 -0
- package/api/integration/validate-integration.type.mjs +12 -1
- package/api/integration/validateIntegration.doc.mjs +17 -3
- package/api/search/search.d.mts +13 -6
- package/api/search/search.domain-priority.test.mjs +93 -18
- package/api/search/search.integration-check.test.mjs +24 -0
- package/api/search/search.mjs +33 -9
- package/api/theme/build/build.family.test.mjs +54 -6
- package/api/theme/build/build.mjs +110 -13
- package/api/theme/themeBuild.doc.mjs +4 -4
- package/assets/docs/styling-overview.doc.mjs +1 -1
- 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 +10 -7
- package/assets/docs/tree/agent-guidance.doc.mjs +2 -2
- package/assets/docs/tree/block-template.doc.mjs +8 -20
- package/assets/docs/tree/build-the-template.doc.mjs +1 -1
- package/assets/docs/tree/check-the-props.doc.mjs +51 -0
- package/assets/docs/tree/check-your-docs.doc.mjs +51 -5
- package/assets/docs/tree/checks.doc.mjs +21 -13
- package/assets/docs/tree/codemods.doc.mjs +4 -4
- package/assets/docs/tree/component-family.doc.mjs +3 -5
- package/assets/docs/tree/component-imports.doc.mjs +2 -2
- package/assets/docs/tree/components.doc.mjs +1 -1
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +7 -18
- package/assets/docs/tree/define-the-theme.doc.mjs +6 -5
- package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
- package/assets/docs/tree/docs.doc.mjs +3 -3
- 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 +6 -6
- package/assets/docs/tree/fonts-and-assets.doc.mjs +2 -2
- package/assets/docs/tree/generate-a-palette.doc.mjs +5 -3
- package/assets/docs/tree/grade-template-with-agent.doc.mjs +1 -1
- package/assets/docs/tree/integrations.doc.mjs +8 -0
- package/assets/docs/tree/links.doc.mjs +5 -4
- package/assets/docs/tree/package-and-test.doc.mjs +1 -1
- package/assets/docs/tree/page-template.doc.mjs +4 -8
- package/assets/docs/tree/publishing.doc.mjs +1 -1
- package/assets/docs/tree/quick-start.doc.mjs +37 -21
- package/assets/docs/tree/replace-a-core-component.doc.mjs +4 -6
- package/assets/docs/tree/replace-a-core-template.doc.mjs +6 -8
- package/assets/docs/tree/sections-and-placement.doc.mjs +4 -6
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +4 -2
- package/assets/docs/tree/short-and-findable.doc.mjs +6 -5
- package/assets/docs/tree/single-component.doc.mjs +12 -4
- package/assets/docs/tree/start-a-template.doc.mjs +3 -3
- package/assets/docs/tree/subcomponent.doc.mjs +6 -6
- package/assets/docs/tree/template-assets.doc.mjs +2 -2
- package/assets/docs/tree/template-doc-overview.doc.mjs +4 -15
- package/assets/docs/tree/template-fonts.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 +2 -2
- package/assets/docs/tree/templates.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +3 -3
- package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
- package/assets/docs/tree/tokens-and-setup.doc.mjs +19 -15
- package/assets/docs/tree/troubleshooting.doc.mjs +4 -4
- package/assets/docs/tree/upgrading.doc.mjs +3 -3
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +3 -1
- package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
- package/assets/docs/tree/versioning.doc.mjs +6 -6
- package/assets/docs/tree/write-the-template-file.doc.mjs +2 -2
- package/authoring/codemod/codemod.doc.mjs +7 -3
- package/authoring/config/config.doc.mjs +9 -6
- package/authoring/config/type.ts +4 -2
- package/authoring/discover/discover.doc.mjs +1 -1
- package/authoring/doctypes/base/graph-fields.doc.mjs +6 -4
- package/authoring/doctypes/command/command.doc.mjs +14 -12
- package/authoring/doctypes/component/component.doc.mjs +28 -25
- package/authoring/doctypes/component/type.ts +7 -5
- package/authoring/doctypes/enum/enum.doc.mjs +7 -4
- package/authoring/doctypes/function/function.doc.mjs +9 -8
- package/authoring/doctypes/hook/hook.doc.mjs +5 -4
- package/authoring/doctypes/namespace/namespace.doc.mjs +7 -6
- package/authoring/doctypes/reference/reference.doc.mjs +11 -10
- package/authoring/doctypes/schema/schema.doc.mjs +9 -9
- package/authoring/doctypes/template/integration-template.doc.mjs +1 -1
- package/authoring/doctypes/template/template.doc.mjs +3 -3
- package/authoring/doctypes/theme/theme.doc.mjs +2 -2
- package/authoring/gap-report/gap-report.doc.mjs +2 -2
- package/authoring/identity/identity.doc.mjs +3 -3
- package/authoring/integration/integration.doc.mjs +4 -3
- package/clients/cli/commands/build-theme.path-safety.test.mjs +155 -21
- package/clients/cli/commands/doctor-integration-components.doc.mjs +8 -3
- package/clients/cli/commands/doctor-integration-validate.doc.mjs +11 -2
- package/clients/cli/commands/doctor-integration.test.mjs +447 -2
- package/clients/cli/commands/doctor.mjs +116 -0
- package/clients/cli/commands/integration-check.doc.mjs +85 -0
- package/clients/cli/commands/integration-check.test.mjs +267 -0
- package/clients/cli/commands/integration.doc.mjs +6 -2
- package/clients/cli/commands/integration.mjs +107 -1
- package/clients/cli/commands/text-json-parity.test.mjs +5 -0
- package/clients/cli/commands/theme-build.doc.mjs +2 -2
- package/clients/cli/index.mjs +1 -0
- package/foundation/discovery/authoring-self-docs.mjs +1 -1
- package/foundation/discovery/doc-types.mjs +2 -2
- package/foundation/discovery/integration-doc-files.d.mts +22 -0
- package/foundation/discovery/integration-doc-files.mjs +231 -0
- package/foundation/discovery/integration-doc-files.test.mjs +246 -0
- package/foundation/discovery/prop-drift.d.mts +61 -3
- package/foundation/discovery/prop-drift.mjs +559 -61
- package/foundation/discovery/prop-drift.test.mjs +1032 -10
- package/foundation/doc-compiler/doc-loads.test.mjs +2 -0
- package/foundation/response/response-types.doc.mjs +7 -2
- package/package.json +9 -9
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file CommandDoc for `astryx integration check`.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** @type {import('@astryxdesign/cli/authoring').CommandDoc} */
|
|
8
|
+
export const doc = {
|
|
9
|
+
type: 'command',
|
|
10
|
+
name: 'integration check',
|
|
11
|
+
displayName: 'astryx integration check',
|
|
12
|
+
namespace: 'cli/commands',
|
|
13
|
+
summary:
|
|
14
|
+
"The CI check for an integration package's own build: every source check, run in continuous integration or a typecheck script, against the package in the current folder",
|
|
15
|
+
description:
|
|
16
|
+
'Takes no package argument: it runs the four `doctor integration` checks, ' +
|
|
17
|
+
'`validate`, `components`, `templates`, and `docs`, against the integration ' +
|
|
18
|
+
'package in the current folder, which is where its own build runs it. It prints ' +
|
|
19
|
+
'each result as that check ' +
|
|
20
|
+
'prints it, then a summary with the errors, warnings, and skipped work of each, ' +
|
|
21
|
+
'and exits 1 when any of the four would exit 1 on its own. With `--strict` it ' +
|
|
22
|
+
'also exits 1 on any warning and on any check, or comparison within a check, ' +
|
|
23
|
+
'that did not run, such as a package with no `astryx.integration.*` or a ' +
|
|
24
|
+
'comparison skipped because the project has no TypeScript, or prop types not ' +
|
|
25
|
+
'judged because its TypeScript is older than 4.8: it adds no check, ' +
|
|
26
|
+
'and lists each of those again as an error, after the checks, in their own ' +
|
|
27
|
+
'issue format. That is the line ' +
|
|
28
|
+
"for the package's own build, so its docs, types, and links stay in sync: run " +
|
|
29
|
+
'it as a `ci` step, or add ' +
|
|
30
|
+
'`"typecheck": "tsc --noEmit && astryx integration check --strict"` to the ' +
|
|
31
|
+
'scripts in package.json. Its exit codes and JSON are a contract for the builds ' +
|
|
32
|
+
'that run it: a new check, or a new failure code, joins only in a minor release ' +
|
|
33
|
+
'that names it in the release notes. A patch can still ship a Core component, ' +
|
|
34
|
+
'template, or CLI topic whose name conflicts with one of yours. Run ' +
|
|
35
|
+
'`integration check` on every build; run ' +
|
|
36
|
+
'`integration verify` before you publish, to check that the packed package ' +
|
|
37
|
+
'works in an app. To check an installed integration by name, run the ' +
|
|
38
|
+
'`doctor integration` subcommands with its package name.',
|
|
39
|
+
fn: 'integrationCheck',
|
|
40
|
+
options: [
|
|
41
|
+
{
|
|
42
|
+
flag: '--strict',
|
|
43
|
+
param: 'options.strict',
|
|
44
|
+
description:
|
|
45
|
+
'Also exit 1 on any warning and on any check that did not run. A new check or failure code joins only in a minor release, named in the release notes.',
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
examples: [
|
|
49
|
+
{
|
|
50
|
+
label:
|
|
51
|
+
'In CI, as the typecheck script: add "typecheck": "tsc --noEmit && astryx integration check --strict" to package.json',
|
|
52
|
+
cli: 'integration check --strict',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: 'Errors only, while you fix the warnings a package already has',
|
|
56
|
+
cli: 'integration check',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
label: 'Read the result as JSON',
|
|
60
|
+
cli: 'integration check --strict --json',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
label:
|
|
64
|
+
'Before you publish: check that the packed package works in an app',
|
|
65
|
+
cli: 'integration verify',
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
exitCodes: [
|
|
69
|
+
{
|
|
70
|
+
code: 0,
|
|
71
|
+
when: 'no check fails on its own; with --strict, also no warning, and every check ran',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
code: 1,
|
|
75
|
+
when: 'a check fails on its own (an error); with --strict, also any warning, or a check that did not run',
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
related: [
|
|
79
|
+
'integration verify',
|
|
80
|
+
'doctor integration validate',
|
|
81
|
+
'doctor integration components',
|
|
82
|
+
'doctor integration templates',
|
|
83
|
+
'doctor integration docs',
|
|
84
|
+
],
|
|
85
|
+
};
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file `astryx integration check`: every source check in one command, the
|
|
5
|
+
* summary, exit codes with and without `--strict`, and the `--strict`
|
|
6
|
+
* failures, in text and JSON alike.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
10
|
+
import * as fs from 'node:fs';
|
|
11
|
+
import * as os from 'node:os';
|
|
12
|
+
import * as path from 'node:path';
|
|
13
|
+
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
14
|
+
import {discoverCoreTemplates} from '../../../foundation/discovery/template-adapter.mjs';
|
|
15
|
+
|
|
16
|
+
/** @type {string} */
|
|
17
|
+
let tmpDir;
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
// Under the repository, so the components check resolves Core.
|
|
21
|
+
tmpDir = fs.mkdtempSync(
|
|
22
|
+
path.join(process.cwd(), '.astryx-integration-check-cli-'),
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A package whose one page template takes a Core template's id: one warning
|
|
32
|
+
* (`templates` conflict). The doc matches TemplateDoc, so no other check
|
|
33
|
+
* warns about it.
|
|
34
|
+
* @param {{id: string, replaces?: string, extraManifest?: string, dir?: string}} options
|
|
35
|
+
*/
|
|
36
|
+
function writePackage({id, replaces, extraManifest = '', dir = tmpDir}) {
|
|
37
|
+
fs.writeFileSync(
|
|
38
|
+
path.join(dir, 'package.json'),
|
|
39
|
+
JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
|
|
40
|
+
);
|
|
41
|
+
fs.writeFileSync(
|
|
42
|
+
path.join(dir, 'astryx.integration.mjs'),
|
|
43
|
+
`export default {templates: './templates'${extraManifest}};\n`,
|
|
44
|
+
);
|
|
45
|
+
fs.mkdirSync(path.join(dir, 'templates'), {recursive: true});
|
|
46
|
+
fs.writeFileSync(
|
|
47
|
+
path.join(dir, 'templates', `${id}.doc.mjs`),
|
|
48
|
+
`export default {type: 'page', name: 'Integration template', displayName: 'Integration template', description: 'fixture'${replaces == null ? '' : `, replaces: ${JSON.stringify(replaces)}`}};\n`,
|
|
49
|
+
);
|
|
50
|
+
fs.writeFileSync(
|
|
51
|
+
path.join(dir, 'templates', `${id}.tsx`),
|
|
52
|
+
'export default function Fixture() { return null; }\n',
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function coreTemplateId() {
|
|
57
|
+
const core = (await discoverCoreTemplates()).find(
|
|
58
|
+
template => template.type === 'page',
|
|
59
|
+
);
|
|
60
|
+
expect(core).toBeDefined();
|
|
61
|
+
return /** @type {{dirName: string}} */ (core).dirName;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
describe('astryx integration check', () => {
|
|
65
|
+
it('runs validate, components, templates, and docs in order, then a summary, and exits 0 on a warning', async () => {
|
|
66
|
+
writePackage({id: await coreTemplateId()});
|
|
67
|
+
|
|
68
|
+
const run = await runCli(['integration', 'check'], tmpDir);
|
|
69
|
+
|
|
70
|
+
const order = [
|
|
71
|
+
'Validating integration: @acme/widgets@1.2.3',
|
|
72
|
+
'Checking integration components: @acme/widgets@1.2.3',
|
|
73
|
+
'Checking integration templates: @acme/widgets@1.2.3',
|
|
74
|
+
'Checking integration docs: @acme/widgets@1.2.3',
|
|
75
|
+
'Integration check: @acme/widgets@1.2.3',
|
|
76
|
+
].map(line => run.stdout.indexOf(line));
|
|
77
|
+
expect(order.every(index => index >= 0)).toBe(true);
|
|
78
|
+
expect([...order].sort((a, b) => a - b)).toEqual(order);
|
|
79
|
+
expect(run.stdout).toContain('Consider renaming');
|
|
80
|
+
expect(run.stdout).not.toContain('Failing under --strict');
|
|
81
|
+
expect(run.stdout).toContain(
|
|
82
|
+
'[ok] 0 errors, 1 warning, 0 skipped. No check failed;',
|
|
83
|
+
);
|
|
84
|
+
// Each check's output stands apart from the next.
|
|
85
|
+
const lines = run.stdout.split('\n');
|
|
86
|
+
for (const header of [
|
|
87
|
+
'Checking integration components:',
|
|
88
|
+
'Checking integration templates:',
|
|
89
|
+
'Checking integration docs:',
|
|
90
|
+
]) {
|
|
91
|
+
expect(lines[lines.findIndex(line => line.includes(header)) - 1]).toBe(
|
|
92
|
+
'',
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
expect(run.status).toBe(0);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('--strict lists the warning again as an error, after the checks, and exits 1', async () => {
|
|
99
|
+
const id = await coreTemplateId();
|
|
100
|
+
writePackage({id});
|
|
101
|
+
|
|
102
|
+
const run = await runCli(['integration', 'check', '--strict'], tmpDir);
|
|
103
|
+
|
|
104
|
+
expect(run.stdout).toContain(
|
|
105
|
+
'Integration check: @acme/widgets@1.2.3 (strict)',
|
|
106
|
+
);
|
|
107
|
+
const block = run.stdout.indexOf('Failing under --strict');
|
|
108
|
+
expect(block).toBeGreaterThan(
|
|
109
|
+
run.stdout.indexOf('Checking integration docs:'),
|
|
110
|
+
);
|
|
111
|
+
expect(run.stdout.slice(block)).toMatch(
|
|
112
|
+
/severity: \[fail\]\ncheck: +templates\ncode: +template_id_conflict\n/,
|
|
113
|
+
);
|
|
114
|
+
expect(run.stdout).toContain(
|
|
115
|
+
'[fail] 0 errors, 1 warning, 0 skipped. --strict fails on every warning and on skipped work;',
|
|
116
|
+
);
|
|
117
|
+
expect(run.status).toBe(1);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('--json carries each check with its own envelope, the --strict failures, and exits as the text does', async () => {
|
|
121
|
+
const id = await coreTemplateId();
|
|
122
|
+
writePackage({id});
|
|
123
|
+
|
|
124
|
+
const run = await runCli(
|
|
125
|
+
['integration', 'check', '--strict', '--json'],
|
|
126
|
+
tmpDir,
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
const parsed = JSON.parse(run.stdout.trim());
|
|
130
|
+
expect(parsed.type).toBe('integration.check');
|
|
131
|
+
expect(parsed.data).toMatchObject({
|
|
132
|
+
validated: true,
|
|
133
|
+
name: '@acme/widgets',
|
|
134
|
+
version: '1.2.3',
|
|
135
|
+
strict: true,
|
|
136
|
+
errors: 0,
|
|
137
|
+
warnings: 1,
|
|
138
|
+
skipped: [],
|
|
139
|
+
failed: true,
|
|
140
|
+
});
|
|
141
|
+
expect(parsed.data.checks.map(check => check.check)).toEqual([
|
|
142
|
+
'validate',
|
|
143
|
+
'components',
|
|
144
|
+
'templates',
|
|
145
|
+
'docs',
|
|
146
|
+
]);
|
|
147
|
+
const templates = parsed.data.checks[2];
|
|
148
|
+
expect(templates).toMatchObject({
|
|
149
|
+
check: 'templates',
|
|
150
|
+
errors: 0,
|
|
151
|
+
warnings: 1,
|
|
152
|
+
skipped: [],
|
|
153
|
+
failed: false,
|
|
154
|
+
response: {
|
|
155
|
+
type: 'integration.template-conflicts',
|
|
156
|
+
data: {conflicts: [expect.objectContaining({id, severity: 'warning'})]},
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
expect(parsed.data.failures).toEqual([
|
|
160
|
+
{
|
|
161
|
+
check: 'templates',
|
|
162
|
+
severity: 'error',
|
|
163
|
+
code: 'template_id_conflict',
|
|
164
|
+
message: templates.response.data.conflicts[0].message,
|
|
165
|
+
},
|
|
166
|
+
]);
|
|
167
|
+
expect(run.status).toBe(1);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('exits 1 without --strict when one check fails on its own, and lists no failures', async () => {
|
|
171
|
+
writePackage({id: 'acme-app-shell', replaces: 'missing-core-shell'});
|
|
172
|
+
|
|
173
|
+
const text = await runCli(['integration', 'check'], tmpDir);
|
|
174
|
+
const json = await runCli(['integration', 'check', '--json'], tmpDir);
|
|
175
|
+
|
|
176
|
+
expect(text.stdout).toContain('missing_template_replacement_target');
|
|
177
|
+
expect(text.stdout).toMatch(
|
|
178
|
+
/\[fail\] [1-9]\d* errors?, .*Address the items marked \[fail\] above\./,
|
|
179
|
+
);
|
|
180
|
+
expect(text.stdout).not.toContain('Failing under --strict');
|
|
181
|
+
expect(JSON.parse(json.stdout.trim()).data).toMatchObject({
|
|
182
|
+
strict: false,
|
|
183
|
+
failures: [],
|
|
184
|
+
failed: true,
|
|
185
|
+
});
|
|
186
|
+
expect(text.status).toBe(1);
|
|
187
|
+
expect(json.status).toBe(1);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('counts a package with no manifest as skipped work: exit 0, and 1 with --strict', async () => {
|
|
191
|
+
fs.writeFileSync(
|
|
192
|
+
path.join(tmpDir, 'package.json'),
|
|
193
|
+
JSON.stringify({name: '@acme/plain', version: '1.0.0'}),
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
const loose = await runCli(['integration', 'check'], tmpDir);
|
|
197
|
+
expect(loose.stdout).toContain(
|
|
198
|
+
"Nothing was checked: no astryx.integration.* found next to package.json. Run this command in an integration package's folder.",
|
|
199
|
+
);
|
|
200
|
+
// One cause, however many checks it stops: counted once.
|
|
201
|
+
expect(loose.stdout).toContain('[ok] 0 errors, 0 warnings, 1 skipped.');
|
|
202
|
+
expect(loose.status).toBe(0);
|
|
203
|
+
|
|
204
|
+
const strict = await runCli(
|
|
205
|
+
['integration', 'check', '--strict', '--json'],
|
|
206
|
+
tmpDir,
|
|
207
|
+
);
|
|
208
|
+
const {data} = JSON.parse(strict.stdout.trim());
|
|
209
|
+
expect(data).toMatchObject({validated: false, errors: 0, failed: true});
|
|
210
|
+
// One cause, however many checks it stops: listed once.
|
|
211
|
+
expect(data.failures).toEqual([
|
|
212
|
+
{
|
|
213
|
+
check: 'validate',
|
|
214
|
+
severity: 'error',
|
|
215
|
+
code: 'missing_manifest',
|
|
216
|
+
message:
|
|
217
|
+
'No astryx.integration.* found next to package.json, so nothing was checked.',
|
|
218
|
+
},
|
|
219
|
+
]);
|
|
220
|
+
expect(strict.status).toBe(1);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it('exits 1 for no package.json, as validate does', async () => {
|
|
224
|
+
const empty = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-no-pkg-'));
|
|
225
|
+
try {
|
|
226
|
+
const run = await runCli(['integration', 'check'], empty);
|
|
227
|
+
expect(run.stdout).toContain(
|
|
228
|
+
'Nothing was checked: no package.json found.',
|
|
229
|
+
);
|
|
230
|
+
expect(run.stdout).toContain('Integration check: (no package.json)');
|
|
231
|
+
expect(run.stdout).toContain(
|
|
232
|
+
'[fail] 1 error, 0 warnings, 0 skipped. No package.json was found here, so nothing was checked.',
|
|
233
|
+
);
|
|
234
|
+
expect(run.stdout).not.toContain('marked [fail] above');
|
|
235
|
+
expect(run.status).toBe(1);
|
|
236
|
+
} finally {
|
|
237
|
+
fs.rmSync(empty, {recursive: true, force: true});
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it('states in its help that it is the CI check, the line to add, and what --strict promises', async () => {
|
|
242
|
+
const run = await runCli(['integration', 'check', '--help'], tmpDir);
|
|
243
|
+
|
|
244
|
+
expect(run.stdout).toContain(
|
|
245
|
+
"The CI check for an integration package's own build",
|
|
246
|
+
);
|
|
247
|
+
expect(run.stdout).toContain(
|
|
248
|
+
'"typecheck": "tsc --noEmit && astryx integration check --strict"',
|
|
249
|
+
);
|
|
250
|
+
expect(run.stdout).toContain(
|
|
251
|
+
'A new check or failure code joins only in a minor release, named in the release notes.',
|
|
252
|
+
);
|
|
253
|
+
expect(run.stdout).toContain('integration verify');
|
|
254
|
+
expect(run.stdout).toContain('against the package in the current folder');
|
|
255
|
+
expect(run.stdout).not.toContain('[package]');
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it('takes no package name: one passed is an error, not a check of the current folder', async () => {
|
|
259
|
+
writePackage({id: 'acme-page'});
|
|
260
|
+
|
|
261
|
+
const run = await runCli(['integration', 'check', '@acme/widgets'], tmpDir);
|
|
262
|
+
|
|
263
|
+
expect(run.stderr).toContain('too many arguments');
|
|
264
|
+
expect(run.stdout).not.toContain('Integration check:');
|
|
265
|
+
expect(run.status).toBe(1);
|
|
266
|
+
});
|
|
267
|
+
});
|
|
@@ -8,13 +8,17 @@ export const doc = {
|
|
|
8
8
|
namespace: 'cli/commands',
|
|
9
9
|
summary: 'Author and verify an Astryx integration package',
|
|
10
10
|
description:
|
|
11
|
-
'Add contributions to your package, then check the packed package the way an app receives it. The guides start at {@link namespace:integrations}.',
|
|
12
|
-
subcommands: ['add', 'verify', 'pack'],
|
|
11
|
+
'Add contributions to your package, check them on every build with `integration check --strict`, then check the packed package the way an app receives it. The guides start at {@link namespace:integrations}.',
|
|
12
|
+
subcommands: ['add', 'check', 'verify', 'pack'],
|
|
13
13
|
examples: [
|
|
14
14
|
{
|
|
15
15
|
label: 'Add a component',
|
|
16
16
|
cli: 'astryx integration add component AcmeWidget',
|
|
17
17
|
},
|
|
18
|
+
{
|
|
19
|
+
label: 'Check the package in CI, as part of its build',
|
|
20
|
+
cli: 'astryx integration check --strict',
|
|
21
|
+
},
|
|
18
22
|
{
|
|
19
23
|
label: 'Check the package before publishing',
|
|
20
24
|
cli: 'astryx integration verify',
|
|
@@ -3,18 +3,22 @@
|
|
|
3
3
|
/** @file CLI bindings for integration authoring and package verification. */
|
|
4
4
|
|
|
5
5
|
import {integrationAdd} from '../../../api/integration/add-contribution.mjs';
|
|
6
|
+
import {integrationCheck} from '../../../api/integration/check/check.mjs';
|
|
6
7
|
import {integrationPackCheck} from '../../../api/integration/pack-check.mjs';
|
|
7
8
|
import {jsonOut} from '../../../foundation/response/json.mjs';
|
|
8
9
|
import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
|
|
9
10
|
import {NO_RESULT_SET} from '../../../foundation/debug/index.mjs';
|
|
10
|
-
import {emit, list, section, text} from '../formatters/index.mjs';
|
|
11
|
+
import {emit, list, records, section, text} from '../formatters/index.mjs';
|
|
11
12
|
import {cliError} from '../lib/cli-error.mjs';
|
|
12
13
|
import {defineCommand} from '../lib/define-command.mjs';
|
|
13
14
|
import {doc as integrationGroup} from './integration.doc.mjs';
|
|
14
15
|
import {doc as integrationAddCommand} from './integration-add.doc.mjs';
|
|
16
|
+
import {doc as integrationCheckCommand} from './integration-check.doc.mjs';
|
|
15
17
|
import {doc as integrationVerifyCommand} from './integration-verify.doc.mjs';
|
|
16
18
|
import {doc as integrationPackCommand} from './integration-pack.doc.mjs';
|
|
17
19
|
import {doc as integrationAddFn} from '../../../api/integration/integrationAdd.doc.mjs';
|
|
20
|
+
import {doc as integrationCheckFn} from '../../../api/integration/integrationCheck.doc.mjs';
|
|
21
|
+
import {printIntegrationCheckResponse} from './doctor.mjs';
|
|
18
22
|
import {doc as integrationPackCheckFn} from '../../../api/integration/integrationPackCheck.doc.mjs';
|
|
19
23
|
|
|
20
24
|
/**
|
|
@@ -88,6 +92,102 @@ async function verifyPackage(program) {
|
|
|
88
92
|
return NO_RESULT_SET;
|
|
89
93
|
}
|
|
90
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Run `integration check` and print each check as its own subcommand prints
|
|
97
|
+
* it, then one summary: each check's errors, warnings and skipped work, and
|
|
98
|
+
* what decided the exit code.
|
|
99
|
+
* @param {import('commander').Command} program
|
|
100
|
+
* @param {{strict?: boolean}} options
|
|
101
|
+
*/
|
|
102
|
+
async function checkPackage(program, options) {
|
|
103
|
+
const result = await integrationCheck({strict: options.strict === true});
|
|
104
|
+
if (program.opts().json) {
|
|
105
|
+
jsonOut(result);
|
|
106
|
+
} else {
|
|
107
|
+
const {data} = result;
|
|
108
|
+
const noPackage = data.checks[0]?.response.data.issues.some(
|
|
109
|
+
issue => issue.code === 'no_package',
|
|
110
|
+
);
|
|
111
|
+
if (noPackage) {
|
|
112
|
+
emit(
|
|
113
|
+
text(
|
|
114
|
+
'Nothing was checked: no package.json found. Run this command inside a package directory.',
|
|
115
|
+
),
|
|
116
|
+
);
|
|
117
|
+
} else if (!data.validated) {
|
|
118
|
+
emit(
|
|
119
|
+
text(
|
|
120
|
+
'Nothing was checked: no astryx.integration.* found next to package.json. ' +
|
|
121
|
+
"Run this command in an integration package's folder.",
|
|
122
|
+
),
|
|
123
|
+
);
|
|
124
|
+
} else {
|
|
125
|
+
data.checks.forEach((check, index) => {
|
|
126
|
+
// A blank line keeps each check's output apart from the next.
|
|
127
|
+
if (index > 0) emit(text(''));
|
|
128
|
+
printIntegrationCheckResponse(check.response);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const plural = (/** @type {number} */ n, /** @type {string} */ word) =>
|
|
132
|
+
`${n} ${word}${n === 1 ? '' : 's'}`;
|
|
133
|
+
const counts =
|
|
134
|
+
`${plural(data.errors, 'error')}, ${plural(data.warnings, 'warning')}, ` +
|
|
135
|
+
`${data.skipped.length} skipped`;
|
|
136
|
+
const notCompared =
|
|
137
|
+
data.unchecked > 0
|
|
138
|
+
? ` ${plural(data.unchecked, 'item')} could not be compared; the checks above list them.`
|
|
139
|
+
: '';
|
|
140
|
+
const closing = noPackage
|
|
141
|
+
? `[fail] ${counts}. No package.json was found here, so nothing was checked.`
|
|
142
|
+
: data.checks.some(check => check.failed)
|
|
143
|
+
? `[fail] ${counts}. Address the items marked [fail] above.`
|
|
144
|
+
: data.failed
|
|
145
|
+
? `[fail] ${counts}. --strict fails on every warning and on skipped work; fix them, or drop --strict to fail only on errors.`
|
|
146
|
+
: data.warnings > 0 || data.skipped.length > 0
|
|
147
|
+
? `[ok] ${counts}. No check failed; review the warnings and skipped work above (--strict fails on them).${notCompared}`
|
|
148
|
+
: notCompared
|
|
149
|
+
? `[ok] ${counts}. No check failed.${notCompared}`
|
|
150
|
+
: `[ok] ${counts}. Every check passed.`;
|
|
151
|
+
const identity = noPackage
|
|
152
|
+
? '(no package.json)'
|
|
153
|
+
: data.version != null
|
|
154
|
+
? `${data.name}@${data.version}`
|
|
155
|
+
: data.name;
|
|
156
|
+
emit(
|
|
157
|
+
// --strict lists each warning and each skipped check again, as the
|
|
158
|
+
// error it now is, in the issue format the checks use.
|
|
159
|
+
...(data.failures.length > 0
|
|
160
|
+
? [
|
|
161
|
+
section('Failing under --strict'),
|
|
162
|
+
records(data.failures, {
|
|
163
|
+
fields: [
|
|
164
|
+
'severity',
|
|
165
|
+
'check',
|
|
166
|
+
'code',
|
|
167
|
+
'component',
|
|
168
|
+
'prop',
|
|
169
|
+
'message',
|
|
170
|
+
'fix',
|
|
171
|
+
'file',
|
|
172
|
+
'line',
|
|
173
|
+
],
|
|
174
|
+
format: {severity: () => '[fail]'},
|
|
175
|
+
}),
|
|
176
|
+
]
|
|
177
|
+
: []),
|
|
178
|
+
section(
|
|
179
|
+
`Integration check: ${identity ?? '(local package)'}${data.strict ? ' (strict)' : ''}`,
|
|
180
|
+
),
|
|
181
|
+
records(data.checks, {
|
|
182
|
+
fields: ['check', 'failed', 'errors', 'warnings', 'skipped'],
|
|
183
|
+
}),
|
|
184
|
+
text(closing),
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
if (result.data.failed) process.exitCode = 1;
|
|
188
|
+
return NO_RESULT_SET;
|
|
189
|
+
}
|
|
190
|
+
|
|
91
191
|
/** @param {import('commander').Command} program */
|
|
92
192
|
export function registerIntegration(program) {
|
|
93
193
|
/** @type {import('commander').Command} */
|
|
@@ -159,6 +259,12 @@ export function registerIntegration(program) {
|
|
|
159
259
|
});
|
|
160
260
|
addCmd.allowExcessArguments(false);
|
|
161
261
|
|
|
262
|
+
// It takes no package name, so a name passed by mistake is an error, not a
|
|
263
|
+
// silent check of the current folder.
|
|
264
|
+
defineCommand(integration, integrationCheckCommand, {
|
|
265
|
+
fn: integrationCheckFn,
|
|
266
|
+
action: async options => checkPackage(program, options),
|
|
267
|
+
}).allowExcessArguments(false);
|
|
162
268
|
defineCommand(integration, integrationVerifyCommand, {
|
|
163
269
|
fn: integrationPackCheckFn,
|
|
164
270
|
action: async () => verifyPackage(program),
|
|
@@ -341,6 +341,11 @@ const CASES = [
|
|
|
341
341
|
args: ['doctor', 'integration', 'validate'],
|
|
342
342
|
skipFieldChecks: true,
|
|
343
343
|
},
|
|
344
|
+
{
|
|
345
|
+
name: 'integration check',
|
|
346
|
+
args: ['integration', 'check'],
|
|
347
|
+
skipFieldChecks: true,
|
|
348
|
+
},
|
|
344
349
|
{
|
|
345
350
|
name: 'doctor integration components',
|
|
346
351
|
args: ['doctor', 'integration', 'components'],
|
|
@@ -30,7 +30,7 @@ export const doc = {
|
|
|
30
30
|
{
|
|
31
31
|
flag: '--family',
|
|
32
32
|
description:
|
|
33
|
-
'Build the selected extension family into one keyed CSS, JS, and declaration set, written beside the family root theme file, which must be inside the working directory (ERR_PATH_TRAVERSAL). Requires --family-key; refused with --out or --watch (ERR_THEME_INVALID)',
|
|
33
|
+
'Build the selected extension family into one keyed CSS, JS, and declaration set, written beside the family root theme file, which must be inside the working directory to build (ERR_PATH_TRAVERSAL); --check only reads, so it compares outputs anywhere. Requires --family-key; refused with --out or --watch (ERR_THEME_INVALID)',
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
36
|
flag: '--family-key <key>',
|
|
@@ -41,7 +41,7 @@ export const doc = {
|
|
|
41
41
|
flag: '-o, --out <path>',
|
|
42
42
|
param: 'options.out',
|
|
43
43
|
description:
|
|
44
|
-
'Output CSS file path, relative or absolute; the .js and .d.ts are written beside it (default: <theme name>.css next to the source).
|
|
44
|
+
'Output CSS file path, relative or absolute; the .js and .d.ts are written beside it (default: <theme name>.css next to the source). A build writes only inside the working directory, the defaults beside the source too (ERR_PATH_TRAVERSAL); --check writes nothing, so it compares outputs anywhere and refuses only a relative path that escapes the working directory. Single theme only: refused with more than one file or with --family (ERR_THEME_INVALID)',
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
flag: '--icons-specifier <specifier>',
|
package/clients/cli/index.mjs
CHANGED
|
@@ -193,7 +193,7 @@ export function buildAuthoringReferenceDoc(docs) {
|
|
|
193
193
|
title: 'Authoring Reference',
|
|
194
194
|
category: 'guide',
|
|
195
195
|
description:
|
|
196
|
-
'Every file an integration author writes, field by field: the integration manifest, astryx.config, codemods, identity, and each doc type.',
|
|
196
|
+
'Every file an integration author writes, field by field: the integration manifest, astryx.config, codemods, identity, and each doc type. The step-by-step guides are under `astryx docs cli/integrations`.',
|
|
197
197
|
sections: docs.map(selfDocSection),
|
|
198
198
|
});
|
|
199
199
|
}
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
* @input Doc files with the root each was found in, the package root, and the
|
|
33
33
|
* directories to resolve `typescript` from.
|
|
34
34
|
* @output A DocTypesReport.
|
|
35
|
-
* @position
|
|
36
|
-
* and
|
|
35
|
+
* @position The check `astryx doctor integration validate` runs on an
|
|
36
|
+
* integration's docs, and the Astryx repository's test runs on Core's own.
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
39
|
import * as fs from 'node:fs';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/** @typedef {import('./doc-types.mjs').DocFile} DocFile */
|
|
5
|
+
/** @typedef {import('./doc-types.mjs').DocRoot} DocRoot */
|
|
6
|
+
/**
|
|
7
|
+
* Every doc file an integration's roots hold, each assigned to the deepest
|
|
8
|
+
* root that holds it, each root a reader could not read, and how many test
|
|
9
|
+
* fixtures no reader serves.
|
|
10
|
+
* @param {any} integration a loaded integration
|
|
11
|
+
* @returns {Promise<{files: DocFile[], unread: Array<{path: string, reason: string}>, fixtures: number}>}
|
|
12
|
+
*/
|
|
13
|
+
export function integrationDocFiles(integration: any): Promise<{
|
|
14
|
+
files: DocFile[];
|
|
15
|
+
unread: Array<{
|
|
16
|
+
path: string;
|
|
17
|
+
reason: string;
|
|
18
|
+
}>;
|
|
19
|
+
fixtures: number;
|
|
20
|
+
}>;
|
|
21
|
+
export type DocFile = import("./doc-types.mjs").DocFile;
|
|
22
|
+
export type DocRoot = import("./doc-types.mjs").DocRoot;
|