diff --git a/.changeset/forty-trains-pull.md b/.changeset/forty-trains-pull.md new file mode 100644 index 000000000..41044a8e8 --- /dev/null +++ b/.changeset/forty-trains-pull.md @@ -0,0 +1,5 @@ +--- +'@gitbook/icons': patch +--- + +Fix first run of the package in development mode diff --git a/bun.lockb b/bun.lockb index 62159121e..44eff2399 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 15fcd3d3d..5913dac90 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "e2e": "turbo run e2e", "changeset": "changeset", "release": "turbo run release && changeset publish", - "download:env": "op read op://gitbook-x-dev/gitbook-open/.env.local >> .env.local" + "download:env": "op read op://gitbook-x-dev/gitbook-open/.env.local >> .env.local", + "clean": "turbo run clean" }, "workspaces": [ "packages/*" @@ -24,7 +25,7 @@ "devDependencies": { "@changesets/cli": "^2.27.7", "prettier": "^3.0.3", - "turbo": "^2.0.9" + "turbo": "^2.1.2" }, "patchedDependencies": { "@vercel/next@4.3.6": "patches/@vercel%2Fnext@4.3.6.patch" diff --git a/packages/emoji-codepoints/package.json b/packages/emoji-codepoints/package.json index b023a384e..50398c455 100644 --- a/packages/emoji-codepoints/package.json +++ b/packages/emoji-codepoints/package.json @@ -9,6 +9,7 @@ "emoji-assets": "^8.0.0" }, "scripts": { - "generate": "bun ./build.ts" + "generate": "bun ./build.ts", + "clean": "rm -rf ./dist" } } diff --git a/packages/gitbook/package.json b/packages/gitbook/package.json index a594313d0..74df29241 100644 --- a/packages/gitbook/package.json +++ b/packages/gitbook/package.json @@ -12,7 +12,8 @@ "e2e": "playwright test", "unit": "bun test {src,packages}", "generate": "gitbook-icons ./public/~gitbook/static/icons custom-icons && gitbook-math ./public/~gitbook/static/math", - "copy:icons": "gitbook-icons ./public/~gitbook/static/icons" + "copy:icons": "gitbook-icons ./public/~gitbook/static/icons", + "clean": "rm -rf ./.next && rm -rf ./public/~gitbook/static" }, "dependencies": { "@gitbook/api": "0.60.0", diff --git a/packages/icons/bin/gen-list.js b/packages/icons/bin/gen-list.js index 6850a7670..3ae8a5c24 100644 --- a/packages/icons/bin/gen-list.js +++ b/packages/icons/bin/gen-list.js @@ -60,12 +60,19 @@ async function main() { async function writeDataFile(name, content) { const dirname = path.dirname(url.fileURLToPath(import.meta.url)); + + const srcData = path.resolve(dirname, '../src/data'); + const distData = path.resolve(dirname, '../dist/data'); + + // Ensure the directories exists await Promise.all([ - fs.writeFile(path.resolve(dirname, `../src/data/${name}.json`), content), - // Write to dist folder if it exists - existsSync(path.resolve(dirname, '../dist/')) - ? fs.writeFile(path.resolve(dirname, `../dist/data/${name}.json`), content) - : null, + fs.mkdir(srcData, { recursive: true }), + fs.mkdir(distData, { recursive: true }), + ]); + + await Promise.all([ + fs.writeFile(path.resolve(srcData, `${name}.json`), content), + fs.writeFile(path.resolve(distData, `${name}.json`), content), ]); } diff --git a/packages/icons/package.json b/packages/icons/package.json index d5087b830..207116bd0 100644 --- a/packages/icons/package.json +++ b/packages/icons/package.json @@ -34,7 +34,8 @@ "generate": "node ./bin/gen-list.js", "build": "tsc", "typecheck": "tsc --noEmit", - "dev": "tsc -w" + "dev": "tsc -w", + "clean": "rm -rf ./dist && rm -rf ./src/data" }, "bin": { "gitbook-icons": "./bin/gitbook-icons.js" diff --git a/packages/icons/src/data/.gitkeep b/packages/icons/src/data/.gitkeep deleted file mode 100644 index d7bce35f9..000000000 --- a/packages/icons/src/data/.gitkeep +++ /dev/null @@ -1 +0,0 @@ -Files in this folder are generated in postinstall script. \ No newline at end of file diff --git a/packages/react-contentkit/package.json b/packages/react-contentkit/package.json index b2c914c01..5457a80a9 100644 --- a/packages/react-contentkit/package.json +++ b/packages/react-contentkit/package.json @@ -22,7 +22,8 @@ "scripts": { "build": "tsc", "typecheck": "tsc --noEmit", - "dev": "tsc -w" + "dev": "tsc -w", + "clean": "rm -rf ./dist" }, "files": [ "dist", diff --git a/packages/react-math/package.json b/packages/react-math/package.json index a055cbf45..b93ee3bae 100644 --- a/packages/react-math/package.json +++ b/packages/react-math/package.json @@ -22,7 +22,8 @@ "scripts": { "build": "tsc", "typecheck": "tsc --noEmit", - "dev": "tsc -w" + "dev": "tsc -w", + "clean": "rm -rf ./dist" }, "bin": { "gitbook-math": "./bin/gitbook-math.js" diff --git a/packages/react-openapi/package.json b/packages/react-openapi/package.json index 075178063..fa08009bc 100644 --- a/packages/react-openapi/package.json +++ b/packages/react-openapi/package.json @@ -31,7 +31,8 @@ "build": "tsc", "typecheck": "tsc --noEmit", "unit": "bun test", - "dev": "tsc -w" + "dev": "tsc -w", + "clean": "rm -rf ./dist" }, "files": [ "dist", diff --git a/turbo.json b/turbo.json index 95c44ac57..981e863d9 100644 --- a/turbo.json +++ b/turbo.json @@ -1,5 +1,6 @@ { "$schema": "https://turbo.build/schema.json", + "ui": "tui", "globalEnv": ["NODE_ENV", "CI", "ARGOS_*", "GITHUB_*"], "tasks": { // Prepare the package for all other tasks @@ -40,11 +41,16 @@ // Start the package in development mode "dev": { "persistent": true, - "cache": false + "cache": false, + "dependsOn": ["generate"] }, // Script run when the package is deployed "release": { "dependsOn": ["^release", "build"] + }, + // Clean up the package + "clean": { + "cache": false } } }