Fix generation of icons package and add task "clean" (#2470)

This commit is contained in:
Samy Pessé
2024-09-17 13:41:18 +02:00
committed by GitHub
parent f12a2155c0
commit ef9d012be9
12 changed files with 39 additions and 15 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@gitbook/icons': patch
---
Fix first run of the package in development mode
BIN
View File
Binary file not shown.
+3 -2
View File
@@ -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"
+2 -1
View File
@@ -9,6 +9,7 @@
"emoji-assets": "^8.0.0"
},
"scripts": {
"generate": "bun ./build.ts"
"generate": "bun ./build.ts",
"clean": "rm -rf ./dist"
}
}
+2 -1
View File
@@ -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",
+12 -5
View File
@@ -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),
]);
}
+2 -1
View File
@@ -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"
-1
View File
@@ -1 +0,0 @@
Files in this folder are generated in postinstall script.
+2 -1
View File
@@ -22,7 +22,8 @@
"scripts": {
"build": "tsc",
"typecheck": "tsc --noEmit",
"dev": "tsc -w"
"dev": "tsc -w",
"clean": "rm -rf ./dist"
},
"files": [
"dist",
+2 -1
View File
@@ -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"
+2 -1
View File
@@ -31,7 +31,8 @@
"build": "tsc",
"typecheck": "tsc --noEmit",
"unit": "bun test",
"dev": "tsc -w"
"dev": "tsc -w",
"clean": "rm -rf ./dist"
},
"files": [
"dist",
+7 -1
View File
@@ -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
}
}
}