@astryxdesign/cli 0.6.5-canary.bfb918a → 0.6.5-canary.c2a49ec
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 +2 -2
- package/api/build/_adapter.d.mts +14 -0
- package/api/build/_adapter.mjs +58 -1
- package/api/build/build.test.mjs +74 -1
- package/api/build/kit/kit.mjs +39 -7
- package/api/build/kit/rank.d.mts +8 -0
- package/api/build/kit/rank.mjs +14 -0
- package/api/build/kit/weights.d.mts +82 -0
- package/api/build/kit/weights.json +1 -0
- package/api/build/kit/weights.mjs +305 -0
- package/api/build/kit/weights.test.mjs +190 -0
- package/api/docs/docs.d.mts +6 -0
- package/api/docs/docs.depth.test.mjs +132 -0
- package/api/docs/docs.doc.mjs +31 -2
- package/api/docs/docs.mjs +44 -1
- package/api/docs/docs.type.d.mts +38 -1
- package/api/docs/docs.type.mjs +18 -1
- package/api/docs/node/node.d.mts +28 -3
- package/api/docs/node/node.mjs +146 -23
- package/api/gap-report/gap-report.d.mts +3 -1
- package/api/gap-report/gap-report.mjs +12 -2
- package/api/gap-report/gap-report.test.mjs +106 -0
- package/api/hook/list/list.d.mts +1 -1
- package/api/integration/add-theme.mjs +93 -3
- package/api/integration/add-theme.test.mjs +100 -0
- package/api/integration/integrationAddTheme.doc.mjs +1 -1
- package/api/search/search.d.mts +12 -5
- package/api/search/search.doc.mjs +4 -4
- package/api/search/search.mjs +123 -53
- package/api/search/search.test.mjs +123 -8
- package/api/search/search.type.d.mts +5 -5
- package/api/search/search.type.mjs +5 -5
- package/api/theme/build/build.icon-lineage.test.mjs +117 -0
- package/api/theme/build/build.icon-preservation.test.mjs +639 -0
- package/api/theme/build/build.mjs +146 -69
- package/api/theme/build/build.test.mjs +190 -1
- package/api/theme/build/icon-imports.d.mts +47 -0
- package/api/theme/build/icon-imports.mjs +691 -0
- package/api/theme/themeBuild.doc.d.mts +4 -1
- package/api/theme/themeBuild.doc.mjs +14 -3
- package/assets/docs/theme.doc.mjs +2 -1
- package/assets/docs/tokens.doc.mjs +3 -3
- package/assets/docs/tree/add-a-theme.doc.mjs +4 -0
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.doc.mjs +15 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.tsx +38 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.doc.mjs +20 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.tsx +48 -0
- package/clients/cli/commands/build-theme.mjs +8 -2
- package/clients/cli/commands/discover.mjs +29 -1
- package/clients/cli/commands/discover.no-source.test.mjs +75 -0
- package/clients/cli/commands/docs.depth.test.mjs +219 -0
- package/clients/cli/commands/docs.doc.mjs +15 -2
- package/clients/cli/commands/docs.mjs +222 -5
- package/clients/cli/commands/gap-report.mjs +12 -0
- package/clients/cli/commands/gap-report.test.mjs +63 -0
- package/clients/cli/commands/integration-add.doc.mjs +1 -1
- package/clients/cli/commands/search.doc.mjs +5 -4
- package/clients/cli/commands/search.mjs +30 -6
- package/clients/cli/commands/search.test.mjs +60 -16
- package/clients/cli/commands/theme-list.behavior.test.mjs +41 -0
- package/foundation/agent-docs/agent-docs.mjs +2 -1
- package/foundation/agent-docs/agent-docs.test.mjs +8 -0
- package/foundation/discovery/theme-discovery.d.mts +6 -0
- package/foundation/discovery/theme-discovery.mjs +9 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +1 -1
- package/package.json +9 -9
|
@@ -25,6 +25,8 @@ import * as os from 'node:os';
|
|
|
25
25
|
import * as path from 'node:path';
|
|
26
26
|
import {fileURLToPath} from 'node:url';
|
|
27
27
|
import {docs} from '../docs/docs.mjs';
|
|
28
|
+
import {listAvailableThemes} from '../theme/_adapter.mjs';
|
|
29
|
+
import {doc as themeAddCommandDoc} from '../../clients/cli/commands/theme-add.doc.mjs';
|
|
28
30
|
import {
|
|
29
31
|
headingWithPhrase,
|
|
30
32
|
titleInQuery,
|
|
@@ -75,8 +77,11 @@ describe('search leaf — envelope + ranking', () => {
|
|
|
75
77
|
});
|
|
76
78
|
|
|
77
79
|
describe('search leaf — per-domain result fields', () => {
|
|
78
|
-
it('carries import for components and hooks, title for docs, displayName and kind for templates', async () => {
|
|
79
|
-
|
|
80
|
+
it('carries import for components and hooks, title for docs, displayName and kind for templates, displayName for themes', async () => {
|
|
81
|
+
// `theme` reaches every domain, but a theme matches it only through its
|
|
82
|
+
// description, a prose mention below every name and keyword hit, so read
|
|
83
|
+
// the whole result list.
|
|
84
|
+
const r = await search('theme', {cwd, limit: 400});
|
|
80
85
|
expect(new Set(r.data.results.map(res => res.domain))).toEqual(
|
|
81
86
|
new Set(SEARCH_DOMAINS),
|
|
82
87
|
);
|
|
@@ -89,9 +94,12 @@ describe('search leaf — per-domain result fields', () => {
|
|
|
89
94
|
expect(res.title).toMatch(/\S/);
|
|
90
95
|
const read = `astryx docs ${res.name}`;
|
|
91
96
|
expect([read, `${read} --index`, `${read} ${res.section}`]).toContain(res.command);
|
|
92
|
-
} else {
|
|
97
|
+
} else if (res.domain === 'template') {
|
|
93
98
|
expect(res.displayName).toMatch(/\S/);
|
|
94
99
|
expect(['page', 'block']).toContain(res.kind);
|
|
100
|
+
} else if (res.domain === 'theme') {
|
|
101
|
+
expect(res.displayName).toMatch(/\S/);
|
|
102
|
+
expect(res.command).toMatch(/^astryx theme add /);
|
|
95
103
|
}
|
|
96
104
|
}
|
|
97
105
|
}, SLOW);
|
|
@@ -397,11 +405,10 @@ describe('search leaf — a candidate that matches every word outranks a partial
|
|
|
397
405
|
expect(score(q, all)).toBeLessThan(160);
|
|
398
406
|
});
|
|
399
407
|
|
|
400
|
-
// Among candidates that match every word, the stronger match
|
|
401
|
-
//
|
|
402
|
-
//
|
|
403
|
-
|
|
404
|
-
it.fails('ranks the stronger of two all-word matches first', () => {
|
|
408
|
+
// Among candidates that match every word, the stronger match comes first:
|
|
409
|
+
// the all-words tier uses total match quality (sum of token scores), not
|
|
410
|
+
// just the strongest, so an exact keyword outranks a stem-form keyword.
|
|
411
|
+
it('ranks the stronger of two all-word matches first', () => {
|
|
405
412
|
const all = {name: 'x', keywords: ['alphas'], description: 'alpha beta gamma delta'};
|
|
406
413
|
const q = 'alpha beta gamma delta';
|
|
407
414
|
expect(score(q, {name: 'y', keywords: ['alpha'], description: 'beta gamma delta'})).toBeGreaterThan(
|
|
@@ -497,6 +504,114 @@ describe('search leaf — limit validation (API matches the CLI contract)', () =
|
|
|
497
504
|
}, SLOW);
|
|
498
505
|
});
|
|
499
506
|
|
|
507
|
+
describe('search leaf — a theme is found by its names; its description is prose (AST-050 FR14)', () => {
|
|
508
|
+
/** A result that answers the query by a name or a declared keyword, not a typo or a mention. */
|
|
509
|
+
const matchesByNameOrKeyword = (/** @type {{reason: string}} */ result) =>
|
|
510
|
+
/^(exact name|plural of the name|name "|name contains ")/.test(result.reason) ||
|
|
511
|
+
/^keyword "[^"]*"$/.test(result.reason);
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* The `theme add` command AST-050 FR12 and FR13 name for the stage that
|
|
515
|
+
* `theme add` itself declares: no `--import` yet, a deprecated copy default
|
|
516
|
+
* beside `--import`, or the cleanup, which keeps `--import` and drops the
|
|
517
|
+
* copy's `--overwrite`.
|
|
518
|
+
* @param {string} slug
|
|
519
|
+
*/
|
|
520
|
+
function themeAddCommandForStage(slug) {
|
|
521
|
+
const flags = themeAddCommandDoc.options.flatMap(option => option.flag.split(/[\s,]+/));
|
|
522
|
+
if (!flags.includes('--import')) return `astryx theme add ${slug}`;
|
|
523
|
+
if (flags.includes('--overwrite')) return `astryx theme add --import ${slug}`;
|
|
524
|
+
return `astryx theme add ${slug}`;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
it(
|
|
528
|
+
'ranks a theme found only through its description below every name and keyword match',
|
|
529
|
+
async () => {
|
|
530
|
+
for (const [query, slugs] of [
|
|
531
|
+
['focus', ['neutral']],
|
|
532
|
+
['content', ['matcha', 'neutral']],
|
|
533
|
+
]) {
|
|
534
|
+
const {results} = (await search(query, {cwd, limit: 400})).data;
|
|
535
|
+
const strong = results.filter(
|
|
536
|
+
result => result.domain !== 'theme' && matchesByNameOrKeyword(result),
|
|
537
|
+
);
|
|
538
|
+
expect(strong.length).toBeGreaterThan(0);
|
|
539
|
+
const lastStrong = Math.max(...strong.map(result => results.indexOf(result)));
|
|
540
|
+
for (const slug of slugs) {
|
|
541
|
+
const at = results.findIndex(result => result.domain === 'theme' && result.name === slug);
|
|
542
|
+
expect(at).toBeGreaterThan(-1);
|
|
543
|
+
expect(results[at].reason).toMatch(/^description mentions /);
|
|
544
|
+
expect(at).toBeGreaterThan(lastStrong);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
},
|
|
548
|
+
SLOW,
|
|
549
|
+
);
|
|
550
|
+
|
|
551
|
+
it(
|
|
552
|
+
'scores a word in a theme description the same as a word in a component description',
|
|
553
|
+
async () => {
|
|
554
|
+
const {results} = (await search('minimal', {cwd, limit: 400})).data;
|
|
555
|
+
const neutral = results.find(result => result.domain === 'theme' && result.name === 'neutral');
|
|
556
|
+
const topNav = results.find(result => result.domain === 'component' && result.name === 'TopNav');
|
|
557
|
+
expect(neutral?.reason).toMatch(/^description mentions /);
|
|
558
|
+
expect(topNav?.reason).toMatch(/^description mentions /);
|
|
559
|
+
expect(neutral?.score).toBe(topNav?.score);
|
|
560
|
+
},
|
|
561
|
+
SLOW,
|
|
562
|
+
);
|
|
563
|
+
|
|
564
|
+
it(
|
|
565
|
+
'keeps a theme that matches every word only in its description below results with a keyword hit',
|
|
566
|
+
async () => {
|
|
567
|
+
// Overlay and Dialog declare `focus` and mention `content`; neutral only
|
|
568
|
+
// mentions both, in "so the content stays the focus".
|
|
569
|
+
const {results} = (await search('content focus', {cwd, limit: 400})).data;
|
|
570
|
+
const neutral = results.findIndex(result => result.domain === 'theme' && result.name === 'neutral');
|
|
571
|
+
expect(neutral).toBeGreaterThan(-1);
|
|
572
|
+
for (const name of ['Overlay', 'Dialog']) {
|
|
573
|
+
const at = results.findIndex(result => result.domain === 'component' && result.name === name);
|
|
574
|
+
expect(at).toBeGreaterThan(-1);
|
|
575
|
+
expect(at).toBeLessThan(neutral);
|
|
576
|
+
}
|
|
577
|
+
},
|
|
578
|
+
SLOW,
|
|
579
|
+
);
|
|
580
|
+
|
|
581
|
+
it(
|
|
582
|
+
'still finds a theme first by its slug or its display name',
|
|
583
|
+
async () => {
|
|
584
|
+
for (const query of ['neutral', 'Matcha', 'Y2K']) {
|
|
585
|
+
const [first] = (await search(query, {cwd})).data.results;
|
|
586
|
+
expect(first).toMatchObject({domain: 'theme', name: query.toLowerCase(), reason: 'exact name'});
|
|
587
|
+
}
|
|
588
|
+
},
|
|
589
|
+
SLOW,
|
|
590
|
+
);
|
|
591
|
+
|
|
592
|
+
it('scores a display name with the same name signals as the slug', () => {
|
|
593
|
+
const theme = {name: 'ocean', aliases: ['Ocean Blue'], description: 'Deep blues for calm reading.'};
|
|
594
|
+
expect(scoreCandidate('ocean blue', theme)).toEqual(scoreCandidate('ocean', theme));
|
|
595
|
+
expect(scoreCandidate('ocean blue', {...theme, aliases: []})?.score ?? 0).toBeLessThan(
|
|
596
|
+
scoreCandidate('ocean', theme).score,
|
|
597
|
+
);
|
|
598
|
+
});
|
|
599
|
+
|
|
600
|
+
it(
|
|
601
|
+
'names the theme add command for the stage theme add declares',
|
|
602
|
+
async () => {
|
|
603
|
+
const themes = await listAvailableThemes(cwd);
|
|
604
|
+
expect(themes.length).toBeGreaterThan(0);
|
|
605
|
+
for (const {slug} of themes) {
|
|
606
|
+
const {results} = (await search(slug, {cwd, type: 'theme'})).data;
|
|
607
|
+
const result = results.find(entry => entry.name === slug);
|
|
608
|
+
expect(result?.command).toBe(themeAddCommandForStage(slug));
|
|
609
|
+
}
|
|
610
|
+
},
|
|
611
|
+
SLOW,
|
|
612
|
+
);
|
|
613
|
+
});
|
|
614
|
+
|
|
500
615
|
describe('search leaf — integration components', () => {
|
|
501
616
|
/**
|
|
502
617
|
* A minimal consumer project: a stub `@astryxdesign/core` (so `findCoreDir`
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* The domain a search result belongs to.
|
|
6
6
|
*/
|
|
7
|
-
export type SearchDomain = "component" | "hook" | "doc" | "template";
|
|
7
|
+
export type SearchDomain = "component" | "hook" | "doc" | "template" | "theme";
|
|
8
8
|
/**
|
|
9
9
|
* A single ranked search result, tagged with its domain.
|
|
10
10
|
*/
|
|
@@ -14,7 +14,7 @@ export type SearchResultEntry = {
|
|
|
14
14
|
*/
|
|
15
15
|
domain: SearchDomain;
|
|
16
16
|
/**
|
|
17
|
-
* - Primary identifier (component/hook name, doc topic or docs-tree route, template dir).
|
|
17
|
+
* - Primary identifier (component/hook name, doc topic or docs-tree route, template dir, theme slug).
|
|
18
18
|
*/
|
|
19
19
|
name: string;
|
|
20
20
|
/**
|
|
@@ -30,7 +30,7 @@ export type SearchResultEntry = {
|
|
|
30
30
|
*/
|
|
31
31
|
description: string;
|
|
32
32
|
/**
|
|
33
|
-
* - Follow-up command to act on this result (e.g. `astryx component Button`).
|
|
33
|
+
* - Follow-up command to act on this result (e.g. `astryx component Button`, or `astryx theme add neutral` for a theme).
|
|
34
34
|
*/
|
|
35
35
|
command: string;
|
|
36
36
|
/**
|
|
@@ -46,7 +46,7 @@ export type SearchResultEntry = {
|
|
|
46
46
|
*/
|
|
47
47
|
section?: string | undefined;
|
|
48
48
|
/**
|
|
49
|
-
* - The npm package that authored a doc result
|
|
49
|
+
* - The npm package that authored a doc result (for a section, the package whose file the section came from), or that ships a theme result.
|
|
50
50
|
*/
|
|
51
51
|
package?: string | undefined;
|
|
52
52
|
/**
|
|
@@ -54,7 +54,7 @@ export type SearchResultEntry = {
|
|
|
54
54
|
*/
|
|
55
55
|
parent?: string | undefined;
|
|
56
56
|
/**
|
|
57
|
-
* - Friendly display name — present for template results.
|
|
57
|
+
* - Friendly display name — present for template and theme results.
|
|
58
58
|
*/
|
|
59
59
|
displayName?: string | undefined;
|
|
60
60
|
/**
|
|
@@ -9,24 +9,24 @@
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* The domain a search result belongs to.
|
|
12
|
-
* @typedef {'component' | 'hook' | 'doc' | 'template'} SearchDomain
|
|
12
|
+
* @typedef {'component' | 'hook' | 'doc' | 'template' | 'theme'} SearchDomain
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* A single ranked search result, tagged with its domain.
|
|
17
17
|
* @typedef {object} SearchResultEntry
|
|
18
18
|
* @property {SearchDomain} domain - Which content domain this result came from.
|
|
19
|
-
* @property {string} name - Primary identifier (component/hook name, doc topic or docs-tree route, template dir).
|
|
19
|
+
* @property {string} name - Primary identifier (component/hook name, doc topic or docs-tree route, template dir, theme slug).
|
|
20
20
|
* @property {number} score - Relevance score (higher is better).
|
|
21
21
|
* @property {string} reason - Human-readable reason the candidate matched (e.g. `keyword "button"`).
|
|
22
22
|
* @property {string} description - One-line description, when available.
|
|
23
|
-
* @property {string} command - Follow-up command to act on this result (e.g. `astryx component Button`).
|
|
23
|
+
* @property {string} command - Follow-up command to act on this result (e.g. `astryx component Button`, or `astryx theme add neutral` for a theme).
|
|
24
24
|
* @property {string} [import] - Import path — present for component and hook results.
|
|
25
25
|
* @property {string} [title] - Doc title — present for doc results.
|
|
26
26
|
* @property {string} [section] - Section key — present when a doc result is one section of a topic; `command` reads only that section.
|
|
27
|
-
* @property {string} [package] - The npm package that authored a doc result
|
|
27
|
+
* @property {string} [package] - The npm package that authored a doc result (for a section, the package whose file the section came from), or that ships a theme result.
|
|
28
28
|
* @property {string} [parent] - Command that opens the level above a doc result — its topic's section list for a section, the docs-tree namespace it sits in for a tree node — so a reader can see the siblings and open another.
|
|
29
|
-
* @property {string} [displayName] - Friendly display name — present for template results.
|
|
29
|
+
* @property {string} [displayName] - Friendly display name — present for template and theme results.
|
|
30
30
|
* @property {'page' | 'block'} [kind] - Template kind (`page` | `block`) — present for template results.
|
|
31
31
|
*/
|
|
32
32
|
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Icon preservation through multiple generations of built themes.
|
|
5
|
+
* @input Real themeBuild calls and registries imported under the same local
|
|
6
|
+
* binding name from separate base and child theme directories.
|
|
7
|
+
* @output A native ESM load verifies inherited and overridden React icons
|
|
8
|
+
* survive when a grandchild extends the child's generated artifact.
|
|
9
|
+
* @position Direct API regression for persisted icon inheritance in #5058.
|
|
10
|
+
* The node project's global setup supplies the compiled core package.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {expect, it} from 'vitest';
|
|
14
|
+
import {execFileSync} from 'node:child_process';
|
|
15
|
+
import * as fs from 'node:fs';
|
|
16
|
+
import * as path from 'node:path';
|
|
17
|
+
import {themeBuild} from './build.mjs';
|
|
18
|
+
|
|
19
|
+
it('preserves merged icon lineage through a built child with colliding import names', async () => {
|
|
20
|
+
const tmpDir = fs.mkdtempSync(
|
|
21
|
+
path.resolve(import.meta.dirname, '../../..', '.tmp-icon-lineage-'),
|
|
22
|
+
);
|
|
23
|
+
try {
|
|
24
|
+
for (const directory of ['base', 'child']) {
|
|
25
|
+
fs.mkdirSync(path.join(tmpDir, directory));
|
|
26
|
+
}
|
|
27
|
+
const write = (file, source) =>
|
|
28
|
+
fs.writeFileSync(path.join(tmpDir, file), source);
|
|
29
|
+
const writeRegistry = (file, labels) => {
|
|
30
|
+
write(
|
|
31
|
+
file,
|
|
32
|
+
`import {createElement} from 'react';
|
|
33
|
+
export const icons = {
|
|
34
|
+
${Object.entries(labels)
|
|
35
|
+
.map(
|
|
36
|
+
([key, label]) =>
|
|
37
|
+
` ${JSON.stringify(key)}: createElement('svg', {'data-icon': ${JSON.stringify(label)}}),`,
|
|
38
|
+
)
|
|
39
|
+
.join('\n')}
|
|
40
|
+
};
|
|
41
|
+
`,
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
writeRegistry('base/icons.mjs', {
|
|
46
|
+
check: 'base-check',
|
|
47
|
+
close: 'base-close',
|
|
48
|
+
});
|
|
49
|
+
writeRegistry('child/icons.mjs', {
|
|
50
|
+
add: 'child-add',
|
|
51
|
+
close: 'child-close',
|
|
52
|
+
});
|
|
53
|
+
write(
|
|
54
|
+
'base/source.mjs',
|
|
55
|
+
`import {defineTheme} from '@astryxdesign/core/theme';
|
|
56
|
+
import {icons} from './icons.mjs';
|
|
57
|
+
export const baseTheme = defineTheme({
|
|
58
|
+
name: 'base', tokens: {'--color-bg': '#fff'}, icons,
|
|
59
|
+
});
|
|
60
|
+
`,
|
|
61
|
+
);
|
|
62
|
+
write(
|
|
63
|
+
'child/source.mjs',
|
|
64
|
+
`import {defineTheme} from '@astryxdesign/core/theme';
|
|
65
|
+
import {baseTheme} from '../base/source.mjs';
|
|
66
|
+
import {icons} from './icons.mjs';
|
|
67
|
+
export default defineTheme({
|
|
68
|
+
name: 'child', extends: baseTheme, tokens: {}, icons,
|
|
69
|
+
});
|
|
70
|
+
`,
|
|
71
|
+
);
|
|
72
|
+
const child = await themeBuild('child/source.mjs', {}, {cwd: tmpDir});
|
|
73
|
+
expect(child?.type).toBe('theme.build');
|
|
74
|
+
|
|
75
|
+
write(
|
|
76
|
+
'grandchild.mjs',
|
|
77
|
+
`import {defineTheme} from '@astryxdesign/core/theme';
|
|
78
|
+
import {childTheme} from './child/child.js';
|
|
79
|
+
export default defineTheme({name: 'grandchild', extends: childTheme, tokens: {}});
|
|
80
|
+
`,
|
|
81
|
+
);
|
|
82
|
+
const grandchild = await themeBuild('grandchild.mjs', {}, {cwd: tmpDir});
|
|
83
|
+
expect(grandchild?.type).toBe('theme.build');
|
|
84
|
+
const checked = await themeBuild(
|
|
85
|
+
'grandchild.mjs',
|
|
86
|
+
{check: true},
|
|
87
|
+
{cwd: tmpDir},
|
|
88
|
+
);
|
|
89
|
+
expect(checked?.data.upToDate).toBe(true);
|
|
90
|
+
|
|
91
|
+
// Native imports catch invalid aliases and incorrect relative specifiers
|
|
92
|
+
// that the source loader could otherwise resolve or transform away.
|
|
93
|
+
execFileSync(
|
|
94
|
+
process.execPath,
|
|
95
|
+
[
|
|
96
|
+
'--input-type=module',
|
|
97
|
+
'--eval',
|
|
98
|
+
`import assert from 'node:assert/strict';
|
|
99
|
+
import {isValidElement} from 'react';
|
|
100
|
+
import {childTheme} from './child/child.js';
|
|
101
|
+
import {grandchildTheme} from './grandchild.js';
|
|
102
|
+
const expected = {check: 'base-check', close: 'child-close', add: 'child-add'};
|
|
103
|
+
assert.deepEqual(Object.keys(grandchildTheme.icons).sort(), Object.keys(expected).sort());
|
|
104
|
+
for (const [key, label] of Object.entries(expected)) {
|
|
105
|
+
const icon = grandchildTheme.icons[key];
|
|
106
|
+
assert.ok(isValidElement(icon), key + ' must remain a React element');
|
|
107
|
+
assert.equal(icon.type, 'svg');
|
|
108
|
+
assert.equal(icon.props['data-icon'], label);
|
|
109
|
+
assert.equal(icon, childTheme.icons[key], key + ' must retain its imported identity');
|
|
110
|
+
}`,
|
|
111
|
+
],
|
|
112
|
+
{cwd: tmpDir, stdio: 'pipe', timeout: 10000},
|
|
113
|
+
);
|
|
114
|
+
} finally {
|
|
115
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
116
|
+
}
|
|
117
|
+
});
|