**Motivations:** - Complete documentation for dashboard, domains, ports and environment configuration - Add new services (ClamAV API, Watermark API) to the infrastructure - Enhance dashboard with new pages and improved functionality - Improve deployment scripts and service configurations **Root causes:** - Missing comprehensive documentation for infrastructure setup - Need for antivirus scanning service integration - Need for watermark service integration - Dashboard required additional pages and features **Correctifs:** - Added comprehensive documentation in docs/ (DASHBOARD.md, DOMAINS_AND_PORTS.md, ENVIRONMENT.md) - Updated systemd service files with proper environment variables - Enhanced nginx proxy configuration script - Updated maintenance documentation **Evolutions:** - Added new ClamAV API service (api-clamav) for file scanning - Added new Watermark API service (api-filigrane) for document watermarking - Enhanced signet-dashboard with new learn.html page - Improved dashboard UI with better styles and navigation - Enhanced app.js with new functionality and better error handling - Updated API documentation page with complete endpoint descriptions - Added deployment scripts for watermark and nginx configuration - Updated hash and UTXO lists with latest data - Enhanced server.js with new routes and improved Bitcoin RPC integration **Pages affectées:** - docs/DASHBOARD.md: New comprehensive dashboard documentation - docs/DOMAINS_AND_PORTS.md: New infrastructure domains and ports documentation - docs/ENVIRONMENT.md: New environment variables documentation - docs/MAINTENANCE.md: Updated maintenance procedures - docs/README.md: Updated main documentation - signet-dashboard/public/app.js: Enhanced with new features - signet-dashboard/public/styles.css: Improved styling - signet-dashboard/public/index.html: Enhanced main page - signet-dashboard/public/learn.html: New educational page - signet-dashboard/public/api-docs.html: Enhanced API documentation - signet-dashboard/public/hash-list.html: Updated hash list page - signet-dashboard/public/utxo-list.html: Updated UTXO list page - signet-dashboard/public/join-signet.html: Updated join signet page - signet-dashboard/src/server.js: Enhanced server with new routes - signet-dashboard/start.sh: Updated startup script - signet-dashboard/signet-dashboard.service: Updated systemd service - api-anchorage/anchorage-api.service: Updated systemd service - api-faucet/faucet-api.service: Updated systemd service - configure-nginx-proxy.sh: Enhanced nginx configuration script - add-watermark-certificate.sh: New watermark certificate script - deploy-watermark-nginx.sh: New deployment script - api-clamav/: New ClamAV API service - api-filigrane/: New Watermark API service - hash_list.txt, utxo_list.txt: Updated with latest data - anchor_count.txt: Updated anchor count
210 lines
4.0 KiB
JavaScript
210 lines
4.0 KiB
JavaScript
'use strict';
|
|
|
|
var parse = require('../');
|
|
var test = require('tape');
|
|
|
|
test('parse args', function (t) {
|
|
t.deepEqual(
|
|
parse(['--no-moo']),
|
|
{ moo: false, _: [] },
|
|
'no'
|
|
);
|
|
t.deepEqual(
|
|
parse(['-v', 'a', '-v', 'b', '-v', 'c']),
|
|
{ v: ['a', 'b', 'c'], _: [] },
|
|
'multi'
|
|
);
|
|
t.end();
|
|
});
|
|
|
|
test('comprehensive', function (t) {
|
|
t.deepEqual(
|
|
parse([
|
|
'--name=meowmers', 'bare', '-cats', 'woo',
|
|
'-h', 'awesome', '--multi=quux',
|
|
'--key', 'value',
|
|
'-b', '--bool', '--no-meep', '--multi=baz',
|
|
'--', '--not-a-flag', 'eek',
|
|
]),
|
|
{
|
|
c: true,
|
|
a: true,
|
|
t: true,
|
|
s: 'woo',
|
|
h: 'awesome',
|
|
b: true,
|
|
bool: true,
|
|
key: 'value',
|
|
multi: ['quux', 'baz'],
|
|
meep: false,
|
|
name: 'meowmers',
|
|
_: ['bare', '--not-a-flag', 'eek'],
|
|
}
|
|
);
|
|
t.end();
|
|
});
|
|
|
|
test('flag boolean', function (t) {
|
|
var argv = parse(['-t', 'moo'], { boolean: 't' });
|
|
t.deepEqual(argv, { t: true, _: ['moo'] });
|
|
t.deepEqual(typeof argv.t, 'boolean');
|
|
t.end();
|
|
});
|
|
|
|
test('flag boolean value', function (t) {
|
|
var argv = parse(['--verbose', 'false', 'moo', '-t', 'true'], {
|
|
boolean: ['t', 'verbose'],
|
|
default: { verbose: true },
|
|
});
|
|
|
|
t.deepEqual(argv, {
|
|
verbose: false,
|
|
t: true,
|
|
_: ['moo'],
|
|
});
|
|
|
|
t.deepEqual(typeof argv.verbose, 'boolean');
|
|
t.deepEqual(typeof argv.t, 'boolean');
|
|
t.end();
|
|
});
|
|
|
|
test('newlines in params', function (t) {
|
|
var args = parse(['-s', 'X\nX']);
|
|
t.deepEqual(args, { _: [], s: 'X\nX' });
|
|
|
|
// reproduce in bash:
|
|
// VALUE="new
|
|
// line"
|
|
// node program.js --s="$VALUE"
|
|
args = parse(['--s=X\nX']);
|
|
t.deepEqual(args, { _: [], s: 'X\nX' });
|
|
t.end();
|
|
});
|
|
|
|
test('strings', function (t) {
|
|
var s = parse(['-s', '0001234'], { string: 's' }).s;
|
|
t.equal(s, '0001234');
|
|
t.equal(typeof s, 'string');
|
|
|
|
var x = parse(['-x', '56'], { string: 'x' }).x;
|
|
t.equal(x, '56');
|
|
t.equal(typeof x, 'string');
|
|
t.end();
|
|
});
|
|
|
|
test('stringArgs', function (t) {
|
|
var s = parse([' ', ' '], { string: '_' })._;
|
|
t.same(s.length, 2);
|
|
t.same(typeof s[0], 'string');
|
|
t.same(s[0], ' ');
|
|
t.same(typeof s[1], 'string');
|
|
t.same(s[1], ' ');
|
|
t.end();
|
|
});
|
|
|
|
test('empty strings', function (t) {
|
|
var s = parse(['-s'], { string: 's' }).s;
|
|
t.equal(s, '');
|
|
t.equal(typeof s, 'string');
|
|
|
|
var str = parse(['--str'], { string: 'str' }).str;
|
|
t.equal(str, '');
|
|
t.equal(typeof str, 'string');
|
|
|
|
var letters = parse(['-art'], {
|
|
string: ['a', 't'],
|
|
});
|
|
|
|
t.equal(letters.a, '');
|
|
t.equal(letters.r, true);
|
|
t.equal(letters.t, '');
|
|
|
|
t.end();
|
|
});
|
|
|
|
test('string and alias', function (t) {
|
|
var x = parse(['--str', '000123'], {
|
|
string: 's',
|
|
alias: { s: 'str' },
|
|
});
|
|
|
|
t.equal(x.str, '000123');
|
|
t.equal(typeof x.str, 'string');
|
|
t.equal(x.s, '000123');
|
|
t.equal(typeof x.s, 'string');
|
|
|
|
var y = parse(['-s', '000123'], {
|
|
string: 'str',
|
|
alias: { str: 's' },
|
|
});
|
|
|
|
t.equal(y.str, '000123');
|
|
t.equal(typeof y.str, 'string');
|
|
t.equal(y.s, '000123');
|
|
t.equal(typeof y.s, 'string');
|
|
|
|
var z = parse(['-s123'], {
|
|
alias: { str: ['s', 'S'] },
|
|
string: ['str'],
|
|
});
|
|
|
|
t.deepEqual(
|
|
z,
|
|
{ _: [], s: '123', S: '123', str: '123' },
|
|
'opt.string works with multiple aliases'
|
|
);
|
|
t.end();
|
|
});
|
|
|
|
test('slashBreak', function (t) {
|
|
t.same(
|
|
parse(['-I/foo/bar/baz']),
|
|
{ I: '/foo/bar/baz', _: [] }
|
|
);
|
|
t.same(
|
|
parse(['-xyz/foo/bar/baz']),
|
|
{ x: true, y: true, z: '/foo/bar/baz', _: [] }
|
|
);
|
|
t.end();
|
|
});
|
|
|
|
test('alias', function (t) {
|
|
var argv = parse(['-f', '11', '--zoom', '55'], {
|
|
alias: { z: 'zoom' },
|
|
});
|
|
t.equal(argv.zoom, 55);
|
|
t.equal(argv.z, argv.zoom);
|
|
t.equal(argv.f, 11);
|
|
t.end();
|
|
});
|
|
|
|
test('multiAlias', function (t) {
|
|
var argv = parse(['-f', '11', '--zoom', '55'], {
|
|
alias: { z: ['zm', 'zoom'] },
|
|
});
|
|
t.equal(argv.zoom, 55);
|
|
t.equal(argv.z, argv.zoom);
|
|
t.equal(argv.z, argv.zm);
|
|
t.equal(argv.f, 11);
|
|
t.end();
|
|
});
|
|
|
|
test('nested dotted objects', function (t) {
|
|
var argv = parse([
|
|
'--foo.bar', '3', '--foo.baz', '4',
|
|
'--foo.quux.quibble', '5', '--foo.quux.o_O',
|
|
'--beep.boop',
|
|
]);
|
|
|
|
t.same(argv.foo, {
|
|
bar: 3,
|
|
baz: 4,
|
|
quux: {
|
|
quibble: 5,
|
|
o_O: true,
|
|
},
|
|
});
|
|
t.same(argv.beep, { boop: true });
|
|
t.end();
|
|
});
|