@astryxdesign/cli 0.7.3-canary.cbe384c → 0.7.3-canary.f94e962
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 +63 -63
- package/api/component/component.mjs +16 -2
- package/api/component/component.test.mjs +15 -0
- package/api/doctor/doctor.test.mjs +28 -3
- package/api/integration/_adapter.d.mts +8 -0
- package/api/integration/_adapter.mjs +21 -1
- package/api/integration/authoring-checks.test.mjs +220 -0
- package/api/integration/validate-integration.d.mts +2 -1
- package/api/integration/validate-integration.mjs +30 -5
- package/api/integration/validate-integration.type.d.mts +2 -1
- package/api/integration/validate-integration.type.mjs +2 -1
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/_entries.mjs +57 -1
- package/api/upgrade/_adapter.d.mts +57 -3
- package/api/upgrade/_adapter.mjs +149 -27
- package/api/upgrade/registry/registry.d.mts +10 -4
- package/api/upgrade/registry/registry.mjs +33 -16
- package/api/upgrade/registry/registry.test.mjs +85 -0
- package/api/upgrade/run/run.d.mts +4 -2
- package/api/upgrade/run/run.mjs +13 -2
- package/api/upgrade/run/run.test.mjs +417 -3
- package/api/upgrade/upgrade.doc.mjs +10 -5
- package/api/upgrade/upgrade.mjs +13 -2
- package/api/upgrade/upgrade.type.d.mts +5 -3
- package/api/upgrade/upgrade.type.mjs +8 -6
- package/assets/docs/tree/add-a-topic.doc.mjs +1 -1
- package/assets/docs/tree/checks.doc.mjs +1 -1
- package/assets/templates/themes/butter/butterTheme.ts +4 -2
- package/assets/templates/themes/stone/stoneTheme.ts +4 -2
- package/assets/templates/themes/y2k/y2kTheme.ts +4 -2
- package/clients/cli/commands/integration-check.test.mjs +48 -0
- package/clients/cli/commands/upgrade.doc.mjs +4 -2
- package/clients/cli/commands/upgrade.mjs +9 -2
- package/clients/cli/commands/upgrade.subfolder-path.test.mjs +97 -0
- package/foundation/config/project.mjs +5 -20
- package/foundation/config/project.test.mjs +30 -0
- package/foundation/discovery/runner-allowlist.d.mts +2 -4
- package/foundation/discovery/runner-allowlist.mjs +2 -4
- package/foundation/discovery/runner-commands.d.mts +77 -0
- package/foundation/discovery/runner-commands.mjs +293 -0
- package/foundation/discovery/runner-commands.test.mjs +128 -0
- package/foundation/discovery/template-needs.mjs +1 -44
- package/foundation/doc-compiler/doc-loads.test.mjs +4 -0
- package/foundation/fs/paths.d.mts +70 -8
- package/foundation/fs/paths.mjs +526 -35
- package/foundation/fs/paths.test.mjs +430 -54
- package/foundation/integrations/autolink.d.mts +2 -1
- package/foundation/integrations/autolink.mjs +4 -13
- package/foundation/integrations/integrations.d.mts +11 -0
- package/foundation/integrations/integrations.mjs +21 -1
- package/foundation/response/response-types.doc.mjs +1 -1
- package/package.json +9 -9
|
@@ -30,7 +30,7 @@ export const docs = {
|
|
|
30
30
|
rows: [
|
|
31
31
|
[
|
|
32
32
|
'`astryx doctor integration validate`',
|
|
33
|
-
'The manifest loads, each root holds contributions the CLI can read, and each doc matches its authoring type',
|
|
33
|
+
'The manifest loads, each root holds contributions the CLI can read, and each doc matches its authoring type. Notes, which fail nothing, list a malformed `cliCommand` and each command a topic writes with a package runner (`runner_command`)',
|
|
34
34
|
'A declared root is missing (`missing_root`), a contribution does not load (`invalid_doc`, `invalid_component`, `invalid_theme`), or two templates in the package replace one Core id (`ambiguous_template_replacement`)',
|
|
35
35
|
"The manifest has a key this CLI does not know (`unknown_manifest_key`), or a doc field does not match the doc's authoring type: a field the type does not have, a missing required field, or a value outside the field's type. It also warns on what no reader can serve: a prop listed twice (`duplicate_prop`), a `propDescriptions` key that names no documented prop (`unknown_translated_prop`), a section with no content (`empty_section`), two sections of a topic with one key (`duplicate_section_key`), or a `.doc.zh.mjs` or `.doc.dense.mjs` overlay beside no topic file (`orphan_doc_overlay`). It checks docs with your installed `typescript`, or, where that is missing or has no JavaScript compiler API (TypeScript 7), with an installed `@typescript/typescript6`; without either, it prints `[skip] Docs not type-checked`. With no `astryx.integration.mjs` it prints a hint and exits 0",
|
|
36
36
|
],
|
|
@@ -81,7 +81,8 @@ const SECONDARY_SELECTOR = {
|
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* The secondary Button treatment on ComplexSelector triggers (AST-079 FR2), with
|
|
84
|
-
* the hover kept off a disabled trigger, whose inner button is disabled
|
|
84
|
+
* the hover kept off a disabled trigger, whose inner button is disabled
|
|
85
|
+
* (natively or, keeping its tab stop, with `aria-disabled`).
|
|
85
86
|
*/
|
|
86
87
|
const SECONDARY_COMPLEX_SELECTOR = {
|
|
87
88
|
backgroundColor: SECONDARY_BUTTON.backgroundColor,
|
|
@@ -89,7 +90,8 @@ const SECONDARY_COMPLEX_SELECTOR = {
|
|
|
89
90
|
borderStyle: SECONDARY_BUTTON.borderStyle,
|
|
90
91
|
borderColor: SECONDARY_BUTTON.borderColor,
|
|
91
92
|
color: SECONDARY_BUTTON.color,
|
|
92
|
-
':hover:not(:has(> :disabled))':
|
|
93
|
+
':hover:not(:has(> :is(:disabled, [aria-disabled="true"])))':
|
|
94
|
+
SECONDARY_BUTTON[':hover'],
|
|
93
95
|
} as const;
|
|
94
96
|
|
|
95
97
|
export const butterTheme = defineTheme({
|
|
@@ -100,14 +100,16 @@ const SECONDARY_SELECTOR = {
|
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
102
|
* The secondary Button treatment on ComplexSelector triggers (AST-079 FR2), with
|
|
103
|
-
* the hover kept off a disabled trigger, whose inner button is disabled
|
|
103
|
+
* the hover kept off a disabled trigger, whose inner button is disabled
|
|
104
|
+
* (natively or, keeping its tab stop, with `aria-disabled`).
|
|
104
105
|
*/
|
|
105
106
|
const SECONDARY_COMPLEX_SELECTOR = {
|
|
106
107
|
backgroundColor: SECONDARY_BUTTON.backgroundColor,
|
|
107
108
|
borderWidth: SECONDARY_BUTTON.borderWidth,
|
|
108
109
|
borderStyle: SECONDARY_BUTTON.borderStyle,
|
|
109
110
|
borderColor: SECONDARY_BUTTON.borderColor,
|
|
110
|
-
':hover:not(:has(> :disabled))':
|
|
111
|
+
':hover:not(:has(> :is(:disabled, [aria-disabled="true"])))':
|
|
112
|
+
SECONDARY_BUTTON[':hover'],
|
|
111
113
|
} as const;
|
|
112
114
|
|
|
113
115
|
export const stoneTheme = defineTheme({
|
|
@@ -76,7 +76,8 @@ const SECONDARY_SELECTOR = {
|
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
78
|
* The secondary Button treatment on ComplexSelector triggers (AST-079 FR2), with
|
|
79
|
-
* the hover kept off a disabled trigger, whose inner button is disabled
|
|
79
|
+
* the hover kept off a disabled trigger, whose inner button is disabled
|
|
80
|
+
* (natively or, keeping its tab stop, with `aria-disabled`).
|
|
80
81
|
*/
|
|
81
82
|
const SECONDARY_COMPLEX_SELECTOR = {
|
|
82
83
|
backgroundColor: SECONDARY_BUTTON.backgroundColor,
|
|
@@ -84,7 +85,8 @@ const SECONDARY_COMPLEX_SELECTOR = {
|
|
|
84
85
|
borderStyle: SECONDARY_BUTTON.borderStyle,
|
|
85
86
|
borderColor: SECONDARY_BUTTON.borderColor,
|
|
86
87
|
color: SECONDARY_BUTTON.color,
|
|
87
|
-
':hover:not(:has(> :disabled))':
|
|
88
|
+
':hover:not(:has(> :is(:disabled, [aria-disabled="true"])))':
|
|
89
|
+
SECONDARY_BUTTON[':hover'],
|
|
88
90
|
} as const;
|
|
89
91
|
|
|
90
92
|
export const y2kTheme = defineTheme({
|
|
@@ -439,3 +439,51 @@ describe('a stray doc pointer', () => {
|
|
|
439
439
|
expect(strict.stdout).toContain('stray_doc_pointer');
|
|
440
440
|
});
|
|
441
441
|
});
|
|
442
|
+
describe('a command written with a runner', () => {
|
|
443
|
+
it('is a note in doctor integration validate, and integration check --strict still passes', async () => {
|
|
444
|
+
fs.writeFileSync(
|
|
445
|
+
path.join(tmpDir, 'package.json'),
|
|
446
|
+
JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
|
|
447
|
+
);
|
|
448
|
+
fs.writeFileSync(
|
|
449
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
450
|
+
`export default {docs: './docs'};\n`,
|
|
451
|
+
);
|
|
452
|
+
fs.mkdirSync(path.join(tmpDir, 'docs'));
|
|
453
|
+
const doc = {
|
|
454
|
+
type: 'generic',
|
|
455
|
+
name: 'acme-setup',
|
|
456
|
+
title: 'Fixture',
|
|
457
|
+
description: 'Fixture topic.',
|
|
458
|
+
sections: [
|
|
459
|
+
{
|
|
460
|
+
title: 'Overview',
|
|
461
|
+
content: [{type: 'code', lang: 'bash', code: 'npx astryx doctor'}],
|
|
462
|
+
},
|
|
463
|
+
],
|
|
464
|
+
};
|
|
465
|
+
fs.writeFileSync(
|
|
466
|
+
path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
|
|
467
|
+
`export default ${JSON.stringify(doc)};\n`,
|
|
468
|
+
);
|
|
469
|
+
|
|
470
|
+
const doctor = await runCli(['doctor', 'integration', 'validate'], tmpDir);
|
|
471
|
+
expect(doctor.status).toBe(0);
|
|
472
|
+
expect(doctor.stdout).toContain(
|
|
473
|
+
'note (runner_command): docs/acme-setup.doc.mjs:',
|
|
474
|
+
);
|
|
475
|
+
expect(doctor.stdout).toContain('Write `astryx doctor`');
|
|
476
|
+
|
|
477
|
+
const strict = await runCli(
|
|
478
|
+
['--json', 'integration', 'check', '--strict'],
|
|
479
|
+
tmpDir,
|
|
480
|
+
);
|
|
481
|
+
expect(strict.status).toBe(0);
|
|
482
|
+
const validate = JSON.parse(strict.stdout).data.checks.find(
|
|
483
|
+
(/** @type {any} */ each) => each.check === 'validate',
|
|
484
|
+
).response.data;
|
|
485
|
+
expect(validate.notes.map((/** @type {any} */ note) => note.code)).toEqual([
|
|
486
|
+
'runner_command',
|
|
487
|
+
]);
|
|
488
|
+
});
|
|
489
|
+
});
|
|
@@ -21,6 +21,7 @@ export const doc = {
|
|
|
21
21
|
'agent-docs block when Core or configured integration guidance changes. ' +
|
|
22
22
|
'Dry-run by default. --apply writes codemod and receipt changes, runs hooks, then refreshes agent docs. ' +
|
|
23
23
|
'Anything a post-codemod hook prints goes to stderr, so stdout carries only the result. ' +
|
|
24
|
+
'Run from a folder inside a project, it upgrades that project and names files in the result relative to the folder you ran it in. ' +
|
|
24
25
|
'ShadCN-copied compositions are checked automatically during a normal upgrade, or alone with --registry. ' +
|
|
25
26
|
'Outside a project, --list lists the codemods this release ships and --registry finds no copied compositions to update; ' +
|
|
26
27
|
'a migration writes nothing and fails with ERR_VERSION_DETECT, because no installed Core names its target.',
|
|
@@ -69,8 +70,9 @@ export const doc = {
|
|
|
69
70
|
{
|
|
70
71
|
flag: '--path <dir>',
|
|
71
72
|
param: 'options.path',
|
|
72
|
-
description:
|
|
73
|
-
|
|
73
|
+
description:
|
|
74
|
+
"Source directory to scan, relative to where you run the command, however you spell it. Without --path, the project's src folder, from any folder in the project",
|
|
75
|
+
default: './src at the project root',
|
|
74
76
|
},
|
|
75
77
|
{
|
|
76
78
|
flag: '--install-deps',
|
|
@@ -31,8 +31,9 @@ export function registerUpgrade(program) {
|
|
|
31
31
|
action:
|
|
32
32
|
/**
|
|
33
33
|
* @param {import('../../../api/upgrade/upgrade.mjs').UpgradeOptions} options
|
|
34
|
+
* @param {import('commander').Command} command
|
|
34
35
|
*/
|
|
35
|
-
async options => {
|
|
36
|
+
async (options, command) => {
|
|
36
37
|
const json = program.opts().json || false;
|
|
37
38
|
const isList = Boolean(options.list);
|
|
38
39
|
// Silence the logger for --list so the handler renders from the
|
|
@@ -42,8 +43,14 @@ export function registerUpgrade(program) {
|
|
|
42
43
|
|
|
43
44
|
/** @type {import('../../../api/upgrade/upgrade.type.mjs').UpgradeListResponse | import('../../../api/upgrade/upgrade.type.mjs').UpgradeRegistryResponse | import('../../../api/upgrade/upgrade.type.mjs').UpgradeStatusResponse | import('../../../api/upgrade/upgrade.type.mjs').UpgradeRunResponse} */
|
|
44
45
|
let result;
|
|
46
|
+
// `--path` shows its default in help, but a path nobody typed is the
|
|
47
|
+
// project's src, not one read from this folder: leave it unset.
|
|
48
|
+
const apiOptions =
|
|
49
|
+
command.getOptionValueSource('path') === 'default'
|
|
50
|
+
? {...options, path: undefined}
|
|
51
|
+
: options;
|
|
45
52
|
try {
|
|
46
|
-
result = await upgradeApi(
|
|
53
|
+
result = await upgradeApi(apiOptions, {cwd: process.cwd()});
|
|
47
54
|
} catch (e) {
|
|
48
55
|
// Re-enable the logger so the error is visible in text mode.
|
|
49
56
|
// For --list the logger was silent; for other modes the API
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file `astryx upgrade` from a folder inside a project: a `--path` you type
|
|
5
|
+
* is read from that folder, however you spell it, and without `--path` the
|
|
6
|
+
* upgrade scans the project's own src. The option's default must not read as
|
|
7
|
+
* a typed `./src`. The `--json` result names files relative to the folder the
|
|
8
|
+
* command ran in.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
12
|
+
import * as fs from 'node:fs';
|
|
13
|
+
import * as os from 'node:os';
|
|
14
|
+
import * as path from 'node:path';
|
|
15
|
+
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
16
|
+
|
|
17
|
+
/** Core 0.7.0 renamed this prop; its codemod renames it on Typeahead. */
|
|
18
|
+
const OLD_PROP_SOURCE =
|
|
19
|
+
"import {Typeahead} from '@astryxdesign/core';\n" +
|
|
20
|
+
'export const App = () => <Typeahead label="Fruit" emptySearchResultsText="None" />;\n';
|
|
21
|
+
|
|
22
|
+
let root;
|
|
23
|
+
|
|
24
|
+
/** @param {string} rel @param {string} body */
|
|
25
|
+
function write(rel, body) {
|
|
26
|
+
const file = path.join(root, rel);
|
|
27
|
+
fs.mkdirSync(path.dirname(file), {recursive: true});
|
|
28
|
+
fs.writeFileSync(file, body);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** @param {string} rel */
|
|
32
|
+
const renamed = rel =>
|
|
33
|
+
fs
|
|
34
|
+
.readFileSync(path.join(root, rel), 'utf-8')
|
|
35
|
+
.includes('emptySearchText="None"');
|
|
36
|
+
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
root = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-upgrade-subfolder-'));
|
|
39
|
+
write(
|
|
40
|
+
'package.json',
|
|
41
|
+
JSON.stringify({
|
|
42
|
+
name: 'app',
|
|
43
|
+
private: true,
|
|
44
|
+
dependencies: {'@astryxdesign/core': '0.7.0'},
|
|
45
|
+
}),
|
|
46
|
+
);
|
|
47
|
+
write(
|
|
48
|
+
'node_modules/@astryxdesign/core/package.json',
|
|
49
|
+
JSON.stringify({name: '@astryxdesign/core', version: '0.7.0'}),
|
|
50
|
+
);
|
|
51
|
+
write('src/App.tsx', OLD_PROP_SOURCE);
|
|
52
|
+
// A folder inside the project with source of its own and no package.json.
|
|
53
|
+
write('frontend/src/App.tsx', OLD_PROP_SOURCE);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
afterEach(() => {
|
|
57
|
+
fs.rmSync(root, {recursive: true, force: true});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
/** @param {string[]} args @param {string} [folder] */
|
|
61
|
+
async function upgradeFrom(args, folder = 'frontend') {
|
|
62
|
+
const r = await runCli(
|
|
63
|
+
['upgrade', '--from', '0.6.8', ...args, '--apply', '--json'],
|
|
64
|
+
{
|
|
65
|
+
cwd: path.join(root, folder),
|
|
66
|
+
},
|
|
67
|
+
);
|
|
68
|
+
expect(r.status).toBe(0);
|
|
69
|
+
return JSON.parse(r.stdout);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
describe('upgrade --path from a folder inside the project', () => {
|
|
73
|
+
it.each([['./src'], ['src'], ['src/'], ['./src/']])(
|
|
74
|
+
'reads --path %s from the folder you ran in',
|
|
75
|
+
async spelling => {
|
|
76
|
+
const result = await upgradeFrom(['--path', spelling]);
|
|
77
|
+
|
|
78
|
+
expect(result.data.modifiedFiles).toEqual(['src/App.tsx']);
|
|
79
|
+
expect(renamed('frontend/src/App.tsx')).toBe(true);
|
|
80
|
+
expect(renamed('src/App.tsx')).toBe(false);
|
|
81
|
+
},
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
it("scans the project's src without --path", async () => {
|
|
85
|
+
const result = await upgradeFrom([]);
|
|
86
|
+
|
|
87
|
+
expect(result.data.modifiedFiles).toEqual(['../src/App.tsx']);
|
|
88
|
+
expect(renamed('src/App.tsx')).toBe(true);
|
|
89
|
+
expect(renamed('frontend/src/App.tsx')).toBe(false);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('names files from the project root when run there', async () => {
|
|
93
|
+
const result = await upgradeFrom([], '.');
|
|
94
|
+
|
|
95
|
+
expect(result.data.modifiedFiles).toEqual(['src/App.tsx']);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
@@ -40,7 +40,7 @@ import {parseConfig} from '../../authoring/config/parse.mjs';
|
|
|
40
40
|
import {
|
|
41
41
|
loadIntegrations,
|
|
42
42
|
loadLocalIntegration,
|
|
43
|
-
|
|
43
|
+
resolveInstalledIntegrationDir,
|
|
44
44
|
} from '../integrations/integrations.mjs';
|
|
45
45
|
import {loadAutolinkCandidates} from '../integrations/autolink.mjs';
|
|
46
46
|
import {
|
|
@@ -65,7 +65,7 @@ import {
|
|
|
65
65
|
discoverValidIntegrationComponents,
|
|
66
66
|
} from '../discovery/component-discovery.mjs';
|
|
67
67
|
import {resolveComponentReplacements} from '../discovery/component-replacement.mjs';
|
|
68
|
-
import {CLI_ROOT, findCoreDir, findProjectCoreDir} from '../fs/paths.mjs';
|
|
68
|
+
import {CLI_ROOT, findCoreDir, findPackageRoot, findProjectCoreDir} from '../fs/paths.mjs';
|
|
69
69
|
import {
|
|
70
70
|
applyTemplateReplacements,
|
|
71
71
|
effectiveTemplateDiscovery,
|
|
@@ -223,7 +223,7 @@ async function loadConfiguredIntegrations(specs, {cwd, fresh}) {
|
|
|
223
223
|
/** @type {string|undefined} */
|
|
224
224
|
let packageDir;
|
|
225
225
|
try {
|
|
226
|
-
packageDir =
|
|
226
|
+
packageDir = resolveInstalledIntegrationDir(spec, cwd);
|
|
227
227
|
} catch {
|
|
228
228
|
// Not a bare package name: there is no install location to record.
|
|
229
229
|
}
|
|
@@ -326,22 +326,6 @@ export const CONFIG_BASENAMES = [
|
|
|
326
326
|
export const DEFAULT_ISSUES_URL =
|
|
327
327
|
'https://github.com/facebook/astryx/issues/new';
|
|
328
328
|
|
|
329
|
-
/**
|
|
330
|
-
* Find the directory of the nearest package.json walking up from startDir.
|
|
331
|
-
* @param {string} startDir
|
|
332
|
-
* @returns {string|null}
|
|
333
|
-
*/
|
|
334
|
-
function findPackageRoot(startDir) {
|
|
335
|
-
let dir = startDir;
|
|
336
|
-
for (let i = 0; i < 50; i++) {
|
|
337
|
-
if (fs.existsSync(path.join(dir, 'package.json'))) return dir;
|
|
338
|
-
const parent = path.dirname(dir);
|
|
339
|
-
if (parent === dir) break;
|
|
340
|
-
dir = parent;
|
|
341
|
-
}
|
|
342
|
-
return null;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
329
|
/**
|
|
346
330
|
* Whether this project accepts `debug` handlers contributed by the
|
|
347
331
|
* integrations it loads.
|
|
@@ -506,7 +490,8 @@ export class Project {
|
|
|
506
490
|
// The project root: the config's directory when there is one (findConfigPath
|
|
507
491
|
// resolves the config as a sibling of the nearest package.json, so the two
|
|
508
492
|
// agree), otherwise that package.json's directory. Dependencies are declared
|
|
509
|
-
// there, and
|
|
493
|
+
// there, and installed packages resolve from there up the node_modules
|
|
494
|
+
// chain.
|
|
510
495
|
const projectDir = configPath
|
|
511
496
|
? path.dirname(configPath)
|
|
512
497
|
: (findPackageRoot(cwd) ?? cwd);
|
|
@@ -856,6 +856,36 @@ describe('Project loads each integration in isolation', () => {
|
|
|
856
856
|
});
|
|
857
857
|
});
|
|
858
858
|
|
|
859
|
+
describe('Project finds configured integrations a workspace hoists', () => {
|
|
860
|
+
// npm, Yarn and Bun workspaces install a member's dependencies at the
|
|
861
|
+
// workspace root, so the member's own node_modules does not hold them.
|
|
862
|
+
it('loads an integration named in a member config from the workspace root', async () => {
|
|
863
|
+
scaffold();
|
|
864
|
+
fs.writeFileSync(
|
|
865
|
+
path.join(tmpDir, 'package.json'),
|
|
866
|
+
JSON.stringify({name: 'root', private: true, workspaces: ['apps/*']}),
|
|
867
|
+
);
|
|
868
|
+
fs.rmSync(path.join(tmpDir, 'astryx.config.mjs'));
|
|
869
|
+
const member = path.join(tmpDir, 'apps', 'web');
|
|
870
|
+
fs.mkdirSync(member, {recursive: true});
|
|
871
|
+
fs.writeFileSync(path.join(member, 'package.json'), JSON.stringify({name: 'web'}));
|
|
872
|
+
fs.writeFileSync(
|
|
873
|
+
path.join(member, 'astryx.config.mjs'),
|
|
874
|
+
`export default ${JSON.stringify({integrations: ['@acme/widgets']})};\n`,
|
|
875
|
+
);
|
|
876
|
+
|
|
877
|
+
const project = await Project.load(member);
|
|
878
|
+
|
|
879
|
+
const widgets = (await project.components()).filter(
|
|
880
|
+
component => component.package === '@acme/widgets',
|
|
881
|
+
);
|
|
882
|
+
expect(widgets.map(component => component.name)).toEqual(['Widget']);
|
|
883
|
+
expect(await project.issues()).not.toContainEqual(
|
|
884
|
+
expect.objectContaining({package: '@acme/widgets', code: 'integration_error'}),
|
|
885
|
+
);
|
|
886
|
+
});
|
|
887
|
+
});
|
|
888
|
+
|
|
859
889
|
describe('Project.issuesUrl routing', () => {
|
|
860
890
|
it('routes core to config.issuesUrl, falling back to the default', async () => {
|
|
861
891
|
scaffold({issuesUrl: 'https://example.com/core'});
|
|
@@ -14,10 +14,8 @@
|
|
|
14
14
|
* command, except in `runnerExamples`, where `npx @astryxdesign/cli …` and a
|
|
15
15
|
* project's runner may (still never the unscoped name through npx).
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* repo test runs that check over Core's and the CLI's own docs with this
|
|
20
|
-
* allowlist.
|
|
17
|
+
* The matcher is runnerCommandsIn (foundation/discovery/runner-commands.mjs),
|
|
18
|
+
* the rule `doctor integration validate` holds integrations to.
|
|
21
19
|
*
|
|
22
20
|
* @input nothing
|
|
23
21
|
* @output the allowlist
|
|
@@ -13,10 +13,8 @@
|
|
|
13
13
|
* command, except in `runnerExamples`, where `npx @astryxdesign/cli …` and a
|
|
14
14
|
* project's runner may (still never the unscoped name through npx).
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* repo test runs that check over Core's and the CLI's own docs with this
|
|
19
|
-
* allowlist.
|
|
16
|
+
* The matcher is runnerCommandsIn (foundation/discovery/runner-commands.mjs),
|
|
17
|
+
* the rule `doctor integration validate` holds integrations to.
|
|
20
18
|
*
|
|
21
19
|
* @input nothing
|
|
22
20
|
* @output the allowlist
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Each runner command in a text, as written, with the bare command to write
|
|
6
|
+
* instead, in order.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} text
|
|
9
|
+
* @returns {{written: string, bare: string, download: boolean}[]}
|
|
10
|
+
*/
|
|
11
|
+
export function runnerCommandsIn(text: string): {
|
|
12
|
+
written: string;
|
|
13
|
+
bare: string;
|
|
14
|
+
download: boolean;
|
|
15
|
+
}[];
|
|
16
|
+
/**
|
|
17
|
+
* An Astryx command a topic writes with a package runner in front.
|
|
18
|
+
*
|
|
19
|
+
* @typedef {object} RunnerCommand
|
|
20
|
+
* @property {string} topic
|
|
21
|
+
* @property {string | null} section the title of the section it is in
|
|
22
|
+
* @property {string} file the doc file
|
|
23
|
+
* @property {number | null} line the file line that holds it, when found
|
|
24
|
+
* @property {string} command the command as written
|
|
25
|
+
* @property {string} message the bare command to write instead
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Runner commands in a package's topics.
|
|
29
|
+
*
|
|
30
|
+
* @param {{records: {name: string, path: string}[], guides?: {name: string, ref?: {topicFile?: string}}[]}} discovered
|
|
31
|
+
* the package's docs, as discoverIntegrationDocs returns them
|
|
32
|
+
* @returns {Promise<RunnerCommand[]>}
|
|
33
|
+
*/
|
|
34
|
+
export function findRunnerCommands(discovered: {
|
|
35
|
+
records: {
|
|
36
|
+
name: string;
|
|
37
|
+
path: string;
|
|
38
|
+
}[];
|
|
39
|
+
guides?: {
|
|
40
|
+
name: string;
|
|
41
|
+
ref?: {
|
|
42
|
+
topicFile?: string;
|
|
43
|
+
};
|
|
44
|
+
}[];
|
|
45
|
+
}): Promise<RunnerCommand[]>;
|
|
46
|
+
/**
|
|
47
|
+
* The CLI's top-level commands, the words that make a project runner's
|
|
48
|
+
* `astryx <word>` a command; runner-commands.test.mjs keeps the list equal to
|
|
49
|
+
* the command docs.
|
|
50
|
+
*/
|
|
51
|
+
export const CLI_COMMANDS: readonly string[];
|
|
52
|
+
/**
|
|
53
|
+
* An Astryx command a topic writes with a package runner in front.
|
|
54
|
+
*/
|
|
55
|
+
export type RunnerCommand = {
|
|
56
|
+
topic: string;
|
|
57
|
+
/**
|
|
58
|
+
* the title of the section it is in
|
|
59
|
+
*/
|
|
60
|
+
section: string | null;
|
|
61
|
+
/**
|
|
62
|
+
* the doc file
|
|
63
|
+
*/
|
|
64
|
+
file: string;
|
|
65
|
+
/**
|
|
66
|
+
* the file line that holds it, when found
|
|
67
|
+
*/
|
|
68
|
+
line: number | null;
|
|
69
|
+
/**
|
|
70
|
+
* the command as written
|
|
71
|
+
*/
|
|
72
|
+
command: string;
|
|
73
|
+
/**
|
|
74
|
+
* the bare command to write instead
|
|
75
|
+
*/
|
|
76
|
+
message: string;
|
|
77
|
+
};
|