wit-uni-cli
Advanced tools
Comparing version 1.0.0 to 1.0.1
62
index.js
#!/usr/bin/env node | ||
let fs = require('fs') | ||
let shell = require('shelljs') | ||
let watch = require('node-watch') | ||
let dayjs = require('dayjs') | ||
const fs = require('fs') | ||
const shell = require('shelljs') | ||
const watch = require('node-watch') | ||
const dayjs = require('dayjs') | ||
const inquirer = require('inquirer') | ||
const minimist = require('minimist') | ||
const chalk = require('chalk') | ||
const log = console.log | ||
let readFileJSON = (file) => { | ||
const readFileJSON = (file) => { | ||
return new Promise((resolve, reject) => { | ||
fs.readFile(file, 'utf8', (err, data) => { | ||
if (err) { | ||
console.log(err) | ||
log(chalk.red(err)) | ||
reject(err) | ||
@@ -21,8 +25,7 @@ } else { | ||
let init = async () => { | ||
console.log(`处理中,请稍后...[${dayjs().format('YYYY-MM-DD hh:mm:ss')}]`) | ||
let pagesDefault = await readFileJSON('./pages-default.json') | ||
let files = shell.find('./pages/app/**/pages.json') | ||
for (i = 0; i < files.length; i++) { | ||
let data = await readFileJSON(files[i]) | ||
const handle = async (appsdir) => { | ||
log(chalk.blue('处理中,请稍后...') + `[${dayjs().format('YYYY-MM-DD hh:mm:ss')}]`) | ||
const pagesDefault = await readFileJSON('./pages-default.json') | ||
for (i = 0; i < appsdir.length; i++) { | ||
const data = await readFileJSON(`${appsdir[i]}/pages.json`) | ||
pagesDefault.pages.push(...data.pages) | ||
@@ -33,12 +36,37 @@ } | ||
if(err) throw err | ||
console.log(`处理成功![${dayjs().format('YYYY-MM-DD hh:mm:ss')}]\n`) | ||
log(chalk.green('处理成功!') + `[${dayjs().format('YYYY-MM-DD hh:mm:ss')}]\n`) | ||
}) | ||
} | ||
if (process.argv[2] === 'watch') { | ||
watch(['./pages/app/', './pages-default.json'], { recursive: true, filter: /pages.json$/ }, () => { | ||
init() | ||
const init = (apps) => { | ||
const appsdir = apps.map(item => { | ||
return `./pages/app/${item}` | ||
}) | ||
if (argv._.indexOf('watch') !== -1) { | ||
watch([...appsdir, './pages-default.json'], { recursive: true, filter: /pages.json$/ }, () => { | ||
handle(appsdir) | ||
}) | ||
} | ||
handle(appsdir) | ||
} | ||
init() | ||
const argv = minimist(process.argv.slice(2)) | ||
const apps = shell.ls('./pages/app/') | ||
const defaultApps = argv._.filter(item => item !== 'watch') | ||
if (argv.j) { | ||
init(defaultApps) | ||
} else { | ||
inquirer.prompt([ | ||
{ | ||
type: 'checkbox', | ||
name: 'apps', | ||
message: '请选择需要编译的模块', | ||
choices: apps, | ||
default: defaultApps | ||
} | ||
]).then(answers => { | ||
init(answers.apps) | ||
console.log(answers.apps) | ||
}) | ||
} | ||
{ | ||
"name": "wit-uni-cli", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"license": "MIT", | ||
@@ -19,6 +19,11 @@ "keywords": [ | ||
"dependencies": { | ||
"chalk": "^4.1.0", | ||
"commander": "^5.1.0", | ||
"dayjs": "^1.8.18", | ||
"inquirer": "^7.3.2", | ||
"minimist": "^1.2.5", | ||
"node-watch": "^0.6.3", | ||
"shelljs": "^0.8.3" | ||
"shelljs": "^0.8.4", | ||
"uglify-js": "^3.10.0" | ||
} | ||
} |
@@ -16,2 +16,6 @@ # wit-uni-cli | ||
$ wit-uni watch | ||
or | ||
$ wit-uni watch [模块名] | ||
or | ||
$ wit-uni watch [模块名] -j | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2688
64
21
8
+ Addedchalk@^4.1.0
+ Addedcommander@^5.1.0
+ Addedinquirer@^7.3.2
+ Addedminimist@^1.2.5
+ Addeduglify-js@^3.10.0
+ Addedansi-escapes@4.3.2(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedchardet@0.7.0(transitive)
+ Addedcli-cursor@3.1.0(transitive)
+ Addedcli-width@3.0.0(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcommander@5.1.0(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedexternal-editor@3.1.0(transitive)
+ Addedfigures@3.2.0(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedinquirer@7.3.3(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmute-stream@0.0.8(transitive)
+ Addedonetime@5.1.2(transitive)
+ Addedos-tmpdir@1.0.2(transitive)
+ Addedrestore-cursor@3.1.0(transitive)
+ Addedrun-async@2.4.1(transitive)
+ Addedrxjs@6.6.7(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedthrough@2.3.8(transitive)
+ Addedtmp@0.0.33(transitive)
+ Addedtslib@1.14.1(transitive)
+ Addedtype-fest@0.21.3(transitive)
+ Addeduglify-js@3.19.3(transitive)
Updatedshelljs@^0.8.4