@vercel/ruby 2.0.2 → 2.0.4

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.
Files changed (2) hide show
  1. package/dist/index.js +66 -24
  2. package/package.json +4 -4
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());
@@ -7669,18 +7670,28 @@ var import_path = require("path");
7669
7670
  var import_semver = __toESM(require_semver2());
7670
7671
  var import_execa = __toESM(require_execa());
7671
7672
  var import_build_utils = require("@vercel/build-utils");
7672
- var allOptions = [
7673
- { major: 2, minor: 7, range: "2.7.x", runtime: "ruby2.7" },
7674
- {
7675
- major: 2,
7676
- minor: 5,
7677
- range: "2.5.x",
7678
- runtime: "ruby2.5",
7679
- discontinueDate: /* @__PURE__ */ new Date("2021-11-30")
7680
- }
7681
- ];
7673
+ function getOptions() {
7674
+ const options = [
7675
+ { major: 3, minor: 2, range: "3.2.x", runtime: "ruby3.2" },
7676
+ {
7677
+ major: 2,
7678
+ minor: 7,
7679
+ range: "2.7.x",
7680
+ runtime: "ruby2.7",
7681
+ discontinueDate: /* @__PURE__ */ new Date("2023-12-07")
7682
+ },
7683
+ {
7684
+ major: 2,
7685
+ minor: 5,
7686
+ range: "2.5.x",
7687
+ runtime: "ruby2.5",
7688
+ discontinueDate: /* @__PURE__ */ new Date("2021-11-30")
7689
+ }
7690
+ ];
7691
+ return options;
7692
+ }
7682
7693
  function getLatestRubyVersion() {
7683
- return allOptions[0];
7694
+ return getOptions()[0];
7684
7695
  }
