@astryxdesign/cli 0.7.4 → 0.7.5-canary.04434e7

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.
Files changed (259) hide show
  1. package/README.md +19 -19
  2. package/api/component/_adapter.mjs +16 -1
  3. package/api/component/component.test.mjs +31 -0
  4. package/api/discover/_adapter.d.mts +1 -1
  5. package/api/docs/_adapter.d.mts +5 -2
  6. package/api/docs/_adapter.mjs +24 -16
  7. package/api/docs/docs.test.mjs +18 -0
  8. package/api/docs/integrationDocs.test.mjs +2 -2
  9. package/api/experimental.d.mts +5 -0
  10. package/api/experimental.mjs +15 -0
  11. package/api/hook/list/list.d.mts +1 -1
  12. package/api/icon/_adapter.d.mts +3 -2
  13. package/api/icon/_adapter.mjs +16 -3
  14. package/api/icon/_authoring.d.mts +5 -1
  15. package/api/icon/_authoring.mjs +478 -63
  16. package/api/icon/_options.d.mts +11 -0
  17. package/api/icon/_options.mjs +39 -4
  18. package/api/icon/_records.d.mts +19 -0
  19. package/api/icon/_records.mjs +25 -0
  20. package/api/icon/add/add.d.mts +3 -3
  21. package/api/icon/add/add.mjs +227 -14
  22. package/api/icon/all-or-nothing.test.mjs +283 -0
  23. package/api/icon/detail/detail.mjs +2 -13
  24. package/api/icon/error-codes.test.mjs +14 -7
  25. package/api/icon/icon.d.mts +2 -2
  26. package/api/icon/icon.doc.mjs +30 -2
  27. package/api/icon/icon.mjs +57 -8
  28. package/api/icon/icon.test.mjs +133 -1
  29. package/api/icon/icon.type.d.mts +126 -1
  30. package/api/icon/icon.type.mjs +67 -3
  31. package/api/icon/iconAdd.doc.mjs +22 -6
  32. package/api/icon/iconMap.doc.mjs +24 -8
  33. package/api/icon/iconNewDefinition.doc.mjs +2 -2
  34. package/api/icon/iconNewSet.doc.mjs +30 -2
  35. package/api/icon/iconUse.doc.mjs +4 -1
  36. package/api/icon/map/map.d.mts +4 -4
  37. package/api/icon/map/map.mjs +134 -9
  38. package/api/icon/new-definition/new-definition.mjs +6 -2
  39. package/api/icon/new-set/new-set.mjs +2 -2
  40. package/api/icon/new-set/new-set.test.mjs +60 -10
  41. package/api/icon/option-pairs.test.mjs +368 -0
  42. package/api/icon/search/search.d.mts +10 -0
  43. package/api/icon/search/search.mjs +55 -14
  44. package/api/icon/use/use.mjs +2 -13
  45. package/api/integration/add-helpers.d.mts +15 -1
  46. package/api/integration/add-helpers.mjs +1 -1
  47. package/api/integration/pack-check.lifecycle-output.test.mjs +24 -1
  48. package/api/integration/pack-check.mjs +10 -4
  49. package/api/integration/pack-check.test.mjs +5 -1
  50. package/api/integration/validate-integration.type.d.mts +3 -2
  51. package/api/integration/validate-integration.type.mjs +3 -2
  52. package/api/render/_adapter.d.mts +28 -0
  53. package/api/render/_adapter.mjs +540 -0
  54. package/api/render/render.d.mts +15 -0
  55. package/api/render/render.doc.d.mts +9 -0
  56. package/api/render/render.doc.mjs +112 -0
  57. package/api/render/render.mjs +113 -0
  58. package/api/render/render.test.mjs +1155 -0
  59. package/api/render/render.type.d.mts +74 -0
  60. package/api/render/render.type.mjs +64 -0
  61. package/api/search/_adapter.test.mjs +21 -2
  62. package/api/search/_result.d.mts +5 -5
  63. package/api/search/search.d.mts +1 -1
  64. package/api/template/template.mjs +3 -1
  65. package/api/template/template.type.d.mts +2 -1
  66. package/api/template/template.type.mjs +1 -1
  67. package/api/template/unknown-name.test.mjs +63 -0
  68. package/api/upgrade/run/failure-receipt.test.mjs +155 -0
  69. package/api/upgrade/run/run.mjs +170 -8
  70. package/api/upgrade/upgrade.doc.mjs +4 -4
  71. package/api/upgrade/upgrade.mjs +19 -4
  72. package/api/upgrade/upgrade.type.d.mts +12 -1
  73. package/api/upgrade/upgrade.type.mjs +16 -3
  74. package/assets/codemods/__tests__/runner.symlinks.test.mjs +205 -0
  75. package/assets/codemods/integration-runner.mjs +1 -1
  76. package/assets/codemods/run-codemod.mjs +17 -3
  77. package/assets/codemods/runner.mjs +81 -8
  78. package/assets/codemods/transform-prop.mjs +99 -49
  79. package/assets/codemods/transform-prop.test.mjs +36 -1
  80. package/assets/codemods/transforms/v0.7.0/__tests__/migrate-deprecated-theme-surface.test.mjs +207 -6
  81. package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +123 -70
  82. package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface-v0.6-data.mjs +6 -1
  83. package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface.mjs +200 -32
  84. package/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs +19 -77
  85. package/assets/discover/official-packages.json +4 -0
  86. package/assets/docs/tree/icon-definitions.doc.mjs +2 -2
  87. package/assets/docs/tree/icon-set-files.doc.mjs +1 -1
  88. package/assets/docs/tree/icon-sets.doc.mjs +50 -20
  89. package/assets/docs/tree/render-pages.doc.mjs +94 -0
  90. package/assets/docs/tree/styling-advanced.doc.mjs +1 -1
  91. package/assets/icons/definitions/activity.doc.mjs +1 -1
  92. package/assets/icons/definitions/alignCenter.doc.mjs +9 -0
  93. package/assets/icons/definitions/alignEnd.doc.mjs +10 -0
  94. package/assets/icons/definitions/alignStart.doc.mjs +10 -0
  95. package/assets/icons/definitions/archive.doc.mjs +1 -1
  96. package/assets/icons/definitions/arrowsUpDown.doc.mjs +1 -1
  97. package/assets/icons/definitions/attach.doc.mjs +1 -1
  98. package/assets/icons/definitions/audio.doc.mjs +1 -1
  99. package/assets/icons/definitions/cart.doc.mjs +1 -1
  100. package/assets/icons/definitions/checkDouble.doc.mjs +1 -1
  101. package/assets/icons/definitions/chevronsLeft.doc.mjs +1 -1
  102. package/assets/icons/definitions/chevronsRight.doc.mjs +1 -1
  103. package/assets/icons/definitions/close.doc.mjs +1 -1
  104. package/assets/icons/definitions/collapse.doc.mjs +1 -1
  105. package/assets/icons/definitions/compose.doc.mjs +1 -1
  106. package/assets/icons/definitions/conversation.doc.mjs +1 -1
  107. package/assets/icons/definitions/copy.doc.mjs +1 -1
  108. package/assets/icons/definitions/cpu.doc.mjs +9 -0
  109. package/assets/icons/definitions/database.doc.mjs +1 -1
  110. package/assets/icons/definitions/desktop.doc.mjs +1 -1
  111. package/assets/icons/definitions/discount.doc.mjs +1 -1
  112. package/assets/icons/definitions/download.doc.mjs +1 -1
  113. package/assets/icons/definitions/emoji.doc.mjs +1 -1
  114. package/assets/icons/definitions/error.doc.mjs +1 -1
  115. package/assets/icons/definitions/expand.doc.mjs +1 -1
  116. package/assets/icons/definitions/experiment.doc.mjs +1 -1
  117. package/assets/icons/definitions/externalLink.doc.mjs +7 -1
  118. package/assets/icons/definitions/eyeSlash.doc.mjs +1 -1
  119. package/assets/icons/definitions/flipHorizontal.doc.mjs +9 -0
  120. package/assets/icons/definitions/flipVertical.doc.mjs +9 -0
  121. package/assets/icons/definitions/folderAdd.doc.mjs +1 -1
  122. package/assets/icons/definitions/gitBranch.doc.mjs +9 -0
  123. package/assets/icons/definitions/gitFork.doc.mjs +9 -0
  124. package/assets/icons/definitions/info.doc.mjs +1 -1
  125. package/assets/icons/definitions/location.doc.mjs +1 -1
  126. package/assets/icons/definitions/mention.doc.mjs +1 -1
  127. package/assets/icons/definitions/menu.doc.mjs +1 -1
  128. package/assets/icons/definitions/microphone.doc.mjs +1 -1
  129. package/assets/icons/definitions/mobile.doc.mjs +1 -1
  130. package/assets/icons/definitions/money.doc.mjs +1 -1
  131. package/assets/icons/definitions/moreHorizontal.doc.mjs +1 -1
  132. package/assets/icons/definitions/notificationActive.doc.mjs +1 -1
  133. package/assets/icons/definitions/notificationOff.doc.mjs +1 -1
  134. package/assets/icons/definitions/panelLeft.doc.mjs +10 -0
  135. package/assets/icons/definitions/panelRight.doc.mjs +10 -0
  136. package/assets/icons/definitions/raiseHand.doc.mjs +1 -1
  137. package/assets/icons/definitions/redo.doc.mjs +1 -1
  138. package/assets/icons/definitions/refresh.doc.mjs +1 -1
  139. package/assets/icons/definitions/rotate.doc.mjs +9 -0
  140. package/assets/icons/definitions/scale.doc.mjs +10 -0
  141. package/assets/icons/definitions/search.doc.mjs +1 -1
  142. package/assets/icons/definitions/send.doc.mjs +1 -1
  143. package/assets/icons/definitions/settings.doc.mjs +1 -1
  144. package/assets/icons/definitions/star.doc.mjs +1 -1
  145. package/assets/icons/definitions/stop.doc.mjs +1 -1
  146. package/assets/icons/definitions/success.doc.mjs +1 -1
  147. package/assets/icons/definitions/textCase.doc.mjs +9 -0
  148. package/assets/icons/definitions/thumbsDown.doc.mjs +1 -1
  149. package/assets/icons/definitions/thumbsUp.doc.mjs +1 -1
  150. package/assets/icons/definitions/trendDown.doc.mjs +7 -1
  151. package/assets/icons/definitions/trendUp.doc.mjs +1 -1
  152. package/assets/icons/definitions/undo.doc.mjs +1 -1
  153. package/assets/icons/definitions/upload.doc.mjs +1 -1
  154. package/assets/icons/definitions/userAdd.doc.mjs +1 -1
  155. package/assets/icons/definitions/warning.doc.mjs +1 -1
  156. package/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx +15 -14
  157. package/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx +30 -30
  158. package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +15 -14
  159. package/assets/templates/blocks/components/Tokenizer/TokenizerIcon.tsx +15 -14
  160. package/assets/templates/blocks/components/Tokenizer/TokenizerMaxEntries.tsx +17 -16
  161. package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx +29 -29
  162. package/assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx +9 -8
  163. package/assets/templates/blocks/components/Tokenizer/TokenizerStates.tsx +39 -41
  164. package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -0
  165. package/assets/templates/pages/form-wizard-inline/template.doc.mjs +6 -1
  166. package/assets/templates/pages/table-comparison/template.doc.mjs +1 -0
  167. package/assets/templates/pages/table-tree/template.doc.mjs +3 -0
  168. package/authoring/debug/parse.d.mts +2 -2
  169. package/authoring/doctypes/icon-definition/icon-definition.doc.mjs +4 -4
  170. package/authoring/doctypes/icon-set/icon-set-data.doc.mjs +6 -0
  171. package/authoring/doctypes/icon-set/parse.d.mts +1 -0
  172. package/authoring/doctypes/icon-set/parse.mjs +1 -0
  173. package/authoring/doctypes/icon-set/type.ts +5 -0
  174. package/authoring/doctypes/template/template.doc.mjs +1 -1
  175. package/authoring/doctypes/template/type.ts +2 -1
  176. package/clients/cli/commands/doctor.mjs +16 -17
  177. package/clients/cli/commands/experimental/icon.mjs +167 -35
  178. package/clients/cli/commands/experimental/index.mjs +2 -0
  179. package/clients/cli/commands/experimental/render.mjs +113 -0
  180. package/clients/cli/commands/experimental-icon-add.doc.mjs +14 -4
  181. package/clients/cli/commands/experimental-icon-map.doc.mjs +12 -2
  182. package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +1 -1
  183. package/clients/cli/commands/experimental-icon-new-set.doc.mjs +28 -1
  184. package/clients/cli/commands/experimental-icon.doc.mjs +18 -2
  185. package/clients/cli/commands/experimental-render.doc.mjs +60 -0
  186. package/clients/cli/commands/experimental.doc.mjs +4 -2
  187. package/clients/cli/commands/icon-authoring.test.mjs +1823 -13
  188. package/clients/cli/commands/icon-options-wiring.test.mjs +158 -0
  189. package/clients/cli/commands/icon.test.mjs +1 -1
  190. package/clients/cli/commands/template.mjs +4 -1
  191. package/clients/cli/commands/text-json-parity.test.mjs +46 -0
  192. package/clients/cli/commands/upgrade.doc.mjs +17 -0
  193. package/clients/cli/commands/upgrade.file-protection.test.mjs +29 -0
  194. package/clients/cli/commands/upgrade.flag-help.test.mjs +37 -0
  195. package/clients/cli/commands/upgrade.integration-policy.test.mjs +103 -0
  196. package/clients/cli/commands/upgrade.mjs +9 -2
  197. package/clients/cli/index.mjs +1 -0
  198. package/foundation/discovery/component-discovery.d.mts +2 -1
  199. package/foundation/discovery/component-discovery.export-names.test.mjs +41 -0
  200. package/foundation/discovery/component-discovery.mjs +13 -7
  201. package/foundation/discovery/icon-set-checks.d.mts +43 -9
  202. package/foundation/discovery/icon-set-checks.mjs +296 -21
  203. package/foundation/discovery/icon-set-checks.test.mjs +125 -12
  204. package/foundation/discovery/icon-set-writer.d.mts +192 -3
  205. package/foundation/discovery/icon-set-writer.mjs +608 -34
  206. package/foundation/discovery/icon-set-writer.test.mjs +26 -0
  207. package/foundation/discovery/module-exports.mjs +82 -25
  208. package/foundation/discovery/module-exports.test.mjs +38 -1
  209. package/foundation/discovery/package-exports.d.mts +13 -0
  210. package/foundation/discovery/package-exports.mjs +40 -1
  211. package/foundation/discovery/template-icons.d.mts +6 -0
  212. package/foundation/discovery/template-icons.mjs +98 -10
  213. package/foundation/discovery/template-icons.test.mjs +103 -0
  214. package/foundation/doc-compiler/doc-loads.test.mjs +20 -5
  215. package/foundation/doc-compiler/import.mjs +81 -8
  216. package/foundation/doc-compiler/read.d.mts +4 -3
  217. package/foundation/doc-compiler/read.mjs +15 -10
  218. package/foundation/doc-compiler/read.test.mjs +59 -1
  219. package/foundation/doc-compiler/tree.mjs +3 -1
  220. package/foundation/fs/module-loader.d.mts +3 -2
  221. package/foundation/fs/module-loader.mjs +3 -2
  222. package/foundation/fs/publish-file-eperm-mutation.test.mjs +2 -0
  223. package/foundation/fs/read-record.d.mts +27 -0
  224. package/foundation/fs/read-record.mjs +83 -15
  225. package/foundation/fs/read-record.test.mjs +88 -1
  226. package/foundation/render/assets.d.mts +31 -0
  227. package/foundation/render/assets.mjs +102 -0
  228. package/foundation/render/component-map.d.mts +52 -0
  229. package/foundation/render/component-map.mjs +141 -0
  230. package/foundation/render/css-cut.d.mts +29 -0
  231. package/foundation/render/css-cut.mjs +144 -0
  232. package/foundation/render/embedded-files.d.mts +28 -0
  233. package/foundation/render/embedded-files.mjs +108 -0
  234. package/foundation/render/embedded-imports.d.mts +61 -0
  235. package/foundation/render/embedded-imports.mjs +315 -0
  236. package/foundation/render/html-reader.d.mts +37 -0
  237. package/foundation/render/html-reader.mjs +121 -0
  238. package/foundation/render/page-worker.d.mts +7 -0
  239. package/foundation/render/page-worker.mjs +519 -0
  240. package/foundation/render/rebuild.d.mts +19 -0
  241. package/foundation/render/rebuild.mjs +269 -0
  242. package/foundation/render/render-page.d.mts +85 -0
  243. package/foundation/render/render-page.mjs +612 -0
  244. package/foundation/render/render.test.mjs +117 -0
  245. package/foundation/render/source-block.d.mts +52 -0
  246. package/foundation/render/source-block.mjs +106 -0
  247. package/foundation/response/base.d.ts +7 -0
  248. package/foundation/response/error-codes.d.mts +10 -1
  249. package/foundation/response/error-codes.doc.mjs +59 -2
  250. package/foundation/response/error-codes.mjs +62 -1
  251. package/foundation/response/json.d.mts +10 -3
  252. package/foundation/response/json.mjs +16 -4
  253. package/foundation/response/response-types.doc.mjs +38 -1
  254. package/foundation/text/string-utils.mjs +33 -0
  255. package/foundation/text/string-utils.test.mjs +17 -0
  256. package/foundation/text/suggest-order.d.mts +17 -3
  257. package/foundation/text/suggest-order.mjs +58 -13
  258. package/foundation/text/suggest-order.test.mjs +53 -0
  259. package/package.json +14 -9
