@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
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Every pair of options an icon command declares has a decided result
|
|
5
|
+
* (spec:AST-042 FR5): for each command, the pairs come from its CommandDoc
|
|
6
|
+
* (its options and its optional arguments; a required argument is always
|
|
7
|
+
* given), and each pair is either
|
|
8
|
+
* - refused together with `ERR_INVALID_OPTION` (the `refused` table), or
|
|
9
|
+
* - composed: the call succeeds with both (the `composes` table), or
|
|
10
|
+
* - prevented by another rule: the call fails with another code the
|
|
11
|
+
* function documents (every other pair).
|
|
12
|
+
* A pair that succeeds without being listed as composing fails this test, so
|
|
13
|
+
* a new option, or a change that starts ignoring one, is decided in review.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import * as fs from 'node:fs';
|
|
17
|
+
import * as os from 'node:os';
|
|
18
|
+
import * as path from 'node:path';
|
|
19
|
+
import {afterAll, beforeAll, describe, expect, it} from 'vitest';
|
|
20
|
+
import {writeIconSetProject} from '../../test-utils/icon-set-fixture.mjs';
|
|
21
|
+
import {icon} from './icon.mjs';
|
|
22
|
+
import {iconAdd} from './add/add.mjs';
|
|
23
|
+
import {iconMap} from './map/map.mjs';
|
|
24
|
+
import {iconNewSet} from './new-set/new-set.mjs';
|
|
25
|
+
import {iconNewDefinition} from './new-definition/new-definition.mjs';
|
|
26
|
+
import {iconUse} from './use/use.mjs';
|
|
27
|
+
import {doc as iconCommand} from '../../clients/cli/commands/experimental-icon.doc.mjs';
|
|
28
|
+
import {doc as addCommand} from '../../clients/cli/commands/experimental-icon-add.doc.mjs';
|
|
29
|
+
import {doc as mapCommand} from '../../clients/cli/commands/experimental-icon-map.doc.mjs';
|
|
30
|
+
import {doc as newSetCommand} from '../../clients/cli/commands/experimental-icon-new-set.doc.mjs';
|
|
31
|
+
import {doc as newDefinitionCommand} from '../../clients/cli/commands/experimental-icon-new-definition.doc.mjs';
|
|
32
|
+
import {doc as useCommand} from '../../clients/cli/commands/experimental-icon-use.doc.mjs';
|
|
33
|
+
import {doc as iconFn} from './icon.doc.mjs';
|
|
34
|
+
import {doc as addFn} from './iconAdd.doc.mjs';
|
|
35
|
+
import {doc as mapFn} from './iconMap.doc.mjs';
|
|
36
|
+
import {doc as newSetFn} from './iconNewSet.doc.mjs';
|
|
37
|
+
import {doc as newDefinitionFn} from './iconNewDefinition.doc.mjs';
|
|
38
|
+
import {doc as useFn} from './iconUse.doc.mjs';
|
|
39
|
+
|
|
40
|
+
/** @type {string} */
|
|
41
|
+
let tmp;
|
|
42
|
+
beforeAll(() => {
|
|
43
|
+
tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-icon-pairs-'));
|
|
44
|
+
});
|
|
45
|
+
afterAll(() => {
|
|
46
|
+
fs.rmSync(tmp, {recursive: true, force: true});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const FROM = '@acme/glyph-library';
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* An icon-set package `@acme/icons` with an installed library, and, unless
|
|
53
|
+
* `bare`, its set `glyphs` made from that library with two variants.
|
|
54
|
+
* @param {{bare?: boolean}} [options]
|
|
55
|
+
* @returns {Promise<string>}
|
|
56
|
+
*/
|
|
57
|
+
async function makePackage({bare = false} = {}) {
|
|
58
|
+
const dir = fs.mkdtempSync(path.join(tmp, 'pkg-'));
|
|
59
|
+
fs.writeFileSync(
|
|
60
|
+
path.join(dir, 'package.json'),
|
|
61
|
+
`${JSON.stringify({name: '@acme/icons', version: '1.0.0', license: 'MIT', type: 'module'}, null, 2)}\n`,
|
|
62
|
+
);
|
|
63
|
+
const lib = path.join(dir, 'node_modules', '@acme', 'glyph-library');
|
|
64
|
+
fs.mkdirSync(lib, {recursive: true});
|
|
65
|
+
fs.writeFileSync(
|
|
66
|
+
path.join(lib, 'package.json'),
|
|
67
|
+
JSON.stringify({
|
|
68
|
+
name: '@acme/glyph-library',
|
|
69
|
+
version: '2.0.0',
|
|
70
|
+
type: 'module',
|
|
71
|
+
exports: {'.': './index.js', './solid': './solid.js'},
|
|
72
|
+
}),
|
|
73
|
+
);
|
|
74
|
+
const icons =
|
|
75
|
+
'export const Bin = props => null;\nexport const Close = props => null;\n';
|
|
76
|
+
fs.writeFileSync(path.join(lib, 'index.js'), icons);
|
|
77
|
+
fs.writeFileSync(path.join(lib, 'solid.js'), icons);
|
|
78
|
+
if (!bare) {
|
|
79
|
+
await iconNewSet('glyphs', {
|
|
80
|
+
cwd: dir,
|
|
81
|
+
from: FROM,
|
|
82
|
+
variants: 'outline,solid',
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return dir;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @typedef {object} Case
|
|
90
|
+
* @property {any} command the CommandDoc
|
|
91
|
+
* @property {any} fn the FunctionDoc
|
|
92
|
+
* @property {(...args: any[]) => Promise<unknown>} call
|
|
93
|
+
* @property {() => Promise<string>} cwd a fresh folder for one call
|
|
94
|
+
* @property {Record<string, unknown>} values a value for each API parameter
|
|
95
|
+
* @property {Array<[string, string]>} refused pairs refused together
|
|
96
|
+
* @property {Array<[string, string]>} composes pairs that succeed together
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
/** @type {Record<string, Case>} */
|
|
100
|
+
const CASES = {
|
|
101
|
+
'experimental icon': {
|
|
102
|
+
command: iconCommand,
|
|
103
|
+
fn: iconFn,
|
|
104
|
+
call: icon,
|
|
105
|
+
cwd: async () =>
|
|
106
|
+
writeIconSetProject(fs.mkdtempSync(path.join(tmp, 'app-'))),
|
|
107
|
+
values: {
|
|
108
|
+
query: 'trash',
|
|
109
|
+
'options.list': true,
|
|
110
|
+
'options.set': 'glyphs',
|
|
111
|
+
'options.limit': 3,
|
|
112
|
+
'options.definitions': true,
|
|
113
|
+
'options.allIcons': true,
|
|
114
|
+
},
|
|
115
|
+
refused: [
|
|
116
|
+
['query', '--list'],
|
|
117
|
+
['query', '--definitions'],
|
|
118
|
+
['query', '--all-icons'],
|
|
119
|
+
['--list', '--set'],
|
|
120
|
+
['--list', '--limit'],
|
|
121
|
+
['--list', '--definitions'],
|
|
122
|
+
['--list', '--all-icons'],
|
|
123
|
+
['--set', '--definitions'],
|
|
124
|
+
['--limit', '--definitions'],
|
|
125
|
+
['--limit', '--all-icons'],
|
|
126
|
+
['--definitions', '--all-icons'],
|
|
127
|
+
],
|
|
128
|
+
composes: [
|
|
129
|
+
['query', '--set'],
|
|
130
|
+
['query', '--limit'],
|
|
131
|
+
['--set', '--all-icons'],
|
|
132
|
+
],
|
|
133
|
+
},
|
|
134
|
+
'experimental icon add': {
|
|
135
|
+
command: addCommand,
|
|
136
|
+
fn: addFn,
|
|
137
|
+
call: iconAdd,
|
|
138
|
+
cwd: () => makePackage(),
|
|
139
|
+
values: {
|
|
140
|
+
exportName: 'Bin',
|
|
141
|
+
'options.from': FROM,
|
|
142
|
+
'options.definition': 'delete',
|
|
143
|
+
'options.newDefinition': 'binIt',
|
|
144
|
+
'options.description': 'Put something in the bin.',
|
|
145
|
+
'options.words': ['bin'],
|
|
146
|
+
'options.useDefault': true,
|
|
147
|
+
'options.variant': 'solid',
|
|
148
|
+
'options.all': true,
|
|
149
|
+
'options.id': 'bin',
|
|
150
|
+
'options.set': 'glyphs',
|
|
151
|
+
},
|
|
152
|
+
refused: [
|
|
153
|
+
['export', '--all'],
|
|
154
|
+
['--definition', '--new-definition'],
|
|
155
|
+
['--definition', '--description'],
|
|
156
|
+
['--definition', '--words'],
|
|
157
|
+
['--definition', '--all'],
|
|
158
|
+
['--new-definition', '--all'],
|
|
159
|
+
['--description', '--all'],
|
|
160
|
+
['--words', '--all'],
|
|
161
|
+
['--default', '--all'],
|
|
162
|
+
['--all', '--id'],
|
|
163
|
+
// A description and words describe only a new definition.
|
|
164
|
+
['export', '--description'],
|
|
165
|
+
['export', '--words'],
|
|
166
|
+
['--from', '--description'],
|
|
167
|
+
['--from', '--words'],
|
|
168
|
+
['--description', '--words'],
|
|
169
|
+
['--description', '--default'],
|
|
170
|
+
['--description', '--variant'],
|
|
171
|
+
['--description', '--id'],
|
|
172
|
+
['--description', '--set'],
|
|
173
|
+
['--words', '--default'],
|
|
174
|
+
['--words', '--variant'],
|
|
175
|
+
['--words', '--id'],
|
|
176
|
+
['--words', '--set'],
|
|
177
|
+
],
|
|
178
|
+
composes: [['export', '--from']],
|
|
179
|
+
},
|
|
180
|
+
'experimental icon map': {
|
|
181
|
+
command: mapCommand,
|
|
182
|
+
fn: mapFn,
|
|
183
|
+
call: iconMap,
|
|
184
|
+
cwd: () => makePackage(),
|
|
185
|
+
values: {
|
|
186
|
+
definition: 'delete',
|
|
187
|
+
icon: 'bin',
|
|
188
|
+
'options.set': 'glyphs',
|
|
189
|
+
'options.remove': true,
|
|
190
|
+
'options.pairs': 'close=close',
|
|
191
|
+
},
|
|
192
|
+
refused: [
|
|
193
|
+
['definition', '--pairs'],
|
|
194
|
+
['icon', '--remove'],
|
|
195
|
+
['icon', '--pairs'],
|
|
196
|
+
['--remove', '--pairs'],
|
|
197
|
+
],
|
|
198
|
+
composes: [
|
|
199
|
+
['definition', 'icon'],
|
|
200
|
+
['definition', '--remove'],
|
|
201
|
+
['--set', '--pairs'],
|
|
202
|
+
],
|
|
203
|
+
},
|
|
204
|
+
'experimental icon new-set': {
|
|
205
|
+
command: newSetCommand,
|
|
206
|
+
fn: newSetFn,
|
|
207
|
+
call: iconNewSet,
|
|
208
|
+
cwd: () => makePackage({bare: true}),
|
|
209
|
+
values: {
|
|
210
|
+
name: 'glyphs',
|
|
211
|
+
'options.dryRun': true,
|
|
212
|
+
'options.from': FROM,
|
|
213
|
+
'options.exclude': 'Close',
|
|
214
|
+
'options.variants': 'outline,solid',
|
|
215
|
+
'options.defaultVariant': 'solid',
|
|
216
|
+
'options.displayName': 'Glyphs',
|
|
217
|
+
'options.description': 'Glyph icons.',
|
|
218
|
+
},
|
|
219
|
+
refused: [
|
|
220
|
+
// `--exclude` needs `--from`, `--default-variant` needs `--variants`.
|
|
221
|
+
['--dry-run', '--exclude'],
|
|
222
|
+
['--dry-run', '--default-variant'],
|
|
223
|
+
['--exclude', '--variants'],
|
|
224
|
+
['--exclude', '--default-variant'],
|
|
225
|
+
['--exclude', '--display-name'],
|
|
226
|
+
['--exclude', '--description'],
|
|
227
|
+
['--from', '--default-variant'],
|
|
228
|
+
['--default-variant', '--display-name'],
|
|
229
|
+
['--default-variant', '--description'],
|
|
230
|
+
],
|
|
231
|
+
composes: [
|
|
232
|
+
['--dry-run', '--from'],
|
|
233
|
+
['--dry-run', '--variants'],
|
|
234
|
+
['--dry-run', '--display-name'],
|
|
235
|
+
['--dry-run', '--description'],
|
|
236
|
+
['--from', '--exclude'],
|
|
237
|
+
['--from', '--variants'],
|
|
238
|
+
['--from', '--display-name'],
|
|
239
|
+
['--from', '--description'],
|
|
240
|
+
['--variants', '--default-variant'],
|
|
241
|
+
['--variants', '--display-name'],
|
|
242
|
+
['--variants', '--description'],
|
|
243
|
+
['--display-name', '--description'],
|
|
244
|
+
],
|
|
245
|
+
},
|
|
246
|
+
'experimental icon new-definition': {
|
|
247
|
+
command: newDefinitionCommand,
|
|
248
|
+
fn: newDefinitionFn,
|
|
249
|
+
call: iconNewDefinition,
|
|
250
|
+
cwd: () => makePackage(),
|
|
251
|
+
values: {
|
|
252
|
+
name: 'binIt',
|
|
253
|
+
'options.dryRun': true,
|
|
254
|
+
'options.set': 'glyphs',
|
|
255
|
+
'options.description': 'Put something in the bin.',
|
|
256
|
+
'options.words': ['bin'],
|
|
257
|
+
'options.icon': 'bin',
|
|
258
|
+
},
|
|
259
|
+
refused: [],
|
|
260
|
+
composes: [['--description', '--words']],
|
|
261
|
+
},
|
|
262
|
+
'experimental icon use': {
|
|
263
|
+
command: useCommand,
|
|
264
|
+
fn: useFn,
|
|
265
|
+
call: iconUse,
|
|
266
|
+
cwd: async () =>
|
|
267
|
+
writeIconSetProject(fs.mkdtempSync(path.join(tmp, 'app-'))),
|
|
268
|
+
values: {set: 'glyphs'},
|
|
269
|
+
refused: [],
|
|
270
|
+
composes: [],
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* The pair members a command declares: its optional arguments, by name, and
|
|
276
|
+
* its options, by long flag; each with the API parameter it sets.
|
|
277
|
+
* @param {any} command
|
|
278
|
+
* @returns {Array<{label: string, param: string}>}
|
|
279
|
+
*/
|
|
280
|
+
function members(command) {
|
|
281
|
+
return [
|
|
282
|
+
...(command.args ?? [])
|
|
283
|
+
.filter((/** @type {any} */ arg) => arg.required !== true)
|
|
284
|
+
.map((/** @type {any} */ arg) => ({label: arg.name, param: arg.param})),
|
|
285
|
+
...(command.options ?? []).map((/** @type {any} */ option) => ({
|
|
286
|
+
label: option.flag.split(/[\s,]/u)[0],
|
|
287
|
+
param: option.param,
|
|
288
|
+
})),
|
|
289
|
+
];
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** @param {[string, string]} pair */
|
|
293
|
+
const key = ([a, b]) => [a, b].sort().join(' + ');
|
|
294
|
+
|
|
295
|
+
describe.each(Object.entries(CASES))('%s', (_name, spec) => {
|
|
296
|
+
const declared = members(spec.command);
|
|
297
|
+
const labels = declared.map(each => each.label);
|
|
298
|
+
/** @type {Array<[string, string]>} */
|
|
299
|
+
const pairs = [];
|
|
300
|
+
for (let i = 0; i < declared.length; i++) {
|
|
301
|
+
for (let j = i + 1; j < declared.length; j++) {
|
|
302
|
+
pairs.push([declared[i].label, declared[j].label]);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
const refused = new Set(spec.refused.map(key));
|
|
306
|
+
const composes = new Set(spec.composes.map(key));
|
|
307
|
+
const documented = new Set(
|
|
308
|
+
(spec.fn.throws ?? []).map((/** @type {any} */ each) => each.code),
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
it('names only pairs the command declares, each in one table', () => {
|
|
312
|
+
for (const pair of [...spec.refused, ...spec.composes]) {
|
|
313
|
+
expect(labels, key(pair)).toEqual(expect.arrayContaining(pair));
|
|
314
|
+
}
|
|
315
|
+
expect([...refused].filter(each => composes.has(each))).toEqual([]);
|
|
316
|
+
for (const {param} of declared) {
|
|
317
|
+
expect(Object.keys(spec.values), param).toContain(param);
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
if (pairs.length === 0) return;
|
|
322
|
+
it.each(pairs)('%s with %s', async (a, b) => {
|
|
323
|
+
const given = new Set([a, b]);
|
|
324
|
+
const cwd = await spec.cwd();
|
|
325
|
+
// Required arguments are always given, in order; the rest only when
|
|
326
|
+
// they are one of the pair.
|
|
327
|
+
const args = (spec.command.args ?? []).map((/** @type {any} */ arg) =>
|
|
328
|
+
arg.required === true || given.has(arg.name)
|
|
329
|
+
? spec.values[arg.param]
|
|
330
|
+
: undefined,
|
|
331
|
+
);
|
|
332
|
+
/** @type {Record<string, unknown>} */
|
|
333
|
+
const options = {cwd};
|
|
334
|
+
for (const {label, param} of declared) {
|
|
335
|
+
if (given.has(label) && param.startsWith('options.')) {
|
|
336
|
+
options[param.slice('options.'.length)] = spec.values[param];
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/** @type {any} */
|
|
340
|
+
let error = null;
|
|
341
|
+
try {
|
|
342
|
+
await spec.call(...args, options);
|
|
343
|
+
} catch (thrown) {
|
|
344
|
+
error = thrown;
|
|
345
|
+
}
|
|
346
|
+
const pair = key([a, b]);
|
|
347
|
+
if (refused.has(pair)) {
|
|
348
|
+
expect(error?.code, `${pair}: ${error?.message}`).toBe(
|
|
349
|
+
'ERR_INVALID_OPTION',
|
|
350
|
+
);
|
|
351
|
+
} else if (composes.has(pair)) {
|
|
352
|
+
expect(error, `${pair}: ${error?.message}`).toBeNull();
|
|
353
|
+
} else {
|
|
354
|
+
// Prevented by another rule: a documented code, never a silent
|
|
355
|
+
// success and never an unknown error.
|
|
356
|
+
expect(
|
|
357
|
+
error,
|
|
358
|
+
`${pair} succeeded but is not listed as composing`,
|
|
359
|
+
).not.toBeNull();
|
|
360
|
+
expect(error.code, `${pair}: ${error.message}`).not.toBe(
|
|
361
|
+
'ERR_INVALID_OPTION',
|
|
362
|
+
);
|
|
363
|
+
expect([...documented], `${pair}: ${error.message}`).toContain(
|
|
364
|
+
error.code,
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
});
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Every icon of one set, by id: `--set <name> --all-icons`, so an author can read
|
|
6
|
+
* a whole library's ids, words, and the definitions each icon draws.
|
|
7
|
+
* @param {{cwd: string, set: string}} options
|
|
8
|
+
* @returns {Promise<import('../icon.type.mjs').IconSetIconsResponse>}
|
|
9
|
+
*/
|
|
10
|
+
export function iconSetIcons({ cwd, set }: {
|
|
11
|
+
cwd: string;
|
|
12
|
+
set: string;
|
|
13
|
+
}): Promise<import("../icon.type.mjs").IconSetIconsResponse>;
|
|
4
14
|
/**
|
|
5
15
|
* Rank every installed icon against a query.
|
|
6
16
|
* @param {string} query
|
|
@@ -12,7 +12,54 @@
|
|
|
12
12
|
import {AstryxError} from '../../error.mjs';
|
|
13
13
|
import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
|
|
14
14
|
import {loadIconSets} from '../_adapter.mjs';
|
|
15
|
-
import {
|
|
15
|
+
import {rankIcons, setsNamed, unusableSet} from '../_records.mjs';
|
|
16
|
+
|
|
17
|
+
/** The lowest score of a whole-word or word-start match. */
|
|
18
|
+
const WORD_SCORE = 60;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Every icon of one set, by id: `--set <name> --all-icons`, so an author can read
|
|
22
|
+
* a whole library's ids, words, and the definitions each icon draws.
|
|
23
|
+
* @param {{cwd: string, set: string}} options
|
|
24
|
+
* @returns {Promise<import('../icon.type.mjs').IconSetIconsResponse>}
|
|
25
|
+
*/
|
|
26
|
+
export async function iconSetIcons({cwd, set}) {
|
|
27
|
+
const {sets, withdrawn} = await loadIconSets(cwd);
|
|
28
|
+
const named = setsNamed(sets, set);
|
|
29
|
+
if (named.length === 0) throw unusableSet(sets, withdrawn, set);
|
|
30
|
+
if (named.length > 1) {
|
|
31
|
+
throw new AstryxError(
|
|
32
|
+
`"${set}" names ${named.length} sets; name one as <package>/<set>`,
|
|
33
|
+
named.map(each => ({
|
|
34
|
+
name: `${each.package}/${each.name}`,
|
|
35
|
+
reason: 'name the package',
|
|
36
|
+
})),
|
|
37
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
const [only] = named;
|
|
41
|
+
/** @type {Map<string, string[]>} */
|
|
42
|
+
const drawn = new Map();
|
|
43
|
+
for (const [definition, id] of Object.entries(only.data.map ?? {})) {
|
|
44
|
+
drawn.set(id, [...(drawn.get(id) ?? []), definition]);
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
type: 'icon.setIcons',
|
|
48
|
+
data: {
|
|
49
|
+
set: only.name,
|
|
50
|
+
package: only.package,
|
|
51
|
+
iconCount: only.data.icons.length,
|
|
52
|
+
icons: [...only.data.icons]
|
|
53
|
+
.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0))
|
|
54
|
+
.map(icon => ({
|
|
55
|
+
id: icon.id,
|
|
56
|
+
export: icon.export,
|
|
57
|
+
words: icon.words,
|
|
58
|
+
definitions: (drawn.get(icon.id) ?? []).sort(),
|
|
59
|
+
})),
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
16
63
|
|
|
17
64
|
/**
|
|
18
65
|
* Rank every installed icon against a query.
|
|
@@ -25,20 +72,14 @@ export async function iconSearch(query, {cwd, set, limit}) {
|
|
|
25
72
|
let searched = sets;
|
|
26
73
|
if (set != null) {
|
|
27
74
|
searched = setsNamed(sets, set);
|
|
28
|
-
if (searched.length === 0)
|
|
29
|
-
throw new AstryxError(
|
|
30
|
-
withdrawnReason(withdrawn, set) ??
|
|
31
|
-
`No installed icon set named "${set}"`,
|
|
32
|
-
closest(
|
|
33
|
-
set,
|
|
34
|
-
sets.flatMap(each => [each.name, `${each.package}/${each.name}`]),
|
|
35
|
-
'installed icon set',
|
|
36
|
-
),
|
|
37
|
-
ERROR_CODES.ERR_NOT_FOUND,
|
|
38
|
-
);
|
|
39
|
-
}
|
|
75
|
+
if (searched.length === 0) throw unusableSet(sets, withdrawn, set);
|
|
40
76
|
}
|
|
41
|
-
const
|
|
77
|
+
const ranked = rankIcons(searched, query);
|
|
78
|
+
// A partial match (`pin` inside `shopping`) answers only when nothing
|
|
79
|
+
// matches a whole word or a word start.
|
|
80
|
+
const matches = ranked.some(each => each.score >= WORD_SCORE)
|
|
81
|
+
? ranked.filter(each => each.score >= WORD_SCORE)
|
|
82
|
+
: ranked;
|
|
42
83
|
return {
|
|
43
84
|
type: 'icon.search',
|
|
44
85
|
data: {
|
package/api/icon/use/use.mjs
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
refuseOutsideProject,
|
|
19
19
|
setConfigString,
|
|
20
20
|
} from '../_adapter.mjs';
|
|
21
|
-
import {
|
|
21
|
+
import {setsNamed, unusableSet} from '../_records.mjs';
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Make an installed set the project's icon set.
|
|
@@ -45,18 +45,7 @@ export async function iconUse(selector, {cwd = process.cwd()} = {}) {
|
|
|
45
45
|
refuseOutsideProject(cwd, 'experimental icon use', 'the app project');
|
|
46
46
|
const {projectDir, sets, withdrawn} = await loadIconProject(cwd);
|
|
47
47
|
const named = setsNamed(sets, selector);
|
|
48
|
-
if (named.length === 0)
|
|
49
|
-
throw new AstryxError(
|
|
50
|
-
withdrawnReason(withdrawn, selector) ??
|
|
51
|
-
`No installed icon set is named "${selector}".`,
|
|
52
|
-
closest(
|
|
53
|
-
selector,
|
|
54
|
-
sets.flatMap(set => [set.name, iconSetKey(set)]),
|
|
55
|
-
'an installed icon set',
|
|
56
|
-
),
|
|
57
|
-
ERROR_CODES.ERR_NOT_FOUND,
|
|
58
|
-
);
|
|
59
|
-
}
|
|
48
|
+
if (named.length === 0) throw unusableSet(sets, withdrawn, selector);
|
|
60
49
|
if (named.length > 1) {
|
|
61
50
|
throw new AstryxError(
|
|
62
51
|
`Two installed packages ship an icon set named "${selector}"; name it with its package.`,
|
|
@@ -92,7 +92,7 @@ export function loadCurrentManifest(manifestFile: string, manifestExists: boolea
|
|
|
92
92
|
* @param {string} manifestPath
|
|
93
93
|
* @param {string[]} files
|
|
94
94
|
* @param {boolean} dryRun
|
|
95
|
-
* @returns {{type: 'integration.add', data: Omit<import('./integration-authoring.type.mjs').IntegrationAddData, 'kind'> & {kind: K, icons?: number, notes?: string[]}}}
|
|
95
|
+
* @returns {{type: 'integration.add', data: Omit<import('./integration-authoring.type.mjs').IntegrationAddData, 'kind'> & {kind: K, icons?: number, refreshed?: boolean, renamed?: Array<{from: string, to: string}>, mapped?: Array<{definition: string, icon: string}>, suggestions?: Array<{definition: string, icon: string, word: string}>, notes?: string[]}}}
|
|
96
96
|
*/
|
|
97
97
|
export function receipt<K extends import("./integration-authoring.type.mjs").IntegrationAddData["kind"] | import("../icon/icon.type.mjs").IconNewData["kind"]>(kind: K, name: string, root: {
|
|
98
98
|
path: string;
|
|
@@ -102,6 +102,20 @@ export function receipt<K extends import("./integration-authoring.type.mjs").Int
|
|
|
102
102
|
data: Omit<import("./integration-authoring.type.mjs").IntegrationAddData, "kind"> & {
|
|
103
103
|
kind: K;
|
|
104
104
|
icons?: number;
|
|
105
|
+
refreshed?: boolean;
|
|
106
|
+
renamed?: Array<{
|
|
107
|
+
from: string;
|
|
108
|
+
to: string;
|
|
109
|
+
}>;
|
|
110
|
+
mapped?: Array<{
|
|
111
|
+
definition: string;
|
|
112
|
+
icon: string;
|
|
113
|
+
}>;
|
|
114
|
+
suggestions?: Array<{
|
|
115
|
+
definition: string;
|
|
116
|
+
icon: string;
|
|
117
|
+
word: string;
|
|
118
|
+
}>;
|
|
105
119
|
notes?: string[];
|
|
106
120
|
};
|
|
107
121
|
};
|
|
@@ -483,7 +483,7 @@ export async function loadCurrentManifest(manifestFile, manifestExists) {
|
|
|
483
483
|
* @param {string} manifestPath
|
|
484
484
|
* @param {string[]} files
|
|
485
485
|
* @param {boolean} dryRun
|
|
486
|
-
* @returns {{type: 'integration.add', data: Omit<import('./integration-authoring.type.mjs').IntegrationAddData, 'kind'> & {kind: K, icons?: number, notes?: string[]}}}
|
|
486
|
+
* @returns {{type: 'integration.add', data: Omit<import('./integration-authoring.type.mjs').IntegrationAddData, 'kind'> & {kind: K, icons?: number, refreshed?: boolean, renamed?: Array<{from: string, to: string}>, mapped?: Array<{definition: string, icon: string}>, suggestions?: Array<{definition: string, icon: string, word: string}>, notes?: string[]}}}
|
|
487
487
|
*/
|
|
488
488
|
export function receipt(kind, name, root, manifestPath, files, dryRun) {
|
|
489
489
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
|
-
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
3
|
+
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
|
4
4
|
import {spawnSync} from 'node:child_process';
|
|
5
5
|
import * as fs from 'node:fs';
|
|
6
6
|
import * as path from 'node:path';
|
|
@@ -123,4 +123,27 @@ describe('integrationPackCheck with lifecycle script output', () => {
|
|
|
123
123
|
expect(failure?.message).toContain('npm pack failed (exit 3)');
|
|
124
124
|
expect(failure?.message).toContain('prepack exploded');
|
|
125
125
|
});
|
|
126
|
+
|
|
127
|
+
it.skipIf(process.platform === 'win32')(
|
|
128
|
+
'packs with npm itself when an earlier npm on the PATH refuses every command',
|
|
129
|
+
async () => {
|
|
130
|
+
writeThemePackage({});
|
|
131
|
+
const refusing = path.join(tmpDir, '.refusing-bin');
|
|
132
|
+
fs.mkdirSync(refusing);
|
|
133
|
+
fs.writeFileSync(
|
|
134
|
+
path.join(refusing, 'npm'),
|
|
135
|
+
"#!/bin/sh\necho 'npm commands are not allowed on this machine'\nexit 1\n",
|
|
136
|
+
{mode: 0o755},
|
|
137
|
+
);
|
|
138
|
+
vi.stubEnv('PATH', `${refusing}${path.delimiter}${process.env.PATH}`);
|
|
139
|
+
try {
|
|
140
|
+
const result = await integrationPackCheck({cwd: tmpDir});
|
|
141
|
+
|
|
142
|
+
expect(result.data.issues).toEqual([]);
|
|
143
|
+
expect(result.data.packable).toBe(true);
|
|
144
|
+
} finally {
|
|
145
|
+
vi.unstubAllEnvs();
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
);
|
|
126
149
|
});
|
|
@@ -25,6 +25,7 @@ import * as os from 'node:os';
|
|
|
25
25
|
import {fileURLToPath} from 'node:url';
|
|
26
26
|
import {spawnSync} from 'node:child_process';
|
|
27
27
|
import {assertWithin} from '../../foundation/fs/path-safety.mjs';
|
|
28
|
+
import {npmCommand} from '../../foundation/release/cache.mjs';
|
|
28
29
|
import {commandTokensIn} from '../../foundation/doc-compiler/doc-syntax.mjs';
|
|
29
30
|
import {resolvePackageDir} from '../../foundation/integrations/integrations.mjs';
|
|
30
31
|
import {
|
|
@@ -265,17 +266,22 @@ function npmPackErrorDetail(output) {
|
|
|
265
266
|
/**
|
|
266
267
|
* Run `npm pack --json` with output directed to `destDir` so no preexisting
|
|
267
268
|
* tgz is overwritten. This intentionally runs the package lifecycle, matching
|
|
268
|
-
* the artifact `npm publish` would produce.
|
|
269
|
-
*
|
|
269
|
+
* the artifact `npm publish` would produce. npm starts the way the CLI starts
|
|
270
|
+
* it everywhere else (`npmCommand`): npm's own entry file run with this Node
|
|
271
|
+
* when one is found, so an `npm` earlier on the PATH that is not npm itself
|
|
272
|
+
* cannot answer for it. Uses spawnSync with an args array — no shell — so
|
|
273
|
+
* paths with metacharacters cannot inject.
|
|
270
274
|
*
|
|
271
275
|
* @param {string} packageDir
|
|
272
276
|
* @param {string} destDir
|
|
273
277
|
* @returns {{filename: string, fileCount: number, size: number, unpackedSize: number, packedPaths: Set<string>}}
|
|
274
278
|
*/
|
|
275
279
|
function runNpmPack(packageDir, destDir) {
|
|
280
|
+
const npm = npmCommand();
|
|
276
281
|
const result = spawnSync(
|
|
277
|
-
|
|
282
|
+
npm.command,
|
|
278
283
|
[
|
|
284
|
+
...npm.prefix,
|
|
279
285
|
'pack',
|
|
280
286
|
'--json',
|
|
281
287
|
'--silent',
|
|
@@ -284,7 +290,7 @@ function runNpmPack(packageDir, destDir) {
|
|
|
284
290
|
'--foreground-scripts=false',
|
|
285
291
|
`--pack-destination=${destDir}`,
|
|
286
292
|
],
|
|
287
|
-
{cwd: packageDir, encoding: 'utf-8', timeout: 60_000},
|
|
293
|
+
{cwd: packageDir, encoding: 'utf-8', shell: false, timeout: 60_000},
|
|
288
294
|
);
|
|
289
295
|
if (result.error) {
|
|
290
296
|
throw new Error(`Could not start npm pack: ${result.error.message}`);
|
|
@@ -2125,10 +2125,13 @@ describe('integrationPackCheck', () => {
|
|
|
2125
2125
|
).toThrow(/without a files array/);
|
|
2126
2126
|
});
|
|
2127
2127
|
|
|
2128
|
-
it('reports
|
|
2128
|
+
it('reports pack_failed when no npm can be found', async () => {
|
|
2129
2129
|
writePackage({files: ['astryx.integration.mjs', 'themes']});
|
|
2130
2130
|
const originalPath = process.env.PATH;
|
|
2131
|
+
const originalExecPath = process.execPath;
|
|
2131
2132
|
process.env.PATH = '';
|
|
2133
|
+
// A Node with no npm beside it, and no npm on the PATH.
|
|
2134
|
+
process.execPath = path.join(tmpDir, 'no-npm', 'bin', 'node');
|
|
2132
2135
|
try {
|
|
2133
2136
|
const result = await integrationPackCheck({cwd: tmpDir});
|
|
2134
2137
|
expect(result.data.packable).toBe(false);
|
|
@@ -2140,6 +2143,7 @@ describe('integrationPackCheck', () => {
|
|
|
2140
2143
|
);
|
|
2141
2144
|
} finally {
|
|
2142
2145
|
process.env.PATH = originalPath;
|
|
2146
|
+
process.execPath = originalExecPath;
|
|
2143
2147
|
}
|
|
2144
2148
|
});
|
|
2145
2149
|
|
|
@@ -166,8 +166,9 @@ export type IconSetCoverage = {
|
|
|
166
166
|
}>;
|
|
167
167
|
/**
|
|
168
168
|
* For each
|
|
169
|
-
* unmapped definition (built-in, optional, or the set's own), the icon
|
|
170
|
-
*
|
|
169
|
+
* unmapped definition (built-in, optional, or the set's own), the best icon
|
|
170
|
+
* `integration check` gives it, by the rule `experimental icon new-set`
|
|
171
|
+
* uses for its suggestions, when one is.
|
|
171
172
|
*/
|
|
172
173
|
suggestions: Array<{
|
|
173
174
|
definition: string;
|
|
@@ -126,8 +126,9 @@
|
|
|
126
126
|
* Astryx's optional (not built-in) definitions the set's `map` does not
|
|
127
127
|
* name. An unmapped built-in definition is an error issue instead.
|
|
128
128
|
* @property {Array<{definition: string, icon: string}>} suggestions For each
|
|
129
|
-
* unmapped definition (built-in, optional, or the set's own), the icon
|
|
130
|
-
*
|
|
129
|
+
* unmapped definition (built-in, optional, or the set's own), the best icon
|
|
130
|
+
* `integration check` gives it, by the rule `experimental icon new-set`
|
|
131
|
+
* uses for its suggestions, when one is.
|
|
131
132
|
* @property {Array<{icon?: string, adapter?: string, entry?: string, reason: string}>} unchecked
|
|
132
133
|
* What the checks could not judge, each with the reason: an icon export
|
|
133
134
|
* whose module is an `exports` target not built yet, or that the reader
|