chore: update map
This commit is contained in:
+17
-53
@@ -13,9 +13,8 @@ def find_config()
|
||||
:react_native_minor_version => nil,
|
||||
:is_tvos_target => nil,
|
||||
:react_native_node_modules_dir => nil,
|
||||
:reanimated_node_modules_dir => nil,
|
||||
:react_native_common_dir => nil,
|
||||
:dynamic_frameworks_reanimated_dir => nil,
|
||||
:dynamic_frameworks_worklets_dir => nil,
|
||||
}
|
||||
|
||||
react_native_node_modules_dir = File.join(File.dirname(`cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('react-native/package.json')"`), '..')
|
||||
@@ -31,13 +30,7 @@ def find_config()
|
||||
raise '[Reanimated] Unable to recognize your `react-native` version. Please set environmental variable with `react-native` location: `export REACT_NATIVE_NODE_MODULES_DIR="<path to react-native>" && pod install`.'
|
||||
end
|
||||
|
||||
validate_worklets_script = File.expand_path(File.join(__dir__, 'validate-worklets-build.js'))
|
||||
unless system("node \"#{validate_worklets_script}\"")
|
||||
abort("[Reanimated] Failed to validate worklets version")
|
||||
end
|
||||
|
||||
|
||||
result[:is_reanimated_example_app] = ENV["IS_REANIMATED_EXAMPLE_APP"] != nil
|
||||
result[:is_reanimated_example_app] = ENV["REANIMATED_EXAMPLE_APP_NAME"] != nil
|
||||
result[:is_tvos_target] = react_native_json['name'] == 'react-native-tvos'
|
||||
result[:react_native_version] = react_native_json['version']
|
||||
result[:react_native_minor_version] = react_native_json['version'].split('.')[1].to_i
|
||||
@@ -45,59 +38,30 @@ def find_config()
|
||||
result[:react_native_minor_version] = 1000
|
||||
end
|
||||
result[:react_native_node_modules_dir] = File.expand_path(react_native_node_modules_dir)
|
||||
result[:reanimated_node_modules_dir] = File.expand_path(File.join(__dir__, '..', '..'))
|
||||
|
||||
pods_root = Pod::Config.instance.project_pods_root
|
||||
react_native_common_dir_absolute = File.join(react_native_node_modules_dir, 'react-native', 'ReactCommon')
|
||||
react_native_common_dir_relative = Pathname.new(react_native_common_dir_absolute).relative_path_from(pods_root).to_s
|
||||
result[:react_native_common_dir] = react_native_common_dir_relative
|
||||
|
||||
react_native_reanimated_dir_absolute = File.join(__dir__, '..')
|
||||
react_native_reanimated_dir_relative = Pathname.new(react_native_reanimated_dir_absolute).relative_path_from(pods_root).to_s
|
||||
result[:dynamic_frameworks_reanimated_dir] = react_native_reanimated_dir_relative
|
||||
|
||||
react_native_worklets_node_modules_dir = File.join(File.dirname(`cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('react-native-worklets/package.json')"`), '..')
|
||||
react_native_worklets_dir_absolute = File.join(react_native_worklets_node_modules_dir, 'react-native-worklets')
|
||||
react_native_worklets_dir_relative = Pathname.new(react_native_worklets_dir_absolute).relative_path_from(pods_root).to_s
|
||||
result[:dynamic_frameworks_worklets_dir] = react_native_worklets_dir_relative
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
def assert_latest_react_native_with_new_architecture(config, reanimated_package_json)
|
||||
reanimated_version = reanimated_package_json['version']
|
||||
reanimated_major_version = reanimated_version.split('.')[0].to_i
|
||||
react_native_minor_version = config[:react_native_minor_version]
|
||||
fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
|
||||
if fabric_enabled && reanimated_major_version == 3 && react_native_minor_version < 72
|
||||
# If you change the minimal React Native version remember to update Compatibility Table in docs
|
||||
raise "[Reanimated] Outdated version of React Native for New Architecture. Reanimated " + reanimated_version + " supports the New Architecture on React Native 0.72.0+. See https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooting#outdated-version-of-react-native-for-new-architecture for more information."
|
||||
end
|
||||
end
|
||||
|
||||
def assert_minimal_react_native_version(config)
|
||||
validate_react_native_version_script = File.expand_path(File.join(__dir__, 'validate-react-native-version.js'))
|
||||
unless system("node \"#{validate_react_native_version_script}\" #{config[:react_native_version]}")
|
||||
raise "[Reanimated] React Native version is not compatible with Reanimated"
|
||||
if config[:react_native_minor_version] < 66
|
||||
# If you change the minimal React Native version remember to update Compatibility Table in docs
|
||||
raise "[Reanimated] Unsupported React Native version. Please use 0.66 or newer."
|
||||
end
|
||||
end
|
||||
|
||||
def assert_new_architecture_enabled(new_arch_enabled)
|
||||
if !new_arch_enabled
|
||||
raise "[Reanimated] Reanimated requires the New Architecture to be enabled. If you have `RCT_NEW_ARCH_ENABLED=0` set in your environment you should remove it."
|
||||
end
|
||||
end
|
||||
|
||||
def get_static_feature_flags()
|
||||
feature_flags = {}
|
||||
|
||||
static_feature_flags_path = File.path('./src/featureFlags/staticFlags.json')
|
||||
if !File.exist?(static_feature_flags_path)
|
||||
raise "[Reanimated] Feature flags file not found at #{static_feature_flags_path}."
|
||||
end
|
||||
static_feature_flags_json = JSON.parse(File.read(static_feature_flags_path))
|
||||
static_feature_flags_json.each do |key, value|
|
||||
feature_flags[key] = value.to_s
|
||||
end
|
||||
|
||||
package_json_path = File.join(Pod::Config.instance.installation_root.to_s, '..', 'package.json')
|
||||
if File.exist?(package_json_path)
|
||||
package_json = JSON.parse(File.read(package_json_path))
|
||||
if package_json['reanimated'] && package_json['reanimated']['staticFeatureFlags']
|
||||
feature_flags_json = package_json['reanimated']['staticFeatureFlags']
|
||||
feature_flags_json.each do |key, value|
|
||||
feature_flags[key] = value.to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return feature_flags.map { |key, value| "[#{key}:#{value}]" }.join('')
|
||||
end
|
||||
|
||||
Generated
Vendored
-43
@@ -1,43 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const semverSatisfies = require('semver/functions/satisfies');
|
||||
const semverPrerelease = require('semver/functions/prerelease');
|
||||
const path = require('path');
|
||||
|
||||
const packageJsonPath = path.resolve(__dirname, '../package.json');
|
||||
const packageJson = require(packageJsonPath);
|
||||
const reanimatedVersion = packageJson.version;
|
||||
const compatibilityFile = require('../compatibility.json');
|
||||
|
||||
const reactNativeVersion = process.argv[2];
|
||||
const supportedRNVersions = [];
|
||||
|
||||
if (semverPrerelease(reactNativeVersion)) {
|
||||
// Don't perform any checks for pre-release versions, like nightlies or
|
||||
// feature previews. The user knows what they're doing.
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
for (const key in compatibilityFile) {
|
||||
if (semverSatisfies(reanimatedVersion, key)) {
|
||||
// @ts-ignore
|
||||
supportedRNVersions.push(...compatibilityFile[key]['react-native']);
|
||||
}
|
||||
}
|
||||
|
||||
// If user uses a version of Reanimated that is not listed in the compatibility file, we skip the check
|
||||
if (supportedRNVersions.length === 0) {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
for (const version of supportedRNVersions) {
|
||||
if (semverSatisfies(reactNativeVersion, `${version}.x`)) {
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line reanimated/use-logger
|
||||
console.error(
|
||||
`[Reanimated] React Native ${reactNativeVersion} version is not compatible with Reanimated ${reanimatedVersion}`
|
||||
);
|
||||
process.exit(1);
|
||||
Generated
Vendored
-17
@@ -1,17 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
// We don't use this script in runtime since `process` might not be available.
|
||||
|
||||
const path = require('path');
|
||||
const packageJsonPath = path.resolve(__dirname, '../package.json');
|
||||
const packageJson = require(packageJsonPath);
|
||||
const reanimatedVersion = packageJson.version;
|
||||
|
||||
const validateVersion = require('./validate-worklets-version');
|
||||
|
||||
const result = validateVersion(reanimatedVersion);
|
||||
if (!result.ok) {
|
||||
// eslint-disable-next-line reanimated/use-logger
|
||||
console.error('[Reanimated] ' + result.message);
|
||||
process.exit(1);
|
||||
}
|
||||
Generated
Vendored
-63
@@ -1,63 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const semverSatisfies = require('semver/functions/satisfies');
|
||||
const semverPrerelease = require('semver/functions/prerelease');
|
||||
const expectedVersion = require('./worklets-version.json');
|
||||
const compatibilityFile = require('../compatibility.json');
|
||||
|
||||
/** @returns {{ ok: boolean; message?: string }} */
|
||||
function validateVersion(reanimatedVersion) {
|
||||
let workletsVersion;
|
||||
try {
|
||||
const { version } = require('react-native-worklets/package.json');
|
||||
workletsVersion = version;
|
||||
} catch (_e) {
|
||||
return {
|
||||
ok: false,
|
||||
message:
|
||||
"react-native-worklets package isn't installed. Please install a version between " +
|
||||
expectedVersion.min +
|
||||
' and ' +
|
||||
expectedVersion.max +
|
||||
' to use Reanimated ' +
|
||||
reanimatedVersion +
|
||||
'.',
|
||||
};
|
||||
}
|
||||
|
||||
if (semverPrerelease(workletsVersion)) {
|
||||
/**
|
||||
* Don't perform any checks for pre-release versions, like nightlies or
|
||||
* feature previews. The user knows what they're doing.
|
||||
*/
|
||||
return { ok: true };
|
||||
}
|
||||
|
||||
const supportedWorkletsVersions = [];
|
||||
|
||||
for (const key in compatibilityFile) {
|
||||
if (semverSatisfies(reanimatedVersion, key)) {
|
||||
// @ts-ignore
|
||||
supportedWorkletsVersions.push(
|
||||
...compatibilityFile[key]['react-native-worklets']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (supportedWorkletsVersions.length === 0) {
|
||||
return { ok: true };
|
||||
}
|
||||
|
||||
for (const version of supportedWorkletsVersions) {
|
||||
if (semverSatisfies(workletsVersion, version)) {
|
||||
return { ok: true };
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
ok: false,
|
||||
message: `Invalid version of \`react-native-worklets\`: "${workletsVersion}". Expected the version to be in inclusive range "${supportedWorkletsVersions.join(', ')}". Please install a compatible version of \`react-native-worklets\`.`,
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = validateVersion;
|
||||
Generated
Vendored
-4
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"min": "0.4.0",
|
||||
"max": "0.4"
|
||||
}
|
||||
Reference in New Issue
Block a user