@astryxdesign/cli 0.7.11-canary.3bbab18 → 0.7.11-canary.4e6e67d
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/icon/_authoring.mjs +228 -32
- package/api/icon/icon.type.d.mts +15 -0
- package/api/icon/icon.type.mjs +2 -0
- package/api/integration/add-helpers.d.mts +10 -1
- package/api/integration/add-helpers.mjs +1 -1
- package/api/swizzle/_adapter.d.mts +1 -0
- package/api/swizzle/_adapter.mjs +4 -1
- package/api/swizzle/_moduleGraph.d.mts +162 -0
- package/api/swizzle/_moduleGraph.mjs +754 -0
- package/api/swizzle/copy/copy.d.mts +2 -43
- package/api/swizzle/copy/copy.mjs +194 -314
- package/api/swizzle/swizzle.d.mts +0 -2
- package/api/swizzle/swizzle.doc.mjs +8 -4
- package/api/swizzle/swizzle.mjs +3 -7
- package/api/swizzle/swizzle.type.d.mts +1 -1
- package/api/swizzle/swizzle.type.mjs +2 -2
- package/assets/discover/official-packages.json +12 -0
- package/assets/docs/tree/icon-sets.doc.mjs +2 -2
- package/assets/templates/pages/file-explorer/page.tsx +103 -79
- package/clients/cli/commands/swizzle.doc.mjs +6 -3
- package/clients/cli/commands/swizzle.mjs +8 -9
- package/foundation/discovery/component-loader.d.mts +1 -1
- package/foundation/discovery/icon-set-checks.mjs +4 -15
- package/foundation/discovery/icon-set-discovery.d.mts +13 -0
- package/foundation/discovery/icon-set-discovery.mjs +25 -0
- package/foundation/discovery/icon-set-writer.d.mts +28 -0
- package/foundation/discovery/icon-set-writer.mjs +57 -0
- package/foundation/discovery/module-exports.mjs +57 -2
- package/foundation/fs/paths.d.mts +2 -1
- package/foundation/fs/paths.mjs +3 -4
- package/package.json +6 -6
package/api/swizzle/swizzle.mjs
CHANGED
|
@@ -9,16 +9,12 @@
|
|
|
9
9
|
* - a component name -> api/swizzle/copy -> `swizzle.copy` receipt
|
|
10
10
|
*
|
|
11
11
|
* Errors throw AstryxError (stable code + suggestions). All human prose /
|
|
12
|
-
* package-manager prefixing lives in the CLI renderer.
|
|
13
|
-
*
|
|
14
|
-
* point (api/index.mjs, the CLI command, and the unit tests all import from
|
|
15
|
-
* here).
|
|
12
|
+
* package-manager prefixing lives in the CLI renderer. api/index.mjs, the CLI
|
|
13
|
+
* command, and the unit tests import `swizzle` from here.
|
|
16
14
|
*/
|
|
17
15
|
|
|
18
16
|
import {swizzleList} from './list/list.mjs';
|
|
19
|
-
import {swizzleCopy
|
|
20
|
-
|
|
21
|
-
export {rewriteImports};
|
|
17
|
+
import {swizzleCopy} from './copy/copy.mjs';
|
|
22
18
|
|
|
23
19
|
/**
|
|
24
20
|
* List swizzlable components, or copy one component's source for customization.
|
|
@@ -62,7 +62,7 @@ export type SwizzleOptions = {
|
|
|
62
62
|
*/
|
|
63
63
|
list?: boolean | undefined;
|
|
64
64
|
/**
|
|
65
|
-
*
|
|
65
|
+
* Replace the component's existing files instead of erroring. A copy that carries a helper an earlier swizzle wrote never replaces it, except a changed private attribute owner module and the style modules it imports; swizzling the component whose folder holds the helper counts it as that component's own file.
|
|
66
66
|
*/
|
|
67
67
|
overwrite?: boolean | undefined;
|
|
68
68
|
};
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
* @property {string} data.package Owner package the component source was copied from.
|
|
35
35
|
* @property {string} data.outputDir
|
|
36
36
|
* @property {number} data.filesCopied
|
|
37
|
-
* @property {string[]} data.files Copied file names, relative to the component folder;
|
|
37
|
+
* @property {string[]} data.files Copied file names, relative to the component folder; the internal modules copied beside it start with `../` (spec:AST-110 FR2).
|
|
38
38
|
* @property {boolean} data.usesStyleX Whether any copied file uses StyleX (requires build-time setup).
|
|
39
39
|
* @property {SwizzleFeedback} [data.feedback]
|
|
40
40
|
*/
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* @property {string} [output] Output directory (must resolve inside cwd). Defaults to ./components/astryx.
|
|
47
47
|
* @property {string} [package] Scope to a specific owning package when a name is ambiguous.
|
|
48
48
|
* @property {boolean} [list] Force the list response even with a component argument.
|
|
49
|
-
* @property {boolean} [overwrite]
|
|
49
|
+
* @property {boolean} [overwrite] Replace the component's existing files instead of erroring. A copy that carries a helper an earlier swizzle wrote never replaces it, except a changed private attribute owner module and the style modules it imports; swizzling the component whose folder holds the helper counts it as that component's own file.
|
|
50
50
|
*/
|
|
51
51
|
|
|
52
52
|
export {};
|
|
@@ -283,6 +283,18 @@
|
|
|
283
283
|
"kind": "component",
|
|
284
284
|
"name": "RichTextEditor"
|
|
285
285
|
},
|
|
286
|
+
{
|
|
287
|
+
"kind": "component",
|
|
288
|
+
"name": "RichTextEditorAutoLinkPlugin"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"kind": "component",
|
|
292
|
+
"name": "RichTextEditorToolbar"
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
"kind": "component",
|
|
296
|
+
"name": "RichTextView"
|
|
297
|
+
},
|
|
286
298
|
{
|
|
287
299
|
"kind": "template",
|
|
288
300
|
"name": "RichTextEditorShowcase"
|
|
@@ -121,11 +121,11 @@ export const docs = {
|
|
|
121
121
|
},
|
|
122
122
|
{
|
|
123
123
|
type: 'prose',
|
|
124
|
-
text: "Every component the library exports becomes an icon (an alias of one component is recorded once), named `<Name>Icon`, with an id from its name (`Squares2X2Icon` is `squares-2x2`: a dimension stays one word). `map` is filled only where a definition's name is an icon's id (`delete` → icon `delete`), and the receipt lists those entries under Mapped by name: a library can draw another meaning under the same name (one library's `delete` is a backspace key), so check each. An icon whose id is only one of a definition's words (`trash` for `delete`) may mean something else in this library, so the receipt lists it under Suggestions, with the `experimental icon map <definition> <icon>` command for each, and writes nothing for it: check the meaning, then run the ones that fit. Run it again after a library release to refresh the icons that library supplies; `map` entries whose icon still exists are kept, and the receipt names any icon the library dropped, any icon `--exclude` left out, and the `map` entries each took with it. Icons you added from your own files or another library are left as they are. An icon you already have is known by the library export it re-exports, so it keeps its export name exactly, its `map` entries, variants, and words, even when a newer CLI spells its id differently or your `--exclude` lets a library prefix come off new ids; the receipt lists each changed id under `renamed`. A refresh with `--dry-run` writes nothing and prints the Mapped by name and Suggestions lists again; `--display-name` and `--description` on a refresh rewrite the descriptor. Variants added with `add --variant … --all` are kept too; run that `add` again to pick up icons the release added. `experimental icon --list` shows how many definitions the set maps.",
|
|
124
|
+
text: "Every component the library exports becomes an icon (an alias of one component is recorded once), named `<Name>Icon`, with an id from its name (`Squares2X2Icon` is `squares-2x2`: a dimension stays one word). `map` is filled only where a definition's name is an icon's id (`delete` → icon `delete`), and the receipt lists those entries under Mapped by name: a library can draw another meaning under the same name (one library's `delete` is a backspace key), so check each. An icon whose id is only one of a definition's words (`trash` for `delete`) may mean something else in this library, so the receipt lists it under Suggestions, with the `experimental icon map <definition> <icon>` command for each, and writes nothing for it: check the meaning, then run the ones that fit. Run it again after a library release to refresh the icons that library supplies; `map` entries whose icon still exists are kept, and the receipt names any icon the library dropped, any icon `--exclude` left out, and the `map` entries each took with it. Icons you added from your own files or another library are left as they are. Icons you added one file at a time from the same package (`--from <package>/dist/XIcon`) move to the root import when you refresh from the package root and the root exports the same icon; each keeps its id, export, `map` entries, variants, and words on that refresh and every later one, and the receipt lists it under `moved`. A library icon whose id or name a moved icon already has is left out. When another icon of the set already reads the same root export, the icon stays on its own file, and the receipt says why. An icon you already have is known by the library export it re-exports, so it keeps its export name exactly, its `map` entries, variants, and words, even when a newer CLI spells its id differently or your `--exclude` lets a library prefix come off new ids; the receipt lists each changed id under `renamed`. An id you chose that is not a spelling of the library name (`dismiss` for `XIcon`) is kept. A refresh with `--dry-run` writes nothing and prints the Mapped by name and Suggestions lists again; `--display-name` and `--description` on a refresh rewrite the descriptor. Variants added with `add --variant … --all` are kept too; run that `add` again to pick up icons the release added. `experimental icon --list` shows how many definitions the set maps.",
|
|
125
125
|
},
|
|
126
126
|
{
|
|
127
127
|
type: 'prose',
|
|
128
|
-
text: "With a package or package subpath, it also records the installed library and version as the data file's `source`, so `integration check` warns when your dependency moves to another version; copies the library's LICENSE (and NOTICE) files into the set directory; and sets the descriptor's `license` to the library's. A set you started without `--from` gets the same the first time a refresh records its source, unless you already changed `license`: a `license` you set is kept (the receipt names the library's), and every later refresh keeps it too. Your package.json `license` is never changed. Edit `license` when the artwork's license differs from the library's package license.",
|
|
128
|
+
text: "With a package or package subpath, it also records the installed library and version as the data file's `source`, so `integration check` warns when your dependency moves to another version; copies the library's LICENSE (and NOTICE) files into the set directory; and sets the descriptor's `license` to the library's. A set you started without `--from` gets the same the first time a refresh records its source, unless you already changed `license`: a `license` you set is kept (the receipt names the library's), and every later refresh keeps it too. Your package.json `license` is never changed. Edit `license` when the artwork's license differs from the library's package license. When the library ships no license file to copy, the receipt says so under `licenseNoticeMissing` and in its notes, and the CLI writes nothing: add a `NOTICE` file to the set directory (`icon-sets/<set>/NOTICE`) that names the library, its version, and its license. `integration check` accepts a file named `LICENSE`, `LICENCE`, `NOTICE`, or `COPYING`, in any case and with an optional suffix such as `NOTICE.md` or `LICENSE-MIT`, in the set directory or the package root; without one it reports `icon_license_notice_missing`.",
|
|
129
129
|
},
|
|
130
130
|
{
|
|
131
131
|
type: 'prose',
|
|
@@ -7,6 +7,8 @@ import {Layout, LayoutContent} from '@astryxdesign/core/Layout';
|
|
|
7
7
|
import {Toolbar} from '@astryxdesign/core/Toolbar';
|
|
8
8
|
import {List, ListItem} from '@astryxdesign/core/List';
|
|
9
9
|
import {HStack, VStack} from '@astryxdesign/core/Layout';
|
|
10
|
+
import {StackItem} from '@astryxdesign/core/Stack';
|
|
11
|
+
import {rtlStyles} from '@astryxdesign/core/utils';
|
|
10
12
|
import {Text} from '@astryxdesign/core/Text';
|
|
11
13
|
import {Icon} from '@astryxdesign/core/Icon';
|
|
12
14
|
import {IconButton} from '@astryxdesign/core/IconButton';
|
|
@@ -260,14 +262,9 @@ const FILESYSTEM: FileSystemItem[] = [
|
|
|
260
262
|
];
|
|
261
263
|
|
|
262
264
|
const page: CSSProperties = {height: '100dvh'};
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
const
|
|
266
|
-
const detailColumn: CSSProperties = {
|
|
267
|
-
flexGrow: 1,
|
|
268
|
-
flexShrink: 0,
|
|
269
|
-
flexBasis: 320,
|
|
270
|
-
};
|
|
265
|
+
// The detail column fills the rest of the row but never narrows below 320px;
|
|
266
|
+
// past that, the row scrolls sideways.
|
|
267
|
+
const detailFloor: CSSProperties = {flexShrink: 0, flexBasis: 320};
|
|
271
268
|
|
|
272
269
|
function findItem(items: FileSystemItem[], id: string): FileSystemItem | null {
|
|
273
270
|
for (const item of items) {
|
|
@@ -361,7 +358,13 @@ export default function FileExplorerPage() {
|
|
|
361
358
|
<IconButton
|
|
362
359
|
variant="ghost"
|
|
363
360
|
size="sm"
|
|
364
|
-
icon={
|
|
361
|
+
icon={
|
|
362
|
+
<Icon
|
|
363
|
+
icon={ChevronLeftIcon}
|
|
364
|
+
size="sm"
|
|
365
|
+
xstyle={rtlStyles.mirror}
|
|
366
|
+
/>
|
|
367
|
+
}
|
|
365
368
|
onClick={() => {
|
|
366
369
|
if (selectedPath.length > 0) {
|
|
367
370
|
setSelectedPath(selectedPath.slice(0, -1));
|
|
@@ -373,7 +376,13 @@ export default function FileExplorerPage() {
|
|
|
373
376
|
<IconButton
|
|
374
377
|
variant="ghost"
|
|
375
378
|
size="sm"
|
|
376
|
-
icon={
|
|
379
|
+
icon={
|
|
380
|
+
<Icon
|
|
381
|
+
icon={ChevronRightIcon}
|
|
382
|
+
size="sm"
|
|
383
|
+
xstyle={rtlStyles.mirror}
|
|
384
|
+
/>
|
|
385
|
+
}
|
|
377
386
|
isDisabled
|
|
378
387
|
label="Go forward"
|
|
379
388
|
/>
|
|
@@ -449,86 +458,101 @@ export default function FileExplorerPage() {
|
|
|
449
458
|
}
|
|
450
459
|
content={
|
|
451
460
|
<LayoutContent padding={0} isScrollable={false}>
|
|
452
|
-
<HStack height="100%"
|
|
461
|
+
<HStack height="100%" isScrollable>
|
|
453
462
|
{columns.map((col, colIndex) => {
|
|
454
463
|
const showDivider =
|
|
455
464
|
colIndex < columns.length - 1 || selectedFile != null;
|
|
456
465
|
return (
|
|
457
|
-
<
|
|
466
|
+
<StackItem
|
|
458
467
|
key={colIndex}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
}
|
|
485
|
-
size="sm"
|
|
486
|
-
/>
|
|
487
|
-
}
|
|
488
|
-
endContent={
|
|
489
|
-
hasChildren ? (
|
|
468
|
+
size="static"
|
|
469
|
+
isScrollable
|
|
470
|
+
aria-label={
|
|
471
|
+
colIndex === 0
|
|
472
|
+
? 'Home'
|
|
473
|
+
: findItem(FILESYSTEM, selectedPath[colIndex - 1])?.name
|
|
474
|
+
}>
|
|
475
|
+
<Section
|
|
476
|
+
width={240}
|
|
477
|
+
height="100%"
|
|
478
|
+
padding={2}
|
|
479
|
+
variant="transparent"
|
|
480
|
+
dividers={showDivider ? ['end'] : undefined}>
|
|
481
|
+
<List density="compact" hasDividers={false}>
|
|
482
|
+
{col.items.map(item => {
|
|
483
|
+
const isSelected = col.selectedId === item.id;
|
|
484
|
+
const hasChildren =
|
|
485
|
+
item.type === 'folder' &&
|
|
486
|
+
item.children != null &&
|
|
487
|
+
item.children.length > 0;
|
|
488
|
+
return (
|
|
489
|
+
<ListItem
|
|
490
|
+
key={item.id}
|
|
491
|
+
label={item.name}
|
|
492
|
+
startContent={
|
|
490
493
|
<Icon
|
|
491
|
-
icon={
|
|
492
|
-
|
|
493
|
-
|
|
494
|
+
icon={
|
|
495
|
+
item.type === 'folder'
|
|
496
|
+
? FolderIcon
|
|
497
|
+
: DocumentIcon
|
|
498
|
+
}
|
|
499
|
+
color={
|
|
500
|
+
item.type === 'folder'
|
|
501
|
+
? 'accent'
|
|
502
|
+
: 'secondary'
|
|
503
|
+
}
|
|
504
|
+
size="sm"
|
|
494
505
|
/>
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
506
|
+
}
|
|
507
|
+
endContent={
|
|
508
|
+
hasChildren ? (
|
|
509
|
+
<Icon
|
|
510
|
+
icon={ChevronRightIcon}
|
|
511
|
+
size="xsm"
|
|
512
|
+
color="secondary"
|
|
513
|
+
xstyle={rtlStyles.mirror}
|
|
514
|
+
/>
|
|
515
|
+
) : undefined
|
|
516
|
+
}
|
|
517
|
+
onClick={() => handleSelect(colIndex, item.id)}
|
|
518
|
+
isSelected={isSelected}
|
|
519
|
+
/>
|
|
520
|
+
);
|
|
521
|
+
})}
|
|
522
|
+
</List>
|
|
523
|
+
</Section>
|
|
524
|
+
</StackItem>
|
|
504
525
|
);
|
|
505
526
|
})}
|
|
506
527
|
{selectedFile && (
|
|
507
|
-
<
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
<VStack gap={
|
|
514
|
-
<
|
|
515
|
-
<
|
|
516
|
-
{
|
|
517
|
-
|
|
528
|
+
<StackItem
|
|
529
|
+
size="fill"
|
|
530
|
+
isScrollable
|
|
531
|
+
aria-label={selectedFile.name}
|
|
532
|
+
style={detailFloor}>
|
|
533
|
+
<Section padding={6} variant="transparent">
|
|
534
|
+
<VStack gap={4} hAlign="center">
|
|
535
|
+
<Avatar name={selectedFile.name} size={96} />
|
|
536
|
+
<VStack gap={1} hAlign="center">
|
|
537
|
+
<Text type="label">{selectedFile.name}</Text>
|
|
538
|
+
<Text type="supporting">
|
|
539
|
+
{getFileExtension(selectedFile.name)} Document
|
|
540
|
+
</Text>
|
|
541
|
+
</VStack>
|
|
542
|
+
<MetadataList title="Information">
|
|
543
|
+
<MetadataListItem label="Created">
|
|
544
|
+
March 28, 2026 at 2:15 PM
|
|
545
|
+
</MetadataListItem>
|
|
546
|
+
<MetadataListItem label="Modified">
|
|
547
|
+
Yesterday, 10:27 PM
|
|
548
|
+
</MetadataListItem>
|
|
549
|
+
<MetadataListItem label="Kind">
|
|
550
|
+
{getFileExtension(selectedFile.name)} Document
|
|
551
|
+
</MetadataListItem>
|
|
552
|
+
</MetadataList>
|
|
518
553
|
</VStack>
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
March 28, 2026 at 2:15 PM
|
|
522
|
-
</MetadataListItem>
|
|
523
|
-
<MetadataListItem label="Modified">
|
|
524
|
-
Yesterday, 10:27 PM
|
|
525
|
-
</MetadataListItem>
|
|
526
|
-
<MetadataListItem label="Kind">
|
|
527
|
-
{getFileExtension(selectedFile.name)} Document
|
|
528
|
-
</MetadataListItem>
|
|
529
|
-
</MetadataList>
|
|
530
|
-
</VStack>
|
|
531
|
-
</Section>
|
|
554
|
+
</Section>
|
|
555
|
+
</StackItem>
|
|
532
556
|
)}
|
|
533
557
|
</HStack>
|
|
534
558
|
</LayoutContent>
|
|
@@ -16,8 +16,11 @@ export const doc = {
|
|
|
16
16
|
summary: 'Copy component source for customization',
|
|
17
17
|
description:
|
|
18
18
|
"Ejects a component's source from the resolved @astryxdesign/core (or its owning " +
|
|
19
|
-
'integration) into your project for deep customization
|
|
20
|
-
'
|
|
19
|
+
'integration) into your project for deep customization. Every import in the copy ' +
|
|
20
|
+
'names a file the copy holds or a path the package exports: names the package ' +
|
|
21
|
+
'exports come from the package, and every internal module the component needs ' +
|
|
22
|
+
"is copied beside it in the package's folder layout. " +
|
|
23
|
+
'Tests, stories and docs are not copied. With no name it lists the swizzlable components. ' +
|
|
21
24
|
'An integration component that replaces a Core component is what that Core name ' +
|
|
22
25
|
'copies; --package @astryxdesign/core copies the original. --list lists Core ' +
|
|
23
26
|
'components, including one an integration replaces.',
|
|
@@ -46,7 +49,7 @@ export const doc = {
|
|
|
46
49
|
flag: '-f, --overwrite',
|
|
47
50
|
param: 'options.overwrite',
|
|
48
51
|
description:
|
|
49
|
-
|
|
52
|
+
"Replace the component's existing files. Without it, existing files fail the command with ERR_FILE_EXISTS and nothing is written. A helper an earlier swizzle wrote is reused when it is the same and is never replaced by a copy that carries it: a different one stays, and this copy writes its own under a version-suffixed name. Swizzling the component whose folder holds that helper counts it as one of that component's own files. A changed private attribute owner module, or a style module it imports, fails the command without --overwrite and is replaced with it",
|
|
50
53
|
},
|
|
51
54
|
],
|
|
52
55
|
examples: [
|
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @file swizzle command — thin wrapper around api/swizzle.
|
|
5
5
|
*
|
|
6
|
-
* Copies a component's source into the consumer project for customization
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* commands for the caller's package manager.
|
|
6
|
+
* Copies a component's source into the consumer project for customization,
|
|
7
|
+
* with the internal modules it needs. All logic — owner resolution, the copy,
|
|
8
|
+
* StyleX detection, maintainer feedback — lives in api/swizzle; this file only
|
|
9
|
+
* parses flags, prints, and prefixes commands for the caller's package manager.
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
import {jsonOut} from '../../../foundation/response/json.mjs';
|
|
@@ -85,18 +84,18 @@ export function registerSwizzle(program) {
|
|
|
85
84
|
text(`[ok] Copied ${filesCopied} files to ${outputDir}/`),
|
|
86
85
|
text(
|
|
87
86
|
[
|
|
88
|
-
`
|
|
87
|
+
`What ${ownerPackage} exports is imported from ${ownerPackage}; the internal modules the component needs are copied beside it.`,
|
|
89
88
|
'You can now customize the component source freely.',
|
|
90
89
|
].join('\n'),
|
|
91
90
|
),
|
|
92
91
|
];
|
|
93
|
-
// Files the copy wrote outside the component folder: the
|
|
94
|
-
//
|
|
92
|
+
// Files the copy wrote outside the component folder: the internal
|
|
93
|
+
// modules it needs, in the package's folder layout.
|
|
95
94
|
const shared = (result.data.files ?? []).filter(f => f.startsWith('../'));
|
|
96
95
|
if (shared.length > 0) {
|
|
97
96
|
out.push(
|
|
98
97
|
text(
|
|
99
|
-
`
|
|
98
|
+
`Copied beside it: ${shared.join(', ')} (in the package's folder layout; imported by relative path)`,
|
|
100
99
|
),
|
|
101
100
|
);
|
|
102
101
|
}
|
|
@@ -44,8 +44,9 @@ import * as path from 'node:path';
|
|
|
44
44
|
import {findInstalledPackage} from '../fs/paths.mjs';
|
|
45
45
|
import {satisfiesRange} from '../env/semver.mjs';
|
|
46
46
|
import {
|
|
47
|
-
NOTICE_FILE_RE,
|
|
48
47
|
discoverIconSetDirectory,
|
|
48
|
+
hasLicenseNotice,
|
|
49
|
+
licenseNoticeFix,
|
|
49
50
|
resolveIconModule,
|
|
50
51
|
splitSpecifier,
|
|
51
52
|
} from './icon-set-discovery.mjs';
|
|
@@ -1003,14 +1004,11 @@ function checkUpstream(set, packageDir, pkg) {
|
|
|
1003
1004
|
),
|
|
1004
1005
|
);
|
|
1005
1006
|
}
|
|
1006
|
-
|
|
1007
|
-
NOTICE_FILE_RE.test(name),
|
|
1008
|
-
);
|
|
1009
|
-
if (set.notices.length === 0 && rootNotices.length === 0) {
|
|
1007
|
+
if (!hasLicenseNotice(set.dir) && !hasLicenseNotice(packageDir)) {
|
|
1010
1008
|
issues.push(
|
|
1011
1009
|
issueWarning(
|
|
1012
1010
|
ICON_LICENSE_NOTICE_MISSING,
|
|
1013
|
-
`${label} is generated from ${source.package} but ships no license notice.
|
|
1011
|
+
`${label} is generated from ${source.package}@${source.version} but ships no license notice. ${licenseNoticeFix(path.relative(packageDir, set.dir).split(path.sep).join('/'), `${source.package}@${source.version}`)} If the library ships a LICENSE or NOTICE file, copy that file there instead.`,
|
|
1014
1012
|
),
|
|
1015
1013
|
);
|
|
1016
1014
|
}
|
|
@@ -1026,12 +1024,3 @@ function safeSatisfies(version, range) {
|
|
|
1026
1024
|
return true;
|
|
1027
1025
|
}
|
|
1028
1026
|
}
|
|
1029
|
-
|
|
1030
|
-
/** @param {string} dir */
|
|
1031
|
-
function safeList(dir) {
|
|
1032
|
-
try {
|
|
1033
|
-
return fs.readdirSync(dir);
|
|
1034
|
-
} catch {
|
|
1035
|
-
return [];
|
|
1036
|
-
}
|
|
1037
|
-
}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* What to add when a set wraps a library and has no license notice: a
|
|
6
|
+
* NOTICE file in the set directory, with the file names that count. The
|
|
7
|
+
* CLI never writes it, because the license text is the author's to state.
|
|
8
|
+
* @param {string} setDir the set directory, from the package root
|
|
9
|
+
* @param {string} library the library as `name@version`
|
|
10
|
+
*/
|
|
11
|
+
export function licenseNoticeFix(setDir: string, library: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Whether a directory has a license or notice file ({@link NOTICE_FILE_RE}).
|
|
14
|
+
* @param {string} dir
|
|
15
|
+
*/
|
|
16
|
+
export function hasLicenseNotice(dir: string): boolean;
|
|
4
17
|
/**
|
|
5
18
|
* One installed icon set: its descriptor, its data, and where it came from.
|
|
6
19
|
* @typedef {object} DiscoveredIconSet
|
|
@@ -43,6 +43,31 @@ const SET_NAME_RE = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;
|
|
|
43
43
|
/** A license or notice file a set ships beside its data (FR15). */
|
|
44
44
|
export const NOTICE_FILE_RE = /^(?:licen[cs]e|notice|copying)(?:[.-].*)?$/iu;
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* What to add when a set wraps a library and has no license notice: a
|
|
48
|
+
* NOTICE file in the set directory, with the file names that count. The
|
|
49
|
+
* CLI never writes it, because the license text is the author's to state.
|
|
50
|
+
* @param {string} setDir the set directory, from the package root
|
|
51
|
+
* @param {string} library the library as `name@version`
|
|
52
|
+
*/
|
|
53
|
+
export function licenseNoticeFix(setDir, library) {
|
|
54
|
+
return `Add a NOTICE (or LICENSE) file to ${setDir} that names ${library} and its license: \`${setDir}/NOTICE\`. A file named LICENSE, LICENCE, NOTICE, or COPYING, in any case and with an optional suffix such as NOTICE.md or LICENSE-MIT, counts in the set directory or the package root.`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Whether a directory has a license or notice file ({@link NOTICE_FILE_RE}).
|
|
59
|
+
* @param {string} dir
|
|
60
|
+
*/
|
|
61
|
+
export function hasLicenseNotice(dir) {
|
|
62
|
+
try {
|
|
63
|
+
return fs
|
|
64
|
+
.readdirSync(dir, {withFileTypes: true})
|
|
65
|
+
.some(file => file.isFile() && NOTICE_FILE_RE.test(file.name));
|
|
66
|
+
} catch {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
46
71
|
/**
|
|
47
72
|
* One installed icon set: its descriptor, its data, and where it came from.
|
|
48
73
|
* @typedef {object} DiscoveredIconSet
|
|
@@ -461,6 +461,34 @@ export function sameIconModule(a: string, b: string): boolean;
|
|
|
461
461
|
* @param {string} specifier
|
|
462
462
|
*/
|
|
463
463
|
export function iconModulePackage(specifier: string): string;
|
|
464
|
+
/**
|
|
465
|
+
* The set's exports that read one file of a package, where a refresh from
|
|
466
|
+
* that package's root can read them from the root instead. An export moves
|
|
467
|
+
* when the root exports the same icon: an export that resolves to the same
|
|
468
|
+
* file and binding. When the subpath export cannot be resolved, a root
|
|
469
|
+
* export of the same name counts. Each maps to the root's
|
|
470
|
+
* export and the module it reads now. Empty unless `root` is a package
|
|
471
|
+
* root, not a subpath or a ./ path.
|
|
472
|
+
* @param {Map<string, {module: string, source: string}>} origins the
|
|
473
|
+
* set's exports ({@link generatedOrigins})
|
|
474
|
+
* @param {{file: string, module: string}} root the refreshed module
|
|
475
|
+
* @param {string[]} rootExports the root's icon exports
|
|
476
|
+
* @param {{packageDir: string, pkg: Record<string, any>}} where
|
|
477
|
+
* @returns {Map<string, {source: string, from: string}>}
|
|
478
|
+
*/
|
|
479
|
+
export function packageRootMoves(origins: Map<string, {
|
|
480
|
+
module: string;
|
|
481
|
+
source: string;
|
|
482
|
+
}>, root: {
|
|
483
|
+
file: string;
|
|
484
|
+
module: string;
|
|
485
|
+
}, rootExports: string[], where: {
|
|
486
|
+
packageDir: string;
|
|
487
|
+
pkg: Record<string, any>;
|
|
488
|
+
}): Map<string, {
|
|
489
|
+
source: string;
|
|
490
|
+
from: string;
|
|
491
|
+
}>;
|
|
464
492
|
/**
|
|
465
493
|
* Write the set's generated module and its declaration file
|
|
466
494
|
* ({@link generatedModuleText}). Returns whether either changed, and a
|
|
@@ -1898,6 +1898,63 @@ export function iconModulePackage(specifier) {
|
|
|
1898
1898
|
return specifier.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0];
|
|
1899
1899
|
}
|
|
1900
1900
|
|
|
1901
|
+
/**
|
|
1902
|
+
* The set's exports that read one file of a package, where a refresh from
|
|
1903
|
+
* that package's root can read them from the root instead. An export moves
|
|
1904
|
+
* when the root exports the same icon: an export that resolves to the same
|
|
1905
|
+
* file and binding. When the subpath export cannot be resolved, a root
|
|
1906
|
+
* export of the same name counts. Each maps to the root's
|
|
1907
|
+
* export and the module it reads now. Empty unless `root` is a package
|
|
1908
|
+
* root, not a subpath or a ./ path.
|
|
1909
|
+
* @param {Map<string, {module: string, source: string}>} origins the
|
|
1910
|
+
* set's exports ({@link generatedOrigins})
|
|
1911
|
+
* @param {{file: string, module: string}} root the refreshed module
|
|
1912
|
+
* @param {string[]} rootExports the root's icon exports
|
|
1913
|
+
* @param {{packageDir: string, pkg: Record<string, any>}} where
|
|
1914
|
+
* @returns {Map<string, {source: string, from: string}>}
|
|
1915
|
+
*/
|
|
1916
|
+
export function packageRootMoves(origins, root, rootExports, where) {
|
|
1917
|
+
/** @type {Map<string, {source: string, from: string}>} */
|
|
1918
|
+
const moves = new Map();
|
|
1919
|
+
if (iconModulePackage(root.module) !== root.module) return moves;
|
|
1920
|
+
if (root.module.startsWith('.')) return moves;
|
|
1921
|
+
const subpaths = [...origins].filter(
|
|
1922
|
+
([, origin]) =>
|
|
1923
|
+
!origin.module.startsWith('.') &&
|
|
1924
|
+
origin.module !== root.module &&
|
|
1925
|
+
iconModulePackage(origin.module) === root.module,
|
|
1926
|
+
);
|
|
1927
|
+
if (subpaths.length === 0) return moves;
|
|
1928
|
+
/** @param {{file: string, name: string}} origin */
|
|
1929
|
+
const keyOf = origin => `${origin.file}\0${origin.name}`;
|
|
1930
|
+
/** @type {Map<string, string>} */
|
|
1931
|
+
const byOrigin = new Map();
|
|
1932
|
+
for (const name of rootExports) {
|
|
1933
|
+
const origin = moduleExportOrigin(root.file, name);
|
|
1934
|
+
if (origin && !byOrigin.has(keyOf(origin))) {
|
|
1935
|
+
byOrigin.set(keyOf(origin), name);
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
const names = new Set(rootExports);
|
|
1939
|
+
const self = {
|
|
1940
|
+
name: typeof where.pkg.name === 'string' ? where.pkg.name : '',
|
|
1941
|
+
dir: where.packageDir,
|
|
1942
|
+
};
|
|
1943
|
+
for (const [name, origin] of subpaths) {
|
|
1944
|
+
const file = resolveIconModule(origin.module, where.packageDir, self);
|
|
1945
|
+
const resolved = file ? moduleExportOrigin(file, origin.source) : null;
|
|
1946
|
+
// A name match counts only when the subpath export cannot be resolved.
|
|
1947
|
+
// A resolved export is the same icon only when it reads the same file.
|
|
1948
|
+
const source = resolved
|
|
1949
|
+
? byOrigin.get(keyOf(resolved))
|
|
1950
|
+
: names.has(origin.source)
|
|
1951
|
+
? origin.source
|
|
1952
|
+
: undefined;
|
|
1953
|
+
if (source) moves.set(name, {source, from: origin.module});
|
|
1954
|
+
}
|
|
1955
|
+
return moves;
|
|
1956
|
+
}
|
|
1957
|
+
|
|
1901
1958
|
/**
|
|
1902
1959
|
* Write the set's generated module and its declaration file
|
|
1903
1960
|
* ({@link generatedModuleText}). Returns whether either changed, and a
|