wappsto-cli
Advanced tools
Comparing version 1.1.5 to 1.1.6
@@ -16,17 +16,17 @@ const axios = require('axios'); | ||
static async post(url, data) { | ||
return axios.post(url, data); | ||
static async post(url, data, options = {}) { | ||
return axios.post(url, data, options); | ||
} | ||
static async put(url, data) { | ||
return axios.put(url, data); | ||
static async put(url, data, options = {}) { | ||
return axios.put(url, data, options); | ||
} | ||
static async patch(url, data) { | ||
return axios.patch(url, data); | ||
static async patch(url, data, options = {}) { | ||
return axios.patch(url, data, options); | ||
} | ||
static async delete(url) { | ||
return axios.delete(url); | ||
static async delete(url, options = {}) { | ||
return axios.delete(url, options); | ||
} | ||
}; |
@@ -9,2 +9,6 @@ const tui = require('./tui'); | ||
setMessage(message) { | ||
this.title = message; | ||
} | ||
start() { | ||
@@ -11,0 +15,0 @@ const len = this.frames.length; |
145
lib/tui.js
@@ -51,3 +51,3 @@ const Inquirer = require('inquirer'); | ||
loadOldWapp: () => { | ||
askForNewWapp: (wapps) => { | ||
const questions = [ | ||
@@ -57,84 +57,16 @@ { | ||
type: 'confirm', | ||
when: wapps.length, | ||
message: 'Do you want to load an existing Wapp?', | ||
}, | ||
]; | ||
return Inquirer.prompt(questions); | ||
}, | ||
deleteWapp: () => { | ||
const questions = [ | ||
{ | ||
name: 'del', | ||
type: 'confirm', | ||
message: 'Do you want to delete the Wapp?', | ||
default: false, | ||
}, | ||
{ | ||
name: 'local', | ||
type: 'confirm', | ||
message: 'Do you want to delete the local files?', | ||
when: answer => answer.del, | ||
}, | ||
{ | ||
name: 'remote', | ||
type: 'confirm', | ||
message: 'Do you want to delete the Wapp on Wappsto?', | ||
when: answer => answer.del, | ||
}, | ||
]; | ||
return Inquirer.prompt(questions); | ||
}, | ||
listWapps: (wapps) => { | ||
const questions = [ | ||
{ | ||
name: 'wapp', | ||
type: 'list', | ||
when: answer => answer.load, | ||
message: 'Please choose the wapp to download:', | ||
choices: wapps, | ||
}, | ||
]; | ||
return Inquirer.prompt(questions); | ||
}, | ||
precisePermissionRequest: (request) => { | ||
let msg = ''; | ||
if (request.message) { | ||
msg = request.message; | ||
} else { | ||
msg = `${request.name_installation} would like to save data under your account. Allow?`; | ||
} | ||
const questions = [ | ||
{ | ||
name: 'accept', | ||
type: 'confirm', | ||
message: msg, | ||
}, | ||
]; | ||
return Inquirer.prompt(questions); | ||
}, | ||
permissionRequest: (request, data) => { | ||
let msg = ''; | ||
if (request.message) { | ||
msg = request.message; | ||
} else { | ||
msg = `Please choose the ${request.type} to share with ${request.name_installation}:`; | ||
} | ||
const questions = [ | ||
{ | ||
name: 'permission', | ||
type: 'checkbox', | ||
message: msg, | ||
choices: data, | ||
}, | ||
]; | ||
return Inquirer.prompt(questions); | ||
}, | ||
askForNewWapp: () => { | ||
const questions = [ | ||
{ | ||
name: 'name', | ||
type: 'input', | ||
when: answer => !answer.load, | ||
message: 'Please enter the name of your Wapp:', | ||
@@ -151,2 +83,3 @@ validate: (answer) => { | ||
type: 'input', | ||
when: answer => !answer.load, | ||
message: 'Please enter the Author of your Wapp:', | ||
@@ -157,3 +90,5 @@ }, | ||
type: 'input', | ||
when: answer => !answer.load, | ||
message: 'Please enter the Version of your Wapp:', | ||
default: '0.0.1', | ||
validate: (answer) => { | ||
@@ -169,2 +104,3 @@ if (/^\d\.\d\.\d$/.test(answer)) { | ||
type: 'checkbox', | ||
when: answer => !answer.load, | ||
message: 'Please choose features for the Wapp:', | ||
@@ -191,2 +127,3 @@ choices: [ | ||
type: 'input', | ||
when: answer => !answer.load, | ||
message: 'Please enter a general descrption about your Wapp:', | ||
@@ -198,3 +135,3 @@ }, | ||
message: 'Please enter a description about your foreground part of your Wapp:', | ||
when: answer => answer.features.indexOf('foreground') !== -1, | ||
when: answer => !answer.load && answer.features.indexOf('foreground') !== -1, | ||
}, | ||
@@ -205,3 +142,3 @@ { | ||
message: 'Please enter a description about your background part of your Wapp:', | ||
when: answer => answer.features.indexOf('background') !== -1, | ||
when: answer => !answer.load && answer.features.indexOf('background') !== -1, | ||
}, | ||
@@ -211,2 +148,3 @@ { | ||
type: 'confirm', | ||
when: answer => !answer.load, | ||
message: 'Generate example files for the Wapp?', | ||
@@ -219,2 +157,61 @@ default: false, | ||
deleteWapp: () => { | ||
const questions = [ | ||
{ | ||
name: 'del', | ||
type: 'confirm', | ||
message: 'Do you want to delete the Wapp?', | ||
default: false, | ||
}, | ||
{ | ||
name: 'local', | ||
type: 'confirm', | ||
message: 'Do you want to delete the local files?', | ||
when: answer => answer.del, | ||
}, | ||
{ | ||
name: 'remote', | ||
type: 'confirm', | ||
message: 'Do you want to delete the Wapp on Wappsto?', | ||
when: answer => answer.del, | ||
}, | ||
]; | ||
return Inquirer.prompt(questions); | ||
}, | ||
precisePermissionRequest: (request) => { | ||
let msg = ''; | ||
if (request.message) { | ||
msg = request.message; | ||
} else { | ||
msg = `${request.name_installation} would like to save data under your account. Allow?`; | ||
} | ||
const questions = [ | ||
{ | ||
name: 'accept', | ||
type: 'confirm', | ||
message: msg, | ||
}, | ||
]; | ||
return Inquirer.prompt(questions); | ||
}, | ||
permissionRequest: (request, data) => { | ||
let msg = ''; | ||
if (request.message) { | ||
msg = request.message; | ||
} else { | ||
msg = `Please choose the ${request.type} to share with ${request.name_installation}:`; | ||
} | ||
const questions = [ | ||
{ | ||
name: 'permission', | ||
type: 'checkbox', | ||
message: msg, | ||
choices: data, | ||
}, | ||
]; | ||
return Inquirer.prompt(questions); | ||
}, | ||
remoteVersionUpdated: () => { | ||
@@ -221,0 +218,0 @@ const questions = [ |
@@ -56,37 +56,33 @@ const fs = require('fs'); | ||
async create() { | ||
let status = new Spinner('Loading Wapps, please wait...'); | ||
const listWapps = []; | ||
const status = new Spinner('Loading Wapps, please wait...'); | ||
status.start(); | ||
await this.wappsto.loadApplications(); | ||
const wapps = await this.wappsto.loadApplications(); | ||
if (wapps.length) { | ||
wapps.forEach((w) => { | ||
if (w.version && w.version[0]) { | ||
const { name } = w.version[0]; | ||
const { id } = w.meta; | ||
listWapps.push({ | ||
name: `${name} (${id})`, | ||
value: id, | ||
}); | ||
} | ||
}); | ||
} | ||
status.stop(); | ||
const wapps = this.wappsto.getApplications(); | ||
if (wapps.length) { | ||
const oldWapps = await tui.loadOldWapp(); | ||
if (oldWapps.load) { | ||
const listWapps = []; | ||
wapps.forEach((w) => { | ||
if (w.version && w.version[0]) { | ||
const { name } = w.version[0]; | ||
const { id } = w.meta; | ||
listWapps.push({ | ||
name: `${name} (${id})`, | ||
value: id, | ||
}); | ||
} | ||
}); | ||
const whatWapp = await tui.listWapps(listWapps); | ||
const newWapp = await tui.askForNewWapp(listWapps); | ||
if (newWapp.load) { | ||
const id = newWapp.wapp; | ||
const wapp = wapps.find(w => w.meta.id === id); | ||
const id = whatWapp.wapp; | ||
const wapp = wapps.find(w => w.meta.id === id); | ||
await this.downloadWapp(wapp); | ||
return; | ||
} | ||
await this.downloadWapp(wapp); | ||
return; | ||
} | ||
const newWapp = await tui.askForNewWapp(); | ||
status = new Spinner('Creating Wapp, please wait...'); | ||
status.setMessage('Creating Wapp, please wait...'); | ||
status.start(); | ||
@@ -145,3 +141,3 @@ const data = await this.wappsto.createApplication(newWapp); | ||
} catch (err) { | ||
console.error('Failed to download path'); | ||
files.deleteFile(path); | ||
} | ||
@@ -272,6 +268,11 @@ } | ||
const status = new Spinner('Uploading Wapp to Wappsto, please wait...'); | ||
status.start(); | ||
const remoteVersion = await this.wappsto.getVersion(versionID); | ||
if (remoteVersion.meta.revision !== localVersion.revision | ||
&& !Wapp.compareVersions(this.manifest, remoteVersion)) { | ||
status.stop(); | ||
const overide = await tui.remoteVersionUpdated(); | ||
status.start(); | ||
if (overide.local) { | ||
@@ -285,4 +286,2 @@ upload = false; | ||
const status = new Spinner('Uploading Wapp to Wappsto, please wait...'); | ||
status.start(); | ||
@@ -289,0 +288,0 @@ // Find all files on disk |
@@ -115,2 +115,3 @@ const WebSocket = require('ws'); | ||
this.applications = response.data; | ||
return response.data; | ||
} catch (err) { | ||
@@ -130,6 +131,2 @@ throw new Error('Failed to load applications'); | ||
getApplications() { | ||
return this.applications; | ||
} | ||
async createApplication(info) { | ||
@@ -136,0 +133,0 @@ try { |
{ | ||
"name": "wappsto-cli", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "Command Line Interface for Wappsto", | ||
@@ -54,3 +54,3 @@ "scripts": { | ||
"devDependencies": { | ||
"ava": "^1.3.1", | ||
"ava": "^1.4.0", | ||
"axios-mock-adapter": "^1.16.0", | ||
@@ -62,7 +62,14 @@ "coveralls": "^3.0.3", | ||
"eslint-plugin-import": "^2.16.0", | ||
"mock-inquirer": "^1.0.2", | ||
"husky": "^1.3.1", | ||
"mock-inquirer": "git+https://github.com/AndreasBomholtz/mock-inquirer.git", | ||
"mock-require": "^3.0.3", | ||
"np": "^4.0.2", | ||
"nyc": "^13.3.0" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "npm test", | ||
"pre-push": "npm test" | ||
} | ||
} | ||
} |
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
74064
12
1666