| 80 | } |
| 81 | |
| 82 | logOptions (options, pad = true) { |
| 83 | const { values, warnings, fromPackageJson, urls, permissions } = { warnings: [], ...options } |
| 84 | if (warnings && warnings.length > 0) { |
| 85 | for (const warningMsg of warnings) { |
| 86 | log.warn('trust', warningMsg) |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | const json = this.config.get('json') |
| 91 | if (json) { |
| 92 | const jsonValues = { ...options.values } |
| 93 | if (permissions) { |
| 94 | jsonValues.permissions = permissions |
| 95 | } |
| 96 | // Disable redaction: trust config values (e.g. CircleCI UUIDs) are not secrets |
| 97 | output.standard(JSON.stringify(jsonValues, null, 2), { [META]: true, redact: false }) |
| 98 | return |
| 99 | } |
| 100 | |
| 101 | const chalk = this.npm.chalk |
| 102 | const { type, id, ...rest } = values || {} |
| 103 | |
| 104 | if (values) { |
| 105 | const lines = [] |
| 106 | if (type) { |
| 107 | lines.push(`type: ${chalk.green(type)}`) |
| 108 | } |
| 109 | if (id) { |
| 110 | lines.push(`id: ${chalk.green(id)}`) |
| 111 | } |
| 112 | for (const [key, value] of Object.entries(rest)) { |
| 113 | if (value !== null && value !== undefined) { |
| 114 | const parts = [ |
| 115 | `${chalk.reset(key)}: ${chalk.green(value)}`, |
| 116 | ] |
| 117 | if (fromPackageJson && fromPackageJson[key]) { |
| 118 | parts.push(`(${chalk.yellow(`from package.json`)})`) |
| 119 | } |
| 120 | lines.push(parts.join(' ')) |
| 121 | } |
| 122 | } |
| 123 | const formattedPermissions = TrustCommand.formatPermissions(permissions) |
| 124 | if (formattedPermissions) { |
| 125 | lines.push(`${chalk.reset('permissions')}: ${chalk.green(formattedPermissions)}`) |
| 126 | } |
| 127 | if (pad) { |
| 128 | output.standard() |
| 129 | } |
| 130 | output.standard(lines.join('\n'), { [META]: true, redact: false }) |
| 131 | // Print URLs on their own lines after config, following the same order as rest keys |
| 132 | if (urls) { |
| 133 | const urlLines = [] |
| 134 | for (const key of Object.keys(rest)) { |
| 135 | if (urls[key]) { |
| 136 | urlLines.push(chalk.blue(urls[key])) |
| 137 | } |
| 138 | } |
| 139 | if (urlLines.length > 0) { |