Use an explicit list of supported platforms for nicer error messages

This commit is contained in:
Benoit Daloze
2022-05-15 12:21:30 +02:00
parent e92b7971f0
commit 296bf7f67a
5 changed files with 37 additions and 2 deletions
+9
View File
@@ -98,6 +98,15 @@ function getImageOS() {
return imageOS return imageOS
} }
export const supportedPlatforms = [
'ubuntu-18.04',
'ubuntu-20.04',
'macos-10.15',
'macos-11.0',
'windows-2019',
'windows-2022',
]
export function getVirtualEnvironmentName() { export function getVirtualEnvironmentName() {
const imageOS = getImageOS() const imageOS = getImageOS()
Generated Vendored
+19 -1
View File
@@ -259,6 +259,7 @@ __nccwpck_require__.r(__webpack_exports__);
/* harmony export */ "isBundler2Default": () => (/* binding */ isBundler2Default), /* harmony export */ "isBundler2Default": () => (/* binding */ isBundler2Default),
/* harmony export */ "floatVersion": () => (/* binding */ floatVersion), /* harmony export */ "floatVersion": () => (/* binding */ floatVersion),
/* harmony export */ "hashFile": () => (/* binding */ hashFile), /* harmony export */ "hashFile": () => (/* binding */ hashFile),
/* harmony export */ "supportedPlatforms": () => (/* binding */ supportedPlatforms),
/* harmony export */ "getVirtualEnvironmentName": () => (/* binding */ getVirtualEnvironmentName), /* harmony export */ "getVirtualEnvironmentName": () => (/* binding */ getVirtualEnvironmentName),
/* harmony export */ "shouldUseToolCache": () => (/* binding */ shouldUseToolCache), /* harmony export */ "shouldUseToolCache": () => (/* binding */ shouldUseToolCache),
/* harmony export */ "getToolCacheRubyPrefix": () => (/* binding */ getToolCacheRubyPrefix), /* harmony export */ "getToolCacheRubyPrefix": () => (/* binding */ getToolCacheRubyPrefix),
@@ -366,6 +367,15 @@ function getImageOS() {
return imageOS return imageOS
} }
const supportedPlatforms = [
'ubuntu-18.04',
'ubuntu-20.04',
'macos-10.15',
'macos-11.0',
'windows-2019',
'windows-2022',
]
function getVirtualEnvironmentName() { function getVirtualEnvironmentName() {
const imageOS = getImageOS() const imageOS = getImageOS()
@@ -59565,6 +59575,10 @@ const releasesURL = 'https://github.com/ruby/ruby-builder/releases'
const windows = common.windows const windows = common.windows
function getAvailableVersions(platform, engine) { function getAvailableVersions(platform, engine) {
if (!common.supportedPlatforms.includes(platform)) {
throw new Error(`Unsupported platform ${platform}`)
}
return rubyBuilderVersions[engine] return rubyBuilderVersions[engine]
} }
@@ -59747,6 +59761,10 @@ const msysPathEntries = [`${msys1}\\mingw\\x86_64-w64-mingw32\\bin`, `${msys1}\\
const virtualEnv = common.getVirtualEnvironmentName() const virtualEnv = common.getVirtualEnvironmentName()
function getAvailableVersions(platform, engine) { function getAvailableVersions(platform, engine) {
if (!common.supportedPlatforms.includes(platform)) {
throw new Error(`Unsupported platform ${platform}`)
}
if (engine === 'ruby') { if (engine === 'ruby') {
return Object.keys(rubyInstallerVersions) return Object.keys(rubyInstallerVersions)
} else { } else {
@@ -60315,7 +60333,7 @@ async function setupRuby(options = {}) {
const [engine, parsedVersion] = parseRubyEngineAndVersion(inputs['ruby-version']) const [engine, parsedVersion] = parseRubyEngineAndVersion(inputs['ruby-version'])
let installer let installer
if (platform.startsWith('windows-') && engine !== 'jruby') { if (platform.startsWith('windows-') && engine === 'ruby') {
installer = __nccwpck_require__(3216) installer = __nccwpck_require__(3216)
} else { } else {
installer = __nccwpck_require__(9974) installer = __nccwpck_require__(9974)
+1 -1
View File
@@ -42,7 +42,7 @@ export async function setupRuby(options = {}) {
const [engine, parsedVersion] = parseRubyEngineAndVersion(inputs['ruby-version']) const [engine, parsedVersion] = parseRubyEngineAndVersion(inputs['ruby-version'])
let installer let installer
if (platform.startsWith('windows-') && engine !== 'jruby') { if (platform.startsWith('windows-') && engine === 'ruby') {
installer = require('./windows') installer = require('./windows')
} else { } else {
installer = require('./ruby-builder') installer = require('./ruby-builder')
+4
View File
@@ -13,6 +13,10 @@ const releasesURL = 'https://github.com/ruby/ruby-builder/releases'
const windows = common.windows const windows = common.windows
export function getAvailableVersions(platform, engine) { export function getAvailableVersions(platform, engine) {
if (!common.supportedPlatforms.includes(platform)) {
throw new Error(`Unsupported platform ${platform}`)
}
return rubyBuilderVersions[engine] return rubyBuilderVersions[engine]
} }
+4
View File
@@ -25,6 +25,10 @@ const msysPathEntries = [`${msys1}\\mingw\\x86_64-w64-mingw32\\bin`, `${msys1}\\
const virtualEnv = common.getVirtualEnvironmentName() const virtualEnv = common.getVirtualEnvironmentName()
export function getAvailableVersions(platform, engine) { export function getAvailableVersions(platform, engine) {
if (!common.supportedPlatforms.includes(platform)) {
throw new Error(`Unsupported platform ${platform}`)
}
if (engine === 'ruby') { if (engine === 'ruby') {
return Object.keys(rubyInstallerVersions) return Object.keys(rubyInstallerVersions)
} else { } else {