linopress-cli 0.1.0 → 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/README.md +11 -0
- package/dist/cli.js +4 -4
- package/dist/{config-B5ZjA9MO.js → config-BsoZ23gK.js} +10 -1
- package/dist/config.d.ts +5 -1
- package/dist/config.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -1
- package/dist/linear.d.ts +8 -4
- package/dist/linear.js +1 -1
- package/dist/markdown.d.ts +5 -0
- package/dist/{model-DAbyGE8k.js → model-CJlOLfea.js} +1 -1
- package/dist/{src-vhdzyr4k.js → src-Bm80C3HE.js} +11 -1
- package/dist/{src-6dU0mCpU.js → src-D8wnsQ43.js} +3 -4
- package/dist/typedoc.d.ts +5 -0
- package/dist/typedoc.js +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -101,6 +101,8 @@ An edition is one view of your API for one audience, published to one target. Ed
|
|
|
101
101
|
- For an audience of your own, tag symbols with a category (`@category Team only`) and leave it out
|
|
102
102
|
with `typedocOptions: { excludeCategories: ["Team only"] }`. TypeDoc's `excludeTags` only removes
|
|
103
103
|
a tag's text from comments; it doesn't hide the symbol.
|
|
104
|
+
- `{ treatWarningsAsErrors: true }` (or `treatValidationWarningsAsErrors`) makes TypeDoc warnings,
|
|
105
|
+
such as a dangling `{@link}`, fail `plan`, `push` and `print`, so CI catches broken doc comments.
|
|
104
106
|
|
|
105
107
|
The config is checked when loaded: an unknown option, a `team` on a Markdown edition or a missing
|
|
106
108
|
`out` is an error.
|
|
@@ -116,6 +118,8 @@ The config is checked when loaded: an unknown option, a `team` on a Markdown edi
|
|
|
116
118
|
- The footer links each source file at the pushed commit, using the git `origin` remote. Set a
|
|
117
119
|
top-level `repository` (`"acme/billing"` or a full URL) if the remote uses an SSH host alias. Links
|
|
118
120
|
appear only when the commit is on a remote branch, so push from a pushed commit or from CI.
|
|
121
|
+
- Linear's version history records only edits made in Linear, not updates through its API, so
|
|
122
|
+
synced docs show no history there. The git history of the doc comments is the record.
|
|
119
123
|
|
|
120
124
|
**`markdown`**: files in `out`, ready for VitePress or another static site generator.
|
|
121
125
|
|
|
@@ -126,6 +130,13 @@ The config is checked when loaded: an unknown option, a `team` on a Markdown edi
|
|
|
126
130
|
and hand-written pages. If a page would overwrite a file it didn't write, `push` stops and names it;
|
|
127
131
|
`--force` replaces it. Each Markdown edition needs its own `out`.
|
|
128
132
|
|
|
133
|
+
## GitHub Action
|
|
134
|
+
|
|
135
|
+
`KarolNov/linopress@v0` runs `plan` on pull requests and `push` on pushes to the default branch,
|
|
136
|
+
writes the output to the job summary, and after a push saves the manifest to a branch with a pull
|
|
137
|
+
request to merge it. See the
|
|
138
|
+
[repository README](https://github.com/KarolNov/linopress#github-action) for the workflow and inputs.
|
|
139
|
+
|
|
129
140
|
## Programmatic use
|
|
130
141
|
|
|
131
142
|
The engine is exported too: `linopress-cli` (sync engine), `linopress-cli/config`,
|
package/dist/cli.js
CHANGED
|
@@ -6,11 +6,11 @@ import { readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
|
6
6
|
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
7
7
|
import { parseArgs } from "node:util";
|
|
8
8
|
import { c as renderDoc, g as collectAssets, i as isEmptyPlan, n as apply, o as pendingUrl, s as plan } from "./src-BU0LDvW9.js";
|
|
9
|
-
import { a as serializeManifest, i as parseManifest, o as layoutPages, r as emptyManifest, s as formatPlan, t as containerKey } from "./model-
|
|
10
|
-
import { n as LinearTarget, t as linearTransforms } from "./src-
|
|
9
|
+
import { a as serializeManifest, i as parseManifest, o as layoutPages, r as emptyManifest, s as formatPlan, t as containerKey } from "./model-CJlOLfea.js";
|
|
10
|
+
import { n as LinearTarget, t as linearTransforms } from "./src-D8wnsQ43.js";
|
|
11
11
|
import { a as applyFiles, i as adoptedPaths, l as planFiles, n as renderMarkdownEdition, o as formatFilePlan, s as isEmptyFilePlan, t as markdownTransforms, u as readOutputState } from "./src-zk0Kzn3v.js";
|
|
12
|
-
import { n as readMarkdownPages, t as generateMarkdown } from "./src-
|
|
13
|
-
import { i as overlaps, r as loadConfig } from "./config-
|
|
12
|
+
import { n as readMarkdownPages, t as generateMarkdown } from "./src-Bm80C3HE.js";
|
|
13
|
+
import { i as overlaps, r as loadConfig } from "./config-BsoZ23gK.js";
|
|
14
14
|
// src/footer.ts
|
|
15
15
|
const toPosix = (path) => path.split(sep).join("/");
|
|
16
16
|
const code = (text) => `\`${text}\``;
|
|
@@ -2,6 +2,11 @@ import { access } from "node:fs/promises";
|
|
|
2
2
|
import { dirname, isAbsolute, relative, resolve } from "node:path";
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
4
|
// src/config.ts
|
|
5
|
+
/**
|
|
6
|
+
* `defineConfig` and the types of `linopress.config.ts`, plus `validateConfig` and `loadConfig`.
|
|
7
|
+
*
|
|
8
|
+
* @module linopress-cli/config
|
|
9
|
+
*/
|
|
5
10
|
/** Identity helper that gives `linopress.config.ts` type checking. */
|
|
6
11
|
function defineConfig(config) {
|
|
7
12
|
return config;
|
|
@@ -32,7 +37,11 @@ const TARGET_KEYS = {
|
|
|
32
37
|
],
|
|
33
38
|
markdown: ["out"]
|
|
34
39
|
};
|
|
35
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* True when `a` and `b` are the same folder or one is inside the other.
|
|
42
|
+
*
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
36
45
|
function overlaps(a, b) {
|
|
37
46
|
const inside = (x, y) => {
|
|
38
47
|
const rel = relative(y, x);
|
package/dist/config.d.ts
CHANGED
|
@@ -51,7 +51,11 @@ export interface LoadedConfig {
|
|
|
51
51
|
/** Directory of the config file; relative paths in the config resolve against it. */
|
|
52
52
|
readonly dir: string;
|
|
53
53
|
}
|
|
54
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* True when `a` and `b` are the same folder or one is inside the other.
|
|
56
|
+
*
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
55
59
|
export declare function overlaps(a: string, b: string): boolean;
|
|
56
60
|
/**
|
|
57
61
|
* Checks a config's shape and returns it typed. Throws one error listing every problem, with the
|
package/dist/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as CONFIG_FILES, n as defineConfig, r as loadConfig, i as overlaps, a as validateConfig } from "./config-
|
|
1
|
+
export { t as CONFIG_FILES, n as defineConfig, r as loadConfig, i as overlaps, a as validateConfig } from "./config-BsoZ23gK.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Programmatic API: the sync engine (layout, plan, apply, manifest, link rewriting).
|
|
3
3
|
* Targets and sources live in `linopress-cli/linear` and `linopress-cli/typedoc`.
|
|
4
|
+
*
|
|
5
|
+
* @module linopress-cli
|
|
4
6
|
*/
|
|
5
7
|
import { _ as rewriteImages, a as unlinkInPageLinks, c as AssetEntry, d as ReadAsset, f as assetHash, g as pendingAssetUrl, h as findImages, i as stripHtmlAnchors, l as CollectedAssets, m as contentTypeFor, n as applyTransforms, o as Asset, p as collectAssets, r as defaultTransforms, s as AssetEntries, t as MarkdownTransform, u as ImageRewriteResult, v as uploadedUrl } from "./transforms-BBEyouxz.js";
|
|
6
8
|
import { a as containerKey, i as Page, n as DocNode, o as parseContainerKey, r as LayoutMode, t as Container } from "./model-CgSIC_VE.js";
|
|
@@ -28,7 +30,7 @@ interface Manifest {
|
|
|
28
30
|
}
|
|
29
31
|
export declare function emptyManifest(): Manifest;
|
|
30
32
|
/**
|
|
31
|
-
* Parses a manifest file. Also accepts the
|
|
33
|
+
* Parses a manifest file. Also accepts the original unversioned format
|
|
32
34
|
* (`{ "team:<id>": { "<path>": { id, url, hash } } }`).
|
|
33
35
|
*/
|
|
34
36
|
export declare function parseManifest(json: string): Manifest;
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { C as rewriteLinks, S as resolveLinkPath, _ as contentTypeFor, a as pendingUploads, b as rewriteImages, c as renderDoc, d as stripHtmlAnchors, f as unlinkInPageLinks, g as collectAssets, h as assetHash, i as isEmptyPlan, l as applyTransforms, m as normalizeMarkdown, n as apply, o as pendingUrl, p as contentHash, r as DocNotFoundError, s as plan, t as PLACEHOLDER_CONTENT, u as defaultTransforms, v as findImages, w as mapProse, x as uploadedUrl, y as pendingAssetUrl } from "./src-BU0LDvW9.js";
|
|
2
|
-
import { a as serializeManifest, i as parseManifest, n as parseContainerKey, o as layoutPages, r as emptyManifest, s as formatPlan, t as containerKey } from "./model-
|
|
2
|
+
import { a as serializeManifest, i as parseManifest, n as parseContainerKey, o as layoutPages, r as emptyManifest, s as formatPlan, t as containerKey } from "./model-CJlOLfea.js";
|
|
3
3
|
export { DocNotFoundError, PLACEHOLDER_CONTENT, apply, applyTransforms, assetHash, collectAssets, containerKey, contentHash, contentTypeFor, defaultTransforms, emptyManifest, findImages, formatPlan, isEmptyPlan, layoutPages, mapProse, normalizeMarkdown, parseContainerKey, parseManifest, pendingAssetUrl, pendingUploads, pendingUrl, plan, renderDoc, resolveLinkPath, rewriteImages, rewriteLinks, serializeManifest, stripHtmlAnchors, unlinkInPageLinks, uploadedUrl };
|
package/dist/linear.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Linear Documents target: the GraphQL client and `LinearTarget`.
|
|
3
|
+
*
|
|
4
|
+
* @module linopress-cli/linear
|
|
5
|
+
*/
|
|
1
6
|
import { o as Asset, t as MarkdownTransform } from "./transforms-BBEyouxz.js";
|
|
2
7
|
import { t as Container } from "./model-CgSIC_VE.js";
|
|
3
8
|
import { a as RemoteDoc, i as DocumentTarget, o as UpdateDocInput, t as CreateDocInput } from "./target-Cb9cQbDZ.js";
|
|
@@ -28,7 +33,7 @@ type GraphQLRequest = <T>(query: string, variables?: Record<string, unknown>) =>
|
|
|
28
33
|
/**
|
|
29
34
|
* Minimal Linear GraphQL client. We don't use `@linear/sdk` for document mutations because its
|
|
30
35
|
* published schema lacks `parentDocumentId`, `subDocumentSortOrder` and `teamId`, which the live
|
|
31
|
-
* API accepts (
|
|
36
|
+
* API accepts (check with `pnpm linear:introspect`).
|
|
32
37
|
*/
|
|
33
38
|
export declare function createGraphQLClient(options: GraphQLClientOptions): GraphQLRequest;
|
|
34
39
|
interface LinearTargetOptions extends Omit<GraphQLClientOptions, "apiKey"> {
|
|
@@ -58,9 +63,8 @@ export declare class LinearTarget implements DocumentTarget {
|
|
|
58
63
|
uploadAsset(asset: Asset): Promise<string>;
|
|
59
64
|
}
|
|
60
65
|
/**
|
|
61
|
-
* The Markdown clean-up Linear needs
|
|
62
|
-
*
|
|
63
|
-
* Pass these to `plan` / `apply` when the target is a `LinearTarget`.
|
|
66
|
+
* The Markdown clean-up Linear needs: Linear shows `<a id>` anchors as literal text, and its heading
|
|
67
|
+
* ids are UUIDs, so `#slug` links are dead. Pass these to `plan` / `apply` when the target is a `LinearTarget`.
|
|
64
68
|
*/
|
|
65
69
|
export declare const linearTransforms: readonly MarkdownTransform[];
|
|
66
70
|
export type { GraphQLClientOptions, GraphQLErrorEntry, GraphQLRequest, LinearTargetOptions };
|
package/dist/linear.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { r as LINEAR_ENDPOINT, i as LinearApiError, n as LinearTarget, a as createGraphQLClient, t as linearTransforms } from "./src-
|
|
1
|
+
export { r as LINEAR_ENDPOINT, i as LinearApiError, n as LinearTarget, a as createGraphQLClient, t as linearTransforms } from "./src-D8wnsQ43.js";
|
package/dist/markdown.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Markdown files target, for VitePress or any other static site generator.
|
|
3
|
+
*
|
|
4
|
+
* @module linopress-cli/markdown
|
|
5
|
+
*/
|
|
1
6
|
import { o as Asset, t as MarkdownTransform } from "./transforms-BBEyouxz.js";
|
|
2
7
|
import { n as DocNode } from "./model-CgSIC_VE.js";
|
|
3
8
|
/**
|
|
@@ -147,7 +147,7 @@ function parseEntries(raw) {
|
|
|
147
147
|
return Object.fromEntries(Object.entries(raw).map(([path, e]) => [path, parseEntry(path, e)]));
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
150
|
-
* Parses a manifest file. Also accepts the
|
|
150
|
+
* Parses a manifest file. Also accepts the original unversioned format
|
|
151
151
|
* (`{ "team:<id>": { "<path>": { id, url, hash } } }`).
|
|
152
152
|
*/
|
|
153
153
|
function parseManifest(json) {
|
|
@@ -135,10 +135,20 @@ async function generateMarkdown(options) {
|
|
|
135
135
|
const files = sourcesOf(event);
|
|
136
136
|
if (files.length > 0) sources.set(event.url.split(sep).join("/"), files);
|
|
137
137
|
});
|
|
138
|
+
const strict = app.options.getValue("treatWarningsAsErrors");
|
|
139
|
+
const failOnWarnings = (step) => {
|
|
140
|
+
if (app.logger.hasErrors()) throw new Error(`TypeDoc reported errors ${step}, see above`);
|
|
141
|
+
if (strict && app.logger.hasWarnings()) throw new Error(`TypeDoc reported warnings ${step} (treatWarningsAsErrors), see above`);
|
|
142
|
+
};
|
|
138
143
|
const project = await app.convert();
|
|
139
144
|
if (!project) throw new Error(`TypeDoc failed to convert the project (${options.options})`);
|
|
145
|
+
failOnWarnings("while converting");
|
|
146
|
+
const before = app.logger.warningCount;
|
|
147
|
+
app.validate(project);
|
|
148
|
+
failOnWarnings("while validating");
|
|
149
|
+
if (app.options.getValue("treatValidationWarningsAsErrors") && (app.logger.warningCount !== before || app.logger.validationWarningCount !== 0)) throw new Error("TypeDoc reported warnings while validating (treatValidationWarningsAsErrors), see above");
|
|
140
150
|
await app.generateOutputs(project);
|
|
141
|
-
|
|
151
|
+
failOnWarnings("while rendering");
|
|
142
152
|
return {
|
|
143
153
|
out,
|
|
144
154
|
pages: (await readMarkdownPages(out)).map((page) => {
|
|
@@ -22,7 +22,7 @@ function isRateLimited(status, errors) {
|
|
|
22
22
|
/**
|
|
23
23
|
* Minimal Linear GraphQL client. We don't use `@linear/sdk` for document mutations because its
|
|
24
24
|
* published schema lacks `parentDocumentId`, `subDocumentSortOrder` and `teamId`, which the live
|
|
25
|
-
* API accepts (
|
|
25
|
+
* API accepts (check with `pnpm linear:introspect`).
|
|
26
26
|
*/
|
|
27
27
|
function createGraphQLClient(options) {
|
|
28
28
|
const doFetch = options.fetch ?? fetch;
|
|
@@ -219,9 +219,8 @@ var LinearTarget = class {
|
|
|
219
219
|
};
|
|
220
220
|
// ../linear/src/transforms.ts
|
|
221
221
|
/**
|
|
222
|
-
* The Markdown clean-up Linear needs
|
|
223
|
-
*
|
|
224
|
-
* Pass these to `plan` / `apply` when the target is a `LinearTarget`.
|
|
222
|
+
* The Markdown clean-up Linear needs: Linear shows `<a id>` anchors as literal text, and its heading
|
|
223
|
+
* ids are UUIDs, so `#slug` links are dead. Pass these to `plan` / `apply` when the target is a `LinearTarget`.
|
|
225
224
|
*/
|
|
226
225
|
const linearTransforms = [stripHtmlAnchors, unlinkInPageLinks];
|
|
227
226
|
export { createGraphQLClient as a, LinearApiError as i, LinearTarget as n, LINEAR_ENDPOINT as r, linearTransforms as t };
|
package/dist/typedoc.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The TypeDoc source: runs TypeDoc with typedoc-plugin-markdown and reads its pages.
|
|
3
|
+
*
|
|
4
|
+
* @module linopress-cli/typedoc
|
|
5
|
+
*/
|
|
1
6
|
import { i as Page } from "./model-CgSIC_VE.js";
|
|
2
7
|
interface GenerateOptions {
|
|
3
8
|
/** Path to a TypeDoc options file (`typedoc.json`). */
|
package/dist/typedoc.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as generateMarkdown, n as readMarkdownPages, r as splitTitle } from "./src-
|
|
1
|
+
export { t as generateMarkdown, n as readMarkdownPages, r as splitTitle } from "./src-Bm80C3HE.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "linopress-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Turn TypeScript doc comments into editions: a public Markdown docs site and an internal reference synced into Linear Documents.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Karol Novljaković",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "git+https://github.com/KarolNov/linopress.git",
|
|
10
10
|
"directory": "packages/cli"
|
|
11
11
|
},
|
|
12
|
-
"homepage": "https://
|
|
12
|
+
"homepage": "https://linopress.karolnov.dev",
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://github.com/KarolNov/linopress/issues"
|
|
15
15
|
},
|
|
@@ -75,10 +75,10 @@
|
|
|
75
75
|
"tsdown": "0.23.7",
|
|
76
76
|
"typedoc": "0.28.20",
|
|
77
77
|
"typedoc-plugin-markdown": "4.14.1",
|
|
78
|
-
"@linopress/linear": "0.0.0",
|
|
79
|
-
"@linopress/markdown": "0.0.0",
|
|
80
78
|
"@linopress/core": "0.0.0",
|
|
81
|
-
"@linopress/
|
|
79
|
+
"@linopress/linear": "0.0.0",
|
|
80
|
+
"@linopress/typedoc": "0.0.0",
|
|
81
|
+
"@linopress/markdown": "0.0.0"
|
|
82
82
|
},
|
|
83
83
|
"publishConfig": {
|
|
84
84
|
"access": "public"
|