@astryxdesign/cli 0.7.0-canary.e92e36f → 0.7.0-canary.ed07233

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 (52) hide show
  1. package/README.md +61 -61
  2. package/api/integration/pack-check.test.mjs +8 -0
  3. package/api/template/template.doc.mjs +1 -1
  4. package/api/template/template.type.mjs +1 -1
  5. package/api/theme/build/build.d.mts +0 -1
  6. package/api/theme/build/build.mjs +4 -29
  7. package/api/theme/build/family.mjs +1 -1
  8. package/assets/codemods/transforms/next/__tests__/migrate-field-input-styling.test.mjs +108 -0
  9. package/assets/codemods/transforms/next/__tests__/validate-data-token-ownership.test.mjs +84 -0
  10. package/assets/codemods/transforms/next/index.mjs +16 -0
  11. package/assets/codemods/transforms/next/migrate-field-input-styling.mjs +198 -0
  12. package/assets/codemods/transforms/next/validate-data-token-ownership.mjs +102 -0
  13. package/assets/docs/author-a-theme.doc.mjs +1 -1
  14. package/assets/docs/tree/tokens-data.doc.mjs +2 -2
  15. package/assets/docs/tree/tokens-usage.doc.mjs +1 -1
  16. package/assets/templates/blocks/components/ComplexSelector/ComplexSelectorDeadlinePicker.tsx +1 -1
  17. package/assets/templates/blocks/components/ComplexSelector/ComplexSelectorShowcase.tsx +1 -1
  18. package/assets/templates/blocks/components/ComplexSelector/ComplexSelectorTreeSearch.tsx +1 -1
  19. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.tsx +1 -1
  20. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider02Overrides.tsx +1 -1
  21. package/assets/templates/blocks/components/Selector/SelectorClearable.tsx +1 -1
  22. package/assets/templates/blocks/components/Selector/SelectorOptionDescriptions.tsx +2 -2
  23. package/assets/templates/blocks/components/Selector/SelectorShowcase.tsx +1 -1
  24. package/assets/templates/blocks/components/Selector/SelectorWithSections.tsx +1 -1
  25. package/assets/templates/blocks/components/SelectorOption/SelectorOptionBasic.tsx +1 -1
  26. package/assets/templates/blocks/components/SelectorOption/SelectorOptionShowcase.tsx +1 -1
  27. package/assets/templates/blocks/components/Slider/SliderFormattedValue.tsx +1 -1
  28. package/assets/templates/blocks/components/Slider/SliderRangeSlider.tsx +1 -1
  29. package/assets/templates/blocks/components/Slider/SliderShowcase.tsx +1 -1
  30. package/assets/templates/blocks/components/Slider/SliderWithMarks.tsx +1 -1
  31. package/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx +1 -1
  32. package/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx +2 -2
  33. package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +1 -1
  34. package/assets/templates/blocks/components/Tokenizer/TokenizerIcon.tsx +1 -1
  35. package/assets/templates/blocks/components/Tokenizer/TokenizerMaxEntries.tsx +1 -1
  36. package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx +2 -2
  37. package/assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx +1 -1
  38. package/assets/templates/blocks/components/Tokenizer/TokenizerStates.tsx +4 -4
  39. package/assets/templates/blocks/components/Toolbar/ToolbarTableFilter.tsx +1 -1
  40. package/assets/templates/pages/canvas-editor/page.tsx +2 -2
  41. package/assets/templates/pages/form-wizard-vertical/page.tsx +1 -1
  42. package/assets/templates/pages/payment-form/page.tsx +1 -1
  43. package/assets/templates/pages/table-filter/page.tsx +3 -3
  44. package/assets/templates/pages/theme-showcase/page.tsx +2 -2
  45. package/clients/cli/commands/build-theme.color-scheme.test.mjs +10 -6
  46. package/clients/cli/commands/build-theme.data-tokens.test.mjs +23 -75
  47. package/foundation/discovery/template-needs.mjs +93 -11
  48. package/foundation/discovery/template-needs.test.mjs +106 -3
  49. package/foundation/env/package-manager.d.mts +13 -0
  50. package/foundation/env/package-manager.mjs +106 -63
  51. package/foundation/response/response-types.doc.mjs +1 -2
  52. package/package.json +9 -9
