amis-rpc-design/node_modules/@react-native-community/cli-doctor/build/tools/healthchecks/ruby.js.map

1 line
9.3 KiB
Plaintext
Raw Normal View History

2023-10-07 19:42:30 +08:00
{"version":3,"names":["output","OK","NO_GEMFILE","NO_RUBY","BUNDLE_INVALID_RUBY","UNKNOWN","checkRubyGemfileRequirement","projectRoot","evaluateGemfile","inline","execa","cwd","e","code","stderr","message","label","isRequired","description","getDiagnostics","Languages","findProjectRoot","logger","debug","fallbackResult","needsToBeFixed","doesSoftwareNeedToBeFixed","version","Ruby","versionRange","versionRanges","RUBY","versionOrError","chalk","bold","dim","warn","runAutomaticFix","loader","logManualInstallation","fail","healthcheck","url","link","docs","hash","guide","platform"],"sources":["../../../src/tools/healthchecks/ruby.ts"],"sourcesContent":["import execa from 'execa';\nimport chalk from 'chalk';\n\nimport {logger, findProjectRoot, link} from '@react-native-community/cli-tools';\n\nimport versionRanges from '../versionRanges';\nimport {doesSoftwareNeedToBeFixed} from '../checkInstallation';\nimport {HealthCheckInterface} from '../../types';\nimport {inline} from './common';\n\n// Exposed for testing only\nexport const output = {\n OK: 'Ok',\n NO_GEMFILE: 'No Gemfile',\n NO_RUBY: 'No Ruby',\n BUNDLE_INVALID_RUBY: 'Bundle invalid Ruby',\n UNKNOWN: 'Unknown',\n} as const;\n\n// The Change:\n// -----------\n//\n// React Native 0.72 primarily defines the compatible version of Ruby in the\n// project's Gemfile [1]. It does this because it allows for ranges instead of\n// pinning to a version of Ruby.\n//\n// In previous versions the .ruby-version file defined the compatible version,\n// and it was derived in the Gemfile [2]:\n//\n// > ruby File.read(File.join(__dir__, '.ruby-version')).strip\n//\n// Why all of the changes with Ruby?\n// ---------------------------------\n//\n// React Native has had to weigh up a couple of concerns:\n//\n// - Cocoapods: we don't control the minimum supported version, although that\n// was defined almost a decade ago [3]. Practically system Ruby on macOS works\n// for our users.\n//\n// - Apple may drop support for scripting language runtimes in future version of\n// macOS [4]. Ruby 2.7 is effectively EOL, which means many supporting tools and\n// developer environments _may_ not support it going forward, and 3.0 is becoming\n// the default in, for example, places like our CI. Some users may be unable to\n// install Ruby 2.7 on their devices as a matter of policy.\n//\n// - Our Codegen is extensively built in Ruby 2.7.\n//\n// - A common pain-point for users (old and new) setting up their environment is\n// configuring a Ruby version manager or managing multiple Ruby versions on their\n// device. This occurs so frequently that we've removed the step from our docs [6]\n//\n// After users suggested bumping Ruby to 3.1.3 [5], a discussion concluded that\n// allowing a range of version of Ruby (>= 2.6.10) was the best way forward. This\n// balanced the need to make the platform easier to start with, but unblocked more\n// sophisticated users.\n//\n// [1] https://github.com/facebook/react-native/pull/36281\n// [2] https://github.com/facebook/react-native/blob/v0.71.3/Gemfile#L4\n// [3] https://github.com/CocoaPods/guides.cocoapods.org/commit/30881800ac2bd431d9c5d7ee74404b13e7f43888\n// [4] https://developer.apple.com/documentation/macos-release-notes/macos-catalina-10_15-release-notes#Scripting-Language-Runtimes\n// [5] https://github.com/facebook/react-native/pull/36074\n// [6] https://github.com/facebook/react-native-website/commit/8db97602347a8623f21e3e516245d04bdf6f1a29\n\nasync function checkRubyGemfileRequirement(\n projectRoot: string,\n): Promise<[string, string?]> {\n const evaluateGemfile = inline`\n require \"Bundler\"\n gemfile = Bundler::Definition.build(\"Gemfile\", nil, {})\n version = gemfile.ruby_version.engine_versions.join(\", \")\n begin\n gemfile.validate_runtime!\n rescue Bundler::GemfileNotFound\n puts \"${output.NO_GEMFILE}\"\n exit 1\n rescue Bundler::RubyVersionMismatch\n puts \"${output.BUNDLE_INVALID_RUBY}\"\n STDERR.puts version\n exit 2\n rescue => e\n STDERR e.message\n exit 3\n else\n puts \"${output.OK