@astryxdesign/cli 0.6.6-canary.9613feb → 0.6.6-canary.bbeffca

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.
Files changed (65) hide show
  1. package/README.md +83 -83
  2. package/api/build/_adapter.d.mts +15 -0
  3. package/api/build/_adapter.mjs +22 -0
  4. package/api/build/build.doc.mjs +1 -1
  5. package/api/build/build.type.d.mts +4 -0
  6. package/api/build/build.type.mjs +1 -0
  7. package/api/build/help/help.mjs +1 -1
  8. package/api/build/kit/kit.mjs +12 -1
  9. package/api/doctor/_adapter.d.mts +7 -0
  10. package/api/doctor/_adapter.mjs +48 -0
  11. package/api/doctor/doctor.mjs +5 -3
  12. package/api/doctor/theme-checks.d.mts +12 -0
  13. package/api/doctor/theme-checks.mjs +115 -1
  14. package/api/doctor/theme-checks.test.mjs +142 -1
  15. package/api/init/run/run.mjs +1 -0
  16. package/api/layout/check/check.d.mts +1 -0
  17. package/api/layout/check/check.mjs +1 -0
  18. package/api/layout/expand/expand.d.mts +1 -0
  19. package/api/layout/expand/expand.mjs +1 -0
  20. package/api/layout/grammar/grammar.d.mts +1 -0
  21. package/api/layout/grammar/grammar.mjs +1 -0
  22. package/api/layout/layoutCheck.doc.mjs +1 -1
  23. package/api/layout/layoutExpand.doc.mjs +1 -1
  24. package/api/layout/layoutGrammar.doc.mjs +1 -1
  25. package/api/template/copy/copy.mjs +12 -0
  26. package/api/template/template.doc.mjs +1 -1
  27. package/api/template/template.type.d.mts +3 -0
  28. package/api/template/template.type.mjs +3 -0
  29. package/api/theme/build/build.d.mts +70 -0
  30. package/api/theme/build/build.mjs +205 -41
  31. package/api/theme/build/font-warning.d.mts +11 -0
  32. package/api/theme/build/font-warning.mjs +28 -3
  33. package/assets/docs/author-a-theme.doc.mjs +1 -1
  34. package/assets/docs/styling-overview.doc.mjs +1 -1
  35. package/assets/docs/theme.doc.dense.mjs +1 -1
  36. package/assets/docs/theme.doc.zh.mjs +1 -1
  37. package/assets/docs/use-a-theme.doc.mjs +1 -1
  38. package/assets/templates/pages/table-comparison/template.doc.mjs +1 -1
  39. package/authoring/doctypes/template/type.ts +1 -0
  40. package/clients/cli/commands/build-theme.adaptations.test.mjs +1 -1
  41. package/clients/cli/commands/build-theme.ascii-output.test.mjs +11 -1
  42. package/clients/cli/commands/build-theme.batch-report.test.mjs +335 -0
  43. package/clients/cli/commands/build-theme.font-warning.test.mjs +36 -7
  44. package/clients/cli/commands/build-theme.import-path.test.mjs +3 -3
  45. package/clients/cli/commands/build-theme.mjs +68 -18
  46. package/clients/cli/commands/build-theme.watch.test.mjs +33 -0
  47. package/clients/cli/commands/build.mjs +1 -0
  48. package/clients/cli/commands/doctor.doc.mjs +1 -1
  49. package/clients/cli/commands/layout-check.doc.mjs +1 -0
  50. package/clients/cli/commands/layout-expand.doc.mjs +1 -0
  51. package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
  52. package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +140 -0
  53. package/clients/cli/commands/layout.doc.mjs +1 -0
  54. package/clients/cli/commands/layout.mjs +6 -11
  55. package/clients/cli/commands/template.mjs +2 -1
  56. package/clients/cli/commands/theme-build.doc.mjs +3 -1
  57. package/clients/cli/index.mjs +1 -1
  58. package/clients/cli/lib/define-command.mjs +4 -0
  59. package/foundation/agent-docs/agent-docs.mjs +4 -1
  60. package/foundation/agent-docs/agent-docs.test.mjs +18 -0
  61. package/foundation/discovery/template-needs.d.mts +31 -0
  62. package/foundation/discovery/template-needs.mjs +156 -0
  63. package/foundation/discovery/template-needs.test.mjs +203 -0
  64. package/foundation/response/response-types.doc.mjs +4 -4
  65. package/package.json +9 -9
