@astryxdesign/cli 0.7.16-canary.gbb5e9d4 → 0.7.16-canary.ge95b87c
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/_adapter.d.mts +1 -0
- package/api/build/blocks/blocks.d.mts +1 -0
- package/api/build/blocks/blocks.mjs +18 -1
- package/api/doctor/_adapter.d.mts +18 -0
- package/api/doctor/_adapter.mjs +34 -0
- package/api/doctor/built-checks.mjs +1 -1
- package/api/doctor/doctor.d.mts +18 -0
- package/api/doctor/doctor.doc.mjs +1 -1
- package/api/doctor/doctor.mjs +87 -1
- package/api/doctor/theme-checks.mjs +6 -10
- package/api/integration/add-contribution.mjs +3 -3
- package/api/integration/pack-check.mjs +1 -1
- package/api/search/_adapter.mjs +12 -0
- package/api/search/_entries.d.mts +2 -1
- package/api/search/_entries.mjs +28 -1
- package/api/swizzle/_moduleGraph.mjs +1 -1
- package/api/theme/_fork.mjs +1 -1
- package/api/theme/build/build.d.mts +52 -5
- package/api/theme/build/build.mjs +131 -56
- package/api/theme-edit/_adapter.d.mts +6 -2
- package/api/theme-edit/_adapter.mjs +32 -7
- package/assets/codemods/parse.mjs +2 -2
- package/assets/docs.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/authoring/shadcn/source-variants.d.mts +1 -1
- package/authoring/shadcn/source-variants.mjs +32 -10
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/theme.mjs +24 -3
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/config/config-writer.mjs +2 -2
- package/foundation/config/project.mjs +10 -0
- package/foundation/discovery/component-discovery.mjs +5 -17
- package/foundation/discovery/icon-set-writer.mjs +1 -1
- package/foundation/discovery/module-exports.mjs +1 -15
- package/foundation/discovery/template-adapter.mjs +16 -19
- package/foundation/discovery/template-source-tree.mjs +3 -16
- package/foundation/discovery/theme-discovery.mjs +38 -41
- package/foundation/fs/gather-cache.d.mts +6 -3
- package/foundation/fs/gather-cache.mjs +38 -12
- package/foundation/integrations/contribution-fixes.mjs +1 -16
- package/foundation/integrations/public-imports.mjs +1 -1
- package/foundation/render/embedded-imports.mjs +1 -1
- package/foundation/runtime/lazy-dependencies.d.mts +14 -0
- package/foundation/runtime/lazy-dependencies.mjs +82 -0
- package/foundation/xle/browser.d.mts +2 -2
- package/package.json +6 -6
package/api/build/_adapter.d.mts
CHANGED
|
@@ -77,6 +77,7 @@ export function loadTreeWeights(): import("../../foundation/route/route.mjs").Cl
|
|
|
77
77
|
export function keptBlockCatalog<T>(key: unknown[], compute: () => T, codec: {
|
|
78
78
|
encode: (value: T) => any;
|
|
79
79
|
decode: (stored: any) => T;
|
|
80
|
+
valid?: (value: any) => boolean;
|
|
80
81
|
}): T;
|
|
81
82
|
/**
|
|
82
83
|
* The block picker's weights (blocks/blocks.weights.json), read once; null
|
|
@@ -90,6 +90,7 @@ export function pickBlocks(request: string, signals: {
|
|
|
90
90
|
export type KeepCatalog = <T>(key: unknown[], compute: () => T, codec: {
|
|
91
91
|
encode: (value: T) => any;
|
|
92
92
|
decode: (stored: any) => T;
|
|
93
|
+
valid?: (value: any) => boolean;
|
|
93
94
|
}) => T;
|
|
94
95
|
export type BlockPickerWeights = {
|
|
95
96
|
/**
|
|
@@ -45,7 +45,7 @@ import {STOPWORDS} from '../../search/_query.mjs';
|
|
|
45
45
|
/**
|
|
46
46
|
* Keeps a value derived from the catalog between runs (build's adapter does
|
|
47
47
|
* it beside the kept search catalog), or works it out.
|
|
48
|
-
* @typedef {<T>(key: unknown[], compute: () => T, codec: {encode: (value: T) => any, decode: (stored: any) => T}) => T} KeepCatalog
|
|
48
|
+
* @typedef {<T>(key: unknown[], compute: () => T, codec: {encode: (value: T) => any, decode: (stored: any) => T, valid?: (value: any) => boolean}) => T} KeepCatalog
|
|
49
49
|
*/
|
|
50
50
|
|
|
51
51
|
/**
|
|
@@ -410,6 +410,23 @@ function computeCatalog(key, catalog, components, weights) {
|
|
|
410
410
|
* projection as its numbers.
|
|
411
411
|
*/
|
|
412
412
|
const CATALOG_CODEC = {
|
|
413
|
+
/**
|
|
414
|
+
* What decode can get wrong in a read-back catalog: its key, each block's
|
|
415
|
+
* component, and projections of one width with finite numbers.
|
|
416
|
+
* @param {any} read
|
|
417
|
+
*/
|
|
418
|
+
valid: read => {
|
|
419
|
+
if (read == null || typeof read.key !== 'string') return false;
|
|
420
|
+
const blocks = [...read.blocks.values()];
|
|
421
|
+
const width = blocks[0]?.projected.length;
|
|
422
|
+
return blocks.every(
|
|
423
|
+
(/** @type {any} */ b) =>
|
|
424
|
+
typeof b.component === 'string' &&
|
|
425
|
+
b.projected.length > 0 &&
|
|
426
|
+
b.projected.length === width &&
|
|
427
|
+
[...b.projected].every(Number.isFinite),
|
|
428
|
+
);
|
|
429
|
+
},
|
|
413
430
|
/** @param {ReturnType<typeof computeCatalog>} read */
|
|
414
431
|
encode: read => ({
|
|
415
432
|
key: read.key,
|
|
@@ -88,6 +88,24 @@ export function doctorElementPropOrigins(file: string, element: Parameters<typeo
|
|
|
88
88
|
* @returns {Set<string>}
|
|
89
89
|
*/
|
|
90
90
|
export function doctorStylesheetImports(css: string): Set<string>;
|
|
91
|
+
/**
|
|
92
|
+
* The `@astryxdesign/core` range a package's peerDependencies declare, and
|
|
93
|
+
* whether it accepts `coreVersion` (spec:AST-017/FR12). The one rule every
|
|
94
|
+
* doctor check uses to compare a package with the installed Core:
|
|
95
|
+
* `theme-core-peers` for added theme packages, `integration-core-range` for
|
|
96
|
+
* every other loaded integration.
|
|
97
|
+
* @param {{peerDependencies?: Record<string, unknown>} | null | undefined} pkg
|
|
98
|
+
* @param {string | null | undefined} coreVersion
|
|
99
|
+
* Any declared string is judged by `satisfiesRange`, so an empty range
|
|
100
|
+
* accepts every Core; only a missing range is `null`.
|
|
101
|
+
* @returns {{range: string | null, accepts: boolean}}
|
|
102
|
+
*/
|
|
103
|
+
export function corePeerRange(pkg: {
|
|
104
|
+
peerDependencies?: Record<string, unknown>;
|
|
105
|
+
} | null | undefined, coreVersion: string | null | undefined): {
|
|
106
|
+
range: string | null;
|
|
107
|
+
accepts: boolean;
|
|
108
|
+
};
|
|
91
109
|
/** @param {string} projectDir */
|
|
92
110
|
export function findDoctorCoreDir(projectDir: string): string | null;
|
|
93
111
|
/** @param {string} projectDir @param {string} packageName */
|
package/api/doctor/_adapter.mjs
CHANGED
|
@@ -44,6 +44,7 @@ export {placeholderFixes} from '../../foundation/discovery/template-icons.mjs';
|
|
|
44
44
|
export {unlistedIconSets} from '../../foundation/discovery/icon-set-discovery.mjs';
|
|
45
45
|
import {elementPropOrigins} from '../../foundation/discovery/module-exports.mjs';
|
|
46
46
|
import {cssImports} from '../../foundation/render/embedded-imports.mjs';
|
|
47
|
+
import {satisfiesRange} from '../../foundation/env/semver.mjs';
|
|
47
48
|
import * as path from 'node:path';
|
|
48
49
|
import {
|
|
49
50
|
persistedGather,
|
|
@@ -92,6 +93,14 @@ export {
|
|
|
92
93
|
const CHECK_CODEC = {
|
|
93
94
|
encode: (/** @type {any} */ check) => check,
|
|
94
95
|
decode: (/** @type {any} */ check) => check,
|
|
96
|
+
/** A check record: its id, label, status and message. */
|
|
97
|
+
valid: (/** @type {any} */ check) =>
|
|
98
|
+
check != null &&
|
|
99
|
+
typeof check === 'object' &&
|
|
100
|
+
typeof check.id === 'string' &&
|
|
101
|
+
typeof check.label === 'string' &&
|
|
102
|
+
typeof check.status === 'string' &&
|
|
103
|
+
typeof check.message === 'string',
|
|
95
104
|
};
|
|
96
105
|
|
|
97
106
|
/**
|
|
@@ -291,6 +300,31 @@ export function doctorStylesheetImports(css) {
|
|
|
291
300
|
return new Set(cssImports(css));
|
|
292
301
|
}
|
|
293
302
|
|
|
303
|
+
/**
|
|
304
|
+
* The `@astryxdesign/core` range a package's peerDependencies declare, and
|
|
305
|
+
* whether it accepts `coreVersion` (spec:AST-017/FR12). The one rule every
|
|
306
|
+
* doctor check uses to compare a package with the installed Core:
|
|
307
|
+
* `theme-core-peers` for added theme packages, `integration-core-range` for
|
|
308
|
+
* every other loaded integration.
|
|
309
|
+
* @param {{peerDependencies?: Record<string, unknown>} | null | undefined} pkg
|
|
310
|
+
* @param {string | null | undefined} coreVersion
|
|
311
|
+
* Any declared string is judged by `satisfiesRange`, so an empty range
|
|
312
|
+
* accepts every Core; only a missing range is `null`.
|
|
313
|
+
* @returns {{range: string | null, accepts: boolean}}
|
|
314
|
+
*/
|
|
315
|
+
export function corePeerRange(pkg, coreVersion) {
|
|
316
|
+
const raw = pkg?.peerDependencies?.['@astryxdesign/core'];
|
|
317
|
+
const range = typeof raw === 'string' ? raw.trim() : null;
|
|
318
|
+
return {
|
|
319
|
+
range,
|
|
320
|
+
accepts:
|
|
321
|
+
range !== null &&
|
|
322
|
+
typeof coreVersion === 'string' &&
|
|
323
|
+
coreVersion !== '' &&
|
|
324
|
+
satisfiesRange(coreVersion, range),
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
|
|
294
328
|
/** @param {string} projectDir */
|
|
295
329
|
export function findDoctorCoreDir(projectDir) {
|
|
296
330
|
return findProjectCoreDir(projectDir);
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
resolveBuiltPath,
|
|
31
31
|
} from './_adapter.mjs';
|
|
32
32
|
import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
|
|
33
|
-
import {
|
|
33
|
+
import {babelParse as parseModule} from '../../foundation/runtime/lazy-dependencies.mjs';
|
|
34
34
|
|
|
35
35
|
/** Source files, read for imports and JSX. */
|
|
36
36
|
const SOURCE_EXT = new Set(['.tsx', '.jsx', '.ts', '.js', '.mjs', '.cjs']);
|
package/api/doctor/doctor.d.mts
CHANGED
|
@@ -86,6 +86,19 @@ export function checkPeerDeps(ctx: DoctorContext): DoctorCheck;
|
|
|
86
86
|
* @returns {DoctorCheck}
|
|
87
87
|
*/
|
|
88
88
|
export function checkIntegrationIssues(ctx: DoctorContext): DoctorCheck;
|
|
89
|
+
/**
|
|
90
|
+
* Every loaded integration's `@astryxdesign/core` peer range admits the
|
|
91
|
+
* installed Core: a package's declared peer ranges define the Core versions it
|
|
92
|
+
* supports (spec:AST-017 FR12). A package made for another Core installs with
|
|
93
|
+
* only a package manager warning, and its components, themes and docs may not
|
|
94
|
+
* work. New, so it warns: a project that passed before keeps passing.
|
|
95
|
+
* Packages of added themes are left to `theme-core-peers` (spec:AST-050 FR11),
|
|
96
|
+
* which applies the same rule. Null when Core is not installed or no other
|
|
97
|
+
* loaded integration declares a Core range.
|
|
98
|
+
* @param {DoctorContext} ctx
|
|
99
|
+
* @returns {DoctorCheck | null}
|
|
100
|
+
*/
|
|
101
|
+
export function checkIntegrationCoreRange(ctx: DoctorContext): DoctorCheck | null;
|
|
89
102
|
/**
|
|
90
103
|
* The project's icon sets (AST-084 FR17). Fails when `experimental.iconSet`
|
|
91
104
|
* names a set, main or backup, that is not installed, that is installed but
|
|
@@ -387,6 +400,11 @@ export type DoctorContext = {
|
|
|
387
400
|
* false means the copy that started the run answered it (spec AST-081 FR2).
|
|
388
401
|
*/
|
|
389
402
|
ownCli?: boolean | undefined;
|
|
403
|
+
/**
|
|
404
|
+
* - Packages of the project's added
|
|
405
|
+
* themes, which `theme-core-peers` checks against Core
|
|
406
|
+
*/
|
|
407
|
+
addedThemePackages?: string[] | undefined;
|
|
390
408
|
/**
|
|
391
409
|
* - The Core release the project names
|
|
392
410
|
* (installed, else locked, else declared), as the daily hint reads it.
|
|
@@ -20,7 +20,7 @@ export const doc = {
|
|
|
20
20
|
'@astryxdesign/core install and version alignment with the CLI, installed ' +
|
|
21
21
|
'themes and wiring, astryx.config validity, whether every integration ' +
|
|
22
22
|
'astryx.config names loads (a failed one fails the run), integrations linked from ' +
|
|
23
|
-
'package.json without a config entry, core peer dependencies, ' +
|
|
23
|
+
'package.json without a config entry, core peer dependencies, whether the @astryxdesign/core peer range of each loaded integration includes the installed Core (`integration-core-range`, a warning; added theme packages are checked by `theme-core-peers` instead), ' +
|
|
24
24
|
'integration provider identity and contribution issues, agent docs, the ' +
|
|
25
25
|
'detected package manager, and the health of the docs the CLI reads (authoring ' +
|
|
26
26
|
'and CLI docs, the docs tree, doc size), and returns a structured ' +
|
package/api/doctor/doctor.mjs
CHANGED
|
@@ -118,6 +118,9 @@ import {
|
|
|
118
118
|
releaseFacts,
|
|
119
119
|
builtIntegrationPackages,
|
|
120
120
|
authoringAudit,
|
|
121
|
+
corePeerRange,
|
|
122
|
+
isLocalThemeOwner,
|
|
123
|
+
readThemeState,
|
|
121
124
|
} from './_adapter.mjs';
|
|
122
125
|
import {checkBuilt} from './built-checks.mjs';
|
|
123
126
|
|
|
@@ -141,6 +144,8 @@ import {checkBuilt} from './built-checks.mjs';
|
|
|
141
144
|
* @property {string|null} coreDir - Resolved core package directory, or null.
|
|
142
145
|
* @property {boolean} [ownCli] - Whether the project installs its own CLI;
|
|
143
146
|
* false means the copy that started the run answered it (spec AST-081 FR2).
|
|
147
|
+
* @property {string[]} [addedThemePackages] - Packages of the project's added
|
|
148
|
+
* themes, which `theme-core-peers` checks against Core
|
|
144
149
|
* @property {string|null} [projectCore] - The Core release the project names
|
|
145
150
|
* (installed, else locked, else declared), as the daily hint reads it.
|
|
146
151
|
* @property {string|null} configPath - Resolved astryx.config.mjs path, or null.
|
|
@@ -191,6 +196,22 @@ function readPkg(pkgPath) {
|
|
|
191
196
|
}
|
|
192
197
|
}
|
|
193
198
|
|
|
199
|
+
/**
|
|
200
|
+
* Packages that own the project's added themes (local themes excluded); empty
|
|
201
|
+
* when the project manages no themes or its theme state cannot be read.
|
|
202
|
+
* @param {string} cwd
|
|
203
|
+
* @returns {string[]}
|
|
204
|
+
*/
|
|
205
|
+
function addedThemePackages(cwd) {
|
|
206
|
+
try {
|
|
207
|
+
return Object.values(readThemeState(cwd).themes ?? {}).filter(
|
|
208
|
+
owner => typeof owner === 'string' && !isLocalThemeOwner(owner),
|
|
209
|
+
);
|
|
210
|
+
} catch {
|
|
211
|
+
return [];
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
194
215
|
/**
|
|
195
216
|
* Read the version of an installed package from a resolved directory.
|
|
196
217
|
* @param {string|null} dir
|
|
@@ -1006,6 +1027,69 @@ export function checkIntegrationIssues(ctx) {
|
|
|
1006
1027
|
};
|
|
1007
1028
|
}
|
|
1008
1029
|
|
|
1030
|
+
/**
|
|
1031
|
+
* Every loaded integration's `@astryxdesign/core` peer range admits the
|
|
1032
|
+
* installed Core: a package's declared peer ranges define the Core versions it
|
|
1033
|
+
* supports (spec:AST-017 FR12). A package made for another Core installs with
|
|
1034
|
+
* only a package manager warning, and its components, themes and docs may not
|
|
1035
|
+
* work. New, so it warns: a project that passed before keeps passing.
|
|
1036
|
+
* Packages of added themes are left to `theme-core-peers` (spec:AST-050 FR11),
|
|
1037
|
+
* which applies the same rule. Null when Core is not installed or no other
|
|
1038
|
+
* loaded integration declares a Core range.
|
|
1039
|
+
* @param {DoctorContext} ctx
|
|
1040
|
+
* @returns {DoctorCheck | null}
|
|
1041
|
+
*/
|
|
1042
|
+
export function checkIntegrationCoreRange(ctx) {
|
|
1043
|
+
const core = pkgVersion(ctx.coreDir);
|
|
1044
|
+
if (!core || ctx.integrations == null) return null;
|
|
1045
|
+
// `theme-core-peers` already judges each added theme package by the same
|
|
1046
|
+
// rule (`corePeerRange`), with a fix that keeps the theme setup working.
|
|
1047
|
+
const reportedByThemeChecks = new Set(ctx.addedThemePackages ?? []);
|
|
1048
|
+
/** @type {Array<{name: string, version: string | null, range: string, accepts: boolean}>} */
|
|
1049
|
+
const declared = [];
|
|
1050
|
+
for (const integration of ctx.integrations) {
|
|
1051
|
+
if (integration.__loadError != null || !integration.__packageDir) continue;
|
|
1052
|
+
const pkg = readPkg(path.join(integration.__packageDir, 'package.json'));
|
|
1053
|
+
const name = typeof pkg?.name === 'string' ? pkg.name : integration.name;
|
|
1054
|
+
if (reportedByThemeChecks.has(name)) continue;
|
|
1055
|
+
const {range, accepts} = corePeerRange(pkg, core);
|
|
1056
|
+
// An integration need not depend on Core; only a declared, non-empty range
|
|
1057
|
+
// is a claim about which Core it supports.
|
|
1058
|
+
if (range == null || range === '') continue;
|
|
1059
|
+
declared.push({
|
|
1060
|
+
name,
|
|
1061
|
+
version: typeof pkg?.version === 'string' ? pkg.version : null,
|
|
1062
|
+
range,
|
|
1063
|
+
accepts,
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
if (declared.length === 0) return null;
|
|
1067
|
+
const excluded = declared.filter(d => !d.accepts);
|
|
1068
|
+
const label = 'Integrations support the installed Core';
|
|
1069
|
+
if (excluded.length === 0) {
|
|
1070
|
+
return {
|
|
1071
|
+
id: 'integration-core-range',
|
|
1072
|
+
label,
|
|
1073
|
+
status: 'pass',
|
|
1074
|
+
message: `${declared.length} loaded integration${declared.length === 1 ? ' supports' : 's support'} @astryxdesign/core ${core} (${nameIntegrations(declared)}).`,
|
|
1075
|
+
};
|
|
1076
|
+
}
|
|
1077
|
+
return {
|
|
1078
|
+
id: 'integration-core-range',
|
|
1079
|
+
label,
|
|
1080
|
+
status: 'warn',
|
|
1081
|
+
message: `${excluded
|
|
1082
|
+
.map(
|
|
1083
|
+
d =>
|
|
1084
|
+
`${d.name}${d.version ? `@${d.version}` : ''} supports @astryxdesign/core ${d.range}`,
|
|
1085
|
+
)
|
|
1086
|
+
.join(
|
|
1087
|
+
'; ',
|
|
1088
|
+
)}, but the project has ${core}. ${excluded.length === 1 ? 'Its' : 'Their'} components, themes and docs were made for another Core and may not work.`,
|
|
1089
|
+
fix: `Install a release of ${excluded.length === 1 ? 'that package' : 'each package'} whose @astryxdesign/core range includes ${core}, or move the project to a Core in that range. When no such release exists, ask the package's owner for one.`,
|
|
1090
|
+
};
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1009
1093
|
/**
|
|
1010
1094
|
* The project's icon sets (AST-084 FR17). Fails when `experimental.iconSet`
|
|
1011
1095
|
* names a set, main or backup, that is not installed, that is installed but
|
|
@@ -2193,7 +2277,7 @@ export function checkGatherCache() {
|
|
|
2193
2277
|
id: 'gather-cache',
|
|
2194
2278
|
label: 'Kept catalog cache',
|
|
2195
2279
|
status: 'info',
|
|
2196
|
-
message: `search, build, component, template, theme, discover and doctor keep what they gather (search's catalogs, each integration's check results, template discovery's records, and doctor's docs checks) in ${summary.dir} (${summary.entries} ${summary.entries === 1 ? 'entry' : 'entries'}, ${size})${summary.pnp ? ", but not in a run under Yarn Plug'n'Play's loader, such as `yarn astryx`, which gathers every time" : ''}; each is used only while nothing it read has changed, and deleting the folder clears it.`,
|
|
2280
|
+
message: `search, build, component, template, theme, discover and doctor keep what they gather (search's catalogs, each integration's check results, template discovery's records, integrations' theme records, and doctor's docs checks) in ${summary.dir} (${summary.entries} ${summary.entries === 1 ? 'entry' : 'entries'}, ${size})${summary.pnp ? ", but not in a run under Yarn Plug'n'Play's loader, such as `yarn astryx`, which gathers every time" : ''}; each is used only while nothing it read has changed, and deleting the folder clears it.`,
|
|
2197
2281
|
};
|
|
2198
2282
|
}
|
|
2199
2283
|
|
|
@@ -2211,6 +2295,7 @@ export const SYNC_CHECKS = [
|
|
|
2211
2295
|
checkConfiguredIntegrations,
|
|
2212
2296
|
checkProviderIdentity,
|
|
2213
2297
|
checkIntegrationIssues,
|
|
2298
|
+
checkIntegrationCoreRange,
|
|
2214
2299
|
checkIconSets,
|
|
2215
2300
|
checkIconPlaceholders,
|
|
2216
2301
|
checkAgentDocs,
|
|
@@ -2401,6 +2486,7 @@ export async function runChecks(options = {}) {
|
|
|
2401
2486
|
coreDir,
|
|
2402
2487
|
ownCli: projectHasOwnCli(cwd),
|
|
2403
2488
|
projectCore: projectCoreVersion(cwd),
|
|
2489
|
+
addedThemePackages: addedThemePackages(cwd),
|
|
2404
2490
|
configPath,
|
|
2405
2491
|
integrations,
|
|
2406
2492
|
docsCatalog,
|
|
@@ -8,12 +8,13 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import * as path from 'node:path';
|
|
11
|
-
import {parse} from '
|
|
11
|
+
import {babelParse as parse} from '../../foundation/runtime/lazy-dependencies.mjs';
|
|
12
12
|
import postcss from 'postcss';
|
|
13
13
|
import {
|
|
14
14
|
collectUnloadedFonts,
|
|
15
15
|
discoverDoctorThemes,
|
|
16
16
|
discoverDoctorUnmigratedCopies,
|
|
17
|
+
corePeerRange,
|
|
17
18
|
findDoctorCoreDir,
|
|
18
19
|
doctorElementPropOrigins,
|
|
19
20
|
doctorStylesheetImports,
|
|
@@ -41,7 +42,6 @@ import {
|
|
|
41
42
|
getCliInvocation,
|
|
42
43
|
formatCliCommand,
|
|
43
44
|
} from '../../foundation/env/package-manager.mjs';
|
|
44
|
-
import {satisfiesRange} from '../../foundation/env/semver.mjs';
|
|
45
45
|
import {logger} from '../logger.mjs';
|
|
46
46
|
|
|
47
47
|
/** @typedef {import('./doctor.mjs').DoctorCheck} DoctorCheck */
|
|
@@ -1248,17 +1248,13 @@ export async function checkAppThemes(cwd) {
|
|
|
1248
1248
|
const pkg = packageDir
|
|
1249
1249
|
? readPackageJson(path.join(packageDir, 'package.json'))
|
|
1250
1250
|
: null;
|
|
1251
|
-
const range = pkg
|
|
1252
|
-
if (
|
|
1253
|
-
!coreVersion ||
|
|
1254
|
-
typeof range !== 'string' ||
|
|
1255
|
-
!satisfiesRange(coreVersion, range)
|
|
1256
|
-
) {
|
|
1251
|
+
const {range, accepts} = corePeerRange(pkg, coreVersion);
|
|
1252
|
+
if (!accepts) {
|
|
1257
1253
|
peerProblems.push({
|
|
1258
1254
|
slug,
|
|
1259
1255
|
owner,
|
|
1260
|
-
range
|
|
1261
|
-
message: `${slug}: ${owner} requires ${
|
|
1256
|
+
range,
|
|
1257
|
+
message: `${slug}: ${owner} requires ${range ?? 'an undeclared Core range'}, installed ${coreVersion ?? 'none'}`,
|
|
1262
1258
|
});
|
|
1263
1259
|
}
|
|
1264
1260
|
}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
import * as fs from 'node:fs';
|
|
15
15
|
import * as path from 'node:path';
|
|
16
|
-
import jscodeshift from '
|
|
16
|
+
import {jscodeshift as loadJscodeshift} from '../../foundation/runtime/lazy-dependencies.mjs';
|
|
17
17
|
import {AstryxError} from '../error.mjs';
|
|
18
18
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
19
19
|
import {
|
|
@@ -928,8 +928,8 @@ async function addAgentDoc(line, options) {
|
|
|
928
928
|
const source = manifestExists
|
|
929
929
|
? fs.readFileSync(manifestFile, 'utf-8')
|
|
930
930
|
: 'export default {};\n';
|
|
931
|
-
const j =
|
|
932
|
-
/** @type {ReturnType<ReturnType<typeof
|
|
931
|
+
const j = loadJscodeshift().withParser('tsx');
|
|
932
|
+
/** @type {ReturnType<ReturnType<ReturnType<typeof loadJscodeshift>['withParser']>>} */
|
|
933
933
|
let ast;
|
|
934
934
|
try {
|
|
935
935
|
ast = j(source);
|
|
@@ -49,7 +49,7 @@ import {
|
|
|
49
49
|
} from '../../foundation/discovery/docs-discovery.mjs';
|
|
50
50
|
import {discoverIntegrationThemes} from '../../foundation/discovery/theme-discovery.mjs';
|
|
51
51
|
import {inspectPackageExport} from '../../foundation/discovery/package-exports.mjs';
|
|
52
|
-
import {
|
|
52
|
+
import {babelParse as parseModule} from '../../foundation/runtime/lazy-dependencies.mjs';
|
|
53
53
|
import {moduleExportsName} from '../../foundation/discovery/module-exports.mjs';
|
|
54
54
|
import {
|
|
55
55
|
ThemeImportError,
|
package/api/search/_adapter.mjs
CHANGED
|
@@ -137,6 +137,18 @@ async function gatherDomains(options) {
|
|
|
137
137
|
* objects it shares.
|
|
138
138
|
*/
|
|
139
139
|
const GATHER_CODEC = {
|
|
140
|
+
/**
|
|
141
|
+
* The shape a read-back gather needs: its candidates and components.
|
|
142
|
+
* @param {any} gathered
|
|
143
|
+
*/
|
|
144
|
+
valid: gathered =>
|
|
145
|
+
gathered != null &&
|
|
146
|
+
Array.isArray(gathered.all) &&
|
|
147
|
+
Array.isArray(gathered.components) &&
|
|
148
|
+
gathered.all.every(
|
|
149
|
+
(/** @type {any} */ c) => c != null && typeof c === 'object',
|
|
150
|
+
) &&
|
|
151
|
+
gathered.components.every((/** @type {any} */ c) => c != null),
|
|
140
152
|
/**
|
|
141
153
|
* @param {any} gathered
|
|
142
154
|
* @returns {any}
|
|
@@ -17,11 +17,12 @@ export function entryTable(all: any[], cards: Record<string, {
|
|
|
17
17
|
* A table's plain-JSON form and back. Candidates are kept as their place in
|
|
18
18
|
* `all`, maps as their entries in order, so the table reads back the same.
|
|
19
19
|
* @param {any[]} all
|
|
20
|
-
* @returns {{encode: (table: EntryTable) => any, decode: (stored: any) => EntryTable}}
|
|
20
|
+
* @returns {{encode: (table: EntryTable) => any, decode: (stored: any) => EntryTable, valid: (table: any) => boolean}}
|
|
21
21
|
*/
|
|
22
22
|
export function tableCodec(all: any[]): {
|
|
23
23
|
encode: (table: EntryTable) => any;
|
|
24
24
|
decode: (stored: any) => EntryTable;
|
|
25
|
+
valid: (table: any) => boolean;
|
|
25
26
|
};
|
|
26
27
|
/**
|
|
27
28
|
* @param {any[]} all
|
package/api/search/_entries.mjs
CHANGED
|
@@ -97,10 +97,37 @@ let last = null;
|
|
|
97
97
|
* A table's plain-JSON form and back. Candidates are kept as their place in
|
|
98
98
|
* `all`, maps as their entries in order, so the table reads back the same.
|
|
99
99
|
* @param {any[]} all
|
|
100
|
-
* @returns {{encode: (table: EntryTable) => any, decode: (stored: any) => EntryTable}}
|
|
100
|
+
* @returns {{encode: (table: EntryTable) => any, decode: (stored: any) => EntryTable, valid: (table: any) => boolean}}
|
|
101
101
|
*/
|
|
102
102
|
export function tableCodec(all) {
|
|
103
103
|
return {
|
|
104
|
+
/**
|
|
105
|
+
* The shape a read-back table needs: a candidate for every id, and its
|
|
106
|
+
* fields.
|
|
107
|
+
* @param {any} table
|
|
108
|
+
*/
|
|
109
|
+
valid: table =>
|
|
110
|
+
table != null &&
|
|
111
|
+
Array.isArray(table.ids) &&
|
|
112
|
+
Array.isArray(table.candidate) &&
|
|
113
|
+
table.candidate.length === table.ids.length &&
|
|
114
|
+
table.candidate.every((/** @type {any} */ c) => c != null) &&
|
|
115
|
+
Array.isArray(table.domain) &&
|
|
116
|
+
table.domain.length === table.ids.length &&
|
|
117
|
+
Array.isArray(table.name) &&
|
|
118
|
+
table.name.length === table.ids.length &&
|
|
119
|
+
table.fields != null &&
|
|
120
|
+
['name', 'desc', 'card'].every(f => {
|
|
121
|
+
const field = table.fields[f];
|
|
122
|
+
return (
|
|
123
|
+
field != null &&
|
|
124
|
+
field.post instanceof Map &&
|
|
125
|
+
field.idf instanceof Map &&
|
|
126
|
+
Array.isArray(field.len) &&
|
|
127
|
+
field.len.length === table.ids.length &&
|
|
128
|
+
typeof field.avg === 'number'
|
|
129
|
+
);
|
|
130
|
+
}),
|
|
104
131
|
encode(table) {
|
|
105
132
|
const place = new Map(all.map((c, k) => [c, k]));
|
|
106
133
|
const t = /** @type {any} */ (table);
|
|
@@ -15,7 +15,7 @@ import * as path from 'node:path';
|
|
|
15
15
|
import {isBuiltin} from 'node:module';
|
|
16
16
|
import {packageOf} from '../../foundation/render/served-packages.mjs';
|
|
17
17
|
import {resolveInstalledPackageDir} from '../../foundation/integrations/installed-package.mjs';
|
|
18
|
-
import {parse} from '
|
|
18
|
+
import {babelParse as parse} from '../../foundation/runtime/lazy-dependencies.mjs';
|
|
19
19
|
import {
|
|
20
20
|
inspectPackageExport,
|
|
21
21
|
sourceExportTarget,
|
package/api/theme/_fork.mjs
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import * as path from 'node:path';
|
|
14
|
-
import {parse} from '
|
|
14
|
+
import {babelParse as parse} from '../../foundation/runtime/lazy-dependencies.mjs';
|
|
15
15
|
import {AstryxError} from '../error.mjs';
|
|
16
16
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
17
17
|
import {
|
|
@@ -81,6 +81,33 @@ export function setEditorFolderListener(listener: ((warning: string) => void) |
|
|
|
81
81
|
* @param {(() => void) | null} listener
|
|
82
82
|
*/
|
|
83
83
|
export function setPrivateVarErrorListener(listener: (() => void) | null): void;
|
|
84
|
+
/**
|
|
85
|
+
* A build's mode flags: what it does (`--check` compares, never writes) and
|
|
86
|
+
* where (`--out`), carried into every build command a refusal suggests.
|
|
87
|
+
* @typedef {{check?: boolean, out?: string, iconsSpecifier?: string}} BuildMode
|
|
88
|
+
*/
|
|
89
|
+
/**
|
|
90
|
+
* How a suggested build writes its source: `glob` leaves a pattern as typed
|
|
91
|
+
* (unquoted, so the shell expands it); `family` makes it a --family run,
|
|
92
|
+
* and `familyKey` names its key (a family run never takes --out).
|
|
93
|
+
* @typedef {{glob?: boolean, family?: boolean, familyKey?: string}} SuggestionShape
|
|
94
|
+
*/
|
|
95
|
+
/**
|
|
96
|
+
* The `theme build` command for `source` with the caller's mode flags, so a
|
|
97
|
+
* suggestion never turns a check into a write or moves the outputs.
|
|
98
|
+
* @param {string | string[]} source as the user types it, from cwd; several
|
|
99
|
+
* for a family (with `shape.familyKey`)
|
|
100
|
+
* @param {BuildMode} mode
|
|
101
|
+
* @param {string} cwd
|
|
102
|
+
* @param {{group: string, build: string}} [words] the command's own words
|
|
103
|
+
* (`experimental theme compile`), else `theme build`
|
|
104
|
+
* @param {SuggestionShape} [shape]
|
|
105
|
+
* @returns {string}
|
|
106
|
+
*/
|
|
107
|
+
export function buildSuggestion(source: string | string[], mode: BuildMode, cwd: string, words?: {
|
|
108
|
+
group: string;
|
|
109
|
+
build: string;
|
|
110
|
+
}, shape?: SuggestionShape): string;
|
|
84
111
|
/**
|
|
85
112
|
* Publish the outputs a batch deferred, one theme at a time, in build order.
|
|
86
113
|
* @param {Array<Array<{dest: string, content: string}>>} deferred
|
|
@@ -90,11 +117,12 @@ export function writeDeferredBuildOutputs(deferred: Array<Array<{
|
|
|
90
117
|
content: string;
|
|
91
118
|
}>>): void;
|
|
92
119
|
/**
|
|
93
|
-
* Import specifier for install/scaffold instructions
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
120
|
+
* Import specifier for install/scaffold instructions, from a file directly
|
|
121
|
+
* in the project's src/ (the file the printed snippet says it is relative
|
|
122
|
+
* to; callers pass the output folder from the outputs' project root): an output
|
|
123
|
+
* under src/ is `./themes/gothic/gothic`, one beside src/ is
|
|
124
|
+
* `../themes/gothic/gothic`.
|
|
125
|
+
* @param {string} relDir the output folder, relative to the outputs' project root
|
|
98
126
|
* @param {string} base
|
|
99
127
|
* @returns {string}
|
|
100
128
|
*/
|
|
@@ -252,6 +280,25 @@ export type CoreBindings = {
|
|
|
252
280
|
generateOnMediaCSS: any;
|
|
253
281
|
generateAdaptationCSS: any;
|
|
254
282
|
};
|
|
283
|
+
/**
|
|
284
|
+
* A build's mode flags: what it does (`--check` compares, never writes) and
|
|
285
|
+
* where (`--out`), carried into every build command a refusal suggests.
|
|
286
|
+
*/
|
|
287
|
+
export type BuildMode = {
|
|
288
|
+
check?: boolean;
|
|
289
|
+
out?: string;
|
|
290
|
+
iconsSpecifier?: string;
|
|
291
|
+
};
|
|
292
|
+
/**
|
|
293
|
+
* How a suggested build writes its source: `glob` leaves a pattern as typed
|
|
294
|
+
* (unquoted, so the shell expands it); `family` makes it a --family run,
|
|
295
|
+
* and `familyKey` names its key (a family run never takes --out).
|
|
296
|
+
*/
|
|
297
|
+
export type SuggestionShape = {
|
|
298
|
+
glob?: boolean;
|
|
299
|
+
family?: boolean;
|
|
300
|
+
familyKey?: string;
|
|
301
|
+
};
|
|
255
302
|
/**
|
|
256
303
|
* How one `prop:value` pair on a component target is classified — the single
|
|
257
304
|
* vocabulary both the root and adaptation paths reason in.
|