downloadstation-cli
Advanced tools
Comparing version 0.3.1 to 0.4.0
@@ -49,3 +49,3 @@ #!/usr/bin/env node | ||
.command('list', { desc: 'List your tasks', run: list }) | ||
.command('new', { desc: 'Add new download task', run: create }) | ||
.command('add', { desc: 'Add new download task', run: create }) | ||
.command('config', { | ||
@@ -61,6 +61,5 @@ desc: 'Setup your Synology Download Station', | ||
async function main() { | ||
const argv = await cli.parseAndExit(); | ||
console.log(JSON.stringify(argv, null, 2)); | ||
await cli.parseAndExit(); | ||
} | ||
if (require.main === module) main(); |
const inquirer = require('inquirer'); | ||
const chalk = require('chalk'); | ||
const ora = require('ora'); | ||
@@ -21,5 +22,9 @@ const initialize = require('./init'); | ||
const spinner = ora('Adding new task ...').start(); | ||
// create new task | ||
const task = await synology.create(answers.url); | ||
spinner.stop(); | ||
if (task.success === true) { | ||
@@ -26,0 +31,0 @@ console.log(chalk.green('Download task successfully created')); |
const inquirer = require('inquirer'); | ||
const validator = require('validator'); | ||
const Configstore = require('configstore'); | ||
const keytar = require('keytar'); | ||
@@ -54,6 +53,5 @@ const packageJson = require('../package.json'); | ||
config.set('username', answers.username); | ||
keytar.setPassword(packageJson.name, answers.username, answers.password); | ||
config.set('password', answers.password); | ||
}; | ||
module.exports = { setup }; |
const Table = require('cli-table'); | ||
const chalk = require('chalk'); | ||
const pretty = require('prettysize'); | ||
const ora = require('ora'); | ||
const { handleError } = require('../lib/helpers'); | ||
const { getError } = require('../lib/error-codes'); | ||
const initialize = require('./init'); | ||
const list = async () => { | ||
const spinner = ora('Retrieving tasks ...').start(); | ||
// initialize synology connection | ||
@@ -16,3 +22,5 @@ const synology = await initialize(); | ||
// no tasks found, terminate here | ||
if (ids.length === 0) { | ||
spinner.stop(); | ||
console.log(chalk.green('No downloads tasks found')); | ||
@@ -24,5 +32,13 @@ process.exit(); | ||
const tasksInfo = await synology.tasksInfo(ids.join(',')); | ||
// check for valid response | ||
if (tasksInfo.success === false) { | ||
spinner.stop(); | ||
const errorMessage = getError(tasksInfo.error.code); | ||
handleError(errorMessage); | ||
} | ||
const tasksDetails = tasksInfo.data.tasks; | ||
const width = process.stdout.columns - 67; | ||
const width = process.stdout.columns - 70; | ||
@@ -32,3 +48,3 @@ // build output table | ||
style: { head: ['green'] }, | ||
colWidths: [width, 12, 12, 12, 12, 12], | ||
colWidths: [width, 12, 12, 12, 13, 12], | ||
head: [ | ||
@@ -55,2 +71,4 @@ 'File name', | ||
spinner.stop(); | ||
console.log(table.toString()); | ||
@@ -57,0 +75,0 @@ }; |
const Configstore = require('configstore'); | ||
const keytar = require('keytar'); | ||
@@ -15,15 +14,9 @@ const packageJson = require('../package.json'); | ||
async getCredentials() { | ||
const { url, username, token } = this.config.all; | ||
const { url, username, password, token } = this.config.all; | ||
if (!url || !username || !token) { | ||
if (!url || !username || !password || !token) { | ||
return null; | ||
} | ||
const password = await keytar.getPassword(packageJson.name, username); | ||
if (password === null) { | ||
return null; | ||
} | ||
return { url, username, token, password }; | ||
return { url, username, password, token }; | ||
} | ||
@@ -30,0 +23,0 @@ |
@@ -0,1 +1,3 @@ | ||
const chalk = require('chalk'); | ||
const packageJson = require('../package.json'); | ||
@@ -5,4 +7,10 @@ | ||
const handleError = message => { | ||
console.error(chalk.white.bgRed(message)); | ||
process.exit(1); | ||
}; | ||
module.exports = { | ||
getCommandName, | ||
handleError, | ||
}; |
{ | ||
"name": "downloadstation-cli", | ||
"description": "Manage your Synology Download Station from your terminal", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"author": "Martín M.", | ||
@@ -29,4 +29,4 @@ "license": "MIT", | ||
"inquirer": "^7.1.0", | ||
"keytar": "^5.5.0", | ||
"node-fetch": "^2.6.0", | ||
"ora": "^4.0.4", | ||
"prettysize": "^2.0.0", | ||
@@ -33,0 +33,0 @@ "sywac": "^1.3.0", |
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
12233
13
340
+ Addedora@^4.0.4
+ Addedansi-styles@3.2.1(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcli-spinners@2.9.2(transitive)
+ Addedclone@1.0.4(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addeddefaults@1.0.4(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedis-interactive@1.0.0(transitive)
+ Addedlog-symbols@3.0.0(transitive)
+ Addedora@4.1.1(transitive)
+ Addedsupports-color@5.5.0(transitive)
+ Addedwcwidth@1.0.1(transitive)
- Removedkeytar@^5.5.0
- Removedansi-regex@2.1.1(transitive)
- Removedaproba@1.2.0(transitive)
- Removedare-we-there-yet@1.1.7(transitive)
- Removedbase64-js@1.5.1(transitive)
- Removedbl@4.1.0(transitive)
- Removedbuffer@5.7.1(transitive)
- Removedchownr@1.1.4(transitive)
- Removedcode-point-at@1.1.0(transitive)
- Removedconsole-control-strings@1.1.0(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removeddecompress-response@4.2.1(transitive)
- Removeddelegates@1.0.0(transitive)
- Removeddetect-libc@1.0.3(transitive)
- Removedexpand-template@2.0.3(transitive)
- Removedfs-constants@1.0.0(transitive)
- Removedgauge@2.7.4(transitive)
- Removedgithub-from-package@0.0.0(transitive)
- Removedhas-unicode@2.0.1(transitive)
- Removedieee754@1.2.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedini@1.3.8(transitive)
- Removedis-fullwidth-code-point@1.0.0(transitive)
- Removedisarray@1.0.0(transitive)
- Removedkeytar@5.6.0(transitive)
- Removedmimic-response@2.1.0(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedmkdirp-classic@0.5.3(transitive)
- Removednan@2.14.1(transitive)
- Removednapi-build-utils@1.0.2(transitive)
- Removednode-abi@2.30.1(transitive)
- Removednoop-logger@0.1.1(transitive)
- Removednpmlog@4.1.2(transitive)
- Removednumber-is-nan@1.0.1(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedprebuild-install@5.3.3(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedreadable-stream@2.3.83.6.2(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedsemver@5.7.2(transitive)
- Removedset-blocking@2.0.0(transitive)
- Removedsimple-concat@1.0.1(transitive)
- Removedsimple-get@3.1.1(transitive)
- Removedstring-width@1.0.2(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedtar-fs@2.1.1(transitive)
- Removedtar-stream@2.2.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removedwhich-pm-runs@1.1.0(transitive)
- Removedwide-align@1.1.5(transitive)