Skip to content

Commit

Permalink
0.2.1
Browse files Browse the repository at this point in the history
* 修复windows平台的bug 重新用bat重写了start脚本
* 修复了错误把build文件夹ignore的问题。
  • Loading branch information
exolution committed Nov 17, 2016
1 parent 8a0f413 commit ae6de79
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 23 deletions.
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ coverage
docs
node_modules
test
build
demo
.editorconfig
.esdocrc
Expand Down
2 changes: 1 addition & 1 deletion README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Weexpack is our next generation of engineering development kits. It allows devel
### pre-environmental requirements

- Currently only supported on Mac.
- Configure the [Node.js] [1] environment and install the [npm] [2] package manager.
- Configure the [Node.js] [1] environment and install the [npm] [2] package manager.(need node 6.0+)
- Configure iOS development environment:
- Install [Xcode IDE] [3] to launch Xcode once so that Xcode automatically installs the Developer Tools and confirms the usage protocol.
- Install cocoaPods
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ weexpack 是 weex 新一代的工程开发套件。它允许开发者通过简
### 前期环境要求

- 目前只支持 Mac 平台。
- 配置 [Node.js][1] 环境,并且安装 [npm][2] 包管理器。
- 配置 [Node.js][1] 环境,并且安装 [npm][2] 包管理器。(需要node6.0+)
- 配置 iOS 开发环境:
- 安装 [Xcode IDE][3] ,启动一次 Xcode ,使 Xcode 自动安装开发者工具和确认使用协议。
- 安装 cocoaPods
- 配置 Android 开发环境:
- 安装 [Android Studio][4] 并打开,新建项目。上方菜单栏,打开 [AVD Manager][5] ,新建 Android 模拟器并启动 。(如果有安装 [Docker][6] ,请关闭 Docker Server 。)
- 或者 只下载 [Android SDK][7] , 命令行运行 [AVD Manager][8] ,新建 Android 模拟器并启动。
- 保证Android build-tool的版本为23.0.2

### 使用方法

首先,全局安装 weex-pack 命令:
Expand Down Expand Up @@ -97,6 +98,9 @@ android的打包和构建是一体的 :


## changelog
0.2.1
* 修复windows平台的bug 重新用bat重写了start脚本
* 修复了错误把build文件夹ignore的问题。
0.2.0
* 优化操作流程,去掉了以前会重复出现的server窗口
* 修复个别打包失败的错误 增强稳定性
Expand Down
3 changes: 2 additions & 1 deletion bin/weexpack-run
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const runWeb = require('../src/run/web')
program
.usage('<platform> [options]')
.option('-c, --config [path]', 'specify the configuration file')
.option('-C, --clean','clean project before build android app')
.parse(process.argv)

