@astryxdesign/cli 0.7.16-canary.ge95b87c → 0.7.16
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/CHANGELOG.md +369 -0
- package/README.md +1 -1
- package/api/build/_adapter.d.mts +9 -0
- package/api/build/_adapter.mjs +24 -0
- package/api/build/kit/shell.weights.json +1 -0
- package/api/build/kit/shellcall.d.mts +26 -0
- package/api/build/kit/shellcall.mjs +87 -0
- package/api/build/kit/start.mjs +67 -4
- package/api/build/kit/weights.d.mts +15 -0
- package/api/build/kit/weights.mjs +27 -0
- package/api/component/__fixtures__/resolutions/modules.txt +1 -1
- package/api/doctor/_adapter.d.mts +3 -2
- package/api/doctor/_adapter.mjs +7 -1
- package/api/doctor/doctor.d.mts +8 -0
- package/api/doctor/doctor.mjs +53 -8
- package/api/doctor/theme-checks.mjs +157 -8
- package/api/icon/_adapter.d.mts +7 -3
- package/api/icon/_adapter.mjs +12 -3
- package/api/icon/icon.type.d.mts +15 -0
- package/api/icon/icon.type.mjs +10 -3
- package/api/icon/iconUse.doc.mjs +19 -5
- package/api/icon/list/list.mjs +7 -1
- package/api/icon/use/use.d.mts +8 -5
- package/api/icon/use/use.mjs +95 -13
- package/api/init/run/run.mjs +1 -0
- package/api/template/template.type.d.mts +6 -2
- package/api/template/template.type.mjs +2 -1
- package/api/theme/_adapter.mjs +16 -2
- package/api/theme/build/build.d.mts +10 -6
- package/api/theme/build/build.mjs +42 -29
- package/api/theme/generateTonalPalette.doc.mjs +2 -2
- package/api/theme/palette/generate/generator.mjs +141 -2
- package/api/theme/theme.type.d.mts +39 -0
- package/api/theme/theme.type.mjs +21 -0
- package/api/theme/themeBuild.doc.mjs +1 -1
- package/api/theme/themePaletteGenerate.doc.mjs +1 -1
- package/api/theme-edit/_adapter.d.mts +1 -0
- package/api/theme-edit/_adapter.mjs +79 -21
- package/api/theme-edit/_check.d.mts +25 -2
- package/api/theme-edit/_check.mjs +251 -61
- package/api/theme-edit/_context.d.mts +2 -1
- package/api/theme-edit/_context.mjs +19 -1
- package/api/theme-edit/_edit.d.mts +16 -0
- package/api/theme-edit/_edit.mjs +360 -59
- package/api/theme-edit/_how-question.d.mts +8 -0
- package/api/theme-edit/_how-question.mjs +169 -22
- package/api/theme-edit/_marks.d.mts +13 -0
- package/api/theme-edit/_marks.mjs +15 -0
- package/api/theme-edit/_palette.d.mts +27 -0
- package/api/theme-edit/_palette.mjs +112 -8
- package/api/theme-edit/_preview-app.d.mts +46 -1
- package/api/theme-edit/_preview-app.mjs +367 -36
- package/api/theme-edit/_preview.d.mts +55 -0
- package/api/theme-edit/_preview.mjs +231 -6
- package/api/theme-edit/_project.d.mts +4 -0
- package/api/theme-edit/_project.mjs +27 -6
- package/api/theme-edit/_settings.d.mts +61 -2
- package/api/theme-edit/_settings.mjs +317 -115
- package/api/theme-edit/_tables.mjs +1 -1
- package/api/theme-edit/theme-edit.type.d.mts +30 -2
- package/api/theme-edit/theme-edit.type.mjs +10 -2
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
- package/assets/docs/author-a-theme.doc.mjs +1 -1
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/theme.doc.zh.mjs +4 -3
- package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/icon-sets.doc.mjs +63 -8
- package/assets/docs.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.doc.mjs +21 -0
- package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.tsx +62 -0
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/page.tsx +20 -2
- package/assets/templates/themes/neutral/neutralPalettes.generated.receipt.json +2 -0
- package/authoring/config/config.doc.mjs +8 -0
- package/authoring/config/parse.d.mts +1 -0
- package/authoring/config/parse.mjs +12 -0
- package/authoring/config/type.ts +8 -0
- package/authoring/doctypes/icon-set/icon-set-data.doc.mjs +3 -3
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/experimental/icon.mjs +61 -6
- package/clients/cli/commands/experimental/theme.mjs +9 -2
- package/clients/cli/commands/experimental-icon-use.doc.mjs +12 -5
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
- package/clients/cli/commands/theme.doc.mjs +7 -2
- package/clients/cli/commands/theme.mjs +41 -18
- package/clients/cli/commands.generated.json +1 -1
- package/clients/cli/index.mjs +25 -5
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/config/config-writer.d.mts +23 -0
- package/foundation/config/config-writer.mjs +150 -56
- package/foundation/config/project.mjs +43 -2
- package/foundation/discovery/component-discovery.mjs +6 -5
- package/foundation/discovery/icon-set-checks.mjs +164 -48
- package/foundation/discovery/icon-set-discovery.d.mts +38 -5
- package/foundation/discovery/icon-set-discovery.mjs +50 -6
- package/foundation/discovery/icon-set-theme-maps.d.mts +59 -0
- package/foundation/discovery/icon-set-theme-maps.mjs +95 -0
- package/foundation/discovery/icon-set-writer.d.mts +2 -3
- package/foundation/discovery/icon-set-writer.mjs +57 -16
- package/foundation/discovery/template-icons.d.mts +27 -10
- package/foundation/discovery/template-icons.mjs +142 -26
- package/foundation/discovery/theme-discovery.d.mts +25 -0
- package/foundation/discovery/theme-discovery.mjs +48 -7
- package/foundation/fs/gather-cache.mjs +6 -2
- package/foundation/integrations/autolink.d.mts +4 -2
- package/foundation/integrations/autolink.mjs +4 -2
- package/foundation/integrations/cli-requirement.d.mts +16 -5
- package/foundation/integrations/cli-requirement.mjs +27 -6
- package/foundation/integrations/may-have-integrations.mjs +5 -2
- package/foundation/integrations/missing-dependency.d.mts +9 -0
- package/foundation/integrations/missing-dependency.mjs +100 -0
- package/package.json +6 -6
|
@@ -673,7 +673,7 @@ export function generateCompressedIndex(
|
|
|
673
673
|
} else {
|
|
674
674
|
lines.push("- Style with component props first, then tokens (var(--color-*|--spacing-*|--radius-*)). No raw hex/px. No StyleX/Tailwind compiler here — don't use xstyle/utility classes directly. Some templates use StyleX and need a compiler plugin; see `astryx docs styling-overview`.");
|
|
675
675
|
}
|
|
676
|
-
lines.push('-
|
|
676
|
+
lines.push('- THEMES: palettes and custom colors go through the theme, never :root overrides. To make or change a theme (colors, fonts, corners, spacing, a look from a picture), prefer the experimental theme editor over hand-written theme files: `astryx experimental theme editor new <name> --like neutral`, then `editor set <name> <thing> <value>` or `editor how "<what you want>"`; wire it with `astryx theme add <name>`; after each change look at it with `astryx experimental theme editor show <name> --png` and open the PNGs it writes (changes nothing in the app); a theme change is not done until you have looked at the pictures. In code, extend an imported theme to customize it; `theme eject <slug>` only forks source. See `astryx docs theme`.');
|
|
677
677
|
// Self-check — post-generation pass. Validated via vibe tests (internal/vibe-tests/
|
|
678
678
|
// prompt-purity-test): on complex multi-step UIs the rules above alone still leave raw
|
|
679
679
|
// CSS in ~11-13% of runs; a re-read-and-fix pass cuts that ~4x at negligible token cost.
|
|
@@ -28,6 +28,24 @@ export function setConfigValue(projectDir: string, key: string, value: string |
|
|
|
28
28
|
previous: string | string[] | null;
|
|
29
29
|
changed: boolean;
|
|
30
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* Set several fields of the project's astryx.config in one write. Each value
|
|
33
|
+
* is a string, a list of strings, or `null`, which removes the field; a
|
|
34
|
+
* field the config does not set needs no removal. Either every field is
|
|
35
|
+
* written or, when one cannot be, none is.
|
|
36
|
+
* @param {string} projectDir
|
|
37
|
+
* @param {ReadonlyArray<readonly [string, string | readonly string[] | null]>} fields
|
|
38
|
+
* each a top-level key or a dotted path (`experimental.iconSet`), and its
|
|
39
|
+
* value
|
|
40
|
+
* @returns {{file: string, created: boolean, previous: Array<string | string[] | null>, changed: boolean}}
|
|
41
|
+
* `previous`: each field's value before the write, in the order given
|
|
42
|
+
*/
|
|
43
|
+
export function setConfigValues(projectDir: string, fields: ReadonlyArray<readonly [string, string | readonly string[] | null]>): {
|
|
44
|
+
file: string;
|
|
45
|
+
created: boolean;
|
|
46
|
+
previous: Array<string | string[] | null>;
|
|
47
|
+
changed: boolean;
|
|
48
|
+
};
|
|
31
49
|
/** A protected astryx.config the writer refused to touch. */
|
|
32
50
|
export class ConfigProtectedError extends Error {
|
|
33
51
|
/**
|
|
@@ -39,3 +57,8 @@ export class ConfigProtectedError extends Error {
|
|
|
39
57
|
file: string;
|
|
40
58
|
protections: import("../fs/file-protection.mjs").FileProtection[];
|
|
41
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* The nested objects of a new config: each key's value, or the object a
|
|
62
|
+
* dotted path opens.
|
|
63
|
+
*/
|
|
64
|
+
export type ConfigTree = Map<string, string | readonly string[] | ConfigTree>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file Write
|
|
5
|
-
* astryx.config.
|
|
4
|
+
* @file Write string fields, or lists of strings, in a project's
|
|
5
|
+
* astryx.config, or remove them, in one write.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* A field is a top-level key or a dotted path into nested object literals
|
|
8
8
|
* (`experimental.iconSet`); a missing object on the path is created.
|
|
9
9
|
*
|
|
10
10
|
* Edits the default-exported object literal in place (comments and other
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
* `ERR_CODEMOD_PROTECTED` naming the protecting declaration, and an unreadable
|
|
20
20
|
* protection source fails with `ERR_CODEMOD_PROTECTION_SOURCE`.
|
|
21
21
|
*
|
|
22
|
-
* @input A project directory
|
|
23
|
-
* list of strings
|
|
24
|
-
* @output The config file written and the
|
|
22
|
+
* @input A project directory and fields: each a name and its value, a string,
|
|
23
|
+
* a list of strings, or null to remove it
|
|
24
|
+
* @output The config file written and the values it replaced
|
|
25
25
|
* @position packages/cli/foundation/config — read by `astryx experimental icon use`
|
|
26
26
|
*/
|
|
27
27
|
|
|
@@ -154,40 +154,104 @@ export function setConfigString(projectDir, key, value) {
|
|
|
154
154
|
* @returns {{file: string, created: boolean, previous: string | string[] | null, changed: boolean}}
|
|
155
155
|
*/
|
|
156
156
|
export function setConfigValue(projectDir, key, value) {
|
|
157
|
-
const
|
|
158
|
-
|
|
157
|
+
const result = setConfigValues(projectDir, [[key, value]]);
|
|
158
|
+
return {...result, previous: result.previous[0] ?? null};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* The sentence that tells a person to make the edits by hand: `Set
|
|
163
|
+
* "experimental.iconSet: 'glyphs'"`, with each further edit after `and`.
|
|
164
|
+
* @param {ReadonlyArray<readonly [string, string | readonly string[] | null]>} fields
|
|
165
|
+
*/
|
|
166
|
+
function byHand(fields) {
|
|
167
|
+
const edits = fields
|
|
168
|
+
.map(([key, value]) =>
|
|
169
|
+
value == null ? `remove "${key}"` : `set "${key}: ${written(value)}"`,
|
|
170
|
+
)
|
|
171
|
+
.join(' and ');
|
|
172
|
+
return edits[0].toUpperCase() + edits.slice(1);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* The nested objects of a new config: each key's value, or the object a
|
|
177
|
+
* dotted path opens.
|
|
178
|
+
* @typedef {Map<string, string | readonly string[] | ConfigTree>} ConfigTree
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* The text of a new astryx.config.mjs that sets the fields: each key on a
|
|
183
|
+
* path opens one nested object (`experimental: {`), shared by the fields
|
|
184
|
+
* under it.
|
|
185
|
+
* @param {ReadonlyArray<readonly [string, string | readonly string[]]>} fields
|
|
186
|
+
*/
|
|
187
|
+
function newConfigText(fields) {
|
|
188
|
+
/** @type {ConfigTree} */
|
|
189
|
+
const tree = new Map();
|
|
190
|
+
for (const [key, value] of fields) {
|
|
191
|
+
const keys = key.split('.');
|
|
192
|
+
let node = tree;
|
|
193
|
+
for (const each of keys.slice(0, -1)) {
|
|
194
|
+
let child = node.get(each);
|
|
195
|
+
if (!(child instanceof Map)) {
|
|
196
|
+
child = new Map();
|
|
197
|
+
node.set(each, child);
|
|
198
|
+
}
|
|
199
|
+
node = child;
|
|
200
|
+
}
|
|
201
|
+
node.set(/** @type {string} */ (keys[keys.length - 1]), value);
|
|
202
|
+
}
|
|
203
|
+
/** @param {ConfigTree} node @param {number} depth @returns {string} */
|
|
204
|
+
const render = (node, depth) =>
|
|
205
|
+
[...node]
|
|
206
|
+
.map(([name, value]) =>
|
|
207
|
+
value instanceof Map
|
|
208
|
+
? `${' '.repeat(depth)}${name}: {\n${render(value, depth + 1)}${' '.repeat(depth)}},\n`
|
|
209
|
+
: `${' '.repeat(depth)}${name}: ${written(value)},\n`,
|
|
210
|
+
)
|
|
211
|
+
.join('');
|
|
212
|
+
return `export default {\n${render(tree, 1)}};\n`;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Set several fields of the project's astryx.config in one write. Each value
|
|
217
|
+
* is a string, a list of strings, or `null`, which removes the field; a
|
|
218
|
+
* field the config does not set needs no removal. Either every field is
|
|
219
|
+
* written or, when one cannot be, none is.
|
|
220
|
+
* @param {string} projectDir
|
|
221
|
+
* @param {ReadonlyArray<readonly [string, string | readonly string[] | null]>} fields
|
|
222
|
+
* each a top-level key or a dotted path (`experimental.iconSet`), and its
|
|
223
|
+
* value
|
|
224
|
+
* @returns {{file: string, created: boolean, previous: Array<string | string[] | null>, changed: boolean}}
|
|
225
|
+
* `previous`: each field's value before the write, in the order given
|
|
226
|
+
*/
|
|
227
|
+
export function setConfigValues(projectDir, fields) {
|
|
159
228
|
const existing = CONFIG_BASENAMES.map(name =>
|
|
160
229
|
path.join(projectDir, name),
|
|
161
230
|
).find(file => fs.existsSync(file));
|
|
231
|
+
/** @type {Array<readonly [string, string | readonly string[]]>} */
|
|
232
|
+
const set = [];
|
|
233
|
+
for (const [key, value] of fields) {
|
|
234
|
+
if (value != null) set.push([key, value]);
|
|
235
|
+
}
|
|
162
236
|
if (!existing) {
|
|
163
237
|
const file = path.join(projectDir, 'astryx.config.mjs');
|
|
238
|
+
const previous = fields.map(() => null);
|
|
239
|
+
if (set.length === 0)
|
|
240
|
+
return {file, created: false, previous, changed: false};
|
|
164
241
|
assertWritable(projectDir, file);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
.slice(0, -1)
|
|
168
|
-
.map((each, depth) => `${' '.repeat(depth + 1)}${each}: {\n`)
|
|
169
|
-
.join('');
|
|
170
|
-
const close = keys
|
|
171
|
-
.slice(0, -1)
|
|
172
|
-
.map((_, depth) => `${' '.repeat(depth + 1)}},\n`)
|
|
173
|
-
.reverse()
|
|
174
|
-
.join('');
|
|
175
|
-
writeAtomically(
|
|
176
|
-
file,
|
|
177
|
-
`export default {\n${open}${' '.repeat(keys.length)}${leaf}: ${written(value)},\n${close}};\n`,
|
|
178
|
-
);
|
|
179
|
-
return {file, created: true, previous: null, changed: true};
|
|
242
|
+
writeAtomically(file, newConfigText(set));
|
|
243
|
+
return {file, created: true, previous, changed: true};
|
|
180
244
|
}
|
|
181
245
|
assertWritable(projectDir, existing);
|
|
182
246
|
const source = fs.readFileSync(existing, 'utf-8');
|
|
183
247
|
const j = loadJscodeshift().withParser('tsx');
|
|
184
248
|
const ast = j(source);
|
|
185
|
-
|
|
249
|
+
const root = findManifestObject(j, ast);
|
|
186
250
|
const refuse = () =>
|
|
187
251
|
new Error(
|
|
188
|
-
`Could not update ${path.basename(existing)} safely: its default export is not a static object literal.
|
|
252
|
+
`Could not update ${path.basename(existing)} safely: its default export is not a static object literal. ${byHand(fields)} in it yourself.`,
|
|
189
253
|
);
|
|
190
|
-
if (!
|
|
254
|
+
if (!root) throw refuse();
|
|
191
255
|
// A spread on the path can hold the same keys: a key added beside it would
|
|
192
256
|
// shadow the spread's whole object and drop what it sets, so nothing is
|
|
193
257
|
// written there (`{...base}` may set `experimental.xle`).
|
|
@@ -195,43 +259,73 @@ export function setConfigValue(projectDir, key, value) {
|
|
|
195
259
|
const assertNoSpread = (holder, where) => {
|
|
196
260
|
if (holder.properties.some((/** @type {any} */ each) => isSpread(each))) {
|
|
197
261
|
throw new Error(
|
|
198
|
-
`Could not update ${path.basename(existing)} safely: ${where} spreads another object (\`...\`), whose keys a written "${key}" could replace.
|
|
262
|
+
`Could not update ${path.basename(existing)} safely: ${where} spreads another object (\`...\`), whose keys a written ${fields.map(([key]) => `"${key}"`).join(' or ')} could replace. ${byHand(fields)} in it yourself.`,
|
|
199
263
|
);
|
|
200
264
|
}
|
|
201
265
|
};
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
const holder = object.properties.find((/** @type {any} */ property) =>
|
|
205
|
-
propertyNamed(property, each),
|
|
206
|
-
);
|
|
207
|
-
if (!holder) {
|
|
208
|
-
const created = j.objectExpression([]);
|
|
209
|
-
object.properties.push(j.objectProperty(j.identifier(each), created));
|
|
210
|
-
object = created;
|
|
211
|
-
continue;
|
|
212
|
-
}
|
|
213
|
-
const nested = unwrapManifestExpression(holder.value);
|
|
214
|
-
if (!j.ObjectExpression.check(nested)) throw refuse();
|
|
215
|
-
assertNoSpread(nested, `its "${each}" object`);
|
|
216
|
-
object = nested;
|
|
217
|
-
}
|
|
218
|
-
const property = object.properties.find((/** @type {any} */ each) =>
|
|
219
|
-
propertyNamed(each, leaf),
|
|
220
|
-
);
|
|
221
|
-
const node =
|
|
266
|
+
/** @param {string | readonly string[]} value */
|
|
267
|
+
const nodeOf = value =>
|
|
222
268
|
typeof value === 'string'
|
|
223
269
|
? j.stringLiteral(value)
|
|
224
270
|
: j.arrayExpression(value.map(each => j.stringLiteral(each)));
|
|
225
|
-
/** @type {string | string[] | null} */
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
271
|
+
/** @type {Array<string | string[] | null>} */
|
|
272
|
+
const previous = [];
|
|
273
|
+
let changed = false;
|
|
274
|
+
for (const [key, value] of fields) {
|
|
275
|
+
const keys = key.split('.');
|
|
276
|
+
const leaf = /** @type {string} */ (keys[keys.length - 1]);
|
|
277
|
+
let object = root;
|
|
278
|
+
assertNoSpread(object, 'its default export');
|
|
279
|
+
let absent = false;
|
|
280
|
+
for (const each of keys.slice(0, -1)) {
|
|
281
|
+
const holder = object.properties.find((/** @type {any} */ property) =>
|
|
282
|
+
propertyNamed(property, each),
|
|
283
|
+
);
|
|
284
|
+
if (!holder) {
|
|
285
|
+
// A field the config does not reach is already removed.
|
|
286
|
+
if (value == null) {
|
|
287
|
+
absent = true;
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
const created = j.objectExpression([]);
|
|
291
|
+
object.properties.push(j.objectProperty(j.identifier(each), created));
|
|
292
|
+
object = created;
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
const nested = unwrapManifestExpression(holder.value);
|
|
296
|
+
if (!j.ObjectExpression.check(nested)) throw refuse();
|
|
297
|
+
assertNoSpread(nested, `its "${each}" object`);
|
|
298
|
+
object = nested;
|
|
299
|
+
}
|
|
300
|
+
if (absent) {
|
|
301
|
+
previous.push(null);
|
|
302
|
+
continue;
|
|
231
303
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
304
|
+
const at = object.properties.findIndex((/** @type {any} */ each) =>
|
|
305
|
+
propertyNamed(each, leaf),
|
|
306
|
+
);
|
|
307
|
+
const property = at === -1 ? null : object.properties[at];
|
|
308
|
+
const before = property ? literalValue(property.value) : null;
|
|
309
|
+
previous.push(before);
|
|
310
|
+
if (value == null) {
|
|
311
|
+
if (property) {
|
|
312
|
+
object.properties.splice(at, 1);
|
|
313
|
+
changed = true;
|
|
314
|
+
}
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
if (property) {
|
|
318
|
+
if (sameValue(before, value)) continue;
|
|
319
|
+
property.value = nodeOf(value);
|
|
320
|
+
} else {
|
|
321
|
+
object.properties.push(
|
|
322
|
+
j.objectProperty(j.identifier(leaf), nodeOf(value)),
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
changed = true;
|
|
326
|
+
}
|
|
327
|
+
if (!changed) {
|
|
328
|
+
return {file: existing, created: false, previous, changed: false};
|
|
235
329
|
}
|
|
236
330
|
let next = ast.toSource({quote: 'single', reuseWhitespace: true});
|
|
237
331
|
if (source.endsWith('\n') && !next.endsWith('\n')) next += '\n';
|
|
@@ -45,6 +45,7 @@ import {
|
|
|
45
45
|
resolveInstalledIntegrationDir,
|
|
46
46
|
} from '../integrations/integrations.mjs';
|
|
47
47
|
import {loadAutolinkCandidates} from '../integrations/autolink.mjs';
|
|
48
|
+
import {missingDeclaredDependency} from '../integrations/missing-dependency.mjs';
|
|
48
49
|
import {
|
|
49
50
|
computerInstallRoots,
|
|
50
51
|
loadComputerIntegrations,
|
|
@@ -1087,6 +1088,7 @@ export class Project {
|
|
|
1087
1088
|
sets,
|
|
1088
1089
|
this.#config.experimental?.iconSet,
|
|
1089
1090
|
withdrawn,
|
|
1091
|
+
this.#config.experimental?.iconVariant,
|
|
1090
1092
|
);
|
|
1091
1093
|
return {sets: orderIconSets(sets, choice), withdrawn, choice};
|
|
1092
1094
|
});
|
|
@@ -1350,6 +1352,41 @@ export class Project {
|
|
|
1350
1352
|
for (const integration of this.#loadedIntegrations) {
|
|
1351
1353
|
await this.#collectIssues(integration);
|
|
1352
1354
|
}
|
|
1355
|
+
// An installed dependency whose manifest could not be loaded for want of
|
|
1356
|
+
// a package leaves no loaded record, so nothing above sees it: report it
|
|
1357
|
+
// here, as a package named in astryx.config that fails to load is.
|
|
1358
|
+
for (const failed of this.#unloadedDependencies()) {
|
|
1359
|
+
this.#pushIssue(failed.spec, {
|
|
1360
|
+
code: 'integration_error',
|
|
1361
|
+
severity: 'error',
|
|
1362
|
+
message: failed.error,
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
/**
|
|
1368
|
+
* The installed dependencies, linked without a config entry, whose manifest
|
|
1369
|
+
* could not be loaded because a package that the importing package requires
|
|
1370
|
+
* (a dependency or a required peer) is missing, with the load error. That is a broken install, which the
|
|
1371
|
+
* project can fix by installing again; a dependency's own packaging bug (a
|
|
1372
|
+
* manifest that throws, does not validate, or imports what it does not
|
|
1373
|
+
* declare) stays out of the project's issues, since the project cannot fix
|
|
1374
|
+
* it.
|
|
1375
|
+
* @returns {Array<{spec: string, error: string}>}
|
|
1376
|
+
*/
|
|
1377
|
+
#unloadedDependencies() {
|
|
1378
|
+
return [...(PROVIDER_LEDGERS.get(this)?.values() ?? [])].flatMap(entry =>
|
|
1379
|
+
entry.outcome === 'load-failed' &&
|
|
1380
|
+
entry.candidate.source === 'autolinked' &&
|
|
1381
|
+
missingDeclaredDependency(entry.error ?? '') != null
|
|
1382
|
+
? [
|
|
1383
|
+
{
|
|
1384
|
+
spec: entry.candidate.spec ?? entry.label,
|
|
1385
|
+
error: entry.error ?? 'its manifest could not be loaded',
|
|
1386
|
+
},
|
|
1387
|
+
]
|
|
1388
|
+
: [],
|
|
1389
|
+
);
|
|
1353
1390
|
}
|
|
1354
1391
|
|
|
1355
1392
|
/**
|
|
@@ -1362,8 +1399,11 @@ export class Project {
|
|
|
1362
1399
|
async issues() {
|
|
1363
1400
|
// Each issue these passes find belongs to an integration, because Core's
|
|
1364
1401
|
// templates and components declare no replacement. A project with no
|
|
1365
|
-
// integration skips them.
|
|
1366
|
-
if (
|
|
1402
|
+
// integration skips them (one whose manifest failed to load counts).
|
|
1403
|
+
if (
|
|
1404
|
+
this.#loadedIntegrations.length > 0 ||
|
|
1405
|
+
this.#unloadedDependencies().length > 0
|
|
1406
|
+
) {
|
|
1367
1407
|
// A function of the files the passes read and of the issues already
|
|
1368
1408
|
// found (which the key holds): the kept gather stamps the files, so a
|
|
1369
1409
|
// later run with every one unchanged reads the whole list back and
|
|
@@ -1381,6 +1421,7 @@ export class Project {
|
|
|
1381
1421
|
integration => integration.__packageDir ?? integration.name ?? null,
|
|
1382
1422
|
),
|
|
1383
1423
|
Boolean(this.#config.experimental?.iconSet),
|
|
1424
|
+
this.#unloadedDependencies(),
|
|
1384
1425
|
before,
|
|
1385
1426
|
],
|
|
1386
1427
|
async () => {
|
|
@@ -681,11 +681,12 @@ function ownSourceFile(coreDir, name) {
|
|
|
681
681
|
if (found) return found;
|
|
682
682
|
}
|
|
683
683
|
|
|
684
|
-
// Search nested (component might be under a parent dir)
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
684
|
+
// Search nested (component might be under a parent dir): only the folders
|
|
685
|
+
// whose listing holds the name, in listing order.
|
|
686
|
+
const nested = foldersHolding(srcDir, listDirEntries(srcDir), [name]).map(
|
|
687
|
+
entry => path.join(srcDir, entry.name, name),
|
|
688
|
+
);
|
|
689
|
+
for (const nestedDir of nested) {
|
|
689
690
|
if (existsCaseExact(nestedDir, srcDir)) {
|
|
690
691
|
const found = searchDir(nestedDir);
|
|
691
692
|
if (found) return found;
|