Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence deprecation warning for react-native dependency. #34368

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions scripts/cocoapods/__tests__/codegen_utils-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def testGetCodegenConfigFromFile_whenFileDoesNotExists_returnEmpty
codegen = CodegenUtils.new().get_codegen_config_from_file('package.json', 'codegenConfig')

# Assert
assert_equal(codegen, {'libraries' => []})
assert_equal(codegen, {})
end

def testGetCodegenConfigFromFile_whenFileExistsButHasNoKey_returnEmpty
Expand All @@ -137,7 +137,7 @@ def testGetCodegenConfigFromFile_whenFileExistsButHasNoKey_returnEmpty
codegen = CodegenUtils.new().get_codegen_config_from_file('package.json', 'codegen')

# Assert
assert_equal(codegen, {'libraries' => []})
assert_equal(codegen, {})
end

def testGetCodegenConfigFromFile_whenFileExistsAndHasKey_returnObject
Expand Down Expand Up @@ -213,19 +213,6 @@ def testGetListOfJSSpecs_whenDoesNotUsesLibraries_returnAListOfFiles
])
end

def testGetListOfJSSpecs_whenMisconfigured_aborts
# Arrange
app_codegen_config = {}
app_path = "~/MyApp/"
# Act
assert_raises() {
files = CodegenUtils.new().get_list_of_js_specs(app_codegen_config, app_path)
}
# Assert
assert_equal(Pod::UI.collected_warns , ["[Error] Codegen not properly configured. Please add the `codegenConfig` entry to your `package.json`"])

end

# ================================== #
# Test - GetReactCodegenScriptPhases #
# ================================== #
Expand Down
5 changes: 1 addition & 4 deletions scripts/cocoapods/codegen_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def get_react_codegen_spec(package_json_file, folly_version: '2021.07.22.00', fa
#
# Returns: the list of dependencies as extracted from the package.json
def get_codegen_config_from_file(config_path, config_key)
empty = {'libraries' => []}
empty = {}
if !File.exist?(config_path)
return empty
end
Expand Down Expand Up @@ -159,9 +159,6 @@ def get_list_of_js_specs(app_codegen_config, app_path)
elsif app_codegen_config['jsSrcsDir'] then
codegen_dir = File.join(app_path, app_codegen_config['jsSrcsDir'])
file_list.concat (Finder.find_codegen_file(codegen_dir))
else
Pod::UI.warn '[Error] Codegen not properly configured. Please add the `codegenConfig` entry to your `package.json`'
abort
end

input_files = file_list.map { |filename| "${PODS_ROOT}/../#{Pathname.new(filename).realpath().relative_path_from(Pod::Config.instance.installation_root)}" }
Expand Down
71 changes: 39 additions & 32 deletions scripts/codegen/generate-artifacts-executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,44 @@ function readPackageJSON(appRootDir) {
return JSON.parse(fs.readFileSync(path.join(appRootDir, 'package.json')));
}

function printDeprecationWarningIfNeeded(dependency) {
if (dependency === REACT_NATIVE_DEPENDENCY_NAME) {
return;
}
console.log(`[Codegen] CodegenConfig Deprecated Setup for ${dependency}.
The configuration file still contains the codegen in the libraries array.
If possible, replace it with a single object.
`);
console.debug(`BEFORE:
{
// ...
"codegenConfig": {
"libraries": [
{
"name": "libName1",
"type": "all|components|modules",
"jsSrcsRoot": "libName1/js"
},
{
"name": "libName2",
"type": "all|components|modules",
"jsSrcsRoot": "libName2/src"
}
]
}
}

AFTER:
{
"codegenConfig": {
"name": "libraries",
"type": "all",
"jsSrcsRoot": "."
}
}
`);
}

// Reading Libraries
function extractLibrariesFromConfigurationArray(
configFile,
Expand Down Expand Up @@ -102,38 +140,7 @@ function extractLibrariesFromJSON(
libraryPath: dependencyPath,
});
} else {
console.log(`[Codegen] CodegenConfig Deprecated Setup for ${dependency}.
The configuration file still contains the codegen in the libraries array.
If possible, replace it with a single object.
`);
console.debug(`BEFORE:
{
// ...
"codegenConfig": {
"libraries": [
{
"name": "libName1",
"type": "all|components|modules",
"jsSrcsRoot": "libName1/js"
},
{
"name": "libName2",
"type": "all|components|modules",
"jsSrcsRoot": "libName2/src"
}
]
}
}

AFTER:
{
"codegenConfig": {
"name": "libraries",
"type": "all",
"jsSrcsRoot": "."
}
}
`);
printDeprecationWarningIfNeeded(dependency);
extractLibrariesFromConfigurationArray(
configFile,
codegenConfigKey,
Expand Down