Skip to content

Commit ae6de79

Browse files
committed
0.2.1
* 修复windows平台的bug 重新用bat重写了start脚本 * 修复了错误把build文件夹ignore的问题。
1 parent 8a0f413 commit ae6de79

File tree

11 files changed

+51
-23
lines changed

11 files changed

+51
-23
lines changed

.npmignore

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ coverage
22
docs
33
node_modules
44
test
5-
build
65
demo
76
.editorconfig
87
.esdocrc

README.en.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Weexpack is our next generation of engineering development kits. It allows devel
88
### pre-environmental requirements
99

1010
- Currently only supported on Mac.
11-
- Configure the [Node.js] [1] environment and install the [npm] [2] package manager.
11+
- Configure the [Node.js] [1] environment and install the [npm] [2] package manager.(need node 6.0+)
1212
- Configure iOS development environment:
1313
- Install [Xcode IDE] [3] to launch Xcode once so that Xcode automatically installs the Developer Tools and confirms the usage protocol.
1414
- Install cocoaPods

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ weexpack 是 weex 新一代的工程开发套件。它允许开发者通过简
99
### 前期环境要求
1010

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

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

9899

99100
## changelog
101+
0.2.1
102+
* 修复windows平台的bug 重新用bat重写了start脚本
103+
* 修复了错误把build文件夹ignore的问题。
100104
0.2.0
101105
* 优化操作流程,去掉了以前会重复出现的server窗口
102106
* 修复个别打包失败的错误 增强稳定性

bin/weexpack-run

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const runWeb = require('../src/run/web')
99
program
1010
.usage('<platform> [options]')
1111
.option('-c, --config [path]', 'specify the configuration file')
12+
.option('-C, --clean','clean project before build android app')
1213
.parse(process.argv)
1314

