Skip to content

Commit

Permalink
Merge pull request #120 from weexteam/bugfix-alisource
Browse files Browse the repository at this point in the history
fixbug-support alisource for ios platform
  • Loading branch information
zhangquan authored Apr 1, 2017
2 parents 8ffa615 + 84439c0 commit 607c307
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ node_js:
script: ./node_modules/mocha/bin/mocha tests/*.test.js
before_install:
- brew install nvm;
- brew install android-platform-tools;
# - brew install android-platform-tools;
- gem install -n /usr/local/bin cocoapods
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ weexpack 所提供的命令大致可分为三组,分别是:

## changelog

0.3.13
* 修复创建ali内部源问题


0.3.12
* 修复merge问题
Expand Down
61 changes: 36 additions & 25 deletions lib/src/platforms/PlatformApiPoly.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,31 +93,15 @@ PlatformApiPoly.createPlatform = function (destinationDir, projectConfig, option

var templatePath = path.join(options.platformDetails.libDir, 'bin', 'templates');
return Q().then(function(){
copyPlatform(templatePath, destinationDir)
//修改source
if(options.ali&&options.platformDetails.platform == "ios"){
var weexPluginRootDir = path.join(destinationDir, 'Weexplugin');
var xcodeProjDir;
var xcodeCordovaProj;

try {
xcodeProjDir = fs.readdirSync(weexPluginRootDir).filter( function(e) { return e.match(/\.xcodeproj$/i); })[0];
if (!xcodeProjDir) {
throw new CordovaError('The provided path "' + weexPluginRootDir + '" is not a Weex iOS project.');
}

var cordovaProjName = xcodeProjDir.substring(xcodeProjDir.lastIndexOf(path.sep)+1, xcodeProjDir.indexOf('.xcodeproj'));
xcodeCordovaProj = path.join(weexPluginRootDir, cordovaProjName);
} catch(e) {
throw new CordovaError('The provided path "'+weexPluginRootDir+'" is not a weexpack iOS project.');
}
var Podfile = require('./ios_pack/lib/Podfile').Podfile;
var project_name = xcodeCordovaProj.split('/').pop();
var podfileFile = new Podfile(path.join(weexPluginRootDir, Podfile.FILENAME), project_name)
podfileFile.writeUseAliSource()
}
return PlatformApiPoly;
})
copyPlatform(templatePath, destinationDir)
//修改source
if(options.ali&&options.platformDetails.platform == "ios"){
var weexPluginRootDir = path.join(destinationDir, 'Weexplugin');
changeSource(destinationDir)
changeSource(weexPluginRootDir)
}
return PlatformApiPoly;
})

// WEEX_HOOK
// var command = path.join(options.platformDetails.libDir, 'bin', 'create');
Expand All @@ -133,6 +117,33 @@ PlatformApiPoly.createPlatform = function (destinationDir, projectConfig, option
// });
};

function changeSource (destinationDir){

var weexPluginRootDir = path.join(destinationDir);
var xcodeProjDir;
var xcodeCordovaProj;

try {
xcodeProjDir = fs.readdirSync(weexPluginRootDir).filter( function(e) { return e.match(/\.xcodeproj$/i); })[0];
if (!xcodeProjDir) {
throw new CordovaError('The provided path "' + weexPluginRootDir + '" is not a Weex iOS project.');
}

var cordovaProjName = xcodeProjDir.substring(xcodeProjDir.lastIndexOf(path.sep)+1, xcodeProjDir.indexOf('.xcodeproj'));
xcodeCordovaProj = path.join(weexPluginRootDir, cordovaProjName);
} catch(e) {
throw new CordovaError('The provided path "'+weexPluginRootDir+'" is not a weexpack iOS project.');
}
var Podfile = require('./ios_pack/lib/Podfile').Podfile;
var project_name = xcodeCordovaProj.split('/').pop();
var podfileFile = new Podfile(path.join(weexPluginRootDir, Podfile.FILENAME), project_name)
podfileFile.writeUseAliSource()


}



/**
* Updates already installed platform.
*
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "weexpack",
"version": "0.3.12",
"version": "0.3.13",
"description": "Weex pack tool",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 607c307

Please sign in to comment.