Skip to content
Merged
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
15 changes: 15 additions & 0 deletions .changeset/lazy-toes-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"@gitbook/react-contentkit": patch
"@gitbook/openapi-parser": patch
"@gitbook/browser-types": patch
"@gitbook/react-openapi": patch
"@gitbook/cache-tags": patch
"@gitbook/react-math": patch
"@gitbook/colors": patch
"@gitbook/embed": patch
"@gitbook/fonts": patch
"@gitbook/icons": patch
"@gitbook/expr": patch
---

Use NPM Trusted publishing for publishing the package.
5 changes: 5 additions & 0 deletions .changeset/social-friends-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@gitbook/expr": patch
---

Use NPM dependency for eval-estree-expression
10 changes: 6 additions & 4 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ on:
branches:
- main

permissions:
id-token: write
contents: read

env:
BUN_NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
BUN_NPM_TOKEN: ${{ secrets.NPM_TOKEN_READONLY }}

concurrency: ${{ github.workflow }}-${{ github.ref }}

Expand All @@ -30,12 +34,10 @@ jobs:
id: changesets
uses: changesets/action@v1
with:
publish: npm run release
publish: npm run publish-all-packages
version: npm run changeset-version
env:
# Using a PAT instead of GITHUB_TOKEN because we need to run workflows when releases are created
# https://github.com/orgs/community/discussions/26875#discussioncomment-3253761
GITHUB_TOKEN: ${{ secrets.GH_PERSONAL_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}

5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ yarn-error.log*

# TypeScript
*.tsbuildinfo
.npmrc
.npmrc

# Bun pack artifacts
packages/*/*.tgz
4 changes: 2 additions & 2 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"acorn-walk": "^8.3.4",
"assert-never": "catalog:",
"escodegen": "^2.1.0",
"eval-estree-expression": "github:jonschlinkert/eval-estree-expression#9cf28d2",
"eval-estree-expression": "github:jonschlinkert/eval-estree-expression#fb0246a",
},
"devDependencies": {
"@tsconfig/node20": "catalog:",
Expand Down Expand Up @@ -1951,7 +1951,7 @@

"etag": ["etag@1.8.1", "", {}, "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg=="],

"eval-estree-expression": ["eval-estree-expression@github:jonschlinkert/eval-estree-expression#9cf28d2", {}, "jonschlinkert-eval-estree-expression-9cf28d2"],
"eval-estree-expression": ["eval-estree-expression@github:jonschlinkert/eval-estree-expression#fb0246a", {}, "jonschlinkert-eval-estree-expression-fb0246a"],

"event-emitter": ["event-emitter@0.3.5", "", { "dependencies": { "d": "1", "es5-ext": "~0.10.14" } }, "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA=="],

Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"turbo": "^2.5.8",
"vercel": "^39.4.2"
},
"packageManager": "bun@1.3.0",
"packageManager": "bun@1.3.2",
"overrides": {
"@codemirror/state": "6.4.1",
"@types/react": "catalog:",
Expand All @@ -32,8 +32,7 @@
"e2e-customers": "turbo run e2e-customers",
"changeset": "changeset",
"changeset-version": "changeset version && bun run format && bun update",
"release": "turbo run release && bun run publish-all-packages",
"publish-all-packages": "for dir in packages/*; do (cd \"$dir\" && bun publish || true); done && changeset tag",
"publish-all-packages": "turbo run publish-to-npm",
"download:env": "op read op://gitbook-x-dev/gitbook-open/.env.local >> .env.local",
"clean": "turbo run clean"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/browser-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"scripts": {
"build": "tsdown",
"typecheck": "tsc --noEmit",
"dev": "bun run build -- --watch ./src"
"dev": "bun run build -- --watch ./src",
"publish-to-npm": "../../scripts/publish-if-new.sh"
},
"files": ["dist", "README.md", "CHANGELOG.md"],
"publishConfig": {
Expand Down
3 changes: 2 additions & 1 deletion packages/cache-tags/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"scripts": {
"build": "tsdown",
"typecheck": "tsc --noEmit",
"dev": "bun run build -- --watch ./src"
"dev": "bun run build -- --watch ./src",
"publish-to-npm": "../../scripts/publish-if-new.sh"
},
"files": ["dist", "README.md", "CHANGELOG.md"],
"publishConfig": {
Expand Down
3 changes: 2 additions & 1 deletion packages/colors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"scripts": {
"build": "tsdown",
"typecheck": "tsc --noEmit",
"dev": "bun run build -- --watch ./src"
"dev": "bun run build -- --watch ./src",
"publish-to-npm": "../../scripts/publish-if-new.sh"
},
"files": ["dist", "README.md", "CHANGELOG.md"],
"publishConfig": {
Expand Down
3 changes: 2 additions & 1 deletion packages/embed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"build-standalone": "bun build src/standalone/index.ts --bundle --minify --outdir=standalone",
"clean": "rm -rf ./dist",
"typecheck": "tsc --noEmit",
"dev": "bun run build -- --watch ./src"
"dev": "bun run build -- --watch ./src",
"publish-to-npm": "../../scripts/publish-if-new.sh"
},
"files": ["dist", "README.md", "CHANGELOG.md"],
"publishConfig": {
Expand Down
5 changes: 3 additions & 2 deletions packages/expr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"acorn-walk": "^8.3.4",
"assert-never": "catalog:",
"escodegen": "^2.1.0",
"eval-estree-expression": "github:jonschlinkert/eval-estree-expression#9cf28d2"
"eval-estree-expression": "github:jonschlinkert/eval-estree-expression#fb0246a"
},
"devDependencies": {
"@tsconfig/strictest": "catalog:",
Expand All @@ -33,7 +33,8 @@
"typecheck": "tsc --noEmit",
"unit": "bun test",
"clean": "rm -rf ./dist",
"dev": "bun run build -- --watch ./src"
"dev": "bun run build -- --watch ./src",
"publish-to-npm": "../../scripts/publish-if-new.sh"
},
"files": ["dist", "README.md", "CHANGELOG.md"],
"publishConfig": {
Expand Down
3 changes: 2 additions & 1 deletion packages/fonts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"typecheck": "tsc --noEmit",
"dev": "bun run build -- --watch ./src",
"clean": "rm -rf ./dist && rm -rf ./src/data",
"unit": "bun test"
"unit": "bun test",
"publish-to-npm": "../../scripts/publish-if-new.sh"
},
"files": ["dist", "bin", "README.md", "CHANGELOG.md"],
"engines": {
Expand Down
3 changes: 2 additions & 1 deletion packages/icons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"typecheck": "tsc --noEmit",
"dev": "bun run build -- --watch ./src",
"clean": "rm -rf ./dist && rm -rf ./src/data",
"unit": "bun test"
"unit": "bun test",
"publish-to-npm": "../../scripts/publish-if-new.sh"
},
"bin": {
"gitbook-icons": "./bin/gitbook-icons.js"
Expand Down
3 changes: 2 additions & 1 deletion packages/openapi-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"typecheck": "tsc --noEmit",
"unit": "bun test",
"dev": "bun run build -- --watch ./src",
"clean": "rm -rf ./dist"
"clean": "rm -rf ./dist",
"publish-to-npm": "../../scripts/publish-if-new.sh"
},
"files": ["dist", "README.md", "CHANGELOG.md"],
"publishConfig": {
Expand Down
3 changes: 2 additions & 1 deletion packages/react-contentkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"build": "tsdown",
"typecheck": "tsc --noEmit",
"dev": "bun run build -- --watch ./src",
"clean": "rm -rf ./dist"
"clean": "rm -rf ./dist",
"publish-to-npm": "../../scripts/publish-if-new.sh"
},
"files": ["dist", "README.md", "CHANGELOG.md"],
"publishConfig": {
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 @@ -30,7 +30,8 @@
"build": "tsdown",
"typecheck": "tsc --noEmit",
"dev": "bun run build -- --watch ./src",
"clean": "rm -rf ./dist"
"clean": "rm -rf ./dist",
"publish-to-npm": "../../scripts/publish-if-new.sh"
},
"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 @@ -50,7 +50,8 @@
"typecheck": "tsc --noEmit",
"unit": "bun test",
"dev": "bun run build -- --watch ./src",
"clean": "rm -rf ./dist"
"clean": "rm -rf ./dist",
"publish-to-npm": "../../scripts/publish-if-new.sh"
},
"files": ["dist", "README.md", "CHANGELOG.md"],
"publishConfig": {
Expand Down
16 changes: 16 additions & 0 deletions scripts/publish-if-new.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -euo pipefail

NAME=$(node -p "require('./package.json').name")
VERSION=$(node -p "require('./package.json').version")

if npm view "${NAME}@${VERSION}" >/dev/null 2>&1; then
echo "${NAME}@${VERSION} already published, skipping."
exit 0
fi

TARBALL=$(bun pm pack --quiet --dirname ./.publish)

npm publish "${TARBALL}" --no-workspaces

8 changes: 4 additions & 4 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@
"cache": false,
"dependsOn": ["generate", "^build"]
},
// Script run when the package is deployed
"release": {
"dependsOn": ["^release", "build"],
"env": ["CLOUDFLARE_ACCOUNT_ID", "CLOUDFLARE_API_TOKEN"]
// Publish the package to npm
"publish-to-npm": {
"dependsOn": ["build"],
"cache": false
},
// Clean up the package
"clean": {
Expand Down