@t8/docsgen 0.1.1 → 0.1.3
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/dist/bin.js +17 -5
- package/package.json +1 -1
- package/src/bin/createFiles.ts +11 -0
- package/src/bin/getConfig.ts +1 -1
- package/src/bin/run.ts +1 -1
- package/src/bin/setImages.ts +3 -1
- package/src/types/EntryConfig.ts +4 -2
package/dist/bin.js
CHANGED
|
@@ -136,7 +136,7 @@ async function getConfig() {
|
|
|
136
136
|
}
|
|
137
137
|
let targetId;
|
|
138
138
|
let args = process.argv.slice(2);
|
|
139
|
-
if (!args[0].startsWith("--")) targetId = args.shift();
|
|
139
|
+
if (args.length !== 0 && !args[0].startsWith("--")) targetId = args.shift();
|
|
140
140
|
config = {
|
|
141
141
|
targetId,
|
|
142
142
|
mainBranch: "main",
|
|
@@ -152,7 +152,7 @@ async function getConfig() {
|
|
|
152
152
|
|
|
153
153
|
// src/bin/runEntry.ts
|
|
154
154
|
var import_node_child_process2 = require("node:child_process");
|
|
155
|
-
var
|
|
155
|
+
var import_promises7 = require("node:fs/promises");
|
|
156
156
|
var import_node_util2 = require("node:util");
|
|
157
157
|
|
|
158
158
|
// src/bin/cleanup.ts
|
|
@@ -166,6 +166,9 @@ async function cleanup({ dir = "" }) {
|
|
|
166
166
|
);
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
// src/bin/createFiles.ts
|
|
170
|
+
var import_promises6 = require("node:fs/promises");
|
|
171
|
+
|
|
169
172
|
// src/bin/setCName.ts
|
|
170
173
|
var import_promises3 = require("node:fs/promises");
|
|
171
174
|
var import_node_path2 = require("node:path");
|
|
@@ -680,13 +683,22 @@ function getIcon(baseColor = "gray") {
|
|
|
680
683
|
}
|
|
681
684
|
|
|
682
685
|
// src/bin/setImages.ts
|
|
683
|
-
async function setImages({ dir = "", colorScheme }) {
|
|
686
|
+
async function setImages({ dir = "", colorScheme, favicon }) {
|
|
687
|
+
if (favicon) return;
|
|
684
688
|
await (0, import_promises5.writeFile)((0, import_node_path4.join)(dir, "./favicon.svg"), `${getIcon(colorScheme)}
|
|
685
689
|
`);
|
|
686
690
|
}
|
|
687
691
|
|
|
688
692
|
// src/bin/createFiles.ts
|
|
689
693
|
async function createFiles(ctx) {
|
|
694
|
+
let { dir } = ctx;
|
|
695
|
+
if (dir) {
|
|
696
|
+
try {
|
|
697
|
+
await (0, import_promises6.access)(dir);
|
|
698
|
+
} catch {
|
|
699
|
+
await (0, import_promises6.mkdir)(dir);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
690
702
|
await Promise.all([setCName(ctx), setContent(ctx), setImages(ctx)]);
|
|
691
703
|
}
|
|
692
704
|
|
|
@@ -695,7 +707,7 @@ var exec2 = (0, import_node_util2.promisify)(import_node_child_process2.exec);
|
|
|
695
707
|
var stdout = async (cmd) => (await exec2(cmd)).stdout.trim();
|
|
696
708
|
async function isGitDir() {
|
|
697
709
|
try {
|
|
698
|
-
await (0,
|
|
710
|
+
await (0, import_promises7.access)("./.git");
|
|
699
711
|
return true;
|
|
700
712
|
} catch {
|
|
701
713
|
return false;
|
|
@@ -743,7 +755,7 @@ async function run() {
|
|
|
743
755
|
let entryCtx = entries.find(
|
|
744
756
|
({ id, dir }) => id === targetId || dir === targetId
|
|
745
757
|
);
|
|
746
|
-
if (entryCtx) runEntry(entryCtx);
|
|
758
|
+
if (entryCtx) runEntry({ ...rootCtx, ...entryCtx });
|
|
747
759
|
else console.warn(`Specified config entry not found: '${targetId}'`);
|
|
748
760
|
} else {
|
|
749
761
|
await Promise.all(
|
package/package.json
CHANGED
package/src/bin/createFiles.ts
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
+
import { access, mkdir } from "node:fs/promises";
|
|
1
2
|
import type { Context } from "../types/Context";
|
|
2
3
|
import { setCName } from "./setCName";
|
|
3
4
|
import { setContent } from "./setContent";
|
|
4
5
|
import { setImages } from "./setImages";
|
|
5
6
|
|
|
6
7
|
export async function createFiles(ctx: Context) {
|
|
8
|
+
let { dir } = ctx;
|
|
9
|
+
|
|
10
|
+
if (dir) {
|
|
11
|
+
try {
|
|
12
|
+
await access(dir);
|
|
13
|
+
} catch {
|
|
14
|
+
await mkdir(dir);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
await Promise.all([setCName(ctx), setContent(ctx), setImages(ctx)]);
|
|
8
19
|
}
|
package/src/bin/getConfig.ts
CHANGED
|
@@ -26,7 +26,7 @@ export async function getConfig(): Promise<BinConfig> {
|
|
|
26
26
|
let targetId: string | undefined;
|
|
27
27
|
let args = process.argv.slice(2);
|
|
28
28
|
|
|
29
|
-
if (!args[0].startsWith("--")) targetId = args.shift();
|
|
29
|
+
if (args.length !== 0 && !args[0].startsWith("--")) targetId = args.shift();
|
|
30
30
|
|
|
31
31
|
config = {
|
|
32
32
|
targetId,
|
package/src/bin/run.ts
CHANGED
|
@@ -17,7 +17,7 @@ async function run() {
|
|
|
17
17
|
({ id, dir }) => id === targetId || dir === targetId,
|
|
18
18
|
);
|
|
19
19
|
|
|
20
|
-
if (entryCtx) runEntry(entryCtx);
|
|
20
|
+
if (entryCtx) runEntry({ ...rootCtx, ...entryCtx });
|
|
21
21
|
else console.warn(`Specified config entry not found: '${targetId}'`);
|
|
22
22
|
} else {
|
|
23
23
|
await Promise.all(
|
package/src/bin/setImages.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { join } from "node:path";
|
|
|
3
3
|
import type { Context } from "../types/Context";
|
|
4
4
|
import { getIcon } from "../utils/getIcon";
|
|
5
5
|
|
|
6
|
-
export async function setImages({ dir = "", colorScheme }: Context) {
|
|
6
|
+
export async function setImages({ dir = "", colorScheme, favicon }: Context) {
|
|
7
|
+
if (favicon) return;
|
|
8
|
+
|
|
7
9
|
await writeFile(join(dir, "./favicon.svg"), `${getIcon(colorScheme)}\n`);
|
|
8
10
|
}
|
package/src/types/EntryConfig.ts
CHANGED
|
@@ -37,9 +37,11 @@ export type EntryConfig = {
|
|
|
37
37
|
backstory?: string;
|
|
38
38
|
/** URL of an HTML file inserted into the navigation bar. */
|
|
39
39
|
nav?: string;
|
|
40
|
-
/**
|
|
40
|
+
/** Favicon URL. */
|
|
41
|
+
favicon?: string;
|
|
42
|
+
/** Scope URL. */
|
|
41
43
|
scope?: string;
|
|
42
|
-
/** Redirection URL */
|
|
44
|
+
/** Redirection URL. */
|
|
43
45
|
redirect?: string;
|
|
44
46
|
/** Whether to remove the GitHub Pages branch and quit. */
|
|
45
47
|
remove?: boolean;
|