linopress-cli 0.0.0-stage → 0.1.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.
@@ -0,0 +1,160 @@
1
+ import { realpathSync } from "node:fs";
2
+ import { mkdtemp, readFile, readdir, rm } from "node:fs/promises";
3
+ import { tmpdir } from "node:os";
4
+ import { dirname, join, relative, resolve, sep } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ // ../typedoc/src/pages.ts
7
+ const H1 = /^\s*#[ \t]+(.+?)(?:[ \t]+#+)?[ \t]*(?:\n+|$)/;
8
+ /**
9
+ * Splits a leading `# Title` off a Markdown page. Linear shows the doc title separately, so
10
+ * keeping TypeDoc's H1 would duplicate it.
11
+ */
12
+ function splitTitle(markdown) {
13
+ const normalized = markdown.replace(/\r\n?/g, "\n");
14
+ const match = H1.exec(normalized);
15
+ if (!match?.[1]) return {
16
+ title: null,
17
+ content: normalized
18
+ };
19
+ return {
20
+ title: match[1].replace(/\\(.)/g, "$1"),
21
+ content: normalized.slice(match[0].length)
22
+ };
23
+ }
24
+ async function walk(dir) {
25
+ const out = [];
26
+ for (const entry of await readdir(dir, { withFileTypes: true })) {
27
+ const full = join(dir, entry.name);
28
+ if (entry.isDirectory()) out.push(...await walk(full));
29
+ else if (entry.isFile() && entry.name.endsWith(".md")) out.push(full);
30
+ }
31
+ return out;
32
+ }
33
+ /**
34
+ * Reads a folder of Markdown (e.g. typedoc-plugin-markdown output) as pages.
35
+ * Titles come from each page's H1, falling back to the file path without `.md`.
36
+ */
37
+ async function readMarkdownPages(dir) {
38
+ const files = await walk(dir);
39
+ return (await Promise.all(files.map(async (file) => {
40
+ const path = relative(dir, file).split(sep).join("/");
41
+ const { title, content } = splitTitle(await readFile(file, "utf8"));
42
+ return {
43
+ path,
44
+ title: title ?? path.replace(/\.md$/, ""),
45
+ content
46
+ };
47
+ }))).sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
48
+ }
49
+ // ../typedoc/src/generate.ts
50
+ const MARKDOWN_PLUGIN = "typedoc-plugin-markdown";
51
+ /**
52
+ * Absolute, symlink-free path, so it compares with the repo root and the footer's display base
53
+ * (also resolved with `realpath`), e.g. under macOS's `/var` → `/private/var`.
54
+ */
55
+ function canonical(file) {
56
+ const abs = resolve(file);
57
+ try {
58
+ return realpathSync(abs);
59
+ } catch {
60
+ return abs;
61
+ }
62
+ }
63
+ /**
64
+ * Source files of a page's reflection. Uses the symbol TypeDoc converted it from, which is known
65
+ * even with `disableSources: true`; falls back to `reflection.sources` when that's recorded.
66
+ */
67
+ function sourcesOf(event) {
68
+ const fromSymbol = event.project?.getSymbolIdFromReflection?.(event.model)?.fileName;
69
+ if (fromSymbol) return [canonical(fromSymbol)];
70
+ const sources = event.model?.sources;
71
+ return [...new Set((sources ?? []).flatMap((s) => s.fullFileName ? [canonical(s.fullFileName)] : []))];
72
+ }
73
+ /** Resolves a plugin from this package first, so it works even when it isn't hoisted. */
74
+ function resolvePlugin(name) {
75
+ try {
76
+ return fileURLToPath(import.meta.resolve(name));
77
+ } catch {
78
+ return name;
79
+ }
80
+ }
81
+ /** Reads the options file's `plugin` list, so ours can be added to it rather than replace it. */
82
+ async function configuredPlugins(options) {
83
+ const override = options.overrides?.["plugin"];
84
+ if (override !== void 0) {
85
+ const base = resolve(options.overridesBase ?? ".");
86
+ return (Array.isArray(override) ? override.map(String) : []).map((name) => name.startsWith(".") ? resolve(base, name) : name);
87
+ }
88
+ try {
89
+ const file = resolve(options.options);
90
+ const plugin = JSON.parse(await readFile(file, "utf8"))?.plugin;
91
+ if (!Array.isArray(plugin)) return [];
92
+ return plugin.map((p) => {
93
+ const name = String(p);
94
+ return name.startsWith(".") ? resolve(dirname(file), name) : name;
95
+ });
96
+ } catch {
97
+ return [];
98
+ }
99
+ }
100
+ /**
101
+ * Runs TypeDoc with typedoc-plugin-markdown and reads the result as pages.
102
+ * `typedoc` and `typedoc-plugin-markdown` are peer dependencies, loaded lazily.
103
+ */
104
+ async function generateMarkdown(options) {
105
+ const typedoc = await import("typedoc").catch((error) => {
106
+ const missing = error?.code === "ERR_MODULE_NOT_FOUND";
107
+ throw new Error(missing ? "The TypeDoc source needs `typedoc` and `typedoc-plugin-markdown` installed" : "Failed to load `typedoc`", { cause: error });
108
+ });
109
+ const plugins = [resolvePlugin(MARKDOWN_PLUGIN), ...(await configuredPlugins(options)).filter((p) => p !== MARKDOWN_PLUGIN)];
110
+ const tempOut = options.out === void 0;
111
+ const out = resolve(options.out ?? await mkdtemp(join(tmpdir(), "linopress-")));
112
+ const { plugin: _plugin, ...overrides } = options.overrides ?? {};
113
+ const base = resolve(options.overridesBase ?? ".");
114
+ const overridesReader = {
115
+ name: "linopress-overrides",
116
+ order: 1e3,
117
+ supportsPackages: false,
118
+ read(container) {
119
+ for (const [name, value] of Object.entries(overrides)) container.setValue(name, value, base);
120
+ }
121
+ };
122
+ try {
123
+ const app = await typedoc.Application.bootstrapWithPlugins({
124
+ options: resolve(options.options),
125
+ plugin: [...new Set(plugins)],
126
+ out,
127
+ cleanOutputDir: true
128
+ }, [
129
+ new typedoc.TypeDocReader(),
130
+ new typedoc.TSConfigReader(),
131
+ overridesReader
132
+ ]);
133
+ const sources = /* @__PURE__ */ new Map();
134
+ app.renderer.on("endPage", (event) => {
135
+ const files = sourcesOf(event);
136
+ if (files.length > 0) sources.set(event.url.split(sep).join("/"), files);
137
+ });
138
+ const project = await app.convert();
139
+ if (!project) throw new Error(`TypeDoc failed to convert the project (${options.options})`);
140
+ await app.generateOutputs(project);
141
+ if (app.logger.hasErrors()) throw new Error("TypeDoc reported errors, see above");
142
+ return {
143
+ out,
144
+ pages: (await readMarkdownPages(out)).map((page) => {
145
+ const files = sources.get(page.path);
146
+ return files ? {
147
+ ...page,
148
+ sources: files
149
+ } : page;
150
+ })
151
+ };
152
+ } catch (error) {
153
+ if (tempOut) await rm(out, {
154
+ recursive: true,
155
+ force: true
156
+ });
157
+ throw error;
158
+ }
159
+ }
160
+ export { readMarkdownPages as n, splitTitle as r, generateMarkdown as t };
@@ -0,0 +1,249 @@
1
+ import { C as rewriteLinks, l as applyTransforms, v as findImages } from "./src-BU0LDvW9.js";
2
+ import { mkdir, readFile, readdir, rename, rmdir, unlink, writeFile } from "node:fs/promises";
3
+ import { dirname, isAbsolute, join, relative, resolve } from "node:path";
4
+ // ../markdown/src/files.ts
5
+ /**
6
+ * The file in the output folder that lists what Linopress wrote there. Only those files are ever
7
+ * deleted; anything else in the folder (a VitePress config, hand-written guides) is left alone.
8
+ */
9
+ const RECORD_FILE = ".linopress.json";
10
+ function sameBytes(a, b) {
11
+ if (a.length !== b.length) return false;
12
+ for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
13
+ return true;
14
+ }
15
+ /**
16
+ * Diffs the files an edition writes against the output folder. Pure.
17
+ *
18
+ * - not on disk → **create**; different bytes on disk → **update**; same bytes → **unchanged**.
19
+ * Compared with the disk, not a stored hash, so a file edited by hand is put back.
20
+ * - in the record, no longer written, still on disk → **delete**.
21
+ */
22
+ function planFiles(files, state) {
23
+ const owned = new Set(state.owned);
24
+ const wanted = /* @__PURE__ */ new Set();
25
+ const writes = [];
26
+ const unchanged = [];
27
+ for (const file of files) {
28
+ if (wanted.has(file.path)) throw new Error(`Two output files at "${file.path}"`);
29
+ wanted.add(file.path);
30
+ const current = state.existing.get(file.path);
31
+ if (current === void 0) writes.push({
32
+ kind: "create",
33
+ path: file.path
34
+ });
35
+ else if (sameBytes(current, file.data)) unchanged.push({
36
+ kind: "unchanged",
37
+ path: file.path
38
+ });
39
+ else writes.push({
40
+ kind: "update",
41
+ path: file.path,
42
+ ...!owned.has(file.path) && { adopted: true }
43
+ });
44
+ }
45
+ const deletes = [...owned].filter((path) => !wanted.has(path) && state.existing.has(path)).sort().map((path) => ({
46
+ kind: "delete",
47
+ path
48
+ }));
49
+ const actions = [
50
+ ...writes,
51
+ ...deletes,
52
+ ...unchanged
53
+ ];
54
+ const counts = {
55
+ create: 0,
56
+ update: 0,
57
+ delete: 0,
58
+ unchanged: 0
59
+ };
60
+ for (const a of actions) counts[a.kind]++;
61
+ return {
62
+ actions,
63
+ counts,
64
+ owned: files.map((f) => f.path)
65
+ };
66
+ }
67
+ /** True when applying the plan would write or delete nothing. */
68
+ function isEmptyFilePlan(p) {
69
+ return p.actions.every((a) => a.kind === "unchanged");
70
+ }
71
+ /**
72
+ * Absolute path of an edition-relative `path` inside `out`. Throws for paths that would land
73
+ * outside it (a tampered record must not make Linopress delete files elsewhere).
74
+ */
75
+ function outputPath(out, path) {
76
+ const full = resolve(out, ...path.split("/"));
77
+ const rel = relative(out, full);
78
+ if (!rel || rel.startsWith("..") || isAbsolute(rel) || path === ".linopress.json") throw new Error(`Refusing to touch "${path}": not a file inside ${out}`);
79
+ return full;
80
+ }
81
+ async function readIfFile(path) {
82
+ try {
83
+ return await readFile(path);
84
+ } catch (error) {
85
+ const code = error.code;
86
+ if (code === "ENOENT" || code === "EISDIR" || code === "ENOTDIR") return void 0;
87
+ throw error;
88
+ }
89
+ }
90
+ /** Reads the record; an empty list when there is none yet. */
91
+ async function readRecord(out) {
92
+ const raw = await readIfFile(join(out, RECORD_FILE));
93
+ if (raw === void 0) return [];
94
+ let parsed;
95
+ try {
96
+ parsed = JSON.parse(new TextDecoder().decode(raw));
97
+ } catch (error) {
98
+ throw new Error(`${join(out, RECORD_FILE)} isn't valid JSON`, { cause: error });
99
+ }
100
+ const files = parsed?.files;
101
+ if (!Array.isArray(files) || !files.every((f) => typeof f === "string")) throw new Error(`${join(out, RECORD_FILE)} needs a "files" array of paths`);
102
+ for (const path of files) outputPath(out, path);
103
+ return files;
104
+ }
105
+ /** Reads the record and the current bytes of every file `files` writes or the record lists. */
106
+ async function readOutputState(out, files) {
107
+ const owned = await readRecord(out);
108
+ const existing = /* @__PURE__ */ new Map();
109
+ for (const path of /* @__PURE__ */ new Set([...files.map((f) => f.path), ...owned])) {
110
+ const data = await readIfFile(outputPath(out, path));
111
+ if (data !== void 0) existing.set(path, data);
112
+ }
113
+ return {
114
+ owned,
115
+ existing
116
+ };
117
+ }
118
+ async function writeRecord(out, files) {
119
+ const body = {
120
+ $comment: "Files Linopress wrote here. It deletes only these, when their pages go away.",
121
+ files: [...new Set(files)].sort()
122
+ };
123
+ const path = join(out, RECORD_FILE);
124
+ await writeFile(`${path}.tmp`, `${JSON.stringify(body, null, 2)}\n`);
125
+ await rename(`${path}.tmp`, path);
126
+ }
127
+ /** Removes `dir` and its parents up to (not including) `out` while they are empty. */
128
+ async function pruneEmptyDirs(out, dir) {
129
+ for (let d = dir; relative(out, d) && !relative(out, d).startsWith(".."); d = dirname(d)) {
130
+ if ((await readdir(d)).length > 0) return;
131
+ await rmdir(d);
132
+ }
133
+ }
134
+ /** Paths of files the plan would replace although Linopress didn't write them. */
135
+ function adoptedPaths(p) {
136
+ return p.actions.filter((a) => a.adopted).map((a) => a.path);
137
+ }
138
+ /**
139
+ * Writes created and updated files, deletes files of removed pages (and directories that become
140
+ * empty), and updates the record. The record is widened before the first write, so a run that
141
+ * stops halfway still knows which files are its own.
142
+ */
143
+ async function applyFiles(options) {
144
+ const { out, plan } = options;
145
+ const byPath = new Map(options.files.map((f) => [f.path, f]));
146
+ const adopted = adoptedPaths(plan);
147
+ if (adopted.length > 0 && !options.force) throw new Error(`Refusing to replace files Linopress didn't write: ${adopted.join(", ")} (pass force to replace them)`);
148
+ await mkdir(out, { recursive: true });
149
+ await writeRecord(out, [...options.owned, ...plan.owned]);
150
+ for (const action of plan.actions) {
151
+ if (action.kind !== "create" && action.kind !== "update") continue;
152
+ const file = byPath.get(action.path);
153
+ if (!file) throw new Error(`Plan writes "${action.path}", which isn't an output file`);
154
+ const full = outputPath(out, action.path);
155
+ await mkdir(dirname(full), { recursive: true });
156
+ await writeFile(full, file.data);
157
+ options.onEvent?.({
158
+ kind: action.kind === "create" ? "created" : "updated",
159
+ path: action.path
160
+ });
161
+ }
162
+ for (const action of plan.actions) {
163
+ if (action.kind !== "delete") continue;
164
+ const full = outputPath(out, action.path);
165
+ try {
166
+ await unlink(full);
167
+ } catch (error) {
168
+ if (error.code !== "ENOENT") throw error;
169
+ }
170
+ await pruneEmptyDirs(out, dirname(full));
171
+ options.onEvent?.({
172
+ kind: "deleted",
173
+ path: action.path
174
+ });
175
+ }
176
+ await writeRecord(out, plan.owned);
177
+ }
178
+ const SYMBOL = {
179
+ create: "+",
180
+ update: "~",
181
+ delete: "-",
182
+ unchanged: "="
183
+ };
184
+ /** Human-readable file plan, one line per file, in the style of `formatPlan`. */
185
+ function formatFilePlan(p, options = {}) {
186
+ const { create, update, delete: del, unchanged } = p.counts;
187
+ const lines = [`${create} to create, ${update} to update, ${del} to delete, ${unchanged} unchanged`];
188
+ const shown = p.actions.filter((a) => options.verbose || a.kind !== "unchanged");
189
+ if (shown.length > 0) lines.push("");
190
+ for (const a of shown) {
191
+ const note = a.adopted ? " (exists, not written by Linopress: push needs --force to replace it)" : "";
192
+ lines.push(` ${SYMBOL[a.kind]} ${a.kind.padEnd(9)} ${a.path}${note}`);
193
+ }
194
+ return lines.join("\n");
195
+ }
196
+ // ../markdown/src/render.ts
197
+ /**
198
+ * Transforms for a Markdown docs site: none. TypeDoc's `<a id>` anchors and `#fragment` links work
199
+ * on a normal site, so they are kept.
200
+ */
201
+ const markdownTransforms = [];
202
+ const encoder = new TextEncoder();
203
+ /**
204
+ * Renders an edition as files: each page gets its title back as an H1 (sources split it off for
205
+ * Linear), links stay relative with their `#fragment`s, and every embedded image that exists is
206
+ * copied to the same relative path, so references keep working.
207
+ */
208
+ function renderMarkdownEdition(nodes, assets, options = {}) {
209
+ const paths = new Set(nodes.map((n) => n.path));
210
+ const unresolvedLinks = {};
211
+ const missingImages = {};
212
+ const files = [];
213
+ for (const node of nodes) {
214
+ const body = applyTransforms(node.content, options.transforms ?? markdownTransforms);
215
+ const { unresolved } = rewriteLinks(body, node.path, (p) => paths.has(p) ? p : void 0);
216
+ if (unresolved.length > 0) unresolvedLinks[node.path] = unresolved;
217
+ const missing = findImages(body, node.path).filter((p) => !assets.has(p));
218
+ if (missing.length > 0) missingImages[node.path] = missing.sort();
219
+ const header = options.header?.(node) ?? "";
220
+ const title = `# ${escapeTitle(node.title)}\n\n`;
221
+ const content = `${header ? `${header.trimEnd()}\n\n` : ""}${title}${body.trimStart()}`;
222
+ files.push({
223
+ path: node.path,
224
+ kind: "page",
225
+ data: encoder.encode(withFinalNewline(content))
226
+ });
227
+ }
228
+ for (const asset of [...assets.values()].sort((a, b) => a.path < b.path ? -1 : 1)) {
229
+ if (paths.has(asset.path)) continue;
230
+ files.push({
231
+ path: asset.path,
232
+ kind: "asset",
233
+ data: asset.data
234
+ });
235
+ }
236
+ return {
237
+ files,
238
+ unresolvedLinks,
239
+ missingImages
240
+ };
241
+ }
242
+ /** Escapes what would make the title something other than plain heading text. */
243
+ function escapeTitle(title) {
244
+ return title.replace(/[\\`*_[\]<>]/g, "\\$&").replace(/\s+#+\s*$/, (m) => m.replace(/#/g, "\\#"));
245
+ }
246
+ function withFinalNewline(text) {
247
+ return text.endsWith("\n") ? text : `${text}\n`;
248
+ }
249
+ export { applyFiles as a, outputPath as c, readRecord as d, adoptedPaths as i, planFiles as l, renderMarkdownEdition as n, formatFilePlan as o, RECORD_FILE as r, isEmptyFilePlan as s, markdownTransforms as t, readOutputState as u };
@@ -0,0 +1,48 @@
1
+ import { o as Asset } from "./transforms-BBEyouxz.js";
2
+ /** Where a doc sits: under `parentId` (or top-level when `null`), at `sortOrder`. */
3
+ interface DocPosition {
4
+ readonly parentId: string | null;
5
+ readonly sortOrder: number;
6
+ }
7
+ interface CreateDocInput extends DocPosition {
8
+ readonly title: string;
9
+ readonly content: string;
10
+ }
11
+ /** Only the fields present are changed. */
12
+ interface UpdateDocInput {
13
+ readonly title?: string;
14
+ readonly content?: string;
15
+ readonly position?: DocPosition;
16
+ }
17
+ interface RemoteDoc {
18
+ readonly id: string;
19
+ readonly url: string;
20
+ }
21
+ /**
22
+ * Thrown by a target when a doc is gone: deleted, or archived outside Linopress.
23
+ * `apply` treats it as recoverable (re-creates the doc, or skips an archive that already happened).
24
+ */
25
+ declare class DocNotFoundError extends Error {
26
+ readonly docId: string;
27
+ constructor(docId: string, message?: string);
28
+ }
29
+ /**
30
+ * A place that stores documents (Linear, a fake in tests, ...).
31
+ * A target is bound to one container; the engine never deletes, it archives.
32
+ */
33
+ interface DocumentTarget {
34
+ create(input: CreateDocInput): Promise<RemoteDoc>;
35
+ /** Throws `DocNotFoundError` when the doc is deleted or archived. */
36
+ update(id: string, input: UpdateDocInput): Promise<void>;
37
+ /**
38
+ * Soft-removes a doc (recoverable in the target's UI). Throws `DocNotFoundError` (or resolves)
39
+ * when the doc is already deleted or archived.
40
+ */
41
+ archive(id: string): Promise<void>;
42
+ /**
43
+ * Stores a file (an image a doc embeds) and returns the URL docs should reference.
44
+ * Optional: without it, `apply` fails when there is an image to upload.
45
+ */
46
+ uploadAsset?(asset: Asset): Promise<string>;
47
+ }
48
+ export { RemoteDoc as a, DocumentTarget as i, DocNotFoundError as n, UpdateDocInput as o, DocPosition as r, CreateDocInput as t };
@@ -0,0 +1,81 @@
1
+ /** A local file a page embeds (an image), read and hashed so it can be uploaded once. */
2
+ interface Asset {
3
+ /** Edition-relative POSIX path, e.g. `_media/diagram.png`. */
4
+ readonly path: string;
5
+ /** Hash of the file's bytes. Unchanged bytes are never uploaded again. */
6
+ readonly hash: string;
7
+ readonly contentType: string;
8
+ readonly data: Uint8Array;
9
+ }
10
+ /** What Linopress knows about an uploaded asset: the bytes it uploaded (hash) and where they live. */
11
+ interface AssetEntry {
12
+ readonly hash: string;
13
+ readonly url: string;
14
+ }
15
+ /** Uploaded assets for one container, keyed by edition-relative asset path. */
16
+ type AssetEntries = Record<string, AssetEntry>;
17
+ /** Reads an edition-relative file; resolves `undefined` when it doesn't exist. */
18
+ type ReadAsset = (path: string) => Promise<Uint8Array | undefined>;
19
+ /** MIME type from the file extension; `application/octet-stream` when unknown. */
20
+ declare function contentTypeFor(path: string): string;
21
+ /** Short, stable hash of an asset's bytes. */
22
+ declare function assetHash(data: Uint8Array): string;
23
+ /** URL used in dry runs for an asset that isn't uploaded yet (differs per content). */
24
+ declare const pendingAssetUrl: (asset: Pick<Asset, "path" | "hash">) => string;
25
+ /**
26
+ * Edition-relative paths of the local files `markdown` embeds or links to (`![alt](./diagram.png)`,
27
+ * `<img src="_media/flow.png">`, `[spec](_media/spec.pdf)`), in order of first use. Code, absolute
28
+ * URLs, paths outside the edition and links to pages are ignored.
29
+ */
30
+ declare function findImages(markdown: string, fromPath: string): string[];
31
+ interface ImageRewriteResult {
32
+ readonly content: string;
33
+ /** Edition-relative file paths that `urlFor` couldn't resolve (left as written). */
34
+ readonly missing: readonly string[];
35
+ }
36
+ /**
37
+ * Points local images (and file links) at their uploaded URLs. Code is left untouched, as are
38
+ * files `urlFor` can't resolve (reported in `missing`).
39
+ */
40
+ declare function rewriteImages(markdown: string, fromPath: string, urlFor: (path: string) => string | undefined): ImageRewriteResult;
41
+ interface CollectedAssets {
42
+ /** Every image that exists, keyed by edition-relative path. */
43
+ readonly assets: ReadonlyMap<string, Asset>;
44
+ /** Image paths that were referenced but couldn't be read. */
45
+ readonly missing: readonly string[];
46
+ }
47
+ /** Finds the images `pages` (or doc nodes) embed and reads them through `read`. */
48
+ declare function collectAssets(pages: readonly {
49
+ readonly path: string;
50
+ readonly content: string;
51
+ }[], read: ReadAsset): Promise<CollectedAssets>;
52
+ /**
53
+ * URL of an already-uploaded copy of `asset`: its own entry when the bytes are unchanged, otherwise
54
+ * any entry with the same bytes (a moved or duplicated image).
55
+ */
56
+ declare function uploadedUrl(entries: AssetEntries, asset: Asset): string | undefined;
57
+ /**
58
+ * A pure Markdown → Markdown step applied to every page before hashing and push. Which ones run is
59
+ * the target's choice: Linear needs anchors and in-page links removed (`linearTransforms` in
60
+ * `@linopress/linear`), while a Markdown docs site keeps both.
61
+ */
62
+ type MarkdownTransform = (markdown: string) => string;
63
+ /**
64
+ * Removes empty HTML anchors (`<a id="property-apikey"></a>`) and the space after them.
65
+ * TypeDoc puts them in table cells; Linear shows them as literal text.
66
+ */
67
+ declare const stripHtmlAnchors: MarkdownTransform;
68
+ /**
69
+ * Turns in-page links `[text](#fragment)` into their plain text (inline code in the text is kept).
70
+ * Linear heading ids are UUIDs, so `#slug` targets don't exist and the links would be dead.
71
+ */
72
+ declare const unlinkInPageLinks: MarkdownTransform;
73
+ /**
74
+ * The clean-up `plan`, `apply` and `renderDoc` use when given no `transforms`: the Linear one, since
75
+ * those sync to a `DocumentTarget`. Pass `[]` for none.
76
+ * @deprecated Import `linearTransforms` from `@linopress/linear` (`linopress-cli/linear`).
77
+ */
78
+ declare const defaultTransforms: readonly MarkdownTransform[];
79
+ /** Runs `transforms` left to right. */
80
+ declare function applyTransforms(markdown: string, transforms: readonly MarkdownTransform[]): string;
81
+ export { rewriteImages as _, unlinkInPageLinks as a, AssetEntry as c, ReadAsset as d, assetHash as f, pendingAssetUrl as g, findImages as h, stripHtmlAnchors as i, CollectedAssets as l, contentTypeFor as m, applyTransforms as n, Asset as o, collectAssets as p, defaultTransforms as r, AssetEntries as s, MarkdownTransform as t, ImageRewriteResult as u, uploadedUrl as v };
@@ -0,0 +1,38 @@
1
+ import { i as Page } from "./model-CgSIC_VE.js";
2
+ interface GenerateOptions {
3
+ /** Path to a TypeDoc options file (`typedoc.json`). */
4
+ readonly options: string;
5
+ /** Where to write Markdown. Defaults to a fresh temp dir, so the config's `out` is untouched. */
6
+ readonly out?: string;
7
+ /** Extra TypeDoc options, applied over the options file. */
8
+ readonly overrides?: Record<string, unknown>;
9
+ /**
10
+ * Folder that relative paths in `overrides` (`entryPoints`, `tsconfig`, `readme`, ...) resolve
11
+ * against, as paths in an options file resolve against that file. Defaults to the working
12
+ * directory.
13
+ */
14
+ readonly overridesBase?: string;
15
+ }
16
+ interface GenerateResult {
17
+ readonly out: string;
18
+ readonly pages: Page[];
19
+ }
20
+ /**
21
+ * Runs TypeDoc with typedoc-plugin-markdown and reads the result as pages.
22
+ * `typedoc` and `typedoc-plugin-markdown` are peer dependencies, loaded lazily.
23
+ */
24
+ export declare function generateMarkdown(options: GenerateOptions): Promise<GenerateResult>;
25
+ /**
26
+ * Splits a leading `# Title` off a Markdown page. Linear shows the doc title separately, so
27
+ * keeping TypeDoc's H1 would duplicate it.
28
+ */
29
+ export declare function splitTitle(markdown: string): {
30
+ title: string | null;
31
+ content: string;
32
+ };
33
+ /**
34
+ * Reads a folder of Markdown (e.g. typedoc-plugin-markdown output) as pages.
35
+ * Titles come from each page's H1, falling back to the file path without `.md`.
36
+ */
37
+ export declare function readMarkdownPages(dir: string): Promise<Page[]>;
38
+ export type { GenerateOptions, GenerateResult };
@@ -0,0 +1 @@
1
+ export { t as generateMarkdown, n as readMarkdownPages, r as splitTitle } from "./src-vhdzyr4k.js";
package/package.json CHANGED
@@ -1,6 +1,89 @@
1
1
  {
2
2
  "name": "linopress-cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Turn TypeScript doc comments into editions: a public Markdown docs site and an internal reference synced into Linear Documents.",
5
+ "license": "MIT",
6
+ "author": "Karol Novljaković",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/KarolNov/linopress.git",
10
+ "directory": "packages/cli"
11
+ },
12
+ "homepage": "https://github.com/KarolNov/linopress#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/KarolNov/linopress/issues"
15
+ },
16
+ "type": "module",
17
+ "bin": {
18
+ "linopress": "./bin/linopress.js"
19
+ },
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "default": "./dist/index.js"
24
+ },
25
+ "./config": {
26
+ "types": "./dist/config.d.ts",
27
+ "default": "./dist/config.js"
28
+ },
29
+ "./linear": {
30
+ "types": "./dist/linear.d.ts",
31
+ "default": "./dist/linear.js"
32
+ },
33
+ "./markdown": {
34
+ "types": "./dist/markdown.d.ts",
35
+ "default": "./dist/markdown.js"
36
+ },
37
+ "./typedoc": {
38
+ "types": "./dist/typedoc.d.ts",
39
+ "default": "./dist/typedoc.js"
40
+ },
41
+ "./package.json": "./package.json"
42
+ },
43
+ "files": [
44
+ "bin",
45
+ "dist",
46
+ "README.md",
47
+ "LICENSE"
48
+ ],
49
+ "engines": {
50
+ "node": ">=22.18"
51
+ },
52
+ "keywords": [
53
+ "typedoc",
54
+ "linear",
55
+ "linear-app",
56
+ "documentation",
57
+ "docs",
58
+ "api-reference",
59
+ "markdown",
60
+ "cli"
61
+ ],
62
+ "peerDependencies": {
63
+ "typedoc": "^0.28.0",
64
+ "typedoc-plugin-markdown": "^4.0.0"
65
+ },
66
+ "peerDependenciesMeta": {
67
+ "typedoc": {
68
+ "optional": true
69
+ },
70
+ "typedoc-plugin-markdown": {
71
+ "optional": true
72
+ }
73
+ },
74
+ "devDependencies": {
75
+ "tsdown": "0.23.7",
76
+ "typedoc": "0.28.20",
77
+ "typedoc-plugin-markdown": "4.14.1",
78
+ "@linopress/linear": "0.0.0",
79
+ "@linopress/markdown": "0.0.0",
80
+ "@linopress/core": "0.0.0",
81
+ "@linopress/typedoc": "0.0.0"
82
+ },
83
+ "publishConfig": {
84
+ "access": "public"
85
+ },
86
+ "scripts": {
87
+ "build": "tsdown"
88
+ }
6
89
  }