function printExample() {
Expand Down Expand Up @@ -52,7 +53,7 @@ if (program.args.length < 1) {
if (isValidPlatform(program.args)) {

// TODO: parse config file
run(program.args[0], program.config)
run(program.args[0], {configPath:program.config,clean:program.clean})

} else {
console.log()
Expand Down
1 change: 1 addition & 0 deletions generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module.exports = yeoman.Base.extend({
copy('README.md')
copy('webpack.config.js')
copy('start')
copy('start.bat')
copy('src/index.we')
copy('web/index.html')
copy('android.config.json')
Expand Down
9 changes: 2 additions & 7 deletions generator/templates/start
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@ echo "*
echo "* https://github.com/alibaba/weex *"
echo "*****************************************************************************"

if nc -w 5 -z localhost 8080 ; then
echo "Port 8080 already in use, server is running"
else

THIS_DIR=$(dirname "$0")
pushd "$THIS_DIR"
npm run serve

open http://localhost:8080/web/index.html

popd
fi

12 changes: 12 additions & 0 deletions generator/templates/start.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@echo off
echo "*****************************************************************************"
echo "* Welcome to Weex *"
echo "* *"
echo "* A framework for building Mobile cross-platform UI. *"
echo "* *"
echo "* https://github.com/alibaba/weex *"
echo "*****************************************************************************"

pushd %~dp0
npm run serve
popd
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "weexpack",
"version": "0.2.0",
"version": "0.2.1",
"description": "Weex pack tool",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -37,6 +37,7 @@
"dependencies": {
"chalk": "^1.1.3",
"commander": "^2.9.0",
"copy": "^0.3.0",
"eslint": "^3.5.0",
"inquirer": "^1.1.3",
"yeoman-environment": "^1.6.3",
Expand Down
20 changes: 14 additions & 6 deletions src/run/Android.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const chalk = require('chalk')
const child_process = require('child_process')
const fs = require('fs')
const inquirer = require('inquirer')

const copy=require('copy')
const utils = require('../utils')
const startJSServer = require('./server')
const {Config,androidConfigResolver} = require('../utils/config')
Expand All @@ -12,10 +12,15 @@ const {Config,androidConfigResolver} = require('../utils/config')
* @param {Object} options
*/
function runAndroid(options) {

console.log(` => ${chalk.blue.bold('npm install&build')}`)
utils.buildJS()
.then(()=>{
return utils.exec('rsync -r -R -q ./dist/* android/playground/app/src/main/assets/')
return new Promise((resolve,reject)=>{
copy('./dist/*','android/playground/app/src/main/assets/',function(err){
if(err) return reject(err);
else resolve();
})
});
})
.then(()=>{
startJSServer()
Expand All @@ -32,7 +37,7 @@ function runAndroid(options) {
.then(runApp)
.catch((err) => {
if (err) {
console.log(111,err)
console.log(chalk.red('Error:',err));
}
})
}
Expand Down Expand Up @@ -86,7 +91,7 @@ function resolveConfig({options,rootPath}){
let androidConfig = new Config(androidConfigResolver,path.join(rootPath,'android.config.json'));
return androidConfig.getConfig().then((config) => {
androidConfigResolver.resolve(config);
return {};
return {options,rootPath};
})
}
/**
Expand Down Expand Up @@ -174,8 +179,11 @@ function reverseDevice({device, options}) {
function buildApp({device, options}) {
return new Promise((resolve, reject) => {
console.log(` => ${chalk.blue.bold('Building app ...')}`)

let clean=options.clean?' clean':'';
console.log(options,clean);
try {
child_process.execSync(`./gradlew clean assemble`, {encoding: 'utf8', stdio: [0,1,2]})
child_process.execSync(process.platform==='win32'?`call gradlew.bat${clean} assemble`:`./gradlew${clean} assemble`, {encoding: 'utf8', stdio: [0,1,2]})
} catch(e) {
reject()
}
Expand Down
7 changes: 3 additions & 4 deletions src/run/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@ function startJSServer() {
let occupied = true;
try {

child_process.execSync('lsof -i :8080', {encoding: 'utf8'});
child_process.execSync(process.platform==='win32'?'netstat -aon|findstr "8080"':'lsof -i :8080', {encoding: 'utf8'});
//console.log(child_process.execSync(`open ./start`, {encoding: 'utf8'}))
} catch (e) {
occupied = false
}
if (!occupied) {
try {
console.log(child_process.execSync(`open ./start`, {encoding: 'utf8'}))
child_process.exec(process.platform==='win32'?'start start.bat':`open ./start`, {encoding: 'utf8'});
}
catch (e){
console.log(e);
console.error(e);
}
}
}

module.exports = startJSServer
startJSServer();
10 changes: 9 additions & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ const utils = {
let hasIosDeploy=fs.existsSync('./node_modules/.bin/ios-deploy');
if(!hasIosDeploy) {
let args='';

if(process.platform==='win32'){
console.log('run ios unsupported on windows');
process.exit(1);
}
if (os.release() >= '15.0.0') {
args=' --unsafe-perm=true --allow-root'
}
Expand All @@ -132,6 +135,11 @@ const utils = {
else {
return Promise.resolve();
}
},
xcopy(source,dest){
if(process.platform==='win32'){
cmd
}
}
}

Expand Down

0 comments on commit ae6de79

Please sign in to comment.