@astryxdesign/cli 0.6.5-canary.cc06b18 → 0.6.5-canary.d11d49e
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/api/gap-report/gap-report.d.mts +1 -3
- package/api/gap-report/gap-report.mjs +2 -12
- package/api/gap-report/gap-report.test.mjs +0 -106
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
- package/clients/cli/commands/gap-report.mjs +0 -12
- package/clients/cli/commands/gap-report.test.mjs +0 -63
- package/package.json +9 -9
|
@@ -4,9 +4,7 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Collect the effective handler set in delivery order: project config first,
|
|
6
6
|
* then integrations in config order. Valid handlers dedupe by handle identity;
|
|
7
|
-
* malformed integration exports
|
|
8
|
-
* their position as failed deliveries. An unloadable integration may export a
|
|
9
|
-
* handler, so it never counts as an empty set that enables the fallback.
|
|
7
|
+
* malformed integration exports retain their position as failed deliveries.
|
|
10
8
|
*
|
|
11
9
|
* @param {Project} project
|
|
12
10
|
* @returns {HandlerEntry[]}
|
|
@@ -189,9 +189,7 @@ async function selectTarget(project, component, packageName) {
|
|
|
189
189
|
/**
|
|
190
190
|
* Collect the effective handler set in delivery order: project config first,
|
|
191
191
|
* then integrations in config order. Valid handlers dedupe by handle identity;
|
|
192
|
-
* malformed integration exports
|
|
193
|
-
* their position as failed deliveries. An unloadable integration may export a
|
|
194
|
-
* handler, so it never counts as an empty set that enables the fallback.
|
|
192
|
+
* malformed integration exports retain their position as failed deliveries.
|
|
195
193
|
*
|
|
196
194
|
* @param {Project} project
|
|
197
195
|
* @returns {HandlerEntry[]}
|
|
@@ -216,15 +214,7 @@ export function collectGapReportHandlers(project) {
|
|
|
216
214
|
}
|
|
217
215
|
|
|
218
216
|
for (const integration of project.loadedIntegrations) {
|
|
219
|
-
if (integration.__loadError)
|
|
220
|
-
entries.push({
|
|
221
|
-
kind: 'malformed',
|
|
222
|
-
handlerType: 'integration',
|
|
223
|
-
handlerName: integration.name,
|
|
224
|
-
error: `Integration failed to load, so it could not receive this report: ${integration.__loadError}. Fix the package or remove it from integrations in astryx.config, then rerun.`,
|
|
225
|
-
});
|
|
226
|
-
continue;
|
|
227
|
-
}
|
|
217
|
+
if (integration.__loadError) continue;
|
|
228
218
|
if (integration.__gapReportError) {
|
|
229
219
|
entries.push({
|
|
230
220
|
kind: 'malformed',
|
|
@@ -105,45 +105,6 @@ function addIntegration({
|
|
|
105
105
|
return {dir};
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
/**
|
|
109
|
-
* Add an integration whose module throws on import, so it never loads.
|
|
110
|
-
* @param {string} name
|
|
111
|
-
*/
|
|
112
|
-
function addBrokenIntegration(name) {
|
|
113
|
-
const dir = packageDir(name);
|
|
114
|
-
fs.mkdirSync(dir, {recursive: true});
|
|
115
|
-
fs.writeFileSync(
|
|
116
|
-
path.join(dir, 'package.json'),
|
|
117
|
-
JSON.stringify({name, version: '1.0.0', type: 'module'}),
|
|
118
|
-
);
|
|
119
|
-
fs.writeFileSync(
|
|
120
|
-
path.join(dir, 'astryx.integration.mjs'),
|
|
121
|
-
"throw new Error('intentional integration load failure');\n",
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Put a fake `gh` first on PATH that records its arguments if it is called.
|
|
127
|
-
* @returns {string} the file the fake writes when invoked
|
|
128
|
-
*/
|
|
129
|
-
function stubGh() {
|
|
130
|
-
const binDir = path.join(projectDir, 'bin');
|
|
131
|
-
const argsFile = path.join(projectDir, 'gh-args.json');
|
|
132
|
-
fs.mkdirSync(binDir, {recursive: true});
|
|
133
|
-
fs.writeFileSync(
|
|
134
|
-
path.join(binDir, 'gh'),
|
|
135
|
-
`#!/usr/bin/env node
|
|
136
|
-
import fs from 'node:fs';
|
|
137
|
-
fs.writeFileSync(${JSON.stringify(argsFile)}, JSON.stringify(process.argv.slice(2)));
|
|
138
|
-
console.log('https://github.com/acme/core/issues/42');
|
|
139
|
-
`,
|
|
140
|
-
{mode: 0o755},
|
|
141
|
-
);
|
|
142
|
-
fs.chmodSync(path.join(binDir, 'gh'), 0o755);
|
|
143
|
-
vi.stubEnv('PATH', `${binDir}${path.delimiter}${process.env.PATH ?? ''}`);
|
|
144
|
-
return argsFile;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
108
|
const reportOptions = {
|
|
148
109
|
category: 'missing_variant',
|
|
149
110
|
reason: 'Need a compact size',
|
|
@@ -720,73 +681,6 @@ describe('gapReport handler isolation', () => {
|
|
|
720
681
|
});
|
|
721
682
|
});
|
|
722
683
|
|
|
723
|
-
it('an integration that fails to load is a failed delivery, not a missing handler', async () => {
|
|
724
|
-
addBrokenIntegration('@test/broken');
|
|
725
|
-
configure(['@test/broken'], {
|
|
726
|
-
issuesUrl: 'https://github.com/acme/core/issues/new',
|
|
727
|
-
});
|
|
728
|
-
|
|
729
|
-
const result = await gapReport('General', {
|
|
730
|
-
...reportOptions,
|
|
731
|
-
cwd: projectDir,
|
|
732
|
-
});
|
|
733
|
-
|
|
734
|
-
expect(result.data.status).toBe('failed');
|
|
735
|
-
expect(result.data.deliveries).toEqual([
|
|
736
|
-
{
|
|
737
|
-
handlerType: 'integration',
|
|
738
|
-
handler: '@test/broken',
|
|
739
|
-
audience: null,
|
|
740
|
-
status: 'failed',
|
|
741
|
-
url: null,
|
|
742
|
-
message: expect.stringContaining(
|
|
743
|
-
'intentional integration load failure',
|
|
744
|
-
),
|
|
745
|
-
},
|
|
746
|
-
]);
|
|
747
|
-
});
|
|
748
|
-
|
|
749
|
-
it('an integration that fails to load keeps the public fallback off, even with consent', async () => {
|
|
750
|
-
addBrokenIntegration('@test/broken');
|
|
751
|
-
configure(['@test/broken'], {
|
|
752
|
-
issuesUrl: 'https://github.com/acme/core/issues/new',
|
|
753
|
-
});
|
|
754
|
-
const argsFile = stubGh();
|
|
755
|
-
|
|
756
|
-
const result = await gapReport('General', {
|
|
757
|
-
...reportOptions,
|
|
758
|
-
confirmPublic: true,
|
|
759
|
-
cwd: projectDir,
|
|
760
|
-
});
|
|
761
|
-
|
|
762
|
-
expect(result.data.status).toBe('failed');
|
|
763
|
-
expect(result.data.deliveries.map(d => d.handlerType)).toEqual([
|
|
764
|
-
'integration',
|
|
765
|
-
]);
|
|
766
|
-
expect(fs.existsSync(argsFile)).toBe(false);
|
|
767
|
-
});
|
|
768
|
-
|
|
769
|
-
it('an integration that fails to load keeps its place beside working handlers', async () => {
|
|
770
|
-
addBrokenIntegration('@test/broken');
|
|
771
|
-
addIntegration({
|
|
772
|
-
name: '@test/valid',
|
|
773
|
-
audience: 'internal',
|
|
774
|
-
handleBody: "return {status: 'filed', message: 'ok'};",
|
|
775
|
-
});
|
|
776
|
-
configure(['@test/broken', '@test/valid']);
|
|
777
|
-
|
|
778
|
-
const result = await gapReport('General', {
|
|
779
|
-
...reportOptions,
|
|
780
|
-
cwd: projectDir,
|
|
781
|
-
});
|
|
782
|
-
|
|
783
|
-
expect(result.data.status).toBe('partial');
|
|
784
|
-
expect(result.data.deliveries.map(d => [d.handler, d.status])).toEqual([
|
|
785
|
-
['@test/broken', 'failed'],
|
|
786
|
-
['@test/valid', 'filed'],
|
|
787
|
-
]);
|
|
788
|
-
});
|
|
789
|
-
|
|
790
684
|
it('invalid handler receipt is recorded as failed delivery', async () => {
|
|
791
685
|
addIntegration({
|
|
792
686
|
name: '@test/bad-receipt',
|
|
@@ -174,7 +174,7 @@ message: Rerun with --confirm-public to file this report.`,
|
|
|
174
174
|
},
|
|
175
175
|
{
|
|
176
176
|
type: 'prose',
|
|
177
|
-
text: 'One handler anywhere in the app, from the app or from any package, turns the fallback off for every report.
|
|
177
|
+
text: 'One handler anywhere in the app, from the app or from any package, turns the fallback off for every report. See {@link command:gap-report}.',
|
|
178
178
|
},
|
|
179
179
|
],
|
|
180
180
|
},
|
|
@@ -55,18 +55,6 @@ export function registerGapReport(program) {
|
|
|
55
55
|
result.type === 'gap-report.file' &&
|
|
56
56
|
(result.data.status === 'failed' || result.data.status === 'partial');
|
|
57
57
|
|
|
58
|
-
// stderr in both modes, so a caller that reads only the exit code or the
|
|
59
|
-
// JSON envelope still sees which delivery failed and why.
|
|
60
|
-
if (isFailure && result.type === 'gap-report.file') {
|
|
61
|
-
for (const delivery of result.data.deliveries) {
|
|
62
|
-
if (delivery.status === 'failed') {
|
|
63
|
-
console.error(
|
|
64
|
-
`gap-report: delivery to ${delivery.handler} failed: ${delivery.message ?? 'no message'}`,
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
58
|
if (program.opts().json) {
|
|
71
59
|
jsonOut(result);
|
|
72
60
|
if (isFailure) process.exitCode = 1;
|
|
@@ -172,69 +172,6 @@ export default {};\n`,
|
|
|
172
172
|
}
|
|
173
173
|
});
|
|
174
174
|
|
|
175
|
-
it('exits nonzero and names the integration on stderr when one fails to load', async () => {
|
|
176
|
-
const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-gap-broken-'));
|
|
177
|
-
try {
|
|
178
|
-
fs.writeFileSync(
|
|
179
|
-
path.join(cwd, 'package.json'),
|
|
180
|
-
JSON.stringify({name: 'fixture-app'}),
|
|
181
|
-
);
|
|
182
|
-
fs.writeFileSync(
|
|
183
|
-
path.join(cwd, 'astryx.config.mjs'),
|
|
184
|
-
"export default {integrations: ['@test/broken']};\n",
|
|
185
|
-
);
|
|
186
|
-
const integrationDir = path.join(cwd, 'node_modules', '@test', 'broken');
|
|
187
|
-
fs.mkdirSync(integrationDir, {recursive: true});
|
|
188
|
-
fs.writeFileSync(
|
|
189
|
-
path.join(integrationDir, 'package.json'),
|
|
190
|
-
JSON.stringify({
|
|
191
|
-
name: '@test/broken',
|
|
192
|
-
version: '1.0.0',
|
|
193
|
-
type: 'module',
|
|
194
|
-
}),
|
|
195
|
-
);
|
|
196
|
-
fs.writeFileSync(
|
|
197
|
-
path.join(integrationDir, 'astryx.integration.mjs'),
|
|
198
|
-
"throw new Error('intentional integration load failure');\n",
|
|
199
|
-
);
|
|
200
|
-
|
|
201
|
-
const cli = await runCli(
|
|
202
|
-
[
|
|
203
|
-
'gap-report',
|
|
204
|
-
'General',
|
|
205
|
-
'--category',
|
|
206
|
-
'docs_gap',
|
|
207
|
-
'--reason',
|
|
208
|
-
'Need a keyboard example',
|
|
209
|
-
'--json',
|
|
210
|
-
],
|
|
211
|
-
{cwd},
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
expect(cli.status).toBe(1);
|
|
215
|
-
expect(JSON.parse(cli.stdout)).toMatchObject({
|
|
216
|
-
type: 'gap-report.file',
|
|
217
|
-
data: {
|
|
218
|
-
status: 'failed',
|
|
219
|
-
filedCount: 0,
|
|
220
|
-
deliveries: [
|
|
221
|
-
{
|
|
222
|
-
handlerType: 'integration',
|
|
223
|
-
handler: '@test/broken',
|
|
224
|
-
status: 'failed',
|
|
225
|
-
},
|
|
226
|
-
],
|
|
227
|
-
},
|
|
228
|
-
});
|
|
229
|
-
expect(cli.stderr).toContain(
|
|
230
|
-
'gap-report: delivery to @test/broken failed:',
|
|
231
|
-
);
|
|
232
|
-
expect(cli.stderr).toContain('intentional integration load failure');
|
|
233
|
-
} finally {
|
|
234
|
-
fs.rmSync(cwd, {recursive: true, force: true});
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
|
|
238
175
|
it('reports missing required fields through the JSON error contract', async () => {
|
|
239
176
|
const cli = await runCli(['gap-report', 'Button', '--json']);
|
|
240
177
|
expect(cli.status).toBe(1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.6.5-canary.
|
|
3
|
+
"version": "0.6.5-canary.d11d49e",
|
|
4
4
|
"displayName": "CLI",
|
|
5
5
|
"description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
|
|
6
6
|
"author": "Meta Open Source",
|
|
@@ -101,10 +101,10 @@
|
|
|
101
101
|
"zod": "^4.4.3"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
|
-
"@astryxdesign/charts": "0.6.5-canary.
|
|
105
|
-
"@astryxdesign/core": "0.6.5-canary.
|
|
106
|
-
"@astryxdesign/lab": "0.6.5-canary.
|
|
107
|
-
"@astryxdesign/theme-neutral": "0.6.5-canary.
|
|
104
|
+
"@astryxdesign/charts": "0.6.5-canary.d11d49e",
|
|
105
|
+
"@astryxdesign/core": "0.6.5-canary.d11d49e",
|
|
106
|
+
"@astryxdesign/lab": "0.6.5-canary.d11d49e",
|
|
107
|
+
"@astryxdesign/theme-neutral": "0.6.5-canary.d11d49e"
|
|
108
108
|
},
|
|
109
109
|
"peerDependenciesMeta": {
|
|
110
110
|
"@astryxdesign/charts": {
|
|
@@ -121,10 +121,10 @@
|
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
123
|
"devDependencies": {
|
|
124
|
-
"@astryxdesign/charts": "0.6.5-canary.
|
|
125
|
-
"@astryxdesign/core": "0.6.5-canary.
|
|
126
|
-
"@astryxdesign/lab": "0.6.5-canary.
|
|
127
|
-
"@astryxdesign/theme-neutral": "0.6.5-canary.
|
|
124
|
+
"@astryxdesign/charts": "0.6.5-canary.d11d49e",
|
|
125
|
+
"@astryxdesign/core": "0.6.5-canary.d11d49e",
|
|
126
|
+
"@astryxdesign/lab": "0.6.5-canary.d11d49e",
|
|
127
|
+
"@astryxdesign/theme-neutral": "0.6.5-canary.d11d49e",
|
|
128
128
|
"@heroicons/react": "^2.2.0",
|
|
129
129
|
"@stylexjs/stylex": "^0.19.0",
|
|
130
130
|
"@types/babel__core": "^7.20.5",
|