@astryxdesign/cli 0.6.5-canary.f261d2f → 0.6.5-canary.f27f749
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 +14 -13
- package/api/error.d.mts +22 -0
- package/api/error.mjs +42 -0
- package/api/integration/add-contribution.d.mts +2 -1
- package/api/integration/add-contribution.mjs +7 -3
- package/api/integration/add-theme.mjs +243 -22
- package/api/integration/add-theme.test.mjs +213 -0
- package/api/integration/authoring-checks.mjs +10 -7
- package/api/integration/authoring-checks.type.d.mts +8 -0
- package/api/integration/authoring-checks.type.mjs +7 -3
- package/api/integration/integration-authoring.type.d.mts +4 -1
- package/api/integration/integration-authoring.type.mjs +6 -1
- package/api/integration/integrationAdd.doc.mjs +6 -0
- package/api/integration/integrationAddTheme.doc.mjs +10 -0
- package/api/integration/integrationComponentConflicts.doc.mjs +1 -1
- package/api/integration/integrationDocConflicts.doc.mjs +1 -1
- package/api/integration/integrationTemplateConflicts.doc.mjs +1 -1
- package/api/integration/validate-integration.d.mts +4 -2
- package/api/integration/validate-integration.mjs +7 -2
- package/api/integration/validate-integration.test.mjs +55 -0
- package/api/integration/validate-integration.type.d.mts +5 -0
- package/api/integration/validate-integration.type.mjs +5 -1
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/layout/expand/expand.mjs +12 -7
- package/api/layout/expand/expand.receipt.test.mjs +74 -0
- package/api/layout/layout.type.d.mts +1 -0
- package/api/layout/layout.type.mjs +1 -0
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/swizzle/copy/copy.mjs +66 -3
- package/api/swizzle/swizzle.doc.mjs +4 -0
- package/api/template/copy/copy.mjs +14 -8
- package/api/template/copy/copy.receipt.test.mjs +77 -0
- package/api/template/show/show.mjs +15 -4
- package/api/template/show/show.test.mjs +76 -0
- package/api/template/template.d.mts +1 -1
- package/api/template/template.doc.mjs +6 -2
- package/api/template/template.mjs +1 -0
- package/api/template/template.type.d.mts +2 -0
- package/api/template/template.type.mjs +2 -0
- package/api/theme/build/build.d.mts +24 -0
- package/api/theme/build/build.mjs +235 -8
- package/api/theme/build/build.project-core.test.mjs +165 -0
- package/api/upgrade/run/run.mjs +20 -3
- package/api/upgrade/run/run.test.mjs +45 -1
- package/api/upgrade/upgrade.doc.mjs +1 -1
- package/api/upgrade/upgrade.type.d.mts +1 -0
- package/api/upgrade/upgrade.type.mjs +1 -0
- package/assets/docs/icons.doc.mjs +1 -0
- package/assets/templates/themes/butter/icons.tsx +2 -0
- package/assets/templates/themes/chocolate/icons.tsx +2 -0
- package/assets/templates/themes/gothic/icons.tsx +2 -0
- package/assets/templates/themes/matcha/icons.tsx +2 -0
- package/assets/templates/themes/neutral/icons.tsx +2 -0
- package/assets/templates/themes/stone/icons.tsx +2 -0
- package/assets/templates/themes/y2k/icons.tsx +2 -0
- package/clients/cli/commands/doctor.mjs +4 -4
- package/clients/cli/commands/integration-add.doc.mjs +10 -0
- package/clients/cli/commands/integration-authoring.test.mjs +12 -2
- package/clients/cli/commands/integration.mjs +3 -1
- package/clients/cli/commands/layout-expand.doc.mjs +3 -1
- package/clients/cli/commands/layout.expand-receipt.test.mjs +94 -0
- package/clients/cli/commands/layout.mjs +16 -0
- package/clients/cli/commands/template.copy-receipt.test.mjs +60 -0
- package/clients/cli/commands/template.mjs +19 -5
- package/clients/cli/commands/template.show-media.test.mjs +62 -0
- package/clients/cli/commands/upgrade.ascii-output.test.mjs +14 -0
- package/clients/cli/commands/write-failure.test.mjs +175 -0
- package/clients/cli/lib/manifest.mjs +44 -165
- package/clients/cli/lib/manifest.test.mjs +98 -7
- package/foundation/discovery/template-adapter.d.mts +13 -0
- package/foundation/discovery/template-adapter.fixture-refs.test.mjs +37 -1
- package/foundation/discovery/template-adapter.mjs +16 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +2 -2
- package/foundation/response/response-types.doc.d.mts +5 -5
- package/foundation/response/response-types.doc.mjs +13 -13
- package/package.json +9 -9
|
@@ -310,3 +310,216 @@ describe('integrationAddTheme', () => {
|
|
|
310
310
|
);
|
|
311
311
|
});
|
|
312
312
|
});
|
|
313
|
+
|
|
314
|
+
describe('integrationAddTheme --from', () => {
|
|
315
|
+
it('forks a bundled theme into the integration package', async () => {
|
|
316
|
+
setup();
|
|
317
|
+
const result = await integrationAddTheme('ocean', {
|
|
318
|
+
cwd: tmpDir,
|
|
319
|
+
from: 'neutral',
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
expect(result.type).toBe('integration.add');
|
|
323
|
+
expect(result.data.kind).toBe('theme');
|
|
324
|
+
expect(result.data.name).toBe('ocean');
|
|
325
|
+
expect(result.data.from).toBe('neutral');
|
|
326
|
+
expect(result.data.written).toBe(true);
|
|
327
|
+
expect(result.data.dryRun).toBe(false);
|
|
328
|
+
expect(result.data.root).toEqual({path: './themes', created: true});
|
|
329
|
+
|
|
330
|
+
// The entry file must exist with the new export name.
|
|
331
|
+
const entry = fs.readFileSync(
|
|
332
|
+
path.join(tmpDir, 'themes/ocean/oceanTheme.ts'),
|
|
333
|
+
'utf-8',
|
|
334
|
+
);
|
|
335
|
+
expect(entry).toContain('oceanTheme');
|
|
336
|
+
expect(entry).toContain("name: 'ocean'");
|
|
337
|
+
// It must NOT contain the original theme identifier as a prefix.
|
|
338
|
+
expect(entry).not.toMatch(/\bneutralTheme\b/);
|
|
339
|
+
expect(entry).not.toMatch(/\bneutralPalettes\b/);
|
|
340
|
+
expect(entry).not.toMatch(/\bneutralSyntax\b/);
|
|
341
|
+
expect(entry).toContain('defineTheme');
|
|
342
|
+
|
|
343
|
+
// A fresh descriptor, not copied from the base.
|
|
344
|
+
const descriptor = fs.readFileSync(
|
|
345
|
+
path.join(tmpDir, 'themes/ocean/oceanTheme.doc.mjs'),
|
|
346
|
+
'utf-8',
|
|
347
|
+
);
|
|
348
|
+
expect(descriptor).toContain("name: 'ocean'");
|
|
349
|
+
expect(descriptor).toContain("@astryxdesign/cli/authoring').ThemeDoc");
|
|
350
|
+
expect(descriptor).toContain('maintained: true');
|
|
351
|
+
|
|
352
|
+
// The theme must validate.
|
|
353
|
+
expect((await validateLocalIntegration(tmpDir)).issues).toEqual([]);
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
it('renames palette and support files from the base theme', async () => {
|
|
357
|
+
setup();
|
|
358
|
+
await integrationAddTheme('ocean', {cwd: tmpDir, from: 'neutral'});
|
|
359
|
+
|
|
360
|
+
const themeDir = path.join(tmpDir, 'themes/ocean');
|
|
361
|
+
const files = fs.readdirSync(themeDir).sort();
|
|
362
|
+
// neutralPalettes.ts → oceanPalettes.ts, etc.
|
|
363
|
+
expect(files).toContain('oceanTheme.ts');
|
|
364
|
+
expect(files).toContain('oceanTheme.doc.mjs');
|
|
365
|
+
expect(files).toContain('oceanPalettes.ts');
|
|
366
|
+
expect(files).toContain('oceanPaletteRefs.generated.ts');
|
|
367
|
+
expect(files).toContain('icons.tsx');
|
|
368
|
+
// Must not contain any file starting with 'neutral'.
|
|
369
|
+
expect(files.filter(f => f.startsWith('neutral'))).toEqual([]);
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
it('rewrites import paths inside forked files', async () => {
|
|
373
|
+
setup();
|
|
374
|
+
await integrationAddTheme('ocean', {cwd: tmpDir, from: 'neutral'});
|
|
375
|
+
|
|
376
|
+
const entry = fs.readFileSync(
|
|
377
|
+
path.join(tmpDir, 'themes/ocean/oceanTheme.ts'),
|
|
378
|
+
'utf-8',
|
|
379
|
+
);
|
|
380
|
+
// Import references must use the new identifier.
|
|
381
|
+
expect(entry).toContain('./oceanPaletteRefs.generated');
|
|
382
|
+
expect(entry).not.toContain('./neutralPaletteRefs.generated');
|
|
383
|
+
// The icon registry import must also be renamed.
|
|
384
|
+
expect(entry).toContain('oceanIconRegistry');
|
|
385
|
+
expect(entry).not.toContain('neutralIconRegistry');
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
it('rewrites CSS custom properties scoped to the base theme', async () => {
|
|
389
|
+
setup();
|
|
390
|
+
await integrationAddTheme('ocean', {cwd: tmpDir, from: 'neutral'});
|
|
391
|
+
|
|
392
|
+
const entry = fs.readFileSync(
|
|
393
|
+
path.join(tmpDir, 'themes/ocean/oceanTheme.ts'),
|
|
394
|
+
'utf-8',
|
|
395
|
+
);
|
|
396
|
+
expect(entry).toContain('--astryx-theme-ocean-');
|
|
397
|
+
expect(entry).not.toContain('--astryx-theme-neutral-');
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
it('rewrites the syntax theme name', async () => {
|
|
401
|
+
setup();
|
|
402
|
+
await integrationAddTheme('ocean', {cwd: tmpDir, from: 'neutral'});
|
|
403
|
+
|
|
404
|
+
const entry = fs.readFileSync(
|
|
405
|
+
path.join(tmpDir, 'themes/ocean/oceanTheme.ts'),
|
|
406
|
+
'utf-8',
|
|
407
|
+
);
|
|
408
|
+
expect(entry).toContain("'astryx-ocean'");
|
|
409
|
+
expect(entry).not.toContain("'astryx-neutral'");
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
it('strips the copyright header from forked files', async () => {
|
|
413
|
+
setup();
|
|
414
|
+
await integrationAddTheme('ocean', {cwd: tmpDir, from: 'neutral'});
|
|
415
|
+
|
|
416
|
+
const entry = fs.readFileSync(
|
|
417
|
+
path.join(tmpDir, 'themes/ocean/oceanTheme.ts'),
|
|
418
|
+
'utf-8',
|
|
419
|
+
);
|
|
420
|
+
expect(entry).not.toContain('Copyright (c) Meta Platforms');
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
it('includes data.from in the receipt only when --from is used', async () => {
|
|
424
|
+
setup();
|
|
425
|
+
const blank = await integrationAddTheme('plain', {cwd: tmpDir});
|
|
426
|
+
expect(blank.data).not.toHaveProperty('from');
|
|
427
|
+
|
|
428
|
+
const forked = await integrationAddTheme('ocean', {
|
|
429
|
+
cwd: tmpDir,
|
|
430
|
+
from: 'neutral',
|
|
431
|
+
});
|
|
432
|
+
expect(forked.data.from).toBe('neutral');
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
it('refuses to fork a theme into itself', async () => {
|
|
436
|
+
setup();
|
|
437
|
+
await expect(
|
|
438
|
+
integrationAddTheme('neutral', {cwd: tmpDir, from: 'neutral'}),
|
|
439
|
+
).rejects.toMatchObject({code: 'ERR_INVALID_ARGUMENT'});
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
it('refuses an unknown base theme with a helpful suggestion list', async () => {
|
|
443
|
+
setup();
|
|
444
|
+
await expect(
|
|
445
|
+
integrationAddTheme('ocean', {cwd: tmpDir, from: 'nonexistent'}),
|
|
446
|
+
).rejects.toMatchObject({
|
|
447
|
+
code: 'ERR_UNKNOWN_THEME',
|
|
448
|
+
message: expect.stringContaining('nonexistent'),
|
|
449
|
+
});
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
it('dry-runs with --from without writing anything', async () => {
|
|
453
|
+
setup();
|
|
454
|
+
const result = await integrationAddTheme('ocean', {
|
|
455
|
+
cwd: tmpDir,
|
|
456
|
+
from: 'neutral',
|
|
457
|
+
dryRun: true,
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
expect(result.data.written).toBe(false);
|
|
461
|
+
expect(result.data.dryRun).toBe(true);
|
|
462
|
+
expect(result.data.from).toBe('neutral');
|
|
463
|
+
expect(result.data.files).toContain('themes/ocean/oceanTheme.ts');
|
|
464
|
+
expect(result.data.files).toContain('themes/ocean/oceanTheme.doc.mjs');
|
|
465
|
+
expect(fs.existsSync(path.join(tmpDir, 'themes'))).toBe(false);
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
it('refuses to overwrite when the target already exists', async () => {
|
|
469
|
+
setup();
|
|
470
|
+
await integrationAddTheme('ocean', {cwd: tmpDir, from: 'neutral'});
|
|
471
|
+
await expect(
|
|
472
|
+
integrationAddTheme('ocean', {cwd: tmpDir, from: 'neutral'}),
|
|
473
|
+
).rejects.toMatchObject({code: 'ERR_FILE_EXISTS'});
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
it('works with different bundled themes', async () => {
|
|
477
|
+
setup();
|
|
478
|
+
const result = await integrationAddTheme('dusk', {
|
|
479
|
+
cwd: tmpDir,
|
|
480
|
+
from: 'gothic',
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
expect(result.data.from).toBe('gothic');
|
|
484
|
+
const entry = fs.readFileSync(
|
|
485
|
+
path.join(tmpDir, 'themes/dusk/duskTheme.ts'),
|
|
486
|
+
'utf-8',
|
|
487
|
+
);
|
|
488
|
+
expect(entry).toContain('duskTheme');
|
|
489
|
+
expect(entry).toContain("name: 'dusk'");
|
|
490
|
+
expect(entry).not.toMatch(/\bgothicTheme\b/);
|
|
491
|
+
expect((await validateLocalIntegration(tmpDir)).issues).toEqual([]);
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
it('forks from a theme the package already owns', async () => {
|
|
495
|
+
setup();
|
|
496
|
+
// First, add a blank theme.
|
|
497
|
+
await integrationAddTheme('base', {cwd: tmpDir});
|
|
498
|
+
// Then fork it.
|
|
499
|
+
const result = await integrationAddTheme('variant', {
|
|
500
|
+
cwd: tmpDir,
|
|
501
|
+
from: 'base',
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
expect(result.data.from).toBe('base');
|
|
505
|
+
const entry = fs.readFileSync(
|
|
506
|
+
path.join(tmpDir, 'themes/variant/variantTheme.ts'),
|
|
507
|
+
'utf-8',
|
|
508
|
+
);
|
|
509
|
+
expect(entry).toContain('variantTheme');
|
|
510
|
+
expect(entry).toContain("name: 'variant'");
|
|
511
|
+
expect((await validateLocalIntegration(tmpDir)).issues).toEqual([]);
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
it('declares the optional CLI peer that reads typed theme descriptors', async () => {
|
|
515
|
+
setup({includeFiles: false});
|
|
516
|
+
await integrationAddTheme('ocean', {cwd: tmpDir, from: 'neutral'});
|
|
517
|
+
const pkg = JSON.parse(
|
|
518
|
+
fs.readFileSync(path.join(tmpDir, 'package.json'), 'utf-8'),
|
|
519
|
+
);
|
|
520
|
+
expect(pkg.peerDependencies).toEqual({'@astryxdesign/cli': '>=0.6.4'});
|
|
521
|
+
expect(pkg.peerDependenciesMeta).toEqual({
|
|
522
|
+
'@astryxdesign/cli': {optional: true},
|
|
523
|
+
});
|
|
524
|
+
});
|
|
525
|
+
});
|
|
@@ -92,6 +92,7 @@ function addErrors(issues, errors, code) {
|
|
|
92
92
|
export async function integrationTemplateConflicts(pkg, options = {}) {
|
|
93
93
|
const {cwd = process.cwd()} = options;
|
|
94
94
|
const resolved = await resolveIntegration(pkg, cwd);
|
|
95
|
+
const validated = resolved.found;
|
|
95
96
|
const name = resolved.found ? (resolved.name ?? null) : null;
|
|
96
97
|
const version = resolved.found ? (resolved.version ?? null) : null;
|
|
97
98
|
const issues = [...resolved.issues];
|
|
@@ -99,7 +100,7 @@ export async function integrationTemplateConflicts(pkg, options = {}) {
|
|
|
99
100
|
if (!resolved.integration || name == null) {
|
|
100
101
|
return {
|
|
101
102
|
type: 'integration.template-conflicts',
|
|
102
|
-
data: {name, version, conflicts: [], issues},
|
|
103
|
+
data: {validated, name, version, conflicts: [], issues},
|
|
103
104
|
};
|
|
104
105
|
}
|
|
105
106
|
|
|
@@ -215,7 +216,7 @@ export async function integrationTemplateConflicts(pkg, options = {}) {
|
|
|
215
216
|
|
|
216
217
|
return {
|
|
217
218
|
type: 'integration.template-conflicts',
|
|
218
|
-
data: {name, version, conflicts, issues},
|
|
219
|
+
data: {validated, name, version, conflicts, issues},
|
|
219
220
|
};
|
|
220
221
|
}
|
|
221
222
|
|
|
@@ -228,6 +229,7 @@ export async function integrationTemplateConflicts(pkg, options = {}) {
|
|
|
228
229
|
export async function integrationComponentConflicts(pkg, options = {}) {
|
|
229
230
|
const {cwd = process.cwd()} = options;
|
|
230
231
|
const resolved = await resolveIntegration(pkg, cwd);
|
|
232
|
+
const validated = resolved.found;
|
|
231
233
|
const name = resolved.found ? (resolved.name ?? null) : null;
|
|
232
234
|
const version = resolved.found ? (resolved.version ?? null) : null;
|
|
233
235
|
const issues = [...resolved.issues];
|
|
@@ -235,7 +237,7 @@ export async function integrationComponentConflicts(pkg, options = {}) {
|
|
|
235
237
|
if (!resolved.integration?.components || name == null) {
|
|
236
238
|
return {
|
|
237
239
|
type: 'integration.component-conflicts',
|
|
238
|
-
data: {name, version, conflicts: [], issues},
|
|
240
|
+
data: {validated, name, version, conflicts: [], issues},
|
|
239
241
|
};
|
|
240
242
|
}
|
|
241
243
|
|
|
@@ -249,7 +251,7 @@ export async function integrationComponentConflicts(pkg, options = {}) {
|
|
|
249
251
|
});
|
|
250
252
|
return {
|
|
251
253
|
type: 'integration.component-conflicts',
|
|
252
|
-
data: {name, version, conflicts: [], issues},
|
|
254
|
+
data: {validated, name, version, conflicts: [], issues},
|
|
253
255
|
};
|
|
254
256
|
}
|
|
255
257
|
|
|
@@ -274,7 +276,7 @@ export async function integrationComponentConflicts(pkg, options = {}) {
|
|
|
274
276
|
|
|
275
277
|
return {
|
|
276
278
|
type: 'integration.component-conflicts',
|
|
277
|
-
data: {name, version, conflicts, issues},
|
|
279
|
+
data: {validated, name, version, conflicts, issues},
|
|
278
280
|
};
|
|
279
281
|
}
|
|
280
282
|
|
|
@@ -287,6 +289,7 @@ export async function integrationComponentConflicts(pkg, options = {}) {
|
|
|
287
289
|
export async function integrationDocConflicts(pkg, options = {}) {
|
|
288
290
|
const {cwd = process.cwd()} = options;
|
|
289
291
|
const resolved = await resolveIntegration(pkg, cwd);
|
|
292
|
+
const validated = resolved.found;
|
|
290
293
|
const name = resolved.found ? (resolved.name ?? null) : null;
|
|
291
294
|
const version = resolved.found ? (resolved.version ?? null) : null;
|
|
292
295
|
const issues = [...resolved.issues];
|
|
@@ -294,7 +297,7 @@ export async function integrationDocConflicts(pkg, options = {}) {
|
|
|
294
297
|
if (!resolved.integration?.docs || name == null) {
|
|
295
298
|
return {
|
|
296
299
|
type: 'integration.doc-conflicts',
|
|
297
|
-
data: {name, version, findings: [], issues},
|
|
300
|
+
data: {validated, name, version, findings: [], issues},
|
|
298
301
|
};
|
|
299
302
|
}
|
|
300
303
|
|
|
@@ -388,6 +391,6 @@ export async function integrationDocConflicts(pkg, options = {}) {
|
|
|
388
391
|
|
|
389
392
|
return {
|
|
390
393
|
type: 'integration.doc-conflicts',
|
|
391
|
-
data: {name, version, findings, issues},
|
|
394
|
+
data: {validated, name, version, findings, issues},
|
|
392
395
|
};
|
|
393
396
|
}
|
|
@@ -32,9 +32,15 @@ export type IntegrationDocFinding = {
|
|
|
32
32
|
coreTopic: string;
|
|
33
33
|
message: string;
|
|
34
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* Each of the three authoring checks reports `validated`: false means no
|
|
37
|
+
* integration manifest was found, so nothing was inspected and the empty
|
|
38
|
+
* conflicts/findings list carries no information about the package.
|
|
39
|
+
*/
|
|
35
40
|
export type IntegrationTemplateConflictResponse = {
|
|
36
41
|
type: "integration.template-conflicts";
|
|
37
42
|
data: {
|
|
43
|
+
validated: boolean;
|
|
38
44
|
name: string | null;
|
|
39
45
|
version: string | null;
|
|
40
46
|
conflicts: IntegrationTemplateConflict[];
|
|
@@ -44,6 +50,7 @@ export type IntegrationTemplateConflictResponse = {
|
|
|
44
50
|
export type IntegrationComponentConflictResponse = {
|
|
45
51
|
type: "integration.component-conflicts";
|
|
46
52
|
data: {
|
|
53
|
+
validated: boolean;
|
|
47
54
|
name: string | null;
|
|
48
55
|
version: string | null;
|
|
49
56
|
conflicts: IntegrationComponentConflict[];
|
|
@@ -53,6 +60,7 @@ export type IntegrationComponentConflictResponse = {
|
|
|
53
60
|
export type IntegrationDocConflictResponse = {
|
|
54
61
|
type: "integration.doc-conflicts";
|
|
55
62
|
data: {
|
|
63
|
+
validated: boolean;
|
|
56
64
|
name: string | null;
|
|
57
65
|
version: string | null;
|
|
58
66
|
findings: IntegrationDocFinding[];
|
|
@@ -49,21 +49,25 @@
|
|
|
49
49
|
*/
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
+
* Each of the three authoring checks reports `validated`: false means no
|
|
53
|
+
* integration manifest was found, so nothing was inspected and the empty
|
|
54
|
+
* conflicts/findings list carries no information about the package.
|
|
55
|
+
*
|
|
52
56
|
* @typedef {object} IntegrationTemplateConflictResponse
|
|
53
57
|
* @property {'integration.template-conflicts'} type
|
|
54
|
-
* @property {{name: string | null, version: string | null, conflicts: IntegrationTemplateConflict[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
|
|
58
|
+
* @property {{validated: boolean, name: string | null, version: string | null, conflicts: IntegrationTemplateConflict[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
|
|
55
59
|
*/
|
|
56
60
|
|
|
57
61
|
/**
|
|
58
62
|
* @typedef {object} IntegrationComponentConflictResponse
|
|
59
63
|
* @property {'integration.component-conflicts'} type
|
|
60
|
-
* @property {{name: string | null, version: string | null, conflicts: IntegrationComponentConflict[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
|
|
64
|
+
* @property {{validated: boolean, name: string | null, version: string | null, conflicts: IntegrationComponentConflict[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
|
|
61
65
|
*/
|
|
62
66
|
|
|
63
67
|
/**
|
|
64
68
|
* @typedef {object} IntegrationDocConflictResponse
|
|
65
69
|
* @property {'integration.doc-conflicts'} type
|
|
66
|
-
* @property {{name: string | null, version: string | null, findings: IntegrationDocFinding[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
|
|
70
|
+
* @property {{validated: boolean, name: string | null, version: string | null, findings: IntegrationDocFinding[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
|
|
67
71
|
*/
|
|
68
72
|
|
|
69
73
|
export {};
|
|
@@ -19,7 +19,9 @@ export type IntegrationAddCodemodOptions = IntegrationAddBaseOptions & {
|
|
|
19
19
|
to: string;
|
|
20
20
|
};
|
|
21
21
|
export type IntegrationAddAgentDocOptions = IntegrationAddBaseOptions;
|
|
22
|
-
export type IntegrationAddThemeOptions = IntegrationAddBaseOptions
|
|
22
|
+
export type IntegrationAddThemeOptions = IntegrationAddBaseOptions & {
|
|
23
|
+
from?: string;
|
|
24
|
+
};
|
|
23
25
|
/**
|
|
24
26
|
* Options for the generic `integrationAdd` dispatcher. Prefer a per-kind API
|
|
25
27
|
* when the contribution kind is known so the accepted options stay narrow.
|
|
@@ -54,4 +56,5 @@ export type IntegrationAddData = {
|
|
|
54
56
|
files: string[];
|
|
55
57
|
written: boolean;
|
|
56
58
|
dryRun: boolean;
|
|
59
|
+
from?: string | undefined;
|
|
57
60
|
};
|
|
@@ -37,7 +37,11 @@
|
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
39
|
/** @typedef {IntegrationAddBaseOptions} IntegrationAddAgentDocOptions */
|
|
40
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* @typedef {IntegrationAddBaseOptions & {
|
|
42
|
+
* from?: string,
|
|
43
|
+
* }} IntegrationAddThemeOptions
|
|
44
|
+
*/
|
|
41
45
|
|
|
42
46
|
/**
|
|
43
47
|
* Options for the generic `integrationAdd` dispatcher. Prefer a per-kind API
|
|
@@ -73,6 +77,7 @@
|
|
|
73
77
|
* @property {string[]} files
|
|
74
78
|
* @property {boolean} written
|
|
75
79
|
* @property {boolean} dryRun
|
|
80
|
+
* @property {string} [from]
|
|
76
81
|
*/
|
|
77
82
|
|
|
78
83
|
export {};
|
|
@@ -78,6 +78,12 @@ export const doc = {
|
|
|
78
78
|
type: 'string',
|
|
79
79
|
description: 'Exact target semver (e.g. 1.2.0). Required for codemod and only valid there.',
|
|
80
80
|
},
|
|
81
|
+
{
|
|
82
|
+
name: 'options.from',
|
|
83
|
+
type: 'string',
|
|
84
|
+
description:
|
|
85
|
+
'Slug of an existing theme to fork as the starting point. Only valid for theme.',
|
|
86
|
+
},
|
|
81
87
|
],
|
|
82
88
|
returns: [
|
|
83
89
|
{
|
|
@@ -33,6 +33,12 @@ export const doc = {
|
|
|
33
33
|
'Validate and return the same receipt without writing; data.written is false and data.dryRun is true.',
|
|
34
34
|
default: 'false',
|
|
35
35
|
},
|
|
36
|
+
{
|
|
37
|
+
name: 'options.from',
|
|
38
|
+
type: 'string',
|
|
39
|
+
description:
|
|
40
|
+
'Slug of an existing theme to fork as the starting point. The new theme copies the base and has no link back.',
|
|
41
|
+
},
|
|
36
42
|
],
|
|
37
43
|
returns: [
|
|
38
44
|
{
|
|
@@ -76,6 +82,10 @@ export const doc = {
|
|
|
76
82
|
label: 'Add a theme',
|
|
77
83
|
code: "await integrationAddTheme('ocean');",
|
|
78
84
|
},
|
|
85
|
+
{
|
|
86
|
+
label: 'Fork an existing theme',
|
|
87
|
+
code: "await integrationAddTheme('ocean', {from: 'neutral'});",
|
|
88
|
+
},
|
|
79
89
|
{
|
|
80
90
|
label: 'Preview writes',
|
|
81
91
|
code: "await integrationAddTheme('ocean', {dryRun: true});",
|
|
@@ -26,7 +26,7 @@ export const doc = {
|
|
|
26
26
|
{
|
|
27
27
|
type: 'integration.component-conflicts',
|
|
28
28
|
description:
|
|
29
|
-
'
|
|
29
|
+
'`validated` (false when no integration manifest was found, so nothing was inspected), integration identity, structural issues, and Core component-name conflicts with package-qualified commands.',
|
|
30
30
|
},
|
|
31
31
|
],
|
|
32
32
|
examples: [
|
|
@@ -26,7 +26,7 @@ export const doc = {
|
|
|
26
26
|
{
|
|
27
27
|
type: 'integration.doc-conflicts',
|
|
28
28
|
description:
|
|
29
|
-
'
|
|
29
|
+
'`validated` (false when no integration manifest was found, so nothing was inspected), integration identity, structural issues, and classified Core doc relationships.',
|
|
30
30
|
},
|
|
31
31
|
],
|
|
32
32
|
examples: [
|
|
@@ -41,7 +41,7 @@ export const doc = {
|
|
|
41
41
|
{
|
|
42
42
|
type: 'integration.template-conflicts',
|
|
43
43
|
description:
|
|
44
|
-
'
|
|
44
|
+
'`validated` (false when no integration manifest was found, so nothing was inspected and the empty conflict list carries no information), the integration identity, structural issues, and every Core template-id conflict with a package-qualified command.',
|
|
45
45
|
},
|
|
46
46
|
],
|
|
47
47
|
examples: [
|
|
@@ -19,8 +19,10 @@ export function validateInstalledIntegration(spec: string, cwd?: string): Promis
|
|
|
19
19
|
/**
|
|
20
20
|
* Unified entry: validate the LOCAL integration (no `pkg`) or an INSTALLED one
|
|
21
21
|
* (`pkg` given) and return the `integration.validate` envelope. The no-manifest
|
|
22
|
-
* local case is guidance, not an error — it comes back with `
|
|
23
|
-
* issues so the CLI can print a hint and stay exit-0.
|
|
22
|
+
* local case is guidance, not an error — it comes back with `validated: false`,
|
|
23
|
+
* `name: null` and no issues so the CLI can print a hint and stay exit-0.
|
|
24
|
+
* `validated` is what tells a machine consumer that empty `issues` means
|
|
25
|
+
* "nothing was checked" rather than "checked and healthy".
|
|
24
26
|
*
|
|
25
27
|
* This is the seam that keeps the CLI a thin wrapper: the command handler calls
|
|
26
28
|
* this and only chooses how to render (human vs --json) + the exit code.
|
|
@@ -427,8 +427,10 @@ export async function validateInstalledIntegration(spec, cwd = process.cwd()) {
|
|
|
427
427
|
/**
|
|
428
428
|
* Unified entry: validate the LOCAL integration (no `pkg`) or an INSTALLED one
|
|
429
429
|
* (`pkg` given) and return the `integration.validate` envelope. The no-manifest
|
|
430
|
-
* local case is guidance, not an error — it comes back with `
|
|
431
|
-
* issues so the CLI can print a hint and stay exit-0.
|
|
430
|
+
* local case is guidance, not an error — it comes back with `validated: false`,
|
|
431
|
+
* `name: null` and no issues so the CLI can print a hint and stay exit-0.
|
|
432
|
+
* `validated` is what tells a machine consumer that empty `issues` means
|
|
433
|
+
* "nothing was checked" rather than "checked and healthy".
|
|
432
434
|
*
|
|
433
435
|
* This is the seam that keeps the CLI a thin wrapper: the command handler calls
|
|
434
436
|
* this and only chooses how to render (human vs --json) + the exit code.
|
|
@@ -445,6 +447,9 @@ export async function validateIntegration(pkg, options = {}) {
|
|
|
445
447
|
return {
|
|
446
448
|
type: 'integration.validate',
|
|
447
449
|
data: {
|
|
450
|
+
// The one bit that separates "checked and clean" from "never checked":
|
|
451
|
+
// with no manifest there is nothing to validate, and issues stays [].
|
|
452
|
+
validated: result.found,
|
|
448
453
|
name: result.found ? (result.name ?? null) : null,
|
|
449
454
|
version: result.found ? (result.version ?? null) : null,
|
|
450
455
|
issues: result.issues,
|
|
@@ -625,3 +625,58 @@ describe('integration diagnostics are read-only', () => {
|
|
|
625
625
|
expect({pkg: snapshot(pkgDir), consumer: snapshot(consumer)}).toEqual(before);
|
|
626
626
|
});
|
|
627
627
|
});
|
|
628
|
+
|
|
629
|
+
describe('validated separates "checked and clean" from "never checked"', () => {
|
|
630
|
+
// `doctor integration validate --json` from a directory with no manifest
|
|
631
|
+
// returned {name: null, version: null, issues: []} and exit 0 — the same
|
|
632
|
+
// envelope a healthy, fully validated integration produces. Wire that into
|
|
633
|
+
// CI from the wrong directory and it is green forever.
|
|
634
|
+
it('is false for every check when no manifest is found', async () => {
|
|
635
|
+
const dir = path.join(tmpDir, 'plain');
|
|
636
|
+
fs.mkdirSync(dir, {recursive: true});
|
|
637
|
+
fs.writeFileSync(
|
|
638
|
+
path.join(dir, 'package.json'),
|
|
639
|
+
JSON.stringify({name: 'plain-app', version: '1.0.0'}),
|
|
640
|
+
);
|
|
641
|
+
|
|
642
|
+
const validate = await validateIntegration(undefined, {cwd: dir});
|
|
643
|
+
expect(validate.data.validated).toBe(false);
|
|
644
|
+
expect(validate.data.issues).toEqual([]);
|
|
645
|
+
|
|
646
|
+
const templates = await integrationTemplateConflicts(undefined, {cwd: dir});
|
|
647
|
+
const components = await integrationComponentConflicts(undefined, {cwd: dir});
|
|
648
|
+
const docs = await integrationDocConflicts(undefined, {cwd: dir});
|
|
649
|
+
expect(templates.data.validated).toBe(false);
|
|
650
|
+
expect(components.data.validated).toBe(false);
|
|
651
|
+
expect(docs.data.validated).toBe(false);
|
|
652
|
+
});
|
|
653
|
+
|
|
654
|
+
it('is true for a real integration, whose empty issue list then means healthy', async () => {
|
|
655
|
+
const dir = path.join(tmpDir, 'integration');
|
|
656
|
+
writePackage(dir, {manifest: 'export default {};\n'});
|
|
657
|
+
|
|
658
|
+
const validate = await validateIntegration(undefined, {cwd: dir});
|
|
659
|
+
expect(validate.data.validated).toBe(true);
|
|
660
|
+
expect(validate.data.name).toBe('@acme/widgets');
|
|
661
|
+
|
|
662
|
+
const templates = await integrationTemplateConflicts(undefined, {cwd: dir});
|
|
663
|
+
const components = await integrationComponentConflicts(undefined, {cwd: dir});
|
|
664
|
+
const docs = await integrationDocConflicts(undefined, {cwd: dir});
|
|
665
|
+
expect(templates.data.validated).toBe(true);
|
|
666
|
+
expect(components.data.validated).toBe(true);
|
|
667
|
+
expect(docs.data.validated).toBe(true);
|
|
668
|
+
});
|
|
669
|
+
|
|
670
|
+
it('is true for an installed package that could not be found — that is a real finding', async () => {
|
|
671
|
+
const consumer = path.join(tmpDir, 'consumer');
|
|
672
|
+
fs.mkdirSync(consumer, {recursive: true});
|
|
673
|
+
fs.writeFileSync(
|
|
674
|
+
path.join(consumer, 'package.json'),
|
|
675
|
+
JSON.stringify({name: 'consumer', version: '1.0.0'}),
|
|
676
|
+
);
|
|
677
|
+
|
|
678
|
+
const res = await validateIntegration('@acme/nope', {cwd: consumer});
|
|
679
|
+
expect(res.data.validated).toBe(true);
|
|
680
|
+
expect(summarizeIssues(res.data.issues).errors).toBeGreaterThan(0);
|
|
681
|
+
});
|
|
682
|
+
});
|
|
@@ -27,10 +27,15 @@ export type ValidateIntegrationOptions = {
|
|
|
27
27
|
};
|
|
28
28
|
/**
|
|
29
29
|
* `astryx --json doctor integration validate [package]`.
|
|
30
|
+
*
|
|
31
|
+
* `validated` is false in exactly one case: no integration manifest was found,
|
|
32
|
+
* so nothing was checked. An empty `issues` then means "not looked at", not
|
|
33
|
+
* "healthy" — the two are otherwise byte-identical.
|
|
30
34
|
*/
|
|
31
35
|
export type ValidateIntegrationResponse = {
|
|
32
36
|
type: "integration.validate";
|
|
33
37
|
data: {
|
|
38
|
+
validated: boolean;
|
|
34
39
|
name: string | null;
|
|
35
40
|
version: string | null;
|
|
36
41
|
issues: import("../../foundation/integrations/issue").AstryxIntegrationIssue[];
|
|
@@ -32,9 +32,13 @@
|
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* `astryx --json doctor integration validate [package]`.
|
|
35
|
+
*
|
|
36
|
+
* `validated` is false in exactly one case: no integration manifest was found,
|
|
37
|
+
* so nothing was checked. An empty `issues` then means "not looked at", not
|
|
38
|
+
* "healthy" — the two are otherwise byte-identical.
|
|
35
39
|
* @typedef {object} ValidateIntegrationResponse
|
|
36
40
|
* @property {'integration.validate'} type
|
|
37
|
-
* @property {{name: string | null, version: string | null, issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
|
|
41
|
+
* @property {{validated: boolean, name: string | null, version: string | null, issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
|
|
38
42
|
*/
|
|
39
43
|
|
|
40
44
|
export {};
|
|
@@ -46,7 +46,7 @@ export const doc = {
|
|
|
46
46
|
{
|
|
47
47
|
type: 'integration.validate',
|
|
48
48
|
description:
|
|
49
|
-
'The result envelope: `data.name` and `data.version` of the validated package (both null
|
|
49
|
+
'The result envelope: `data.validated`, false only when no integration manifest was found — nothing was checked, so the empty `data.issues` means "not looked at", not "healthy"; `data.name` and `data.version` of the validated package (both null when `data.validated` is false; `data.name` is `(local package)` when the local package.json has no readable name), plus `data.issues`, an AstryxIntegrationIssue[] of {code, severity: `warning` | `error`, message}.',
|
|
50
50
|
},
|
|
51
51
|
],
|
|
52
52
|
examples: [
|