MCPcopy Index your code
hub / github.com/npmx-dev/npmx.dev / executeOperation

Function executeOperation

cli/src/server.ts:746–829  ·  view source on GitHub ↗
(
  op: PendingOperation,
  options: { otp?: string; interactive?: boolean; openUrls?: boolean } = {},
)

Source from the content-addressed store, hash-verified

744}
745
746async 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)

Callers 1

createConnectorAppFunction · 0.85

Calls 12

orgAddUserFunction · 0.90
orgRemoveUserFunction · 0.90
teamCreateFunction · 0.90
teamDestroyFunction · 0.90
teamAddUserFunction · 0.90
teamRemoveUserFunction · 0.90
accessGrantFunction · 0.90
accessRevokeFunction · 0.90
ownerAddFunction · 0.90
ownerRemoveFunction · 0.90
packageInitFunction · 0.90
extractUrlsFunction · 0.90

Tested by

no test coverage detected