Skip to content

Commit

Permalink
feat(taro-cli): 添加更新提示
Browse files Browse the repository at this point in the history
  • Loading branch information
Pines-Cheng committed Jun 19, 2018
1 parent 842404c commit 196b21b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
33 changes: 22 additions & 11 deletions packages/taro-cli/bin/taro
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
#! /usr/bin/env node

const program = require('commander')
const latestVersion = require('latest-version')
const chalk = require('chalk')
const {getPkgVersion, getPkgItemByKey} = require('../src/util')

const {
getPkgVersion
} = require('../src/util')

program
.version(getPkgVersion())
.usage('<command> [options]')
.command('init [projectName]', 'Init a project with default templete')
.command('build', 'Build a project with options')
.command('update', 'Update packages of taro')
.parse(process.argv)
const pkgName = getPkgItemByKey('name')
const currentVersion = getPkgVersion()

latestVersion(pkgName).then((latestVersion) => {
console.log(
`Current : ${chalk.yellow('v' +
currentVersion)} Latest : ${chalk.green('v' +
latestVersion)}`)

console.log(
`Run ${chalk.green('taro update')} update to the latest version`)
program
.version(getPkgVersion())
.usage('<command> [options]')
.command('init [projectName]', 'Init a project with default templete')
.command('build', 'Build a project with options')
.command('update', 'Update packages of taro')
.parse(process.argv)
})
3 changes: 1 addition & 2 deletions packages/taro-cli/bin/taro-build
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const chalk = require('chalk')
const _ = require('lodash')

const build = require('../src/build')
const {getPkgVersion, PROJECT_CONFIG} = require('../src/util')
const {PROJECT_CONFIG} = require('../src/util')
const projectConfPath = path.join(process.cwd(), PROJECT_CONFIG)

program
Expand All @@ -16,7 +16,6 @@ program

const args = program.args
const { type, watch } = program
console.log(`Taro v${getPkgVersion()}`)
console.log()
if (!fs.existsSync(projectConfPath)) {
console.log(chalk.red(`找不到项目配置文件${PROJECT_CONFIG},请确定当前目录是Taro项目根目录!`))
Expand Down
5 changes: 0 additions & 5 deletions packages/taro-cli/bin/taro-init
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ const program = require('commander')

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

const {
getPkgVersion
} = require('../src/util')

program
.option('--name', '项目名称')
.option('--template', '项目模板')
Expand All @@ -25,7 +21,6 @@ const project = new Project({
description
})

console.log(`Taro v${getPkgVersion()}`)
console.log()

project.create()

0 comments on commit 196b21b

Please sign in to comment.