WIP - add extractor, generate snippet_data

This commit is contained in:
Stefan Fejes
2019-08-20 15:52:05 +02:00
parent 88084d3d30
commit cc8f1d8a7a
37396 changed files with 4588842 additions and 133 deletions

19
node_modules/ltcdr/test/test.literal.args.js generated vendored Normal file
View File

@ -0,0 +1,19 @@
/**
* Module dependencies.
*/
var program = new (require('../').Command)();
var test = require('tape');
program
.version('0.0.1')
.option('-f, --foo', 'add some foo')
.option('-b, --bar', 'add some bar');
program.parse(['node', 'test', '--foo', '--', '--bar', 'baz']);
test('literal args', function (t) {
t.ok(program.foo);
t.equal(program.bar, undefined);
t.deepEqual(program.args, ['--bar', 'baz']);
t.end();
});

24
node_modules/ltcdr/test/test.options.alias.js generated vendored Normal file
View File

@ -0,0 +1,24 @@
/**
* Module dependencies.
*/
var program = new (require('../').Command)();
var test = require('tape');
test('options alias', function (t) {
t.plan(3);
var i = 1;
program
.command('initialize <name>')
.alias('init')
.alias('i')
.action(function () {
t.pass('passed ' + i++);
});
program.parse(['node', 'test', 'initialize', 'pepper']);
program.parse(['node', 'test', 'init', 'pepper']);
program.parse(['node', 'test', 'i', 'pepper']);
});

View File

@ -0,0 +1,17 @@
/**
* Module dependencies.
*/
var program = require('../');
var program = new (require('../').Command)();
var test = require('tape');
program
.version('0.0.1')
.option('-c, --cheese [type]', 'optionally specify the type of cheese');
program.parse(['node', 'test', '--cheese', 'feta']);
test('options camelcase', function (t) {
t.equals(program.cheese, 'feta');
t.end();
});

17
node_modules/ltcdr/test/test.options.args.optional.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
/**
* Module dependencies.
*/
var program = require('../');
var program = new (require('../').Command)();
var test = require('tape');
program
.version('0.0.1')
.option('-c, --cheese [type]', 'optionally specify the type of cheese');
program.parse(['node', 'test', '--cheese']);
test('options camelcase', function (t) {
t.ok(program.cheese);
t.end();
});

19
node_modules/ltcdr/test/test.options.bool.js generated vendored Normal file
View File

@ -0,0 +1,19 @@
/**
* Module dependencies.
*/
var program = new (require('../').Command)();
var test = require('tape');
program
.version('0.0.1')
.option('-p, --pepper', 'add pepper')
.option('-c, --no-cheese', 'remove cheese');
program.parse(['node', 'test', '--pepper']);
test('options camelcase', function (t) {
t.ok(program.pepper);
t.ok(program.cheese);
t.end();
});

19
node_modules/ltcdr/test/test.options.bool.no.js generated vendored Normal file
View File

@ -0,0 +1,19 @@
/**
* Module dependencies.
*/
var program = require('../');
var program = new (require('../').Command)();
var test = require('tape');
program
.version('0.0.1')
.option('-p, --pepper', 'add pepper')
.option('-c|--no-cheese', 'remove cheese');
program.parse(['node', 'test', '--no-cheese']);
test('options bool no', function (t) {
t.equals(program.pepper, undefined);
t.equals(program.cheese, false);
t.end();
});

View File

@ -0,0 +1,19 @@
/**
* Module dependencies.
*/
var program = require('../');
var program = new (require('../').Command)();
var test = require('tape');
program
.version('0.0.1')
.option('-p, --pepper', 'add pepper')
.option('-c, --no-cheese', 'remove cheese');
program.parse(['node', 'test', '-pc']);
test('options bool small combined', function (t) {
t.ok(program.pepper);
t.equals(program.cheese, false);
t.end();
});

19
node_modules/ltcdr/test/test.options.bool.small.js generated vendored Normal file
View File

@ -0,0 +1,19 @@
/**
* Module dependencies.
*/
var program = require('../');
var program = new (require('../').Command)();
var test = require('tape');
program
.version('0.0.1')
.option('-p, --pepper', 'add pepper')
.option('-c, --no-cheese', 'remove cheese');
program.parse(['node', 'test', '-p', '-c']);
test('options bool, small', function (t) {
t.ok(program.pepper);
t.equals(program.cheese, false);
t.end();
});

