@astryxdesign/cli 0.7.4 → 0.7.5-canary.2a50a80
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 +18 -18
- package/api/icon/_adapter.d.mts +3 -2
- package/api/icon/_adapter.mjs +16 -3
- package/api/icon/_authoring.d.mts +5 -1
- package/api/icon/_authoring.mjs +478 -63
- package/api/icon/_options.d.mts +11 -0
- package/api/icon/_options.mjs +39 -4
- package/api/icon/_records.d.mts +19 -0
- package/api/icon/_records.mjs +25 -0
- package/api/icon/add/add.d.mts +3 -3
- package/api/icon/add/add.mjs +227 -14
- package/api/icon/all-or-nothing.test.mjs +283 -0
- package/api/icon/detail/detail.mjs +2 -13
- package/api/icon/error-codes.test.mjs +14 -7
- package/api/icon/icon.d.mts +2 -2
- package/api/icon/icon.doc.mjs +30 -2
- package/api/icon/icon.mjs +57 -8
- package/api/icon/icon.test.mjs +133 -1
- package/api/icon/icon.type.d.mts +126 -1
- package/api/icon/icon.type.mjs +67 -3
- package/api/icon/iconAdd.doc.mjs +22 -6
- package/api/icon/iconMap.doc.mjs +24 -8
- package/api/icon/iconNewDefinition.doc.mjs +2 -2
- package/api/icon/iconNewSet.doc.mjs +30 -2
- package/api/icon/iconUse.doc.mjs +4 -1
- package/api/icon/map/map.d.mts +4 -4
- package/api/icon/map/map.mjs +134 -9
- package/api/icon/new-definition/new-definition.mjs +6 -2
- package/api/icon/new-set/new-set.mjs +2 -2
- package/api/icon/new-set/new-set.test.mjs +60 -10
- package/api/icon/option-pairs.test.mjs +368 -0
- package/api/icon/search/search.d.mts +10 -0
- package/api/icon/search/search.mjs +55 -14
- package/api/icon/use/use.mjs +2 -13
- package/api/integration/add-helpers.d.mts +15 -1
- package/api/integration/add-helpers.mjs +1 -1
- package/api/integration/validate-integration.type.d.mts +3 -2
- package/api/integration/validate-integration.type.mjs +3 -2
- package/api/template/template.type.d.mts +2 -1
- package/api/template/template.type.mjs +1 -1
- package/assets/discover/official-packages.json +4 -0
- package/assets/docs/tree/icon-definitions.doc.mjs +2 -2
- package/assets/docs/tree/icon-set-files.doc.mjs +1 -1
- package/assets/docs/tree/icon-sets.doc.mjs +50 -20
- package/assets/icons/definitions/activity.doc.mjs +1 -1
- package/assets/icons/definitions/alignCenter.doc.mjs +9 -0
- package/assets/icons/definitions/alignEnd.doc.mjs +10 -0
- package/assets/icons/definitions/alignStart.doc.mjs +10 -0
- package/assets/icons/definitions/archive.doc.mjs +1 -1
- package/assets/icons/definitions/arrowsUpDown.doc.mjs +1 -1
- package/assets/icons/definitions/attach.doc.mjs +1 -1
- package/assets/icons/definitions/audio.doc.mjs +1 -1
- package/assets/icons/definitions/cart.doc.mjs +1 -1
- package/assets/icons/definitions/checkDouble.doc.mjs +1 -1
- package/assets/icons/definitions/chevronsLeft.doc.mjs +1 -1
- package/assets/icons/definitions/chevronsRight.doc.mjs +1 -1
- package/assets/icons/definitions/close.doc.mjs +1 -1
- package/assets/icons/definitions/collapse.doc.mjs +1 -1
- package/assets/icons/definitions/compose.doc.mjs +1 -1
- package/assets/icons/definitions/conversation.doc.mjs +1 -1
- package/assets/icons/definitions/copy.doc.mjs +1 -1
- package/assets/icons/definitions/cpu.doc.mjs +9 -0
- package/assets/icons/definitions/database.doc.mjs +1 -1
- package/assets/icons/definitions/desktop.doc.mjs +1 -1
- package/assets/icons/definitions/discount.doc.mjs +1 -1
- package/assets/icons/definitions/download.doc.mjs +1 -1
- package/assets/icons/definitions/emoji.doc.mjs +1 -1
- package/assets/icons/definitions/error.doc.mjs +1 -1
- package/assets/icons/definitions/expand.doc.mjs +1 -1
- package/assets/icons/definitions/experiment.doc.mjs +1 -1
- package/assets/icons/definitions/externalLink.doc.mjs +7 -1
- package/assets/icons/definitions/eyeSlash.doc.mjs +1 -1
- package/assets/icons/definitions/flipHorizontal.doc.mjs +9 -0
- package/assets/icons/definitions/flipVertical.doc.mjs +9 -0
- package/assets/icons/definitions/folderAdd.doc.mjs +1 -1
- package/assets/icons/definitions/gitBranch.doc.mjs +9 -0
- package/assets/icons/definitions/gitFork.doc.mjs +9 -0
- package/assets/icons/definitions/info.doc.mjs +1 -1
- package/assets/icons/definitions/location.doc.mjs +1 -1
- package/assets/icons/definitions/mention.doc.mjs +1 -1
- package/assets/icons/definitions/menu.doc.mjs +1 -1
- package/assets/icons/definitions/microphone.doc.mjs +1 -1
- package/assets/icons/definitions/mobile.doc.mjs +1 -1
- package/assets/icons/definitions/money.doc.mjs +1 -1
- package/assets/icons/definitions/moreHorizontal.doc.mjs +1 -1
- package/assets/icons/definitions/notificationActive.doc.mjs +1 -1
- package/assets/icons/definitions/notificationOff.doc.mjs +1 -1
- package/assets/icons/definitions/panelLeft.doc.mjs +10 -0
- package/assets/icons/definitions/panelRight.doc.mjs +10 -0
- package/assets/icons/definitions/raiseHand.doc.mjs +1 -1
- package/assets/icons/definitions/redo.doc.mjs +1 -1
- package/assets/icons/definitions/refresh.doc.mjs +1 -1
- package/assets/icons/definitions/rotate.doc.mjs +9 -0
- package/assets/icons/definitions/scale.doc.mjs +10 -0
- package/assets/icons/definitions/search.doc.mjs +1 -1
- package/assets/icons/definitions/send.doc.mjs +1 -1
- package/assets/icons/definitions/settings.doc.mjs +1 -1
- package/assets/icons/definitions/star.doc.mjs +1 -1
- package/assets/icons/definitions/stop.doc.mjs +1 -1
- package/assets/icons/definitions/success.doc.mjs +1 -1
- package/assets/icons/definitions/textCase.doc.mjs +9 -0
- package/assets/icons/definitions/thumbsDown.doc.mjs +1 -1
- package/assets/icons/definitions/thumbsUp.doc.mjs +1 -1
- package/assets/icons/definitions/trendDown.doc.mjs +7 -1
- package/assets/icons/definitions/trendUp.doc.mjs +1 -1
- package/assets/icons/definitions/undo.doc.mjs +1 -1
- package/assets/icons/definitions/upload.doc.mjs +1 -1
- package/assets/icons/definitions/userAdd.doc.mjs +1 -1
- package/assets/icons/definitions/warning.doc.mjs +1 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx +15 -14
- package/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx +30 -30
- package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +15 -14
- package/assets/templates/blocks/components/Tokenizer/TokenizerIcon.tsx +15 -14
- package/assets/templates/blocks/components/Tokenizer/TokenizerMaxEntries.tsx +17 -16
- package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx +29 -29
- package/assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx +9 -8
- package/assets/templates/blocks/components/Tokenizer/TokenizerStates.tsx +39 -41
- package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -0
- package/assets/templates/pages/form-wizard-inline/template.doc.mjs +6 -1
- package/assets/templates/pages/table-comparison/template.doc.mjs +1 -0
- package/assets/templates/pages/table-tree/template.doc.mjs +3 -0
- package/authoring/doctypes/icon-definition/icon-definition.doc.mjs +4 -4
- package/authoring/doctypes/icon-set/icon-set-data.doc.mjs +6 -0
- package/authoring/doctypes/icon-set/parse.d.mts +1 -0
- package/authoring/doctypes/icon-set/parse.mjs +1 -0
- package/authoring/doctypes/icon-set/type.ts +5 -0
- package/authoring/doctypes/template/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +2 -1
- package/clients/cli/commands/doctor.mjs +16 -17
- package/clients/cli/commands/experimental/icon.mjs +167 -35
- package/clients/cli/commands/experimental-icon-add.doc.mjs +14 -4
- package/clients/cli/commands/experimental-icon-map.doc.mjs +12 -2
- package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon-new-set.doc.mjs +28 -1
- package/clients/cli/commands/experimental-icon.doc.mjs +18 -2
- package/clients/cli/commands/experimental.doc.mjs +2 -1
- package/clients/cli/commands/icon-authoring.test.mjs +1823 -13
- package/clients/cli/commands/icon-options-wiring.test.mjs +158 -0
- package/clients/cli/commands/icon.test.mjs +1 -1
- package/clients/cli/commands/template.mjs +4 -1
- package/foundation/discovery/component-discovery.d.mts +2 -1
- package/foundation/discovery/component-discovery.export-names.test.mjs +41 -0
- package/foundation/discovery/component-discovery.mjs +13 -7
- package/foundation/discovery/icon-set-checks.d.mts +43 -9
- package/foundation/discovery/icon-set-checks.mjs +296 -21
- package/foundation/discovery/icon-set-checks.test.mjs +125 -12
- package/foundation/discovery/icon-set-writer.d.mts +192 -3
- package/foundation/discovery/icon-set-writer.mjs +608 -34
- package/foundation/discovery/icon-set-writer.test.mjs +26 -0
- package/foundation/discovery/module-exports.mjs +82 -25
- package/foundation/discovery/module-exports.test.mjs +38 -1
- package/foundation/discovery/package-exports.d.mts +13 -0
- package/foundation/discovery/package-exports.mjs +40 -1
- package/foundation/discovery/template-icons.d.mts +6 -0
- package/foundation/discovery/template-icons.mjs +98 -10
- package/foundation/discovery/template-icons.test.mjs +103 -0
- package/foundation/doc-compiler/tree.mjs +3 -1
- package/foundation/response/response-types.doc.mjs +25 -1
- package/foundation/text/string-utils.mjs +33 -0
- package/foundation/text/string-utils.test.mjs +17 -0
- package/package.json +9 -9
|
@@ -9,5 +9,10 @@ export const doc = {
|
|
|
9
9
|
'Accordion wizard stacking every step in one column: the active step expands in place while finished ones collapse to a single line carrying their result and a way back in. Steps that run themselves expand into a nested stepper that ticks check by check and halts the column where one fails. Best when later steps depend on what earlier ones decided.',
|
|
10
10
|
isReady: true,
|
|
11
11
|
category: 'Form - Wizard Inline',
|
|
12
|
-
icons: {
|
|
12
|
+
icons: {
|
|
13
|
+
BeakerIcon: 'experiment',
|
|
14
|
+
BoltIcon: 'bolt',
|
|
15
|
+
CpuChipIcon: 'cpu',
|
|
16
|
+
CubeIcon: 'package',
|
|
17
|
+
},
|
|
13
18
|
};
|
|
@@ -62,13 +62,13 @@ export const doc = {
|
|
|
62
62
|
examples: [
|
|
63
63
|
{
|
|
64
64
|
label:
|
|
65
|
-
"A set's own definition at icon-sets/outline/definitions/
|
|
65
|
+
"A set's own definition at icon-sets/outline/definitions/random.doc.mjs",
|
|
66
66
|
code: `/** @type {import('@astryxdesign/cli/authoring').IconDefinitionDoc} */
|
|
67
67
|
export default {
|
|
68
68
|
type: 'icon-definition',
|
|
69
|
-
name: '
|
|
70
|
-
description: '
|
|
71
|
-
words: ['
|
|
69
|
+
name: 'random',
|
|
70
|
+
description: 'Pick something at random.',
|
|
71
|
+
words: ['dice', 'shuffle', 'chance'],
|
|
72
72
|
};`,
|
|
73
73
|
},
|
|
74
74
|
],
|
|
@@ -37,6 +37,12 @@ export const doc = {
|
|
|
37
37
|
description:
|
|
38
38
|
'The upstream library and version the file was generated from. Omit it for a set with no upstream.',
|
|
39
39
|
},
|
|
40
|
+
{
|
|
41
|
+
name: 'exclude',
|
|
42
|
+
type: 'string[]',
|
|
43
|
+
description:
|
|
44
|
+
'Library exports that are not icons. `experimental icon new-set --from` leaves them out every time it wraps or refreshes the set; `--exclude` adds to the list. A CLI whose reference does not list this key withdraws a set that sets it, naming the key; leave it out for a set those CLIs must read.',
|
|
45
|
+
},
|
|
40
46
|
{
|
|
41
47
|
name: 'generated',
|
|
42
48
|
type: 'string',
|
|
@@ -69,6 +69,7 @@ declare const dataSchema: z.ZodObject<{
|
|
|
69
69
|
package: z.ZodString;
|
|
70
70
|
version: z.ZodString;
|
|
71
71
|
}, z.core.$strict>>;
|
|
72
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
72
73
|
variants: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
73
74
|
default: z.ZodOptional<z.ZodObject<{
|
|
74
75
|
variant: z.ZodOptional<z.ZodString>;
|
|
@@ -146,6 +146,11 @@ export interface IconSetData {
|
|
|
146
146
|
module: string;
|
|
147
147
|
/** The upstream library, absent for a set with no upstream. */
|
|
148
148
|
source?: IconSetSource;
|
|
149
|
+
/**
|
|
150
|
+
* Library exports that are not icons, left out every time
|
|
151
|
+
* `astryx experimental icon new-set --from` wraps or refreshes the set.
|
|
152
|
+
*/
|
|
153
|
+
exclude?: string[];
|
|
149
154
|
/**
|
|
150
155
|
* The variants the set supplies, lower-kebab names such as `outline` and
|
|
151
156
|
* `solid`; absent when it has one look. A variant is a named look the set
|
|
@@ -69,7 +69,7 @@ export const doc = {
|
|
|
69
69
|
type: 'Record<string, string>',
|
|
70
70
|
stability: 'experimental',
|
|
71
71
|
description:
|
|
72
|
-
"The icon definition each icon the source imports draws, such as `{TrashIcon: 'delete'}`: a named import is keyed by the name it imports (`{Trash as TrashIcon}` is `Trash`), a default import by its local name (`import DeleteIcon from …` is `DeleteIcon`). When the project sets `experimental.iconSet`, `astryx template` (shown or copied) replaces each declared icon with the set's icon for that definition (`astryx docs cli/experimental/icon-definitions`) and reports every key as mapped or kept; an undeclared import is left alone.",
|
|
72
|
+
"The icon definition each icon the source imports draws, such as `{TrashIcon: 'delete'}`: a named import is keyed by the name it imports (`{Trash as TrashIcon}` is `Trash`), a default import by its local name (`import DeleteIcon from …` is `DeleteIcon`). When the project sets `experimental.iconSet`, `astryx template` (shown or copied) replaces each declared icon with the set's icon for that definition (`astryx docs cli/experimental/icon-definitions`) and reports every key as mapped or kept; an undeclared import is left alone. A name imported from two modules (`TrashIcon` from an outline and a solid module) needs one key, and each import keeps its variant when its module belongs to an installed set.",
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
75
|
name: 'isReady',
|
|
@@ -57,7 +57,8 @@ export interface BaseTemplateDoc extends AuthoredDocGraphFields {
|
|
|
57
57
|
* (`import DeleteIcon from …` is `DeleteIcon`). When the project has an
|
|
58
58
|
* icon set, each declared icon is replaced by the set's icon for that
|
|
59
59
|
* definition (`astryx docs cli/experimental/icon-definitions`), and every
|
|
60
|
-
* key is reported as mapped or kept.
|
|
60
|
+
* key is reported as mapped or kept. A name imported from two modules
|
|
61
|
+
* (`TrashIcon` from an outline and a solid module) needs one key.
|
|
61
62
|
* @experimental May change or be removed in a patch release. */
|
|
62
63
|
icons?: Record<string, string>;
|
|
63
64
|
|
|
@@ -355,26 +355,25 @@ function unmappedBlocks(listed) {
|
|
|
355
355
|
listed.map(each => ({
|
|
356
356
|
set: each.set,
|
|
357
357
|
unmapped: each.unmappedDefinitions.length,
|
|
358
|
-
definitions: each.unmappedDefinitions
|
|
359
|
-
.map(definition => definition.name)
|
|
360
|
-
.join(', '),
|
|
361
358
|
})),
|
|
362
|
-
{fields: ['set', 'unmapped'
|
|
363
|
-
),
|
|
364
|
-
...listed.flatMap(each =>
|
|
365
|
-
each.suggestions.length > 0
|
|
366
|
-
? [
|
|
367
|
-
list(
|
|
368
|
-
each.suggestions.map(
|
|
369
|
-
({definition, icon}) =>
|
|
370
|
-
`astryx experimental icon map ${definition} ${icon}${listed.length === 1 ? '' : ` --set ${each.set}`}`,
|
|
371
|
-
),
|
|
372
|
-
),
|
|
373
|
-
]
|
|
374
|
-
: [],
|
|
359
|
+
{fields: ['set', 'unmapped']},
|
|
375
360
|
),
|
|
361
|
+
// One line per definition: what it means and its words, so an author
|
|
362
|
+
// can pick from the text alone; a suggested icon when one fits.
|
|
363
|
+
...listed.map(each => {
|
|
364
|
+
const suggested = new Map(
|
|
365
|
+
each.suggestions.map(({definition, icon}) => [definition, icon]),
|
|
366
|
+
);
|
|
367
|
+
const setFlag = listed.length === 1 ? '' : ` --set ${each.set}`;
|
|
368
|
+
return list(
|
|
369
|
+
each.unmappedDefinitions.map(
|
|
370
|
+
definition =>
|
|
371
|
+
`${definition.name}: ${definition.description} Words: ${definition.words.join(', ')}.${suggested.has(definition.name) ? ` Suggested: astryx experimental icon map ${definition.name} ${suggested.get(definition.name)}${setFlag}` : ''}`,
|
|
372
|
+
),
|
|
373
|
+
);
|
|
374
|
+
}),
|
|
376
375
|
text(
|
|
377
|
-
'Mapping these is optional and never fails a check. --
|
|
376
|
+
'Mapping these is optional and never fails a check. Map one with `astryx experimental icon map <definition> <icon id>`; list your icons with `astryx experimental icon --set <set> --all-icons`; see how many definitions each set maps with `astryx experimental icon --list`.',
|
|
378
377
|
),
|
|
379
378
|
];
|
|
380
379
|
}
|
|
@@ -68,7 +68,7 @@ export function registerExperimentalIcon(group, program) {
|
|
|
68
68
|
fn: iconFn,
|
|
69
69
|
action: async (
|
|
70
70
|
/** @type {string[] | string | undefined} */ words,
|
|
71
|
-
/** @type {{list?: boolean, set?: string, limit?: string}} */ options,
|
|
71
|
+
/** @type {{list?: boolean, set?: string, limit?: string, allIcons?: boolean, definitions?: boolean}} */ options,
|
|
72
72
|
) => {
|
|
73
73
|
const json = program.opts().json || false;
|
|
74
74
|
const query = Array.isArray(words) ? words.join(' ') : words;
|
|
@@ -83,6 +83,8 @@ export function registerExperimentalIcon(group, program) {
|
|
|
83
83
|
list: options.list ?? false,
|
|
84
84
|
set: options.set,
|
|
85
85
|
limit,
|
|
86
|
+
allIcons: options.allIcons ?? false,
|
|
87
|
+
definitions: options.definitions ?? false,
|
|
86
88
|
});
|
|
87
89
|
} catch (e) {
|
|
88
90
|
const err =
|
|
@@ -100,13 +102,24 @@ export function registerExperimentalIcon(group, program) {
|
|
|
100
102
|
resultKind: 'mixed',
|
|
101
103
|
empty: result.data.matchCount === 0,
|
|
102
104
|
})
|
|
103
|
-
: result.type === 'icon.
|
|
105
|
+
: result.type === 'icon.definitions'
|
|
104
106
|
? resultSet({
|
|
105
|
-
count: result.data.
|
|
107
|
+
count: result.data.definitions.length,
|
|
106
108
|
resultKind: 'mixed',
|
|
107
|
-
empty: result.data.sets.length === 0,
|
|
108
109
|
})
|
|
109
|
-
:
|
|
110
|
+
: result.type === 'icon.setIcons'
|
|
111
|
+
? resultSet({
|
|
112
|
+
count: result.data.icons.length,
|
|
113
|
+
resultKind: 'mixed',
|
|
114
|
+
empty: result.data.icons.length === 0,
|
|
115
|
+
})
|
|
116
|
+
: result.type === 'icon.list'
|
|
117
|
+
? resultSet({
|
|
118
|
+
count: result.data.sets.length,
|
|
119
|
+
resultKind: 'mixed',
|
|
120
|
+
empty: result.data.sets.length === 0,
|
|
121
|
+
})
|
|
122
|
+
: resultSet({count: 1, resultKind: 'mixed', directMatch: true});
|
|
110
123
|
|
|
111
124
|
if (json) {
|
|
112
125
|
jsonOut(result);
|
|
@@ -114,6 +127,40 @@ export function registerExperimentalIcon(group, program) {
|
|
|
114
127
|
}
|
|
115
128
|
|
|
116
129
|
const run = getCliInvocation();
|
|
130
|
+
if (result.type === 'icon.definitions') {
|
|
131
|
+
const {definitions} = result.data;
|
|
132
|
+
emit(
|
|
133
|
+
section(
|
|
134
|
+
`Icon definitions (${definitions.length}, ${definitions.filter(each => each.builtIn).length} built-in)`,
|
|
135
|
+
),
|
|
136
|
+
list(
|
|
137
|
+
definitions.map(
|
|
138
|
+
each =>
|
|
139
|
+
`${each.name} [${each.builtIn ? 'built-in' : 'optional'}]: ${each.description} Words: ${each.words.join(', ')}.`,
|
|
140
|
+
),
|
|
141
|
+
),
|
|
142
|
+
text(
|
|
143
|
+
`Built-in definitions are the ones every set maps. Map one: ${run} experimental icon map <definition> <icon id>`,
|
|
144
|
+
),
|
|
145
|
+
);
|
|
146
|
+
return answered;
|
|
147
|
+
}
|
|
148
|
+
if (result.type === 'icon.setIcons') {
|
|
149
|
+
const {set, iconCount, icons} = result.data;
|
|
150
|
+
emit(
|
|
151
|
+
section(`Icons in ${set} (${iconCount})`),
|
|
152
|
+
// One line each, so a whole library reads at a glance:
|
|
153
|
+
// id, then its words, then the definitions it draws.
|
|
154
|
+
list(
|
|
155
|
+
icons.map(
|
|
156
|
+
each =>
|
|
157
|
+
`${each.id}: ${each.words.join(', ')}${each.definitions.length > 0 ? ` = ${each.definitions.join(', ')}` : ''}`,
|
|
158
|
+
),
|
|
159
|
+
),
|
|
160
|
+
text(`Map one: ${run} experimental icon map <definition> <id>`),
|
|
161
|
+
);
|
|
162
|
+
return answered;
|
|
163
|
+
}
|
|
117
164
|
if (result.type === 'icon.search') {
|
|
118
165
|
const {query: q, matchCount, matches} = result.data;
|
|
119
166
|
if (matches.length === 0) {
|
|
@@ -129,13 +176,17 @@ export function registerExperimentalIcon(group, program) {
|
|
|
129
176
|
? `Icons for "${q}" (${matches.length} of ${matchCount})`
|
|
130
177
|
: `Icons for "${q}" (${matches.length})`,
|
|
131
178
|
),
|
|
132
|
-
//
|
|
133
|
-
// with
|
|
179
|
+
// The import draws the icon's default look; its other variants
|
|
180
|
+
// are named with their exports and read with `icon <set>/<id>`.
|
|
134
181
|
records(
|
|
135
182
|
matches.map(({variants, ...match}) => ({
|
|
136
183
|
...match,
|
|
137
184
|
...(variants.length > 0
|
|
138
|
-
? {
|
|
185
|
+
? {
|
|
186
|
+
variant: variants
|
|
187
|
+
.map(each => `${each.variant} (${each.export})`)
|
|
188
|
+
.join(', '),
|
|
189
|
+
}
|
|
139
190
|
: {}),
|
|
140
191
|
})),
|
|
141
192
|
{
|
|
@@ -175,7 +226,7 @@ export function registerExperimentalIcon(group, program) {
|
|
|
175
226
|
}),
|
|
176
227
|
...(variants.length > 0
|
|
177
228
|
? [
|
|
178
|
-
section('
|
|
229
|
+
section('Other variants'),
|
|
179
230
|
records(variants, {
|
|
180
231
|
fields: ['variant', 'module', 'export', 'import'],
|
|
181
232
|
}),
|
|
@@ -239,6 +290,18 @@ export function registerExperimentalIcon(group, program) {
|
|
|
239
290
|
},
|
|
240
291
|
});
|
|
241
292
|
|
|
293
|
+
/**
|
|
294
|
+
* The set an authoring subcommand edits. `experimental icon` declares
|
|
295
|
+
* `--set` too, so Commander gives the parent a `--set` written after a
|
|
296
|
+
* subcommand's name; the subcommand reads it there.
|
|
297
|
+
* @param {{set?: unknown}} options the subcommand's own options
|
|
298
|
+
* @returns {string | undefined}
|
|
299
|
+
*/
|
|
300
|
+
const setOf = options => {
|
|
301
|
+
const value = options.set ?? iconCli.opts().set;
|
|
302
|
+
return typeof value === 'string' ? value : undefined;
|
|
303
|
+
};
|
|
304
|
+
|
|
242
305
|
/**
|
|
243
306
|
* Run one authoring call and print its receipt, or its error.
|
|
244
307
|
* @param {() => Promise<any>} call
|
|
@@ -284,36 +347,51 @@ export function registerExperimentalIcon(group, program) {
|
|
|
284
347
|
defineCommand(iconCli, iconMapCommand, {
|
|
285
348
|
fn: iconMapFn,
|
|
286
349
|
action: (
|
|
287
|
-
/** @type {string} */ definition,
|
|
350
|
+
/** @type {string | undefined} */ definition,
|
|
288
351
|
/** @type {string | undefined} */ iconId,
|
|
289
|
-
/** @type {{set?: string, remove?: boolean}} */ options,
|
|
352
|
+
/** @type {{set?: string, remove?: boolean, pairs?: string}} */ options,
|
|
290
353
|
) =>
|
|
291
354
|
run(
|
|
292
355
|
() =>
|
|
293
356
|
iconMap(definition, iconId, {
|
|
294
357
|
cwd: process.cwd(),
|
|
295
|
-
set: options
|
|
358
|
+
set: setOf(options),
|
|
296
359
|
remove: options.remove ?? false,
|
|
360
|
+
pairs: options.pairs,
|
|
297
361
|
}),
|
|
298
|
-
({data}) =>
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
362
|
+
(/** @type {any} */ {type, data}) =>
|
|
363
|
+
type === 'icon.mapMany'
|
|
364
|
+
? emit(
|
|
365
|
+
text(
|
|
366
|
+
`[ok] ${data.entries.filter((/** @type {{changed: boolean}} */ each) => each.changed).length} of ${data.entries.length} map entries changed in ${data.file}.`,
|
|
367
|
+
),
|
|
368
|
+
list(
|
|
369
|
+
data.entries.map(
|
|
370
|
+
(
|
|
371
|
+
/** @type {{definition: string, icon: string, previous: string | null}} */ each,
|
|
372
|
+
) =>
|
|
373
|
+
`${each.definition} = "${each.icon}"${each.previous && each.previous !== each.icon ? ` (was "${each.previous}")` : ''}`,
|
|
374
|
+
),
|
|
375
|
+
),
|
|
376
|
+
)
|
|
377
|
+
: emit(
|
|
378
|
+
text(
|
|
379
|
+
data.icon == null
|
|
380
|
+
? data.changed
|
|
381
|
+
? `[ok] Removed map.${data.definition} (was "${data.previous}") from ${data.file}.`
|
|
382
|
+
: `[ok] ${data.file} has no map.${data.definition}.`
|
|
383
|
+
: data.changed
|
|
384
|
+
? `[ok] map.${data.definition} = "${data.icon}" in ${data.file}${data.previous ? ` (was "${data.previous}")` : ''}.`
|
|
385
|
+
: `[ok] map.${data.definition} is already "${data.icon}".`,
|
|
386
|
+
),
|
|
387
|
+
),
|
|
310
388
|
),
|
|
311
389
|
});
|
|
312
390
|
|
|
313
391
|
defineCommand(iconCli, iconAddCommand, {
|
|
314
392
|
fn: iconAddFn,
|
|
315
393
|
action: (
|
|
316
|
-
/** @type {string} */ exportName,
|
|
394
|
+
/** @type {string | undefined} */ exportName,
|
|
317
395
|
/** @type {Record<string, string | boolean | undefined>} */ options,
|
|
318
396
|
) =>
|
|
319
397
|
run(
|
|
@@ -321,7 +399,7 @@ export function registerExperimentalIcon(group, program) {
|
|
|
321
399
|
iconAdd(exportName, {
|
|
322
400
|
cwd: process.cwd(),
|
|
323
401
|
from: /** @type {string} */ (options.from),
|
|
324
|
-
set:
|
|
402
|
+
set: setOf(options),
|
|
325
403
|
definition: /** @type {string | undefined} */ (options.definition),
|
|
326
404
|
newDefinition: /** @type {string | undefined} */ (
|
|
327
405
|
options.newDefinition
|
|
@@ -336,9 +414,27 @@ export function registerExperimentalIcon(group, program) {
|
|
|
336
414
|
useDefault: options.default === true,
|
|
337
415
|
variant: /** @type {string | undefined} */ (options.variant),
|
|
338
416
|
id: /** @type {string | undefined} */ (options.id),
|
|
417
|
+
all: options.all === true,
|
|
339
418
|
}),
|
|
340
419
|
result => {
|
|
341
420
|
const cli = getCliInvocation();
|
|
421
|
+
if (result.type === 'icon.addVariants') {
|
|
422
|
+
const {data} = result;
|
|
423
|
+
emit(
|
|
424
|
+
text(
|
|
425
|
+
`[ok] ${data.variant}: ${data.added} icons gained it${data.already > 0 ? `, ${data.already} already had it` : ''}, read from ${data.from}.`,
|
|
426
|
+
),
|
|
427
|
+
...(data.files.length > 0 ? [list(data.files)] : []),
|
|
428
|
+
...(data.missing.length > 0
|
|
429
|
+
? [
|
|
430
|
+
text(
|
|
431
|
+
`${data.missing.length} icons have no ${data.variant} export in ${data.from} and keep none: ${data.missing.join(', ')}`,
|
|
432
|
+
),
|
|
433
|
+
]
|
|
434
|
+
: []),
|
|
435
|
+
);
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
342
438
|
if (result.type === 'icon.definitionMatches') {
|
|
343
439
|
const {matches, newDefinition} = result.data;
|
|
344
440
|
emit(
|
|
@@ -403,22 +499,54 @@ export function registerExperimentalIcon(group, program) {
|
|
|
403
499
|
) => {
|
|
404
500
|
const {root, manifest, files, written, dryRun} = data;
|
|
405
501
|
const state = dryRun ? 'plan' : written ? 'ok' : 'unchanged';
|
|
502
|
+
const refreshed = data.refreshed === true;
|
|
406
503
|
emit(
|
|
407
504
|
section(
|
|
408
|
-
|
|
409
|
-
?
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
505
|
+
refreshed
|
|
506
|
+
? dryRun
|
|
507
|
+
? `Refresh ${what} plan`
|
|
508
|
+
: `${what[0].toUpperCase()}${what.slice(1)} refreshed`
|
|
509
|
+
: dryRun
|
|
510
|
+
? `New ${what} plan`
|
|
511
|
+
: written
|
|
512
|
+
? `New ${what} added`
|
|
513
|
+
: `New ${what} unchanged`,
|
|
413
514
|
),
|
|
414
515
|
text(`[${state}] ${data.name}`),
|
|
516
|
+
// What the command did (or, in a dry run, would do): never a step
|
|
517
|
+
// left for the author.
|
|
415
518
|
text(
|
|
416
519
|
root != null
|
|
417
|
-
?
|
|
418
|
-
|
|
520
|
+
? root.created
|
|
521
|
+
? `${dryRun ? 'Would declare' : 'Declared'} the experimental.iconSets root ${root.path} in ${manifest}.`
|
|
522
|
+
: `The experimental.iconSets root ${root.path} in ${manifest} is unchanged.`
|
|
523
|
+
: `${dryRun ? 'Would update' : 'Updated'} ${manifest}.`,
|
|
419
524
|
),
|
|
420
525
|
...(files.length > 0 ? [list(files)] : []),
|
|
526
|
+
// What to do next comes before the long lists, so it never scrolls
|
|
527
|
+
// away.
|
|
421
528
|
...(data.notes ?? []).map(note => text(`[next] ${note}`)),
|
|
529
|
+
...(data.mapped && data.mapped.length > 0
|
|
530
|
+
? [
|
|
531
|
+
section(`Mapped by name (${data.mapped.length}, check each)`),
|
|
532
|
+
list(
|
|
533
|
+
data.mapped.map(each => `${each.definition} = ${each.icon}`),
|
|
534
|
+
),
|
|
535
|
+
]
|
|
536
|
+
: []),
|
|
537
|
+
...(data.suggestions && data.suggestions.length > 0
|
|
538
|
+
? [
|
|
539
|
+
section(
|
|
540
|
+
`Suggestions (${data.suggestions.length} for ${new Set(data.suggestions.map(each => each.definition)).size} definitions, not written)`,
|
|
541
|
+
),
|
|
542
|
+
list(
|
|
543
|
+
data.suggestions.map(
|
|
544
|
+
each =>
|
|
545
|
+
`${each.definition} -> ${each.icon} (${each.word}): ${formatCliCommand(`astryx experimental icon map ${each.definition} ${each.icon}`)}`,
|
|
546
|
+
),
|
|
547
|
+
),
|
|
548
|
+
]
|
|
549
|
+
: []),
|
|
422
550
|
);
|
|
423
551
|
};
|
|
424
552
|
|
|
@@ -426,7 +554,7 @@ export function registerExperimentalIcon(group, program) {
|
|
|
426
554
|
fn: iconNewSetFn,
|
|
427
555
|
action: (
|
|
428
556
|
/** @type {string} */ name,
|
|
429
|
-
/** @type {{dryRun?: boolean, from?: string, exclude?: string}} */ options,
|
|
557
|
+
/** @type {{dryRun?: boolean, from?: string, exclude?: string, variants?: string, defaultVariant?: string, displayName?: string, description?: string}} */ options,
|
|
430
558
|
) =>
|
|
431
559
|
run(
|
|
432
560
|
() =>
|
|
@@ -435,6 +563,10 @@ export function registerExperimentalIcon(group, program) {
|
|
|
435
563
|
dryRun: options.dryRun,
|
|
436
564
|
from: options.from,
|
|
437
565
|
exclude: options.exclude,
|
|
566
|
+
variants: options.variants,
|
|
567
|
+
defaultVariant: options.defaultVariant,
|
|
568
|
+
displayName: options.displayName,
|
|
569
|
+
description: options.description,
|
|
438
570
|
}),
|
|
439
571
|
printNew('icon set'),
|
|
440
572
|
),
|
|
@@ -451,7 +583,7 @@ export function registerExperimentalIcon(group, program) {
|
|
|
451
583
|
iconNewDefinition(name, {
|
|
452
584
|
cwd: process.cwd(),
|
|
453
585
|
dryRun: options.dryRun,
|
|
454
|
-
set: options
|
|
586
|
+
set: setOf(options),
|
|
455
587
|
description: options.description,
|
|
456
588
|
words: options.words,
|
|
457
589
|
icon: options.icon,
|
|
@@ -11,15 +11,15 @@ export const doc = {
|
|
|
11
11
|
stability: 'experimental',
|
|
12
12
|
summary: 'Register one icon you chose from a library in your icon set',
|
|
13
13
|
description:
|
|
14
|
-
"Run inside an icon-set package. You pick the export; the CLI proves it is a component of --from, read without running it, and never searches the library. Without a definition it lists the icon definitions that fit and the command for each. With --definition it adds the icon and maps the definition to it; --new-definition first adds your set's own definition. Experimental: it may change or be removed in a patch release.",
|
|
14
|
+
"Run inside an icon-set package. You pick the export; the CLI proves it is a component of --from, read without running it, and never searches the library. Without a definition it lists the icon definitions that fit and the command for each. With --definition it adds the icon and maps the definition to it; --new-definition first adds your set's own definition. With --variant <name> --from <module> --all and no export, it adds that variant for every icon whose id the module exports. Experimental: it may change or be removed in a patch release.",
|
|
15
15
|
fn: 'iconAdd',
|
|
16
|
-
args: [{name: 'export', param: 'exportName', required:
|
|
16
|
+
args: [{name: 'export', param: 'exportName', required: false}],
|
|
17
17
|
options: [
|
|
18
18
|
{
|
|
19
19
|
flag: '--from <module>',
|
|
20
20
|
param: 'options.from',
|
|
21
21
|
description:
|
|
22
|
-
'The module the icon is exported from: a package, a subpath, or a
|
|
22
|
+
'The module the icon is exported from: a package, a subpath, or a ./ path to a file inside this package',
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
25
|
flag: '--definition <name>',
|
|
@@ -55,6 +55,12 @@ export const doc = {
|
|
|
55
55
|
description:
|
|
56
56
|
"Add the export as this variant of an existing icon: one of the set's declared variants, such as solid",
|
|
57
57
|
},
|
|
58
|
+
{
|
|
59
|
+
flag: '--all',
|
|
60
|
+
param: 'options.all',
|
|
61
|
+
description:
|
|
62
|
+
'With --variant and --from, and no export: add that variant for every icon whose id the module exports, in one run',
|
|
63
|
+
},
|
|
58
64
|
{
|
|
59
65
|
flag: '--id <id>',
|
|
60
66
|
param: 'options.id',
|
|
@@ -75,9 +81,13 @@ export const doc = {
|
|
|
75
81
|
label: 'Add and map',
|
|
76
82
|
cli: 'astryx experimental icon add Bin --from @acme/glyph-library --definition delete',
|
|
77
83
|
},
|
|
84
|
+
{
|
|
85
|
+
label: 'Add the solid variant of every icon',
|
|
86
|
+
cli: 'astryx experimental icon add --variant solid --from @heroicons/react/24/solid --all',
|
|
87
|
+
},
|
|
78
88
|
{
|
|
79
89
|
label: 'Add your own definition',
|
|
80
|
-
cli: "astryx experimental icon add
|
|
90
|
+
cli: "astryx experimental icon add Dice5 --from @acme/glyph-library --new-definition random --description 'Pick something at random.' --words dice,shuffle,chance",
|
|
81
91
|
},
|
|
82
92
|
{
|
|
83
93
|
label: 'Add a solid variant',
|
|
@@ -11,10 +11,10 @@ export const doc = {
|
|
|
11
11
|
stability: 'experimental',
|
|
12
12
|
summary: 'Register which icon of your set draws an icon definition',
|
|
13
13
|
description:
|
|
14
|
-
"Run inside an icon-set package. Sets `map[<definition>]
|
|
14
|
+
"Run inside an icon-set package. Sets `map[<definition>]` to the icon's id in the set's data file; name the icon by its id, its export name in any case, or another name its library exports it as (`trash-2` or `Trash2`), never by one word of its id, and the definition by its name or kebab id; `integration check` prints these commands for definitions your set already has a fitting icon for. Experimental: it may change or be removed in a patch release.",
|
|
15
15
|
fn: 'iconMap',
|
|
16
16
|
args: [
|
|
17
|
-
{name: 'definition', param: 'definition', required:
|
|
17
|
+
{name: 'definition', param: 'definition', required: false},
|
|
18
18
|
{name: 'icon', param: 'icon', required: false},
|
|
19
19
|
],
|
|
20
20
|
options: [
|
|
@@ -28,12 +28,22 @@ export const doc = {
|
|
|
28
28
|
param: 'options.remove',
|
|
29
29
|
description: "Remove the definition's entry; takes no icon",
|
|
30
30
|
},
|
|
31
|
+
{
|
|
32
|
+
flag: '--pairs <list>',
|
|
33
|
+
param: 'options.pairs',
|
|
34
|
+
description:
|
|
35
|
+
'Many entries in one write: <definition>=<icon> pairs, comma-separated; checked together, all or none; an existing entry is replaced',
|
|
36
|
+
},
|
|
31
37
|
],
|
|
32
38
|
examples: [
|
|
33
39
|
{
|
|
34
40
|
label: 'Map a definition',
|
|
35
41
|
cli: 'astryx experimental icon map delete trash',
|
|
36
42
|
},
|
|
43
|
+
{
|
|
44
|
+
label: 'Map many at once',
|
|
45
|
+
cli: 'astryx experimental icon map --pairs close=x-mark,error=x-circle,search=magnifying-glass',
|
|
46
|
+
},
|
|
37
47
|
{
|
|
38
48
|
label: 'Remove an entry',
|
|
39
49
|
cli: 'astryx experimental icon map delete --remove',
|
|
@@ -51,7 +51,7 @@ export const doc = {
|
|
|
51
51
|
examples: [
|
|
52
52
|
{
|
|
53
53
|
label: "Add a set's own icon definition",
|
|
54
|
-
cli: "astryx experimental icon new-definition
|
|
54
|
+
cli: "astryx experimental icon new-definition random --description 'Pick something at random.' --words dice,shuffle,chance --icon dice-5",
|
|
55
55
|
},
|
|
56
56
|
],
|
|
57
57
|
outsideProject: 'refuse',
|
|
@@ -11,7 +11,7 @@ export const doc = {
|
|
|
11
11
|
stability: 'experimental',
|
|
12
12
|
summary: 'Start an icon set in your integration package',
|
|
13
13
|
description:
|
|
14
|
-
"Run inside an integration package. Writes the set's folder with its descriptor, its data file, and its generated module, and declares the manifest's `experimental.iconSets` root on first use. With --from it wraps every icon component of a library;
|
|
14
|
+
"Run inside an integration package. Writes the set's folder with its descriptor, its data file, and its generated module, and declares the manifest's `experimental.iconSets` root on first use. With --from it wraps every icon component of a library, records the library and its version as the set's source, copies its license notice, and maps each Astryx icon definition whose name is an icon's id; definitions an icon only shares a word with are listed as suggestions, never written. Run it again to refresh. --variants and --default-variant declare the set's variants. Experimental: it may change or be removed in a patch release.",
|
|
15
15
|
fn: 'iconNewSet',
|
|
16
16
|
args: [
|
|
17
17
|
{
|
|
@@ -39,6 +39,29 @@ export const doc = {
|
|
|
39
39
|
description:
|
|
40
40
|
'With --from: comma-separated export names of the library that are not icons',
|
|
41
41
|
},
|
|
42
|
+
{
|
|
43
|
+
flag: '--variants <list>',
|
|
44
|
+
param: 'options.variants',
|
|
45
|
+
description:
|
|
46
|
+
'Comma-separated variants the set supplies, such as outline,solid',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
flag: '--default-variant <variant>',
|
|
50
|
+
param: 'options.defaultVariant',
|
|
51
|
+
description:
|
|
52
|
+
"With --variants: the variant each icon's own export draws (the first variant when omitted)",
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
flag: '--display-name <text>',
|
|
56
|
+
param: 'options.displayName',
|
|
57
|
+
description:
|
|
58
|
+
"The set's display name (the name in title case when omitted)",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
flag: '--description <text>',
|
|
62
|
+
param: 'options.description',
|
|
63
|
+
description: "The set's one-line description",
|
|
64
|
+
},
|
|
42
65
|
],
|
|
43
66
|
examples: [
|
|
44
67
|
{
|
|
@@ -49,6 +72,10 @@ export const doc = {
|
|
|
49
72
|
label: 'Wrap a whole icon library',
|
|
50
73
|
cli: 'astryx experimental icon new-set outline --from @acme/glyph-library',
|
|
51
74
|
},
|
|
75
|
+
{
|
|
76
|
+
label: 'Wrap a library with two variants',
|
|
77
|
+
cli: 'astryx experimental icon new-set heroicons --from @heroicons/react/24/outline --variants outline,solid --default-variant outline',
|
|
78
|
+
},
|
|
52
79
|
{
|
|
53
80
|
label: 'Preview the files',
|
|
54
81
|
cli: 'astryx experimental icon new-set outline --dry-run --json',
|