@astryxdesign/cli 0.7.4 → 0.7.5-canary.07605c2

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 (235) hide show
  1. package/README.md +18 -18
  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/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +123 -70
  69. package/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs +19 -77
  70. package/assets/discover/official-packages.json +4 -0
  71. package/assets/docs/tree/icon-definitions.doc.mjs +2 -2
  72. package/assets/docs/tree/icon-set-files.doc.mjs +1 -1
  73. package/assets/docs/tree/icon-sets.doc.mjs +50 -20
  74. package/assets/docs/tree/render-pages.doc.mjs +94 -0
  75. package/assets/icons/definitions/activity.doc.mjs +1 -1
  76. package/assets/icons/definitions/alignCenter.doc.mjs +9 -0
  77. package/assets/icons/definitions/alignEnd.doc.mjs +10 -0
  78. package/assets/icons/definitions/alignStart.doc.mjs +10 -0
  79. package/assets/icons/definitions/archive.doc.mjs +1 -1
  80. package/assets/icons/definitions/arrowsUpDown.doc.mjs +1 -1
  81. package/assets/icons/definitions/attach.doc.mjs +1 -1
  82. package/assets/icons/definitions/audio.doc.mjs +1 -1
  83. package/assets/icons/definitions/cart.doc.mjs +1 -1
  84. package/assets/icons/definitions/checkDouble.doc.mjs +1 -1
  85. package/assets/icons/definitions/chevronsLeft.doc.mjs +1 -1
  86. package/assets/icons/definitions/chevronsRight.doc.mjs +1 -1
  87. package/assets/icons/definitions/close.doc.mjs +1 -1
  88. package/assets/icons/definitions/collapse.doc.mjs +1 -1
  89. package/assets/icons/definitions/compose.doc.mjs +1 -1
  90. package/assets/icons/definitions/conversation.doc.mjs +1 -1
  91. package/assets/icons/definitions/copy.doc.mjs +1 -1
  92. package/assets/icons/definitions/cpu.doc.mjs +9 -0
  93. package/assets/icons/definitions/database.doc.mjs +1 -1
  94. package/assets/icons/definitions/desktop.doc.mjs +1 -1
  95. package/assets/icons/definitions/discount.doc.mjs +1 -1
  96. package/assets/icons/definitions/download.doc.mjs +1 -1
  97. package/assets/icons/definitions/emoji.doc.mjs +1 -1
  98. package/assets/icons/definitions/error.doc.mjs +1 -1
  99. package/assets/icons/definitions/expand.doc.mjs +1 -1
  100. package/assets/icons/definitions/experiment.doc.mjs +1 -1
  101. package/assets/icons/definitions/externalLink.doc.mjs +7 -1
  102. package/assets/icons/definitions/eyeSlash.doc.mjs +1 -1
  103. package/assets/icons/definitions/flipHorizontal.doc.mjs +9 -0
  104. package/assets/icons/definitions/flipVertical.doc.mjs +9 -0
  105. package/assets/icons/definitions/folderAdd.doc.mjs +1 -1
  106. package/assets/icons/definitions/gitBranch.doc.mjs +9 -0
  107. package/assets/icons/definitions/gitFork.doc.mjs +9 -0
  108. package/assets/icons/definitions/info.doc.mjs +1 -1
  109. package/assets/icons/definitions/location.doc.mjs +1 -1
  110. package/assets/icons/definitions/mention.doc.mjs +1 -1
  111. package/assets/icons/definitions/menu.doc.mjs +1 -1
  112. package/assets/icons/definitions/microphone.doc.mjs +1 -1
  113. package/assets/icons/definitions/mobile.doc.mjs +1 -1
  114. package/assets/icons/definitions/money.doc.mjs +1 -1
  115. package/assets/icons/definitions/moreHorizontal.doc.mjs +1 -1
  116. package/assets/icons/definitions/notificationActive.doc.mjs +1 -1
  117. package/assets/icons/definitions/notificationOff.doc.mjs +1 -1
  118. package/assets/icons/definitions/panelLeft.doc.mjs +10 -0
  119. package/assets/icons/definitions/panelRight.doc.mjs +10 -0
  120. package/assets/icons/definitions/raiseHand.doc.mjs +1 -1
  121. package/assets/icons/definitions/redo.doc.mjs +1 -1
  122. package/assets/icons/definitions/refresh.doc.mjs +1 -1
  123. package/assets/icons/definitions/rotate.doc.mjs +9 -0
  124. package/assets/icons/definitions/scale.doc.mjs +10 -0
  125. package/assets/icons/definitions/search.doc.mjs +1 -1
  126. package/assets/icons/definitions/send.doc.mjs +1 -1
  127. package/assets/icons/definitions/settings.doc.mjs +1 -1
  128. package/assets/icons/definitions/star.doc.mjs +1 -1
  129. package/assets/icons/definitions/stop.doc.mjs +1 -1
  130. package/assets/icons/definitions/success.doc.mjs +1 -1
  131. package/assets/icons/definitions/textCase.doc.mjs +9 -0
  132. package/assets/icons/definitions/thumbsDown.doc.mjs +1 -1
  133. package/assets/icons/definitions/thumbsUp.doc.mjs +1 -1
  134. package/assets/icons/definitions/trendDown.doc.mjs +7 -1
  135. package/assets/icons/definitions/trendUp.doc.mjs +1 -1
  136. package/assets/icons/definitions/undo.doc.mjs +1 -1
  137. package/assets/icons/definitions/upload.doc.mjs +1 -1
  138. package/assets/icons/definitions/userAdd.doc.mjs +1 -1
  139. package/assets/icons/definitions/warning.doc.mjs +1 -1
  140. package/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx +15 -14
  141. package/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx +30 -30
  142. package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +15 -14
  143. package/assets/templates/blocks/components/Tokenizer/TokenizerIcon.tsx +15 -14
  144. package/assets/templates/blocks/components/Tokenizer/TokenizerMaxEntries.tsx +17 -16
  145. package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx +29 -29
  146. package/assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx +9 -8
  147. package/assets/templates/blocks/components/Tokenizer/TokenizerStates.tsx +39 -41
  148. package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -0
  149. package/assets/templates/pages/form-wizard-inline/template.doc.mjs +6 -1
  150. package/assets/templates/pages/table-comparison/template.doc.mjs +1 -0
  151. package/assets/templates/pages/table-tree/template.doc.mjs +3 -0
  152. package/authoring/debug/parse.d.mts +2 -2
  153. package/authoring/doctypes/icon-definition/icon-definition.doc.mjs +4 -4
  154. package/authoring/doctypes/icon-set/icon-set-data.doc.mjs +6 -0
  155. package/authoring/doctypes/icon-set/parse.d.mts +1 -0
  156. package/authoring/doctypes/icon-set/parse.mjs +1 -0
  157. package/authoring/doctypes/icon-set/type.ts +5 -0
  158. package/authoring/doctypes/template/template.doc.mjs +1 -1
  159. package/authoring/doctypes/template/type.ts +2 -1
  160. package/clients/cli/commands/doctor.mjs +16 -17
  161. package/clients/cli/commands/experimental/icon.mjs +167 -35
  162. package/clients/cli/commands/experimental/index.mjs +2 -0
  163. package/clients/cli/commands/experimental/render.mjs +113 -0
  164. package/clients/cli/commands/experimental-icon-add.doc.mjs +14 -4
  165. package/clients/cli/commands/experimental-icon-map.doc.mjs +12 -2
  166. package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +1 -1
  167. package/clients/cli/commands/experimental-icon-new-set.doc.mjs +28 -1
  168. package/clients/cli/commands/experimental-icon.doc.mjs +18 -2
  169. package/clients/cli/commands/experimental-render.doc.mjs +60 -0
  170. package/clients/cli/commands/experimental.doc.mjs +4 -2
  171. package/clients/cli/commands/icon-authoring.test.mjs +1823 -13
  172. package/clients/cli/commands/icon-options-wiring.test.mjs +158 -0
  173. package/clients/cli/commands/icon.test.mjs +1 -1
  174. package/clients/cli/commands/template.mjs +4 -1
  175. package/clients/cli/commands/text-json-parity.test.mjs +46 -0
  176. package/clients/cli/index.mjs +1 -0
  177. package/foundation/discovery/component-discovery.d.mts +2 -1
  178. package/foundation/discovery/component-discovery.export-names.test.mjs +41 -0
  179. package/foundation/discovery/component-discovery.mjs +13 -7
  180. package/foundation/discovery/icon-set-checks.d.mts +43 -9
  181. package/foundation/discovery/icon-set-checks.mjs +296 -21
  182. package/foundation/discovery/icon-set-checks.test.mjs +125 -12
  183. package/foundation/discovery/icon-set-writer.d.mts +192 -3
  184. package/foundation/discovery/icon-set-writer.mjs +608 -34
  185. package/foundation/discovery/icon-set-writer.test.mjs +26 -0
  186. package/foundation/discovery/module-exports.mjs +82 -25
  187. package/foundation/discovery/module-exports.test.mjs +38 -1
  188. package/foundation/discovery/package-exports.d.mts +13 -0
  189. package/foundation/discovery/package-exports.mjs +40 -1
  190. package/foundation/discovery/template-icons.d.mts +6 -0
  191. package/foundation/discovery/template-icons.mjs +98 -10
  192. package/foundation/discovery/template-icons.test.mjs +103 -0
  193. package/foundation/doc-compiler/doc-loads.test.mjs +20 -5
  194. package/foundation/doc-compiler/import.mjs +81 -8
  195. package/foundation/doc-compiler/read.d.mts +4 -3
  196. package/foundation/doc-compiler/read.mjs +15 -10
  197. package/foundation/doc-compiler/read.test.mjs +59 -1
  198. package/foundation/doc-compiler/tree.mjs +3 -1
  199. package/foundation/fs/module-loader.d.mts +3 -2
  200. package/foundation/fs/module-loader.mjs +3 -2
  201. package/foundation/fs/publish-file-eperm-mutation.test.mjs +2 -0
  202. package/foundation/fs/read-record.d.mts +27 -0
  203. package/foundation/fs/read-record.mjs +83 -15
  204. package/foundation/fs/read-record.test.mjs +88 -1
  205. package/foundation/render/assets.d.mts +31 -0
  206. package/foundation/render/assets.mjs +102 -0
  207. package/foundation/render/component-map.d.mts +52 -0
  208. package/foundation/render/component-map.mjs +141 -0
  209. package/foundation/render/css-cut.d.mts +29 -0
  210. package/foundation/render/css-cut.mjs +144 -0
  211. package/foundation/render/embedded-files.d.mts +28 -0
  212. package/foundation/render/embedded-files.mjs +108 -0
  213. package/foundation/render/embedded-imports.d.mts +61 -0
  214. package/foundation/render/embedded-imports.mjs +315 -0
  215. package/foundation/render/html-reader.d.mts +37 -0
  216. package/foundation/render/html-reader.mjs +121 -0
  217. package/foundation/render/page-worker.d.mts +7 -0
  218. package/foundation/render/page-worker.mjs +519 -0
  219. package/foundation/render/rebuild.d.mts +19 -0
  220. package/foundation/render/rebuild.mjs +269 -0
  221. package/foundation/render/render-page.d.mts +85 -0
  222. package/foundation/render/render-page.mjs +612 -0
  223. package/foundation/render/render.test.mjs +117 -0
  224. package/foundation/render/source-block.d.mts +52 -0
  225. package/foundation/render/source-block.mjs +106 -0
  226. package/foundation/response/error-codes.d.mts +10 -1
  227. package/foundation/response/error-codes.doc.mjs +56 -0
  228. package/foundation/response/error-codes.mjs +61 -0
  229. package/foundation/response/response-types.doc.mjs +38 -1
  230. package/foundation/text/string-utils.mjs +33 -0
  231. package/foundation/text/string-utils.test.mjs +17 -0
  232. package/foundation/text/suggest-order.d.mts +17 -3
  233. package/foundation/text/suggest-order.mjs +58 -13
  234. package/foundation/text/suggest-order.test.mjs +53 -0
  235. package/package.json +14 -9
