@astryxdesign/cli 0.7.4-canary.e5c5a87 → 0.7.4-canary.faa934f
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/api/doctor/built-checks.mjs +43 -13
- package/api/doctor/built-checks.test.mjs +29 -0
- package/api/doctor/doctor.doc.mjs +1 -1
- package/assets/discover/official-packages.json +16 -0
- package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +54 -0
- package/assets/templates/themes/butter/butterPalettes.generated.receipt.json +1499 -0
- package/assets/templates/themes/butter/butterPalettes.generated.ts +550 -0
- package/assets/templates/themes/butter/butterTheme.ts +274 -234
- package/assets/templates/themes/butter/palette.config.json +484 -0
- package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +41 -0
- package/assets/templates/themes/gothic/gothicPalettes.generated.receipt.json +979 -0
- package/assets/templates/themes/gothic/gothicPalettes.generated.ts +271 -0
- package/assets/templates/themes/gothic/gothicTheme.ts +130 -160
- package/assets/templates/themes/gothic/palette.config.json +371 -0
- package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +51 -0
- package/assets/templates/themes/matcha/matchaPalettes.generated.receipt.json +1502 -0
- package/assets/templates/themes/matcha/matchaPalettes.generated.ts +501 -0
- package/assets/templates/themes/matcha/matchaPalettes.ts +21 -0
- package/assets/templates/themes/matcha/matchaTheme.ts +164 -103
- package/assets/templates/themes/matcha/palette.config.json +448 -0
- package/assets/templates/themes/y2k/palette.config.json +166 -0
- package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +54 -0
- package/assets/templates/themes/y2k/y2kPalettes.generated.receipt.json +872 -0
- package/assets/templates/themes/y2k/y2kPalettes.generated.ts +550 -0
- package/assets/templates/themes/y2k/y2kPalettes.ts +257 -0
- package/assets/templates/themes/y2k/y2kTheme.ts +164 -391
- package/package.json +9 -9
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* built `.html` page or a source file), and the package names whose
|
|
10
10
|
* components count as Astryx: every `@astryxdesign/*` package and each
|
|
11
11
|
* integration the project loads (its component catalog's providers).
|
|
12
|
-
* @output `built-astryx-usage`: fails when the path holds no import from those
|
|
12
|
+
* @output `built-astryx-usage`: fails when the path holds no value import from those
|
|
13
13
|
* packages, no use of a component imported from them, and no Astryx
|
|
14
14
|
* stylesheet in built CSS or HTML. `built-astryx-purity`: warns with the
|
|
15
15
|
* findings of the source check in `astryx docs is-my-code-good` (raw
|
|
@@ -323,12 +323,17 @@ function astImports(ast) {
|
|
|
323
323
|
/** @type {{spec: string, names: string[], at: number}[]} */
|
|
324
324
|
const found = [];
|
|
325
325
|
for (const node of ast.program.body) {
|
|
326
|
+
// A type-only import or re-export is erased from the built page, so it
|
|
327
|
+
// is not Astryx use.
|
|
328
|
+
if (node.importKind === 'type' || node.exportKind === 'type') continue;
|
|
326
329
|
if (node.type === 'ImportDeclaration') {
|
|
330
|
+
const values = node.specifiers.filter(
|
|
331
|
+
(/** @type {any} */ each) => each.importKind !== 'type',
|
|
332
|
+
);
|
|
333
|
+
if (node.specifiers.length > 0 && values.length === 0) continue;
|
|
327
334
|
found.push({
|
|
328
335
|
spec: node.source.value,
|
|
329
|
-
names:
|
|
330
|
-
(/** @type {any} */ each) => each.local.name,
|
|
331
|
-
),
|
|
336
|
+
names: values.map((/** @type {any} */ each) => each.local.name),
|
|
332
337
|
at: node.start,
|
|
333
338
|
});
|
|
334
339
|
} else if (
|
|
@@ -336,6 +341,15 @@ function astImports(ast) {
|
|
|
336
341
|
node.type === 'ExportAllDeclaration') &&
|
|
337
342
|
node.source
|
|
338
343
|
) {
|
|
344
|
+
const specifiers = node.specifiers ?? [];
|
|
345
|
+
if (
|
|
346
|
+
specifiers.length > 0 &&
|
|
347
|
+
specifiers.every(
|
|
348
|
+
(/** @type {any} */ each) => each.exportKind === 'type',
|
|
349
|
+
)
|
|
350
|
+
) {
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
339
353
|
found.push({spec: node.source.value, names: [], at: node.start});
|
|
340
354
|
}
|
|
341
355
|
}
|
|
@@ -406,14 +420,26 @@ function importsOf(text) {
|
|
|
406
420
|
/** @type {{spec: string, names: string[], at: number}[]} */
|
|
407
421
|
const found = [];
|
|
408
422
|
const fromImport =
|
|
409
|
-
/\bimport\s+(
|
|
423
|
+
/\bimport\s+(type\s+)?([^'";]*?)\s+from\s+['"]([^'"]+)['"]|\bimport\s+['"]([^'"]+)['"]/g;
|
|
424
|
+
/** Whether every name in a `{…}` list is marked `type`. */
|
|
425
|
+
const allTypes = (/** @type {string} */ list) => {
|
|
426
|
+
const parts = list
|
|
427
|
+
.split(',')
|
|
428
|
+
.map(part => part.trim())
|
|
429
|
+
.filter(Boolean);
|
|
430
|
+
return parts.length > 0 && parts.every(part => /^type\s/.test(part));
|
|
431
|
+
};
|
|
410
432
|
for (const match of text.matchAll(fromImport)) {
|
|
411
433
|
const at = /** @type {number} */ (match.index);
|
|
412
|
-
if (match[
|
|
413
|
-
found.push({spec: match[
|
|
434
|
+
if (match[4]) {
|
|
435
|
+
found.push({spec: match[4], names: [], at});
|
|
414
436
|
continue;
|
|
415
437
|
}
|
|
416
|
-
|
|
438
|
+
// A type-only import is erased from the build, so it is not use.
|
|
439
|
+
if (match[1]) continue;
|
|
440
|
+
const clause = match[2];
|
|
441
|
+
const onlyBraces = /^\{([\s\S]*)\}$/.exec(clause.trim());
|
|
442
|
+
if (onlyBraces && allTypes(onlyBraces[1])) continue;
|
|
417
443
|
/** @type {string[]} */
|
|
418
444
|
const names = [];
|
|
419
445
|
const braces = /\{([\s\S]*)\}/.exec(clause);
|
|
@@ -433,14 +459,18 @@ function importsOf(text) {
|
|
|
433
459
|
const name = part.trim().replace(/^\*\s+as\s+/, '');
|
|
434
460
|
if (/^[A-Za-z_$][\w$]*$/.test(name)) names.push(name);
|
|
435
461
|
}
|
|
436
|
-
found.push({spec: match[
|
|
462
|
+
found.push({spec: match[3], names, at});
|
|
437
463
|
}
|
|
438
|
-
// A barrel that re-exports a package reaches it as an import does
|
|
464
|
+
// A barrel that re-exports a package reaches it as an import does; a
|
|
465
|
+
// type-only re-export is erased like a type-only import.
|
|
439
466
|
for (const match of text.matchAll(
|
|
440
|
-
/\bexport\s+(
|
|
467
|
+
/\bexport\s+(type\s+)?(\*(?:\s+as\s+[\w$]+)?|\{[^}]*\})\s*from\s+['"]([^'"]+)['"]/g,
|
|
441
468
|
)) {
|
|
469
|
+
if (match[1]) continue;
|
|
470
|
+
const list = /^\{([\s\S]*)\}$/.exec(match[2]);
|
|
471
|
+
if (list && allTypes(list[1])) continue;
|
|
442
472
|
found.push({
|
|
443
|
-
spec: match[
|
|
473
|
+
spec: match[3],
|
|
444
474
|
names: [],
|
|
445
475
|
at: /** @type {number} */ (match.index),
|
|
446
476
|
});
|
|
@@ -738,7 +768,7 @@ export function checkBuilt(target, {cwd, packages}) {
|
|
|
738
768
|
id: 'built-astryx-usage',
|
|
739
769
|
label: 'Built output uses Astryx',
|
|
740
770
|
status: 'fail',
|
|
741
|
-
message: `Read ${read}: no import from an Astryx package, no Astryx component, and no Astryx styles, so this output does not use Astryx.`,
|
|
771
|
+
message: `Read ${read}: no value import from an Astryx package (a type-only import is erased from the build), no Astryx component, and no Astryx styles, so this output does not use Astryx.`,
|
|
742
772
|
fix: `Rebuild the page from an Astryx template: run \`${formatCliCommand('build "<what the page is>"', cwd)}\`, scaffold the template it names, and fill it with Astryx components. Do not deliver this output.`,
|
|
743
773
|
};
|
|
744
774
|
const unreadNames =
|
|
@@ -425,6 +425,35 @@ describe('--built edge cases', () => {
|
|
|
425
425
|
expect(check('dist').usage.status).toBe('fail');
|
|
426
426
|
});
|
|
427
427
|
|
|
428
|
+
it('does not count a type-only Astryx import as use', () => {
|
|
429
|
+
write({
|
|
430
|
+
'src/Page.tsx': [
|
|
431
|
+
"import type {ButtonProps} from '@astryxdesign/core/Button';",
|
|
432
|
+
"import {type TextProps} from '@astryxdesign/core/Text';",
|
|
433
|
+
"export type {CardProps} from '@astryxdesign/core/Card';",
|
|
434
|
+
"export {type BadgeProps} from '@astryxdesign/core/Badge';",
|
|
435
|
+
'export const Page = (props: ButtonProps & TextProps) => null;',
|
|
436
|
+
'',
|
|
437
|
+
].join('\n'),
|
|
438
|
+
});
|
|
439
|
+
expect(check('src').usage.status).toBe('fail');
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
it('does not count a type-only import in a file the parser cannot read', () => {
|
|
443
|
+
write({
|
|
444
|
+
'src/Broken.tsx': [
|
|
445
|
+
"import type {ButtonProps} from '@astryxdesign/core/Button';",
|
|
446
|
+
"import {type TextProps} from '@astryxdesign/core/Text';",
|
|
447
|
+
"export type {CardProps} from '@astryxdesign/core/Card';",
|
|
448
|
+
"export {type BadgeProps} from '@astryxdesign/core/Badge';",
|
|
449
|
+
'export const B = () => <div>{</div>;',
|
|
450
|
+
'@@ enum ;',
|
|
451
|
+
'',
|
|
452
|
+
].join('\n'),
|
|
453
|
+
});
|
|
454
|
+
expect(check('src').usage.status).not.toBe('pass');
|
|
455
|
+
});
|
|
456
|
+
|
|
428
457
|
it('does not count an import written only in a string or JSX text', () => {
|
|
429
458
|
write({
|
|
430
459
|
'src/Page.tsx': [
|
|
@@ -41,7 +41,7 @@ export const doc = {
|
|
|
41
41
|
name: 'options.built',
|
|
42
42
|
type: 'string',
|
|
43
43
|
description:
|
|
44
|
-
'A finished build to check before you deliver it: a project folder, a build output folder, or one built `.html` file, relative to `cwd`. Adds two checks after the others. `built-astryx-usage` fails when the path holds no import from an Astryx package (any `@astryxdesign/*` package or an integration the project installs), no component imported from one, and no Astryx styles in built CSS or HTML. `built-astryx-purity` warns with the source check of `astryx docs is-my-code-good`: raw elements Astryx has a component for, raw SVG and icon-library icons, inline styles, classes, `stylex.create` and imported stylesheets, each with its file and line, in `.tsx` and `.jsx` files and JSX in `.js` source, found by parsing it; it is info, not inspected, when the path holds no source with JSX, such as a bundle. It reads at most 20,000 files, each up to 5 MB, skipping installs and version control; when either limit leaves source unread and nothing was found, the purity check is info, not fully inspected, and when the file limit ends the read before any Astryx turns up, `built-astryx-usage` warns that the rest went unread instead of failing. Given one built `.html` file, it also reads the local stylesheets and scripts that page links, finding a root-relative link from the nearest folder above the page that holds it; a linked file that is not there makes `built-astryx-usage` warn instead of fail. An empty folder fails with nothing checked, like a missing path. A source tree counts as using Astryx through an import, a re-export (`export … from`) or a stylesheet `@import` of an Astryx package. `--built` goes with `doctor` alone; a `doctor integration` check refuses it. A path that does not exist fails `built-astryx-usage` with nothing checked, and the purity check is left out. The integrations that count are the dependencies the nearest package.json above the path declares whose installed copy, found the way the CLI autolinks (a hoisted workspace copy included), has an integration manifest. The files under the path, and that configuration, are only read, never run. Without it, doctor runs exactly as before.',
|
|
44
|
+
'A finished build to check before you deliver it: a project folder, a build output folder, or one built `.html` file, relative to `cwd`. Adds two checks after the others. `built-astryx-usage` fails when the path holds no value import from an Astryx package (any `@astryxdesign/*` package or an integration the project installs), no component imported from one, and no Astryx styles in built CSS or HTML. `built-astryx-purity` warns with the source check of `astryx docs is-my-code-good`: raw elements Astryx has a component for, raw SVG and icon-library icons, inline styles, classes, `stylex.create` and imported stylesheets, each with its file and line, in `.tsx` and `.jsx` files and JSX in `.js` source, found by parsing it; it is info, not inspected, when the path holds no source with JSX, such as a bundle. It reads at most 20,000 files, each up to 5 MB, skipping installs and version control; when either limit leaves source unread and nothing was found, the purity check is info, not fully inspected, and when the file limit ends the read before any Astryx turns up, `built-astryx-usage` warns that the rest went unread instead of failing. Given one built `.html` file, it also reads the local stylesheets and scripts that page links, finding a root-relative link from the nearest folder above the page that holds it; a linked file that is not there makes `built-astryx-usage` warn instead of fail. An empty folder fails with nothing checked, like a missing path. A source tree counts as using Astryx through an import, a re-export (`export … from`) or a stylesheet `@import` of an Astryx package; a type-only import or re-export (`import type`, `export type`, or a list whose names are all `type`) does not count, since the build erases it. `--built` goes with `doctor` alone; a `doctor integration` check refuses it. A path that does not exist fails `built-astryx-usage` with nothing checked, and the purity check is left out. The integrations that count are the dependencies the nearest package.json above the path declares whose installed copy, found the way the CLI autolinks (a hoisted workspace copy included), has an integration manifest. The files under the path, and that configuration, are only read, never run. Without it, doctor runs exactly as before.',
|
|
45
45
|
},
|
|
46
46
|
],
|
|
47
47
|
returns: [
|
|
@@ -243,6 +243,22 @@
|
|
|
243
243
|
{
|
|
244
244
|
"kind": "template",
|
|
245
245
|
"name": "EmojiPickerShowcase"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"kind": "template",
|
|
249
|
+
"name": "ListInputBudgetAllocation"
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"kind": "template",
|
|
253
|
+
"name": "ListInputFamilyMembers"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"kind": "template",
|
|
257
|
+
"name": "ListInputMailingList"
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
"kind": "template",
|
|
261
|
+
"name": "ListInputShowcase"
|
|
246
262
|
}
|
|
247
263
|
]
|
|
248
264
|
},
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
// Generated from the committed full palette for the stops used by Butter's
|
|
4
|
+
// theme source. Regenerate with `pnpm generate:butter-palette-refs`.
|
|
5
|
+
// Keep the complete palette available for authoring and audits without
|
|
6
|
+
// making consumers pay for unused palette stops.
|
|
7
|
+
// prettier-ignore
|
|
8
|
+
export const butterPaletteRefs = {
|
|
9
|
+
purple: {
|
|
10
|
+
light: {25: '#52237b', 80: '#ddb9f6', 90: '#f2daff'},
|
|
11
|
+
dark: {25: '#52237b', 80: '#ddb9f6', 90: '#f2daff'},
|
|
12
|
+
},
|
|
13
|
+
green: {
|
|
14
|
+
light: {25: '#004a05', 70: '#7bbf7a', 80: '#a2d7a0', 85: '#b6e3b4', 90: '#caeec8'},
|
|
15
|
+
dark: {15: '#013004', 20: '#063c0a', 70: '#83bc82', 80: '#a8d4a6', 90: '#cdedcc'},
|
|
16
|
+
},
|
|
17
|
+
neutral: {
|
|
18
|
+
light: {0: '#000000', 15: '#1d1c11', 30: '#4a4732', 45: '#605f52', 55: '#79786a', 70: '#adac9e', 75: '#c7c4b2', 80: '#d6d3b8', 85: '#e5e3d4', 90: '#f3f2e2', 95: '#fdfbe4', 100: '#ffffff'},
|
|
19
|
+
dark: {0: '#000000', 5: '#131107', 10: '#261a13', 15: '#2e2117', 20: '#3a2a1f', 30: '#4a4732', 35: '#49473b', 40: '#725538', 45: '#605f52', 60: '#939184', 70: '#adac9e', 80: '#d6d3b8', 85: '#f0edd4', 90: '#f3f2e2', 95: '#fdfbe4', 100: '#ffffff'},
|
|
20
|
+
},
|
|
21
|
+
orange: {
|
|
22
|
+
light: {25: '#622e00', 80: '#f2bd81', 90: '#ffdcb6'},
|
|
23
|
+
dark: {25: '#622e00', 80: '#f2bd81', 90: '#ffdcb6'},
|
|
24
|
+
},
|
|
25
|
+
blue: {
|
|
26
|
+
light: {25: '#203a6c', 80: '#bdc5eb', 90: '#dbe1ff'},
|
|
27
|
+
dark: {25: '#203a6c', 80: '#bdc5eb', 90: '#dbe1ff'},
|
|
28
|
+
},
|
|
29
|
+
red: {
|
|
30
|
+
light: {10: '#3b0200', 25: '#6f1400', 30: '#821b00', 60: '#e56241', 80: '#ffb09b', 90: '#ffd9cf', 95: '#ffece7'},
|
|
31
|
+
dark: {15: '#4c0700', 25: '#6f1400', 80: '#ffb09b', 85: '#ffc5b5', 90: '#ffd9cf'},
|
|
32
|
+
},
|
|
33
|
+
yellow: {
|
|
34
|
+
light: {25: '#443c00', 30: '#514700', 70: '#bfae35', 80: '#dfcf5b', 85: '#f0df72', 90: '#fdee8c', 95: '#fff7c0'},
|
|
35
|
+
dark: {15: '#2c2600', 25: '#443c00', 70: '#bcae4e', 75: '#cdbe59', 85: '#eedf75', 90: '#fdee8c'},
|
|
36
|
+
},
|
|
37
|
+
teal: {
|
|
38
|
+
light: {25: '#00482d', 80: '#94d3bb', 90: '#b0f0d7'},
|
|
39
|
+
dark: {25: '#00482d', 80: '#94d3bb', 90: '#b0f0d7'},
|
|
40
|
+
},
|
|
41
|
+
accent: {
|
|
42
|
+
light: {35: '#194ce8', 40: '#225bff', 55: '#4d82ff'},
|
|
43
|
+
},
|
|
44
|
+
cyan: {
|
|
45
|
+
light: {25: '#004649', 80: '#8dd2d3', 90: '#a9eff0'},
|
|
46
|
+
dark: {25: '#004649', 80: '#8dd2d3', 90: '#a9eff0'},
|
|
47
|
+
},
|
|
48
|
+
pink: {
|
|
49
|
+
light: {25: '#6c0a68', 80: '#f0b3e8', 90: '#ffd5fb'},
|
|
50
|
+
dark: {25: '#6c0a68', 80: '#f0b3e8', 90: '#ffd5fb'},
|
|
51
|
+
},
|
|
52
|
+
} as const;
|
|
53
|
+
|
|
54
|
+
export default butterPaletteRefs;
|