@astryxdesign/cli 0.7.14 → 0.7.15-canary.g79b95eb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/doctor/_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.d.mts +7 -0
- package/api/doctor/doctor.mjs +24 -39
- package/api/search/_adapter.mjs +124 -3
- package/api/search/_candidate-score.mjs +63 -9
- package/api/search/_entries.d.mts +10 -0
- package/api/search/_entries.mjs +68 -1
- package/api/search/_gather-templates.d.mts +11 -0
- package/api/search/_gather-templates.mjs +22 -2
- package/api/search/_words.mjs +26 -6
- package/api/swizzle/copy/copy.mjs +1 -1
- package/api/theme/_adapter.mjs +20 -9
- package/api/theme/build/build.d.mts +15 -1
- package/api/theme/build/build.mjs +132 -32
- package/api/theme/targets/targets.d.mts +8 -0
- package/api/theme/targets/targets.mjs +14 -1
- package/api/theme/themeBuild.doc.mjs +6 -3
- package/api/theme/themeEject.doc.mjs +3 -3
- package/api/theme/themeTargets.doc.mjs +1 -1
- package/api/theme-edit/_adapter.d.mts +46 -3
- package/api/theme-edit/_adapter.mjs +372 -109
- package/api/theme-edit/_check.d.mts +6 -3
- package/api/theme-edit/_check.mjs +665 -87
- package/api/theme-edit/_color.mjs +4 -2
- package/api/theme-edit/_compiler.d.mts +2 -1
- package/api/theme-edit/_compiler.mjs +27 -13
- package/api/theme-edit/_context.d.mts +2 -1
- package/api/theme-edit/_context.mjs +47 -8
- package/api/theme-edit/_edit.d.mts +9 -3
- package/api/theme-edit/_edit.mjs +484 -66
- package/api/theme-edit/_how-commands.d.mts +33 -7
- package/api/theme-edit/_how-commands.mjs +57 -45
- package/api/theme-edit/_how-question.d.mts +4 -0
- package/api/theme-edit/_how-question.mjs +1004 -223
- package/api/theme-edit/_how.mjs +96 -9
- package/api/theme-edit/_palette.d.mts +38 -13
- package/api/theme-edit/_palette.mjs +620 -223
- package/api/theme-edit/_parts.mjs +63 -7
- package/api/theme-edit/_png.d.mts +4 -4
- package/api/theme-edit/_png.mjs +4 -2
- package/api/theme-edit/_preview-app.d.mts +6 -0
- package/api/theme-edit/_preview-app.mjs +1194 -207
- package/api/theme-edit/_preview.mjs +2 -2
- package/api/theme-edit/_project.d.mts +12 -1
- package/api/theme-edit/_project.mjs +37 -6
- package/api/theme-edit/_settings.d.mts +104 -33
- package/api/theme-edit/_settings.mjs +818 -118
- package/api/theme-edit/_tables.d.mts +7 -0
- package/api/theme-edit/_tables.mjs +61 -0
- package/api/theme-edit/theme-edit.type.d.mts +11 -1
- package/api/theme-edit/theme-edit.type.mjs +4 -3
- package/api/theme-edit/themeEditHow.doc.mjs +6 -0
- package/api/theme-edit/themeEditPreviewAdd.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewList.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +5 -1
- package/api/theme-edit/themeEditUndo.doc.mjs +1 -1
- package/api/upgrade/_adapter.d.mts +1 -0
- package/assets/codemods/run-codemod.mjs +61 -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/migrate-deprecated-theme-surface.mjs +4 -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/tree/calendars.doc.mjs +1 -3
- package/assets/docs.generated.json +2 -1
- package/assets/self-audit.generated.json +1 -0
- package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.tsx +31 -0
- package/assets/templates/components.generated.json +1 -1
- package/clients/cli/bin/astryx.mjs +19 -15
- package/clients/cli/build-id.generated.json +1 -0
- package/clients/cli/commands/ensure-core-built.mjs +12 -5
- package/clients/cli/commands/experimental/theme.mjs +178 -78
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -2
- 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-eject.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-list.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-remove.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-template.doc.mjs +4 -3
- package/clients/cli/commands/manifest.mjs +5 -2
- package/clients/cli/commands/theme.mjs +118 -22
- package/clients/cli/index.mjs +9 -3
- package/clients/cli/lib/manifest.mjs +37 -0
- package/clients/cli/lib/resolve-theme.mjs +2 -1
- package/clients/cli/manifest.generated.json +1 -0
- 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 +48 -2
- package/foundation/discovery/template-adapter.mjs +51 -19
- package/foundation/discovery/template-needs.d.mts +6 -0
- package/foundation/discovery/template-needs.mjs +20 -1
- package/foundation/discovery/template-source-tree.d.mts +7 -0
- package/foundation/discovery/template-source-tree.mjs +15 -0
- package/foundation/discovery/theme-discovery.d.mts +2 -1
- package/foundation/discovery/theme-discovery.mjs +2 -8
- package/foundation/discovery/theme-module-extensions.d.mts +18 -0
- package/foundation/discovery/theme-module-extensions.mjs +30 -0
- package/foundation/doc-compiler/import.mjs +12 -11
- package/foundation/doc-compiler/stored-docs.d.mts +18 -12
- package/foundation/doc-compiler/stored-docs.mjs +52 -19
- package/foundation/env/private-dir.d.mts +17 -0
- package/foundation/env/private-dir.mjs +42 -0
- package/foundation/fs/gather-cache.d.mts +108 -0
- package/foundation/fs/gather-cache.mjs +716 -0
- package/foundation/fs/module-loader.mjs +7 -1
- package/foundation/fs/read-record.d.mts +31 -1
- package/foundation/fs/read-record.mjs +93 -6
- package/foundation/integrations/validate-contributions.mjs +24 -11
- package/foundation/release/cache.d.mts +11 -2
- package/foundation/release/cache.mjs +59 -10
- package/foundation/release/folder-lock.d.mts +21 -0
- package/foundation/release/folder-lock.mjs +171 -0
- package/package.json +8 -6
|
@@ -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.d.mts
CHANGED
|
@@ -296,6 +296,13 @@ export function checkComputerIntegrationsAvailable({ installed, candidates, inst
|
|
|
296
296
|
install: ((name: string) => string) | null;
|
|
297
297
|
elsewhere?: boolean;
|
|
298
298
|
}): DoctorCheck;
|
|
299
|
+
/**
|
|
300
|
+
* Where `search` and `build` keep their gathered catalog between runs, and
|
|
301
|
+
* how much it holds; and, in a run under Yarn Plug'n'Play's loader, that the
|
|
302
|
+
* run keeps none (runsUnderPnp). Left out of a checkout, which keeps none.
|
|
303
|
+
* @returns {DoctorCheck | null}
|
|
304
|
+
*/
|
|
305
|
+
export function checkGatherCache(): DoctorCheck | null;
|
|
299
306
|
/**
|
|
300
307
|
* Run all diagnostic checks and return a structured report.
|
|
301
308
|
*
|
package/api/doctor/doctor.mjs
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
|
|
27
27
|
import * as fs from 'node:fs';
|
|
28
28
|
import * as path from 'node:path';
|
|
29
|
+
import {gatherCacheSummary} from '../../foundation/fs/gather-cache.mjs';
|
|
29
30
|
|
|
30
31
|
import {
|
|
31
32
|
MIN_NODE_VERSION,
|
|
@@ -73,12 +74,11 @@ import {
|
|
|
73
74
|
compileTopic,
|
|
74
75
|
docsLinkProblems,
|
|
75
76
|
guideEntry,
|
|
76
|
-
lowerTopic,
|
|
77
77
|
overlayLanguages,
|
|
78
78
|
projectTree,
|
|
79
79
|
} from '../docs/_adapter.mjs';
|
|
80
80
|
import {typedEdges} from '../docs/node/node.mjs';
|
|
81
|
-
import {detailView
|
|
81
|
+
import {detailView} from '../../foundation/doc-compiler/lenses.mjs';
|
|
82
82
|
import {isExperimentalTreeNode} from '../../foundation/doc-compiler/tree.mjs';
|
|
83
83
|
import {
|
|
84
84
|
semverCompare,
|
|
@@ -116,6 +116,7 @@ import {
|
|
|
116
116
|
outsideProject,
|
|
117
117
|
releaseFacts,
|
|
118
118
|
builtIntegrationPackages,
|
|
119
|
+
authoringAudit,
|
|
119
120
|
} from './_adapter.mjs';
|
|
120
121
|
import {checkBuilt} from './built-checks.mjs';
|
|
121
122
|
|
|
@@ -1307,30 +1308,6 @@ function nameTypes(names) {
|
|
|
1307
1308
|
: `${names.slice(0, NAMED_TYPES).join(', ')} and ${names.length - NAMED_TYPES} more`;
|
|
1308
1309
|
}
|
|
1309
1310
|
|
|
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
1311
|
/**
|
|
1335
1312
|
* @param {Awaited<ReturnType<typeof import('../../foundation/discovery/authoring-surface.mjs').auditAuthoringSurface>>} surface
|
|
1336
1313
|
* @returns {string[]}
|
|
@@ -1386,12 +1363,7 @@ export async function checkAuthoringDocs(_ctx, options = {}) {
|
|
|
1386
1363
|
const id = 'authoring-docs';
|
|
1387
1364
|
const label = 'Authoring docs';
|
|
1388
1365
|
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});
|
|
1366
|
+
const {audit, topic, surface: surfaceAudit} = await authoringAudit(options);
|
|
1395
1367
|
const problems = [
|
|
1396
1368
|
...audit.unreachable.map(
|
|
1397
1369
|
source =>
|
|
@@ -1405,19 +1377,13 @@ export async function checkAuthoringDocs(_ctx, options = {}) {
|
|
|
1405
1377
|
`authoring section "${key}" is ${kilobytes(bytes)}, over the ${kilobytes(DOC_OUTPUT_BUDGET_BYTES)} one read may return`,
|
|
1406
1378
|
),
|
|
1407
1379
|
];
|
|
1408
|
-
const topic =
|
|
1409
|
-
options.topicKeys === undefined
|
|
1410
|
-
? await authoringTopicKeys()
|
|
1411
|
-
: {keys: options.topicKeys};
|
|
1412
1380
|
const surface = [
|
|
1413
1381
|
...('error' in topic
|
|
1414
1382
|
? [
|
|
1415
1383
|
`\`${formatCliCommand('docs authoring/field-reference')}\` could not be read: ${topic.error}`,
|
|
1416
1384
|
]
|
|
1417
1385
|
: []),
|
|
1418
|
-
...surfaceProblems(
|
|
1419
|
-
await auditAuthoringSurface({root, sources, topicKeys: topic.keys}),
|
|
1420
|
-
),
|
|
1386
|
+
...surfaceProblems(surfaceAudit),
|
|
1421
1387
|
];
|
|
1422
1388
|
if (problems.length + surface.length > 0) {
|
|
1423
1389
|
return {
|
|
@@ -2212,6 +2178,24 @@ async function runComputerChecks(cwd) {
|
|
|
2212
2178
|
return {checks, summary};
|
|
2213
2179
|
}
|
|
2214
2180
|
|
|
2181
|
+
/**
|
|
2182
|
+
* Where `search` and `build` keep their gathered catalog between runs, and
|
|
2183
|
+
* how much it holds; and, in a run under Yarn Plug'n'Play's loader, that the
|
|
2184
|
+
* run keeps none (runsUnderPnp). Left out of a checkout, which keeps none.
|
|
2185
|
+
* @returns {DoctorCheck | null}
|
|
2186
|
+
*/
|
|
2187
|
+
export function checkGatherCache() {
|
|
2188
|
+
const summary = gatherCacheSummary();
|
|
2189
|
+
if (summary == null) return null;
|
|
2190
|
+
const size = `${(summary.bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
2191
|
+
return {
|
|
2192
|
+
id: 'gather-cache',
|
|
2193
|
+
label: 'Search catalog cache',
|
|
2194
|
+
status: 'info',
|
|
2195
|
+
message: `search and build keep the catalogs they gather in ${summary.dir} (${summary.entries} ${summary.entries === 1 ? 'entry' : 'entries'}, ${size})${summary.pnp ? ", but not in a run under Yarn Plug'n'Play's loader, such as `yarn astryx`, which gathers every time" : ''}; a catalog is used only while nothing it read has changed, and deleting the folder clears it.`,
|
|
2196
|
+
};
|
|
2197
|
+
}
|
|
2198
|
+
|
|
2215
2199
|
/**
|
|
2216
2200
|
* Ordered list of synchronous check functions. Append here to add a check.
|
|
2217
2201
|
* (checkConfig is async and is awaited separately by {@link runChecks}.)
|
|
@@ -2232,6 +2216,7 @@ export const SYNC_CHECKS = [
|
|
|
2232
2216
|
checkPeerDeps,
|
|
2233
2217
|
checkPackageManager,
|
|
2234
2218
|
checkCliCommand,
|
|
2219
|
+
checkGatherCache,
|
|
2235
2220
|
];
|
|
2236
2221
|
|
|
2237
2222
|
/**
|
package/api/search/_adapter.mjs
CHANGED
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
* domain, _gather-*.mjs) and loads the tree's static data before it runs.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {readFileSync} from 'node:fs';
|
|
9
|
+
import {readFileSync, realpathSync} from 'node:fs';
|
|
10
10
|
import * as path from 'node:path';
|
|
11
11
|
import {requireCoreDir} from '../../foundation/fs/paths.mjs';
|
|
12
12
|
import {withListingCache} from '../../foundation/fs/listing-cache.mjs';
|
|
13
|
+
import {persistedGather} from '../../foundation/fs/gather-cache.mjs';
|
|
13
14
|
import {
|
|
14
15
|
reusedWhileUnchanged,
|
|
15
16
|
unchangedSince,
|
|
@@ -21,7 +22,12 @@ import {CORELESS_DOMAINS} from './_query.mjs';
|
|
|
21
22
|
import {gatherComponents} from './_gather-components.mjs';
|
|
22
23
|
import {gatherHooks} from './_gather-hooks.mjs';
|
|
23
24
|
import {gatherDocs} from './_gather-docs.mjs';
|
|
24
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
derivedFromSource,
|
|
27
|
+
gatherTemplates,
|
|
28
|
+
gatherThemes,
|
|
29
|
+
} from './_gather-templates.mjs';
|
|
30
|
+
import {componentsInSource} from '../../foundation/discovery/template-adapter.mjs';
|
|
25
31
|
|
|
26
32
|
export {componentKeywords} from './_gather-components.mjs';
|
|
27
33
|
|
|
@@ -124,6 +130,112 @@ async function gatherDomains(options) {
|
|
|
124
130
|
};
|
|
125
131
|
}
|
|
126
132
|
|
|
133
|
+
/**
|
|
134
|
+
* The folder's real path, so a link and its target share a kept gather.
|
|
135
|
+
* @param {string} dir
|
|
136
|
+
* @returns {string}
|
|
137
|
+
*/
|
|
138
|
+
function realFolder(dir) {
|
|
139
|
+
try {
|
|
140
|
+
return realpathSync(dir);
|
|
141
|
+
} catch {
|
|
142
|
+
return dir;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* A gathered catalog as plain JSON and back, for a gather kept between runs
|
|
148
|
+
* (persistedGather). A template's derived component names are read once and
|
|
149
|
+
* stored as their value; `components` is stored by position in `all`, whose
|
|
150
|
+
* objects it shares.
|
|
151
|
+
*/
|
|
152
|
+
const GATHER_CODEC = {
|
|
153
|
+
/**
|
|
154
|
+
* @param {any} gathered
|
|
155
|
+
* @returns {any}
|
|
156
|
+
*/
|
|
157
|
+
encode(gathered) {
|
|
158
|
+
const position = new Map(
|
|
159
|
+
gathered.all.map((/** @type {any} */ c, /** @type {number} */ i) => [
|
|
160
|
+
c,
|
|
161
|
+
i,
|
|
162
|
+
]),
|
|
163
|
+
);
|
|
164
|
+
return {
|
|
165
|
+
...gathered,
|
|
166
|
+
all: gathered.all.map((/** @type {any} */ c) => {
|
|
167
|
+
if (!Object.getOwnPropertyDescriptor(c, 'weakKeywords')?.get) return c;
|
|
168
|
+
// The names come from the source file, read again when first asked
|
|
169
|
+
// for (its content is one of the stored inputs); a source that could
|
|
170
|
+
// not be read derives none.
|
|
171
|
+
const from = derivedFromSource.get(c);
|
|
172
|
+
const names = from?.derivedSoFar();
|
|
173
|
+
/** @type {Record<string, unknown>} */
|
|
174
|
+
const out = {};
|
|
175
|
+
for (const k of Object.keys(c)) {
|
|
176
|
+
out[k] =
|
|
177
|
+
k === 'weakKeywords'
|
|
178
|
+
? {[DERIVED]: names ?? from?.file ?? null}
|
|
179
|
+
: c[k];
|
|
180
|
+
}
|
|
181
|
+
return out;
|
|
182
|
+
}),
|
|
183
|
+
components: gathered.components.map((/** @type {any} */ c) =>
|
|
184
|
+
position.get(c),
|
|
185
|
+
),
|
|
186
|
+
};
|
|
187
|
+
},
|
|
188
|
+
/**
|
|
189
|
+
* @param {any} stored
|
|
190
|
+
* @returns {any}
|
|
191
|
+
*/
|
|
192
|
+
decode(stored) {
|
|
193
|
+
const all = stored.all.map((/** @type {any} */ c) => {
|
|
194
|
+
const stored = c.weakKeywords?.[DERIVED];
|
|
195
|
+
if (stored === undefined) return c;
|
|
196
|
+
// Names read by the run that stored them, or the file to read them from.
|
|
197
|
+
const file = typeof stored === 'string' ? stored : null;
|
|
198
|
+
/** @type {string[] | undefined} */
|
|
199
|
+
let derived = Array.isArray(stored) ? stored : undefined;
|
|
200
|
+
const derive = () => {
|
|
201
|
+
if (derived === undefined) {
|
|
202
|
+
try {
|
|
203
|
+
derived =
|
|
204
|
+
file == null
|
|
205
|
+
? []
|
|
206
|
+
: componentsInSource(readFileSync(file, 'utf-8'));
|
|
207
|
+
} catch {
|
|
208
|
+
derived = [];
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return derived;
|
|
212
|
+
};
|
|
213
|
+
/** @type {Record<string, unknown>} */
|
|
214
|
+
const out = {};
|
|
215
|
+
for (const k of Object.keys(c)) {
|
|
216
|
+
if (k === 'weakKeywords') {
|
|
217
|
+
Object.defineProperty(out, k, {
|
|
218
|
+
get: derive,
|
|
219
|
+
enumerable: true,
|
|
220
|
+
configurable: true,
|
|
221
|
+
});
|
|
222
|
+
} else {
|
|
223
|
+
out[k] = c[k];
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return out;
|
|
227
|
+
});
|
|
228
|
+
return {
|
|
229
|
+
...stored,
|
|
230
|
+
all,
|
|
231
|
+
components: stored.components.map((/** @type {number} */ i) => all[i]),
|
|
232
|
+
};
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
/** The key a stored template's derived component names sit under. */
|
|
237
|
+
const DERIVED = '\0derived';
|
|
238
|
+
|
|
127
239
|
/**
|
|
128
240
|
* @typedef {Awaited<ReturnType<typeof gatherCandidates>>} Gathered
|
|
129
241
|
* @type {Map<string, (options?: {fresh?: boolean}) => Promise<Gathered>>}
|
|
@@ -150,7 +262,16 @@ export function gatherCandidatesReused(options) {
|
|
|
150
262
|
let gather = gathered.get(key);
|
|
151
263
|
if (!gather) {
|
|
152
264
|
gather = reusedWhileUnchanged(
|
|
153
|
-
() =>
|
|
265
|
+
() =>
|
|
266
|
+
persistedGather(
|
|
267
|
+
[realFolder(cwd), type ?? null],
|
|
268
|
+
() => gatherCandidates({cwd, type}),
|
|
269
|
+
GATHER_CODEC,
|
|
270
|
+
// A gather that skipped Core (a failed install still in its
|
|
271
|
+
// backoff, spec:AST-081 FR2) is not kept: once the backoff ends,
|
|
272
|
+
// the next run must try again.
|
|
273
|
+
value => value.coreSkipped == null,
|
|
274
|
+
),
|
|
154
275
|
unchangedSince,
|
|
155
276
|
);
|
|
156
277
|
gathered.set(key, gather);
|
|
@@ -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
|
}
|
|
@@ -13,6 +13,16 @@ export function entryTable(all: any[], cards: Record<string, {
|
|
|
13
13
|
synonyms?: string[];
|
|
14
14
|
props?: string[];
|
|
15
15
|
}>): EntryTable;
|
|
16
|
+
/**
|
|
17
|
+
* A table's plain-JSON form and back. Candidates are kept as their place in
|
|
18
|
+
* `all`, maps as their entries in order, so the table reads back the same.
|
|
19
|
+
* @param {any[]} all
|
|
20
|
+
* @returns {{encode: (table: EntryTable) => any, decode: (stored: any) => EntryTable}}
|
|
21
|
+
*/
|
|
22
|
+
export function tableCodec(all: any[]): {
|
|
23
|
+
encode: (table: EntryTable) => any;
|
|
24
|
+
decode: (stored: any) => EntryTable;
|
|
25
|
+
};
|
|
16
26
|
/**
|
|
17
27
|
* @param {any[]} all
|
|
18
28
|
* @param {Record<string, {what?: string, synonyms?: string[], props?: string[]}>} cards
|
package/api/search/_entries.mjs
CHANGED
|
@@ -8,6 +8,16 @@
|
|
|
8
8
|
|
|
9
9
|
import {createHash} from 'node:crypto';
|
|
10
10
|
import {DOMAINS, words, fold, nameWords} from './_query-words.mjs';
|
|
11
|
+
import {fileURLToPath} from 'node:url';
|
|
12
|
+
import {persistedDerived} from '../../foundation/fs/gather-cache.mjs';
|
|
13
|
+
|
|
14
|
+
/** This module and the word rules it builds entries with, by path. */
|
|
15
|
+
const ENTRIES_FILE = fileURLToPath(import.meta.url);
|
|
16
|
+
const QUERY_WORDS_FILE = fileURLToPath(
|
|
17
|
+
new URL('./_query-words.mjs', import.meta.url),
|
|
18
|
+
);
|
|
19
|
+
/** The cards search reads (./_adapter.mjs), by path. */
|
|
20
|
+
const CARDS_FILE = fileURLToPath(new URL('./_cards.json', import.meta.url));
|
|
11
21
|
|
|
12
22
|
/** @param {string[]} list @returns {Map<string, number>} */
|
|
13
23
|
const counts = list => {
|
|
@@ -65,7 +75,16 @@ export function entryTable(all, cards) {
|
|
|
65
75
|
tables.set(all, last.table);
|
|
66
76
|
return last.table;
|
|
67
77
|
}
|
|
68
|
-
|
|
78
|
+
// The table is a function of the text it is built from: kept beside the
|
|
79
|
+
// catalog, a later run with the same catalog reads it back.
|
|
80
|
+
const built = persistedDerived(
|
|
81
|
+
['entry-table', key],
|
|
82
|
+
() => buildTable(all, cards),
|
|
83
|
+
tableCodec(all),
|
|
84
|
+
// The code that builds it, loaded or not when the table is kept, and the
|
|
85
|
+
// cards it reads, which search reads after the catalog is kept.
|
|
86
|
+
[ENTRIES_FILE, QUERY_WORDS_FILE, CARDS_FILE],
|
|
87
|
+
);
|
|
69
88
|
last = {key, table: built};
|
|
70
89
|
tables.set(all, built);
|
|
71
90
|
return built;
|
|
@@ -73,6 +92,54 @@ export function entryTable(all, cards) {
|
|
|
73
92
|
|
|
74
93
|
/** @type {{key: string, table: EntryTable} | null} */
|
|
75
94
|
let last = null;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* A table's plain-JSON form and back. Candidates are kept as their place in
|
|
98
|
+
* `all`, maps as their entries in order, so the table reads back the same.
|
|
99
|
+
* @param {any[]} all
|
|
100
|
+
* @returns {{encode: (table: EntryTable) => any, decode: (stored: any) => EntryTable}}
|
|
101
|
+
*/
|
|
102
|
+
export function tableCodec(all) {
|
|
103
|
+
return {
|
|
104
|
+
encode(table) {
|
|
105
|
+
const place = new Map(all.map((c, k) => [c, k]));
|
|
106
|
+
const t = /** @type {any} */ (table);
|
|
107
|
+
return {
|
|
108
|
+
ids: t.ids,
|
|
109
|
+
candidate: t.candidate.map((/** @type {any} */ c) => place.get(c)),
|
|
110
|
+
domain: t.domain,
|
|
111
|
+
name: t.name,
|
|
112
|
+
fields: Object.fromEntries(
|
|
113
|
+
Object.entries(t.fields).map(([f, {post, idf, len, avg}]) => [
|
|
114
|
+
f,
|
|
115
|
+
{post: [...post], idf: [...idf], len, avg},
|
|
116
|
+
]),
|
|
117
|
+
),
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
decode(stored) {
|
|
121
|
+
return /** @type {EntryTable} */ (
|
|
122
|
+
/** @type {unknown} */ ({
|
|
123
|
+
ids: stored.ids,
|
|
124
|
+
index: new Map(
|
|
125
|
+
stored.ids.map(
|
|
126
|
+
(/** @type {string} */ id, /** @type {number} */ k) => [id, k],
|
|
127
|
+
),
|
|
128
|
+
),
|
|
129
|
+
candidate: stored.candidate.map((/** @type {number} */ k) => all[k]),
|
|
130
|
+
domain: stored.domain,
|
|
131
|
+
name: stored.name,
|
|
132
|
+
fields: Object.fromEntries(
|
|
133
|
+
Object.entries(stored.fields).map(([f, {post, idf, len, avg}]) => [
|
|
134
|
+
f,
|
|
135
|
+
{post: new Map(post), idf: new Map(idf), len, avg},
|
|
136
|
+
]),
|
|
137
|
+
),
|
|
138
|
+
})
|
|
139
|
+
);
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
76
143
|
/** @type {WeakMap<object, number>} */
|
|
77
144
|
const cardIds = new WeakMap();
|
|
78
145
|
let nextCardId = 0;
|