@astryxdesign/cli 0.7.14-canary.g63bbda1 → 0.7.14-canary.g92e660a
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/component/_adapter.d.mts +15 -0
- package/api/component/_adapter.mjs +76 -0
- package/api/component/component.mjs +8 -1
- package/api/doctor/_adapter.d.mts +1 -0
- package/api/doctor/_adapter.mjs +8 -0
- package/api/doctor/_authoring-audit.d.mts +42 -0
- package/api/doctor/_authoring-audit.mjs +106 -0
- package/api/doctor/doctor.mjs +4 -39
- package/api/search/_candidate-score.mjs +63 -9
- package/api/search/_words.mjs +26 -6
- package/api/theme/_adapter.d.mts +33 -0
- package/api/theme/_adapter.mjs +352 -16
- package/api/theme/build/build.mjs +261 -10
- package/api/theme/eject/eject.mjs +13 -1
- package/api/theme/list/list.mjs +11 -2
- package/api/theme/template/template.mjs +139 -6
- package/api/theme/theme.type.d.mts +15 -1
- package/api/theme/theme.type.mjs +9 -3
- package/api/theme/themeAdd.doc.mjs +1 -1
- package/api/theme/themeBuild.doc.mjs +10 -2
- package/api/theme/themeEject.doc.mjs +2 -2
- package/api/theme/themeListAvailable.doc.mjs +1 -1
- package/api/theme/themeRemove.doc.mjs +1 -1
- package/api/theme/themeTemplate.doc.mjs +8 -0
- package/api/theme/themeUse.doc.mjs +1 -1
- package/api/theme-edit/_adapter.d.mts +36 -2
- package/api/theme-edit/_adapter.mjs +371 -12
- package/api/theme-edit/_check.d.mts +28 -25
- package/api/theme-edit/_check.mjs +847 -555
- package/api/theme-edit/_color.d.mts +38 -4
- package/api/theme-edit/_color.mjs +373 -74
- package/api/theme-edit/_compiler.d.mts +9 -4
- package/api/theme-edit/_compiler.mjs +65 -34
- package/api/theme-edit/_context.d.mts +10 -4
- package/api/theme-edit/_context.mjs +46 -5
- package/api/theme-edit/_edit.mjs +487 -65
- package/api/theme-edit/_how-commands.d.mts +99 -0
- package/api/theme-edit/_how-commands.mjs +320 -0
- package/api/theme-edit/_how-question.d.mts +61 -0
- package/api/theme-edit/_how-question.mjs +3096 -0
- package/api/theme-edit/_how.d.mts +25 -17
- package/api/theme-edit/_how.mjs +743 -305
- package/api/theme-edit/_palette.d.mts +153 -19
- package/api/theme-edit/_palette.mjs +1548 -397
- package/api/theme-edit/_parts.mjs +36 -3
- package/api/theme-edit/_png.d.mts +17 -5
- package/api/theme-edit/_png.mjs +136 -24
- package/api/theme-edit/_preview-app.d.mts +26 -7
- package/api/theme-edit/_preview-app.mjs +2180 -291
- package/api/theme-edit/_preview.d.mts +4 -2
- package/api/theme-edit/_preview.mjs +23 -9
- package/api/theme-edit/_settings.d.mts +129 -7
- package/api/theme-edit/_settings.mjs +711 -76
- package/api/theme-edit/_tables.d.mts +7 -12
- package/api/theme-edit/_tables.mjs +85 -97
- package/api/theme-edit/theme-edit.type.d.mts +38 -17
- package/api/theme-edit/theme-edit.type.mjs +29 -18
- package/api/theme-edit/themeEditHow.doc.mjs +13 -3
- package/api/theme-edit/themeEditNew.doc.mjs +8 -2
- package/api/theme-edit/themeEditPreviewAdd.doc.mjs +18 -5
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +12 -4
- package/api/theme-edit/themeEditPreviewList.doc.mjs +11 -2
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +33 -3
- package/api/theme-edit/themeEditSet.doc.mjs +9 -3
- package/api/theme-edit/themeEditShow.doc.mjs +6 -1
- package/api/theme-edit/themeEditUndo.doc.mjs +7 -2
- package/api/upgrade/_adapter.d.mts +1 -0
- package/assets/codemods/run-codemod.mjs +53 -0
- package/assets/codemods/runner.mjs +5 -4
- package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +3 -0
- package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +5 -1
- package/assets/codemods/transforms/v0.6.4/migrate-native-picker-to-presentation.mjs +3 -0
- package/assets/codemods/transforms/v0.7.0/rename-empty-search-results-text.mjs +17 -12
- package/assets/codemods/transforms/v0.7.2/migrate-list-edge-compensation-to-edge.mjs +3 -0
- package/assets/codemods/transforms/v0.7.5/migrate-codeblock-tokenizer-to-language.mjs +3 -0
- package/assets/codemods/transforms/v0.7.8/promote-tokenizer-presentation.mjs +3 -0
- package/assets/docs.generated.json +2 -0
- package/assets/preview-app/gitignore +3 -0
- package/assets/self-audit.generated.json +1 -0
- package/assets/templates/components.generated.json +1 -0
- package/clients/cli/bin/astryx.mjs +37 -5
- package/clients/cli/commands/ensure-core-built.mjs +12 -5
- package/clients/cli/commands/experimental/theme.mjs +291 -39
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +14 -5
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +0 -1
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +3 -2
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-preview-list.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-targets.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme.doc.mjs +2 -2
- package/clients/cli/commands/manifest.mjs +5 -2
- package/clients/cli/commands/theme-build.doc.mjs +1 -1
- package/clients/cli/commands/theme-eject.doc.mjs +3 -3
- package/clients/cli/commands/theme-remove.doc.mjs +2 -2
- package/clients/cli/commands/theme-template.doc.mjs +11 -4
- package/clients/cli/commands/theme.mjs +104 -40
- package/clients/cli/commands.generated.json +1 -0
- package/clients/cli/index.mjs +100 -6
- package/clients/cli/lib/json-shim.mjs +29 -1
- package/clients/cli/lib/manifest.mjs +33 -0
- package/clients/cli/lib/resolve-theme.mjs +2 -1
- package/clients/cli/manifest.generated.json +1 -0
- package/foundation/config/project.d.mts +16 -2
- package/foundation/config/project.mjs +40 -6
- package/foundation/config/theme-state.d.mts +9 -0
- package/foundation/config/theme-state.mjs +20 -1
- package/foundation/discovery/module-exports.mjs +16 -2
- package/foundation/discovery/stored-self-audit.d.mts +31 -0
- package/foundation/discovery/stored-self-audit.mjs +119 -0
- package/foundation/discovery/template-adapter.d.mts +12 -1
- package/foundation/discovery/template-adapter.mjs +24 -1
- package/foundation/discovery/template-needs.d.mts +7 -0
- package/foundation/discovery/template-needs.mjs +117 -8
- package/foundation/discovery/template-source-tree.d.mts +5 -1
- package/foundation/discovery/template-source-tree.mjs +6 -4
- package/foundation/discovery/theme-discovery.d.mts +14 -3
- package/foundation/discovery/theme-discovery.mjs +45 -12
- package/foundation/doc-compiler/import.mjs +70 -4
- package/foundation/doc-compiler/stored-docs.d.mts +33 -0
- package/foundation/doc-compiler/stored-docs.mjs +98 -0
- package/foundation/fs/fs-error.d.mts +17 -0
- package/foundation/fs/fs-error.mjs +34 -0
- package/foundation/fs/module-loader.mjs +7 -1
- package/foundation/integrations/validate-contributions.mjs +24 -11
- package/foundation/response/error-codes.d.mts +2 -1
- package/foundation/response/error-codes.doc.mjs +6 -0
- package/foundation/response/error-codes.mjs +5 -0
- package/package.json +6 -6
|
@@ -276,6 +276,21 @@ export function linkComponentResponse<R extends {
|
|
|
276
276
|
package?: string;
|
|
277
277
|
data?: any;
|
|
278
278
|
}>(response: R, cwd: string): Promise<R>;
|
|
279
|
+
/**
|
|
280
|
+
* When `error` is the unknown-component error for a name that is an example
|
|
281
|
+
* block, returns the same error with the commands that show the block in its
|
|
282
|
+
* message: `astryx template <Block>`, and `astryx component <Parent> --blocks`
|
|
283
|
+
* for a component whose `--blocks` listing holds the block. The code and the
|
|
284
|
+
* matcher's suggestions stay. Returns `error` unchanged otherwise.
|
|
285
|
+
* @param {unknown} error
|
|
286
|
+
* @param {string} dirName
|
|
287
|
+
* @param {{coreDir: string, cwd: string}} context
|
|
288
|
+
* @returns {Promise<unknown>}
|
|
289
|
+
*/
|
|
290
|
+
export function withExampleBlockPointer(error: unknown, dirName: string, { coreDir, cwd }: {
|
|
291
|
+
coreDir: string;
|
|
292
|
+
cwd: string;
|
|
293
|
+
}): Promise<unknown>;
|
|
279
294
|
/**
|
|
280
295
|
* Internal ambiguity marker. Single-component callers still receive the same
|
|
281
296
|
* AstryxError code, message, and suggestions; batch callers can additionally
|
|
@@ -49,6 +49,10 @@ import {
|
|
|
49
49
|
synonymMatches,
|
|
50
50
|
} from '../../foundation/text/suggest-order.mjs';
|
|
51
51
|
import {AstryxError, coreDirOrThrow} from '../error.mjs';
|
|
52
|
+
import {
|
|
53
|
+
discoverAll,
|
|
54
|
+
findRelatedBlocks,
|
|
55
|
+
} from '../../foundation/discovery/template-adapter.mjs';
|
|
52
56
|
import {levenshteinDistance} from '../../foundation/text/levenshtein.mjs';
|
|
53
57
|
import {
|
|
54
58
|
componentLinkProvider,
|
|
@@ -827,3 +831,75 @@ export async function linkComponentResponse(response, cwd) {
|
|
|
827
831
|
}
|
|
828
832
|
return {...response, data: {...response.data, components}};
|
|
829
833
|
}
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* When `error` is the unknown-component error for a name that is an example
|
|
837
|
+
* block, returns the same error with the commands that show the block in its
|
|
838
|
+
* message: `astryx template <Block>`, and `astryx component <Parent> --blocks`
|
|
839
|
+
* for a component whose `--blocks` listing holds the block. The code and the
|
|
840
|
+
* matcher's suggestions stay. Returns `error` unchanged otherwise.
|
|
841
|
+
* @param {unknown} error
|
|
842
|
+
* @param {string} dirName
|
|
843
|
+
* @param {{coreDir: string, cwd: string}} context
|
|
844
|
+
* @returns {Promise<unknown>}
|
|
845
|
+
*/
|
|
846
|
+
export async function withExampleBlockPointer(error, dirName, {coreDir, cwd}) {
|
|
847
|
+
if (
|
|
848
|
+
!(error instanceof AstryxError) ||
|
|
849
|
+
error.code !== ERROR_CODES.ERR_UNKNOWN_COMPONENT
|
|
850
|
+
) {
|
|
851
|
+
return error;
|
|
852
|
+
}
|
|
853
|
+
// A block doc that fails to load must not replace the unknown-component
|
|
854
|
+
// error and its suggestions: the pointer is extra help, so a failed lookup
|
|
855
|
+
// keeps the original error.
|
|
856
|
+
try {
|
|
857
|
+
const typed = dirName.toLowerCase();
|
|
858
|
+
const block = (await discoverAll(cwd)).find(
|
|
859
|
+
template =>
|
|
860
|
+
template.type === 'block' && template.dirName.toLowerCase() === typed,
|
|
861
|
+
);
|
|
862
|
+
if (block == null) {
|
|
863
|
+
return error;
|
|
864
|
+
}
|
|
865
|
+
const parent = await listingParent(block, coreDir, cwd);
|
|
866
|
+
const listing = parent
|
|
867
|
+
? `, and astryx component ${parent} --blocks lists it`
|
|
868
|
+
: '';
|
|
869
|
+
return new AstryxError(
|
|
870
|
+
`${error.message}. It is an example block: astryx template ${block.dirName} prints its source${listing}.`,
|
|
871
|
+
error.suggestions,
|
|
872
|
+
ERROR_CODES.ERR_UNKNOWN_COMPONENT,
|
|
873
|
+
);
|
|
874
|
+
} catch {
|
|
875
|
+
return error;
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* A component whose `component <Name> --blocks` listing holds `block`: one of
|
|
881
|
+
* the components the block uses, its own folder's component first, that
|
|
882
|
+
* resolves as a component and whose related blocks include the block.
|
|
883
|
+
* @param {{dirName: string, category?: string, componentsUsed?: string[]}} block
|
|
884
|
+
* @param {string} coreDir
|
|
885
|
+
* @param {string} cwd
|
|
886
|
+
* @returns {Promise<string | null>}
|
|
887
|
+
*/
|
|
888
|
+
async function listingParent(block, coreDir, cwd) {
|
|
889
|
+
const used = block.componentsUsed ?? [];
|
|
890
|
+
const folder = path.basename(block.category ?? '');
|
|
891
|
+
const candidates = [
|
|
892
|
+
...used.filter(name => name === folder),
|
|
893
|
+
...used.filter(name => name !== folder),
|
|
894
|
+
];
|
|
895
|
+
for (const name of candidates) {
|
|
896
|
+
if (findComponentReadme(coreDir, name) == null) {
|
|
897
|
+
continue;
|
|
898
|
+
}
|
|
899
|
+
const related = await findRelatedBlocks(name, cwd);
|
|
900
|
+
if (related.some(entry => entry.dirName === block.dirName)) {
|
|
901
|
+
return name;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
return null;
|
|
905
|
+
}
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
legacyExternalKeeps,
|
|
32
32
|
resolveCoreSourcePath,
|
|
33
33
|
resolveUnscopedDoc,
|
|
34
|
+
withExampleBlockPointer,
|
|
34
35
|
loadComponentDoc,
|
|
35
36
|
scopeSubComponent,
|
|
36
37
|
ComponentAmbiguityError,
|
|
@@ -623,7 +624,13 @@ async function componentRead(name, options = {}) {
|
|
|
623
624
|
});
|
|
624
625
|
}
|
|
625
626
|
|
|
626
|
-
const resolved = await resolveUnscopedDoc(dirName, {
|
|
627
|
+
const resolved = await resolveUnscopedDoc(dirName, {
|
|
628
|
+
coreDir,
|
|
629
|
+
cwd,
|
|
630
|
+
name,
|
|
631
|
+
}).catch(async error => {
|
|
632
|
+
throw await withExampleBlockPointer(error, dirName, {coreDir, cwd});
|
|
633
|
+
});
|
|
627
634
|
const docs = await loadComponentDoc(resolved.readmePath, docOpts);
|
|
628
635
|
|
|
629
636
|
// ── Blocks mode ──────────────────────────────────────────────
|
|
@@ -264,3 +264,4 @@ import { stateLockHolder } from '../../foundation/release/global-state.mjs';
|
|
|
264
264
|
import { displayHomePath } from '../../foundation/agent-docs/computer-agent-text.mjs';
|
|
265
265
|
export { isLocalThemeOwner, planThemeAppWrite, readThemeState, resolveThemeModule } from "../../foundation/config/theme-state.mjs";
|
|
266
266
|
export { themeBuild, validateThemePrivateInputs } from "../theme/build/build.mjs";
|
|
267
|
+
export { AUTHORING_AUDIT, authoringAudit, authoringAuditData } from "./_authoring-audit.mjs";
|
package/api/doctor/_adapter.mjs
CHANGED
|
@@ -70,6 +70,14 @@ export {themeBuild, validateThemePrivateInputs} from '../theme/build/build.mjs';
|
|
|
70
70
|
export {resolveRecordedTheme} from '../theme/theme.mjs';
|
|
71
71
|
export {collectUnloadedFonts} from '../theme/build/font-warning.mjs';
|
|
72
72
|
|
|
73
|
+
// What the authoring-docs check reads (./_authoring-audit.mjs), reached only
|
|
74
|
+
// through this adapter.
|
|
75
|
+
export {
|
|
76
|
+
AUTHORING_AUDIT,
|
|
77
|
+
authoringAudit,
|
|
78
|
+
authoringAuditData,
|
|
79
|
+
} from './_authoring-audit.mjs';
|
|
80
|
+
|
|
73
81
|
/**
|
|
74
82
|
* Package written to the generated app record for one discovered theme.
|
|
75
83
|
* @param {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme} theme
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
/**
|
|
5
|
+
* What the authoring-docs check reads: the self-docs audit, the field
|
|
6
|
+
* reference's section keys, and the authoring-surface audit. They read only
|
|
7
|
+
* the CLI's own files, so `prepack` stores them for the published package
|
|
8
|
+
* (scripts/generate-self-audit.mjs).
|
|
9
|
+
* @param {{root?: string, sources?: string[], topicKeys?: Set<string> | null}} [options]
|
|
10
|
+
* @returns {Promise<AuthoringAuditData>}
|
|
11
|
+
*/
|
|
12
|
+
export function authoringAuditData(options?: {
|
|
13
|
+
root?: string;
|
|
14
|
+
sources?: string[];
|
|
15
|
+
topicKeys?: Set<string> | null;
|
|
16
|
+
}): Promise<AuthoringAuditData>;
|
|
17
|
+
/**
|
|
18
|
+
* The authoring-docs check's data: as stored at publish while what it read is
|
|
19
|
+
* unchanged, else read now. Another tree, list or topic index (tests) is
|
|
20
|
+
* always read now.
|
|
21
|
+
* @param {{root?: string, sources?: string[], topicKeys?: Set<string> | null}} [options]
|
|
22
|
+
* @returns {Promise<AuthoringAuditData>}
|
|
23
|
+
*/
|
|
24
|
+
export function authoringAudit(options?: {
|
|
25
|
+
root?: string;
|
|
26
|
+
sources?: string[];
|
|
27
|
+
topicKeys?: Set<string> | null;
|
|
28
|
+
}): Promise<AuthoringAuditData>;
|
|
29
|
+
/** The name the authoring-docs check's data is stored under. */
|
|
30
|
+
export const AUTHORING_AUDIT: "authoring-docs";
|
|
31
|
+
export type AuthoringAuditData = {
|
|
32
|
+
audit: Awaited<ReturnType<typeof import("../../foundation/discovery/authoring-self-docs.mjs").auditAuthoringSelfDocs>>;
|
|
33
|
+
/**
|
|
34
|
+
* - The field
|
|
35
|
+
* reference's section keys, or why they could not be read.
|
|
36
|
+
*/
|
|
37
|
+
topic: {
|
|
38
|
+
keys: Set<string> | null;
|
|
39
|
+
error?: string;
|
|
40
|
+
};
|
|
41
|
+
surface: Awaited<ReturnType<typeof import("../../foundation/discovery/authoring-surface.mjs").auditAuthoringSurface>>;
|
|
42
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file What Doctor's authoring-docs check reads, kept apart from the public
|
|
5
|
+
* doctor API: api/doctor/doctor.mjs reports it, and
|
|
6
|
+
* scripts/generate-self-audit.mjs stores it at publish.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {DocsCatalog} from '../../foundation/discovery/docs-discovery.mjs';
|
|
10
|
+
import {storedSelfAudit} from '../../foundation/discovery/stored-self-audit.mjs';
|
|
11
|
+
import {indexView} from '../../foundation/doc-compiler/lenses.mjs';
|
|
12
|
+
import {guideEntry, lowerTopic, projectTree} from '../docs/_adapter.mjs';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {object} AuthoringAuditData
|
|
16
|
+
* @property {Awaited<ReturnType<typeof import('../../foundation/discovery/authoring-self-docs.mjs').auditAuthoringSelfDocs>>} audit
|
|
17
|
+
* @property {{keys: Set<string> | null, error?: string}} topic - The field
|
|
18
|
+
* reference's section keys, or why they could not be read.
|
|
19
|
+
* @property {Awaited<ReturnType<typeof import('../../foundation/discovery/authoring-surface.mjs').auditAuthoringSurface>>} surface
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The section keys the field reference lists (`astryx docs
|
|
24
|
+
* authoring/field-reference --index`), read the way that command reads them.
|
|
25
|
+
* @returns {Promise<{keys: Set<string>} | {keys: null, error: string}>}
|
|
26
|
+
*/
|
|
27
|
+
async function authoringTopicKeys() {
|
|
28
|
+
try {
|
|
29
|
+
const {AUTHORING_REFERENCE_ROUTE} =
|
|
30
|
+
await import('../../foundation/discovery/authoring-self-docs.mjs');
|
|
31
|
+
const catalog = DocsCatalog.fromBuiltins();
|
|
32
|
+
const node = (await projectTree(catalog)).get(AUTHORING_REFERENCE_ROUTE);
|
|
33
|
+
if (!node?.ref?.topicFile) {
|
|
34
|
+
return {keys: null, error: 'the docs tree has no field reference'};
|
|
35
|
+
}
|
|
36
|
+
const index = indexView(await lowerTopic(catalog, guideEntry(node)));
|
|
37
|
+
return {keys: new Set(index.sections.map(section => section.id))};
|
|
38
|
+
} catch (err) {
|
|
39
|
+
return {
|
|
40
|
+
keys: null,
|
|
41
|
+
error: err instanceof Error ? err.message : String(err),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* What the authoring-docs check reads: the self-docs audit, the field
|
|
48
|
+
* reference's section keys, and the authoring-surface audit. They read only
|
|
49
|
+
* the CLI's own files, so `prepack` stores them for the published package
|
|
50
|
+
* (scripts/generate-self-audit.mjs).
|
|
51
|
+
* @param {{root?: string, sources?: string[], topicKeys?: Set<string> | null}} [options]
|
|
52
|
+
* @returns {Promise<AuthoringAuditData>}
|
|
53
|
+
*/
|
|
54
|
+
export async function authoringAuditData(options = {}) {
|
|
55
|
+
const {auditAuthoringSelfDocs} =
|
|
56
|
+
await import('../../foundation/discovery/authoring-self-docs.mjs');
|
|
57
|
+
const {auditAuthoringSurface} =
|
|
58
|
+
await import('../../foundation/discovery/authoring-surface.mjs');
|
|
59
|
+
const {root, sources} = options;
|
|
60
|
+
const audit = await auditAuthoringSelfDocs({root, sources});
|
|
61
|
+
const topic =
|
|
62
|
+
options.topicKeys === undefined
|
|
63
|
+
? await authoringTopicKeys()
|
|
64
|
+
: {keys: options.topicKeys};
|
|
65
|
+
const surface = await auditAuthoringSurface({
|
|
66
|
+
root,
|
|
67
|
+
sources,
|
|
68
|
+
topicKeys: topic.keys,
|
|
69
|
+
});
|
|
70
|
+
return {audit, topic, surface};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The name the authoring-docs check's data is stored under. */
|
|
74
|
+
export const AUTHORING_AUDIT = 'authoring-docs';
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The authoring-docs check's data as stored at publish, while the files it
|
|
78
|
+
* read are unchanged, else undefined.
|
|
79
|
+
* @returns {AuthoringAuditData | undefined}
|
|
80
|
+
*/
|
|
81
|
+
function storedAuthoringAudit() {
|
|
82
|
+
const value = /** @type {any} */ (storedSelfAudit(AUTHORING_AUDIT));
|
|
83
|
+
if (!value) return undefined;
|
|
84
|
+
const {keys, ...rest} = value.topic;
|
|
85
|
+
return {
|
|
86
|
+
...value,
|
|
87
|
+
topic: keys === null ? {keys: null, ...rest} : {keys: new Set(keys)},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The authoring-docs check's data: as stored at publish while what it read is
|
|
93
|
+
* unchanged, else read now. Another tree, list or topic index (tests) is
|
|
94
|
+
* always read now.
|
|
95
|
+
* @param {{root?: string, sources?: string[], topicKeys?: Set<string> | null}} [options]
|
|
96
|
+
* @returns {Promise<AuthoringAuditData>}
|
|
97
|
+
*/
|
|
98
|
+
export async function authoringAudit(options = {}) {
|
|
99
|
+
const fresh =
|
|
100
|
+
options.root !== undefined ||
|
|
101
|
+
options.sources !== undefined ||
|
|
102
|
+
options.topicKeys !== undefined;
|
|
103
|
+
return (
|
|
104
|
+
(fresh ? undefined : storedAuthoringAudit()) ?? authoringAuditData(options)
|
|
105
|
+
);
|
|
106
|
+
}
|
package/api/doctor/doctor.mjs
CHANGED
|
@@ -73,12 +73,11 @@ import {
|
|
|
73
73
|
compileTopic,
|
|
74
74
|
docsLinkProblems,
|
|
75
75
|
guideEntry,
|
|
76
|
-
lowerTopic,
|
|
77
76
|
overlayLanguages,
|
|
78
77
|
projectTree,
|
|
79
78
|
} from '../docs/_adapter.mjs';
|
|
80
79
|
import {typedEdges} from '../docs/node/node.mjs';
|
|
81
|
-
import {detailView
|
|
80
|
+
import {detailView} from '../../foundation/doc-compiler/lenses.mjs';
|
|
82
81
|
import {isExperimentalTreeNode} from '../../foundation/doc-compiler/tree.mjs';
|
|
83
82
|
import {
|
|
84
83
|
semverCompare,
|
|
@@ -116,6 +115,7 @@ import {
|
|
|
116
115
|
outsideProject,
|
|
117
116
|
releaseFacts,
|
|
118
117
|
builtIntegrationPackages,
|
|
118
|
+
authoringAudit,
|
|
119
119
|
} from './_adapter.mjs';
|
|
120
120
|
import {checkBuilt} from './built-checks.mjs';
|
|
121
121
|
|
|
@@ -1307,30 +1307,6 @@ function nameTypes(names) {
|
|
|
1307
1307
|
: `${names.slice(0, NAMED_TYPES).join(', ')} and ${names.length - NAMED_TYPES} more`;
|
|
1308
1308
|
}
|
|
1309
1309
|
|
|
1310
|
-
/**
|
|
1311
|
-
* The section keys the field reference lists (`astryx docs
|
|
1312
|
-
* authoring/field-reference --index`), read the way that command reads them.
|
|
1313
|
-
* @returns {Promise<{keys: Set<string>} | {keys: null, error: string}>}
|
|
1314
|
-
*/
|
|
1315
|
-
async function authoringTopicKeys() {
|
|
1316
|
-
try {
|
|
1317
|
-
const {AUTHORING_REFERENCE_ROUTE} =
|
|
1318
|
-
await import('../../foundation/discovery/authoring-self-docs.mjs');
|
|
1319
|
-
const catalog = DocsCatalog.fromBuiltins();
|
|
1320
|
-
const node = (await projectTree(catalog)).get(AUTHORING_REFERENCE_ROUTE);
|
|
1321
|
-
if (!node?.ref?.topicFile) {
|
|
1322
|
-
return {keys: null, error: 'the docs tree has no field reference'};
|
|
1323
|
-
}
|
|
1324
|
-
const index = indexView(await lowerTopic(catalog, guideEntry(node)));
|
|
1325
|
-
return {keys: new Set(index.sections.map(section => section.id))};
|
|
1326
|
-
} catch (err) {
|
|
1327
|
-
return {
|
|
1328
|
-
keys: null,
|
|
1329
|
-
error: err instanceof Error ? err.message : String(err),
|
|
1330
|
-
};
|
|
1331
|
-
}
|
|
1332
|
-
}
|
|
1333
|
-
|
|
1334
1310
|
/**
|
|
1335
1311
|
* @param {Awaited<ReturnType<typeof import('../../foundation/discovery/authoring-surface.mjs').auditAuthoringSurface>>} surface
|
|
1336
1312
|
* @returns {string[]}
|
|
@@ -1386,12 +1362,7 @@ export async function checkAuthoringDocs(_ctx, options = {}) {
|
|
|
1386
1362
|
const id = 'authoring-docs';
|
|
1387
1363
|
const label = 'Authoring docs';
|
|
1388
1364
|
try {
|
|
1389
|
-
const {
|
|
1390
|
-
await import('../../foundation/discovery/authoring-self-docs.mjs');
|
|
1391
|
-
const {auditAuthoringSurface} =
|
|
1392
|
-
await import('../../foundation/discovery/authoring-surface.mjs');
|
|
1393
|
-
const {root, sources} = options;
|
|
1394
|
-
const audit = await auditAuthoringSelfDocs({root, sources});
|
|
1365
|
+
const {audit, topic, surface: surfaceAudit} = await authoringAudit(options);
|
|
1395
1366
|
const problems = [
|
|
1396
1367
|
...audit.unreachable.map(
|
|
1397
1368
|
source =>
|
|
@@ -1405,19 +1376,13 @@ export async function checkAuthoringDocs(_ctx, options = {}) {
|
|
|
1405
1376
|
`authoring section "${key}" is ${kilobytes(bytes)}, over the ${kilobytes(DOC_OUTPUT_BUDGET_BYTES)} one read may return`,
|
|
1406
1377
|
),
|
|
1407
1378
|
];
|
|
1408
|
-
const topic =
|
|
1409
|
-
options.topicKeys === undefined
|
|
1410
|
-
? await authoringTopicKeys()
|
|
1411
|
-
: {keys: options.topicKeys};
|
|
1412
1379
|
const surface = [
|
|
1413
1380
|
...('error' in topic
|
|
1414
1381
|
? [
|
|
1415
1382
|
`\`${formatCliCommand('docs authoring/field-reference')}\` could not be read: ${topic.error}`,
|
|
1416
1383
|
]
|
|
1417
1384
|
: []),
|
|
1418
|
-
...surfaceProblems(
|
|
1419
|
-
await auditAuthoringSurface({root, sources, topicKeys: topic.keys}),
|
|
1420
|
-
),
|
|
1385
|
+
...surfaceProblems(surfaceAudit),
|
|
1421
1386
|
];
|
|
1422
1387
|
if (problems.length + surface.length > 0) {
|
|
1423
1388
|
return {
|
|
@@ -94,6 +94,65 @@ function headOfLetters(t, name) {
|
|
|
94
94
|
/** How many of a family's members a query naming the family lists. */
|
|
95
95
|
const FAMILY_MEMBERS = 3;
|
|
96
96
|
|
|
97
|
+
/**
|
|
98
|
+
* The pattern that finds any form of a term as a whole word in prose, with
|
|
99
|
+
* any common suffix, built once per term: a search tests it against every
|
|
100
|
+
* candidate's description.
|
|
101
|
+
* @type {Map<string, RegExp>}
|
|
102
|
+
*/
|
|
103
|
+
const mentionPatterns = new Map();
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* How many terms' patterns are kept before the cache starts over. A compiled
|
|
107
|
+
* pattern is several kilobytes and a long-running caller sees ever new
|
|
108
|
+
* terms, so this cache stays small; one search uses a handful of terms.
|
|
109
|
+
*/
|
|
110
|
+
const MENTION_LIMIT = 1_000;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @param {string} term
|
|
114
|
+
* @param {ReturnType<typeof termWords>} t - the term's words
|
|
115
|
+
* @returns {RegExp}
|
|
116
|
+
*/
|
|
117
|
+
function mentionPattern(term, t) {
|
|
118
|
+
let re = mentionPatterns.get(term);
|
|
119
|
+
if (!re) {
|
|
120
|
+
if (mentionPatterns.size >= MENTION_LIMIT) mentionPatterns.clear();
|
|
121
|
+
// Any form of the term, with any common suffix: `spacing` finds
|
|
122
|
+
// "space" and "spaces", `tables` finds "table".
|
|
123
|
+
const roots = [...new Set([stem(term), ...t.forms])]
|
|
124
|
+
.filter(f => f.length >= 3)
|
|
125
|
+
.map(f => f.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
|
|
126
|
+
re = new RegExp(`\\b(?:${roots.join('|')})(s|es|ing|ed|ies)?\\b`);
|
|
127
|
+
mentionPatterns.set(term, re);
|
|
128
|
+
}
|
|
129
|
+
return re;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Each prose text lowercased once per process: a search reads every
|
|
134
|
+
* candidate's description for every term.
|
|
135
|
+
* @type {Map<string, string>}
|
|
136
|
+
*/
|
|
137
|
+
const lowered = new Map();
|
|
138
|
+
|
|
139
|
+
/** How many texts are kept lowercased before the cache starts over. */
|
|
140
|
+
const CACHE_LIMIT = 100_000;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* @param {string} text
|
|
144
|
+
* @returns {string}
|
|
145
|
+
*/
|
|
146
|
+
function lower(text) {
|
|
147
|
+
let out = lowered.get(text);
|
|
148
|
+
if (out === undefined) {
|
|
149
|
+
if (lowered.size >= CACHE_LIMIT) lowered.clear();
|
|
150
|
+
out = text.toLowerCase();
|
|
151
|
+
lowered.set(text, out);
|
|
152
|
+
}
|
|
153
|
+
return out;
|
|
154
|
+
}
|
|
155
|
+
|
|
97
156
|
/**
|
|
98
157
|
* A derived name's score for a term: 60 for the same word, 40 for a word the
|
|
99
158
|
* term starts, else 0.
|
|
@@ -308,18 +367,13 @@ export function scoreCandidate(
|
|
|
308
367
|
// Match the term's stem as a whole word, tolerating plural/gerund suffixes
|
|
309
368
|
// so "chart" matches "charts" and "filter" matches "filtering".
|
|
310
369
|
if (term.length >= 3) {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
const roots = [...new Set([stem(term), ...t.forms])]
|
|
314
|
-
.filter(f => f.length >= 3)
|
|
315
|
-
.map(f => f.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
|
|
316
|
-
const re = new RegExp(`\\b(?:${roots.join('|')})(s|es|ing|ed|ies)?\\b`);
|
|
317
|
-
if (description && re.test(description.toLowerCase())) {
|
|
370
|
+
const re = mentionPattern(term, t);
|
|
371
|
+
if (description && re.test(lower(description))) {
|
|
318
372
|
consider(50, `description mentions "${term}"`);
|
|
319
373
|
} else {
|
|
320
374
|
let matchedProse = false;
|
|
321
375
|
for (const blob of prose) {
|
|
322
|
-
if (blob && re.test(String(blob)
|
|
376
|
+
if (blob && re.test(lower(String(blob)))) {
|
|
323
377
|
consider(50, `docs mention "${term}"`);
|
|
324
378
|
matchedProse = true;
|
|
325
379
|
break;
|
|
@@ -330,7 +384,7 @@ export function scoreCandidate(
|
|
|
330
384
|
// summary. Only consulted when nothing stronger matched.
|
|
331
385
|
if (!matchedProse) {
|
|
332
386
|
for (const blob of guidance) {
|
|
333
|
-
if (blob && re.test(String(blob)
|
|
387
|
+
if (blob && re.test(lower(String(blob)))) {
|
|
334
388
|
consider(45, `guidance mentions "${term}"`);
|
|
335
389
|
break;
|
|
336
390
|
}
|
package/api/search/_words.mjs
CHANGED
|
@@ -136,14 +136,34 @@ export function sameTermWord(t, w) {
|
|
|
136
136
|
* @returns {string[]}
|
|
137
137
|
*/
|
|
138
138
|
export function wordsOf(text) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
.
|
|
143
|
-
.
|
|
144
|
-
.
|
|
139
|
+
const key = String(text);
|
|
140
|
+
let words = splitWords.get(key);
|
|
141
|
+
if (words === undefined) {
|
|
142
|
+
// A long-running caller ranks many queries; start over rather than grow.
|
|
143
|
+
if (splitWords.size >= SPLIT_WORDS_LIMIT) splitWords.clear();
|
|
144
|
+
words = Object.freeze(
|
|
145
|
+
key
|
|
146
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
147
|
+
.replace(/([A-Z])([A-Z][a-z])/g, '$1 $2')
|
|
148
|
+
.toLowerCase()
|
|
149
|
+
.split(/[^a-z0-9]+/)
|
|
150
|
+
.filter(Boolean),
|
|
151
|
+
);
|
|
152
|
+
splitWords.set(key, words);
|
|
153
|
+
}
|
|
154
|
+
return /** @type {string[]} */ (words);
|
|
145
155
|
}
|
|
146
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Each text's words, split once per process: a search splits the same names
|
|
159
|
+
* and keywords for every term of every query.
|
|
160
|
+
* @type {Map<string, readonly string[]>}
|
|
161
|
+
*/
|
|
162
|
+
const splitWords = new Map();
|
|
163
|
+
|
|
164
|
+
/** How many texts' words are kept before the cache starts over. */
|
|
165
|
+
const SPLIT_WORDS_LIMIT = 100_000;
|
|
166
|
+
|
|
147
167
|
/**
|
|
148
168
|
* Whether a term is found inside a name or keyword: it is one of its words, or
|
|
149
169
|
* the start of one (a truncation), and covers at least half of the whole
|
package/api/theme/_adapter.d.mts
CHANGED
|
@@ -16,6 +16,19 @@ export function themeRecordOwner(theme: import("../../foundation/discovery/theme
|
|
|
16
16
|
* @returns {BundledTheme[]}
|
|
17
17
|
*/
|
|
18
18
|
export function listThemes(): BundledTheme[];
|
|
19
|
+
/**
|
|
20
|
+
* A local theme folder that failed validation and was left out.
|
|
21
|
+
* @typedef {{slug: string, path: string, reason: string}} SkippedLocalTheme
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Available themes, and the local folders left out because they are broken.
|
|
25
|
+
* @param {string} [cwd]
|
|
26
|
+
* @returns {Promise<{themes: import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme[], skipped: SkippedLocalTheme[]}>}
|
|
27
|
+
*/
|
|
28
|
+
export function listAvailableThemeState(cwd?: string): Promise<{
|
|
29
|
+
themes: import("../../foundation/discovery/theme-discovery.mjs").DiscoveredTheme[];
|
|
30
|
+
skipped: SkippedLocalTheme[];
|
|
31
|
+
}>;
|
|
19
32
|
/**
|
|
20
33
|
* Bundled themes plus local and installed integration themes available to the
|
|
21
34
|
* project.
|
|
@@ -61,6 +74,18 @@ export function ejectThemeFiles(theme: import("../../foundation/discovery/theme-
|
|
|
61
74
|
targetPath?: string;
|
|
62
75
|
overwrite?: boolean;
|
|
63
76
|
}): string;
|
|
77
|
+
/**
|
|
78
|
+
* The packages the fork imports that the app does not declare. A fork that
|
|
79
|
+
* imports a missing package (bundled icon sets use `lucide-react`) fails to
|
|
80
|
+
* build, so the receipt names them with an install command.
|
|
81
|
+
* @param {string} outputDir fork folder, relative to cwd
|
|
82
|
+
* @param {string[]} files
|
|
83
|
+
* @param {string} cwd
|
|
84
|
+
*/
|
|
85
|
+
export function forkNeeds(outputDir: string, files: string[], cwd: string): {
|
|
86
|
+
missingPackages: string[];
|
|
87
|
+
installCommand: string | null;
|
|
88
|
+
};
|
|
64
89
|
/**
|
|
65
90
|
* Resolve an available theme by case-insensitive slug and optional owner package.
|
|
66
91
|
* Without an explicit package, a local theme shadows package themes that share
|
|
@@ -149,6 +174,14 @@ export function fetchCarriedThemeCoreDir(cwd: string): string | null;
|
|
|
149
174
|
* A bundled theme entry kept for the historical public `listThemes()` helper.
|
|
150
175
|
*/
|
|
151
176
|
export type BundledTheme = Pick<import("../../foundation/discovery/theme-discovery.mjs").DiscoveredTheme, "slug" | "displayName" | "description" | "maintained" | "entry" | "exportName" | "files">;
|
|
177
|
+
/**
|
|
178
|
+
* A local theme folder that failed validation and was left out.
|
|
179
|
+
*/
|
|
180
|
+
export type SkippedLocalTheme = {
|
|
181
|
+
slug: string;
|
|
182
|
+
path: string;
|
|
183
|
+
reason: string;
|
|
184
|
+
};
|
|
152
185
|
import { readThemeState } from '../../foundation/config/theme-state.mjs';
|
|
153
186
|
import { BUNDLED_THEME_PACKAGE } from '../../foundation/discovery/theme-discovery.mjs';
|
|
154
187
|
import { THEMES_DIR } from '../../foundation/discovery/theme-discovery.mjs';
|