@astryxdesign/cli 0.6.6-canary.bbeffca → 0.6.6-canary.cc0df20
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/assets/docs/author-a-theme.doc.mjs +12 -7
- package/assets/docs/tree/layout.doc.mjs +20 -0
- package/assets/docs/use-a-theme.doc.mjs +5 -2
- package/assets/templates/pages/incident-console/page.tsx +1 -1
- package/clients/cli/commands/blog.mjs +3 -3
- package/clients/cli/commands/docs.test.mjs +2 -1
- package/clients/cli/commands/doctor.test.mjs +17 -1
- package/clients/cli/commands/import-hint-correctness.test.mjs +23 -0
- 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 +2 -2
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +9 -6
- package/clients/cli/commands/upgrade.config-ordering.test.mjs +2 -1
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/foundation/env/package-manager.d.mts +28 -8
- package/foundation/env/package-manager.mjs +49 -10
- package/foundation/env/package-manager.test.mjs +93 -1
- package/package.json +9 -9
|
@@ -34,7 +34,7 @@ export const docs = {
|
|
|
34
34
|
{
|
|
35
35
|
title: 'defineTheme',
|
|
36
36
|
content: [
|
|
37
|
-
{type: 'prose', text: "defineTheme creates a theme from token overrides and optional scale configs. Scale configs generate tokens from parameters. Explicit token overrides always take precedence over scale-generated values, token by token. localTokens accepts any valid CSS custom-property name; prefixes do not establish ownership. One caveat for the accent: overriding --color-accent in tokens re-points the reference tokens (--color-accent-muted, --color-text-accent, --color-icon-accent) but NOT --color-on-accent, which stays baked from the color.accent seed. To give each scheme its own accent with a consistent derived palette, pass a [light, dark] tuple to color.accent instead of overriding the token."},
|
|
37
|
+
{type: 'prose', text: "defineTheme creates a theme from token overrides and optional scale configs. Only override tokens that differ from defaults; omitted tokens use the design system defaults. Scale configs generate tokens from parameters. Explicit token overrides always take precedence over scale-generated values, token by token. localTokens accepts any valid CSS custom-property name; prefixes do not establish ownership. One caveat for the accent: overriding --color-accent in tokens re-points the reference tokens (--color-accent-muted, --color-text-accent, --color-icon-accent) but NOT --color-on-accent, which stays baked from the color.accent seed. To give each scheme its own accent with a consistent derived palette, pass a [light, dark] tuple to color.accent instead of overriding the token."},
|
|
38
38
|
{type: 'code', lang: 'tsx', label: 'defineTheme with scale configs', code: "import {defineTheme} from '@astryxdesign/core/theme';\n\nconst myTheme = defineTheme({\n name: 'my-theme',\n // accent: single hex, or [light, dark] tuple to seed each scheme separately\n color: { accent: ['#7B61FF', '#9B85FF'], neutralStyle: 'cool' },\n typography: {\n scale: { base: 14, ratio: 1.2 },\n body: { family: 'Inter', fallbacks: '-apple-system, sans-serif' },\n },\n radius: { base: 4, multiplier: 1 },\n motion: { fast: 175, medium: 410, ratio: 0.75 },\n tokens: {\n // Explicit overrides take precedence over scale-generated values\n '--color-background-body': ['#FFFFFF', '#0A0A0A'],\n },\n});"},
|
|
39
39
|
{type: 'table', headers: ['Config', 'Generates', 'Parameters'], rows: [
|
|
40
40
|
['color', '--color-accent, --color-background-*, --color-text-*, --color-border, etc.', 'accent? (hex or [light, dark] tuple; omit for neutral-only), neutralStyle? (warm|cool|neutral), contrast? (standard|high)'],
|
|
@@ -60,7 +60,7 @@ export const docs = {
|
|
|
60
60
|
['typography, motion, radius, color', 'Child config replaces base entirely (these are scale inputs, not additive).'],
|
|
61
61
|
['adaptations', 'Width-breakpoint overrides merge by fixed name. Inherited ordered rules keep their relative order; child rules append and re-resolve against the child root axes.'],
|
|
62
62
|
]},
|
|
63
|
-
{type: 'prose', text: "Inheritance is resolved when the theme is defined, so an extended theme is flat: `astryx theme build` emits one self-contained stylesheet holding everything the child inherited, and the base theme's CSS does not need to be loaded next to it."},
|
|
63
|
+
{type: 'prose', text: "Inheritance is resolved when the theme is defined, so an extended theme is flat: `astryx theme build` emits one self-contained stylesheet holding everything the child inherited, and the base theme's CSS does not need to be loaded next to it. A base that is not a theme (most often an import that missed) throws when `defineTheme` runs, rather than producing a theme that silently inherits nothing."},
|
|
64
64
|
{type: 'prose', text: 'For the integration-specific guidance on mapping a palette to tokens when extending, see `astryx docs cli/integrations/building-blocks/themes/define-the-theme`.'},
|
|
65
65
|
],
|
|
66
66
|
},
|
|
@@ -71,7 +71,7 @@ export const docs = {
|
|
|
71
71
|
{type: 'code', lang: 'tsx', label: 'Component overrides with standard CSS', code: "components: {\n card: {\n base: { borderRadius: '20px', padding: '24px' },\n },\n button: {\n base: {\n borderRadius: '9999px',\n textTransform: 'uppercase',\n '--button-focus-offset': '3px',\n },\n 'variant:ghost': { borderWidth: '2px', borderStyle: 'solid' },\n },\n}"},
|
|
72
72
|
{type: 'prose', text: "Run `astryx theme targets` for every themeable key in the system (`astryx theme targets <Name>` to scope it, `--json` to lint a theme against it), and `astryx component <Name>` for one component's theming targets, public CSS variables, and which standard CSS properties are supported."},
|
|
73
73
|
{type: 'list', style: 'do', items: ['Write standard CSS properties (borderRadius, padding); the pipeline expands them into internal vars.', 'Set public CSS vars directly when no standard property equivalent exists.']},
|
|
74
|
-
{type: 'list', style: 'dont', items: ['Set private CSS vars (prefixed --_) directly. Use standard CSS properties instead. `astryx theme build` will error.']},
|
|
74
|
+
{type: 'list', style: 'dont', items: ['Set private CSS vars (prefixed --_) directly. Use standard CSS properties instead. `astryx theme build` will error.', 'Set a public CSS var the component does not define. It compiles to CSS that never applies, and the build does not warn. Take the names from `astryx component <Name>`.']},
|
|
75
75
|
],
|
|
76
76
|
},
|
|
77
77
|
{
|
|
@@ -94,7 +94,7 @@ export const docs = {
|
|
|
94
94
|
['contrast', 'more | less | no-preference'],
|
|
95
95
|
['motion', 'reduce | no-preference'],
|
|
96
96
|
]},
|
|
97
|
-
{type: 'prose', text: "`widthBreakpoints` are fixed named start points. Defaults are 640 / 768 / 1024 / 1280 / 1536 CSS pixels. `from` includes its point; `below` excludes it."},
|
|
97
|
+
{type: 'prose', text: "`widthBreakpoints` are fixed named start points. Defaults are 640 / 768 / 1024 / 1280 / 1536 CSS pixels. `from` includes its point; `below` excludes it. Breakpoint configuration alone emits no CSS."},
|
|
98
98
|
],
|
|
99
99
|
},
|
|
100
100
|
{
|
|
@@ -103,6 +103,7 @@ export const docs = {
|
|
|
103
103
|
content: [
|
|
104
104
|
{type: 'prose', text: "Precedence follows rule order. Root theme values apply first, then every matching rule in declaration order. A later rule may deliberately restore a root value. `onDark` and `onLight` media-surface overrides apply after adaptations and win on the same leaf."},
|
|
105
105
|
{type: 'prose', text: "`extends` preserves the base rule order and appends child rules. Inherited conditions use the child's effective breakpoint map. An empty child rule is a no-op, not a removal operator."},
|
|
106
|
+
{type: 'prose', text: "A rule may replace a theme-local token only when the exact name is already enrolled by root `localTokens` or an enrolled base. Component writes in a rule are validated exactly like root `components`: same targets, axes, and value domains. The one addition is that a rule may not be the only place a custom value is enrolled: a value that is valid only because a theme enrolls it generates unconditional type augmentation, so declare it on the root theme first and let rules restyle it. Built-in values need no root declaration. When rules can match together, their ordered portable and local token writes are validated as one effective graph; any reachable cycle fails before CSS is emitted."},
|
|
106
107
|
{type: 'prose', text: 'Adaptations compile to CSS media queries with no resize listener or styling rerender. Runtime and `astryx theme build` use the same compiler, but only a built theme is present at first paint in an SSR app.'},
|
|
107
108
|
],
|
|
108
109
|
},
|
|
@@ -118,8 +119,9 @@ export const docs = {
|
|
|
118
119
|
['ocean.d.ts', 'TypeScript declarations for the theme and icon registry exports'],
|
|
119
120
|
['ocean.variants.d.ts', "(Optional) Module augmentations for custom component prop values"],
|
|
120
121
|
]},
|
|
122
|
+
{type: 'prose', text: 'The `__built: true` flag tells Theme to skip runtime `<style>` injection; the CSS file handles it. Load the generated CSS wherever you load the module.'},
|
|
121
123
|
{type: 'code', lang: 'tsx', label: 'Using a custom built theme', code: "import {Theme} from '@astryxdesign/core';\nimport {oceanTheme} from './themes/ocean';\nimport './themes/ocean.css';\n\n<Theme theme={oceanTheme}>\n <App />\n</Theme>"},
|
|
122
|
-
{type: 'prose', text: "After upgrading Astryx, rerun `astryx theme build` for every custom prebuilt theme. Deploy the regenerated files together. The build also warns when the theme names font families it does not load. See {@link generic:typography} for the full recipe."},
|
|
124
|
+
{type: 'prose', text: "After upgrading Astryx, rerun `astryx theme build` for every custom prebuilt theme. Deploy the regenerated files together. The runtime intentionally trusts `__built: true` and will not repair stale CSS from an older build. The build also warns when the theme names font families it does not load. See {@link generic:typography} for the full recipe."},
|
|
123
125
|
{type: 'prose', text: 'For the runtime vs built tradeoff, see the Runtime vs Built section of {@link generic:use-a-theme}.'},
|
|
124
126
|
],
|
|
125
127
|
},
|
|
@@ -129,13 +131,15 @@ export const docs = {
|
|
|
129
131
|
content: [
|
|
130
132
|
{type: 'prose', text: "`theme build` emits an icon import when it detects a named import used by the theme's `icons:` field. It does not compile that registry module. Move the registry to a separate module and use a named import."},
|
|
131
133
|
{type: 'code', lang: 'bash', label: 'Compiling the icon registry sidecar', code: "# Emit the built theme\nastryx theme build ./src/themes/ocean.ts -o dist/theme.css --icons-specifier ./icons.mjs\n\n# Compile the icon registry alongside it\nesbuild src/themes/icons.tsx --bundle --format=esm --outfile=dist/icons.mjs \\\n --external:react --external:lucide-react --jsx=automatic"},
|
|
134
|
+
{type: 'prose', text: 'In the example above, the generated theme imports `./icons.mjs` from `dist`. If the second command is skipped, `theme build` can still succeed, but loading or bundling the generated module fails because `dist/icons.mjs` is missing. `--icons-specifier` changes the emitted import; it does not create or verify the target file. Match the specifier to a module that resolves from the generated JS file.'},
|
|
135
|
+
{type: 'prose', text: 'Without `--icons-specifier`, the detected source import specifier is emitted unchanged. In the default flow without `--out`, a bundler can resolve an extensionless `./icons` to the neighboring `icons.tsx` source, but Node ESM does not perform that lookup and reports `ERR_MODULE_NOT_FOUND`. Moving the output with `--out` also changes where relative imports resolve from.'},
|
|
132
136
|
{type: 'prose', text: 'Keep `react` and the icon library external so the registry does not bundle its own copies of those dependencies.'},
|
|
133
137
|
],
|
|
134
138
|
},
|
|
135
139
|
{
|
|
136
140
|
title: 'Building a Theme Family',
|
|
137
141
|
content: [
|
|
138
|
-
{type: 'prose', text: 'Use family mode when an app switches among one base theme and its selected descendants. The build writes one keyed CSS file containing every member, plus one keyed JavaScript module and one declaration file.'},
|
|
142
|
+
{type: 'prose', text: 'Use family mode when an app switches among one base theme and its selected descendants. The build writes one keyed CSS file containing every member, plus one keyed JavaScript module and one declaration file, beside the root source.'},
|
|
139
143
|
{type: 'code', lang: 'bash', label: 'Build one family', code: "astryx theme build --family \\\n ./src/themes/ocean.mjs \\\n ./src/themes/ocean-calm.mjs \\\n ./src/themes/ocean-calm-deep.mjs \\\n --family-key ocean-family"},
|
|
140
144
|
{type: 'prose', text: 'The family stylesheet eagerly downloads every selected member so first paint is complete. Switching members changes only the theme identity; it does not add, remove, or reorder stylesheets.'},
|
|
141
145
|
],
|
|
@@ -143,9 +147,10 @@ export const docs = {
|
|
|
143
147
|
{
|
|
144
148
|
title: 'Token Utilities',
|
|
145
149
|
content: [
|
|
146
|
-
{type: 'prose', text: 'Use `tokenVar()` when a non-StyleX styling library wants a CSS variable reference, and `resolveThemeTokens()` when JavaScript needs token values for a specific theme and mode without React context.'},
|
|
150
|
+
{type: 'prose', text: 'Use `tokenVar()` when a non-StyleX styling library wants a CSS variable reference, and `resolveThemeTokens()` when JavaScript needs token values for a specific theme and mode without React context. Themes are registered by name when created with `defineTheme()`; call `registerTheme(theme)` for prebuilt or object-literal themes that need name-based SSR lookup.'},
|
|
147
151
|
{type: 'code', lang: 'ts', label: 'CSS var references for styling-library configs', code: "import {tokenVar, tokenVars} from '@astryxdesign/core/theme/tokens';\n\nconst pandaOrEmotionTheme = {\n colors: {\n text: tokenVar('--color-text-primary'),\n surface: tokenVars['--color-background-surface'],\n },\n};"},
|
|
148
152
|
{type: 'code', lang: 'ts', label: 'Resolve token values without a hook', code: "import {resolveThemeTokens} from '@astryxdesign/core/theme/tokens';\nimport {neutralTheme} from '@astryxdesign/theme-neutral';\n\nconst lightTokens = resolveThemeTokens(neutralTheme, {mode: 'light'});\nconst chartTheme = {\n textColor: lightTokens['--color-text-primary'],\n seriesColor: lightTokens['--color-data-categorical-blue'],\n};"},
|
|
153
|
+
{type: 'prose', text: 'The `@astryxdesign/core/theme/tokens` subpath is server-safe and does not require React. The main `@astryxdesign/core/theme` barrel also re-exports these helpers for client code that already imports theme APIs.'},
|
|
149
154
|
{type: 'prose', text: 'For styling library interop patterns, see {@link generic:styling-libraries}.'},
|
|
150
155
|
],
|
|
151
156
|
},
|
|
@@ -26,6 +26,26 @@ export const docs = {
|
|
|
26
26
|
'SideNav',
|
|
27
27
|
'TopNav',
|
|
28
28
|
],
|
|
29
|
+
blocks: [
|
|
30
|
+
{
|
|
31
|
+
type: 'prose',
|
|
32
|
+
text: "Build a layout outside-in. Settle the shell and its region budgets before any content exists, then work inward. Content-first layouts drift into a padded column of cards, because every section ends up inventing its own container.",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
type: 'list',
|
|
36
|
+
style: 'ordered',
|
|
37
|
+
items: [
|
|
38
|
+
"Scaffold: pick the shell, budget each region, and choose navigation",
|
|
39
|
+
"Structure: rank the content in each region, then pick the weakest container that groups it",
|
|
40
|
+
"Spacing: hold one content line per region, then tune gaps and density",
|
|
41
|
+
"Breakpoints: decide what each region does as width changes",
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: 'prose',
|
|
46
|
+
text: "This guide decides layout, not component APIs. Run `npx astryx build \"<idea>\"` to start from the closest template for your app type, and `npx astryx component <Name>` for a component's props.",
|
|
47
|
+
},
|
|
48
|
+
],
|
|
29
49
|
slots: {
|
|
30
50
|
guides: {title: 'Guides', accepts: {kinds: ['generic']}},
|
|
31
51
|
},
|
|
@@ -179,7 +179,7 @@ export const docs = {
|
|
|
179
179
|
['How it works', 'useInsertionEffect injects <style> at hydration', 'Pre-compiled .css file loaded with the page'],
|
|
180
180
|
['Component overrides', 'Injected client-only', 'In static CSS: present during SSR'],
|
|
181
181
|
['SSR safe', 'Tokens yes, component overrides flash on hydration', 'Fully SSR safe: no flash'],
|
|
182
|
-
['Best for', '
|
|
182
|
+
['Best for', 'Authoring input for `astryx theme build`', 'App wiring, in development and production'],
|
|
183
183
|
],
|
|
184
184
|
},
|
|
185
185
|
{
|
|
@@ -187,7 +187,8 @@ export const docs = {
|
|
|
187
187
|
style: 'do',
|
|
188
188
|
items: [
|
|
189
189
|
'Use `theme add --import` for production apps; it wires the built module and CSS.',
|
|
190
|
-
'
|
|
190
|
+
'Import `themes` and `defaultThemeSlug` from the generated module once, and keep that wiring in development too.',
|
|
191
|
+
'While you edit a local theme, run `astryx theme build --watch` so its built files stay current.',
|
|
191
192
|
'Run `astryx theme build` for custom themes to get the built artifacts.',
|
|
192
193
|
],
|
|
193
194
|
},
|
|
@@ -197,6 +198,8 @@ export const docs = {
|
|
|
197
198
|
items: [
|
|
198
199
|
'Use runtime themes in production SSR apps; component overrides will flash on hydration.',
|
|
199
200
|
"Import /built without the CSS file; component overrides won't apply.",
|
|
201
|
+
'Import package theme source into app runtime code.',
|
|
202
|
+
'Hand-edit the generated theme module; `theme add`, `theme remove`, and `theme use` regenerate it.',
|
|
200
203
|
],
|
|
201
204
|
},
|
|
202
205
|
{
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* Incident Console — an on-call incident response tool.
|
|
7
7
|
*
|
|
8
|
-
* Frame-first layout (see `npx
|
|
8
|
+
* Frame-first layout (see `npx @astryxdesign/cli docs layout`), distilled from
|
|
9
9
|
* product-scale apps built with the design system:
|
|
10
10
|
*
|
|
11
11
|
* Frame: header | grouped incident rows (fill) | inspector 380 (resizable)
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* astryx blog --json Structured list/detail envelope
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import {getCliInvocation} from '../../../foundation/env/package-manager.mjs';
|
|
18
18
|
import {jsonOut} from '../../../foundation/response/json.mjs';
|
|
19
19
|
import {emit, section, text, record, records, code} from '../formatters/index.mjs';
|
|
20
20
|
import {cliError} from '../lib/cli-error.mjs';
|
|
@@ -43,7 +43,7 @@ export function registerBlog(program) {
|
|
|
43
43
|
defineCommand(program, blogCommand, {
|
|
44
44
|
fn: blogFn,
|
|
45
45
|
action: async (/** @type {string | undefined} */ slug) => {
|
|
46
|
-
const run =
|
|
46
|
+
const run = getCliInvocation();
|
|
47
47
|
/** @type {import('../../../api/blog/blog.type.mjs').BlogListResponse | import('../../../api/blog/blog.type.mjs').BlogDetailResponse} */
|
|
48
48
|
let result;
|
|
49
49
|
try {
|
|
@@ -84,7 +84,7 @@ export function registerBlog(program) {
|
|
|
84
84
|
section('Astryx blog'),
|
|
85
85
|
record({feedUrl}),
|
|
86
86
|
records(posts, {fields: POST_FIELDS}),
|
|
87
|
-
text(`Read one: ${run}
|
|
87
|
+
text(`Read one: ${run} blog <slug>`),
|
|
88
88
|
);
|
|
89
89
|
} else {
|
|
90
90
|
// blog.detail — the post's fields and the feed URL, then the body
|
|
@@ -113,7 +113,8 @@ describe('progressive reads', () => {
|
|
|
113
113
|
expect(status).toBe(0);
|
|
114
114
|
expect(stdout).toMatch(/^principles +\S/m);
|
|
115
115
|
expect(widest(stdout)).toBeLessThanOrEqual(120);
|
|
116
|
-
|
|
116
|
+
// The repo root has no `astryx` bin, so the CLI names the scoped package.
|
|
117
|
+
expect(stdout).toMatch(/Usage: \S+(?: dlx)? (?:astryx|@astryxdesign\/cli) docs <topic>/);
|
|
117
118
|
}, SLOW);
|
|
118
119
|
|
|
119
120
|
it("prints a topic's section index with the keys to read by", async () => {
|
|
@@ -168,7 +168,23 @@ describe('doctor — individual checks', () => {
|
|
|
168
168
|
it('agent-docs: INFO when no docs present', () => {
|
|
169
169
|
const res = checkAgentDocs({cwd: tmpDir});
|
|
170
170
|
expect(res.status).toBe('info');
|
|
171
|
-
expect(res.fix).toContain('
|
|
171
|
+
expect(res.fix).toContain('init --features agents');
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// The npm package named `astryx` is not this CLI: a project without the
|
|
175
|
+
// `astryx` bin gets the scoped package in the fix, one with it keeps the bin.
|
|
176
|
+
it('agent-docs: the fix names the scoped package when the project has no local CLI', () => {
|
|
177
|
+
fs.writeFileSync(path.join(tmpDir, 'package-lock.json'), '{}');
|
|
178
|
+
const res = checkAgentDocs({cwd: tmpDir});
|
|
179
|
+
expect(res.fix).toContain('`npx @astryxdesign/cli init --features agents`');
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('agent-docs: the fix keeps `npx astryx` when the project has a local CLI', () => {
|
|
183
|
+
fs.writeFileSync(path.join(tmpDir, 'package-lock.json'), '{}');
|
|
184
|
+
fs.mkdirSync(path.join(tmpDir, 'node_modules', '.bin'), {recursive: true});
|
|
185
|
+
fs.writeFileSync(path.join(tmpDir, 'node_modules', '.bin', 'astryx'), '');
|
|
186
|
+
const res = checkAgentDocs({cwd: tmpDir});
|
|
187
|
+
expect(res.fix).toContain('`npx astryx init --features agents`');
|
|
172
188
|
});
|
|
173
189
|
|
|
174
190
|
it('agent-docs: WARN when docs exist without XDS markers', () => {
|
|
@@ -248,4 +248,27 @@ describe('import hint correctness', () => {
|
|
|
248
248
|
});
|
|
249
249
|
}
|
|
250
250
|
});
|
|
251
|
+
|
|
252
|
+
describe('CLI --detail brief text output for a single component', () => {
|
|
253
|
+
it('brief text output names the component and its package', async () => {
|
|
254
|
+
const result = await runCli(['component', 'Button', '--detail', 'brief'], REPO_ROOT);
|
|
255
|
+
expect(result.code).toBe(0);
|
|
256
|
+
expect(result.stdout).toContain('Button');
|
|
257
|
+
expect(result.stdout).toContain('@astryxdesign/core');
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it('brief text is shorter than compact text', async () => {
|
|
261
|
+
const brief = await runCli(['component', 'Button', '--detail', 'brief'], REPO_ROOT);
|
|
262
|
+
const compact = await runCli(['component', 'Button', '--detail', 'compact'], REPO_ROOT);
|
|
263
|
+
expect(brief.code).toBe(0);
|
|
264
|
+
expect(compact.code).toBe(0);
|
|
265
|
+
expect(brief.stdout.length).toBeLessThan(compact.stdout.length);
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it('brief text shows the import path in the signature line', async () => {
|
|
269
|
+
const result = await runCli(['component', 'Button', '--detail', 'brief'], REPO_ROOT);
|
|
270
|
+
expect(result.code).toBe(0);
|
|
271
|
+
expect(result.stdout).toContain('@astryxdesign/core/Button');
|
|
272
|
+
});
|
|
273
|
+
});
|
|
251
274
|
});
|
|
@@ -53,7 +53,11 @@ function asText(value) {
|
|
|
53
53
|
* @param {unknown} value
|
|
54
54
|
*/
|
|
55
55
|
function printsField(lines, key, value) {
|
|
56
|
-
|
|
56
|
+
// The text prefixes a command (`command`, `parent`) with the project's
|
|
57
|
+
// invocation (`pnpm exec astryx`, or `pnpm dlx @astryxdesign/cli` where no
|
|
58
|
+
// `astryx` bin is installed), so compare the part after `astryx`.
|
|
59
|
+
const text = asText(value).split('\n')[0].trimEnd();
|
|
60
|
+
const shown = text.replace(/^astryx /, '');
|
|
57
61
|
return lines.some(line => line.startsWith(`${key}:`) && line.trimEnd().endsWith(shown));
|
|
58
62
|
}
|
|
59
63
|
|
|
@@ -282,7 +286,7 @@ describe('search CLI — exit codes + JSON contract', () => {
|
|
|
282
286
|
|
|
283
287
|
it('renders each result as a greppable key: value record', async () => {
|
|
284
288
|
const r = await runCli(['search', 'button'], REPO_ROOT);
|
|
285
|
-
expect(r.stdout).
|
|
289
|
+
expect(r.stdout).toMatch(/^command:\s+\S.*(?:astryx|@astryxdesign\/cli) component Button$/m);
|
|
286
290
|
// Fields mirror the JSON object and are line-greppable.
|
|
287
291
|
expect(r.stdout).toMatch(/^name:\s+Button$/m);
|
|
288
292
|
expect(r.stdout).toMatch(/^domain:\s+component$/m);
|
|
@@ -305,7 +305,8 @@ describe('swizzle — StyleX build setup note (#3373)', () => {
|
|
|
305
305
|
expect(humanResult.stdout).toMatch(/StyleX compiler/i);
|
|
306
306
|
expect(humanResult.stdout).toMatch(/unstyled/i);
|
|
307
307
|
expect(humanResult.stdout).toMatch(/next\/font/i);
|
|
308
|
-
|
|
308
|
+
// The fixture has no `astryx` bin installed, so the note names the scoped package.
|
|
309
|
+
expect(humanResult.stdout).toMatch(/@astryxdesign\/cli docs styling/);
|
|
309
310
|
});
|
|
310
311
|
|
|
311
312
|
it('does not print the StyleX note for components without StyleX', async () => {
|
|
@@ -137,9 +137,9 @@ export function registerTemplate(program) {
|
|
|
137
137
|
return lines.join('\n');
|
|
138
138
|
};
|
|
139
139
|
emit(
|
|
140
|
-
section(`Page Templates (${pages.length})`),
|
|
140
|
+
pages.length > 0 && section(`Page Templates (${pages.length})`),
|
|
141
141
|
pages.length > 0 && text(grouped(pages)),
|
|
142
|
-
section(`Block Templates (${blocks.length})`),
|
|
142
|
+
blocks.length > 0 && section(`Block Templates (${blocks.length})`),
|
|
143
143
|
blocks.length > 0 && text(grouped(blocks)),
|
|
144
144
|
section('Usage'),
|
|
145
145
|
text(
|
|
@@ -7,6 +7,7 @@ import * as fs from 'node:fs';
|
|
|
7
7
|
import * as os from 'node:os';
|
|
8
8
|
import * as path from 'node:path';
|
|
9
9
|
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
10
|
+
import {getCliInvocation} from '../../../foundation/env/package-manager.mjs';
|
|
10
11
|
|
|
11
12
|
let tmpDir;
|
|
12
13
|
|
|
@@ -35,10 +36,11 @@ describe('theme add compatibility lifecycle', () => {
|
|
|
35
36
|
expect(result.stderr.match(/source copying is deprecated/g)).toHaveLength(
|
|
36
37
|
1,
|
|
37
38
|
);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
);
|
|
39
|
+
// The app has no CLI installed, so the commands name the scoped package.
|
|
40
|
+
const run = getCliInvocation(tmpDir);
|
|
41
|
+
expect(run).toMatch(/ @astryxdesign\/cli$/);
|
|
42
|
+
expect(result.stderr).toContain(`${run} theme eject neutral`);
|
|
43
|
+
expect(result.stderr).toContain(`${run} theme add neutral --import`);
|
|
42
44
|
expect(fs.existsSync(path.join(tmpDir, 'src/themes/neutral'))).toBe(true);
|
|
43
45
|
expect(fs.existsSync(path.join(tmpDir, 'src/astryx-themes.ts'))).toBe(
|
|
44
46
|
false,
|
|
@@ -77,11 +79,12 @@ describe('theme add compatibility lifecycle', () => {
|
|
|
77
79
|
|
|
78
80
|
const textResult = await runCli(['theme', 'add', '--list'], tmpDir);
|
|
79
81
|
expect(textResult.status, textResult.stderr).toBe(0);
|
|
82
|
+
const run = getCliInvocation(tmpDir);
|
|
80
83
|
expect(textResult.stdout).toContain(
|
|
81
|
-
|
|
84
|
+
`Import one: ${run} theme add <slug> --import [--package <package>]`,
|
|
82
85
|
);
|
|
83
86
|
expect(textResult.stdout).toContain(
|
|
84
|
-
|
|
87
|
+
`Fork source: ${run} theme eject <slug> [target-path]`,
|
|
85
88
|
);
|
|
86
89
|
expect(textResult.stdout).not.toContain('theme add <slug> [target-path]');
|
|
87
90
|
expect(textResult.stderr).not.toContain('deprecated');
|
|
@@ -187,8 +187,9 @@ describe('upgrade — core codemods run before config load', () => {
|
|
|
187
187
|
|
|
188
188
|
const out = await runHuman(['upgrade', '--from', '0.1.2', '--path', 'src']);
|
|
189
189
|
expect(out).toMatch(/fails strict validation/i);
|
|
190
|
+
// The fixture has no `astryx` bin installed, so the command names the scoped package.
|
|
190
191
|
expect(out).toContain(
|
|
191
|
-
'
|
|
192
|
+
'@astryxdesign/cli upgrade --from 0.1.2 --codemod migrate-layout-components-to-experimental --apply',
|
|
192
193
|
);
|
|
193
194
|
expect(exitCode).not.toBe(1);
|
|
194
195
|
});
|
|
@@ -56,7 +56,7 @@ describe('formatFull sub-component rendering', () => {
|
|
|
56
56
|
expect(out).toContain('### XDSRadioListItem');
|
|
57
57
|
expect(out).not.toContain('undefined');
|
|
58
58
|
// Points the reader at the sub-component's own docs instead of a blank.
|
|
59
|
-
expect(out).
|
|
59
|
+
expect(out).toMatch(/(?:astryx|@astryxdesign\/cli) component XDSRadioListItem/);
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
it('renders a full props table for a sub-component that has inline props', () => {
|
|
@@ -90,22 +90,42 @@ export function getDlxPrefix(targetDir?: string): string;
|
|
|
90
90
|
*
|
|
91
91
|
* We sniff the entry path (`process.argv[1]`) for well-known runner-cache
|
|
92
92
|
* markers. This errs safe in both directions: a false negative falls back to
|
|
93
|
-
*
|
|
94
|
-
*
|
|
93
|
+
* {@link getCliInvocation}'s on-disk check, and a false positive emits the
|
|
94
|
+
* always-valid scoped form (`<dlx> @astryxdesign/cli`).
|
|
95
95
|
*
|
|
96
96
|
* @returns {boolean}
|
|
97
97
|
*/
|
|
98
98
|
export function isCliOneOff(): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Does the bare `astryx` bin resolve from `targetDir`?
|
|
101
|
+
*
|
|
102
|
+
* A package runner finds an installed bin in `node_modules/.bin`, in the
|
|
103
|
+
* project or in a folder above it (a workspace root). When no such link
|
|
104
|
+
* exists, `npx astryx` and `bunx astryx` fetch the unrelated registry package
|
|
105
|
+
* named `astryx` instead of running this CLI, and `pnpm exec astryx` or
|
|
106
|
+
* `yarn astryx` fail. A global install, or a workspace install running in a
|
|
107
|
+
* fresh package, is exactly that case.
|
|
108
|
+
*
|
|
109
|
+
* A false negative (a layout without `node_modules/.bin`, such as Yarn Plug'n'Play)
|
|
110
|
+
* is safe: the caller suggests the scoped package, which always resolves.
|
|
111
|
+
*
|
|
112
|
+
* @param {string} [targetDir=process.cwd()]
|
|
113
|
+
* @returns {boolean}
|
|
114
|
+
*/
|
|
115
|
+
export function cliBinResolves(targetDir?: string): boolean;
|
|
99
116
|
/**
|
|
100
117
|
* The safe, install-aware CLI invocation stem to suggest to users.
|
|
101
118
|
*
|
|
102
|
-
* -
|
|
103
|
-
*
|
|
104
|
-
* -
|
|
105
|
-
* `
|
|
106
|
-
*
|
|
119
|
+
* - The `astryx` bin resolves from `targetDir`: `<run-prefix> astryx`
|
|
120
|
+
* (e.g. `pnpm exec astryx`).
|
|
121
|
+
* - Launched one-off (npx/dlx cache), or the bin does not resolve from
|
|
122
|
+
* `targetDir` (a global install, a fresh package in a workspace):
|
|
123
|
+
* `<dlx-prefix> @astryxdesign/cli`. The bare `astryx` name would make npm
|
|
124
|
+
* fetch an unrelated registry package; the scoped package always resolves
|
|
125
|
+
* to this CLI.
|
|
107
126
|
*
|
|
108
|
-
* @param {string} [targetDir]
|
|
127
|
+
* @param {string} [targetDir] the project the printed command runs in;
|
|
128
|
+
* defaults to the working directory
|
|
109
129
|
* @returns {string}
|
|
110
130
|
*/
|
|
111
131
|
export function getCliInvocation(targetDir?: string): string;
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* The order is: the `packageManager` field a project DECLARES, then the
|
|
7
7
|
* lockfiles it happens to have, then a committed package-manager config, then
|
|
8
8
|
* the runner that launched us. Returns the correct command prefix for running
|
|
9
|
-
* package binaries (e.g. 'npx astryx', 'yarn astryx', 'pnpm exec astryx')
|
|
9
|
+
* package binaries (e.g. 'npx astryx', 'yarn astryx', 'pnpm exec astryx'), and
|
|
10
|
+
* the scoped one-off form ('npx @astryxdesign/cli') when the `astryx` bin does
|
|
11
|
+
* not resolve from the project.
|
|
10
12
|
*/
|
|
11
13
|
|
|
12
14
|
import * as fs from 'node:fs';
|
|
@@ -319,8 +321,8 @@ export function getDlxPrefix(targetDir) {
|
|
|
319
321
|
*
|
|
320
322
|
* We sniff the entry path (`process.argv[1]`) for well-known runner-cache
|
|
321
323
|
* markers. This errs safe in both directions: a false negative falls back to
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
+
* {@link getCliInvocation}'s on-disk check, and a false positive emits the
|
|
325
|
+
* always-valid scoped form (`<dlx> @astryxdesign/cli`).
|
|
324
326
|
*
|
|
325
327
|
* @returns {boolean}
|
|
326
328
|
*/
|
|
@@ -329,20 +331,57 @@ export function isCliOneOff() {
|
|
|
329
331
|
return /\/_npx\/|\/dlx[-/]|\/\.bun\/install\/cache\/|\/bunx-/.test(entry);
|
|
330
332
|
}
|
|
331
333
|
|
|
334
|
+
/** The `astryx` bin as package managers link it, including the Windows shims. */
|
|
335
|
+
const CLI_BIN_LINKS = [CLI_BIN, `${CLI_BIN}.cmd`, `${CLI_BIN}.ps1`];
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Does the bare `astryx` bin resolve from `targetDir`?
|
|
339
|
+
*
|
|
340
|
+
* A package runner finds an installed bin in `node_modules/.bin`, in the
|
|
341
|
+
* project or in a folder above it (a workspace root). When no such link
|
|
342
|
+
* exists, `npx astryx` and `bunx astryx` fetch the unrelated registry package
|
|
343
|
+
* named `astryx` instead of running this CLI, and `pnpm exec astryx` or
|
|
344
|
+
* `yarn astryx` fail. A global install, or a workspace install running in a
|
|
345
|
+
* fresh package, is exactly that case.
|
|
346
|
+
*
|
|
347
|
+
* A false negative (a layout without `node_modules/.bin`, such as Yarn Plug'n'Play)
|
|
348
|
+
* is safe: the caller suggests the scoped package, which always resolves.
|
|
349
|
+
*
|
|
350
|
+
* @param {string} [targetDir=process.cwd()]
|
|
351
|
+
* @returns {boolean}
|
|
352
|
+
*/
|
|
353
|
+
export function cliBinResolves(targetDir = process.cwd()) {
|
|
354
|
+
let dir = path.resolve(targetDir);
|
|
355
|
+
for (;;) {
|
|
356
|
+
const binDir = path.join(dir, 'node_modules', '.bin');
|
|
357
|
+
if (CLI_BIN_LINKS.some(name => fs.existsSync(path.join(binDir, name)))) {
|
|
358
|
+
return true;
|
|
359
|
+
}
|
|
360
|
+
const parent = path.dirname(dir);
|
|
361
|
+
if (parent === dir) return false;
|
|
362
|
+
dir = parent;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
332
366
|
/**
|
|
333
367
|
* The safe, install-aware CLI invocation stem to suggest to users.
|
|
334
368
|
*
|
|
335
|
-
* -
|
|
336
|
-
*
|
|
337
|
-
* -
|
|
338
|
-
* `
|
|
339
|
-
*
|
|
369
|
+
* - The `astryx` bin resolves from `targetDir`: `<run-prefix> astryx`
|
|
370
|
+
* (e.g. `pnpm exec astryx`).
|
|
371
|
+
* - Launched one-off (npx/dlx cache), or the bin does not resolve from
|
|
372
|
+
* `targetDir` (a global install, a fresh package in a workspace):
|
|
373
|
+
* `<dlx-prefix> @astryxdesign/cli`. The bare `astryx` name would make npm
|
|
374
|
+
* fetch an unrelated registry package; the scoped package always resolves
|
|
375
|
+
* to this CLI.
|
|
340
376
|
*
|
|
341
|
-
* @param {string} [targetDir]
|
|
377
|
+
* @param {string} [targetDir] the project the printed command runs in;
|
|
378
|
+
* defaults to the working directory
|
|
342
379
|
* @returns {string}
|
|
343
380
|
*/
|
|
344
381
|
export function getCliInvocation(targetDir) {
|
|
345
|
-
if (isCliOneOff()
|
|
382
|
+
if (isCliOneOff() || !cliBinResolves(targetDir)) {
|
|
383
|
+
return `${getDlxPrefix(targetDir)} ${CLI_PACKAGE}`;
|
|
384
|
+
}
|
|
346
385
|
return `${getRunPrefix(targetDir)} ${CLI_BIN}`;
|
|
347
386
|
}
|
|
348
387
|
|
|
@@ -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,16 @@ 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
|
+
/** An installed CLI's entry, outside any runner cache (a global or workspace install). */
|
|
43
|
+
const INSTALLED_ENTRY = '/usr/local/lib/node_modules/@astryxdesign/cli/clients/cli/bin/astryx.mjs';
|
|
44
|
+
|
|
34
45
|
describe('detectPackageManager', () => {
|
|
35
46
|
it('detects yarn from yarn.lock', () => {
|
|
36
47
|
const dir = makeTmpDir();
|
|
@@ -79,6 +90,7 @@ describe('detectPackageManager', () => {
|
|
|
79
90
|
const dir = makeTmpDir();
|
|
80
91
|
fs.writeFileSync(path.join(dir, 'pnpm-lock.yaml'), '');
|
|
81
92
|
fs.writeFileSync(path.join(dir, 'yarn.lock'), '');
|
|
93
|
+
linkCliBin(dir);
|
|
82
94
|
process.env.npm_config_user_agent = 'yarn/1.22.21 npm/? node/v22.0.0';
|
|
83
95
|
expect(detectPackageManager(dir)).not.toBe('yarn');
|
|
84
96
|
expect(getCliInvocation(dir)).toBe('npx astryx');
|
|
@@ -90,6 +102,7 @@ describe('detectPackageManager', () => {
|
|
|
90
102
|
try {
|
|
91
103
|
fs.writeFileSync(path.join(dir, 'pnpm-lock.yaml'), '');
|
|
92
104
|
fs.writeFileSync(path.join(dir, 'yarn.lock'), '');
|
|
105
|
+
linkCliBin(dir);
|
|
93
106
|
process.env.npm_config_user_agent = 'yarn/1.22.21 npm/? node/v22.0.0';
|
|
94
107
|
process.argv[1] = path.join(dir, 'node_modules/.bin/astryx');
|
|
95
108
|
expect(getCliInvocation(dir)).toBe('npx astryx');
|
|
@@ -198,6 +211,7 @@ describe('detectPackageManager', () => {
|
|
|
198
211
|
path.join(dir, 'package.json'),
|
|
199
212
|
JSON.stringify({packageManager: 'pnpm@8.0.0'}),
|
|
200
213
|
);
|
|
214
|
+
linkCliBin(dir);
|
|
201
215
|
expect(detectPackageManager(dir)).toBe('pnpm');
|
|
202
216
|
expect(getCliInvocation(dir)).toBe('pnpm exec astryx');
|
|
203
217
|
});
|
|
@@ -351,14 +365,90 @@ describe('isCliOneOff', () => {
|
|
|
351
365
|
});
|
|
352
366
|
});
|
|
353
367
|
|
|
368
|
+
describe('cliBinResolves', () => {
|
|
369
|
+
it('finds the bin link in the project', () => {
|
|
370
|
+
const dir = makeTmpDir();
|
|
371
|
+
linkCliBin(dir);
|
|
372
|
+
expect(cliBinResolves(dir)).toBe(true);
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
it('finds it in a folder above the project (a workspace root)', () => {
|
|
376
|
+
const root = makeTmpDir();
|
|
377
|
+
linkCliBin(root);
|
|
378
|
+
const pkg = path.join(root, 'packages', 'app');
|
|
379
|
+
fs.mkdirSync(pkg, {recursive: true});
|
|
380
|
+
expect(cliBinResolves(pkg)).toBe(true);
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
it('finds a Windows shim', () => {
|
|
384
|
+
const dir = makeTmpDir();
|
|
385
|
+
linkCliBin(dir, 'astryx.cmd');
|
|
386
|
+
expect(cliBinResolves(dir)).toBe(true);
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
it('is false when no bin link exists up the tree', () => {
|
|
390
|
+
const dir = makeTmpDir();
|
|
391
|
+
fs.mkdirSync(path.join(dir, 'node_modules', '.bin'), {recursive: true});
|
|
392
|
+
expect(cliBinResolves(dir)).toBe(false);
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
|
|
354
396
|
describe('getCliInvocation', () => {
|
|
355
|
-
it('uses the run-prefix + bare bin when
|
|
397
|
+
it('uses the run-prefix + bare bin when the bin resolves from the project', () => {
|
|
356
398
|
process.argv[1] = '/proj/node_modules/@astryxdesign/cli/bin/astryx.mjs';
|
|
357
399
|
const dir = makeTmpDir();
|
|
358
400
|
fs.writeFileSync(path.join(dir, 'pnpm-lock.yaml'), '');
|
|
401
|
+
linkCliBin(dir);
|
|
359
402
|
expect(getCliInvocation(dir)).toBe('pnpm exec astryx');
|
|
360
403
|
});
|
|
361
404
|
|
|
405
|
+
it('keeps `npx astryx` for a project with a local CLI', () => {
|
|
406
|
+
process.argv[1] = INSTALLED_ENTRY;
|
|
407
|
+
const dir = makeTmpDir();
|
|
408
|
+
fs.writeFileSync(path.join(dir, 'package-lock.json'), '{}');
|
|
409
|
+
linkCliBin(dir);
|
|
410
|
+
expect(getCliInvocation(dir)).toBe('npx astryx');
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
it('keeps the installed form in a workspace package when the root has the bin', () => {
|
|
414
|
+
process.argv[1] = INSTALLED_ENTRY;
|
|
415
|
+
const root = makeTmpDir();
|
|
416
|
+
fs.writeFileSync(path.join(root, 'pnpm-lock.yaml'), '');
|
|
417
|
+
linkCliBin(root);
|
|
418
|
+
const pkg = path.join(root, 'packages', 'app');
|
|
419
|
+
fs.mkdirSync(pkg, {recursive: true});
|
|
420
|
+
fs.writeFileSync(path.join(pkg, 'package.json'), '{"name":"app"}');
|
|
421
|
+
expect(getCliInvocation(pkg)).toBe('pnpm exec astryx');
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
// The hazard: the npm package named `astryx` is not this CLI. Launched from
|
|
425
|
+
// an installed path (a global install, or a workspace install running in a
|
|
426
|
+
// fresh package), the CLI used to print `npx astryx` for a project where that
|
|
427
|
+
// bin does not resolve, so following the hint fetched someone else's package.
|
|
428
|
+
it.each([
|
|
429
|
+
['package-lock.json', '{}', 'npx @astryxdesign/cli'],
|
|
430
|
+
['pnpm-lock.yaml', '', 'pnpm dlx @astryxdesign/cli'],
|
|
431
|
+
['yarn.lock', '', 'yarn dlx @astryxdesign/cli'],
|
|
432
|
+
['bun.lockb', '', 'bunx @astryxdesign/cli'],
|
|
433
|
+
])(
|
|
434
|
+
'prints the scoped package for a project with no local CLI (%s), launched from an installed path',
|
|
435
|
+
(lockfile, contents, expected) => {
|
|
436
|
+
process.argv[1] = INSTALLED_ENTRY;
|
|
437
|
+
const dir = makeTmpDir();
|
|
438
|
+
fs.writeFileSync(path.join(dir, lockfile), contents);
|
|
439
|
+
expect(isCliOneOff()).toBe(false);
|
|
440
|
+
expect(getCliInvocation(dir)).toBe(expected);
|
|
441
|
+
},
|
|
442
|
+
);
|
|
443
|
+
|
|
444
|
+
it('prints the scoped package for a fresh package with no lockfile or install', () => {
|
|
445
|
+
process.argv[1] = INSTALLED_ENTRY;
|
|
446
|
+
const dir = makeTmpDir();
|
|
447
|
+
delete process.env.npm_config_user_agent;
|
|
448
|
+
fs.writeFileSync(path.join(dir, 'package.json'), '{"name":"fresh"}');
|
|
449
|
+
expect(getCliInvocation(dir)).toBe('npx @astryxdesign/cli');
|
|
450
|
+
});
|
|
451
|
+
|
|
362
452
|
it('uses the dlx runner + scoped package when run one-off', () => {
|
|
363
453
|
process.argv[1] = '/home/u/.npm/_npx/a1b2/node_modules/.bin/astryx';
|
|
364
454
|
const dir = makeTmpDir();
|
|
@@ -379,6 +469,7 @@ describe('formatCliCommand', () => {
|
|
|
379
469
|
process.argv[1] = '/proj/node_modules/@astryxdesign/cli/bin/astryx.mjs';
|
|
380
470
|
const dir = makeTmpDir();
|
|
381
471
|
fs.writeFileSync(path.join(dir, 'pnpm-lock.yaml'), '');
|
|
472
|
+
linkCliBin(dir);
|
|
382
473
|
expect(formatCliCommand('astryx component Button', dir)).toBe('pnpm exec astryx component Button');
|
|
383
474
|
});
|
|
384
475
|
|
|
@@ -386,6 +477,7 @@ describe('formatCliCommand', () => {
|
|
|
386
477
|
process.argv[1] = '/proj/node_modules/@astryxdesign/cli/bin/astryx.mjs';
|
|
387
478
|
const dir = makeTmpDir();
|
|
388
479
|
fs.writeFileSync(path.join(dir, 'package-lock.json'), '{}');
|
|
480
|
+
linkCliBin(dir);
|
|
389
481
|
expect(formatCliCommand('docs tokens', dir)).toBe('npx astryx docs tokens');
|
|
390
482
|
});
|
|
391
483
|
|
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.cc0df20",
|
|
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.cc0df20",
|
|
105
|
+
"@astryxdesign/core": "0.6.6-canary.cc0df20",
|
|
106
|
+
"@astryxdesign/lab": "0.6.6-canary.cc0df20",
|
|
107
|
+
"@astryxdesign/theme-neutral": "0.6.6-canary.cc0df20"
|
|
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.cc0df20",
|
|
125
|
+
"@astryxdesign/core": "0.6.6-canary.cc0df20",
|
|
126
|
+
"@astryxdesign/lab": "0.6.6-canary.cc0df20",
|
|
127
|
+
"@astryxdesign/theme-neutral": "0.6.6-canary.cc0df20",
|
|
128
128
|
"@heroicons/react": "^2.2.0",
|
|
129
129
|
"@stylexjs/stylex": "^0.19.0",
|
|
130
130
|
"@types/babel__core": "^7.20.5",
|