@t8/docsgen 0.1.20 → 0.1.22
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/.biomeincludes +1 -0
- package/dist/bin.js +1 -1
- package/package.json +4 -3
- package/schema.json +1 -0
- package/src/bin/getConfig.ts +6 -6
- package/src/bin/toConfig.ts +2 -2
- package/src/bin/toFileContent.ts +1 -1
- package/src/types/{BinConfig.ts → Config.ts} +1 -1
- package/src/types/Context.ts +2 -2
package/.biomeincludes
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!schema.json
|
package/dist/bin.js
CHANGED
|
@@ -548,7 +548,7 @@ function getTitle(ctx, { cover, originalContent, withPackageURL } = {}) {
|
|
|
548
548
|
|
|
549
549
|
// src/bin/toFileContent.ts
|
|
550
550
|
function toFileContent(x) {
|
|
551
|
-
return `${x.replace(/\s+(
|
|
551
|
+
return `${x.replace(/\s+(\r?\n *<\/(script|link|head|body)>)/g, "$1").trim()}
|
|
552
552
|
`;
|
|
553
553
|
}
|
|
554
554
|
|
package/package.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t8/docsgen",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/bin.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"docsgen": "dist/bin.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"build": "npx npm-run-all clean build-bin -
|
|
10
|
+
"build": "npx npm-run-all clean build-bin -p build-css",
|
|
11
11
|
"build-bin": "npx esbuild ./src/bin/run.ts --bundle --outfile=dist/bin.js --platform=node --external:jsdom --external:markdown-it",
|
|
12
12
|
"build-css": "node -e \"require('node:fs').cpSync('src/css', 'dist/css', { force: true, recursive: true });\"",
|
|
13
|
+
"build-schema": "npx ts-json-schema-generator -p src/types/Config.ts -t Config -o schema.json --minify",
|
|
13
14
|
"clean": "node -e \"require('node:fs').rmSync('dist', { force: true, recursive: true });\"",
|
|
14
15
|
"prepublishOnly": "npm run build",
|
|
15
|
-
"preversion": "npx npm-run-all typecheck shape build",
|
|
16
|
+
"preversion": "npx npm-run-all typecheck build-schema shape build",
|
|
16
17
|
"shape": "npx codeshape",
|
|
17
18
|
"typecheck": "tsc --noEmit"
|
|
18
19
|
},
|
package/schema.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"$ref":"#/definitions/Config","$schema":"http://json-schema.org/draft-07/schema#","definitions":{"Config":{"additionalProperties":false,"properties":{"append":{"$ref":"#/definitions/ContentInjectionMap%3C(%22head%22%7C%22body%22)%3E"},"backstory":{"description":"Backstory link URL to be added to the front page.","type":"string"},"baseColor":{"type":"string"},"cname":{"description":"Content of the './CNAME' file.","type":"string"},"contentDir":{"description":"Generated section content directory.","type":"string"},"description":{"type":"string"},"dir":{"type":"string"},"entries":{"items":{"$ref":"#/definitions/EntryConfig"},"type":"array"},"favicon":{"description":"Favicon URL.","type":"string"},"faviconType":{"type":"string"},"htmlTitle":{"type":"string"},"id":{"type":"string"},"jsorg":{"description":"As a boolean, it means whether to add the '<package_name>.js.org' domain to the './CNAME' file.\n\nAs a string, it sets the '<jsorg_value>.js.org' domain to the './CNAME' file.","type":["boolean","string"]},"mainBranch":{"type":"string"},"name":{"type":"string"},"nav":{"description":"URL of an HTML file inserted into the navigation bar.","type":"string"},"npm":{"type":"string"},"redirect":{"description":"Redirection URL.","type":"string"},"remove":{"description":"Whether to remove the GitHub Pages branch and quit.","type":"boolean"},"repo":{"type":"string"},"root":{"description":"Main page root path.","type":"string"},"scope":{"description":"Scope URL.","type":"string"},"singlePage":{"description":"Whether to show all sections on a single page.","type":"boolean"},"source":{"type":"string"},"targetBranch":{"description":"Target branch.","examples":["gh-pages"],"type":"string"},"targetId":{"type":"string"},"theme":{"type":"string"},"title":{"type":"string"},"version":{"type":"string"},"ymid":{"type":["number","string"]}},"type":"object"},"ContentInjectionMap<(\"head\"|\"body\")>":{"additionalProperties":false,"properties":{"body":{"anyOf":[{"type":"string"},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"},{"items":{"anyOf":[{"type":"string"},{"not":{}},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"}]},"type":"array"}]},"head":{"anyOf":[{"type":"string"},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"},{"items":{"anyOf":[{"type":"string"},{"not":{}},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"}]},"type":"array"}]}},"type":"object"},"EntryConfig":{"additionalProperties":false,"properties":{"append":{"$ref":"#/definitions/ContentInjectionMap%3C(%22head%22%7C%22body%22)%3E"},"backstory":{"description":"Backstory link URL to be added to the front page.","type":"string"},"baseColor":{"type":"string"},"cname":{"description":"Content of the './CNAME' file.","type":"string"},"contentDir":{"description":"Generated section content directory.","type":"string"},"description":{"type":"string"},"dir":{"type":"string"},"favicon":{"description":"Favicon URL.","type":"string"},"faviconType":{"type":"string"},"htmlTitle":{"type":"string"},"id":{"type":"string"},"jsorg":{"description":"As a boolean, it means whether to add the '<package_name>.js.org' domain to the './CNAME' file.\n\nAs a string, it sets the '<jsorg_value>.js.org' domain to the './CNAME' file.","type":["boolean","string"]},"mainBranch":{"type":"string"},"name":{"type":"string"},"nav":{"description":"URL of an HTML file inserted into the navigation bar.","type":"string"},"npm":{"type":"string"},"redirect":{"description":"Redirection URL.","type":"string"},"remove":{"description":"Whether to remove the GitHub Pages branch and quit.","type":"boolean"},"repo":{"type":"string"},"root":{"description":"Main page root path.","type":"string"},"scope":{"description":"Scope URL.","type":"string"},"singlePage":{"description":"Whether to show all sections on a single page.","type":"boolean"},"source":{"type":"string"},"targetBranch":{"description":"Target branch.","examples":["gh-pages"],"type":"string"},"theme":{"type":"string"},"title":{"type":"string"},"version":{"type":"string"},"ymid":{"type":["number","string"]}},"type":"object"},"Page":{"enum":["index","start","section","redirect"],"type":"string"}}}
|
package/src/bin/getConfig.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseArgs } from "args-json";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Config } from "../types/Config";
|
|
3
3
|
import type { EntryConfig } from "../types/EntryConfig";
|
|
4
4
|
import type { PackageMetadata } from "../types/PackageMetadata";
|
|
5
5
|
import { fetchText } from "./fetchText";
|
|
@@ -41,17 +41,17 @@ async function reviseConfig(config: EntryConfig) {
|
|
|
41
41
|
return deriveMissingProps(await addMetadata(config));
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
let config:
|
|
44
|
+
let config: Config | null = null;
|
|
45
45
|
|
|
46
|
-
export async function getConfig(): Promise<
|
|
46
|
+
export async function getConfig(): Promise<Config> {
|
|
47
47
|
if (config) return config;
|
|
48
48
|
|
|
49
|
-
let localConfig:
|
|
49
|
+
let localConfig: Config = {};
|
|
50
50
|
|
|
51
51
|
try {
|
|
52
52
|
localConfig = JSON.parse(
|
|
53
53
|
await fetchText("./docsgen.config.json"),
|
|
54
|
-
) as
|
|
54
|
+
) as Config;
|
|
55
55
|
} catch {}
|
|
56
56
|
|
|
57
57
|
let targetId: string | undefined;
|
|
@@ -65,7 +65,7 @@ export async function getConfig(): Promise<BinConfig> {
|
|
|
65
65
|
root: "/",
|
|
66
66
|
contentDir: "x",
|
|
67
67
|
...localConfig,
|
|
68
|
-
...parseArgs<
|
|
68
|
+
...parseArgs<Config>(args),
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
if (config.entries)
|
package/src/bin/toConfig.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Config } from "../types/Config";
|
|
2
2
|
import type { PackageMetadata } from "../types/PackageMetadata";
|
|
3
3
|
import { toRepoURL } from "./toRepoURL";
|
|
4
4
|
|
|
5
|
-
export function toConfig(metadata: PackageMetadata): Partial<
|
|
5
|
+
export function toConfig(metadata: PackageMetadata): Partial<Config> {
|
|
6
6
|
let { name, description, version, repository } = metadata;
|
|
7
7
|
|
|
8
8
|
return {
|
package/src/bin/toFileContent.ts
CHANGED
package/src/types/Context.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Config } from "./Config";
|
|
2
2
|
import type { EntryConfig } from "./EntryConfig";
|
|
3
3
|
|
|
4
|
-
export type Context = Omit<
|
|
4
|
+
export type Context = Omit<Config, "entries"> & EntryConfig;
|