@mdocs/server 0.1.1 → 0.1.2
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/index.d.ts +1 -0
- package/dist/index.js +12 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -52,7 +52,8 @@ function parseConfig(overrides = {}) {
|
|
|
52
52
|
port: overrides.port ?? parseInt(process.env["PORT"] ?? String(DEFAULT_PORT), 10),
|
|
53
53
|
host: overrides.host ?? process.env["HOST"] ?? DEFAULT_HOST,
|
|
54
54
|
dataDir: overrides.dataDir ?? process.env["DATA_DIR"] ?? homedir(),
|
|
55
|
-
origins: overrides.origins ?? DEFAULT_ORIGINS
|
|
55
|
+
origins: overrides.origins ?? DEFAULT_ORIGINS,
|
|
56
|
+
githubToken: overrides.githubToken ?? process.env["GITHUB_TOKEN"]
|
|
56
57
|
};
|
|
57
58
|
}
|
|
58
59
|
function reposDir(dataDir) {
|
|
@@ -98,11 +99,18 @@ function run(args, cwd) {
|
|
|
98
99
|
});
|
|
99
100
|
});
|
|
100
101
|
}
|
|
101
|
-
async function cloneRepo(url, dest, branch) {
|
|
102
|
-
const
|
|
102
|
+
async function cloneRepo(url, dest, branch, token) {
|
|
103
|
+
const cloneUrl = token ? injectToken(url, token) : url;
|
|
104
|
+
const args = ["clone", cloneUrl, dest, "--single-branch"];
|
|
103
105
|
if (branch) args.push("--branch", branch);
|
|
104
106
|
await run(args);
|
|
105
107
|
}
|
|
108
|
+
function injectToken(url, token) {
|
|
109
|
+
const parsed = new URL(url);
|
|
110
|
+
parsed.username = "oauth2";
|
|
111
|
+
parsed.password = token;
|
|
112
|
+
return parsed.toString();
|
|
113
|
+
}
|
|
106
114
|
async function pullRepo(repoPath) {
|
|
107
115
|
await run(["pull", "--ff-only"], repoPath);
|
|
108
116
|
}
|
|
@@ -286,7 +294,7 @@ function reposRouter(config) {
|
|
|
286
294
|
const cloneDir = join4(reposDir2, id);
|
|
287
295
|
try {
|
|
288
296
|
mkdirSync(reposDir2, { recursive: true });
|
|
289
|
-
await cloneRepo(url, cloneDir, branch);
|
|
297
|
+
await cloneRepo(url, cloneDir, branch, config.githubToken);
|
|
290
298
|
const detectedBranch = branch ?? await getDefaultBranch(cloneDir);
|
|
291
299
|
const currentCommit = await getHeadCommit(cloneDir);
|
|
292
300
|
const files = scanMarkdownFiles(cloneDir, id);
|