New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

viewar-cli

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

viewar-cli - npm Package Compare versions

Comparing version 0.1.0 to 0.1.3

94

index.js

@@ -5,4 +5,6 @@ #!/usr/bin/env node

const fs = require('fs')
const archiver = require('archiver')
const path = require('path')
const shell = require('shelljs')
const semver = require('semver')

@@ -19,5 +21,5 @@ const currentVersion = require('./package.json').version

const latestVersion = shell.exec('npm show viewar-cli version', {silent: true}).stdout
const latestVersion = shell.exec('npm show viewar-cli version', {silent: true}).stdout.trim()
if (currentVersion !== latestVersion) {
if (semver.gt(latestVersion, currentVersion)) {
console.log(chalk`{bold

@@ -28,6 +30,6 @@ A newer version is available: ${latestVersion}!} Update now by running:

process.exit(function () {
(function () {
if (args.length === 0 || args[0] === '--help') {
printUsage()
return 0
return process.exit(0)
} else {

@@ -43,10 +45,10 @@ switch (args[0]) {

console.log(`Current app version is ${chalk.green(get('version'))}`)
return 0
return process.exit(0)
case 'set-version':
if (args[1]) {
setVersion(args[1])
return 0
return process.exit(0)
} else {
console.log(chalk.red('Please provide a version!'))
return 1
return process.exit(1)
}

@@ -56,10 +58,10 @@ case 'display-token':

console.log(`Current app token is ${chalk.green(token)}`)
return 0
return process.exit(0)
case 'set-token':
if (args[1]) {
setToken(args[1])
return 0
return process.exit(0)
} else {
console.log(chalk.red('Please provide a new token!'))
return 1
return process.exit(1)
}

@@ -69,3 +71,3 @@ default:

printUsage()
return 1
return process.exit(1)
}

@@ -94,14 +96,34 @@ }

function zip (appRoot) {
shell.exec(`cd ${appRoot}/build && zip -r -q ${appRoot}/bundle.zip . && cd ${appRoot}`, {silent: true})
return new Promise((resolve, reject) => {
const output = fs.createWriteStream(`${appRoot}/bundle.zip`)
output.on('close', resolve)
output.on('error', reject)
const archive = archiver('zip', {})
archive.pipe(output)
archive.directory(`${appRoot}/build/`, false)
archive.finalize()
})
}
async function deploy (version) {
zip(process.cwd())
const oldVersion = get('version')
version && setVersion(version, {silent: true})
const config = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), '.viewar-config'), 'utf8'))
uploadBundle(config.token, `${process.cwd()}/bundle.zip`)
setVersion(oldVersion, {silent: true})
shell.rm('-rf', `${process.cwd()}/bundle.zip`)
return 0
try {
console.log(chalk`Bundling app...`)
shell.exec('npm run build', {silent: true})
await zip(process.cwd())
const oldVersion = get('version')
version && setVersion(version, {silent: true})
const config = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), '.viewar-config'), 'utf8'))
console.log(chalk`Uploading app bundle...`)
uploadBundle(config.token, `${process.cwd()}/bundle.zip`)
setVersion(oldVersion, {silent: true})
shell.rm('-rf', `${process.cwd()}/bundle.zip`)
shell.rm('-rf', `${process.cwd()}/build`)
console.log(chalk`{bold Done!}`)
process.exit(0)
} catch (error) {
console.error(error)
process.exit(1)
}
}

@@ -111,2 +133,3 @@

console.log(chalk.red('File .viewar-config not found! Are you in a project directory generated by the viewar-cli?'))
process.exit(1)
}

@@ -121,3 +144,3 @@

displayConfigNotFound()
return 1
process.exit(1)
}

@@ -130,3 +153,3 @@ }

displayConfigNotFound()
return
process.exit(1)
}

@@ -141,7 +164,6 @@ return config

const newConfig = {
...config,
const newConfig = Object.assign({}, config, {
token,
version: token.split('-')[1].split('_')[0],
}
})

@@ -155,5 +177,6 @@ fs.writeFileSync(path.resolve(process.cwd(), '.viewar-config'), JSON.stringify(newConfig, null, ' '), 'utf8')

}
process.exit(0)
} catch (err) {
displayConfigNotFound()
return 1
process.exit(1)
}

@@ -169,7 +192,6 @@ }

const newConfig = {
...config,
const newConfig = Object.assign({}, config, {
token: token.split('-')[0] + '-' + version + '_' + token.split('_')[1],
version,
}
})

@@ -184,5 +206,6 @@ fs.writeFileSync(path.resolve(process.cwd(), '.viewar-config'), JSON.stringify(newConfig, null, ' '), 'utf8')

}
process.exit(0)
} catch (err) {
displayConfigNotFound()
return 1
process.exit(1)
}

@@ -197,7 +220,10 @@ }

shell.exec(`git clone -b master ${repo} ./temp && mv ./temp/${type}/* . && rm -rf temp && git init`, {silent: true})
shell.exec(`git clone -b master ${repo} temp`, {silent: true})
shell.mv(`./temp/${type}/*`, `.`)
shell.rm('-rf', 'temp')
shell.exec('git init', {silent: true})
console.log(chalk.bold('\nInstalling dependencies...'))
shell.exec(`npm install`, {silent: true})
shell.exec('npm install', {silent: true})

@@ -208,3 +234,3 @@ const packageInfo = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), 'package.json'), 'utf8'))

name: projectName,
version: "0.1.0",
version: '0.1.0',
description: '',

@@ -230,2 +256,4 @@ })

Open {green \`/src/index.js\`} to begin editing your app.`)
process.exit(1)
}

@@ -232,0 +260,0 @@

{
"name": "viewar-cli",
"version": "0.1.0",
"version": "0.1.3",
"description": "ViewAR SDK Command Line Interface",

@@ -16,7 +16,7 @@ "main": "index.js",

"scripts": {
"version": "npm run build && git add -A",
"version": "git add -A",
"postversion": "git push origin HEAD && git push --tags"
},
"engines": {
"node": ">=6"
"node": ">=8"
},

@@ -27,6 +27,8 @@ "bin": {

"dependencies": {
"archiver": "^2.1.1",
"chalk": "^2.3.0",
"request": "^2.83.0",
"semver": "^5.5.0",
"shelljs": "^0.8.1"
}
}
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