linopress-cli 0.0.0-stage → 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.
@@ -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,43 @@
1
+ /**
2
+ * The TypeDoc source: runs TypeDoc with typedoc-plugin-markdown and reads its pages.
3
+ *
4
+ * @module linopress-cli/typedoc
5
+ */
6
+ import { i as Page } from "./model-CgSIC_VE.js";
7
+ interface GenerateOptions {
8
+ /** Path to a TypeDoc options file (`typedoc.json`). */
9
+ readonly options: string;
10
+ /** Where to write Markdown. Defaults to a fresh temp dir, so the config's `out` is untouched. */
11
+ readonly out?: string;
12
+ /** Extra TypeDoc options, applied over the options file. */
13
+ readonly overrides?: Record<string, unknown>;
14
+ /**
15
+ * Folder that relative paths in `overrides` (`entryPoints`, `tsconfig`, `readme`, ...) resolve
16
+ * against, as paths in an options file resolve against that file. Defaults to the working
17
+ * directory.
18
+ */
19
+ readonly overridesBase?: string;
20
+ }
21
+ interface GenerateResult {
22
+ readonly out: string;
23
+ readonly pages: Page[];
24
+ }
25
+ /**
26
+ * Runs TypeDoc with typedoc-plugin-markdown and reads the result as pages.
27
+ * `typedoc` and `typedoc-plugin-markdown` are peer dependencies, loaded lazily.
28
+ */
29
+ export declare function generateMarkdown(options: GenerateOptions): Promise<GenerateResult>;
30
+ /**
31
+ * Splits a leading `# Title` off a Markdown page. Linear shows the doc title separately, so
32
+ * keeping TypeDoc's H1 would duplicate it.
33
+ */
34
+ export declare function splitTitle(markdown: string): {
35
+ title: string | null;
36
+ content: string;
37
+ };
38
+ /**
39
+ * Reads a folder of Markdown (e.g. typedoc-plugin-markdown output) as pages.
40
+ * Titles come from each page's H1, falling back to the file path without `.md`.
41
+ */
42
+ export declare function readMarkdownPages(dir: string): Promise<Page[]>;
43
+ export type { GenerateOptions, GenerateResult };
@@ -0,0 +1 @@
1
+ export { t as generateMarkdown, n as readMarkdownPages, r as splitTitle } from "./src-Bm80C3HE.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.2.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://linopress.karolnov.dev",
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/core": "0.0.0",
79
+ "@linopress/linear": "0.0.0",
80
+ "@linopress/typedoc": "0.0.0",
81
+ "@linopress/markdown": "0.0.0"
82
+ },
83
+ "publishConfig": {
84
+ "access": "public"
85
+ },
86
+ "scripts": {
87
+ "build": "tsdown"
88
+ }
6
89
  }