-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from CanalTP/release/2.2.0
Release/2.2.0
- Loading branch information
Showing
5 changed files
with
163 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
module.exports = function(ctx) { | ||
var fs = require('fs'); | ||
var os = require('os'); | ||
var package; | ||
try { | ||
package = require(ctx.opts.projectRoot + '/package.json'); | ||
} catch (err) { } | ||
|
||
var PLUGIN_ID = ctx.opts.plugin.id; | ||
|
||
var _getPreferenceValue = function(key) { | ||
if (package && package.cordova && package.cordova.plugins && package.cordova.plugins[PLUGIN_ID] && package.cordova.plugins[PLUGIN_ID][key]) { | ||
return package.cordova.plugins[PLUGIN_ID][key]; | ||
} | ||
|
||
var config = fs.readFileSync('config.xml').toString(); | ||
var confValue = config.match(new RegExp(`"${PLUGIN_ID}"(.(?!<\/plugin>))*?<variable name="${key}" value="(.*?)".*?<\/plugin>`, 'is')); | ||
if (confValue && confValue[2]) { | ||
return confValue[2]; | ||
} else { | ||
var defaultPreferences = ctx.opts.plugin.pluginInfo.getPreferences(); | ||
return defaultPreferences[key] || null; | ||
} | ||
} | ||
|
||
if (ctx.opts.platforms.includes('android')) { | ||
// Android platform: add the authentification informations into the gradle.properties file in the project | ||
var gradlePropertiesPath = './platforms/android/gradle.properties'; | ||
var gradleProperties = fs.readFileSync(gradlePropertiesPath); | ||
gradleProperties = gradleProperties.toString(); | ||
if (gradleProperties) { | ||
gradleProperties = gradleProperties.toString(); | ||
if (!gradleProperties.match('kisio_artifactory_url')) { | ||
gradleProperties += `\nkisio_artifactory_url=${_getPreferenceValue('ARTIFACTORY_URL')}`; | ||
gradleProperties += `\nkisio_artifactory_username=${_getPreferenceValue('ARTIFACTORY_USERNAME')}`; | ||
gradleProperties += `\nkisio_artifactory_password=${_getPreferenceValue('ARTIFACTORY_PASSWORD')}`; | ||
gradleProperties += `\nkisio_artifactory_android_repo_release=${_getPreferenceValue('ARTIFACTORY_ANDROID_REPO_RELEASE')}`; | ||
gradleProperties += `\nkisio_artifactory_android_repo_snapshot=${_getPreferenceValue('ARTIFACTORY_ANDROID_REPO_SNAPSHOT')}`; | ||
fs.writeFileSync(gradlePropertiesPath, gradleProperties, 'utf8'); | ||
} | ||
} else { | ||
console.error('gradle.properties file not found to add the kisio plugins dependencies'); | ||
} | ||
} | ||
|
||
if (ctx.opts.platforms.includes('ios')) { | ||
// IOS platform: add the authentification informations into the .netrc file (on the home directory) | ||
var netrcPath = os.homedir() + '/.netrc'; | ||
var machine = _getPreferenceValue('ARTIFACTORY_URL').match(/^https?:\/\/([^:\/?#]*)/)[1]; | ||
var netrcLine = `machine ${machine} login ${_getPreferenceValue('ARTIFACTORY_USERNAME')} password ${_getPreferenceValue('ARTIFACTORY_PASSWORD')}\n`; | ||
if (machine) { | ||
var netrcContent = ''; | ||
if (fs.existsSync(netrcPath)) { | ||
var netrcContent = fs.readFileSync(netrcPath).toString() || ''; | ||
if (!netrcContent.match(new RegExp(`machine ${machine}`))) { | ||
netrcContent += `\n${netrcLine}`; | ||
} else { | ||
netrcContent = netrcContent.replace(new RegExp(`machine ${machine}[ \n]login (.*?)[ \n]password (.*?)(?=\n|$)`, 'ism'), netrcLine); | ||
} | ||
} else { | ||
netrcContent += netrcLine; | ||
} | ||
fs.writeFileSync(netrcPath, netrcContent, 'utf8'); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
module.exports = function(ctx) { | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var et = require('elementtree'); | ||
var xcode = require('xcode'); | ||
|
||
var PLUGIN_ID = ctx.opts.plugin.id; | ||
var PLUGIN_NAME = ctx.opts.plugin.pluginInfo.name; | ||
|
||
// Get the projet name | ||
var config = path.join(ctx.opts.projectRoot, 'config.xml'); | ||
var config_contents = fs.readFileSync(config, 'utf-8').toString(); | ||
if (config_contents) { | ||
config_contents = config_contents.substring(config_contents.indexOf('<')); | ||
} | ||
var configXmlData = new et.ElementTree(et.XML(config_contents)); | ||
var projectName = configXmlData.findtext('name'); | ||
|
||
// Get the xcode project | ||
var projectPath = path.join(ctx.opts.projectRoot, '/platforms/ios/', projectName + '.xcodeproj/project.pbxproj'); | ||
var proj = xcode.project(projectPath); | ||
|
||
proj.parseSync(); | ||
proj.addBuildPhase([], 'PBXShellScriptBuildPhase', `[${PLUGIN_ID}] Run Script ${PLUGIN_NAME}`, proj.getFirstTarget().uuid, { | ||
shellPath: '/bin/sh', | ||
shellScript: ` | ||
APP_PATH="$\{TARGET_BUILD_DIR}/$\{WRAPPER_NAME}" | ||
# This script loops through the frameworks embedded in the application and | ||
# removes unused architectures. | ||
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK | ||
do | ||
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable) | ||
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME" | ||
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH" | ||
EXTRACTED_ARCHS=() | ||
for ARCH in $ARCHS | ||
do | ||
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME" | ||
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH" | ||
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH") | ||
done | ||
echo "Merging extracted architectures: $\{ARCHS}" | ||
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "$\{EXTRACTED_ARCHS[@]}" | ||
rm "$\{EXTRACTED_ARCHS[@]}" | ||
echo "Replacing original executable with thinned version" | ||
rm "$FRAMEWORK_EXECUTABLE_PATH" | ||
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH" | ||
done | ||
`, | ||
inputPaths: [ | ||
`"$(SRCROOT)/${projectName}/Plugins/${PLUGIN_ID}/${PLUGIN_NAME}.framework"` | ||
] | ||
}); | ||
fs.writeFileSync(projectPath, proj.writeSync()); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters