@astryxdesign/cli 0.7.4 → 0.7.5-canary.0026f37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -18
- package/api/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/unknown-name.test.mjs +63 -0
- package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +123 -70
- package/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs +19 -77
- package/assets/discover/official-packages.json +4 -0
- package/assets/docs/tree/icon-definitions.doc.mjs +2 -2
- package/assets/docs/tree/icon-set-files.doc.mjs +1 -1
- package/assets/docs/tree/icon-sets.doc.mjs +50 -20
- package/assets/docs/tree/render-pages.doc.mjs +94 -0
- package/assets/icons/definitions/activity.doc.mjs +1 -1
- package/assets/icons/definitions/alignCenter.doc.mjs +9 -0
- package/assets/icons/definitions/alignEnd.doc.mjs +10 -0
- package/assets/icons/definitions/alignStart.doc.mjs +10 -0
- package/assets/icons/definitions/archive.doc.mjs +1 -1
- package/assets/icons/definitions/arrowsUpDown.doc.mjs +1 -1
- package/assets/icons/definitions/attach.doc.mjs +1 -1
- package/assets/icons/definitions/audio.doc.mjs +1 -1
- package/assets/icons/definitions/cart.doc.mjs +1 -1
- package/assets/icons/definitions/checkDouble.doc.mjs +1 -1
- package/assets/icons/definitions/chevronsLeft.doc.mjs +1 -1
- package/assets/icons/definitions/chevronsRight.doc.mjs +1 -1
- package/assets/icons/definitions/close.doc.mjs +1 -1
- package/assets/icons/definitions/collapse.doc.mjs +1 -1
- package/assets/icons/definitions/compose.doc.mjs +1 -1
- package/assets/icons/definitions/conversation.doc.mjs +1 -1
- package/assets/icons/definitions/copy.doc.mjs +1 -1
- package/assets/icons/definitions/cpu.doc.mjs +9 -0
- package/assets/icons/definitions/database.doc.mjs +1 -1
- package/assets/icons/definitions/desktop.doc.mjs +1 -1
- package/assets/icons/definitions/discount.doc.mjs +1 -1
- package/assets/icons/definitions/download.doc.mjs +1 -1
- package/assets/icons/definitions/emoji.doc.mjs +1 -1
- package/assets/icons/definitions/error.doc.mjs +1 -1
- package/assets/icons/definitions/expand.doc.mjs +1 -1
- package/assets/icons/definitions/experiment.doc.mjs +1 -1
- package/assets/icons/definitions/externalLink.doc.mjs +7 -1
- package/assets/icons/definitions/eyeSlash.doc.mjs +1 -1
- package/assets/icons/definitions/flipHorizontal.doc.mjs +9 -0
- package/assets/icons/definitions/flipVertical.doc.mjs +9 -0
- package/assets/icons/definitions/folderAdd.doc.mjs +1 -1
- package/assets/icons/definitions/gitBranch.doc.mjs +9 -0
- package/assets/icons/definitions/gitFork.doc.mjs +9 -0
- package/assets/icons/definitions/info.doc.mjs +1 -1
- package/assets/icons/definitions/location.doc.mjs +1 -1
- package/assets/icons/definitions/mention.doc.mjs +1 -1
- package/assets/icons/definitions/menu.doc.mjs +1 -1
- package/assets/icons/definitions/microphone.doc.mjs +1 -1
- package/assets/icons/definitions/mobile.doc.mjs +1 -1
- package/assets/icons/definitions/money.doc.mjs +1 -1
- package/assets/icons/definitions/moreHorizontal.doc.mjs +1 -1
- package/assets/icons/definitions/notificationActive.doc.mjs +1 -1
- package/assets/icons/definitions/notificationOff.doc.mjs +1 -1
- package/assets/icons/definitions/panelLeft.doc.mjs +10 -0
- package/assets/icons/definitions/panelRight.doc.mjs +10 -0
- package/assets/icons/definitions/raiseHand.doc.mjs +1 -1
- package/assets/icons/definitions/redo.doc.mjs +1 -1
- package/assets/icons/definitions/refresh.doc.mjs +1 -1
- package/assets/icons/definitions/rotate.doc.mjs +9 -0
- package/assets/icons/definitions/scale.doc.mjs +10 -0
- package/assets/icons/definitions/search.doc.mjs +1 -1
- package/assets/icons/definitions/send.doc.mjs +1 -1
- package/assets/icons/definitions/settings.doc.mjs +1 -1
- package/assets/icons/definitions/star.doc.mjs +1 -1
- package/assets/icons/definitions/stop.doc.mjs +1 -1
- package/assets/icons/definitions/success.doc.mjs +1 -1
- package/assets/icons/definitions/textCase.doc.mjs +9 -0
- package/assets/icons/definitions/thumbsDown.doc.mjs +1 -1
- package/assets/icons/definitions/thumbsUp.doc.mjs +1 -1
- package/assets/icons/definitions/trendDown.doc.mjs +7 -1
- package/assets/icons/definitions/trendUp.doc.mjs +1 -1
- package/assets/icons/definitions/undo.doc.mjs +1 -1
- package/assets/icons/definitions/upload.doc.mjs +1 -1
- package/assets/icons/definitions/userAdd.doc.mjs +1 -1
- package/assets/icons/definitions/warning.doc.mjs +1 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx +15 -14
- package/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx +30 -30
- package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +15 -14
- package/assets/templates/blocks/components/Tokenizer/TokenizerIcon.tsx +15 -14
- package/assets/templates/blocks/components/Tokenizer/TokenizerMaxEntries.tsx +17 -16
- package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx +29 -29
- package/assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx +9 -8
- package/assets/templates/blocks/components/Tokenizer/TokenizerStates.tsx +39 -41
- package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -0
- package/assets/templates/pages/form-wizard-inline/template.doc.mjs +6 -1
- package/assets/templates/pages/table-comparison/template.doc.mjs +1 -0
- package/assets/templates/pages/table-tree/template.doc.mjs +3 -0
- package/authoring/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/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/index.mjs +1 -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/error-codes.d.mts +10 -1
- package/foundation/response/error-codes.doc.mjs +56 -0
- package/foundation/response/error-codes.mjs +61 -0
- package/foundation/response/response-types.doc.mjs +38 -1
- 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 +14 -9
package/api/icon/_authoring.mjs
CHANGED
|
@@ -33,17 +33,29 @@ import {
|
|
|
33
33
|
findLocalIconSet,
|
|
34
34
|
generatedModulePath,
|
|
35
35
|
generatedModuleText,
|
|
36
|
+
generatedOrigins,
|
|
37
|
+
sameIconModule,
|
|
36
38
|
generatedTypesPath,
|
|
37
39
|
THEME_MAP_NAME,
|
|
40
|
+
entryWiringNote,
|
|
38
41
|
iconSetDataText,
|
|
42
|
+
journalFile,
|
|
43
|
+
librarySource,
|
|
39
44
|
libraryIcons,
|
|
45
|
+
nonIconExports,
|
|
40
46
|
resolveIconSource,
|
|
41
|
-
|
|
47
|
+
peerNote,
|
|
48
|
+
typecheckNote,
|
|
42
49
|
writeDefinitionFile,
|
|
43
50
|
writeGeneratedIcons,
|
|
44
51
|
writeIconSetData,
|
|
45
52
|
} from '../../foundation/discovery/icon-set-writer.mjs';
|
|
46
53
|
import {astryxIconDefinitions} from '../../foundation/discovery/icon-definition-discovery.mjs';
|
|
54
|
+
import {suggestedIcons} from '../../foundation/discovery/icon-set-checks.mjs';
|
|
55
|
+
import {
|
|
56
|
+
resolveProjectTypeScript,
|
|
57
|
+
TYPESCRIPT_FIX,
|
|
58
|
+
} from '../../foundation/discovery/project-typescript.mjs';
|
|
47
59
|
import {
|
|
48
60
|
KEBAB_NAME_RE,
|
|
49
61
|
applyWrites,
|
|
@@ -82,11 +94,12 @@ function quoteJs(value) {
|
|
|
82
94
|
* discoverable; `integration check` then names every built-in icon
|
|
83
95
|
* definition it still has to map.
|
|
84
96
|
* @param {string} name icon set name (kebab-case)
|
|
85
|
-
* @param {{cwd?: string, dryRun?: boolean, from?: string, exclude?: string[] | string}} options
|
|
97
|
+
* @param {{cwd?: string, dryRun?: boolean, from?: string, exclude?: string[] | string, variants?: string[] | string, defaultVariant?: string, displayName?: string, description?: string}} options
|
|
86
98
|
* @returns {Promise<{type: 'integration.add', data: import('./icon.type.mjs').IconNewData}>}
|
|
87
99
|
*/
|
|
88
100
|
export async function addIconSet(name, options) {
|
|
89
101
|
const {cwd = process.cwd(), dryRun = false, from} = options;
|
|
102
|
+
const looks = variantOptions(options);
|
|
90
103
|
const exclude =
|
|
91
104
|
typeof options.exclude === 'string'
|
|
92
105
|
? options.exclude
|
|
@@ -98,7 +111,7 @@ export async function addIconSet(name, options) {
|
|
|
98
111
|
throw new AstryxError(
|
|
99
112
|
'--exclude names library exports to leave out, so it needs --from.',
|
|
100
113
|
undefined,
|
|
101
|
-
ERROR_CODES.
|
|
114
|
+
ERROR_CODES.ERR_INVALID_OPTION,
|
|
102
115
|
);
|
|
103
116
|
}
|
|
104
117
|
if (!KEBAB_NAME_RE.test(name)) {
|
|
@@ -179,6 +192,11 @@ export async function addIconSet(name, options) {
|
|
|
179
192
|
dryRun,
|
|
180
193
|
from,
|
|
181
194
|
exclude,
|
|
195
|
+
looks,
|
|
196
|
+
describe: {
|
|
197
|
+
displayName: options.displayName,
|
|
198
|
+
description: options.description,
|
|
199
|
+
},
|
|
182
200
|
packageDir,
|
|
183
201
|
rootPath,
|
|
184
202
|
manifestPath: projectPath(path.relative(packageDir, manifestFile)),
|
|
@@ -203,6 +221,12 @@ export async function addIconSet(name, options) {
|
|
|
203
221
|
let map = {};
|
|
204
222
|
/** @type {import('../../foundation/discovery/icon-set-writer.mjs').GeneratedIcon[]} */
|
|
205
223
|
let exportsToWrite = [];
|
|
224
|
+
/** @type {Array<{definition: string, icon: string, word: string}>} */
|
|
225
|
+
let suggestions = [];
|
|
226
|
+
/** @type {string[]} */
|
|
227
|
+
let skipped = [];
|
|
228
|
+
/** @type {ReturnType<typeof librarySource>} */
|
|
229
|
+
let library = null;
|
|
206
230
|
if (from != null) {
|
|
207
231
|
const source = await iconAuthoring(() =>
|
|
208
232
|
resolveIconSource(from, {packageDir, pkg}),
|
|
@@ -218,9 +242,12 @@ export async function addIconSet(name, options) {
|
|
|
218
242
|
icons = found.map(icon => ({
|
|
219
243
|
id: icon.id,
|
|
220
244
|
export: icon.name,
|
|
221
|
-
words: icon.id.
|
|
245
|
+
words: [...new Set([...idWords(icon.id), ...icon.aliases])],
|
|
222
246
|
}));
|
|
223
247
|
map = exactDefinitionMap(icons, {});
|
|
248
|
+
skipped = nonIconExports(source.file, {exclude});
|
|
249
|
+
suggestions = definitionSuggestions(icons, map);
|
|
250
|
+
library = librarySource(source.module, packageDir);
|
|
224
251
|
exportsToWrite = found.map(icon => ({
|
|
225
252
|
name: icon.name,
|
|
226
253
|
from: source.module,
|
|
@@ -231,7 +258,14 @@ export async function addIconSet(name, options) {
|
|
|
231
258
|
const data = {
|
|
232
259
|
schemaVersion: /** @type {const} */ (1),
|
|
233
260
|
module: pkg.name,
|
|
261
|
+
...(library
|
|
262
|
+
? {source: {package: library.package, version: library.version}}
|
|
263
|
+
: {}),
|
|
264
|
+
...(exclude.length > 0 ? {exclude: [...new Set(exclude)].sort()} : {}),
|
|
234
265
|
generated,
|
|
266
|
+
...(looks
|
|
267
|
+
? {variants: looks.variants, default: {variant: looks.default}}
|
|
268
|
+
: {}),
|
|
235
269
|
themeMap: THEME_MAP_NAME,
|
|
236
270
|
map,
|
|
237
271
|
icons,
|
|
@@ -240,20 +274,21 @@ export async function addIconSet(name, options) {
|
|
|
240
274
|
generatedModuleText(packageDir, generated, null, data, exportsToWrite),
|
|
241
275
|
);
|
|
242
276
|
|
|
243
|
-
const displayName = kebabToTitle(name);
|
|
244
|
-
// The artwork license
|
|
245
|
-
// edits it when the artwork comes from elsewhere.
|
|
277
|
+
const displayName = options.displayName?.trim() || kebabToTitle(name);
|
|
278
|
+
// The artwork license is the wrapped library's, else the package's own;
|
|
279
|
+
// the author edits it when the artwork comes from elsewhere.
|
|
246
280
|
const license =
|
|
247
|
-
|
|
281
|
+
library?.license ??
|
|
282
|
+
(typeof pkg.license === 'string' && pkg.license.trim() !== ''
|
|
248
283
|
? pkg.license
|
|
249
|
-
: 'UNLICENSED';
|
|
284
|
+
: 'UNLICENSED');
|
|
250
285
|
const docContents = [
|
|
251
286
|
"/** @type {import('@astryxdesign/cli/authoring').IconSetDoc} */",
|
|
252
287
|
'export default {',
|
|
253
288
|
" type: 'icon-set',",
|
|
254
289
|
` name: ${quoteJs(name)},`,
|
|
255
290
|
` displayName: ${quoteJs(displayName)},`,
|
|
256
|
-
` description: ${quoteJs(`${displayName} icons.`)},`,
|
|
291
|
+
` description: ${quoteJs(options.description?.trim() || `${displayName} icons.`)},`,
|
|
257
292
|
' maintained: true,',
|
|
258
293
|
` license: ${quoteJs(license)},`,
|
|
259
294
|
'};',
|
|
@@ -273,6 +308,16 @@ export async function addIconSet(name, options) {
|
|
|
273
308
|
contents: generatedText.js,
|
|
274
309
|
createOnly: true,
|
|
275
310
|
});
|
|
311
|
+
// The wrapped library's license notices travel with its artwork.
|
|
312
|
+
for (const notice of library?.notices ?? []) {
|
|
313
|
+
const target = assertWithin(notice, setDir, {label: 'license notice'});
|
|
314
|
+
if (!library || fs.existsSync(target)) continue;
|
|
315
|
+
plans.push({
|
|
316
|
+
path: target,
|
|
317
|
+
contents: fs.readFileSync(path.join(library.dir, notice), 'utf-8'),
|
|
318
|
+
createOnly: true,
|
|
319
|
+
});
|
|
320
|
+
}
|
|
276
321
|
const typesPath = generatedTypesPath(generated);
|
|
277
322
|
if (typesPath && generatedText.dts != null) {
|
|
278
323
|
plans.push({
|
|
@@ -308,6 +353,10 @@ export async function addIconSet(name, options) {
|
|
|
308
353
|
};
|
|
309
354
|
if (!dryRun) {
|
|
310
355
|
let rollback = () => {};
|
|
356
|
+
// Every file this writes, the manifest included, is journaled first, so
|
|
357
|
+
// a failure anywhere puts each back (AST-084 FR13).
|
|
358
|
+
for (const plan of plans) journalFile(plan.path);
|
|
359
|
+
journalFile(manifestFile);
|
|
311
360
|
try {
|
|
312
361
|
rollback = applyWrites(plans);
|
|
313
362
|
rootReceipt = await patchIntegrationRoot(
|
|
@@ -366,19 +415,45 @@ export async function addIconSet(name, options) {
|
|
|
366
415
|
);
|
|
367
416
|
{
|
|
368
417
|
result.data.icons = icons.length;
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
);
|
|
418
|
+
if (from != null) {
|
|
419
|
+
result.data.mapped = Object.entries(map).map(([definition, icon]) => ({
|
|
420
|
+
definition,
|
|
421
|
+
icon,
|
|
422
|
+
}));
|
|
423
|
+
result.data.suggestions = suggestions;
|
|
424
|
+
}
|
|
425
|
+
// `integration check --strict` type-checks the set's typed doc files.
|
|
426
|
+
const typescript = resolveProjectTypeScript([packageDir]);
|
|
427
|
+
/** @type {Record<string, any>} */
|
|
428
|
+
const packageAfter = pkgUpdate ? JSON.parse(pkgUpdate.contents) : pkg;
|
|
380
429
|
result.data.notes = [
|
|
381
|
-
|
|
430
|
+
// First, so a long receipt never hides it: the strict check needs it.
|
|
431
|
+
...(typescript?.ts
|
|
432
|
+
? []
|
|
433
|
+
: [
|
|
434
|
+
typescript
|
|
435
|
+
? `\`integration check --strict\` type-checks the set's doc files with this package's TypeScript, ${typescript.version}, which has no compiler API. ${TYPESCRIPT_FIX}`
|
|
436
|
+
: "`integration check --strict` type-checks the set's doc files with TypeScript, which this package does not have: run `npm install -D typescript@6` (TypeScript 5.0 through 6).",
|
|
437
|
+
]),
|
|
438
|
+
// What the package needs that the CLI leaves to its author
|
|
439
|
+
// (architecture:cli-surface INV16), each as the exact change to make.
|
|
440
|
+
...[
|
|
441
|
+
entryWiringNote(packageDir, packageAfter, generated),
|
|
442
|
+
peerNote(packageAfter),
|
|
443
|
+
typecheckNote(packageAfter),
|
|
444
|
+
].filter(note => note != null),
|
|
445
|
+
...(options.description?.trim()
|
|
446
|
+
? []
|
|
447
|
+
: [
|
|
448
|
+
`The set's description is a placeholder ("${displayName} icons."): apps and discover show it. Pass --description when you create a set, or edit ${projectPath(path.relative(packageDir, docFile))}.`,
|
|
449
|
+
]),
|
|
450
|
+
...(skipped.length > 0
|
|
451
|
+
? [
|
|
452
|
+
`Left out ${skipped.length} exports that are not icons: ${skipped.slice(0, 12).join(', ')}${skipped.length > 12 ? ', …' : ''}.`,
|
|
453
|
+
]
|
|
454
|
+
: []),
|
|
455
|
+
...mappedNotes(map),
|
|
456
|
+
...suggestionNotes(suggestions),
|
|
382
457
|
'Run `astryx integration check` to see the icon definitions still to map.',
|
|
383
458
|
];
|
|
384
459
|
}
|
|
@@ -386,8 +461,26 @@ export async function addIconSet(name, options) {
|
|
|
386
461
|
}
|
|
387
462
|
|
|
388
463
|
/**
|
|
389
|
-
*
|
|
390
|
-
*
|
|
464
|
+
* An icon's words from its id: each part, leaving out a bare number
|
|
465
|
+
* (`volume-2` is `volume`) unless the id is only numbers.
|
|
466
|
+
* @param {string} id
|
|
467
|
+
*/
|
|
468
|
+
function idWords(id) {
|
|
469
|
+
const parts = id.split('-');
|
|
470
|
+
const named = parts.filter(part => !/^[0-9]+$/u.test(part));
|
|
471
|
+
return named.length > 0 ? named : parts;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/** @param {string} name a camelCase definition name, as a kebab id */
|
|
475
|
+
const definitionId = name =>
|
|
476
|
+
name.replace(/([a-z0-9])([A-Z])/gu, '$1-$2').toLowerCase();
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* The `map` entries an exact name gives: each Astryx definition whose name
|
|
480
|
+
* is an icon's id (`delete` → icon `delete`). A word alone never maps: a
|
|
481
|
+
* library's `trash` may not mean what a template's delete means, so it is a
|
|
482
|
+
* suggestion ({@link definitionSuggestions}). Entries the map already has are
|
|
483
|
+
* kept.
|
|
391
484
|
* @param {Array<{id: string}>} icons
|
|
392
485
|
* @param {Record<string, string>} map
|
|
393
486
|
*/
|
|
@@ -397,18 +490,113 @@ function exactDefinitionMap(icons, map) {
|
|
|
397
490
|
const next = {...map};
|
|
398
491
|
for (const {doc} of astryxIconDefinitions().definitions) {
|
|
399
492
|
if (next[doc.name]) continue;
|
|
400
|
-
const
|
|
401
|
-
|
|
402
|
-
.toLowerCase();
|
|
403
|
-
const hit = [
|
|
404
|
-
kebab,
|
|
405
|
-
...doc.words.map(word => word.replace(/\s+/gu, '-')),
|
|
406
|
-
].find(candidate => ids.has(candidate));
|
|
407
|
-
if (hit) next[doc.name] = hit;
|
|
493
|
+
const id = definitionId(doc.name);
|
|
494
|
+
if (ids.has(id)) next[doc.name] = id;
|
|
408
495
|
}
|
|
409
496
|
return next;
|
|
410
497
|
}
|
|
411
498
|
|
|
499
|
+
/**
|
|
500
|
+
* The icons each still-unmapped Astryx definition might map to
|
|
501
|
+
* ({@link suggestedIcons}). Never written; the author chooses with
|
|
502
|
+
* `astryx experimental icon map <definition> <icon>`.
|
|
503
|
+
* @param {Array<{id: string, words: string[]}>} icons
|
|
504
|
+
* @param {Record<string, string>} map
|
|
505
|
+
* @returns {Array<{definition: string, icon: string, word: string}>}
|
|
506
|
+
*/
|
|
507
|
+
function definitionSuggestions(icons, map) {
|
|
508
|
+
const set = {data: {icons, map}};
|
|
509
|
+
return astryxIconDefinitions()
|
|
510
|
+
.definitions.map(each => each.doc)
|
|
511
|
+
.filter(doc => !map[doc.name])
|
|
512
|
+
.flatMap(doc =>
|
|
513
|
+
suggestedIcons(set, doc).map(each => ({definition: doc.name, ...each})),
|
|
514
|
+
)
|
|
515
|
+
.sort((a, b) =>
|
|
516
|
+
a.definition < b.definition ? -1 : a.definition > b.definition ? 1 : 0,
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* The receipt's note for the suggestions, if any.
|
|
522
|
+
* @param {Array<{definition: string, icon: string}>} suggestions
|
|
523
|
+
*/
|
|
524
|
+
function suggestionNotes(suggestions) {
|
|
525
|
+
if (suggestions.length === 0) return [];
|
|
526
|
+
const count = new Set(suggestions.map(each => each.definition)).size;
|
|
527
|
+
return [
|
|
528
|
+
`${count} unmapped icon definitions have possible icons (listed under Suggestions; nothing was written for them). Check each meaning, then map the ones that fit: \`astryx experimental icon map <definition> <icon>\`.`,
|
|
529
|
+
];
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* The receipt's note for the entries an exact name wrote, if any.
|
|
534
|
+
* @param {Record<string, string>} map
|
|
535
|
+
*/
|
|
536
|
+
function mappedNotes(map) {
|
|
537
|
+
const count = Object.keys(map).length;
|
|
538
|
+
if (count === 0) return [];
|
|
539
|
+
return [
|
|
540
|
+
`${count} icon definitions were mapped because an icon has their exact name (listed under Mapped by name). A library can draw another meaning under the same name, such as a backspace key named delete: check each, and remap with \`astryx experimental icon map <definition> <icon>\`.`,
|
|
541
|
+
];
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/** A variant name: lower-kebab, such as `outline` or `mini-solid`. */
|
|
545
|
+
const VARIANT_NAME_RE = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* The variants and default variant `--variants` and `--default-variant`
|
|
549
|
+
* declare, or
|
|
550
|
+
* null when neither is given. The default is the first variant unless named.
|
|
551
|
+
* @param {{variants?: string[] | string, defaultVariant?: string}} options
|
|
552
|
+
* @returns {{variants: string[], default: string} | null}
|
|
553
|
+
*/
|
|
554
|
+
function variantOptions(options) {
|
|
555
|
+
const given =
|
|
556
|
+
typeof options.variants === 'string'
|
|
557
|
+
? options.variants.split(',')
|
|
558
|
+
: options.variants;
|
|
559
|
+
const variants = [
|
|
560
|
+
...new Set((given ?? []).map(each => each.trim()).filter(Boolean)),
|
|
561
|
+
];
|
|
562
|
+
const chosen = options.defaultVariant?.trim();
|
|
563
|
+
if (variants.length === 0) {
|
|
564
|
+
if (chosen) {
|
|
565
|
+
throw new AstryxError(
|
|
566
|
+
"--default-variant names one of the set's variants, so it needs --variants.",
|
|
567
|
+
[
|
|
568
|
+
{
|
|
569
|
+
name: `--variants ${chosen},<other>`,
|
|
570
|
+
reason: 'declare the variants',
|
|
571
|
+
},
|
|
572
|
+
],
|
|
573
|
+
ERROR_CODES.ERR_INVALID_OPTION,
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
return null;
|
|
577
|
+
}
|
|
578
|
+
for (const variant of variants) {
|
|
579
|
+
if (!VARIANT_NAME_RE.test(variant)) {
|
|
580
|
+
throw new AstryxError(
|
|
581
|
+
`Invalid variant name "${variant}": use lower-kebab, such as outline or solid.`,
|
|
582
|
+
undefined,
|
|
583
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
if (chosen && !variants.includes(chosen)) {
|
|
588
|
+
throw new AstryxError(
|
|
589
|
+
`--default-variant "${chosen}" is not one of --variants (${variants.join(', ')}).`,
|
|
590
|
+
variants.map(each => ({
|
|
591
|
+
name: `--default-variant ${each}`,
|
|
592
|
+
reason: 'a declared variant',
|
|
593
|
+
})),
|
|
594
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
595
|
+
);
|
|
596
|
+
}
|
|
597
|
+
return {variants, default: chosen || variants[0]};
|
|
598
|
+
}
|
|
599
|
+
|
|
412
600
|
/**
|
|
413
601
|
* Run an icon-set authoring step, turning its errors into AstryxErrors.
|
|
414
602
|
* @template T
|
|
@@ -444,74 +632,254 @@ async function iconAuthoring(step) {
|
|
|
444
632
|
* them), the generated module gains the new exports, `map` keeps every entry
|
|
445
633
|
* whose icon still exists, and the receipt names the entries that lost theirs.
|
|
446
634
|
* @param {string} name
|
|
447
|
-
* @param {{cwd: string, dryRun: boolean, from: string, exclude: string[], packageDir: string, rootPath: string, manifestPath: string}} options
|
|
635
|
+
* @param {{cwd: string, dryRun: boolean, from: string, exclude: string[], looks: {variants: string[], default: string} | null, describe: {displayName?: string, description?: string}, packageDir: string, rootPath: string, manifestPath: string}} options
|
|
448
636
|
*/
|
|
449
637
|
async function refreshIconSet(
|
|
450
638
|
name,
|
|
451
|
-
{
|
|
639
|
+
{
|
|
640
|
+
cwd,
|
|
641
|
+
dryRun,
|
|
642
|
+
from,
|
|
643
|
+
exclude,
|
|
644
|
+
looks,
|
|
645
|
+
describe,
|
|
646
|
+
packageDir,
|
|
647
|
+
rootPath,
|
|
648
|
+
manifestPath,
|
|
649
|
+
},
|
|
452
650
|
) {
|
|
453
651
|
return iconAuthoring(async () => {
|
|
454
652
|
const where = await findLocalIconSet(cwd, name);
|
|
455
653
|
const {set} = where;
|
|
456
654
|
const source = resolveIconSource(from, where);
|
|
655
|
+
// Exports left out before stay out; --exclude adds to them.
|
|
656
|
+
const excluded = [
|
|
657
|
+
...new Set([...(set.data.exclude ?? []), ...exclude]),
|
|
658
|
+
].sort();
|
|
457
659
|
const found = libraryIcons(source.file, {
|
|
458
660
|
adapter: Boolean(set.data.adapter),
|
|
459
|
-
exclude,
|
|
661
|
+
exclude: excluded,
|
|
460
662
|
});
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
663
|
+
// A refresh changes only the icons the refreshed module supplies: those
|
|
664
|
+
// the generated module re-exports or adapts from it. Every other icon
|
|
665
|
+
// (your own `./` artwork, another library's) is kept as it is, with its
|
|
666
|
+
// map entries and variants.
|
|
667
|
+
const generatedBefore = generatedModulePath(set, packageDir);
|
|
668
|
+
const origins = generatedOrigins(packageDir, generatedBefore);
|
|
669
|
+
/** @param {{export: string, module?: string}} icon */
|
|
670
|
+
const suppliedHere = icon => {
|
|
671
|
+
if ((icon.module ?? set.data.module) !== set.data.module) return false;
|
|
672
|
+
const origin = origins.get(icon.export);
|
|
673
|
+
return origin != null && sameIconModule(origin.module, source.module);
|
|
674
|
+
};
|
|
675
|
+
const supplied = set.data.icons.filter(suppliedHere);
|
|
676
|
+
const others = set.data.icons.filter(icon => !suppliedHere(icon));
|
|
677
|
+
// An existing icon is the same icon when the library still exports it:
|
|
678
|
+
// its identity is the library export its generated module re-exports
|
|
679
|
+
// (`HiSquares2X2Icon`), then its public export, then its id. Ids and
|
|
680
|
+
// public names are derived, and a newer rule may spell them differently
|
|
681
|
+
// (`squares-2-x2` is now `squares-2x2`); an icon matched this way keeps
|
|
682
|
+
// its public export byte for byte, every field it had (its variants, the
|
|
683
|
+
// words the author added, its module), and its map entries.
|
|
684
|
+
const byId = new Map(supplied.map(icon => [icon.id, icon]));
|
|
685
|
+
const byExport = new Map(supplied.map(icon => [icon.export, icon]));
|
|
686
|
+
const bySource = new Map(
|
|
687
|
+
supplied.map(icon => [origins.get(icon.export)?.source, icon]),
|
|
688
|
+
);
|
|
689
|
+
/** @param {{export: string, name: string, id: string}} icon */
|
|
690
|
+
const priorOf = icon =>
|
|
691
|
+
bySource.get(icon.export) ??
|
|
692
|
+
byExport.get(icon.name) ??
|
|
693
|
+
byId.get(icon.id) ??
|
|
694
|
+
null;
|
|
695
|
+
const otherIds = new Set(others.map(icon => icon.id));
|
|
696
|
+
const otherExports = new Set(others.map(icon => icon.export));
|
|
697
|
+
/** @type {string[]} library icons left out: an icon of yours has the id or name */
|
|
698
|
+
const shadowed = [];
|
|
699
|
+
/** @type {Map<string, string>} old id → new id */
|
|
700
|
+
const renames = new Map();
|
|
701
|
+
/** @type {Map<string, string>} the library export → the set's export */
|
|
702
|
+
const publicName = new Map();
|
|
703
|
+
const fromLibrary = found.flatMap(icon => {
|
|
704
|
+
const prior = priorOf(icon);
|
|
705
|
+
const name = prior?.export ?? icon.name;
|
|
706
|
+
if (!prior && (otherIds.has(icon.id) || otherExports.has(name))) {
|
|
707
|
+
shadowed.push(icon.id);
|
|
708
|
+
return [];
|
|
709
|
+
}
|
|
710
|
+
if (prior && prior.id !== icon.id) renames.set(prior.id, icon.id);
|
|
711
|
+
publicName.set(icon.export, name);
|
|
712
|
+
// The words its old id gave are the old rule's, not the author's.
|
|
713
|
+
const oldIdWords =
|
|
714
|
+
prior && prior.id !== icon.id ? new Set(idWords(prior.id)) : new Set();
|
|
715
|
+
return [
|
|
716
|
+
{
|
|
717
|
+
...(prior ?? {}),
|
|
718
|
+
id: icon.id,
|
|
719
|
+
export: name,
|
|
720
|
+
words: [
|
|
721
|
+
...new Set([
|
|
722
|
+
...idWords(icon.id),
|
|
723
|
+
...icon.aliases,
|
|
724
|
+
...(prior?.words ?? []).filter(word => !oldIdWords.has(word)),
|
|
725
|
+
]),
|
|
726
|
+
],
|
|
727
|
+
},
|
|
728
|
+
];
|
|
470
729
|
});
|
|
730
|
+
const icons = [...fromLibrary, ...others];
|
|
731
|
+
// The icons this module supplied that it no longer exports: they leave
|
|
732
|
+
// the set and its generated module, and the receipt names them.
|
|
733
|
+
// Each is named for why it left: `--exclude` (or the data file's
|
|
734
|
+
// `exclude`) names its library export, or the library no longer exports
|
|
735
|
+
// it.
|
|
736
|
+
const excludedNames = new Set(excluded);
|
|
737
|
+
const gone = supplied.filter(
|
|
738
|
+
icon => !fromLibrary.some(each => each.export === icon.export),
|
|
739
|
+
);
|
|
740
|
+
const isExcluded = (/** @type {{export: string}} */ icon) =>
|
|
741
|
+
excludedNames.has(origins.get(icon.export)?.source ?? '') ||
|
|
742
|
+
excludedNames.has(icon.export);
|
|
743
|
+
const goneExcluded = gone.filter(isExcluded);
|
|
744
|
+
const goneMissing = gone.filter(icon => !isExcluded(icon));
|
|
745
|
+
const excludedIds = new Set(goneExcluded.map(icon => icon.id));
|
|
471
746
|
const ids = new Set(icons.map(icon => icon.id));
|
|
472
747
|
/** @type {Record<string, string>} */
|
|
473
748
|
const kept = {};
|
|
474
|
-
|
|
475
|
-
|
|
749
|
+
// The data file's `map` names only icons in the set (its parser refuses
|
|
750
|
+
// anything else), so each lost entry's icon is one of these.
|
|
751
|
+
/** @type {{excluded: string[], missing: string[]}} */
|
|
752
|
+
const lost = {excluded: [], missing: []};
|
|
476
753
|
for (const [definition, id] of Object.entries(set.data.map ?? {})) {
|
|
477
|
-
|
|
478
|
-
|
|
754
|
+
const now = renames.get(id) ?? id;
|
|
755
|
+
if (ids.has(now)) kept[definition] = now;
|
|
756
|
+
else if (excludedIds.has(id)) {
|
|
757
|
+
lost.excluded.push(`${definition} -> "${id}"`);
|
|
758
|
+
} else lost.missing.push(`${definition} -> "${id}"`);
|
|
479
759
|
}
|
|
480
760
|
const generated = generatedModulePath(set, packageDir);
|
|
761
|
+
const library = librarySource(source.module, packageDir);
|
|
762
|
+
const map = exactDefinitionMap(icons, kept);
|
|
763
|
+
const suggestions = definitionSuggestions(icons, map);
|
|
481
764
|
const next = {
|
|
482
765
|
...set.data,
|
|
766
|
+
...(library
|
|
767
|
+
? {source: {package: library.package, version: library.version}}
|
|
768
|
+
: {}),
|
|
769
|
+
...(excluded.length > 0 ? {exclude: excluded} : {}),
|
|
483
770
|
generated,
|
|
771
|
+
...(looks
|
|
772
|
+
? {variants: looks.variants, default: {variant: looks.default}}
|
|
773
|
+
: {}),
|
|
484
774
|
...(set.data.themeMap ? {} : {themeMap: THEME_MAP_NAME}),
|
|
485
|
-
map
|
|
775
|
+
map,
|
|
486
776
|
icons,
|
|
487
777
|
};
|
|
488
778
|
/** @type {string[]} */
|
|
489
779
|
const files = [];
|
|
780
|
+
const dataChanged =
|
|
781
|
+
iconSetDataText(next) !== fs.readFileSync(set.dataPath, 'utf-8');
|
|
782
|
+
// --display-name and --description rewrite the descriptor's fields.
|
|
783
|
+
const docFile = path.join(set.dir, `${set.name}.doc.mjs`);
|
|
784
|
+
const docBefore = fs.readFileSync(docFile, 'utf-8');
|
|
785
|
+
let docAfter = docBefore;
|
|
786
|
+
for (const [field, value] of /** @type {const} */ ([
|
|
787
|
+
['displayName', describe.displayName],
|
|
788
|
+
['description', describe.description],
|
|
789
|
+
])) {
|
|
790
|
+
if (!value?.trim()) continue;
|
|
791
|
+
docAfter = docAfter.replace(
|
|
792
|
+
new RegExp(
|
|
793
|
+
`^(\\s*${field}:\\s*)(['"\`])(?:\\\\.|(?!\\2).)*\\2,?$`,
|
|
794
|
+
'mu',
|
|
795
|
+
),
|
|
796
|
+
(_, lead) => `${lead}${quoteJs(value.trim())},`,
|
|
797
|
+
);
|
|
798
|
+
}
|
|
799
|
+
// A refresh that first records the library as the set's source does what
|
|
800
|
+
// `new-set --from` does: the descriptor takes the library's license, but
|
|
801
|
+
// only over the value `new-set` wrote by default (the package's license,
|
|
802
|
+
// or UNLICENSED), never over one the author chose. Either way the
|
|
803
|
+
// receipt names both values.
|
|
804
|
+
/** @type {string | null} */
|
|
805
|
+
let licenseNote = null;
|
|
806
|
+
if (library?.license && !set.data.source) {
|
|
807
|
+
const license = library.license;
|
|
808
|
+
const licenseRe = /^(\s*license:\s*)(['"`])((?:\\.|(?!\2).)*)\2,?$/mu;
|
|
809
|
+
const current = licenseRe.exec(docBefore)?.[3] ?? null;
|
|
810
|
+
const packageLicense =
|
|
811
|
+
typeof where.pkg.license === 'string' && where.pkg.license.trim() !== ''
|
|
812
|
+
? where.pkg.license
|
|
813
|
+
: 'UNLICENSED';
|
|
814
|
+
const docRel = projectPath(path.relative(packageDir, docFile));
|
|
815
|
+
if (current === license) {
|
|
816
|
+
// Already the library's.
|
|
817
|
+
} else if (current == null || current === packageLicense) {
|
|
818
|
+
docAfter = docAfter.replace(
|
|
819
|
+
licenseRe,
|
|
820
|
+
(_, lead) => `${lead}${quoteJs(license)},`,
|
|
821
|
+
);
|
|
822
|
+
licenseNote = `The set's license in ${docRel} changed from "${current ?? '(none)'}" to "${license}", the license of ${library.package}, whose artwork it now wraps. Edit it if the artwork's license differs.`;
|
|
823
|
+
} else {
|
|
824
|
+
licenseNote = `The set's license in ${docRel} stays "${current}", which you set; ${library.package} is licensed "${license}". Change it if the artwork is the library's.`;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
if (docAfter !== docBefore) {
|
|
828
|
+
files.push(projectPath(path.relative(packageDir, docFile)));
|
|
829
|
+
}
|
|
830
|
+
// The library's license notices travel with its artwork, as new-set
|
|
831
|
+
// copies them: each one the set directory does not have yet.
|
|
832
|
+
const libraryDir = library?.dir ?? '';
|
|
833
|
+
const notices = (library?.notices ?? [])
|
|
834
|
+
.map(notice => ({
|
|
835
|
+
notice,
|
|
836
|
+
target: assertWithin(notice, set.dir, {label: 'license notice'}),
|
|
837
|
+
}))
|
|
838
|
+
.filter(({target}) => !fs.existsSync(target));
|
|
839
|
+
for (const {target} of notices) {
|
|
840
|
+
files.push(projectPath(path.relative(packageDir, target)));
|
|
841
|
+
}
|
|
490
842
|
if (!dryRun) {
|
|
491
843
|
const written = writeGeneratedIcons(
|
|
492
844
|
packageDir,
|
|
493
845
|
generated,
|
|
494
846
|
next,
|
|
495
|
-
found
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
847
|
+
found
|
|
848
|
+
.map(icon => ({
|
|
849
|
+
name: publicName.get(icon.export) ?? icon.name,
|
|
850
|
+
from: source.module,
|
|
851
|
+
source: icon.export,
|
|
852
|
+
adapt: icon.adapt,
|
|
853
|
+
}))
|
|
854
|
+
.filter(icon => publicName.has(icon.source)),
|
|
855
|
+
// The icons the library no longer exports leave the module too; a
|
|
856
|
+
// renamed icon keeps its export.
|
|
857
|
+
gone.map(icon => icon.export),
|
|
505
858
|
);
|
|
506
859
|
files.push(...written.files);
|
|
507
860
|
try {
|
|
508
861
|
writeIconSetData(set, next);
|
|
862
|
+
// The descriptor last: the command's journal puts it back with the
|
|
863
|
+
// rest if anything after it fails (AST-084 FR13).
|
|
864
|
+
for (const {notice, target} of notices) {
|
|
865
|
+
journalFile(target);
|
|
866
|
+
fs.writeFileSync(
|
|
867
|
+
target,
|
|
868
|
+
fs.readFileSync(path.join(libraryDir, notice)),
|
|
869
|
+
);
|
|
870
|
+
}
|
|
871
|
+
if (docAfter !== docBefore) {
|
|
872
|
+
journalFile(docFile);
|
|
873
|
+
fs.writeFileSync(docFile, docAfter);
|
|
874
|
+
}
|
|
509
875
|
} catch (error) {
|
|
510
876
|
written.undo();
|
|
511
877
|
throw error;
|
|
512
878
|
}
|
|
513
879
|
}
|
|
514
|
-
|
|
880
|
+
if (dataChanged) {
|
|
881
|
+
files.push(projectPath(path.relative(packageDir, set.dataPath)));
|
|
882
|
+
}
|
|
515
883
|
const result = receipt(
|
|
516
884
|
'icon-set',
|
|
517
885
|
name,
|
|
@@ -521,13 +889,60 @@ async function refreshIconSet(
|
|
|
521
889
|
dryRun,
|
|
522
890
|
);
|
|
523
891
|
result.data.icons = icons.length;
|
|
892
|
+
result.data.refreshed = true;
|
|
893
|
+
// Every entry an exact name gives, kept or new, so a refresh lists
|
|
894
|
+
// them for review again.
|
|
895
|
+
const byName = Object.fromEntries(
|
|
896
|
+
Object.entries(map).filter(
|
|
897
|
+
([definition, id]) =>
|
|
898
|
+
!(definition in kept) || id === definitionId(definition),
|
|
899
|
+
),
|
|
900
|
+
);
|
|
901
|
+
result.data.mapped = Object.entries(byName).map(([definition, icon]) => ({
|
|
902
|
+
definition,
|
|
903
|
+
icon,
|
|
904
|
+
}));
|
|
905
|
+
result.data.suggestions = suggestions;
|
|
906
|
+
if (renames.size > 0) {
|
|
907
|
+
result.data.renamed = [...renames].map(([from, to]) => ({from, to}));
|
|
908
|
+
}
|
|
524
909
|
result.data.notes = [
|
|
525
|
-
...(
|
|
910
|
+
...(licenseNote ? [licenseNote] : []),
|
|
911
|
+
...(renames.size > 0
|
|
526
912
|
? [
|
|
527
|
-
|
|
913
|
+
`${renames.size} icons have a new id under this release's id rule, and keep their map entries, variants, and words: ${[...renames].map(([from, to]) => `${from} -> ${to}`).join(', ')}.`,
|
|
528
914
|
]
|
|
529
915
|
: []),
|
|
530
|
-
|
|
916
|
+
...mappedNotes(byName),
|
|
917
|
+
...suggestionNotes(suggestions),
|
|
918
|
+
...(goneMissing.length > 0
|
|
919
|
+
? [
|
|
920
|
+
`${goneMissing.length} icons the library no longer exports were removed from the set: ${goneMissing.map(icon => icon.id).join(', ')}.`,
|
|
921
|
+
]
|
|
922
|
+
: []),
|
|
923
|
+
...(lost.missing.length > 0
|
|
924
|
+
? [
|
|
925
|
+
`These map entries named those icons and were removed: ${lost.missing.join(', ')}.`,
|
|
926
|
+
]
|
|
927
|
+
: []),
|
|
928
|
+
...(goneExcluded.length > 0
|
|
929
|
+
? [
|
|
930
|
+
`Left out by --exclude, and removed from the set: ${goneExcluded.map(icon => icon.id).join(', ')}.`,
|
|
931
|
+
]
|
|
932
|
+
: []),
|
|
933
|
+
...(lost.excluded.length > 0
|
|
934
|
+
? [
|
|
935
|
+
`These map entries named icons --exclude left out and were removed: ${lost.excluded.join(', ')}.`,
|
|
936
|
+
]
|
|
937
|
+
: []),
|
|
938
|
+
...(shadowed.length > 0
|
|
939
|
+
? [
|
|
940
|
+
`Left out ${shadowed.length} library icons whose id or name an icon of yours from another module already has: ${shadowed.join(', ')}.`,
|
|
941
|
+
]
|
|
942
|
+
: []),
|
|
943
|
+
astryxIconDefinitions().definitions.every(({doc}) => map[doc.name])
|
|
944
|
+
? 'Every Astryx icon definition is mapped.'
|
|
945
|
+
: 'Run `astryx integration check` to see the icon definitions still to map.',
|
|
531
946
|
];
|
|
532
947
|
return result;
|
|
533
948
|
});
|