@vercel/go 3.6.0 → 3.7.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.
@@ -0,0 +1,3 @@
1
+ module vc-init
2
+
3
+ go 1.23
package/dist/index.js CHANGED
@@ -3566,8 +3566,8 @@ var require_graceful_fs = __commonJS({
3566
3566
  }
3567
3567
  }
3568
3568
  var fs$writeFile = fs3.writeFile;
3569
- fs3.writeFile = writeFile3;
3570
- function writeFile3(path, data, options, cb) {
3569
+ fs3.writeFile = writeFile2;
3570
+ function writeFile2(path, data, options, cb) {
3571
3571
  if (typeof options === "function")
3572
3572
  cb = options, options = null;
3573
3573
  return go$writeFile(path, data, options, cb);
@@ -5343,7 +5343,7 @@ var require_jsonfile = __commonJS({
5343
5343
  var str = JSON.stringify(obj, options ? options.replacer : null, spaces);
5344
5344
  return str.replace(/\n/g, EOL) + EOL;
5345
5345
  }
5346
- function writeFile3(file, obj, options, callback) {
5346
+ function writeFile2(file, obj, options, callback) {
5347
5347
  if (callback == null) {
5348
5348
  callback = options;
5349
5349
  options = {};
@@ -5375,7 +5375,7 @@ var require_jsonfile = __commonJS({
5375
5375
  var jsonfile = {
5376
5376
  readFile: readFile4,
5377
5377
  readFileSync,
5378
- writeFile: writeFile3,
5378
+ writeFile: writeFile2,
5379
5379
  writeFileSync
5380
5380
  };
5381
5381
  module2.exports = jsonfile;
@@ -10881,6 +10881,8 @@ var require_xdg_app_paths = __commonJS({
10881
10881
  var src_exports = {};
10882
10882
  __export(src_exports, {
10883
10883
  build: () => build,
10884
+ detectEntrypoint: () => detectEntrypoint,
10885
+ detectGoEntrypoint: () => detectGoEntrypoint,
10884
10886
  getNewHandlerFunctionName: () => getNewHandlerFunctionName,
10885
10887
  prepareCache: () => prepareCache,
10886
10888
  shouldServe: () => import_build_utils4.shouldServe,
@@ -14271,6 +14273,7 @@ var GoWrapper = class {
14271
14273
  const subprocess = (0, import_execa.default)("go", args, {
14272
14274
  ...opts,
14273
14275
  env,
14276
+ extendEnv: false,
14274
14277
  stdio: captureAndForwardOutput ? "pipe" : opts.stdio
14275
14278
  });
14276
14279
  if (captureAndForwardOutput) {
@@ -14324,7 +14327,7 @@ async function createGo({
14324
14327
  goPreferredVersion = await parseGoModVersionFromModule(modulePath);
14325
14328
  }
14326
14329
  const goSelectedVersion = goPreferredVersion ? goPreferredVersion.toolchain || goPreferredVersion.go : Array.from(versionMap.values())[0];
14327
- const env = (0, import_build_utils.cloneEnv)(process.env, opts.env);
14330
+ const env = opts.env ? (0, import_build_utils.cloneEnv)(opts.env) : (0, import_build_utils.cloneEnv)(process.env);
14328
14331
  const { PATH } = env;
14329
14332
  const { platform } = process;
14330
14333
  const goGlobalCacheDir = (0, import_path4.join)(
@@ -14393,7 +14396,10 @@ async function createGo({
14393
14396
  }
14394
14397
  env.GOROOT = goDir || void 0;
14395
14398
  env.PATH = goBinDir || PATH;
14396
- const { stdout } = await (0, import_execa.default)("go", ["version"], { env });
14399
+ const { stdout } = await (0, import_execa.default)("go", ["version"], {
14400
+ env,
14401
+ extendEnv: false
14402
+ });
14397
14403
  const { major, minor, short, version: version2 } = parseGoVersionString(stdout);
14398
14404
  if (major < GO_MIN_MAJOR_VERSION || major === GO_MIN_MAJOR_VERSION && minor < GO_MIN_MINOR_VERSION) {
14399
14405
  (0, import_build_utils.debug)(`Found go ${version2} in ${label}, but version is unsupported`);
@@ -14537,7 +14543,7 @@ var GO_CANDIDATE_ENTRYPOINTS = [
14537
14543
  "cmd/server/main.go"
14538
14544
  ];
14539
14545
  async function detectGoEntrypoint(workPath, configuredEntrypoint) {
14540
- if (await (0, import_fs_extra2.pathExists)((0, import_path5.join)(workPath, configuredEntrypoint))) {
14546
+ if (configuredEntrypoint && await (0, import_fs_extra2.pathExists)((0, import_path5.join)(workPath, configuredEntrypoint))) {
14541
14547
  (0, import_build_utils2.debug)(`Using configured Go entrypoint: ${configuredEntrypoint}`);
14542
14548
  return configuredEntrypoint;
14543
14549
  }
@@ -14549,6 +14555,12 @@ async function detectGoEntrypoint(workPath, configuredEntrypoint) {
14549
14555
  }
14550
14556
  return null;
14551
14557
  }
14558
+ var detectEntrypoint = async ({ workPath }) => {
14559
+ const file = await detectGoEntrypoint(workPath);
14560
+ if (!file)
14561
+ return null;
14562
+ return { kind: "file", entrypoint: file };
14563
+ };
14552
14564
 
14553
14565
  // src/standalone-server.ts
14554
14566
  var import_child_process = require("child_process");
@@ -14618,19 +14630,28 @@ async function buildStandaloneServer({
14618
14630
  console.error(`Failed to build standalone Go server: ${buildTarget}`);
14619
14631
  throw err;
14620
14632
  }
14621
- const bootstrapSrc = (0, import_path6.join)(__dirname, "../vc-init.go");
14622
- const utilsSrc = (0, import_path6.join)(__dirname, "../vc-utils.go");
14633
+ const bootstrapDir = (0, import_path6.join)(__dirname, "../bootstrap");
14634
+ const bootstrapSrc = (0, import_path6.join)(bootstrapDir, "vc-init.go");
14635
+ const utilsSrc = (0, import_path6.join)(bootstrapDir, "vc-utils.go");
14636
+ const bootstrapGoModSrc = (0, import_path6.join)(bootstrapDir, "go.mod");
14623
14637
  (0, import_build_utils3.debug)(`Building bootstrap wrapper: ${bootstrapSrc} -> ${bootstrapPath}`);
14624
14638
  try {
14625
14639
  const bootstrapBuildDir = await (0, import_build_utils3.getWriteableDirectory)();
14626
14640
  const bootstrapGoFile = (0, import_path6.join)(bootstrapBuildDir, "main.go");
14627
14641
  await (0, import_fs_extra3.copy)(bootstrapSrc, bootstrapGoFile);
14628
14642
  await (0, import_fs_extra3.copy)(utilsSrc, (0, import_path6.join)(bootstrapBuildDir, "vc-utils.go"));
14629
- const bootstrapGoMod = (0, import_path6.join)(bootstrapBuildDir, "go.mod");
14630
- await (0, import_fs_extra3.writeFile)(bootstrapGoMod, "module vc-init\n\ngo 1.21\n");
14643
+ await (0, import_fs_extra3.copy)(bootstrapGoModSrc, (0, import_path6.join)(bootstrapBuildDir, "go.mod"));
14644
+ const bootstrapEnv = {
14645
+ PATH: process.env.PATH || "",
14646
+ HOME: process.env.HOME || "",
14647
+ TMPDIR: process.env.TMPDIR || "",
14648
+ GOARCH: architecture === "arm64" ? "arm64" : "amd64",
14649
+ GOOS: "linux",
14650
+ CGO_ENABLED: "0"
14651
+ };
14631
14652
  const bootstrapGo = await createGo({
14632
14653
  modulePath: bootstrapBuildDir,
14633
- opts: { cwd: bootstrapBuildDir, env },
14654
+ opts: { cwd: bootstrapBuildDir, env: bootstrapEnv },
14634
14655
  workPath: bootstrapBuildDir
14635
14656
  });
14636
14657
  await bootstrapGo.build(".", bootstrapPath);
@@ -14676,8 +14697,8 @@ async function startStandaloneDevServer(opts, resolvedEntrypoint) {
14676
14697
  PORT: String(port)
14677
14698
  });
14678
14699
  const runTarget = resolvedEntrypoint === "main.go" ? "." : "./" + (0, import_path6.dirname)(resolvedEntrypoint);
14679
- const devWrapper = (0, import_path6.join)(__dirname, "../vc-init-dev.go");
14680
- const devUtils = (0, import_path6.join)(__dirname, "../vc-utils.go");
14700
+ const devWrapper = (0, import_path6.join)(__dirname, "../bootstrap/vc-init-dev.go");
14701
+ const devUtils = (0, import_path6.join)(__dirname, "../bootstrap/vc-utils.go");
14681
14702
  (0, import_build_utils3.debug)(
14682
14703
  `Starting standalone Go dev server wrapper: go run ${devWrapper} (target ${runTarget}, port ${port})`
14683
14704
  );
@@ -15451,6 +15472,8 @@ async function prepareCache({
15451
15472
  // Annotate the CommonJS export names for ESM import in node:
15452
15473
  0 && (module.exports = {
15453
15474
  build,
15475
+ detectEntrypoint,
15476
+ detectGoEntrypoint,
15454
15477
  getNewHandlerFunctionName,
15455
15478
  prepareCache,
15456
15479
  shouldServe,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/go",
3
- "version": "3.6.0",
3
+ "version": "3.7.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/go",
@@ -11,32 +11,34 @@
11
11
  },
12
12
  "files": [
13
13
  "dist",
14
- "*.go"
14
+ "*.go",
15
+ "bootstrap"
15
16
  ],
16
17
  "devDependencies": {
17
18
  "@tootallnate/once": "1.1.2",
18
19
  "@types/async-retry": "1.4.5",
19
20
  "@types/execa": "^0.9.0",
20
21
  "@types/fs-extra": "^5.0.5",
21
- "@types/jest": "28.1.6",
22
22
  "@types/node": "20.11.0",
23
23
  "@types/node-fetch": "^2.3.0",
24
24
  "@types/yauzl-promise": "2.1.0",
25
25
  "async-retry": "1.3.3",
26
26
  "execa": "^1.0.0",
27
27
  "fs-extra": "^7.0.0",
28
- "jest-junit": "16.0.0",
29
28
  "node-fetch": "^2.2.1",
30
29
  "string-argv": "0.3.1",
31
30
  "tar": "7.5.11",
31
+ "vitest": "2.0.3",
32
32
  "xdg-app-paths": "5.1.0",
33
33
  "yauzl-promise": "2.1.3",
34
- "@vercel/build-utils": "13.21.0"
34
+ "@vercel/build-utils": "13.26.0"
35
35
  },
36
36
  "scripts": {
37
37
  "build": "node ../../utils/build-builder.mjs",
38
- "test": "jest --reporters=default --reporters=jest-junit --env node --verbose --runInBand --bail",
38
+ "test": "vitest run --config ../../vitest.config.mts",
39
39
  "test-e2e": "pnpm test test/integration-*",
40
- "type-check": "tsc --noEmit"
40
+ "type-check": "tsc --noEmit",
41
+ "vitest-run": "vitest -c ../../vitest.config.mts",
42
+ "vitest-e2e": "glob --absolute 'test/integration-*'"
41
43
  }
42
44
  }
File without changes
File without changes
File without changes