@@ -10,7 +10,11 @@ import * as fs from 'node:fs';
10
10
  import * as os from 'node:os';
11
11
  import * as path from 'node:path';
12
12
  import {afterEach, beforeEach, describe, expect, it} from 'vitest';
13
- import {iconSetCoverage, iconSetIssues} from './icon-set-checks.mjs';
13
+ import {
14
+ iconSetCoverage,
15
+ iconSetIssues,
16
+ suggestedIcons,
17
+ } from './icon-set-checks.mjs';
14
18
  import {moduleExportOrigin} from './module-exports.mjs';
15
19
  import {generatedTypesText} from './icon-set-writer.mjs';
16
20
  import {integrationCheck} from '../../api/integration/check/check.mjs';
@@ -22,6 +26,13 @@ import {
22
26
  writeIconPackage,
23
27
  } from '../../test-utils/icon-set-fixture.mjs';
24
28
  import {ICON_NAMES} from '../../authoring/doctypes/icon-set/icon-names.mjs';
29
+ import {rankIcons} from './icon-ranking.mjs';
30
+ import {astryxIconDefinitions} from './icon-definition-discovery.mjs';
31
+ import {discoverIconSetDirectory} from './icon-set-discovery.mjs';
32
+
33
+ /** The fixture package's one set, as discovery reads it. */
34
+ const readSet = () =>
35
+ discoverIconSetDirectory(path.join(dir, 'icon-sets'), '@acme/glyphs').sets[0];
25
36
 
