Skip to content

Commit

Permalink
fix(workflows): error when running garden in a workflow script step
Browse files Browse the repository at this point in the history
This works around vercel/pkg#897 by patching
the `pkg` `prelude/bootstrap.js` script.

Fixes #2032
  • Loading branch information
edvald committed May 28, 2021
1 parent 673099b commit 00c065b
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 5 deletions.
9 changes: 8 additions & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
"minimist": "^1.2.5",
"mocha": "^8.1.1",
"mocha-logger": "^1.0.6",
"patch-package": "^6.4.7",
"pkg": "4.4.9",
"postinstall-postinstall": "^2.1.0",
"prettier": "^2.1.0",
"split2": "^3.2.2",
"tslint": "^6.1.3",
Expand Down Expand Up @@ -67,5 +69,10 @@
"node_modules/@garden-io/**/*.js",
"node_modules/es-get-iterator/**/*.js"
]
},
"workspaces": {
"nohoist": [
"pkg"
]
}
}
}
13 changes: 13 additions & 0 deletions cli/patches/pkg+4.4.9.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/node_modules/pkg/prelude/bootstrap.js b/node_modules/pkg/prelude/bootstrap.js
index 0d19f1d..f7f5415 100644
--- a/node_modules/pkg/prelude/bootstrap.js
+++ b/node_modules/pkg/prelude/bootstrap.js
@@ -1400,7 +1400,7 @@ function payloadFileSync (pointer) {
}
var opts = args[pos];
if (!opts.env) opts.env = require('util')._extend({}, process.env);
- if (opts.env.PKG_EXECPATH === 'PKG_INVOKE_NODEJS') return;
+ if (opts.env.PKG_EXECPATH !== undefined) return;
opts.env.PKG_EXECPATH = EXECPATH;
}

2 changes: 1 addition & 1 deletion cli/src/build-pkg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require("source-map-support").install()
const repoRoot = resolve(GARDEN_CLI_ROOT, "..")
const tmpDir = resolve(repoRoot, "tmp", "pkg")
const tmpStaticDir = resolve(tmpDir, "static")
const pkgPath = resolve(repoRoot, "node_modules", ".bin", "pkg")
const pkgPath = resolve(repoRoot, "cli", "node_modules", ".bin", "pkg")
const pkgFetchPath = resolve(repoRoot, "node_modules", ".bin", "pkg-fetch")
const distPath = resolve(repoRoot, "dist")
const sqliteBinFilename = "better_sqlite3.node"
Expand Down
5 changes: 5 additions & 0 deletions core/src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,11 @@ export async function runScript({
script: string
envVars?: PrimitiveMap
}) {
envVars = envVars || {}

// Workaround for https://github.com/vercel/pkg/issues/897
envVars.PKG_EXECPATH = ""

// Run the script, capturing any errors
const proc = execa("bash", ["-s"], {
all: true,
Expand Down
2 changes: 1 addition & 1 deletion support/alpine-builder.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ ADD static /garden/static

# Create the binary
RUN mkdir -p /garden \
&& ../pkg/node_modules/.bin/pkg --target node12-alpine-x64 . --output /garden/garden \
&& node_modules/.bin/pkg --target node12-alpine-x64 . --output /garden/garden \
&& cp node_modules/better-sqlite3/build/Release/better_sqlite3.node /garden \
&& /garden/garden version
47 changes: 45 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3200,6 +3200,11 @@
"@types/emscripten" "^1.38.0"
tslib "^1.13.0"

"@yarnpkg/lockfile@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31"
integrity sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==

"@yarnpkg/parsers@^2.3.0":
version "2.3.0"
resolved "https://registry.yarnpkg.com/@yarnpkg/parsers/-/parsers-2.3.0.tgz#7b9564c6df02f4921d5cfe8287c4b648e93ea84b"
Expand Down Expand Up @@ -7956,6 +7961,13 @@ find-versions@^4.0.0:
dependencies:
semver-regex "^3.1.2"

find-yarn-workspace-root@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz#f47fb8d239c900eb78179aa81b66673eac88f7bd"
integrity sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ==
dependencies:
micromatch "^4.0.2"

findup-sync@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-2.0.0.tgz#9326b1488c22d1a6088650a86901b2d9a90a2cbc"
Expand Down Expand Up @@ -8216,7 +8228,7 @@ fs-extra@^4.0.2:
jsonfile "^4.0.0"
universalify "^0.1.0"

fs-extra@^7.0.0:
fs-extra@^7.0.0, fs-extra@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9"
integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==
Expand Down Expand Up @@ -11145,6 +11157,13 @@ kind-of@^6.0.0, kind-of@^6.0.2, kind-of@^6.0.3:
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==

klaw-sync@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/klaw-sync/-/klaw-sync-6.0.0.tgz#1fd2cfd56ebb6250181114f0a581167099c2b28c"
integrity sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==
dependencies:
graceful-fs "^4.1.11"

klaw@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/klaw/-/klaw-3.0.0.tgz#b11bec9cf2492f06756d6e809ab73a2910259146"
Expand Down Expand Up @@ -13226,7 +13245,7 @@ only@~0.0.2:
resolved "https://registry.yarnpkg.com/only/-/only-0.0.2.tgz#2afde84d03e50b9a8edc444e30610a70295edfb4"
integrity sha1-Kv3oTQPlC5qO3EROMGEKcCle37Q=

open@^7.0.2, open@^7.0.4:
open@^7.0.2, open@^7.0.4, open@^7.4.2:
version "7.4.2"
resolved "https://registry.yarnpkg.com/open/-/open-7.4.2.tgz#b8147e26dcf3e426316c730089fd71edd29c2321"
integrity sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==
Expand Down Expand Up @@ -13652,6 +13671,25 @@ pascalcase@^0.1.1:
resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14"
integrity sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=

patch-package@^6.4.7:
version "6.4.7"
resolved "https://registry.yarnpkg.com/patch-package/-/patch-package-6.4.7.tgz#2282d53c397909a0d9ef92dae3fdeb558382b148"
integrity sha512-S0vh/ZEafZ17hbhgqdnpunKDfzHQibQizx9g8yEf5dcVk3KOflOfdufRXQX8CSEkyOQwuM/bNz1GwKvFj54kaQ==
dependencies:
"@yarnpkg/lockfile" "^1.1.0"
chalk "^2.4.2"
cross-spawn "^6.0.5"
find-yarn-workspace-root "^2.0.0"
fs-extra "^7.0.1"
is-ci "^2.0.0"
klaw-sync "^6.0.0"
minimist "^1.2.0"
open "^7.4.2"
rimraf "^2.6.3"
semver "^5.6.0"
slash "^2.0.0"
tmp "^0.0.33"

path-browserify@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.1.tgz#e6c4ddd7ed3aa27c68a20cc4e50e1a4ee83bbc4a"
Expand Down Expand Up @@ -14646,6 +14684,11 @@ postcss@^7, postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.17, po
source-map "^0.6.1"
supports-color "^6.1.0"

postinstall-postinstall@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/postinstall-postinstall/-/postinstall-postinstall-2.1.0.tgz#4f7f77441ef539d1512c40bd04c71b06a4704ca3"
integrity sha512-7hQX6ZlZXIoRiWNrbMQaLzUUfH+sSx39u8EJ9HYuDc1kLo9IXKWjM5RSquZN1ad5GnH8CGFM78fsAAQi3OKEEQ==

prebuild-install@^5.3.3:
version "5.3.6"
resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-5.3.6.tgz#7c225568d864c71d89d07f8796042733a3f54291"
Expand Down

0 comments on commit 00c065b

Please sign in to comment.