@astryxdesign/cli 0.7.3-canary.641d08e → 0.7.3-canary.6856cfa
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 +63 -63
- package/api/build/_adapter.mjs +37 -25
- package/api/build/blocks/blocks.d.mts +68 -18
- package/api/build/blocks/blocks.mjs +475 -116
- package/api/build/blocks/blocks.test.mjs +191 -61
- package/api/build/blocks/blocks.weights.json +1 -1
- package/api/build/build.type.mjs +1 -1
- package/api/build/kit/answer.d.mts +9 -5
- package/api/build/kit/answer.mjs +123 -13
- package/api/build/kit/answer.test.mjs +73 -3
- package/api/build/kit/signals.d.mts +19 -0
- package/api/build/kit/signals.mjs +18 -7
- package/api/build/tree.mjs +2 -1
- package/api/build/tree.test.mjs +36 -28
- package/api/component/_adapter.mjs +39 -5
- package/api/component/component-replacement.test.mjs +1 -0
- package/api/component/component.mjs +1 -1
- package/api/discover/_adapter.d.mts +1 -2
- package/api/discover/_adapter.mjs +6 -8
- package/api/discover/discover.mjs +0 -1
- package/api/docs/_adapter.mjs +4 -0
- package/api/doctor/_adapter.d.mts +24 -10
- package/api/doctor/_adapter.mjs +28 -25
- package/api/doctor/doctor.d.mts +7 -4
- package/api/doctor/doctor.mjs +52 -14
- package/api/doctor/doctor.test.mjs +58 -0
- package/api/hook/hook.mjs +1 -1
- package/api/integration/validate-integration-fixes.test.mjs +6 -5
- package/api/integration/validate-integration-gaps.test.mjs +12 -1
- package/api/integration/validate-integration.d.mts +4 -0
- package/api/integration/validate-integration.mjs +48 -7
- package/api/integration/validate-integration.type.d.mts +36 -5
- package/api/integration/validate-integration.type.mjs +27 -6
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/_adapter.d.mts +16 -0
- package/api/search/_adapter.mjs +39 -0
- package/api/search/_adapter.test.mjs +173 -0
- package/api/search/_entries.d.mts +11 -0
- package/api/search/_entries.mjs +35 -17
- package/api/search/_entries.test.mjs +48 -0
- package/api/search/search.mjs +6 -2
- package/api/template/template.mjs +5 -1
- package/assets/docs/tree/checks.doc.mjs +1 -1
- package/assets/docs/tree/versioning.doc.mjs +4 -0
- package/assets/docs/use-integrations.doc.mjs +120 -0
- package/clients/cli/command-result-coverage.test.mjs +6 -5
- package/clients/cli/commands/build-theme.color-scheme.test.mjs +1 -1
- package/clients/cli/commands/{component/index.mjs → component.mjs} +37 -37
- package/clients/cli/commands/component.test.mjs +6 -6
- package/clients/cli/commands/doctor-integration.test.mjs +49 -1
- package/clients/cli/commands/doctor.mjs +10 -0
- package/clients/cli/commands/{hook/index.mjs → hook.mjs} +22 -22
- package/clients/cli/commands/import-hint-correctness.test.mjs +1 -1
- package/clients/cli/commands/manifest.doc.mjs +1 -1
- package/clients/cli/commands/manifest.mjs +67 -0
- package/clients/cli/commands/postinstall.doc.mjs +23 -0
- package/clients/cli/commands/postinstall.mjs +31 -0
- package/clients/cli/commands/setup-nudge.test.mjs +17 -0
- package/clients/cli/commands/{build-theme.mjs → theme.mjs} +1 -1
- package/clients/cli/index.mjs +35 -93
- package/clients/cli/lib/component-format.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +12 -7
- package/clients/cli/lib/exit-codes.test.mjs +5 -0
- package/clients/cli/lib/manifest.test.mjs +12 -0
- package/clients/cli/lib/welcome-box.mjs +50 -0
- package/foundation/agent-docs/agent-doc-state.d.mts +12 -0
- package/foundation/agent-docs/agent-doc-state.mjs +24 -2
- package/foundation/agent-docs/agent-docs.mjs +5 -5
- package/foundation/agent-docs/computer-agent-text.mjs +16 -1
- package/foundation/agent-docs/computer-agent-text.test.mjs +23 -2
- package/foundation/discovery/runner-commands.mjs +1 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +21 -9
- package/foundation/fs/read-record.d.mts +18 -0
- package/foundation/fs/read-record.mjs +131 -0
- package/foundation/fs/read-record.test.mjs +77 -0
- package/foundation/integrations/cli-peer-version.d.mts +36 -0
- package/foundation/integrations/cli-peer-version.mjs +132 -0
- package/foundation/integrations/cli-peer-version.test.mjs +354 -0
- package/foundation/integrations/exports-subpaths.d.mts +57 -0
- package/foundation/integrations/exports-subpaths.mjs +113 -0
- package/foundation/integrations/public-imports.d.mts +118 -0
- package/foundation/integrations/public-imports.mjs +1769 -0
- package/foundation/integrations/public-imports.test.mjs +1793 -0
- package/foundation/release/global-state.d.mts +8 -4
- package/foundation/release/global-state.mjs +4 -2
- package/foundation/release/notices.d.mts +62 -8
- package/foundation/release/notices.mjs +136 -25
- package/foundation/release/notices.test.mjs +21 -0
- package/foundation/response/response-types.doc.mjs +1 -1
- package/foundation/text/string-utils.d.mts +2 -1
- package/foundation/text/string-utils.mjs +16 -5
- package/foundation/text/suggest-order.d.mts +72 -0
- package/foundation/text/suggest-order.mjs +363 -0
- package/foundation/text/suggest-order.test.mjs +259 -0
- package/package.json +9 -9
package/api/docs/_adapter.mjs
CHANGED
|
@@ -71,6 +71,7 @@ import {
|
|
|
71
71
|
import {findCoreDir} from '../../foundation/fs/paths.mjs';
|
|
72
72
|
import {AstryxError} from '../error.mjs';
|
|
73
73
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
74
|
+
import {orderRouteSuggestions} from '../../foundation/text/suggest-order.mjs';
|
|
74
75
|
import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
|
|
75
76
|
|
|
76
77
|
export {OVERLAY_LANGUAGES, overlayLanguages};
|
|
@@ -1622,6 +1623,9 @@ export async function unknownTopicError(topic, catalog) {
|
|
|
1622
1623
|
...catalog.names().map(name => ({name, reason: 'available topic'})),
|
|
1623
1624
|
];
|
|
1624
1625
|
}
|
|
1626
|
+
if (typeof topic === 'string') {
|
|
1627
|
+
suggestions = orderRouteSuggestions(topic, suggestions);
|
|
1628
|
+
}
|
|
1625
1629
|
// A route that moved names where it went, ahead of the usual suggestions
|
|
1626
1630
|
// (spec:AST-046 FR9, FR6).
|
|
1627
1631
|
const moved = movedRoute(topic, tree);
|
|
@@ -108,13 +108,14 @@ export function outsideProject(cwd: string): boolean;
|
|
|
108
108
|
/**
|
|
109
109
|
* The commands that bring a project's own CLI and Core to one release, with
|
|
110
110
|
* the project's package manager: Core up to the CLI, then its codemods, when
|
|
111
|
-
* the CLI is newer; else the CLI to the Core's release.
|
|
111
|
+
* the CLI is newer; else the CLI to the Core's release. Null when no
|
|
112
|
+
* command fits (see `alignCliAndCore`).
|
|
112
113
|
* @param {string} cwd
|
|
113
114
|
* @param {string} cli
|
|
114
115
|
* @param {string} core
|
|
115
|
-
* @returns {string}
|
|
116
|
+
* @returns {string | null}
|
|
116
117
|
*/
|
|
117
|
-
export function alignCommand(cwd: string, cli: string, core: string): string;
|
|
118
|
+
export function alignCommand(cwd: string, cli: string, core: string): string | null;
|
|
118
119
|
/**
|
|
119
120
|
* The Core release the project at `cwd` names: installed, else locked, else
|
|
120
121
|
* declared; the version the daily hint and notice compare against (spec
|
|
@@ -131,19 +132,32 @@ export function projectCoreVersion(cwd: string): string | null;
|
|
|
131
132
|
export function projectHasOwnCli(cwd: string): boolean;
|
|
132
133
|
/**
|
|
133
134
|
* The command that adds the CLI at `version` with the project's package
|
|
134
|
-
* manager.
|
|
135
|
+
* manager, and the Core it matches: from a folder whose package.json declares
|
|
136
|
+
* no Astryx package, in the Astryx project above at that project's Core; null
|
|
137
|
+
* when there is none (see `cliInstallAdvice`).
|
|
135
138
|
* @param {string} cwd
|
|
136
139
|
* @param {string} version
|
|
137
|
-
* @returns {string}
|
|
140
|
+
* @returns {{command: string, core: string} | null}
|
|
138
141
|
*/
|
|
139
|
-
export function addCliCommandFor(cwd: string, version: string):
|
|
142
|
+
export function addCliCommandFor(cwd: string, version: string): {
|
|
143
|
+
command: string;
|
|
144
|
+
core: string;
|
|
145
|
+
} | null;
|
|
140
146
|
/**
|
|
141
|
-
* The command that adds a package
|
|
142
|
-
*
|
|
147
|
+
* The command that adds a package to the project of `cwd`; null in a folder
|
|
148
|
+
* that belongs to no project or whose package.json is not the project's (see
|
|
149
|
+
* `projectAddCommand`).
|
|
143
150
|
* @param {string} cwd
|
|
144
|
-
* @returns {(name: string) => string}
|
|
151
|
+
* @returns {((name: string) => string) | null}
|
|
152
|
+
*/
|
|
153
|
+
export function installCommandFor(cwd: string): ((name: string) => string) | null;
|
|
154
|
+
/**
|
|
155
|
+
* Whether `cwd` is inside a project whose package.json is not the project's,
|
|
156
|
+
* so advice points at the project's folder (see `installFolder`).
|
|
157
|
+
* @param {string} cwd
|
|
158
|
+
* @returns {boolean}
|
|
145
159
|
*/
|
|
146
|
-
export function
|
|
160
|
+
export function insideProjectElsewhere(cwd: string): boolean;
|
|
147
161
|
export { resolveRecordedTheme } from "../theme/theme.mjs";
|
|
148
162
|
export { collectUnloadedFonts } from "../theme/build/font-warning.mjs";
|
|
149
163
|
export const SOURCE_EXTENSIONS: Set<string>;
|
package/api/doctor/_adapter.mjs
CHANGED
|
@@ -10,20 +10,17 @@ import {
|
|
|
10
10
|
stateLockHolder,
|
|
11
11
|
} from '../../foundation/release/global-state.mjs';
|
|
12
12
|
import {
|
|
13
|
-
addCliCommand,
|
|
14
13
|
alignCliAndCore,
|
|
14
|
+
cliInstallAdvice,
|
|
15
|
+
installFolder,
|
|
16
|
+
projectAddCommand,
|
|
15
17
|
globalBehind,
|
|
16
18
|
globalUpgradeCommand,
|
|
17
19
|
lastNoticeSkip,
|
|
18
20
|
projectLag,
|
|
19
21
|
} from '../../foundation/release/notices.mjs';
|
|
20
|
-
import {
|
|
21
|
-
coreVersionOf,
|
|
22
|
-
isGlobalCopy,
|
|
23
|
-
projectRootOf,
|
|
24
|
-
} from '../../foundation/release/choose.mjs';
|
|
22
|
+
import {coreVersionOf, isGlobalCopy} from '../../foundation/release/choose.mjs';
|
|
25
23
|
import {readReleaseFacts} from '../../foundation/release/project.mjs';
|
|
26
|
-
import {detectPackageManager} from '../../foundation/env/package-manager.mjs';
|
|
27
24
|
import {astryxCommandsOnSearchPath} from '../../foundation/env/search-path.mjs';
|
|
28
25
|
import {readDeclaredDependencies} from '../../foundation/integrations/autolink.mjs';
|
|
29
26
|
import {
|
|
@@ -348,11 +345,12 @@ export function outsideProject(/** @type {string} */ cwd) {
|
|
|
348
345
|
/**
|
|
349
346
|
* The commands that bring a project's own CLI and Core to one release, with
|
|
350
347
|
* the project's package manager: Core up to the CLI, then its codemods, when
|
|
351
|
-
* the CLI is newer; else the CLI to the Core's release.
|
|
348
|
+
* the CLI is newer; else the CLI to the Core's release. Null when no
|
|
349
|
+
* command fits (see `alignCliAndCore`).
|
|
352
350
|
* @param {string} cwd
|
|
353
351
|
* @param {string} cli
|
|
354
352
|
* @param {string} core
|
|
355
|
-
* @returns {string}
|
|
353
|
+
* @returns {string | null}
|
|
356
354
|
*/
|
|
357
355
|
export function alignCommand(cwd, cli, core) {
|
|
358
356
|
return alignCliAndCore({cwd, cli, core});
|
|
@@ -380,30 +378,35 @@ export function projectHasOwnCli(cwd) {
|
|
|
380
378
|
|
|
381
379
|
/**
|
|
382
380
|
* The command that adds the CLI at `version` with the project's package
|
|
383
|
-
* manager.
|
|
381
|
+
* manager, and the Core it matches: from a folder whose package.json declares
|
|
382
|
+
* no Astryx package, in the Astryx project above at that project's Core; null
|
|
383
|
+
* when there is none (see `cliInstallAdvice`).
|
|
384
384
|
* @param {string} cwd
|
|
385
385
|
* @param {string} version
|
|
386
|
-
* @returns {string}
|
|
386
|
+
* @returns {{command: string, core: string} | null}
|
|
387
387
|
*/
|
|
388
388
|
export function addCliCommandFor(cwd, version) {
|
|
389
|
-
|
|
389
|
+
const advice = cliInstallAdvice({cwd, core: version});
|
|
390
|
+
return advice?.command ? {command: advice.command, core: advice.core} : null;
|
|
390
391
|
}
|
|
391
392
|
|
|
392
393
|
/**
|
|
393
|
-
* The command that adds a package
|
|
394
|
-
*
|
|
394
|
+
* The command that adds a package to the project of `cwd`; null in a folder
|
|
395
|
+
* that belongs to no project or whose package.json is not the project's (see
|
|
396
|
+
* `projectAddCommand`).
|
|
395
397
|
* @param {string} cwd
|
|
396
|
-
* @returns {(name: string) => string}
|
|
398
|
+
* @returns {((name: string) => string) | null}
|
|
397
399
|
*/
|
|
398
400
|
export function installCommandFor(cwd) {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
401
|
+
return projectAddCommand(cwd);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Whether `cwd` is inside a project whose package.json is not the project's,
|
|
406
|
+
* so advice points at the project's folder (see `installFolder`).
|
|
407
|
+
* @param {string} cwd
|
|
408
|
+
* @returns {boolean}
|
|
409
|
+
*/
|
|
410
|
+
export function insideProjectElsewhere(cwd) {
|
|
411
|
+
return installFolder(cwd)?.moved === true;
|
|
409
412
|
}
|
package/api/doctor/doctor.d.mts
CHANGED
|
@@ -259,15 +259,18 @@ export function checkComputerIntegrations(ctx: ComputerContext): DoctorCheck;
|
|
|
259
259
|
* Inside a project, the integrations installed for the computer that the
|
|
260
260
|
* project does not install: available, never used (spec AST-081 FR12).
|
|
261
261
|
* Always info.
|
|
262
|
-
* @param {{installed: Set<string>, candidates: import('../../foundation/integrations/computer-integrations.mjs').ComputerIntegrationCandidate[], install: (name: string) => string}} input
|
|
262
|
+
* @param {{installed: Set<string>, candidates: import('../../foundation/integrations/computer-integrations.mjs').ComputerIntegrationCandidate[], install: ((name: string) => string) | null, elsewhere?: boolean}} input
|
|
263
263
|
* `install`: the command that adds a package with the project's package
|
|
264
|
-
* manager (read by the adapter)
|
|
264
|
+
* manager (read by the adapter); null when the folder belongs to no
|
|
265
|
+
* project, or `elsewhere`: its package.json is not the project's, where the
|
|
266
|
+
* fix points at the project's folder
|
|
265
267
|
* @returns {DoctorCheck}
|
|
266
268
|
*/
|
|
267
|
-
export function checkComputerIntegrationsAvailable({ installed, candidates, install }: {
|
|
269
|
+
export function checkComputerIntegrationsAvailable({ installed, candidates, install, elsewhere }: {
|
|
268
270
|
installed: Set<string>;
|
|
269
271
|
candidates: import("../../foundation/integrations/computer-integrations.mjs").ComputerIntegrationCandidate[];
|
|
270
|
-
install: (name: string) => string;
|
|
272
|
+
install: ((name: string) => string) | null;
|
|
273
|
+
elsewhere?: boolean;
|
|
271
274
|
}): DoctorCheck;
|
|
272
275
|
/**
|
|
273
276
|
* Run all diagnostic checks and return a structured report.
|
package/api/doctor/doctor.mjs
CHANGED
|
@@ -65,8 +65,8 @@ import {typedEdges} from '../docs/node/node.mjs';
|
|
|
65
65
|
import {detailView, indexView} from '../../foundation/doc-compiler/lenses.mjs';
|
|
66
66
|
import {semverCompare, isValidSemver, satisfiesRange} from '../../foundation/env/semver.mjs';
|
|
67
67
|
import {checkAppThemes, checkThemes} from './theme-checks.mjs';
|
|
68
|
-
import {availableLine, upgradeLine} from '../../foundation/release/notices.mjs';
|
|
69
|
-
import {alignCommand, addCliCommandFor, computerAgentTextState, installCommandFor, projectCoreVersion, projectHasOwnCli, computerIntegrationsOutside, computerIntegrationsToAdd, displayHomePath, outsideProject, releaseFacts} from './_adapter.mjs';
|
|
68
|
+
import {availableLine, RUN_FROM_PROJECT, upgradeLine} from '../../foundation/release/notices.mjs';
|
|
69
|
+
import {alignCommand, addCliCommandFor, computerAgentTextState, installCommandFor, insideProjectElsewhere, projectCoreVersion, projectHasOwnCli, computerIntegrationsOutside, computerIntegrationsToAdd, displayHomePath, outsideProject, releaseFacts} from './_adapter.mjs';
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* @typedef {'pass'|'warn'|'fail'|'info'} DoctorStatus
|
|
@@ -286,15 +286,25 @@ export function checkVersionAlignment(ctx) {
|
|
|
286
286
|
// the run (spec AST-081 FR2): say so, and how to add the CLI at Core's
|
|
287
287
|
// version.
|
|
288
288
|
if (ctx.ownCli === false) {
|
|
289
|
+
// The same comparison as the daily hint: the CLI against the Core the
|
|
290
|
+
// run reads (spec AST-081 FR2). The command adds the CLI in the project
|
|
291
|
+
// spec:AST-040 FR9 defines; from a folder inside it whose package.json
|
|
292
|
+
// is not the project's, or in no project, the fix says how to reach one.
|
|
293
|
+
const add = addCliCommandFor(ctx.cwd, coreVersion);
|
|
294
|
+
const matches = coreVersion === cliVersion;
|
|
295
|
+
const fix = add
|
|
296
|
+
? `${matches ? 'To pin it for the team and CI' : 'To match'}, run: ${add.command}.`
|
|
297
|
+
: matches
|
|
298
|
+
? null
|
|
299
|
+
: NO_PROJECT_FIX;
|
|
289
300
|
return {
|
|
290
301
|
id: 'version-alignment',
|
|
291
302
|
label: '@astryxdesign/core <-> @astryxdesign/cli alignment',
|
|
292
|
-
status:
|
|
293
|
-
message:
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
fix: `${coreVersion === cliVersion ? 'To pin it for the team and CI' : 'To match'}, run: ${addCliCommandFor(ctx.cwd, coreVersion)}.`,
|
|
303
|
+
status: matches ? 'info' : 'warn',
|
|
304
|
+
message: matches
|
|
305
|
+
? `This project has no Astryx CLI installed; CLI ${cliVersion}, the one you started, answered and matches its Core.`
|
|
306
|
+
: `This project has no Astryx CLI installed; CLI ${cliVersion}, the one you started, answered while its Core is ${coreVersion}.`,
|
|
307
|
+
...(fix ? {fix} : {}),
|
|
298
308
|
};
|
|
299
309
|
}
|
|
300
310
|
// The project's own CLI answers this project whatever its version
|
|
@@ -308,10 +318,31 @@ export function checkVersionAlignment(ctx) {
|
|
|
308
318
|
message: drift
|
|
309
319
|
? `This project's CLI ${cliVersion} answers it, but its Core is ${coreVersion}: templates, docs, and agent text come from CLI ${cliVersion}, components from Core ${coreVersion}.`
|
|
310
320
|
: `@astryxdesign/core v${coreVersion} is in step with @astryxdesign/cli v${cliVersion}.`,
|
|
311
|
-
...(drift ?
|
|
321
|
+
...(drift ? alignFix(ctx.cwd, cliVersion, coreVersion) : {}),
|
|
312
322
|
};
|
|
313
323
|
}
|
|
314
324
|
|
|
325
|
+
/**
|
|
326
|
+
* The fix for a CLI and Core on different releases, when a command fits.
|
|
327
|
+
* @param {string} cwd
|
|
328
|
+
* @param {string} cli
|
|
329
|
+
* @param {string} core
|
|
330
|
+
* @returns {{fix?: string}}
|
|
331
|
+
*/
|
|
332
|
+
function alignFix(cwd, cli, core) {
|
|
333
|
+
// From a folder inside a project whose package.json is not the project's,
|
|
334
|
+
// aligning the project would leave this warning in place, so no command
|
|
335
|
+
// fits there (alignCommand returns none): point at the project instead.
|
|
336
|
+
const command = alignCommand(cwd, cli, core);
|
|
337
|
+
return {fix: command ? `To align them, run: ${command}.` : NO_PROJECT_FIX};
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* The fix where no install command fits: the folder's package.json is not an
|
|
342
|
+
* Astryx project's (spec AST-040 FR9), and adding there would make it one.
|
|
343
|
+
*/
|
|
344
|
+
const NO_PROJECT_FIX = RUN_FROM_PROJECT;
|
|
345
|
+
|
|
315
346
|
/**
|
|
316
347
|
* Check 5 — astryx.config.mjs (if present) loads and has a valid shape.
|
|
317
348
|
* @param {DoctorContext} ctx
|
|
@@ -1559,6 +1590,7 @@ function checkFailureNote(failed) {
|
|
|
1559
1590
|
const SKIP_REASONS = {
|
|
1560
1591
|
'already-shown': 'it had already printed that day',
|
|
1561
1592
|
'no-newer': 'no newer release was known',
|
|
1593
|
+
'no-project': 'the folder belongs to no Astryx project, so no install command fits',
|
|
1562
1594
|
};
|
|
1563
1595
|
|
|
1564
1596
|
/**
|
|
@@ -1764,12 +1796,14 @@ export function checkComputerIntegrations(ctx) {
|
|
|
1764
1796
|
* Inside a project, the integrations installed for the computer that the
|
|
1765
1797
|
* project does not install: available, never used (spec AST-081 FR12).
|
|
1766
1798
|
* Always info.
|
|
1767
|
-
* @param {{installed: Set<string>, candidates: import('../../foundation/integrations/computer-integrations.mjs').ComputerIntegrationCandidate[], install: (name: string) => string}} input
|
|
1799
|
+
* @param {{installed: Set<string>, candidates: import('../../foundation/integrations/computer-integrations.mjs').ComputerIntegrationCandidate[], install: ((name: string) => string) | null, elsewhere?: boolean}} input
|
|
1768
1800
|
* `install`: the command that adds a package with the project's package
|
|
1769
|
-
* manager (read by the adapter)
|
|
1801
|
+
* manager (read by the adapter); null when the folder belongs to no
|
|
1802
|
+
* project, or `elsewhere`: its package.json is not the project's, where the
|
|
1803
|
+
* fix points at the project's folder
|
|
1770
1804
|
* @returns {DoctorCheck}
|
|
1771
1805
|
*/
|
|
1772
|
-
export function checkComputerIntegrationsAvailable({installed, candidates, install}) {
|
|
1806
|
+
export function checkComputerIntegrationsAvailable({installed, candidates, install, elsewhere = false}) {
|
|
1773
1807
|
const available = candidates.filter(c => !installed.has(c.name));
|
|
1774
1808
|
const base = {id: 'computer-integrations', label: 'Integrations installed for this computer', status: /** @type {const} */ ('info')};
|
|
1775
1809
|
if (available.length === 0) {
|
|
@@ -1779,7 +1813,11 @@ export function checkComputerIntegrationsAvailable({installed, candidates, insta
|
|
|
1779
1813
|
return {
|
|
1780
1814
|
...base,
|
|
1781
1815
|
message: `Installed for this computer but not in this project, so not used here: ${available.map(c => c.name).join(', ')}.`,
|
|
1782
|
-
|
|
1816
|
+
...(add
|
|
1817
|
+
? {fix: `To use one in this project, run ${available.map(c => `\`${add(c.name)}\``).join(' or ')}.`}
|
|
1818
|
+
: elsewhere
|
|
1819
|
+
? {fix: NO_PROJECT_FIX}
|
|
1820
|
+
: {}),
|
|
1783
1821
|
};
|
|
1784
1822
|
}
|
|
1785
1823
|
|
|
@@ -2038,7 +2076,7 @@ export async function runChecks(options = {}) {
|
|
|
2038
2076
|
{
|
|
2039
2077
|
const loadedNames = (project?.loadedIntegrations ?? []).map((/** @type {{name: string}} */ i) => i.name);
|
|
2040
2078
|
const candidates = await computerIntegrationsToAdd(cwd, loadedNames);
|
|
2041
|
-
checks.push(checkComputerIntegrationsAvailable({installed: new Set(loadedNames), candidates, install: installCommandFor(cwd)}));
|
|
2079
|
+
checks.push(checkComputerIntegrationsAvailable({installed: new Set(loadedNames), candidates, install: installCommandFor(cwd), elsewhere: insideProjectElsewhere(cwd)}));
|
|
2042
2080
|
}
|
|
2043
2081
|
checks.push(await checkAuthoringDocs(ctx));
|
|
2044
2082
|
checks.push(await checkCliDocs(ctx));
|
|
@@ -31,7 +31,9 @@ import {
|
|
|
31
31
|
checkIntegrationIssues,
|
|
32
32
|
checkVersionAlignment,
|
|
33
33
|
checkPackageManager,
|
|
34
|
+
checkComputerIntegrationsAvailable,
|
|
34
35
|
} from './doctor.mjs';
|
|
36
|
+
import {installCommandFor} from './_adapter.mjs';
|
|
35
37
|
import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
|
|
36
38
|
import {Project} from '../../foundation/config/project.mjs';
|
|
37
39
|
|
|
@@ -223,7 +225,13 @@ describe("doctor — the project's own CLI and Core on different releases", () =
|
|
|
223
225
|
).version;
|
|
224
226
|
/** @param {string} core */
|
|
225
227
|
const at = core => {
|
|
228
|
+
// A project as spec:AST-040 FR9 defines it: its package.json declares
|
|
229
|
+
// an Astryx package.
|
|
226
230
|
const dir = mkProject({
|
|
231
|
+
'package.json': JSON.stringify({
|
|
232
|
+
name: 'app',
|
|
233
|
+
dependencies: {'@astryxdesign/core': core},
|
|
234
|
+
}),
|
|
227
235
|
'package-lock.json': '{}',
|
|
228
236
|
'node_modules/@astryxdesign/core/package.json': JSON.stringify({
|
|
229
237
|
name: '@astryxdesign/core',
|
|
@@ -257,6 +265,10 @@ describe("doctor — the project's own CLI and Core on different releases", () =
|
|
|
257
265
|
|
|
258
266
|
it('in a project with no CLI of its own, warns that the started copy answered and names the command that adds the CLI at Core', () => {
|
|
259
267
|
const dir = mkProject({
|
|
268
|
+
'package.json': JSON.stringify({
|
|
269
|
+
name: 'app',
|
|
270
|
+
dependencies: {'@astryxdesign/core': '0.0.1'},
|
|
271
|
+
}),
|
|
260
272
|
'package-lock.json': '{}',
|
|
261
273
|
'node_modules/@astryxdesign/core/package.json': JSON.stringify({
|
|
262
274
|
name: '@astryxdesign/core',
|
|
@@ -279,6 +291,52 @@ describe("doctor — the project's own CLI and Core on different releases", () =
|
|
|
279
291
|
});
|
|
280
292
|
});
|
|
281
293
|
|
|
294
|
+
describe('the command that adds an integration installed for the computer', () => {
|
|
295
|
+
const app = () =>
|
|
296
|
+
mkProject({
|
|
297
|
+
'package.json': JSON.stringify({
|
|
298
|
+
name: 'app',
|
|
299
|
+
dependencies: {'@astryxdesign/core': '0.7.0'},
|
|
300
|
+
}),
|
|
301
|
+
'pnpm-lock.yaml': '',
|
|
302
|
+
'tools/codegen/package.json': JSON.stringify({name: 'codegen'}),
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
it('adds it in the project, with its package manager', () => {
|
|
306
|
+
const dir = app();
|
|
307
|
+
expect(installCommandFor(dir)?.('@acme/a')).toBe('pnpm add @acme/a');
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
// A package.json that is not the project's (spec AST-040 FR9): a run
|
|
311
|
+
// there loads integrations from it, so a package added to the project
|
|
312
|
+
// stays unused there. No command; the fix points at the project.
|
|
313
|
+
it("from a tool folder inside the project, names no command and points at the project's folder", () => {
|
|
314
|
+
const dir = app();
|
|
315
|
+
expect(installCommandFor(path.join(dir, 'tools', 'codegen'))).toBeNull();
|
|
316
|
+
const c = checkComputerIntegrationsAvailable({
|
|
317
|
+
installed: new Set(),
|
|
318
|
+
candidates: [/** @type {any} */ ({name: '@acme/a'})],
|
|
319
|
+
install: null,
|
|
320
|
+
elsewhere: true,
|
|
321
|
+
});
|
|
322
|
+
expect(c.fix).toBe(
|
|
323
|
+
"Run this from the Astryx project's folder, or declare an Astryx package in this folder's package.json to make it a project of its own.",
|
|
324
|
+
);
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it('in a folder that belongs to no project, names no command', () => {
|
|
328
|
+
const dir = mkProject({'package.json': JSON.stringify({name: 'tool'})});
|
|
329
|
+
expect(installCommandFor(dir)).toBeNull();
|
|
330
|
+
const c = checkComputerIntegrationsAvailable({
|
|
331
|
+
installed: new Set(),
|
|
332
|
+
candidates: [/** @type {any} */ ({name: '@acme/a'})],
|
|
333
|
+
install: null,
|
|
334
|
+
});
|
|
335
|
+
expect(c.status).toBe('info');
|
|
336
|
+
expect(c).not.toHaveProperty('fix');
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
|
|
282
340
|
describe('checkCliCommand', () => {
|
|
283
341
|
it('is informational when no integration declares a command', () => {
|
|
284
342
|
const dir = mkProject({'pnpm-lock.yaml': ''});
|
package/api/hook/hook.mjs
CHANGED
|
@@ -43,7 +43,7 @@ export async function hook(name, options = {}) {
|
|
|
43
43
|
zh = false,
|
|
44
44
|
} = options;
|
|
45
45
|
|
|
46
|
-
// Default detail level mirrors the CLI (see commands/hook
|
|
46
|
+
// Default detail level mirrors the CLI (see commands/hook.mjs):
|
|
47
47
|
// single-hook views default to 'full', list-style views (--list,
|
|
48
48
|
// --category, or no name) default to 'brief' (scannable name lists).
|
|
49
49
|
// Keeping this in sync with the CLI is what the API↔CLI parity test checks.
|
|
@@ -37,6 +37,7 @@ const componentDoc = name =>
|
|
|
37
37
|
`export default {type: 'component', name: '${name}', displayName: '${name}', usage: {description: '${name}.'}, props: []};\n`;
|
|
38
38
|
/** @param {string} name */
|
|
39
39
|
const componentSource = name => `export function ${name}() { return null; }\n`;
|
|
40
|
+
/** @param {string} name */
|
|
40
41
|
const templateSource = name =>
|
|
41
42
|
`export default function ${name}() { return null; }\n`;
|
|
42
43
|
/** @param {string} name */
|
|
@@ -398,9 +399,9 @@ describe('unreachable_contribution fixes hold when followed', () => {
|
|
|
398
399
|
const dir = writePackage({
|
|
399
400
|
[MANIFEST]: manifest({templates: './templates'}),
|
|
400
401
|
'templates/hero.doc.mjs': `export default {type: 'page', name: 'hero', displayName: 'Hero'};\n`,
|
|
401
|
-
'templates/hero.tsx':
|
|
402
|
+
'templates/hero.tsx': templateSource('Hero'),
|
|
402
403
|
'src/blocks/Carousel.doc.mjs': `export default {type: 'block', name: 'Carousel', displayName: 'Carousel', aspectRatio: 1};\n`,
|
|
403
|
-
'src/blocks/Carousel.tsx':
|
|
404
|
+
'src/blocks/Carousel.tsx': templateSource('Carousel'),
|
|
404
405
|
});
|
|
405
406
|
|
|
406
407
|
const message = only(await issuesOf(dir), 'unreachable_contribution');
|
|
@@ -423,7 +424,7 @@ describe('unreachable_contribution fixes hold when followed', () => {
|
|
|
423
424
|
[MANIFEST]: manifest({templates: './templates'}),
|
|
424
425
|
'templates/.keep': '',
|
|
425
426
|
'src/blocks/Carousel.doc.mjs': `export default {type: 'block', name: 'Carousel', displayName: 'Carousel', aspectRatio: 1};\n`,
|
|
426
|
-
'src/blocks/Carousel.tsx':
|
|
427
|
+
'src/blocks/Carousel.tsx': templateSource('Carousel'),
|
|
427
428
|
});
|
|
428
429
|
|
|
429
430
|
const message = only(await issuesOf(dir), 'unreachable_contribution');
|
|
@@ -687,9 +688,9 @@ describe('fixes never move a contribution onto a name its root already has', ()
|
|
|
687
688
|
const dir = writePackage({
|
|
688
689
|
[MANIFEST]: manifest({templates: './templates'}),
|
|
689
690
|
'templates/hero.doc.mjs': `export default {type: 'page', name: 'hero', displayName: 'Hero'};\n`,
|
|
690
|
-
'templates/hero.tsx':
|
|
691
|
+
'templates/hero.tsx': templateSource('Hero'),
|
|
691
692
|
'extra/hero.doc.mjs': `export default {type: 'page', name: 'hero', displayName: 'Hero'};\n`,
|
|
692
|
-
'extra/hero.tsx':
|
|
693
|
+
'extra/hero.tsx': templateSource('Hero'),
|
|
693
694
|
});
|
|
694
695
|
|
|
695
696
|
const message = only(await issuesOf(dir), 'unreachable_contribution');
|
|
@@ -169,6 +169,7 @@ const writeNamed = files =>
|
|
|
169
169
|
version: '1.0.0',
|
|
170
170
|
exports: {
|
|
171
171
|
'./components/*': './components/*.tsx',
|
|
172
|
+
'./templates/*': './templates/*.tsx',
|
|
172
173
|
'.': './index.ts',
|
|
173
174
|
},
|
|
174
175
|
});
|
|
@@ -534,7 +535,14 @@ describe('block component names', () => {
|
|
|
534
535
|
'export function Panel() { return null; }\nexport const UI = {};\nexport const Lib = {};\nexport function pick() { return null; }\n',
|
|
535
536
|
...files,
|
|
536
537
|
},
|
|
537
|
-
{
|
|
538
|
+
{
|
|
539
|
+
name: '@acme/kit',
|
|
540
|
+
version: '1.0.0',
|
|
541
|
+
exports: {
|
|
542
|
+
'.': './index.tsx',
|
|
543
|
+
'./templates/*': './templates/*.tsx',
|
|
544
|
+
},
|
|
545
|
+
},
|
|
538
546
|
);
|
|
539
547
|
/** @param {string} extra */
|
|
540
548
|
const block = extra =>
|
|
@@ -572,6 +580,9 @@ describe('block component names', () => {
|
|
|
572
580
|
),
|
|
573
581
|
'templates/account-card.tsx':
|
|
574
582
|
"import {Helper} from 'some-lib';\nexport default function A() {\n return <Helper />;\n}\n",
|
|
583
|
+
// The package root the doc's derived import names exports the component.
|
|
584
|
+
'index.tsx':
|
|
585
|
+
"export function Panel() { return null; }\nexport {AcmeWidget} from './components/AcmeWidget';\n",
|
|
575
586
|
});
|
|
576
587
|
|
|
577
588
|
expect(await allOf(dir)).toEqual([]);
|
|
@@ -83,6 +83,10 @@ export type ValidateResult = {
|
|
|
83
83
|
*/
|
|
84
84
|
listed?: import("../../foundation/integrations/issue").AstryxIntegrationIssue[] | undefined;
|
|
85
85
|
integration?: import("../../foundation/integrations/integrations.mjs").LoadedIntegration | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* what the public-import check could not judge
|
|
88
|
+
*/
|
|
89
|
+
publicImports?: import("./validate-integration.type.mjs").PublicImportsReport | undefined;
|
|
86
90
|
};
|
|
87
91
|
import { validateLoadedIntegration } from '../../foundation/integrations/validate-contributions.mjs';
|
|
88
92
|
import { isListedIssue } from '../../foundation/integrations/validate-contributions.mjs';
|
|
@@ -70,6 +70,12 @@ import {
|
|
|
70
70
|
rootProblem,
|
|
71
71
|
} from '../../foundation/integrations/validate-contributions.mjs';
|
|
72
72
|
import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
|
|
73
|
+
import {cliPeerVersionProblem} from '../../foundation/integrations/cli-peer-version.mjs';
|
|
74
|
+
import {publicImportIssues} from '../../foundation/integrations/public-imports.mjs';
|
|
75
|
+
import {runChoice} from '../../foundation/release/run-context.mjs';
|
|
76
|
+
|
|
77
|
+
/** The running CLI is outside the package's `@astryxdesign/cli` peer range. */
|
|
78
|
+
const CLI_PEER_VERSION = 'cli_peer_version';
|
|
73
79
|
|
|
74
80
|
export {validateLoadedIntegration, isListedIssue};
|
|
75
81
|
|
|
@@ -92,6 +98,8 @@ export {validateLoadedIntegration, isListedIssue};
|
|
|
92
98
|
* may not fail `--strict` until the next (architecture:cli-surface INV35);
|
|
93
99
|
* `integration verify` still fails on a package.json npm cannot pack.
|
|
94
100
|
* @property {import('../../foundation/integrations/integrations.mjs').LoadedIntegration} [integration]
|
|
101
|
+
* @property {import('./validate-integration.type.mjs').PublicImportsReport} [publicImports]
|
|
102
|
+
* what the public-import check could not judge
|
|
95
103
|
*/
|
|
96
104
|
|
|
97
105
|
/**
|
|
@@ -278,13 +286,15 @@ async function findUnreachableContributionIssues(
|
|
|
278
286
|
* Shared core for the local and installed entry points.
|
|
279
287
|
* @param {string} packageDir
|
|
280
288
|
* @param {{name: string, version?: string}} identity
|
|
281
|
-
* @param {{scanUnreachable?: boolean}} [options]
|
|
289
|
+
* @param {{scanUnreachable?: boolean, own?: boolean, cwd?: string}} [options]
|
|
290
|
+
* `own`: the package is the one being authored in the current folder;
|
|
291
|
+
* `cwd`: the folder whose package manager an install command names
|
|
282
292
|
* @returns {Promise<ValidateResult>}
|
|
283
293
|
*/
|
|
284
294
|
async function validateAtPackageDir(
|
|
285
295
|
packageDir,
|
|
286
296
|
identity,
|
|
287
|
-
{scanUnreachable = false} = {},
|
|
297
|
+
{scanUnreachable = false, own = false, cwd = packageDir} = {},
|
|
288
298
|
) {
|
|
289
299
|
/** @type {Issue[]} */
|
|
290
300
|
const issues = [];
|
|
@@ -426,6 +436,24 @@ async function validateAtPackageDir(
|
|
|
426
436
|
issues.push(issue);
|
|
427
437
|
}
|
|
428
438
|
}
|
|
439
|
+
// The running CLI outside the package's `@astryxdesign/cli` peer range is a
|
|
440
|
+
// note for the same reason. It is built here, not among the contribution
|
|
441
|
+
// checks, so `integration verify` (which reports their layout findings)
|
|
442
|
+
// does not see it.
|
|
443
|
+
// The version an upgrade starts from is the project's: its own CLI's, or,
|
|
444
|
+
// with none, its Core's, as the project-upgrade notice takes it.
|
|
445
|
+
const choice = runChoice(cwd);
|
|
446
|
+
const from =
|
|
447
|
+
choice.inProject && choice.copy === 'starting' && choice.coreVersion
|
|
448
|
+
? choice.coreVersion
|
|
449
|
+
: undefined;
|
|
450
|
+
const peerProblem = cliPeerVersionProblem(loaded, undefined, cwd, {
|
|
451
|
+
own,
|
|
452
|
+
from,
|
|
453
|
+
});
|
|
454
|
+
if (peerProblem) {
|
|
455
|
+
(result.notes ??= []).push({code: CLI_PEER_VERSION, message: peerProblem});
|
|
456
|
+
}
|
|
429
457
|
if (loaded.themes && !rootProblem(loaded.themes))
|
|
430
458
|
issues.push(...unreadThemeFolderIssues(packageDir, loaded));
|
|
431
459
|
// What the docs say that no reader serves: a prop listed twice, an
|
|
@@ -444,6 +472,14 @@ async function validateAtPackageDir(
|
|
|
444
472
|
packageDir,
|
|
445
473
|
)),
|
|
446
474
|
);
|
|
475
|
+
// What the package tells apps to import, read from source: package.json
|
|
476
|
+
// `exports`, docs, examples and template imports.
|
|
477
|
+
const publicImports = await publicImportIssues(packageDir, loaded);
|
|
478
|
+
issues.push(...publicImports.issues);
|
|
479
|
+
// Each finding is a note until the next minor makes it a warning.
|
|
480
|
+
if (publicImports.notes.length > 0)
|
|
481
|
+
(result.notes ??= []).push(...publicImports.notes);
|
|
482
|
+
result.publicImports = publicImports.report;
|
|
447
483
|
if (scanUnreachable) {
|
|
448
484
|
issues.push(
|
|
449
485
|
...(await findUnreachableContributionIssues(
|
|
@@ -507,7 +543,7 @@ export async function validateLocalIntegration(cwd = process.cwd()) {
|
|
|
507
543
|
const result = await validateAtPackageDir(
|
|
508
544
|
packageDir,
|
|
509
545
|
{name, version: pkg.version},
|
|
510
|
-
{scanUnreachable: true},
|
|
546
|
+
{scanUnreachable: true, own: true},
|
|
511
547
|
);
|
|
512
548
|
(result.listed ??= []).unshift(
|
|
513
549
|
...fields,
|
|
@@ -642,10 +678,11 @@ export async function validateInstalledIntegration(spec, cwd = process.cwd()) {
|
|
|
642
678
|
};
|
|
643
679
|
}
|
|
644
680
|
|
|
645
|
-
return validateAtPackageDir(
|
|
646
|
-
|
|
647
|
-
version: pkg.version,
|
|
648
|
-
|
|
681
|
+
return validateAtPackageDir(
|
|
682
|
+
packageDir,
|
|
683
|
+
{name: pkg.name ?? spec, version: pkg.version},
|
|
684
|
+
{cwd},
|
|
685
|
+
);
|
|
649
686
|
}
|
|
650
687
|
|
|
651
688
|
/**
|
|
@@ -744,6 +781,10 @@ export async function validateIntegration(pkg, options = {}) {
|
|
|
744
781
|
...(docTypes ? {docTypes} : {}),
|
|
745
782
|
...(docNames ? {docNames} : {}),
|
|
746
783
|
...(blockComponents ? {blockComponents} : {}),
|
|
784
|
+
// What the public-import check could not judge: listed, never failed on.
|
|
785
|
+
...(result.found && result.publicImports
|
|
786
|
+
? {publicImports: result.publicImports}
|
|
787
|
+
: {}),
|
|
747
788
|
},
|
|
748
789
|
};
|
|
749
790
|
}
|