Skip to content

Commit

Permalink
Merge branch 'master' of github.com:NervJS/taro
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/taro-cli/src/rn/styleProcess.ts
#	packages/taro-cli/src/util/index.js
  • Loading branch information
Pines-Cheng committed Apr 26, 2019
2 parents f87c5ce + 0907cdf commit 53b3eab
Show file tree
Hide file tree
Showing 214 changed files with 16,374 additions and 5,482 deletions.
2 changes: 1 addition & 1 deletion docs/components/forms/slider.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default class PageView extends Component {
<Text>设置 step</Text>
<Slider step={1} value={50}/>
<Text>显示当前 value</Text>
<Slider step={1} value={50 showValue/>
<Slider step={1} value={50} showValue/>
<Text>设置最小/最大值</Text>
<Slider step={1} value={100} showValue min={50} max={200}/>
</View>
Expand Down
32 changes: 25 additions & 7 deletions docs/components/viewContainer/scroll-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,38 @@ export default class PageView extends Component {
}

render() {
const scrollStyle = {
height: '150px'
}
const scrollTop = 0
const Threshold = 20
const vStyleA = {
height: '150px',
'background-color': rgb(26, 173, 25)
}
const vStyleB = {
height: '150px',
'background-color': rgb(39,130,215)
}
const vStyleC = {
height: '150px',
'background-color': rgb(241,241,241),
color: '#333'
}
return (
<ScrollView
className='scrollview'
scrollY
scrollWithAnimation
scrollTop='0'
style='height: 150px;'
lowerThreshold='20'
upperThreshold='20'
scrollTop={scrollTop}
style={scrollStyle}
lowerThreshold={Threshold}
upperThreshold={Threshold}
onScrolltoupper={this.onScrolltoupper}
onScroll={this.onScroll}>
<View style='height:150px;background-color:rgb(26,173,25);'>A</View>
<View style='height:150px;background-color:rgb(39,130,215);'>B</View>
<View style='height:150px;background-color:rgb(241,241,241);color: #333;'>C</View>
<View style={vStyleA}>A</View>
<View style={vStyleB}>B</View>
<View style={vStyleC}>C</View>
</ScrollView>
)
}
Expand Down
1 change: 1 addition & 0 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"packages/taro-swan",
"packages/taro-alipay",
"packages/taro-tt",
"packages/taro-quickapp",
"packages/taro-webpack-runner",
"packages/postcss-plugin-constparse",
"packages/eslint-config-taro",
Expand Down
4 changes: 4 additions & 0 deletions packages/eslint-config-taro/rules/jsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,14 @@ module.exports = {
// beforeSelfClosing: 'always',
// afterOpening: 'never'
// }],
'react/jsx-tag-spacing': ['error', { beforeSelfClosing: 'always' }],

// Enforce spaces before the closing bracket of self-closing JSX elements
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md
'react/jsx-tag-spacing': ["error", { "beforeSelfClosing": "always" }],
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-space-before-closing.md
// Deprecated in favor of jsx-tag-spacing
// 'react/jsx-space-before-closing': ['error', 'always'],

// // Prevent usage of Array index in keys
// // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin-taro/rules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ const has = require('has')
const allRules = {
// 'if-statement-in-map-loop': require('./if-statement-in-map-loop'),
'manipulate-jsx-as-array': require('./manipulate-jsx-as-array'),
// 'no-anonymous-function-in-props': require('./no-anonymous-function-in-props'),
'no-jsx-in-class-method': require('./no-jsx-in-class-method'),
//'no-anonymous-function-in-props': require('./no-anonymous-function-in-props'),
// 'no-jsx-in-class-method': require('./no-jsx-in-class-method'),
'no-spread-in-props': require('./no-spread-in-props'),
'no-stateless-component': require('./no-stateless-component'),
// 'no-stateless-component': require('./no-stateless-component'),
// 'jsx-handler-names': require('./jsx-handler-names'),
'reserve-class-properties': require('./reserve-class-properties'),
// 'function-naming': require('./function-naming'),
Expand Down
13 changes: 3 additions & 10 deletions packages/taro-alipay/src/create-component.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getCurrentPageUrl } from '@tarojs/utils'

import { commitAttachRef, detachAllRef } from '@tarojs/taro'
import { isEmptyObject } from './util'
import { updateComponent } from './lifecycle'
import { cacheDataGet, cacheDataHas } from './data-cache'
Expand Down Expand Up @@ -192,11 +192,7 @@ export function componentTrigger (component, key, args) {
const query = my.createSelectorQuery().in(component.$scope)
target = query.select(`#${ref.id}`)
}
if (target && 'refName' in ref && ref['refName']) {
refs[ref.refName] = target
} else if (target && 'fn' in ref && typeof ref['fn'] === 'function') {
ref['fn'].call(component, target)
}
commitAttachRef(ref, target, component, refs, true)
ref.target = target
})
component.refs = Object.assign({}, component.refs || {}, refs)
Expand All @@ -219,10 +215,7 @@ export function componentTrigger (component, key, args) {
component._pendingStates = []
component._pendingCallbacks = []
// refs
if (component['$$refs'] && component['$$refs'].length > 0) {
component['$$refs'].forEach(ref => typeof ref['fn'] === 'function' && ref['fn'].call(component, null))
component.refs = {}
}
detachAllRef(component)
const scope = component.$scope
if (component.$componentType === 'COMPONENT' &&
typeof scope.props[COLLECT_CHILDS] === 'function' &&
Expand Down
2 changes: 2 additions & 0 deletions packages/taro-alipay/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Events,
eventCenter,
ENV_TYPE,
createRef,
render,
internal_safe_get,
internal_safe_set,
Expand All @@ -27,6 +28,7 @@ export const Taro = {
Events,
eventCenter,
getEnv,
createRef,
render,
ENV_TYPE,
internal_safe_get,
Expand Down
6 changes: 3 additions & 3 deletions packages/taro-alipay/src/lifecycle.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
internal_safe_get as safeGet,
internal_safe_set as safeSet
internal_safe_set as safeSet,
commitAttachRef
} from '@tarojs/taro'
import { componentTrigger } from './create-component'
import { shakeFnFromObject, isEmptyObject, diffObjToPath } from './util'
Expand Down Expand Up @@ -106,8 +107,7 @@ function doUpdate (component, prevProps, prevState) {
const prevRef = ref.target

if (target !== prevRef) {
if (ref.refName) component.refs[ref.refName] = target
typeof ref.fn === 'function' && ref.fn.call(component, target)
commitAttachRef(ref, target, component, component.refs)
ref.target = target
}
})
Expand Down
11 changes: 2 additions & 9 deletions packages/taro-cli/bin/taro
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
#! /usr/bin/env node

const program = require('commander')
const { getPkgVersion, printPkgVersion } = require('../src/util')
const { getPkgVersion, printPkgVersion } = require('../dist/util')

printPkgVersion()

const startTime = new Date('2019-1-1 00:00').getTime()
const endTime = new Date('2019-1-2 00:00').getTime()
const nowTime = Date.now()
if (nowTime >= startTime && nowTime <= endTime) {
const yearTxt = String(require('fs-extra').readFileSync(require('path').resolve(__dirname, 'year.txt')))
console.log(require('chalk').rgb(255, 87, 34)(yearTxt))
}

program
.version(getPkgVersion())
.usage('<command> [options]')
Expand All @@ -21,4 +13,5 @@ program
.command('update', 'Update packages of taro')
.command('convert', 'Convert weapp to taro')
.command('info', 'Diagnostics Taro env info')
.command('doctor', 'Diagnose taro project')
.parse(process.argv)
28 changes: 17 additions & 11 deletions packages/taro-cli/bin/taro-build
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,29 @@ const program = require('commander')
const chalk = require('chalk')
const _ = require('lodash')

const build = require('../src/build')
const { PROJECT_CONFIG, BUILD_TYPES } = require('../src/util')
const projectConfPath = path.join(process.cwd(), PROJECT_CONFIG)
const build = require('../dist/build').default
const { PROJECT_CONFIG, BUILD_TYPES } = require('../dist/util/constants')
const appPath = process.cwd()
const projectConfPath = path.join(appPath, PROJECT_CONFIG)

program
.option('--type [typeName]', 'Build type, weapp/h5/rn/swan/alipay/tt')
.option('--type [typeName]', 'Build type, weapp/swan/alipay/tt/h5/quickapp/rn/qq')
.option('--watch', 'Watch mode')
.option('--env [env]', 'Env type')
.option('--ui', 'Build Taro UI library')
.option('--plugin [typeName]', 'Build Taro plugin project, weapp')
.option('--port [port]', 'Specified port')
.option('--release', 'Release quickapp')
.parse(process.argv)

const args = program.args
const { type, watch, ui } = program
let { env, plugin } = program
const { type, watch, ui, port, release } = program
let { env, plugin } = program

env = process.env.NODE_ENV || env

if (ui) {
console.log(chalk.green(`开始编译 UI 库`))
build(args, {
build(appPath, {
type: 'ui',
watch
})
Expand All @@ -36,7 +38,7 @@ if (plugin) {
if (typeof plugin === 'boolean') {
plugin = BUILD_TYPES.WEAPP
}
build(args, {
build(appPath, {
type: BUILD_TYPES.PLUGIN,
platform: plugin,
watch
Expand All @@ -59,10 +61,14 @@ if (env) {
}
}

process.env.TARO_ENV = type

const projectConf = require(projectConfPath)(_.merge)
console.log(chalk.green(`开始编译项目 ${chalk.bold(projectConf.projectName)}`))

build(args, {
build(appPath, {
type,
watch
watch,
port: typeof port === 'string' ? port: undefined,
release: !!release
})
4 changes: 2 additions & 2 deletions packages/taro-cli/bin/taro-convert
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

const program = require('commander')

const Convertor = require('../src/convertor')
const Convertor = require('../dist/convertor').default

program
.parse(process.argv)

const convertor = new Convertor()
const convertor = new Convertor(process.cwd())

convertor.run()
65 changes: 65 additions & 0 deletions packages/taro-cli/bin/taro-doctor
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env node

const path = require('path')
const program = require('commander')
const _ = require('lodash/fp')
const ora = require('ora')
const chalk = require('chalk')
const fs = require('fs-extra')
const { PROJECT_CONFIG } = require('../dist/util/constants')
const PROJECT_CONF_PATH = path.join(process.cwd(), PROJECT_CONFIG)

if (!fs.existsSync(PROJECT_CONF_PATH)) {
console.log(chalk.red(`找不到项目配置文件${PROJECT_CONFIG},请确定当前目录是Taro项目根目录!`))
process.exit(1)
}

const { validators } = require('../dist/doctor').default

const NOTE_ALL_RIGHT = chalk.green('[✓] ')
const NOTE_VALID = chalk.yellow('[!] ')
const NOTE_INVALID = chalk.red('[✗] ')

const titleChalk = chalk.hex('#aaa')
const lineChalk = chalk.hex('#fff')
const solutionChalk = chalk.hex('#999')

function printReport (reports) {
_.forEach(report => {
console.log('\n' + titleChalk(report.desc))

if (report.raw) {
console.log(report.raw)
return
}

if (_.getOr(0, 'lines.length', report) === 0) {
console.log(` ${NOTE_ALL_RIGHT}没有发现问题`)
return
}

_.forEach(line => {
console.log(
' ' +
(line.valid ? NOTE_VALID : NOTE_INVALID) +
lineChalk(line.desc)
)
if (line.solution) {
console.log(' ' + solutionChalk(line.solution))
}
}, report.lines)
}, reports)
}

program
.option('-v --verbose', 'Print all message')
.parse(process.argv)

async function diagnose () {
const spinner = ora('正在诊断项目...').start()
const reportsP = _.map(validator => validator(), validators)
const reports = await Promise.all(reportsP)
spinner.succeed('诊断完成')
printReport(reports)
}
diagnose()
4 changes: 2 additions & 2 deletions packages/taro-cli/bin/taro-info
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const fs = require('fs')
const path = require('path')
const envinfo = require('envinfo')
const {getPkgVersion, UPDATE_PACKAGE_LIST} = require('../src/util')
const { getPkgVersion, UPDATE_PACKAGE_LIST } = require('../dist/util')
const process = require('process')
const program = require('commander')

Expand Down Expand Up @@ -37,7 +37,7 @@ function rnInfo (options) {
}

async function info (options) {
let info = await envinfo.run(Object.assign({}, {
const info = await envinfo.run(Object.assign({}, {
System: ['OS', 'Shell'],
Binaries: ['Node', 'Yarn', 'npm'],
npmPackages,
Expand Down
4 changes: 2 additions & 2 deletions packages/taro-cli/bin/taro-init
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const program = require('commander')

const Project = require('../src/project')
const Project = require('../dist/project').default

program
.option('--name [name]', '项目名称')
Expand All @@ -15,7 +15,7 @@ program

const args = program.args
const { template, description, name, css } = program
let typescript = ''
let typescript = false

/**
* 非标准做法
Expand Down
9 changes: 4 additions & 5 deletions packages/taro-cli/bin/taro-update
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ const path = require('path')
const fs = require('fs-extra')
const program = require('commander')
const chalk = require('chalk')
const { getPkgItemByKey } = require('../src/util')
const { getPkgItemByKey, shouldUseYarn, shouldUseCnpm } = require('../dist/util')
const ora = require('ora')
const exec = require('child_process').exec
const getLatestVersion = require('latest-version')
const { PROJECT_CONFIG, UPDATE_PACKAGE_LIST} = require('../src/util')
const { PROJECT_CONFIG, UPDATE_PACKAGE_LIST } = require('../dist/util/constants')
const projectConfPath = path.join(process.cwd(), PROJECT_CONFIG)
const pkgPath = path.join(process.cwd(), 'package.json')
const { shouldUseYarn, shouldUseCnpm } = require('../src/util')

const pkgName = getPkgItemByKey('name')

Expand Down Expand Up @@ -50,7 +49,7 @@ function updateSelf () {
command = 'npm i -g @tarojs/cli@latest'
}

let child = exec(command)
const child = exec(command)

const spinner = ora('即将将 Taro 开发工具 taro-cli 更新到最新版本...').start()

Expand Down Expand Up @@ -103,7 +102,7 @@ async function updateProject () {
command = 'npm install'
}

let child = exec(command)
const child = exec(command)

const spinner = ora('即将将项目所有 Taro 相关依赖更新到最新版本...').start()

Expand Down
Loading

0 comments on commit 53b3eab

Please sign in to comment.