pterodoc 0.2.0

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/lib/cli/run.js ADDED
@@ -0,0 +1,447 @@
1
+ import path from 'node:path';
2
+ import fs from 'node:fs/promises';
3
+ import { ConfigError, EXIT, VERSION, loadConfig, TargetError, PterodocError, runSync } from '@pterodoc/core';
4
+ import { formatIssue, compareSeverity } from '@pterodoc/core/util';
5
+ import { createDocusaurusReader } from '@pterodoc/docusaurus';
6
+ import { writeCapture, createCaptureReader } from '@pterodoc/core/model';
7
+ import { r as resolveTarget } from '../chunks/target-BC_VOAlJ.js';
8
+ import { detectPlugin, WpClient, DEFAULT_RETRY } from '@pterodoc/wordpress';
9
+ import { parseArgs } from 'node:util';
10
+
11
+ /** Command line parsing and the usage text. */
12
+ /** Commands the CLI accepts. */
13
+ const COMMANDS = ['sync', 'render', 'doctor', 'capture', 'init'];
14
+ /** The help text. */
15
+ const USAGE = `Publish a Docusaurus site to WordPress as a tree of pages.
16
+
17
+ Usage: pterodoc <command> [options]
18
+
19
+ Commands
20
+ sync Reconcile the target with the site. The default.
21
+ render Render every page to the output directory; contacts nothing.
22
+ doctor Check the configuration, the credentials and the target.
23
+ capture Write the loaded site model to a JSON file.
24
+ init Write a starter pterodoc.config.mjs.
25
+
26
+ Source
27
+ --site-dir <dir> Docusaurus site directory (default: the working directory).
28
+ --config <file> pterodoc config file.
29
+ --docusaurus-config <file> Explicit docusaurus.config.* path.
30
+ --model <file> Use a captured model; Docusaurus is never loaded.
31
+ --instance <id> Docs plugin instance. Repeatable.
32
+ --locale <code> Locale to publish. Repeatable.
33
+ --all-locales Publish every locale the site declares.
34
+ --docs-version <name> Version to publish. Repeatable.
35
+ --all-versions Publish every version.
36
+
37
+ Target
38
+ --root <path> Path the documentation hangs from.
39
+ --base <segment> Segment below the root ("" publishes under the root).
40
+ --status <status> publish, draft or private.
41
+ --only <prefix> Restrict writes to pages under <prefix>.
42
+ --dry-run Plan and render, change nothing.
43
+ --prune Trash pages with no source document.
44
+ --offline Render only; never open a session.
45
+ --no-media Skip uploads; leave image URLs as written.
46
+
47
+ Output
48
+ --out <dir> Output directory (default <site-dir>/.pterodoc).
49
+ --capture <file> Also write the site model to <file>.
50
+ --env-file <file> Read this .env file. None is read otherwise.
51
+ --strict Fail when an issue reaches the configured severity.
52
+ --json Print a machine-readable summary.
53
+ --verbose Log every page as it is processed.
54
+ --quiet Only print errors.
55
+ --help, --version
56
+
57
+ Credentials come from the environment: WP_URL, WP_USER, WP_APP_PASSWORD.
58
+ Without them every command still renders and reports what it would have done.`;
59
+ /**
60
+ * Parse the command line.
61
+ *
62
+ * @param argv Arguments after the executable and script name.
63
+ */
64
+ function parseCliArgs(argv) {
65
+ let values;
66
+ let positionals;
67
+ try {
68
+ ({ values, positionals } = parseArgs({
69
+ args: argv,
70
+ allowPositionals: true,
71
+ strict: true,
72
+ options: {
73
+ 'site-dir': { type: 'string' },
74
+ config: { type: 'string' },
75
+ 'docusaurus-config': { type: 'string' },
76
+ model: { type: 'string' },
77
+ instance: { type: 'string', multiple: true },
78
+ locale: { type: 'string', multiple: true },
79
+ 'all-locales': { type: 'boolean' },
80
+ 'docs-version': { type: 'string', multiple: true },
81
+ 'all-versions': { type: 'boolean' },
82
+ root: { type: 'string' },
83
+ base: { type: 'string' },
84
+ status: { type: 'string' },
85
+ only: { type: 'string' },
86
+ 'dry-run': { type: 'boolean' },
87
+ prune: { type: 'boolean' },
88
+ offline: { type: 'boolean' },
89
+ 'no-media': { type: 'boolean' },
90
+ out: { type: 'string' },
91
+ capture: { type: 'string' },
92
+ 'env-file': { type: 'string' },
93
+ strict: { type: 'boolean' },
94
+ json: { type: 'boolean' },
95
+ verbose: { type: 'boolean' },
96
+ quiet: { type: 'boolean' },
97
+ help: { type: 'boolean' },
98
+ version: { type: 'boolean' },
99
+ },
100
+ }));
101
+ }
102
+ catch (error) {
103
+ throw new ConfigError(`${error.message}\n\n${USAGE}`);
104
+ }
105
+ const [first] = positionals;
106
+ if (first !== undefined && !COMMANDS.includes(first)) {
107
+ throw new ConfigError(`Unknown command "${first}".\n\n${USAGE}`);
108
+ }
109
+ if (positionals.length > 1) {
110
+ throw new ConfigError(`Expected one command but got ${positionals.length}.\n\n${USAGE}`);
111
+ }
112
+ const flags = {
113
+ siteDir: values['site-dir'],
114
+ config: values['config'],
115
+ docusaurusConfig: values['docusaurus-config'],
116
+ model: values['model'],
117
+ instance: values['instance'],
118
+ locale: values['locale'],
119
+ allLocales: values['all-locales'],
120
+ docsVersion: values['docs-version'],
121
+ allVersions: values['all-versions'],
122
+ root: values['root'],
123
+ base: values['base'],
124
+ status: values['status'],
125
+ only: values['only'],
126
+ out: values['out'],
127
+ dryRun: values['dry-run'],
128
+ prune: values['prune'],
129
+ offline: values['offline'],
130
+ noMedia: values['no-media'],
131
+ strict: values['strict'],
132
+ envFile: values['env-file'],
133
+ };
134
+ return {
135
+ command: first ?? 'sync',
136
+ flags,
137
+ capture: values['capture'],
138
+ json: values['json'] === true,
139
+ verbose: values['verbose'] === true,
140
+ quiet: values['quiet'] === true,
141
+ help: values['help'] === true,
142
+ version: values['version'] === true,
143
+ };
144
+ }
145
+
146
+ /**
147
+ * What the user sees.
148
+ *
149
+ * GitHub Actions gets annotations it can surface on the run; a terminal gets
150
+ * something readable.
151
+ */
152
+ /** Build a reporter. */
153
+ function createReporter(options) {
154
+ const env = options.env ?? process.env;
155
+ const inActions = Boolean(env['GITHUB_ACTIONS']);
156
+ const quiet = options.quiet === true || options.json === true;
157
+ const annotate = (severity) => severity === 'error' ? 'error' : severity === 'warning' ? 'warning' : 'notice';
158
+ return {
159
+ info(message) {
160
+ if (!quiet)
161
+ process.stdout.write(`${message}\n`);
162
+ },
163
+ detail(message) {
164
+ if (options.verbose && !quiet)
165
+ process.stdout.write(` ${message}\n`);
166
+ },
167
+ issue(issue) {
168
+ const text = formatIssue(issue);
169
+ if (inActions) {
170
+ process.stderr.write(`::${annotate(issue.severity)} title=${issue.code}::${text}\n`);
171
+ return;
172
+ }
173
+ if (issue.severity === 'info' && !options.verbose)
174
+ return;
175
+ if (quiet && issue.severity !== 'error')
176
+ return;
177
+ process.stderr.write(` ${issue.severity === 'error' ? '✗' : '!'} ${text}\n`);
178
+ },
179
+ summary(plan) {
180
+ if (options.json) {
181
+ process.stdout.write(`${JSON.stringify(plan, null, 2)}\n`);
182
+ return;
183
+ }
184
+ const order = ['create-root', 'create', 'update', 'unchanged', 'prune', 'upload-media', 'reuse-media'];
185
+ const parts = order
186
+ .filter((op) => plan.summary[op])
187
+ .map((op) => `${plan.summary[op]} ${op.replace('-', ' ')}`);
188
+ process.stdout.write(`\n${parts.join(', ') || 'nothing to do'}`);
189
+ if (plan.requests)
190
+ process.stdout.write(` · ${plan.requests} requests`);
191
+ process.stdout.write('\n');
192
+ },
193
+ };
194
+ }
195
+
196
+ /**
197
+ * Command line entry point.
198
+ *
199
+ * The only place that catches: every other module raises, and this decides how
200
+ * it is shown and which exit code it becomes.
201
+ */
202
+ /** Run the CLI. */
203
+ async function main(argv) {
204
+ let parsed;
205
+ try {
206
+ parsed = parseCliArgs(argv);
207
+ }
208
+ catch (error) {
209
+ return report(error);
210
+ }
211
+ if (parsed.help) {
212
+ process.stdout.write(`${USAGE}\n`);
213
+ return EXIT.ok;
214
+ }
215
+ if (parsed.version) {
216
+ process.stdout.write(`${VERSION}\n`);
217
+ return EXIT.ok;
218
+ }
219
+ const reporter = createReporter({
220
+ verbose: parsed.verbose,
221
+ quiet: parsed.quiet,
222
+ json: parsed.json,
223
+ });
224
+ try {
225
+ const config = await loadConfig(parsed.flags);
226
+ for (const notice of config.notices)
227
+ reporter.info(`note: ${notice}`);
228
+ switch (parsed.command) {
229
+ case 'init':
230
+ return await commandInit(config, reporter);
231
+ case 'capture':
232
+ return await commandCapture(config, parsed, reporter);
233
+ case 'doctor':
234
+ return await commandDoctor(config, reporter);
235
+ case 'render':
236
+ case 'sync':
237
+ return await commandSync(config, parsed, reporter);
238
+ default:
239
+ return EXIT.ok;
240
+ }
241
+ }
242
+ catch (error) {
243
+ return report(error);
244
+ }
245
+ }
246
+ /** Build the reader the commands share. */
247
+ function readerFor(config, reporter) {
248
+ if (config.modelFile)
249
+ return createCaptureReader(config.modelFile);
250
+ return createDocusaurusReader({
251
+ siteDir: config.siteDir,
252
+ configPath: config.docusaurusConfig,
253
+ instances: config.instances,
254
+ versions: config.versions,
255
+ includeDrafts: config.includeDrafts,
256
+ warn: (message) => reporter.issue({ code: 'docusaurus-version', severity: 'warning', message }),
257
+ });
258
+ }
259
+ /** `sync` and `render`. */
260
+ async function commandSync(config, parsed, reporter) {
261
+ const render = parsed.command === 'render';
262
+ const reader = readerFor(config, reporter);
263
+ const target = resolveTarget(config);
264
+ const renderOnly = render || config.offline;
265
+ const where = `/${[...config.rootSegments, ...config.baseSegments].join('/')}/`;
266
+ reporter.info(renderOnly
267
+ ? `Rendering the documentation for ${where}.`
268
+ : `${config.dryRun ? 'Planning' : 'Publishing'} the documentation to ${config.targetUrl}${where} as ${config.status}.`);
269
+ const { plan } = await runSync(config, {
270
+ reader,
271
+ target,
272
+ renderOnly,
273
+ log: (message) => reporter.detail(message),
274
+ });
275
+ if (parsed.capture) {
276
+ await writeCapture(parsed.capture, await reader.read());
277
+ reporter.info(`Model written to ${parsed.capture}`);
278
+ }
279
+ for (const issue of plan.issues)
280
+ reporter.issue(issue);
281
+ reporter.summary(plan);
282
+ if (plan.mediaPending > 0) {
283
+ reporter.info(`${plan.mediaPending} file(s) would be uploaded. Until they are, the rendered pages show the paths from the source.`);
284
+ }
285
+ const pruneable = plan.actions.filter((action) => action.op === 'prune' && action.applied !== true);
286
+ if (pruneable.length > 0) {
287
+ reporter.info(`${pruneable.length} page(s) have no source document. Re-run with --prune to trash them.`);
288
+ }
289
+ if (plan.artifactError) {
290
+ reporter.issue({
291
+ code: 'artifacts-unwritten',
292
+ severity: 'warning',
293
+ message: `The run finished but its output could not be written: ${plan.artifactError}`,
294
+ });
295
+ }
296
+ else {
297
+ reporter.info(`Rendered pages and plan.json written to ${path.relative(process.cwd(), config.outDir) || config.outDir}/`);
298
+ }
299
+ if (config.dryRun && !config.offline)
300
+ reporter.info('Dry run: the site was not modified.');
301
+ if (config.strict) {
302
+ const blocking = plan.issues.filter((issue) => compareSeverity(issue.severity, config.strictAt) >= 0);
303
+ if (blocking.length > 0) {
304
+ reporter.info(`\n${blocking.length} issue(s) at or above "${config.strictAt}" with --strict.`);
305
+ return EXIT.strict;
306
+ }
307
+ }
308
+ return EXIT.ok;
309
+ }
310
+ /** `capture`. */
311
+ async function commandCapture(config, parsed, reporter) {
312
+ const file = parsed.capture ?? path.join(config.outDir, 'model.json');
313
+ const model = await readerFor(config, reporter).read();
314
+ await writeCapture(file, model);
315
+ const docs = model.instances.reduce((total, instance) => total + instance.versions.reduce((count, version) => count + version.docs.length, 0), 0);
316
+ reporter.info(`Captured ${docs} document(s) from ${model.siteDir} to ${file}`);
317
+ return EXIT.ok;
318
+ }
319
+ /** `doctor`. */
320
+ async function commandDoctor(config, reporter) {
321
+ reporter.info('Checking the setup.\n');
322
+ reporter.info(` config ${config.configFile ?? 'none found; using defaults'}`);
323
+ reporter.info(` site ${config.siteDir}`);
324
+ reporter.info(` target ${config.targetUrl || 'not set'}`);
325
+ reporter.info(` root path /${[...config.rootSegments, ...config.baseSegments].join('/')}/`);
326
+ reporter.info(` credentials ${config.user ? `as ${config.user}` : 'missing'}`);
327
+ const reader = readerFor(config, reporter);
328
+ const model = await reader.read();
329
+ reporter.info(` docusaurus ${model.docusaurusVersion}`);
330
+ reporter.info(` locales ${model.locales.join(', ')} (default ${model.defaultLocale})`);
331
+ for (const instance of model.instances) {
332
+ const versions = instance.versions.map((version) => version.name).join(', ');
333
+ const docs = instance.versions.reduce((count, version) => count + version.docs.length, 0);
334
+ reporter.info(` instance ${instance.id}: ${docs} document(s), version(s) ${versions}`);
335
+ }
336
+ if (config.offline) {
337
+ reporter.info('\nNo credentials, so the target was not contacted.');
338
+ return EXIT.ok;
339
+ }
340
+ const session = await resolveTarget(config).open({ locale: model.locale, dryRun: true });
341
+ const index = await session.loadIndex();
342
+ reporter.info(`\nReached the target: ${index.length} page(s) exist.`);
343
+ const media = await session.loadMediaIndex();
344
+ reporter.info(`${media.size} file(s) previously uploaded by pterodoc.`);
345
+ await reportPlugin(config, reporter);
346
+ return EXIT.ok;
347
+ }
348
+ /**
349
+ * Say whether the WordPress plugin is installed, and whether the two ends agree.
350
+ *
351
+ * A prefix mismatch is the failure worth catching here: everything publishes,
352
+ * the plugin loads, and none of its styling applies, with nothing on either side
353
+ * to say why.
354
+ */
355
+ async function reportPlugin(config, reporter) {
356
+ const status = await detectPlugin(new WpClient({
357
+ baseUrl: config.targetUrl,
358
+ user: config.user,
359
+ appPassword: config.appPassword,
360
+ retry: DEFAULT_RETRY,
361
+ }));
362
+ if (status.unknown) {
363
+ reporter.info('');
364
+ reporter.info(`The pterodoc plugin: ${status.unknown}.`);
365
+ return;
366
+ }
367
+ if (!status.installed) {
368
+ reporter.info('');
369
+ reporter.info('The pterodoc WordPress plugin is not installed.');
370
+ if (config.blocks === 'plugin') {
371
+ reporter.issue({
372
+ code: 'plugin-missing',
373
+ severity: 'warning',
374
+ message: "render.blocks is 'plugin', but the plugin did not answer. Pages will still display; anything only it can render will not.",
375
+ });
376
+ }
377
+ return;
378
+ }
379
+ reporter.info('');
380
+ reporter.info('The pterodoc WordPress plugin is installed.');
381
+ if (config.blocks !== 'plugin') {
382
+ reporter.info("Set render.blocks to 'plugin' to let it render what core blocks cannot.");
383
+ }
384
+ const prefix = status.classPrefix ?? 'pterodoc';
385
+ if (prefix !== config.classPrefix) {
386
+ reporter.issue({
387
+ code: 'plugin-prefix-mismatch',
388
+ severity: 'warning',
389
+ message: `The plugin is styling "${prefix}" but pterodoc writes "${config.classPrefix}". Set them the same, on the plugin's settings page or in render.classPrefix; nothing needs re-publishing.`,
390
+ });
391
+ }
392
+ }
393
+ /** `init`. */
394
+ async function commandInit(config, reporter) {
395
+ const file = path.join(config.siteDir, 'pterodoc.config.mjs');
396
+ try {
397
+ await fs.access(file);
398
+ throw new ConfigError(`${file} already exists.`);
399
+ }
400
+ catch (error) {
401
+ if (error instanceof ConfigError)
402
+ throw error;
403
+ }
404
+ await fs.writeFile(file, `import { defineConfig } from 'pterodoc';
405
+
406
+ export default defineConfig({
407
+ site: {
408
+ // Sidebars to publish. A document no listed sidebar reaches is not published.
409
+ sidebars: 'all',
410
+ versions: 'last',
411
+ locales: 'default',
412
+ },
413
+ target: {
414
+ type: 'wordpress',
415
+ // Where the documentation hangs on the site. Missing pages along this path
416
+ // are created once and never edited again.
417
+ root: '/docs',
418
+ base: '',
419
+ status: 'publish',
420
+ },
421
+ });
422
+ `, 'utf8');
423
+ reporter.info(`Wrote ${file}`);
424
+ return EXIT.ok;
425
+ }
426
+ /** Present an error the way its type deserves. */
427
+ function report(error) {
428
+ if (error instanceof ConfigError) {
429
+ process.stderr.write(`\n${error.message}\n`);
430
+ return error.exitCode;
431
+ }
432
+ if (error instanceof TargetError) {
433
+ process.stderr.write(`\nThe target refused a request: ${error.message}\n`);
434
+ if (error.bodySnippet)
435
+ process.stderr.write(` body: ${error.bodySnippet}\n`);
436
+ return error.exitCode;
437
+ }
438
+ if (error instanceof PterodocError) {
439
+ process.stderr.write(`\n${error.message}\n`);
440
+ return error.exitCode;
441
+ }
442
+ process.stderr.write(`\n${error instanceof Error ? (error.stack ?? error.message) : String(error)}\n`);
443
+ return EXIT.internal;
444
+ }
445
+
446
+ export { main };
447
+ //# sourceMappingURL=run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.js","sources":["../../src/cli/args.ts","../../src/cli/reporter.ts","../../src/cli/run.ts"],"sourcesContent":[null,null,null],"names":[],"mappings":";;;;;;;;;;AAAA;AAMA;AACO,MAAM,QAAQ,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAU;AAKhF;AACO,MAAM,KAAK,GAA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CAAC,IAAI,CAAC,SAAS,IAAI,CAAA,CAAE,CAAC;IAC9B,OAAO,IAAI,CAAC,EAAE;AAChB;AAEA;AACA,SAAS,MAAM,CAAC,KAAc,EAAA;AAC5B,IAAA,IAAI,KAAK,YAAY,WAAW,EAAE;QAChC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA,EAAA,EAAK,KAAK,CAAC,OAAO,CAAA,EAAA,CAAI,CAAC;QAC5C,OAAO,KAAK,CAAC,QAAQ;IACvB;AACA,IAAA,IAAI,KAAK,YAAY,WAAW,EAAE;QAChC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA,gCAAA,EAAmC,KAAK,CAAC,OAAO,CAAA,EAAA,CAAI,CAAC;QAC1E,IAAI,KAAK,CAAC,WAAW;YAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA,QAAA,EAAW,KAAK,CAAC,WAAW,CAAA,EAAA,CAAI,CAAC;QAC7E,OAAO,KAAK,CAAC,QAAQ;IACvB;AACA,IAAA,IAAI,KAAK,YAAY,aAAa,EAAE;QAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA,EAAA,EAAK,KAAK,CAAC,OAAO,CAAA,EAAA,CAAI,CAAC;QAC5C,OAAO,KAAK,CAAC,QAAQ;IACvB;AACA,IAAA,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,CAAA,EAAA,EAAK,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,CAAA,EAAA,CAAI,CACjF;IACD,OAAO,IAAI,CAAC,QAAQ;AACtB;;"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Public API.
3
+ *
4
+ * Importing pterodoc as a library is supported for two things: authoring a
5
+ * configuration with type checking, and driving a sync from your own script.
6
+ *
7
+ * The implementation lives in `@pterodoc/core`, `@pterodoc/docusaurus` and
8
+ * `@pterodoc/wordpress`; this package is where they are wired together, and
9
+ * this barrel is the surface that wiring exposes.
10
+ */
11
+ export { EXIT, PterodocError, ConfigError, TargetError, UnsupportedContentError } from '@pterodoc/core';
12
+ export { VERSION } from '@pterodoc/core';
13
+ export { defineConfig } from '@pterodoc/core';
14
+ export type { PterodocConfig, SiteConfig, TargetConfig, RenderConfig, MdxConfig, MediaConfig, OutputConfig, } from '@pterodoc/core';
15
+ export { loadConfig, resolveConfig } from '@pterodoc/core';
16
+ export type { ResolvedConfig, ConfigFlags } from '@pterodoc/core';
17
+ export { runSync } from '@pterodoc/core';
18
+ export type { RunResult, RunSyncDeps, Plan, Action } from '@pterodoc/core';
19
+ export { buildPageTree, createCaptureReader, createMemoryReader } from '@pterodoc/core/model';
20
+ export type { SiteModel, Doc, DocsVersion, PageNode, PageTree, SourceReader } from '@pterodoc/core/model';
21
+ export { loadModel, toSiteModel, createDocusaurusReader } from '@pterodoc/docusaurus';
22
+ export { createWordpressTarget } from '@pterodoc/wordpress';
23
+ export type { Target, TargetSession, RenderedPage, RemotePage } from '@pterodoc/core/target';
24
+ export { renderDoc, createTheme, composePage, DEFAULT_LAYOUT } from '@pterodoc/core/render';
25
+ export type { RenderedDoc, Theme, Strings, PageLayout } from '@pterodoc/core/render';
26
+ export { IssueCollector, formatIssue, compareSeverity } from '@pterodoc/core/util';
27
+ export type { Issue, Severity } from '@pterodoc/core/util';
28
+ export { resolveTarget } from './target';
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACxG,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAA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SION, defineConfig, loadConfig, resolveConfig, runSync } from '@pterodoc/core';
2
+ export { buildPageTree, createCaptureReader, createMemoryReader } from '@pterodoc/core/model';
3
+ export { createDocusaurusReader, loadModel, toSiteModel } from '@pterodoc/docusaurus';
4
+ export { createWordpressTarget } from '@pterodoc/wordpress';
5
+ export { DEFAULT_LAYOUT, composePage, createTheme, renderDoc } from '@pterodoc/core/render';
6
+ export { IssueCollector, compareSeverity, formatIssue } from '@pterodoc/core/util';
7
+ export { r as resolveTarget } from './chunks/target-BC_VOAlJ.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The Docusaurus plugin.
3
+ *
4
+ * Optional: the command line is the usual way to publish. This exists for a
5
+ * site that would rather publish as part of its build, and it costs nothing
6
+ * extra, because a build has already loaded everything the model needs.
7
+ */
8
+ import type { LoadedSite } from '@pterodoc/docusaurus';
9
+ import type { Target } from '@pterodoc/core/target';
10
+ /** Options the plugin accepts in `docusaurus.config`. */
11
+ export interface PterodocPluginOptions {
12
+ /** Path to the pterodoc config; discovered beside the site when unset. */
13
+ config?: string;
14
+ /**
15
+ * Publish at the end of `docusaurus build`.
16
+ *
17
+ * Off by default: building a site should not also change another one.
18
+ */
19
+ runOnBuild?: boolean;
20
+ /** Plan and render without writing, even when `runOnBuild` is set. */
21
+ dryRun?: boolean;
22
+ /**
23
+ * Publish somewhere other than the configured target.
24
+ *
25
+ * An escape hatch for a test or a second target; the configured one is built
26
+ * when this is absent.
27
+ */
28
+ target?: Target;
29
+ }
30
+ /** The part of the Docusaurus plugin contract this uses. */
31
+ interface PluginLike {
32
+ name: string;
33
+ postBuild?: (props: LoadedSite['props']) => Promise<void>;
34
+ }
35
+ /** The part of the Docusaurus context this reads. */
36
+ interface ContextLike {
37
+ siteDir: string;
38
+ }
39
+ /**
40
+ * Create the plugin.
41
+ *
42
+ * @param context The Docusaurus load context.
43
+ * @param options Plugin options from `docusaurus.config`.
44
+ */
45
+ export default function pterodocPlugin(context: ContextLike, options?: PterodocPluginOptions): PluginLike;
46
+ export {};
47
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAIvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,yDAAyD;AACzD,MAAM,WAAW,qBAAqB;IACpC,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,sEAAsE;IACtE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,4DAA4D;AAC5D,UAAU,UAAU;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3D;AAED,qDAAqD;AACrD,UAAU,WAAW;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,qBAA0B,GAClC,UAAU,CAuCZ"}
@@ -0,0 +1,57 @@
1
+ import { toSiteModel } from '@pterodoc/docusaurus';
2
+ import { createMemoryReader } from '@pterodoc/core/model';
3
+ import { loadConfig, runSync } from '@pterodoc/core';
4
+ import { r as resolveTarget } from '../chunks/target-BC_VOAlJ.js';
5
+ import '@pterodoc/wordpress';
6
+
7
+ /**
8
+ * The Docusaurus plugin.
9
+ *
10
+ * Optional: the command line is the usual way to publish. This exists for a
11
+ * site that would rather publish as part of its build, and it costs nothing
12
+ * extra, because a build has already loaded everything the model needs.
13
+ */
14
+ /**
15
+ * Create the plugin.
16
+ *
17
+ * @param context The Docusaurus load context.
18
+ * @param options Plugin options from `docusaurus.config`.
19
+ */
20
+ function pterodocPlugin(context, options = {}) {
21
+ return {
22
+ name: 'pterodoc',
23
+ async postBuild(props) {
24
+ if (options.runOnBuild !== true)
25
+ return;
26
+ const config = await loadConfig({
27
+ siteDir: context.siteDir,
28
+ config: options.config,
29
+ dryRun: options.dryRun,
30
+ });
31
+ // The build has already run every plugin's content lifecycle, so the
32
+ // model is right here; there is nothing to load a second time.
33
+ const model = toSiteModel({ props }, {
34
+ siteDir: props.siteDir,
35
+ instances: config.instances,
36
+ versions: config.versions,
37
+ includeDrafts: config.includeDrafts,
38
+ });
39
+ const target = options.target ?? resolveTarget(config);
40
+ const { plan } = await runSync(config, {
41
+ reader: createMemoryReader(model),
42
+ target,
43
+ renderOnly: config.offline,
44
+ });
45
+ const counts = Object.entries(plan.summary)
46
+ .map(([op, count]) => `${count} ${op}`)
47
+ .join(', ');
48
+ process.stdout.write(`[pterodoc] ${counts || 'nothing to do'}\n`);
49
+ for (const issue of plan.issues.filter((entry) => entry.severity !== 'info')) {
50
+ process.stdout.write(`[pterodoc] ${issue.severity}: ${issue.message}\n`);
51
+ }
52
+ },
53
+ };
54
+ }
55
+
56
+ export { pterodocPlugin as default };
57
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/plugin/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AAAA;;;;;;AAMG;AA0CH;;;;;AAKG;AACW,SAAU,cAAc,CACpC,OAAoB,EACpB,UAAiC,EAAE,EAAA;IAEnC,OAAO;AACL,QAAA,IAAI,EAAE,UAAU;QAEhB,MAAM,SAAS,CAAC,KAAK,EAAA;AACnB,YAAA,IAAI,OAAO,CAAC,UAAU,KAAK,IAAI;gB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OAAO,CAAA,EAAA,CAAI,CAAC;YAC1E;QACF,CAAC;KACF;AACH;;"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Build the target a run publishes to.
3
+ *
4
+ * Both entry points — the command line and the Docusaurus plugin — need the
5
+ * same object built the same way, and having built it in two places once
6
+ * already, the copies drifted apart in how they spelled the URL policy.
7
+ */
8
+ import type { ResolvedConfig, Target } from '@pterodoc/core';
9
+ /**
10
+ * Build the configured target.
11
+ *
12
+ * Always built, even offline: the target decides what a page's URL is, and a
13
+ * render with the wrong URLs is worse than no render at all. Only opening a
14
+ * session needs credentials.
15
+ *
16
+ * @param config The resolved configuration.
17
+ */
18
+ export declare function resolveTarget(config: ResolvedConfig): Target;
19
+ //# sourceMappingURL=target.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"target.d.ts","sourceRoot":"","sources":["../src/target.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAG7D;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAgB5D"}