(positionalArgs, flags)
| 26 | ] |
| 27 | |
| 28 | async exec (positionalArgs, flags) { |
| 29 | const dryRun = this.config.get('dry-run') |
| 30 | const pkgName = positionalArgs[0] || (await this.optionalPkgJson()).name |
| 31 | if (!pkgName) { |
| 32 | throw new Error('Package name must be specified either as an argument or in the package.json file') |
| 33 | } |
| 34 | const { id } = flags |
| 35 | if (!id) { |
| 36 | throw new Error('ID of the trusted relationship to revoke must be specified with the --id option') |
| 37 | } |
| 38 | this.dialogue`Attempting to revoke trusted configuration for package ${pkgName} with id ${id}` |
| 39 | if (dryRun) { |
| 40 | return |
| 41 | } |
| 42 | const spec = npa(pkgName) |
| 43 | const uri = `/-/package/${spec.escapedName}/trust/${encodeURIComponent(id)}` |
| 44 | await otplease(this.npm, this.npm.flatOptions, opts => npmFetch(uri, { |
| 45 | ...opts, |
| 46 | method: 'DELETE', |
| 47 | })) |
| 48 | this.dialogue`Revoked trusted configuration for package ${pkgName} with id ${id}` |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | module.exports = TrustRevoke |
nothing calls this directly
no test coverage detected