@vercel/go 3.3.0 → 3.3.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 +44 -42
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -17027,7 +17027,7 @@ __export(src_exports, {
|
|
|
17027
17027
|
build: () => build,
|
|
17028
17028
|
getNewHandlerFunctionName: () => getNewHandlerFunctionName,
|
|
17029
17029
|
prepareCache: () => prepareCache,
|
|
17030
|
-
shouldServe: () =>
|
|
17030
|
+
shouldServe: () => import_build_utils2.shouldServe,
|
|
17031
17031
|
startDevServer: () => startDevServer,
|
|
17032
17032
|
version: () => version
|
|
17033
17033
|
});
|
|
@@ -17039,9 +17039,10 @@ var import_child_process = require("child_process");
|
|
|
17039
17039
|
var import_once = __toESM(require_dist());
|
|
17040
17040
|
var import_path2 = require("path");
|
|
17041
17041
|
var import_fs_extra2 = __toESM(require_lib2());
|
|
17042
|
-
var
|
|
17042
|
+
var import_build_utils2 = require("@vercel/build-utils");
|
|
17043
17043
|
|
|
17044
17044
|
// src/go-helpers.ts
|
|
17045
|
+
var import_crypto = require("crypto");
|
|
17045
17046
|
var import_tar = __toESM(require_tar());
|
|
17046
17047
|
var import_execa = __toESM(require_execa());
|
|
17047
17048
|
var import_node_fetch = __toESM(require_lib4());
|
|
@@ -17054,7 +17055,6 @@ var import_util = require("util");
|
|
|
17054
17055
|
var import_os = require("os");
|
|
17055
17056
|
var import_yauzl_promise = __toESM(require_lib6());
|
|
17056
17057
|
var import_xdg_app_paths = __toESM(require_xdg_app_paths());
|
|
17057
|
-
var import_build_utils2 = require("@vercel/build-utils");
|
|
17058
17058
|
var streamPipeline = (0, import_util.promisify)(import_stream.pipeline);
|
|
17059
17059
|
var versionMap = /* @__PURE__ */ new Map([
|
|
17060
17060
|
["1.24", "1.24.5"],
|
|
@@ -17240,15 +17240,17 @@ async function createGo({
|
|
|
17240
17240
|
setEnvPaths(modCache, buildCache);
|
|
17241
17241
|
goDir = goCacheDir;
|
|
17242
17242
|
} else if (isUnix && goDir === goCacheDir) {
|
|
17243
|
-
const
|
|
17244
|
-
const
|
|
17245
|
-
const
|
|
17246
|
-
|
|
17247
|
-
|
|
17248
|
-
|
|
17249
|
-
|
|
17250
|
-
|
|
17251
|
-
|
|
17243
|
+
const hash = (0, import_crypto.createHash)("md5").update(workPath).digest("hex").slice(0, 8);
|
|
17244
|
+
const tmpBase = (0, import_path.join)((0, import_os.tmpdir)(), `vercel-go-cache-${hash}`);
|
|
17245
|
+
const tmpModCache = (0, import_path.join)(tmpBase, "mod");
|
|
17246
|
+
const tmpBuildCache = (0, import_path.join)(tmpBase, "go-build");
|
|
17247
|
+
await (0, import_fs_extra.mkdirp)((0, import_path.join)(goDir, "pkg", "mod"));
|
|
17248
|
+
await (0, import_fs_extra.mkdirp)((0, import_path.join)(goDir, "go-build"));
|
|
17249
|
+
await (0, import_fs_extra.mkdirp)(tmpBase);
|
|
17250
|
+
await (0, import_fs_extra.remove)(tmpModCache);
|
|
17251
|
+
await (0, import_fs_extra.symlink)((0, import_path.join)(goCacheDir, "pkg", "mod"), tmpModCache);
|
|
17252
|
+
await (0, import_fs_extra.remove)(tmpBuildCache);
|
|
17253
|
+
await (0, import_fs_extra.symlink)((0, import_path.join)(goCacheDir, "go-build"), tmpBuildCache);
|
|
17252
17254
|
setEnvPaths(tmpModCache, tmpBuildCache);
|
|
17253
17255
|
}
|
|
17254
17256
|
env.GOROOT = goDir;
|
|
@@ -17420,7 +17422,7 @@ function getRenamedEntrypoint(entrypoint) {
|
|
|
17420
17422
|
const filename = (0, import_path2.basename)(entrypoint);
|
|
17421
17423
|
if (filename.startsWith("[")) {
|
|
17422
17424
|
const newEntrypoint = entrypoint.replace("/[", "/now-bracket[");
|
|
17423
|
-
(0,
|
|
17425
|
+
(0, import_build_utils2.debug)(`Renamed entrypoint from ${entrypoint} to ${newEntrypoint}`);
|
|
17424
17426
|
return newEntrypoint;
|
|
17425
17427
|
}
|
|
17426
17428
|
return void 0;
|
|
@@ -17433,22 +17435,22 @@ async function build({
|
|
|
17433
17435
|
workPath,
|
|
17434
17436
|
meta = {}
|
|
17435
17437
|
}) {
|
|
17436
|
-
const goPath = await (0,
|
|
17438
|
+
const goPath = await (0, import_build_utils2.getWriteableDirectory)();
|
|
17437
17439
|
const srcPath = (0, import_path2.join)(goPath, "src", "lambda");
|
|
17438
17440
|
const downloadPath = meta.skipDownload ? workPath : srcPath;
|
|
17439
|
-
await (0,
|
|
17441
|
+
await (0, import_build_utils2.download)(files, downloadPath, meta);
|
|
17440
17442
|
const undo = {
|
|
17441
17443
|
fileActions: [],
|
|
17442
17444
|
directoryCreation: [],
|
|
17443
17445
|
functionRenames: []
|
|
17444
17446
|
};
|
|
17445
|
-
const env = (0,
|
|
17447
|
+
const env = (0, import_build_utils2.cloneEnv)(process.env, meta.env, {
|
|
17446
17448
|
GOARCH: "amd64",
|
|
17447
17449
|
GOOS: "linux"
|
|
17448
17450
|
});
|
|
17449
17451
|
try {
|
|
17450
17452
|
if (env.GIT_CREDENTIALS) {
|
|
17451
|
-
(0,
|
|
17453
|
+
(0, import_build_utils2.debug)("Initialize Git credentials...");
|
|
17452
17454
|
await initPrivateGit(env.GIT_CREDENTIALS);
|
|
17453
17455
|
}
|
|
17454
17456
|
if (env.GO111MODULE) {
|
|
@@ -17510,7 +17512,7 @@ Manually assigning 'GO111MODULE' is not recommended.
|
|
|
17510
17512
|
if (config && config.includeFiles) {
|
|
17511
17513
|
const patterns = Array.isArray(config.includeFiles) ? config.includeFiles : [config.includeFiles];
|
|
17512
17514
|
for (const pattern of patterns) {
|
|
17513
|
-
const fsFiles = await (0,
|
|
17515
|
+
const fsFiles = await (0, import_build_utils2.glob)(pattern, entrypointDirname);
|
|
17514
17516
|
for (const [assetName, asset] of Object.entries(fsFiles)) {
|
|
17515
17517
|
includedFiles[assetName] = asset;
|
|
17516
17518
|
}
|
|
@@ -17525,7 +17527,7 @@ Manually assigning 'GO111MODULE' is not recommended.
|
|
|
17525
17527
|
},
|
|
17526
17528
|
workPath
|
|
17527
17529
|
});
|
|
17528
|
-
const outDir = await (0,
|
|
17530
|
+
const outDir = await (0, import_build_utils2.getWriteableDirectory)();
|
|
17529
17531
|
const buildOptions = {
|
|
17530
17532
|
downloadPath,
|
|
17531
17533
|
entrypoint,
|
|
@@ -17544,9 +17546,9 @@ Manually assigning 'GO111MODULE' is not recommended.
|
|
|
17544
17546
|
} else {
|
|
17545
17547
|
await buildHandlerWithGoMod(buildOptions);
|
|
17546
17548
|
}
|
|
17547
|
-
const runtime = await (0,
|
|
17548
|
-
const lambda = new
|
|
17549
|
-
files: { ...await (0,
|
|
17549
|
+
const runtime = await (0, import_build_utils2.getProvidedRuntime)();
|
|
17550
|
+
const lambda = new import_build_utils2.Lambda({
|
|
17551
|
+
files: { ...await (0, import_build_utils2.glob)("**", outDir), ...includedFiles },
|
|
17550
17552
|
handler: HANDLER_FILENAME,
|
|
17551
17553
|
runtime,
|
|
17552
17554
|
supportsWrapper: true,
|
|
@@ -17556,7 +17558,7 @@ Manually assigning 'GO111MODULE' is not recommended.
|
|
|
17556
17558
|
output: lambda
|
|
17557
17559
|
};
|
|
17558
17560
|
} catch (error) {
|
|
17559
|
-
(0,
|
|
17561
|
+
(0, import_build_utils2.debug)(`Go Builder Error: ${error}`);
|
|
17560
17562
|
throw error;
|
|
17561
17563
|
} finally {
|
|
17562
17564
|
try {
|
|
@@ -17565,7 +17567,7 @@ Manually assigning 'GO111MODULE' is not recommended.
|
|
|
17565
17567
|
if (error instanceof Error) {
|
|
17566
17568
|
console.error(`Build cleanup failed: ${error.message}`);
|
|
17567
17569
|
}
|
|
17568
|
-
(0,
|
|
17570
|
+
(0, import_build_utils2.debug)("Cleanup Error: " + error);
|
|
17569
17571
|
}
|
|
17570
17572
|
}
|
|
17571
17573
|
}
|
|
@@ -17582,7 +17584,7 @@ async function buildHandlerWithGoMod({
|
|
|
17582
17584
|
packageName,
|
|
17583
17585
|
undo
|
|
17584
17586
|
}) {
|
|
17585
|
-
(0,
|
|
17587
|
+
(0, import_build_utils2.debug)(
|
|
17586
17588
|
`Building Go handler as package "${packageName}" (with${goModPath ? "" : "out"} go.mod)`
|
|
17587
17589
|
);
|
|
17588
17590
|
let goModDirname;
|
|
@@ -17613,13 +17615,13 @@ async function buildHandlerWithGoMod({
|
|
|
17613
17615
|
}
|
|
17614
17616
|
let mainGoFile;
|
|
17615
17617
|
if (goModPath && isGoModInRootDir) {
|
|
17616
|
-
(0,
|
|
17618
|
+
(0, import_build_utils2.debug)(`[mod-root] Write main file to ${downloadPath}`);
|
|
17617
17619
|
mainGoFile = (0, import_path2.join)(downloadPath, MAIN_GO_FILENAME);
|
|
17618
17620
|
} else if (goModDirname && !isGoModInRootDir) {
|
|
17619
|
-
(0,
|
|
17621
|
+
(0, import_build_utils2.debug)(`[mod-other] Write main file to ${goModDirname}`);
|
|
17620
17622
|
mainGoFile = (0, import_path2.join)(goModDirname, MAIN_GO_FILENAME);
|
|
17621
17623
|
} else {
|
|
17622
|
-
(0,
|
|
17624
|
+
(0, import_build_utils2.debug)(`[entrypoint] Write main file to ${entrypointDirname}`);
|
|
17623
17625
|
mainGoFile = (0, import_path2.join)(entrypointDirname, MAIN_GO_FILENAME);
|
|
17624
17626
|
}
|
|
17625
17627
|
await Promise.all([
|
|
@@ -17645,7 +17647,7 @@ async function buildHandlerWithGoMod({
|
|
|
17645
17647
|
);
|
|
17646
17648
|
}
|
|
17647
17649
|
if (!goModPath || (0, import_path2.dirname)(entrypointAbsolute) === (0, import_path2.dirname)(goModPath)) {
|
|
17648
|
-
(0,
|
|
17650
|
+
(0, import_build_utils2.debug)(
|
|
17649
17651
|
`moving entrypoint "${entrypointAbsolute}" to "${finalDestination}"`
|
|
17650
17652
|
);
|
|
17651
17653
|
await (0, import_fs_extra2.move)(entrypointAbsolute, finalDestination);
|
|
@@ -17667,14 +17669,14 @@ async function buildHandlerWithGoMod({
|
|
|
17667
17669
|
} else {
|
|
17668
17670
|
baseGoModPath = entrypointDirname;
|
|
17669
17671
|
}
|
|
17670
|
-
(0,
|
|
17672
|
+
(0, import_build_utils2.debug)("Tidy `go.mod` file...");
|
|
17671
17673
|
try {
|
|
17672
17674
|
await go.mod();
|
|
17673
17675
|
} catch (err) {
|
|
17674
17676
|
console.error("failed to `go mod tidy`");
|
|
17675
17677
|
throw err;
|
|
17676
17678
|
}
|
|
17677
|
-
(0,
|
|
17679
|
+
(0, import_build_utils2.debug)("Running `go build`...");
|
|
17678
17680
|
const destPath = (0, import_path2.join)(outDir, HANDLER_FILENAME);
|
|
17679
17681
|
try {
|
|
17680
17682
|
const src = [(0, import_path2.join)(baseGoModPath, MAIN_GO_FILENAME)];
|
|
@@ -17692,7 +17694,7 @@ async function buildHandlerAsPackageMain({
|
|
|
17692
17694
|
outDir,
|
|
17693
17695
|
undo
|
|
17694
17696
|
}) {
|
|
17695
|
-
(0,
|
|
17697
|
+
(0, import_build_utils2.debug)('Building Go handler as package "main" (legacy)');
|
|
17696
17698
|
await writeEntrypoint(
|
|
17697
17699
|
(0, import_path2.join)(entrypointDirname, MAIN_GO_FILENAME),
|
|
17698
17700
|
"",
|
|
@@ -17703,14 +17705,14 @@ async function buildHandlerAsPackageMain({
|
|
|
17703
17705
|
// delete
|
|
17704
17706
|
from: (0, import_path2.join)(entrypointDirname, MAIN_GO_FILENAME)
|
|
17705
17707
|
});
|
|
17706
|
-
(0,
|
|
17708
|
+
(0, import_build_utils2.debug)("Running `go get`...");
|
|
17707
17709
|
try {
|
|
17708
17710
|
await go.get();
|
|
17709
17711
|
} catch (err) {
|
|
17710
17712
|
console.error("Failed to `go get`");
|
|
17711
17713
|
throw err;
|
|
17712
17714
|
}
|
|
17713
|
-
(0,
|
|
17715
|
+
(0, import_build_utils2.debug)("Running `go build`...");
|
|
17714
17716
|
const destPath = (0, import_path2.join)(outDir, HANDLER_FILENAME);
|
|
17715
17717
|
try {
|
|
17716
17718
|
const src = [
|
|
@@ -17740,10 +17742,10 @@ function getNewHandlerFunctionName(originalFunctionName, entrypoint) {
|
|
|
17740
17742
|
"Handler function renaming failed because entrypoint was empty."
|
|
17741
17743
|
);
|
|
17742
17744
|
}
|
|
17743
|
-
(0,
|
|
17745
|
+
(0, import_build_utils2.debug)(`Found exported function "${originalFunctionName}" in "${entrypoint}"`);
|
|
17744
17746
|
const pathSlug = entrypoint.replace(/(\s|\\|\/|\]|\[|-|\.)/g, "_");
|
|
17745
17747
|
const newHandlerName = `${originalFunctionName}_${pathSlug}`;
|
|
17746
|
-
(0,
|
|
17748
|
+
(0, import_build_utils2.debug)(
|
|
17747
17749
|
`Renaming handler function temporarily from "${originalFunctionName}" to "${newHandlerName}"`
|
|
17748
17750
|
);
|
|
17749
17751
|
return newHandlerName;
|
|
@@ -17781,7 +17783,7 @@ async function findGoModPath(entrypointDir, workPath) {
|
|
|
17781
17783
|
const goMod = (0, import_path2.join)(dir, "go.mod");
|
|
17782
17784
|
if (await (0, import_fs_extra2.pathExists)(goMod)) {
|
|
17783
17785
|
goModPath = goMod;
|
|
17784
|
-
(0,
|
|
17786
|
+
(0, import_build_utils2.debug)(`Found ${goModPath}"`);
|
|
17785
17787
|
break;
|
|
17786
17788
|
}
|
|
17787
17789
|
dir = (0, import_path2.dirname)(dir);
|
|
@@ -17857,7 +17859,7 @@ async function writeGoMod({
|
|
|
17857
17859
|
}
|
|
17858
17860
|
}
|
|
17859
17861
|
const destGoModPath = (0, import_path2.join)(destDir, "go.mod");
|
|
17860
|
-
(0,
|
|
17862
|
+
(0, import_build_utils2.debug)(`Writing ${destGoModPath}`);
|
|
17861
17863
|
await (0, import_fs_extra2.writeFile)(destGoModPath, contents, "utf-8");
|
|
17862
17864
|
}
|
|
17863
17865
|
async function findGoWorkFile(goWorkDir, workPath) {
|
|
@@ -17962,7 +17964,7 @@ async function startDevServer(opts) {
|
|
|
17962
17964
|
TMP,
|
|
17963
17965
|
`vercel-dev-port-${Math.random().toString(32).substring(2)}`
|
|
17964
17966
|
);
|
|
17965
|
-
const env = (0,
|
|
17967
|
+
const env = (0, import_build_utils2.cloneEnv)(process.env, meta.env, {
|
|
17966
17968
|
VERCEL_DEV_PORT_FILE: portFile
|
|
17967
17969
|
});
|
|
17968
17970
|
const executable = `./vercel-dev-server-go${process.platform === "win32" ? ".exe" : ""}`;
|
|
@@ -17975,7 +17977,7 @@ async function startDevServer(opts) {
|
|
|
17975
17977
|
workPath
|
|
17976
17978
|
});
|
|
17977
17979
|
await go.build("./...", executable);
|
|
17978
|
-
(0,
|
|
17980
|
+
(0, import_build_utils2.debug)(`SPAWNING ${executable} CWD=${tmp}`);
|
|
17979
17981
|
const child = (0, import_child_process.spawn)(executable, [], {
|
|
17980
17982
|
cwd: tmp,
|
|
17981
17983
|
env,
|
|
@@ -18047,11 +18049,11 @@ async function prepareCache({
|
|
|
18047
18049
|
const stat = await (0, import_fs_extra2.lstat)(goCacheDir);
|
|
18048
18050
|
if (stat.isSymbolicLink()) {
|
|
18049
18051
|
const goGlobalCacheDir = await (0, import_fs_extra2.readlink)(goCacheDir);
|
|
18050
|
-
(0,
|
|
18052
|
+
(0, import_build_utils2.debug)(`Preparing cache by moving ${goGlobalCacheDir} -> ${goCacheDir}`);
|
|
18051
18053
|
await (0, import_fs_extra2.unlink)(goCacheDir);
|
|
18052
18054
|
await (0, import_fs_extra2.move)(goGlobalCacheDir, goCacheDir);
|
|
18053
18055
|
}
|
|
18054
|
-
const cache = await (0,
|
|
18056
|
+
const cache = await (0, import_build_utils2.glob)(`${localCacheDir}/**`, workPath);
|
|
18055
18057
|
return cache;
|
|
18056
18058
|
}
|
|
18057
18059
|
// Annotate the CommonJS export names for ESM import in node:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/go",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index",
|
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/go",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"typescript": "4.3.4",
|
|
34
34
|
"xdg-app-paths": "5.1.0",
|
|
35
35
|
"yauzl-promise": "2.1.3",
|
|
36
|
-
"@vercel/build-utils": "13.2.
|
|
36
|
+
"@vercel/build-utils": "13.2.10"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "node ../../utils/build-builder.mjs",
|