@astryxdesign/cli 0.7.2-canary.a7d26b7 → 0.7.2-canary.acfd1ff
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/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/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 +11 -0
- package/api/docs/_adapter.mjs +244 -1
- package/api/docs/integrationDocs.test.mjs +124 -0
- 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 +152 -48
- 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 +32 -0
- package/api/integration/_adapter.mjs +80 -0
- package/api/integration/add-contribution.mjs +1 -1
- package/api/integration/add-contribution.test.mjs +4 -2
- package/api/integration/authoring-checks.mjs +44 -4
- package/api/integration/authoring-checks.test.mjs +515 -0
- package/api/integration/authoring-checks.type.d.mts +95 -0
- package/api/integration/authoring-checks.type.mjs +53 -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 +43 -6
- package/api/integration/integrationDocConflicts.doc.mjs +19 -5
- package/api/integration/pack-check.mjs +292 -7
- package/api/integration/pack-check.test.mjs +367 -0
- package/api/integration/validate-integration-fixes.test.mjs +67 -0
- package/api/integration/validate-integration.mjs +8 -0
- package/api/integration/validate-integration.test.mjs +41 -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 +19 -3
- package/api/search/search.d.mts +72 -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 +501 -37
- package/api/search/search.test.mjs +139 -0
- package/api/theme/build/build.family.test.mjs +54 -6
- package/api/theme/build/build.mjs +114 -17
- 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/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 +1 -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 +196 -0
- package/assets/docs/tree/check-your-docs.doc.mjs +61 -7
- package/assets/docs/tree/checks.doc.mjs +25 -17
- 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 +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 +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/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 +14 -5
- 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 +8 -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 +6 -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/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 +29 -26
- 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.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 +155 -21
- 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 +17 -4
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +18 -5
- package/clients/cli/commands/doctor-integration-validate.doc.mjs +13 -2
- package/clients/cli/commands/doctor-integration.test.mjs +837 -0
- package/clients/cli/commands/doctor.mjs +250 -3
- 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-check.doc.mjs +85 -0
- package/clients/cli/commands/integration-check.test.mjs +370 -0
- package/clients/cli/commands/integration.doc.mjs +6 -2
- package/clients/cli/commands/integration.mjs +106 -1
- 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 +18 -0
- package/foundation/discovery/component-discovery.mjs +2 -2
- 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-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 +1224 -0
- package/foundation/discovery/doc-types.test.mjs +700 -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/project-typescript.d.mts +11 -2
- package/foundation/discovery/project-typescript.mjs +32 -4
- package/foundation/discovery/prop-drift.d.mts +278 -0
- package/foundation/discovery/prop-drift.mjs +2263 -0
- package/foundation/discovery/prop-drift.test.mjs +2272 -0
- 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/doc-compiler/doc-loads.test.mjs +16 -2
- package/foundation/doc-compiler/links.d.mts +9 -5
- package/foundation/doc-compiler/links.mjs +4 -2
- 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 +50 -2
- package/foundation/integrations/validate-contributions.mjs +30 -1
- package/foundation/response/response-types.doc.mjs +14 -8
- package/package.json +11 -11
- package/scripts/postinstall.mjs +3 -3
|
@@ -0,0 +1,370 @@
|
|
|
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
|
+
});
|
|
@@ -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,101 @@ 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: by check, code and place only, since the check's own
|
|
159
|
+
// output above already printed its message and fix once.
|
|
160
|
+
...(data.failures.length > 0
|
|
161
|
+
? [
|
|
162
|
+
section('Failing under --strict'),
|
|
163
|
+
records(data.failures, {
|
|
164
|
+
fields: [
|
|
165
|
+
'severity',
|
|
166
|
+
'check',
|
|
167
|
+
'code',
|
|
168
|
+
'component',
|
|
169
|
+
'prop',
|
|
170
|
+
'file',
|
|
171
|
+
'line',
|
|
172
|
+
],
|
|
173
|
+
format: {severity: () => '[fail]'},
|
|
174
|
+
}),
|
|
175
|
+
]
|
|
176
|
+
: []),
|
|
177
|
+
section(
|
|
178
|
+
`Integration check: ${identity ?? '(local package)'}${data.strict ? ' (strict)' : ''}`,
|
|
179
|
+
),
|
|
180
|
+
records(data.checks, {
|
|
181
|
+
fields: ['check', 'failed', 'errors', 'warnings', 'skipped'],
|
|
182
|
+
}),
|
|
183
|
+
text(closing),
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
if (result.data.failed) process.exitCode = 1;
|
|
187
|
+
return NO_RESULT_SET;
|
|
188
|
+
}
|
|
189
|
+
|
|
91
190
|
/** @param {import('commander').Command} program */
|
|
92
191
|
export function registerIntegration(program) {
|
|
93
192
|
/** @type {import('commander').Command} */
|
|
@@ -159,6 +258,12 @@ export function registerIntegration(program) {
|
|
|
159
258
|
});
|
|
160
259
|
addCmd.allowExcessArguments(false);
|
|
161
260
|
|
|
261
|
+
// It takes no package name, so a name passed by mistake is an error, not a
|
|
262
|
+
// silent check of the current folder.
|
|
263
|
+
defineCommand(integration, integrationCheckCommand, {
|
|
264
|
+
fn: integrationCheckFn,
|
|
265
|
+
action: async options => checkPackage(program, options),
|
|
266
|
+
}).allowExcessArguments(false);
|
|
162
267
|
defineCommand(integration, integrationVerifyCommand, {
|
|
163
268
|
fn: integrationPackCheckFn,
|
|
164
269
|
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 () => {
|
|
@@ -16,9 +16,24 @@ import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
|
16
16
|
import * as fs from 'node:fs';
|
|
17
17
|
import * as path from 'node:path';
|
|
18
18
|
import * as os from 'node:os';
|
|
19
|
-
import {
|
|
19
|
+
import {fileURLToPath} from 'node:url';
|
|
20
|
+
import {
|
|
21
|
+
isAstryxInitialized,
|
|
22
|
+
isAstryxPromptInReach,
|
|
23
|
+
} from '../../../foundation/agent-docs/agent-docs.mjs';
|
|
20
24
|
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
21
25
|
|
|
26
|
+
/** This source checkout: the tests run the CLI from it. */
|
|
27
|
+
const REPO = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../..');
|
|
28
|
+
|
|
29
|
+
/** Is `dir` inside a git repository? The temp folder normally is not. */
|
|
30
|
+
function insideRepository(dir) {
|
|
31
|
+
for (let d = path.resolve(dir); ; d = path.dirname(d)) {
|
|
32
|
+
if (fs.existsSync(path.join(d, '.git'))) return true;
|
|
33
|
+
if (path.dirname(d) === d) return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
22
37
|
const MARKER = '<!-- ASTRYX:START -->';
|
|
23
38
|
const NUDGE = /finish setup and install the Astryx agent prompt/;
|
|
24
39
|
|
|
@@ -61,6 +76,41 @@ describe('isAstryxInitialized — centralized setup check (one place)', () => {
|
|
|
61
76
|
});
|
|
62
77
|
});
|
|
63
78
|
|
|
79
|
+
// Agents read the agent docs between the repository root and the folder they
|
|
80
|
+
// work in, so a monorepo initialized at its root is set up in every package.
|
|
81
|
+
describe('isAstryxPromptInReach — up to the repository root', () => {
|
|
82
|
+
it('finds init\'s block at the repository root from a workspace package', () => {
|
|
83
|
+
fs.mkdirSync(path.join(tmp, '.git'));
|
|
84
|
+
write('AGENTS.md', MARKER);
|
|
85
|
+
write('packages/app/package.json', '{"name":"app"}');
|
|
86
|
+
expect(isAstryxPromptInReach(path.join(tmp, 'packages/app'))).toBe(true);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('treats a worktree .git file as the repository root', () => {
|
|
90
|
+
write('.git', 'gitdir: /elsewhere\n');
|
|
91
|
+
write('CLAUDE.md', MARKER);
|
|
92
|
+
write('packages/app/package.json', '{"name":"app"}');
|
|
93
|
+
expect(isAstryxPromptInReach(path.join(tmp, 'packages/app'))).toBe(true);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('does not look above the repository root', () => {
|
|
97
|
+
write('AGENTS.md', MARKER);
|
|
98
|
+
fs.mkdirSync(path.join(tmp, 'repo/.git'), {recursive: true});
|
|
99
|
+
write('repo/pkg/package.json', '{"name":"pkg"}');
|
|
100
|
+
expect(isAstryxPromptInReach(path.join(tmp, 'repo/pkg'))).toBe(false);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it.skipIf(insideRepository(os.tmpdir()))(
|
|
104
|
+
'checks only the folder itself outside a repository',
|
|
105
|
+
() => {
|
|
106
|
+
write('AGENTS.md', MARKER);
|
|
107
|
+
write('pkg/package.json', '{"name":"pkg"}');
|
|
108
|
+
expect(isAstryxPromptInReach(tmp)).toBe(true);
|
|
109
|
+
expect(isAstryxPromptInReach(path.join(tmp, 'pkg'))).toBe(false);
|
|
110
|
+
},
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
|
|
64
114
|
describe('enforcement layer 3 — per-command setup nudge', () => {
|
|
65
115
|
const asProject = () => write('package.json', '{"name":"t"}');
|
|
66
116
|
|
|
@@ -99,4 +149,32 @@ describe('enforcement layer 3 — per-command setup nudge', () => {
|
|
|
99
149
|
asProject();
|
|
100
150
|
expect((await runCli(['init'], tmp)).stderr).not.toMatch(NUDGE);
|
|
101
151
|
});
|
|
152
|
+
|
|
153
|
+
it('is quiet in a workspace package when init\'s block is at the repository root', async () => {
|
|
154
|
+
fs.mkdirSync(path.join(tmp, '.git'));
|
|
155
|
+
write('AGENTS.md', MARKER);
|
|
156
|
+
write('packages/app/package.json', '{"name":"app"}');
|
|
157
|
+
const r = await runCli(['docs', 'tokens'], path.join(tmp, 'packages/app'));
|
|
158
|
+
expect(r.stderr).not.toMatch(NUDGE);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('still nudges in a workspace package with no block up to the repository root', async () => {
|
|
162
|
+
fs.mkdirSync(path.join(tmp, '.git'));
|
|
163
|
+
write('AGENTS.md', 'project notes, no astryx block');
|
|
164
|
+
write('packages/app/package.json', '{"name":"app"}');
|
|
165
|
+
const r = await runCli(['docs', 'tokens'], path.join(tmp, 'packages/app'));
|
|
166
|
+
expect(r.stderr).toMatch(NUDGE);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// The tests run the CLI from this checkout, so a project inside it is the
|
|
170
|
+
// contributor flow. The same project in the temp folder nudges (above).
|
|
171
|
+
it('is quiet inside the source checkout the CLI runs from', async () => {
|
|
172
|
+
const inside = fs.mkdtempSync(path.join(REPO, '.astryx-setup-nudge-'));
|
|
173
|
+
try {
|
|
174
|
+
fs.writeFileSync(path.join(inside, 'package.json'), '{"name":"t"}');
|
|
175
|
+
expect((await runCli(['docs', 'tokens'], inside)).stderr).not.toMatch(NUDGE);
|
|
176
|
+
} finally {
|
|
177
|
+
fs.rmSync(inside, {recursive: true, force: true});
|
|
178
|
+
}
|
|
179
|
+
});
|
|
102
180
|
});
|
|
@@ -91,14 +91,16 @@ export function registerSwizzle(program) {
|
|
|
91
91
|
),
|
|
92
92
|
];
|
|
93
93
|
|
|
94
|
-
// StyleX build requirement — swizzled StyleX source
|
|
95
|
-
//
|
|
94
|
+
// StyleX build requirement — swizzled StyleX source throws on import
|
|
95
|
+
// ("Unexpected 'stylex.create' call at runtime") unless the consumer's
|
|
96
|
+
// build runs a StyleX compiler, so the page does not render at all.
|
|
96
97
|
if (usesStyleX) {
|
|
97
98
|
out.push(
|
|
98
99
|
text(
|
|
99
100
|
[
|
|
100
101
|
`${WARN} These components use StyleX and require a StyleX compiler in your build.`,
|
|
101
|
-
|
|
102
|
+
` Without one, importing them throws "Unexpected 'stylex.create' call at runtime"`,
|
|
103
|
+
' and the page does not render. See setup per framework:',
|
|
102
104
|
` ${run} docs styling`,
|
|
103
105
|
' Next.js note: the StyleX Babel plugin disables SWC and breaks next/font -',
|
|
104
106
|
' use an SWC-based StyleX transform instead (covered in the guide).',
|