@@ -68,7 +68,7 @@ export function registerExperimentalIcon(group, program) {
68
68
  fn: iconFn,
69
69
  action: async (
70
70
  /** @type {string[] | string | undefined} */ words,
71
- /** @type {{list?: boolean, set?: string, limit?: string}} */ options,
71
+ /** @type {{list?: boolean, set?: string, limit?: string, allIcons?: boolean, definitions?: boolean}} */ options,
72
72
  ) => {
73
73
  const json = program.opts().json || false;
74
74
  const query = Array.isArray(words) ? words.join(' ') : words;
@@ -83,6 +83,8 @@ export function registerExperimentalIcon(group, program) {
83
83
  list: options.list ?? false,
84
84
  set: options.set,
85
85
  limit,
86
+ allIcons: options.allIcons ?? false,
87
+ definitions: options.definitions ?? false,
86
88
  });
87
89
  } catch (e) {
88
90
  const err =
@@ -100,13 +102,24 @@ export function registerExperimentalIcon(group, program) {
100
102
  resultKind: 'mixed',
101
103
  empty: result.data.matchCount === 0,
102
104
  })
103
- : result.type === 'icon.list'
105
+ : result.type === 'icon.definitions'
104
106
  ? resultSet({
105
- count: result.data.sets.length,
107
+ count: result.data.definitions.length,
106
108
  resultKind: 'mixed',
107
- empty: result.data.sets.length === 0,
108
109
  })
