Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cli-engine-command

Package Overview
Dependencies
Maintainers
4
Versions
159
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cli-engine-command - npm Package Compare versions

Comparing version 6.0.2 to 7.0.0

10

lib/command.js

@@ -21,5 +21,5 @@ 'use strict';

var _http = require('./http');
var _httpCall = require('http-call');
var _http2 = _interopRequireDefault(_http);
var _httpCall2 = _interopRequireDefault(_httpCall);

@@ -72,3 +72,7 @@ var _help = require('./help');

this.out = options.output || new _output2.default({ config: this.config });
this.http = new _http2.default(this.out);
this.http = _httpCall2.default.defaults({
headers: {
'user-agent': `${this.config.name}/${this.config.version} (${this.config.platform}-${this.config.arch}) node-${process.version}`
}
});
}

@@ -75,0 +79,0 @@

@@ -11,3 +11,6 @@ 'use strict';

function boolean(options = {}) {
return options;
return {
...options,
parse: null
};
}

@@ -6,13 +6,4 @@ 'use strict';

});
exports.flags = exports.merge = undefined;
exports.flags = undefined;
var _lodash = require('lodash.merge');
Object.defineProperty(exports, 'merge', {
enumerable: true,
get: function () {
return _interopRequireDefault(_lodash).default;
}
});
var _boolean = require('./boolean');

@@ -19,0 +10,0 @@

@@ -6,17 +6,8 @@ 'use strict';

});
exports.default = NumberFlag;
var _string = require('./string');
function NumberFlag(options = {}) {
const required = options.optional === false || options.required;
const defaultOptions = {
parse: (input, cmd, name) => {
let value = input;
if (!value && options.default) return options.default();
if (!value && required) throw new _string.RequiredFlagError(name);
if (value) return parseInt(input);
}
exports.default = StringFlag;
function StringFlag(options = {}) {
return {
parse: (input, cmd, name) => parseInt(input),
...options
};
return Object.assign(defaultOptions, options);
}

@@ -6,25 +6,11 @@ 'use strict';

});
exports.RequiredFlagError = undefined;
exports.default = StringFlag;
var _ = require('.');
require('.');
function StringFlag(options = {}) {
const required = options.optional === false || options.required;
const defaultOptions = {
parse: (input, cmd, name) => {
let value = input;
if (!value && options.default) value = options.default;
if (!value && required) throw new RequiredFlagError(name);
return input;
}
return {
parse: (input, cmd, name) => input,
...options
};
return (0, _.merge)(defaultOptions, options);
}
class RequiredFlagError extends Error {
constructor(name) {
super(`Missing required flag --${name}`);
}
}
exports.RequiredFlagError = RequiredFlagError;
}

@@ -7,6 +7,2 @@ 'use strict';

var _util = require('util');
var _util2 = _interopRequireDefault(_util);
var _httpCall = require('http-call');

@@ -20,99 +16,29 @@

