From 5d50d0ef112cb903b8bf65c3f6523b52ef87c1b2 Mon Sep 17 00:00:00 2001 From: Simon Vocella Date: Tue, 11 Apr 2017 00:10:16 +0200 Subject: [PATCH 1/2] - move aliases to unsupported aliases - tests properly camelised comand - tests properly command with hyphen - move generation of documentation in src/cli/commands/index.js - move every command related stuff in src/cli/commands/index.js - tests some corner cases - delete every camelCase use in src/cli/commands/index.js and src/cli/commands/help.js --- __tests__/cli/aliases.js | 32 ----- __tests__/cli/unsupported-aliases.js | 32 +++++ .../run-generate-lock-entry/package.json | 5 + __tests__/index.js | 45 ++++++- src/cli/aliases.js | 39 +----- src/cli/commands/help.js | 17 +-- src/cli/commands/index.js | 111 ++++++++++++------ src/cli/index.js | 31 +---- src/cli/unsupported-aliases.js | 39 ++++++ 9 files changed, 209 insertions(+), 142 deletions(-) delete mode 100644 __tests__/cli/aliases.js create mode 100644 __tests__/cli/unsupported-aliases.js create mode 100644 __tests__/fixtures/index/run-generate-lock-entry/package.json create mode 100644 src/cli/unsupported-aliases.js diff --git a/__tests__/cli/aliases.js b/__tests__/cli/aliases.js deleted file mode 100644 index 5700c8a973..0000000000 --- a/__tests__/cli/aliases.js +++ /dev/null @@ -1,32 +0,0 @@ -/* @flow */ - -import aliases from '../../src/cli/aliases.js'; - -test('shorthands and affordances', () => { - expect(aliases['run-script']).toBe('run'); - expect(aliases['c']).toBe('config'); - expect(aliases['i']).toBe('install'); - expect(aliases['ls']).toBe('list'); - expect(aliases['rb']).toBe('rebuild'); - expect(aliases['runScript']).toBe('run'); - expect(aliases['t']).toBe('test'); - expect(aliases['tst']).toBe('test'); - expect(aliases['un']).toBe('remove'); - expect(aliases['up']).toBe('upgrade'); - expect(aliases['v']).toBe('version'); - expect(aliases['add-user']).toBe('login'); - expect(aliases['dist-tag']).toBe('tag'); - expect(aliases['dist-tags']).toBe('tag'); - expect(aliases['adduser']).toBe('login'); - expect(aliases['author']).toBe('owner'); - expect(aliases['isntall']).toBe('install'); - expect(aliases['la']).toBe('list'); - expect(aliases['ll']).toBe('list'); - expect(aliases['r']).toBe('remove'); - expect(aliases['rm']).toBe('remove'); - expect(aliases['show']).toBe('info'); - expect(aliases['uninstall']).toBe('remove'); - expect(aliases['update']).toBe('upgrade'); - expect(aliases['verison']).toBe('version'); - expect(aliases['view']).toBe('info'); -}); diff --git a/__tests__/cli/unsupported-aliases.js b/__tests__/cli/unsupported-aliases.js new file mode 100644 index 0000000000..b32a1bc261 --- /dev/null +++ b/__tests__/cli/unsupported-aliases.js @@ -0,0 +1,32 @@ +/* @flow */ + +import unsupportedAliases from '../../src/cli/unsupported-aliases.js'; + +test('shorthands and affordances', () => { + expect(unsupportedAliases['run-script']).toBe('run'); + expect(unsupportedAliases['c']).toBe('config'); + expect(unsupportedAliases['i']).toBe('install'); + expect(unsupportedAliases['ls']).toBe('list'); + expect(unsupportedAliases['rb']).toBe('rebuild'); + expect(unsupportedAliases['runScript']).toBe('run'); + expect(unsupportedAliases['t']).toBe('test'); + expect(unsupportedAliases['tst']).toBe('test'); + expect(unsupportedAliases['un']).toBe('remove'); + expect(unsupportedAliases['up']).toBe('upgrade'); + expect(unsupportedAliases['v']).toBe('version'); + expect(unsupportedAliases['add-user']).toBe('login'); + expect(unsupportedAliases['dist-tag']).toBe('tag'); + expect(unsupportedAliases['dist-tags']).toBe('tag'); + expect(unsupportedAliases['adduser']).toBe('login'); + expect(unsupportedAliases['author']).toBe('owner'); + expect(unsupportedAliases['isntall']).toBe('install'); + expect(unsupportedAliases['la']).toBe('list'); + expect(unsupportedAliases['ll']).toBe('list'); + expect(unsupportedAliases['r']).toBe('remove'); + expect(unsupportedAliases['rm']).toBe('remove'); + expect(unsupportedAliases['show']).toBe('info'); + expect(unsupportedAliases['uninstall']).toBe('remove'); + expect(unsupportedAliases['update']).toBe('upgrade'); + expect(unsupportedAliases['verison']).toBe('version'); + expect(unsupportedAliases['view']).toBe('info'); +}); diff --git a/__tests__/fixtures/index/run-generate-lock-entry/package.json b/__tests__/fixtures/index/run-generate-lock-entry/package.json new file mode 100644 index 0000000000..d97761b53a --- /dev/null +++ b/__tests__/fixtures/index/run-generate-lock-entry/package.json @@ -0,0 +1,5 @@ +{ + "name": "test_generate_lock_entry", + "version": "1.0.0", + "license": "UNLICENSED" +} diff --git a/__tests__/index.js b/__tests__/index.js index 695e60fd75..cd04a50859 100644 --- a/__tests__/index.js +++ b/__tests__/index.js @@ -211,20 +211,26 @@ test.concurrent('should not output JSON activity/progress if given --no-progress }); }); -test.concurrent('should interpolate aliases', async () => { +test.concurrent('should interpolate unsopported aliases', async () => { await expectAnErrorMessage( execCommand('i', [], 'run-add', true), 'Did you mean `yarn install`?', ); }); -test.concurrent('should display correct documentation link for aliases', async () => { +test.concurrent('should display correct documentation link for unsopported aliases', async () => { await expectAnInfoMessageAfterError( execCommand('i', [], 'run-add', true), 'Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.', ); }); +test.concurrent('should show help and ignore unsopported aliases', async () => { + const stdout = await execCommand('i', ['--help'], 'run-help'); + expect(stdout[stdout.length - 1]) + .toEqual('Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.'); +}); + test.concurrent('should run help of run command if --help is before --', async () => { const stdout = await execCommand('run', ['custom-script', '--help', '--'], 'run-custom-script-with-arguments'); expect(stdout[0]).toEqual('Usage: yarn [command] [flags]'); @@ -286,3 +292,38 @@ test.concurrent('should throws missing command for constructor command', async ( 'Command \"constructor\" not found', ); }); + +test.concurrent('should show help and ignore constructor command', async () => { + const stdout = await execCommand('constructor', ['--help'], 'run-help'); + expectHelpOutput(stdout); +}); + +test.concurrent('should run command with hyphens', async () => { + const stdout = await execCommand('generate-lock-entry', [], 'run-generate-lock-entry'); + expect(stdout[0]).toMatch(/# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY./); + expect(stdout[1]).toMatch(/# yarn lockfile v1/); +}); + +test.concurrent('should run camelised command for command with hyphens', async () => { + const stdout = await execCommand('generateLockEntry', [], 'run-generate-lock-entry'); + expect(stdout[0]).toMatch(/# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY./); + expect(stdout[1]).toMatch(/# yarn lockfile v1/); +}); + +test.concurrent('should run help for command with hyphens', async () => { + const stdout = await execCommand('generate-lock-entry', ['--help'], 'run-generate-lock-entry'); + const lastLines = stdout.slice(stdout.length - 4); + expect(lastLines[0]).toMatch(/yarn generate-lock-entry/); + expect(lastLines[1]).toMatch(/yarn generate-lock-entry --use-manifest .\/package.json/); + expect(lastLines[2]).toMatch(/yarn generate-lock-entry --resolved local-file.tgz#hash/); + expect(lastLines[3]).toMatch(/Visit https:\/\/yarnpkg.com\/en\/docs\/cli\/generate-lock-entry/); +}); + +test.concurrent('should run help for camelised command', async () => { + const stdout = await execCommand('generateLockEntry', ['--help'], 'run-generate-lock-entry'); + const lastLines = stdout.slice(stdout.length - 4); + expect(lastLines[0]).toMatch(/yarn generate-lock-entry/); + expect(lastLines[1]).toMatch(/yarn generate-lock-entry --use-manifest .\/package.json/); + expect(lastLines[2]).toMatch(/yarn generate-lock-entry --resolved local-file.tgz#hash/); + expect(lastLines[3]).toMatch(/Visit https:\/\/yarnpkg.com\/en\/docs\/cli\/generate-lock-entry/); +}); diff --git a/src/cli/aliases.js b/src/cli/aliases.js index 2fe150c4af..1c7035f83e 100644 --- a/src/cli/aliases.js +++ b/src/cli/aliases.js @@ -1,39 +1,6 @@ /* @flow */ -const shorthands: { [key: string]: string } = { - c: 'config', - i: 'install', - la: 'list', - ll: 'list', - ln: 'link', - ls: 'list', - r: 'remove', - rb: 'rebuild', - rm: 'remove', - t: 'test', - tst: 'test', - un: 'remove', - up: 'upgrade', - v: 'version', -}; - -const affordances: { [key: string]: string } = { - 'add-user': 'login', - adduser: 'login', - author: 'owner', - 'dist-tag': 'tag', - 'dist-tags': 'tag', - isntall: 'install', - 'run-script': 'run', - runScript: 'run', - show: 'info', - uninstall: 'remove', - update: 'upgrade', - verison: 'version', - view: 'info', -}; - -export default ({ - ...shorthands, - ...affordances, +export default({ + 'upgrade-interactive': 'upgradeInteractive', + 'generate-lock-entry': 'generateLockEntry', }: { [key: string]: string }); diff --git a/src/cli/commands/help.js b/src/cli/commands/help.js index 7219065963..0dcbe66944 100644 --- a/src/cli/commands/help.js +++ b/src/cli/commands/help.js @@ -1,10 +1,10 @@ /* @flow */ -import * as commands from './index.js'; +import commands from './index.js'; import * as constants from '../../constants.js'; import type {Reporter} from '../../reporters/index.js'; import type Config from '../../config.js'; -import {sortAlpha, hyphenate, camelCase} from '../../util/misc.js'; +import {sortAlpha, hyphenate} from '../../util/misc.js'; const chalk = require('chalk'); export function hasWrapper(): boolean { @@ -19,15 +19,10 @@ export function run( commander: Object, args: Array, ): Promise { - const getDocsLink = (name) => `${constants.YARN_DOCS}${name || ''}`; - const getDocsInfo = (name) => 'Visit ' + chalk.bold(getDocsLink(name)) + ' for documentation about this command.'; - if (args.length) { - const commandName = camelCase(args.shift()); - - if (commandName) { + const commandName = args.shift(); + if (Object.prototype.hasOwnProperty.call(commands, commandName)) { const command = commands[commandName]; - if (command) { command.setFlags(commander); const examples: Array = (command && command.examples) || []; @@ -40,8 +35,7 @@ export function run( console.log(); }); } - commander.on('--help', () => console.log(' ' + getDocsInfo(commandName) + '\n')); - + commander.on('--help', () => console.log(' ' + command.getDocsInfo + '\n')); commander.help(); return Promise.resolve(); } @@ -49,6 +43,7 @@ export function run( } commander.on('--help', () => { + const getDocsLink = (name) => `${constants.YARN_DOCS}${name || ''}`; console.log(' Commands:\n'); for (const name of Object.keys(commands).sort(sortAlpha)) { if (commands[name].useless) { diff --git a/src/cli/commands/index.js b/src/cli/commands/index.js index 44669bdb57..79131fa597 100644 --- a/src/cli/commands/index.js +++ b/src/cli/commands/index.js @@ -1,49 +1,88 @@ /* @flow */ +import {ConsoleReporter, JSONReporter} from '../../reporters/index.js'; +import * as constants from '../../constants.js'; +import {MessageError} from '../../errors.js'; +import Config from '../../config.js'; -import * as access from './access.js'; export {access}; -import * as add from './add.js'; export {add}; -import * as bin from './bin.js'; export {bin}; -import * as cache from './cache.js'; export {cache}; -import * as check from './check.js'; export {check}; -import * as clean from './clean.js'; export {clean}; -import * as config from './config.js'; export {config}; -import * as generateLockEntry from './generate-lock-entry.js'; export {generateLockEntry}; -import * as global from './global.js'; export {global}; -import * as help from './help.js'; export {help}; -import * as import_ from './import.js'; export {import_ as import}; -import * as info from './info.js'; export {info}; -import * as init from './init.js'; export {init}; -import * as install from './install.js'; export {install}; -import * as licenses from './licenses.js'; export {licenses}; -import * as link from './link.js'; export {link}; -import * as login from './login.js'; export {login}; -import * as logout from './logout.js'; export {logout}; -import * as list from './list.js'; export {list}; -import * as outdated from './outdated.js'; export {outdated}; -import * as owner from './owner.js'; export {owner}; -import * as pack from './pack.js'; export {pack}; -import * as publish from './publish.js'; export {publish}; -import * as remove from './remove.js'; export {remove}; -import * as run from './run.js'; export {run}; -import * as tag from './tag.js'; export {tag}; -import * as team from './team.js'; export {team}; -import * as unlink from './unlink.js'; export {unlink}; -import * as upgrade from './upgrade.js'; export {upgrade}; -import * as version from './version.js'; export {version}; -import * as versions from './versions.js'; export {versions}; -import * as why from './why.js'; export {why}; -import * as upgradeInteractive from './upgrade-interactive.js'; export {upgradeInteractive}; +const chalk = require('chalk'); + +const getDocsLink = (name) => `${constants.YARN_DOCS}${name || ''}`; +const getDocsInfo = (name) => 'Visit ' + chalk.bold(getDocsLink(name)) + ' for documentation about this command.'; + +const commands = {}; + +import * as access from './access.js'; commands['access'] = access; +import * as add from './add.js'; commands['add'] = add; +import * as bin from './bin.js'; commands['bin'] = bin; +import * as cache from './cache.js'; commands['cache'] = cache; +import * as check from './check.js'; commands['check'] = check; +import * as clean from './clean.js'; commands['clean'] = clean; +import * as config from './config.js'; commands['config'] = config; +import * as generateLockEntry from './generate-lock-entry.js'; commands['generateLockEntry'] = generateLockEntry; +import * as global from './global.js'; commands['global'] = global; +import * as help from './help.js'; commands['help'] = help; +import * as import_ from './import.js'; commands['import'] = import_; +import * as info from './info.js'; commands['info'] = info; +import * as init from './init.js'; commands['init'] = init; +import * as install from './install.js'; commands['install'] = install; +import * as licenses from './licenses.js'; commands['licenses'] = licenses; +import * as link from './link.js'; commands['link'] = link; +import * as login from './login.js'; commands['login'] = login; +import * as logout from './logout.js'; commands['logout'] = logout; +import * as list from './list.js'; commands['list'] = list; +import * as outdated from './outdated.js'; commands['outdated'] = outdated; +import * as owner from './owner.js'; commands['owner'] = owner; +import * as pack from './pack.js'; commands['pack'] = pack; +import * as publish from './publish.js'; commands['publish'] = publish; +import * as remove from './remove.js'; commands['remove'] = remove; +import * as run from './run.js'; commands['run'] = run; +import * as tag from './tag.js'; commands['tag'] = tag; +import * as team from './team.js'; commands['team'] = team; +import * as unlink from './unlink.js'; commands['unlink'] = unlink; +import * as upgrade from './upgrade.js'; commands['upgrade'] = upgrade; +import * as version from './version.js'; commands['version'] = version; +import * as versions from './versions.js'; commands['versions'] = versions; +import * as why from './why.js'; commands['why'] = why; +import * as upgradeInteractive from './upgrade-interactive.js'; commands['upgradeInteractive'] = upgradeInteractive; import buildUseless from './_useless.js'; -export const lockfile = buildUseless( +commands['lockfile'] = buildUseless( "The lockfile command isn't necessary. `yarn install` will produce a lockfile.", ); -export const dedupe = buildUseless( +commands['dedupe'] = buildUseless( "The dedupe command isn't necessary. `yarn install` will already dedupe.", ); -export const prune = buildUseless( +commands['prune'] = buildUseless( "The prune command isn't necessary. `yarn install` will prune extraneous packages.", ); + +for (const key in commands) { + commands[key].getDocsInfo = getDocsInfo(key); +} + +import aliases from '../aliases.js'; + +for (const key in aliases) { + commands[key] = commands[aliases[key]]; + commands[key].getDocsInfo = getDocsInfo(key); +} + +import unsupportedAliases from '../unsupported-aliases.js'; + +for (const key in unsupportedAliases) { + commands[key] = { + run(config: Config, reporter: ConsoleReporter | JSONReporter): Promise { + throw new MessageError(`Did you mean \`yarn ${unsupportedAliases[key]}\`?`); + }, + setFlags: () => {}, + hasWrapper: () => true, + getDocsInfo: getDocsInfo(unsupportedAliases[key]), + }; +} + +export default ({ + ...commands, +}: { [key: string]: Object }); diff --git a/src/cli/index.js b/src/cli/index.js index 26b9439e9a..d56fd91ffb 100644 --- a/src/cli/index.js +++ b/src/cli/index.js @@ -2,16 +2,13 @@ import {ConsoleReporter, JSONReporter} from '../reporters/index.js'; import {registries, registryNames} from '../registries/index.js'; -import * as _commands from './commands/index.js'; +import commands from './commands/index.js'; import * as constants from '../constants.js'; import * as network from '../util/network.js'; import {MessageError} from '../errors.js'; -import aliases from './aliases.js'; import Config from '../config.js'; import {getRcArgs} from '../rc.js'; -import {camelCase} from '../util/misc.js'; -const chalk = require('chalk'); const commander = require('commander'); const fs = require('fs'); const invariant = require('invariant'); @@ -24,17 +21,6 @@ const pkg = require('../../package.json'); loudRejection(); -const commands = {..._commands}; -for (const key in aliases) { - commands[key] = { - run(config: Config, reporter: ConsoleReporter | JSONReporter): Promise { - throw new MessageError(`Did you mean \`yarn ${aliases[key]}\`?`); - }, - setFlags: () => {}, - hasWrapper: () => true, - }; -} - const startArgs = process.argv.slice(0, 2); // ignore all arguments after a -- @@ -96,8 +82,6 @@ commander.option('--network-concurrency ', 'maximum number of concurrent commander.option('--network-timeout ', 'TCP timeout for network requests', parseInt); commander.option('--non-interactive', 'do not show interactive prompts'); -const getDocsLink = (name) => `${constants.YARN_DOCS}${name || ''}`; -const getDocsInfo = (name) => 'Visit ' + chalk.bold(getDocsLink(name)) + ' for documentation about this command.'; // get command name let commandName: string = args.shift() || 'install'; @@ -118,9 +102,8 @@ if (commandName[0] === '-') { } let command; -const camelised = camelCase(commandName); -if (camelised && Object.prototype.hasOwnProperty.call(commands, camelised)) { - command = commands[camelised]; +if (Object.prototype.hasOwnProperty.call(commands, commandName)) { + command = commands[commandName]; } // if command is not recognized, then set default to `run` @@ -165,7 +148,7 @@ if (outputWrapper) { if (command.noArguments && commander.args.length) { reporter.error(reporter.lang('noArguments')); - reporter.info(getDocsInfo(commandName)); + reporter.info(command.getDocsInfo); process.exit(1); } @@ -375,10 +358,8 @@ config.init({ onUnexpectedError(err); } - if (aliases[commandName]) { - reporter.info(getDocsInfo(aliases[commandName])); - } else if (commands[commandName]) { - reporter.info(getDocsInfo(commandName)); + if (commands[commandName]) { + reporter.info(commands[commandName].getDocsInfo); } process.exit(1); diff --git a/src/cli/unsupported-aliases.js b/src/cli/unsupported-aliases.js new file mode 100644 index 0000000000..2fe150c4af --- /dev/null +++ b/src/cli/unsupported-aliases.js @@ -0,0 +1,39 @@ +/* @flow */ + +const shorthands: { [key: string]: string } = { + c: 'config', + i: 'install', + la: 'list', + ll: 'list', + ln: 'link', + ls: 'list', + r: 'remove', + rb: 'rebuild', + rm: 'remove', + t: 'test', + tst: 'test', + un: 'remove', + up: 'upgrade', + v: 'version', +}; + +const affordances: { [key: string]: string } = { + 'add-user': 'login', + adduser: 'login', + author: 'owner', + 'dist-tag': 'tag', + 'dist-tags': 'tag', + isntall: 'install', + 'run-script': 'run', + runScript: 'run', + show: 'info', + uninstall: 'remove', + update: 'upgrade', + verison: 'version', + view: 'info', +}; + +export default ({ + ...shorthands, + ...affordances, +}: { [key: string]: string }); From 367c24988fdb948ba613f73562ca0652b9595d8f Mon Sep 17 00:00:00 2001 From: Simon Vocella Date: Thu, 20 Apr 2017 16:43:45 +0200 Subject: [PATCH 2/2] fix typo and initialize commands in a clearer way --- __tests__/index.js | 6 +- src/cli/commands/index.js | 127 +++++++++++++++++++++++--------------- 2 files changed, 81 insertions(+), 52 deletions(-) diff --git a/__tests__/index.js b/__tests__/index.js index cd04a50859..f4ea40f88c 100644 --- a/__tests__/index.js +++ b/__tests__/index.js @@ -211,21 +211,21 @@ test.concurrent('should not output JSON activity/progress if given --no-progress }); }); -test.concurrent('should interpolate unsopported aliases', async () => { +test.concurrent('should interpolate unsupported aliases', async () => { await expectAnErrorMessage( execCommand('i', [], 'run-add', true), 'Did you mean `yarn install`?', ); }); -test.concurrent('should display correct documentation link for unsopported aliases', async () => { +test.concurrent('should display correct documentation link for unsupported aliases', async () => { await expectAnInfoMessageAfterError( execCommand('i', [], 'run-add', true), 'Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.', ); }); -test.concurrent('should show help and ignore unsopported aliases', async () => { +test.concurrent('should show help and ignore unsupported aliases', async () => { const stdout = await execCommand('i', ['--help'], 'run-help'); expect(stdout[stdout.length - 1]) .toEqual('Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.'); diff --git a/src/cli/commands/index.js b/src/cli/commands/index.js index 79131fa597..32797a5de7 100644 --- a/src/cli/commands/index.js +++ b/src/cli/commands/index.js @@ -9,55 +9,86 @@ const chalk = require('chalk'); const getDocsLink = (name) => `${constants.YARN_DOCS}${name || ''}`; const getDocsInfo = (name) => 'Visit ' + chalk.bold(getDocsLink(name)) + ' for documentation about this command.'; -const commands = {}; - -import * as access from './access.js'; commands['access'] = access; -import * as add from './add.js'; commands['add'] = add; -import * as bin from './bin.js'; commands['bin'] = bin; -import * as cache from './cache.js'; commands['cache'] = cache; -import * as check from './check.js'; commands['check'] = check; -import * as clean from './clean.js'; commands['clean'] = clean; -import * as config from './config.js'; commands['config'] = config; -import * as generateLockEntry from './generate-lock-entry.js'; commands['generateLockEntry'] = generateLockEntry; -import * as global from './global.js'; commands['global'] = global; -import * as help from './help.js'; commands['help'] = help; -import * as import_ from './import.js'; commands['import'] = import_; -import * as info from './info.js'; commands['info'] = info; -import * as init from './init.js'; commands['init'] = init; -import * as install from './install.js'; commands['install'] = install; -import * as licenses from './licenses.js'; commands['licenses'] = licenses; -import * as link from './link.js'; commands['link'] = link; -import * as login from './login.js'; commands['login'] = login; -import * as logout from './logout.js'; commands['logout'] = logout; -import * as list from './list.js'; commands['list'] = list; -import * as outdated from './outdated.js'; commands['outdated'] = outdated; -import * as owner from './owner.js'; commands['owner'] = owner; -import * as pack from './pack.js'; commands['pack'] = pack; -import * as publish from './publish.js'; commands['publish'] = publish; -import * as remove from './remove.js'; commands['remove'] = remove; -import * as run from './run.js'; commands['run'] = run; -import * as tag from './tag.js'; commands['tag'] = tag; -import * as team from './team.js'; commands['team'] = team; -import * as unlink from './unlink.js'; commands['unlink'] = unlink; -import * as upgrade from './upgrade.js'; commands['upgrade'] = upgrade; -import * as version from './version.js'; commands['version'] = version; -import * as versions from './versions.js'; commands['versions'] = versions; -import * as why from './why.js'; commands['why'] = why; -import * as upgradeInteractive from './upgrade-interactive.js'; commands['upgradeInteractive'] = upgradeInteractive; +import * as access from './access.js'; +import * as add from './add.js'; +import * as bin from './bin.js'; +import * as cache from './cache.js'; +import * as check from './check.js'; +import * as clean from './clean.js'; +import * as config from './config.js'; +import * as generateLockEntry from './generate-lock-entry.js'; +import * as global from './global.js'; +import * as help from './help.js'; +import * as import_ from './import.js'; +import * as info from './info.js'; +import * as init from './init.js'; +import * as install from './install.js'; +import * as licenses from './licenses.js'; +import * as link from './link.js'; +import * as login from './login.js'; +import * as logout from './logout.js'; +import * as list from './list.js'; +import * as outdated from './outdated.js'; +import * as owner from './owner.js'; +import * as pack from './pack.js'; +import * as publish from './publish.js'; +import * as remove from './remove.js'; +import * as run from './run.js'; +import * as tag from './tag.js'; +import * as team from './team.js'; +import * as unlink from './unlink.js'; +import * as upgrade from './upgrade.js'; +import * as version from './version.js'; +import * as versions from './versions.js'; +import * as why from './why.js'; +import * as upgradeInteractive from './upgrade-interactive.js'; import buildUseless from './_useless.js'; -commands['lockfile'] = buildUseless( - "The lockfile command isn't necessary. `yarn install` will produce a lockfile.", -); - -commands['dedupe'] = buildUseless( - "The dedupe command isn't necessary. `yarn install` will already dedupe.", -); - -commands['prune'] = buildUseless( - "The prune command isn't necessary. `yarn install` will prune extraneous packages.", -); +const commands = { + access, + add, + bin, + cache, + check, + clean, + config, + dedupe: buildUseless( + "The dedupe command isn't necessary. `yarn install` will already dedupe.", + ), + generateLockEntry, + global, + help, + import: import_, + info, + init, + install, + licenses, + link, + lockfile: buildUseless( + "The lockfile command isn't necessary. `yarn install` will produce a lockfile.", + ), + login, + logout, + list, + outdated, + owner, + pack, + prune: buildUseless( + "The prune command isn't necessary. `yarn install` will prune extraneous packages.", + ), + publish, + remove, + run, + tag, + team, + unlink, + upgrade, + version, + versions, + why, + upgradeInteractive, +}; for (const key in commands) { commands[key].getDocsInfo = getDocsInfo(key); @@ -83,6 +114,4 @@ for (const key in unsupportedAliases) { }; } -export default ({ - ...commands, -}: { [key: string]: Object }); +export default (commands);