mockyeah-cli
Advanced tools
Comparing version 0.22.1 to 0.23.1
@@ -5,23 +5,2 @@ #!/usr/bin/env node | ||
/** | ||
* mockyeah cli api "table of contents". | ||
* Root `mockyeah` command does not invoke behavior other than | ||
* providing user with a catalog of available actions. | ||
*/ | ||
const program = require('commander'); | ||
const boot = require('../lib/boot'); | ||
const version = require('../version'); | ||
program.parse(process.argv); | ||
boot(() => { | ||
program | ||
.version(version) | ||
.command('ls', 'list suites') | ||
.command('play [name]', 'play suite') | ||
.command('playAll', 'play all suites') | ||
.command('record [name]', 'record suite') | ||
.command('start', 'start server') | ||
.parse(process.argv); | ||
}); | ||
require('./mockyeah'); |
@@ -17,12 +17,15 @@ 'use strict'; | ||
program.option('-v, --verbose', 'verbose output').parse(process.argv); | ||
program | ||
.arguments('[suiteNames]') | ||
.option('-v, --verbose', 'verbose output') | ||
.parse(process.argv); | ||
const withName = (env, name) => { | ||
const withNames = (env, names) => { | ||
const { adminUrl } = env; | ||
request.get(`${adminUrl}/play?name=${name}`, err => { | ||
request.get(`${adminUrl}/play?name=${names.join(',')}`, err => { | ||
if (err) { | ||
// TODO: Detect errors that shouldn't result in local fallback. | ||
// eslint-disable-next-line global-require, import/no-dynamic-require | ||
require(env.modulePath).play(name); | ||
require(env.modulePath).play(names); | ||
} | ||
@@ -36,3 +39,3 @@ }); | ||
boot(env => { | ||
const name = program.args[0]; | ||
const names = program.args; | ||
@@ -53,9 +56,9 @@ const { suitesDir } = env.config; | ||
console.log(chalk.red('No suites available to start')); | ||
console.log(chalk.red('Record one by running: mockyeah record [name]')); | ||
console.log(chalk.red('Record one by running: mockyeah record [suiteName]')); | ||
process.exit(0); | ||
} | ||
if (!name) { | ||
inquirer.prompt( | ||
[ | ||
if (!names) { | ||
inquirer | ||
.prompt([ | ||
{ | ||
@@ -67,9 +70,9 @@ type: 'list', | ||
} | ||
] | ||
).then(answers => { | ||
withName(env, answers.name); | ||
}); | ||
]) | ||
.then(answers => { | ||
withNames(env, [answers.name]); | ||
}); | ||
} else { | ||
withName(env, name); | ||
withNames(env, names); | ||
} | ||
}); |
@@ -31,12 +31,8 @@ 'use strict'; | ||
.option( | ||
'-g, --groups [name]', | ||
'-g, --groups [names]', | ||
'record with these named groups from configuration (comma-separated and/or repeatable)', | ||
collectCommaSeparated | ||
) | ||
.option('--group [names]', 'alias of -g, --groups', collectCommaSeparated) | ||
.option( | ||
'--group [name]', | ||
'alias of -g, --groups', | ||
collectCommaSeparated | ||
) | ||
.option( | ||
'-o, --only [regex]', | ||
@@ -81,4 +77,4 @@ 'only record calls to URLs matching given regex pattern (repeatable)', | ||
inquirer.prompt( | ||
[ | ||
inquirer | ||
.prompt([ | ||
{ | ||
@@ -89,21 +85,19 @@ type: 'confirm', | ||
} | ||
] | ||
).then(answer => { | ||
const { write = true } = answer; | ||
]) | ||
.then(answer => { | ||
const { write = true } = answer; | ||
const stopOptions = { noWrite: !write }; | ||
const stopOptions = { noWrite: !write }; | ||
if (remote) { | ||
const qs2 = querystring.stringify({ | ||
options: JSON.stringify(stopOptions) | ||
}); | ||
if (remote) { | ||
const qs2 = querystring.stringify({ | ||
options: JSON.stringify(stopOptions) | ||
}); | ||
request.get(`${adminUrl}/record-stop?${qs2}`, recordStopCallback, { | ||
}); | ||
} else { | ||
// eslint-disable-next-line global-require, import/no-dynamic-require | ||
require(env.modulePath).recordStop(stopOptions, recordStopCallback); | ||
} | ||
}); | ||
request.get(`${adminUrl}/record-stop?${qs2}`, recordStopCallback, {}); | ||
} else { | ||
// eslint-disable-next-line global-require, import/no-dynamic-require | ||
require(env.modulePath).recordStop(stopOptions, recordStopCallback); | ||
} | ||
}); | ||
}); | ||
@@ -130,4 +124,4 @@ }; | ||
if (!name) { | ||
inquirer.prompt( | ||
[ | ||
inquirer | ||
.prompt([ | ||
{ | ||
@@ -138,11 +132,11 @@ type: 'input', | ||
} | ||
] | ||
).then(answers => { | ||
if (!answers.name.length) { | ||
console.log(chalk.red('Recording name required')); | ||
process.exit(1); | ||
} | ||
]) | ||
.then(answers => { | ||
if (!answers.name.length) { | ||
console.log(chalk.red('Recording name required')); | ||
process.exit(1); | ||
} | ||
withName(env, answers.name, options); | ||
}) | ||
withName(env, answers.name, options); | ||
}); | ||
} else { | ||
@@ -149,0 +143,0 @@ withName(env, name, options); |
@@ -12,5 +12,3 @@ 'use strict'; | ||
program | ||
.option('-w, --watch', 'enable watch mode') | ||
.parse(process.argv); | ||
program.option('-w, --watch', 'enable watch mode').parse(process.argv); | ||
@@ -17,0 +15,0 @@ boot(env => { |
{ | ||
"name": "mockyeah-cli", | ||
"version": "0.22.1", | ||
"version": "0.23.1", | ||
"description": "A powerful service mocking, recording, and playback utility.", | ||
@@ -65,3 +65,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"mockyeah": "^0.22.1" | ||
"mockyeah": "^0.23.1" | ||
}, | ||
@@ -68,0 +68,0 @@ "engines": { |
# mockyeah-cli | ||
Command line utility for [mockyeah](https://github.com/ryanricard/mockyeah), | ||
Command line utility for [mockyeah](https://github.com/mockyeah/mockyeah), | ||
a powerful service mocking, recording, and playback utility. | ||
<img src="../../packages/mockyeah-docs/book/logo/mockyeah.png" height="200" /> | ||
<img src="https://raw.githubusercontent.com/mockyeah/mockyeah/master/packages/mockyeah-docs/book/images/logo/mockyeah-600.png" height="200" /> | ||
@@ -19,7 +19,7 @@ [![npm](https://img.shields.io/npm/v/mockyeah-cli.svg)](https://www.npmjs.com/package/mockyeah-cli) | ||
ls list suites | ||
play [name] play suite | ||
playAll play all suites | ||
record [name] record suite | ||
help [cmd] display help for [cmd] | ||
ls list suites | ||
play [suiteNames] play suite(s) | ||
playAll play all suites | ||
record [suiteName] record suite | ||
help [cmd] display help for [cmd] | ||
@@ -26,0 +26,0 @@ Options: |
'use strict'; | ||
module.exports = require('./package.json').version; | ||
module.exports = require('./package.json').version; |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
0
11294
12
301