Skip to content

Commit

Permalink
Fix generation of icons package and add task "clean" (#2470)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamyPesse committed Sep 17, 2024
1 parent f12a215 commit ef9d012
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/forty-trains-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@gitbook/icons': patch
---

Fix first run of the package in development mode
Binary file modified bun.lockb
Binary file not shown.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@
"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/*"
],
"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"
Expand Down
3 changes: 2 additions & 1 deletion packages/emoji-codepoints/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"emoji-assets": "^8.0.0"
},
"scripts": {
"generate": "bun ./build.ts"
"generate": "bun ./build.ts",
"clean": "rm -rf ./dist"
}
}
3 changes: 2 additions & 1 deletion packages/gitbook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
17 changes: 12 additions & 5 deletions packages/icons/bin/gen-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.mkdir(srcData, { recursive: true }),
fs.mkdir(distData, { recursive: true }),
]);

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.writeFile(path.resolve(srcData, `${name}.json`), content),
fs.writeFile(path.resolve(distData, `${name}.json`), content),
]);
}

Expand Down
3 changes: 2 additions & 1 deletion packages/icons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion packages/icons/src/data/.gitkeep

This file was deleted.

3 changes: 2 additions & 1 deletion packages/react-contentkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"scripts": {
"build": "tsc",
"typecheck": "tsc --noEmit",
"dev": "tsc -w"
"dev": "tsc -w",
"clean": "rm -rf ./dist"
},
"files": [
"dist",
Expand Down
3 changes: 2 additions & 1 deletion packages/react-math/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion packages/react-openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"build": "tsc",
"typecheck": "tsc --noEmit",
"unit": "bun test",
"dev": "tsc -w"
"dev": "tsc -w",
"clean": "rm -rf ./dist"
},
"files": [
"dist",
Expand Down
8 changes: 7 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
}
}
}

0 comments on commit ef9d012

Please sign in to comment.