@astryxdesign/cli 0.7.4 → 0.7.5-canary.0418c47
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 +20 -20
- package/api/component/_adapter.mjs +16 -1
- package/api/component/component.test.mjs +31 -0
- package/api/discover/_adapter.d.mts +1 -1
- package/api/docs/_adapter.d.mts +5 -2
- package/api/docs/_adapter.mjs +24 -16
- package/api/docs/docs.test.mjs +18 -0
- package/api/docs/integrationDocs.test.mjs +2 -2
- package/api/experimental.d.mts +5 -0
- package/api/experimental.mjs +15 -0
- package/api/hook/list/list.d.mts +1 -1
- 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/pack-check.lifecycle-output.test.mjs +24 -1
- package/api/integration/pack-check.mjs +10 -4
- package/api/integration/pack-check.test.mjs +5 -1
- package/api/integration/validate-integration.type.d.mts +3 -2
- package/api/integration/validate-integration.type.mjs +3 -2
- package/api/render/_adapter.d.mts +28 -0
- package/api/render/_adapter.mjs +540 -0
- package/api/render/render.d.mts +15 -0
- package/api/render/render.doc.d.mts +9 -0
- package/api/render/render.doc.mjs +112 -0
- package/api/render/render.mjs +113 -0
- package/api/render/render.test.mjs +1155 -0
- package/api/render/render.type.d.mts +74 -0
- package/api/render/render.type.mjs +64 -0
- package/api/search/_adapter.test.mjs +21 -2
- package/api/search/_result.d.mts +5 -5
- package/api/search/search.d.mts +1 -1
- package/api/template/template.mjs +3 -1
- package/api/template/template.type.d.mts +2 -1
- package/api/template/template.type.mjs +1 -1
- package/api/template/tokenizer-showcase.test.mjs +47 -0
- package/api/template/unknown-name.test.mjs +63 -0
- package/api/theme/build/build.adaptation-enrollment.test.mjs +4 -0
- package/api/theme/build/build.icon-variants.test.mjs +105 -0
- package/api/theme/build/build.mjs +36 -7
- package/api/theme/build/build.test.mjs +27 -0
- package/api/upgrade/_adapter.d.mts +47 -2
- package/api/upgrade/_adapter.mjs +58 -2
- package/api/upgrade/run/failure-receipt.test.mjs +212 -0
- package/api/upgrade/run/outcomes.test.mjs +646 -0
- package/api/upgrade/run/run.d.mts +36 -0
- package/api/upgrade/run/run.mjs +670 -44
- package/api/upgrade/upgrade.doc.mjs +4 -4
- package/api/upgrade/upgrade.mjs +19 -4
- package/api/upgrade/upgrade.type.d.mts +36 -1
- package/api/upgrade/upgrade.type.mjs +29 -4
- package/assets/codemods/__tests__/runner.symlinks.test.mjs +205 -0
- package/assets/codemods/__tests__/runner.unparseable.test.mjs +457 -0
- package/assets/codemods/integration-runner.mjs +8 -2
- package/assets/codemods/integration-runner.protection.test.mjs +53 -0
- package/assets/codemods/outcome.mjs +79 -0
- package/assets/codemods/outcome.test.mjs +40 -0
- package/assets/codemods/parse.mjs +94 -0
- package/assets/codemods/run-codemod.mjs +109 -5
- package/assets/codemods/runner.mjs +119 -13
- package/assets/codemods/transform-prop.mjs +99 -49
- package/assets/codemods/transform-prop.test.mjs +36 -1
- package/assets/codemods/transforms/next/__tests__/migrate-codeblock-tokenizer-to-language.test.mjs +130 -0
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-codeblock-tokenizer-to-language.mjs +315 -0
- package/assets/codemods/transforms/v0.1.3/__tests__/migrate-layout-components-to-experimental.test.mjs +216 -2
- package/assets/codemods/transforms/v0.1.3/migrate-layout-components-to-experimental.mjs +88 -6
- package/assets/codemods/transforms/v0.6.0/migrate-astryx-theme-selectors-to-data-attrs.mjs +4 -3
- package/assets/codemods/transforms/v0.7.0/__tests__/migrate-deprecated-theme-surface.test.mjs +207 -6
- package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +143 -70
- package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface-v0.6-data.mjs +6 -1
- package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface.mjs +244 -42
- package/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs +23 -78
- package/assets/discover/official-packages.json +4 -0
- package/assets/docs/author-a-theme.doc.mjs +3 -1
- package/assets/docs/icons.doc.mjs +71 -1
- package/assets/docs/theme.doc.dense.mjs +8 -0
- package/assets/docs/theme.doc.mjs +16 -0
- package/assets/docs/theme.doc.zh.mjs +11 -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/docs/tree/render-pages.doc.mjs +94 -0
- package/assets/docs/tree/styling-advanced.doc.mjs +1 -1
- package/assets/docs/tree/template-styles.doc.mjs +1 -1
- package/assets/docs/tree/tokens-color.doc.mjs +145 -1
- package/assets/docs/tree/tokens.doc.mjs +1 -1
- 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/BottomSheet/BottomSheetSwitcherReviewFlow.doc.mjs +6 -4
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.tsx +61 -55
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherShowcase.doc.mjs +6 -4
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherShowcase.tsx +68 -37
- package/assets/templates/blocks/components/CodeBlock/CodeBlockBashCommand.doc.mjs +1 -1
- package/assets/templates/blocks/components/CodeBlock/CodeBlockBashCommand.tsx +10 -2
- package/assets/templates/blocks/components/Thumbnail/ThumbnailDisabled.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 +22 -14
- 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/dashboard-alert-rail/page.tsx +3 -3
- package/assets/templates/pages/form-wizard-inline/template.doc.mjs +6 -1
- package/assets/templates/pages/library/page.tsx +1 -2
- package/assets/templates/pages/table-comparison/page.tsx +12 -3
- package/assets/templates/pages/table-comparison/template.doc.mjs +1 -0
- package/assets/templates/pages/table-tree/template.doc.mjs +3 -0
- package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +3 -2
- package/assets/templates/themes/butter/butterTheme.ts +47 -44
- package/assets/templates/themes/chocolate/chocolateTheme.ts +15 -2
- package/assets/templates/themes/gothic/gothicTheme.ts +21 -16
- package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +1 -1
- package/assets/templates/themes/matcha/matchaTheme.ts +15 -2
- package/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts +4 -4
- package/assets/templates/themes/neutral/neutralTheme.ts +24 -119
- package/assets/templates/themes/stone/stoneTheme.ts +46 -21
- package/assets/templates/themes/y2k/y2kTheme.ts +20 -16
- package/assets/theme.template.ts +18 -5
- package/authoring/codemod/type.ts +10 -0
- package/authoring/debug/parse.d.mts +2 -2
- 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/build-theme.adaptations.test.mjs +110 -0
- package/clients/cli/commands/doctor.mjs +16 -17
- package/clients/cli/commands/experimental/icon.mjs +167 -35
- package/clients/cli/commands/experimental/index.mjs +2 -0
- package/clients/cli/commands/experimental/render.mjs +113 -0
- 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-render.doc.mjs +60 -0
- package/clients/cli/commands/experimental.doc.mjs +4 -2
- 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/clients/cli/commands/text-json-parity.test.mjs +46 -0
- package/clients/cli/commands/upgrade.doc.mjs +47 -2
- package/clients/cli/commands/upgrade.file-protection.test.mjs +175 -0
- package/clients/cli/commands/upgrade.flag-help.test.mjs +37 -0
- package/clients/cli/commands/upgrade.integration-policy.test.mjs +103 -0
- package/clients/cli/commands/upgrade.mjs +9 -2
- package/clients/cli/commands/upgrade.outcomes.test.mjs +350 -0
- package/clients/cli/index.mjs +1 -0
- package/foundation/agent-docs/agent-docs.mjs +1 -0
- package/foundation/agent-docs/agent-docs.test.mjs +5 -0
- 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/doc-loads.test.mjs +20 -5
- package/foundation/doc-compiler/import.mjs +81 -8
- package/foundation/doc-compiler/read.d.mts +4 -3
- package/foundation/doc-compiler/read.mjs +15 -10
- package/foundation/doc-compiler/read.test.mjs +59 -1
- package/foundation/doc-compiler/tree.mjs +3 -1
- package/foundation/fs/module-loader.d.mts +3 -2
- package/foundation/fs/module-loader.mjs +3 -2
- package/foundation/fs/publish-file-eperm-mutation.test.mjs +2 -0
- package/foundation/fs/read-record.d.mts +27 -0
- package/foundation/fs/read-record.mjs +83 -15
- package/foundation/fs/read-record.test.mjs +88 -1
- package/foundation/render/assets.d.mts +31 -0
- package/foundation/render/assets.mjs +102 -0
- package/foundation/render/component-map.d.mts +52 -0
- package/foundation/render/component-map.mjs +141 -0
- package/foundation/render/css-cut.d.mts +29 -0
- package/foundation/render/css-cut.mjs +144 -0
- package/foundation/render/embedded-files.d.mts +28 -0
- package/foundation/render/embedded-files.mjs +108 -0
- package/foundation/render/embedded-imports.d.mts +61 -0
- package/foundation/render/embedded-imports.mjs +315 -0
- package/foundation/render/html-reader.d.mts +37 -0
- package/foundation/render/html-reader.mjs +121 -0
- package/foundation/render/page-worker.d.mts +7 -0
- package/foundation/render/page-worker.mjs +519 -0
- package/foundation/render/rebuild.d.mts +19 -0
- package/foundation/render/rebuild.mjs +269 -0
- package/foundation/render/render-page.d.mts +85 -0
- package/foundation/render/render-page.mjs +612 -0
- package/foundation/render/render.test.mjs +117 -0
- package/foundation/render/source-block.d.mts +52 -0
- package/foundation/render/source-block.mjs +106 -0
- package/foundation/response/base.d.ts +7 -0
- package/foundation/response/error-codes.d.mts +10 -1
- package/foundation/response/error-codes.doc.mjs +59 -2
- package/foundation/response/error-codes.mjs +62 -1
- package/foundation/response/json.d.mts +10 -3
- package/foundation/response/json.mjs +16 -4
- package/foundation/response/response-types.doc.mjs +39 -2
- package/foundation/text/string-utils.mjs +33 -0
- package/foundation/text/string-utils.test.mjs +17 -0
- package/foundation/text/suggest-order.d.mts +17 -3
- package/foundation/text/suggest-order.mjs +58 -13
- package/foundation/text/suggest-order.test.mjs +53 -0
- package/package.json +15 -9
package/api/icon/icon.test.mjs
CHANGED
|
@@ -11,10 +11,14 @@ import * as path from 'node:path';
|
|
|
11
11
|
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
12
12
|
import {icon} from './icon.mjs';
|
|
13
13
|
import {iconUse} from './use/use.mjs';
|
|
14
|
+
import {iconMap} from './map/map.mjs';
|
|
15
|
+
import {iconAdd} from './add/add.mjs';
|
|
16
|
+
import {iconNewDefinition} from './new-definition/new-definition.mjs';
|
|
14
17
|
import {ICON_NAMES} from '../../authoring/doctypes/icon-set/icon-names.mjs';
|
|
15
18
|
import {rankIcons, scoreIcon} from './_records.mjs';
|
|
16
19
|
import {
|
|
17
20
|
glyphsData,
|
|
21
|
+
writeIconPackage,
|
|
18
22
|
writeIconSetProject,
|
|
19
23
|
} from '../../test-utils/icon-set-fixture.mjs';
|
|
20
24
|
|
|
@@ -331,9 +335,18 @@ describe('icon.list', () => {
|
|
|
331
335
|
expect(set.coverage.own).toEqual([]);
|
|
332
336
|
});
|
|
333
337
|
|
|
338
|
+
it('refuses --set and --limit with one icon, which they would not change', async () => {
|
|
339
|
+
for (const options of [{set: 'glyphs'}, {limit: 2}]) {
|
|
340
|
+
await expect(
|
|
341
|
+
icon('glyphs/trash', {cwd, ...options}),
|
|
342
|
+
).rejects.toMatchObject({code: 'ERR_INVALID_OPTION'});
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
|
|
334
346
|
it('refuses a query with --list and no query without it', async () => {
|
|
335
347
|
await expect(icon('x', {cwd, list: true})).rejects.toMatchObject({
|
|
336
|
-
code: '
|
|
348
|
+
code: 'ERR_INVALID_OPTION',
|
|
349
|
+
message: '--list and a query cannot be used together',
|
|
337
350
|
});
|
|
338
351
|
await expect(icon('', {cwd})).rejects.toMatchObject({
|
|
339
352
|
code: 'ERR_MISSING_ARGUMENT',
|
|
@@ -372,3 +385,122 @@ describe('a withdrawn set, named', () => {
|
|
|
372
385
|
});
|
|
373
386
|
});
|
|
374
387
|
});
|
|
388
|
+
|
|
389
|
+
describe('every entry point that names a set reports it the same way (FR17)', () => {
|
|
390
|
+
/** @type {string} */
|
|
391
|
+
let app;
|
|
392
|
+
/** @type {string} */
|
|
393
|
+
let authored;
|
|
394
|
+
beforeEach(() => {
|
|
395
|
+
app = writeIconSetProject(path.join(tmp, 'entry-app'), {
|
|
396
|
+
packages: [{}, {name: '@acme/lines', data: '{nope'}],
|
|
397
|
+
});
|
|
398
|
+
// A package being authored with one valid set and one withdrawn one.
|
|
399
|
+
authored = path.join(tmp, 'entry-pkg', 'glyphs');
|
|
400
|
+
writeIconPackage(authored);
|
|
401
|
+
const broken = path.join(authored, 'icon-sets', 'lines');
|
|
402
|
+
fs.mkdirSync(broken, {recursive: true});
|
|
403
|
+
fs.copyFileSync(
|
|
404
|
+
path.join(authored, 'icon-sets', 'glyphs', 'glyphs.doc.mjs'),
|
|
405
|
+
path.join(broken, 'lines.doc.mjs'),
|
|
406
|
+
);
|
|
407
|
+
fs.writeFileSync(
|
|
408
|
+
path.join(broken, 'lines.doc.mjs'),
|
|
409
|
+
fs
|
|
410
|
+
.readFileSync(path.join(broken, 'lines.doc.mjs'), 'utf8')
|
|
411
|
+
.replace('"name": "glyphs"', '"name": "lines"'),
|
|
412
|
+
);
|
|
413
|
+
fs.writeFileSync(path.join(broken, 'lines.icons.json'), '{nope');
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
/** @type {Array<[string, 'installed' | 'authored', (cwd: string, set: string) => Promise<unknown>]>} */
|
|
417
|
+
const ENTRY_POINTS = [
|
|
418
|
+
[
|
|
419
|
+
'a query with --set',
|
|
420
|
+
'installed',
|
|
421
|
+
(dir, set) => icon('close', {cwd: dir, set}),
|
|
422
|
+
],
|
|
423
|
+
[
|
|
424
|
+
'--set with --all-icons',
|
|
425
|
+
'installed',
|
|
426
|
+
(dir, set) => icon(undefined, {cwd: dir, set, allIcons: true}),
|
|
427
|
+
],
|
|
428
|
+
['<set>/<id>', 'installed', (dir, set) => icon(`${set}/x`, {cwd: dir})],
|
|
429
|
+
['use', 'installed', (dir, set) => iconUse(set, {cwd: dir})],
|
|
430
|
+
[
|
|
431
|
+
'map --set',
|
|
432
|
+
'authored',
|
|
433
|
+
(dir, set) => iconMap('close', 'x', {cwd: dir, set}),
|
|
434
|
+
],
|
|
435
|
+
[
|
|
436
|
+
'add --set',
|
|
437
|
+
'authored',
|
|
438
|
+
(dir, set) =>
|
|
439
|
+
iconAdd('XIcon', {
|
|
440
|
+
cwd: dir,
|
|
441
|
+
set,
|
|
442
|
+
from: './icons/x.js',
|
|
443
|
+
definition: 'close',
|
|
444
|
+
}),
|
|
445
|
+
],
|
|
446
|
+
[
|
|
447
|
+
'new-definition --set',
|
|
448
|
+
'authored',
|
|
449
|
+
(dir, set) =>
|
|
450
|
+
iconNewDefinition('binIt', {
|
|
451
|
+
cwd: dir,
|
|
452
|
+
set,
|
|
453
|
+
description: 'Put something in the bin.',
|
|
454
|
+
words: ['bin'],
|
|
455
|
+
}),
|
|
456
|
+
],
|
|
457
|
+
];
|
|
458
|
+
|
|
459
|
+
it.each(ENTRY_POINTS)('%s: a missing set', async (_label, kind, run) => {
|
|
460
|
+
await expect(
|
|
461
|
+
run(kind === 'installed' ? app : authored, 'nope'),
|
|
462
|
+
).rejects.toMatchObject({
|
|
463
|
+
code: 'ERR_NOT_FOUND',
|
|
464
|
+
message:
|
|
465
|
+
kind === 'installed'
|
|
466
|
+
? 'No installed icon set named "nope"'
|
|
467
|
+
: 'No icon set named "nope" in this package',
|
|
468
|
+
});
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
it.each(ENTRY_POINTS)('%s: a withdrawn set', async (_label, kind, run) => {
|
|
472
|
+
await expect(
|
|
473
|
+
run(kind === 'installed' ? app : authored, 'lines'),
|
|
474
|
+
).rejects.toMatchObject({
|
|
475
|
+
code: 'ERR_NOT_FOUND',
|
|
476
|
+
message: expect.stringMatching(
|
|
477
|
+
kind === 'installed'
|
|
478
|
+
? /^Icon set "lines" is installed but withdrawn: .*not valid JSON/u
|
|
479
|
+
: /^Icon set "lines" is in this package but withdrawn: .*not valid JSON/u,
|
|
480
|
+
),
|
|
481
|
+
});
|
|
482
|
+
});
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
describe('partial matches answer only when nothing better does (FR6)', () => {
|
|
486
|
+
/** @param {string} query */
|
|
487
|
+
const ids = async query => {
|
|
488
|
+
const result = await icon(query, {cwd, set: 'glyphs'});
|
|
489
|
+
if (result.type !== 'icon.search') throw new Error(result.type);
|
|
490
|
+
return result.data.matches.map(match => [match.id, match.score]);
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
it('leaves out a partial match when a word starts with the query', async () => {
|
|
494
|
+
// `se` starts `search`, and is only inside `house` (home).
|
|
495
|
+
const found = await ids('se');
|
|
496
|
+
expect(found.map(([id]) => id)).toContain('search');
|
|
497
|
+
expect(found.map(([id]) => id)).not.toContain('home');
|
|
498
|
+
expect(found.every(([, score]) => Number(score) >= 60)).toBe(true);
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
it('answers with partial matches when nothing scores 60 or more', async () => {
|
|
502
|
+
// `ouse` starts no word; it is inside `house`.
|
|
503
|
+
const found = await ids('ouse');
|
|
504
|
+
expect(found).toEqual([['home', 40]]);
|
|
505
|
+
});
|
|
506
|
+
});
|
package/api/icon/icon.type.d.mts
CHANGED
|
@@ -202,6 +202,29 @@ export type IconMapOptions = {
|
|
|
202
202
|
* - Remove the definition's entry instead.
|
|
203
203
|
*/
|
|
204
204
|
remove?: boolean | undefined;
|
|
205
|
+
/**
|
|
206
|
+
* - Many entries at once, as `<definition>=<icon>` pairs separated by commas or spaces; then no definition or icon is passed. All are checked before any is written.
|
|
207
|
+
*/
|
|
208
|
+
pairs?: string | string[] | undefined;
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* `astryx --json experimental icon map --pairs <definition>=<icon>,...`.
|
|
212
|
+
*/
|
|
213
|
+
export type IconMapManyResponse = {
|
|
214
|
+
type: "icon.mapMany";
|
|
215
|
+
data: {
|
|
216
|
+
set: string;
|
|
217
|
+
package: string;
|
|
218
|
+
file: string;
|
|
219
|
+
entries: Array<{
|
|
220
|
+
definition: string;
|
|
221
|
+
icon: string;
|
|
222
|
+
previous: string | null;
|
|
223
|
+
changed: boolean;
|
|
224
|
+
}>;
|
|
225
|
+
changed: boolean;
|
|
226
|
+
files?: string[] | undefined;
|
|
227
|
+
};
|
|
205
228
|
};
|
|
206
229
|
/**
|
|
207
230
|
* `astryx --json experimental icon map <definition> <icon>`.
|
|
@@ -260,6 +283,27 @@ export type IconAddOptions = {
|
|
|
260
283
|
* - The icon's id, instead of the one its name gives.
|
|
261
284
|
*/
|
|
262
285
|
id?: string | undefined;
|
|
286
|
+
/**
|
|
287
|
+
* - With `variant` and `from`, and no export name: add that variant for every icon whose id an export of `from` has.
|
|
288
|
+
*/
|
|
289
|
+
all?: boolean | undefined;
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* `astryx --json experimental icon add --variant <name> --from <module> --all`.
|
|
293
|
+
*/
|
|
294
|
+
export type IconAddVariantsResponse = {
|
|
295
|
+
type: "icon.addVariants";
|
|
296
|
+
data: {
|
|
297
|
+
set: string;
|
|
298
|
+
package: string;
|
|
299
|
+
variant: string;
|
|
300
|
+
from: string;
|
|
301
|
+
added: number;
|
|
302
|
+
already: number;
|
|
303
|
+
missing: string[];
|
|
304
|
+
files: string[];
|
|
305
|
+
changed: boolean;
|
|
306
|
+
};
|
|
263
307
|
};
|
|
264
308
|
/**
|
|
265
309
|
* `astryx --json experimental icon add <Export> --from <module> --definition <name>`.
|
|
@@ -329,6 +373,45 @@ export type IconOptions = {
|
|
|
329
373
|
* - Max matches (default 10).
|
|
330
374
|
*/
|
|
331
375
|
limit?: number | undefined;
|
|
376
|
+
/**
|
|
377
|
+
* - With `set` and no query: every icon of that set.
|
|
378
|
+
*/
|
|
379
|
+
allIcons?: boolean | undefined;
|
|
380
|
+
/**
|
|
381
|
+
* - Every Astryx icon definition, and nothing else.
|
|
382
|
+
*/
|
|
383
|
+
definitions?: boolean | undefined;
|
|
384
|
+
};
|
|
385
|
+
/**
|
|
386
|
+
* `astryx --json experimental icon --definitions`.
|
|
387
|
+
*/
|
|
388
|
+
export type IconDefinitionsResponse = {
|
|
389
|
+
type: "icon.definitions";
|
|
390
|
+
data: {
|
|
391
|
+
definitions: Array<{
|
|
392
|
+
name: string;
|
|
393
|
+
builtIn: boolean;
|
|
394
|
+
description: string;
|
|
395
|
+
words: string[];
|
|
396
|
+
}>;
|
|
397
|
+
};
|
|
398
|
+
};
|
|
399
|
+
/**
|
|
400
|
+
* `astryx --json experimental icon --set <name> --all-icons`.
|
|
401
|
+
*/
|
|
402
|
+
export type IconSetIconsResponse = {
|
|
403
|
+
type: "icon.setIcons";
|
|
404
|
+
data: {
|
|
405
|
+
set: string;
|
|
406
|
+
package: string;
|
|
407
|
+
iconCount: number;
|
|
408
|
+
icons: Array<{
|
|
409
|
+
id: string;
|
|
410
|
+
export: string;
|
|
411
|
+
words: string[];
|
|
412
|
+
definitions: string[];
|
|
413
|
+
}>;
|
|
414
|
+
};
|
|
332
415
|
};
|
|
333
416
|
/**
|
|
334
417
|
* Options for `iconNewSet()`.
|
|
@@ -350,6 +433,22 @@ export type IconNewSetOptions = {
|
|
|
350
433
|
* - With `from`: export names that are not icons; a string is split on commas.
|
|
351
434
|
*/
|
|
352
435
|
exclude?: string | string[] | undefined;
|
|
436
|
+
/**
|
|
437
|
+
* - The variants the set supplies, such as `outline,solid`; a string is split on commas.
|
|
438
|
+
*/
|
|
439
|
+
variants?: string | string[] | undefined;
|
|
440
|
+
/**
|
|
441
|
+
* - With `variants`: the variant each icon's own export draws; the first variant when absent.
|
|
442
|
+
*/
|
|
443
|
+
defaultVariant?: string | undefined;
|
|
444
|
+
/**
|
|
445
|
+
* - The descriptor's display name; the set name in title case when absent.
|
|
446
|
+
*/
|
|
447
|
+
displayName?: string | undefined;
|
|
448
|
+
/**
|
|
449
|
+
* - The descriptor's one-line description; `<Display name> icons.` when absent.
|
|
450
|
+
*/
|
|
451
|
+
description?: string | undefined;
|
|
353
452
|
};
|
|
354
453
|
/**
|
|
355
454
|
* Options for `iconNewDefinition()`.
|
|
@@ -409,7 +508,33 @@ export type IconNewData = {
|
|
|
409
508
|
*/
|
|
410
509
|
icons?: number | undefined;
|
|
411
510
|
/**
|
|
412
|
-
* -
|
|
511
|
+
* - With `from` on an existing set: the set was refreshed, not created.
|
|
512
|
+
*/
|
|
513
|
+
refreshed?: boolean | undefined;
|
|
514
|
+
/**
|
|
515
|
+
* - On a refresh: the icons whose id this release's id rule changes, matched by the export the library still has; each keeps its `map` entries, variants, and words.
|
|
516
|
+
*/
|
|
517
|
+
renamed?: {
|
|
518
|
+
from: string;
|
|
519
|
+
to: string;
|
|
520
|
+
}[] | undefined;
|
|
521
|
+
/**
|
|
522
|
+
* - With `from`: the `map` entries an icon with the definition's exact name gives (on a refresh, every such entry, kept or new); check each.
|
|
523
|
+
*/
|
|
524
|
+
mapped?: {
|
|
525
|
+
definition: string;
|
|
526
|
+
icon: string;
|
|
527
|
+
}[] | undefined;
|
|
528
|
+
/**
|
|
529
|
+
* - With `from`: for each unmapped Astryx definition, up to three icons it might map to, best first: the definition's name in another spelling or as another name of an icon, ids that start with it, an id or another name that is one of its words, then two-word ids that are a one-word word sized, shaped, or numbered (`grid-2x2`); never a negated form, the opposite direction, or an icon already mapped. `word` is the name or word that matched. Never written.
|
|
530
|
+
*/
|
|
531
|
+
suggestions?: {
|
|
532
|
+
definition: string;
|
|
533
|
+
icon: string;
|
|
534
|
+
word: string;
|
|
535
|
+
}[] | undefined;
|
|
536
|
+
/**
|
|
537
|
+
* - What the author does next, including each change the package needs that the CLI never makes itself (its entry, peers, scripts), as text to copy.
|
|
413
538
|
*/
|
|
414
539
|
notes?: string[] | undefined;
|
|
415
540
|
};
|
package/api/icon/icon.type.mjs
CHANGED
|
@@ -142,6 +142,21 @@
|
|
|
142
142
|
* @property {string} [cwd]
|
|
143
143
|
* @property {string} [set] - The set to edit, when the package ships several.
|
|
144
144
|
* @property {boolean} [remove] - Remove the definition's entry instead.
|
|
145
|
+
* @property {string | string[]} [pairs] - Many entries at once, as `<definition>=<icon>` pairs separated by commas or spaces; then no definition or icon is passed. All are checked before any is written.
|
|
146
|
+
*/
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* `astryx --json experimental icon map --pairs <definition>=<icon>,...`.
|
|
150
|
+
* @experimental May change or be removed in a patch release.
|
|
151
|
+
* @typedef {object} IconMapManyResponse
|
|
152
|
+
* @property {'icon.mapMany'} type
|
|
153
|
+
* @property {object} data
|
|
154
|
+
* @property {string} data.set
|
|
155
|
+
* @property {string} data.package
|
|
156
|
+
* @property {string} data.file - The data file, relative to the package.
|
|
157
|
+
* @property {Array<{definition: string, icon: string, previous: string | null, changed: boolean}>} data.entries - Each pair, in order, and what it replaced.
|
|
158
|
+
* @property {boolean} data.changed - Whether the file was written.
|
|
159
|
+
* @property {string[]} [data.files] - The generated module and its types, when its theme map was rewritten.
|
|
145
160
|
*/
|
|
146
161
|
|
|
147
162
|
/**
|
|
@@ -154,7 +169,7 @@
|
|
|
154
169
|
* @property {string} data.package
|
|
155
170
|
* @property {string} data.file - The data file, relative to the package.
|
|
156
171
|
* @property {string} data.definition
|
|
157
|
-
* @property {string | null} data.icon - The icon
|
|
172
|
+
* @property {string | null} data.icon - The id of the icon now mapped (the icon may be named by any name `map` accepts); null after `remove`.
|
|
158
173
|
* @property {string | null} data.previous - The icon id it replaced.
|
|
159
174
|
* @property {boolean} data.changed - Whether the file was written.
|
|
160
175
|
* @property {string[]} [data.files] - The generated module and its types, when its theme map was rewritten.
|
|
@@ -174,6 +189,24 @@
|
|
|
174
189
|
* @property {boolean} [useDefault] - The module's default export is the icon.
|
|
175
190
|
* @property {string} [variant] - Add the export as this declared variant of an existing icon.
|
|
176
191
|
* @property {string} [id] - The icon's id, instead of the one its name gives.
|
|
192
|
+
* @property {boolean} [all] - With `variant` and `from`, and no export name: add that variant for every icon whose id an export of `from` has.
|
|
193
|
+
*/
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* `astryx --json experimental icon add --variant <name> --from <module> --all`.
|
|
197
|
+
* @experimental May change or be removed in a patch release.
|
|
198
|
+
* @typedef {object} IconAddVariantsResponse
|
|
199
|
+
* @property {'icon.addVariants'} type
|
|
200
|
+
* @property {object} data
|
|
201
|
+
* @property {string} data.set
|
|
202
|
+
* @property {string} data.package
|
|
203
|
+
* @property {string} data.variant
|
|
204
|
+
* @property {string} data.from - The module the variant exports are read from.
|
|
205
|
+
* @property {number} data.added - Icons that gained the variant.
|
|
206
|
+
* @property {number} data.already - Icons that already had it.
|
|
207
|
+
* @property {string[]} data.missing - Ids of icons `from` has no export for; they keep no such variant.
|
|
208
|
+
* @property {string[]} data.files - Files written, relative to the package.
|
|
209
|
+
* @property {boolean} data.changed
|
|
177
210
|
*/
|
|
178
211
|
|
|
179
212
|
/**
|
|
@@ -190,7 +223,7 @@
|
|
|
190
223
|
* @property {string} [data.newDefinition] - The set's own definition the command wrote.
|
|
191
224
|
* @property {string[]} data.files - Files written, relative to the package.
|
|
192
225
|
* @property {boolean} data.changed - Whether anything was written.
|
|
193
|
-
* @property {string} [data.note] - What the
|
|
226
|
+
* @property {string} [data.note] - What the package still needs, as text to copy: the entry line that exports the icon from the set's module, and the package.json `files` that publishes a `./` source.
|
|
194
227
|
*/
|
|
195
228
|
|
|
196
229
|
/**
|
|
@@ -226,6 +259,29 @@
|
|
|
226
259
|
* @property {boolean} [list] - List the installed sets.
|
|
227
260
|
* @property {string} [set] - Keep one set, by name or `<package>/<set>`.
|
|
228
261
|
* @property {number} [limit] - Max matches (default 10).
|
|
262
|
+
* @property {boolean} [allIcons] - With `set` and no query: every icon of that set.
|
|
263
|
+
* @property {boolean} [definitions] - Every Astryx icon definition, and nothing else.
|
|
264
|
+
*/
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* `astryx --json experimental icon --definitions`.
|
|
268
|
+
* @experimental May change or be removed in a patch release.
|
|
269
|
+
* @typedef {object} IconDefinitionsResponse
|
|
270
|
+
* @property {'icon.definitions'} type
|
|
271
|
+
* @property {object} data
|
|
272
|
+
* @property {Array<{name: string, builtIn: boolean, description: string, words: string[]}>} data.definitions - Every Astryx icon definition, by name; `builtIn` ones every set maps.
|
|
273
|
+
*/
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* `astryx --json experimental icon --set <name> --all-icons`.
|
|
277
|
+
* @experimental May change or be removed in a patch release.
|
|
278
|
+
* @typedef {object} IconSetIconsResponse
|
|
279
|
+
* @property {'icon.setIcons'} type
|
|
280
|
+
* @property {object} data
|
|
281
|
+
* @property {string} data.set
|
|
282
|
+
* @property {string} data.package
|
|
283
|
+
* @property {number} data.iconCount
|
|
284
|
+
* @property {Array<{id: string, export: string, words: string[], definitions: string[]}>} data.icons - Every icon, by id, with the definitions `map` names it for.
|
|
229
285
|
*/
|
|
230
286
|
|
|
231
287
|
/**
|
|
@@ -236,6 +292,10 @@
|
|
|
236
292
|
* @property {boolean} [dryRun] - Return the receipt without writing.
|
|
237
293
|
* @property {string} [from] - A module whose every icon component the set wraps: a package, a package subpath, or a ./ path in the package.
|
|
238
294
|
* @property {string[] | string} [exclude] - With `from`: export names that are not icons; a string is split on commas.
|
|
295
|
+
* @property {string[] | string} [variants] - The variants the set supplies, such as `outline,solid`; a string is split on commas.
|
|
296
|
+
* @property {string} [defaultVariant] - With `variants`: the variant each icon's own export draws; the first variant when absent.
|
|
297
|
+
* @property {string} [displayName] - The descriptor's display name; the set name in title case when absent.
|
|
298
|
+
* @property {string} [description] - The descriptor's one-line description; `<Display name> icons.` when absent.
|
|
239
299
|
*/
|
|
240
300
|
|
|
241
301
|
/**
|
|
@@ -263,7 +323,11 @@
|
|
|
263
323
|
* @property {boolean} dryRun
|
|
264
324
|
* @property {string} [from]
|
|
265
325
|
* @property {number} [icons] - With `from`: how many icons it wrote.
|
|
266
|
-
* @property {
|
|
326
|
+
* @property {boolean} [refreshed] - With `from` on an existing set: the set was refreshed, not created.
|
|
327
|
+
* @property {Array<{from: string, to: string}>} [renamed] - On a refresh: the icons whose id this release's id rule changes, matched by the export the library still has; each keeps its `map` entries, variants, and words.
|
|
328
|
+
* @property {Array<{definition: string, icon: string}>} [mapped] - With `from`: the `map` entries an icon with the definition's exact name gives (on a refresh, every such entry, kept or new); check each.
|
|
329
|
+
* @property {Array<{definition: string, icon: string, word: string}>} [suggestions] - With `from`: for each unmapped Astryx definition, up to three icons it might map to, best first: the definition's name in another spelling or as another name of an icon, ids that start with it, an id or another name that is one of its words, then two-word ids that are a one-word word sized, shaped, or numbered (`grid-2x2`); never a negated form, the opposite direction, or an icon already mapped. `word` is the name or word that matched. Never written.
|
|
330
|
+
* @property {string[]} [notes] - What the author does next, including each change the package needs that the CLI never makes itself (its entry, peers, scripts), as text to copy.
|
|
267
331
|
*/
|
|
268
332
|
|
|
269
333
|
/**
|
package/api/icon/iconAdd.doc.mjs
CHANGED
|
@@ -13,10 +13,10 @@ export const doc = {
|
|
|
13
13
|
summary:
|
|
14
14
|
'Register one icon you chose from a library in the set being authored.',
|
|
15
15
|
description:
|
|
16
|
-
"Run inside an icon-set package. The caller picks the export; the CLI never searches the library. It proves the export is a runtime component of `from` (a package, a package subpath, or a
|
|
16
|
+
"Run inside an icon-set package. The caller picks the export; the CLI never searches the library. It proves the export is a runtime component of `from` (a package, a package subpath, or a ./ path to a file inside this package), read without running it. With no definition it answers the icon definitions that fit the export, Astryx's and the set's own, and writes nothing. With `definition` it adds the icon (id from its name, `module` the source unless the set's own module already exports it, words from its name and the definition) and maps the definition to it. With `newDefinition` it first writes the set's own definition file. A `variant` adds the export as that declared variant of an existing icon. With `variant`, `from`, and `all` and no export name, it adds that variant for every icon of the set whose id an export of `from` has, in one write. Running it again changes nothing. Experimental: it may change or be removed in a patch release.",
|
|
17
17
|
importPath: '@astryxdesign/cli/api',
|
|
18
18
|
signature:
|
|
19
|
-
'iconAdd(exportName: string, options: IconAddOptions): Promise<IconAddResponse | IconDefinitionMatchesResponse>',
|
|
19
|
+
'iconAdd(exportName: string | undefined, options: IconAddOptions): Promise<IconAddResponse | IconDefinitionMatchesResponse | IconAddVariantsResponse>',
|
|
20
20
|
keywords: [
|
|
21
21
|
'icon',
|
|
22
22
|
'icon set',
|
|
@@ -28,10 +28,10 @@ export const doc = {
|
|
|
28
28
|
params: [
|
|
29
29
|
{
|
|
30
30
|
name: 'exportName',
|
|
31
|
-
type: 'string',
|
|
31
|
+
type: 'string | undefined',
|
|
32
32
|
description:
|
|
33
|
-
'The export the set exposes the icon as, such as `Bin`; the set exports it as `<Name>Icon`.',
|
|
34
|
-
required:
|
|
33
|
+
'The export the set exposes the icon as, such as `Bin`; the set exports it as `<Name>Icon`. Omitted with `options.all`.',
|
|
34
|
+
required: false,
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
37
|
name: 'options.from',
|
|
@@ -82,6 +82,13 @@ export const doc = {
|
|
|
82
82
|
type: 'string',
|
|
83
83
|
description: "The icon's id, instead of the one its name gives.",
|
|
84
84
|
},
|
|
85
|
+
{
|
|
86
|
+
name: 'options.all',
|
|
87
|
+
type: 'boolean',
|
|
88
|
+
description:
|
|
89
|
+
'With `variant` and `from`, and no export name: add that variant for every icon of the set whose id an export of `from` has (`TrashIcon` in a solid module becomes the solid variant of `trash`).',
|
|
90
|
+
default: 'false',
|
|
91
|
+
},
|
|
85
92
|
{
|
|
86
93
|
name: 'options.cwd',
|
|
87
94
|
type: 'string',
|
|
@@ -94,6 +101,11 @@ export const doc = {
|
|
|
94
101
|
description:
|
|
95
102
|
'The icon registered, the definition mapped, and the files written.',
|
|
96
103
|
},
|
|
104
|
+
{
|
|
105
|
+
type: 'icon.addVariants',
|
|
106
|
+
description:
|
|
107
|
+
'With all: how many icons gained the variant, how many had it, the ids the module has no export for, and the files written.',
|
|
108
|
+
},
|
|
97
109
|
{
|
|
98
110
|
type: 'icon.definitionMatches',
|
|
99
111
|
description:
|
|
@@ -103,13 +115,17 @@ export const doc = {
|
|
|
103
115
|
throws: [
|
|
104
116
|
{
|
|
105
117
|
code: 'ERR_NOT_FOUND',
|
|
106
|
-
when: 'the module does not export the name, or the
|
|
118
|
+
when: 'the module does not export the name, the definition is unknown, or `set` names no set in the package or one that is withdrawn (with why)',
|
|
107
119
|
},
|
|
108
120
|
{
|
|
109
121
|
code: 'ERR_INVALID_ARGUMENT',
|
|
110
122
|
when: 'the export is data rather than a component, a new definition is named like an Astryx one, or the variant is not one the set declares',
|
|
111
123
|
},
|
|
112
124
|
{code: 'ERR_FILE_EXISTS', when: 'another icon already has the id'},
|
|
125
|
+
{
|
|
126
|
+
code: 'ERR_INVALID_OPTION',
|
|
127
|
+
when: 'an option is given that the call would ignore: `all` with an export name, `definition`, `newDefinition`, `description`, `words`, `useDefault`, or `id`; `definition` with `newDefinition`; or `description` or `words` without `newDefinition`',
|
|
128
|
+
},
|
|
113
129
|
{
|
|
114
130
|
code: 'ERR_PROJECT_REQUIRED',
|
|
115
131
|
when: 'the folder is outside any project and has no package.json at or above it',
|
package/api/icon/iconMap.doc.mjs
CHANGED
|
@@ -13,22 +13,23 @@ export const doc = {
|
|
|
13
13
|
summary:
|
|
14
14
|
'Register which icon of the set being authored draws an icon definition.',
|
|
15
15
|
description:
|
|
16
|
-
"Run inside an icon-set package. Sets `map[definition] = icon` in the set's data file, or removes the entry. The definition must be Astryx's or one the set declares,
|
|
16
|
+
"Run inside an icon-set package. Sets `map[definition] = icon` in the set's data file, or removes the entry. The definition must be Astryx's or one the set declares, named by its name or kebab id. The icon must be in the set, named 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; the entry records its id. The file is written in one fixed shape, `map` keys sorted. `integration check` suggests these commands for definitions the set has a fitting icon for. Experimental: it may change or be removed in a patch release.",
|
|
17
17
|
importPath: '@astryxdesign/cli/api',
|
|
18
18
|
signature:
|
|
19
|
-
'iconMap(definition: string, icon?: string, options?: IconMapOptions): Promise<IconMapResponse>',
|
|
19
|
+
'iconMap(definition: string | undefined, icon?: string, options?: IconMapOptions): Promise<IconMapResponse | IconMapManyResponse>',
|
|
20
20
|
keywords: ['icon', 'icon set', 'map', 'icon definition', 'register'],
|
|
21
21
|
params: [
|
|
22
22
|
{
|
|
23
23
|
name: 'definition',
|
|
24
|
-
type: 'string',
|
|
25
|
-
description: 'The icon definition.',
|
|
26
|
-
required:
|
|
24
|
+
type: 'string | undefined',
|
|
25
|
+
description: 'The icon definition. Omit with `options.pairs`.',
|
|
26
|
+
required: false,
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
name: 'icon',
|
|
30
30
|
type: 'string',
|
|
31
|
-
description:
|
|
31
|
+
description:
|
|
32
|
+
'An icon in the set, named by its id, its export name in any case (`TrashIcon`, `trashicon`), or another name its library exports it as, as an id or as the library spells it (`trash-2`, `Trash2`); never one word of its id. Omit with `remove`.',
|
|
32
33
|
},
|
|
33
34
|
{
|
|
34
35
|
name: 'options.cwd',
|
|
@@ -46,8 +47,19 @@ export const doc = {
|
|
|
46
47
|
description: "Remove the definition's entry.",
|
|
47
48
|
default: 'false',
|
|
48
49
|
},
|
|
50
|
+
{
|
|
51
|
+
name: 'options.pairs',
|
|
52
|
+
type: 'string | string[]',
|
|
53
|
+
description:
|
|
54
|
+
'Many entries at once: `<definition>=<icon>` pairs separated by commas or spaces, with no definition or icon argument; each icon is named as the icon argument is. Every pair is checked before any is written.',
|
|
55
|
+
},
|
|
49
56
|
],
|
|
50
57
|
returns: [
|
|
58
|
+
{
|
|
59
|
+
type: 'icon.mapMany',
|
|
60
|
+
description:
|
|
61
|
+
'With pairs: the set, the data file, each entry with the icon it replaced, and whether the file changed.',
|
|
62
|
+
},
|
|
51
63
|
{
|
|
52
64
|
type: 'icon.map',
|
|
53
65
|
description:
|
|
@@ -57,19 +69,23 @@ export const doc = {
|
|
|
57
69
|
throws: [
|
|
58
70
|
{
|
|
59
71
|
code: 'ERR_NOT_FOUND',
|
|
60
|
-
when: 'the definition is unknown,
|
|
72
|
+
when: 'the definition is unknown, the set has no such icon, or `set` names no set in the package or one that is withdrawn (with why)',
|
|
61
73
|
},
|
|
62
74
|
{
|
|
63
75
|
code: 'ERR_INVALID_ARGUMENT',
|
|
64
76
|
when: 'the package ships several sets and none is named',
|
|
65
77
|
},
|
|
78
|
+
{
|
|
79
|
+
code: 'ERR_INVALID_OPTION',
|
|
80
|
+
when: '`pairs` is given with a definition, an icon, or `remove`, or `remove` with an icon',
|
|
81
|
+
},
|
|
66
82
|
{
|
|
67
83
|
code: 'ERR_PROJECT_REQUIRED',
|
|
68
84
|
when: 'the folder is outside any project and has no package.json at or above it',
|
|
69
85
|
},
|
|
70
86
|
{
|
|
71
87
|
code: 'ERR_MISSING_ARGUMENT',
|
|
72
|
-
when: 'the definition is missing, or the icon
|
|
88
|
+
when: 'the definition is missing, or the icon without `remove`',
|
|
73
89
|
},
|
|
74
90
|
{
|
|
75
91
|
code: 'ERR_PATH_TRAVERSAL',
|
|
@@ -75,7 +75,7 @@ export const doc = {
|
|
|
75
75
|
{code: 'ERR_FILE_EXISTS', when: 'the definition file already exists'},
|
|
76
76
|
{
|
|
77
77
|
code: 'ERR_NOT_FOUND',
|
|
78
|
-
when: 'the package ships no icon set, or the set has no such icon',
|
|
78
|
+
when: 'the package ships no icon set, `set` names no set in it or one that is withdrawn (with why), or the set has no such icon',
|
|
79
79
|
},
|
|
80
80
|
{
|
|
81
81
|
code: 'ERR_PROJECT_REQUIRED',
|
|
@@ -93,7 +93,7 @@ export const doc = {
|
|
|
93
93
|
examples: [
|
|
94
94
|
{
|
|
95
95
|
label: 'Add and map a definition',
|
|
96
|
-
code: "await iconNewDefinition('
|
|
96
|
+
code: "await iconNewDefinition('random', {description: 'Pick something at random.', words: ['dice', 'shuffle', 'chance'], icon: 'dice-5'});",
|
|
97
97
|
},
|
|
98
98
|
],
|
|
99
99
|
command: 'experimental icon new-definition',
|
|
@@ -10,7 +10,7 @@ export const doc = {
|
|
|
10
10
|
displayName: 'iconNewSet()',
|
|
11
11
|
summary: 'Add an icon set to an integration package.',
|
|
12
12
|
description:
|
|
13
|
-
"Creates an integration manifest when the package has none, writes the set directory with its strongly typed same-stem IconSetDoc and a starter data file (schemaVersion 1, module set to the package name, no icons and an empty map yet), and the set's generated module with its declaration file and an empty themeIcons theme map; with from, it wraps a library's icons into them. It declares the manifest's `experimental.iconSets` root on first use, and includes the manifest and root in package.json files when the package already uses an allowlist. Every path is confined to the package and existing files are never overwritten. Experimental: it may change or be removed in a patch release.",
|
|
13
|
+
"Creates an integration manifest when the package has none, writes the set directory with its strongly typed same-stem IconSetDoc and a starter data file (schemaVersion 1, module set to the package name, no icons and an empty map yet), and the set's generated module with its declaration file and an empty themeIcons theme map; with from, it wraps a library's icons into them, records the installed library and version as the data file's source, copies the library's license notices into the set, uses the library's license, maps each Astryx definition whose name is an icon id, and returns up to three likely icons for each other definition as suggestions (by its name, its words, and the other names the library gives an icon; never a part of a word, a negated form, or the opposite direction), never written. It declares the manifest's `experimental.iconSets` root on first use, and includes the manifest and root in package.json files when the package already uses an allowlist. It never writes the package's entry, exports, main, types, files list, peers, or scripts: its notes name each change the package needs as text to copy. Every path is confined to the package and existing files are never overwritten. Experimental: it may change or be removed in a patch release.",
|
|
14
14
|
importPath: '@astryxdesign/cli/api',
|
|
15
15
|
signature:
|
|
16
16
|
'iconNewSet(name: string, options?: IconNewSetOptions): Promise<IconNewSetResponse>',
|
|
@@ -46,6 +46,30 @@ export const doc = {
|
|
|
46
46
|
description:
|
|
47
47
|
'With from: export names that are not icons; a string is split on commas. SCREAMING_CASE names and number or boolean exports are always left out.',
|
|
48
48
|
},
|
|
49
|
+
{
|
|
50
|
+
name: 'options.variants',
|
|
51
|
+
type: 'string[] | string',
|
|
52
|
+
description:
|
|
53
|
+
"The variants the set supplies, lower-kebab names such as outline and solid; a string is split on commas. Written to the data file's variants.",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'options.defaultVariant',
|
|
57
|
+
type: 'string',
|
|
58
|
+
description:
|
|
59
|
+
"With variants: the variant each icon's own export draws, written to the data file's default; the first variant when absent.",
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'options.displayName',
|
|
63
|
+
type: 'string',
|
|
64
|
+
description:
|
|
65
|
+
"The descriptor's display name; the set name in title case when absent.",
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'options.description',
|
|
69
|
+
type: 'string',
|
|
70
|
+
description:
|
|
71
|
+
"The descriptor's one-line description; '<Display name> icons.' when absent.",
|
|
72
|
+
},
|
|
49
73
|
],
|
|
50
74
|
returns: [
|
|
51
75
|
{
|
|
@@ -57,7 +81,11 @@ export const doc = {
|
|
|
57
81
|
throws: [
|
|
58
82
|
{
|
|
59
83
|
code: 'ERR_INVALID_ARGUMENT',
|
|
60
|
-
when: 'the name is not lowercase kebab-case,
|
|
84
|
+
when: 'the name is not lowercase kebab-case, package.json has no name, or a variant name or the default variant is invalid',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
code: 'ERR_INVALID_OPTION',
|
|
88
|
+
when: '`exclude` is given without `from`, or `defaultVariant` without `variants`',
|
|
61
89
|
},
|
|
62
90
|
{
|
|
63
91
|
code: 'ERR_FILE_EXISTS',
|
package/api/icon/iconUse.doc.mjs
CHANGED
|
@@ -38,7 +38,10 @@ export const doc = {
|
|
|
38
38
|
},
|
|
39
39
|
],
|
|
40
40
|
throws: [
|
|
41
|
-
{
|
|
41
|
+
{
|
|
42
|
+
code: 'ERR_NOT_FOUND',
|
|
43
|
+
when: 'no installed set has the name, or the set it names is withdrawn (the message says which, and why)',
|
|
44
|
+
},
|
|
42
45
|
{
|
|
43
46
|
code: 'ERR_INVALID_ARGUMENT',
|
|
44
47
|
when: 'two installed packages ship a set with the name',
|