@astryxdesign/cli 0.7.2-canary.07f97c6 → 0.7.2-canary.081ccea
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 +74 -73
- package/api/build/help/help.mjs +1 -1
- package/api/component/_adapter.d.mts +72 -1
- package/api/component/_adapter.mjs +209 -7
- package/api/component/component.mjs +82 -15
- package/api/component/component.test.mjs +80 -0
- package/api/component/doc-links.test.mjs +386 -0
- package/api/component/integration-export-name.test.mjs +644 -0
- package/api/component/list/list.mjs +42 -4
- 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 +74 -0
- package/api/docs/_adapter.mjs +550 -14
- package/api/docs/integration-tree.test.mjs +22 -0
- package/api/docs/integrationDocs.test.mjs +124 -0
- package/api/docs/list/list.mjs +12 -2
- package/api/doctor/doctor.mjs +27 -3
- package/api/doctor/doctor.test.mjs +43 -0
- package/api/doctor/theme-checks.mjs +1 -1
- package/api/doctor/theme-checks.test.mjs +136 -0
- package/api/gap-report/gap-report.d.mts +3 -0
- package/api/gap-report/gap-report.doc.mjs +11 -3
- package/api/gap-report/gap-report.mjs +219 -52
- package/api/gap-report/gap-report.test.mjs +233 -0
- package/api/gap-report/gap-report.type.d.mts +41 -0
- package/api/gap-report/gap-report.type.mjs +18 -0
- package/api/index.d.mts +2 -0
- package/api/index.mjs +2 -0
- package/api/init/run/run.mjs +2 -2
- package/api/integration/_adapter.d.mts +45 -0
- package/api/integration/_adapter.mjs +112 -0
- package/api/integration/add-contribution.component-names.test.mjs +66 -0
- package/api/integration/add-contribution.mjs +8 -4
- package/api/integration/add-contribution.test.mjs +4 -2
- package/api/integration/authoring-checks.mjs +108 -4
- package/api/integration/authoring-checks.test.mjs +808 -0
- package/api/integration/authoring-checks.type.d.mts +143 -0
- package/api/integration/authoring-checks.type.mjs +74 -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 +45 -6
- package/api/integration/integrationDocConflicts.doc.mjs +22 -5
- package/api/integration/pack-check.mjs +357 -114
- package/api/integration/pack-check.test.mjs +726 -0
- package/api/integration/validate-integration-fixes.test.mjs +67 -0
- package/api/integration/validate-integration.mjs +36 -3
- package/api/integration/validate-integration.test.mjs +88 -8
- 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 +19 -3
- package/api/search/search.d.mts +81 -12
- package/api/search/search.domain-priority.test.mjs +108 -18
- package/api/search/search.integration-check.test.mjs +24 -0
- package/api/search/search.mjs +611 -54
- package/api/search/search.test.mjs +175 -0
- package/api/swizzle/copy/copy.mjs +28 -14
- package/api/template/template.test.mjs +120 -3
- package/api/theme/build/build.family.test.mjs +64 -0
- package/api/theme/build/build.mjs +180 -24
- package/api/theme/themeBuild.doc.mjs +4 -4
- package/api/upgrade/_adapter.d.mts +40 -2
- package/api/upgrade/_adapter.mjs +117 -4
- package/api/upgrade/run/cli-behind-core.test.mjs +438 -0
- package/api/upgrade/run/run.mjs +30 -1
- package/api/upgrade/status/status.d.mts +21 -5
- package/api/upgrade/status/status.mjs +45 -8
- package/api/upgrade/upgrade.doc.mjs +5 -3
- package/api/upgrade/upgrade.type.d.mts +23 -0
- package/api/upgrade/upgrade.type.mjs +16 -1
- package/assets/codemods/runner.mjs +7 -1
- package/assets/codemods/transforms/next/__tests__/migrate-list-edge-compensation-to-edge.test.mjs +120 -0
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-list-edge-compensation-to-edge.mjs +198 -0
- package/assets/discover/official-packages.json +367 -0
- package/assets/docs/README.md +10 -0
- package/assets/docs/author-a-theme.doc.mjs +3 -3
- package/assets/docs/browser-support.doc.mjs +1 -1
- package/assets/docs/getting-started.doc.mjs +3 -3
- package/assets/docs/styling-overview.doc.mjs +1 -1
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +2 -2
- package/assets/docs/theme.doc.zh.mjs +1 -1
- package/assets/docs/tree/add-a-component.doc.mjs +11 -1
- package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
- package/assets/docs/tree/add-a-topic.doc.mjs +11 -8
- 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 +201 -0
- package/assets/docs/tree/check-your-docs.doc.mjs +65 -7
- package/assets/docs/tree/checks.doc.mjs +26 -18
- package/assets/docs/tree/codemods.doc.mjs +4 -4
- package/assets/docs/tree/component-family.doc.mjs +8 -6
- package/assets/docs/tree/component-imports.doc.mjs +10 -2
- package/assets/docs/tree/components.doc.mjs +1 -1
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +30 -21
- package/assets/docs/tree/define-the-theme.doc.mjs +6 -5
- package/assets/docs/tree/describe-the-component.doc.mjs +2 -2
- 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 +3 -3
- 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/layout-spacing.doc.mjs +2 -3
- package/assets/docs/tree/layout.doc.mjs +6 -6
- package/assets/docs/tree/links.doc.mjs +6 -5
- package/assets/docs/tree/migration-setup.doc.mjs +3 -2
- package/assets/docs/tree/migration-verification.doc.mjs +0 -1
- package/assets/docs/tree/migration.doc.mjs +0 -1
- 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 +4 -4
- package/assets/docs/tree/quick-start.doc.mjs +38 -22
- 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 +6 -8
- 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 +15 -6
- 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 +5 -16
- 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 +16 -8
- package/assets/docs/tree/type-scale.doc.mjs +3 -3
- package/assets/docs/tree/upgrading.doc.mjs +4 -4
- 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 +7 -6
- package/assets/docs/tree/write-the-template-file.doc.mjs +4 -3
- package/assets/docs/use-a-theme.doc.mjs +2 -2
- package/assets/docs/working-with-ai.doc.mjs +43 -4
- package/assets/theme.template.ts +1 -1
- 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 +30 -27
- package/authoring/doctypes/component/type.ts +21 -8
- 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/hook/type.ts +4 -0
- 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.d.mts +11 -0
- package/authoring/doctypes/template/integration-template.doc.mjs +49 -0
- package/authoring/doctypes/template/parse.d.mts +6 -2
- package/authoring/doctypes/template/parse.mjs +3 -1
- package/authoring/doctypes/template/template.doc.mjs +3 -3
- package/authoring/doctypes/template/type.ts +22 -0
- 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/index.d.ts +1 -0
- package/authoring/integration/integration.doc.mjs +12 -4
- package/authoring/integration/parse.test.mjs +10 -0
- package/authoring/integration/schema.d.mts +2 -0
- package/authoring/integration/schema.mjs +1 -0
- package/authoring/integration/type.ts +4 -0
- package/clients/cli/commands/build-theme.batch-report.test.mjs +3 -1
- package/clients/cli/commands/build-theme.mjs +1 -1
- package/clients/cli/commands/build-theme.path-safety.test.mjs +224 -6
- package/clients/cli/commands/build-theme.registry.test.mjs +5 -2
- package/clients/cli/commands/cli-postinstall.test.mjs +49 -1
- 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 +18 -4
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +19 -5
- package/clients/cli/commands/doctor-integration-validate.doc.mjs +13 -2
- package/clients/cli/commands/doctor-integration.test.mjs +884 -0
- package/clients/cli/commands/doctor.mjs +281 -5
- package/clients/cli/commands/gap-report.doc.mjs +14 -2
- package/clients/cli/commands/gap-report.mjs +24 -2
- package/clients/cli/commands/gap-report.test.mjs +79 -0
- package/clients/cli/commands/integration-authoring.test.mjs +46 -0
- package/clients/cli/commands/integration-check.doc.mjs +85 -0
- package/clients/cli/commands/integration-check.test.mjs +411 -0
- package/clients/cli/commands/integration.doc.mjs +6 -2
- package/clients/cli/commands/integration.mjs +116 -5
- package/clients/cli/commands/json-contract.test.mjs +5 -1
- package/clients/cli/commands/setup-nudge.test.mjs +79 -1
- package/clients/cli/commands/swizzle.mjs +5 -3
- package/clients/cli/commands/swizzle.routing.test.mjs +18 -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/commands/upgrade.doc.mjs +14 -0
- package/clients/cli/commands/upgrade.older-cli.test.mjs +160 -0
- package/clients/cli/index.mjs +30 -5
- package/foundation/agent-docs/agent-doc-state.d.mts +14 -0
- package/foundation/agent-docs/agent-doc-state.mjs +38 -0
- package/foundation/agent-docs/agent-docs.d.mts +2 -1
- package/foundation/agent-docs/agent-docs.mjs +8 -6
- package/foundation/config/project.mjs +82 -0
- package/foundation/discovery/authoring-self-docs.mjs +2 -1
- package/foundation/discovery/component-discovery.d.mts +190 -10
- package/foundation/discovery/component-discovery.export-names.test.mjs +760 -0
- package/foundation/discovery/component-discovery.mjs +864 -56
- package/foundation/discovery/component-discovery.test.mjs +96 -0
- package/foundation/discovery/component-replacement.mjs +18 -0
- package/foundation/discovery/component-replacement.test.mjs +40 -0
- 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.d.mts +157 -0
- package/foundation/discovery/doc-types.mjs +1231 -0
- package/foundation/discovery/doc-types.test.mjs +744 -0
- package/foundation/discovery/docs-discovery.d.mts +88 -0
- package/foundation/discovery/docs-discovery.mjs +83 -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/module-exports.d.mts +27 -0
- package/foundation/discovery/module-exports.mjs +356 -31
- package/foundation/discovery/module-exports.test.mjs +172 -0
- package/foundation/discovery/package-tsconfig.d.mts +14 -0
- package/foundation/discovery/package-tsconfig.mjs +228 -0
- package/foundation/discovery/package-tsconfig.test.mjs +210 -0
- package/foundation/discovery/project-typescript.d.mts +32 -0
- package/foundation/discovery/project-typescript.mjs +89 -0
- package/foundation/discovery/prop-drift.d.mts +297 -0
- package/foundation/discovery/prop-drift.mjs +2428 -0
- package/foundation/discovery/prop-drift.test.mjs +2337 -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/discovery/template-adapter.mjs +74 -5
- package/foundation/discovery/type-match.d.mts +53 -0
- package/foundation/discovery/type-match.mjs +660 -0
- package/foundation/discovery/type-match.test.mjs +169 -0
- package/foundation/discovery/type-text.d.mts +68 -0
- package/foundation/discovery/type-text.mjs +658 -0
- package/foundation/discovery/type-text.test.mjs +196 -0
- package/foundation/discovery/unresolved-references.d.mts +62 -0
- package/foundation/discovery/unresolved-references.mjs +790 -0
- package/foundation/discovery/unresolved-references.test.mjs +567 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +31 -1
- package/foundation/doc-compiler/inputs.mjs +23 -0
- package/foundation/doc-compiler/inputs.test.mjs +0 -1
- package/foundation/doc-compiler/links.d.mts +41 -5
- package/foundation/doc-compiler/links.mjs +167 -28
- 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/env/package-manager.d.mts +32 -0
- package/foundation/env/package-manager.mjs +47 -0
- package/foundation/env/package-manager.test.mjs +194 -7
- 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 +56 -3
- package/foundation/integrations/issue.ts +6 -0
- package/foundation/integrations/validate-contributions.mjs +30 -1
- package/foundation/response/response-types.doc.mjs +15 -9
- package/foundation/xle/registry.mjs +4 -0
- package/foundation/xle/registry.test.mjs +28 -0
- package/package.json +11 -11
- package/scripts/postinstall.mjs +3 -3
|
@@ -0,0 +1,411 @@
|
|
|
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('--strict prints each finding once: its message above, its code in the failing list', async () => {
|
|
121
|
+
const id = await coreTemplateId();
|
|
122
|
+
writePackage({id});
|
|
123
|
+
|
|
124
|
+
const run = await runCli(['integration', 'check', '--strict'], tmpDir);
|
|
125
|
+
const json = await runCli(
|
|
126
|
+
['integration', 'check', '--strict', '--json'],
|
|
127
|
+
tmpDir,
|
|
128
|
+
);
|
|
129
|
+
const [failure] = JSON.parse(json.stdout.trim()).data.failures;
|
|
130
|
+
|
|
131
|
+
expect(run.stdout.split(failure.message).length - 1).toBe(1);
|
|
132
|
+
expect(
|
|
133
|
+
run.stdout.slice(run.stdout.indexOf('Failing under --strict')),
|
|
134
|
+
).toContain('template_id_conflict');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('--json carries each check with its own envelope, the --strict failures, and exits as the text does', async () => {
|
|
138
|
+
const id = await coreTemplateId();
|
|
139
|
+
writePackage({id});
|
|
140
|
+
|
|
141
|
+
const run = await runCli(
|
|
142
|
+
['integration', 'check', '--strict', '--json'],
|
|
143
|
+
tmpDir,
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
const parsed = JSON.parse(run.stdout.trim());
|
|
147
|
+
expect(parsed.type).toBe('integration.check');
|
|
148
|
+
expect(parsed.data).toMatchObject({
|
|
149
|
+
validated: true,
|
|
150
|
+
name: '@acme/widgets',
|
|
151
|
+
version: '1.2.3',
|
|
152
|
+
strict: true,
|
|
153
|
+
errors: 0,
|
|
154
|
+
warnings: 1,
|
|
155
|
+
skipped: [],
|
|
156
|
+
failed: true,
|
|
157
|
+
});
|
|
158
|
+
expect(parsed.data.checks.map(check => check.check)).toEqual([
|
|
159
|
+
'validate',
|
|
160
|
+
'components',
|
|
161
|
+
'templates',
|
|
162
|
+
'docs',
|
|
163
|
+
]);
|
|
164
|
+
const templates = parsed.data.checks[2];
|
|
165
|
+
expect(templates).toMatchObject({
|
|
166
|
+
check: 'templates',
|
|
167
|
+
errors: 0,
|
|
168
|
+
warnings: 1,
|
|
169
|
+
skipped: [],
|
|
170
|
+
failed: false,
|
|
171
|
+
response: {
|
|
172
|
+
type: 'integration.template-conflicts',
|
|
173
|
+
data: {conflicts: [expect.objectContaining({id, severity: 'warning'})]},
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
expect(parsed.data.failures).toEqual([
|
|
177
|
+
{
|
|
178
|
+
check: 'templates',
|
|
179
|
+
severity: 'error',
|
|
180
|
+
code: 'template_id_conflict',
|
|
181
|
+
message: templates.response.data.conflicts[0].message,
|
|
182
|
+
},
|
|
183
|
+
]);
|
|
184
|
+
expect(run.status).toBe(1);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it('exits 1 without --strict when one check fails on its own, and lists no failures', async () => {
|
|
188
|
+
writePackage({id: 'acme-app-shell', replaces: 'missing-core-shell'});
|
|
189
|
+
|
|
190
|
+
const text = await runCli(['integration', 'check'], tmpDir);
|
|
191
|
+
const json = await runCli(['integration', 'check', '--json'], tmpDir);
|
|
192
|
+
|
|
193
|
+
expect(text.stdout).toContain('missing_template_replacement_target');
|
|
194
|
+
expect(text.stdout).toMatch(
|
|
195
|
+
/\[fail\] [1-9]\d* errors?, .*Address the items marked \[fail\] above\./,
|
|
196
|
+
);
|
|
197
|
+
expect(text.stdout).not.toContain('Failing under --strict');
|
|
198
|
+
expect(JSON.parse(json.stdout.trim()).data).toMatchObject({
|
|
199
|
+
strict: false,
|
|
200
|
+
failures: [],
|
|
201
|
+
failed: true,
|
|
202
|
+
});
|
|
203
|
+
expect(text.status).toBe(1);
|
|
204
|
+
expect(json.status).toBe(1);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('counts a package with no manifest as skipped work: exit 0, and 1 with --strict', async () => {
|
|
208
|
+
fs.writeFileSync(
|
|
209
|
+
path.join(tmpDir, 'package.json'),
|
|
210
|
+
JSON.stringify({name: '@acme/plain', version: '1.0.0'}),
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
const loose = await runCli(['integration', 'check'], tmpDir);
|
|
214
|
+
expect(loose.stdout).toContain(
|
|
215
|
+
"Nothing was checked: no astryx.integration.* found next to package.json. Run this command in an integration package's folder.",
|
|
216
|
+
);
|
|
217
|
+
// One cause, however many checks it stops: counted once.
|
|
218
|
+
expect(loose.stdout).toContain('[ok] 0 errors, 0 warnings, 1 skipped.');
|
|
219
|
+
expect(loose.status).toBe(0);
|
|
220
|
+
|
|
221
|
+
const strict = await runCli(
|
|
222
|
+
['integration', 'check', '--strict', '--json'],
|
|
223
|
+
tmpDir,
|
|
224
|
+
);
|
|
225
|
+
const {data} = JSON.parse(strict.stdout.trim());
|
|
226
|
+
expect(data).toMatchObject({validated: false, errors: 0, failed: true});
|
|
227
|
+
// One cause, however many checks it stops: listed once.
|
|
228
|
+
expect(data.failures).toEqual([
|
|
229
|
+
{
|
|
230
|
+
check: 'validate',
|
|
231
|
+
severity: 'error',
|
|
232
|
+
code: 'missing_manifest',
|
|
233
|
+
message:
|
|
234
|
+
'No astryx.integration.* found next to package.json, so nothing was checked.',
|
|
235
|
+
},
|
|
236
|
+
]);
|
|
237
|
+
expect(strict.status).toBe(1);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it('exits 1 for no package.json, as validate does', async () => {
|
|
241
|
+
const empty = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-no-pkg-'));
|
|
242
|
+
try {
|
|
243
|
+
const run = await runCli(['integration', 'check'], empty);
|
|
244
|
+
expect(run.stdout).toContain(
|
|
245
|
+
'Nothing was checked: no package.json found.',
|
|
246
|
+
);
|
|
247
|
+
expect(run.stdout).toContain('Integration check: (no package.json)');
|
|
248
|
+
expect(run.stdout).toContain(
|
|
249
|
+
'[fail] 1 error, 0 warnings, 0 skipped. No package.json was found here, so nothing was checked.',
|
|
250
|
+
);
|
|
251
|
+
expect(run.stdout).not.toContain('marked [fail] above');
|
|
252
|
+
expect(run.status).toBe(1);
|
|
253
|
+
} finally {
|
|
254
|
+
fs.rmSync(empty, {recursive: true, force: true});
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it('states in its help that it is the CI check, the line to add, and what --strict promises', async () => {
|
|
259
|
+
const run = await runCli(['integration', 'check', '--help'], tmpDir);
|
|
260
|
+
|
|
261
|
+
expect(run.stdout).toContain(
|
|
262
|
+
"The CI check for an integration package's own build",
|
|
263
|
+
);
|
|
264
|
+
expect(run.stdout).toContain(
|
|
265
|
+
'"typecheck": "tsc --noEmit && astryx integration check --strict"',
|
|
266
|
+
);
|
|
267
|
+
expect(run.stdout).toContain(
|
|
268
|
+
'A new check or failure code joins only in a minor release, named in the release notes.',
|
|
269
|
+
);
|
|
270
|
+
expect(run.stdout).toContain('integration verify');
|
|
271
|
+
expect(run.stdout).toContain('against the package in the current folder');
|
|
272
|
+
expect(run.stdout).not.toContain('[package]');
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
it('takes no package name: one passed is an error, not a check of the current folder', async () => {
|
|
276
|
+
writePackage({id: 'acme-page'});
|
|
277
|
+
|
|
278
|
+
const run = await runCli(['integration', 'check', '@acme/widgets'], tmpDir);
|
|
279
|
+
|
|
280
|
+
expect(run.stderr).toContain('too many arguments');
|
|
281
|
+
expect(run.stdout).not.toContain('Integration check:');
|
|
282
|
+
expect(run.status).toBe(1);
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
describe('a copied passage', () => {
|
|
287
|
+
const passage =
|
|
288
|
+
'Themes cannot style the layer that holds a menu or a popover, so a menu ' +
|
|
289
|
+
'keeps the default surface color until the next release adds a token for it.';
|
|
290
|
+
|
|
291
|
+
function writeCopiedDocs() {
|
|
292
|
+
fs.writeFileSync(
|
|
293
|
+
path.join(tmpDir, 'package.json'),
|
|
294
|
+
JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
|
|
295
|
+
);
|
|
296
|
+
fs.writeFileSync(
|
|
297
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
298
|
+
`export default {docs: './docs'};\n`,
|
|
299
|
+
);
|
|
300
|
+
fs.mkdirSync(path.join(tmpDir, 'docs'));
|
|
301
|
+
for (const name of ['acme-setup', 'acme-menus']) {
|
|
302
|
+
const doc = {
|
|
303
|
+
type: 'generic',
|
|
304
|
+
name,
|
|
305
|
+
title: 'Fixture',
|
|
306
|
+
description: 'Fixture topic.',
|
|
307
|
+
sections: [
|
|
308
|
+
{title: 'Overview', content: [{type: 'prose', text: passage}]},
|
|
309
|
+
],
|
|
310
|
+
};
|
|
311
|
+
fs.writeFileSync(
|
|
312
|
+
path.join(tmpDir, 'docs', `${name}.doc.mjs`),
|
|
313
|
+
`export default ${JSON.stringify(doc)};\n`,
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
it('keeps doctor integration docs at exit 0, and fails integration check --strict', async () => {
|
|
319
|
+
writeCopiedDocs();
|
|
320
|
+
|
|
321
|
+
const doctor = await runCli(['doctor', 'integration', 'docs'], tmpDir);
|
|
322
|
+
expect(doctor.status).toBe(0);
|
|
323
|
+
expect(doctor.stdout).toContain('1 copied passage(s)');
|
|
324
|
+
|
|
325
|
+
const loose = await runCli(['integration', 'check'], tmpDir);
|
|
326
|
+
expect(loose.status).toBe(0);
|
|
327
|
+
|
|
328
|
+
const strict = await runCli(['integration', 'check', '--strict'], tmpDir);
|
|
329
|
+
expect(strict.status).toBe(1);
|
|
330
|
+
expect(strict.stdout).toContain('copied_passage');
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
describe('a padding phrase', () => {
|
|
335
|
+
it('keeps doctor integration docs at exit 0, and fails integration check --strict', async () => {
|
|
336
|
+
fs.writeFileSync(
|
|
337
|
+
path.join(tmpDir, 'package.json'),
|
|
338
|
+
JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
|
|
339
|
+
);
|
|
340
|
+
fs.writeFileSync(
|
|
341
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
342
|
+
`export default {docs: './docs'};\n`,
|
|
343
|
+
);
|
|
344
|
+
fs.mkdirSync(path.join(tmpDir, 'docs'));
|
|
345
|
+
const doc = {
|
|
346
|
+
type: 'generic',
|
|
347
|
+
name: 'acme-setup',
|
|
348
|
+
title: 'Fixture',
|
|
349
|
+
description: 'Fixture topic.',
|
|
350
|
+
sections: [
|
|
351
|
+
{
|
|
352
|
+
title: 'Overview',
|
|
353
|
+
content: [{type: 'prose', text: 'In order to start, run the setup.'}],
|
|
354
|
+
},
|
|
355
|
+
],
|
|
356
|
+
};
|
|
357
|
+
fs.writeFileSync(
|
|
358
|
+
path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
|
|
359
|
+
`export default ${JSON.stringify(doc)};\n`,
|
|
360
|
+
);
|
|
361
|
+
|
|
362
|
+
const doctor = await runCli(['doctor', 'integration', 'docs'], tmpDir);
|
|
363
|
+
expect(doctor.status).toBe(0);
|
|
364
|
+
expect(doctor.stdout).toContain('1 fluff finding(s)');
|
|
365
|
+
|
|
366
|
+
const strict = await runCli(['integration', 'check', '--strict'], tmpDir);
|
|
367
|
+
expect(strict.status).toBe(1);
|
|
368
|
+
expect(strict.stdout).toContain('doc_fluff');
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
describe('a stray doc pointer', () => {
|
|
373
|
+
it('keeps doctor integration docs at exit 0, and fails integration check --strict', async () => {
|
|
374
|
+
fs.writeFileSync(
|
|
375
|
+
path.join(tmpDir, 'package.json'),
|
|
376
|
+
JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
|
|
377
|
+
);
|
|
378
|
+
fs.writeFileSync(
|
|
379
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
380
|
+
`export default {docs: './docs'};\n`,
|
|
381
|
+
);
|
|
382
|
+
fs.mkdirSync(path.join(tmpDir, 'docs'));
|
|
383
|
+
const doc = {
|
|
384
|
+
type: 'generic',
|
|
385
|
+
name: 'acme-setup',
|
|
386
|
+
title: 'Fixture',
|
|
387
|
+
description: 'Fixture topic.',
|
|
388
|
+
sections: [
|
|
389
|
+
{
|
|
390
|
+
title: 'Overview',
|
|
391
|
+
content: [
|
|
392
|
+
{type: 'prose', text: 'The theme is in `astryx docs theme`.'},
|
|
393
|
+
],
|
|
394
|
+
},
|
|
395
|
+
],
|
|
396
|
+
};
|
|
397
|
+
fs.writeFileSync(
|
|
398
|
+
path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
|
|
399
|
+
`export default ${JSON.stringify(doc)};\n`,
|
|
400
|
+
);
|
|
401
|
+
|
|
402
|
+
const doctor = await runCli(['doctor', 'integration', 'docs'], tmpDir);
|
|
403
|
+
expect(doctor.status).toBe(0);
|
|
404
|
+
expect(doctor.stdout).toContain('1 stray doc pointer(s)');
|
|
405
|
+
expect(doctor.stdout).toContain('{@link @astryxdesign/cli:generic:theme}');
|
|
406
|
+
|
|
407
|
+
const strict = await runCli(['integration', 'check', '--strict'], tmpDir);
|
|
408
|
+
expect(strict.status).toBe(1);
|
|
409
|
+
expect(strict.stdout).toContain('stray_doc_pointer');
|
|
410
|
+
});
|
|
411
|
+
});
|
|
@@ -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
|
/**
|
|
@@ -75,10 +79,16 @@ async function verifyPackage(program) {
|
|
|
75
79
|
if (issues.length > 0) {
|
|
76
80
|
blocks.push(
|
|
77
81
|
list(
|
|
78
|
-
issues.map(
|
|
79
|
-
issue
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
issues.map(issue => [
|
|
83
|
+
`[${issue.severity === 'error' ? 'fail' : 'warn'}] ${issue.message}`,
|
|
84
|
+
// Every field the JSON issue carries.
|
|
85
|
+
...(issue.file != null
|
|
86
|
+
? [
|
|
87
|
+
`file: ${issue.file}${issue.line != null ? `:${issue.line}` : ''}`,
|
|
88
|
+
]
|
|
89
|
+
: []),
|
|
90
|
+
...(issue.fix != null ? [`fix: ${issue.fix}`] : []),
|
|
91
|
+
]),
|
|
82
92
|
),
|
|
83
93
|
);
|
|
84
94
|
}
|
|
@@ -88,6 +98,101 @@ async function verifyPackage(program) {
|
|
|
88
98
|
return NO_RESULT_SET;
|
|
89
99
|
}
|
|
90
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Run `integration check` and print each check as its own subcommand prints
|
|
103
|
+
* it, then one summary: each check's errors, warnings and skipped work, and
|
|
104
|
+
* what decided the exit code.
|
|
105
|
+
* @param {import('commander').Command} program
|
|
106
|
+
* @param {{strict?: boolean}} options
|
|
107
|
+
*/
|
|
108
|
+
async function checkPackage(program, options) {
|
|
109
|
+
const result = await integrationCheck({strict: options.strict === true});
|
|
110
|
+
if (program.opts().json) {
|
|
111
|
+
jsonOut(result);
|
|
112
|
+
} else {
|
|
113
|
+
const {data} = result;
|
|
114
|
+
const noPackage = data.checks[0]?.response.data.issues.some(
|
|
115
|
+
issue => issue.code === 'no_package',
|
|
116
|
+
);
|
|
117
|
+
if (noPackage) {
|
|
118
|
+
emit(
|
|
119
|
+
text(
|
|
120
|
+
'Nothing was checked: no package.json found. Run this command inside a package directory.',
|
|
121
|
+
),
|
|
122
|
+
);
|
|
123
|
+
} else if (!data.validated) {
|
|
124
|
+
emit(
|
|
125
|
+
text(
|
|
126
|
+
'Nothing was checked: no astryx.integration.* found next to package.json. ' +
|
|
127
|
+
"Run this command in an integration package's folder.",
|
|
128
|
+
),
|
|
129
|
+
);
|
|
130
|
+
} else {
|
|
131
|
+
data.checks.forEach((check, index) => {
|
|
132
|
+
// A blank line keeps each check's output apart from the next.
|
|
133
|
+
if (index > 0) emit(text(''));
|
|
134
|
+
printIntegrationCheckResponse(check.response);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
const plural = (/** @type {number} */ n, /** @type {string} */ word) =>
|
|
138
|
+
`${n} ${word}${n === 1 ? '' : 's'}`;
|
|
139
|
+
const counts =
|
|
140
|
+
`${plural(data.errors, 'error')}, ${plural(data.warnings, 'warning')}, ` +
|
|
141
|
+
`${data.skipped.length} skipped`;
|
|
142
|
+
const notCompared =
|
|
143
|
+
data.unchecked > 0
|
|
144
|
+
? ` ${plural(data.unchecked, 'item')} could not be compared; the checks above list them.`
|
|
145
|
+
: '';
|
|
146
|
+
const closing = noPackage
|
|
147
|
+
? `[fail] ${counts}. No package.json was found here, so nothing was checked.`
|
|
148
|
+
: data.checks.some(check => check.failed)
|
|
149
|
+
? `[fail] ${counts}. Address the items marked [fail] above.`
|
|
150
|
+
: data.failed
|
|
151
|
+
? `[fail] ${counts}. --strict fails on every warning and on skipped work; fix them, or drop --strict to fail only on errors.`
|
|
152
|
+
: data.warnings > 0 || data.skipped.length > 0
|
|
153
|
+
? `[ok] ${counts}. No check failed; review the warnings and skipped work above (--strict fails on them).${notCompared}`
|
|
154
|
+
: notCompared
|
|
155
|
+
? `[ok] ${counts}. No check failed.${notCompared}`
|
|
156
|
+
: `[ok] ${counts}. Every check passed.`;
|
|
157
|
+
const identity = noPackage
|
|
158
|
+
? '(no package.json)'
|
|
159
|
+
: data.version != null
|
|
160
|
+
? `${data.name}@${data.version}`
|
|
161
|
+
: data.name;
|
|
162
|
+
emit(
|
|
163
|
+
// --strict lists each warning and each skipped check again, as the
|
|
164
|
+
// error it now is: by check, code and place only, since the check's own
|
|
165
|
+
// output above already printed its message and fix once.
|
|
166
|
+
...(data.failures.length > 0
|
|
167
|
+
? [
|
|
168
|
+
section('Failing under --strict'),
|
|
169
|
+
records(data.failures, {
|
|
170
|
+
fields: [
|
|
171
|
+
'severity',
|
|
172
|
+
'check',
|
|
173
|
+
'code',
|
|
174
|
+
'component',
|
|
175
|
+
'prop',
|
|
176
|
+
'file',
|
|
177
|
+
'line',
|
|
178
|
+
],
|
|
179
|
+
format: {severity: () => '[fail]'},
|
|
180
|
+
}),
|
|
181
|
+
]
|
|
182
|
+
: []),
|
|
183
|
+
section(
|
|
184
|
+
`Integration check: ${identity ?? '(local package)'}${data.strict ? ' (strict)' : ''}`,
|
|
185
|
+
),
|
|
186
|
+
records(data.checks, {
|
|
187
|
+
fields: ['check', 'failed', 'errors', 'warnings', 'skipped'],
|
|
188
|
+
}),
|
|
189
|
+
text(closing),
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
if (result.data.failed) process.exitCode = 1;
|
|
193
|
+
return NO_RESULT_SET;
|
|
194
|
+
}
|
|
195
|
+
|
|
91
196
|
/** @param {import('commander').Command} program */
|
|
92
197
|
export function registerIntegration(program) {
|
|
93
198
|
/** @type {import('commander').Command} */
|
|
@@ -159,6 +264,12 @@ export function registerIntegration(program) {
|
|
|
159
264
|
});
|
|
160
265
|
addCmd.allowExcessArguments(false);
|
|
161
266
|
|
|
267
|
+
// It takes no package name, so a name passed by mistake is an error, not a
|
|
268
|
+
// silent check of the current folder.
|
|
269
|
+
defineCommand(integration, integrationCheckCommand, {
|
|
270
|
+
fn: integrationCheckFn,
|
|
271
|
+
action: async options => checkPackage(program, options),
|
|
272
|
+
}).allowExcessArguments(false);
|
|
162
273
|
defineCommand(integration, integrationVerifyCommand, {
|
|
163
274
|
fn: integrationPackCheckFn,
|
|
164
275
|
action: async () => verifyPackage(program),
|
|
@@ -143,7 +143,11 @@ describe('--json contract: supported commands emit valid envelopes', () => {
|
|
|
143
143
|
const parsed = parseJson(stdout);
|
|
144
144
|
expect(parsed.type).toBe('discover.list');
|
|
145
145
|
expect(parsed.data).toEqual([]);
|
|
146
|
-
expect(parsed.meta).
|
|
146
|
+
expect(parsed.meta.configured).toBe(false);
|
|
147
|
+
// The official list the CLI carries is always a source.
|
|
148
|
+
expect(parsed.meta.sources).toEqual([
|
|
149
|
+
expect.objectContaining({name: 'Astryx', status: 'fresh'}),
|
|
150
|
+
]);
|
|
147
151
|
});
|
|
148
152
|
|
|
149
153
|
it('astryx template --json emits a typed envelope', async () => {
|