diff --git a/cli.js b/cli.js index b84629b..30a2c49 100755 --- a/cli.js +++ b/cli.js @@ -59,6 +59,7 @@ const parser = yargs(hideBin(process.argv)) .completion('completion', false) .command(commands) .demandCommand(1) + // .recommendCommands() .strict(false) .fail(false) diff --git a/commands/index.js b/commands/index.js index e9495ba..1f93445 100644 --- a/commands/index.js +++ b/commands/index.js @@ -1,5 +1,5 @@ import * as exec from './exec.js' -import * as install from './install.js' +import * as pkg from './package/index.js' import * as list from './list.js' import * as upload from './upload.js' import * as rm from './rm.js' @@ -7,7 +7,7 @@ import * as get from './get.js' export const commands = [ exec, - install, + pkg, list, upload, rm, diff --git a/commands/package/index.js b/commands/package/index.js new file mode 100644 index 0000000..cc6644b --- /dev/null +++ b/commands/package/index.js @@ -0,0 +1,12 @@ +import * as install from './install.js' + +export const command = ['package ', 'pkg'] +export const describe = 'do something with packages' +export async function handler (argv) { + if (argv.help) { + return 0 + } +} +export const builder = function (yargs) { + return yargs.command([install]).recommendCommands() +} diff --git a/commands/install.js b/commands/package/install.js similarity index 100% rename from commands/install.js rename to commands/package/install.js diff --git a/spec/fixtures/.xstrc b/spec/fixtures/.xstrc index b33bfc9..1df8bad 100644 --- a/spec/fixtures/.xstrc +++ b/spec/fixtures/.xstrc @@ -3,7 +3,13 @@ "basic_auth": { "user": "admin", "pass": "" - } + }, + "rejectUnauthorized": false, + "host": "localhost", + "port": 8443, + "secure": true }, - "extensionsort": true + "extensionsort": true, + "color": true, + "insert-final-newline": true } diff --git a/spec/tests/install.js b/spec/tests/install.js index ab17e7e..b281e2c 100644 --- a/spec/tests/install.js +++ b/spec/tests/install.js @@ -22,17 +22,17 @@ async function noTestApp (t) { } test('shows help', async function (t) { - const { stderr, stdout } = await run('xst', ['install', '--help']) + const { stderr, stdout } = await run('xst', ['package', 'install', '--help']) if (stderr) { return t.fail(stderr) } t.ok(stdout, 'got output') const firstLine = stdout.split('\n')[0] - t.equal(firstLine, 'xst install [options] ', firstLine) + t.equal(firstLine, 'xst package install [options] ', firstLine) }) test('single valid package', async function (t) { t.test('installs on first run', async function (st) { - const { stderr, stdout } = await run('xst', ['install', 'spec/fixtures/test-app.xar'], asAdmin) + const { stderr, stdout } = await run('xst', ['package', 'install', 'spec/fixtures/test-app.xar'], asAdmin) if (stderr) { st.fail(stderr) st.end() @@ -47,7 +47,7 @@ test('single valid package', async function (t) { }) t.test('updates on second run', async function (st) { - const { stderr, stdout } = await run('xst', ['install', 'spec/fixtures/test-app.xar'], asAdmin) + const { stderr, stdout } = await run('xst', ['package', 'install', 'spec/fixtures/test-app.xar'], asAdmin) if (stderr) { st.fail(stderr) st.end() @@ -72,7 +72,7 @@ test('single valid package', async function (t) { test('single broken package', async function (t) { t.test(async function (st) { - const { stderr, stdout } = await run('xst', ['install', 'spec/fixtures/broken-test-app.xar'], asAdmin) + const { stderr, stdout } = await run('xst', ['package', 'install', 'spec/fixtures/broken-test-app.xar'], asAdmin) const lines = stdout.split('\n') st.equal(lines[0], 'Install broken-test-app.xar on https://localhost:8443') @@ -86,7 +86,7 @@ test('single broken package', async function (t) { test('multiple valid packages', async function (t) { t.test('twice the same package', async function (st) { - const { stderr, stdout } = await run('xst', ['install', 'spec/fixtures/test-app.xar', 'spec/fixtures/test-app.xar'], asAdmin) + const { stderr, stdout } = await run('xst', ['package', 'install', 'spec/fixtures/test-app.xar', 'spec/fixtures/test-app.xar'], asAdmin) if (stderr) { console.error(stderr) st.fail(stderr) @@ -114,7 +114,7 @@ test('multiple valid packages', async function (t) { test('multiple packages', async function (t) { t.test('first is broken', async function (st) { - const { stderr, stdout } = await run('xst', ['install', 'spec/fixtures/broken-test-app.xar', 'spec/fixtures/test-app.xar'], asAdmin) + const { stderr, stdout } = await run('xst', ['package', 'install', 'spec/fixtures/broken-test-app.xar', 'spec/fixtures/test-app.xar'], asAdmin) if (stdout) { st.equal(stdout, 'Install broken-test-app.xar on https://localhost:8443\n✔︎ uploaded\n') } @@ -133,7 +133,7 @@ test('multiple packages', async function (t) { test('multiple packages', async function (t) { t.test('second is broken', async function (st) { - const { stderr, stdout } = await run('xst', ['install', 'spec/fixtures/test-app.xar', 'spec/fixtures/broken-test-app.xar'], asAdmin) + const { stderr, stdout } = await run('xst', ['package', 'install', 'spec/fixtures/test-app.xar', 'spec/fixtures/broken-test-app.xar'], asAdmin) const lines = stdout.split('\n') st.equal(lines[0], 'Install test-app.xar on https://localhost:8443') @@ -155,7 +155,7 @@ test('multiple packages', async function (t) { }) test('error', async function (t) { - const { stderr, stdout } = await run('xst', ['i', 'asdf'], asAdmin) + const { stderr, stdout } = await run('xst', ['pkg', 'i', 'asdf'], asAdmin) if (stdout) { t.fail(stdout) return @@ -164,7 +164,7 @@ test('error', async function (t) { }) test('error file not found', async function (t) { - const { stderr, stdout } = await run('xst', ['i', 'asdf'], asAdmin) + const { stderr, stdout } = await run('xst', ['pkg', 'i', 'asdf'], asAdmin) if (stdout) { t.fail(stdout) return @@ -173,7 +173,7 @@ test('error file not found', async function (t) { }) test('error install as guest', async function (t) { - const { stderr, stdout } = await run('xst', ['i', 'spec/fixtures/test-app.xar']) + const { stderr, stdout } = await run('xst', ['pkg', 'i', 'spec/fixtures/test-app.xar']) if (stdout) { t.fail(stdout) return