@@ -144,6 +144,76 @@ function evidenceIn(dir) {
144
144
  * them, because a tool that trusts the lockfile instead will disagree with us.
145
145
  */
146
146
 
147
+ /**
148
+ * What one directory's own files say about its package manager, by the rules
149
+ * {@link explainPackageManager} applies within a directory (declared field,
150
+ * then a single lockfile, then committed config when lockfiles tie). Returns
151
+ * null when the directory has neither a declaration nor a lockfile, so a caller
152
+ * walking up keeps looking. An ambiguous directory reports `ambiguous: true`
153
+ * with the lockfiles that disagree, so a caller can name them.
154
+ * @param {string} dir
155
+ * @returns {(Omit<PackageManagerResolution, 'dir'> & {lockfiles: FoundLockfile[]}) | null}
156
+ */
157
+ export function decidePackageManagerIn(dir) {
158
+ const locks = lockfilesIn(dir);
159
+ const candidates = locks.map(lock => lock.pm);
160
+ const declared = declaredPackageManager(dir);
161
+
162
+ // The project declared one. Nothing on the filesystem outranks that.
163
+ if (declared) {
164
+ return {
165
+ pm: declared,
166
+ ambiguous: false,
167
+ candidates,
168
+ declared,
169
+ source: 'declared',
170
+ lockfiles: locks,
171
+ strayLockfiles: locks.filter(lock => lock.pm !== declared),
172
+ };
173
+ }
174
+
175
+ // One lockfile is unambiguous.
176
+ if (locks.length === 1) {
177
+ return {
178
+ pm: locks[0].pm,
179
+ ambiguous: false,
180
+ candidates,
181
+ declared: null,
182
+ source: 'lockfile',
183
+ lockfiles: locks,
184
+ strayLockfiles: [],
185
+ };
186
+ }
187
+
188
+ // Several lockfiles and no declaration: the filesystem cannot say. Only a
189
+ // file the project committed on purpose can.
190
+ if (locks.length > 1) {
191
+ const evidence = evidenceIn(dir).filter(pm => candidates.includes(pm));
192
+ if (evidence.length === 1) {
193
+ return {
194
+ pm: evidence[0],
195
+ ambiguous: false,
196
+ candidates,
197
+ declared: null,
198
+ source: 'evidence',
199
+ lockfiles: locks,
200
+ strayLockfiles: [],
201
+ };
202
+ }
203
+ return {
204
+ pm: 'npx',
205
+ ambiguous: true,
206
+ candidates,
207
+ declared: null,
208
+ source: 'none',
209
+ lockfiles: locks,
210
+ strayLockfiles: [],
211
+ };
212
+ }
213
+
214
+ return null;
215
+ }
216
+
147
217
  /**
148
218
  * Detect the project's package manager, with the reasoning attached.
149
219
  * Walks up from targetDir, taking the first directory that answers.
@@ -182,59 +252,16 @@ export function explainPackageManager(targetDir = process.cwd()) {
182
252
  const root = path.parse(dir).root;
183
253
 
184
254
  while (dir !== root) {
185
- const locks = lockfilesIn(dir);
186
- const candidates = locks.map(lock => lock.pm);
187
- const declared = declaredPackageManager(dir);
188
-
189
- // 1. The project declared one. Nothing on the filesystem outranks that.
190
- if (declared) {
255
+ const decision = decidePackageManagerIn(dir);
256
+ if (decision) {
191
257
  return {
192
- pm: declared,
193
- ambiguous: false,
194
- dir,
195
- candidates,
196
- declared,
197
- source: 'declared',
198
- strayLockfiles: locks.filter(lock => lock.pm !== declared),
199
- };
200
- }
201
-
202
- // 2. One lockfile is unambiguous.
203
- if (locks.length === 1) {
204
- return {
205
- pm: locks[0].pm,
206
- ambiguous: false,
258
+ pm: decision.pm,
259
+ ambiguous: decision.ambiguous,
207
260
  dir,
208
- candidates,
209
- declared: null,
210
- source: 'lockfile',
211
- strayLockfiles: [],
212
- };
213
- }
214
-
215
- // 3. Several lockfiles and no declaration: the filesystem cannot say.
216
- // Only a file the project committed on purpose can.
217
- if (locks.length > 1) {
218
- const evidence = evidenceIn(dir).filter(pm => candidates.includes(pm));
219
- if (evidence.length === 1) {
220
- return {
221
- pm: evidence[0],
222
- ambiguous: false,
223
- dir,
224
- candidates,
225
- declared: null,
226
- source: 'evidence',
227
- strayLockfiles: [],
228
- };
229
- }
230
- return {
231
- pm: 'npx',
232
- ambiguous: true,
233
- dir,
234
- candidates,
235
- declared: null,
236
- source: 'none',
237
- strayLockfiles: [],
261
+ candidates: decision.candidates,
262
+ declared: decision.declared,
263
+ source: decision.source,
264
+ strayLockfiles: decision.strayLockfiles,
238
265
  };
239
266
  }
240
267
 
@@ -279,11 +306,15 @@ export function detectPackageManager(targetDir = process.cwd()) {
279
306
  export function getRunPrefix(targetDir) {
280
307
  const pm = detectPackageManager(targetDir);
281
308
  switch (pm) {
282
- case 'yarn': return 'yarn';
283
- case 'pnpm': return 'pnpm exec';
284
- case 'bun': return 'bunx';
309
+ case 'yarn':
310
+ return 'yarn';
311
+ case 'pnpm':
312
+ return 'pnpm exec';
313
+ case 'bun':
314
+ return 'bunx';
285
315
  case 'npm':
286
- default: return 'npx';
316
+ default:
317
+ return 'npx';
287
318
  }
288
319
  }
289
320
 
@@ -310,11 +341,15 @@ export const CLI_BIN = 'astryx';
310
341
  export function getDlxPrefix(targetDir) {
311
342
  const resolution = explainPackageManager(targetDir);
312
343
  switch (resolution.pm) {
313
- case 'yarn': return isYarnClassic(resolution) ? 'npx' : 'yarn dlx';
314
- case 'pnpm': return 'pnpm dlx';
315
- case 'bun': return 'bunx';
344
+ case 'yarn':
345
+ return isYarnClassic(resolution) ? 'npx' : 'yarn dlx';
346
+ case 'pnpm':
347
+ return 'pnpm dlx';
348
+ case 'bun':
349
+ return 'bunx';
316
350
  case 'npm':
317
- default: return 'npx';
351
+ default:
352
+ return 'npx';
318
353
  }
319
354
  }
320
355
 
@@ -343,7 +378,9 @@ function isYarnClassic({dir}) {
343
378
  if (fs.existsSync(path.join(dir, '.yarnrc.yml'))) return false;
344
379
  if (fs.existsSync(path.join(dir, '.yarnrc'))) return true;
345
380
  }
346
- const agent = /^yarn\/(\d+)\./.exec(String(process.env.npm_config_user_agent ?? ''));
381
+ const agent = /^yarn\/(\d+)\./.exec(
382
+ String(process.env.npm_config_user_agent ?? ''),
383
+ );
347
384
  return agent ? agent[1] === '1' : false;
348
385
  }
349
386
 
@@ -354,8 +391,12 @@ function isYarnClassic({dir}) {
354
391
  */
355
392
  function declaredYarnMajor(dir) {
356
393
  try {
357
- const pkg = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf-8'));
358
- const match = /^yarn@(\d+)(?:[.+]|$)/.exec(String(pkg.packageManager ?? ''));
394
+ const pkg = JSON.parse(
395
+ fs.readFileSync(path.join(dir, 'package.json'), 'utf-8'),
396
+ );
397
+ const match = /^yarn@(\d+)(?:[.+]|$)/.exec(
398
+ String(pkg.packageManager ?? ''),
399
+ );
359
400
  return match ? Number(match[1]) : null;
360
401
  } catch {
361
402
  // Best-effort: no package.json, or an unreadable one.
@@ -465,7 +506,9 @@ export function getCliInvocation(targetDir) {
465
506
  * @returns {string}
466
507
  */
467
508
  export function formatCliCommand(command, targetDir) {
468
- const sub = String(command).replace(/^\s*astryx\b\s*/, '').trim();
509
+ const sub = String(command)
510
+ .replace(/^\s*astryx\b\s*/, '')
511
+ .trim();
469
512
  const stem = getCliInvocation(targetDir);
470
513
  return sub ? `${stem} ${sub}` : stem;
471
514
  }
@@ -196,7 +196,7 @@ export const doc = {
196
196
  {
197
197
  value: 'template.copy',
198
198
  description:
199
- "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.",
199
+ "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, or when several lockfiles leave the package manager undetermined). The envelope's package names the npm package that owns the template.",
200
200
  },
201
201
 
202
202
  {
@@ -349,6 +349,5 @@ export const doc = {
349
349
  description:
350
350
  'validated (false when no integration manifest was found, so nothing was inspected), the integration identity, structural issues, and Core doc overlaps. Each finding includes `severity` (`info` | `error`) and `relationship` (`replaces` | `extends` | `accidental`).',
351
351
  },
352
-
353
352
  ],
354
353
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.7.0-canary.e92e36f",
3
+ "version": "0.7.0-canary.ed07233",
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.7.0-canary.e92e36f",
105
- "@astryxdesign/core": "0.7.0-canary.e92e36f",
106
- "@astryxdesign/lab": "0.7.0-canary.e92e36f",
107
- "@astryxdesign/theme-neutral": "0.7.0-canary.e92e36f"
104
+ "@astryxdesign/charts": "0.7.0-canary.ed07233",
105
+ "@astryxdesign/core": "0.7.0-canary.ed07233",
106
+ "@astryxdesign/lab": "0.7.0-canary.ed07233",
107
+ "@astryxdesign/theme-neutral": "0.7.0-canary.ed07233"
108
108
  },
109
109
  "peerDependenciesMeta": {
110
110
  "@astryxdesign/charts": {
@@ -121,10 +121,10 @@
121
121
  }
122
122
  },
123
123
  "devDependencies": {
124
- "@astryxdesign/charts": "0.7.0-canary.e92e36f",
125
- "@astryxdesign/core": "0.7.0-canary.e92e36f",
126
- "@astryxdesign/lab": "0.7.0-canary.e92e36f",
127
- "@astryxdesign/theme-neutral": "0.7.0-canary.e92e36f",
124
+ "@astryxdesign/charts": "0.7.0-canary.ed07233",
125
+ "@astryxdesign/core": "0.7.0-canary.ed07233",
126
+ "@astryxdesign/lab": "0.7.0-canary.ed07233",
127
+ "@astryxdesign/theme-neutral": "0.7.0-canary.ed07233",
128
128
  "@heroicons/react": "^2.2.0",
129
129
  "@stylexjs/stylex": "^0.19.0",
130
130
  "@types/babel__core": "^7.20.5",