@astryxdesign/cli 0.7.4 → 0.7.5-canary.07605c2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -18
- package/api/component/_adapter.mjs +16 -1
- package/api/component/component.test.mjs +31 -0
- package/api/discover/_adapter.d.mts +1 -1
- package/api/docs/_adapter.d.mts +5 -2
- package/api/docs/_adapter.mjs +24 -16
- package/api/docs/docs.test.mjs +18 -0
- package/api/docs/integrationDocs.test.mjs +2 -2
- package/api/experimental.d.mts +5 -0
- package/api/experimental.mjs +15 -0
- package/api/hook/list/list.d.mts +1 -1
- package/api/icon/_adapter.d.mts +3 -2
- package/api/icon/_adapter.mjs +16 -3
- package/api/icon/_authoring.d.mts +5 -1
- package/api/icon/_authoring.mjs +478 -63
- package/api/icon/_options.d.mts +11 -0
- package/api/icon/_options.mjs +39 -4
- package/api/icon/_records.d.mts +19 -0
- package/api/icon/_records.mjs +25 -0
- package/api/icon/add/add.d.mts +3 -3
- package/api/icon/add/add.mjs +227 -14
- package/api/icon/all-or-nothing.test.mjs +283 -0
- package/api/icon/detail/detail.mjs +2 -13
- package/api/icon/error-codes.test.mjs +14 -7
- package/api/icon/icon.d.mts +2 -2
- package/api/icon/icon.doc.mjs +30 -2
- package/api/icon/icon.mjs +57 -8
- package/api/icon/icon.test.mjs +133 -1
- package/api/icon/icon.type.d.mts +126 -1
- package/api/icon/icon.type.mjs +67 -3
- package/api/icon/iconAdd.doc.mjs +22 -6
- package/api/icon/iconMap.doc.mjs +24 -8
- package/api/icon/iconNewDefinition.doc.mjs +2 -2
- package/api/icon/iconNewSet.doc.mjs +30 -2
- package/api/icon/iconUse.doc.mjs +4 -1
- package/api/icon/map/map.d.mts +4 -4
- package/api/icon/map/map.mjs +134 -9
- package/api/icon/new-definition/new-definition.mjs +6 -2
- package/api/icon/new-set/new-set.mjs +2 -2
- package/api/icon/new-set/new-set.test.mjs +60 -10
- package/api/icon/option-pairs.test.mjs +368 -0
- package/api/icon/search/search.d.mts +10 -0
- package/api/icon/search/search.mjs +55 -14
- package/api/icon/use/use.mjs +2 -13
- package/api/integration/add-helpers.d.mts +15 -1
- package/api/integration/add-helpers.mjs +1 -1
- package/api/integration/pack-check.lifecycle-output.test.mjs +24 -1
- package/api/integration/pack-check.mjs +10 -4
- package/api/integration/pack-check.test.mjs +5 -1
- package/api/integration/validate-integration.type.d.mts +3 -2
- package/api/integration/validate-integration.type.mjs +3 -2
- package/api/render/_adapter.d.mts +28 -0
- package/api/render/_adapter.mjs +540 -0
- package/api/render/render.d.mts +15 -0
- package/api/render/render.doc.d.mts +9 -0
- package/api/render/render.doc.mjs +112 -0
- package/api/render/render.mjs +113 -0
- package/api/render/render.test.mjs +1155 -0
- package/api/render/render.type.d.mts +74 -0
- package/api/render/render.type.mjs +64 -0
- package/api/search/_adapter.test.mjs +21 -2
- package/api/search/_result.d.mts +5 -5
- package/api/search/search.d.mts +1 -1
- package/api/template/template.mjs +3 -1
- package/api/template/template.type.d.mts +2 -1
- package/api/template/template.type.mjs +1 -1
- package/api/template/unknown-name.test.mjs +63 -0
- package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +123 -70
- package/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs +19 -77
- package/assets/discover/official-packages.json +4 -0
- package/assets/docs/tree/icon-definitions.doc.mjs +2 -2
- package/assets/docs/tree/icon-set-files.doc.mjs +1 -1
- package/assets/docs/tree/icon-sets.doc.mjs +50 -20
- package/assets/docs/tree/render-pages.doc.mjs +94 -0
- package/assets/icons/definitions/activity.doc.mjs +1 -1
- package/assets/icons/definitions/alignCenter.doc.mjs +9 -0
- package/assets/icons/definitions/alignEnd.doc.mjs +10 -0
- package/assets/icons/definitions/alignStart.doc.mjs +10 -0
- package/assets/icons/definitions/archive.doc.mjs +1 -1
- package/assets/icons/definitions/arrowsUpDown.doc.mjs +1 -1
- package/assets/icons/definitions/attach.doc.mjs +1 -1
- package/assets/icons/definitions/audio.doc.mjs +1 -1
- package/assets/icons/definitions/cart.doc.mjs +1 -1
- package/assets/icons/definitions/checkDouble.doc.mjs +1 -1
- package/assets/icons/definitions/chevronsLeft.doc.mjs +1 -1
- package/assets/icons/definitions/chevronsRight.doc.mjs +1 -1
- package/assets/icons/definitions/close.doc.mjs +1 -1
- package/assets/icons/definitions/collapse.doc.mjs +1 -1
- package/assets/icons/definitions/compose.doc.mjs +1 -1
- package/assets/icons/definitions/conversation.doc.mjs +1 -1
- package/assets/icons/definitions/copy.doc.mjs +1 -1
- package/assets/icons/definitions/cpu.doc.mjs +9 -0
- package/assets/icons/definitions/database.doc.mjs +1 -1
- package/assets/icons/definitions/desktop.doc.mjs +1 -1
- package/assets/icons/definitions/discount.doc.mjs +1 -1
- package/assets/icons/definitions/download.doc.mjs +1 -1
- package/assets/icons/definitions/emoji.doc.mjs +1 -1
- package/assets/icons/definitions/error.doc.mjs +1 -1
- package/assets/icons/definitions/expand.doc.mjs +1 -1
- package/assets/icons/definitions/experiment.doc.mjs +1 -1
- package/assets/icons/definitions/externalLink.doc.mjs +7 -1
- package/assets/icons/definitions/eyeSlash.doc.mjs +1 -1
- package/assets/icons/definitions/flipHorizontal.doc.mjs +9 -0
- package/assets/icons/definitions/flipVertical.doc.mjs +9 -0
- package/assets/icons/definitions/folderAdd.doc.mjs +1 -1
- package/assets/icons/definitions/gitBranch.doc.mjs +9 -0
- package/assets/icons/definitions/gitFork.doc.mjs +9 -0
- package/assets/icons/definitions/info.doc.mjs +1 -1
- package/assets/icons/definitions/location.doc.mjs +1 -1
- package/assets/icons/definitions/mention.doc.mjs +1 -1
- package/assets/icons/definitions/menu.doc.mjs +1 -1
- package/assets/icons/definitions/microphone.doc.mjs +1 -1
- package/assets/icons/definitions/mobile.doc.mjs +1 -1
- package/assets/icons/definitions/money.doc.mjs +1 -1
- package/assets/icons/definitions/moreHorizontal.doc.mjs +1 -1
- package/assets/icons/definitions/notificationActive.doc.mjs +1 -1
- package/assets/icons/definitions/notificationOff.doc.mjs +1 -1
- package/assets/icons/definitions/panelLeft.doc.mjs +10 -0
- package/assets/icons/definitions/panelRight.doc.mjs +10 -0
- package/assets/icons/definitions/raiseHand.doc.mjs +1 -1
- package/assets/icons/definitions/redo.doc.mjs +1 -1
- package/assets/icons/definitions/refresh.doc.mjs +1 -1
- package/assets/icons/definitions/rotate.doc.mjs +9 -0
- package/assets/icons/definitions/scale.doc.mjs +10 -0
- package/assets/icons/definitions/search.doc.mjs +1 -1
- package/assets/icons/definitions/send.doc.mjs +1 -1
- package/assets/icons/definitions/settings.doc.mjs +1 -1
- package/assets/icons/definitions/star.doc.mjs +1 -1
- package/assets/icons/definitions/stop.doc.mjs +1 -1
- package/assets/icons/definitions/success.doc.mjs +1 -1
- package/assets/icons/definitions/textCase.doc.mjs +9 -0
- package/assets/icons/definitions/thumbsDown.doc.mjs +1 -1
- package/assets/icons/definitions/thumbsUp.doc.mjs +1 -1
- package/assets/icons/definitions/trendDown.doc.mjs +7 -1
- package/assets/icons/definitions/trendUp.doc.mjs +1 -1
- package/assets/icons/definitions/undo.doc.mjs +1 -1
- package/assets/icons/definitions/upload.doc.mjs +1 -1
- package/assets/icons/definitions/userAdd.doc.mjs +1 -1
- package/assets/icons/definitions/warning.doc.mjs +1 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx +15 -14
- package/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx +30 -30
- package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +15 -14
- package/assets/templates/blocks/components/Tokenizer/TokenizerIcon.tsx +15 -14
- package/assets/templates/blocks/components/Tokenizer/TokenizerMaxEntries.tsx +17 -16
- package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx +29 -29
- package/assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx +9 -8
- package/assets/templates/blocks/components/Tokenizer/TokenizerStates.tsx +39 -41
- package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -0
- package/assets/templates/pages/form-wizard-inline/template.doc.mjs +6 -1
- package/assets/templates/pages/table-comparison/template.doc.mjs +1 -0
- package/assets/templates/pages/table-tree/template.doc.mjs +3 -0
- package/authoring/debug/parse.d.mts +2 -2
- package/authoring/doctypes/icon-definition/icon-definition.doc.mjs +4 -4
- package/authoring/doctypes/icon-set/icon-set-data.doc.mjs +6 -0
- package/authoring/doctypes/icon-set/parse.d.mts +1 -0
- package/authoring/doctypes/icon-set/parse.mjs +1 -0
- package/authoring/doctypes/icon-set/type.ts +5 -0
- package/authoring/doctypes/template/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +2 -1
- package/clients/cli/commands/doctor.mjs +16 -17
- package/clients/cli/commands/experimental/icon.mjs +167 -35
- package/clients/cli/commands/experimental/index.mjs +2 -0
- package/clients/cli/commands/experimental/render.mjs +113 -0
- package/clients/cli/commands/experimental-icon-add.doc.mjs +14 -4
- package/clients/cli/commands/experimental-icon-map.doc.mjs +12 -2
- package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon-new-set.doc.mjs +28 -1
- package/clients/cli/commands/experimental-icon.doc.mjs +18 -2
- package/clients/cli/commands/experimental-render.doc.mjs +60 -0
- package/clients/cli/commands/experimental.doc.mjs +4 -2
- package/clients/cli/commands/icon-authoring.test.mjs +1823 -13
- package/clients/cli/commands/icon-options-wiring.test.mjs +158 -0
- package/clients/cli/commands/icon.test.mjs +1 -1
- package/clients/cli/commands/template.mjs +4 -1
- package/clients/cli/commands/text-json-parity.test.mjs +46 -0
- package/clients/cli/index.mjs +1 -0
- package/foundation/discovery/component-discovery.d.mts +2 -1
- package/foundation/discovery/component-discovery.export-names.test.mjs +41 -0
- package/foundation/discovery/component-discovery.mjs +13 -7
- package/foundation/discovery/icon-set-checks.d.mts +43 -9
- package/foundation/discovery/icon-set-checks.mjs +296 -21
- package/foundation/discovery/icon-set-checks.test.mjs +125 -12
- package/foundation/discovery/icon-set-writer.d.mts +192 -3
- package/foundation/discovery/icon-set-writer.mjs +608 -34
- package/foundation/discovery/icon-set-writer.test.mjs +26 -0
- package/foundation/discovery/module-exports.mjs +82 -25
- package/foundation/discovery/module-exports.test.mjs +38 -1
- package/foundation/discovery/package-exports.d.mts +13 -0
- package/foundation/discovery/package-exports.mjs +40 -1
- package/foundation/discovery/template-icons.d.mts +6 -0
- package/foundation/discovery/template-icons.mjs +98 -10
- package/foundation/discovery/template-icons.test.mjs +103 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +20 -5
- package/foundation/doc-compiler/import.mjs +81 -8
- package/foundation/doc-compiler/read.d.mts +4 -3
- package/foundation/doc-compiler/read.mjs +15 -10
- package/foundation/doc-compiler/read.test.mjs +59 -1
- package/foundation/doc-compiler/tree.mjs +3 -1
- package/foundation/fs/module-loader.d.mts +3 -2
- package/foundation/fs/module-loader.mjs +3 -2
- package/foundation/fs/publish-file-eperm-mutation.test.mjs +2 -0
- package/foundation/fs/read-record.d.mts +27 -0
- package/foundation/fs/read-record.mjs +83 -15
- package/foundation/fs/read-record.test.mjs +88 -1
- package/foundation/render/assets.d.mts +31 -0
- package/foundation/render/assets.mjs +102 -0
- package/foundation/render/component-map.d.mts +52 -0
- package/foundation/render/component-map.mjs +141 -0
- package/foundation/render/css-cut.d.mts +29 -0
- package/foundation/render/css-cut.mjs +144 -0
- package/foundation/render/embedded-files.d.mts +28 -0
- package/foundation/render/embedded-files.mjs +108 -0
- package/foundation/render/embedded-imports.d.mts +61 -0
- package/foundation/render/embedded-imports.mjs +315 -0
- package/foundation/render/html-reader.d.mts +37 -0
- package/foundation/render/html-reader.mjs +121 -0
- package/foundation/render/page-worker.d.mts +7 -0
- package/foundation/render/page-worker.mjs +519 -0
- package/foundation/render/rebuild.d.mts +19 -0
- package/foundation/render/rebuild.mjs +269 -0
- package/foundation/render/render-page.d.mts +85 -0
- package/foundation/render/render-page.mjs +612 -0
- package/foundation/render/render.test.mjs +117 -0
- package/foundation/render/source-block.d.mts +52 -0
- package/foundation/render/source-block.mjs +106 -0
- package/foundation/response/error-codes.d.mts +10 -1
- package/foundation/response/error-codes.doc.mjs +56 -0
- package/foundation/response/error-codes.mjs +61 -0
- package/foundation/response/response-types.doc.mjs +38 -1
- package/foundation/text/string-utils.mjs +33 -0
- package/foundation/text/string-utils.test.mjs +17 -0
- package/foundation/text/suggest-order.d.mts +17 -3
- package/foundation/text/suggest-order.mjs +58 -13
- package/foundation/text/suggest-order.test.mjs +53 -0
- package/package.json +14 -9
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
export type RenderOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* - Folder relative paths resolve from (default: process.cwd()).
|
|
7
|
+
*/
|
|
8
|
+
cwd?: string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* - The file to write. Rendering: an .html file (default: the page's name with .html). Reversing: a page module (default: inside a new folder beside the HTML file, named after it, such as `report-restored/`).
|
|
11
|
+
*/
|
|
12
|
+
out?: string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* - Turn a rendered HTML file back into a page module.
|
|
15
|
+
*/
|
|
16
|
+
reverse?: boolean | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* - The rendered page's title (default: its first heading, else the file name). Rendering only.
|
|
19
|
+
*/
|
|
20
|
+
title?: string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* - Replace the existing page module when reversing (never a protected file, and never a file other than the page, which always goes into a new folder). Rendering replaces an existing HTML file only when a render wrote it.
|
|
23
|
+
*/
|
|
24
|
+
overwrite?: boolean | undefined;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Something the render noticed that may make the page differ from what its
|
|
28
|
+
* author meant.
|
|
29
|
+
*/
|
|
30
|
+
export type RenderWarning = {
|
|
31
|
+
/**
|
|
32
|
+
* - What kind of problem.
|
|
33
|
+
*/
|
|
34
|
+
code: "dropped-children" | "remote-asset" | "missing-asset" | "page-output" | "page-script" | "no-astryx-styles" | "chart-size" | "not-embedded";
|
|
35
|
+
/**
|
|
36
|
+
* - What happened and what to do, in one sentence.
|
|
37
|
+
*/
|
|
38
|
+
message: string;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* `astryx --json experimental render <page>`.
|
|
42
|
+
*/
|
|
43
|
+
export type RenderPageResponse = {
|
|
44
|
+
type: "render.page";
|
|
45
|
+
data: {
|
|
46
|
+
input: string;
|
|
47
|
+
output: string;
|
|
48
|
+
bytes: number;
|
|
49
|
+
files: string[];
|
|
50
|
+
stylesheets: string[];
|
|
51
|
+
classes: number;
|
|
52
|
+
cssBytes: number;
|
|
53
|
+
images: number;
|
|
54
|
+
warnings: RenderWarning[];
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* `astryx --json experimental render --reverse <file.html>`.
|
|
59
|
+
*/
|
|
60
|
+
export type RenderReverseResponse = {
|
|
61
|
+
type: "render.reverse";
|
|
62
|
+
data: {
|
|
63
|
+
input: string;
|
|
64
|
+
mode: "embedded" | "rebuilt";
|
|
65
|
+
output: string;
|
|
66
|
+
files: string[];
|
|
67
|
+
exact: boolean;
|
|
68
|
+
missing?: string[] | undefined;
|
|
69
|
+
components?: string[] | undefined;
|
|
70
|
+
elements?: number | undefined;
|
|
71
|
+
unknown?: string[] | undefined;
|
|
72
|
+
omitted?: string[] | undefined;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Colocated types for `astryx experimental render`: the source of truth
|
|
5
|
+
* for its response shapes.
|
|
6
|
+
*
|
|
7
|
+
* @position api/render — typedefs for api/render/render.mjs
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @experimental May change or be removed in a patch release.
|
|
12
|
+
* @typedef {object} RenderOptions
|
|
13
|
+
* @property {string} [cwd] - Folder relative paths resolve from (default: process.cwd()).
|
|
14
|
+
* @property {string} [out] - The file to write. Rendering: an .html file (default: the page's name with .html). Reversing: a page module (default: inside a new folder beside the HTML file, named after it, such as `report-restored/`).
|
|
15
|
+
* @property {boolean} [reverse] - Turn a rendered HTML file back into a page module.
|
|
16
|
+
* @property {string} [title] - The rendered page's title (default: its first heading, else the file name). Rendering only.
|
|
17
|
+
* @property {boolean} [overwrite] - Replace the existing page module when reversing (never a protected file, and never a file other than the page, which always goes into a new folder). Rendering replaces an existing HTML file only when a render wrote it.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Something the render noticed that may make the page differ from what its
|
|
22
|
+
* author meant.
|
|
23
|
+
* @experimental May change or be removed in a patch release.
|
|
24
|
+
* @typedef {object} RenderWarning
|
|
25
|
+
* @property {'dropped-children' | 'remote-asset' | 'missing-asset' | 'page-output' | 'page-script' | 'no-astryx-styles' | 'chart-size' | 'not-embedded'} code - What kind of problem.
|
|
26
|
+
* @property {string} message - What happened and what to do, in one sentence.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* `astryx --json experimental render <page>`.
|
|
31
|
+
* @experimental May change or be removed in a patch release.
|
|
32
|
+
* @typedef {object} RenderPageResponse
|
|
33
|
+
* @property {'render.page'} type
|
|
34
|
+
* @property {object} data
|
|
35
|
+
* @property {string} data.input - The page module, relative to cwd when inside it.
|
|
36
|
+
* @property {string} data.output - The HTML file written.
|
|
37
|
+
* @property {number} data.bytes - Size of the HTML file.
|
|
38
|
+
* @property {string[]} data.files - Local files the page loaded (modules, stylesheets, images, JSON), relative to the folder that holds them all (the page's folder unless it imports from above it), page first; each is embedded so --reverse can give it back.
|
|
39
|
+
* @property {string[]} data.stylesheets - Package stylesheets that were cut to the rules the page uses and inlined.
|
|
40
|
+
* @property {number} data.classes - Distinct class names in the markup.
|
|
41
|
+
* @property {number} data.cssBytes - Size of the inlined CSS.
|
|
42
|
+
* @property {number} data.images - Local files inlined as data: URIs.
|
|
43
|
+
* @property {RenderWarning[]} data.warnings - Empty when nothing looked wrong.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* `astryx --json experimental render --reverse <file.html>`.
|
|
48
|
+
* @experimental May change or be removed in a patch release.
|
|
49
|
+
* @typedef {object} RenderReverseResponse
|
|
50
|
+
* @property {'render.reverse'} type
|
|
51
|
+
* @property {object} data
|
|
52
|
+
* @property {string} data.input - The HTML file read.
|
|
53
|
+
* @property {'embedded' | 'rebuilt'} data.mode - `embedded`: the file carried its source, written back byte for byte. `rebuilt`: rebuilt from Astryx markup (text and layout only).
|
|
54
|
+
* @property {string} data.output - The page module written: `out`, or by default inside a new folder beside the HTML file named after it (`report.html` gives `report-restored/`).
|
|
55
|
+
* @property {string[]} data.files - Every file written, page first.
|
|
56
|
+
* @property {boolean} data.exact - Whether the page and every file it imports came back exactly as rendered.
|
|
57
|
+
* @property {string[]} [data.missing] - Embedded only: relative imports the file did not carry (files a render never embeds), so the restored page needs them before it renders.
|
|
58
|
+
* @property {string[]} [data.components] - Rebuilt only: the components the page uses.
|
|
59
|
+
* @property {number} [data.elements] - Rebuilt only: how many component elements were rebuilt.
|
|
60
|
+
* @property {string[]} [data.unknown] - Rebuilt only: Astryx class names no installed component claims; their content is kept as plain elements.
|
|
61
|
+
* @property {string[]} [data.omitted] - Rebuilt only: component kinds left out because the markup cannot give them back (such as icons).
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
export {};
|
|
@@ -85,7 +85,7 @@ describe('gatherCandidatesReused', () => {
|
|
|
85
85
|
);
|
|
86
86
|
|
|
87
87
|
it(
|
|
88
|
-
'gathers again when a file the gather read changes, in a linked package too',
|
|
88
|
+
'gathers again when a file the gather read or imported changes, in a linked package too',
|
|
89
89
|
async () => {
|
|
90
90
|
// A consumer whose integration is a symlink to a package folder
|
|
91
91
|
// elsewhere, as a workspace package is.
|
|
@@ -162,7 +162,26 @@ describe('gatherCandidatesReused', () => {
|
|
|
162
162
|
// An edited file the gather read: the linked package's manifest.
|
|
163
163
|
const later = new Date(Date.now() + 5_000);
|
|
164
164
|
fs.utimesSync(path.join(pkg, 'package.json'), later, later);
|
|
165
|
-
|
|
165
|
+
const third = await gatherCandidatesReused(options);
|
|
166
|
+
expect(third).not.toBe(second);
|
|
167
|
+
|
|
168
|
+
// An edited doc the gather imported: the next gather reads its new
|
|
169
|
+
// content, not the module this process imported first.
|
|
170
|
+
fs.writeFileSync(
|
|
171
|
+
path.join(pkg, 'components', 'FancyGizmo.doc.mjs'),
|
|
172
|
+
`export default {
|
|
173
|
+
type: 'component',
|
|
174
|
+
name: 'FancyGizmo',
|
|
175
|
+
keywords: ['gizmo'],
|
|
176
|
+
usage: {description: 'A shinier part, now with sprockets.'},
|
|
177
|
+
props: [],
|
|
178
|
+
};\n`,
|
|
179
|
+
);
|
|
180
|
+
const fourth = await gatherCandidatesReused(options);
|
|
181
|
+
expect(fourth).not.toBe(third);
|
|
182
|
+
expect(
|
|
183
|
+
JSON.stringify(fourth.all.find(c => c.name === 'FancyGizmo')),
|
|
184
|
+
).toContain('A shinier part, now with sprockets.');
|
|
166
185
|
} finally {
|
|
167
186
|
fs.rmSync(dir, {recursive: true, force: true});
|
|
168
187
|
fs.rmSync(pkg, {recursive: true, force: true});
|
package/api/search/_result.d.mts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* (spec AST-081 FR3).
|
|
18
18
|
*/
|
|
19
19
|
export function toResult(c: Candidate, score: number, reason: string, matchedTerms: number, queryTerms: number, outside?: boolean): {
|
|
20
|
-
domain: "
|
|
20
|
+
domain: "template" | "component" | "hook" | "theme" | "doc";
|
|
21
21
|
name: string;
|
|
22
22
|
package: string | undefined;
|
|
23
23
|
score: number;
|
|
@@ -26,7 +26,7 @@ export function toResult(c: Candidate, score: number, reason: string, matchedTer
|
|
|
26
26
|
} | {
|
|
27
27
|
import: string | undefined;
|
|
28
28
|
command: string;
|
|
29
|
-
domain: "
|
|
29
|
+
domain: "template" | "component" | "hook" | "theme" | "doc";
|
|
30
30
|
name: string;
|
|
31
31
|
package: string | undefined;
|
|
32
32
|
score: number;
|
|
@@ -38,7 +38,7 @@ export function toResult(c: Candidate, score: number, reason: string, matchedTer
|
|
|
38
38
|
command: string;
|
|
39
39
|
section?: string | undefined;
|
|
40
40
|
name: string;
|
|
41
|
-
domain: "
|
|
41
|
+
domain: "template" | "component" | "hook" | "theme" | "doc";
|
|
42
42
|
package: string | undefined;
|
|
43
43
|
score: number;
|
|
44
44
|
reason: string;
|
|
@@ -47,7 +47,7 @@ export function toResult(c: Candidate, score: number, reason: string, matchedTer
|
|
|
47
47
|
displayName: string | undefined;
|
|
48
48
|
kind: "page" | "block" | undefined;
|
|
49
49
|
command: string;
|
|
50
|
-
domain: "
|
|
50
|
+
domain: "template" | "component" | "hook" | "theme" | "doc";
|
|
51
51
|
name: string;
|
|
52
52
|
package: string | undefined;
|
|
53
53
|
score: number;
|
|
@@ -56,7 +56,7 @@ export function toResult(c: Candidate, score: number, reason: string, matchedTer
|
|
|
56
56
|
} | {
|
|
57
57
|
displayName: string | undefined;
|
|
58
58
|
command: string;
|
|
59
|
-
domain: "
|
|
59
|
+
domain: "template" | "component" | "hook" | "theme" | "doc";
|
|
60
60
|
name: string;
|
|
61
61
|
package: string | undefined;
|
|
62
62
|
score: number;
|
package/api/search/search.d.mts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
export function search(query: string, options?: {
|
|
15
15
|
cwd?: string | undefined;
|
|
16
|
-
type?: "
|
|
16
|
+
type?: "template" | "component" | "hook" | "theme" | "doc" | undefined;
|
|
17
17
|
limit?: number | undefined;
|
|
18
18
|
}): Promise<import("./search.type.mjs").SearchResponse>;
|
|
19
19
|
/**
|
|
@@ -190,7 +190,9 @@ export async function template(name, options = {}) {
|
|
|
190
190
|
if (name && candidates.length === 0) {
|
|
191
191
|
throw new AstryxError(
|
|
192
192
|
`Unknown template "${name}"`,
|
|
193
|
-
orderByAffinity(name, templates, t => [t.dirName, t.name]
|
|
193
|
+
orderByAffinity(name, templates, t => [t.dirName, t.name], {
|
|
194
|
+
closest: true,
|
|
195
|
+
}).map(t => ({
|
|
194
196
|
name: t.dirName,
|
|
195
197
|
reason: `${t.type} template`,
|
|
196
198
|
})),
|
|
@@ -131,7 +131,7 @@ export type TemplateIconsReport = {
|
|
|
131
131
|
*/
|
|
132
132
|
reason: string;
|
|
133
133
|
/**
|
|
134
|
-
* Icons rewritten to the project's set, and the rule that chose each one: a reviewed `exact` or `strong` match, or the icon the set's `map` names for the icon definition the template declares.
|
|
134
|
+
* Icons rewritten to the project's set, and the rule that chose each one: a reviewed `exact` or `strong` match, or the icon the set's `map` names for the icon definition the template declares. `dropped` names the library's sizing props (`size`, `strokeWidth`, `absoluteStrokeWidth`) removed from the icon's elements: an icon set's icons take their size from CSS.
|
|
135
135
|
*/
|
|
136
136
|
mapped: Array<{
|
|
137
137
|
source: {
|
|
@@ -146,6 +146,7 @@ export type TemplateIconsReport = {
|
|
|
146
146
|
export: string;
|
|
147
147
|
};
|
|
148
148
|
by: "match" | "definition";
|
|
149
|
+
dropped?: string[];
|
|
149
150
|
}>;
|
|
150
151
|
/**
|
|
151
152
|
* Icons left as the template wrote them, with why, and a `likely` reviewed match as a suggestion when the project set has one. Every declared key is mapped or kept; `module` is null for a key the template does not import, and `export` is `default` for a default import and `*` for a namespace import.
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
* @property {'selected' | 'none' | 'ambiguous' | 'missing' | 'withdrawn'} status The project's icon-set state.
|
|
97
97
|
* @property {string | null} set The project's icon set as `<package>/<set>`, when selected.
|
|
98
98
|
* @property {string} reason Why the project has that set, or none.
|
|
99
|
-
* @property {Array<{source: {module: string, export: string}, target: {set: string, package: string, id: string, module: string, export: string}, by: 'match' | 'definition'}>} mapped Icons rewritten to the project's set, and the rule that chose each one: a reviewed `exact` or `strong` match, or the icon the set's `map` names for the icon definition the template declares.
|
|
99
|
+
* @property {Array<{source: {module: string, export: string}, target: {set: string, package: string, id: string, module: string, export: string}, by: 'match' | 'definition', dropped?: string[]}>} mapped Icons rewritten to the project's set, and the rule that chose each one: a reviewed `exact` or `strong` match, or the icon the set's `map` names for the icon definition the template declares. `dropped` names the library's sizing props (`size`, `strokeWidth`, `absoluteStrokeWidth`) removed from the icon's elements: an icon set's icons take their size from CSS.
|
|
100
100
|
* @property {Array<{module: string | null, export: string, reason: string, suggestion?: {set: string, id: string, module: string, export: string, confidence: 'likely'}}>} kept Icons left as the template wrote them, with why, and a `likely` reviewed match as a suggestion when the project set has one. Every declared key is mapped or kept; `module` is null for a key the template does not import, and `export` is `default` for a default import and `*` for a namespace import.
|
|
101
101
|
*/
|
|
102
102
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The suggestions an unknown template name prints: the closest
|
|
5
|
+
* templates first, and the list stops where the matches get weaker. A name
|
|
6
|
+
* that shares no word with any template still lists every template.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {describe, it, expect} from 'vitest';
|
|
10
|
+
import * as path from 'node:path';
|
|
11
|
+
import {fileURLToPath} from 'node:url';
|
|
12
|
+
import {template} from './template.mjs';
|
|
13
|
+
import {nameWords} from '../../foundation/text/suggest-order.mjs';
|
|
14
|
+
|
|
15
|
+
const cwd = path.resolve(
|
|
16
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
17
|
+
'../../../..',
|
|
18
|
+
);
|
|
19
|
+
const SLOW = 30_000;
|
|
20
|
+
|
|
21
|
+
/** @param {string} name */
|
|
22
|
+
async function suggested(name) {
|
|
23
|
+
const error = await template(name, {cwd}).catch(e => e);
|
|
24
|
+
expect(error.code).toBe('ERR_UNKNOWN_TEMPLATE');
|
|
25
|
+
return error.suggestions.map((/** @type {{name: string}} */ s) => s.name);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
describe('unknown template suggestions', () => {
|
|
29
|
+
it(
|
|
30
|
+
'lists only templates that carry the typed words when one carries them all',
|
|
31
|
+
async () => {
|
|
32
|
+
const all = await suggested('zzqx-nothing-like-it');
|
|
33
|
+
const near = await suggested('settings-panel');
|
|
34
|
+
expect(near.length).toBeGreaterThan(0);
|
|
35
|
+
expect(near.length).toBeLessThan(all.length);
|
|
36
|
+
for (const name of near.slice(1)) {
|
|
37
|
+
const words = nameWords(name);
|
|
38
|
+
expect(words).toContain('setting');
|
|
39
|
+
expect(words).toContain('panel');
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
SLOW,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
it(
|
|
46
|
+
'does not narrow the list on a one-letter word',
|
|
47
|
+
async () => {
|
|
48
|
+
const all = await suggested('zzqx-nothing-like-it');
|
|
49
|
+
expect(await suggested('a11y')).toHaveLength(all.length);
|
|
50
|
+
},
|
|
51
|
+
SLOW,
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
it(
|
|
55
|
+
'lists every template when no template shares a word with the name',
|
|
56
|
+
async () => {
|
|
57
|
+
const all = await suggested('zzqx-nothing-like-it');
|
|
58
|
+
expect(new Set(all).size).toBe(all.length);
|
|
59
|
+
expect(all.length).toBeGreaterThan(100);
|
|
60
|
+
},
|
|
61
|
+
SLOW,
|
|
62
|
+
);
|
|
63
|
+
});
|
|
@@ -1,95 +1,148 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import * as fs from 'node:fs';
|
|
4
|
+
import * as os from 'node:os';
|
|
5
|
+
import * as path from 'node:path';
|
|
6
|
+
import {afterAll, describe, expect, it} from 'vitest';
|
|
7
|
+
import transform, {meta} from '../validate-data-token-ownership.mjs';
|
|
8
|
+
import {upgrade} from '../../../../../api/upgrade/upgrade.mjs';
|
|
5
9
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const SLOW = 30_000;
|
|
11
|
+
const tempRoots = [];
|
|
12
|
+
|
|
13
|
+
afterAll(() => {
|
|
14
|
+
for (const root of tempRoots) fs.rmSync(root, {recursive: true, force: true});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const STALE_THEME = `/* @generated by \`astryx theme build\` */
|
|
18
|
+
@layer astryx-base {
|
|
19
|
+
:root { --color-data-categorical-green: #008000; }
|
|
20
|
+
}`;
|
|
21
|
+
|
|
22
|
+
const RAW_USES = {
|
|
23
|
+
'src/chart.tsx': `export const fill = 'var(--color-data-categorical-green)';
|
|
24
|
+
export const border = \`1px solid var(--color-data-blue-3)\`;
|
|
25
|
+
`,
|
|
26
|
+
'src/chart.css': '.bar { fill: var(--color-data-categorical-green); }\n',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A project with Core 0.7.0 installed and the given files, as a repository.
|
|
31
|
+
* @param {Record<string, string | object>} files
|
|
32
|
+
*/
|
|
33
|
+
function project(files) {
|
|
34
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-data-token-'));
|
|
35
|
+
tempRoots.push(root);
|
|
36
|
+
fs.mkdirSync(path.join(root, '.git'));
|
|
37
|
+
const all = {
|
|
38
|
+
'node_modules/@astryxdesign/core/package.json': {
|
|
39
|
+
name: '@astryxdesign/core',
|
|
40
|
+
version: '0.7.0',
|
|
41
|
+
},
|
|
42
|
+
...files,
|
|
14
43
|
};
|
|
15
|
-
|
|
44
|
+
for (const [rel, contents] of Object.entries(all)) {
|
|
45
|
+
const file = path.join(root, rel);
|
|
46
|
+
fs.mkdirSync(path.dirname(file), {recursive: true});
|
|
47
|
+
fs.writeFileSync(
|
|
48
|
+
file,
|
|
49
|
+
typeof contents === 'string' ? contents : JSON.stringify(contents),
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
return root;
|
|
16
53
|
}
|
|
17
54
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
55
|
+
const PREBUILT = {
|
|
56
|
+
'package.json': {dependencies: {'@astryxdesign/core': '0.7.3'}},
|
|
57
|
+
'src/main.tsx': "import '@astryxdesign/core/astryx.css';\n",
|
|
58
|
+
};
|
|
59
|
+
const SOURCE_BUILT = {
|
|
60
|
+
'package.json': {
|
|
61
|
+
dependencies: {'@astryxdesign/core': '0.7.3'},
|
|
62
|
+
devDependencies: {'@astryxdesign/build': '0.7.3'},
|
|
63
|
+
},
|
|
64
|
+
'vite.config.ts':
|
|
65
|
+
"import {astryxStylex} from '@astryxdesign/build/vite';\nexport default {plugins: [...astryxStylex()]};\n",
|
|
66
|
+
};
|
|
31
67
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
);
|
|
38
|
-
await expect(
|
|
39
|
-
run('.bar { fill: var(--color-data-categorical-blue); }', 'chart.css'),
|
|
40
|
-
).rejects.toThrow(/load @astryxdesign\/core\/astryx\.css in prebuilt mode/);
|
|
41
|
-
});
|
|
68
|
+
const runUpgrade = root =>
|
|
69
|
+
upgrade(
|
|
70
|
+
{from: '0.6.9', codemod: 'validate-data-token-ownership', apply: true},
|
|
71
|
+
{cwd: root},
|
|
72
|
+
);
|
|
42
73
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const fallback = 'var(--color-data-categorical-green, #008000)';
|
|
47
|
-
const fill = dataVars['--color-data-categorical-green'];
|
|
48
|
-
`;
|
|
49
|
-
expect(await run(source)).toBeUndefined();
|
|
74
|
+
describe('validate-data-token-ownership', () => {
|
|
75
|
+
it('reads only stylesheets', () => {
|
|
76
|
+
expect(meta.fileExtensions).toEqual(['.css']);
|
|
50
77
|
});
|
|
51
78
|
|
|
52
|
-
it('
|
|
53
|
-
|
|
54
|
-
@layer astryx-base {
|
|
55
|
-
:root { --color-data-categorical-green: #008000; }
|
|
56
|
-
}`;
|
|
57
|
-
await expect(run(source, 'theme.css')).rejects.toThrow(
|
|
79
|
+
it('fails on stale generated theme CSS with root data defaults', () => {
|
|
80
|
+
expect(() => transform({source: STALE_THEME, path: 'theme.css'})).toThrow(
|
|
58
81
|
/Rebuild it with `astryx theme build`/,
|
|
59
82
|
);
|
|
60
83
|
});
|
|
61
84
|
|
|
62
|
-
it('
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
`/* var(--color-data-categorical-green) */
|
|
72
|
-
.bar { fill: var(--color-data-categorical-green, #008000); }`,
|
|
73
|
-
'chart.css',
|
|
74
|
-
),
|
|
75
|
-
).toBeUndefined();
|
|
85
|
+
it('passes raw data-token uses with or without a fallback', () => {
|
|
86
|
+
for (const source of [
|
|
87
|
+
'.bar { fill: var(--color-data-categorical-green); }',
|
|
88
|
+
'.bar { fill: var(--color-data-categorical-green, #008000); }',
|
|
89
|
+
`/* @generated by \`astryx theme build\` */
|
|
90
|
+
.bar { fill: var(--color-data-blue-3); }`,
|
|
91
|
+
]) {
|
|
92
|
+
expect(transform({source, path: 'chart.css'})).toBeUndefined();
|
|
93
|
+
}
|
|
76
94
|
});
|
|
77
95
|
|
|
78
|
-
it('does not claim ownership of hand-authored CSS or sparse theme overrides',
|
|
96
|
+
it('does not claim ownership of hand-authored CSS or sparse theme overrides', () => {
|
|
79
97
|
expect(
|
|
80
|
-
|
|
81
|
-
':root { --color-data-categorical-green: #008000; }',
|
|
82
|
-
'app.css',
|
|
83
|
-
),
|
|
98
|
+
transform({
|
|
99
|
+
source: ':root { --color-data-categorical-green: #008000; }',
|
|
100
|
+
path: 'app.css',
|
|
101
|
+
}),
|
|
84
102
|
).toBeUndefined();
|
|
85
103
|
expect(
|
|
86
|
-
|
|
87
|
-
`/* @generated by \`astryx theme build\` */
|
|
104
|
+
transform({
|
|
105
|
+
source: `/* @generated by \`astryx theme build\` */
|
|
88
106
|
@scope ([data-astryx-theme="ocean"]) {
|
|
89
107
|
:scope { --color-data-categorical-green: #008000; }
|
|
90
108
|
}`,
|
|
91
|
-
'theme.css',
|
|
92
|
-
),
|
|
109
|
+
path: 'theme.css',
|
|
110
|
+
}),
|
|
93
111
|
).toBeUndefined();
|
|
94
112
|
});
|
|
113
|
+
|
|
114
|
+
it(
|
|
115
|
+
'completes `astryx upgrade --apply` over raw uses in a prebuilt project',
|
|
116
|
+
async () => {
|
|
117
|
+
const root = project({...PREBUILT, ...RAW_USES});
|
|
118
|
+
const res = await runUpgrade(root);
|
|
119
|
+
expect(res.data.complete).toBe(true);
|
|
120
|
+
expect(res.data.errors ?? []).toEqual([]);
|
|
121
|
+
expect(res.data.modifiedFiles ?? []).toEqual([]);
|
|
122
|
+
},
|
|
123
|
+
SLOW,
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
it(
|
|
127
|
+
'completes `astryx upgrade --apply` over raw uses in a source-built project',
|
|
128
|
+
async () => {
|
|
129
|
+
const root = project({...SOURCE_BUILT, ...RAW_USES});
|
|
130
|
+
const res = await runUpgrade(root);
|
|
131
|
+
expect(res.data.complete).toBe(true);
|
|
132
|
+
expect(res.data.errors ?? []).toEqual([]);
|
|
133
|
+
expect(res.data.modifiedFiles ?? []).toEqual([]);
|
|
134
|
+
},
|
|
135
|
+
SLOW,
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
it(
|
|
139
|
+
'fails `astryx upgrade --apply` on stale generated theme CSS',
|
|
140
|
+
async () => {
|
|
141
|
+
const root = project({...PREBUILT, 'src/theme.css': STALE_THEME});
|
|
142
|
+
await expect(runUpgrade(root)).rejects.toMatchObject({
|
|
143
|
+
code: 'ERR_CODEMOD_FAILED',
|
|
144
|
+
});
|
|
145
|
+
},
|
|
146
|
+
SLOW,
|
|
147
|
+
);
|
|
95
148
|
});
|