@astryxdesign/cli 0.7.11 → 0.7.12-canary.0f28099
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/api/build/kit/rank.mjs +21 -4
- package/api/build/kit/words.d.mts +1 -0
- package/api/build/kit/words.mjs +1 -1
- package/api/component/__fixtures__/resolutions/modules.txt +2 -2
- package/api/docs/_adapter.d.mts +22 -0
- package/api/docs/_adapter.mjs +81 -3
- package/api/docs/docs.doc.mjs +5 -5
- package/api/docs/docs.type.d.mts +21 -0
- package/api/docs/docs.type.mjs +11 -0
- package/api/docs/list/list.d.mts +5 -1
- package/api/docs/list/list.mjs +72 -6
- package/api/docs/node/node.mjs +2 -40
- package/api/icon/_adapter.d.mts +3 -2
- package/api/icon/_adapter.mjs +8 -2
- package/api/icon/_authoring.d.mts +1 -0
- package/api/icon/_authoring.mjs +586 -66
- package/api/icon/_default-look.d.mts +155 -0
- package/api/icon/_default-look.mjs +474 -0
- package/api/icon/_records.d.mts +1 -1
- package/api/icon/_records.mjs +1 -0
- package/api/icon/add/add.mjs +224 -38
- package/api/icon/icon.type.d.mts +22 -2
- package/api/icon/icon.type.mjs +6 -2
- package/api/icon/iconAdd.doc.mjs +2 -2
- package/api/icon/iconNewDefinition.doc.mjs +3 -2
- package/api/icon/iconNewSet.doc.mjs +4 -4
- package/api/icon/search/search.mjs +10 -9
- package/api/index.d.mts +1 -0
- package/api/index.mjs +1 -0
- package/api/integration/add-helpers.d.mts +11 -1
- package/api/integration/add-helpers.mjs +5 -2
- package/api/integration/authoring-checks.d.mts +0 -2
- package/api/integration/authoring-checks.mjs +1 -6
- package/api/logger.mjs +2 -1
- package/api/render/_adapter.mjs +9 -0
- package/api/render/render.doc.mjs +2 -2
- package/api/search/_adapter.d.mts +22 -1
- package/api/search/_adapter.mjs +37 -20
- package/api/search/exportSearchIndex.doc.d.mts +10 -0
- package/api/search/exportSearchIndex.doc.mjs +58 -0
- package/api/search/rankSearchIndex.doc.d.mts +10 -0
- package/api/search/rankSearchIndex.doc.mjs +79 -0
- package/api/search/search-index.d.mts +44 -0
- package/api/search/search-index.mjs +270 -0
- package/api/search/search.type.d.mts +28 -0
- package/api/search/search.type.mjs +17 -0
- package/api/swizzle/_adapter.d.mts +1 -0
- package/api/swizzle/_adapter.mjs +4 -1
- package/api/swizzle/_moduleGraph.d.mts +178 -0
- package/api/swizzle/_moduleGraph.mjs +903 -0
- package/api/swizzle/copy/copy.d.mts +2 -43
- package/api/swizzle/copy/copy.mjs +287 -315
- package/api/swizzle/swizzle.d.mts +0 -2
- package/api/swizzle/swizzle.doc.mjs +13 -4
- package/api/swizzle/swizzle.mjs +3 -7
- package/api/swizzle/swizzle.type.d.mts +7 -1
- package/api/swizzle/swizzle.type.mjs +4 -2
- package/assets/discover/official-packages.json +20 -0
- package/assets/docs/browser-support.doc.mjs +2 -2
- package/assets/docs/styling-overview.doc.mjs +4 -0
- package/assets/docs/tree/icon-sets.doc.mjs +11 -5
- package/assets/docs/tree/render-pages.doc.mjs +2 -2
- package/assets/templates/blocks/components/Calendar/useCalendarConstraintsHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Calendar/useCalendarConstraintsHookUsage.tsx +146 -0
- package/assets/templates/blocks/components/Calendar/useCalendarNavigationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Calendar/useCalendarNavigationHookUsage.tsx +173 -0
- package/assets/templates/blocks/components/Hooks/useInputStatusIconHookUsage.tsx +1 -0
- package/assets/templates/blocks/components/Table/TableRowIndexTable.doc.mjs +1 -1
- package/assets/templates/blocks/components/Table/TableRowIndexTable.tsx +2 -2
- package/assets/templates/pages/course-detail/page.tsx +699 -0
- package/assets/templates/pages/course-detail/template.doc.mjs +37 -0
- package/assets/templates/pages/file-explorer/page.tsx +103 -79
- package/assets/templates/pages/table-filter/page.tsx +1 -0
- package/assets/templates/pages/table-grouped/page.tsx +160 -232
- package/assets/templates/pages/table-grouped/template.doc.mjs +0 -2
- package/assets/templates/pages/theme-showcase/page.tsx +724 -792
- package/assets/templates/pages/theme-showcase/template.doc.mjs +4 -5
- package/assets/templates/themes/butter/butterTheme.ts +3 -2
- package/assets/templates/themes/stone/stoneTheme.ts +1 -1
- package/assets/templates/themes/y2k/y2kTheme.ts +1 -1
- package/authoring/doctypes/template/type.ts +1 -0
- package/clients/cli/commands/docs.doc.mjs +5 -1
- package/clients/cli/commands/docs.mjs +30 -2
- package/clients/cli/commands/experimental/icon.mjs +31 -10
- package/clients/cli/commands/experimental-icon-add.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +2 -1
- package/clients/cli/commands/experimental-icon-new-set.doc.mjs +2 -2
- package/clients/cli/commands/swizzle.doc.mjs +12 -3
- package/clients/cli/commands/swizzle.mjs +33 -9
- package/foundation/discovery/component-loader.d.mts +1 -1
- package/foundation/discovery/doc-types.mjs +9 -2
- package/foundation/discovery/icon-ranking.d.mts +27 -3
- package/foundation/discovery/icon-ranking.mjs +125 -8
- package/foundation/discovery/icon-set-checks.mjs +44 -35
- package/foundation/discovery/icon-set-discovery.d.mts +13 -0
- package/foundation/discovery/icon-set-discovery.mjs +25 -0
- package/foundation/discovery/icon-set-writer.d.mts +238 -16
- package/foundation/discovery/icon-set-writer.mjs +676 -79
- package/foundation/discovery/module-exports.d.mts +3 -2
- package/foundation/discovery/module-exports.mjs +167 -37
- package/foundation/fs/paths.d.mts +2 -1
- package/foundation/fs/paths.mjs +3 -4
- package/foundation/render/charts.d.mts +59 -0
- package/foundation/render/charts.mjs +216 -0
- package/foundation/render/embedded-imports.d.mts +7 -7
- package/foundation/render/embedded-imports.mjs +63 -54
- package/foundation/render/page-worker.mjs +339 -52
- package/foundation/render/render-page.mjs +26 -10
- package/foundation/render/ts-paths.d.mts +63 -0
- package/foundation/render/ts-paths.mjs +138 -0
- package/foundation/response/error-codes.doc.mjs +2 -2
- package/foundation/response/error-codes.mjs +3 -2
- package/foundation/text/shell-arg.d.mts +14 -0
- package/foundation/text/shell-arg.mjs +17 -0
- package/package.json +7 -6
|
@@ -9,8 +9,18 @@
|
|
|
9
9
|
* 90 an exact match in the reading the searched sets favor (below)
|
|
10
10
|
* 80 an exact match in the other reading
|
|
11
11
|
* 60 one of its words starts with the query
|
|
12
|
-
* 40 a partial match: the id or a word contains the query
|
|
13
|
-
* word of the query starts one of the
|
|
12
|
+
* 40 a partial match: the id or a word contains the query (three
|
|
13
|
+
* letters or more), or every word of the query starts one of the
|
|
14
|
+
* icon's words or id parts
|
|
15
|
+
*
|
|
16
|
+
* A word matches a whole word: a word's plural or singular (`stars` for
|
|
17
|
+
* `star`) is an exact match, while a longer word that only starts with it
|
|
18
|
+
* (`start`) is a word-start match, and {@link answeringMatches} keeps
|
|
19
|
+
* word-start and partial matches only when nothing matches a whole word.
|
|
20
|
+
* A query is scored as typed first. Only when nothing answers it with a
|
|
21
|
+
* whole word are the words that only phrase it (`go`, `the`, `icon`) left
|
|
22
|
+
* out of a query of several words, so `go home` asks for `home` while
|
|
23
|
+
* `arrow up to line` still names `arrow-up-to-line`.
|
|
14
24
|
*
|
|
15
25
|
* An exact match is a NAME match when the query is the icon's id, or one of
|
|
16
26
|
* its words that is also a part of its id (`trash` for `trash-2`); it is a
|
|
@@ -26,7 +36,8 @@
|
|
|
26
36
|
*
|
|
27
37
|
* Equal scores keep the set order first (the project's set, then load
|
|
28
38
|
* order), so the project's set always leads at a score. Within one set, a
|
|
29
|
-
* name match on the whole id
|
|
39
|
+
* name match on the whole id (or its plural or singular) comes before one on
|
|
40
|
+
* a part of it, and a meaning
|
|
30
41
|
* match whose query sits earlier among the icon's tags comes first (sets list
|
|
31
42
|
* an icon's most telling tags first). Remaining ties keep id order, so the
|
|
32
43
|
* same installation always answers the same way.
|
|
@@ -93,7 +104,9 @@ const squash = value => value.toLowerCase().replace(/[\s_-]+/g, '');
|
|
|
93
104
|
* @property {boolean} meaning the query is one of the icon's tags (never
|
|
94
105
|
* both: a tag is a word that is not the id or one of its parts)
|
|
95
106
|
* @property {number} rank within-tier key, lower first: for a name match 0
|
|
96
|
-
* (whole id)
|
|
107
|
+
* (whole id), 1 (the whole id's plural or singular), 2 (an id part), or 3
|
|
108
|
+
* (an id part's plural or singular); for a meaning match the tag's
|
|
109
|
+
* position
|
|
97
110
|
* @property {string} reason
|
|
98
111
|
*/
|
|
99
112
|
|
|
@@ -127,10 +140,27 @@ export function matchIcon(query, icon, definitions = []) {
|
|
|
127
140
|
tier: 'exact',
|
|
128
141
|
name: wholeId || partWord,
|
|
129
142
|
meaning: !wholeId && !partWord,
|
|
130
|
-
rank: wholeId ? 0 : partWord ?
|
|
143
|
+
rank: wholeId ? 0 : partWord ? 2 : tagAt,
|
|
131
144
|
reason: wholeId ? `id "${icon.id}"` : `word "${query}"`,
|
|
132
145
|
};
|
|
133
146
|
}
|
|
147
|
+
const plural = icon.words.find(word => sameWord(word, query));
|
|
148
|
+
if (plural) {
|
|
149
|
+
const named = parts.has(plural);
|
|
150
|
+
return {
|
|
151
|
+
tier: 'exact',
|
|
152
|
+
name: named,
|
|
153
|
+
meaning: !named,
|
|
154
|
+
// The whole id's plural or singular right after the whole id, then
|
|
155
|
+
// after the word itself, wherever it sits.
|
|
156
|
+
rank: named
|
|
157
|
+
? plural === icon.id
|
|
158
|
+
? 1
|
|
159
|
+
: 3
|
|
160
|
+
: tags.length + tags.indexOf(plural),
|
|
161
|
+
reason: `word "${plural}"`,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
134
164
|
const prefix = icon.words.find(word => word.startsWith(query));
|
|
135
165
|
if (prefix) {
|
|
136
166
|
return {
|
|
@@ -141,7 +171,11 @@ export function matchIcon(query, icon, definitions = []) {
|
|
|
141
171
|
reason: `word "${prefix}" starts with "${query}"`,
|
|
142
172
|
};
|
|
143
173
|
}
|
|
144
|
-
|
|
174
|
+
// A letter or two inside a word (`x` in `box`) says nothing about it.
|
|
175
|
+
const contains =
|
|
176
|
+
query.replace(/\s+/gu, '').length >= 3
|
|
177
|
+
? [icon.id, ...icon.words].find(text => text.includes(query))
|
|
178
|
+
: undefined;
|
|
145
179
|
if (contains) {
|
|
146
180
|
return {
|
|
147
181
|
tier: 'partial',
|
|
@@ -170,6 +204,72 @@ export function matchIcon(query, icon, definitions = []) {
|
|
|
170
204
|
return null;
|
|
171
205
|
}
|
|
172
206
|
|
|
207
|
+
/**
|
|
208
|
+
* Whether two words are one word's singular and plural (`star`, `stars`;
|
|
209
|
+
* `box`, `boxes`), never the same word.
|
|
210
|
+
* @param {string} a
|
|
211
|
+
* @param {string} b
|
|
212
|
+
*/
|
|
213
|
+
function sameWord(a, b) {
|
|
214
|
+
if (a === b || /\s/u.test(a) || /\s/u.test(b)) return false;
|
|
215
|
+
const [short, long] = a.length < b.length ? [a, b] : [b, a];
|
|
216
|
+
return short.length >= 2 && (long === `${short}s` || long === `${short}es`);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Words that phrase a query without naming anything: left out of a query of
|
|
221
|
+
* several words that nothing answers as typed (`go home` asks for `home`).
|
|
222
|
+
*/
|
|
223
|
+
const FILLER_WORDS = new Set([
|
|
224
|
+
'a',
|
|
225
|
+
'an',
|
|
226
|
+
'the',
|
|
227
|
+
'go',
|
|
228
|
+
'to',
|
|
229
|
+
'my',
|
|
230
|
+
'of',
|
|
231
|
+
'for',
|
|
232
|
+
'icon',
|
|
233
|
+
'icons',
|
|
234
|
+
]);
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* A query as typed: trimmed and lower-case, one space between words.
|
|
238
|
+
* @param {string} query
|
|
239
|
+
*/
|
|
240
|
+
function typedQuery(query) {
|
|
241
|
+
return query.trim().toLowerCase().split(/\s+/u).filter(Boolean).join(' ');
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* The query without the words that only phrase it, when it has several
|
|
246
|
+
* words and some word names something; else the query as typed.
|
|
247
|
+
* @param {string} query
|
|
248
|
+
*/
|
|
249
|
+
export function iconQuery(query) {
|
|
250
|
+
const words = typedQuery(query).split(' ').filter(Boolean);
|
|
251
|
+
const named = words.filter(word => !FILLER_WORDS.has(word));
|
|
252
|
+
return (words.length > 1 && named.length > 0 ? named : words).join(' ');
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* The matches that answer a query: the whole-word ones (a definition or an
|
|
257
|
+
* exact match, 80 and up) when there are any, else word starts (60) when
|
|
258
|
+
* there are any, else partial matches. A longer word that only starts with
|
|
259
|
+
* the query (`start` for `star`) never stands beside a whole-word answer.
|
|
260
|
+
* @template {{score: number}} T
|
|
261
|
+
* @param {T[]} ranked best first
|
|
262
|
+
* @returns {T[]}
|
|
263
|
+
*/
|
|
264
|
+
export function answeringMatches(ranked) {
|
|
265
|
+
for (const floor of [80, 60]) {
|
|
266
|
+
if (ranked.some(each => each.score >= floor)) {
|
|
267
|
+
return ranked.filter(each => each.score >= floor);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return ranked;
|
|
271
|
+
}
|
|
272
|
+
|
|
173
273
|
/**
|
|
174
274
|
* The score of one match, given which exact reading leads.
|
|
175
275
|
* @param {IconMatch} match
|
|
@@ -249,13 +349,30 @@ export function withDefinitionWords(icon, definitions, lookup) {
|
|
|
249
349
|
}
|
|
250
350
|
|
|
251
351
|
/**
|
|
252
|
-
* Every icon in `sets` that answers the query, ranked
|
|
352
|
+
* Every icon in `sets` that answers the query, ranked. The query is
|
|
353
|
+
* scored as typed; when nothing answers it with a whole word (80 and up),
|
|
354
|
+
* it is scored again without its filler words ({@link iconQuery}).
|
|
253
355
|
* @param {DiscoveredIconSet[]} sets in tie order
|
|
254
356
|
* @param {string} query
|
|
255
357
|
* @returns {IconMatchEntry[]}
|
|
256
358
|
*/
|
|
257
359
|
export function rankIcons(sets, query) {
|
|
258
|
-
const
|
|
360
|
+
const typed = typedQuery(query);
|
|
361
|
+
const asTyped = rankTerm(sets, typed);
|
|
362
|
+
if (asTyped.some(each => each.score >= 80)) return asTyped;
|
|
363
|
+
const named = iconQuery(query);
|
|
364
|
+
if (named === typed) return asTyped;
|
|
365
|
+
const withoutFiller = rankTerm(sets, named);
|
|
366
|
+
return withoutFiller.length > 0 ? withoutFiller : asTyped;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* {@link rankIcons} for one normalized query.
|
|
371
|
+
* @param {DiscoveredIconSet[]} sets
|
|
372
|
+
* @param {string} term
|
|
373
|
+
* @returns {IconMatchEntry[]}
|
|
374
|
+
*/
|
|
375
|
+
function rankTerm(sets, term) {
|
|
259
376
|
const astryx = astryxDefinitionsByName();
|
|
260
377
|
/** @type {Array<{set: DiscoveredIconSet, icon: IconSetIcon, definitions: string[], match: IconMatch, setIndex: number}>} */
|
|
261
378
|
const hits = [];
|
|
@@ -44,8 +44,9 @@ import * as path from 'node:path';
|
|
|
44
44
|
import {findInstalledPackage} from '../fs/paths.mjs';
|
|
45
45
|
import {satisfiesRange} from '../env/semver.mjs';
|
|
46
46
|
import {
|
|
47
|
-
NOTICE_FILE_RE,
|
|
48
47
|
discoverIconSetDirectory,
|
|
48
|
+
hasLicenseNotice,
|
|
49
|
+
licenseNoticeFix,
|
|
49
50
|
resolveIconModule,
|
|
50
51
|
splitSpecifier,
|
|
51
52
|
} from './icon-set-discovery.mjs';
|
|
@@ -57,6 +58,7 @@ import {
|
|
|
57
58
|
otherNamesOf,
|
|
58
59
|
generatedTypesText,
|
|
59
60
|
readGeneratedStatements,
|
|
61
|
+
generatedTypesMatch,
|
|
60
62
|
} from './icon-set-writer.mjs';
|
|
61
63
|
import {
|
|
62
64
|
exportValueKind,
|
|
@@ -67,6 +69,7 @@ import {
|
|
|
67
69
|
} from './module-exports.mjs';
|
|
68
70
|
import {astryxIconDefinitions} from './icon-definition-discovery.mjs';
|
|
69
71
|
import {rankIcons} from './icon-ranking.mjs';
|
|
72
|
+
import {shellArg} from '../text/shell-arg.mjs';
|
|
70
73
|
import {
|
|
71
74
|
issueError,
|
|
72
75
|
issueWarning,
|
|
@@ -276,16 +279,17 @@ function checkContract(set, packageName, pkg, unchecked) {
|
|
|
276
279
|
const actual = fs.existsSync(typesFile)
|
|
277
280
|
? fs.readFileSync(typesFile, 'utf-8')
|
|
278
281
|
: null;
|
|
279
|
-
// The
|
|
280
|
-
// the
|
|
281
|
-
|
|
282
|
-
text
|
|
283
|
-
.split('\n')
|
|
284
|
-
.filter(line => !line.startsWith('//'))
|
|
285
|
-
.join('\n');
|
|
282
|
+
// The declarations must match, statement by statement, however a
|
|
283
|
+
// formatter left the file; the header comment is the writer's and
|
|
284
|
+
// changes between releases.
|
|
286
285
|
if (
|
|
287
286
|
expected != null &&
|
|
288
|
-
(actual == null ||
|
|
287
|
+
(actual == null ||
|
|
288
|
+
!generatedTypesMatch(
|
|
289
|
+
actual,
|
|
290
|
+
expected,
|
|
291
|
+
/** @type {string} */ (typesRel),
|
|
292
|
+
))
|
|
289
293
|
) {
|
|
290
294
|
issues.push(
|
|
291
295
|
issueError(
|
|
@@ -359,12 +363,12 @@ function checkDefinitions(set) {
|
|
|
359
363
|
if (mapped.has(doc.name) || !doc.builtIn) continue;
|
|
360
364
|
const suggestion = suggestIcon(set, doc);
|
|
361
365
|
const hint = suggestion
|
|
362
|
-
? ` Suggested: astryx experimental icon map ${doc.name} ${suggestion.icon}.`
|
|
366
|
+
? ` Suggested: astryx experimental icon map ${doc.name} ${suggestion.icon} --set ${set.name}.`
|
|
363
367
|
: '';
|
|
364
368
|
issues.push(
|
|
365
369
|
issueError(
|
|
366
370
|
ICON_BUILTIN_DEFINITION_MISSING,
|
|
367
|
-
`${label} maps no icon to the built-in icon definition "${doc.name}" (${doc.description} Words: ${doc.words.join(', ')}.). Every set maps every built-in definition: run \`astryx experimental icon map ${doc.name} <icon id
|
|
371
|
+
`${label} maps no icon to the built-in icon definition "${doc.name}" (${doc.description} Words: ${doc.words.join(', ')}.). Every set maps every built-in definition: run \`astryx experimental icon map ${doc.name} <icon id> --set ${set.name}\` with the icon that draws it${findHint(set, doc)}.${hint}`,
|
|
368
372
|
),
|
|
369
373
|
);
|
|
370
374
|
}
|
|
@@ -382,7 +386,7 @@ function checkDefinitions(set) {
|
|
|
382
386
|
issues.push(
|
|
383
387
|
issueWarning(
|
|
384
388
|
ICON_DEFINITION_UNUSED,
|
|
385
|
-
`${label} declares the icon definition "${doc.name}", but "map" names no icon for it. Map it with \`astryx experimental icon map ${doc.name} <icon id
|
|
389
|
+
`${label} declares the icon definition "${doc.name}", but "map" names no icon for it. Map it with \`astryx experimental icon map ${doc.name} <icon id> --set ${set.name}\`, or remove definitions/${doc.name}.doc.mjs.${suggestion ? ` Suggested: astryx experimental icon map ${doc.name} ${suggestion.icon} --set ${set.name}.` : ''}`,
|
|
386
390
|
),
|
|
387
391
|
);
|
|
388
392
|
}
|
|
@@ -538,13 +542,7 @@ export function suggestedIcons(set, doc) {
|
|
|
538
542
|
...nameWords,
|
|
539
543
|
...wordIds.flatMap(id => id.split('-')).map(stem),
|
|
540
544
|
]);
|
|
541
|
-
const icons = set.data.icons
|
|
542
|
-
id: icon.id,
|
|
543
|
-
words: icon.id.split('-').map(stem),
|
|
544
|
-
raw: icon.id.split('-'),
|
|
545
|
-
// The library's other names for it, the same ones `map` accepts.
|
|
546
|
-
other: otherNamesOf(icon),
|
|
547
|
-
}));
|
|
545
|
+
const icons = suggestionIndex(set.data.icons);
|
|
548
546
|
/** How many of the definition's words an id has: more is a better fit. */
|
|
549
547
|
const fit = (/** @type {string[]} */ words) =>
|
|
550
548
|
words.filter(word => meaning.has(word)).length;
|
|
@@ -636,6 +634,29 @@ export function suggestedIcons(set, doc) {
|
|
|
636
634
|
return found.slice(0, SUGGESTIONS_PER_DEFINITION);
|
|
637
635
|
}
|
|
638
636
|
|
|
637
|
+
/**
|
|
638
|
+
* Each icon as the suggestion rules read it: its id's words as written and
|
|
639
|
+
* in singular form, and the library's other names for it (the same ones
|
|
640
|
+
* `map` accepts). Built once per list of icons, so suggesting for every
|
|
641
|
+
* definition of a large library reads each icon once.
|
|
642
|
+
* @type {WeakMap<object, Array<{id: string, words: string[], raw: string[], other: string[]}>>}
|
|
643
|
+
*/
|
|
644
|
+
const suggestionIndexes = new WeakMap();
|
|
645
|
+
|
|
646
|
+
/** @param {Array<{id: string, words?: string[]}>} list */
|
|
647
|
+
function suggestionIndex(list) {
|
|
648
|
+
const cached = suggestionIndexes.get(list);
|
|
649
|
+
if (cached) return cached;
|
|
650
|
+
const index = list.map(icon => ({
|
|
651
|
+
id: icon.id,
|
|
652
|
+
words: icon.id.split('-').map(stem),
|
|
653
|
+
raw: icon.id.split('-'),
|
|
654
|
+
other: otherNamesOf(icon),
|
|
655
|
+
}));
|
|
656
|
+
suggestionIndexes.set(list, index);
|
|
657
|
+
return index;
|
|
658
|
+
}
|
|
659
|
+
|
|
639
660
|
/**
|
|
640
661
|
* A word in its singular form, so a plural meets its singular and nothing
|
|
641
662
|
* else: `languages` meets `language`, `arrows` meets `arrow`. Only a
|
|
@@ -934,10 +955,10 @@ function findHint(set, doc) {
|
|
|
934
955
|
each => each.score >= FIND_FLOOR,
|
|
935
956
|
);
|
|
936
957
|
if (found.length > 0) {
|
|
937
|
-
return ` (icons matching "${query}": \`astryx experimental icon ${query} --set ${set.name}\`)`;
|
|
958
|
+
return ` (icons matching "${query}": \`astryx experimental icon ${shellArg(query)} --set ${set.name}\`)`;
|
|
938
959
|
}
|
|
939
960
|
}
|
|
940
|
-
return
|
|
961
|
+
return ` (no icon in the set has its name or words: pick the library icon that draws it; if the library has none, map the closest, or add your own artwork with \`astryx experimental icon add <Name> --from ./src/icons/<name>.js --definition ${doc.name} --set ${set.name}\`)`;
|
|
941
962
|
}
|
|
942
963
|
|
|
943
964
|
/**
|
|
@@ -983,14 +1004,11 @@ function checkUpstream(set, packageDir, pkg) {
|
|
|
983
1004
|
),
|
|
984
1005
|
);
|
|
985
1006
|
}
|
|
986
|
-
|
|
987
|
-
NOTICE_FILE_RE.test(name),
|
|
988
|
-
);
|
|
989
|
-
if (set.notices.length === 0 && rootNotices.length === 0) {
|
|
1007
|
+
if (!hasLicenseNotice(set.dir) && !hasLicenseNotice(packageDir)) {
|
|
990
1008
|
issues.push(
|
|
991
1009
|
issueWarning(
|
|
992
1010
|
ICON_LICENSE_NOTICE_MISSING,
|
|
993
|
-
`${label} is generated from ${source.package} but ships no license notice.
|
|
1011
|
+
`${label} is generated from ${source.package}@${source.version} but ships no license notice. ${licenseNoticeFix(path.relative(packageDir, set.dir).split(path.sep).join('/'), `${source.package}@${source.version}`)} If the library ships a LICENSE or NOTICE file, copy that file there instead.`,
|
|
994
1012
|
),
|
|
995
1013
|
);
|
|
996
1014
|
}
|
|
@@ -1006,12 +1024,3 @@ function safeSatisfies(version, range) {
|
|
|
1006
1024
|
return true;
|
|
1007
1025
|
}
|
|
1008
1026
|
}
|
|
1009
|
-
|
|
1010
|
-
/** @param {string} dir */
|
|
1011
|
-
function safeList(dir) {
|
|
1012
|
-
try {
|
|
1013
|
-
return fs.readdirSync(dir);
|
|
1014
|
-
} catch {
|
|
1015
|
-
return [];
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* What to add when a set wraps a library and has no license notice: a
|
|
6
|
+
* NOTICE file in the set directory, with the file names that count. The
|
|
7
|
+
* CLI never writes it, because the license text is the author's to state.
|
|
8
|
+
* @param {string} setDir the set directory, from the package root
|
|
9
|
+
* @param {string} library the library as `name@version`
|
|
10
|
+
*/
|
|
11
|
+
export function licenseNoticeFix(setDir: string, library: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Whether a directory has a license or notice file ({@link NOTICE_FILE_RE}).
|
|
14
|
+
* @param {string} dir
|
|
15
|
+
*/
|
|
16
|
+
export function hasLicenseNotice(dir: string): boolean;
|
|
4
17
|
/**
|
|
5
18
|
* One installed icon set: its descriptor, its data, and where it came from.
|
|
6
19
|
* @typedef {object} DiscoveredIconSet
|
|
@@ -43,6 +43,31 @@ const SET_NAME_RE = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;
|
|
|
43
43
|
/** A license or notice file a set ships beside its data (FR15). */
|
|
44
44
|
export const NOTICE_FILE_RE = /^(?:licen[cs]e|notice|copying)(?:[.-].*)?$/iu;
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* What to add when a set wraps a library and has no license notice: a
|
|
48
|
+
* NOTICE file in the set directory, with the file names that count. The
|
|
49
|
+
* CLI never writes it, because the license text is the author's to state.
|
|
50
|
+
* @param {string} setDir the set directory, from the package root
|
|
51
|
+
* @param {string} library the library as `name@version`
|
|
52
|
+
*/
|
|
53
|
+
export function licenseNoticeFix(setDir, library) {
|
|
54
|
+
return `Add a NOTICE (or LICENSE) file to ${setDir} that names ${library} and its license: \`${setDir}/NOTICE\`. A file named LICENSE, LICENCE, NOTICE, or COPYING, in any case and with an optional suffix such as NOTICE.md or LICENSE-MIT, counts in the set directory or the package root.`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Whether a directory has a license or notice file ({@link NOTICE_FILE_RE}).
|
|
59
|
+
* @param {string} dir
|
|
60
|
+
*/
|
|
61
|
+
export function hasLicenseNotice(dir) {
|
|
62
|
+
try {
|
|
63
|
+
return fs
|
|
64
|
+
.readdirSync(dir, {withFileTypes: true})
|
|
65
|
+
.some(file => file.isFile() && NOTICE_FILE_RE.test(file.name));
|
|
66
|
+
} catch {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
46
71
|
/**
|
|
47
72
|
* One installed icon set: its descriptor, its data, and where it came from.
|
|
48
73
|
* @typedef {object} DiscoveredIconSet
|