Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
grabbou committed Mar 20, 2019
1 parent 4f17675 commit 32da7cf
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/commands/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @format
*/
import loadConfig from '../../tools/loadConfig';
import loadConfig from '../../tools/config';

export default {
name: 'config',
Expand Down
38 changes: 38 additions & 0 deletions packages/cli/src/tools/android/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,41 @@ export function dependencyConfig(folder, userConfig = {}) {

return {sourceDir, folder, manifest, packageImportPath, packageInstance};
}

/**
* New version of getDependencyConfig
*/
export function getDependencyConfig(folder, userConfig) {
const src = userConfig.sourceDir || findAndroidAppFolder(folder);

if (!src) {
return null;
}

const sourceDir = path.join(folder, src);
const manifestPath = userConfig.manifestPath
? path.join(sourceDir, userConfig.manifestPath)
: findManifest(sourceDir);

if (!manifestPath) {
return null;
}

const manifest = readManifest(manifestPath);
const packageName = userConfig.packageName || getPackageName(manifest);
const packageClassName =
userConfig.packageClassName || findPackageClassName(sourceDir);

/**
* This module has no package to export
*/
if (!packageClassName) {
return null;
}

const packageImportPath = `import ${packageName}.${packageClassName};`;

const packageInstance = `new ${packageClassName}()`;

return {packageImportPath, packageInstance};
}
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import path from 'path';
import merge from 'deepmerge';
import {get} from 'lodash';

import getPlatforms from './getPlatforms';
import getProjectDependencies from '../commands/link/getProjectDependencies';
import getProjectDependencies from '../../commands/link/getProjectDependencies';

const explorer = comsmiconfig('react-native');

Expand Down Expand Up @@ -43,11 +42,16 @@ function readConfigFromDisk(root: string) {
return config;
}

/**
* Loads default CLI configuration
*/
function getDefaultConfig(config: Config, root: string) {
const platforms = getPlatforms(root);
const platforms = {
ios: {
getDependencyConfig: require('../ios').getDependencyConfig,
},
android: {
getDependencyConfig: require('../android').getDependencyConfig,
},
...config.platforms,
};

const dependencies = getProjectDependencies(root).reduce(
(deps, dependency) => {
Expand All @@ -64,16 +68,16 @@ function getDefaultConfig(config: Config, root: string) {
if (dependencyPlatformConfig === null) {
return acc;
}
const detectedConfig = platforms[platform].dependencyConfig(
const detectedConfig = platforms[platform].getDependencyConfig(
folder,
dependencyPlatformConfig,
);
if (detectedConfig === null) {
return acc;
}
acc[platform] = {
...dependencyPlatformConfig,
...detectedConfig,
...dependencyPlatformConfig,
};
return acc;
},
Expand Down
9 changes: 9 additions & 0 deletions packages/cli/src/tools/ios/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,12 @@ export function projectConfig(folder, userConfig) {
}

export const dependencyConfig = projectConfig;

/**
* New version of `ios` configuration
*/
export function getDependencyConfig(folder) {
return {
podspec: findPodspecName(folder),
};
}

0 comments on commit 32da7cf

Please sign in to comment.