@astryxdesign/cli 0.4.3-canary.71781fc → 0.4.3-canary.915a7aa
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/discover/_adapter.d.mts +5 -3
- package/api/discover/_adapter.mjs +6 -4
- package/clients/cli/commands/discover.broken-integration.test.mjs +112 -0
- package/clients/cli/commands/discover.mjs +12 -0
- package/clients/cli/commands/search.mjs +9 -0
- package/foundation/integrations/integration-warnings.test.mjs +17 -0
- package/foundation/integrations/validate-contributions.mjs +7 -0
- package/package.json +9 -9
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
*
|
|
7
7
|
* External packages come from configured integrations that declare a components
|
|
8
8
|
* root; each becomes a scannable package keyed by its docsDir. `configured`
|
|
9
|
-
* reports whether
|
|
10
|
-
*
|
|
11
|
-
* nothing
|
|
9
|
+
* reports whether the project configured ANY integration — including one whose
|
|
10
|
+
* manifest failed to load, which contributes nothing but is emphatically not
|
|
11
|
+
* "nothing configured". It lets an empty result distinguish "nothing
|
|
12
|
+
* configured" (`false`) from "configured but nothing discovered" (`true`),
|
|
13
|
+
* which the list leaf surfaces as `meta`.
|
|
12
14
|
*
|
|
13
15
|
* @returns {Promise<{packages: ScannedPackage[], configured: boolean}>}
|
|
14
16
|
*/
|
|
@@ -62,9 +62,11 @@ function validateDocs(docs) {
|
|
|
62
62
|
*
|
|
63
63
|
* External packages come from configured integrations that declare a components
|
|
64
64
|
* root; each becomes a scannable package keyed by its docsDir. `configured`
|
|
65
|
-
* reports whether
|
|
66
|
-
*
|
|
67
|
-
* nothing
|
|
65
|
+
* reports whether the project configured ANY integration — including one whose
|
|
66
|
+
* manifest failed to load, which contributes nothing but is emphatically not
|
|
67
|
+
* "nothing configured". It lets an empty result distinguish "nothing
|
|
68
|
+
* configured" (`false`) from "configured but nothing discovered" (`true`),
|
|
69
|
+
* which the list leaf surfaces as `meta`.
|
|
68
70
|
*
|
|
69
71
|
* @returns {Promise<{packages: ScannedPackage[], configured: boolean}>}
|
|
70
72
|
*/
|
|
@@ -84,7 +86,7 @@ export async function discoverPackages() {
|
|
|
84
86
|
docsDir: integration.components,
|
|
85
87
|
}));
|
|
86
88
|
if (explicitPackages.length === 0) {
|
|
87
|
-
return {packages: [], configured:
|
|
89
|
+
return {packages: [], configured: loadedIntegrations.length > 0};
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
const packages = scanAllPackages(
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file `astryx discover` and `astryx search` against an integration whose
|
|
5
|
+
* manifest fails to load.
|
|
6
|
+
*
|
|
7
|
+
* A manifest authored against a removed API throws on import, contributes
|
|
8
|
+
* nothing, and used to leave discover reporting "No integrations configured."
|
|
9
|
+
* — the package simply vanished. These drive the real CLI in-process against a
|
|
10
|
+
* hermetic project (astryx.config.mjs + a throwing astryx.integration.mjs under
|
|
11
|
+
* node_modules) and pin the loud behavior.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
15
|
+
import * as fs from 'node:fs';
|
|
16
|
+
import * as path from 'node:path';
|
|
17
|
+
import * as os from 'node:os';
|
|
18
|
+
import {fileURLToPath} from 'node:url';
|
|
19
|
+
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
20
|
+
|
|
21
|
+
const CORE_DIR = path.resolve(
|
|
22
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
23
|
+
'../../../../core',
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
let tmpDir;
|
|
27
|
+
let project;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Configure `@test/broken` with a manifest that throws at import. Calling an
|
|
31
|
+
* undeclared factory stands in for the real failure this came from: a 0.2.x
|
|
32
|
+
* manifest still calling `createIntegration`, which 0.3.0 removed.
|
|
33
|
+
*/
|
|
34
|
+
function buildBrokenIntegration() {
|
|
35
|
+
const intDir = path.join(project, 'node_modules', '@test', 'broken');
|
|
36
|
+
fs.mkdirSync(path.join(intDir, 'components'), {recursive: true});
|
|
37
|
+
fs.writeFileSync(
|
|
38
|
+
path.join(intDir, 'package.json'),
|
|
39
|
+
JSON.stringify({name: '@test/broken', version: '1.2.3'}),
|
|
40
|
+
);
|
|
41
|
+
fs.writeFileSync(
|
|
42
|
+
path.join(intDir, 'astryx.integration.mjs'),
|
|
43
|
+
`export default createIntegration({components: './components'});\n`,
|
|
44
|
+
);
|
|
45
|
+
fs.writeFileSync(
|
|
46
|
+
path.join(project, 'astryx.config.mjs'),
|
|
47
|
+
`export default {integrations: ['@test/broken']};\n`,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
beforeEach(() => {
|
|
52
|
+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-discover-broken-'));
|
|
53
|
+
project = path.join(tmpDir, 'project');
|
|
54
|
+
fs.mkdirSync(project, {recursive: true});
|
|
55
|
+
fs.writeFileSync(
|
|
56
|
+
path.join(project, 'package.json'),
|
|
57
|
+
JSON.stringify({name: 'proj', version: '1.0.0'}),
|
|
58
|
+
);
|
|
59
|
+
buildBrokenIntegration();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
afterEach(() => {
|
|
63
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe('astryx discover with a manifest that fails to load', () => {
|
|
67
|
+
it('warns on stderr and does not claim nothing is configured', async () => {
|
|
68
|
+
const {status, stdout, stderr} = await runCli(['discover'], {cwd: project});
|
|
69
|
+
|
|
70
|
+
expect(status).toBe(0);
|
|
71
|
+
expect(stderr).toContain(
|
|
72
|
+
'Warning: @test/broken has 1 integration issue(s). ' +
|
|
73
|
+
'Run: astryx validate-integration @test/broken',
|
|
74
|
+
);
|
|
75
|
+
expect(stdout).not.toContain('No integrations configured.');
|
|
76
|
+
expect(stdout).toContain('No external components found in configured integrations.');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('reports meta.configured=true in --json, with the nudge suppressed', async () => {
|
|
80
|
+
const {status, stdout, stderr} = await runCli(['discover', '--json'], {
|
|
81
|
+
cwd: project,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
expect(status).toBe(0);
|
|
85
|
+
expect(JSON.parse(stdout).meta).toEqual({configured: true});
|
|
86
|
+
expect(stderr).not.toContain('integration issue');
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe('astryx search with a manifest that fails to load', () => {
|
|
91
|
+
// search needs a resolvable @astryxdesign/core; without one it errors out
|
|
92
|
+
// before it can list anything, which is not the case under test.
|
|
93
|
+
beforeEach(() => {
|
|
94
|
+
const scope = path.join(project, 'node_modules', '@astryxdesign');
|
|
95
|
+
fs.mkdirSync(scope, {recursive: true});
|
|
96
|
+
fs.symlinkSync(CORE_DIR, path.join(scope, 'core'), 'dir');
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('warns on stderr, and suppresses the nudge under --json', async () => {
|
|
100
|
+
const {status, stderr} = await runCli(['search', 'button'], {cwd: project});
|
|
101
|
+
|
|
102
|
+
expect(status).toBe(0);
|
|
103
|
+
expect(stderr).toContain(
|
|
104
|
+
'Warning: @test/broken has 1 integration issue(s). ' +
|
|
105
|
+
'Run: astryx validate-integration @test/broken',
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const asJson = await runCli(['search', 'button', '--json'], {cwd: project});
|
|
109
|
+
expect(asJson.status).toBe(0);
|
|
110
|
+
expect(asJson.stderr).not.toContain('integration issue');
|
|
111
|
+
}, 30_000);
|
|
112
|
+
});
|
|
@@ -15,6 +15,8 @@ import {jsonOut} from '../../../foundation/response/json.mjs';
|
|
|
15
15
|
import {emit, section, text, record, records, list, code} from '../formatters/index.mjs';
|
|
16
16
|
import {cliError} from '../lib/cli-error.mjs';
|
|
17
17
|
import {discover as discoverApi} from '../../../api/discover/discover.mjs';
|
|
18
|
+
import {Project} from '../../../foundation/config/project.mjs';
|
|
19
|
+
import {warnOnIntegrationIssues} from '../../../foundation/integrations/integration-warnings.mjs';
|
|
18
20
|
import {getCliInvocation} from '../../../foundation/env/package-manager.mjs';
|
|
19
21
|
import {defineCommand} from '../lib/define-command.mjs';
|
|
20
22
|
import {doc as discoverCommand} from './discover.doc.mjs';
|
|
@@ -41,6 +43,16 @@ export function registerDiscover(program) {
|
|
|
41
43
|
const zh = program.opts().zh || false;
|
|
42
44
|
const run = getCliInvocation();
|
|
43
45
|
|
|
46
|
+
// Non-blocking nudge: if any configured integration has validation
|
|
47
|
+
// issues, print one compact line to stderr pointing at
|
|
48
|
+
// validate-integration. Best-effort; suppressed in --json mode.
|
|
49
|
+
try {
|
|
50
|
+
const project = await Project.load(process.cwd());
|
|
51
|
+
await warnOnIntegrationIssues(project.loadedIntegrations, {json});
|
|
52
|
+
} catch {
|
|
53
|
+
// Never let the nudge break the command.
|
|
54
|
+
}
|
|
55
|
+
|
|
44
56
|
let result;
|
|
45
57
|
try {
|
|
46
58
|
result = await discoverApi(query, {components: options.components, lang, zh});
|
|
@@ -26,6 +26,8 @@ import {emit, section, text, records} from '../formatters/index.mjs';
|
|
|
26
26
|
import {cliError} from '../lib/cli-error.mjs';
|
|
27
27
|
import {defineCommand} from '../lib/define-command.mjs';
|
|
28
28
|
import {search as searchApi} from '../../../api/search/search.mjs';
|
|
29
|
+
import {Project} from '../../../foundation/config/project.mjs';
|
|
30
|
+
import {warnOnIntegrationIssues} from '../../../foundation/integrations/integration-warnings.mjs';
|
|
29
31
|
import {doc as searchCommand} from './search.doc.mjs';
|
|
30
32
|
import {doc as searchFn} from '../../../api/search/search.doc.mjs';
|
|
31
33
|
|
|
@@ -41,6 +43,13 @@ export function registerSearch(program) {
|
|
|
41
43
|
) => {
|
|
42
44
|
const json = program.opts().json || false;
|
|
43
45
|
|
|
46
|
+
try {
|
|
47
|
+
const project = await Project.load(process.cwd());
|
|
48
|
+
await warnOnIntegrationIssues(project.loadedIntegrations, {json});
|
|
49
|
+
} catch {
|
|
50
|
+
// Never let the nudge break the command.
|
|
51
|
+
}
|
|
52
|
+
|
|
44
53
|
// Parse --limit to a number; the API validates it (positive integer) and
|
|
45
54
|
// throws ERR_INVALID_ARGUMENT, so we pass NaN through rather than
|
|
46
55
|
// pre-rejecting with a generic code here.
|
|
@@ -68,6 +68,23 @@ describe('warnOnIntegrationIssues', () => {
|
|
|
68
68
|
expect(errLines).toHaveLength(0);
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
+
it('warns for a manifest that failed to load, which declares no roots', async () => {
|
|
72
|
+
// loadIntegrations records __loadError and no contribution roots, so every
|
|
73
|
+
// on-disk check finds nothing — without the load error itself counting as
|
|
74
|
+
// an issue, a stale manifest is silent everywhere.
|
|
75
|
+
const integration = {
|
|
76
|
+
...loaded({name: '@acme/stale'}),
|
|
77
|
+
__loadError: 'createIntegration is not a function',
|
|
78
|
+
};
|
|
79
|
+
await warnOnIntegrationIssues([integration], {json: false});
|
|
80
|
+
|
|
81
|
+
expect(errLines).toHaveLength(1);
|
|
82
|
+
expect(errLines[0]).toBe(
|
|
83
|
+
'Warning: @acme/stale has 1 integration issue(s). ' +
|
|
84
|
+
'Run: astryx validate-integration @acme/stale',
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
|
|
71
88
|
it('emits nothing for an integration with no issues', async () => {
|
|
72
89
|
// Existing components root with no broken contributions → no issues.
|
|
73
90
|
const componentsRoot = path.join(tmpDir, 'components');
|
|
@@ -149,6 +149,13 @@ export async function validateLoadedIntegration(loaded) {
|
|
|
149
149
|
/** @type {Issue[]} */
|
|
150
150
|
const issues = [];
|
|
151
151
|
if (!loaded || typeof loaded !== 'object') return issues;
|
|
152
|
+
// A manifest that threw on import (or failed the schema) carries a load-error
|
|
153
|
+
// marker and no contribution roots, so every check below would find nothing
|
|
154
|
+
// and report a clean integration — which is how a stale manifest used to go
|
|
155
|
+
// silently invisible. The load error IS the issue.
|
|
156
|
+
if (loaded.__loadError) {
|
|
157
|
+
return [issueError('integration_error', loaded.__loadError)];
|
|
158
|
+
}
|
|
152
159
|
checkRoots(
|
|
153
160
|
{
|
|
154
161
|
components: loaded.components,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.4.3-canary.
|
|
3
|
+
"version": "0.4.3-canary.915a7aa",
|
|
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",
|
|
@@ -87,10 +87,10 @@
|
|
|
87
87
|
"zod": "^4.4.3"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|
|
90
|
-
"@astryxdesign/charts": "0.4.3-canary.
|
|
91
|
-
"@astryxdesign/core": "0.4.3-canary.
|
|
92
|
-
"@astryxdesign/lab": "0.4.3-canary.
|
|
93
|
-
"@astryxdesign/theme-neutral": "0.4.3-canary.
|
|
90
|
+
"@astryxdesign/charts": "0.4.3-canary.915a7aa",
|
|
91
|
+
"@astryxdesign/core": "0.4.3-canary.915a7aa",
|
|
92
|
+
"@astryxdesign/lab": "0.4.3-canary.915a7aa",
|
|
93
|
+
"@astryxdesign/theme-neutral": "0.4.3-canary.915a7aa",
|
|
94
94
|
"gpt-tokenizer": "^3.4.0"
|
|
95
95
|
},
|
|
96
96
|
"peerDependenciesMeta": {
|
|
@@ -108,10 +108,10 @@
|
|
|
108
108
|
}
|
|
109
109
|
},
|
|
110
110
|
"devDependencies": {
|
|
111
|
-
"@astryxdesign/charts": "0.4.3-canary.
|
|
112
|
-
"@astryxdesign/core": "0.4.3-canary.
|
|
113
|
-
"@astryxdesign/lab": "0.4.3-canary.
|
|
114
|
-
"@astryxdesign/theme-neutral": "0.4.3-canary.
|
|
111
|
+
"@astryxdesign/charts": "0.4.3-canary.915a7aa",
|
|
112
|
+
"@astryxdesign/core": "0.4.3-canary.915a7aa",
|
|
113
|
+
"@astryxdesign/lab": "0.4.3-canary.915a7aa",
|
|
114
|
+
"@astryxdesign/theme-neutral": "0.4.3-canary.915a7aa",
|
|
115
115
|
"gpt-tokenizer": "^3.4.0"
|
|
116
116
|
},
|
|
117
117
|
"scripts": {
|