31
node_modules/ltcdr/test/test.options.camelcase.js generated vendored Normal file
View File

@ -0,0 +1,31 @@
/**
* Module dependencies.
*/
var program = require('../');
var program = new (require('../').Command)();
var test = require('tape');
function parseRange(str) {
return str.split('..').map(Number);
}
program
.version('0.0.1')
.option('-i, --my-int <n>', 'pass an int', parseInt)
.option('-n, --my-num <n>', 'pass a number', Number)
.option('-f, --my-fLOAT <n>', 'pass a float', parseFloat)
.option('-m, --my-very-long-float <n>', 'pass a float', parseFloat)
.option('-u, --my-URL-count <n>', 'pass a float', parseFloat)
.option('-r, --my-long-range <a..b>', 'pass a range', parseRange);
program.parse('node test -i 5.5 -f 5.5 -m 6.5 -u 7.5 -n 15.99 -r 1..5'.split(' '));
test('options camelcase', function (t) {
t.equals(program.myInt, 5);
t.equals(program.myNum, 15.99);
t.equals(program.myFLOAT, 5.5);
t.equals(program.myVeryLongFloat, 6.5);
t.equals(program.myURLCount, 7.5);
t.deepEquals(program.myLongRange, [1,5]);
t.end();
});

26
node_modules/ltcdr/test/test.options.cflags.js generated vendored Normal file
View File

@ -0,0 +1,26 @@
/**
* Module dependencies.
*/
var program = require('../');
var program = new (require('../').Command)();
var test = require('tape');
program
.version('0.0.1')
.option('-c, --cflags <cflags>', 'pass options/flags to a compiler')
.option('-o, --other', 'just some other option')
.option('-x, --xother', 'just some other option')
.option('-y, --yother', 'just some other option')
.option('-z, --zother', 'just some other option');
program.parse(['node', 'test', '--cflags', '-DDEBUG', '-o', '-xyz']);
test('cflags', function(t) {
t.equals(program.cflags, '-DDEBUG');
t.ok(program.other);
t.ok(program.xother);
t.ok(program.yother);
t.ok(program.zother);
t.end();
});

27
node_modules/ltcdr/test/test.options.coercion.js generated vendored Normal file
View File

@ -0,0 +1,27 @@
/**
* Module dependencies.
*/
var program = require('../');
var program = new (require('../').Command)();
var test = require('tape');
function parseRange(str) {
return str.split('..').map(Number);
}
program
.version('0.0.1')
.option('-i, --int <n>', 'pass an int', parseInt)
.option('-n, --num <n>', 'pass a number', Number)
.option('-f, --float <n>', 'pass a float', parseFloat)
.option('-r, --range <a..b>', 'pass a range', parseRange);
program.parse('node test -i 5.5 -f 5.5 -n 15.99 -r 1..5'.split(' '));
test('option coercion', function(t) {
t.equals(program.int, 5);
t.equals(program.num, 15.99);
t.equals(program.float, 5.5);
t.deepEquals(program.range, [1,5]);
t.end();
});

188
node_modules/ltcdr/test/test.options.commands.js generated vendored Normal file
View File

