Skip to content

Commit

Permalink
feat: create
Browse files Browse the repository at this point in the history
  • Loading branch information
罗学 committed Apr 14, 2021
1 parent 697f0bc commit 6770237
Show file tree
Hide file tree
Showing 70 changed files with 418 additions and 4,662 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"devDependencies": {
"@pkb/cli": "^1.4.21",
"@pkb/plugin-react": "^1.4.8",
"@pkb/webpack-box": "^1.4.19",
"@pkb/rollup-box": "^1.4.20"
"@pkb/rollup-box": "^1.4.20",
"@pkb/webpack-box": "^1.4.19"
},
"bugs": {
"url": "https://github.com/luoxue-victor/learn_webpack/issues"
Expand Down
4 changes: 1 addition & 3 deletions packages/cli/bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const didYouMean = require('didyoumean')
const program = require('commander')
const path = require('path')
const fs = require('fs')
const LOG = require('../lib/tools/log')
const execSync = require('child_process').execSync

didYouMean.threshold = 0.6
Expand All @@ -24,7 +23,6 @@ fileNames.forEach(fileName => {
command.registerCommand({
program,
cleanArgs,
LOG,
execSync
})
})
Expand All @@ -49,7 +47,7 @@ program.on('--help', () => {
program.commands.forEach(c => c.on('--help', () => console.log()))

// enhance common error messages
const enhanceErrorMessages = require('../lib/util/enhanceErrorMessages')
const enhanceErrorMessages = require('../util/enhanceErrorMessages')

enhanceErrorMessages('missingArgument', argName => {
return `Missing required argument ${chalk.yellow(`<${argName}>`)}.`
Expand Down
22 changes: 21 additions & 1 deletion packages/cli/commands/upgrade.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// https://www.npmjs.com/package/npm-check-updates
const ncu = require('npm-check-updates')

exports.registerCommand = (params) => {
const { program, cleanArgs } = params
program
Expand All @@ -6,6 +9,23 @@ exports.registerCommand = (params) => {
.action((filter, cmd) => {
const options = cleanArgs(cmd)
options.filter = filter || '@pkb/*'
require('../lib/upgrade')(options)
exports.upgrade(options)
})
}

exports.upgrade = async ({ filter }) => {
const upgraded = await ncu.run({
jsonUpgraded: true,
filter: filter || '@pkb/*',
upgrade: true,
silent: true
})

const keys = Object.keys(upgraded)
if (keys.length) {
console.log(`检查出${keys.length}项, 可以执行 npm i 更新依赖`)
console.log(upgraded)
} else {
console.log('已经是最新版本,没有可更新的依赖')
}
}
65 changes: 0 additions & 65 deletions packages/cli/lib/ConfigTransform.js

This file was deleted.

Loading

0 comments on commit 6770237

Please sign in to comment.