@astryxdesign/cli 0.7.16 → 0.7.17-canary.g335a172
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 +76 -86
- package/api/build/_adapter.d.mts +12 -0
- package/api/build/_adapter.mjs +51 -34
- package/api/build/blocks/blocks.d.mts +7 -5
- package/api/build/blocks/blocks.mjs +113 -26
- package/api/build/build.doc.mjs +4 -3
- package/api/build/build.type.d.mts +2 -2
- package/api/build/build.type.mjs +3 -3
- package/api/build/kit/kind.d.mts +2 -1
- package/api/build/kit/kind.mjs +199 -10
- package/api/build/kit/kit.mjs +6 -4
- package/api/build/kit/rank.mjs +69 -16
- package/api/build/kit/start.d.mts +5 -4
- package/api/build/kit/start.mjs +12 -8
- package/api/build/kit/weights.d.mts +16 -3
- package/api/build/kit/weights.json +1 -1
- package/api/build/kit/weights.mjs +251 -35
- package/api/build/kit/word-model.d.mts +23 -0
- package/api/build/kit/word-model.mjs +46 -0
- package/api/build/kit/words.d.mts +48 -0
- package/api/build/kit/words.mjs +90 -1
- package/api/component/__fixtures__/resolutions/modules.txt +4 -5
- package/api/component/list/list.d.mts +1 -1
- package/api/component/list/list.mjs +48 -6
- package/api/discover/_adapter.d.mts +1 -1
- package/api/discover/search/search.mjs +3 -2
- package/api/docs/_adapter.d.mts +26 -2
- package/api/docs/_adapter.mjs +219 -6
- package/api/docs/docs.d.mts +3 -0
- package/api/docs/docs.doc.mjs +7 -1
- package/api/docs/docs.mjs +12 -0
- package/api/docs/docs.type.d.mts +5 -0
- package/api/docs/docs.type.mjs +2 -0
- package/api/docs/node/node.mjs +1 -1
- package/api/doctor/_adapter.d.mts +27 -5
- package/api/doctor/_adapter.mjs +83 -10
- package/api/doctor/built-checks.mjs +40 -14
- package/api/doctor/doctor.d.mts +4 -3
- package/api/doctor/doctor.mjs +14 -7
- package/api/doctor/theme-checks.mjs +121 -17
- package/api/icon/_records.mjs +2 -1
- package/api/index.d.mts +2 -0
- package/api/index.mjs +2 -0
- package/api/integration/_adapter.d.mts +44 -0
- package/api/integration/_adapter.mjs +77 -1
- package/api/integration/authoring-checks.mjs +6 -6
- package/api/integration/example-scope.d.mts +14 -0
- package/api/integration/example-scope.mjs +44 -0
- package/api/integration/example-scope.type.d.mts +29 -0
- package/api/integration/example-scope.type.mjs +25 -0
- package/api/integration/integrationExampleScope.doc.d.mts +11 -0
- package/api/integration/integrationExampleScope.doc.mjs +59 -0
- package/api/integration/validate-integration.mjs +19 -1
- package/api/integration/validate-integration.type.d.mts +9 -0
- package/api/integration/validate-integration.type.mjs +1 -1
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/render/_adapter.mjs +591 -195
- package/api/render/render.doc.mjs +11 -3
- package/api/render/render.type.d.mts +52 -0
- package/api/render/render.type.mjs +31 -1
- package/api/search/ORDERING.md +1 -1
- package/api/search/_candidate-score.mjs +51 -32
- package/api/search/_fit-order.mjs +3 -3
- package/api/search/_gather-components.d.mts +3 -2
- package/api/search/_gather-components.mjs +12 -3
- package/api/search/_lexical.d.mts +5 -0
- package/api/search/_lexical.mjs +8 -2
- package/api/search/_result.d.mts +11 -9
- package/api/search/_result.mjs +4 -4
- package/api/search/_score.d.mts +6 -1
- package/api/search/_score.mjs +15 -3
- package/api/search/search-index.mjs +7 -1
- package/api/search/search.d.mts +1 -1
- package/api/theme/_adapter.mjs +12 -1
- package/api/theme/build/build.d.mts +60 -0
- package/api/theme/build/build.mjs +210 -54
- package/api/theme/build/font-warning.d.mts +8 -0
- package/api/theme/build/font-warning.mjs +19 -0
- package/api/theme/theme.type.d.mts +10 -0
- package/api/theme/theme.type.mjs +7 -1
- package/api/theme-edit/_adapter.d.mts +55 -0
- package/api/theme-edit/_adapter.mjs +673 -42
- package/api/theme-edit/_check.d.mts +28 -22
- package/api/theme-edit/_check.mjs +1858 -312
- package/api/theme-edit/_color.d.mts +10 -0
- package/api/theme-edit/_color.mjs +49 -1
- package/api/theme-edit/_compiler.mjs +9 -0
- package/api/theme-edit/_context.mjs +60 -3
- package/api/theme-edit/_css.mjs +21 -1
- package/api/theme-edit/_edit.d.mts +22 -0
- package/api/theme-edit/_edit.mjs +1533 -92
- package/api/theme-edit/_how-commands.d.mts +57 -0
- package/api/theme-edit/_how-commands.mjs +587 -1
- package/api/theme-edit/_how-question.d.mts +78 -0
- package/api/theme-edit/_how-question.mjs +4716 -235
- package/api/theme-edit/_how.mjs +134 -8
- package/api/theme-edit/_marks.d.mts +31 -5
- package/api/theme-edit/_marks.mjs +57 -5
- package/api/theme-edit/_normal.d.mts +219 -0
- package/api/theme-edit/_normal.mjs +1041 -0
- package/api/theme-edit/_palette.mjs +10 -4
- package/api/theme-edit/_parts.d.mts +8 -0
- package/api/theme-edit/_parts.mjs +103 -2
- package/api/theme-edit/_playwright-picture.d.mts +4 -0
- package/api/theme-edit/_playwright-picture.mjs +34 -0
- package/api/theme-edit/_preview-app.d.mts +7 -1
- package/api/theme-edit/_preview-app.mjs +394 -74
- package/api/theme-edit/_preview.d.mts +69 -8
- package/api/theme-edit/_preview.mjs +531 -108
- package/api/theme-edit/_settings.d.mts +243 -6
- package/api/theme-edit/_settings.mjs +2415 -147
- package/api/theme-edit/_tables.d.mts +6 -0
- package/api/theme-edit/_tables.mjs +44 -1
- package/api/theme-edit/_vet.d.mts +18 -0
- package/api/theme-edit/_vet.mjs +32 -0
- package/api/theme-edit/theme-edit.type.d.mts +10 -1
- package/api/theme-edit/theme-edit.type.mjs +4 -1
- package/api/theme-edit/themeEditHow.doc.mjs +1 -1
- package/api/theme-edit/themeEditNew.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +3 -3
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +2 -2
- package/api/upgrade/run/run.mjs +4 -3
- package/assets/codemods/integration-discovery.mjs +2 -1
- package/assets/codemods/run-codemod.mjs +87 -7
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +394 -0
- package/assets/component-list.generated.json +1 -0
- package/assets/docs/author-a-theme.doc.mjs +1 -0
- package/assets/docs/theme.doc.dense.mjs +2 -2
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
- package/assets/docs/tree/checks.doc.mjs +1 -1
- package/assets/docs/tree/cli-command.doc.mjs +2 -3
- package/assets/docs/tree/render-pages.doc.mjs +44 -3
- package/assets/docs/tree/single-component.doc.mjs +4 -0
- package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
- package/assets/docs/use-a-theme.doc.mjs +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
- package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +2 -2
- package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/template.doc.mjs +5 -4
- package/assets/templates/pages/ai-chat-landing/template.doc.mjs +2 -1
- package/assets/templates/pages/blank/template.doc.mjs +1 -1
- package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
- package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
- package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
- package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
- package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
- package/assets/templates/pages/documentation/template.doc.mjs +4 -1
- package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
- package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
- package/assets/templates/pages/editor/template.doc.mjs +2 -8
- package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
- package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
- package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
- package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
- package/assets/templates/pages/ide/page.tsx +24 -2
- package/assets/templates/pages/kanban-board/template.doc.mjs +1 -9
- package/assets/templates/pages/library/template.doc.mjs +4 -1
- package/assets/templates/pages/login/template.doc.mjs +2 -1
- package/assets/templates/pages/login-card/template.doc.mjs +2 -1
- package/assets/templates/pages/login-split/template.doc.mjs +2 -1
- package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
- package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
- package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
- package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
- package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
- package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
- package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
- package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
- package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
- package/assets/templates/pages/table-page/template.doc.mjs +5 -4
- package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
- package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -9
- package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
- package/assets/theme.template.ts +6 -0
- package/authoring/debug/parse.d.mts +3 -3
- package/authoring/doctypes/_schema.d.mts +3 -3
- package/authoring/doctypes/command/command.doc.mjs +1 -1
- package/authoring/doctypes/component/categories.d.mts +37 -0
- package/authoring/doctypes/component/categories.mjs +54 -0
- package/authoring/doctypes/template/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +9 -0
- package/authoring/example/example.doc.d.mts +12 -0
- package/authoring/example/example.doc.mjs +69 -0
- package/authoring/example/preview.d.mts +92 -0
- package/authoring/example/preview.mjs +994 -0
- package/authoring/example/type.ts +102 -0
- package/authoring/index.d.mts +1 -0
- package/authoring/index.d.ts +12 -0
- package/authoring/index.mjs +3 -1
- package/clients/cli/bin/astryx.mjs +6 -9
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/component.doc.mjs +1 -1
- package/clients/cli/commands/component.mjs +22 -3
- package/clients/cli/commands/docs.doc.mjs +7 -1
- package/clients/cli/commands/docs.mjs +3 -1
- package/clients/cli/commands/doctor.mjs +32 -14
- package/clients/cli/commands/experimental/render.mjs +42 -1
- package/clients/cli/commands/experimental/theme.mjs +145 -16
- package/clients/cli/commands/experimental-render.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +87 -1
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
- package/clients/cli/commands/search.doc.mjs +2 -1
- package/clients/cli/commands/search.mjs +6 -1
- package/clients/cli/commands/template.mjs +4 -2
- package/clients/cli/commands/theme-build.doc.mjs +5 -1
- package/clients/cli/commands/theme.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +183 -6
- package/clients/cli/commands/upgrade.mjs +42 -7
- package/clients/cli/index.mjs +1 -1
- package/clients/cli/lib/cli-error.mjs +2 -1
- package/clients/cli/lib/component-format.mjs +205 -98
- package/clients/cli/lib/hook-format.mjs +9 -19
- package/clients/cli/lib/json-shim.mjs +77 -21
- package/clients/cli/lib/manifest.mjs +3 -2
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/config/theme-state.d.mts +13 -1
- package/foundation/config/theme-state.mjs +47 -7
- package/foundation/discovery/authoring-self-docs.mjs +1 -0
- package/foundation/discovery/component-discovery.d.mts +11 -0
- package/foundation/discovery/component-discovery.mjs +56 -8
- package/foundation/discovery/component-replacement.mjs +130 -1
- package/foundation/discovery/copied-passages.mjs +2 -1
- package/foundation/discovery/doc-types.mjs +4 -3
- package/foundation/discovery/entry-name-files.d.mts +43 -0
- package/foundation/discovery/entry-name-files.mjs +264 -0
- package/foundation/discovery/hook-discovery.d.mts +8 -2
- package/foundation/discovery/hook-discovery.mjs +22 -8
- package/foundation/discovery/icon-definition-discovery.mjs +2 -1
- package/foundation/discovery/icon-set-checks.mjs +2 -1
- package/foundation/discovery/icon-set-discovery.mjs +2 -1
- package/foundation/discovery/integration-doc-files.mjs +2 -1
- package/foundation/discovery/package-exports.d.mts +10 -0
- package/foundation/discovery/package-exports.mjs +56 -3
- package/foundation/discovery/prop-drift.mjs +9 -9
- package/foundation/discovery/runner-allowlist.d.mts +1 -0
- package/foundation/discovery/runner-allowlist.mjs +2 -0
- package/foundation/discovery/stored-component-list.d.mts +43 -0
- package/foundation/discovery/stored-component-list.mjs +90 -0
- package/foundation/discovery/stored-self-audit.d.mts +26 -10
- package/foundation/discovery/stored-self-audit.mjs +38 -18
- package/foundation/discovery/template-adapter.d.mts +52 -0
- package/foundation/discovery/template-adapter.mjs +176 -12
- package/foundation/discovery/template-icons.mjs +2 -1
- package/foundation/discovery/theme-discovery.mjs +3 -2
- package/foundation/discovery/theme-imports.d.mts +14 -0
- package/foundation/discovery/theme-imports.mjs +43 -1
- package/foundation/discovery/theming-targets.mjs +3 -2
- package/foundation/doc-compiler/import.mjs +7 -1
- package/foundation/doc-compiler/inputs.mjs +3 -2
- package/foundation/doc-compiler/parse-readable.mjs +4 -1
- package/foundation/doc-compiler/stored-docs.d.mts +22 -0
- package/foundation/doc-compiler/stored-docs.mjs +49 -0
- package/foundation/env/semver.mjs +3 -1
- package/foundation/fonts/font-stylesheet.d.mts +31 -0
- package/foundation/fonts/font-stylesheet.mjs +115 -0
- package/foundation/fs/cache-eviction.d.mts +21 -0
- package/foundation/fs/cache-eviction.mjs +73 -0
- package/foundation/fs/file-protection.mjs +4 -3
- package/foundation/fs/gather-cache.d.mts +25 -4
- package/foundation/fs/gather-cache.mjs +164 -55
- package/foundation/fs/jiti-cache.d.mts +19 -1
- package/foundation/fs/jiti-cache.mjs +130 -6
- package/foundation/fs/kept-tree.d.mts +60 -0
- package/foundation/fs/kept-tree.mjs +154 -0
- package/foundation/fs/listing-cache.d.mts +7 -0
- package/foundation/fs/listing-cache.mjs +10 -0
- package/foundation/fs/module-loader.d.mts +24 -2
- package/foundation/fs/module-loader.mjs +94 -21
- package/foundation/fs/paths.d.mts +18 -0
- package/foundation/fs/paths.mjs +15 -2
- package/foundation/identity/provider-identity.d.mts +6 -0
- package/foundation/identity/provider-identity.mjs +10 -1
- package/foundation/integrations/contribution-inventory.mjs +4 -3
- package/foundation/integrations/example-code.d.mts +63 -0
- package/foundation/integrations/example-code.mjs +416 -0
- package/foundation/integrations/public-imports.d.mts +9 -0
- package/foundation/integrations/public-imports.mjs +3 -2
- package/foundation/integrations/validate-contributions.mjs +17 -45
- package/foundation/render/embedded-files.d.mts +6 -0
- package/foundation/render/embedded-files.mjs +25 -5
- package/foundation/render/embedded-imports.d.mts +39 -7
- package/foundation/render/embedded-imports.mjs +66 -27
- package/foundation/render/file-header.d.mts +66 -0
- package/foundation/render/file-header.mjs +118 -0
- package/foundation/render/host-answer.d.mts +18 -0
- package/foundation/render/host-answer.mjs +46 -0
- package/foundation/render/host-exit.d.mts +1 -0
- package/foundation/render/host-exit.mjs +6 -1
- package/foundation/render/html-reader.d.mts +55 -2
- package/foundation/render/html-reader.mjs +145 -26
- package/foundation/render/markup-edits.d.mts +57 -0
- package/foundation/render/markup-edits.mjs +182 -0
- package/foundation/render/page-host.mjs +29 -12
- package/foundation/render/page-worker.mjs +121 -13
- package/foundation/render/rebuild.mjs +2 -1
- package/foundation/render/render-page.d.mts +35 -3
- package/foundation/render/render-page.mjs +316 -42
- package/foundation/render/source-block.d.mts +85 -6
- package/foundation/render/source-block.mjs +211 -20
- package/foundation/render/ts-paths.d.mts +69 -6
- package/foundation/render/ts-paths.mjs +326 -40
- package/foundation/response/error-codes.d.mts +3 -1
- package/foundation/response/error-codes.d.ts +1 -0
- package/foundation/response/error-codes.doc.mjs +12 -1
- package/foundation/response/error-codes.mjs +11 -1
- package/foundation/response/response-types.doc.mjs +2 -2
- package/foundation/text/compare-text.d.mts +14 -0
- package/foundation/text/compare-text.mjs +68 -0
- package/foundation/text/string-utils.d.mts +3 -2
- package/foundation/text/string-utils.mjs +18 -4
- package/foundation/text/suggest-order.d.mts +9 -0
- package/foundation/text/suggest-order.mjs +15 -1
- package/foundation/xle/expand.mjs +2 -1
- package/host/index.mjs +8 -6
- package/package.json +7 -6
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file A summary of a folder tree's names and of the text of the files it
|
|
5
|
+
* reads, kept between runs while no folder in the tree and no file the
|
|
6
|
+
* summary read has changed.
|
|
7
|
+
*
|
|
8
|
+
* @input A root folder, the kind of summary, the modules whose code makes it,
|
|
9
|
+
* and the function that makes it from the tree's listing.
|
|
10
|
+
* @output The summary: the stored one while every folder and every read file
|
|
11
|
+
* has the stamp it was stored with, else a new one, which is stored. The
|
|
12
|
+
* kept gathers' store holds it (gather-cache.mjs persistedSummary), under
|
|
13
|
+
* that store's rules.
|
|
14
|
+
* @position Used by the docs not-found hint (foundation/discovery) to check
|
|
15
|
+
* one name against Core's sources, the CLI's blocks and each integration's
|
|
16
|
+
* folders without listing every folder on each run.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import * as fs from 'node:fs';
|
|
20
|
+
import * as path from 'node:path';
|
|
21
|
+
import {fileURLToPath} from 'node:url';
|
|
22
|
+
import {persistedSummary} from './gather-cache.mjs';
|
|
23
|
+
import {fileStamp} from './read-record.mjs';
|
|
24
|
+
|
|
25
|
+
/** The module's own file: its code decides every summary's shape. */
|
|
26
|
+
const OWN_FILE = fileURLToPath(import.meta.url);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* One folder of the tree: its path from the root (`''` for the root) and its
|
|
30
|
+
* entries, in the order the disk lists them.
|
|
31
|
+
* @typedef {{rel: string, entries: Array<{name: string, isDir: boolean}>}} TreeFolder
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The tree under `root`, folder by folder, outside any folder `skip` names.
|
|
36
|
+
* Each folder's stamp goes into `stamps` before the folder is read, so a
|
|
37
|
+
* change during the read shows as a change. A folder that cannot be read has
|
|
38
|
+
* no entries.
|
|
39
|
+
* @param {string} root
|
|
40
|
+
* @param {(name: string) => boolean} skip
|
|
41
|
+
* @param {Array<[string, string]>} stamps
|
|
42
|
+
* @returns {TreeFolder[]}
|
|
43
|
+
*/
|
|
44
|
+
function walkTree(root, skip, stamps) {
|
|
45
|
+
/** @type {TreeFolder[]} */
|
|
46
|
+
const folders = [];
|
|
47
|
+
/** @param {string} rel */
|
|
48
|
+
const visit = rel => {
|
|
49
|
+
const full = rel === '' ? root : path.join(root, rel);
|
|
50
|
+
stamps.push([rel, fileStamp(full)]);
|
|
51
|
+
/** @type {fs.Dirent[]} */
|
|
52
|
+
let dirents;
|
|
53
|
+
try {
|
|
54
|
+
dirents = fs.readdirSync(full, {withFileTypes: true});
|
|
55
|
+
} catch {
|
|
56
|
+
dirents = [];
|
|
57
|
+
}
|
|
58
|
+
const entries = dirents.map(entry => ({
|
|
59
|
+
name: entry.name,
|
|
60
|
+
isDir: entry.isDirectory(),
|
|
61
|
+
}));
|
|
62
|
+
folders.push({rel, entries});
|
|
63
|
+
for (const entry of entries) {
|
|
64
|
+
if (entry.isDir && !skip(entry.name)) {
|
|
65
|
+
visit(rel === '' ? entry.name : path.join(rel, entry.name));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
visit('');
|
|
70
|
+
return folders;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** @type {Map<string, string>} each code file's stamp, once per process */
|
|
74
|
+
const codeStamps = new Map();
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Names as one string a lookup can search without parsing a list: each name
|
|
78
|
+
* on its own line. A list when a name holds a line break.
|
|
79
|
+
* @param {Iterable<string>} names
|
|
80
|
+
* @returns {string | string[]}
|
|
81
|
+
*/
|
|
82
|
+
export function nameLines(names) {
|
|
83
|
+
const list = [...new Set(names)];
|
|
84
|
+
return list.some(name => name.includes('\n'))
|
|
85
|
+
? list
|
|
86
|
+
: `\n${list.join('\n')}\n`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Whether `lines` ({@link nameLines}) holds `name`.
|
|
91
|
+
* @param {string | string[]} lines
|
|
92
|
+
* @param {string} name
|
|
93
|
+
* @returns {boolean}
|
|
94
|
+
*/
|
|
95
|
+
export function hasNameLine(lines, name) {
|
|
96
|
+
if (typeof lines !== 'string') return lines.includes(name);
|
|
97
|
+
return !name.includes('\n') && lines.includes(`\n${name}\n`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* One root's tree as a summary reads it: its folders, and `readText`, which
|
|
102
|
+
* reads a file by its path from the root and stamps it.
|
|
103
|
+
* @typedef {{root: string, folders: TreeFolder[], readText: (rel: string) => string}} Tree
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The summary `summarize` makes of the trees under `roots`, or the one a run
|
|
108
|
+
* stored for the same roots, kind and code while every folder it listed and
|
|
109
|
+
* every file it read is unchanged. Any failure to read or store a summary is
|
|
110
|
+
* silent, and the summary is made again.
|
|
111
|
+
* @template T
|
|
112
|
+
* @param {{kind: string, roots: string[], code: string[], skip?: (name: string) => boolean}} options
|
|
113
|
+
* `code`: the files whose code makes the summary; `skip`: folder names the
|
|
114
|
+
* walk does not enter (it is part of `kind`)
|
|
115
|
+
* @param {(trees: Tree[]) => T} summarize gets one tree per root, in order
|
|
116
|
+
* @returns {T}
|
|
117
|
+
*/
|
|
118
|
+
export function keptTreeSummary(
|
|
119
|
+
{kind, roots, code, skip = () => false},
|
|
120
|
+
summarize,
|
|
121
|
+
) {
|
|
122
|
+
const resolved = roots.map(root => path.resolve(root));
|
|
123
|
+
const codeState = [OWN_FILE, ...code].map(file => {
|
|
124
|
+
let stamp = codeStamps.get(file);
|
|
125
|
+
if (stamp === undefined) {
|
|
126
|
+
stamp = fileStamp(file);
|
|
127
|
+
codeStamps.set(file, stamp);
|
|
128
|
+
}
|
|
129
|
+
return [file, stamp];
|
|
130
|
+
});
|
|
131
|
+
return persistedSummary(['kept-tree', kind, resolved, codeState], () => {
|
|
132
|
+
/** @type {[string, string][]} */
|
|
133
|
+
const stamps = [];
|
|
134
|
+
const trees = resolved.map(root => {
|
|
135
|
+
/** @type {Array<[string, string]>} */
|
|
136
|
+
const own = [];
|
|
137
|
+
const folders = walkTree(root, skip, own);
|
|
138
|
+
for (const [rel, stamp] of own) {
|
|
139
|
+
stamps.push([rel === '' ? root : root + path.sep + rel, stamp]);
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
root,
|
|
143
|
+
folders,
|
|
144
|
+
/** @param {string} rel */
|
|
145
|
+
readText: rel => {
|
|
146
|
+
const full = rel === '' ? root : root + path.sep + rel;
|
|
147
|
+
stamps.push([full, fileStamp(full)]);
|
|
148
|
+
return fs.readFileSync(full, 'utf8');
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
return {value: summarize(trees), stamps};
|
|
153
|
+
});
|
|
154
|
+
}
|
|
@@ -18,6 +18,13 @@ export function withListingCache<T>(fn: () => T): T;
|
|
|
18
18
|
* @returns {T}
|
|
19
19
|
*/
|
|
20
20
|
export function oncePerListing<T>(key: string, compute: () => T): T;
|
|
21
|
+
/**
|
|
22
|
+
* What `oncePerListing(key, …)` already computed in this operation, without
|
|
23
|
+
* computing it: undefined when nothing has.
|
|
24
|
+
* @param {string} key
|
|
25
|
+
* @returns {unknown}
|
|
26
|
+
*/
|
|
27
|
+
export function onceComputed(key: string): unknown;
|
|
21
28
|
/**
|
|
22
29
|
* Whether an operation's listing cache is active.
|
|
23
30
|
* @returns {boolean}
|
|
@@ -91,6 +91,16 @@ export function oncePerListing(key, compute) {
|
|
|
91
91
|
return /** @type {T} */ (cache.memos.get(key));
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
/**
|
|
95
|
+
* What `oncePerListing(key, …)` already computed in this operation, without
|
|
96
|
+
* computing it: undefined when nothing has.
|
|
97
|
+
* @param {string} key
|
|
98
|
+
* @returns {unknown}
|
|
99
|
+
*/
|
|
100
|
+
export function onceComputed(key) {
|
|
101
|
+
return scope.getStore()?.memos.get(key);
|
|
102
|
+
}
|
|
103
|
+
|
|
94
104
|
/**
|
|
95
105
|
* Whether an operation's listing cache is active.
|
|
96
106
|
* @returns {boolean}
|
|
@@ -19,11 +19,27 @@
|
|
|
19
19
|
export function importUserModule(file: string, { fresh }?: {
|
|
20
20
|
fresh?: boolean;
|
|
21
21
|
}): Promise<Record<string, unknown>>;
|
|
22
|
+
/**
|
|
23
|
+
* Run a theme module load with every stylesheet that the theme's modules
|
|
24
|
+
* import, at any depth, loaded as an empty module. A theme module can import
|
|
25
|
+
* a stylesheet so that the app's bundler emits it, and Node cannot load a
|
|
26
|
+
* stylesheet. Node resolves each import from the module that writes it, so a
|
|
27
|
+
* missing stylesheet fails like any missing import, and an import that ends
|
|
28
|
+
* in `.css` but names a JavaScript file loads that file. Module loads outside
|
|
29
|
+
* this call's async context do not change. The module hook is installed for
|
|
30
|
+
* the first overlapping load and removed after the last. A Node without module
|
|
31
|
+
* hooks (before 22.15) runs the load unchanged.
|
|
32
|
+
* @template T
|
|
33
|
+
* @param {() => Promise<T>} load
|
|
34
|
+
* @returns {Promise<T>}
|
|
35
|
+
*/
|
|
36
|
+
export function withEmptyStylesheets<T>(load: () => Promise<T>): Promise<T>;
|
|
22
37
|
/**
|
|
23
38
|
* Load a generated theme artifact and its extensionless JS/JSX/TS/TSX graph.
|
|
24
39
|
* Package specifiers resolve from the consumer project, while relative paths
|
|
25
|
-
* resolve from that same project root.
|
|
26
|
-
* loads as an empty module.
|
|
40
|
+
* resolve from that same project root. A stylesheet that a module in the graph
|
|
41
|
+
* imports loads as an empty module (`withEmptyStylesheets`). A target that is
|
|
42
|
+
* itself a stylesheet is not a theme module, and fails as one.
|
|
27
43
|
* @param {string} specifier
|
|
28
44
|
* @param {string} cwd
|
|
29
45
|
* @returns {Promise<Record<string, unknown>>}
|
|
@@ -71,4 +87,10 @@ export function loadModuleWithParser<T>(file: string, parse: (input: unknown, la
|
|
|
71
87
|
fresh?: boolean;
|
|
72
88
|
}): Promise<T>;
|
|
73
89
|
export { findPresentFiles };
|
|
90
|
+
/**
|
|
91
|
+
* jiti, loaded on first use: only TypeScript files and built theme modules
|
|
92
|
+
* need it, so a run that reads neither never loads it.
|
|
93
|
+
* @type {typeof import('jiti').createJiti}
|
|
94
|
+
*/
|
|
95
|
+
export const createJiti: typeof import("jiti").createJiti;
|
|
74
96
|
import { findPresentFiles } from './present-files.mjs';
|
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
* user-authored module (`.ts` via jiti, `.mjs`/`.js` via native dynamic
|
|
8
8
|
* import) and (b) find conventional files by basename in a fixed
|
|
9
9
|
* load-precedence order. Generated theme artifacts also use a dedicated jiti
|
|
10
|
-
* path that resolves extensionless JSX/TSX registry imports
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
10
|
+
* path that resolves extensionless JSX/TSX registry imports. On Node 22.15 and
|
|
11
|
+
* later, a theme module load, of a built artifact or of theme source, loads
|
|
12
|
+
* the stylesheets its modules import as empty modules. These helpers
|
|
13
|
+
* centralize that behavior so callers stay in lockstep. A module's stdout
|
|
14
|
+
* writes go to stderr while it loads, so project code that prints cannot
|
|
15
|
+
* corrupt a `--json` envelope.
|
|
15
16
|
*
|
|
16
17
|
* `loadModuleWithParser` builds on these primitives to provide the single
|
|
17
18
|
* load/validation boundary shared by config, integration, codemod, and
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
|
|
22
23
|
import * as path from 'node:path';
|
|
23
24
|
import {AsyncLocalStorage} from 'node:async_hooks';
|
|
24
|
-
import {createRequire} from 'node:module';
|
|
25
|
+
import nodeModule, {createRequire} from 'node:module';
|
|
25
26
|
import {pathToFileURL} from 'node:url';
|
|
26
27
|
import * as fs from 'node:fs';
|
|
27
28
|
import {findPresentFiles} from './present-files.mjs';
|
|
@@ -40,7 +41,8 @@ const requireFromHere = createRequire(import.meta.url);
|
|
|
40
41
|
* need it, so a run that reads neither never loads it.
|
|
41
42
|
* @type {typeof import('jiti').createJiti}
|
|
42
43
|
*/
|
|
43
|
-
const createJiti = (...args) =>
|
|
44
|
+
export const createJiti = (...args) =>
|
|
45
|
+
requireFromHere('jiti').createJiti(...args);
|
|
44
46
|
function getJiti() {
|
|
45
47
|
if (!jitiInstance) {
|
|
46
48
|
jitiInstance = createJiti(import.meta.url, jitiCacheOptions());
|
|
@@ -138,16 +140,80 @@ function resolvesToStylesheet(specifier, from) {
|
|
|
138
140
|
}
|
|
139
141
|
|
|
140
142
|
/**
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
143
|
+
* Module hooks that run in the loading thread: Node 22.15 and later have them.
|
|
144
|
+
* @type {((hooks: object) => {deregister: () => void}) | undefined}
|
|
145
|
+
*/
|
|
146
|
+
const registerHooks = /** @type {any} */ (nodeModule).registerHooks;
|
|
147
|
+
/** Set in the async context of a theme module load, and only there. */
|
|
148
|
+
const themeModuleLoad = new AsyncLocalStorage();
|
|
149
|
+
let themeModuleLoadsInFlight = 0;
|
|
150
|
+
/** @type {{deregister: () => void} | null} */
|
|
151
|
+
let stylesheetHooks = null;
|
|
152
|
+
|
|
153
|
+
/** @param {string} url */
|
|
154
|
+
function isStylesheetUrl(url) {
|
|
155
|
+
return url.startsWith('file:') && new URL(url).pathname.endsWith('.css');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* In a theme module load, a module that Node resolves to a `.css` file loads
|
|
160
|
+
* as an empty module. Any other module loads unchanged.
|
|
161
|
+
* @param {string} url
|
|
162
|
+
* @param {any} context
|
|
163
|
+
* @param {(url: string, context: any) => any} next
|
|
164
|
+
*/
|
|
165
|
+
function loadStylesheetAsEmptyModule(url, context, next) {
|
|
166
|
+
if (themeModuleLoad.getStore() && isStylesheetUrl(url)) {
|
|
167
|
+
return {format: 'module', source: '', shortCircuit: true};
|
|
168
|
+
}
|
|
169
|
+
return next(url, context);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function removeStylesheetHooks() {
|
|
173
|
+
try {
|
|
174
|
+
stylesheetHooks?.deregister();
|
|
175
|
+
stylesheetHooks = null;
|
|
176
|
+
} catch {
|
|
177
|
+
// A hook that Node cannot remove stays inert: it acts only in a theme
|
|
178
|
+
// module load, and the next load uses it again.
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Run a theme module load with every stylesheet that the theme's modules
|
|
184
|
+
* import, at any depth, loaded as an empty module. A theme module can import
|
|
185
|
+
* a stylesheet so that the app's bundler emits it, and Node cannot load a
|
|
186
|
+
* stylesheet. Node resolves each import from the module that writes it, so a
|
|
187
|
+
* missing stylesheet fails like any missing import, and an import that ends
|
|
188
|
+
* in `.css` but names a JavaScript file loads that file. Module loads outside
|
|
189
|
+
* this call's async context do not change. The module hook is installed for
|
|
190
|
+
* the first overlapping load and removed after the last. A Node without module
|
|
191
|
+
* hooks (before 22.15) runs the load unchanged.
|
|
192
|
+
* @template T
|
|
193
|
+
* @param {() => Promise<T>} load
|
|
194
|
+
* @returns {Promise<T>}
|
|
195
|
+
*/
|
|
196
|
+
export async function withEmptyStylesheets(load) {
|
|
197
|
+
if (typeof registerHooks !== 'function') return await load();
|
|
198
|
+
stylesheetHooks ??= registerHooks({load: loadStylesheetAsEmptyModule});
|
|
199
|
+
themeModuleLoadsInFlight++;
|
|
200
|
+
try {
|
|
201
|
+
return await themeModuleLoad.run(true, load);
|
|
202
|
+
} finally {
|
|
203
|
+
if (--themeModuleLoadsInFlight === 0) removeStylesheetHooks();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* The stylesheet rule for a Node without module hooks. An import that ends in
|
|
209
|
+
* `.css` and resolves from the theme module to an existing `.css` file loads
|
|
210
|
+
* as an empty module. Any other import loads as before: a missing stylesheet
|
|
211
|
+
* fails like any missing import, and `./tokens.css` loads `tokens.css.js` when
|
|
212
|
+
* that is the file it names. jiti shows only the import text, so the check
|
|
213
|
+
* resolves it from the theme module's folder, not from the importing module's.
|
|
214
|
+
* A module in another folder fails on a stylesheet it reaches by a different
|
|
215
|
+
* relative path, and passes on a missing stylesheet whose path exists from the
|
|
216
|
+
* theme module's folder.
|
|
151
217
|
* @param {() => string} themeModule returns the theme module's path
|
|
152
218
|
* @returns {Record<string, unknown>}
|
|
153
219
|
*/
|
|
@@ -193,8 +259,9 @@ function isMissingPackageExport(error) {
|
|
|
193
259
|
/**
|
|
194
260
|
* Load a generated theme artifact and its extensionless JS/JSX/TS/TSX graph.
|
|
195
261
|
* Package specifiers resolve from the consumer project, while relative paths
|
|
196
|
-
* resolve from that same project root.
|
|
197
|
-
* loads as an empty module.
|
|
262
|
+
* resolve from that same project root. A stylesheet that a module in the graph
|
|
263
|
+
* imports loads as an empty module (`withEmptyStylesheets`). A target that is
|
|
264
|
+
* itself a stylesheet is not a theme module, and fails as one.
|
|
198
265
|
* @param {string} specifier
|
|
199
266
|
* @param {string} cwd
|
|
200
267
|
* @returns {Promise<Record<string, unknown>>}
|
|
@@ -207,7 +274,9 @@ export async function importThemeArtifact(specifier, cwd) {
|
|
|
207
274
|
jsx: true,
|
|
208
275
|
interopDefault: true,
|
|
209
276
|
extensions: THEME_ARTIFACT_EXTENSIONS,
|
|
210
|
-
|
|
277
|
+
...(typeof registerHooks === 'function'
|
|
278
|
+
? {}
|
|
279
|
+
: {virtualModules: themeArtifactStylesheets(() => themeModule)}),
|
|
211
280
|
});
|
|
212
281
|
let target;
|
|
213
282
|
if (specifier.startsWith('.') || path.isAbsolute(specifier)) {
|
|
@@ -224,7 +293,11 @@ export async function importThemeArtifact(specifier, cwd) {
|
|
|
224
293
|
throw new ThemeArtifactNotFoundError(specifier);
|
|
225
294
|
}
|
|
226
295
|
themeModule = target;
|
|
227
|
-
|
|
296
|
+
/** @type {() => Promise<Record<string, unknown>>} */
|
|
297
|
+
const load = () => loader.import(target);
|
|
298
|
+
return await withStdoutOnStderr(
|
|
299
|
+
isStylesheetSpecifier(target) ? load : () => withEmptyStylesheets(load),
|
|
300
|
+
);
|
|
228
301
|
}
|
|
229
302
|
|
|
230
303
|
/**
|
|
@@ -74,6 +74,24 @@ export function realDir(p: string): string;
|
|
|
74
74
|
* @returns {string|null}
|
|
75
75
|
*/
|
|
76
76
|
export function homeFolder(): string | null;
|
|
77
|
+
/**
|
|
78
|
+
* Whether a relative path climbs out of the folder it starts in: `..`
|
|
79
|
+
* itself, or a path that begins with `../` (or `..` and the platform's
|
|
80
|
+
* separator). A name that only
|
|
81
|
+
* begins with two dots (`..x`) is a folder or file like any other.
|
|
82
|
+
*
|
|
83
|
+
* @param {string} rel
|
|
84
|
+
* @returns {boolean}
|
|
85
|
+
*/
|
|
86
|
+
export function climbsOut(rel: string): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Whether `child` lies strictly inside `parent`.
|
|
89
|
+
*
|
|
90
|
+
* @param {string} child
|
|
91
|
+
* @param {string} parent
|
|
92
|
+
* @returns {boolean}
|
|
93
|
+
*/
|
|
94
|
+
export function isInside(child: string, parent: string): boolean;
|
|
77
95
|
/**
|
|
78
96
|
* The project root: the directory of the nearest package.json at or above
|
|
79
97
|
* `startDir`, or null when there is none.
|
package/foundation/fs/paths.mjs
CHANGED
|
@@ -291,6 +291,19 @@ export function homeFolder() {
|
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
+
/**
|
|
295
|
+
* Whether a relative path climbs out of the folder it starts in: `..`
|
|
296
|
+
* itself, or a path that begins with `../` (or `..` and the platform's
|
|
297
|
+
* separator). A name that only
|
|
298
|
+
* begins with two dots (`..x`) is a folder or file like any other.
|
|
299
|
+
*
|
|
300
|
+
* @param {string} rel
|
|
301
|
+
* @returns {boolean}
|
|
302
|
+
*/
|
|
303
|
+
export function climbsOut(rel) {
|
|
304
|
+
return rel === '..' || rel.startsWith('../') || rel.startsWith(`..${path.sep}`);
|
|
305
|
+
}
|
|
306
|
+
|
|
294
307
|
/**
|
|
295
308
|
* Whether `child` lies strictly inside `parent`.
|
|
296
309
|
*
|
|
@@ -298,9 +311,9 @@ export function homeFolder() {
|
|
|
298
311
|
* @param {string} parent
|
|
299
312
|
* @returns {boolean}
|
|
300
313
|
*/
|
|
301
|
-
function isInside(child, parent) {
|
|
314
|
+
export function isInside(child, parent) {
|
|
302
315
|
const rel = path.relative(parent, child);
|
|
303
|
-
return rel !== '' && !rel
|
|
316
|
+
return rel !== '' && !climbsOut(rel) && !path.isAbsolute(rel);
|
|
304
317
|
}
|
|
305
318
|
|
|
306
319
|
/**
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Whether a value is a bare npm package name, as written (lowercase).
|
|
6
|
+
* @param {unknown} name
|
|
7
|
+
* @returns {boolean}
|
|
8
|
+
*/
|
|
9
|
+
export function isPackageName(name: unknown): boolean;
|
|
4
10
|
/**
|
|
5
11
|
* Normalize an npm package name into a ProviderId.
|
|
6
12
|
* @param {string} packageName
|
|
@@ -57,6 +57,15 @@ const DOC_KINDS = new Set([
|
|
|
57
57
|
'icon-definition',
|
|
58
58
|
]);
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Whether a value is a bare npm package name, as written (lowercase).
|
|
62
|
+
* @param {unknown} name
|
|
63
|
+
* @returns {boolean}
|
|
64
|
+
*/
|
|
65
|
+
export function isPackageName(name) {
|
|
66
|
+
return typeof name === 'string' && PACKAGE_NAME_RE.test(name);
|
|
67
|
+
}
|
|
68
|
+
|
|
60
69
|
/** RFC 3986 path-segment encoding with uppercase escapes. */
|
|
61
70
|
/** @param {string} value @returns {string} */
|
|
62
71
|
function encodeSegment(value) {
|
|
@@ -92,7 +101,7 @@ function normalizeName(value, label) {
|
|
|
92
101
|
*/
|
|
93
102
|
export function normalizeProviderId(packageName) {
|
|
94
103
|
const normalized = normalizeName(packageName, 'Provider ID').toLowerCase();
|
|
95
|
-
if (!
|
|
104
|
+
if (!isPackageName(normalized)) {
|
|
96
105
|
throw new Error(
|
|
97
106
|
`Provider ID "${packageName}" must be a bare npm package name.`,
|
|
98
107
|
);
|
|
@@ -26,6 +26,7 @@ import {discoverIntegrationCodemods} from '../../assets/codemods/integration-dis
|
|
|
26
26
|
import {discoverIntegrationDocs} from '../discovery/docs-discovery.mjs';
|
|
27
27
|
import {discoverIconSetDirectory} from '../discovery/icon-set-discovery.mjs';
|
|
28
28
|
import {generatedTypesPath} from '../discovery/icon-set-paths.mjs';
|
|
29
|
+
import {compareText} from '../text/compare-text.mjs';
|
|
29
30
|
|
|
30
31
|
// ── File-walk helpers (no module imports, no execution) ──────────
|
|
31
32
|
|
|
@@ -314,7 +315,7 @@ export async function collectIdentities(loaded) {
|
|
|
314
315
|
);
|
|
315
316
|
identities.themes = themes
|
|
316
317
|
.map(t => ({slug: t.slug, exportName: t.exportName}))
|
|
317
|
-
.sort((a, b) => a.slug
|
|
318
|
+
.sort((a, b) => compareText(a.slug, b.slug));
|
|
318
319
|
} catch (err) {
|
|
319
320
|
errors.push({
|
|
320
321
|
kind: 'themes',
|
|
@@ -367,7 +368,7 @@ export async function collectIdentities(loaded) {
|
|
|
367
368
|
name: t.name,
|
|
368
369
|
...(t.replaces == null ? {} : {replaces: t.replaces}),
|
|
369
370
|
}))
|
|
370
|
-
.sort((a, b) => a.id
|
|
371
|
+
.sort((a, b) => compareText(a.id, b.id));
|
|
371
372
|
} catch (err) {
|
|
372
373
|
errors.push({
|
|
373
374
|
kind: 'templates',
|
|
@@ -385,7 +386,7 @@ export async function collectIdentities(loaded) {
|
|
|
385
386
|
for (const cm of codemods) entries.push({version, id: cm.id});
|
|
386
387
|
}
|
|
387
388
|
identities.codemods = entries.sort((a, b) =>
|
|
388
|
-
`${a.version}/${a.id}
|
|
389
|
+
compareText(`${a.version}/${a.id}`, `${b.version}/${b.id}`),
|
|
389
390
|
);
|
|
390
391
|
} catch (err) {
|
|
391
392
|
errors.push({
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {object} ExampleScopeRead
|
|
6
|
+
* @property {ExampleScope | null} scope null when there is nothing to read
|
|
7
|
+
* examples against: no package.json with a name
|
|
8
|
+
* @property {string} [reason] why `scope` is null
|
|
9
|
+
* @property {string} [incomplete] why names Core or React give could not be
|
|
10
|
+
* read: the scope then lists none of them, so a name it does not list may
|
|
11
|
+
* still be defined
|
|
12
|
+
* @property {Map<string, any>} docs each component doc that loaded, by path
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* The scope a package's component examples are read against, as JSON: the
|
|
16
|
+
* components the package documents with the import an app uses for each,
|
|
17
|
+
* the components and hooks the Core installed beside it documents, the
|
|
18
|
+
* React it resolves, the packages it declares, and its server-only modules
|
|
19
|
+
* and async components.
|
|
20
|
+
* @param {any} integration a loaded integration
|
|
21
|
+
* @returns {Promise<ExampleScopeRead>}
|
|
22
|
+
*/
|
|
23
|
+
export function exampleScopeFor(integration: any): Promise<ExampleScopeRead>;
|
|
24
|
+
/**
|
|
25
|
+
* Check every example of every component doc the package ships.
|
|
26
|
+
* @param {any} integration a loaded integration
|
|
27
|
+
* @returns {Promise<{notes: ExampleCodeNote[], unchecked: ExampleCodeUnchecked[]}>}
|
|
28
|
+
*/
|
|
29
|
+
export function exampleCodeCheck(integration: any): Promise<{
|
|
30
|
+
notes: ExampleCodeNote[];
|
|
31
|
+
unchecked: ExampleCodeUnchecked[];
|
|
32
|
+
}>;
|
|
33
|
+
export type ExampleCodeNote = {
|
|
34
|
+
code: string;
|
|
35
|
+
message: string;
|
|
36
|
+
};
|
|
37
|
+
export type ExampleCodeUnchecked = {
|
|
38
|
+
file: string;
|
|
39
|
+
example: string;
|
|
40
|
+
reason: string;
|
|
41
|
+
};
|
|
42
|
+
export type ExampleScope = import("../../authoring/example/type.ts").ExampleScope;
|
|
43
|
+
export type ExampleScopeRead = {
|
|
44
|
+
/**
|
|
45
|
+
* null when there is nothing to read
|
|
46
|
+
* examples against: no package.json with a name
|
|
47
|
+
*/
|
|
48
|
+
scope: ExampleScope | null;
|
|
49
|
+
/**
|
|
50
|
+
* why `scope` is null
|
|
51
|
+
*/
|
|
52
|
+
reason?: string | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* why names Core or React give could not be
|
|
55
|
+
* read: the scope then lists none of them, so a name it does not list may
|
|
56
|
+
* still be defined
|
|
57
|
+
*/
|
|
58
|
+
incomplete?: string | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* each component doc that loaded, by path
|
|
61
|
+
*/
|
|
62
|
+
docs: Map<string, any>;
|
|
63
|
+
};
|