109
- : resultSet({count: 1, resultKind: 'mixed', directMatch: true});
110
+ : result.type === 'icon.setIcons'
111
+ ? resultSet({
112
+ count: result.data.icons.length,
113
+ resultKind: 'mixed',
114
+ empty: result.data.icons.length === 0,
115
+ })
116
+ : result.type === 'icon.list'
117
+ ? resultSet({
118
+ count: result.data.sets.length,
119
+ resultKind: 'mixed',
120
+ empty: result.data.sets.length === 0,
121
+ })
122
+ : resultSet({count: 1, resultKind: 'mixed', directMatch: true});
110
123
 
111
124
  if (json) {
112
125
  jsonOut(result);
@@ -114,6 +127,40 @@ export function registerExperimentalIcon(group, program) {
114
127
  }
115
128
 
116
129
  const run = getCliInvocation();
130
+ if (result.type === 'icon.definitions') {
131
+ const {definitions} = result.data;
132
+ emit(
133
+ section(
134
+ `Icon definitions (${definitions.length}, ${definitions.filter(each => each.builtIn).length} built-in)`,
135
+ ),
136
+ list(
137
+ definitions.map(
138
+ each =>
139
+ `${each.name} [${each.builtIn ? 'built-in' : 'optional'}]: ${each.description} Words: ${each.words.join(', ')}.`,
140
+ ),
141
+ ),
142
+ text(
143
+ `Built-in definitions are the ones every set maps. Map one: ${run} experimental icon map <definition> <icon id>`,
144
+ ),
145
+ );
146
+ return answered;
147
+ }
148
+ if (result.type === 'icon.setIcons') {
149
+ const {set, iconCount, icons} = result.data;
150
+ emit(
151
+ section(`Icons in ${set} (${iconCount})`),
152
+ // One line each, so a whole library reads at a glance:
153
+ // id, then its words, then the definitions it draws.
154
+ list(
155
+ icons.map(
156
+ each =>
157
+ `${each.id}: ${each.words.join(', ')}${each.definitions.length > 0 ? ` = ${each.definitions.join(', ')}` : ''}`,
158
+ ),
159
+ ),
160
+ text(`Map one: ${run} experimental icon map <definition> <id>`),
161
+ );
162
+ return answered;
163
+ }
117
164
  if (result.type === 'icon.search') {
118
165
  const {query: q, matchCount, matches} = result.data;
119
166
  if (matches.length === 0) {
@@ -129,13 +176,17 @@ export function registerExperimentalIcon(group, program) {
129
176
  ? `Icons for "${q}" (${matches.length} of ${matchCount})`
130
177
  : `Icons for "${q}" (${matches.length})`,
131
178
  ),
132
- // A match's variants are read with `icon <set>/<id>`; each match
133
- // with any says how many.
179
+ // The import draws the icon's default look; its other variants
180
+ // are named with their exports and read with `icon <set>/<id>`.
134
181
  records(
135
182
  matches.map(({variants, ...match}) => ({
136
183
  ...match,
137
184
  ...(variants.length > 0
138
- ? {variant: variants.map(each => each.variant).join(', ')}
185
+ ? {
186
+ variant: variants
187
+ .map(each => `${each.variant} (${each.export})`)
188
+ .join(', '),
189
+ }
139
190
  : {}),
140
191
  })),
141
192
  {
@@ -175,7 +226,7 @@ export function registerExperimentalIcon(group, program) {
175
226
  }),
176
227
  ...(variants.length > 0
177
228
  ? [
178
- section('Variants'),
229
+ section('Other variants'),
179
230
  records(variants, {
180
231
  fields: ['variant', 'module', 'export', 'import'],
181
232
  }),
@@ -239,6 +290,18 @@ export function registerExperimentalIcon(group, program) {
239
290
  },
240
291
  });
241
292
 
293
+ /**
294
+ * The set an authoring subcommand edits. `experimental icon` declares
295
+ * `--set` too, so Commander gives the parent a `--set` written after a
296
+ * subcommand's name; the subcommand reads it there.
297
+ * @param {{set?: unknown}} options the subcommand's own options
298
+ * @returns {string | undefined}
299
+ */
300
+ const setOf = options => {
301
+ const value = options.set ?? iconCli.opts().set;
302
+ return typeof value === 'string' ? value : undefined;
303
+ };
304
+
242
305
  /**
243
306
  * Run one authoring call and print its receipt, or its error.
244
307
  * @param {() => Promise<any>} call
@@ -284,36 +347,51 @@ export function registerExperimentalIcon(group, program) {
284
347
  defineCommand(iconCli, iconMapCommand, {
285
348
  fn: iconMapFn,
286
349
  action: (
287
- /** @type {string} */ definition,
350
+ /** @type {string | undefined} */ definition,
288
351
  /** @type {string | undefined} */ iconId,
289
- /** @type {{set?: string, remove?: boolean}} */ options,
352
+ /** @type {{set?: string, remove?: boolean, pairs?: string}} */ options,
290
353
  ) =>
291
354
  run(
292
355
  () =>
293
356
  iconMap(definition, iconId, {
294
357
  cwd: process.cwd(),
295
- set: options.set,
358
+ set: setOf(options),
296
359
  remove: options.remove ?? false,
360
+ pairs: options.pairs,
297
361
  }),
298
- ({data}) =>
299
- emit(
300
- text(
301
- data.icon == null
302
- ? data.changed
303
- ? `[ok] Removed map.${data.definition} (was "${data.previous}") from ${data.file}.`
304
- : `[ok] ${data.file} has no map.${data.definition}.`
305
- : data.changed
306
- ? `[ok] map.${data.definition} = "${data.icon}" in ${data.file}${data.previous ? ` (was "${data.previous}")` : ''}.`
307
- : `[ok] map.${data.definition} is already "${data.icon}".`,
308
- ),
309
- ),
362
+ (/** @type {any} */ {type, data}) =>
363
+ type === 'icon.mapMany'
364
+ ? emit(
365
+ text(
366
+ `[ok] ${data.entries.filter((/** @type {{changed: boolean}} */ each) => each.changed).length} of ${data.entries.length} map entries changed in ${data.file}.`,
367
+ ),
368
+ list(
369
+ data.entries.map(
370
+ (
371
+ /** @type {{definition: string, icon: string, previous: string | null}} */ each,
372
+ ) =>
373
+ `${each.definition} = "${each.icon}"${each.previous && each.previous !== each.icon ? ` (was "${each.previous}")` : ''}`,
374
+ ),
375
+ ),
376
+ )
377
+ : emit(
378
+ text(
379
+ data.icon == null
380
+ ? data.changed
381
+ ? `[ok] Removed map.${data.definition} (was "${data.previous}") from ${data.file}.`
382
+ : `[ok] ${data.file} has no map.${data.definition}.`
383
+ : data.changed
384
+ ? `[ok] map.${data.definition} = "${data.icon}" in ${data.file}${data.previous ? ` (was "${data.previous}")` : ''}.`
385
+ : `[ok] map.${data.definition} is already "${data.icon}".`,
386
+ ),
387
+ ),
310
388
  ),
311
389
  });
312
390
 
313
391
  defineCommand(iconCli, iconAddCommand, {
314
392
  fn: iconAddFn,
315
393
  action: (
316
- /** @type {string} */ exportName,
394
+ /** @type {string | undefined} */ exportName,
317
395
  /** @type {Record<string, string | boolean | undefined>} */ options,
318
396
  ) =>
319
397
  run(
@@ -321,7 +399,7 @@ export function registerExperimentalIcon(group, program) {
321
399
  iconAdd(exportName, {
322
400
  cwd: process.cwd(),
323
401
  from: /** @type {string} */ (options.from),
324
- set: /** @type {string | undefined} */ (options.set),
402
+ set: setOf(options),
325
403
  definition: /** @type {string | undefined} */ (options.definition),
326
404
  newDefinition: /** @type {string | undefined} */ (
327
405
  options.newDefinition
@@ -336,9 +414,27 @@ export function registerExperimentalIcon(group, program) {
336
414
  useDefault: options.default === true,
337
415
  variant: /** @type {string | undefined} */ (options.variant),
338
416
  id: /** @type {string | undefined} */ (options.id),
417
+ all: options.all === true,
339
418
  }),
340
419
  result => {
341
420
  const cli = getCliInvocation();
421
+ if (result.type === 'icon.addVariants') {
422
+ const {data} = result;
423
+ emit(
424
+ text(
425
+ `[ok] ${data.variant}: ${data.added} icons gained it${data.already > 0 ? `, ${data.already} already had it` : ''}, read from ${data.from}.`,
426
+ ),
427
+ ...(data.files.length > 0 ? [list(data.files)] : []),
428
+ ...(data.missing.length > 0
429
+ ? [
430
+ text(
431
+ `${data.missing.length} icons have no ${data.variant} export in ${data.from} and keep none: ${data.missing.join(', ')}`,
432
+ ),
433
+ ]
434
+ : []),
435
+ );
436
+ return;
437
+ }
342
438
  if (result.type === 'icon.definitionMatches') {
343
439
  const {matches, newDefinition} = result.data;
344
440
  emit(
@@ -403,22 +499,54 @@ export function registerExperimentalIcon(group, program) {
403
499
  ) => {
404
500
  const {root, manifest, files, written, dryRun} = data;
405
501
  const state = dryRun ? 'plan' : written ? 'ok' : 'unchanged';
502
+ const refreshed = data.refreshed === true;
406
503
  emit(
407
504
  section(
408
- dryRun
409
- ? `New ${what} plan`
410
- : written
411
- ? `New ${what} added`
412
- : `New ${what} unchanged`,
505
+ refreshed
506
+ ? dryRun
507
+ ? `Refresh ${what} plan`
508
+ : `${what[0].toUpperCase()}${what.slice(1)} refreshed`
509
+ : dryRun
510
+ ? `New ${what} plan`
511
+ : written
512
+ ? `New ${what} added`
513
+ : `New ${what} unchanged`,
413
514
  ),
414
515
  text(`[${state}] ${data.name}`),
516
+ // What the command did (or, in a dry run, would do): never a step
517
+ // left for the author.
415
518
  text(
416
519
  root != null
417
- ? `${root.created ? 'Declare' : 'Use'} experimental.iconSets root ${root.path} in ${manifest}.`
418
- : `Update ${manifest}.`,
520
+ ? root.created
521
+ ? `${dryRun ? 'Would declare' : 'Declared'} the experimental.iconSets root ${root.path} in ${manifest}.`
522
+ : `The experimental.iconSets root ${root.path} in ${manifest} is unchanged.`
523
+ : `${dryRun ? 'Would update' : 'Updated'} ${manifest}.`,
419
524
  ),
420
525
  ...(files.length > 0 ? [list(files)] : []),
526
+ // What to do next comes before the long lists, so it never scrolls
527
+ // away.
421
528
  ...(data.notes ?? []).map(note => text(`[next] ${note}`)),
529
+ ...(data.mapped && data.mapped.length > 0
530
+ ? [
531
+ section(`Mapped by name (${data.mapped.length}, check each)`),
532
+ list(
533
+ data.mapped.map(each => `${each.definition} = ${each.icon}`),
534
+ ),
535
+ ]
536
+ : []),
537
+ ...(data.suggestions && data.suggestions.length > 0
538
+ ? [
539
+ section(
540
+ `Suggestions (${data.suggestions.length} for ${new Set(data.suggestions.map(each => each.definition)).size} definitions, not written)`,
541
+ ),
542
+ list(
543
+ data.suggestions.map(
544
+ each =>
545
+ `${each.definition} -> ${each.icon} (${each.word}): ${formatCliCommand(`astryx experimental icon map ${each.definition} ${each.icon}`)}`,
546
+ ),
547
+ ),
548
+ ]
549
+ : []),
422
550
  );
423
551
  };
424
552
 
@@ -426,7 +554,7 @@ export function registerExperimentalIcon(group, program) {
426
554
  fn: iconNewSetFn,
427
555
  action: (
428
556
  /** @type {string} */ name,
429
- /** @type {{dryRun?: boolean, from?: string, exclude?: string}} */ options,
557
+ /** @type {{dryRun?: boolean, from?: string, exclude?: string, variants?: string, defaultVariant?: string, displayName?: string, description?: string}} */ options,
430
558
  ) =>
431
559
  run(
432
560
  () =>
@@ -435,6 +563,10 @@ export function registerExperimentalIcon(group, program) {
435
563
  dryRun: options.dryRun,
436
564
  from: options.from,
437
565
  exclude: options.exclude,
566
+ variants: options.variants,
567
+ defaultVariant: options.defaultVariant,
568
+ displayName: options.displayName,
569
+ description: options.description,
438
570
  }),
439
571
  printNew('icon set'),
440
572
  ),
@@ -451,7 +583,7 @@ export function registerExperimentalIcon(group, program) {
451
583
  iconNewDefinition(name, {
452
584
  cwd: process.cwd(),
453
585
  dryRun: options.dryRun,
454
- set: options.set,
586
+ set: setOf(options),
455
587
  description: options.description,
456
588
  words: options.words,
457
589
  icon: options.icon,
@@ -13,6 +13,7 @@ import {cliError} from '../../lib/cli-error.mjs';
13
13
  import {defineCommand} from '../../lib/define-command.mjs';
14
14
  import {doc as experimentalGroup} from '../experimental.doc.mjs';
15
15
  import {registerExperimentalIcon} from './icon.mjs';
16
+ import {registerExperimentalRender} from './render.mjs';
16
17
 
17
18
  /** @param {import('commander').Command} program */
18
19
  export function registerExperimental(program) {
@@ -40,4 +41,5 @@ export function registerExperimental(program) {
40
41
  },
41
42
  });
42
43
  registerExperimentalIcon(experimental, program);
44
+ registerExperimentalRender(experimental, program);
43
45
  }
@@ -0,0 +1,113 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `astryx experimental render` — a page to one self-contained HTML
5
+ * file, and back. Experimental (spec:AST-017 FR27): it is registered only
6
+ * under the `experimental` group.
7
+ *
8
+ * The command surface comes from the colocated CommandDoc via
9
+ * `defineCommand`; this file reads flags, calls `render()`, and prints.
10
+ *
11
+ * Usage:
12
+ * astryx experimental render page.tsx --out page.html
13
+ * astryx experimental render --reverse page.html --out page.tsx
14
+ */
15
+
16
+ import {getCliInvocation} from '../../../../foundation/env/package-manager.mjs';
17
+ import {jsonOut} from '../../../../foundation/response/json.mjs';
18
+ import {resultSet} from '../../../../foundation/debug/index.mjs';
19
+ import {emit, section, text, record, list} from '../../formatters/index.mjs';
20
+ import {cliError} from '../../lib/cli-error.mjs';
21
+ import {defineCommand} from '../../lib/define-command.mjs';
22
+ import {render as renderApi} from '../../../../api/render/render.mjs';
23
+ import {doc as renderCommand} from '../experimental-render.doc.mjs';
24
+ import {doc as renderFn} from '../../../../api/render/render.doc.mjs';
25
+
26
+ /** @param {number} n */
27
+ const kb = n => (n < 1024 ? `${n} B` : `${(n / 1024).toFixed(1)} KB`);
28
+
29
+ /**
30
+ * Register `render` under the `experimental` group.
31
+ * @param {import('commander').Command} group the `experimental` command
32
+ * @param {import('commander').Command} program the root program
33
+ */
34
+ export function registerExperimentalRender(group, program) {
35
+ defineCommand(group, renderCommand, {
36
+ fn: renderFn,
37
+ action: async (
38
+ /** @type {string | undefined} */ file,
39
+ /** @type {{out?: string, reverse?: boolean, title?: string, overwrite?: boolean}} */ options,
40
+ ) => {
41
+ const json = program.opts().json || false;
42
+ /** @type {Awaited<ReturnType<typeof renderApi>>} */
43
+ let result;
44
+ try {
45
+ result = await renderApi(file ?? '', {
46
+ cwd: process.cwd(),
47
+ out: options.out,
48
+ reverse: options.reverse ?? false,
49
+ title: options.title,
50
+ overwrite: options.overwrite ?? false,
51
+ });
52
+ } catch (e) {
53
+ const err = /** @type {import('../../../../api/error.mjs').AstryxError} */ (e);
54
+ return cliError(err.message, {suggestions: err.suggestions, code: err.code});
55
+ }
56
+ const answered = resultSet({count: 1, resultKind: 'mixed', directMatch: true});
57
+ if (json) {
58
+ jsonOut(result);
59
+ return answered;
60
+ }
61
+ const run = getCliInvocation();
62
+ if (result.type === 'render.page') {
63
+ const d = result.data;
64
+ emit(
65
+ section(`Rendered ${d.input}`),
66
+ record({
67
+ input: d.input,
68
+ output: d.output,
69
+ bytes: kb(d.bytes),
70
+ cssBytes: kb(d.cssBytes),
71
+ classes: d.classes,
72
+ images: d.images,
73
+ files: d.files.join(', '),
74
+ stylesheets: d.stylesheets.join(', ') || 'none',
75
+ }),
76
+ ...(d.warnings.length > 0
77
+ ? [section('Warnings'), list(d.warnings.map(w => w.message))]
78
+ : []),
79
+ text(`Give it back: ${run} experimental render --reverse ${d.output}`),
80
+ );
81
+ return answered;
82
+ }
83
+ const d = result.data;
84
+ emit(
85
+ section(d.mode === 'embedded' ? `Restored ${d.output}` : `Rebuilt ${d.output}`),
86
+ record({
87
+ input: d.input,
88
+ mode: d.mode,
89
+ exact: d.exact,
90
+ output: d.output,
91
+ files: d.files.join(', '),
92
+ ...(d.missing?.length ? {missing: d.missing.join(', ')} : {}),
93
+ ...(d.mode === 'rebuilt'
94
+ ? {
95
+ components: (d.components ?? []).join(', ') || 'none',
96
+ elements: d.elements ?? 0,
97
+ ...(d.omitted?.length ? {omitted: d.omitted.join(', ')} : {}),
98
+ ...(d.unknown?.length ? {unknown: d.unknown.join(', ')} : {}),
99
+ }
100
+ : {}),
101
+ }),
102
+ ...(d.mode === 'rebuilt'
103
+ ? [
104
+ text(
105
+ 'The file had no embedded source, so the page was rebuilt from its Astryx markup: text and layout only. Review it before use.',
106
+ ),
107
+ ]
108
+ : []),
109
+ );
110
+ return answered;
111
+ },
112
+ });
113
+ }
@@ -11,15 +11,15 @@ export const doc = {
11
11
  stability: 'experimental',
12
12
  summary: 'Register one icon you chose from a library in your icon set',
13
13
  description:
14
- "Run inside an icon-set package. You pick the export; the CLI proves it is a component of --from, read without running it, and never searches the library. Without a definition it lists the icon definitions that fit and the command for each. With --definition it adds the icon and maps the definition to it; --new-definition first adds your set's own definition. Experimental: it may change or be removed in a patch release.",
14
+ "Run inside an icon-set package. You pick the export; the CLI proves it is a component of --from, read without running it, and never searches the library. Without a definition it lists the icon definitions that fit and the command for each. With --definition it adds the icon and maps the definition to it; --new-definition first adds your set's own definition. With --variant <name> --from <module> --all and no export, it adds that variant for every icon whose id the module exports. Experimental: it may change or be removed in a patch release.",
15
15
  fn: 'iconAdd',
16
- args: [{name: 'export', param: 'exportName', required: true}],
16
+ args: [{name: 'export', param: 'exportName', required: false}],
17
17
  options: [
18
18
  {
19
19
  flag: '--from <module>',
20
20
  param: 'options.from',
21
21
  description:
22
- 'The module the icon is exported from: a package, a subpath, or a relative path this package exports',
22
+ 'The module the icon is exported from: a package, a subpath, or a ./ path to a file inside this package',
23
23
  },
24
24
  {
25
25
  flag: '--definition <name>',
@@ -55,6 +55,12 @@ export const doc = {
55
55
  description:
56
56
  "Add the export as this variant of an existing icon: one of the set's declared variants, such as solid",
57
57
  },
58
+ {
59
+ flag: '--all',
60
+ param: 'options.all',
61
+ description:
62
+ 'With --variant and --from, and no export: add that variant for every icon whose id the module exports, in one run',
63
+ },
58
64
  {
59
65
  flag: '--id <id>',
60
66
  param: 'options.id',
@@ -75,9 +81,13 @@ export const doc = {
75
81
  label: 'Add and map',
76
82
  cli: 'astryx experimental icon add Bin --from @acme/glyph-library --definition delete',
77
83
  },
84
+ {
85
+ label: 'Add the solid variant of every icon',
86
+ cli: 'astryx experimental icon add --variant solid --from @heroicons/react/24/solid --all',
87
+ },
78
88
  {
79
89
  label: 'Add your own definition',
80
- cli: "astryx experimental icon add RotateCw --from @acme/glyph-library --new-definition rotate --description 'Rotate an image or shape.' --words turn,spin",
90
+ cli: "astryx experimental icon add Dice5 --from @acme/glyph-library --new-definition random --description 'Pick something at random.' --words dice,shuffle,chance",
81
91
  },
82
92
  {
83
93
  label: 'Add a solid variant',
@@ -11,10 +11,10 @@ export const doc = {
11
11
  stability: 'experimental',
12
12
  summary: 'Register which icon of your set draws an icon definition',
13
13
  description:
14
- "Run inside an icon-set package. Sets `map[<definition>] = <icon>` in the set's data file; `integration check` prints these commands for definitions your set already has a fitting icon for. Experimental: it may change or be removed in a patch release.",
14
+ "Run inside an icon-set package. Sets `map[<definition>]` to the icon's id in the set's data file; name the icon by its id, its export name in any case, or another name its library exports it as (`trash-2` or `Trash2`), never by one word of its id, and the definition by its name or kebab id; `integration check` prints these commands for definitions your set already has a fitting icon for. Experimental: it may change or be removed in a patch release.",
15
15
  fn: 'iconMap',
16
16
  args: [
17
- {name: 'definition', param: 'definition', required: true},
17
+ {name: 'definition', param: 'definition', required: false},
18
18
  {name: 'icon', param: 'icon', required: false},
19
19
  ],
20
20
  options: [
@@ -28,12 +28,22 @@ export const doc = {
28
28
  param: 'options.remove',
29
29
  description: "Remove the definition's entry; takes no icon",
30
30
  },
31
+ {
32
+ flag: '--pairs <list>',
33
+ param: 'options.pairs',
34
+ description:
35
+ 'Many entries in one write: <definition>=<icon> pairs, comma-separated; checked together, all or none; an existing entry is replaced',
36
+ },
31
37
  ],
32
38
  examples: [
33
39
  {
34
40
  label: 'Map a definition',
35
41
  cli: 'astryx experimental icon map delete trash',
36
42
  },
43
+ {
44
+ label: 'Map many at once',
45
+ cli: 'astryx experimental icon map --pairs close=x-mark,error=x-circle,search=magnifying-glass',
46
+ },
37
47
  {
38
48
  label: 'Remove an entry',
39
49
  cli: 'astryx experimental icon map delete --remove',
@@ -51,7 +51,7 @@ export const doc = {
51
51
  examples: [
52
52
  {
53
53
  label: "Add a set's own icon definition",
54
- cli: "astryx experimental icon new-definition rotate --description 'Rotate an image or shape.' --words turn,spin --icon rotate-cw",
54
+ cli: "astryx experimental icon new-definition random --description 'Pick something at random.' --words dice,shuffle,chance --icon dice-5",
55
55
  },
56
56
  ],
57
57
  outsideProject: 'refuse',
@@ -11,7 +11,7 @@ export const doc = {
11
11
  stability: 'experimental',
12
12
  summary: 'Start an icon set in your integration package',
13
13
  description:
14
- "Run inside an integration package. Writes the set's folder with its descriptor, its data file, and its generated module, and declares the manifest's `experimental.iconSets` root on first use. With --from it wraps every icon component of a library; run it again to refresh. Experimental: it may change or be removed in a patch release.",
14
+ "Run inside an integration package. Writes the set's folder with its descriptor, its data file, and its generated module, and declares the manifest's `experimental.iconSets` root on first use. With --from it wraps every icon component of a library, records the library and its version as the set's source, copies its license notice, and maps each Astryx icon definition whose name is an icon's id; definitions an icon only shares a word with are listed as suggestions, never written. Run it again to refresh. --variants and --default-variant declare the set's variants. Experimental: it may change or be removed in a patch release.",
15
15
  fn: 'iconNewSet',
16
16
  args: [
17
17
  {
@@ -39,6 +39,29 @@ export const doc = {
39
39
  description:
40
40
  'With --from: comma-separated export names of the library that are not icons',
41
41
  },
42
+ {
43
+ flag: '--variants <list>',
44
+ param: 'options.variants',
45
+ description:
46
+ 'Comma-separated variants the set supplies, such as outline,solid',
47
+ },
48
+ {
49
+ flag: '--default-variant <variant>',
50
+ param: 'options.defaultVariant',
51
+ description:
52
+ "With --variants: the variant each icon's own export draws (the first variant when omitted)",
53
+ },
54
+ {
55
+ flag: '--display-name <text>',
56
+ param: 'options.displayName',
57
+ description:
58
+ "The set's display name (the name in title case when omitted)",
59
+ },
60
+ {
61
+ flag: '--description <text>',
62
+ param: 'options.description',
63
+ description: "The set's one-line description",
64
+ },
42
65
  ],
43
66
  examples: [
44
67
  {
@@ -49,6 +72,10 @@ export const doc = {
49
72
  label: 'Wrap a whole icon library',
50
73
  cli: 'astryx experimental icon new-set outline --from @acme/glyph-library',
51
74
  },
75
+ {
76
+ label: 'Wrap a library with two variants',
77
+ cli: 'astryx experimental icon new-set heroicons --from @heroicons/react/24/outline --variants outline,solid --default-variant outline',
78
+ },
52
79
  {
53
80
  label: 'Preview the files',
54
81
  cli: 'astryx experimental icon new-set outline --dry-run --json',
@@ -14,9 +14,9 @@ export const doc = {
14
14
  namespace: 'cli/commands',
15
15
  stability: 'experimental',
16
16
  summary:
17
- 'Find an icon by meaning in the installed icon sets, with its import line',
17
+ 'Find an icon by meaning, or build an icon set from a library (guide: astryx docs cli/experimental/icon-sets)',
18
18
  description:
19
- "Terminal front-end to icon(): searches every installed icon set's data file by meaning and prints each match's import line. `<set>/<id>` reads one icon with every variant's import line; --list lists the installed sets and how many icon definitions each one maps. The subcommands author a set: `new-set` starts one in an integration package, `new-definition` adds the set's own icon definition, `add` registers an icon from a library, `map` points an icon definition at an icon, and `use` makes a set the project's. Experimental: it may change or be removed in a patch release.",
19
+ "Terminal front-end to icon(): searches every installed icon set's data file by meaning and prints each match's import line. `<set>/<id>` reads one icon with every variant's import line; --list lists the installed sets and how many icon definitions each one maps. The subcommands author a set: `new-set` starts one in an integration package, `new-definition` adds the set's own icon definition, `add` registers an icon from a library, `map` points an icon definition at an icon, and `use` makes a set the project's. Start a set with `new-set <name> --from <library>`; the guide is `astryx docs cli/experimental/icon-sets`. Experimental: it may change or be removed in a patch release.",
20
20
  fn: 'icon',
21
21
  // `new-set` and `new-definition` start a set and its own definitions,
22
22
  // `add` registers an icon, `map` edits a map entry, and `use` picks the
@@ -43,6 +43,18 @@ export const doc = {
43
43
  param: 'options.limit',
44
44
  description: 'Max number of matches, a positive integer (default 10)',
45
45
  },
46
+ {
47
+ flag: '--definitions',
48
+ param: 'options.definitions',
49
+ description:
50
+ 'Every Astryx icon definition, one line each: name, built in or not, description, words',
51
+ },
52
+ {
53
+ flag: '--all-icons',
54
+ param: 'options.allIcons',
55
+ description:
56
+ 'With --set and no words: every icon of that set, one line each (id, words, definitions)',
57
+ },
46
58
  ],
47
59
  examples: [
48
60
  {label: 'Find by meaning', cli: 'astryx experimental icon delete'},
@@ -51,6 +63,10 @@ export const doc = {
51
63
  cli: 'astryx experimental icon outline/trash',
52
64
  },
53
65
  {label: 'Installed sets', cli: 'astryx experimental icon --list --json'},
66
+ {
67
+ label: 'Every icon of one set',
68
+ cli: 'astryx experimental icon --set outline --all-icons',
69
+ },
54
70
  {
55
71
  label: 'One set, top 3',
56
72
  cli: 'astryx experimental icon arrow --set outline --limit 3',