@vercel/go 5.0.0 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
Binary file
package/dist/index.js CHANGED
@@ -14579,6 +14579,7 @@ var localCacheDir = (0, import_path4.join)(".vercel", "cache", "golang");
14579
14579
  var GO_FLAGS = process.platform === "win32" ? [] : ["-ldflags", "-s -w"];
14580
14580
  var GO_MIN_MAJOR_VERSION = 1;
14581
14581
  var GO_MIN_MINOR_VERSION = 13;
14582
+ var GO_INSTALL_MARKER = ".vercel-go-install-complete";
14582
14583
  function getGoUrl(version2) {
14583
14584
  const { arch, platform } = process;
14584
14585
  const ext = platform === "win32" ? "zip" : "tar.gz";
@@ -14885,9 +14886,17 @@ async function createGo({
14885
14886
  for (const [label, goDir] of Object.entries(goDirs)) {
14886
14887
  try {
14887
14888
  const goBinDir = goDir && (0, import_path4.join)(goDir, "bin");
14888
- if (goBinDir && !await (0, import_fs_extra.pathExists)(goBinDir)) {
14889
- (0, import_build_utils.debug)(`Go not found in ${label}`);
14890
- continue;
14889
+ if (goBinDir) {
14890
+ if (!await (0, import_fs_extra.pathExists)(goBinDir)) {
14891
+ (0, import_build_utils.debug)(`Go not found in ${label}`);
14892
+ continue;
14893
+ }
14894
+ if (!await (0, import_fs_extra.pathExists)((0, import_path4.join)(goDir, GO_INSTALL_MARKER))) {
14895
+ (0, import_build_utils.debug)(
14896
+ `Go install in ${label} is incomplete, ignoring this installation`
14897
+ );
14898
+ continue;
14899
+ }
14891
14900
  }
14892
14901
  env.GOROOT = goDir || void 0;
14893
14902
  env.PATH = goBinDir || PATH;
@@ -14924,40 +14933,56 @@ async function download({ dest, version: version2 }) {
14924
14933
  if (!res.ok) {
14925
14934
  throw new Error(`Failed to download: ${url} (${res.status})`);
14926
14935
  }
14927
- (0, import_build_utils.debug)(`Installing go ${version2} to ${dest}`);
14928
- await (0, import_fs_extra.remove)(dest);
14929
- await (0, import_fs_extra.mkdirp)(dest);
14930
- if (/\.zip$/.test(filename)) {
14931
- const zipFile = (0, import_path4.join)((0, import_os.tmpdir)(), filename);
14932
- try {
14933
- await streamPipeline(res.body, (0, import_fs_extra.createWriteStream)(zipFile));
14934
- const zip = await import_yauzl_promise.default.open(zipFile);
14935
- let entry = await zip.readEntry();
14936
- while (entry) {
14937
- const fileName = entry.fileName.split("/").slice(1).join("/");
14938
- if (fileName) {
14939
- const destPath = (0, import_path4.join)(dest, fileName);
14940
- if (/\/$/.test(fileName)) {
14941
- await (0, import_fs_extra.mkdirp)(destPath);
14942
- } else {
14943
- const [entryStream] = await Promise.all([
14944
- entry.openReadStream(),
14945
- (0, import_fs_extra.mkdirp)((0, import_path4.dirname)(destPath))
14946
- ]);
14947
- const out = (0, import_fs_extra.createWriteStream)(destPath);
14948
- await streamPipeline(entryStream, out);
14936
+ const tmpSuffix = `${process.pid}-${Math.random().toString(36).slice(2)}`;
14937
+ const tmpDest = `${dest}.tmp-${tmpSuffix}`;
14938
+ (0, import_build_utils.debug)(`Installing go ${version2} to ${dest} (via ${tmpDest})`);
14939
+ await (0, import_fs_extra.mkdirp)(tmpDest);
14940
+ try {
14941
+ if (/\.zip$/.test(filename)) {
14942
+ const zipFile = (0, import_path4.join)((0, import_os.tmpdir)(), `${tmpSuffix}-${filename}`);
14943
+ try {
14944
+ await streamPipeline(res.body, (0, import_fs_extra.createWriteStream)(zipFile));
14945
+ const zip = await import_yauzl_promise.default.open(zipFile);
14946
+ let entry = await zip.readEntry();
14947
+ while (entry) {
14948
+ const fileName = entry.fileName.split("/").slice(1).join("/");
14949
+ if (fileName) {
14950
+ const destPath = (0, import_path4.join)(tmpDest, fileName);
14951
+ if (/\/$/.test(fileName)) {
14952
+ await (0, import_fs_extra.mkdirp)(destPath);
14953
+ } else {
14954
+ const [entryStream] = await Promise.all([
14955
+ entry.openReadStream(),
14956
+ (0, import_fs_extra.mkdirp)((0, import_path4.dirname)(destPath))
14957
+ ]);
14958
+ const out = (0, import_fs_extra.createWriteStream)(destPath);
14959
+ await streamPipeline(entryStream, out);
14960
+ }
14949
14961
  }
14962
+ entry = await zip.readEntry();
14950
14963
  }
14951
- entry = await zip.readEntry();
14964
+ } finally {
14965
+ await (0, import_fs_extra.remove)(zipFile);
14952
14966
  }
14953
- } finally {
14954
- await (0, import_fs_extra.remove)(zipFile);
14967
+ } else {
14968
+ await new Promise((resolve, reject) => {
14969
+ res.body.on("error", reject).pipe(lo({ cwd: tmpDest, strip: 1 })).on("error", reject).on("finish", resolve);
14970
+ });
14955
14971
  }
14956
- return;
14972
+ await import_fs5.default.promises.writeFile((0, import_path4.join)(tmpDest, GO_INSTALL_MARKER), version2);
14973
+ if (!await (0, import_fs_extra.pathExists)((0, import_path4.join)(dest, GO_INSTALL_MARKER))) {
14974
+ await (0, import_fs_extra.remove)(dest);
14975
+ }
14976
+ try {
14977
+ await import_fs5.default.promises.rename(tmpDest, dest);
14978
+ } catch (err) {
14979
+ if (!await (0, import_fs_extra.pathExists)((0, import_path4.join)(dest, GO_INSTALL_MARKER))) {
14980
+ throw err;
14981
+ }
14982
+ }
14983
+ } finally {
14984
+ await (0, import_fs_extra.remove)(tmpDest);
14957
14985
  }
14958
- await new Promise((resolve, reject) => {
14959
- res.body.on("error", reject).pipe(lo({ cwd: dest, strip: 1 })).on("error", reject).on("finish", resolve);
14960
- });
14961
14986
  }
14962
14987
  var goVersionRegExp = /(\d+)\.(\d+)(?:\.(\d+))?/;
14963
14988
  function parseGoVersionString(goVersionOutput) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/go",
3
- "version": "5.0.0",
3
+ "version": "6.0.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/go",
@@ -16,7 +16,7 @@
16
16
  ],
17
17
  "dependencies": {},
18
18
  "peerDependencies": {
19
- "@vercel/build-utils": "14.4.0"
19
+ "@vercel/build-utils": "14.5.1"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@tootallnate/once": "1.1.2",
@@ -35,7 +35,7 @@
35
35
  "vitest": "4.1.10",
36
36
  "xdg-app-paths": "5.1.0",
37
37
  "yauzl-promise": "2.1.3",
38
- "@vercel/build-utils": "14.4.0",
38
+ "@vercel/build-utils": "14.5.1",
39
39
  "@vercel-internals/ipc-proxy": "1.0.0"
40
40
  },
41
41
  "scripts": {