26
37
  /** @type {string} */
27
38
  let tmp;
@@ -641,6 +652,26 @@ describe('icon definitions (map)', () => {
641
652
  // close and search are mapped; every other built-in is not.
642
653
  expect(builtIn).toHaveLength(ICON_NAMES.length - 2);
643
654
  expect(builtIn.every(issue => issue.severity === 'error')).toBe(true);
655
+ // Each names the command that maps it, never a hand edit of the data.
656
+ const error = builtIn.find(issue => issue.message.includes('"error"'));
657
+ expect(error?.message).toContain(
658
+ '`astryx experimental icon map error <icon id>`',
659
+ );
660
+ expect(error?.message).not.toContain('add it to "map"');
661
+ // A find hint names a search only when that search finds icons.
662
+ for (const issue of builtIn) {
663
+ const query =
664
+ /icons matching "([^"]+)": `astryx experimental icon \1 --set glyphs`/u.exec(
665
+ issue.message,
666
+ );
667
+ if (query) {
668
+ expect(rankIcons([readSet()], query[1]).length).toBeGreaterThan(0);
669
+ } else {
670
+ expect(issue.message).toContain(
671
+ 'no icon in the set has its name or words',
672
+ );
673
+ }
674
+ }
644
675
  // An issue is only ever an error or a warning.
