barodoc 7.2.0 → 8.0.0
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/chunk-EFTFHBH3.js +183 -0
- package/dist/cli.js +125 -96
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1 -1
- package/package.json +20 -3
- package/dist/chunk-G25BMQMN.js +0 -255
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
// src/runtime/project.ts
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import pc from "picocolors";
|
|
6
|
+
var BARODOC_DIR = ".barodoc";
|
|
7
|
+
var __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
function findCliNodeModules() {
|
|
9
|
+
let best = null;
|
|
10
|
+
let dir = __dirname;
|
|
11
|
+
while (dir !== path.parse(dir).root) {
|
|
12
|
+
const candidate = path.join(dir, "node_modules");
|
|
13
|
+
if (fs.existsSync(candidate) && fs.existsSync(path.join(candidate, "@barodoc", "theme-docs"))) {
|
|
14
|
+
best = candidate;
|
|
15
|
+
}
|
|
16
|
+
dir = path.dirname(dir);
|
|
17
|
+
}
|
|
18
|
+
if (!best) {
|
|
19
|
+
throw new Error(
|
|
20
|
+
"Could not locate node_modules for barodoc runtime dependencies"
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
return best;
|
|
24
|
+
}
|
|
25
|
+
function isCustomProject(dir) {
|
|
26
|
+
return fs.existsSync(path.join(dir, "astro.config.mjs")) || fs.existsSync(path.join(dir, "astro.config.ts")) || fs.existsSync(path.join(dir, "astro.config.js"));
|
|
27
|
+
}
|
|
28
|
+
async function loadProjectConfig(dir, configFile) {
|
|
29
|
+
const configPath = configFile ? path.resolve(dir, configFile) : path.join(dir, "barodoc.config.json");
|
|
30
|
+
if (fs.existsSync(configPath)) {
|
|
31
|
+
const content = await fs.readFile(configPath, "utf-8");
|
|
32
|
+
return {
|
|
33
|
+
config: JSON.parse(content),
|
|
34
|
+
configPath
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
config: getDefaultConfig(),
|
|
39
|
+
configPath: null
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function getDefaultConfig() {
|
|
43
|
+
return {
|
|
44
|
+
name: "Documentation",
|
|
45
|
+
navigation: [],
|
|
46
|
+
i18n: {
|
|
47
|
+
defaultLocale: "en",
|
|
48
|
+
locales: ["en"]
|
|
49
|
+
},
|
|
50
|
+
search: {
|
|
51
|
+
enabled: true
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
async function createProject(options) {
|
|
56
|
+
const { root, docsDir, config } = options;
|
|
57
|
+
const projectDir = path.join(root, BARODOC_DIR);
|
|
58
|
+
console.log(pc.dim(`Creating temporary project in ${BARODOC_DIR}/`));
|
|
59
|
+
await fs.remove(projectDir);
|
|
60
|
+
await fs.ensureDir(projectDir);
|
|
61
|
+
const cliNodeModules = findCliNodeModules();
|
|
62
|
+
await fs.symlink(cliNodeModules, path.join(projectDir, "node_modules"), "junction");
|
|
63
|
+
await fs.writeJSON(
|
|
64
|
+
path.join(projectDir, "package.json"),
|
|
65
|
+
{ name: "barodoc-temp", private: true },
|
|
66
|
+
{ spaces: 2 }
|
|
67
|
+
);
|
|
68
|
+
await fs.writeJSON(path.join(projectDir, "barodoc.config.json"), config, {
|
|
69
|
+
spaces: 2
|
|
70
|
+
});
|
|
71
|
+
await fs.writeJSON(
|
|
72
|
+
path.join(projectDir, "tsconfig.json"),
|
|
73
|
+
{
|
|
74
|
+
extends: "astro/tsconfigs/strict",
|
|
75
|
+
compilerOptions: {
|
|
76
|
+
jsx: "react-jsx",
|
|
77
|
+
jsxImportSource: "react"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
{ spaces: 2 }
|
|
81
|
+
);
|
|
82
|
+
const contentDir = path.join(projectDir, "src/content");
|
|
83
|
+
await fs.ensureDir(contentDir);
|
|
84
|
+
const docsAbsolute = path.resolve(root, docsDir);
|
|
85
|
+
const docsLink = path.join(contentDir, "docs");
|
|
86
|
+
if (fs.existsSync(docsAbsolute)) {
|
|
87
|
+
await fs.copy(docsAbsolute, docsLink);
|
|
88
|
+
} else {
|
|
89
|
+
await fs.ensureDir(docsLink);
|
|
90
|
+
}
|
|
91
|
+
const blogDir = path.join(root, "blog");
|
|
92
|
+
const blogLink = path.join(contentDir, "blog");
|
|
93
|
+
if (fs.existsSync(blogDir)) {
|
|
94
|
+
await fs.copy(blogDir, blogLink);
|
|
95
|
+
}
|
|
96
|
+
const changelogDir = path.join(root, "changelog");
|
|
97
|
+
const changelogLink = path.join(contentDir, "changelog");
|
|
98
|
+
if (fs.existsSync(changelogDir)) {
|
|
99
|
+
await fs.copy(changelogDir, changelogLink);
|
|
100
|
+
}
|
|
101
|
+
if (config.sections) {
|
|
102
|
+
for (const section of config.sections) {
|
|
103
|
+
const sectionDir = path.join(root, section.slug);
|
|
104
|
+
const sectionDest = path.join(contentDir, section.slug);
|
|
105
|
+
if (fs.existsSync(sectionDir)) {
|
|
106
|
+
await fs.copy(sectionDir, sectionDest);
|
|
107
|
+
console.log(pc.dim(` Copied ${section.slug}/ section`));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const pagesDir = path.join(root, "pages");
|
|
112
|
+
const pagesDest = path.join(contentDir, "pages");
|
|
113
|
+
if (fs.existsSync(pagesDir)) {
|
|
114
|
+
await fs.copy(pagesDir, pagesDest);
|
|
115
|
+
console.log(pc.dim(" Copied pages/ directory"));
|
|
116
|
+
}
|
|
117
|
+
const publicDir = path.join(root, "public");
|
|
118
|
+
const publicLink = path.join(projectDir, "public");
|
|
119
|
+
if (fs.existsSync(publicDir)) {
|
|
120
|
+
await fs.symlink(publicDir, publicLink, "dir");
|
|
121
|
+
} else {
|
|
122
|
+
await fs.ensureDir(publicLink);
|
|
123
|
+
}
|
|
124
|
+
const overridesDir = path.join(root, "overrides");
|
|
125
|
+
const overridesLink = path.join(projectDir, "overrides");
|
|
126
|
+
if (fs.existsSync(overridesDir)) {
|
|
127
|
+
await fs.symlink(overridesDir, overridesLink, "dir");
|
|
128
|
+
console.log(pc.dim(" Linked overrides/ directory"));
|
|
129
|
+
}
|
|
130
|
+
return projectDir;
|
|
131
|
+
}
|
|
132
|
+
async function cleanupProject(root) {
|
|
133
|
+
const projectDir = path.join(root, BARODOC_DIR);
|
|
134
|
+
if (fs.existsSync(projectDir)) {
|
|
135
|
+
await fs.remove(projectDir);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function generateAstroConfigFile(config) {
|
|
139
|
+
const siteLine = config.site ? `
|
|
140
|
+
site: ${JSON.stringify(config.site)},` : "";
|
|
141
|
+
const baseLine = config.base ? `
|
|
142
|
+
base: ${JSON.stringify(config.base)},` : "";
|
|
143
|
+
return `import { defineConfig } from "astro/config";
|
|
144
|
+
import barodoc from "@barodoc/core";
|
|
145
|
+
import docsTheme from "@barodoc/theme-docs/theme";
|
|
146
|
+
|
|
147
|
+
export default defineConfig({${siteLine}${baseLine}
|
|
148
|
+
integrations: [
|
|
149
|
+
barodoc({
|
|
150
|
+
config: "./barodoc.config.json",
|
|
151
|
+
theme: docsTheme(),
|
|
152
|
+
}),
|
|
153
|
+
],
|
|
154
|
+
vite: {
|
|
155
|
+
resolve: {
|
|
156
|
+
preserveSymlinks: true,
|
|
157
|
+
},
|
|
158
|
+
ssr: {
|
|
159
|
+
noExternal: true,
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
`;
|
|
164
|
+
}
|
|
165
|
+
function findDocsDir(root) {
|
|
166
|
+
const candidates = ["docs", "content", "src/content/docs"];
|
|
167
|
+
for (const candidate of candidates) {
|
|
168
|
+
const fullPath = path.join(root, candidate);
|
|
169
|
+
if (fs.existsSync(fullPath)) {
|
|
170
|
+
return candidate;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return "docs";
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export {
|
|
177
|
+
isCustomProject,
|
|
178
|
+
loadProjectConfig,
|
|
179
|
+
createProject,
|
|
180
|
+
cleanupProject,
|
|
181
|
+
generateAstroConfigFile,
|
|
182
|
+
findDocsDir
|
|
183
|
+
};
|
package/dist/cli.js
CHANGED
|
@@ -3,22 +3,26 @@ import {
|
|
|
3
3
|
cleanupProject,
|
|
4
4
|
createProject,
|
|
5
5
|
findDocsDir,
|
|
6
|
-
|
|
6
|
+
generateAstroConfigFile,
|
|
7
7
|
isCustomProject,
|
|
8
|
-
loadProjectConfig
|
|
9
|
-
|
|
10
|
-
} from "./chunk-G25BMQMN.js";
|
|
8
|
+
loadProjectConfig
|
|
9
|
+
} from "./chunk-EFTFHBH3.js";
|
|
11
10
|
|
|
12
11
|
// src/cli.ts
|
|
13
12
|
import cac from "cac";
|
|
14
13
|
import pc10 from "picocolors";
|
|
15
14
|
|
|
15
|
+
// package.json
|
|
16
|
+
var version = "8.0.0";
|
|
17
|
+
|
|
16
18
|
// src/commands/serve.ts
|
|
17
19
|
import path from "path";
|
|
18
20
|
import pc from "picocolors";
|
|
19
|
-
import {
|
|
21
|
+
import { dev } from "astro";
|
|
22
|
+
import barodoc from "@barodoc/core";
|
|
23
|
+
import docsTheme from "@barodoc/theme-docs/theme";
|
|
20
24
|
async function serve(dir, options) {
|
|
21
|
-
const root = path.resolve(process.cwd()
|
|
25
|
+
const root = path.resolve(process.cwd());
|
|
22
26
|
console.log();
|
|
23
27
|
console.log(pc.bold(pc.cyan(" barodoc serve")));
|
|
24
28
|
console.log();
|
|
@@ -26,11 +30,16 @@ async function serve(dir, options) {
|
|
|
26
30
|
console.log(pc.dim("Detected custom Astro project"));
|
|
27
31
|
console.log(pc.dim("Running astro dev..."));
|
|
28
32
|
console.log();
|
|
29
|
-
await
|
|
33
|
+
const devServer2 = await dev({ root });
|
|
34
|
+
process.on("SIGINT", async () => {
|
|
35
|
+
console.log();
|
|
36
|
+
console.log(pc.dim("Shutting down..."));
|
|
37
|
+
await devServer2.stop();
|
|
38
|
+
});
|
|
30
39
|
return;
|
|
31
40
|
}
|
|
32
41
|
console.log(pc.dim("Quick mode - creating temporary project..."));
|
|
33
|
-
const docsDir = findDocsDir(root);
|
|
42
|
+
const docsDir = dir || findDocsDir(root);
|
|
34
43
|
const { config } = await loadProjectConfig(root, options.config);
|
|
35
44
|
const projectDir = await createProject({
|
|
36
45
|
root,
|
|
@@ -38,44 +47,50 @@ async function serve(dir, options) {
|
|
|
38
47
|
config,
|
|
39
48
|
configPath: options.config
|
|
40
49
|
});
|
|
41
|
-
console.log(pc.green("\u2713 Project
|
|
50
|
+
console.log(pc.green("\u2713 Project ready"));
|
|
42
51
|
console.log();
|
|
43
|
-
await
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
52
|
+
const devServer = await dev({
|
|
53
|
+
root: projectDir,
|
|
54
|
+
configFile: false,
|
|
55
|
+
integrations: [
|
|
56
|
+
barodoc({
|
|
57
|
+
config: "./barodoc.config.json",
|
|
58
|
+
theme: docsTheme()
|
|
59
|
+
})
|
|
60
|
+
],
|
|
61
|
+
vite: {
|
|
62
|
+
resolve: {
|
|
63
|
+
preserveSymlinks: true
|
|
64
|
+
},
|
|
65
|
+
ssr: {
|
|
66
|
+
noExternal: [/^@barodoc\//]
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
server: {
|
|
70
|
+
port: options.port,
|
|
71
|
+
host: options.host ? true : void 0,
|
|
72
|
+
open: options.open
|
|
73
|
+
},
|
|
74
|
+
...config.site ? { site: config.site } : {},
|
|
75
|
+
...config.base ? { base: config.base } : {}
|
|
76
|
+
});
|
|
77
|
+
process.on("SIGINT", async () => {
|
|
78
|
+
console.log();
|
|
79
|
+
console.log(pc.dim("Shutting down..."));
|
|
80
|
+
await devServer.stop();
|
|
81
|
+
});
|
|
70
82
|
}
|
|
71
83
|
|
|
72
84
|
// src/commands/build.ts
|
|
73
85
|
import path2 from "path";
|
|
74
86
|
import pc2 from "picocolors";
|
|
75
87
|
import fs from "fs-extra";
|
|
76
|
-
import { execa
|
|
88
|
+
import { execa } from "execa";
|
|
89
|
+
import { build as astroBuild } from "astro";
|
|
90
|
+
import barodoc2 from "@barodoc/core";
|
|
91
|
+
import docsTheme2 from "@barodoc/theme-docs/theme";
|
|
77
92
|
async function build(dir, options) {
|
|
78
|
-
const root = path2.resolve(process.cwd()
|
|
93
|
+
const root = path2.resolve(process.cwd());
|
|
79
94
|
const outputDir = path2.resolve(process.cwd(), options.output);
|
|
80
95
|
console.log();
|
|
81
96
|
console.log(pc2.bold(pc2.cyan(" barodoc build")));
|
|
@@ -84,11 +99,11 @@ async function build(dir, options) {
|
|
|
84
99
|
console.log(pc2.dim("Detected custom Astro project"));
|
|
85
100
|
console.log(pc2.dim("Running astro build..."));
|
|
86
101
|
console.log();
|
|
87
|
-
await
|
|
102
|
+
await astroBuild({ root });
|
|
88
103
|
return;
|
|
89
104
|
}
|
|
90
105
|
console.log(pc2.dim("Quick mode - creating temporary project..."));
|
|
91
|
-
const docsDir = findDocsDir(root);
|
|
106
|
+
const docsDir = dir || findDocsDir(root);
|
|
92
107
|
const { config } = await loadProjectConfig(root, options.config);
|
|
93
108
|
const projectDir = await createProject({
|
|
94
109
|
root,
|
|
@@ -96,11 +111,43 @@ async function build(dir, options) {
|
|
|
96
111
|
config,
|
|
97
112
|
configPath: options.config
|
|
98
113
|
});
|
|
99
|
-
console.log(pc2.green("\u2713 Project
|
|
114
|
+
console.log(pc2.green("\u2713 Project ready"));
|
|
100
115
|
console.log();
|
|
101
|
-
await installDependencies(projectDir, options.clean);
|
|
102
116
|
try {
|
|
103
|
-
|
|
117
|
+
console.log(pc2.dim("Building site..."));
|
|
118
|
+
await astroBuild({
|
|
119
|
+
root: projectDir,
|
|
120
|
+
configFile: false,
|
|
121
|
+
integrations: [
|
|
122
|
+
barodoc2({
|
|
123
|
+
config: "./barodoc.config.json",
|
|
124
|
+
theme: docsTheme2()
|
|
125
|
+
})
|
|
126
|
+
],
|
|
127
|
+
vite: {
|
|
128
|
+
resolve: {
|
|
129
|
+
preserveSymlinks: true
|
|
130
|
+
},
|
|
131
|
+
ssr: {
|
|
132
|
+
noExternal: true
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
logLevel: "info",
|
|
136
|
+
...config.site ? { site: config.site } : {},
|
|
137
|
+
...config.base ? { base: config.base } : {}
|
|
138
|
+
});
|
|
139
|
+
console.log();
|
|
140
|
+
console.log(pc2.dim("Generating search index..."));
|
|
141
|
+
try {
|
|
142
|
+
await execa("npx", ["pagefind", "--site", "dist"], {
|
|
143
|
+
cwd: projectDir,
|
|
144
|
+
stdio: "inherit"
|
|
145
|
+
});
|
|
146
|
+
} catch {
|
|
147
|
+
console.log(
|
|
148
|
+
pc2.yellow("\u26A0 Pagefind not available, skipping search index")
|
|
149
|
+
);
|
|
150
|
+
}
|
|
104
151
|
const tempDist = path2.join(projectDir, "dist");
|
|
105
152
|
if (await fs.pathExists(tempDist)) {
|
|
106
153
|
await fs.ensureDir(outputDir);
|
|
@@ -119,23 +166,6 @@ async function build(dir, options) {
|
|
|
119
166
|
console.log(` ${pc2.dim("Preview:")} barodoc preview ${dir}`);
|
|
120
167
|
console.log();
|
|
121
168
|
}
|
|
122
|
-
async function runAstroBuild(projectDir, outputDir) {
|
|
123
|
-
console.log(pc2.dim("Building site..."));
|
|
124
|
-
await execa2("npx", ["astro", "build"], {
|
|
125
|
-
cwd: projectDir,
|
|
126
|
-
stdio: "inherit"
|
|
127
|
-
});
|
|
128
|
-
console.log();
|
|
129
|
-
console.log(pc2.dim("Generating search index..."));
|
|
130
|
-
try {
|
|
131
|
-
await execa2("npx", ["pagefind", "--site", "dist"], {
|
|
132
|
-
cwd: projectDir,
|
|
133
|
-
stdio: "inherit"
|
|
134
|
-
});
|
|
135
|
-
} catch {
|
|
136
|
-
console.log(pc2.yellow("\u26A0 Pagefind not available, skipping search index"));
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
169
|
|
|
140
170
|
// src/commands/create.ts
|
|
141
171
|
import path3 from "path";
|
|
@@ -547,7 +577,7 @@ node_modules/
|
|
|
547
577
|
import path4 from "path";
|
|
548
578
|
import pc4 from "picocolors";
|
|
549
579
|
import fs3 from "fs-extra";
|
|
550
|
-
import {
|
|
580
|
+
import { preview as astroPreview } from "astro";
|
|
551
581
|
async function preview(dir, options) {
|
|
552
582
|
const root = path4.resolve(process.cwd(), dir);
|
|
553
583
|
const distDir = path4.resolve(root, options.output);
|
|
@@ -565,22 +595,17 @@ async function preview(dir, options) {
|
|
|
565
595
|
}
|
|
566
596
|
console.log(pc4.dim(`Serving from ${options.output}/`));
|
|
567
597
|
console.log();
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
{
|
|
573
|
-
stdio: "inherit"
|
|
574
|
-
}
|
|
575
|
-
);
|
|
576
|
-
} catch (error) {
|
|
577
|
-
if (error.signal === "SIGINT") {
|
|
578
|
-
console.log();
|
|
579
|
-
console.log(pc4.dim("Shutting down..."));
|
|
580
|
-
} else {
|
|
581
|
-
throw error;
|
|
598
|
+
const previewServer = await astroPreview({
|
|
599
|
+
root,
|
|
600
|
+
server: {
|
|
601
|
+
port: options.port
|
|
582
602
|
}
|
|
583
|
-
}
|
|
603
|
+
});
|
|
604
|
+
process.on("SIGINT", async () => {
|
|
605
|
+
console.log();
|
|
606
|
+
console.log(pc4.dim("Shutting down..."));
|
|
607
|
+
await previewServer.stop();
|
|
608
|
+
});
|
|
584
609
|
}
|
|
585
610
|
|
|
586
611
|
// src/commands/init.ts
|
|
@@ -722,7 +747,7 @@ barodoc preview
|
|
|
722
747
|
import path6 from "path";
|
|
723
748
|
import pc6 from "picocolors";
|
|
724
749
|
import fs5 from "fs-extra";
|
|
725
|
-
|
|
750
|
+
import { execa as execa2 } from "execa";
|
|
726
751
|
async function eject(dir, options) {
|
|
727
752
|
const root = path6.resolve(process.cwd(), dir);
|
|
728
753
|
console.log();
|
|
@@ -773,17 +798,28 @@ async function eject(dir, options) {
|
|
|
773
798
|
configPath: options.config
|
|
774
799
|
});
|
|
775
800
|
console.log(pc6.green("\u2713 Generated project files"));
|
|
776
|
-
await
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
801
|
+
await fs5.writeFile(
|
|
802
|
+
path6.join(root, "astro.config.mjs"),
|
|
803
|
+
generateAstroConfigFile(config)
|
|
804
|
+
);
|
|
780
805
|
console.log(pc6.green("\u2713 Created astro.config.mjs"));
|
|
781
806
|
await fs5.copy(
|
|
782
807
|
path6.join(projectDir, "tsconfig.json"),
|
|
783
808
|
path6.join(root, "tsconfig.json")
|
|
784
809
|
);
|
|
785
810
|
console.log(pc6.green("\u2713 Created tsconfig.json"));
|
|
786
|
-
const
|
|
811
|
+
const runtimeDeps = {
|
|
812
|
+
astro: "^5.0.0",
|
|
813
|
+
"@astrojs/mdx": "^4.0.0",
|
|
814
|
+
"@astrojs/react": "^4.0.0",
|
|
815
|
+
"@barodoc/core": "latest",
|
|
816
|
+
"@barodoc/theme-docs": "latest",
|
|
817
|
+
"@tailwindcss/typography": "^0.5.19",
|
|
818
|
+
"@tailwindcss/vite": "^4.0.0",
|
|
819
|
+
tailwindcss: "^4.0.0",
|
|
820
|
+
react: "^19.0.0",
|
|
821
|
+
"react-dom": "^19.0.0"
|
|
822
|
+
};
|
|
787
823
|
const rootPkgPath = path6.join(root, "package.json");
|
|
788
824
|
if (await fs5.pathExists(rootPkgPath)) {
|
|
789
825
|
const existingPkg = await fs5.readJSON(rootPkgPath);
|
|
@@ -792,7 +828,7 @@ async function eject(dir, options) {
|
|
|
792
828
|
type: "module",
|
|
793
829
|
dependencies: {
|
|
794
830
|
...existingPkg.dependencies ?? {},
|
|
795
|
-
...
|
|
831
|
+
...runtimeDeps
|
|
796
832
|
}
|
|
797
833
|
};
|
|
798
834
|
await fs5.writeJSON(rootPkgPath, merged, { spaces: 2 });
|
|
@@ -807,7 +843,7 @@ async function eject(dir, options) {
|
|
|
807
843
|
build: "astro build",
|
|
808
844
|
preview: "astro preview"
|
|
809
845
|
},
|
|
810
|
-
dependencies:
|
|
846
|
+
dependencies: runtimeDeps
|
|
811
847
|
};
|
|
812
848
|
await fs5.writeJSON(rootPkgPath, newPkg, { spaces: 2 });
|
|
813
849
|
console.log(pc6.green("\u2713 Created package.json"));
|
|
@@ -819,19 +855,12 @@ async function eject(dir, options) {
|
|
|
819
855
|
await fs5.copy(contentConfigSrc, contentConfigDst);
|
|
820
856
|
console.log(pc6.green("\u2713 Created src/content/config.ts"));
|
|
821
857
|
}
|
|
822
|
-
|
|
823
|
-
const dstNodeModules = path6.join(root, "node_modules");
|
|
824
|
-
if (await fs5.pathExists(srcNodeModules)) {
|
|
825
|
-
if (!await fs5.pathExists(dstNodeModules)) {
|
|
826
|
-
console.log(pc6.dim("Moving node_modules to project root..."));
|
|
827
|
-
await fs5.move(srcNodeModules, dstNodeModules);
|
|
828
|
-
console.log(pc6.green("\u2713 Moved node_modules"));
|
|
829
|
-
} else {
|
|
830
|
-
console.log(pc6.dim("node_modules already exists in root, skipping move"));
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
await fs5.remove(path6.join(root, BARODOC_DIR));
|
|
858
|
+
await cleanupProject(root);
|
|
834
859
|
console.log(pc6.green("\u2713 Removed .barodoc/ directory"));
|
|
860
|
+
console.log();
|
|
861
|
+
console.log(pc6.dim("Installing dependencies..."));
|
|
862
|
+
await execa2("npm", ["install"], { cwd: root, stdio: "inherit" });
|
|
863
|
+
console.log(pc6.green("\u2713 Dependencies installed"));
|
|
835
864
|
const gitignorePath = path6.join(root, ".gitignore");
|
|
836
865
|
if (await fs5.pathExists(gitignorePath)) {
|
|
837
866
|
const content = await fs5.readFile(gitignorePath, "utf-8");
|
package/dist/index.d.ts
CHANGED
|
@@ -8,11 +8,13 @@ interface ProjectOptions {
|
|
|
8
8
|
configPath?: string;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* Create temporary Astro project for quick mode
|
|
11
|
+
* Create temporary Astro project for quick mode.
|
|
12
|
+
* Only generates config files and content symlinks — no node_modules needed.
|
|
13
|
+
* Astro is invoked programmatically from the CLI process.
|
|
12
14
|
*/
|
|
13
15
|
declare function createProject(options: ProjectOptions): Promise<string>;
|
|
14
16
|
/**
|
|
15
|
-
* Clean up temporary project
|
|
17
|
+
* Clean up temporary project (remove everything).
|
|
16
18
|
*/
|
|
17
19
|
declare function cleanupProject(root: string): Promise<void>;
|
|
18
20
|
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "barodoc",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "Documentation framework powered by Astro",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -18,6 +18,14 @@
|
|
|
18
18
|
"dist"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
+
"astro": "^5.0.0",
|
|
22
|
+
"@astrojs/mdx": "^4.0.0",
|
|
23
|
+
"@astrojs/react": "^4.0.0",
|
|
24
|
+
"@tailwindcss/typography": "^0.5.19",
|
|
25
|
+
"@tailwindcss/vite": "^4.0.0",
|
|
26
|
+
"tailwindcss": "^4.0.0",
|
|
27
|
+
"react": "^19.0.0",
|
|
28
|
+
"react-dom": "^19.0.0",
|
|
21
29
|
"cac": "^6.7.14",
|
|
22
30
|
"chokidar": "^4.0.0",
|
|
23
31
|
"execa": "^9.5.0",
|
|
@@ -26,8 +34,17 @@
|
|
|
26
34
|
"picocolors": "^1.1.1",
|
|
27
35
|
"zod": "^3.24.0",
|
|
28
36
|
"zod-to-json-schema": "^3.25.1",
|
|
29
|
-
"@barodoc/
|
|
30
|
-
"@barodoc/
|
|
37
|
+
"@barodoc/core": "8.0.0",
|
|
38
|
+
"@barodoc/theme-docs": "8.0.0",
|
|
39
|
+
"@barodoc/plugin-analytics": "8.0.0",
|
|
40
|
+
"@barodoc/plugin-docsearch": "8.0.0",
|
|
41
|
+
"@barodoc/plugin-llms-txt": "8.0.0",
|
|
42
|
+
"@barodoc/plugin-og-image": "7.0.0",
|
|
43
|
+
"@barodoc/plugin-openapi": "8.0.0",
|
|
44
|
+
"@barodoc/plugin-pwa": "8.0.0",
|
|
45
|
+
"@barodoc/plugin-rss": "8.0.0",
|
|
46
|
+
"@barodoc/plugin-search": "8.0.0",
|
|
47
|
+
"@barodoc/plugin-sitemap": "8.0.0"
|
|
31
48
|
},
|
|
32
49
|
"devDependencies": {
|
|
33
50
|
"@types/fs-extra": "^11.0.4",
|
package/dist/chunk-G25BMQMN.js
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
// package.json
|
|
2
|
-
var version = "7.2.0";
|
|
3
|
-
|
|
4
|
-
// src/runtime/project.ts
|
|
5
|
-
import fs from "fs-extra";
|
|
6
|
-
import path from "path";
|
|
7
|
-
import pc from "picocolors";
|
|
8
|
-
import { execa } from "execa";
|
|
9
|
-
var BARODOC_DIR = ".barodoc";
|
|
10
|
-
var CLI_VERSION_FILE = ".cli-version";
|
|
11
|
-
function isCustomProject(dir) {
|
|
12
|
-
return fs.existsSync(path.join(dir, "astro.config.mjs")) || fs.existsSync(path.join(dir, "astro.config.ts")) || fs.existsSync(path.join(dir, "astro.config.js"));
|
|
13
|
-
}
|
|
14
|
-
async function loadProjectConfig(dir, configFile) {
|
|
15
|
-
const configPath = configFile ? path.resolve(dir, configFile) : path.join(dir, "barodoc.config.json");
|
|
16
|
-
if (fs.existsSync(configPath)) {
|
|
17
|
-
const content = await fs.readFile(configPath, "utf-8");
|
|
18
|
-
return {
|
|
19
|
-
config: JSON.parse(content),
|
|
20
|
-
configPath
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
config: getDefaultConfig(),
|
|
25
|
-
configPath: null
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
function getDefaultConfig() {
|
|
29
|
-
return {
|
|
30
|
-
name: "Documentation",
|
|
31
|
-
navigation: [],
|
|
32
|
-
i18n: {
|
|
33
|
-
defaultLocale: "en",
|
|
34
|
-
locales: ["en"]
|
|
35
|
-
},
|
|
36
|
-
search: {
|
|
37
|
-
enabled: true
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
async function createProject(options) {
|
|
42
|
-
const { root, docsDir, config, configPath } = options;
|
|
43
|
-
const projectDir = path.join(root, BARODOC_DIR);
|
|
44
|
-
console.log(pc.dim(`Creating temporary project in ${BARODOC_DIR}/`));
|
|
45
|
-
const nodeModulesDir = path.join(projectDir, "node_modules");
|
|
46
|
-
const hasNodeModules = fs.existsSync(nodeModulesDir);
|
|
47
|
-
if (hasNodeModules) {
|
|
48
|
-
const preserve = /* @__PURE__ */ new Set(["node_modules", CLI_VERSION_FILE]);
|
|
49
|
-
const entries = await fs.readdir(projectDir);
|
|
50
|
-
for (const entry of entries) {
|
|
51
|
-
if (!preserve.has(entry)) {
|
|
52
|
-
await fs.remove(path.join(projectDir, entry));
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
} else {
|
|
56
|
-
await fs.remove(projectDir);
|
|
57
|
-
await fs.ensureDir(projectDir);
|
|
58
|
-
}
|
|
59
|
-
await fs.writeJSON(
|
|
60
|
-
path.join(projectDir, "package.json"),
|
|
61
|
-
{
|
|
62
|
-
name: "barodoc-temp",
|
|
63
|
-
type: "module",
|
|
64
|
-
private: true,
|
|
65
|
-
dependencies: {
|
|
66
|
-
astro: "^5.0.0",
|
|
67
|
-
"@astrojs/mdx": "^4.0.0",
|
|
68
|
-
"@astrojs/react": "^4.0.0",
|
|
69
|
-
"@tailwindcss/typography": "^0.5.19",
|
|
70
|
-
"@tailwindcss/vite": "^4.0.0",
|
|
71
|
-
tailwindcss: "^4.0.0",
|
|
72
|
-
"@barodoc/core": `^${version.split(".")[0]}.0.0`,
|
|
73
|
-
"@barodoc/theme-docs": `^${version.split(".")[0]}.0.0`,
|
|
74
|
-
react: "^19.0.0",
|
|
75
|
-
"react-dom": "^19.0.0"
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
{ spaces: 2 }
|
|
79
|
-
);
|
|
80
|
-
const astroConfig = generateAstroConfig(config, configPath || null, docsDir);
|
|
81
|
-
await fs.writeFile(path.join(projectDir, "astro.config.mjs"), astroConfig);
|
|
82
|
-
await fs.writeJSON(
|
|
83
|
-
path.join(projectDir, "tsconfig.json"),
|
|
84
|
-
{
|
|
85
|
-
extends: "astro/tsconfigs/strict",
|
|
86
|
-
compilerOptions: {
|
|
87
|
-
jsx: "react-jsx",
|
|
88
|
-
jsxImportSource: "react"
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
{ spaces: 2 }
|
|
92
|
-
);
|
|
93
|
-
const tempConfigPath = path.join(projectDir, "barodoc.config.json");
|
|
94
|
-
await fs.writeJSON(tempConfigPath, config, { spaces: 2 });
|
|
95
|
-
const contentDir = path.join(projectDir, "src/content");
|
|
96
|
-
await fs.ensureDir(contentDir);
|
|
97
|
-
await fs.writeFile(
|
|
98
|
-
path.join(contentDir, "config.ts"),
|
|
99
|
-
generateContentConfig()
|
|
100
|
-
);
|
|
101
|
-
const docsAbsolute = path.resolve(root, docsDir);
|
|
102
|
-
const docsLink = path.join(contentDir, "docs");
|
|
103
|
-
if (fs.existsSync(docsAbsolute)) {
|
|
104
|
-
await fs.symlink(docsAbsolute, docsLink, "dir");
|
|
105
|
-
} else {
|
|
106
|
-
await fs.ensureDir(docsLink);
|
|
107
|
-
}
|
|
108
|
-
const publicDir = path.join(root, "public");
|
|
109
|
-
const publicLink = path.join(projectDir, "public");
|
|
110
|
-
if (fs.existsSync(publicDir)) {
|
|
111
|
-
await fs.symlink(publicDir, publicLink, "dir");
|
|
112
|
-
} else {
|
|
113
|
-
await fs.ensureDir(publicLink);
|
|
114
|
-
}
|
|
115
|
-
const overridesDir = path.join(root, "overrides");
|
|
116
|
-
const overridesLink = path.join(projectDir, "overrides");
|
|
117
|
-
if (fs.existsSync(overridesDir)) {
|
|
118
|
-
await fs.symlink(overridesDir, overridesLink, "dir");
|
|
119
|
-
console.log(pc.dim(" Linked overrides/ directory"));
|
|
120
|
-
}
|
|
121
|
-
return projectDir;
|
|
122
|
-
}
|
|
123
|
-
function needsReinstall(projectDir) {
|
|
124
|
-
const versionFile = path.join(projectDir, CLI_VERSION_FILE);
|
|
125
|
-
if (!fs.existsSync(versionFile)) return true;
|
|
126
|
-
const cached = fs.readFileSync(versionFile, "utf-8").trim();
|
|
127
|
-
return cached !== version;
|
|
128
|
-
}
|
|
129
|
-
function writeCLIVersion(projectDir) {
|
|
130
|
-
fs.writeFileSync(path.join(projectDir, CLI_VERSION_FILE), version);
|
|
131
|
-
}
|
|
132
|
-
async function installDependencies(projectDir, force = false) {
|
|
133
|
-
const nodeModulesDir = path.join(projectDir, "node_modules");
|
|
134
|
-
const hasNodeModules = fs.existsSync(nodeModulesDir);
|
|
135
|
-
const versionChanged = hasNodeModules && needsReinstall(projectDir);
|
|
136
|
-
if (versionChanged && !force) {
|
|
137
|
-
console.log(
|
|
138
|
-
pc.yellow(`Barodoc updated (\u2192 ${version}), reinstalling dependencies...`)
|
|
139
|
-
);
|
|
140
|
-
force = true;
|
|
141
|
-
}
|
|
142
|
-
if (!force && hasNodeModules) {
|
|
143
|
-
console.log(pc.dim("Using cached dependencies..."));
|
|
144
|
-
console.log();
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
if (force && hasNodeModules) {
|
|
148
|
-
console.log(pc.dim("Clearing cached dependencies..."));
|
|
149
|
-
await fs.remove(nodeModulesDir);
|
|
150
|
-
}
|
|
151
|
-
console.log(pc.dim("Installing dependencies..."));
|
|
152
|
-
await execa("npm", ["install", "--prefer-offline"], {
|
|
153
|
-
cwd: projectDir,
|
|
154
|
-
stdio: "inherit"
|
|
155
|
-
});
|
|
156
|
-
writeCLIVersion(projectDir);
|
|
157
|
-
console.log(pc.green("\u2713 Dependencies installed"));
|
|
158
|
-
console.log();
|
|
159
|
-
}
|
|
160
|
-
async function cleanupProject(root) {
|
|
161
|
-
const projectDir = path.join(root, BARODOC_DIR);
|
|
162
|
-
if (!fs.existsSync(projectDir)) return;
|
|
163
|
-
const preserve = /* @__PURE__ */ new Set(["node_modules", CLI_VERSION_FILE]);
|
|
164
|
-
const entries = await fs.readdir(projectDir);
|
|
165
|
-
for (const entry of entries) {
|
|
166
|
-
if (!preserve.has(entry)) {
|
|
167
|
-
await fs.remove(path.join(projectDir, entry));
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
function generateAstroConfig(config, configPath, docsDir) {
|
|
172
|
-
const siteLine = config.site ? `
|
|
173
|
-
site: ${JSON.stringify(config.site)},` : "";
|
|
174
|
-
const baseLine = config.base ? `
|
|
175
|
-
base: ${JSON.stringify(config.base)},` : "";
|
|
176
|
-
return `import { defineConfig } from "astro/config";
|
|
177
|
-
import barodoc from "@barodoc/core";
|
|
178
|
-
import docsTheme from "@barodoc/theme-docs/theme";
|
|
179
|
-
|
|
180
|
-
export default defineConfig({${siteLine}${baseLine}
|
|
181
|
-
integrations: [
|
|
182
|
-
barodoc({
|
|
183
|
-
config: "./barodoc.config.json",
|
|
184
|
-
theme: docsTheme(),
|
|
185
|
-
}),
|
|
186
|
-
],
|
|
187
|
-
});
|
|
188
|
-
`;
|
|
189
|
-
}
|
|
190
|
-
function generateContentConfig() {
|
|
191
|
-
return `import { defineCollection, z } from "astro:content";
|
|
192
|
-
|
|
193
|
-
const docsCollection = defineCollection({
|
|
194
|
-
type: "content",
|
|
195
|
-
schema: z.object({
|
|
196
|
-
title: z.string().optional(),
|
|
197
|
-
description: z.string().optional(),
|
|
198
|
-
tags: z.array(z.string()).optional(),
|
|
199
|
-
related: z.array(z.string()).optional(),
|
|
200
|
-
category: z.string().optional(),
|
|
201
|
-
api_reference: z.boolean().optional(),
|
|
202
|
-
difficulty: z.enum(["beginner", "intermediate", "advanced"]).optional(),
|
|
203
|
-
lastUpdated: z.date().optional(),
|
|
204
|
-
}),
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
const blogCollection = defineCollection({
|
|
208
|
-
type: "content",
|
|
209
|
-
schema: z.object({
|
|
210
|
-
title: z.string(),
|
|
211
|
-
description: z.string().optional(),
|
|
212
|
-
excerpt: z.string().optional(),
|
|
213
|
-
date: z.coerce.date().optional(),
|
|
214
|
-
author: z.string().optional(),
|
|
215
|
-
image: z.string().optional(),
|
|
216
|
-
tags: z.array(z.string()).optional(),
|
|
217
|
-
}),
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
const changelogCollection = defineCollection({
|
|
221
|
-
type: "content",
|
|
222
|
-
schema: z.object({
|
|
223
|
-
title: z.string().optional(),
|
|
224
|
-
version: z.string(),
|
|
225
|
-
date: z.coerce.date(),
|
|
226
|
-
}),
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
export const collections = {
|
|
230
|
-
docs: docsCollection,
|
|
231
|
-
blog: blogCollection,
|
|
232
|
-
changelog: changelogCollection,
|
|
233
|
-
};
|
|
234
|
-
`;
|
|
235
|
-
}
|
|
236
|
-
function findDocsDir(root) {
|
|
237
|
-
const candidates = ["docs", "content", "src/content/docs"];
|
|
238
|
-
for (const candidate of candidates) {
|
|
239
|
-
const fullPath = path.join(root, candidate);
|
|
240
|
-
if (fs.existsSync(fullPath)) {
|
|
241
|
-
return candidate;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return "docs";
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
export {
|
|
248
|
-
version,
|
|
249
|
-
isCustomProject,
|
|
250
|
-
loadProjectConfig,
|
|
251
|
-
createProject,
|
|
252
|
-
installDependencies,
|
|
253
|
-
cleanupProject,
|
|
254
|
-
findDocsDir
|
|
255
|
-
};
|