@astryxdesign/cli 0.7.3 → 0.7.4-canary.1a552f2
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 +63 -63
- package/api/component/_adapter.mjs +4 -3
- package/api/component/component.mjs +13 -6
- package/api/component/doc-links.test.mjs +33 -0
- package/api/discover/_adapter.mjs +22 -10
- package/api/discover/_catalog-view.d.mts +2 -0
- package/api/discover/_catalog-view.mjs +1 -0
- package/api/discover/_catalog-view.test.mjs +1 -0
- package/api/discover/detail/detail.mjs +1 -0
- package/api/discover/detail/detail.test.mjs +3 -0
- package/api/discover/detail/doc/doc.mjs +5 -1
- package/api/discover/detail/doc/doc.test.mjs +1 -0
- package/api/discover/detail/item/item.mjs +2 -0
- package/api/discover/detail/item/item.test.mjs +2 -0
- package/api/discover/discover.doc.mjs +4 -4
- package/api/discover/discover.type.d.mts +20 -0
- package/api/discover/discover.type.mjs +5 -0
- package/api/discover/list/list.test.mjs +2 -0
- package/api/discover/search/search.d.mts +3 -2
- package/api/discover/search/search.mjs +26 -7
- package/api/discover/search/search.test.mjs +67 -0
- package/api/docs/_adapter.d.mts +80 -0
- package/api/docs/_adapter.mjs +261 -11
- package/api/docs/detail/detail.mjs +8 -0
- package/api/docs/docOverlays.test.mjs +2 -1
- package/api/docs/docs.d.mts +16 -6
- package/api/docs/docs.doc.mjs +1 -1
- package/api/docs/docs.mjs +55 -6
- package/api/docs/docs.type.d.mts +28 -2
- package/api/docs/docs.type.mjs +13 -3
- package/api/docs/guide-route-targets.test.mjs +1002 -0
- package/api/docs/index/index.mjs +9 -0
- package/api/docs/integration-tree.test.mjs +22 -0
- package/api/docs/integrationDocs.test.mjs +85 -0
- package/api/docs/list/list.mjs +7 -1
- package/api/docs/node/node.mjs +9 -1
- package/api/docs/reference-blocks.test.mjs +1 -1
- package/api/doctor/_adapter.d.mts +40 -0
- package/api/doctor/_adapter.mjs +171 -1
- package/api/doctor/built-checks.d.mts +85 -0
- package/api/doctor/built-checks.mjs +837 -0
- package/api/doctor/built-checks.test.mjs +531 -0
- package/api/doctor/doctor.d.mts +6 -5
- package/api/doctor/doctor.doc.mjs +11 -1
- package/api/doctor/doctor.mjs +18 -3
- package/api/doctor/doctor.type.d.mts +6 -0
- package/api/doctor/doctor.type.mjs +3 -0
- package/api/hook/list/list.d.mts +1 -1
- package/api/integration/_adapter.d.mts +11 -2
- package/api/integration/_adapter.mjs +30 -4
- package/api/integration/authoring-checks.mjs +29 -2
- package/api/integration/authoring-checks.test.mjs +131 -1
- package/api/integration/check/check.d.mts +4 -1
- package/api/integration/check/check.mjs +34 -4
- package/api/integration/check/check.test.mjs +49 -0
- package/api/integration/integration-check.type.d.mts +8 -0
- package/api/integration/integration-check.type.mjs +4 -1
- package/api/integration/integrationCheck.doc.mjs +8 -1
- package/api/integration/integrationDocConflicts.doc.mjs +1 -1
- package/api/integration/pack-check.mjs +71 -2
- package/api/integration/pack-check.test.mjs +77 -0
- package/api/integration/validate-integration-case-disk.test.mjs +2 -0
- package/api/integration/validate-integration-gaps.test.mjs +7 -4
- package/api/integration/validate-integration.mjs +96 -14
- package/api/integration/validate-integration.type.d.mts +10 -4
- package/api/integration/validate-integration.type.mjs +10 -5
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/_candidate-score.d.mts +3 -2
- package/api/search/_candidate-score.mjs +66 -3
- package/api/search/_gather-docs.mjs +12 -2
- package/api/search/_priority.mjs +2 -1
- package/api/search/_score.d.mts +2 -1
- package/api/search/_score.mjs +2 -2
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.family-members.test.mjs +124 -0
- package/api/search/search.mjs +28 -0
- package/api/theme/palette/generate/generate.d.mts +8 -0
- package/api/theme/palette/generate/generate.mjs +38 -11
- package/api/theme/palette/generate/generate.test.mjs +83 -4
- package/api/theme/palette/generate/generator.d.mts +6 -0
- package/api/theme/palette/generate/generator.mjs +6 -0
- package/api/theme/theme.type.d.mts +12 -1
- package/api/theme/theme.type.mjs +7 -1
- package/api/theme/themeBuild.doc.mjs +1 -1
- package/api/theme/themeList.doc.mjs +1 -1
- package/api/theme/themePaletteGenerate.doc.mjs +1 -1
- package/api/theme/themeTargets.doc.mjs +1 -1
- package/assets/discover/official-packages.json +16 -0
- package/assets/docs/author-a-theme.doc.mjs +15 -15
- package/assets/docs/browser-support.doc.mjs +1 -1
- package/assets/docs/getting-started.doc.mjs +16 -16
- package/assets/docs/is-my-code-good.doc.mjs +6 -6
- package/assets/docs/styling-overview.doc.mjs +5 -5
- package/assets/docs/theme.doc.mjs +5 -5
- package/assets/docs/tree/add-a-component.doc.mjs +1 -1
- package/assets/docs/tree/add-a-theme.doc.mjs +2 -2
- package/assets/docs/tree/add-a-topic.doc.mjs +6 -6
- package/assets/docs/tree/agent-guidance.doc.mjs +5 -5
- package/assets/docs/tree/authoring.doc.mjs +2 -2
- package/assets/docs/tree/block-template.doc.mjs +1 -1
- package/assets/docs/tree/check-the-props.doc.mjs +3 -3
- package/assets/docs/tree/check-your-docs.doc.mjs +6 -6
- package/assets/docs/tree/checks.doc.mjs +11 -11
- package/assets/docs/tree/ci-and-containers.doc.mjs +1 -1
- package/assets/docs/tree/cli-command.doc.mjs +6 -6
- package/assets/docs/tree/codemods.doc.mjs +7 -7
- package/assets/docs/tree/component-family.doc.mjs +1 -1
- package/assets/docs/tree/component-imports.doc.mjs +2 -2
- package/assets/docs/tree/component-lookups.doc.mjs +6 -5
- package/assets/docs/tree/computer-agent-guide.doc.mjs +7 -7
- package/assets/docs/tree/computer-integrations.doc.mjs +5 -5
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +3 -3
- package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
- package/assets/docs/tree/doc-syntax.doc.mjs +219 -0
- package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
- package/assets/docs/tree/extend-or-replace.doc.mjs +39 -7
- package/assets/docs/tree/font-setup.doc.mjs +1 -1
- package/assets/docs/tree/generate-a-palette.doc.mjs +1 -1
- package/assets/docs/tree/global-integrations.doc.mjs +11 -11
- package/assets/docs/tree/global.doc.mjs +2 -2
- package/assets/docs/tree/host-entry.doc.mjs +1 -1
- package/assets/docs/tree/install-once.doc.mjs +4 -4
- package/assets/docs/tree/layout.doc.mjs +1 -1
- package/assets/docs/tree/links.doc.mjs +2 -2
- package/assets/docs/tree/migration-setup.doc.mjs +15 -15
- package/assets/docs/tree/migration.doc.mjs +2 -1
- package/assets/docs/tree/other-libraries.doc.mjs +1 -1
- package/assets/docs/tree/page-template.doc.mjs +2 -2
- package/assets/docs/tree/problems.doc.mjs +8 -8
- package/assets/docs/tree/project-global-or-both.doc.mjs +2 -2
- package/assets/docs/tree/publishing.doc.mjs +7 -7
- package/assets/docs/tree/quick-start.doc.mjs +9 -9
- package/assets/docs/tree/reference.doc.mjs +2 -2
- package/assets/docs/tree/replace-a-core-component.doc.mjs +1 -1
- package/assets/docs/tree/replace-a-core-template.doc.mjs +4 -4
- package/assets/docs/tree/scaffold.doc.mjs +1 -1
- package/assets/docs/tree/sections-and-placement.doc.mjs +3 -3
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +3 -3
- package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
- package/assets/docs/tree/single-component.doc.mjs +4 -4
- package/assets/docs/tree/start-a-template.doc.mjs +5 -5
- package/assets/docs/tree/styling-advanced.doc.mjs +1 -1
- package/assets/docs/tree/styling-libraries.doc.mjs +2 -1
- package/assets/docs/tree/styling.doc.mjs +1 -1
- package/assets/docs/tree/tailwind.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +5 -5
- package/assets/docs/tree/test-template-in-app.doc.mjs +6 -6
- package/assets/docs/tree/tokens-and-setup.doc.mjs +1 -1
- package/assets/docs/tree/troubleshooting.doc.mjs +24 -20
- package/assets/docs/tree/uninstall.doc.mjs +2 -2
- package/assets/docs/tree/updates.doc.mjs +1 -1
- package/assets/docs/tree/upgrading.doc.mjs +3 -3
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/verify-packed-template.doc.mjs +3 -3
- package/assets/docs/tree/versioning.doc.mjs +4 -4
- package/assets/docs/tree/who-answers.doc.mjs +4 -4
- package/assets/docs/tree/write-the-template-file.doc.mjs +4 -4
- package/assets/docs/use-a-theme.doc.mjs +10 -10
- package/assets/docs/use-integrations.doc.mjs +1 -1
- package/assets/docs/working-with-ai.doc.mjs +15 -15
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.doc.mjs +1 -1
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherShowcase.doc.mjs +1 -1
- package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +54 -0
- package/assets/templates/themes/butter/butterPalettes.generated.receipt.json +1499 -0
- package/assets/templates/themes/butter/butterPalettes.generated.ts +550 -0
- package/assets/templates/themes/butter/butterTheme.ts +274 -234
- package/assets/templates/themes/butter/palette.config.json +484 -0
- package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +41 -0
- package/assets/templates/themes/gothic/gothicPalettes.generated.receipt.json +979 -0
- package/assets/templates/themes/gothic/gothicPalettes.generated.ts +271 -0
- package/assets/templates/themes/gothic/gothicTheme.ts +130 -160
- package/assets/templates/themes/gothic/palette.config.json +371 -0
- package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +51 -0
- package/assets/templates/themes/matcha/matchaPalettes.generated.receipt.json +1502 -0
- package/assets/templates/themes/matcha/matchaPalettes.generated.ts +501 -0
- package/assets/templates/themes/matcha/matchaPalettes.ts +21 -0
- package/assets/templates/themes/matcha/matchaTheme.ts +164 -103
- package/assets/templates/themes/matcha/palette.config.json +448 -0
- package/assets/templates/themes/stone/palette.config.json +262 -0
- package/assets/templates/themes/stone/stonePaletteRefs.generated.ts +51 -0
- package/assets/templates/themes/stone/stonePalettes.generated.receipt.json +840 -0
- package/assets/templates/themes/stone/stonePalettes.generated.ts +501 -0
- package/assets/templates/themes/stone/stoneTheme.ts +190 -207
- package/assets/templates/themes/y2k/palette.config.json +166 -0
- package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +54 -0
- package/assets/templates/themes/y2k/y2kPalettes.generated.receipt.json +872 -0
- package/assets/templates/themes/y2k/y2kPalettes.generated.ts +550 -0
- package/assets/templates/themes/y2k/y2kPalettes.ts +257 -0
- package/assets/templates/themes/y2k/y2kTheme.ts +164 -391
- package/authoring/codemod/codemod.doc.mjs +1 -1
- package/authoring/config/config.doc.mjs +4 -4
- package/authoring/debug/parse.d.mts +1 -1
- package/authoring/discover/discover.doc.mjs +1 -1
- package/authoring/doctypes/_schema.d.mts +4 -0
- package/authoring/doctypes/_schema.mjs +4 -0
- package/authoring/doctypes/reference/type.ts +14 -2
- package/authoring/gap-report/gap-report.doc.mjs +1 -1
- package/authoring/integration/integration.doc.mjs +6 -6
- package/clients/cli/commands/discover.mjs +1 -1
- package/clients/cli/commands/discover.sources.test.mjs +6 -0
- package/clients/cli/commands/docs.doc.mjs +1 -1
- package/clients/cli/commands/docs.mjs +27 -2
- package/clients/cli/commands/docs.test.mjs +1 -1
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
- package/clients/cli/commands/doctor.doc.mjs +13 -1
- package/clients/cli/commands/doctor.mjs +25 -9
- package/clients/cli/commands/integration-check.doc.mjs +11 -0
- package/clients/cli/commands/integration-check.test.mjs +36 -3
- package/clients/cli/commands/integration-pack.doc.mjs +1 -1
- package/clients/cli/commands/integration-verify.doc.mjs +1 -1
- package/clients/cli/commands/integration.mjs +15 -3
- package/clients/cli/commands/theme-targets.doc.mjs +1 -1
- package/clients/cli/commands/upgrade.doc.mjs +2 -2
- package/clients/cli/lib/define-command.mjs +5 -3
- package/foundation/agent-docs/agent-docs.d.mts +14 -2
- package/foundation/agent-docs/agent-docs.mjs +65 -4
- package/foundation/agent-docs/agent-docs.test.mjs +107 -0
- package/foundation/discovery/docs-discovery.d.mts +93 -2
- package/foundation/discovery/docs-discovery.mjs +237 -8
- package/foundation/discovery/runner-allowlist.d.mts +2 -0
- package/foundation/discovery/runner-allowlist.mjs +4 -0
- package/foundation/discovery/runner-commands.d.mts +29 -13
- package/foundation/discovery/runner-commands.mjs +253 -17
- package/foundation/discovery/stray-pointers.mjs +11 -5
- package/foundation/discovery/stray-pointers.test.mjs +6 -0
- package/foundation/doc-compiler/compile.mjs +8 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +3 -0
- package/foundation/doc-compiler/doc-syntax.d.mts +194 -0
- package/foundation/doc-compiler/doc-syntax.mjs +739 -0
- package/foundation/doc-compiler/doc-syntax.test.mjs +383 -0
- package/foundation/doc-compiler/links.d.mts +13 -16
- package/foundation/doc-compiler/links.mjs +40 -7
- package/foundation/doc-compiler/tree.d.mts +5 -0
- package/foundation/doc-compiler/tree.mjs +9 -0
- package/foundation/env/package-manager.d.mts +18 -0
- package/foundation/env/package-manager.mjs +40 -0
- package/foundation/integrations/cli-requirement.d.mts +29 -0
- package/foundation/integrations/cli-requirement.mjs +47 -0
- package/foundation/integrations/cli-requirement.test.mjs +23 -2
- package/foundation/response/error-codes.test.mjs +9 -0
- package/foundation/response/response-types.doc.mjs +11 -11
- package/foundation/response/response-types.doc.test.mjs +29 -0
- package/package.json +9 -9
|
@@ -24,6 +24,12 @@
|
|
|
24
24
|
import fs from 'node:fs';
|
|
25
25
|
|
|
26
26
|
import {loadTopicModule} from './docs-discovery.mjs';
|
|
27
|
+
import {
|
|
28
|
+
commandTokensIn,
|
|
29
|
+
tokenForCommand,
|
|
30
|
+
unclosedTokensIn,
|
|
31
|
+
unknownTokensIn,
|
|
32
|
+
} from '../doc-compiler/doc-syntax.mjs';
|
|
27
33
|
|
|
28
34
|
/**
|
|
29
35
|
* @param {string} file
|
|
@@ -133,20 +139,22 @@ export function runnerCommandsIn(text) {
|
|
|
133
139
|
* most commands sit in code blocks.
|
|
134
140
|
*
|
|
135
141
|
* @param {unknown} doc
|
|
136
|
-
* @returns {{text: string, section: string | null}[]}
|
|
142
|
+
* @returns {{text: string, section: string | null, lang: string | null}[]}
|
|
137
143
|
*/
|
|
138
144
|
function allStrings(doc) {
|
|
139
|
-
/** @type {{text: string, section: string | null}[]} */
|
|
145
|
+
/** @type {{text: string, section: string | null, lang: string | null}[]} */
|
|
140
146
|
const strings = [];
|
|
141
147
|
// A doc that refers back to itself is walked once.
|
|
142
148
|
const visited = new WeakSet();
|
|
143
149
|
/**
|
|
144
150
|
* @param {unknown} value
|
|
145
151
|
* @param {string | null} section
|
|
152
|
+
* @param {string | null} lang the code block's language when `value` is
|
|
153
|
+
* its code; null for text
|
|
146
154
|
*/
|
|
147
|
-
const walk = (value, section) => {
|
|
155
|
+
const walk = (value, section, lang = null) => {
|
|
148
156
|
if (typeof value === 'string') {
|
|
149
|
-
strings.push({text: value, section});
|
|
157
|
+
strings.push({text: value, section, lang});
|
|
150
158
|
} else if (value != null && typeof value === 'object') {
|
|
151
159
|
if (visited.has(value)) return;
|
|
152
160
|
visited.add(value);
|
|
@@ -160,6 +168,12 @@ function allStrings(doc) {
|
|
|
160
168
|
for (const each of field) {
|
|
161
169
|
walk(each, typeof each?.title === 'string' ? each.title : section);
|
|
162
170
|
}
|
|
171
|
+
} else if (key === 'code' && typeof field === 'string') {
|
|
172
|
+
walk(
|
|
173
|
+
field,
|
|
174
|
+
section,
|
|
175
|
+
typeof record.lang === 'string' ? record.lang : '',
|
|
176
|
+
);
|
|
163
177
|
} else {
|
|
164
178
|
walk(field, section);
|
|
165
179
|
}
|
|
@@ -196,25 +210,213 @@ function locate(lines, written, cursor) {
|
|
|
196
210
|
}
|
|
197
211
|
|
|
198
212
|
/**
|
|
199
|
-
*
|
|
213
|
+
* A command a topic writes that the doc syntax writes another way: with a
|
|
214
|
+
* runner in front (`runner_command`), a package-manager command written for
|
|
215
|
+
* one package manager (`package_manager_command`), a bare Astryx command
|
|
216
|
+
* (`plain_command`), or a doc token that does not parse (`doc_token`).
|
|
200
217
|
*
|
|
201
218
|
* @typedef {object} RunnerCommand
|
|
219
|
+
* @property {string} code
|
|
202
220
|
* @property {string} topic
|
|
203
221
|
* @property {string | null} section the title of the section it is in
|
|
204
222
|
* @property {string} file the doc file
|
|
205
223
|
* @property {number | null} line the file line that holds it, when found
|
|
206
224
|
* @property {string} command the command as written
|
|
207
|
-
* @property {string} message
|
|
225
|
+
* @property {string} message what to write instead
|
|
226
|
+
*/
|
|
227
|
+
|
|
228
|
+
/** Code-block languages whose lines are shell commands. */
|
|
229
|
+
/**
|
|
230
|
+
* Whether a package-manager command names a verb without what it acts on, so
|
|
231
|
+
* prose mentions the verb rather than giving a step: `npm run`, `pnpm dlx`,
|
|
232
|
+
* `npm i -g`, `yarn global add`, `npm pkg set`. Flags alone are not an
|
|
233
|
+
* argument.
|
|
234
|
+
* @param {string} command
|
|
235
|
+
*/
|
|
236
|
+
function isMention(command) {
|
|
237
|
+
const [, verb = '', ...rest] = command.trim().split(/\s+/);
|
|
238
|
+
const args = rest.filter(word => !word.startsWith('-'));
|
|
239
|
+
const global = rest.some(word => word === '-g' || word === '--global');
|
|
240
|
+
if (MENTION_VERBS.has(verb) && args.length === 0) return true;
|
|
241
|
+
if ((verb === 'i' || verb === 'install') && global && args.length === 0) {
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
if (verb === 'global' && args.length <= 1 && (args[0] ?? 'add') === 'add') {
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
return (
|
|
248
|
+
(verb === 'pkg' || verb === 'config') &&
|
|
249
|
+
args.length <= 1 &&
|
|
250
|
+
(args[0] ?? 'set') === 'set'
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** Package-manager verbs that take an argument: named alone, a mention. */
|
|
255
|
+
const MENTION_VERBS = new Set([
|
|
256
|
+
'run',
|
|
257
|
+
'dlx',
|
|
258
|
+
'exec',
|
|
259
|
+
'x',
|
|
260
|
+
'add',
|
|
261
|
+
'remove',
|
|
262
|
+
'rm',
|
|
263
|
+
'uninstall',
|
|
264
|
+
'create',
|
|
265
|
+
'up',
|
|
266
|
+
'upgrade',
|
|
267
|
+
]);
|
|
268
|
+
|
|
269
|
+
const SHELL_LANGS = new Set(['', 'bash', 'sh', 'shell', 'zsh', 'console']);
|
|
270
|
+
|
|
271
|
+
/** Package-manager binaries a written command may start with. */
|
|
272
|
+
const PM_START = /^(?:npm|npx|pnpm|yarn|bun|bunx)[ \t]+\S/;
|
|
273
|
+
|
|
274
|
+
/** A bare Astryx command: `astryx` and one of the CLI's commands. */
|
|
275
|
+
const PLAIN_START = new RegExp(
|
|
276
|
+
`^astryx${BLANK}(?:${alternatives(CLI_COMMANDS)})(?![\\w-])`,
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* The commands a code span or a shell line holds, each as written: split at
|
|
281
|
+
* `&&`, `||`, `;` and `|`, without a leading `$ ` or a trailing comment. A
|
|
282
|
+
* line with a quote holds one command, its first: a quoted value can hold
|
|
283
|
+
* `&&` that is not the shell's.
|
|
284
|
+
* @param {string} line
|
|
285
|
+
* @returns {string[]}
|
|
208
286
|
*/
|
|
287
|
+
function commandsOf(line) {
|
|
288
|
+
const body = line.replace(/^\s*\$\s+/, '').replace(/\s+#\s.*$/, '');
|
|
289
|
+
const parts = /["']/.test(body) ? [body] : body.split(/&&|\|\||;|\|/);
|
|
290
|
+
return parts.map(each => each.trim()).filter(Boolean);
|
|
291
|
+
}
|
|
209
292
|
|
|
210
293
|
/**
|
|
211
|
-
*
|
|
294
|
+
* The doc-syntax findings in one string of a doc, in order: runner commands,
|
|
295
|
+
* package-manager commands, bare Astryx commands and tokens that do not
|
|
296
|
+
* parse, each with what to write instead.
|
|
297
|
+
* @param {string} text
|
|
298
|
+
* @param {string | null} lang the code block's language; null for text
|
|
299
|
+
* @returns {{at: number, written: string, code: string, fix: string}[]}
|
|
300
|
+
*/
|
|
301
|
+
export function docCommandsIn(text, lang) {
|
|
302
|
+
/** @type {{at: number, written: string, code: string, fix: string}[]} */
|
|
303
|
+
const found = [];
|
|
304
|
+
const source = String(text);
|
|
305
|
+
for (const each of runnerCommandsIn(source)) {
|
|
306
|
+
found.push({
|
|
307
|
+
at: source.indexOf(each.written),
|
|
308
|
+
written: each.written,
|
|
309
|
+
code: 'runner_command',
|
|
310
|
+
fix:
|
|
311
|
+
`Write the token \`{@command ${each.bare.slice('astryx '.length) || '…'}}\`; the CLI shows it with your project's runner` +
|
|
312
|
+
(each.download
|
|
313
|
+
? ', and a download runner with the bare name fetches an unrelated package called astryx.'
|
|
314
|
+
: '.'),
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
// The commands a reader runs: code spans in text, lines in a shell block.
|
|
318
|
+
/** @type {{at: number, command: string}[]} */
|
|
319
|
+
const commands = [];
|
|
320
|
+
if (lang == null) {
|
|
321
|
+
for (const match of source.matchAll(/`([^`\n]+)`/g)) {
|
|
322
|
+
// A span that is only `astryx docs <name>` points at a doc: the
|
|
323
|
+
// stray-pointer check names the {@link} to write for it.
|
|
324
|
+
if (/^astryx docs [\w-]+$/.test(match[1].trim())) continue;
|
|
325
|
+
for (const command of commandsOf(match[1])) {
|
|
326
|
+
commands.push({at: /** @type {number} */ (match.index), command});
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
} else if (SHELL_LANGS.has(lang.toLowerCase())) {
|
|
330
|
+
let offset = 0;
|
|
331
|
+
for (const line of source.split('\n')) {
|
|
332
|
+
for (const command of commandsOf(line)) {
|
|
333
|
+
commands.push({at: offset, command});
|
|
334
|
+
}
|
|
335
|
+
offset += line.length + 1;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
for (const {at, command} of commands) {
|
|
339
|
+
if (found.some(each => command.includes(each.written))) continue;
|
|
340
|
+
if (isMention(command)) continue;
|
|
341
|
+
if (PM_START.test(command)) {
|
|
342
|
+
const token = tokenForCommand(command);
|
|
343
|
+
if (token == null || token.startsWith('{@command')) continue;
|
|
344
|
+
found.push({
|
|
345
|
+
at,
|
|
346
|
+
written: command,
|
|
347
|
+
code: 'package_manager_command',
|
|
348
|
+
fix: token.startsWith('{@pm-only')
|
|
349
|
+
? `Only ${command.split(/\s+/)[0]} runs this; write \`${token}\` with the reason readers see, or the \`{@pm …}\` step every package manager runs`
|
|
350
|
+
: `Write \`${token}\`; the CLI shows it in your reader's package manager`,
|
|
351
|
+
});
|
|
352
|
+
} else if (PLAIN_START.test(command)) {
|
|
353
|
+
found.push({
|
|
354
|
+
at,
|
|
355
|
+
written: command,
|
|
356
|
+
code: 'plain_command',
|
|
357
|
+
fix: `Write \`{@command ${command.slice('astryx'.length).trim()}}\`; the CLI shows it with your reader's runner and checks that the command exists`,
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
for (const {token, step} of commandTokensIn(source)) {
|
|
362
|
+
if ('error' in step) {
|
|
363
|
+
found.push({
|
|
364
|
+
at: source.indexOf(token),
|
|
365
|
+
written: token,
|
|
366
|
+
code: 'doc_token',
|
|
367
|
+
fix: step.error,
|
|
368
|
+
});
|
|
369
|
+
} else if (
|
|
370
|
+
step.kind === 'command' &&
|
|
371
|
+
!CLI_COMMANDS.includes(commandWord(step.args)) &&
|
|
372
|
+
// `astryx --version` and `astryx --help` stand alone.
|
|
373
|
+
!(step.args.length === 1 && STANDALONE_FLAGS.has(step.args[0]))
|
|
374
|
+
) {
|
|
375
|
+
const word = commandWord(step.args);
|
|
376
|
+
found.push({
|
|
377
|
+
at: source.indexOf(token),
|
|
378
|
+
written: token,
|
|
379
|
+
code: 'doc_token',
|
|
380
|
+
fix:
|
|
381
|
+
word === ''
|
|
382
|
+
? `This token names no Astryx command: write the command first, then its flags; the commands are ${CLI_COMMANDS.join(', ')}`
|
|
383
|
+
: `\`${word}\` is not an Astryx command; the commands are ${CLI_COMMANDS.join(', ')}`,
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
// A sample in another language has tokens of its own, such as TSDoc's
|
|
388
|
+
// `{@inheritDoc}`: only prose and shell blocks are read for doc tokens.
|
|
389
|
+
const readsTokens = lang == null || SHELL_LANGS.has(lang.toLowerCase());
|
|
390
|
+
// An unclosed doc token prints as written in any block: only the three
|
|
391
|
+
// doc token names are looked for, so another language's tags never match.
|
|
392
|
+
for (const opening of unclosedTokensIn(source)) {
|
|
393
|
+
found.push({
|
|
394
|
+
at: source.indexOf(opening),
|
|
395
|
+
written: opening,
|
|
396
|
+
code: 'doc_token',
|
|
397
|
+
fix: 'This token never closes, so it prints as written: end it with `}`, and close any quote inside it',
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
for (const token of readsTokens ? unknownTokensIn(source) : []) {
|
|
401
|
+
found.push({
|
|
402
|
+
at: source.indexOf(token),
|
|
403
|
+
written: token,
|
|
404
|
+
code: 'doc_token',
|
|
405
|
+
fix: 'Doc tokens are `{@link}`, `{@command}`, `{@pm}` and `{@pm-only}`; write `{@@…}` to show a token as written',
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
return found.sort((a, b) => a.at - b.at);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* The doc-syntax findings in a package's topics, each placed on the file line
|
|
413
|
+
* that holds it.
|
|
212
414
|
*
|
|
213
415
|
* @param {{records: {name: string, path: string}[], guides?: {name: string, ref?: {topicFile?: string}}[]}} discovered
|
|
214
416
|
* the package's docs, as discoverIntegrationDocs returns them
|
|
215
417
|
* @returns {Promise<RunnerCommand[]>}
|
|
216
418
|
*/
|
|
217
|
-
export async function
|
|
419
|
+
export async function findDocCommands(discovered) {
|
|
218
420
|
const topics = [
|
|
219
421
|
...discovered.records.map(record => ({
|
|
220
422
|
name: record.name,
|
|
@@ -238,8 +440,8 @@ export async function findRunnerCommands(discovered) {
|
|
|
238
440
|
// The doc loaded, so only the line number is lost.
|
|
239
441
|
}
|
|
240
442
|
let cursor = {line: 0, column: 0};
|
|
241
|
-
for (const {text, section} of allStrings(doc)) {
|
|
242
|
-
const commands =
|
|
443
|
+
for (const {text, section, lang} of allStrings(doc)) {
|
|
444
|
+
const commands = docCommandsIn(text, lang);
|
|
243
445
|
if (commands.length === 0) continue;
|
|
244
446
|
// A one-line string's own literal places it, wherever the walk reached
|
|
245
447
|
// it (a section in a constant above the doc object, say); else the
|
|
@@ -261,7 +463,7 @@ export async function findRunnerCommands(discovered) {
|
|
|
261
463
|
after >= 0 || text.includes('\n') ? after : lines.findIndex(holds);
|
|
262
464
|
const column = after >= 0 && after === cursor.line ? cursor.column : 0;
|
|
263
465
|
let from = literal >= 0 ? {line: literal, column} : cursor;
|
|
264
|
-
for (const {written,
|
|
466
|
+
for (const {written, code, fix} of commands) {
|
|
265
467
|
const place = locate(lines, written, from);
|
|
266
468
|
if (place) {
|
|
267
469
|
from = {line: place.line, column: place.column + written.length};
|
|
@@ -275,20 +477,54 @@ export async function findRunnerCommands(discovered) {
|
|
|
275
477
|
const line = place ? place.line + 1 : null;
|
|
276
478
|
const where = section ? ` (section "${section}")` : '';
|
|
277
479
|
found.push({
|
|
480
|
+
code,
|
|
278
481
|
topic: name,
|
|
279
482
|
section,
|
|
280
483
|
file,
|
|
281
484
|
line,
|
|
282
485
|
command: written,
|
|
283
|
-
message:
|
|
284
|
-
`"${name}"${where} writes \`${written}\`${line == null ? '' : ` (line ${line})`}. ` +
|
|
285
|
-
`Write \`${bare}\`; the CLI shows it with your project's runner` +
|
|
286
|
-
(download
|
|
287
|
-
? ', and a download runner with the bare name fetches an unrelated package called astryx.'
|
|
288
|
-
: '.'),
|
|
486
|
+
message: `"${name}"${where} writes \`${written}\`${line == null ? '' : ` (line ${line})`}. ${fix}`,
|
|
289
487
|
});
|
|
290
488
|
}
|
|
291
489
|
}
|
|
292
490
|
}
|
|
293
491
|
return found;
|
|
294
492
|
}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Runner commands in a package's topics: the `runner_command` findings of
|
|
496
|
+
* {@link findDocCommands}.
|
|
497
|
+
*
|
|
498
|
+
* @param {Parameters<typeof findDocCommands>[0]} discovered
|
|
499
|
+
* @returns {Promise<RunnerCommand[]>}
|
|
500
|
+
*/
|
|
501
|
+
export async function findRunnerCommands(discovered) {
|
|
502
|
+
return (await findDocCommands(discovered)).filter(
|
|
503
|
+
each => each.code === 'runner_command',
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/** Flags the CLI answers on their own, with no command. */
|
|
508
|
+
const STANDALONE_FLAGS = new Set(['--version', '-V', '--help', '-h']);
|
|
509
|
+
|
|
510
|
+
/** The CLI's global flags that take a value (`--detail full`). */
|
|
511
|
+
const VALUED_GLOBAL_FLAGS = new Set(['--detail', '--lang']);
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* The word a `{@command}` token names as its command: the first word that is
|
|
515
|
+
* not a global flag or the value of one (`--json component Button`,
|
|
516
|
+
* `--detail full docs acme`).
|
|
517
|
+
* @param {string[]} args
|
|
518
|
+
* @returns {string}
|
|
519
|
+
*/
|
|
520
|
+
function commandWord(args) {
|
|
521
|
+
for (let i = 0; i < args.length; i++) {
|
|
522
|
+
const arg = args[i];
|
|
523
|
+
if (VALUED_GLOBAL_FLAGS.has(arg)) {
|
|
524
|
+
i++;
|
|
525
|
+
continue;
|
|
526
|
+
}
|
|
527
|
+
if (!arg.startsWith('-')) return arg;
|
|
528
|
+
}
|
|
529
|
+
return '';
|
|
530
|
+
}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file Stray doc pointers (architecture:cli-surface DEC-8): a code span in
|
|
5
|
-
* prose that is exactly `astryx docs <name
|
|
5
|
+
* prose that is exactly `astryx docs <name>`, or its `{@command docs <name>}`
|
|
6
|
+
* token, for a doc that exists. The doc's
|
|
6
7
|
* `{@link}` prints the command that opens the doc and is checked by doctor's
|
|
7
8
|
* link check, so a written command is a pointer nothing checks.
|
|
8
9
|
*
|
|
@@ -28,7 +29,8 @@ import {
|
|
|
28
29
|
* more words, a flag, or a route is a walkthrough, not a pointer. A name holds
|
|
29
30
|
* what a topic name may (letters, digits, `_` and `-`), never opening with `-`.
|
|
30
31
|
*/
|
|
31
|
-
const POINTER =
|
|
32
|
+
const POINTER =
|
|
33
|
+
/`astryx docs ([A-Za-z0-9_][A-Za-z0-9_-]*)`|`?\{@command docs ([A-Za-z0-9_][A-Za-z0-9_-]*)\}`?/g;
|
|
32
34
|
|
|
33
35
|
/** @type {Promise<Map<string, string>> | undefined} */
|
|
34
36
|
let coreKinds;
|
|
@@ -126,7 +128,7 @@ export function linkableStrings(doc) {
|
|
|
126
128
|
* @returns {string[]} the doc name each one points at
|
|
127
129
|
*/
|
|
128
130
|
export function pointersIn(text) {
|
|
129
|
-
return [...text.matchAll(POINTER)].map(match => match[1]);
|
|
131
|
+
return [...text.matchAll(POINTER)].map(match => match[1] ?? match[2]);
|
|
130
132
|
}
|
|
131
133
|
|
|
132
134
|
/**
|
|
@@ -253,10 +255,14 @@ export async function findStrayPointers(discovered) {
|
|
|
253
255
|
const index = locateString(lines, source, text, words, cursor);
|
|
254
256
|
if (index >= 0) cursor = index + words.length;
|
|
255
257
|
for (const match of text.matchAll(POINTER)) {
|
|
256
|
-
const target = match[1];
|
|
258
|
+
const target = match[1] ?? match[2];
|
|
257
259
|
const link = linkFor(target);
|
|
258
260
|
if (!link) continue;
|
|
259
|
-
|
|
261
|
+
// As written: the bare command, or its `{@command}` token.
|
|
262
|
+
const command =
|
|
263
|
+
match[1] != null
|
|
264
|
+
? `astryx docs ${target}`
|
|
265
|
+
: match[0].replace(/`/g, '');
|
|
260
266
|
const line =
|
|
261
267
|
index < 0
|
|
262
268
|
? null
|
|
@@ -21,6 +21,12 @@ describe('pointersIn', () => {
|
|
|
21
21
|
).toEqual([]);
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
+
it('finds the {@command docs <name>} token too, with or without ticks', () => {
|
|
25
|
+
expect(
|
|
26
|
+
pointersIn('Read {@command docs theme}, then `{@command docs layout}`.'),
|
|
27
|
+
).toEqual(['theme', 'layout']);
|
|
28
|
+
});
|
|
29
|
+
|
|
24
30
|
it('leaves the bare name and a runner-written command alone', () => {
|
|
25
31
|
expect(
|
|
26
32
|
pointersIn('See astryx docs theme, or `pnpm astryx docs theme`.'),
|
|
@@ -23,7 +23,11 @@
|
|
|
23
23
|
|
|
24
24
|
import {parseTemplate} from '../../authoring/doctypes/template/parse.mjs';
|
|
25
25
|
import {parseTheme} from '../../authoring/doctypes/theme/parse.mjs';
|
|
26
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
mergeTopic,
|
|
28
|
+
problemsInTopic,
|
|
29
|
+
withoutPosition,
|
|
30
|
+
} from '../discovery/docs-discovery.mjs';
|
|
27
31
|
import {
|
|
28
32
|
sectionKey,
|
|
29
33
|
sectionKeyErrors,
|
|
@@ -179,6 +183,9 @@ export function lowerReferenceTopic(input) {
|
|
|
179
183
|
);
|
|
180
184
|
}
|
|
181
185
|
}
|
|
186
|
+
// `before` and `after` place an extension's sections while it merges; no
|
|
187
|
+
// read carries them, whether or not the doc extends anything.
|
|
188
|
+
doc = {...doc, sections: doc.sections.map(withoutPosition)};
|
|
182
189
|
// Derived keys are stamped only now, so they never take part in merging.
|
|
183
190
|
const keyed = withSectionKeys(doc);
|
|
184
191
|
/** @type {Record<string, string>} */
|
|
@@ -389,8 +389,11 @@ const LOADER_MODULES = {
|
|
|
389
389
|
'discoverIntegrationDocs',
|
|
390
390
|
'GRAPH_BLOCK_TYPES',
|
|
391
391
|
'GRAPH_ONLY_FIELDS',
|
|
392
|
+
'isGuideRoute',
|
|
392
393
|
'mergeTopic',
|
|
394
|
+
'mergeTopicReport',
|
|
393
395
|
'problemsInTopic',
|
|
396
|
+
'withoutPosition',
|
|
394
397
|
'withSourceTitle',
|
|
395
398
|
],
|
|
396
399
|
};
|
|
@@ -0,0 +1,194 @@
|
|
|
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
|
+
* Split a token body into words, keeping a double-quoted run as one word.
|
|
6
|
+
* @param {string} body
|
|
7
|
+
* @returns {string[]}
|
|
8
|
+
*/
|
|
9
|
+
export function splitWords(body: string): string[];
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {object} PmStep
|
|
12
|
+
* @property {'pm'} kind
|
|
13
|
+
* @property {typeof PM_VERBS[number]} verb
|
|
14
|
+
* @property {string[]} args packages, a script or binary and its arguments
|
|
15
|
+
* @property {Set<string>} flags
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {object} PmOnlyStep
|
|
19
|
+
* @property {'pm-only'} kind
|
|
20
|
+
* @property {DocPackageManager} manager
|
|
21
|
+
* @property {string} reason
|
|
22
|
+
* @property {string[]} args the command after the manager's name
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {object} CliStep
|
|
26
|
+
* @property {'command'} kind
|
|
27
|
+
* @property {string[]} args the command after `astryx`
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* @typedef {PmStep | PmOnlyStep | CliStep} DocStep
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* Read one token. Returns the step, or `{error}` saying what is wrong and how
|
|
34
|
+
* to write it.
|
|
35
|
+
* @param {string} name the token name, `pm` in `{@pm install x}`
|
|
36
|
+
* @param {string} body what follows the name
|
|
37
|
+
* @returns {DocStep | {error: string}}
|
|
38
|
+
*/
|
|
39
|
+
export function parseCommandToken(name: string, body?: string): DocStep | {
|
|
40
|
+
error: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* The command a package-manager step runs in one package manager.
|
|
44
|
+
* @param {PmStep} step
|
|
45
|
+
* @param {DocPackageManager} pm
|
|
46
|
+
* @returns {string}
|
|
47
|
+
*/
|
|
48
|
+
export function renderPmStep(step: PmStep, pm: DocPackageManager): string;
|
|
49
|
+
/**
|
|
50
|
+
* @typedef {object} RenderOptions
|
|
51
|
+
* @property {string} stem how the reader runs the CLI, e.g. `pnpm exec astryx`
|
|
52
|
+
* @property {DocPackageManager} pm the reader's package manager
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* One step as the reader runs it, and, for a one-manager step, the line
|
|
56
|
+
* readers see beside it.
|
|
57
|
+
* @param {DocStep} step
|
|
58
|
+
* @param {RenderOptions} options
|
|
59
|
+
* @returns {{command: string, note: string | null}}
|
|
60
|
+
*/
|
|
61
|
+
export function renderStep(step: DocStep, { stem, pm }: RenderOptions): {
|
|
62
|
+
command: string;
|
|
63
|
+
note: string | null;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* A package manager's name as readers read it.
|
|
67
|
+
* @param {DocPackageManager} pm
|
|
68
|
+
* @returns {string}
|
|
69
|
+
*/
|
|
70
|
+
export function managerName(pm: DocPackageManager): string;
|
|
71
|
+
/**
|
|
72
|
+
* Text with each `{@command}`, `{@pm}` and `{@pm-only}` token rendered for the
|
|
73
|
+
* reader, and each `{@@…}` shown as `{@…}`. A token in prose prints as a code
|
|
74
|
+
* span; in a code span or code block, as the bare command. A one-manager
|
|
75
|
+
* step's reason follows it: in prose right after the command, after a code
|
|
76
|
+
* span, in parentheses; in a shell block as a comment. A Markdown fence in
|
|
77
|
+
* prose is a code block in its language. A token that does not parse prints
|
|
78
|
+
* as written, and doctor names it.
|
|
79
|
+
* @param {string} text
|
|
80
|
+
* @param {RenderOptions} options
|
|
81
|
+
* @param {string | null} [lang] the code block's language when `text` is one
|
|
82
|
+
* block's body; omit for prose
|
|
83
|
+
* @returns {string}
|
|
84
|
+
*/
|
|
85
|
+
export function renderCommandTokens(text: string, options: RenderOptions, lang?: string | null): string;
|
|
86
|
+
/**
|
|
87
|
+
* Every command token in a text, with its parse, for doctor.
|
|
88
|
+
* @param {string} text
|
|
89
|
+
* @returns {Array<{token: string, name: string, step: DocStep | {error: string}}>}
|
|
90
|
+
*/
|
|
91
|
+
export function commandTokensIn(text: string): Array<{
|
|
92
|
+
token: string;
|
|
93
|
+
name: string;
|
|
94
|
+
step: DocStep | {
|
|
95
|
+
error: string;
|
|
96
|
+
};
|
|
97
|
+
}>;
|
|
98
|
+
/**
|
|
99
|
+
* Every `{@name …}` whose name is not a doc token, for doctor.
|
|
100
|
+
* @param {string} text
|
|
101
|
+
* @returns {string[]}
|
|
102
|
+
*/
|
|
103
|
+
export function unknownTokensIn(text: string): string[];
|
|
104
|
+
/**
|
|
105
|
+
* Each `{@command`, `{@pm` or `{@pm-only` opening (escaped with more `@`s
|
|
106
|
+
* too) that no whole token starts at: one with no closing brace, or with a
|
|
107
|
+
* quote it never closes. It prints as written, so doctor names it.
|
|
108
|
+
* @param {string} text
|
|
109
|
+
* @returns {string[]} the opening and the rest of its line
|
|
110
|
+
*/
|
|
111
|
+
export function unclosedTokensIn(text: string): string[];
|
|
112
|
+
/**
|
|
113
|
+
* The token a plain-text package-manager command should be written as, for
|
|
114
|
+
* doctor's fix: `{@pm …}` when every package manager can run it, `{@pm-only
|
|
115
|
+
* <manager> "<why>" …}` when only that one can, or null when the text is not
|
|
116
|
+
* a package-manager command. A runner in front of `astryx` is an Astryx
|
|
117
|
+
* command: `{@command …}`.
|
|
118
|
+
* @param {string} command one command, such as `npm install -D @acme/x`
|
|
119
|
+
* @returns {string | null}
|
|
120
|
+
*/
|
|
121
|
+
export function tokenForCommand(command: string): string | null;
|
|
122
|
+
/**
|
|
123
|
+
* @file The doc syntax for commands a reader runs: `{@command …}` for an
|
|
124
|
+
* Astryx command, `{@pm …}` for a package-manager step, `{@pm-only <manager>
|
|
125
|
+
* "<reason>" …}` for a step only one package manager can do, and `{@@…}` to
|
|
126
|
+
* show a token as written. Each token is rendered for the reader: an Astryx
|
|
127
|
+
* command with the reader's runner, a package-manager step in the reader's
|
|
128
|
+
* package manager.
|
|
129
|
+
*
|
|
130
|
+
* @input Doc text, the reader's CLI invocation and package manager.
|
|
131
|
+
* @output The text with each token rendered; each token's parse, for doctor;
|
|
132
|
+
* the token a plain-text command should be written as, for doctor's fix.
|
|
133
|
+
* @position foundation/doc-compiler — pure; the env lookup lives in
|
|
134
|
+
* foundation/env/package-manager.mjs.
|
|
135
|
+
*/
|
|
136
|
+
/**
|
|
137
|
+
* The package managers a `{@pm}` token renders for. `yarn-classic` is Yarn 1;
|
|
138
|
+
* `yarn` is Yarn 2 and newer.
|
|
139
|
+
* @typedef {'npm' | 'pnpm' | 'yarn' | 'yarn-classic' | 'bun'} DocPackageManager
|
|
140
|
+
*/
|
|
141
|
+
/** Every package manager a token renders for, in the order docs list them. */
|
|
142
|
+
export const DOC_PACKAGE_MANAGERS: readonly ["npm", "pnpm", "yarn", "yarn-classic", "bun"];
|
|
143
|
+
/** The verbs `{@pm}` takes, each portable across every package manager. */
|
|
144
|
+
export const PM_VERBS: readonly ["install", "remove", "update", "run", "exec", "dlx", "create"];
|
|
145
|
+
/** The flags `{@pm}` takes, and the verbs each applies to. */
|
|
146
|
+
export const PM_FLAGS: {
|
|
147
|
+
'--dev': string[];
|
|
148
|
+
'--exact': string[];
|
|
149
|
+
'--global': string[];
|
|
150
|
+
'--latest': string[];
|
|
151
|
+
};
|
|
152
|
+
/** The token names a doc may write: these and `{@link}`. */
|
|
153
|
+
export const DOC_TOKEN_NAMES: Set<string>;
|
|
154
|
+
export type PmStep = {
|
|
155
|
+
kind: "pm";
|
|
156
|
+
verb: (typeof PM_VERBS)[number];
|
|
157
|
+
/**
|
|
158
|
+
* packages, a script or binary and its arguments
|
|
159
|
+
*/
|
|
160
|
+
args: string[];
|
|
161
|
+
flags: Set<string>;
|
|
162
|
+
};
|
|
163
|
+
export type PmOnlyStep = {
|
|
164
|
+
kind: "pm-only";
|
|
165
|
+
manager: DocPackageManager;
|
|
166
|
+
reason: string;
|
|
167
|
+
/**
|
|
168
|
+
* the command after the manager's name
|
|
169
|
+
*/
|
|
170
|
+
args: string[];
|
|
171
|
+
};
|
|
172
|
+
export type CliStep = {
|
|
173
|
+
kind: "command";
|
|
174
|
+
/**
|
|
175
|
+
* the command after `astryx`
|
|
176
|
+
*/
|
|
177
|
+
args: string[];
|
|
178
|
+
};
|
|
179
|
+
export type DocStep = PmStep | PmOnlyStep | CliStep;
|
|
180
|
+
export type RenderOptions = {
|
|
181
|
+
/**
|
|
182
|
+
* how the reader runs the CLI, e.g. `pnpm exec astryx`
|
|
183
|
+
*/
|
|
184
|
+
stem: string;
|
|
185
|
+
/**
|
|
186
|
+
* the reader's package manager
|
|
187
|
+
*/
|
|
188
|
+
pm: DocPackageManager;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* The package managers a `{@pm}` token renders for. `yarn-classic` is Yarn 1;
|
|
192
|
+
* `yarn` is Yarn 2 and newer.
|
|
193
|
+
*/
|
|
194
|
+
export type DocPackageManager = "npm" | "pnpm" | "yarn" | "yarn-classic" | "bun";
|