@vercel/ruby 1.2.8-canary.4 → 1.2.9

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 +55 -11
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -8665,10 +8665,11 @@ exports.version = 3;
8665
8665
  async function build({ workPath, files, entrypoint, config, meta = {}, }) {
8666
8666
  await build_utils_1.download(files, workPath, meta);
8667
8667
  const entrypointFsDirname = path_1.join(workPath, path_1.dirname(entrypoint));
8668
+ const gemfileName = 'Gemfile';
8668
8669
  const gemfilePath = await build_utils_1.walkParentDirs({
8669
8670
  base: workPath,
8670
8671
  start: entrypointFsDirname,
8671
- filename: 'Gemfile',
8672
+ filename: gemfileName,
8672
8673
  });
8673
8674
  const gemfileContents = gemfilePath
8674
8675
  ? await fs_extra_1.readFile(gemfilePath, 'utf8')
@@ -8700,14 +8701,23 @@ async function build({ workPath, files, entrypoint, config, meta = {}, }) {
8700
8701
  if (!hasVendorDir) {
8701
8702
  if (gemfilePath) {
8702
8703
  build_utils_1.debug('did not find a vendor directory but found a Gemfile, bundling gems...');
8703
- // try installing. this won't work if native extesions are required.
8704
- // if that's the case, gems should be vendored locally before deploying.
8705
- try {
8706
- await bundleInstall(bundlerPath, bundleDir, gemfilePath);
8704
+ const fileAtRoot = path_1.relative(workPath, gemfilePath) === gemfileName;
8705
+ // If the `Gemfile` is located in the Root Directory of the project and
8706
+ // the new File System API is used (`avoidTopLevelInstall`), the Install Command
8707
+ // will have already installed its dependencies, so we don't need to do it again.
8708
+ if (meta.avoidTopLevelInstall && fileAtRoot) {
8709
+ build_utils_1.debug('Skipping `bundle install` — already handled by Install Command');
8707
8710
  }
8708
- catch (err) {
8709
- build_utils_1.debug('unable to build gems from Gemfile. vendor the gems locally with "bundle install --deployment" and retry.');
8710
- throw err;
8711
+ else {
8712
+ // try installing. this won't work if native extesions are required.
8713
+ // if that's the case, gems should be vendored locally before deploying.
8714
+ try {
8715
+ await bundleInstall(bundlerPath, bundleDir, gemfilePath);
8716
+ }
8717
+ catch (err) {
8718
+ build_utils_1.debug('unable to build gems from Gemfile. vendor the gems locally with "bundle install --deployment" and retry.');
8719
+ throw err;
8720
+ }
8711
8721
  }
8712
8722
  }
8713
8723
  }
@@ -8783,11 +8793,21 @@ const execa_1 = __importDefault(__webpack_require__(4237));
8783
8793
  const build_utils_1 = __webpack_require__(3445);
8784
8794
  const allOptions = [
8785
8795
  { major: 2, minor: 7, range: '2.7.x', runtime: 'ruby2.7' },
8786
- { major: 2, minor: 5, range: '2.5.x', runtime: 'ruby2.5' },
8796
+ {
8797
+ major: 2,
8798
+ minor: 5,
8799
+ range: '2.5.x',
8800
+ runtime: 'ruby2.5',
8801
+ discontinueDate: new Date('2021-11-30'),
8802
+ },
8787
8803
  ];
8788
8804
  function getLatestRubyVersion() {
8789
8805
  return allOptions[0];
8790
8806
  }
8807
+ function isDiscontinued({ discontinueDate }) {
8808
+ const today = Date.now();
8809
+ return discontinueDate !== undefined && discontinueDate.getTime() <= today;
8810
+ }
8791
8811
  function getRubyPath(meta, gemfileContents) {
8792
8812
  let selection = getLatestRubyVersion();
8793
8813
  if (meta.isDev) {
@@ -8808,8 +8828,19 @@ function getRubyPath(meta, gemfileContents) {
8808
8828
  if (!found) {
8809
8829
  throw new build_utils_1.NowBuildError({
8810
8830
  code: 'RUBY_INVALID_VERSION',
8811
- message: 'Found `Gemfile` with invalid Ruby version: `' + line + '`.',
8812
- link: 'https://vercel.com/docs/runtimes#official-runtimes/ruby/ruby-version',
8831
+ message: `Found \`Gemfile\` with invalid Ruby version: \`${line}.\``,
8832
+ link: 'http://vercel.link/ruby-version',
8833
+ });
8834
+ }
8835
+ if (isDiscontinued(selection)) {
8836
+ const latest = getLatestRubyVersion();
8837
+ const intro = `Found \`Gemfile\` with discontinued Ruby version: \`${line}.\``;
8838
+ const hint = `Please set \`ruby "~> ${latest.range}"\` in your \`Gemfile\` to use Ruby ${latest.range}.`;
8839
+ const upstream = 'This change is the result of a decision made by an upstream infrastructure provider (AWS).';
8840
+ throw new build_utils_1.NowBuildError({
8841
+ code: 'RUBY_DISCONTINUED_VERSION',
8842
+ link: 'http://vercel.link/ruby-version',
8843
+ message: `${intro} ${hint} ${upstream}`,
8813
8844
  });
8814
8845
  }
8815
8846
  }
@@ -8831,6 +8862,19 @@ function getRubyPath(meta, gemfileContents) {
8831
8862
  // the absolute path to it
8832
8863
  async function installBundler(meta, gemfileContents) {
8833
8864
  const { gemHome, rubyPath, gemPath, vendorPath, runtime } = getRubyPath(meta, gemfileContents);
8865
+ // If the new File System API is used (`avoidTopLevelInstall`), the Install Command
8866
+ // will have already installed the dependencies, so we don't need to do it again.
8867
+ if (meta.avoidTopLevelInstall) {
8868
+ build_utils_1.debug(`Skipping bundler installation, already installed by Install Command`);
8869
+ return {
8870
+ gemHome,
8871
+ rubyPath,
8872
+ gemPath,
8873
+ vendorPath,
8874
+ runtime,
8875
+ bundlerPath: path_1.join(gemHome, 'bin', 'bundler'),
8876
+ };
8877
+ }
8834
8878
  build_utils_1.debug('installing bundler...');
8835
8879
  await execa_1.default(gemPath, ['install', 'bundler', '--no-document'], {
8836
8880
  stdio: 'pipe',
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": "1.2.8-canary.4",
4
+ "version": "1.2.9",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index",
7
7
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/ruby",
@@ -28,5 +28,5 @@
28
28
  "semver": "6.1.1",
29
29
  "typescript": "4.3.4"
30
30
  },
31
- "gitHead": "ed1dacd27698f3bb181f32b516af6953655b37e9"
31
+ "gitHead": "160f4d46d906c8b7614a9aa63a60d3c79c3f0093"
32
32
  }