mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-07 21:07:46 +00:00
[ruby] Show error when Ruby 2.5.x detected (#7126)
* [ruby] Show error when Ruby 2.5.x detected * Add test with ruby 2.5.x
This commit is contained in:
@@ -9,13 +9,24 @@ interface RubyVersion extends NodeVersion {
|
||||
|
||||
const allOptions: RubyVersion[] = [
|
||||
{ major: 2, minor: 7, range: '2.7.x', runtime: 'ruby2.7' },
|
||||
{ major: 2, minor: 5, range: '2.5.x', runtime: 'ruby2.5' },
|
||||
{
|
||||
major: 2,
|
||||
minor: 5,
|
||||
range: '2.5.x',
|
||||
runtime: 'ruby2.5',
|
||||
discontinueDate: new Date('2021-11-30'),
|
||||
},
|
||||
];
|
||||
|
||||
function getLatestRubyVersion(): RubyVersion {
|
||||
return allOptions[0];
|
||||
}
|
||||
|
||||
function isDiscontinued({ discontinueDate }: RubyVersion): boolean {
|
||||
const today = Date.now();
|
||||
return discontinueDate !== undefined && discontinueDate.getTime() <= today;
|
||||
}
|
||||
|
||||
function getRubyPath(meta: Meta, gemfileContents: string) {
|
||||
let selection = getLatestRubyVersion();
|
||||
if (meta.isDev) {
|
||||
@@ -37,8 +48,20 @@ function getRubyPath(meta: Meta, gemfileContents: string) {
|
||||
if (!found) {
|
||||
throw new NowBuildError({
|
||||
code: 'RUBY_INVALID_VERSION',
|
||||
message: 'Found `Gemfile` with invalid Ruby version: `' + line + '`.',
|
||||
link: 'https://vercel.com/docs/runtimes#official-runtimes/ruby/ruby-version',
|
||||
message: `Found \`Gemfile\` with invalid Ruby version: \`${line}.\``,
|
||||
link: 'http://vercel.link/ruby-version',
|
||||
});
|
||||
}
|
||||
if (isDiscontinued(selection)) {
|
||||
const latest = getLatestRubyVersion();
|
||||
const intro = `Found \`Gemfile\` with discontinued Ruby version: \`${line}.\``;
|
||||
const hint = `Please set \`ruby "~> ${latest.range}"\` in your \`Gemfile\` to use Ruby ${latest.range}.`;
|
||||
const upstream =
|
||||
'This change is the result of a decision made by an upstream infrastructure provider (AWS).';
|
||||
throw new NowBuildError({
|
||||
code: 'RUBY_DISCONTINUED_VERSION',
|
||||
link: 'http://vercel.link/ruby-version',
|
||||
message: `${intro} ${hint} ${upstream}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user