Skip to content

Commit

Permalink
Refactor generate-artifacts-executor.js: various cleanups (#41528)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #41528

This diff makes some minor cleanups in `generate-artifacts-executor.js`. Specifically:
1. remove unused argument `iosOutputDir`
2. remove unused `libraryConfig.library` property
3. Fix typo in `handleReactNativeCo`**r**`eLibraries` function name

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D51115394

fbshipit-source-id: 8ee9b5f35cf254510714a023dab32077c700e061
  • Loading branch information
dmytrorykun authored and facebook-github-bot committed Nov 20, 2023
1 parent 0056fc8 commit 6321371
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ describe('extractLibrariesFromJSON', () => {
);
expect(libraries.length).toBe(1);
expect(libraries[0]).toEqual({
library: 'my-app',
config: {
name: 'AppModules',
type: 'all',
Expand Down Expand Up @@ -155,7 +154,6 @@ describe('extractLibrariesFromJSON', () => {
);
expect(libraries.length).toBe(1);
expect(libraries[0]).toEqual({
library: reactNativeDependencyName,
config: {
name: 'react-native',
type: 'all',
Expand All @@ -179,7 +177,6 @@ describe('extractLibrariesFromJSON', () => {
);
expect(libraries.length).toBe(3);
expect(libraries[0]).toEqual({
library: myDependency,
config: {
name: 'react-native',
type: 'all',
Expand All @@ -188,7 +185,6 @@ describe('extractLibrariesFromJSON', () => {
libraryPath: myDependencyPath,
});
expect(libraries[1]).toEqual({
library: myDependency,
config: {
name: 'my-component',
type: 'components',
Expand All @@ -197,7 +193,6 @@ describe('extractLibrariesFromJSON', () => {
libraryPath: myDependencyPath,
});
expect(libraries[2]).toEqual({
library: myDependency,
config: {
name: 'my-module',
type: 'module',
Expand Down Expand Up @@ -272,12 +267,10 @@ describe('findCodegenEnabledLibraries', () => {

expect(libraries).toEqual([
{
library: 'react-native',
config: {},
libraryPath: baseCodegenConfigFileDir,
},
{
library: 'react-native-foo',
config: {name: 'RNFooSpec', type: 'modules', jsSrcsDir: 'src'},
libraryPath: path.join(projectDir, 'library-foo'),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,10 @@ function extractLibrariesFromConfigurationArray(
configFile,
codegenConfigKey,
libraries,
dependency,
dependencyPath,
) {
console.log(`[Codegen] Found ${dependency}`);
configFile[codegenConfigKey].libraries.forEach(config => {
const libraryConfig = {
library: dependency,
config,
libraryPath: dependencyPath,
};
Expand Down Expand Up @@ -142,11 +139,10 @@ function extractLibrariesFromJSON(
return;
}

console.log(`[Codegen] Found ${dependency}`);
if (configFile[codegenConfigKey].libraries == null) {
console.log(`[Codegen] Found ${dependency}`);
var config = configFile[codegenConfigKey];
libraries.push({
library: dependency,
config,
libraryPath: dependencyPath,
});
Expand All @@ -156,13 +152,12 @@ function extractLibrariesFromJSON(
configFile,
codegenConfigKey,
libraries,
dependency,
dependencyPath,
);
}
}

function handleReactNativeCodeLibraries(
function handleReactNativeCoreLibraries(
libraries,
codegenConfigFilename,
codegenConfigKey,
Expand Down Expand Up @@ -397,7 +392,7 @@ function generateNativeCodegenFiles(
});
}

function createComponentProvider(schemaPaths, node, iosOutputDir) {
function createComponentProvider(schemaPaths, node) {
console.log('\n\n>>>>> Creating component provider');
// Save the list of spec paths to a temp file.
const schemaListTmpPath = `${os.tmpdir()}/rn-tmp-schema-list.json`;
Expand Down Expand Up @@ -440,7 +435,7 @@ function findCodegenEnabledLibraries(
const dependencies = {...pkgJson.dependencies, ...pkgJson.devDependencies};
const libraries = [];

handleReactNativeCodeLibraries(
handleReactNativeCoreLibraries(
libraries,
codegenConfigFilename,
codegenConfigKey,
Expand Down Expand Up @@ -554,7 +549,7 @@ function execute(
schemaPaths,
);

createComponentProvider(schemaPaths, node, iosOutputDir);
createComponentProvider(schemaPaths, node);
cleanupEmptyFilesAndFolders(iosOutputDir);
} catch (err) {
console.error(err);
Expand Down

0 comments on commit 6321371

Please sign in to comment.