@ -0,0 +1,188 @@
/**
* Module dependencies.
*/
var program = require('../');
var program = new (require('../').Command)();
var test = require('tape');
program
.version('0.0.1')
.option('-C, --chdir <path>', 'change the working directory')
.option('-c, --config <path>', 'set config path. defaults to ./deploy.conf')
.option('-T, --no-tests', 'ignore test hook')
var envValue = '';
var cmdValue = '';
var nameValue = '';
var customHelp = false;
program
.command('setup [env]')
.description('run setup commands for all envs')
.option('-s, --setup_mode [mode]', 'Which setup mode to use')
.option('-o, --host [host]', 'Host to use')
.action(function(env, options){
var mode = options.setup_mode || 'normal';
env = env || 'all';
envValue = env;
});
program
.command('exec <cmd>')
.aliases('run')
.description('execute the given remote cmd')
.option('-e, --exec_mode <mode>', 'Which exec mode to use')
.option('-t, --target [target]', 'Target to use')
.action(function(cmd, options){
cmdValue = cmd;
}).on('--help', function(){
customHelp = true;
});
program
.command('initialize <name>')
.aliases(['init', 'i'])
.description('Initialises the config')
.action(function (name) {
nameValue = name;
});
program
.command('*')
.action(function(env){
console.log('deploying \'%s\'', env);
});
test('test 1', function (t) {
program.parse(['node', 'test', '--config', 'conf']);
t.equals(program.config, 'conf');
t.notOk(program.command[0] && 'setup_mode' in program.command[0]);
t.notOk(program.command[1] && 'exec_mode' in program.command[1]);
t.notOk(envValue);
t.notOk(cmdValue);
t.end();
});
test('test 2', function (t) {
program.parse(['node', 'test', '--config', 'conf1', 'setup', '--setup_mode', 'mode3', 'env1']);
t.equals(program.config, 'conf1');
t.equals(program.commands[0].setup_mode, 'mode3');
t.equals(program.commands[0].host, undefined);
t.equals(envValue, 'env1');
t.end();
});
test('test 3', function (t) {
program.parse(['node', 'test', '--config', 'conf2', 'setup', '--setup_mode', 'mode3', '-o', 'host1', 'env2']);
t.equals(program.config, 'conf2');
t.equals(program.commands[0].setup_mode, 'mode3');
t.equals(program.commands[0].host, 'host1');
t.equals(envValue, 'env2');
t.end();
});
test('test 4', function (t) {
program.parse(['node', 'test', '--config', 'conf3', 'setup', '-s', 'mode4', 'env3']);
t.equals(program.config, 'conf3');
t.equals(program.commands[0].setup_mode, 'mode4');
t.equals(envValue, 'env3');
t.end();
});
test('test 5', function (t) {
program.parse(['node', 'test', '--config', 'conf4', 'exec', '--exec_mode', 'mode1', 'exec1']);
t.equals(program.config, 'conf4');
t.equals(program.commands[1].exec_mode, 'mode1');
t.notOk('target' in program.commands[1]);
t.equals(cmdValue, 'exec1');
t.end();
});
test('test 6', function (t) {
program.parse(['node', 'test', '--config', 'conf5', 'exec', '-e', 'mode2', 'exec2']);
t.equals(program.config, 'conf5');
t.equals(program.commands[1].exec_mode, 'mode2');
t.equals(cmdValue, 'exec2');
t.end();
});
test('test 7', function (t) {
program.parse(['node', 'test', '--config', 'conf6', 'exec', '--target', 'target1', '-e', 'mode2', 'exec3']);
t.equals(program.config, 'conf6');
t.equals(program.commands[1].exec_mode, 'mode2');
t.equals(program.commands[1].target, 'target1');
t.equals(cmdValue, 'exec3');
t.end();
});
test('has aliases', function (t) {
program.parse(['node', 'test', '--config', 'conf7', 'exec', '--target', 'target7', '-e', 'mode7', 'exec7']);
t.equals(program.config, 'conf7');
t.equals(program.commands[1]._aliases[0], 'run');
t.equals(program.commands[1].exec_mode, 'mode7');
t.equals(program.commands[1].target, 'target7');
t.equals(cmdValue, 'exec7');
t.end();
});
test('multiple aliases', function (t) {
program.parse(['node', 'test', 'initialize', 'config8']);
var command = program.commands[2],
expectedAliases = ['init', 'i'];
t.equals(command._name, 'initialize');
t.same(command._aliases, expectedAliases);
t.equals(nameValue, 'config8');
t.end();
});
test('running an alias', function (t) {
program.parse(['node', 'test', 'init', 'config9']);
var command = program.commands[2];
t.equals(command._aliases.length, 2);
t.equals(command._name, 'initialize');
t.equals(nameValue, 'config9');
t.end();
});
// Make sure we still catch errors with required values for options
test('errors', function (t) {
var exceptionOccurred = false;
var oldProcessExit = process.exit;
var oldConsoleError = console.error;
process.exit = function() { exceptionOccurred = true; throw new Error(); };
console.error = function() {};
t.test('should work even if it throws', function (t) {
try {
program.parse(['node', 'test', '--config', 'conf6', 'exec', '--help']);
} catch(ex) {
t.equals(program.config, 'conf6');
t.end();
}
});
t.test('should exid right', function (t) {
try {
program.parse(['node', 'test', '--config', 'conf', 'exec', '-t', 'target1', 'exec1', '-e']);
}
catch(ex) {
}
process.exit = oldProcessExit;
t.ok(exceptionOccurred);
t.ok(customHelp);
t.end();
});
});

27
node_modules/ltcdr/test/test.options.defaults.given.js generated vendored Normal file
View File

