Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wit-uni-cli

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wit-uni-cli - npm Package Compare versions

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
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc