@vercel/go 3.1.2 → 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 +36 -22
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -17908,8 +17908,8 @@ 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.23", "1.23.0"],
17912
- ["1.22", "1.22.6"],
17911
+ ["1.23", "1.23.1"],
17912
+ ["1.22", "1.22.7"],
17913
17913
  ["1.21", "1.21.13"],
17914
17914
  ["1.20", "1.20.14"],
17915
17915
  ["1.19", "1.19.13"],
@@ -18047,7 +18047,7 @@ async function createGo({
18047
18047
  }) {
18048
18048
  let goPreferredVersion;
18049
18049
  if (modulePath) {
18050
- goPreferredVersion = await parseGoModVersion(modulePath);
18050
+ goPreferredVersion = await getFullVersionFromGoMod(modulePath);
18051
18051
  }
18052
18052
  const goSelectedVersion = goPreferredVersion || Array.from(versionMap.values())[0];
18053
18053
  const env = (0, import_build_utils.cloneEnv)(process.env, opts.env);
@@ -18172,34 +18172,48 @@ function parseGoVersionString(goVersionOutput) {
18172
18172
  }
18173
18173
  var GoError = class extends Error {
18174
18174
  };
18175
- async function parseGoModVersion(modulePath) {
18176
- let version2;
18175
+ async function getFullVersionFromGoMod(modulePath) {
18177
18176
  const file = (0, import_path.join)(modulePath, "go.mod");
18177
+ let content;
18178
18178
  try {
18179
- const content = await (0, import_fs_extra.readFile)(file, "utf8");
18180
- const matches = /^go (\d+)\.(\d+)\.?$/gm.exec(content) || [];
18181
- const major = parseInt(matches[1], 10);
18182
- const minor = parseInt(matches[2], 10);
18183
- const full = versionMap.get(`${major}.${minor}`);
18184
- if (major === 1 && minor >= GO_MIN_VERSION && full) {
18185
- version2 = full;
18186
- } else if (!isNaN(minor)) {
18187
- const err = new GoError(
18188
- `Unsupported Go version ${major}.${minor} in ${file}`
18189
- );
18190
- err.code = "ERR_UNSUPPORTED_GO_VERSION";
18191
- throw err;
18192
- } else {
18193
- console.log(`Warning: Unknown Go version in ${file}`);
18194
- }
18179
+ content = await (0, import_fs_extra.readFile)(file, "utf8");
18195
18180
  } catch (err) {
18196
18181
  if (err.code === "ENOENT") {
18197
18182
  (0, import_build_utils.debug)(`File not found: ${file}`);
18183
+ return void 0;
18198
18184
  } else {
18199
18185
  throw err;
18200
18186
  }
18201
18187
  }
18202
- 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;
18203
18217
  }
18204
18218
 
18205
18219
  // src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/go",
3
- "version": "3.1.2",
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": "8.3.9",
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",