@@ -0,0 +1,203 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Tests for template-needs analysis: external package detection, StyleX
5
+ * compiler warning, and install command generation.
6
+ */
7
+
8
+ import {describe, it, expect, beforeEach, afterEach} from 'vitest';
9
+ import * as fs from 'node:fs';
10
+ import * as os from 'node:os';
11
+ import * as path from 'node:path';
12
+ import {
13
+ extractImportedPackages,
14
+ analyzeTemplateNeeds,
15
+ } from './template-needs.mjs';
16
+
17
+ // ── extractImportedPackages ─────────────────────────────────────────────────
18
+
19
+ describe('extractImportedPackages', () => {
20
+ it('extracts bare package names from static imports', () => {
21
+ const source = `
22
+ import {Button} from '@astryxdesign/core';
23
+ import {ArrowIcon} from '@heroicons/react/24/outline';
24
+ import * as stylex from '@stylexjs/stylex';
25
+ import {useState} from 'react';
26
+ import recharts from 'recharts';
27
+ `;
28
+ const pkgs = extractImportedPackages(source);
29
+ expect(pkgs).toEqual(
30
+ new Set([
31
+ '@astryxdesign/core',
32
+ '@heroicons/react',
33
+ '@stylexjs/stylex',
34
+ 'react',
35
+ 'recharts',
36
+ ]),
37
+ );
38
+ });
39
+
40
+ it('ignores relative and absolute imports', () => {
41
+ const source = `
42
+ import {foo} from './bar';
43
+ import {baz} from '../qux';
44
+ import {thing} from '/absolute/path';
45
+ `;
46
+ expect(extractImportedPackages(source).size).toBe(0);
47
+ });
48
+
49
+ it('ignores Node builtins with the node: prefix', () => {
50
+ const source = `
51
+ import * as fs from 'node:fs';
52
+ import * as path from 'node:path';
53
+ import {createRequire} from 'node:module';
54
+ `;
55
+ expect(extractImportedPackages(source).size).toBe(0);
56
+ });
57
+
58
+ it('ignores bare Node builtins and their subpaths', () => {
59
+ const source = `
60
+ import * as fs from 'fs';
61
+ import {join} from 'path';
62
+ import {createReadStream} from 'fs/promises';
63
+ `;
64
+ expect(extractImportedPackages(source).size).toBe(0);
65
+ });
66
+
67
+ it('handles type imports', () => {
68
+ const source = `import type {Props} from 'some-package';`;
69
+ expect(extractImportedPackages(source)).toEqual(new Set(['some-package']));
70
+ });
71
+
72
+ it('deduplicates multiple imports from the same package', () => {
73
+ const source = `
74
+ import {A} from '@heroicons/react/24/outline';
75
+ import {B} from '@heroicons/react/24/solid';
76
+ `;
77
+ expect(extractImportedPackages(source)).toEqual(
78
+ new Set(['@heroicons/react']),
79
+ );
80
+ });
81
+
82
+ it('maps subpath imports to the package root', () => {
83
+ const source = `
84
+ import debounce from 'lodash/debounce';
85
+ import {Chart} from 'recharts/es6';
86
+ `;
87
+ const pkgs = extractImportedPackages(source);
88
+ expect(pkgs).toEqual(new Set(['lodash', 'recharts']));
89
+ });
90
+ });
91
+
92
+ // ── analyzeTemplateNeeds ────────────────────────────────────────────────────
93
+
94
+ describe('analyzeTemplateNeeds', () => {
95
+ let dir;
96
+ beforeEach(() => {
97
+ dir = fs.mkdtempSync(path.join(os.tmpdir(), 'tmpl-needs-'));
98
+ });
99
+ afterEach(() => fs.rmSync(dir, {recursive: true, force: true}));
100
+
101
+ it('reports missing external packages with an install command', () => {
102
+ fs.writeFileSync(
103
+ path.join(dir, 'package.json'),
104
+ JSON.stringify({dependencies: {'react': '^19.0.0', '@astryxdesign/core': '^0.6.0'}}),
105
+ );
106
+ const source = `
107
+ import {Button} from '@astryxdesign/core';
108
+ import {ArrowIcon} from '@heroicons/react/24/outline';
109
+ import {useState} from 'react';
110
+ `;
111
+ const result = analyzeTemplateNeeds(source, dir);
112
+ expect(result.missingPackages).toEqual(['@heroicons/react']);
113
+ expect(result.installCommand).toMatch(/npm install @heroicons\/react/);
114
+ expect(result.notes.length).toBeGreaterThanOrEqual(1);
115
+ expect(result.notes[0]).toMatch(/Install missing dependencies/);
116
+ });
117
+
118
+ it('reports nothing when all packages are installed', () => {
119
+ fs.writeFileSync(
120
+ path.join(dir, 'package.json'),
121
+ JSON.stringify({
122
+ dependencies: {
123
+ 'react': '^19.0.0',
124
+ '@astryxdesign/core': '^0.6.0',
125
+ '@heroicons/react': '^2.2.0',
126
+ },
127
+ }),
128
+ );
129
+ const source = `
130
+ import {Button} from '@astryxdesign/core';
131
+ import {ArrowIcon} from '@heroicons/react/24/outline';
132
+ `;
133
+ const result = analyzeTemplateNeeds(source, dir);
134
+ expect(result.missingPackages).toEqual([]);
135
+ expect(result.installCommand).toBeNull();
136
+ expect(result.notes).toEqual([]);
137
+ });
138
+
139
+ it('warns about StyleX compiler when template uses it and project lacks one', () => {
140
+ fs.writeFileSync(
141
+ path.join(dir, 'package.json'),
142
+ JSON.stringify({dependencies: {'@stylexjs/stylex': '^0.10.0'}}),
143
+ );
144
+ const source = `import * as stylex from '@stylexjs/stylex';`;
145
+ const result = analyzeTemplateNeeds(source, dir);
146
+ expect(result.notes).toEqual(
147
+ expect.arrayContaining([
148
+ expect.stringContaining('StyleX'),
149
+ expect.stringContaining('styling-overview'),
150
+ ]),
151
+ );
152
+ });
153
+
154
+ it('does NOT warn about StyleX when the project has a compiler', () => {
155
+ fs.writeFileSync(
156
+ path.join(dir, 'package.json'),
157
+ JSON.stringify({
158
+ devDependencies: {
159
+ '@stylexjs/stylex': '^0.10.0',
160
+ '@stylexjs/rollup-plugin': '^0.10.0',
161
+ },
162
+ }),
163
+ );
164
+ const source = `import * as stylex from '@stylexjs/stylex';`;
165
+ const result = analyzeTemplateNeeds(source, dir);
166
+ const stylexNotes = result.notes.filter(n => n.includes('StyleX'));
167
+ expect(stylexNotes).toEqual([]);
168
+ });
169
+
170
+ it('detects pnpm from lockfile', () => {
171
+ fs.writeFileSync(path.join(dir, 'package.json'), '{}');
172
+ fs.writeFileSync(path.join(dir, 'pnpm-lock.yaml'), '');
173
+ const source = `import {Chart} from 'recharts';`;
174
+ const result = analyzeTemplateNeeds(source, dir);
175
+ expect(result.installCommand).toMatch(/^pnpm add /);
176
+ });
177
+
178
+ it('detects yarn from lockfile', () => {
179
+ fs.writeFileSync(path.join(dir, 'package.json'), '{}');
180
+ fs.writeFileSync(path.join(dir, 'yarn.lock'), '');
181
+ const source = `import {Chart} from 'recharts';`;
182
+ const result = analyzeTemplateNeeds(source, dir);
183
+ expect(result.installCommand).toMatch(/^yarn add /);
184
+ });
185
+
186
+ it('excludes @stylexjs/stylex from missing packages (it is a Core peer)', () => {
187
+ fs.writeFileSync(path.join(dir, 'package.json'), '{}');
188
+ const source = `import * as stylex from '@stylexjs/stylex';`;
189
+ const result = analyzeTemplateNeeds(source, dir);
190
+ expect(result.missingPackages).not.toContain('@stylexjs/stylex');
191
+ });
192
+
193
+ it('handles a template with no external imports', () => {
194
+ fs.writeFileSync(path.join(dir, 'package.json'), '{}');
195
+ const source = `
196
+ import {useState} from 'react';
197
+ import {Button} from '@astryxdesign/core';
198
+ `;
199
+ const result = analyzeTemplateNeeds(source, dir);
200
+ expect(result.notes).toEqual([]);
201
+ expect(result.missingPackages).toEqual([]);
202
+ });
203
+ });
@@ -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, and demoMediaReplaced (how many Astryx demo media references were replaced with placeholders for you to swap for your own media). The envelope\'s package names the npm package that owns the template.',
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.9613feb",
3
+ "version": "0.6.6-canary.bbeffca",
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.9613feb",
105
- "@astryxdesign/core": "0.6.6-canary.9613feb",
106
- "@astryxdesign/lab": "0.6.6-canary.9613feb",
107
- "@astryxdesign/theme-neutral": "0.6.6-canary.9613feb"
104
+ "@astryxdesign/charts": "0.6.6-canary.bbeffca",
105
+ "@astryxdesign/core": "0.6.6-canary.bbeffca",
106
+ "@astryxdesign/lab": "0.6.6-canary.bbeffca",
107
+ "@astryxdesign/theme-neutral": "0.6.6-canary.bbeffca"
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.9613feb",
125
- "@astryxdesign/core": "0.6.6-canary.9613feb",
126
- "@astryxdesign/lab": "0.6.6-canary.9613feb",
127
- "@astryxdesign/theme-neutral": "0.6.6-canary.9613feb",
124
+ "@astryxdesign/charts": "0.6.6-canary.bbeffca",
125
+ "@astryxdesign/core": "0.6.6-canary.bbeffca",
126
+ "@astryxdesign/lab": "0.6.6-canary.bbeffca",
127
+ "@astryxdesign/theme-neutral": "0.6.6-canary.bbeffca",
128
128
  "@heroicons/react": "^2.2.0",
129
129
  "@stylexjs/stylex": "^0.19.0",
130
130
  "@types/babel__core": "^7.20.5",