@vercel/go 3.3.0 → 3.3.2
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 +45 -42
- package/package.json +3 -3
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,11 +17546,12 @@ 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,
|
|
17554
|
+
runtimeLanguage: "go",
|
|
17552
17555
|
supportsWrapper: true,
|
|
17553
17556
|
environment: {}
|
|
17554
17557
|
});
|
|
@@ -17556,7 +17559,7 @@ Manually assigning 'GO111MODULE' is not recommended.
|
|
|
17556
17559
|
output: lambda
|
|
17557
17560
|
};
|
|
17558
17561
|
} catch (error) {
|
|
17559
|
-
(0,
|
|
17562
|
+
(0, import_build_utils2.debug)(`Go Builder Error: ${error}`);
|
|
17560
17563
|
throw error;
|
|
17561
17564
|
} finally {
|
|
17562
17565
|
try {
|
|
@@ -17565,7 +17568,7 @@ Manually assigning 'GO111MODULE' is not recommended.
|
|
|
17565
17568
|
if (error instanceof Error) {
|
|
17566
17569
|
console.error(`Build cleanup failed: ${error.message}`);
|
|
17567
17570
|
}
|
|
17568
|
-
(0,
|
|
17571
|
+
(0, import_build_utils2.debug)("Cleanup Error: " + error);
|
|
17569
17572
|
}
|
|
17570
17573
|
}
|
|
17571
17574
|
}
|
|
@@ -17582,7 +17585,7 @@ async function buildHandlerWithGoMod({
|
|
|
17582
17585
|
packageName,
|
|
17583
17586
|
undo
|
|
17584
17587
|
}) {
|
|
17585
|
-
(0,
|
|
17588
|
+
(0, import_build_utils2.debug)(
|
|
17586
17589
|
`Building Go handler as package "${packageName}" (with${goModPath ? "" : "out"} go.mod)`
|
|
17587
17590
|
);
|
|
17588
17591
|
let goModDirname;
|
|
@@ -17613,13 +17616,13 @@ async function buildHandlerWithGoMod({
|
|
|
17613
17616
|
}
|
|
17614
17617
|
let mainGoFile;
|
|
17615
17618
|
if (goModPath && isGoModInRootDir) {
|
|
17616
|
-
(0,
|
|
17619
|
+
(0, import_build_utils2.debug)(`[mod-root] Write main file to ${downloadPath}`);
|
|
17617
17620
|
mainGoFile = (0, import_path2.join)(downloadPath, MAIN_GO_FILENAME);
|
|
17618
17621
|
} else if (goModDirname && !isGoModInRootDir) {
|
|
17619
|
-
(0,
|
|
17622
|
+
(0, import_build_utils2.debug)(`[mod-other] Write main file to ${goModDirname}`);
|
|
17620
17623
|
mainGoFile = (0, import_path2.join)(goModDirname, MAIN_GO_FILENAME);
|
|
17621
17624
|
} else {
|
|
17622
|
-
(0,
|
|
17625
|
+
(0, import_build_utils2.debug)(`[entrypoint] Write main file to ${entrypointDirname}`);
|
|
17623
17626
|
mainGoFile = (0, import_path2.join)(entrypointDirname, MAIN_GO_FILENAME);
|
|
17624
17627
|
}
|
|
17625
17628
|
await Promise.all([
|
|
@@ -17645,7 +17648,7 @@ async function buildHandlerWithGoMod({
|
|
|
17645
17648
|
);
|
|
17646
17649
|
}
|
|
17647
17650
|
if (!goModPath || (0, import_path2.dirname)(entrypointAbsolute) === (0, import_path2.dirname)(goModPath)) {
|
|
17648
|
-
(0,
|
|
17651
|
+
(0, import_build_utils2.debug)(
|
|
17649
17652
|
`moving entrypoint "${entrypointAbsolute}" to "${finalDestination}"`
|
|
17650
17653
|
);
|
|
17651
17654
|
await (0, import_fs_extra2.move)(entrypointAbsolute, finalDestination);
|
|
@@ -17667,14 +17670,14 @@ async function buildHandlerWithGoMod({
|
|
|
17667
17670
|
} else {
|
|
17668
17671
|
baseGoModPath = entrypointDirname;
|
|
17669
17672
|
}
|
|
17670
|
-
(0,
|
|
17673
|
+
(0, import_build_utils2.debug)("Tidy `go.mod` file...");
|
|
17671
17674
|
try {
|
|
17672
17675
|
await go.mod();
|
|
17673
17676
|
} catch (err) {
|
|
17674
17677
|
console.error("failed to `go mod tidy`");
|
|
17675
17678
|
throw err;
|
|
17676
17679
|
}
|
|
17677
|
-
(0,
|
|
17680
|
+
(0, import_build_utils2.debug)("Running `go build`...");
|
|
17678
17681
|
const destPath = (0, import_path2.join)(outDir, HANDLER_FILENAME);
|
|
17679
17682
|
try {
|
|
17680
17683
|
const src = [(0, import_path2.join)(baseGoModPath, MAIN_GO_FILENAME)];
|
|
@@ -17692,7 +17695,7 @@ async function buildHandlerAsPackageMain({
|
|
|
17692
17695
|
outDir,
|
|
17693
17696
|
undo
|
|
17694
17697
|
}) {
|
|
17695
|
-
(0,
|
|
17698
|
+
(0, import_build_utils2.debug)('Building Go handler as package "main" (legacy)');
|
|
17696
17699
|
await writeEntrypoint(
|
|
17697
17700
|
(0, import_path2.join)(entrypointDirname, MAIN_GO_FILENAME),
|
|
17698
17701
|
"",
|
|
@@ -17703,14 +17706,14 @@ async function buildHandlerAsPackageMain({
|
|
|
17703
17706
|
// delete
|
|
17704
17707
|
from: (0, import_path2.join)(entrypointDirname, MAIN_GO_FILENAME)
|
|
17705
17708
|
});
|
|
17706
|
-
(0,
|
|
17709
|
+
(0, import_build_utils2.debug)("Running `go get`...");
|
|
17707
17710
|
try {
|
|
17708
17711
|
await go.get();
|
|
17709
17712
|
} catch (err) {
|
|
17710
17713
|
console.error("Failed to `go get`");
|
|
17711
17714
|
throw err;
|
|
17712
17715
|
}
|
|
17713
|
-
(0,
|
|
17716
|
+
(0, import_build_utils2.debug)("Running `go build`...");
|
|
17714
17717
|
const destPath = (0, import_path2.join)(outDir, HANDLER_FILENAME);
|
|
17715
17718
|
try {
|
|
17716
17719
|
const src = [
|
|
@@ -17740,10 +17743,10 @@ function getNewHandlerFunctionName(originalFunctionName, entrypoint) {
|
|
|
17740
17743
|
"Handler function renaming failed because entrypoint was empty."
|
|
17741
17744
|
);
|
|
17742
17745
|
}
|
|
17743
|
-
(0,
|
|
17746
|
+
(0, import_build_utils2.debug)(`Found exported function "${originalFunctionName}" in "${entrypoint}"`);
|
|
17744
17747
|
const pathSlug = entrypoint.replace(/(\s|\\|\/|\]|\[|-|\.)/g, "_");
|
|
17745
17748
|
const newHandlerName = `${originalFunctionName}_${pathSlug}`;
|
|
17746
|
-
(0,
|
|
17749
|
+
(0, import_build_utils2.debug)(
|
|
17747
17750
|
`Renaming handler function temporarily from "${originalFunctionName}" to "${newHandlerName}"`
|
|
17748
17751
|
);
|
|
17749
17752
|
return newHandlerName;
|
|
@@ -17781,7 +17784,7 @@ async function findGoModPath(entrypointDir, workPath) {
|
|
|
17781
17784
|
const goMod = (0, import_path2.join)(dir, "go.mod");
|
|
17782
17785
|
if (await (0, import_fs_extra2.pathExists)(goMod)) {
|
|
17783
17786
|
goModPath = goMod;
|
|
17784
|
-
(0,
|
|
17787
|
+
(0, import_build_utils2.debug)(`Found ${goModPath}"`);
|
|
17785
17788
|
break;
|
|
17786
17789
|
}
|
|
17787
17790
|
dir = (0, import_path2.dirname)(dir);
|
|
@@ -17857,7 +17860,7 @@ async function writeGoMod({
|
|
|
17857
17860
|
}
|
|
17858
17861
|
}
|
|
17859
17862
|
const destGoModPath = (0, import_path2.join)(destDir, "go.mod");
|
|
17860
|
-
(0,
|
|
17863
|
+
(0, import_build_utils2.debug)(`Writing ${destGoModPath}`);
|
|
17861
17864
|
await (0, import_fs_extra2.writeFile)(destGoModPath, contents, "utf-8");
|
|
17862
17865
|
}
|
|
17863
17866
|
async function findGoWorkFile(goWorkDir, workPath) {
|
|
@@ -17962,7 +17965,7 @@ async function startDevServer(opts) {
|
|
|
17962
17965
|
TMP,
|
|
17963
17966
|
`vercel-dev-port-${Math.random().toString(32).substring(2)}`
|
|
17964
17967
|
);
|
|
17965
|
-
const env = (0,
|
|
17968
|
+
const env = (0, import_build_utils2.cloneEnv)(process.env, meta.env, {
|
|
17966
17969
|
VERCEL_DEV_PORT_FILE: portFile
|
|
17967
17970
|
});
|
|
17968
17971
|
const executable = `./vercel-dev-server-go${process.platform === "win32" ? ".exe" : ""}`;
|
|
@@ -17975,7 +17978,7 @@ async function startDevServer(opts) {
|
|
|
17975
17978
|
workPath
|
|
17976
17979
|
});
|
|
17977
17980
|
await go.build("./...", executable);
|
|
17978
|
-
(0,
|
|
17981
|
+
(0, import_build_utils2.debug)(`SPAWNING ${executable} CWD=${tmp}`);
|
|
17979
17982
|
const child = (0, import_child_process.spawn)(executable, [], {
|
|
17980
17983
|
cwd: tmp,
|
|
17981
17984
|
env,
|
|
@@ -18047,11 +18050,11 @@ async function prepareCache({
|
|
|
18047
18050
|
const stat = await (0, import_fs_extra2.lstat)(goCacheDir);
|
|
18048
18051
|
if (stat.isSymbolicLink()) {
|
|
18049
18052
|
const goGlobalCacheDir = await (0, import_fs_extra2.readlink)(goCacheDir);
|
|
18050
|
-
(0,
|
|
18053
|
+
(0, import_build_utils2.debug)(`Preparing cache by moving ${goGlobalCacheDir} -> ${goCacheDir}`);
|
|
18051
18054
|
await (0, import_fs_extra2.unlink)(goCacheDir);
|
|
18052
18055
|
await (0, import_fs_extra2.move)(goGlobalCacheDir, goCacheDir);
|
|
18053
18056
|
}
|
|
18054
|
-
const cache = await (0,
|
|
18057
|
+
const cache = await (0, import_build_utils2.glob)(`${localCacheDir}/**`, workPath);
|
|
18055
18058
|
return cache;
|
|
18056
18059
|
}
|
|
18057
18060
|
// 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.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index",
|
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/go",
|
|
@@ -33,12 +33,12 @@
|
|
|
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.11"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "node ../../utils/build-builder.mjs",
|
|
40
40
|
"test": "jest --reporters=default --reporters=jest-junit --env node --verbose --runInBand --bail",
|
|
41
|
-
"test-e2e": "
|
|
41
|
+
"test-e2e": "echo 'Go e2e tests temporarily disabled'",
|
|
42
42
|
"type-check": "tsc --noEmit"
|
|
43
43
|
}
|
|
44
44
|
}
|