@vercel/go 3.1.1 → 3.1.3

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.
Files changed (2) hide show
  1. package/dist/index.js +37 -22
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -17908,8 +17908,9 @@ var import_yauzl_promise = __toESM(require_lib6());
17908
17908
  var import_xdg_app_paths = __toESM(require_xdg_app_paths());
17909
17909
  var streamPipeline = (0, import_util.promisify)(import_stream.pipeline);
17910
17910
  var versionMap = /* @__PURE__ */ new Map([
17911
- ["1.22", "1.22.2"],
17912
- ["1.21", "1.21.8"],
17911
+ ["1.23", "1.23.1"],
17912
+ ["1.22", "1.22.7"],
17913
+ ["1.21", "1.21.13"],
17913
17914
  ["1.20", "1.20.14"],
17914
17915
  ["1.19", "1.19.13"],
17915
17916
  ["1.18", "1.18.10"],
@@ -18046,7 +18047,7 @@ async function createGo({
18046
18047
  }) {
18047
18048
  let goPreferredVersion;
18048
18049
  if (modulePath) {
18049
- goPreferredVersion = await parseGoModVersion(modulePath);
18050
+ goPreferredVersion = await getFullVersionFromGoMod(modulePath);
18050
18051
  }
18051
18052
  const goSelectedVersion = goPreferredVersion || Array.from(versionMap.values())[0];
18052
18053
  const env = (0, import_build_utils.cloneEnv)(process.env, opts.env);
@@ -18171,34 +18172,48 @@ function parseGoVersionString(goVersionOutput) {
18171
18172
  }
18172
18173
  var GoError = class extends Error {
18173
18174
  };
18174
- async function parseGoModVersion(modulePath) {
18175
- let version2;
18175
+ async function getFullVersionFromGoMod(modulePath) {
18176
18176
  const file = (0, import_path.join)(modulePath, "go.mod");
18177
+ let content;
18177
18178
  try {
18178
- const content = await (0, import_fs_extra.readFile)(file, "utf8");
18179
- const matches = /^go (\d+)\.(\d+)\.?$/gm.exec(content) || [];
18180
- const major = parseInt(matches[1], 10);
18181
- const minor = parseInt(matches[2], 10);
18182
- const full = versionMap.get(`${major}.${minor}`);
18183
- if (major === 1 && minor >= GO_MIN_VERSION && full) {
18184
- version2 = full;
18185
- } else if (!isNaN(minor)) {
18186
- const err = new GoError(
18187
- `Unsupported Go version ${major}.${minor} in ${file}`
18188
- );
18189
- err.code = "ERR_UNSUPPORTED_GO_VERSION";
18190
- throw err;
18191
- } else {
18192
- console.log(`Warning: Unknown Go version in ${file}`);
18193
- }
18179
+ content = await (0, import_fs_extra.readFile)(file, "utf8");
18194
18180
  } catch (err) {
18195
18181
  if (err.code === "ENOENT") {
18196
18182
  (0, import_build_utils.debug)(`File not found: ${file}`);
18183
+ return void 0;
18197
18184
  } else {
18198
18185
  throw err;
18199
18186
  }
18200
18187
  }
18201
- return version2;
18188
+ const version2 = parseGoVersion(content);
18189
+ if (!version2) {
18190
+ console.log(`Warning: Unknown Go version in ${file}`);
18191
+ return void 0;
18192
+ }
18193
+ if (version2.major === 1 && version2.minor >= GO_MIN_VERSION) {
18194
+ return version2.patch === null ? versionMap.get(`${version2.major}.${version2.minor}`) : `${version2.major}.${version2.minor}.${version2.patch}`;
18195
+ } else {
18196
+ const versionString = version2.patch ? `${version2.major}.${version2.minor}.${version2.patch}` : `${version2.major}.${version2.minor}`;
18197
+ const err = new GoError(
18198
+ `Unsupported Go version ${versionString} in ${file}`
18199
+ );
18200
+ err.code = "ERR_UNSUPPORTED_GO_VERSION";
18201
+ throw err;
18202
+ }
18203
+ }
18204
+ function parseGoVersion(goModContent) {
18205
+ const goVersionRegex = /^go\s+(\d+)\.(\d+)(?:\.(\d+))?$/m;
18206
+ const match = goModContent.match(goVersionRegex);
18207
+ if (match) {
18208
+ const major = parseInt(match[1], 10);
18209
+ const minor = parseInt(match[2], 10);
18210
+ const patch = match[3] ? parseInt(match[3], 10) : null;
18211
+ if (isNaN(major) || isNaN(minor) || patch !== null && isNaN(patch)) {
18212
+ return null;
18213
+ }
18214
+ return { major, minor, patch };
18215
+ }
18216
+ return null;
18202
18217
  }
18203
18218
 
18204
18219
  // src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/go",
3
- "version": "3.1.1",
3
+ "version": "3.1.3",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/go",
@@ -23,7 +23,7 @@
23
23
  "@types/node-fetch": "^2.3.0",
24
24
  "@types/tar": "6.1.5",
25
25
  "@types/yauzl-promise": "2.1.0",
26
- "@vercel/build-utils": "7.11.0",
26
+ "@vercel/build-utils": "8.4.2",
27
27
  "async-retry": "1.3.3",
28
28
  "execa": "^1.0.0",
29
29
  "fs-extra": "^7.0.0",