@t8/docsgen 0.1.2 → 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 +15 -3
- package/package.json +1 -1
- package/src/bin/createFiles.ts +11 -0
- package/src/bin/setImages.ts +3 -1
- package/src/types/EntryConfig.ts +4 -2
package/dist/bin.js
CHANGED
|
@@ -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;
|
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/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;
|