(
op: PendingOperation,
options: { otp?: string; interactive?: boolean; openUrls?: boolean } = {},
)
| 744 | } |
| 745 | |
| 746 | async function executeOperation( |
| 747 | op: PendingOperation, |
| 748 | options: { otp?: string; interactive?: boolean; openUrls?: boolean } = {}, |
| 749 | ): Promise<NpmExecResult> { |
| 750 | const { type, params } = op |
| 751 | |
| 752 | // Build exec options that get passed through to execNpm, which |
| 753 | // internally routes to either execFile or PTY-based execution. |
| 754 | const execOptions: ExecNpmOptions = { |
| 755 | otp: options.otp, |
| 756 | interactive: options.interactive, |
| 757 | openUrls: options.openUrls, |
| 758 | onAuthUrl: options.interactive |
| 759 | ? url => { |
| 760 | // Set authUrl on the operation so /state exposes it to the |
| 761 | // frontend while npm is still polling for authentication. |
| 762 | op.authUrl = url |
| 763 | } |
| 764 | : undefined, |
| 765 | } |
| 766 | |
| 767 | let result: NpmExecResult |
| 768 | |
| 769 | switch (type) { |
| 770 | case 'org:add-user': |
| 771 | case 'org:set-role': |
| 772 | result = await orgAddUser( |
| 773 | params.org, |
| 774 | params.user, |
| 775 | params.role as 'developer' | 'admin' | 'owner', |
| 776 | execOptions, |
| 777 | ) |
| 778 | break |
| 779 | case 'org:rm-user': |
| 780 | result = await orgRemoveUser(params.org, params.user, execOptions) |
| 781 | break |
| 782 | case 'team:create': |
| 783 | result = await teamCreate(params.scopeTeam, execOptions) |
| 784 | break |
| 785 | case 'team:destroy': |
| 786 | result = await teamDestroy(params.scopeTeam, execOptions) |
| 787 | break |
| 788 | case 'team:add-user': |
| 789 | result = await teamAddUser(params.scopeTeam, params.user, execOptions) |
| 790 | break |
| 791 | case 'team:rm-user': |
| 792 | result = await teamRemoveUser(params.scopeTeam, params.user, execOptions) |
| 793 | break |
| 794 | case 'access:grant': |
| 795 | result = await accessGrant( |
| 796 | params.permission as 'read-only' | 'read-write', |
| 797 | params.scopeTeam, |
| 798 | params.pkg, |
| 799 | execOptions, |
| 800 | ) |
| 801 | break |
| 802 | case 'access:revoke': |
| 803 | result = await accessRevoke(params.scopeTeam, params.pkg, execOptions) |
no test coverage detected