@astryxdesign/cli 0.7.0-canary.94bdc8e → 0.7.0-canary.97a0d31
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/doctor/doctor.d.mts +30 -2
- package/api/doctor/doctor.doc.mjs +2 -1
- package/api/doctor/doctor.mjs +153 -3
- package/api/doctor/doctor.test.mjs +250 -4
- package/assets/codemods/transforms/next/__tests__/preserve-bottom-sheet-content-padding.test.mjs +178 -0
- package/assets/codemods/transforms/next/__tests__/rename-empty-search-results-text.test.mjs +202 -0
- package/assets/codemods/transforms/next/index.mjs +16 -0
- package/assets/codemods/transforms/next/preserve-bottom-sheet-content-padding.mjs +242 -0
- package/assets/codemods/transforms/next/rename-empty-search-results-text.mjs +254 -0
- package/assets/docs/spacing.doc.mjs +2 -2
- package/assets/docs/tree/tokens-spacing.doc.mjs +15 -15
- package/assets/templates/blocks/components/BottomSheet/BottomSheetHeights.tsx +1 -1
- package/assets/templates/blocks/components/BottomSheet/BottomSheetMobileKeyboard.tsx +1 -1
- package/assets/templates/blocks/components/BottomSheet/BottomSheetNoScrim.tsx +1 -1
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSnapPoints.tsx +1 -1
- package/assets/templates/blocks/components/Dialog/DialogAdaptivePresentation.tsx +1 -1
- package/assets/templates/pages/table-filter/page.tsx +8 -3
- package/assets/templates/pages/table-inbox/page.tsx +3 -1
- package/assets/templates/themes/butter/butterTheme.ts +12 -0
- package/assets/templates/themes/chocolate/chocolateTheme.ts +12 -0
- package/assets/templates/themes/matcha/matchaTheme.ts +14 -14
- package/assets/templates/themes/neutral/neutralTheme.ts +12 -0
- package/assets/templates/themes/stone/stoneTheme.ts +12 -0
- package/assets/templates/themes/y2k/y2kTheme.ts +10 -10
- package/assets/theme.template.ts +1 -1
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.test.mjs +33 -0
- package/package.json +9 -9
package/api/doctor/doctor.d.mts
CHANGED
|
@@ -49,6 +49,25 @@ export function checkConfig(ctx: DoctorContext): Promise<DoctorCheck>;
|
|
|
49
49
|
* @returns {DoctorCheck}
|
|
50
50
|
*/
|
|
51
51
|
export function checkImplicitIntegrations(ctx: DoctorContext): DoctorCheck;
|
|
52
|
+
/**
|
|
53
|
+
* Every integration named in astryx.config loads.
|
|
54
|
+
*
|
|
55
|
+
* A configured integration that cannot be loaded (not installed, no
|
|
56
|
+
* manifest, or a manifest that throws or fails its schema) is withdrawn
|
|
57
|
+
* whole, because none of its contribution roots is trustworthy
|
|
58
|
+
* (spec:AST-035 FR9). The project then runs without something it asked
|
|
59
|
+
* for, so this fails the CI gate.
|
|
60
|
+
*
|
|
61
|
+
* Two neighbours stay as they were. A problem inside one contribution kind
|
|
62
|
+
* leaves the rest of the integration working, so `integration-issues` keeps
|
|
63
|
+
* warning about it (spec:AST-035 FR9). An autolinked dependency that cannot
|
|
64
|
+
* be loaded stays informational in `implicit-integrations`: the project did
|
|
65
|
+
* not ask for it.
|
|
66
|
+
*
|
|
67
|
+
* @param {DoctorContext} ctx
|
|
68
|
+
* @returns {DoctorCheck}
|
|
69
|
+
*/
|
|
70
|
+
export function checkConfiguredIntegrations(ctx: DoctorContext): DoctorCheck;
|
|
52
71
|
/**
|
|
53
72
|
* Check 7 — agent docs exist and contain the Astryx section markers.
|
|
54
73
|
* @param {DoctorContext} ctx
|
|
@@ -253,13 +272,22 @@ export type DoctorContext = {
|
|
|
253
272
|
severity: "warning" | "error";
|
|
254
273
|
message: string;
|
|
255
274
|
}[] | null | undefined;
|
|
275
|
+
autolinkFailures?: {
|
|
276
|
+
spec: string;
|
|
277
|
+
error: string;
|
|
278
|
+
}[] | null | undefined;
|
|
256
279
|
/**
|
|
280
|
+
* Every name astryx.config lists, from the provider ledger: the package it
|
|
281
|
+
* reached (or failed to reach) and why loading failed, if it did. Set aside
|
|
282
|
+
* for a provider conflict, replaced by the package being authored, or
|
|
283
|
+
* repeated under another name all still count as configured.
|
|
257
284
|
* installed dependencies whose integration manifest could not be loaded
|
|
258
285
|
* Combined project-level integration issues, including cross-package template replacement warnings.
|
|
259
286
|
*/
|
|
260
|
-
|
|
287
|
+
configuredIntegrations?: {
|
|
261
288
|
spec: string;
|
|
262
|
-
|
|
289
|
+
label: string;
|
|
290
|
+
error: string | null;
|
|
263
291
|
}[] | null | undefined;
|
|
264
292
|
/**
|
|
265
293
|
* - Error thrown while resolving the config
|
|
@@ -18,7 +18,8 @@ export const doc = {
|
|
|
18
18
|
description:
|
|
19
19
|
'Runs a series of diagnostics: Node version, ' +
|
|
20
20
|
'@astryxdesign/core install and version alignment with the CLI, installed ' +
|
|
21
|
-
'themes and wiring, astryx.config validity,
|
|
21
|
+
'themes and wiring, astryx.config validity, whether every integration ' +
|
|
22
|
+
'astryx.config names loads (a failed one fails the run), integrations linked from ' +
|
|
22
23
|
'package.json without a config entry, core peer dependencies, ' +
|
|
23
24
|
'integration provider identity and contribution issues, agent docs, the ' +
|
|
24
25
|
'detected package manager, and the health of the docs the CLI reads (authoring ' +
|
package/api/doctor/doctor.mjs
CHANGED
|
@@ -82,6 +82,11 @@ import {checkAppThemes, checkThemes} from './theme-checks.mjs';
|
|
|
82
82
|
* could not be built, when it could not.
|
|
83
83
|
* @property {Array<{package: string, code: string, severity: 'warning'|'error', message: string}>|null} [integrationIssues]
|
|
84
84
|
* @property {Array<{spec: string, error: string}>|null} [autolinkFailures]
|
|
85
|
+
* @property {Array<{spec: string, label: string, error: string|null}>|null} [configuredIntegrations]
|
|
86
|
+
* Every name astryx.config lists, from the provider ledger: the package it
|
|
87
|
+
* reached (or failed to reach) and why loading failed, if it did. Set aside
|
|
88
|
+
* for a provider conflict, replaced by the package being authored, or
|
|
89
|
+
* repeated under another name all still count as configured.
|
|
85
90
|
* installed dependencies whose integration manifest could not be loaded
|
|
86
91
|
* Combined project-level integration issues, including cross-package template replacement warnings.
|
|
87
92
|
* @property {Error|null} [configError] - Error thrown while resolving the config
|
|
@@ -319,12 +324,12 @@ export async function checkConfig(ctx) {
|
|
|
319
324
|
}
|
|
320
325
|
// Importing is not the whole test: the CLI also validates the config, and
|
|
321
326
|
// a config it rejects leaves every project-aware command without the
|
|
322
|
-
// project.
|
|
327
|
+
// project. Doctor is the CI gate, so that fails.
|
|
323
328
|
if (ctx.projectError) {
|
|
324
329
|
return {
|
|
325
330
|
id: 'config',
|
|
326
331
|
label: 'astryx.config.mjs',
|
|
327
|
-
status: '
|
|
332
|
+
status: 'fail',
|
|
328
333
|
message: `astryx.config.mjs loads, but the CLI could not load the project from it: ${firstLine(ctx.projectError)}`,
|
|
329
334
|
fix: 'Fix what the message names. `astryx docs authoring config` lists every field astryx.config accepts.',
|
|
330
335
|
};
|
|
@@ -475,6 +480,88 @@ function describeUnreadableManifests(failures) {
|
|
|
475
480
|
);
|
|
476
481
|
}
|
|
477
482
|
|
|
483
|
+
/**
|
|
484
|
+
* Every integration named in astryx.config loads.
|
|
485
|
+
*
|
|
486
|
+
* A configured integration that cannot be loaded (not installed, no
|
|
487
|
+
* manifest, or a manifest that throws or fails its schema) is withdrawn
|
|
488
|
+
* whole, because none of its contribution roots is trustworthy
|
|
489
|
+
* (spec:AST-035 FR9). The project then runs without something it asked
|
|
490
|
+
* for, so this fails the CI gate.
|
|
491
|
+
*
|
|
492
|
+
* Two neighbours stay as they were. A problem inside one contribution kind
|
|
493
|
+
* leaves the rest of the integration working, so `integration-issues` keeps
|
|
494
|
+
* warning about it (spec:AST-035 FR9). An autolinked dependency that cannot
|
|
495
|
+
* be loaded stays informational in `implicit-integrations`: the project did
|
|
496
|
+
* not ask for it.
|
|
497
|
+
*
|
|
498
|
+
* @param {DoctorContext} ctx
|
|
499
|
+
* @returns {DoctorCheck}
|
|
500
|
+
*/
|
|
501
|
+
export function checkConfiguredIntegrations(ctx) {
|
|
502
|
+
const id = 'configured-integrations';
|
|
503
|
+
const label = 'Configured integrations';
|
|
504
|
+
if (ctx.integrations == null) {
|
|
505
|
+
// The config check reports a config the CLI cannot load.
|
|
506
|
+
return {
|
|
507
|
+
id,
|
|
508
|
+
label,
|
|
509
|
+
status: 'info',
|
|
510
|
+
message: skippedBecause(ctx, 'the project configuration could not be read'),
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
// What counts as configured is what astryx.config names, read from the
|
|
514
|
+
// provider ledger so a package set aside for a provider conflict, or the
|
|
515
|
+
// package being authored when its own config names it, still counts.
|
|
516
|
+
const configured =
|
|
517
|
+
ctx.configuredIntegrations ??
|
|
518
|
+
ctx.integrations
|
|
519
|
+
.filter(integration => !integration.__autolinked && !integration.__local)
|
|
520
|
+
.map(integration => ({
|
|
521
|
+
spec: integration.__spec,
|
|
522
|
+
label: integration.name ?? integration.__spec,
|
|
523
|
+
error:
|
|
524
|
+
integration.__loadError == null
|
|
525
|
+
? null
|
|
526
|
+
: String(integration.__loadError),
|
|
527
|
+
}));
|
|
528
|
+
if (configured.length === 0) {
|
|
529
|
+
return {
|
|
530
|
+
id,
|
|
531
|
+
label,
|
|
532
|
+
status: 'info',
|
|
533
|
+
message: 'No integration is named in astryx.config.',
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
const plural = configured.length === 1 ? '' : 's';
|
|
537
|
+
const withdrawn = configured.filter(entry => entry.error != null);
|
|
538
|
+
if (withdrawn.length > 0) {
|
|
539
|
+
const listed = withdrawn
|
|
540
|
+
.map(
|
|
541
|
+
entry =>
|
|
542
|
+
`${entry.label} (${firstLine(String(entry.error)).slice(0, 160)})`,
|
|
543
|
+
)
|
|
544
|
+
.join('; ');
|
|
545
|
+
return {
|
|
546
|
+
id,
|
|
547
|
+
label,
|
|
548
|
+
status: 'fail',
|
|
549
|
+
message:
|
|
550
|
+
`${withdrawn.length} of ${configured.length} integration${plural} named in astryx.config could not be loaded, ` +
|
|
551
|
+
`so ${withdrawn.length === 1 ? 'it contributes' : 'they contribute'} nothing: ${listed}.`,
|
|
552
|
+
fix:
|
|
553
|
+
'Install each one, fix its astryx.integration.* manifest (`astryx doctor integration validate <package>` says what is wrong), ' +
|
|
554
|
+
'or remove it from `integrations` in astryx.config.',
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
return {
|
|
558
|
+
id,
|
|
559
|
+
label,
|
|
560
|
+
status: 'pass',
|
|
561
|
+
message: `${configured.length} integration${plural} named in astryx.config loaded: ${configured.map(entry => entry.label).join(', ')}.`,
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
|
|
478
565
|
/**
|
|
479
566
|
* Check 7 — agent docs exist and contain the Astryx section markers.
|
|
480
567
|
* @param {DoctorContext} ctx
|
|
@@ -1201,6 +1288,7 @@ export const SYNC_CHECKS = [
|
|
|
1201
1288
|
checkCoreInstalled,
|
|
1202
1289
|
checkVersionAlignment,
|
|
1203
1290
|
checkImplicitIntegrations,
|
|
1291
|
+
checkConfiguredIntegrations,
|
|
1204
1292
|
checkProviderIdentity,
|
|
1205
1293
|
checkIntegrationIssues,
|
|
1206
1294
|
checkAgentDocs,
|
|
@@ -1244,6 +1332,8 @@ export async function runChecks(options = {}) {
|
|
|
1244
1332
|
let integrationIssues = null;
|
|
1245
1333
|
/** @type {Array<{spec: string, error: string}>|null} */
|
|
1246
1334
|
let autolinkFailures = null;
|
|
1335
|
+
/** @type {Array<{spec: string, label: string, error: string|null}>|null} */
|
|
1336
|
+
let configuredIntegrations = null;
|
|
1247
1337
|
/** @type {string|null} */
|
|
1248
1338
|
let projectError = null;
|
|
1249
1339
|
/** @type {import('../../foundation/config/project.mjs').Project | null} */
|
|
@@ -1261,7 +1351,66 @@ export async function runChecks(options = {}) {
|
|
|
1261
1351
|
integrations = project.loadedIntegrations;
|
|
1262
1352
|
// An installed dependency whose manifest cannot be loaded is kept out of
|
|
1263
1353
|
// loadedIntegrations on purpose. The provider ledger still records it.
|
|
1264
|
-
|
|
1354
|
+
const ledgerMap = providerLedgerOf(project);
|
|
1355
|
+
const ledger = [...ledgerMap.values()];
|
|
1356
|
+
// The package that stands for a configured name: when the package
|
|
1357
|
+
// being authored replaces the configured copy, the authored package's
|
|
1358
|
+
// outcome is the one that matters, so a broken authored manifest fails
|
|
1359
|
+
// the check even though the configured copy itself loaded. A package
|
|
1360
|
+
// set aside for a provider conflict keeps its own outcome.
|
|
1361
|
+
/** @param {import('../../foundation/integrations/provider-resolution.mjs').ProviderLedgerEntry} entry */
|
|
1362
|
+
const standsFor = entry => {
|
|
1363
|
+
let current = entry;
|
|
1364
|
+
const seen = new Set();
|
|
1365
|
+
while (
|
|
1366
|
+
current.outcome === 'set-aside' &&
|
|
1367
|
+
current.reason === 'replaced-by-authored' &&
|
|
1368
|
+
current.winner != null &&
|
|
1369
|
+
!seen.has(current.winner) &&
|
|
1370
|
+
ledgerMap.has(current.winner)
|
|
1371
|
+
) {
|
|
1372
|
+
seen.add(current.winner);
|
|
1373
|
+
current = /** @type {typeof entry} */ (ledgerMap.get(current.winner));
|
|
1374
|
+
}
|
|
1375
|
+
return current;
|
|
1376
|
+
};
|
|
1377
|
+
// Every package a configured name reached, however it was resolved.
|
|
1378
|
+
configuredIntegrations = ledger
|
|
1379
|
+
.filter(entry =>
|
|
1380
|
+
entry.refs.some(
|
|
1381
|
+
ref => ref.source === 'configured' && ref.repeat !== true,
|
|
1382
|
+
),
|
|
1383
|
+
)
|
|
1384
|
+
.map(entry => {
|
|
1385
|
+
const ref = entry.refs.find(
|
|
1386
|
+
candidate => candidate.source === 'configured',
|
|
1387
|
+
);
|
|
1388
|
+
const effective = standsFor(entry);
|
|
1389
|
+
// When node_modules/<name> links back to the package being authored,
|
|
1390
|
+
// the configured and local candidates share one real path and one
|
|
1391
|
+
// entry whose outcome is the set-aside; the authored (`local`)
|
|
1392
|
+
// candidate on that entry carries the load error, so it is the
|
|
1393
|
+
// outcome that counts. Reading it from the ref, not by comparing
|
|
1394
|
+
// paths, holds whether or not the working directory is itself a
|
|
1395
|
+
// symlink.
|
|
1396
|
+
const authored = effective.refs.find(
|
|
1397
|
+
candidate => candidate.source === 'local',
|
|
1398
|
+
);
|
|
1399
|
+
const authoredError =
|
|
1400
|
+
authored?.integration?.__loadError ?? authored?.error ?? null;
|
|
1401
|
+
const loadError =
|
|
1402
|
+
effective.outcome === 'load-failed'
|
|
1403
|
+
? (effective.error ?? 'its manifest could not be loaded')
|
|
1404
|
+
: authoredError != null
|
|
1405
|
+
? String(authoredError)
|
|
1406
|
+
: null;
|
|
1407
|
+
return {
|
|
1408
|
+
spec: ref?.spec ?? entry.label,
|
|
1409
|
+
label: entry.integration?.name ?? ref?.spec ?? entry.label,
|
|
1410
|
+
error: loadError,
|
|
1411
|
+
};
|
|
1412
|
+
});
|
|
1413
|
+
autolinkFailures = ledger
|
|
1265
1414
|
.filter(
|
|
1266
1415
|
entry =>
|
|
1267
1416
|
entry.outcome === 'load-failed' &&
|
|
@@ -1300,6 +1449,7 @@ export async function runChecks(options = {}) {
|
|
|
1300
1449
|
docsCatalogError,
|
|
1301
1450
|
integrationIssues,
|
|
1302
1451
|
autolinkFailures,
|
|
1452
|
+
configuredIntegrations,
|
|
1303
1453
|
configError,
|
|
1304
1454
|
projectError,
|
|
1305
1455
|
};
|
|
@@ -1042,7 +1042,7 @@ describe('doctor says why it skipped and what it checked', () => {
|
|
|
1042
1042
|
}
|
|
1043
1043
|
|
|
1044
1044
|
it(
|
|
1045
|
-
'
|
|
1045
|
+
'fails, and quotes the reason, when the CLI cannot load the project from a config that imports',
|
|
1046
1046
|
async () => {
|
|
1047
1047
|
const dir = cwdProject({
|
|
1048
1048
|
'package.json': '{"name":"app"}',
|
|
@@ -1051,7 +1051,7 @@ describe('doctor says why it skipped and what it checked', () => {
|
|
|
1051
1051
|
});
|
|
1052
1052
|
const {checks, summary} = (await doctor({cwd: dir})).data;
|
|
1053
1053
|
const by = Object.fromEntries(checks.map(c => [c.id, c]));
|
|
1054
|
-
expect(by.config.status).toBe('
|
|
1054
|
+
expect(by.config.status).toBe('fail');
|
|
1055
1055
|
expect(by.config.message).toMatch(
|
|
1056
1056
|
/^astryx\.config\.mjs loads, but the CLI could not load the project from it: .*integrations/,
|
|
1057
1057
|
);
|
|
@@ -1064,8 +1064,8 @@ describe('doctor says why it skipped and what it checked', () => {
|
|
|
1064
1064
|
expect(by['integration-issues'].message).toMatch(
|
|
1065
1065
|
/^Skipped — the project integration graph could not be loaded: .*integrations/,
|
|
1066
1066
|
);
|
|
1067
|
-
//
|
|
1068
|
-
expect(summary.fail).toBe(
|
|
1067
|
+
// The config check is the one failure; the skipped checks stay info.
|
|
1068
|
+
expect(summary.fail).toBe(1);
|
|
1069
1069
|
},
|
|
1070
1070
|
SLOW,
|
|
1071
1071
|
);
|
|
@@ -1123,6 +1123,252 @@ describe('doctor says why it skipped and what it checked', () => {
|
|
|
1123
1123
|
});
|
|
1124
1124
|
});
|
|
1125
1125
|
|
|
1126
|
+
describe('a configured integration that cannot load fails the gate', () => {
|
|
1127
|
+
const CORE_STUB = {
|
|
1128
|
+
'node_modules/@astryxdesign/core/package.json': JSON.stringify({
|
|
1129
|
+
name: '@astryxdesign/core',
|
|
1130
|
+
version: '0.6.3',
|
|
1131
|
+
}),
|
|
1132
|
+
};
|
|
1133
|
+
const WIDGETS = 'node_modules/@acme/widgets';
|
|
1134
|
+
/** @param {string} [manifest] */
|
|
1135
|
+
const widgets = (
|
|
1136
|
+
manifest = "export default {components: './components'};\n",
|
|
1137
|
+
) => ({
|
|
1138
|
+
[`${WIDGETS}/package.json`]: JSON.stringify({
|
|
1139
|
+
name: '@acme/widgets',
|
|
1140
|
+
version: '1.0.0',
|
|
1141
|
+
}),
|
|
1142
|
+
[`${WIDGETS}/astryx.integration.mjs`]: manifest,
|
|
1143
|
+
[`${WIDGETS}/components/AcmeCard.doc.mjs`]:
|
|
1144
|
+
"export default {type: 'component', name: 'AcmeCard', displayName: 'AcmeCard', description: 'Fixture.', props: []};\n",
|
|
1145
|
+
[`${WIDGETS}/components/AcmeCard.tsx`]:
|
|
1146
|
+
'export default function AcmeCard() { return null; }\n',
|
|
1147
|
+
});
|
|
1148
|
+
const APP = {
|
|
1149
|
+
'package.json': '{"name":"app"}',
|
|
1150
|
+
...CORE_STUB,
|
|
1151
|
+
'astryx.config.mjs': "export default { integrations: ['@acme/widgets'] };\n",
|
|
1152
|
+
};
|
|
1153
|
+
|
|
1154
|
+
/** Run doctor on a project under the working directory. */
|
|
1155
|
+
async function report(files) {
|
|
1156
|
+
const dir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-doctor-gate-'));
|
|
1157
|
+
tmpDirs.push(dir);
|
|
1158
|
+
for (const [rel, content] of Object.entries(files)) {
|
|
1159
|
+
const abs = path.join(dir, rel);
|
|
1160
|
+
fs.mkdirSync(path.dirname(abs), {recursive: true});
|
|
1161
|
+
fs.writeFileSync(abs, content);
|
|
1162
|
+
}
|
|
1163
|
+
const {checks, summary} = (await doctor({cwd: dir})).data;
|
|
1164
|
+
return {by: Object.fromEntries(checks.map(c => [c.id, c])), summary};
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
it.each([
|
|
1168
|
+
['not installed', {}, /Could not find installed integration package "@acme\/widgets"/],
|
|
1169
|
+
[
|
|
1170
|
+
'installed without a manifest',
|
|
1171
|
+
{[`${WIDGETS}/package.json`]: JSON.stringify({name: '@acme/widgets', version: '1.0.0'})},
|
|
1172
|
+
/no conventional root manifest/,
|
|
1173
|
+
],
|
|
1174
|
+
['installed with a manifest that throws', widgets('export default { not valid ((\n'), /Unexpected/],
|
|
1175
|
+
])(
|
|
1176
|
+
'fails when a configured integration is %s, and names it',
|
|
1177
|
+
async (_shape, extra, reason) => {
|
|
1178
|
+
const {by, summary} = await report({...APP, ...extra});
|
|
1179
|
+
const check = by['configured-integrations'];
|
|
1180
|
+
expect(check.status).toBe('fail');
|
|
1181
|
+
expect(check.message).toMatch(
|
|
1182
|
+
/^1 of 1 integration named in astryx\.config could not be loaded, so it contributes nothing: @acme\/widgets \(/,
|
|
1183
|
+
);
|
|
1184
|
+
expect(check.message).toMatch(reason);
|
|
1185
|
+
expect(check.fix).toContain('astryx doctor integration validate <package>');
|
|
1186
|
+
expect(summary.fail).toBe(1);
|
|
1187
|
+
},
|
|
1188
|
+
SLOW,
|
|
1189
|
+
);
|
|
1190
|
+
|
|
1191
|
+
it(
|
|
1192
|
+
'counts the package being authored when its own config names it',
|
|
1193
|
+
async () => {
|
|
1194
|
+
const {by} = await report({
|
|
1195
|
+
...CORE_STUB,
|
|
1196
|
+
'package.json': JSON.stringify({name: '@acme/widgets', version: '1.0.0'}),
|
|
1197
|
+
'astryx.integration.mjs': "export default {components: './components'};\n",
|
|
1198
|
+
'components/AcmeCard.doc.mjs':
|
|
1199
|
+
"export default {type: 'component', name: 'AcmeCard', displayName: 'AcmeCard', description: 'Fixture.', props: []};\n",
|
|
1200
|
+
'components/AcmeCard.tsx': 'export default function AcmeCard() { return null; }\n',
|
|
1201
|
+
'astryx.config.mjs': "export default { integrations: ['@acme/widgets'] };\n",
|
|
1202
|
+
});
|
|
1203
|
+
expect(by['configured-integrations'].status).toBe('pass');
|
|
1204
|
+
expect(by['configured-integrations'].message).toBe(
|
|
1205
|
+
'1 integration named in astryx.config loaded: @acme/widgets.',
|
|
1206
|
+
);
|
|
1207
|
+
},
|
|
1208
|
+
SLOW,
|
|
1209
|
+
);
|
|
1210
|
+
|
|
1211
|
+
it(
|
|
1212
|
+
'fails when the package being authored is named by its own config and its manifest throws',
|
|
1213
|
+
async () => {
|
|
1214
|
+
const {by, summary} = await report({
|
|
1215
|
+
...CORE_STUB,
|
|
1216
|
+
'package.json': JSON.stringify({name: '@acme/widgets', version: '1.0.0'}),
|
|
1217
|
+
'astryx.integration.mjs': 'export default { not valid ((\n',
|
|
1218
|
+
'astryx.config.mjs': "export default { integrations: ['@acme/widgets'] };\n",
|
|
1219
|
+
});
|
|
1220
|
+
const check = by['configured-integrations'];
|
|
1221
|
+
expect(check.status).toBe('fail');
|
|
1222
|
+
expect(check.message).toMatch(
|
|
1223
|
+
/^1 of 1 integration named in astryx\.config could not be loaded, so it contributes nothing: @acme\/widgets \(/,
|
|
1224
|
+
);
|
|
1225
|
+
expect(summary.fail).toBe(1);
|
|
1226
|
+
},
|
|
1227
|
+
SLOW,
|
|
1228
|
+
);
|
|
1229
|
+
|
|
1230
|
+
it(
|
|
1231
|
+
'fails when node_modules links the configured name back to the authored package and its manifest throws',
|
|
1232
|
+
async () => {
|
|
1233
|
+
const dir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-doctor-gate-'));
|
|
1234
|
+
tmpDirs.push(dir);
|
|
1235
|
+
const files = {
|
|
1236
|
+
...CORE_STUB,
|
|
1237
|
+
'package.json': JSON.stringify({name: '@acme/widgets', version: '1.0.0'}),
|
|
1238
|
+
'astryx.integration.mjs': 'export default { not valid ((\n',
|
|
1239
|
+
'astryx.config.mjs': "export default { integrations: ['@acme/widgets'] };\n",
|
|
1240
|
+
};
|
|
1241
|
+
for (const [rel, content] of Object.entries(files)) {
|
|
1242
|
+
const abs = path.join(dir, rel);
|
|
1243
|
+
fs.mkdirSync(path.dirname(abs), {recursive: true});
|
|
1244
|
+
fs.writeFileSync(abs, content);
|
|
1245
|
+
}
|
|
1246
|
+
fs.mkdirSync(path.join(dir, 'node_modules/@acme'), {recursive: true});
|
|
1247
|
+
fs.symlinkSync(dir, path.join(dir, 'node_modules/@acme/widgets'), 'dir');
|
|
1248
|
+
const {checks, summary} = (await doctor({cwd: dir})).data;
|
|
1249
|
+
const by = Object.fromEntries(checks.map(c => [c.id, c]));
|
|
1250
|
+
expect(by['configured-integrations'].status).toBe('fail');
|
|
1251
|
+
expect(by['configured-integrations'].message).toMatch(
|
|
1252
|
+
/^1 of 1 integration named in astryx\.config could not be loaded/,
|
|
1253
|
+
);
|
|
1254
|
+
expect(summary.fail).toBe(1);
|
|
1255
|
+
},
|
|
1256
|
+
SLOW,
|
|
1257
|
+
);
|
|
1258
|
+
|
|
1259
|
+
it(
|
|
1260
|
+
'fails for the self-linked authored package when the working directory is itself a symlink',
|
|
1261
|
+
async () => {
|
|
1262
|
+
const real = fs.mkdtempSync(path.join(process.cwd(), '.astryx-doctor-gate-'));
|
|
1263
|
+
tmpDirs.push(real);
|
|
1264
|
+
const linkParent = fs.mkdtempSync(path.join(process.cwd(), '.astryx-doctor-gate-'));
|
|
1265
|
+
tmpDirs.push(linkParent);
|
|
1266
|
+
const cwd = path.join(linkParent, 'link');
|
|
1267
|
+
fs.symlinkSync(real, cwd, 'dir');
|
|
1268
|
+
const files = {
|
|
1269
|
+
...CORE_STUB,
|
|
1270
|
+
'package.json': JSON.stringify({name: '@acme/widgets', version: '1.0.0'}),
|
|
1271
|
+
'astryx.integration.mjs': 'export default { not valid ((\n',
|
|
1272
|
+
'astryx.config.mjs': "export default { integrations: ['@acme/widgets'] };\n",
|
|
1273
|
+
};
|
|
1274
|
+
for (const [rel, content] of Object.entries(files)) {
|
|
1275
|
+
const abs = path.join(real, rel);
|
|
1276
|
+
fs.mkdirSync(path.dirname(abs), {recursive: true});
|
|
1277
|
+
fs.writeFileSync(abs, content);
|
|
1278
|
+
}
|
|
1279
|
+
fs.mkdirSync(path.join(real, 'node_modules/@acme'), {recursive: true});
|
|
1280
|
+
fs.symlinkSync(real, path.join(real, 'node_modules/@acme/widgets'), 'dir');
|
|
1281
|
+
const {checks, summary} = (await doctor({cwd})).data;
|
|
1282
|
+
const by = Object.fromEntries(checks.map(c => [c.id, c]));
|
|
1283
|
+
expect(by['configured-integrations'].status).toBe('fail');
|
|
1284
|
+
expect(summary.fail).toBe(1);
|
|
1285
|
+
},
|
|
1286
|
+
SLOW,
|
|
1287
|
+
);
|
|
1288
|
+
|
|
1289
|
+
it(
|
|
1290
|
+
'still counts a configured package that was set aside for a provider conflict',
|
|
1291
|
+
async () => {
|
|
1292
|
+
const CHARTS = 'node_modules/@acme/charts';
|
|
1293
|
+
const {by} = await report({
|
|
1294
|
+
...APP,
|
|
1295
|
+
'astryx.config.mjs':
|
|
1296
|
+
"export default { integrations: ['@acme/widgets', '@acme/charts'] };\n",
|
|
1297
|
+
...widgets("export default {providerId: 'acme', components: './components'};\n"),
|
|
1298
|
+
[`${CHARTS}/package.json`]: JSON.stringify({name: '@acme/charts', version: '1.0.0'}),
|
|
1299
|
+
[`${CHARTS}/astryx.integration.mjs`]:
|
|
1300
|
+
"export default {providerId: 'acme', components: './components'};\n",
|
|
1301
|
+
[`${CHARTS}/components/AcmeChart.doc.mjs`]:
|
|
1302
|
+
"export default {type: 'component', name: 'AcmeChart', displayName: 'AcmeChart', description: 'Fixture.', props: []};\n",
|
|
1303
|
+
[`${CHARTS}/components/AcmeChart.tsx`]: 'export default function AcmeChart() { return null; }\n',
|
|
1304
|
+
});
|
|
1305
|
+
expect(by['configured-integrations'].status).toBe('pass');
|
|
1306
|
+
expect(by['configured-integrations'].message).toMatch(/^2 integrations named in astryx\.config loaded: /);
|
|
1307
|
+
expect(by['configured-integrations'].message).toContain('@acme/charts');
|
|
1308
|
+
},
|
|
1309
|
+
SLOW,
|
|
1310
|
+
);
|
|
1311
|
+
|
|
1312
|
+
it(
|
|
1313
|
+
'passes, naming each one, when every configured integration loads',
|
|
1314
|
+
async () => {
|
|
1315
|
+
const {by, summary} = await report({...APP, ...widgets()});
|
|
1316
|
+
expect(by['configured-integrations']).toEqual({
|
|
1317
|
+
id: 'configured-integrations',
|
|
1318
|
+
label: 'Configured integrations',
|
|
1319
|
+
status: 'pass',
|
|
1320
|
+
message: '1 integration named in astryx.config loaded: @acme/widgets.',
|
|
1321
|
+
});
|
|
1322
|
+
expect(summary.fail).toBe(0);
|
|
1323
|
+
},
|
|
1324
|
+
SLOW,
|
|
1325
|
+
);
|
|
1326
|
+
|
|
1327
|
+
it.each([
|
|
1328
|
+
[
|
|
1329
|
+
'an invalid component doc',
|
|
1330
|
+
{[`${WIDGETS}/components/AcmeCard.doc.mjs`]: 'export default {;\n'},
|
|
1331
|
+
],
|
|
1332
|
+
[
|
|
1333
|
+
'a declared root missing on disk',
|
|
1334
|
+
{
|
|
1335
|
+
[`${WIDGETS}/astryx.integration.mjs`]:
|
|
1336
|
+
"export default {components: './components', templates: './templates'};\n",
|
|
1337
|
+
},
|
|
1338
|
+
],
|
|
1339
|
+
])(
|
|
1340
|
+
'keeps %s a warning, because the rest of the integration still loads (spec:AST-035 FR9)',
|
|
1341
|
+
async (_shape, extra) => {
|
|
1342
|
+
const {by, summary} = await report({...APP, ...widgets(), ...extra});
|
|
1343
|
+
expect(by['configured-integrations'].status).toBe('pass');
|
|
1344
|
+
expect(by['integration-issues'].status).toBe('warn');
|
|
1345
|
+
expect(summary.fail).toBe(0);
|
|
1346
|
+
},
|
|
1347
|
+
SLOW,
|
|
1348
|
+
);
|
|
1349
|
+
|
|
1350
|
+
it(
|
|
1351
|
+
'leaves an autolinked dependency that cannot load informational',
|
|
1352
|
+
async () => {
|
|
1353
|
+
const {by, summary} = await report({
|
|
1354
|
+
'package.json': JSON.stringify({
|
|
1355
|
+
name: 'app',
|
|
1356
|
+
dependencies: {'@acme/widgets': '1.0.0'},
|
|
1357
|
+
}),
|
|
1358
|
+
...CORE_STUB,
|
|
1359
|
+
...widgets('export default { not valid ((\n'),
|
|
1360
|
+
});
|
|
1361
|
+
expect(by['configured-integrations']).toMatchObject({
|
|
1362
|
+
status: 'info',
|
|
1363
|
+
message: 'No integration is named in astryx.config.',
|
|
1364
|
+
});
|
|
1365
|
+
expect(by['implicit-integrations'].status).toBe('info');
|
|
1366
|
+
expect(summary.fail).toBe(0);
|
|
1367
|
+
},
|
|
1368
|
+
SLOW,
|
|
1369
|
+
);
|
|
1370
|
+
});
|
|
1371
|
+
|
|
1126
1372
|
describe('no Astryx-owned environment variables (spec:AST-017 FR14)', () => {
|
|
1127
1373
|
it('no source file reads an ASTRYX_* env var', () => {
|
|
1128
1374
|
const cliDir = path.resolve(REPO, 'packages/cli');
|