@ -0,0 +1,27 @@
/**
* Module dependencies.
*/
var program = require('../');
var program = new (require('../').Command)();
var test = require('tape');
program
.version('0.0.1')
.option('-a, --anchovies', 'Add anchovies?')
.option('-o, --onions', 'Add onions?', true)
.option('-v, --olives', 'Add olives? Sorry we only have black.', 'black')
.option('-s, --no-sauce', 'Uh… okay')
.option('-r, --crust <type>', 'What kind of crust would you like?', 'hand-tossed')
.option('-c, --cheese [type]', 'optionally specify the type of cheese', 'mozzarella');
program.parse(['node', 'test', '--anchovies', '--onions', '--olives', '--no-sauce', '--crust', 'thin', '--cheese', 'wensleydale']);
test('options defaults given', function (t) {
t.equals(program.anchovies, true);
t.equals(program.onions, true);
t.equals(program.olives, 'black');
t.equals(program.sauce, false);
t.equals(program.crust, 'thin');
t.equals(program.cheese, 'wensleydale');
t.end();
});

27
node_modules/ltcdr/test/test.options.defaults.js generated vendored Normal file
View File

@ -0,0 +1,27 @@
/**
* Module dependencies.
*/
var program = require('../');
var program = new (require('../').Command)();
var test = require('tape');
program
.version('0.0.1')
.option('-a, --anchovies', 'Add anchovies?')
.option('-o, --onions', 'Add onions?', true)
.option('-v, --olives', 'Add olives? Sorry we only have black.', 'black')
.option('-s, --no-sauce', 'Uh… okay')
.option('-r, --crust <type>', 'What kind of crust would you like?', 'hand-tossed')
.option('-c, --cheese [type]', 'optionally specify the type of cheese', 'mozzarella');
program.parse(['node', 'test']);
test('options defaults', function (t) {
t.notOk(program.anchovies);
t.notOk(program.onions);
t.notOk(program.olives);
t.equals(program.sauce, true);
t.equals(program.crust, 'hand-tossed');
t.equals(program.cheese, 'mozzarella');
t.end();
});

21
node_modules/ltcdr/test/test.options.equals.js generated vendored Normal file
View File

@ -0,0 +1,21 @@
/**
* Module dependencies.
*/
var program = require('../');
var program = new (require('../').Command)();
var test = require('tape');
program
.version('0.0.1')
.option('--string <n>', 'pass a string')
.option('--string2 <n>', 'pass another string')
.option('--num <n>', 'pass a number', Number);
program.parse('node test --string=Hello --string2 Hello=World --num=5.5'.split(' '));
test('options equals', function (t) {
t.equals(program.string, 'Hello');
t.equals(program.string2, 'Hello=World');
t.equals(program.num, 5.5);
t.end();
});

27
node_modules/ltcdr/test/test.options.hyphen.js generated vendored Normal file
View File

@ -0,0 +1,27 @@
/**
* Module dependencies.
*/
var program = require('../');
var program = new (require('../').Command)();
var test = require('tape');
function parseRange(str) {
return str.split('..').map(Number);
}
program
.version('0.0.1')
.option('-a, --alpha <a>', 'hyphen')
.option('-b, --bravo <b>', 'hyphen')
.option('-c, --charlie <c>', 'hyphen');
program.parse('node test -a - --bravo - --charlie=- - -- -'.split(' '));
test('options hyphen', function(t) {
t.equals(program.alpha, '-', 'alpha is hyphen');
t.equals(program.bravo, '-', 'bravo is hyphen');
t.equals(program.charlie, '-', 'charlie is hyphen');
t.equals(program.args[0], '-', 'args[0] is hypthen');
t.equals(program.args[1], '-', 'args[1] is hyphen');
t.end();
});

View File

@ -0,0 +1,17 @@
/**
* Module dependencies.
*/
var program = require('../');
var program = new (require('../').Command)();
var test = require('tape');
program
.version('0.0.1')
.option('--longflag [value]', 'A long only flag with a value');
program.parse(['node', 'test', '--longflag', 'something']);
test('option large only with value', function (t) {
t.equals(program.longflag, 'something');
t.end();
});

17
node_modules/ltcdr/test/test.options.large-only.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
/**
* Module dependencies.
*/
var program = require('../');
var program = new (require('../').Command)();
var test = require('tape');
program
.version('0.0.1')
.option('--verbose', 'do stuff');
program.parse(['node', 'test', '--verbose']);
test('options large only', function (t) {
t.equals(program.verbose, true);
t.end();
});