diff --git a/package-lock.json b/package-lock.json index 71c7a1a..35b18ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9448,9 +9448,6 @@ "cpu": [ "arm64" ], - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -9471,9 +9468,6 @@ "cpu": [ "arm64" ], - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -9494,9 +9488,6 @@ "cpu": [ "x64" ], - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -9517,9 +9508,6 @@ "cpu": [ "x64" ], - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -9986,9 +9974,6 @@ "cpu": [ "arm" ], - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -10009,9 +9994,6 @@ "cpu": [ "arm" ], - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -10032,9 +10014,6 @@ "cpu": [ "arm64" ], - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -10055,9 +10034,6 @@ "cpu": [ "arm64" ], - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -10078,9 +10054,6 @@ "cpu": [ "x64" ], - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -10101,9 +10074,6 @@ "cpu": [ "x64" ], - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -12058,9 +12028,6 @@ "cpu": [ "arm64" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0 AND MIT", "optional": true, "os": [ @@ -12077,9 +12044,6 @@ "cpu": [ "arm64" ], - "libc": [ - "musl" - ], "license": "Apache-2.0 AND MIT", "optional": true, "os": [ @@ -12096,9 +12060,6 @@ "cpu": [ "x64" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0 AND MIT", "optional": true, "os": [ @@ -12115,9 +12076,6 @@ "cpu": [ "x64" ], - "libc": [ - "musl" - ], "license": "Apache-2.0 AND MIT", "optional": true, "os": [ @@ -22213,9 +22171,6 @@ "cpu": [ "arm64" ], - "libc": [ - "glibc" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -22236,9 +22191,6 @@ "cpu": [ "arm64" ], - "libc": [ - "musl" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -22259,9 +22211,6 @@ "cpu": [ "x64" ], - "libc": [ - "glibc" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -22282,9 +22231,6 @@ "cpu": [ "x64" ], - "libc": [ - "musl" - ], "license": "MPL-2.0", "optional": true, "os": [ diff --git a/src/commands/discover.js b/src/commands/discover.js index 37bb35d..272bd54 100644 --- a/src/commands/discover.js +++ b/src/commands/discover.js @@ -12,8 +12,8 @@ const { Command, Flags } = require('@oclif/core') const inquirer = require('inquirer') +const chalk = require('chalk') const { sortValues } = require('../helpers') -const { printTable } = require('../table') /* This is how cordova does it: @@ -24,6 +24,12 @@ future: use keywords ecosytem:aio-cli-plugin class DiscoCommand extends Command { async _install (plugins) { + const dateOptions = { + year: 'numeric', + month: 'long', + day: 'numeric' + } + // get installed plugins const installedPlugins = this.config.commands.map(elem => { return elem.pluginName @@ -34,8 +40,10 @@ class DiscoCommand extends Command { return !installedPlugins.includes(elem.name) }) .map(elem => { // map to expected inquirer format + const date = new Date(elem.date).toLocaleDateString('en', dateOptions) return { - name: `${elem.name}@${elem.version}`, + name: `${chalk.bold(elem.name)} · ${elem.version} · ${date}\n ${chalk.gray(elem.description)}`, + short: elem.name, value: elem.name } }) @@ -61,30 +69,19 @@ class DiscoCommand extends Command { } async _list (plugins) { - const options = { + const dateOptions = { year: 'numeric', month: 'long', day: 'numeric' } - const columns = { - name: { - width: 10, - get: row => `${row.name}` - }, - version: { - minWidth: 10, - get: row => `${row.version}` - }, - description: { - get: row => `${row.description}` - }, - published: { - get: row => `${new Date(row.date).toLocaleDateString('en', options)}` - } + console.log(chalk.bold(`Discover plugins (${plugins.length})`)) + console.log() + for (const plugin of plugins) { + const date = new Date(plugin.date).toLocaleDateString('en', dateOptions) + console.log(` ● ${chalk.bold(plugin.name)} · ${plugin.version} · ${date}`) + console.log(` ${chalk.gray(plugin.description)}`) } - // skip ones that aren't from us - printTable(plugins, columns) } async run () { diff --git a/src/table.js b/src/table.js index c02c4be..d94b604 100644 --- a/src/table.js +++ b/src/table.js @@ -37,12 +37,12 @@ function printTable (data, columns) { const widths = headers.map((h, i) => { const min = Math.max(columns[h].minWidth || 0, columns[h].width || 0) - return Math.max(stringWidth(h), min, ...rows.map(r => stringWidth(r[i]))) + return Math.max(stringWidth(h), min, ...rows.map(r => stringWidth(r[i]))) + 2 }) - console.log(headers.map((h, i) => padEndVisible(h, widths[i])).join(' ')) - console.log(widths.map(w => '─'.repeat(w)).join(' ')) - rows.forEach(row => console.log(row.map((c, i) => padEndVisible(c, widths[i])).join(' '))) + console.log(headers.map((h, i) => padEndVisible(h, widths[i])).join('')) + console.log(widths.map(w => '─'.repeat(w - 1)).join(' ')) + rows.forEach(row => console.log(row.map((c, i) => padEndVisible(c, widths[i])).join(''))) } -module.exports = { printTable } +module.exports = { printTable, padEndVisible } diff --git a/test/commands/discover.test.js b/test/commands/discover.test.js index d0a3446..9414995 100644 --- a/test/commands/discover.test.js +++ b/test/commands/discover.test.js @@ -60,7 +60,7 @@ describe('sorting', () => { await command.run() const splitOutput = stdout.output.split('\n') expect(splitOutput[2]).toMatch('@adobe/aio-cli-plugin-a') // @adobe/aio-cli-plugin-a is first - expect(splitOutput[3]).toMatch('@adobe/aio-cli-plugin-b') // @adobe/aio-cli-plugin-b is second + expect(splitOutput[4]).toMatch('@adobe/aio-cli-plugin-b') // @adobe/aio-cli-plugin-b is second }) test('sort-field=name, descending', async () => { @@ -68,7 +68,7 @@ describe('sorting', () => { await command.run() const splitOutput = stdout.output.split('\n') expect(splitOutput[2]).toMatch('@adobe/aio-cli-plugin-b') // @adobe/aio-cli-plugin-b is first - expect(splitOutput[3]).toMatch('@adobe/aio-cli-plugin-a') // @adobe/aio-cli-plugin-a is second + expect(splitOutput[4]).toMatch('@adobe/aio-cli-plugin-a') // @adobe/aio-cli-plugin-a is second }) test('sort-field=date, ascending', async () => { @@ -76,7 +76,7 @@ describe('sorting', () => { await command.run() const splitOutput = stdout.output.split('\n') expect(splitOutput[2]).toMatch('@adobe/aio-cli-plugin-a') // @adobe/aio-cli-plugin-a is first - expect(splitOutput[3]).toMatch('@adobe/aio-cli-plugin-b') // @adobe/aio-cli-plugin-b is second + expect(splitOutput[4]).toMatch('@adobe/aio-cli-plugin-b') // @adobe/aio-cli-plugin-b is second }) test('sort-field=date, descending', async () => { @@ -84,7 +84,7 @@ describe('sorting', () => { await command.run() const splitOutput = stdout.output.split('\n') expect(splitOutput[2]).toMatch('@adobe/aio-cli-plugin-b') // @adobe/aio-cli-plugin-b is first - expect(splitOutput[3]).toMatch('@adobe/aio-cli-plugin-a') // @adobe/aio-cli-plugin-a is second + expect(splitOutput[4]).toMatch('@adobe/aio-cli-plugin-a') // @adobe/aio-cli-plugin-a is second }) })