7685
7696
  function isDiscontinued({ discontinueDate }) {
7686
7697
  const today = Date.now();
@@ -7696,7 +7707,7 @@ function getRubyPath(meta, gemfileContents) {
7696
7707
  const line = gemfileContents.split("\n").find((line2) => line2.startsWith("ruby"));
7697
7708
  if (line) {
7698
7709
  const strVersion = line.slice(4).trim().slice(1, -1).replace("~>", "");
7699
- const found = allOptions.some((o) => {
7710
+ const found = getOptions().some((o) => {
7700
7711
  selection = o;
7701
7712
  return (0, import_semver.intersects)(o.range, strVersion);
7702
7713
  });
@@ -7780,7 +7791,7 @@ async function matchPaths(configPatterns, workPath) {
7780
7791
  );
7781
7792
  return patternPaths.reduce((a, b) => a.concat(b), []);
7782
7793
  }
7783
- async function bundleInstall(bundlePath, bundleDir, gemfilePath) {
7794
+ async function bundleInstall(bundlePath, bundleDir, gemfilePath, runtime) {
7784
7795
  (0, import_build_utils2.debug)(`running "bundle install --deployment"...`);
7785
7796
  const bundleAppConfig = await (0, import_build_utils2.getWriteableDirectory)();
7786
7797
  const gemfileContent = await (0, import_fs_extra.readFile)(gemfilePath, "utf8");
@@ -7789,19 +7800,46 @@ async function bundleInstall(bundlePath, bundleDir, gemfilePath) {
7789
7800
  gemfilePath,
7790
7801
  gemfileContent.replace('ruby "~> 2.7.x"', 'ruby "~> 2.7.0"')
7791
7802
  );
7803
+ } else if (gemfileContent.includes('ruby "~> 3.2.x"')) {
7804
+ await (0, import_fs_extra.writeFile)(
7805
+ gemfilePath,
7806
+ gemfileContent.replace('ruby "~> 3.2.x"', 'ruby "~> 3.2.0"')
7807
+ );
7792
7808
  }
7793
- await (0, import_execa2.default)(
7809
+ const bundlerEnv = (0, import_build_utils2.cloneEnv)(process.env, {
7810
+ // Ensure the correct version of `ruby` is in front of the $PATH
7811
+ PATH: `${(0, import_path2.dirname)(bundlePath)}:${process.env.PATH}`,
7812
+ BUNDLE_SILENCE_ROOT_WARNING: "1",
7813
+ BUNDLE_APP_CONFIG: bundleAppConfig,
7814
+ BUNDLE_JOBS: "4"
7815
+ });
7816
+ if (runtime === "ruby3.2") {
7817
+ const result2 = await (0, import_execa2.default)("bundler", ["add", "webrick"], {
7818
+ cwd: (0, import_path2.dirname)(gemfilePath),
7819
+ stdio: "pipe",
7820
+ env: bundlerEnv,
7821
+ reject: false
7822
+ });
7823
+ if (result2.exitCode !== 0) {
7824
+ console.log(result2.stdout);
7825
+ console.error(result2.stderr);
7826
+ throw result2;
7827
+ }
7828
+ }
7829
+ const result = await (0, import_execa2.default)(
7794
7830
  bundlePath,
7795
7831
  ["install", "--deployment", "--gemfile", gemfilePath, "--path", bundleDir],
7796
7832
  {
7797
7833
  stdio: "pipe",
7798
- env: (0, import_build_utils2.cloneEnv)(process.env, {
7799
- BUNDLE_SILENCE_ROOT_WARNING: "1",
7800
- BUNDLE_APP_CONFIG: bundleAppConfig,
7801
- BUNDLE_JOBS: "4"
7802
- })
7834
+ env: bundlerEnv,
7835
+ reject: false
7803
7836
  }
7804
7837
  );
7838
+ if (result.exitCode !== 0) {
7839
+ console.log(result.stdout);
7840
+ console.error(result.stderr);
7841
+ throw result;
7842
+ }
7805
7843
  }
7806
7844
  var version = 3;
7807
7845
  async function build({
@@ -7814,11 +7852,15 @@ async function build({
7814
7852
  await (0, import_build_utils2.download)(files, workPath, meta);
7815
7853
  const entrypointFsDirname = (0, import_path2.join)(workPath, (0, import_path2.dirname)(entrypoint));
7816
7854
  const gemfileName = "Gemfile";
7817
- const gemfilePath = await (0, import_build_utils2.walkParentDirs)({
7855
+ let gemfilePath = await (0, import_build_utils2.walkParentDirs)({
7818
7856
  base: workPath,
7819
7857
  start: entrypointFsDirname,
7820
7858
  filename: gemfileName
7821
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
+ }
7822
7864
  const gemfileContents = gemfilePath ? await (0, import_fs_extra.readFile)(gemfilePath, "utf8") : "";
7823
7865
  const { gemHome, bundlerPath, vendorPath, runtime } = await installBundler(
7824
7866
  meta,
@@ -7854,7 +7896,7 @@ async function build({
7854
7896
  if (meta.avoidTopLevelInstall && fileAtRoot) {
7855
7897
  (0, import_build_utils2.debug)("Skipping `bundle install` \u2014 already handled by Install Command");
7856
7898
  } else {
7857
- await bundleInstall(bundlerPath, bundleDir, gemfilePath);
7899
+ await bundleInstall(bundlerPath, bundleDir, gemfilePath, runtime);
7858
7900
  }
7859
7901
  }
7860
7902
  } else {
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.2",
4
+ "version": "2.0.4",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index",
7
7
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/ruby",
@@ -17,8 +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.0",
21
- "@vercel/ncc": "0.24.0",
20
+ "@vercel/build-utils": "7.3.0",
22
21
  "execa": "2.0.4",
23
22
  "fs-extra": "^7.0.1",
24
23
  "jest-junit": "16.0.0",
@@ -27,6 +26,7 @@
27
26
  "scripts": {
28
27
  "build": "node ../../utils/build-builder.mjs",
29
28
  "test": "jest --reporters=default --reporters=jest-junit --env node --verbose --runInBand --bail",
30
- "test-e2e": "pnpm test"
29
+ "test-e2e": "pnpm test",
30
+ "type-check": "tsc --noEmit"
31
31
  }
32
32
  }