@astryxdesign/cli 0.7.13 → 0.7.14-canary.d08ce65
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/__fixtures__/resolutions/modules.txt +1 -1
- package/api/doctor/doctor.mjs +3 -7
- package/api/experimental.d.mts +2 -0
- package/api/experimental.mjs +10 -0
- package/api/icon/_adapter.d.mts +10 -0
- package/api/icon/_adapter.mjs +31 -2
- package/api/icon/_authoring.d.mts +2 -1
- package/api/icon/_authoring.mjs +91 -6
- package/api/icon/_options.mjs +1 -0
- package/api/icon/_records.d.mts +18 -0
- package/api/icon/_records.mjs +26 -0
- package/api/icon/add/add.mjs +7 -1
- package/api/icon/definitions/definitions.d.mts +12 -0
- package/api/icon/definitions/definitions.mjs +83 -0
- package/api/icon/icon.doc.mjs +5 -4
- package/api/icon/icon.mjs +5 -16
- package/api/icon/icon.type.d.mts +29 -2
- package/api/icon/icon.type.mjs +17 -3
- package/api/icon/iconAdd.doc.mjs +1 -1
- package/api/icon/iconMap.doc.mjs +2 -2
- package/api/icon/iconNewSet.doc.mjs +8 -2
- package/api/icon/map/map.mjs +21 -2
- package/api/icon/new-set/new-set.mjs +14 -2
- package/api/icon/search/search.mjs +2 -15
- package/api/icon/use/use.mjs +4 -3
- package/api/integration/validate-integration.mjs +6 -1
- package/api/integration/validate-integration.type.d.mts +12 -0
- package/api/integration/validate-integration.type.mjs +5 -0
- package/api/theme-edit/_adapter.d.mts +96 -0
- package/api/theme-edit/_adapter.mjs +1039 -0
- package/api/theme-edit/_catalog.d.mts +59 -0
- package/api/theme-edit/_catalog.mjs +564 -0
- package/api/theme-edit/_check.d.mts +49 -0
- package/api/theme-edit/_check.mjs +842 -0
- package/api/theme-edit/_color.d.mts +35 -0
- package/api/theme-edit/_color.mjs +125 -0
- package/api/theme-edit/_compiler.d.mts +61 -0
- package/api/theme-edit/_compiler.mjs +522 -0
- package/api/theme-edit/_css-properties.d.mts +10 -0
- package/api/theme-edit/_css-properties.mjs +556 -0
- package/api/theme-edit/_parts.d.mts +111 -0
- package/api/theme-edit/_parts.mjs +409 -0
- package/api/theme-edit/_png.d.mts +40 -0
- package/api/theme-edit/_png.mjs +187 -0
- package/api/theme-edit/_preview.d.mts +86 -0
- package/api/theme-edit/_preview.mjs +564 -0
- package/api/theme-edit/_project.d.mts +83 -0
- package/api/theme-edit/_project.mjs +289 -0
- package/api/theme-edit/_settings.d.mts +222 -0
- package/api/theme-edit/_settings.mjs +848 -0
- package/api/theme-edit/_tables.d.mts +130 -0
- package/api/theme-edit/_tables.mjs +697 -0
- package/api/theme-edit/theme-edit.d.mts +89 -0
- package/api/theme-edit/theme-edit.mjs +119 -0
- package/api/theme-edit/theme-edit.type.d.mts +270 -0
- package/api/theme-edit/theme-edit.type.mjs +155 -0
- package/api/theme-edit/themeEditExplain.doc.d.mts +6 -0
- package/api/theme-edit/themeEditExplain.doc.mjs +88 -0
- package/api/theme-edit/themeEditNew.doc.d.mts +6 -0
- package/api/theme-edit/themeEditNew.doc.mjs +89 -0
- package/api/theme-edit/themeEditPreview.doc.d.mts +6 -0
- package/api/theme-edit/themeEditPreview.doc.mjs +96 -0
- package/api/theme-edit/themeEditReset.doc.d.mts +6 -0
- package/api/theme-edit/themeEditReset.doc.mjs +161 -0
- package/api/theme-edit/themeEditSet.doc.d.mts +6 -0
- package/api/theme-edit/themeEditSet.doc.mjs +165 -0
- package/api/theme-edit/themeEditShow.doc.d.mts +6 -0
- package/api/theme-edit/themeEditShow.doc.mjs +86 -0
- package/api/theme-edit/themeEditUndo.doc.d.mts +6 -0
- package/api/theme-edit/themeEditUndo.doc.mjs +80 -0
- package/assets/docs/color.doc.mjs +5 -5
- package/assets/docs/tree/icon-sets.doc.mjs +6 -2
- package/assets/docs/tree/tokens-border.doc.mjs +1 -1
- package/assets/docs/tree/tokens-color.doc.mjs +2 -2
- package/assets/docs/tree/tokens-data.doc.mjs +2 -2
- package/assets/docs/tree/tokens-duration.doc.mjs +1 -1
- package/assets/docs/tree/tokens-ease.doc.mjs +1 -1
- package/assets/docs/tree/tokens-focus.doc.mjs +1 -1
- package/assets/docs/tree/tokens-font-weight.doc.mjs +1 -1
- package/assets/docs/tree/tokens-radius.doc.mjs +1 -1
- package/assets/docs/tree/tokens-shadow.doc.mjs +1 -1
- package/assets/docs/tree/tokens-size.doc.mjs +1 -1
- package/assets/docs/tree/tokens-spacing.doc.mjs +1 -1
- package/assets/docs/tree/tokens-syntax.doc.mjs +1 -1
- package/assets/docs/tree/tokens-text-size.doc.mjs +1 -1
- package/assets/docs/tree/tokens-type-scale.doc.mjs +1 -1
- package/assets/docs/tree/tokens-typography.doc.mjs +1 -1
- package/assets/icons/definitions/bank.doc.mjs +1 -1
- package/assets/icons/definitions/save.doc.mjs +1 -1
- package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.doc.mjs +2 -1
- package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider02Overrides.doc.mjs +2 -1
- package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider03RtlDirection.doc.mjs +2 -1
- package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider04Calendar.doc.mjs +2 -1
- package/assets/templates/blocks/components/Text/useTruncationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Text/useTruncationHookUsage.tsx +112 -0
- package/authoring/doctypes/_schema.d.mts +1 -0
- package/authoring/doctypes/_schema.mjs +1 -0
- package/authoring/doctypes/command/command.doc.mjs +7 -0
- package/authoring/doctypes/command/type.ts +3 -0
- package/authoring/doctypes/icon-set/parse.d.mts +7 -0
- package/authoring/doctypes/icon-set/parse.mjs +18 -8
- package/clients/cli/commands/doctor.mjs +33 -3
- package/clients/cli/commands/experimental/icon.mjs +67 -14
- package/clients/cli/commands/experimental/index.mjs +2 -0
- package/clients/cli/commands/experimental/theme.mjs +542 -0
- package/clients/cli/commands/experimental-icon-new-set.doc.mjs +7 -1
- package/clients/cli/commands/experimental-icon.doc.mjs +3 -2
- package/clients/cli/commands/experimental-theme-add.doc.mjs +78 -0
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +97 -0
- package/clients/cli/commands/experimental-theme-eject.doc.mjs +71 -0
- package/clients/cli/commands/experimental-theme-explain.doc.mjs +84 -0
- package/clients/cli/commands/experimental-theme-list.doc.mjs +49 -0
- package/clients/cli/commands/experimental-theme-new.doc.mjs +66 -0
- package/clients/cli/commands/experimental-theme-palette-generate.doc.mjs +73 -0
- package/clients/cli/commands/experimental-theme-palette.doc.mjs +37 -0
- package/clients/cli/commands/experimental-theme-preview.doc.mjs +76 -0
- package/clients/cli/commands/experimental-theme-remove.doc.mjs +55 -0
- package/clients/cli/commands/experimental-theme-reset.doc.mjs +103 -0
- package/clients/cli/commands/experimental-theme-set.doc.mjs +121 -0
- package/clients/cli/commands/experimental-theme-show.doc.mjs +66 -0
- package/clients/cli/commands/experimental-theme-targets.doc.mjs +61 -0
- package/clients/cli/commands/experimental-theme-template.doc.mjs +61 -0
- package/clients/cli/commands/experimental-theme-undo.doc.mjs +55 -0
- package/clients/cli/commands/experimental-theme-use.doc.mjs +55 -0
- package/clients/cli/commands/experimental-theme.doc.mjs +66 -0
- package/clients/cli/commands/experimental.doc.mjs +10 -3
- package/clients/cli/commands/theme.mjs +101 -34
- package/clients/cli/index.mjs +16 -0
- package/clients/cli/lib/define-command.mjs +3 -0
- package/foundation/discovery/icon-set-checks.d.mts +16 -1
- package/foundation/discovery/icon-set-checks.mjs +68 -7
- package/foundation/discovery/icon-set-discovery.d.mts +21 -6
- package/foundation/discovery/icon-set-discovery.mjs +17 -8
- package/foundation/discovery/template-icon-meanings.d.mts +39 -0
- package/foundation/discovery/template-icon-meanings.mjs +95 -0
- package/foundation/discovery/theming-targets.d.mts +6 -0
- package/foundation/discovery/theming-targets.mjs +33 -0
- package/foundation/response/error-codes.d.mts +12 -1
- package/foundation/response/error-codes.doc.mjs +66 -0
- package/foundation/response/error-codes.mjs +55 -0
- package/foundation/response/response-types.doc.mjs +43 -0
- package/foundation/text/template-meanings-line.d.mts +16 -0
- package/foundation/text/template-meanings-line.mjs +37 -0
- package/foundation/xle/browser.d.mts +2 -2
- package/package.json +6 -6
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file `astryx experimental theme` — make and change a theme one checked
|
|
5
|
+
* change at a time. Experimental (spec:AST-017 FR27): it is registered only
|
|
6
|
+
* under the `experimental` group.
|
|
7
|
+
*
|
|
8
|
+
* The command surface comes from the colocated CommandDocs via
|
|
9
|
+
* `defineCommand`; this file reads flags, calls the theme-edit API, and
|
|
10
|
+
* prints its receipt.
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* astryx experimental theme new brand --like neutral
|
|
14
|
+
* astryx experimental theme set brand corners pill
|
|
15
|
+
* astryx experimental theme explain "white text in the banner"
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import {getCliInvocation} from '../../../../foundation/env/package-manager.mjs';
|
|
19
|
+
import {jsonOut} from '../../../../foundation/response/json.mjs';
|
|
20
|
+
import {NO_RESULT_SET, resultSet} from '../../../../foundation/debug/index.mjs';
|
|
21
|
+
import {ERROR_CODES} from '../../../../foundation/response/error-codes.mjs';
|
|
22
|
+
import {emit, text} from '../../formatters/index.mjs';
|
|
23
|
+
import {cliError} from '../../lib/cli-error.mjs';
|
|
24
|
+
import {defineCommand} from '../../lib/define-command.mjs';
|
|
25
|
+
import {
|
|
26
|
+
themeEditExplain,
|
|
27
|
+
themeEditNew,
|
|
28
|
+
themeEditPreview,
|
|
29
|
+
themeEditReset,
|
|
30
|
+
themeEditSet,
|
|
31
|
+
themeEditShow,
|
|
32
|
+
themeEditUndo,
|
|
33
|
+
} from '../../../../api/theme-edit/theme-edit.mjs';
|
|
34
|
+
import {registerThemeSubcommands} from '../theme.mjs';
|
|
35
|
+
import {doc as groupDoc} from '../experimental-theme.doc.mjs';
|
|
36
|
+
import {doc as newDoc} from '../experimental-theme-new.doc.mjs';
|
|
37
|
+
import {doc as setDoc} from '../experimental-theme-set.doc.mjs';
|
|
38
|
+
import {doc as resetDoc} from '../experimental-theme-reset.doc.mjs';
|
|
39
|
+
import {doc as showDoc} from '../experimental-theme-show.doc.mjs';
|
|
40
|
+
import {doc as undoDoc} from '../experimental-theme-undo.doc.mjs';
|
|
41
|
+
import {doc as previewDoc} from '../experimental-theme-preview.doc.mjs';
|
|
42
|
+
import {doc as explainDoc} from '../experimental-theme-explain.doc.mjs';
|
|
43
|
+
import {doc as paletteDoc} from '../experimental-theme-palette.doc.mjs';
|
|
44
|
+
import {doc as paletteGenerateDoc} from '../experimental-theme-palette-generate.doc.mjs';
|
|
45
|
+
import {doc as compileDoc} from '../experimental-theme-compile.doc.mjs';
|
|
46
|
+
import {doc as listDoc} from '../experimental-theme-list.doc.mjs';
|
|
47
|
+
import {doc as addDoc} from '../experimental-theme-add.doc.mjs';
|
|
48
|
+
import {doc as removeDoc} from '../experimental-theme-remove.doc.mjs';
|
|
49
|
+
import {doc as useDoc} from '../experimental-theme-use.doc.mjs';
|
|
50
|
+
import {doc as ejectDoc} from '../experimental-theme-eject.doc.mjs';
|
|
51
|
+
import {doc as templateDoc} from '../experimental-theme-template.doc.mjs';
|
|
52
|
+
import {doc as targetsDoc} from '../experimental-theme-targets.doc.mjs';
|
|
53
|
+
import {doc as newFn} from '../../../../api/theme-edit/themeEditNew.doc.mjs';
|
|
54
|
+
import {doc as setFn} from '../../../../api/theme-edit/themeEditSet.doc.mjs';
|
|
55
|
+
import {doc as resetFn} from '../../../../api/theme-edit/themeEditReset.doc.mjs';
|
|
56
|
+
import {doc as showFn} from '../../../../api/theme-edit/themeEditShow.doc.mjs';
|
|
57
|
+
import {doc as undoFn} from '../../../../api/theme-edit/themeEditUndo.doc.mjs';
|
|
58
|
+
import {doc as previewFn} from '../../../../api/theme-edit/themeEditPreview.doc.mjs';
|
|
59
|
+
import {doc as explainFn} from '../../../../api/theme-edit/themeEditExplain.doc.mjs';
|
|
60
|
+
|
|
61
|
+
const PREFIX = 'astryx experimental theme';
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Commands in a line, with the run prefix this project uses.
|
|
65
|
+
* @param {string} line
|
|
66
|
+
*/
|
|
67
|
+
const cmd = line =>
|
|
68
|
+
line.split(PREFIX).join(`${getCliInvocation()} experimental theme`);
|
|
69
|
+
|
|
70
|
+
/** Print lines as one block. @param {string[]} lines */
|
|
71
|
+
const print = lines => emit(text(lines.map(cmd).join('\n')));
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Run one API call: errors become the CLI error envelope, results go to
|
|
75
|
+
* JSON or to `render`.
|
|
76
|
+
* @template T
|
|
77
|
+
* @param {import('commander').Command} program
|
|
78
|
+
* @param {() => Promise<T>} call
|
|
79
|
+
* @param {(result: T) => string[]} render
|
|
80
|
+
* @param {(result: T) => import('../../../../foundation/debug/command-result.mjs').CommandResult} [answer]
|
|
81
|
+
*/
|
|
82
|
+
async function run(program, call, render, answer) {
|
|
83
|
+
const json = program.opts().json || false;
|
|
84
|
+
/** @type {T} */
|
|
85
|
+
let result;
|
|
86
|
+
try {
|
|
87
|
+
result = await call();
|
|
88
|
+
} catch (e) {
|
|
89
|
+
const err = /** @type {import('../../../../api/error.mjs').AstryxError} */ (
|
|
90
|
+
e
|
|
91
|
+
);
|
|
92
|
+
return cliError(err.message, {
|
|
93
|
+
suggestions: err.suggestions,
|
|
94
|
+
code: err.code ?? ERROR_CODES.ERR_UNKNOWN,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
const answered = answer
|
|
98
|
+
? answer(result)
|
|
99
|
+
: resultSet({count: 1, resultKind: 'mixed', directMatch: true});
|
|
100
|
+
if (json) {
|
|
101
|
+
jsonOut(/** @type {any} */ (result));
|
|
102
|
+
return answered;
|
|
103
|
+
}
|
|
104
|
+
print(render(result));
|
|
105
|
+
return answered;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** @param {{pictures: string[], pictureProblem: string | null}} d */
|
|
109
|
+
const pictureLines = d => [
|
|
110
|
+
...(d.pictures.length ? [` pictures: ${d.pictures.join(', ')}`] : []),
|
|
111
|
+
...(d.pictureProblem ? [` pictures: none. ${d.pictureProblem}`] : []),
|
|
112
|
+
];
|
|
113
|
+
|
|
114
|
+
/** @param {import('../../../../api/theme-edit/theme-edit.type.mjs').ThemeEditSetting} s */
|
|
115
|
+
function describe(s) {
|
|
116
|
+
const where = s.on
|
|
117
|
+
? ` on ${s.on}${s.only ? ' only' : ''}${s.when ? ` when ${s.when}` : ''}${s.state ? ` :${s.state}` : ''}`
|
|
118
|
+
: ' (whole theme)';
|
|
119
|
+
return `${s.thing} = ${s.value}${where}${s.mode ? ` [${s.mode} only]` : ''}`;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* The flags of a change, from Commander's options.
|
|
124
|
+
* @param {any} o
|
|
125
|
+
*/
|
|
126
|
+
const changeOptions = o => ({
|
|
127
|
+
cwd: process.cwd(),
|
|
128
|
+
on: o.on,
|
|
129
|
+
when: o.when,
|
|
130
|
+
state: o.state,
|
|
131
|
+
mode: o.mode,
|
|
132
|
+
only: o.only ?? false,
|
|
133
|
+
png: o.png ?? false,
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* The receipt of a set or unset.
|
|
138
|
+
* @param {import('../../../../api/theme-edit/theme-edit.type.mjs').ThemeEditChangeResponse} r
|
|
139
|
+
*/
|
|
140
|
+
function changeLines(r) {
|
|
141
|
+
const d = r.data;
|
|
142
|
+
const s = d.setting;
|
|
143
|
+
/** @type {string[]} */
|
|
144
|
+
const lines = [];
|
|
145
|
+
if (d.was != null)
|
|
146
|
+
lines.push(`[ok] ${d.theme}: ${s.thing} ${d.was} -> ${s.value}`);
|
|
147
|
+
else
|
|
148
|
+
lines.push(
|
|
149
|
+
`[ok] ${d.theme}: ${d.action === 'set' ? describe(s) : `reset ${describe(s)} to the base theme's value`}${d.replaced ? ` (was ${d.replaced.value})` : ''}`,
|
|
150
|
+
);
|
|
151
|
+
if (d.family)
|
|
152
|
+
lines.push(
|
|
153
|
+
` applied to the ${d.family.name} family: ${d.family.members.join(', ')}${d.family.onlyHint && s.on && !s.only ? ` (add --only to style just ${s.on})` : ''}`,
|
|
154
|
+
);
|
|
155
|
+
for (const n of d.notes) lines.push(` note: ${n}`);
|
|
156
|
+
if (d.changedTokens.length) {
|
|
157
|
+
lines.push(
|
|
158
|
+
` resolved changes (${d.changedTokens.length}):`,
|
|
159
|
+
...d.changedTokens.slice(0, 8).map(c => ` ${c}`),
|
|
160
|
+
);
|
|
161
|
+
if (d.changedTokens.length > 8)
|
|
162
|
+
lines.push(` ... ${d.changedTokens.length - 8} more (--json for all)`);
|
|
163
|
+
}
|
|
164
|
+
if (d.styled.length) {
|
|
165
|
+
lines.push(
|
|
166
|
+
` styled (${d.styled.length}):`,
|
|
167
|
+
...d.styled.slice(0, 8).map(c => ` ${c}`),
|
|
168
|
+
);
|
|
169
|
+
if (d.styled.length > 8)
|
|
170
|
+
lines.push(` ... ${d.styled.length - 8} more (--json for all)`);
|
|
171
|
+
}
|
|
172
|
+
if (!d.changedTokens.length && !d.styled.length && d.was == null)
|
|
173
|
+
lines.push(' no visible change: the theme already looked this way');
|
|
174
|
+
for (const k of d.kept)
|
|
175
|
+
lines.push(` kept (a part setting beats the whole-theme dial): ${k}`);
|
|
176
|
+
if (d.lifted.length) {
|
|
177
|
+
const keys = [
|
|
178
|
+
...new Set(d.lifted.map(x => x.split(' ').slice(0, 2).join(' '))),
|
|
179
|
+
];
|
|
180
|
+
lines.push(
|
|
181
|
+
` also applied to ${keys.slice(0, 6).join(', ')}${keys.length > 6 ? ` and ${keys.length - 6} more` : ''}: the base theme styles those separately, so the plain setting alone would lose there`,
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
for (const w of d.warnings) lines.push(` build: ${w}`);
|
|
185
|
+
for (const p of d.problems) lines.push(` contrast: ${p}`);
|
|
186
|
+
lines.push(` preview: ${d.preview}`, ...pictureLines(d));
|
|
187
|
+
return lines;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* The text of an explain answer, by its kind.
|
|
192
|
+
* @param {any} d
|
|
193
|
+
* @returns {string[]}
|
|
194
|
+
*/
|
|
195
|
+
function explainLines(d) {
|
|
196
|
+
if (d.kind === 'question') {
|
|
197
|
+
if (!d.results.length) {
|
|
198
|
+
return [
|
|
199
|
+
`No match for "${d.subject}". Name the part (header, nav links, card, button, banner, input...) and what to change (text color, background, gradient, corners, border, shadow, spacing, bold). Or: ${PREFIX} explain --list parts`,
|
|
200
|
+
];
|
|
201
|
+
}
|
|
202
|
+
return [
|
|
203
|
+
`"${d.subject}" -> parts: ${d.understood.parts.join(', ') || 'whole theme'}; aspects: ${d.understood.aspects.join(', ') || '?'}`,
|
|
204
|
+
...d.results.flatMap((/** @type {any} */ x) => [
|
|
205
|
+
` ${x.text}`,
|
|
206
|
+
...x.commands.map((/** @type {string} */ c) => ` ${c}`),
|
|
207
|
+
]),
|
|
208
|
+
];
|
|
209
|
+
}
|
|
210
|
+
if (d.kind === 'aspect')
|
|
211
|
+
return [
|
|
212
|
+
`${d.subject} for the whole theme:`,
|
|
213
|
+
...d.results.flatMap((/** @type {any} */ x) => [
|
|
214
|
+
` ${x.text}`,
|
|
215
|
+
...x.commands.map((/** @type {string} */ c) => ` ${c}`),
|
|
216
|
+
]),
|
|
217
|
+
];
|
|
218
|
+
if (d.kind === 'picture') {
|
|
219
|
+
if (d.points)
|
|
220
|
+
return [
|
|
221
|
+
`colors in ${d.file} (${d.width}x${d.height}) at:`,
|
|
222
|
+
...d.points.map(
|
|
223
|
+
(/** @type {any} */ c) =>
|
|
224
|
+
` (${c.at}) ${c.color ?? 'outside the picture'}`,
|
|
225
|
+
),
|
|
226
|
+
];
|
|
227
|
+
return [
|
|
228
|
+
`main colors in ${d.file} (${d.width}x${d.height}; share of the picture, where):`,
|
|
229
|
+
...d.colors.map(
|
|
230
|
+
(/** @type {any} */ c) => ` ${c.color} ${c.share}% ${c.where}`,
|
|
231
|
+
),
|
|
232
|
+
];
|
|
233
|
+
}
|
|
234
|
+
if (d.kind === 'list') {
|
|
235
|
+
const items = /** @type {any[]} */ (d.items);
|
|
236
|
+
if (d.list === 'dials')
|
|
237
|
+
return items.flatMap(x => [
|
|
238
|
+
`${x.name}: ${x.values}`,
|
|
239
|
+
` ${x.help}`,
|
|
240
|
+
...x.examples.map((/** @type {string} */ e) => ` e.g. ${e}`),
|
|
241
|
+
]);
|
|
242
|
+
if (d.list === 'families')
|
|
243
|
+
return items.map(
|
|
244
|
+
x =>
|
|
245
|
+
`${x.name}: ${x.members.join(', ')}${x.spreads ? ' (styling one styles all; --only to opt out)' : ' (--on the family styles all)'}`,
|
|
246
|
+
);
|
|
247
|
+
if (d.list === 'properties')
|
|
248
|
+
return [
|
|
249
|
+
...items.map(x => x.name),
|
|
250
|
+
...(d.common
|
|
251
|
+
? [
|
|
252
|
+
`(the common ones; any standard CSS property works: ${PREFIX} explain <filter> --list properties)`,
|
|
253
|
+
]
|
|
254
|
+
: []),
|
|
255
|
+
];
|
|
256
|
+
if (d.list === 'tokens')
|
|
257
|
+
return items.map(
|
|
258
|
+
x =>
|
|
259
|
+
`${x.name} [${x.type}] default ${x.default}; read by ${x.readBy} parts`,
|
|
260
|
+
);
|
|
261
|
+
return [
|
|
262
|
+
...items.map(
|
|
263
|
+
x =>
|
|
264
|
+
`${x.name} (${x.component})${x.family ? ` [${x.family}]` : ''}${Object.entries(
|
|
265
|
+
/** @type {Record<string, string[]>} */ (x.variants),
|
|
266
|
+
)
|
|
267
|
+
.map(
|
|
268
|
+
([p, v]) => ` --when ${p}:${v.length ? v.join('|') : '<value>'}`,
|
|
269
|
+
)
|
|
270
|
+
.join(
|
|
271
|
+
'',
|
|
272
|
+
)}${x.states.length ? ` --state ${x.states.join('|')}` : ''}${x.recorded ? '' : ' (no compiled record: changes on it are not checked)'}`,
|
|
273
|
+
),
|
|
274
|
+
`What a part reads: ${PREFIX} explain <part>`,
|
|
275
|
+
];
|
|
276
|
+
}
|
|
277
|
+
return d.lines;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Help that explains exactly what a subcommand does: its whole description
|
|
282
|
+
* under the usage line, while the group's list keeps the one-line summary.
|
|
283
|
+
* Token names start with `--`, so set and unset take unknown options as
|
|
284
|
+
* operands.
|
|
285
|
+
* @param {import('commander').Command} c
|
|
286
|
+
* @param {import('@astryxdesign/cli/authoring').CommandDoc} doc
|
|
287
|
+
* @param {{tokens?: boolean}} [options]
|
|
288
|
+
*/
|
|
289
|
+
function explained(c, doc, {tokens = false} = {}) {
|
|
290
|
+
c.summary(c.description());
|
|
291
|
+
c.description(`[experimental] ${doc.description ?? doc.summary ?? ''}`);
|
|
292
|
+
if (tokens) c.allowUnknownOption(true);
|
|
293
|
+
return c;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Register `theme` and its subcommands under the `experimental` group.
|
|
298
|
+
* @param {import('commander').Command} group the `experimental` command
|
|
299
|
+
* @param {import('commander').Command} program the root program
|
|
300
|
+
*/
|
|
301
|
+
export function registerExperimentalTheme(group, program) {
|
|
302
|
+
/** @type {import('commander').Command} */
|
|
303
|
+
const theme = defineCommand(group, groupDoc, {
|
|
304
|
+
action: (
|
|
305
|
+
/** @type {unknown} */ _options,
|
|
306
|
+
/** @type {import('commander').Command} */ c,
|
|
307
|
+
) => {
|
|
308
|
+
const extras = c?.args ?? [];
|
|
309
|
+
if (extras.length > 0) {
|
|
310
|
+
return cliError(
|
|
311
|
+
`unknown subcommand 'experimental theme ${String(extras[0])}'`,
|
|
312
|
+
{
|
|
313
|
+
suggestions: (theme.commands ?? []).map(command => ({
|
|
314
|
+
name: command.name(),
|
|
315
|
+
reason: 'available subcommand',
|
|
316
|
+
})),
|
|
317
|
+
code: ERROR_CODES.ERR_UNKNOWN_SUBCOMMAND,
|
|
318
|
+
},
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
theme.help();
|
|
322
|
+
return NO_RESULT_SET;
|
|
323
|
+
},
|
|
324
|
+
});
|
|
325
|
+
explained(theme, groupDoc);
|
|
326
|
+
theme.addHelpText(
|
|
327
|
+
'after',
|
|
328
|
+
`\nComponent style overrides:\n` +
|
|
329
|
+
` ${getCliInvocation()} experimental theme targets Every themeable class, with its props and states\n` +
|
|
330
|
+
` ${getCliInvocation()} experimental theme explain <part> What one part reads, and the commands that change it\n` +
|
|
331
|
+
` ${getCliInvocation()} component <Name> One component's theming table\n`,
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
explained(
|
|
335
|
+
defineCommand(theme, newDoc, {
|
|
336
|
+
fn: newFn,
|
|
337
|
+
action: (/** @type {string} */ name, /** @type {any} */ o) =>
|
|
338
|
+
run(
|
|
339
|
+
program,
|
|
340
|
+
() =>
|
|
341
|
+
themeEditNew(name, {
|
|
342
|
+
cwd: process.cwd(),
|
|
343
|
+
like: o.like,
|
|
344
|
+
png: o.png ?? false,
|
|
345
|
+
}),
|
|
346
|
+
r => [
|
|
347
|
+
`[ok] made theme "${r.data.theme}"${r.data.like ? ` on top of ${r.data.like}` : ''}: ${r.data.files.settings} (owned by this command) -> ${r.data.files.source} -> ${r.data.files.css}`,
|
|
348
|
+
...r.data.problems.map(p => ` contrast: ${p}`),
|
|
349
|
+
` preview: ${r.data.preview}`,
|
|
350
|
+
...pictureLines(r.data),
|
|
351
|
+
` next: ${PREFIX} set ${r.data.theme} <thing> <value> (${PREFIX} explain "<what you want>")`,
|
|
352
|
+
],
|
|
353
|
+
),
|
|
354
|
+
}),
|
|
355
|
+
newDoc,
|
|
356
|
+
);
|
|
357
|
+
|
|
358
|
+
explained(
|
|
359
|
+
defineCommand(theme, setDoc, {
|
|
360
|
+
fn: setFn,
|
|
361
|
+
action: (
|
|
362
|
+
/** @type {string} */ name,
|
|
363
|
+
/** @type {string} */ thing,
|
|
364
|
+
/** @type {string[]} */ value,
|
|
365
|
+
/** @type {any} */ o,
|
|
366
|
+
) =>
|
|
367
|
+
run(
|
|
368
|
+
program,
|
|
369
|
+
() => themeEditSet(name, thing, value.join(' '), changeOptions(o)),
|
|
370
|
+
changeLines,
|
|
371
|
+
),
|
|
372
|
+
}),
|
|
373
|
+
setDoc,
|
|
374
|
+
{tokens: true},
|
|
375
|
+
);
|
|
376
|
+
|
|
377
|
+
explained(
|
|
378
|
+
defineCommand(theme, resetDoc, {
|
|
379
|
+
fn: resetFn,
|
|
380
|
+
action: (
|
|
381
|
+
/** @type {string} */ name,
|
|
382
|
+
/** @type {string} */ thing,
|
|
383
|
+
/** @type {string | undefined} */ which,
|
|
384
|
+
/** @type {any} */ o,
|
|
385
|
+
) =>
|
|
386
|
+
run(
|
|
387
|
+
program,
|
|
388
|
+
() =>
|
|
389
|
+
themeEditReset(name, thing, {...changeOptions(o), value: which}),
|
|
390
|
+
changeLines,
|
|
391
|
+
),
|
|
392
|
+
}),
|
|
393
|
+
resetDoc,
|
|
394
|
+
{tokens: true},
|
|
395
|
+
);
|
|
396
|
+
|
|
397
|
+
explained(
|
|
398
|
+
defineCommand(theme, showDoc, {
|
|
399
|
+
fn: showFn,
|
|
400
|
+
action: (/** @type {string} */ name, /** @type {any} */ o) =>
|
|
401
|
+
run(
|
|
402
|
+
program,
|
|
403
|
+
() =>
|
|
404
|
+
themeEditShow(name, {
|
|
405
|
+
cwd: process.cwd(),
|
|
406
|
+
png: o.png ?? false,
|
|
407
|
+
group: o.group,
|
|
408
|
+
}),
|
|
409
|
+
r => {
|
|
410
|
+
const d = r.data;
|
|
411
|
+
const modes =
|
|
412
|
+
d.mode === 'light-only'
|
|
413
|
+
? ['light']
|
|
414
|
+
: d.mode === 'dark-only'
|
|
415
|
+
? ['dark']
|
|
416
|
+
: ['light', 'dark'];
|
|
417
|
+
return [
|
|
418
|
+
`theme "${d.theme}"${d.like ? ` (on top of ${d.like})` : ''}, mode ${d.mode}, ${d.settings.length} settings:`,
|
|
419
|
+
...d.settings.map(
|
|
420
|
+
(s, i) =>
|
|
421
|
+
` ${i + 1}. [${s.source}] ${describe(s)}${s.parts.length > 1 ? ` -> ${s.parts.length} parts` : ''}`,
|
|
422
|
+
),
|
|
423
|
+
`key values (${modes.join(' / ')}):`,
|
|
424
|
+
...Object.entries(d.resolved).map(
|
|
425
|
+
([k, v]) =>
|
|
426
|
+
` ${k}: ${modes.map(m => v[m] ?? '-').join(' / ')}`,
|
|
427
|
+
),
|
|
428
|
+
...(d.problems.length
|
|
429
|
+
? d.problems.map(p => `contrast: ${p}`)
|
|
430
|
+
: ['problems: none caused by this theme']),
|
|
431
|
+
...d.notes.map(n => `note: ${n}`),
|
|
432
|
+
`preview (sample app page): ${d.preview}`,
|
|
433
|
+
`every component (theme-building page, ${d.sheetComponents} components): ${d.sheet}`,
|
|
434
|
+
...d.skipped.map(x => ` left out: ${x}`),
|
|
435
|
+
...pictureLines(d),
|
|
436
|
+
];
|
|
437
|
+
},
|
|
438
|
+
),
|
|
439
|
+
}),
|
|
440
|
+
showDoc,
|
|
441
|
+
);
|
|
442
|
+
|
|
443
|
+
explained(
|
|
444
|
+
defineCommand(theme, undoDoc, {
|
|
445
|
+
fn: undoFn,
|
|
446
|
+
action: (/** @type {string} */ name, /** @type {any} */ o) =>
|
|
447
|
+
run(
|
|
448
|
+
program,
|
|
449
|
+
() => themeEditUndo(name, {cwd: process.cwd(), png: o.png ?? false}),
|
|
450
|
+
r => [
|
|
451
|
+
`[ok] ${r.data.theme}: undid the last change${r.data.undone.length ? `: ${r.data.undone.join('; ')}` : ''}`,
|
|
452
|
+
` now ${r.data.settings} settings; ${r.data.stepsLeft} earlier change${r.data.stepsLeft === 1 ? '' : 's'} can still be undone`,
|
|
453
|
+
` preview: ${r.data.preview}`,
|
|
454
|
+
...pictureLines(r.data),
|
|
455
|
+
],
|
|
456
|
+
),
|
|
457
|
+
}),
|
|
458
|
+
undoDoc,
|
|
459
|
+
);
|
|
460
|
+
|
|
461
|
+
explained(
|
|
462
|
+
defineCommand(theme, previewDoc, {
|
|
463
|
+
fn: previewFn,
|
|
464
|
+
action: (/** @type {string} */ name, /** @type {any} */ o) =>
|
|
465
|
+
run(
|
|
466
|
+
program,
|
|
467
|
+
() =>
|
|
468
|
+
themeEditPreview(name, {
|
|
469
|
+
cwd: process.cwd(),
|
|
470
|
+
write: o.write,
|
|
471
|
+
group: o.group,
|
|
472
|
+
png: o.png ?? false,
|
|
473
|
+
}),
|
|
474
|
+
r => [
|
|
475
|
+
r.data.mode === 'page'
|
|
476
|
+
? `[ok] wrote the theme-building page for ${r.data.theme} into the app (${r.data.components} components): ${r.data.files.join(', ')}. Serve it from a route to build the theme in the browser.`
|
|
477
|
+
: `[ok] rendered the theme-building page for ${r.data.theme} (${r.data.components} components): ${r.data.html}`,
|
|
478
|
+
...r.data.skipped.map(x => ` left out: ${x}`),
|
|
479
|
+
...pictureLines(r.data),
|
|
480
|
+
],
|
|
481
|
+
),
|
|
482
|
+
}),
|
|
483
|
+
previewDoc,
|
|
484
|
+
);
|
|
485
|
+
|
|
486
|
+
explained(
|
|
487
|
+
defineCommand(theme, explainDoc, {
|
|
488
|
+
fn: explainFn,
|
|
489
|
+
action: (/** @type {string[]} */ words, /** @type {any} */ o) => {
|
|
490
|
+
// A number after a picture is how many colors to list.
|
|
491
|
+
const count =
|
|
492
|
+
words.length === 2 &&
|
|
493
|
+
/\.png$/i.test(words[0]) &&
|
|
494
|
+
/^\d+$/.test(words[1])
|
|
495
|
+
? Number(words[1])
|
|
496
|
+
: undefined;
|
|
497
|
+
const subject = count == null ? words.join(' ') : words[0];
|
|
498
|
+
return run(
|
|
499
|
+
program,
|
|
500
|
+
() =>
|
|
501
|
+
themeEditExplain(subject, {
|
|
502
|
+
cwd: process.cwd(),
|
|
503
|
+
list: o.list,
|
|
504
|
+
at: o.at ?? [],
|
|
505
|
+
count,
|
|
506
|
+
}),
|
|
507
|
+
r => explainLines(/** @type {any} */ (r.data)),
|
|
508
|
+
r => {
|
|
509
|
+
const d = /** @type {any} */ (r.data);
|
|
510
|
+
const n =
|
|
511
|
+
d.kind === 'list'
|
|
512
|
+
? d.items.length
|
|
513
|
+
: d.kind === 'question'
|
|
514
|
+
? d.results.length
|
|
515
|
+
: 1;
|
|
516
|
+
return resultSet({count: n, resultKind: 'mixed', empty: n === 0});
|
|
517
|
+
},
|
|
518
|
+
);
|
|
519
|
+
},
|
|
520
|
+
}),
|
|
521
|
+
explainDoc,
|
|
522
|
+
{tokens: true},
|
|
523
|
+
);
|
|
524
|
+
|
|
525
|
+
registerThemeSubcommands(
|
|
526
|
+
theme,
|
|
527
|
+
program,
|
|
528
|
+
{
|
|
529
|
+
palette: paletteDoc,
|
|
530
|
+
paletteGenerate: paletteGenerateDoc,
|
|
531
|
+
build: compileDoc,
|
|
532
|
+
list: listDoc,
|
|
533
|
+
add: addDoc,
|
|
534
|
+
remove: removeDoc,
|
|
535
|
+
use: useDoc,
|
|
536
|
+
eject: ejectDoc,
|
|
537
|
+
template: templateDoc,
|
|
538
|
+
targets: targetsDoc,
|
|
539
|
+
},
|
|
540
|
+
{group: 'experimental theme', build: 'compile'},
|
|
541
|
+
);
|
|
542
|
+
}
|
|
@@ -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, 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. A library whose export names end in looks (XOutline24WGHT500Icon) gives one icon per glyph, by its glyph id (x), in the look the default variant names, else the library's usual default. Run it again with --from to refresh. --variants and --default-variant declare the set's variants; over an existing set without --from, they, --display-name and --description update the set in place and leave its icons as they are; a set with icons changes its default variant only with --from, and only in a library whose export names encode looks. 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. A library whose export names end in looks (XOutline24WGHT500Icon) gives one icon per glyph, by its glyph id (x), in the look the default variant names, else the library's usual default. Run it again with --from to refresh. A library whose icons are data objects or SVG strings needs --adapter, a function in your package that turns one into a component. --variants and --default-variant declare the set's variants; over an existing set without --from, they, --display-name and --description update the set in place and leave its icons as they are; a set with icons changes its default variant only with --from, and only in a library whose export names encode looks. Experimental: it may change or be removed in a patch release.",
|
|
15
15
|
fn: 'iconNewSet',
|
|
16
16
|
args: [
|
|
17
17
|
{
|
|
@@ -39,6 +39,12 @@ 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: '--adapter <module>#<export>',
|
|
44
|
+
param: 'options.adapter',
|
|
45
|
+
description:
|
|
46
|
+
"A function in your package that turns one icon export that is not a component (an icon data object, an SVG string) into one, as ./<path>#<export>; it is declared in the set's data file, and with --from every data export of the library becomes an icon through it",
|
|
47
|
+
},
|
|
42
48
|
{
|
|
43
49
|
flag: '--variants <list>',
|
|
44
50
|
param: 'options.variants',
|
|
@@ -36,7 +36,8 @@ export const doc = {
|
|
|
36
36
|
{
|
|
37
37
|
flag: '--set <name>',
|
|
38
38
|
param: 'options.set',
|
|
39
|
-
description:
|
|
39
|
+
description:
|
|
40
|
+
'Search one set, by name or <package>/<set>; with --definitions, the set to check them against',
|
|
40
41
|
},
|
|
41
42
|
{
|
|
42
43
|
flag: '--limit <n>',
|
|
@@ -47,7 +48,7 @@ export const doc = {
|
|
|
47
48
|
flag: '--definitions',
|
|
48
49
|
param: 'options.definitions',
|
|
49
50
|
description:
|
|
50
|
-
|
|
51
|
+
"Every Astryx icon definition, one line each: name, built in or not, how many bundled templates use it, whether the set maps it (--set, else the project's main set, else the package's only set), description, words",
|
|
51
52
|
},
|
|
52
53
|
{
|
|
53
54
|
flag: '--all-icons',
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file CommandDoc for `astryx experimental theme add`: the experimental
|
|
5
|
+
* copy of `astryx theme add`, with the same function, flags and output.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** @type {import('@astryxdesign/cli/authoring').CommandDoc} */
|
|
9
|
+
export const doc = {
|
|
10
|
+
type: 'command',
|
|
11
|
+
name: 'experimental theme add',
|
|
12
|
+
displayName: 'astryx experimental theme add',
|
|
13
|
+
namespace: 'cli/commands',
|
|
14
|
+
stability: 'experimental',
|
|
15
|
+
summary:
|
|
16
|
+
"Add a built theme to the app. To copy a theme's source as an editable fork, run `experimental theme eject <slug> [path] [--overwrite]`.",
|
|
17
|
+
description:
|
|
18
|
+
"Records the theme in the generated app module and imports its built module and stylesheets. --import remains accepted as a compatibility no-op. To copy a theme's source as an editable fork, run `experimental theme eject <slug> [path] [--overwrite]`. A bare command or --list delegates to themeListCopySources(), whose released JSON bytes stay unchanged while its text names the current add and eject commands; use --package when owners share a slug. Outside a project, a bare command or --list lists the available themes as in a new project; given a slug it writes nothing and fails, naming the app project it needs (ERR_THEME_INVALID), or with ERR_UNKNOWN_THEME when no theme has that slug.",
|
|
19
|
+
fn: 'themeAdd',
|
|
20
|
+
args: [
|
|
21
|
+
{
|
|
22
|
+
name: 'slug',
|
|
23
|
+
param: 'slug',
|
|
24
|
+
required: false,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
options: [
|
|
28
|
+
{
|
|
29
|
+
flag: '--list',
|
|
30
|
+
description: 'List available themes',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
flag: '--import',
|
|
34
|
+
param: 'options.import',
|
|
35
|
+
description:
|
|
36
|
+
'Compatibility no-op; the built theme is added with or without this flag',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
flag: '--package <package>',
|
|
40
|
+
param: 'options.package',
|
|
41
|
+
description: 'Select the package that owns the theme',
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
examples: [
|
|
45
|
+
{
|
|
46
|
+
label: 'Add a built theme to the app',
|
|
47
|
+
cli: 'astryx experimental theme add ocean',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
label: 'Select a package theme over a local theme',
|
|
51
|
+
cli: 'astryx experimental theme add ocean --package @acme/themes',
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
outsideProject: 'own',
|
|
55
|
+
exitCodes: [
|
|
56
|
+
{
|
|
57
|
+
code: 0,
|
|
58
|
+
when: 'the theme is listed or added',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
code: 1,
|
|
62
|
+
when: 'the theme, its built imports, its record, or the option combination is invalid',
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
related: [
|
|
66
|
+
'experimental theme list',
|
|
67
|
+
'experimental theme remove',
|
|
68
|
+
'experimental theme use',
|
|
69
|
+
'experimental theme eject',
|
|
70
|
+
],
|
|
71
|
+
notes: [
|
|
72
|
+
{
|
|
73
|
+
type: 'prose',
|
|
74
|
+
text: 'In global mode: outside a project, experimental theme add with no slug lists the themes available, as in a new project; with a slug it writes nothing and stops with `ERR_THEME_INVALID`: "No package.json found. Run this command inside an app project." In a project, the project\'s version of Astryx runs it, whichever astryx command you start. See {@link namespace:global} and {@link generic:problems}.',
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
replaces: ['theme add'],
|
|
78
|
+
};
|