docus 3.0.1-20250617-084102-6d354ce → 3.0.1-20250617-085304-b250a1b
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/app/modules/default-configs.ts +25 -3
- package/dist/main.mjs +7 -119
- package/package.json +1 -1
|
@@ -1,26 +1,48 @@
|
|
|
1
1
|
import { defineNuxtModule } from 'nuxt/kit'
|
|
2
2
|
import { defu } from 'defu'
|
|
3
3
|
import { inferSiteURL, getPackageJsonMetadata } from '../../cli/utils'
|
|
4
|
+
import { getGitBranch, getGitEnv, getLocalGitInfo } from '../../cli/git'
|
|
4
5
|
|
|
5
6
|
export default defineNuxtModule({
|
|
6
7
|
meta: {
|
|
7
8
|
name: 'default-configs',
|
|
8
9
|
},
|
|
9
10
|
async setup(_options, nuxt) {
|
|
11
|
+
const dir = nuxt.options.rootDir
|
|
10
12
|
const url = inferSiteURL()
|
|
11
|
-
const meta = await getPackageJsonMetadata(
|
|
13
|
+
const meta = await getPackageJsonMetadata(dir)
|
|
14
|
+
const gitInfo = await getLocalGitInfo(dir) || getGitEnv()
|
|
15
|
+
const siteName = nuxt.options?.site?.name || meta.name || gitInfo?.name || ''
|
|
12
16
|
|
|
13
17
|
// @ts-expect-error llms is not defined in the schema
|
|
14
18
|
nuxt.options.llms = defu(nuxt.options.llms, {
|
|
15
19
|
domain: url,
|
|
16
|
-
title:
|
|
20
|
+
title: siteName,
|
|
17
21
|
description: meta.description || '',
|
|
18
22
|
})
|
|
19
23
|
|
|
20
24
|
nuxt.options.site = defu(nuxt.options.site, {
|
|
21
25
|
url,
|
|
22
|
-
name:
|
|
26
|
+
name: siteName,
|
|
23
27
|
debug: false,
|
|
24
28
|
})
|
|
29
|
+
|
|
30
|
+
nuxt.options.appConfig = defu(nuxt.options.appConfig, {
|
|
31
|
+
header: {
|
|
32
|
+
title: siteName,
|
|
33
|
+
},
|
|
34
|
+
github: {
|
|
35
|
+
owner: gitInfo?.owner,
|
|
36
|
+
name: gitInfo?.name,
|
|
37
|
+
url: gitInfo?.url,
|
|
38
|
+
branch: getGitBranch(),
|
|
39
|
+
},
|
|
40
|
+
seo: {
|
|
41
|
+
titleTemplate: `%s - ${siteName}`,
|
|
42
|
+
title: siteName,
|
|
43
|
+
description: meta.description || '',
|
|
44
|
+
},
|
|
45
|
+
toc: {},
|
|
46
|
+
})
|
|
25
47
|
},
|
|
26
48
|
})
|
package/dist/main.mjs
CHANGED
|
@@ -4,132 +4,20 @@
|
|
|
4
4
|
import * as dotenv from "dotenv";
|
|
5
5
|
|
|
6
6
|
// cli/cli.ts
|
|
7
|
-
import { resolve as
|
|
7
|
+
import { resolve as resolve2 } from "path";
|
|
8
8
|
import { defineCommand, runMain } from "citty";
|
|
9
9
|
|
|
10
10
|
// cli/setup.ts
|
|
11
11
|
import { fileURLToPath } from "url";
|
|
12
|
-
import { resolve as resolve2 } from "path";
|
|
13
|
-
|
|
14
|
-
// cli/git.ts
|
|
15
|
-
import { execSync } from "child_process";
|
|
16
|
-
import { readGitConfig } from "pkg-types";
|
|
17
|
-
import gitUrlParse from "git-url-parse";
|
|
18
|
-
function getGitBranch() {
|
|
19
|
-
const envName = process.env.CF_PAGES_BRANCH || process.env.CI_COMMIT_BRANCH || process.env.VERCEL_GIT_COMMIT_REF || process.env.BRANCH || process.env.GITHUB_REF_NAME;
|
|
20
|
-
if (envName && envName !== "HEAD") {
|
|
21
|
-
return envName;
|
|
22
|
-
}
|
|
23
|
-
try {
|
|
24
|
-
const branch = execSync("git rev-parse --abbrev-ref HEAD").toString().trim();
|
|
25
|
-
if (branch && branch !== "HEAD") {
|
|
26
|
-
return branch;
|
|
27
|
-
}
|
|
28
|
-
} catch {
|
|
29
|
-
return "main";
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
async function getLocalGitInfo(rootDir) {
|
|
33
|
-
const remote = await getLocalGitRemote(rootDir);
|
|
34
|
-
if (!remote) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
const { name, owner, source } = gitUrlParse(remote);
|
|
38
|
-
const url = `https://${source}/${owner}/${name}`;
|
|
39
|
-
return {
|
|
40
|
-
name,
|
|
41
|
-
owner,
|
|
42
|
-
url
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
async function getLocalGitRemote(dir) {
|
|
46
|
-
var _a, _b;
|
|
47
|
-
try {
|
|
48
|
-
const parsed = await readGitConfig(dir);
|
|
49
|
-
if (!parsed) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
return (_b = (_a = parsed.remote) == null ? void 0 : _a["origin"]) == null ? void 0 : _b.url;
|
|
53
|
-
} catch {
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function getGitEnv() {
|
|
57
|
-
var _a, _b, _c;
|
|
58
|
-
const envInfo = {
|
|
59
|
-
// Provider
|
|
60
|
-
provider: process.env.VERCEL_GIT_PROVIDER || (process.env.GITHUB_SERVER_URL ? "github" : void 0) || "",
|
|
61
|
-
// Owner
|
|
62
|
-
owner: process.env.VERCEL_GIT_REPO_OWNER || process.env.GITHUB_REPOSITORY_OWNER || ((_a = process.env.CI_PROJECT_PATH) == null ? void 0 : _a.split("/").shift()) || "",
|
|
63
|
-
// Name
|
|
64
|
-
name: process.env.VERCEL_GIT_REPO_SLUG || ((_b = process.env.GITHUB_REPOSITORY) == null ? void 0 : _b.split("/").pop()) || ((_c = process.env.CI_PROJECT_PATH) == null ? void 0 : _c.split("/").splice(1).join("/")) || "",
|
|
65
|
-
// Url
|
|
66
|
-
url: process.env.REPOSITORY_URL || ""
|
|
67
|
-
// netlify
|
|
68
|
-
};
|
|
69
|
-
if (!envInfo.url && envInfo.provider && envInfo.owner && envInfo.name) {
|
|
70
|
-
envInfo.url = `https://${envInfo.provider}.com/${envInfo.owner}/${envInfo.name}`;
|
|
71
|
-
}
|
|
72
|
-
if (!envInfo.name && !envInfo.owner && envInfo.url) {
|
|
73
|
-
try {
|
|
74
|
-
const { name, owner } = gitUrlParse(envInfo.url);
|
|
75
|
-
envInfo.name = name;
|
|
76
|
-
envInfo.owner = owner;
|
|
77
|
-
} catch {
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return {
|
|
81
|
-
name: envInfo.name,
|
|
82
|
-
owner: envInfo.owner,
|
|
83
|
-
url: envInfo.url
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// cli/utils.ts
|
|
88
|
-
import { readFile } from "fs/promises";
|
|
89
12
|
import { resolve } from "path";
|
|
90
|
-
async function getPackageJsonMetadata(dir) {
|
|
91
|
-
try {
|
|
92
|
-
const packageJson = await readFile(resolve(dir, "package.json"), "utf-8");
|
|
93
|
-
const parsed = JSON.parse(packageJson);
|
|
94
|
-
return {
|
|
95
|
-
name: parsed.name,
|
|
96
|
-
description: parsed.description
|
|
97
|
-
};
|
|
98
|
-
} catch {
|
|
99
|
-
return {
|
|
100
|
-
name: "docs"
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// cli/setup.ts
|
|
106
13
|
var appDir = fileURLToPath(new URL("../app", import.meta.url));
|
|
107
14
|
var pkgDir = fileURLToPath(new URL("..", import.meta.url));
|
|
108
15
|
async function getNuxtConfig(dir, _opts = {}) {
|
|
109
|
-
|
|
110
|
-
global.__DOCS_DIR__ = resolve2(dir, "content");
|
|
111
|
-
const gitInfo = await getLocalGitInfo(dir) || getGitEnv();
|
|
16
|
+
global.__DOCS_DIR__ = resolve(dir, "content");
|
|
112
17
|
return {
|
|
113
|
-
compatibilityDate: "2025-
|
|
18
|
+
compatibilityDate: "2025-06-17",
|
|
114
19
|
extends: [appDir],
|
|
115
|
-
modulesDir: [
|
|
116
|
-
appConfig: {
|
|
117
|
-
header: {
|
|
118
|
-
title: meta.name || ""
|
|
119
|
-
},
|
|
120
|
-
github: {
|
|
121
|
-
owner: gitInfo == null ? void 0 : gitInfo.owner,
|
|
122
|
-
name: gitInfo == null ? void 0 : gitInfo.name,
|
|
123
|
-
url: gitInfo == null ? void 0 : gitInfo.url,
|
|
124
|
-
branch: getGitBranch()
|
|
125
|
-
},
|
|
126
|
-
seo: {
|
|
127
|
-
titleTemplate: `%s - ${meta.name}`,
|
|
128
|
-
title: meta.name || "",
|
|
129
|
-
description: meta.description || ""
|
|
130
|
-
},
|
|
131
|
-
toc: {}
|
|
132
|
-
}
|
|
20
|
+
modulesDir: [resolve(pkgDir, "node_modules"), resolve(appDir, "node_modules")]
|
|
133
21
|
};
|
|
134
22
|
}
|
|
135
23
|
|
|
@@ -150,7 +38,7 @@ function createCLI(opts) {
|
|
|
150
38
|
},
|
|
151
39
|
args: { ...sharedArgs },
|
|
152
40
|
async setup({ args }) {
|
|
153
|
-
const dir =
|
|
41
|
+
const dir = resolve2(args.dir);
|
|
154
42
|
const { runCommand } = await import("nuxi");
|
|
155
43
|
await runCommand("init", [dir, "-t", "gh:nuxtlabs/docus/.starter", dir]);
|
|
156
44
|
}
|
|
@@ -162,7 +50,7 @@ function createCLI(opts) {
|
|
|
162
50
|
},
|
|
163
51
|
args: { ...sharedArgs },
|
|
164
52
|
async setup({ args }) {
|
|
165
|
-
const dir =
|
|
53
|
+
const dir = resolve2(args.dir);
|
|
166
54
|
const nuxtConfig = await getNuxtConfig(dir, {
|
|
167
55
|
...opts.setup,
|
|
168
56
|
dev: true
|
|
@@ -178,7 +66,7 @@ function createCLI(opts) {
|
|
|
178
66
|
},
|
|
179
67
|
args: { ...sharedArgs },
|
|
180
68
|
async setup({ args }) {
|
|
181
|
-
const dir =
|
|
69
|
+
const dir = resolve2(args.dir);
|
|
182
70
|
const nuxtConfig = await getNuxtConfig(dir, opts.setup);
|
|
183
71
|
const { runCommand } = await import("nuxi");
|
|
184
72
|
await runCommand("build", [dir], { overrides: nuxtConfig });
|