@vercel/ruby 2.0.3 → 2.0.5

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 CHANGED
@@ -6110,17 +6110,17 @@ var require_jsonfile = __commonJS({
6110
6110
  }
6111
6111
  function stringify(obj, options) {
6112
6112
  var spaces;
6113
- var EOL = "\n";
6113
+ var EOL2 = "\n";
6114
6114
  if (typeof options === "object" && options !== null) {
6115
6115
  if (options.spaces) {
6116
6116
  spaces = options.spaces;
6117
6117
  }
6118
6118
  if (options.EOL) {
6119
- EOL = options.EOL;
6119
+ EOL2 = options.EOL;
6120
6120
  }
6121
6121
  }
6122
6122
  var str = JSON.stringify(obj, options ? options.replacer : null, spaces);
6123
- return str.replace(/\n/g, EOL) + EOL;
6123
+ return str.replace(/\n/g, EOL2) + EOL2;
6124
6124
  }
6125
6125
  function writeFile2(file, obj, options, callback) {
6126
6126
  if (callback == null) {
@@ -7659,6 +7659,7 @@ __export(src_exports, {
7659
7659
  version: () => version
7660
7660
  });
7661
7661
  module.exports = __toCommonJS(src_exports);
7662
+ var import_os = require("os");
7662
7663
  var import_path2 = require("path");
7663
7664
  var import_execa2 = __toESM(require_execa());
7664
7665
  var import_fs_extra = __toESM(require_lib());
@@ -7671,6 +7672,7 @@ var import_execa = __toESM(require_execa());
7671
7672
  var import_build_utils = require("@vercel/build-utils");
7672
7673
  function getOptions() {
7673
7674
  const options = [
7675
+ { major: 3, minor: 2, range: "3.2.x", runtime: "ruby3.2" },
7674
7676
  {
7675
7677
  major: 2,
7676
7678
  minor: 7,
@@ -7686,12 +7688,6 @@ function getOptions() {
7686
7688
  discontinueDate: /* @__PURE__ */ new Date("2021-11-30")
7687
7689
  }
7688
7690
  ];
7689
- if (process.env.VERCEL_ALLOW_RUBY32 === "1") {
7690
- return [
7691
- { major: 3, minor: 2, range: "3.2.x", runtime: "ruby3.2" },
7692
- ...options
7693
- ];
7694
- }
7695
7691
  return options;
7696
7692
  }
7697
7693
  function getLatestRubyVersion() {
@@ -7795,7 +7791,7 @@ async function matchPaths(configPatterns, workPath) {
7795
7791
  );
7796
7792
  return patternPaths.reduce((a, b) => a.concat(b), []);
7797
7793
  }
7798
- async function bundleInstall(bundlePath, bundleDir, gemfilePath, runtime) {
7794
+ async function bundleInstall(bundlePath, bundleDir, gemfilePath, rubyPath, runtime) {
7799
7795
  (0, import_build_utils2.debug)(`running "bundle install --deployment"...`);
7800
7796
  const bundleAppConfig = await (0, import_build_utils2.getWriteableDirectory)();
7801
7797
  const gemfileContent = await (0, import_fs_extra.readFile)(gemfilePath, "utf8");
@@ -7812,13 +7808,14 @@ async function bundleInstall(bundlePath, bundleDir, gemfilePath, runtime) {
7812
7808
  }
7813
7809
  const bundlerEnv = (0, import_build_utils2.cloneEnv)(process.env, {
7814
7810
  // Ensure the correct version of `ruby` is in front of the $PATH
7815
- PATH: `${(0, import_path2.dirname)(bundlePath)}:${process.env.PATH}`,
7811
+ PATH: `${(0, import_path2.dirname)(rubyPath)}:${(0, import_path2.dirname)(bundlePath)}:${process.env.PATH}`,
7816
7812
  BUNDLE_SILENCE_ROOT_WARNING: "1",
7817
7813
  BUNDLE_APP_CONFIG: bundleAppConfig,
7818
7814
  BUNDLE_JOBS: "4"
7819
7815
  });
7820
7816
  if (runtime === "ruby3.2") {
7821
7817
  const result2 = await (0, import_execa2.default)("bundler", ["add", "webrick"], {
7818
+ cwd: (0, import_path2.dirname)(gemfilePath),
7822
7819
  stdio: "pipe",
7823
7820
  env: bundlerEnv,
7824
7821
  reject: false
@@ -7845,26 +7842,27 @@ async function bundleInstall(bundlePath, bundleDir, gemfilePath, runtime) {
7845
7842
  }
7846
7843
  }
7847
7844
  var version = 3;
7848
- async function build({
7845
+ var build = async ({
7849
7846
  workPath,
7850
7847
  files,
7851
7848
  entrypoint,
7852
7849
  config,
7853
7850
  meta = {}
7854
- }) {
7851
+ }) => {
7855
7852
  await (0, import_build_utils2.download)(files, workPath, meta);
7856
7853
  const entrypointFsDirname = (0, import_path2.join)(workPath, (0, import_path2.dirname)(entrypoint));
7857
7854
  const gemfileName = "Gemfile";
7858
- const gemfilePath = await (0, import_build_utils2.walkParentDirs)({
7855
+ let gemfilePath = await (0, import_build_utils2.walkParentDirs)({
7859
7856
  base: workPath,
7860
7857
  start: entrypointFsDirname,
7861
7858
  filename: gemfileName
7862
7859
  });
7860
+ if (!gemfilePath) {
7861
+ gemfilePath = (0, import_path2.join)(entrypointFsDirname, gemfileName);
7862
+ await (0, import_fs_extra.writeFile)(gemfilePath, `source "https://rubygems.org"${import_os.EOL}`);
7863
+ }
7863
7864
  const gemfileContents = gemfilePath ? await (0, import_fs_extra.readFile)(gemfilePath, "utf8") : "";
7864
- const { gemHome, bundlerPath, vendorPath, runtime } = await installBundler(
7865
- meta,
7866
- gemfileContents
7867
- );
7865
+ const { gemHome, bundlerPath, vendorPath, runtime, rubyPath } = await installBundler(meta, gemfileContents);
7868
7866
  process.env.GEM_HOME = gemHome;
7869
7867
  (0, import_build_utils2.debug)(`Checking existing vendor directory at "${vendorPath}"`);
7870
7868
  const vendorDir = (0, import_path2.join)(workPath, vendorPath);
@@ -7895,7 +7893,13 @@ async function build({
7895
7893
  if (meta.avoidTopLevelInstall && fileAtRoot) {
7896
7894
  (0, import_build_utils2.debug)("Skipping `bundle install` \u2014 already handled by Install Command");
7897
7895
  } else {
7898
- await bundleInstall(bundlerPath, bundleDir, gemfilePath, runtime);
7896
+ await bundleInstall(
7897
+ bundlerPath,
7898
+ bundleDir,
7899
+ gemfilePath,
7900
+ rubyPath,
7901
+ runtime
7902
+ );
7899
7903
  }
7900
7904
  }
7901
7905
  } else {
@@ -7914,11 +7918,10 @@ async function build({
7914
7918
  userHandlerFilePath
7915
7919
  );
7916
7920
  const handlerRbFilename = "vc__handler__ruby";
7917
- await (0, import_fs_extra.writeFile)(
7918
- (0, import_path2.join)(workPath, `${handlerRbFilename}.rb`),
7919
- nowHandlerRbContents
7920
- );
7921
7921
  const outputFiles = await (0, import_build_utils2.glob)("**", workPath);
7922
+ outputFiles[`${handlerRbFilename}.rb`] = new import_build_utils2.FileBlob({
7923
+ data: nowHandlerRbContents
7924
+ });
7922
7925
  if (config && (config.includeFiles || config.excludeFiles)) {
7923
7926
  const includedPaths = await matchPaths(config.includeFiles, workPath);
7924
7927
  const excludedPaths = await matchPaths(
@@ -7938,14 +7941,14 @@ async function build({
7938
7941
  delete outputFiles[excludedPaths[i]];
7939
7942
  }
7940
7943
  }
7941
- const lambda = await (0, import_build_utils2.createLambda)({
7944
+ const output = new import_build_utils2.Lambda({
7942
7945
  files: outputFiles,
7943
7946
  handler: `${handlerRbFilename}.vc__handler`,
7944
7947
  runtime,
7945
7948
  environment: {}
7946
7949
  });
7947
- return { output: lambda };
7948
- }
7950
+ return { output };
7951
+ };
7949
7952
  // Annotate the CommonJS export names for ESM import in node:
7950
7953
  0 && (module.exports = {
7951
7954
  build,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vercel/ruby",
3
3
  "author": "Nathan Cahill <nathan@nathancahill.com>",
4
- "version": "2.0.3",
4
+ "version": "2.0.5",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index",
7
7
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/ruby",
@@ -17,7 +17,7 @@
17
17
  "devDependencies": {
18
18
  "@types/fs-extra": "8.0.0",
19
19
  "@types/semver": "6.0.0",
20
- "@vercel/build-utils": "7.2.5",
20
+ "@vercel/build-utils": "7.5.1",
21
21
  "execa": "2.0.4",
22
22
  "fs-extra": "^7.0.1",
23
23
  "jest-junit": "16.0.0",
package/vc_init.rb CHANGED
@@ -81,6 +81,12 @@ def vc__handler(event:, context:)
81
81
  payload = JSON.parse(event['body'])
82
82
  path = payload['path']
83
83
  headers = payload['headers']
84
+
85
+ if ENV['VERCEL_DEBUG']
86
+ puts 'Request Headers: '
87
+ puts headers
88
+ end
89
+
84
90
  httpMethod = payload['method']
85
91
  encoding = payload['encoding']
86
92
  body = payload['body']