Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bun run dev:restore
3 changes: 3 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
"scripts": {
"build": "bun run prebuild.ts && next build",
"dev": "bun run prebuild.ts && next dev",
"dev:local": "bun run predev.ts && next dev",
"dev:restore": "bun run restore-languages.ts",
"start": "next start",
"types:check": "fumadocs-mdx && tsc --noEmit",
"postinstall": "fumadocs-mdx",
"lint": "eslint",
"format": "prettier --write .",
"format:check": "prettier --check ."
"format:check": "prettier --check .",
"prepare": "husky"
},
"dependencies": {
"@mdx-js/mdx": "^3.1.1",
Expand Down Expand Up @@ -55,6 +58,7 @@
"@types/react-dom": "^19.2.3",
"eslint": "^9.39.1",
"eslint-config-next": "16.0.7",
"husky": "^9.1.7",
"postcss": "^8.5.6",
"prettier": "^3.7.4",
"prettier-plugin-tailwindcss": "^0.7.2",
Expand Down
57 changes: 57 additions & 0 deletions predev.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { $ } from "bun";
import { rmdir } from "fs/promises";
import { existsSync } from "fs";

console.log("Preparing development environment...");

//check if git is available
$`git --version`.catch(() => {
console.warn("Git is not available. Skipping git-info.json generation.");
process.exit(0);
});


const languagesToRemove = [
"af-ZA",
"ar-SA",
"cs-CZ",
"da-DK",
"de-DE",
"es-ES",
"fr-FR",
"hi-IN",
"hu-HU",
"id-ID",
"it-IT",
"ja-JP",
"lt-LT",
"lv-LV",
"nl-NL",
"pl-PL",
"pt-BR",
"pt-PT",
"ro-RO",
"ru-RU",
"sq-AL",
"sv-SE",
"tr-TR",
"uk-UA",
"vi-VN",
];

console.log("Removing non-English language directories from content/docs/...");

const removePromises = languagesToRemove.map(async (lang) => {
const path = `content/docs/${lang}`;
if (existsSync(path)) {
await rmdir(path, { recursive: true });
console.log(`Removed ${lang}`);
}
});

await Promise.all(removePromises);

console.log("Development environment ready (English only for faster builds)");
console.log(
"Run 'bun run dev:restore' to restore all languages after development",
);
54 changes: 54 additions & 0 deletions restore-languages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
console.log("Restoring language directories...");

import { $ } from "bun";

const languagesToRestore = [
"af-ZA",
"ar-SA",
"cs-CZ",
"da-DK",
"de-DE",
"es-ES",
"fr-FR",
"hi-IN",
"hu-HU",
"id-ID",
"it-IT",
"ja-JP",
"lt-LT",
"lv-LV",
"nl-NL",
"pl-PL",
"pt-BR",
"pt-PT",
"ro-RO",
"ru-RU",
"sq-AL",
"sv-SE",
"tr-TR",
"uk-UA",
"vi-VN",
];

console.log("Restoring deleted language directories from git...");

try {
// Restore each language directory individually
for (const lang of languagesToRestore) {
const path = `./content/docs/${lang}/`;
try {
await $`git reset -q -- ${path}`; // Unstage any changes to the directory
await $`git restore -q ${path}`; // Restore the directory from the last commit
await $`git add ${path}`; // Stage the restored directory
console.log(` Restored ${lang}`);
} catch {
// If the directory was not deleted or already restored, ignore the error
}
}

console.log("All language directories restored successfully");
console.log("Your changes in content/docs/en remain untouched\n");
} catch (error) {
console.log("Something went wrong while restoring languages:");
console.error(error);
}
Loading