initial commit taken from gitlab.lrz.de

This commit is contained in:
privatereese
2018-08-24 18:09:42 +02:00
parent ae54ed4c48
commit fc05486403
28494 changed files with 2159823 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const toCamelCase = require('lodash').camelCase;
module.exports = function applyParams(str, params, prefix) {
return str.replace(
/\$\{(\w+)\}/g,
(pattern, param) => {
const name = toCamelCase(prefix) + '_' + param;
return params[param]
? `getResources().getString(R.string.${name})`
: null;
}
);
};

View File

@@ -0,0 +1,15 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const fs = require('fs');
module.exports = function applyPatch(file, patch) {
fs.writeFileSync(file, fs
.readFileSync(file, 'utf8')
.replace(patch.pattern, match => `${match}${patch.patch}`)
);
};

View File

@@ -0,0 +1,18 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
module.exports = function makeBuildPatch(name) {
const installPattern = new RegExp(
`\\s{4}(compile)(\\(|\\s)(project)\\(\\\':${name}\\\'\\)(\\)|\\s)`
);
return {
installPattern,
pattern: /[^ \t]dependencies {\n/,
patch: ` compile project(':${name}')\n`
};
};

View File

@@ -0,0 +1,13 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
module.exports = function makeImportPatch(packageImportPath) {
return {
pattern: 'import com.facebook.react.ReactApplication;',
patch: '\n' + packageImportPath,
};
};

View File

@@ -0,0 +1,17 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const applyParams = require('./applyParams');
module.exports = function makePackagePatch(packageInstance, params, prefix) {
const processedInstance = applyParams(packageInstance, params, prefix);
return {
pattern: 'new MainReactPackage()',
patch: ',\n ' + processedInstance,
};
};

View File

@@ -0,0 +1,33 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const path = require('path');
const isWin = process.platform === 'win32';
module.exports = function makeSettingsPatch(name, androidConfig, projectConfig) {
var projectDir = path.relative(
path.dirname(projectConfig.settingsGradlePath),
androidConfig.sourceDir
);
/*
* Fix for Windows
* Backslashes is the escape character and will result in
* an invalid path in settings.gradle
* https://github.com/rnpm/rnpm/issues/113
*/
if (isWin) {
projectDir = projectDir.replace(/\\/g, '/');
}
return {
pattern: '\n',
patch: `include ':${name}'\n` +
`project(':${name}').projectDir = ` +
`new File(rootProject.projectDir, '${projectDir}')\n`,
};
};

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const toCamelCase = require('lodash').camelCase;
module.exports = function makeStringsPatch(params, prefix) {
const values = Object.keys(params)
.map(param => {
const name = toCamelCase(prefix) + '_' + param;
return ' ' +
`<string moduleConfig="true" name="${name}">${params[param]}</string>`;
});
const patch = values.length > 0
? values.join('\n') + '\n'
: '';
return {
pattern: '<resources>\n',
patch,
};
};

View File

@@ -0,0 +1,15 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const fs = require('fs');
module.exports = function revokePatch(file, patch) {
fs.writeFileSync(file, fs
.readFileSync(file, 'utf8')
.replace(patch.patch, '')
);
};