function mergeRequestOptions(...options) {
let output = { method: 'GET', headers: {} };
for (let o of options) {
let headers = Object.assign(output.headers, o.headers);
Object.assign(output, o);
output.headers = headers;
}
return output;
}
function renderHeaders(headers) {
return Object.keys(headers).map(key => {
let value = key.toUpperCase() === 'AUTHORIZATION' ? 'REDACTED' : headers[key];
return ' ' + key + '=' + value;
}).join('\n');
}
class HTTP {
constructor(output, config) {
let self = this;
this.out = output;
this.config = (0, _cliEngineConfig.buildConfig)(config || this.out.config);
this.requestOptions = mergeRequestOptions({
headers: {
'user-agent': `${this.config.name}/${this.config.version} (${this.config.platform}-${this.config.arch}) node-${process.version}`
}
});
this.http = class extends _httpCall2.default {
async _request(...args) {
self._logRequest(this);
await super._request(...args);
self._logResponse(this);
}
};
constructor(config) {
this.config = config || (0, _cliEngineConfig.buildConfig)();
}
get(url, options = {}) {
options = mergeRequestOptions(this.requestOptions, options);
return this.http.get(url, options);
}
post(url, options = {}) {
options = mergeRequestOptions(this.requestOptions, options);
return this.http.post(url, options);
}
put(url, options = {}) {
options = mergeRequestOptions(this.requestOptions, options);
return this.http.put(url, options);
}
patch(url, options = {}) {
options = mergeRequestOptions(this.requestOptions, options);
return this.http.patch(url, options);
}
delete(url, options = {}) {
options = mergeRequestOptions(this.requestOptions, options);
return this.http.delete(url, options);
}
stream(url, options = {}) {
options = mergeRequestOptions(this.requestOptions, options);
return this.http.stream(url, options);
}
request(url, options = {}) {
options = mergeRequestOptions(this.requestOptions, options);
return this.http.request(url, options);
}
get _debugHeaders() {
if (this.out.config.debug > 1) return true;
const HEROKU_DEBUG_HEADERS = process.env.HEROKU_DEBUG_HEADERS;
return HEROKU_DEBUG_HEADERS === 'true' || HEROKU_DEBUG_HEADERS === '1';
}
_logRequest(http) {
if (!this.out.config.debug) return;
this.out.stderr.log(`--> ${http.method} ${http.url}`);
if (this._debugHeaders) {
this.out.stderr.log(renderHeaders(http.headers));
}
// TODO: conditionally add displaying of POST body
// if (body) this.error(`--- BODY\n${util.inspect(body)}\n---`)
}
_logResponse(http) {
if (!this.out.config.debug) return;
this.out.stderr.log(`<-- ${http.method} ${http.url} ${http.response.statusCode}`);
if (this.out.config.debug > 1) {
this.out.stderr.log(renderHeaders(http.response.headers));
if (http.body) this.out.stderr.log(`--- BODY\n${_util2.default.inspect(http.body)}\n---`);
}
}
}
exports.default = HTTP;

@@ -6,2 +6,3 @@ 'use strict';

});
exports.RequiredFlagError = undefined;

@@ -96,2 +97,4 @@ require('./arg');

output.flags[name] = await flag.parse(output.flags[name], this.input.cmd, name);
flag.required = flag.required || flag.optional === false;
if (flag.required && !output.flags[name]) throw new RequiredFlagError(name);
}

@@ -103,2 +106,9 @@ }

}
exports.default = Parse;
exports.default = Parse;
class RequiredFlagError extends Error {
constructor(name) {
super(`Missing required flag --${name}`);
}
}
exports.RequiredFlagError = RequiredFlagError;
{
"name": "cli-engine-command",
"description": "base CLI command for cli-engine",
"version": "6.0.2",
"version": "7.0.0",
"author": "Jeff Dickey @dickeyxxx",

@@ -12,3 +12,3 @@ "bugs": "https://github.com/heroku/cli-engine-command/issues",

"fs-extra": "^4.0.1",
"http-call": "^2.1.5",
"http-call": "^3.0.0",
"lodash.ary": "^4.1.1",

@@ -32,9 +32,10 @@ "lodash.defaults": "^4.2.0",

"babel-jest": "20.0.3",
"babel-plugin-syntax-object-rest-spread": "^6.13.0",
"babel-plugin-transform-class-properties": "6.24.1",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"babel-plugin-transform-flow-strip-types": "6.22.0",
"cli-engine-config": "^1.6.1",
"eslint": "^4.5.0",
"cli-engine-config": "^1.6.4",
"eslint": "^4.6.0",
"eslint-config-standard": "10.2.1",
"eslint-plugin-flowtype": "^2.34.1",
"eslint-plugin-flowtype": "^2.35.1",
"eslint-plugin-import": "^2.7.0",

@@ -45,7 +46,9 @@ "eslint-plugin-jest": "20.0.3",

"eslint-plugin-standard": "3.0.1",
"flow-bin": "^0.53.1",
"flow-bin": "^0.54.0",
"flow-copy-source": "^1.2.1",
"flow-typed": "^2.1.5",
"husky": "^0.14.3",
"jest": "20.0.4",
"jest-junit": "^3.0.0",
"lint-staged": "^4.0.4",
"nock": "^9.0.14",

@@ -78,2 +81,8 @@ "nodemon": "1.11.0",

"license": "ISC",
"lint-staged": {
"src/**/*.js": [
"eslint --fix",
"git add"
]
},
"main": "lib/index.js",

@@ -88,2 +97,3 @@ "peerDependencies": {

"copy-flow": "flow-copy-source -v -i '**/*.test.js' src lib",
"precommit": "lint-staged",
"prepare": "npm run clean && npm run build && npm run copy-flow",

@@ -90,0 +100,0 @@ "test": "jest && flow && eslint .",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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