prostore.cli
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -7,14 +7,9 @@ #!/usr/bin/env node | ||
nomnom.command('login') | ||
.help('Obtain authentication tokens for ProStore') | ||
.help('Получить аутентификацию из ProStore') | ||
.option('url', { | ||
position: 1, | ||
help: 'Store URL (e.g. https://example.store)' | ||
help: 'URL магазина (пр. https://example.store)' | ||
}) | ||
.option('verbose', { | ||
abbr: 'v', | ||
help: 'Print debug messages', | ||
flag: true | ||
}) | ||
.option('cwd', { | ||
help: 'Current work directory', | ||
help: 'Рабочая директория', | ||
default: process.cwd() | ||
@@ -25,58 +20,43 @@ }) | ||
nomnom.command('status') | ||
.option('verbose', { | ||
abbr: 'v', | ||
help: 'Print debug messages', | ||
flag: true | ||
}) | ||
.help('Показать отличия локальной версии от версии на сервере') | ||
.option('cwd', { | ||
help: 'Current work directory', | ||
help: 'Рабочая директория', | ||
default: process.cwd() | ||
}) | ||
.callback(require('../lib/cmd/status')) | ||
.help('Show what\'s modified on server vs. locally'); | ||
.callback(require('../lib/cmd/status')); | ||
nomnom.command('pull') | ||
.help('Скачать файлы с сервера') | ||
.option('force', { | ||
flag: true, | ||
help: 'Ignore last modified cache' | ||
help: 'Не использовать кэш' | ||
}) | ||
.option('remove', { | ||
flag: true, | ||
help: 'Remove files not present on server' | ||
help: 'Удалить файлы локально, если их больше нет на сервере' | ||
}) | ||
.option('verbose', { | ||
abbr: 'v', | ||
help: 'Print debug messages', | ||
flag: true | ||
}) | ||
.option('theme', { | ||
help: 'Download theme files instead' | ||
help: 'Скачать обновление указанной темы' | ||
}) | ||
.option('cwd', { | ||
help: 'Current work directory', | ||
help: 'Рабочая директория', | ||
default: process.cwd() | ||
}) | ||
.callback(require('../lib/cmd/pull')) | ||
.help('Download store files from server'); | ||
.callback(require('../lib/cmd/pull')); | ||
nomnom.command('push') | ||
.help('Загрузить файлы на сервер') | ||
.option('force', { | ||
flag: true, | ||
help: 'Ignore last modified cache' | ||
help: 'Не использовать кэш' | ||
}) | ||
.option('remove', { | ||
flag: true, | ||
help: 'Remove files not present locally' | ||
help: 'Удалить файлы с сервера, которых больше нет локально' | ||
}) | ||
.option('verbose', { | ||
abbr: 'v', | ||
help: 'Print debug messages', | ||
flag: true | ||
}) | ||
.option('cwd', { | ||
help: 'Current work directory', | ||
help: 'Рабочая директория', | ||
default: process.cwd() | ||
}) | ||
.callback(require('../lib/cmd/push')) | ||
.help('Upload store files to server'); | ||
.callback(require('../lib/cmd/push')); | ||
@@ -90,8 +70,8 @@ nomnom.command('mock') | ||
.option('cwd', { | ||
help: 'Current work directory', | ||
help: 'Рабочая директория', | ||
default: process.cwd() | ||
}) | ||
.callback(require('../lib/cmd/mock')) | ||
.help('Start mock server for local development'); | ||
.help('Запустить мокап для локальной разработки'); | ||
nomnom.parse(); |
@@ -8,7 +8,7 @@ 'use strict'; | ||
if (!url) | ||
throw new Error('ProStore URL not specified.\n' + | ||
'Make sure `prostore.json` contains valid `url`.'); | ||
throw new Error('ProStore URL не указан.\n' + | ||
'Убедитесь, что `prostore.json` содержит `url`.'); | ||
var creds = require('./credentials')(options)[url]; | ||
if (!creds) | ||
throw new Error('Auth credentials not found. Run `prostore login`.'); | ||
throw new Error('Ошибка аутентификации. Запустите `prostore login`.'); | ||
return new Client({ | ||
@@ -15,0 +15,0 @@ url: url, |
@@ -10,3 +10,4 @@ 'use strict'; | ||
, sha256 = require('sha256') | ||
, homedir = require('homedir'); | ||
, homedir = require('homedir') | ||
, colors = require('colors'); | ||
@@ -18,3 +19,3 @@ module.exports = exports = function(opts) { | ||
if (!/https?:\/\/\S+/g.test(url)) | ||
return done(new Error('URL must start with http:// or https://')); | ||
return done(new Error('URL должен начинаться с http:// или https://')); | ||
prompt.message = 'Login'; | ||
@@ -28,3 +29,3 @@ var schema = { | ||
password: { | ||
description: 'Password', | ||
description: 'Пароль', | ||
hidden: true, | ||
@@ -49,4 +50,5 @@ required: true | ||
if (err) return done(err); | ||
if (res.statusCode == 404) | ||
return done(new Error('Incorrect email or password.')); | ||
var user = body && body.user || {}; | ||
if (!user._id) | ||
return done(new Error('Ошибка входа, попробуйте еще раз.')); | ||
var credentialsFile = path.join(homedir(), '.prostore'); | ||
@@ -56,3 +58,3 @@ fs.readJsonFile(credentialsFile, 'utf-8', function(err, loginData) { | ||
loginData[url] = { | ||
userId: body.userId, | ||
userId: body.user._id, | ||
privateToken: body.privateToken | ||
@@ -69,3 +71,8 @@ }; | ||
}); | ||
async.parallel(queries, done); | ||
async.parallel(queries, function(err) { | ||
if (err) return done(err); | ||
console.log('Добро пожаловать, %s %s!', | ||
colors.yellow(user.firstName), | ||
colors.yellow(user.secondName)) | ||
}); | ||
}); | ||
@@ -72,0 +79,0 @@ }); |
@@ -7,3 +7,3 @@ 'use strict'; | ||
, fs = require('fs-extra') | ||
, colors = require('cli-color') | ||
, colors = require('colors') | ||
, path = require('path') | ||
@@ -47,4 +47,4 @@ , glob = require('prostore.glob-utils'); | ||
} else { | ||
console.log('%s file(s) no longer exist on server; ' + | ||
'use --remove to remove them locally', | ||
console.log('%s файл(ов) были удалены на сервере; ' + | ||
'используйте --remove, чтобы удалить их локально', | ||
colors.red(diff.removed.length)); | ||
@@ -88,3 +88,3 @@ } | ||
if (err) return done(err); | ||
console.log('Pull done:'); | ||
console.log('prostore pull:'); | ||
console.log('\t%s pulled', colors.green(cSuccess)); | ||
@@ -91,0 +91,0 @@ console.log('\t%s removed', colors.red(cRemoved)); |
@@ -7,3 +7,3 @@ 'use strict'; | ||
, fs = require('fs-extra') | ||
, colors = require('cli-color') | ||
, colors = require('colors') | ||
, path = require('path') | ||
@@ -41,4 +41,4 @@ , glob = require('prostore.glob-utils'); | ||
} else { | ||
console.log('%s file(s) no longer exist locally; ' + | ||
'use --remove to remove them from server', | ||
console.log('%s файл(ов) были удалены локально; ' + | ||
'используйте --remove, чтобы удалить их с сервера', | ||
colors.red(diff.removed.length)); | ||
@@ -45,0 +45,0 @@ } |
@@ -6,3 +6,3 @@ 'use strict'; | ||
, done = require('../done') | ||
, colors = require('cli-color') | ||
, colors = require('colors') | ||
, path = require('path') | ||
@@ -22,3 +22,3 @@ , glob = require('prostore.glob-utils'); | ||
if (diff.added.length) { | ||
console.log('%s file(s) added', colors.green(diff.added.length)); | ||
console.log('%s файл(ов) добавлено', colors.green(diff.added.length)); | ||
diff.added.forEach(function(file) { | ||
@@ -29,3 +29,3 @@ console.log('\t%s', file.path); | ||
if (diff.removed.length) { | ||
console.log('%s file(s) removed', colors.red(diff.removed.length)); | ||
console.log('%s файл(ов) удалено', colors.red(diff.removed.length)); | ||
diff.removed.forEach(function(file) { | ||
@@ -36,3 +36,3 @@ console.log('\t%s', file.path); | ||
if (diff.modified.length) { | ||
console.log('%s file(s) modified', colors.yellow(diff.modified.length)); | ||
console.log('%s файл(ов) изменено', colors.yellow(diff.modified.length)); | ||
diff.modified.forEach(function(file) { | ||
@@ -43,3 +43,3 @@ console.log('\t%s', file.path); | ||
if (diff.added.length + diff.removed.length + diff.modified.length == 0) | ||
console.log('This project is up-to-date with server.'); | ||
console.log('Проект синхронизирован с сервером.'); | ||
done(); | ||
@@ -46,0 +46,0 @@ }); |
@@ -12,3 +12,2 @@ "use strict"; | ||
* @param {string} options.file - credentials file, defaults to `$HOME/.prostore` | ||
* @param {string} options.verbose - print debug messages if true | ||
* @returns {object} credentials object or {} | ||
@@ -20,10 +19,8 @@ * @module credentials | ||
var file = options.file || path.resolve(homedir(), '.prostore'); | ||
if (options.verbose) | ||
console.log('Reading credentials from %s', file); | ||
try { | ||
return fs.readJsonFileSync(file, 'utf-8'); | ||
} catch (e) { | ||
console.error('Couldn\'t read credentials from %s', file); | ||
console.error('Не удалось прочитать данные аутентификации из %s', file); | ||
return {}; | ||
} | ||
}; |
@@ -11,3 +11,2 @@ "use strict"; | ||
* @param {string} options.file - override default file | ||
* @param {string} options.verbose - print debug messages if true | ||
* @returns {object} data or empty object if file does not exist | ||
@@ -19,4 +18,2 @@ * @module locals | ||
var file = options.file || path.resolve(process.cwd(), 'prostore.json'); | ||
if (options.verbose) | ||
console.log('Reading locals from %s', file); | ||
try { | ||
@@ -23,0 +20,0 @@ return fs.readJsonFileSync(file, 'utf-8') || {}; |
{ | ||
"name": "prostore.cli", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "ProStore Command Line Interface", | ||
@@ -21,3 +21,3 @@ "bin": { | ||
"async": "*", | ||
"cli-color": "*", | ||
"colors": "*", | ||
"homedir": "*", | ||
@@ -24,0 +24,0 @@ "express": "*", |
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
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
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
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
19705
569
+ Addedcolors@*
+ Addedcolors@1.4.0(transitive)
- Removedcli-color@*
- Removedcli-color@2.0.4(transitive)
- Removedd@1.0.2(transitive)
- Removedes5-ext@0.10.64(transitive)
- Removedes6-iterator@2.0.3(transitive)
- Removedes6-symbol@3.1.4(transitive)
- Removedes6-weak-map@2.0.3(transitive)
- Removedesniff@2.0.1(transitive)
- Removedevent-emitter@0.3.5(transitive)
- Removedext@1.7.0(transitive)
- Removedis-promise@2.2.2(transitive)
- Removedlru-queue@0.1.0(transitive)
- Removedmemoizee@0.4.17(transitive)
- Removednext-tick@1.1.0(transitive)
- Removedtimers-ext@0.1.8(transitive)
- Removedtype@2.7.3(transitive)