From ef9d012be97c8fdba7d8d0e48cde6ff0354d1c9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Tue, 17 Sep 2024 13:41:18 +0200 Subject: [PATCH] Fix generation of icons package and add task "clean" (#2470) --- .changeset/forty-trains-pull.md | 5 +++++ bun.lockb | Bin 673984 -> 673984 bytes package.json | 5 +++-- packages/emoji-codepoints/package.json | 3 ++- packages/gitbook/package.json | 3 ++- packages/icons/bin/gen-list.js | 17 ++++++++++++----- packages/icons/package.json | 3 ++- packages/icons/src/data/.gitkeep | 1 - packages/react-contentkit/package.json | 3 ++- packages/react-math/package.json | 3 ++- packages/react-openapi/package.json | 3 ++- turbo.json | 8 +++++++- 12 files changed, 39 insertions(+), 15 deletions(-) create mode 100644 .changeset/forty-trains-pull.md delete mode 100644 packages/icons/src/data/.gitkeep 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 62159121efedc9f9a0e0e07641b1f9fce89b5250..44eff239912c64e40187c641f7197d723fea1408 100755 GIT binary patch delta 913 zcmX>wQS-n=%?Wx6mS*Nb_Y7)+JD&X9p<`^CA$dTM;kj|AM2D-wtO+%3vp4#+rB9xc zV=|c|g9l7|K!&2+8gTu9 z`rr0j6EEq1+qAsA=1Q%i>Gh53P1~=<1irW{c{ilKDp2>>Mtf1YIl^-f-?K3YzIE5i zcA@wB>AKlW67^?qUhmtH^0s*w$Nve>ncr1-pX1p0V~W`>?ylE|)Rq*c^EV!0%Z)Nt zi?Z0c#44N1MrP{-q0bw3pA(#za#x4lUY?PGfsug)2pJfdffxo@THmU5CTHEu@jQ3% z&n=T}>CNKHDvjq~Y5%zHZ^ze1YF^u(vbZQ^&yn1C*uv%8nz(!eMyc9sb2e?5to3r) z8vZ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&D+K@i5V)7S@O%dcuh!*u z+gv6fW(HywAZFceo6B}1QpP~fl7T@7Xe%EBL&HseoAZYru%2aMG|~e~OgB8vCTD7Kt_NzCgJ`Y+DiH=M>8@g# zamCG87N&Xnf$MBC?H7)-ZNG4w{cbWd$j%Mg9P1bjrU#zoRGi+R!=Z)5W}ALVheHWP oKt`8C0ZD*&dbTcyIFbO{^i{eXG9ZK7PwH|2G3WM^x?JC-07$u9F#rGn 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 } } }