645
676
  expect(
646
677
  issues.every(issue => ['error', 'warning'].includes(issue.severity)),
@@ -692,23 +723,23 @@ describe('icon definitions (map)', () => {
692
723
  });
693
724
 
694
725
  it("a map key that is neither Astryx's definition nor the set's own is an error", () => {
695
- const issues = issuesOf({data: data(d => (d.map.rotate = 'home'))});
726
+ const issues = issuesOf({data: data(d => (d.map.orbit = 'home'))});
696
727
  expect(issues).toEqual([
697
728
  expect.objectContaining({code: 'invalid_icon_set', severity: 'error'}),
698
729
  ]);
699
730
  expect(issues[0].message).toMatch(
700
- /map "rotate" \(icon "home"\) is not an icon definition\. Declare it in definitions\/rotate\.doc\.mjs/,
731
+ /map "orbit" \(icon "home"\) is not an icon definition\. Declare it in definitions\/orbit\.doc\.mjs/,
701
732
  );
702
733
  });
703
734
 
704
735
  it("the set's own definitions: mapped is fine, unmapped warns with a suggestion, and one Astryx has warns", () => {
705
736
  const issues = issuesOf({
706
- data: data(d => (d.map.rotate = 'home')),
737
+ data: data(d => (d.map.orbit = 'home')),
707
738
  definitions: {
708
- rotate: definitionSource('rotate'),
739
+ orbit: definitionSource('orbit'),
709
740
  garbage: definitionSource('garbage', {words: ['bin', 'trash']}),
710
- // The trash icon is tagged garbage, and `tra` starts its id: neither
711
- // is a suggestion. No guessing.
741
+ // The trash icon has the word garbage, so it is a suggestion; `tra`
742
+ // only starts its id, so that is not. Never part of a word.
712
743
  rubbish: definitionSource('rubbish', {words: ['garbage', 'tra']}),
713
744
  delete: definitionSource('delete'),
714
745
  },
@@ -726,7 +757,9 @@ describe('icon definitions (map)', () => {
726
757
  'astryx experimental icon map garbage trash',
727
758
  );
728
759
  const rubbish = unused.find(issue => issue.message.includes('"rubbish"'));
729
- expect(rubbish?.message).not.toContain('Suggested');
760
+ expect(rubbish?.message).toContain(
761
+ 'Suggested: astryx experimental icon map rubbish trash.',
762
+ );
730
763
  const [coverage] = iconSetCoverage({
731
764
  name: '@acme/glyphs',
732
765
  iconSets: path.join(dir, 'icon-sets'),
@@ -735,9 +768,10 @@ describe('icon definitions (map)', () => {
735
768
  definition: 'garbage',
736
769
  icon: 'trash',
737
770
  });
738
- expect(
739
- coverage.suggestions.some(each => each.definition === 'rubbish'),
740
- ).toBe(false);
771
+ expect(coverage.suggestions).toContainEqual({
772
+ definition: 'rubbish',
773
+ icon: 'trash',
774
+ });
741
775
  expect(
742
776
  issues.find(issue => issue.code === 'icon_definition_shadowed')?.message,
743
777
  ).toContain('Astryx now has');
@@ -745,7 +779,7 @@ describe('icon definitions (map)', () => {
745
779
 
746
780
  it('a definition file that does not read makes the set invalid', () => {
747
781
  const issues = issuesOf({
748
- definitions: {rotate: definitionSource('Rotate')},
782
+ definitions: {orbit: definitionSource('Orbit')},
749
783
  });
750
784
  expect(issues).toEqual([
751
785
  expect.objectContaining({code: 'invalid_icon_set'}),
@@ -903,3 +937,82 @@ describe('the codes and severities FR15 lists', () => {
903
937
  expect(listed).toEqual(raised);
904
938
  });
905
939
  });
940
+
941
+ describe('suggestions join a plural only to its singular', () => {
942
+ /**
943
+ * @param {string[]} ids
944
+ * @param {{name: string, words?: string[]}} doc
945
+ */
946
+ const suggest = (ids, {name, words = []}) =>
947
+ suggestedIcons(
948
+ {data: {icons: ids.map(id => ({id, words: id.split('-')})), map: {}}},
949
+ {name, words},
950
+ ).map(each => each.icon);
951
+
952
+ it('never offers a grid of squares for stop, whose word is square', () => {
953
+ expect(suggest(['squares-2x2'], {name: 'stop', words: ['square']})).toEqual(
954
+ [],
955
+ );
956
+ expect(
957
+ suggest(['squares-2x2', 'square'], {name: 'stop', words: ['square']}),
958
+ ).toEqual(['square']);
959
+ });
960
+
961
+ it('meets a plural and its singular of the same word, either way', () => {
962
+ expect(suggest(['squares'], {name: 'square'})).toEqual(['squares']);
963
+ expect(suggest(['square'], {name: 'squares'})).toEqual(['square']);
964
+ expect(suggest(['arrows'], {name: 'arrow'})).toEqual(['arrows']);
965
+ expect(suggest(['arrow'], {name: 'arrows'})).toEqual(['arrow']);
966
+ });
967
+
968
+ it('never bridges a verb ending or a plural to a longer id', () => {
969
+ // `drafting` is not `draft`; `users` does not start `user-plus`.
970
+ expect(
971
+ suggest(['drafting-compass'], {name: 'compose', words: ['draft']}),
972
+ ).toEqual([]);
973
+ expect(suggest(['user-plus', 'user-cog'], {name: 'users'})).toEqual([]);
974
+ expect(suggest(['tool-case'], {name: 'wrench', words: ['tools']})).toEqual(
975
+ [],
976
+ );
977
+ });
978
+ });
979
+
980
+ describe('suggestions from a definition word never bridge to another meaning', () => {
981
+ const definitions = new Map(
982
+ astryxIconDefinitions().definitions.map(({doc}) => [doc.name, doc]),
983
+ );
984
+ /** @param {string} name @param {string[]} ids */
985
+ const suggest = (name, ids) =>
986
+ suggestedIcons(
987
+ {data: {icons: ids.map(id => ({id, words: id.split('-')})), map: {}}},
988
+ /** @type {any} */ (definitions.get(name)),
989
+ ).map(each => each.icon);
990
+
991
+ it.each([
992
+ ['creditCard', 'card-sim'],
993
+ ['bolt', 'fast-forward'],
994
+ ['archive', 'store'],
995
+ ['mobile', 'device-tablet'],
996
+ ['raiseHand', 'stop-circle'],
997
+ ['star', 'bookmark-square'],
998
+ ['database', 'table-cells'],
999
+ ['redo', 'forward'],
1000
+ ['activity', 'monitor'],
1001
+ ['stop', 'square-square'],
1002
+ ['moreHorizontal', 'ellipsis-vertical'],
1003
+ ])('%s never suggests %s', (name, id) => {
1004
+ expect(suggest(name, [id])).toEqual([]);
1005
+ });
1006
+
1007
+ it('still suggests a word with only a size, shape, or number after it', () => {
1008
+ expect(suggest('gridView', ['grid-2x2'])).toEqual(['grid-2x2']);
1009
+ expect(suggest('viewColumns', ['columns-3'])).toEqual(['columns-3']);
1010
+ expect(suggest('add', ['plus-circle'])).toEqual(['plus-circle']);
1011
+ });
1012
+
1013
+ it('finds the glyph a library names in two words through the definition’s words', () => {
1014
+ expect(suggest('raiseHand', ['hand-raised'])).toEqual(['hand-raised']);
1015
+ expect(suggest('location', ['map-pin'])).toEqual(['map-pin']);
1016
+ expect(suggest('textCase', ['case-sensitive'])).toEqual(['case-sensitive']);
1017
+ });
1018
+ });
@@ -3,7 +3,9 @@
3
3
 
4
4
  /**
5
5
  * `XMarkIcon` → `x-mark`; `Trash2` → `trash-2`; `ArrowUpDown` →
6
- * `arrow-up-down`: an icon id from an export name.
6
+ * `arrow-up-down`; `Squares2X2Icon` and `Grid2x2` → `squares-2x2`,
7
+ * `grid-2x2`: an icon id from an export name. A dimension (a digit, `x` or
8
+ * `X`, a digit) stays one word.
7
9
  * @param {string} name
8
10
  */
9
11
  export function iconIdOf(name: string): string;
@@ -58,6 +60,23 @@ export function mappableDefinitions(set: DiscoveredIconSet, extra?: string[]): S
58
60
  export function writeIconSetData(set: DiscoveredIconSet, next: IconSetData, { extraDefinitions }?: {
59
61
  extraDefinitions?: string[];
60
62
  }): () => void;
63
+ /**
64
+ * Record a file's bytes before the running command writes or removes it, and
65
+ * the folders above it that do not exist yet. Outside {@link allOrNothing}
66
+ * this does nothing.
67
+ * @param {string} file
68
+ */
69
+ export function journalFile(file: string): void;
70
+ /**
71
+ * Run one authoring command so its writes are all or nothing: when it throws,
72
+ * every file it wrote gets its old bytes back (a file it created is removed,
73
+ * with the folders it created), and the error is rethrown. A file system
74
+ * error becomes `ERR_WRITE_FAILED`.
75
+ * @template T
76
+ * @param {() => T | Promise<T>} step
77
+ * @returns {Promise<T>}
78
+ */
79
+ export function allOrNothing<T>(step: () => T | Promise<T>): Promise<T>;
61
80
  /**
62
81
  * The names closest to one that matched nothing.
63
82
  * @param {string} wanted
@@ -82,6 +101,21 @@ export function resolveIconSource(from: string, { packageDir, pkg }: {
82
101
  file: string;
83
102
  module: string;
84
103
  };
104
+ /**
105
+ * The installed library a package specifier reads from: its name, version,
106
+ * license, and license notice files, from its own package.json. Null for a
107
+ * ./ path, or when the library is not installed or has no version.
108
+ * @param {string} from a package or package subpath
109
+ * @param {string} packageDir the set's package
110
+ * @returns {{package: string, version: string, license: string | null, dir: string, notices: string[]} | null}
111
+ */
112
+ export function librarySource(from: string, packageDir: string): {
113
+ package: string;
114
+ version: string;
115
+ license: string | null;
116
+ dir: string;
117
+ notices: string[];
118
+ } | null;
85
119
  /**
86
120
  * Prove a source module has one export, without running it. `default` reads
87
121
  * the module's default export.
@@ -90,6 +124,18 @@ export function resolveIconSource(from: string, { packageDir, pkg }: {
90
124
  * @param {string} exportName
91
125
  */
92
126
  export function assertIconExport(file: string, module: string, exportName: string): void;
127
+ /**
128
+ * The exports of a library that are not icons and that wrapping it leaves
129
+ * out (`Icon`, `LucideProvider`, `createLucideIcon`, constants), so the
130
+ * receipt can say so. Another name of an icon is not listed.
131
+ * @param {string} file
132
+ * @param {{adapter?: boolean, exclude?: string[]}} [options]
133
+ * @returns {string[]}
134
+ */
135
+ export function nonIconExports(file: string, options?: {
136
+ adapter?: boolean;
137
+ exclude?: string[];
138
+ }): string[];
93
139
  /**
94
140
  * The leading words every icon export of a library shares, such as
95
141
  * `feather` in `featherEye` and `featherSun`: a library prefix that ids and
@@ -129,7 +175,9 @@ export function modulePrefix(file: string, options?: {
129
175
  * @param {string} file
130
176
  * @param {{adapter?: boolean, exclude?: string[]}} [options] `adapter`:
131
177
  * whether the set declares one; `exclude`: export names that are not icons
132
- * @returns {Array<{export: string, id: string, name: string, adapt: boolean}>}
178
+ * @returns {Array<{export: string, id: string, name: string, adapt: boolean, aliases: string[]}>}
179
+ * `aliases`: the ids of the other names the library exports the icon as,
180
+ * leaving out the library's own name (`lucide-trash`)
133
181
  */
134
182
  export function libraryIcons(file: string, options?: {
135
183
  adapter?: boolean;
@@ -139,6 +187,7 @@ export function libraryIcons(file: string, options?: {
139
187
  id: string;
140
188
  name: string;
141
189
  adapt: boolean;
190
+ aliases: string[];
142
191
  }>;
143
192
  /**
144
193
  * The source of one icon definition file, typed IconDefinitionDoc.
@@ -244,6 +293,36 @@ export function generatedModuleText(packageDir: string, generated: string, befor
244
293
  * @returns {string[]}
245
294
  */
246
295
  export function generatedNamesOf(packageDir: string, generated: string, from: string, source: string): string[];
296
+ /**
297
+ * Where each of the set's exports comes from, read from its generated
298
+ * module: the module it re-exports or adapts (a package specifier, or a
299
+ * `./` path from the package root) and the export it reads there
300
+ * (`default` for a default export). `export {HiTrashIcon as TrashIcon} from
301
+ * '@acme/hero'` gives `TrashIcon` → `{module: '@acme/hero', source:
302
+ * 'HiTrashIcon'}`. An existing icon is known by this first: ids and the
303
+ * set's export names are derived from it, and a newer rule may spell them
304
+ * differently; and a refresh changes only the icons its module supplies.
305
+ * @param {string} packageDir
306
+ * @param {string} generated
307
+ * @returns {Map<string, {module: string, source: string}>}
308
+ */
309
+ export function generatedOrigins(packageDir: string, generated: string): Map<string, {
310
+ module: string;
311
+ source: string;
312
+ }>;
313
+ /**
314
+ * Whether two module specifiers name the same module: the same package
315
+ * specifier, or the same `./` path from the package root.
316
+ * @param {string} a
317
+ * @param {string} b
318
+ */
319
+ export function sameIconModule(a: string, b: string): boolean;
320
+ /**
321
+ * The package a module specifier belongs to (`@acme/hero` for
322
+ * `@acme/hero/24/solid`), or `.` for a `./` path in the package itself.
323
+ * @param {string} specifier
324
+ */
325
+ export function iconModulePackage(specifier: string): string;
247
326
  /**
248
327
  * Write the set's generated module and its declaration file
249
328
  * ({@link generatedModuleText}). Returns whether either changed, and a
@@ -260,9 +339,29 @@ export function writeGeneratedIcons(packageDir: string, generated: string, data:
260
339
  files: string[];
261
340
  undo: () => void;
262
341
  };
342
+ /**
343
+ * The exact change that makes a set's generated module part of the
344
+ * package's public entry, so its icons and theme map import from the package
345
+ * by name (FR14), or null when the entry already exports `name`. The CLI
346
+ * never makes this change itself: `exports`, `main`, `types`, `files`, and the
347
+ * entry file are the author's (architecture:cli-surface INV16). `new-set`
348
+ * prints it in its receipt and `integration check` in its finding, the same
349
+ * words. A built or CommonJS entry is never named as the file to edit.
350
+ * @param {string} packageDir
351
+ * @param {Record<string, any>} pkg the package's package.json
352
+ * @param {string} generated the generated module's ./ path from the package root
353
+ * @param {{module?: string, name?: string}} [options] `module` the set's
354
+ * module (default the package name); `name` an export the entry must have
355
+ * (default the theme map)
356
+ * @returns {string | null}
357
+ */
358
+ export function entryWiringNote(packageDir: string, pkg: Record<string, any>, generated: string, options?: {
359
+ module?: string;
360
+ name?: string;
361
+ }): string | null;
263
362
  /**
264
363
  * Whether the set's own module exports `name`, read without running it, and
265
- * the line its entry needs when it does not.
364
+ * the line its entry needs when it does not ({@link entryWiringNote}).
266
365
  * @param {DiscoveredIconSet} set
267
366
  * @param {{packageDir: string, pkg: Record<string, any>}} where
268
367
  * @param {string} generated the generated module's ./ path from the package root
@@ -273,6 +372,86 @@ export function setModuleNote(set: DiscoveredIconSet, where: {
273
372
  packageDir: string;
274
373
  pkg: Record<string, any>;
275
374
  }, generated: string, name: string): string | null;
375
+ /**
376
+ * The peers an icon-set package publishes with, as the guide's "Before you
377
+ * publish" asks, that package.json does not declare yet, as the exact JSON
378
+ * to add, or null when it declares them all: `react` (the theme map and
379
+ * adapter use it), and as optional peers `@types/react` (the generated
380
+ * declaration file imports it) and `@astryxdesign/cli` from this release.
381
+ * The CLI never edits them (architecture:cli-surface INV16).
382
+ * @param {Record<string, any>} pkg
383
+ * @returns {string | null}
384
+ */
385
+ export function peerNote(pkg: Record<string, any>): string | null;
386
+ /**
387
+ * The `typecheck` script every integration runs in its build, as the line to
388
+ * add, or null when package.json has one.
389
+ * @param {Record<string, any>} pkg
390
+ * @returns {string | null}
391
+ */
392
+ export function typecheckNote(pkg: Record<string, any>): string | null;
393
+ /**
394
+ * A definition name as `map` keys it: camelCase. The docs list each
395
+ * definition by its kebab id too (`eye-slash`), so that spelling resolves.
396
+ * @param {string} name
397
+ * @param {Set<string>} known the definitions the set may map
398
+ * @returns {string}
399
+ */
400
+ export function definitionNameOf(name: string, known: Set<string>): string;
401
+ /**
402
+ * An icon id in the set, named by its id, its export name in any case
403
+ * (`XMarkIcon`, `xmark`), or another name the library exports the same icon
404
+ * as, as an id or as the library spells it (`trash-2` or `Trash2` for
405
+ * `trash`, recorded in its words; AST-084 FR13). Never by a word alone:
406
+ * null when none of these names an icon.
407
+ * @param {{data: {icons: Array<{id: string, export: string, words: string[]}>}}} set
408
+ * @param {string} id
409
+ * @returns {string | null}
410
+ */
411
+ export function iconIdIn(set: {
412
+ data: {
413
+ icons: Array<{
414
+ id: string;
415
+ export: string;
416
+ words: string[];
417
+ }>;
418
+ };
419
+ }, id: string): string | null;
420
+ /**
421
+ * The other names a library exports an icon as, recorded among its words:
422
+ * each word that is not a part of its id.
423
+ * @param {{id: string, words?: string[]}} icon
424
+ * @returns {string[]}
425
+ */
426
+ export function otherNamesOf(icon: {
427
+ id: string;
428
+ words?: string[];
429
+ }): string[];
430
+ /**
431
+ * The icons that carry `word` but are not named by it, for a refusal's
432
+ * suggestions: `glass` is a word of `magnifying-glass`, not its name.
433
+ * @param {{data: {icons: Array<{id: string, words?: string[]}>}}} set
434
+ * @param {string} word
435
+ * @returns {string[]}
436
+ */
437
+ export function iconsWithWord(set: {
438
+ data: {
439
+ icons: Array<{
440
+ id: string;
441
+ words?: string[];
442
+ }>;
443
+ };
444
+ }, word: string): string[];
445
+ /**
446
+ * The package.json `files` change a ./ source needs to ship, or null when
447
+ * the package lists no `files` or one covers it: its own folder (`src/icons`
448
+ * for `./src/icons/x.js`), as the exact array. The CLI never edits `files`
449
+ * (architecture:cli-surface INV16).
450
+ * @param {string} packageDir
451
+ * @param {string} module the source specifier
452
+ * @returns {string | null}
453
+ */
454
+ export function localSourceNote(packageDir: string, module: string): string | null;
276
455
  /** @typedef {import('./icon-set-discovery.mjs').DiscoveredIconSet} DiscoveredIconSet */
277
456
  /** @typedef {import('../../authoring/doctypes/icon-set/type').IconSetData} IconSetData */
278
457
  /**
@@ -298,6 +477,16 @@ export class IconSetAuthoringError extends Error {
298
477
  export const THEME_MAP_NAME: "themeIcons";
299
478
  export type DiscoveredIconSet = import("./icon-set-discovery.mjs").DiscoveredIconSet;
300
479
  export type IconSetData = import("../../authoring/doctypes/icon-set/type").IconSetData;
480
+ /**
481
+ * The files one authoring command has changed, each with the bytes it had
482
+ * before (null: it did not exist), and the folders it created. Every write of
483
+ * an icon authoring command records here first, so a command that fails
484
+ * after some of its writes puts every file back (AST-084 FR13).
485
+ */
486
+ export type WriteJournal = {
487
+ files: Map<string, Buffer | null>;
488
+ dirs: string[];
489
+ };
301
490
  /**
302
491
  * One icon export of the generated module.
303
492
  */