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.1 to 1.0.2

58

index.js

@@ -25,4 +25,54 @@ #!/usr/bin/env node

const isFileExisted = (file) => {
return new Promise(function(resolve, reject) {
fs.access(file, (err) => {
if (err) {
reject(false)
} else {
resolve(true)
}
})
})
}
const handle = async (appsdir) => {
log(chalk.blue('处理中,请稍后...') + `[${dayjs().format('YYYY-MM-DD hh:mm:ss')}]`)
log(chalk.blue('store处理中,请稍后...') + `[${dayjs().format('YYYY-MM-DD hh:mm:ss')}]`)
let storeDefault = await fs.readFileSync('./store/store.js', 'utf-8')
for (i = 0; i < appsdir.length; i++) {
try {
const isExisted = await isFileExisted(`${appsdir[i]}/store.js`)
if (isExisted) {
const store = await fs.readFileSync(`${appsdir[i]}/store.js`, 'utf-8')
// 处理state
const storeState = store.match(/state:(.|\n|\r)*getters:/gi)[0].replace(/,?(\s|\n|\r)*},(\s|\n|\r)*getters:/gi, '')
if (!/state:(.|\n|\r)*{$/gi.test(storeState)) {
storeDefault = storeDefault.replace(/state:(\s|\n|\r)*{{1}/gi, storeState + ',')
}
// 处理getters
const storeGetters = store.match(/getters:(.|\n|\r)*mutations:/gi)[0].replace(/,?(\s|\n|\r)*},(\s|\n|\r)*mutations:/gi, '')
if (!/getters:(.|\n|\r)*{$/gi.test(storeGetters)) {
storeDefault = storeDefault.replace(/getters:(\s|\n|\r)*{{1}/gi, storeGetters + ',')
}
// 处理mutations
const storeMutations = store.match(/mutations:(.|\n|\r)*actions:/gi)[0].replace(/,?(\s|\n|\r)*},(\s|\n|\r)*actions:/gi, '')
if (!/mutations:(.|\n|\r)*{$/gi.test(storeMutations)) {
storeDefault = storeDefault.replace(/mutations:(\s|\n|\r)*{{1}/gi, storeMutations + ',')
}
// 处理actions
const storeActions = store.match(/actions:(.|\n|\r)*}(\s|\n|\r)*$/gi)[0].replace(/(,?(\s|\n|\r)*}(\s|\n|\r)*){2}$/gi, '')
if (!/actions:(.|\n|\r)*{$/gi.test(storeActions)) {
storeDefault = storeDefault.replace(/actions:(\s|\n|\r)*{{1}/gi, storeActions + ',')
}
}
} catch (error) {}
}
log(storeDefault)
fs.writeFile('./store/index.js', storeDefault, (err) => {
if(err) throw err
log(chalk.green('store处理成功!') + `[${dayjs().format('YYYY-MM-DD hh:mm:ss')}]\n`)
})
log(chalk.blue('page处理中,请稍后...') + `[${dayjs().format('YYYY-MM-DD hh:mm:ss')}]`)
const pagesDefault = await readFileJSON('./pages-default.json')

@@ -33,6 +83,6 @@ for (i = 0; i < appsdir.length; i++) {

}
console.log(pagesDefault)
log(pagesDefault)
fs.writeFile('./pages.json', JSON.stringify(pagesDefault), (err) => {
if(err) throw err
log(chalk.green('处理成功!') + `[${dayjs().format('YYYY-MM-DD hh:mm:ss')}]\n`)
log(chalk.green('page处理成功!') + `[${dayjs().format('YYYY-MM-DD hh:mm:ss')}]\n`)
})

@@ -69,5 +119,5 @@ }

init(answers.apps)
console.log(answers.apps)
log(answers.apps)
})
}

2

package.json
{
"name": "wit-uni-cli",
"version": "1.0.1",
"version": "1.0.2",
"license": "MIT",

@@ -5,0 +5,0 @@ "keywords": [

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