From 8ffeb71dfb248b4a76744bd06cd4d6100f17c8ae Mon Sep 17 00:00:00 2001 From: Gar Date: Thu, 7 Oct 2021 18:40:03 -0700 Subject: chore: refactor commands This is the first phase of refactoring the internal structure of the npm commands to set us up for future changes. This iteration changes the function signature of `exec` for all the commands to be a async (no more callbacks), and also groups all the commands into their own subdirectory. It also removes the Proxy `npm.commands` object, in favor of an `npm.cmd` and `npm.exec` function that breaks up the two things that proxy was doing. Namely, getting to the attributes of a given command (`npm.cmd` now does this), and actually running the command `npm.exec` does this. PR-URL: https://github.com/npm/cli/pull/3959 Credit: @wraithgar Close: #3959 Reviewed-by: @lukekarrys --- tap-snapshots/test/lib/commands/team.js.test.cjs | 85 ++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 tap-snapshots/test/lib/commands/team.js.test.cjs (limited to 'tap-snapshots/test/lib/commands/team.js.test.cjs') diff --git a/tap-snapshots/test/lib/commands/team.js.test.cjs b/tap-snapshots/test/lib/commands/team.js.test.cjs new file mode 100644 index 000000000..6a93234f5 --- /dev/null +++ b/tap-snapshots/test/lib/commands/team.js.test.cjs @@ -0,0 +1,85 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/lib/commands/team.js TAP team add --parseable > should output success result for parseable add user 1`] = ` +foo npmcli:developers added +` + +exports[`test/lib/commands/team.js TAP team add default output > should output success result for add user 1`] = ` +foo added to @npmcli:developers +` + +exports[`test/lib/commands/team.js TAP team create --parseable > should output parseable success result for create team 1`] = ` +npmcli:newteam created +` + +exports[`test/lib/commands/team.js TAP team create default output > should output success result for create team 1`] = ` ++@npmcli:newteam +` + +exports[`test/lib/commands/team.js TAP team destroy --parseable > should output parseable result for destroy team 1`] = ` +npmcli:newteam deleted +` + +exports[`test/lib/commands/team.js TAP team destroy default output > should output success result for destroy team 1`] = ` +-@npmcli:newteam +` + +exports[`test/lib/commands/team.js TAP team ls --parseable > should list users for a parseable scope:team 1`] = ` +darcyclarke +isaacs +nlf +ruyadorno +` + +exports[`test/lib/commands/team.js TAP team ls default output > should list users for a given scope:team 1`] = ` + +@npmcli:developers has 4 users: +darcyclarke isaacs nlf ruyadorno +` + +exports[`test/lib/commands/team.js TAP team ls no users > should list no users for a given scope 1`] = ` + +@npmcli:developers has 0 users +` + +exports[`test/lib/commands/team.js TAP team ls single user > should list single user for a given scope 1`] = ` + +@npmcli:developers has 1 user: +foo +` + +exports[`test/lib/commands/team.js TAP team ls --parseable > should list teams for a parseable scope 1`] = ` +npmcli:designers +npmcli:developers +npmcli:product +` + +exports[`test/lib/commands/team.js TAP team ls default output > should list teams for a given scope 1`] = ` + +@npmcli has 3 teams: +@npmcli:designers @npmcli:developers @npmcli:product +` + +exports[`test/lib/commands/team.js TAP team ls no teams > should list no teams for a given scope 1`] = ` + +@npmcli has 0 teams +` + +exports[`test/lib/commands/team.js TAP team ls single team > should list single team for a given scope 1`] = ` + +@npmcli has 1 team: +@npmcli:developers +` + +exports[`test/lib/commands/team.js TAP team rm --parseable > should output parseable result for remove user 1`] = ` +foo npmcli:newteam removed +` + +exports[`test/lib/commands/team.js TAP team rm default output > should output success result for remove user 1`] = ` +foo removed from @npmcli:newteam +` -- cgit v1.2.3