Skip to content

Commit b3c8850

Browse files
committed
Escape env pulled from vercel
1 parent c0dec2b commit b3c8850

File tree

4 files changed

+137
-2
lines changed

4 files changed

+137
-2
lines changed

.github/workflows/validate-workflow.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ jobs:
9090
run: |
9191
npm install --global vercel@latest
9292
vercel link --token $VERCEL_TOKEN --scope openint-dev --yes
93-
vercel env pull --token $VERCEL_TOKEN ./apps/web/.env.local
93+
vercel env pull --token $VERCEL_TOKEN ./apps/web/.env.local.orig
94+
cat .env.local.orig | pnpm bun scripts/escape-env.ts > .env.local
9495
9596
- name: Ensure OpenAPI spec and docs are up to date
9697
run: pnpm --dir ./kits/sdk run gen && pnpm --dir ./docs generate && git diff --exit-code

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
"pgdump": "pg_dump --schema public --schema-only --no-owner --exclude-schema=graphile_migrate --file=packages/db/schema.sql $DATABASE_URL",
2626
"worker:setup": "tsx ./bin/openint setupWorker",
2727
"worker:run": "tsx ./bin/openint runWorker",
28-
"env:pull": "vercel env pull --environment development .env.dev && vercel env pull --environment preview --git-branch $(git rev-parse --abbrev-ref HEAD) .env.pre && vercel env pull --environment production .env.prod"
28+
"env:pull:development": "vercel env pull --environment development .env.dev.orig && cat .env.dev.orig | pnpm bun scripts/escape-env.ts > .env.dev",
29+
"env:pull:preview": "vercel env pull --environment preview --git-branch $(git rev-parse --abbrev-ref HEAD) .env.pre.orig && cat .env.pre.orig | pnpm bun scripts/escape-env.ts > .env.pre",
30+
"env:pull:production": "vercel env pull --environment production .env.prod.orig && cat .env.prod.orig | pnpm bun scripts/escape-env.ts > .env.prod",
31+
"env:pull": "run-s env:pull:*"
2932
},
3033
"lint-staged": {
3134
"**/*.{js,ts,tsx,json,css,yml,yaml}": "prettier --write",
@@ -46,6 +49,7 @@
4649
"@types/prettier": "3.0.0",
4750
"@typescript-eslint/eslint-plugin": "6.21.0",
4851
"@typescript-eslint/parser": "6.21.0",
52+
"bun": "latest",
4953
"esbuild": "0.17.5",
5054
"esbuild-jest": "0.5.0",
5155
"eslint": "8.23.0",

pnpm-lock.yaml

Lines changed: 111 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/escape-env.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Workaround for vercel env pull cannot properly handle value that contains " #11258
2+
// https://github.com/vercel/vercel/issues/11258
3+
import * as readline from 'node:readline'
4+
5+
const rl = readline.createInterface({
6+
input: process.stdin,
7+
output: process.stdout,
8+
terminal: false,
9+
})
10+
11+
rl.on('line', (line) => {
12+
// Replace double quotes with single quotes, but only when they're part of the value
13+
const processed = line.replace(/^(.*)="(.*)"$/g, "$1='$2'")
14+
console.log(processed)
15+
})
16+
17+
rl.on('close', () => {
18+
process.exit(0)
19+
})

0 commit comments

Comments
 (0)