1415
function printExample() {
@@ -52,7 +53,7 @@ if (program.args.length < 1) {
5253
if (isValidPlatform(program.args)) {
5354

5455
// TODO: parse config file
55-
run(program.args[0], program.config)
56+
run(program.args[0], {configPath:program.config,clean:program.clean})
5657

5758
} else {
5859
console.log()

generator/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ module.exports = yeoman.Base.extend({
4242
copy('README.md')
4343
copy('webpack.config.js')
4444
copy('start')
45+
copy('start.bat')
4546
copy('src/index.we')
4647
copy('web/index.html')
4748
copy('android.config.json')

generator/templates/start

+2-7
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,9 @@ echo "*
66
echo "* https://github.com/alibaba/weex *"
77
echo "*****************************************************************************"
88

9-
if nc -w 5 -z localhost 8080 ; then
10-
echo "Port 8080 already in use, server is running"
11-
else
9+
1210
THIS_DIR=$(dirname "$0")
1311
pushd "$THIS_DIR"
1412
npm run serve
15-
16-
open http://localhost:8080/web/index.html
17-
1813
popd
19-
fi
14+

generator/templates/start.bat

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@echo off
2+
echo "*****************************************************************************"
3+
echo "* Welcome to Weex *"
4+
echo "* *"
5+
echo "* A framework for building Mobile cross-platform UI. *"
6+
echo "* *"
7+
echo "* https://github.com/alibaba/weex *"
8+
echo "*****************************************************************************"
9+
10+
pushd %~dp0
11+
npm run serve
12+
popd

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "weexpack",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "Weex pack tool",
55
"main": "index.js",
66
"scripts": {
@@ -37,6 +37,7 @@
3737
"dependencies": {
3838
"chalk": "^1.1.3",
3939
"commander": "^2.9.0",
40+
"copy": "^0.3.0",
4041
"eslint": "^3.5.0",
4142
"inquirer": "^1.1.3",
4243
"yeoman-environment": "^1.6.3",

src/run/Android.js

+14-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const chalk = require('chalk')
33
const child_process = require('child_process')
44
const fs = require('fs')
55
const inquirer = require('inquirer')
6-
6+
const copy=require('copy')
77
const utils = require('../utils')
88
const startJSServer = require('./server')
99
const {Config,androidConfigResolver} = require('../utils/config')
@@ -12,10 +12,15 @@ const {Config,androidConfigResolver} = require('../utils/config')
1212
* @param {Object} options
1313
*/
1414
function runAndroid(options) {
15-
15+
console.log(` => ${chalk.blue.bold('npm install&build')}`)
1616
utils.buildJS()
1717
.then(()=>{
18-
return utils.exec('rsync -r -R -q ./dist/* android/playground/app/src/main/assets/')
18+
return new Promise((resolve,reject)=>{
19+
copy('./dist/*','android/playground/app/src/main/assets/',function(err){
20+
if(err) return reject(err);
21+
else resolve();
22+
})
23+
});
1924
})
2025
.then(()=>{
2126
startJSServer()
@@ -32,7 +37,7 @@ function runAndroid(options) {
3237
.then(runApp)
3338
.catch((err) => {
3439
if (err) {
35-
console.log(111,err)
40+
console.log(chalk.red('Error:',err));
3641
}
3742
})
3843
}
@@ -86,7 +91,7 @@ function resolveConfig({options,rootPath}){
8691
let androidConfig = new Config(androidConfigResolver,path.join(rootPath,'android.config.json'));
8792
return androidConfig.getConfig().then((config) => {
8893
androidConfigResolver.resolve(config);
89-
return {};
94+
return {options,rootPath};
9095
})
9196
}
9297
/**
@@ -174,8 +179,11 @@ function reverseDevice({device, options}) {
174179
function buildApp({device, options}) {
175180
return new Promise((resolve, reject) => {
176181
console.log(` => ${chalk.blue.bold('Building app ...')}`)
182+
183+
let clean=options.clean?' clean':'';
184+
console.log(options,clean);
177185
try {
178-
child_process.execSync(`./gradlew clean assemble`, {encoding: 'utf8', stdio: [0,1,2]})
186+
child_process.execSync(process.platform==='win32'?`call gradlew.bat${clean} assemble`:`./gradlew${clean} assemble`, {encoding: 'utf8', stdio: [0,1,2]})
179187
} catch(e) {
180188
reject()
181189
}

src/run/server.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@ function startJSServer() {
88
let occupied = true;
99
try {
1010

11-
child_process.execSync('lsof -i :8080', {encoding: 'utf8'});
11+
child_process.execSync(process.platform==='win32'?'netstat -aon|findstr "8080"':'lsof -i :8080', {encoding: 'utf8'});
1212
//console.log(child_process.execSync(`open ./start`, {encoding: 'utf8'}))
1313
} catch (e) {
1414
occupied = false
1515
}
1616
if (!occupied) {
1717
try {
18-
console.log(child_process.execSync(`open ./start`, {encoding: 'utf8'}))
18+
child_process.exec(process.platform==='win32'?'start start.bat':`open ./start`, {encoding: 'utf8'});
1919
}
2020
catch (e){
21-
console.log(e);
21+
console.error(e);
2222
}
2323
}
2424
}
2525

2626
module.exports = startJSServer
27-
startJSServer();

src/utils/index.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ const utils = {
123123
let hasIosDeploy=fs.existsSync('./node_modules/.bin/ios-deploy');
124124
if(!hasIosDeploy) {
125125
let args='';
126-
126+
if(process.platform==='win32'){
127+
console.log('run ios unsupported on windows');
128+
process.exit(1);
129+
}
127130
if (os.release() >= '15.0.0') {
128131
args=' --unsafe-perm=true --allow-root'
129132
}
@@ -132,6 +135,11 @@ const utils = {
132135
else {
133136
return Promise.resolve();
134137
}
138+
},
139+
xcopy(source,dest){
140+
if(process.platform==='win32'){
141+
cmd
142+
}
135143
}
136144
}
137145

0 commit comments

Comments
 (0)