@vercel/go 3.1.3 → 3.2.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.
- package/dist/index.js +68 -39
- 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.
|
|
17912
|
-
["1.22", "1.22.
|
|
17911
|
+
["1.23", "1.23.2"],
|
|
17912
|
+
["1.22", "1.22.8"],
|
|
17913
17913
|
["1.21", "1.21.13"],
|
|
17914
17914
|
["1.20", "1.20.14"],
|
|
17915
17915
|
["1.19", "1.19.13"],
|
|
@@ -17927,13 +17927,14 @@ var archMap = /* @__PURE__ */ new Map([
|
|
|
17927
17927
|
var platformMap = /* @__PURE__ */ new Map([["win32", "windows"]]);
|
|
17928
17928
|
var localCacheDir = (0, import_path.join)(".vercel", "cache", "golang");
|
|
17929
17929
|
var GO_FLAGS = process.platform === "win32" ? [] : ["-ldflags", "-s -w"];
|
|
17930
|
-
var
|
|
17930
|
+
var GO_MIN_MAJOR_VERSION = 1;
|
|
17931
|
+
var GO_MIN_MINOR_VERSION = 13;
|
|
17931
17932
|
function getGoUrl(version2) {
|
|
17932
17933
|
const { arch, platform } = process;
|
|
17933
17934
|
const ext = platform === "win32" ? "zip" : "tar.gz";
|
|
17934
17935
|
const goPlatform = platformMap.get(platform) || platform;
|
|
17935
17936
|
let goArch = archMap.get(arch) || arch;
|
|
17936
|
-
if (platform === "darwin" && goArch === "arm64" && parseInt(
|
|
17937
|
+
if (platform === "darwin" && goArch === "arm64" && parseInt(/^\d+.(\d+)/.exec(version2)[1], 10) < 16) {
|
|
17937
17938
|
goArch = "amd64";
|
|
17938
17939
|
}
|
|
17939
17940
|
const filename = `go${version2}.${goPlatform}-${goArch}.${ext}`;
|
|
@@ -18047,9 +18048,9 @@ async function createGo({
|
|
|
18047
18048
|
}) {
|
|
18048
18049
|
let goPreferredVersion;
|
|
18049
18050
|
if (modulePath) {
|
|
18050
|
-
goPreferredVersion = await
|
|
18051
|
+
goPreferredVersion = await parseGoModVersionFromModule(modulePath);
|
|
18051
18052
|
}
|
|
18052
|
-
const goSelectedVersion = goPreferredVersion || Array.from(versionMap.values())[0];
|
|
18053
|
+
const goSelectedVersion = goPreferredVersion ? goPreferredVersion.toolchain || goPreferredVersion.go : Array.from(versionMap.values())[0];
|
|
18053
18054
|
const env = (0, import_build_utils.cloneEnv)(process.env, opts.env);
|
|
18054
18055
|
const { PATH } = env;
|
|
18055
18056
|
const { platform } = process;
|
|
@@ -18059,7 +18060,7 @@ async function createGo({
|
|
|
18059
18060
|
);
|
|
18060
18061
|
const goCacheDir = (0, import_path.join)(workPath, localCacheDir);
|
|
18061
18062
|
if (goPreferredVersion) {
|
|
18062
|
-
(0, import_build_utils.debug)(`Preferred go version ${
|
|
18063
|
+
(0, import_build_utils.debug)(`Preferred go version ${goSelectedVersion} (from go.mod)`);
|
|
18063
18064
|
env.GO111MODULE = "on";
|
|
18064
18065
|
} else {
|
|
18065
18066
|
(0, import_build_utils.debug)(
|
|
@@ -18092,8 +18093,8 @@ async function createGo({
|
|
|
18092
18093
|
env.GOROOT = goDir || void 0;
|
|
18093
18094
|
env.PATH = goBinDir || PATH;
|
|
18094
18095
|
const { stdout } = await (0, import_execa.default)("go", ["version"], { env });
|
|
18095
|
-
const { minor, short, version: version2 } = parseGoVersionString(stdout);
|
|
18096
|
-
if (minor <
|
|
18096
|
+
const { major, minor, short, version: version2 } = parseGoVersionString(stdout);
|
|
18097
|
+
if (major < GO_MIN_MAJOR_VERSION || major === GO_MIN_MAJOR_VERSION && minor < GO_MIN_MINOR_VERSION) {
|
|
18097
18098
|
(0, import_build_utils.debug)(`Found go ${version2} in ${label}, but version is unsupported`);
|
|
18098
18099
|
}
|
|
18099
18100
|
if (version2 === goSelectedVersion || short === goSelectedVersion) {
|
|
@@ -18172,48 +18173,57 @@ function parseGoVersionString(goVersionOutput) {
|
|
|
18172
18173
|
}
|
|
18173
18174
|
var GoError = class extends Error {
|
|
18174
18175
|
};
|
|
18175
|
-
async function
|
|
18176
|
+
async function parseGoModVersionFromModule(modulePath) {
|
|
18177
|
+
let version2;
|
|
18176
18178
|
const file = (0, import_path.join)(modulePath, "go.mod");
|
|
18177
|
-
let content;
|
|
18178
18179
|
try {
|
|
18179
|
-
content = await (0, import_fs_extra.readFile)(file, "utf8");
|
|
18180
|
+
const content = await (0, import_fs_extra.readFile)(file, "utf8");
|
|
18181
|
+
version2 = parseGoModVersion(content);
|
|
18182
|
+
if (!version2) {
|
|
18183
|
+
console.log(`Warning: Unknown Go version in ${file}`);
|
|
18184
|
+
}
|
|
18180
18185
|
} catch (err) {
|
|
18181
|
-
if (err.code === "ENOENT") {
|
|
18186
|
+
if (typeof err === "object" && err.code === "ENOENT") {
|
|
18182
18187
|
(0, import_build_utils.debug)(`File not found: ${file}`);
|
|
18183
18188
|
return void 0;
|
|
18184
18189
|
} else {
|
|
18185
18190
|
throw err;
|
|
18186
18191
|
}
|
|
18187
18192
|
}
|
|
18188
|
-
|
|
18189
|
-
|
|
18190
|
-
|
|
18193
|
+
return version2;
|
|
18194
|
+
}
|
|
18195
|
+
function parseGoModVersion(content) {
|
|
18196
|
+
const goMatches = /^\s*go\s+(\d+)\.(\d+)(?:\.(\d+))?\s*(?:\/\/.*)?$/gm.exec(
|
|
18197
|
+
content
|
|
18198
|
+
);
|
|
18199
|
+
if (!goMatches) {
|
|
18191
18200
|
return void 0;
|
|
18192
18201
|
}
|
|
18193
|
-
|
|
18194
|
-
|
|
18195
|
-
|
|
18196
|
-
|
|
18197
|
-
|
|
18198
|
-
|
|
18199
|
-
|
|
18200
|
-
|
|
18201
|
-
|
|
18202
|
-
|
|
18203
|
-
}
|
|
18204
|
-
|
|
18205
|
-
|
|
18206
|
-
|
|
18207
|
-
|
|
18208
|
-
|
|
18209
|
-
|
|
18210
|
-
|
|
18211
|
-
|
|
18212
|
-
|
|
18202
|
+
const major = parseInt(goMatches[1], 10);
|
|
18203
|
+
const minor = parseInt(goMatches[2], 10);
|
|
18204
|
+
const patch = goMatches[3] && parseInt(goMatches[3], 10);
|
|
18205
|
+
const toolchainMatches = /^\s*toolchain\s+go((\d+)\.(\d+)(?:\.(\d+)|\w+\d+)?)\s*(?:\/\/.*)?$/gm.exec(
|
|
18206
|
+
content
|
|
18207
|
+
);
|
|
18208
|
+
const toolchain = toolchainMatches ? toolchainMatches[1] : void 0;
|
|
18209
|
+
if (major >= GO_MIN_MAJOR_VERSION && minor >= GO_MIN_MINOR_VERSION) {
|
|
18210
|
+
if (patch) {
|
|
18211
|
+
return {
|
|
18212
|
+
go: `${major}.${minor}.${patch}`,
|
|
18213
|
+
toolchain
|
|
18214
|
+
};
|
|
18215
|
+
}
|
|
18216
|
+
const full = versionMap.get(`${major}.${minor}`);
|
|
18217
|
+
if (full) {
|
|
18218
|
+
return {
|
|
18219
|
+
go: full,
|
|
18220
|
+
toolchain
|
|
18221
|
+
};
|
|
18213
18222
|
}
|
|
18214
|
-
return { major, minor, patch };
|
|
18215
18223
|
}
|
|
18216
|
-
|
|
18224
|
+
const err = new GoError(`Unsupported Go version ${major}.${minor}`);
|
|
18225
|
+
err.code = "ERR_UNSUPPORTED_GO_VERSION";
|
|
18226
|
+
throw err;
|
|
18217
18227
|
}
|
|
18218
18228
|
|
|
18219
18229
|
// src/index.ts
|
|
@@ -18686,8 +18696,13 @@ async function findGoWorkFile(goWorkDir, workPath) {
|
|
|
18686
18696
|
async function writeGoWork(destDir, workPath, modulePath) {
|
|
18687
18697
|
const workspaces = /* @__PURE__ */ new Set(["."]);
|
|
18688
18698
|
const goWorkPath = await findGoWorkFile(modulePath || workPath, workPath);
|
|
18699
|
+
let goVersion;
|
|
18689
18700
|
if (goWorkPath) {
|
|
18690
18701
|
const contents2 = await (0, import_fs_extra2.readFile)(goWorkPath, "utf-8");
|
|
18702
|
+
const goVersionMatch = contents2.match(/^go\s+(\d+\.\d+(\.\d+)?)/m);
|
|
18703
|
+
if (goVersionMatch) {
|
|
18704
|
+
goVersion = goVersionMatch[1];
|
|
18705
|
+
}
|
|
18691
18706
|
const addPath = (path) => {
|
|
18692
18707
|
if (path) {
|
|
18693
18708
|
if (path.startsWith(".")) {
|
|
@@ -18715,8 +18730,22 @@ async function writeGoWork(destDir, workPath, modulePath) {
|
|
|
18715
18730
|
}
|
|
18716
18731
|
} else if (modulePath) {
|
|
18717
18732
|
workspaces.add((0, import_path2.relative)(destDir, modulePath));
|
|
18733
|
+
const goModPath = (0, import_path2.join)(modulePath, "go.mod");
|
|
18734
|
+
if (await (0, import_fs_extra2.pathExists)(goModPath)) {
|
|
18735
|
+
const goModContents = await (0, import_fs_extra2.readFile)(goModPath, "utf-8");
|
|
18736
|
+
const goVersionMatch = goModContents.match(/^go\s+(\d+\.\d+(\.\d+)?)/m);
|
|
18737
|
+
if (goVersionMatch) {
|
|
18738
|
+
goVersion = goVersionMatch[1];
|
|
18739
|
+
}
|
|
18740
|
+
}
|
|
18741
|
+
}
|
|
18742
|
+
let contents = "";
|
|
18743
|
+
if (goVersion) {
|
|
18744
|
+
contents += `go ${goVersion}
|
|
18745
|
+
|
|
18746
|
+
`;
|
|
18718
18747
|
}
|
|
18719
|
-
|
|
18748
|
+
contents += `use (
|
|
18720
18749
|
${Array.from(workspaces).map((w) => ` ${w}
|
|
18721
18750
|
`).join("")})
|
|
18722
18751
|
`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/go",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.2.1",
|
|
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.4.
|
|
26
|
+
"@vercel/build-utils": "8.4.12",
|
|
27
27
|
"async-retry": "1.3.3",
|
|
28
28
|
"execa": "^1.0.0",
|
|
29
29
|
"fs-extra": "^7.0.0",
|