2018-02-09 01:10:29 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2018-02-09 01:10:29 +00:00
|
|
|
*/
|
|
|
|
|
2016-05-20 11:52:08 +00:00
|
|
|
const fs = require('fs');
|
2016-06-03 16:05:14 +00:00
|
|
|
const toCamelCase = require('lodash').camelCase;
|
2016-05-20 11:52:08 +00:00
|
|
|
|
|
|
|
const revokePatch = require('./patches/revokePatch');
|
|
|
|
const makeSettingsPatch = require('./patches/makeSettingsPatch');
|
|
|
|
const makeBuildPatch = require('./patches/makeBuildPatch');
|
|
|
|
const makeStringsPatch = require('./patches/makeStringsPatch');
|
2016-07-30 15:59:16 +00:00
|
|
|
const makeImportPatch = require('./patches/makeImportPatch');
|
|
|
|
const makePackagePatch = require('./patches/makePackagePatch');
|
2016-05-20 11:52:08 +00:00
|
|
|
|
|
|
|
module.exports = function unregisterNativeAndroidModule(
|
|
|
|
name,
|
|
|
|
androidConfig,
|
|
|
|
projectConfig
|
|
|
|
) {
|
|
|
|
const buildPatch = makeBuildPatch(name);
|
|
|
|
const strings = fs.readFileSync(projectConfig.stringsPath, 'utf8');
|
|
|
|
var params = {};
|
|
|
|
|
|
|
|
strings.replace(
|
|
|
|
/moduleConfig="true" name="(\w+)">(.*)</g,
|
|
|
|
(_, param, value) => {
|
|
|
|
params[param.slice(toCamelCase(name).length + 1)] = value;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
revokePatch(
|
|
|
|
projectConfig.settingsGradlePath,
|
|
|
|
makeSettingsPatch(name, androidConfig, projectConfig)
|
|
|
|
);
|
|
|
|
|
|
|
|
revokePatch(projectConfig.buildGradlePath, buildPatch);
|
|
|
|
revokePatch(projectConfig.stringsPath, makeStringsPatch(params, name));
|
|
|
|
|
|
|
|
revokePatch(
|
2016-07-16 17:52:38 +00:00
|
|
|
projectConfig.mainFilePath,
|
2016-05-20 11:52:08 +00:00
|
|
|
makePackagePatch(androidConfig.packageInstance, params, name)
|
|
|
|
);
|
|
|
|
|
|
|
|
revokePatch(
|
2016-07-16 17:52:38 +00:00
|
|
|
projectConfig.mainFilePath,
|
2016-05-20 11:52:08 +00:00
|
|
|
makeImportPatch(androidConfig.packageImportPath)
|
|
|
|
);
|
|
|
|
};
|