Skip to content

Commit 9b414e7

Browse files
Optimize DevStackBox content clone
Replace the Netlify build-time full repository clone with a dedicated script that performs a sparse clone of only the docs and required top-level files. Update the screenshot gallery to read prepared images from `public/docs-images`, and ignore/exclude the generated `devstackbox` checkout from Git and TypeScript.
1 parent ec84a48 commit 9b414e7

5 files changed

Lines changed: 37 additions & 4 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@
3131
.vercel
3232
*.tsbuildinfo
3333
next-env.d.ts
34+
devstackbox/

components/screenshot-gallery.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import fs from "node:fs";
22
import path from "node:path";
33
import Image from "next/image";
4-
import { devstackboxPath } from "@/lib/devstackbox-root";
54

65
const IMAGE_EXT = new Set([".png", ".jpg", ".jpeg", ".webp", ".gif"]);
76

87
export function getScreenshotFiles(): string[] {
9-
const dir = devstackboxPath("docs", "images");
8+
const dir = path.join(process.cwd(), "public", "docs-images");
109
if (!fs.existsSync(dir)) return [];
1110
return fs
1211
.readdirSync(dir)

netlify.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build]
2-
command = "git clone --depth 1 https://github.com/DevStackBox/DevStackBox.git devstackbox && node scripts/prepare-content.mjs && pnpm build"
2+
command = "node scripts/clone-devstackbox.mjs && node scripts/prepare-content.mjs && pnpm build"
33
publish = ".next"
44

55
[build.environment]

scripts/clone-devstackbox.mjs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { execSync } from "node:child_process";
2+
import fs from "node:fs";
3+
import path from "node:path";
4+
import { fileURLToPath } from "node:url";
5+
6+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
7+
const websiteRoot = path.join(__dirname, "..");
8+
const target = path.join(websiteRoot, "devstackbox");
9+
10+
if (fs.existsSync(target)) {
11+
fs.rmSync(target, { recursive: true, force: true });
12+
}
13+
14+
const repo = process.env.DEVSTACKBOX_GIT_URL ?? "https://github.com/DevStackBox/DevStackBox.git";
15+
16+
console.log("Cloning DevStackBox (docs only)...");
17+
execSync(
18+
`git clone --depth 1 --filter=blob:none --sparse ${repo} devstackbox`,
19+
{ cwd: websiteRoot, stdio: "inherit" },
20+
);
21+
22+
execSync("git sparse-checkout init --no-cone", {
23+
cwd: target,
24+
stdio: "inherit",
25+
});
26+
27+
execSync(
28+
"git sparse-checkout set docs /CHANGELOG.md /PRIVACY.md /SECURITY.md /LICENSE",
29+
{ cwd: target, stdio: "inherit" },
30+
);
31+
32+
console.log("DevStackBox docs ready at", target);

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
".next/dev/types/**/*.ts"
4141
],
4242
"exclude": [
43-
"node_modules"
43+
"node_modules",
44+
"devstackbox"
4445
]
4546
}

0 commit comments

Comments
 (0)