@astryxdesign/cli 0.6.6-canary.fcf255b → 0.6.6-canary.ffa4f72
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 +83 -83
- package/api/build/_adapter.d.mts +15 -0
- package/api/build/_adapter.mjs +22 -0
- package/api/build/build.doc.mjs +1 -1
- package/api/build/build.type.d.mts +4 -0
- package/api/build/build.type.mjs +1 -0
- package/api/build/help/help.mjs +1 -1
- package/api/build/kit/kit.mjs +12 -1
- package/api/component/component-replacement.test.mjs +12 -0
- package/api/component/component.doc.mjs +5 -2
- package/api/docs/_adapter.mjs +48 -1
- package/api/docs/compiled-topics.test.mjs +1 -1
- package/api/docs/detail/section/section.d.mts +44 -0
- package/api/docs/detail/section/section.mjs +164 -13
- package/api/docs/detail/section/section.test.mjs +4 -4
- package/api/docs/docOverlays.test.mjs +28 -17
- package/api/docs/docs.doc.mjs +3 -3
- package/api/docs/docs.mjs +11 -16
- package/api/docs/docs.test.mjs +9 -10
- package/api/docs/integration-tree.test.mjs +26 -26
- package/api/docs/integrationDocs.test.mjs +2 -2
- package/api/docs/namespace-section.test.mjs +260 -0
- package/api/docs/token-tables.test.mjs +93 -0
- package/api/doctor/_adapter.d.mts +7 -0
- package/api/doctor/_adapter.mjs +48 -0
- package/api/doctor/doctor.d.mts +6 -0
- package/api/doctor/doctor.mjs +154 -43
- package/api/doctor/doctor.test.mjs +104 -0
- package/api/doctor/theme-checks.d.mts +12 -0
- package/api/doctor/theme-checks.mjs +115 -1
- package/api/doctor/theme-checks.test.mjs +142 -1
- package/api/gap-report/gap-report.doc.mjs +2 -1
- package/api/init/run/run.mjs +1 -0
- package/api/integration/validate-integration.mjs +20 -4
- package/api/integration/validate-integration.test.mjs +73 -0
- package/api/layout/check/check.d.mts +1 -0
- package/api/layout/check/check.mjs +1 -0
- package/api/layout/expand/expand.d.mts +1 -0
- package/api/layout/expand/expand.mjs +1 -0
- package/api/layout/grammar/grammar.d.mts +1 -0
- package/api/layout/grammar/grammar.mjs +1 -0
- package/api/layout/layoutCheck.doc.mjs +1 -1
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/layout/layoutGrammar.doc.mjs +1 -1
- package/api/search/search.d.mts +44 -0
- package/api/search/search.domain-priority.test.mjs +261 -0
- package/api/search/search.mjs +191 -29
- package/api/swizzle/swizzle.doc.mjs +5 -2
- package/api/template/copy/copy.mjs +12 -0
- package/api/template/template.doc.mjs +1 -1
- package/api/template/template.type.d.mts +3 -0
- package/api/template/template.type.mjs +3 -0
- package/api/theme/build/build.d.mts +70 -0
- package/api/theme/build/build.mjs +205 -41
- package/api/theme/build/font-warning.d.mts +11 -0
- package/api/theme/build/font-warning.mjs +28 -3
- package/assets/docs/author-a-theme.doc.mjs +19 -14
- package/assets/docs/getting-started.doc.mjs +2 -2
- package/assets/docs/principles.doc.dense.mjs +3 -3
- package/assets/docs/principles.doc.mjs +4 -4
- package/assets/docs/principles.doc.zh.mjs +3 -3
- package/assets/docs/styling-overview.doc.mjs +211 -0
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +5 -5
- package/assets/docs/theme.doc.zh.mjs +1 -1
- package/assets/docs/tree/component-migration.doc.mjs +107 -0
- package/assets/docs/tree/css-and-stylex.doc.mjs +150 -0
- package/assets/docs/tree/font-setup.doc.mjs +122 -0
- package/assets/docs/tree/headers-and-footers.doc.mjs +0 -1
- package/assets/docs/tree/i18n-library-integration.doc.mjs +167 -0
- package/assets/docs/tree/i18n-quick-start.doc.mjs +101 -0
- package/assets/docs/{internationalization.doc.mjs → tree/i18n-rtl-and-testing.doc.mjs} +17 -223
- package/assets/docs/tree/internationalization.doc.mjs +29 -0
- package/assets/docs/tree/layout.doc.mjs +23 -0
- package/assets/docs/{migration.doc.mjs → tree/migration-setup.doc.mjs} +24 -129
- package/assets/docs/tree/migration-verification.doc.mjs +67 -0
- package/assets/docs/tree/migration.doc.mjs +28 -0
- package/assets/docs/tree/non-css-processing.doc.mjs +112 -0
- package/assets/docs/tree/other-libraries.doc.mjs +218 -0
- package/assets/docs/tree/responsive.doc.mjs +0 -4
- package/assets/docs/tree/scaffold.doc.mjs +0 -5
- package/assets/docs/tree/side-panels.doc.mjs +0 -1
- package/assets/docs/tree/structure.doc.mjs +0 -4
- package/assets/docs/tree/styling-advanced.doc.mjs +159 -0
- package/assets/docs/tree/styling-basics.doc.mjs +181 -0
- package/assets/docs/tree/styling-libraries.doc.mjs +30 -0
- package/assets/docs/tree/styling.doc.mjs +29 -0
- package/assets/docs/tree/tailwind.doc.mjs +65 -0
- package/assets/docs/tree/tokens-and-setup.doc.mjs +128 -0
- package/assets/docs/tree/tokens-border.doc.mjs +46 -0
- package/assets/docs/tree/tokens-color.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-color.doc.mjs +438 -0
- package/assets/docs/tree/tokens-color.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-data.doc.mjs +323 -0
- package/assets/docs/tree/tokens-duration.doc.mjs +78 -0
- package/assets/docs/tree/tokens-ease.doc.mjs +46 -0
- package/assets/docs/tree/tokens-focus.doc.mjs +57 -0
- package/assets/docs/tree/tokens-font-weight.doc.mjs +58 -0
- package/assets/docs/tree/tokens-radius.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-radius.doc.mjs +70 -0
- package/assets/docs/tree/tokens-radius.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-shadow.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-shadow.doc.mjs +74 -0
- package/assets/docs/tree/tokens-shadow.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-size.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-size.doc.mjs +54 -0
- package/assets/docs/tree/tokens-size.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-spacing.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-spacing.doc.mjs +102 -0
- package/assets/docs/tree/tokens-spacing.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-syntax.doc.mjs +98 -0
- package/assets/docs/tree/tokens-text-size.doc.mjs +90 -0
- package/assets/docs/tree/tokens-type-scale.doc.mjs +210 -0
- package/assets/docs/tree/tokens-typography.doc.mjs +54 -0
- package/assets/docs/tree/tokens-usage.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-usage.doc.mjs +36 -0
- package/assets/docs/tree/tokens-usage.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens.doc.mjs +28 -0
- package/assets/docs/tree/type-scale.doc.mjs +147 -0
- package/assets/docs/tree/typography-best-practices.doc.mjs +55 -0
- package/assets/docs/tree/typography.doc.mjs +29 -0
- package/assets/docs/use-a-theme.doc.mjs +162 -47
- package/assets/templates/pages/incident-console/page.tsx +1 -1
- package/assets/templates/pages/table-comparison/template.doc.mjs +1 -1
- package/assets/theme.template.ts +4 -3
- package/authoring/doctypes/template/type.ts +1 -0
- package/clients/cli/commands/blog.mjs +3 -3
- package/clients/cli/commands/build-theme.adaptations.test.mjs +1 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +11 -1
- package/clients/cli/commands/build-theme.batch-report.test.mjs +335 -0
- package/clients/cli/commands/build-theme.font-warning.test.mjs +36 -7
- package/clients/cli/commands/build-theme.import-path.test.mjs +3 -3
- package/clients/cli/commands/build-theme.mjs +68 -18
- package/clients/cli/commands/build-theme.watch.test.mjs +33 -0
- package/clients/cli/commands/build.mjs +1 -0
- package/clients/cli/commands/component/index.mjs +4 -1
- package/clients/cli/commands/component-replacement.text.test.mjs +45 -0
- package/clients/cli/commands/docs.doc.mjs +2 -1
- package/clients/cli/commands/docs.test.mjs +16 -13
- package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.test.mjs +50 -1
- package/clients/cli/commands/import-hint-correctness.test.mjs +23 -0
- package/clients/cli/commands/layout-check.doc.mjs +1 -0
- package/clients/cli/commands/layout-expand.doc.mjs +1 -0
- package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
- package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +140 -0
- package/clients/cli/commands/layout.doc.mjs +1 -0
- package/clients/cli/commands/layout.mjs +6 -11
- package/clients/cli/commands/search.test.mjs +6 -2
- package/clients/cli/commands/swizzle.routing.test.mjs +2 -1
- package/clients/cli/commands/template.mjs +4 -3
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +9 -6
- package/clients/cli/commands/theme-build.doc.mjs +3 -1
- package/clients/cli/commands/upgrade.config-ordering.test.mjs +2 -1
- package/clients/cli/index.mjs +1 -1
- package/clients/cli/lib/component-format.mjs +13 -3
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +4 -0
- package/foundation/agent-docs/agent-docs.mjs +18 -2
- package/foundation/agent-docs/agent-docs.test.mjs +18 -0
- package/foundation/config/project.test.mjs +1 -1
- package/foundation/discovery/docs-discovery.test.mjs +1 -1
- package/foundation/discovery/template-needs.d.mts +31 -0
- package/foundation/discovery/template-needs.mjs +156 -0
- package/foundation/discovery/template-needs.test.mjs +203 -0
- package/foundation/doc-compiler/bundle.mjs +52 -1
- package/foundation/doc-compiler/split-topic-keywords.test.mjs +73 -0
- package/foundation/doc-compiler/tree.d.mts +10 -0
- package/foundation/doc-compiler/tree.mjs +22 -0
- package/foundation/doc-compiler/tree.test.mjs +3 -2
- package/foundation/env/package-manager.d.mts +31 -8
- package/foundation/env/package-manager.mjs +120 -13
- package/foundation/env/package-manager.test.mjs +174 -1
- package/foundation/integrations/validate-contributions.d.mts +16 -0
- package/foundation/integrations/validate-contributions.mjs +56 -8
- package/foundation/response/response-types.doc.mjs +4 -4
- package/package.json +9 -9
- package/assets/docs/styling-libraries.doc.mjs +0 -469
- package/assets/docs/styling.doc.mjs +0 -412
- package/assets/docs/tokens.doc.dense.mjs +0 -15
- package/assets/docs/tokens.doc.mjs +0 -1491
- package/assets/docs/tokens.doc.zh.mjs +0 -15
- package/assets/docs/typography.doc.mjs +0 -286
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
explainPackageManager,
|
|
10
10
|
getDlxPrefix,
|
|
11
11
|
isCliOneOff,
|
|
12
|
+
cliBinResolves,
|
|
12
13
|
getCliInvocation,
|
|
13
14
|
formatCliCommand,
|
|
14
15
|
} from './package-manager.mjs';
|
|
@@ -31,6 +32,24 @@ function makeTmpDir() {
|
|
|
31
32
|
return tmpDir;
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
/** Install the CLI's bin link in `dir`, the way a package manager does. */
|
|
36
|
+
function linkCliBin(dir, name = 'astryx') {
|
|
37
|
+
const binDir = path.join(dir, 'node_modules', '.bin');
|
|
38
|
+
fs.mkdirSync(binDir, {recursive: true});
|
|
39
|
+
fs.writeFileSync(path.join(binDir, name), '');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The header a classic Yarn (1.x) lockfile starts with. */
|
|
43
|
+
const YARN_V1_LOCK =
|
|
44
|
+
'# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.\n# yarn lockfile v1\n\n';
|
|
45
|
+
|
|
46
|
+
/** The header a Berry (Yarn 2+) lockfile starts with. */
|
|
47
|
+
const YARN_BERRY_LOCK =
|
|
48
|
+
'# This file is generated by running "yarn install" inside your project.\n# Manual changes might be lost - proceed with caution!\n\n__metadata:\n version: 8\n';
|
|
49
|
+
|
|
50
|
+
/** An installed CLI's entry, outside any runner cache (a global or workspace install). */
|
|
51
|
+
const INSTALLED_ENTRY = '/usr/local/lib/node_modules/@astryxdesign/cli/clients/cli/bin/astryx.mjs';
|
|
52
|
+
|
|
34
53
|
describe('detectPackageManager', () => {
|
|
35
54
|
it('detects yarn from yarn.lock', () => {
|
|
36
55
|
const dir = makeTmpDir();
|
|
@@ -79,6 +98,7 @@ describe('detectPackageManager', () => {
|
|
|
79
98
|
const dir = makeTmpDir();
|
|
80
99
|
fs.writeFileSync(path.join(dir, 'pnpm-lock.yaml'), '');
|
|
81
100
|
fs.writeFileSync(path.join(dir, 'yarn.lock'), '');
|
|
101
|
+
linkCliBin(dir);
|
|
82
102
|
process.env.npm_config_user_agent = 'yarn/1.22.21 npm/? node/v22.0.0';
|
|
83
103
|
expect(detectPackageManager(dir)).not.toBe('yarn');
|
|
84
104
|
expect(getCliInvocation(dir)).toBe('npx astryx');
|
|
@@ -90,6 +110,7 @@ describe('detectPackageManager', () => {
|
|
|
90
110
|
try {
|
|
91
111
|
fs.writeFileSync(path.join(dir, 'pnpm-lock.yaml'), '');
|
|
92
112
|
fs.writeFileSync(path.join(dir, 'yarn.lock'), '');
|
|
113
|
+
linkCliBin(dir);
|
|
93
114
|
process.env.npm_config_user_agent = 'yarn/1.22.21 npm/? node/v22.0.0';
|
|
94
115
|
process.argv[1] = path.join(dir, 'node_modules/.bin/astryx');
|
|
95
116
|
expect(getCliInvocation(dir)).toBe('npx astryx');
|
|
@@ -198,6 +219,7 @@ describe('detectPackageManager', () => {
|
|
|
198
219
|
path.join(dir, 'package.json'),
|
|
199
220
|
JSON.stringify({packageManager: 'pnpm@8.0.0'}),
|
|
200
221
|
);
|
|
222
|
+
linkCliBin(dir);
|
|
201
223
|
expect(detectPackageManager(dir)).toBe('pnpm');
|
|
202
224
|
expect(getCliInvocation(dir)).toBe('pnpm exec astryx');
|
|
203
225
|
});
|
|
@@ -311,6 +333,78 @@ describe('getDlxPrefix', () => {
|
|
|
311
333
|
expect(getDlxPrefix(dir)).toBe('yarn dlx');
|
|
312
334
|
});
|
|
313
335
|
|
|
336
|
+
// Classic Yarn (1.x) has no `dlx`; `yarn dlx …` fails there, so its one-off
|
|
337
|
+
// form is `npx`. Berry (2+) keeps `yarn dlx`.
|
|
338
|
+
it('returns "npx" for a classic Yarn lockfile', () => {
|
|
339
|
+
const dir = makeTmpDir();
|
|
340
|
+
fs.writeFileSync(path.join(dir, 'yarn.lock'), YARN_V1_LOCK);
|
|
341
|
+
expect(getDlxPrefix(dir)).toBe('npx');
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
it('returns "yarn dlx" for a Berry lockfile', () => {
|
|
345
|
+
const dir = makeTmpDir();
|
|
346
|
+
fs.writeFileSync(path.join(dir, 'yarn.lock'), YARN_BERRY_LOCK);
|
|
347
|
+
expect(getDlxPrefix(dir)).toBe('yarn dlx');
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it('reads the declared packageManager version first', () => {
|
|
351
|
+
const classic = makeTmpDir();
|
|
352
|
+
fs.writeFileSync(
|
|
353
|
+
path.join(classic, 'package.json'),
|
|
354
|
+
JSON.stringify({packageManager: 'yarn@1.22.19'}),
|
|
355
|
+
);
|
|
356
|
+
// A Berry-looking lockfile does not outrank the declaration.
|
|
357
|
+
fs.writeFileSync(path.join(classic, 'yarn.lock'), YARN_BERRY_LOCK);
|
|
358
|
+
expect(getDlxPrefix(classic)).toBe('npx');
|
|
359
|
+
fs.rmSync(classic, {recursive: true, force: true});
|
|
360
|
+
|
|
361
|
+
const berry = makeTmpDir();
|
|
362
|
+
fs.writeFileSync(
|
|
363
|
+
path.join(berry, 'package.json'),
|
|
364
|
+
JSON.stringify({packageManager: 'yarn@4.5.0'}),
|
|
365
|
+
);
|
|
366
|
+
fs.writeFileSync(path.join(berry, 'yarn.lock'), YARN_V1_LOCK);
|
|
367
|
+
expect(getDlxPrefix(berry)).toBe('yarn dlx');
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
it('reads a bare major version in the declaration', () => {
|
|
371
|
+
const classic = makeTmpDir();
|
|
372
|
+
fs.writeFileSync(
|
|
373
|
+
path.join(classic, 'package.json'),
|
|
374
|
+
JSON.stringify({packageManager: 'yarn@1'}),
|
|
375
|
+
);
|
|
376
|
+
expect(getDlxPrefix(classic)).toBe('npx');
|
|
377
|
+
fs.rmSync(classic, {recursive: true, force: true});
|
|
378
|
+
|
|
379
|
+
const berry = makeTmpDir();
|
|
380
|
+
fs.writeFileSync(
|
|
381
|
+
path.join(berry, 'package.json'),
|
|
382
|
+
JSON.stringify({packageManager: 'yarn@4'}),
|
|
383
|
+
);
|
|
384
|
+
expect(getDlxPrefix(berry)).toBe('yarn dlx');
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
it('reads a committed Yarn config when the lockfile has no header', () => {
|
|
388
|
+
const classic = makeTmpDir();
|
|
389
|
+
fs.writeFileSync(path.join(classic, 'yarn.lock'), '');
|
|
390
|
+
fs.writeFileSync(path.join(classic, '.yarnrc'), '');
|
|
391
|
+
expect(getDlxPrefix(classic)).toBe('npx');
|
|
392
|
+
fs.rmSync(classic, {recursive: true, force: true});
|
|
393
|
+
|
|
394
|
+
const berry = makeTmpDir();
|
|
395
|
+
fs.writeFileSync(path.join(berry, 'yarn.lock'), '');
|
|
396
|
+
fs.writeFileSync(path.join(berry, '.yarnrc.yml'), '');
|
|
397
|
+
expect(getDlxPrefix(berry)).toBe('yarn dlx');
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
it('reads the runner version when nothing on disk names Yarn', () => {
|
|
401
|
+
makeTmpDir();
|
|
402
|
+
process.env.npm_config_user_agent = 'yarn/1.22.21 npm/? node/v22.0.0';
|
|
403
|
+
expect(getDlxPrefix(tmpDir)).toBe('npx');
|
|
404
|
+
process.env.npm_config_user_agent = 'yarn/4.5.0 npm/? node/v22.0.0';
|
|
405
|
+
expect(getDlxPrefix(tmpDir)).toBe('yarn dlx');
|
|
406
|
+
});
|
|
407
|
+
|
|
314
408
|
it('returns "bunx" for bun projects', () => {
|
|
315
409
|
const dir = makeTmpDir();
|
|
316
410
|
fs.writeFileSync(path.join(dir, 'bun.lockb'), '');
|
|
@@ -351,14 +445,91 @@ describe('isCliOneOff', () => {
|
|
|
351
445
|
});
|
|
352
446
|
});
|
|
353
447
|
|
|
448
|
+
describe('cliBinResolves', () => {
|
|
449
|
+
it('finds the bin link in the project', () => {
|
|
450
|
+
const dir = makeTmpDir();
|
|
451
|
+
linkCliBin(dir);
|
|
452
|
+
expect(cliBinResolves(dir)).toBe(true);
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
it('finds it in a folder above the project (a workspace root)', () => {
|
|
456
|
+
const root = makeTmpDir();
|
|
457
|
+
linkCliBin(root);
|
|
458
|
+
const pkg = path.join(root, 'packages', 'app');
|
|
459
|
+
fs.mkdirSync(pkg, {recursive: true});
|
|
460
|
+
expect(cliBinResolves(pkg)).toBe(true);
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
it('finds a Windows shim', () => {
|
|
464
|
+
const dir = makeTmpDir();
|
|
465
|
+
linkCliBin(dir, 'astryx.cmd');
|
|
466
|
+
expect(cliBinResolves(dir)).toBe(true);
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
it('is false when no bin link exists up the tree', () => {
|
|
470
|
+
const dir = makeTmpDir();
|
|
471
|
+
fs.mkdirSync(path.join(dir, 'node_modules', '.bin'), {recursive: true});
|
|
472
|
+
expect(cliBinResolves(dir)).toBe(false);
|
|
473
|
+
});
|
|
474
|
+
});
|
|
475
|
+
|
|
354
476
|
describe('getCliInvocation', () => {
|
|
355
|
-
it('uses the run-prefix + bare bin when
|
|
477
|
+
it('uses the run-prefix + bare bin when the bin resolves from the project', () => {
|
|
356
478
|
process.argv[1] = '/proj/node_modules/@astryxdesign/cli/bin/astryx.mjs';
|
|
357
479
|
const dir = makeTmpDir();
|
|
358
480
|
fs.writeFileSync(path.join(dir, 'pnpm-lock.yaml'), '');
|
|
481
|
+
linkCliBin(dir);
|
|
359
482
|
expect(getCliInvocation(dir)).toBe('pnpm exec astryx');
|
|
360
483
|
});
|
|
361
484
|
|
|
485
|
+
it('keeps `npx astryx` for a project with a local CLI', () => {
|
|
486
|
+
process.argv[1] = INSTALLED_ENTRY;
|
|
487
|
+
const dir = makeTmpDir();
|
|
488
|
+
fs.writeFileSync(path.join(dir, 'package-lock.json'), '{}');
|
|
489
|
+
linkCliBin(dir);
|
|
490
|
+
expect(getCliInvocation(dir)).toBe('npx astryx');
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
it('keeps the installed form in a workspace package when the root has the bin', () => {
|
|
494
|
+
process.argv[1] = INSTALLED_ENTRY;
|
|
495
|
+
const root = makeTmpDir();
|
|
496
|
+
fs.writeFileSync(path.join(root, 'pnpm-lock.yaml'), '');
|
|
497
|
+
linkCliBin(root);
|
|
498
|
+
const pkg = path.join(root, 'packages', 'app');
|
|
499
|
+
fs.mkdirSync(pkg, {recursive: true});
|
|
500
|
+
fs.writeFileSync(path.join(pkg, 'package.json'), '{"name":"app"}');
|
|
501
|
+
expect(getCliInvocation(pkg)).toBe('pnpm exec astryx');
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
// The hazard: the npm package named `astryx` is not this CLI. Launched from
|
|
505
|
+
// an installed path (a global install, or a workspace install running in a
|
|
506
|
+
// fresh package), the CLI used to print `npx astryx` for a project where that
|
|
507
|
+
// bin does not resolve, so following the hint fetched someone else's package.
|
|
508
|
+
it.each([
|
|
509
|
+
['package-lock.json', '{}', 'npx @astryxdesign/cli'],
|
|
510
|
+
['pnpm-lock.yaml', '', 'pnpm dlx @astryxdesign/cli'],
|
|
511
|
+
['yarn.lock', YARN_BERRY_LOCK, 'yarn dlx @astryxdesign/cli'],
|
|
512
|
+
['yarn.lock', YARN_V1_LOCK, 'npx @astryxdesign/cli'],
|
|
513
|
+
['bun.lockb', '', 'bunx @astryxdesign/cli'],
|
|
514
|
+
])(
|
|
515
|
+
'prints the scoped package for a project with no local CLI (%s), launched from an installed path',
|
|
516
|
+
(lockfile, contents, expected) => {
|
|
517
|
+
process.argv[1] = INSTALLED_ENTRY;
|
|
518
|
+
const dir = makeTmpDir();
|
|
519
|
+
fs.writeFileSync(path.join(dir, lockfile), contents);
|
|
520
|
+
expect(isCliOneOff()).toBe(false);
|
|
521
|
+
expect(getCliInvocation(dir)).toBe(expected);
|
|
522
|
+
},
|
|
523
|
+
);
|
|
524
|
+
|
|
525
|
+
it('prints the scoped package for a fresh package with no lockfile or install', () => {
|
|
526
|
+
process.argv[1] = INSTALLED_ENTRY;
|
|
527
|
+
const dir = makeTmpDir();
|
|
528
|
+
delete process.env.npm_config_user_agent;
|
|
529
|
+
fs.writeFileSync(path.join(dir, 'package.json'), '{"name":"fresh"}');
|
|
530
|
+
expect(getCliInvocation(dir)).toBe('npx @astryxdesign/cli');
|
|
531
|
+
});
|
|
532
|
+
|
|
362
533
|
it('uses the dlx runner + scoped package when run one-off', () => {
|
|
363
534
|
process.argv[1] = '/home/u/.npm/_npx/a1b2/node_modules/.bin/astryx';
|
|
364
535
|
const dir = makeTmpDir();
|
|
@@ -379,6 +550,7 @@ describe('formatCliCommand', () => {
|
|
|
379
550
|
process.argv[1] = '/proj/node_modules/@astryxdesign/cli/bin/astryx.mjs';
|
|
380
551
|
const dir = makeTmpDir();
|
|
381
552
|
fs.writeFileSync(path.join(dir, 'pnpm-lock.yaml'), '');
|
|
553
|
+
linkCliBin(dir);
|
|
382
554
|
expect(formatCliCommand('astryx component Button', dir)).toBe('pnpm exec astryx component Button');
|
|
383
555
|
});
|
|
384
556
|
|
|
@@ -386,6 +558,7 @@ describe('formatCliCommand', () => {
|
|
|
386
558
|
process.argv[1] = '/proj/node_modules/@astryxdesign/cli/bin/astryx.mjs';
|
|
387
559
|
const dir = makeTmpDir();
|
|
388
560
|
fs.writeFileSync(path.join(dir, 'package-lock.json'), '{}');
|
|
561
|
+
linkCliBin(dir);
|
|
389
562
|
expect(formatCliCommand('docs tokens', dir)).toBe('npx astryx docs tokens');
|
|
390
563
|
});
|
|
391
564
|
|
|
@@ -5,6 +5,22 @@
|
|
|
5
5
|
export function issueError(code: string, message: string): Issue;
|
|
6
6
|
/** @param {string} code @param {string} message @returns {Issue} */
|
|
7
7
|
export function issueWarning(code: string, message: string): Issue;
|
|
8
|
+
/**
|
|
9
|
+
* Why a declared root cannot be read as a folder, or null when it can.
|
|
10
|
+
* A missing root keeps its own issue; a root that is a file or that the
|
|
11
|
+
* user running astryx cannot read used to surface as a raw errno from
|
|
12
|
+
* whichever check touched it first, or end validation outright.
|
|
13
|
+
* @param {string} root
|
|
14
|
+
* @returns {{kind: 'missing'} | {kind: 'not-a-folder'} | {kind: 'unreadable', code: string} | null}
|
|
15
|
+
*/
|
|
16
|
+
export function rootProblem(root: string): {
|
|
17
|
+
kind: "missing";
|
|
18
|
+
} | {
|
|
19
|
+
kind: "not-a-folder";
|
|
20
|
+
} | {
|
|
21
|
+
kind: "unreadable";
|
|
22
|
+
code: string;
|
|
23
|
+
} | null;
|
|
8
24
|
/**
|
|
9
25
|
* Validate an already-LOADED integration (as produced by `loadIntegrations` —
|
|
10
26
|
* absolute contribution roots plus identity) and return its issues. This is the
|
|
@@ -99,8 +99,40 @@ function checkUnknownKeys(integration, issues) {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
|
-
*
|
|
103
|
-
* root is a
|
|
102
|
+
* Why a declared root cannot be read as a folder, or null when it can.
|
|
103
|
+
* A missing root keeps its own issue; a root that is a file or that the
|
|
104
|
+
* user running astryx cannot read used to surface as a raw errno from
|
|
105
|
+
* whichever check touched it first, or end validation outright.
|
|
106
|
+
* @param {string} root
|
|
107
|
+
* @returns {{kind: 'missing'} | {kind: 'not-a-folder'} | {kind: 'unreadable', code: string} | null}
|
|
108
|
+
*/
|
|
109
|
+
export function rootProblem(root) {
|
|
110
|
+
let stat;
|
|
111
|
+
try {
|
|
112
|
+
stat = fs.statSync(root);
|
|
113
|
+
} catch (err) {
|
|
114
|
+
const code = /** @type {any} */ (err)?.code;
|
|
115
|
+
return code === 'ENOENT' || code === 'ENOTDIR'
|
|
116
|
+
? {kind: 'missing'}
|
|
117
|
+
: {kind: 'unreadable', code: String(code ?? 'unknown error')};
|
|
118
|
+
}
|
|
119
|
+
if (!stat.isDirectory()) return {kind: 'not-a-folder'};
|
|
120
|
+
try {
|
|
121
|
+
fs.accessSync(root, fs.constants.R_OK | fs.constants.X_OK);
|
|
122
|
+
} catch (err) {
|
|
123
|
+
return {
|
|
124
|
+
kind: 'unreadable',
|
|
125
|
+
code: String(/** @type {any} */ (err)?.code ?? 'unknown error'),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Verify each declared contribution root is a folder Astryx can read. A
|
|
133
|
+
* declared-but-missing root is a `missing_root` error, a file is an
|
|
134
|
+
* `invalid_root` error, and a folder that cannot be read is an
|
|
135
|
+
* `unreadable_root` error. The contribution checks skip all three.
|
|
104
136
|
* @param {{components?: string, templates?: string, codemods?: string, docs?: string, themes?: string}} resolved
|
|
105
137
|
* absolute resolved roots (undefined when not declared)
|
|
106
138
|
* @param {Issue[]} issues
|
|
@@ -116,13 +148,29 @@ function checkRoots(resolved, issues) {
|
|
|
116
148
|
for (const kind of kinds) {
|
|
117
149
|
const root = resolved[kind];
|
|
118
150
|
if (root == null) continue;
|
|
119
|
-
|
|
151
|
+
const problem = rootProblem(root);
|
|
152
|
+
if (problem == null) continue;
|
|
153
|
+
if (problem.kind === 'missing') {
|
|
120
154
|
issues.push(
|
|
121
155
|
issueError(
|
|
122
156
|
'missing_root',
|
|
123
157
|
`Declared ${kind} root does not exist on disk: ${root}`,
|
|
124
158
|
),
|
|
125
159
|
);
|
|
160
|
+
} else if (problem.kind === 'not-a-folder') {
|
|
161
|
+
issues.push(
|
|
162
|
+
issueError(
|
|
163
|
+
'invalid_root',
|
|
164
|
+
`Declared ${kind} root is a file, not a folder: ${root}. Fix: point "${kind}" in the manifest at the folder that holds them.`,
|
|
165
|
+
),
|
|
166
|
+
);
|
|
167
|
+
} else {
|
|
168
|
+
issues.push(
|
|
169
|
+
issueError(
|
|
170
|
+
'unreadable_root',
|
|
171
|
+
`Declared ${kind} root cannot be read (${problem.code}): ${root}. Fix: make it readable by the user running astryx.`,
|
|
172
|
+
),
|
|
173
|
+
);
|
|
126
174
|
}
|
|
127
175
|
}
|
|
128
176
|
}
|
|
@@ -135,7 +183,7 @@ function checkRoots(resolved, issues) {
|
|
|
135
183
|
* @param {Issue[]} issues
|
|
136
184
|
*/
|
|
137
185
|
async function checkCodemods(integration, issues) {
|
|
138
|
-
if (!integration.codemods ||
|
|
186
|
+
if (!integration.codemods || rootProblem(integration.codemods)) return;
|
|
139
187
|
const context = integration.__packageDir
|
|
140
188
|
? createFixContext(integration.__packageDir, integration)
|
|
141
189
|
: null;
|
|
@@ -232,7 +280,7 @@ async function checkCodemods(integration, issues) {
|
|
|
232
280
|
* @param {Issue[]} issues
|
|
233
281
|
*/
|
|
234
282
|
async function checkTemplates(integration, issues) {
|
|
235
|
-
if (!integration.templates ||
|
|
283
|
+
if (!integration.templates || rootProblem(integration.templates)) return;
|
|
236
284
|
try {
|
|
237
285
|
const {errors} = await discoverIntegrationTemplatesForOne(integration);
|
|
238
286
|
for (const e of errors) {
|
|
@@ -257,7 +305,7 @@ async function checkTemplates(integration, issues) {
|
|
|
257
305
|
* @param {Issue[]} issues
|
|
258
306
|
*/
|
|
259
307
|
async function checkComponents(integration, issues) {
|
|
260
|
-
if (!integration.components ||
|
|
308
|
+
if (!integration.components || rootProblem(integration.components)) return;
|
|
261
309
|
const discover = componentDiscovery.discoverValidIntegrationComponents;
|
|
262
310
|
if (typeof discover !== 'function') return; // feature not present yet
|
|
263
311
|
try {
|
|
@@ -330,7 +378,7 @@ async function checkComponents(integration, issues) {
|
|
|
330
378
|
* @param {Issue[]} issues
|
|
331
379
|
*/
|
|
332
380
|
async function checkDocs(integration, issues) {
|
|
333
|
-
if (!integration.docs ||
|
|
381
|
+
if (!integration.docs || rootProblem(integration.docs)) return;
|
|
334
382
|
try {
|
|
335
383
|
const {errors} = await discoverIntegrationDocs(integration);
|
|
336
384
|
for (const e of errors) {
|
|
@@ -349,7 +397,7 @@ async function checkDocs(integration, issues) {
|
|
|
349
397
|
* @param {Issue[]} issues
|
|
350
398
|
*/
|
|
351
399
|
async function checkThemes(integration, issues) {
|
|
352
|
-
if (!integration.themes ||
|
|
400
|
+
if (!integration.themes || rootProblem(integration.themes)) return;
|
|
353
401
|
try {
|
|
354
402
|
await discoverIntegrationThemes(integration);
|
|
355
403
|
} catch (err) {
|
|
@@ -194,7 +194,7 @@ export const doc = {
|
|
|
194
194
|
{
|
|
195
195
|
value: 'template.copy',
|
|
196
196
|
description:
|
|
197
|
-
'A scaffold receipt: template id, output directory, written file name, file count,
|
|
197
|
+
'A scaffold receipt: template id, output directory, written file name, file count, demoMediaReplaced (how many Astryx demo media references were replaced with placeholders), notes (setup notes naming what the template needs that the project lacks — missing packages, missing StyleX compiler; empty when satisfied), missingPackages (external package names the template imports that are not in the project), and installCommand (a ready-to-run install command with the detected package manager and workspace version ranges; null when nothing is missing). The envelope\'s package names the npm package that owns the template.',
|
|
198
198
|
},
|
|
199
199
|
|
|
200
200
|
{
|
|
@@ -357,17 +357,17 @@ export const doc = {
|
|
|
357
357
|
{
|
|
358
358
|
value: 'layout.expand',
|
|
359
359
|
description:
|
|
360
|
-
'The expansion: parsed form, generated TSX code, componentsUsed, states (count of useState hooks scaffolded), todos, blocksReferenced (each {name, mode}), warnings, written (the output path, or null when nothing was written), and demoMediaReplaced (count of demo media placeholders).',
|
|
360
|
+
'The expansion: parsed form, generated TSX code, componentsUsed, states (count of useState hooks scaffolded), todos, blocksReferenced (each {name, mode}), warnings, written (the output path, or null when nothing was written), and demoMediaReplaced (count of demo media placeholders). Carries `meta.deprecations` with DEP-0006 and its replacement commands.',
|
|
361
361
|
},
|
|
362
362
|
{
|
|
363
363
|
value: 'layout.check',
|
|
364
364
|
description:
|
|
365
|
-
'The validation result: a valid flag, the detected form, errors (each with line/col, message, formatted text, and suggestions), warnings, and the expression re-printed in both canonical surfaces (compact and outline).',
|
|
365
|
+
'The validation result: a valid flag, the detected form, errors (each with line/col, message, formatted text, and suggestions), warnings, and the expression re-printed in both canonical surfaces (compact and outline). Carries `meta.deprecations` with DEP-0006 and its replacement commands.',
|
|
366
366
|
},
|
|
367
367
|
{
|
|
368
368
|
value: 'layout.grammar',
|
|
369
369
|
description:
|
|
370
|
-
"The XLE/XLO grammar cheatsheet: a text field with the full reference plus an aliases map (short name → canonical component) generated from this install's registry.",
|
|
370
|
+
"The XLE/XLO grammar cheatsheet: a text field with the full reference plus an aliases map (short name → canonical component) generated from this install's registry. Carries `meta.deprecations` with DEP-0006 and its replacement commands.",
|
|
371
371
|
},
|
|
372
372
|
],
|
|
373
373
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.6.6-canary.
|
|
3
|
+
"version": "0.6.6-canary.ffa4f72",
|
|
4
4
|
"displayName": "CLI",
|
|
5
5
|
"description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
|
|
6
6
|
"author": "Meta Open Source",
|
|
@@ -101,10 +101,10 @@
|
|
|
101
101
|
"zod": "^4.4.3"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
|
-
"@astryxdesign/charts": "0.6.6-canary.
|
|
105
|
-
"@astryxdesign/core": "0.6.6-canary.
|
|
106
|
-
"@astryxdesign/lab": "0.6.6-canary.
|
|
107
|
-
"@astryxdesign/theme-neutral": "0.6.6-canary.
|
|
104
|
+
"@astryxdesign/charts": "0.6.6-canary.ffa4f72",
|
|
105
|
+
"@astryxdesign/core": "0.6.6-canary.ffa4f72",
|
|
106
|
+
"@astryxdesign/lab": "0.6.6-canary.ffa4f72",
|
|
107
|
+
"@astryxdesign/theme-neutral": "0.6.6-canary.ffa4f72"
|
|
108
108
|
},
|
|
109
109
|
"peerDependenciesMeta": {
|
|
110
110
|
"@astryxdesign/charts": {
|
|
@@ -121,10 +121,10 @@
|
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
123
|
"devDependencies": {
|
|
124
|
-
"@astryxdesign/charts": "0.6.6-canary.
|
|
125
|
-
"@astryxdesign/core": "0.6.6-canary.
|
|
126
|
-
"@astryxdesign/lab": "0.6.6-canary.
|
|
127
|
-
"@astryxdesign/theme-neutral": "0.6.6-canary.
|
|
124
|
+
"@astryxdesign/charts": "0.6.6-canary.ffa4f72",
|
|
125
|
+
"@astryxdesign/core": "0.6.6-canary.ffa4f72",
|
|
126
|
+
"@astryxdesign/lab": "0.6.6-canary.ffa4f72",
|
|
127
|
+
"@astryxdesign/theme-neutral": "0.6.6-canary.ffa4f72",
|
|
128
128
|
"@heroicons/react": "^2.2.0",
|
|
129
129
|
"@stylexjs/stylex": "^0.19.0",
|
|
130
130
|
"@types/babel__core": "^7.20.5",
|