| 59 | } |
| 60 | |
| 61 | function parseArgs(argv) { |
| 62 | const options = { |
| 63 | registry: DEFAULT_REGISTRY, |
| 64 | tag: DEFAULT_TAG, |
| 65 | provenance: false, |
| 66 | dryRun: false, |
| 67 | }; |
| 68 | |
| 69 | for (const arg of argv) { |
| 70 | if (arg.startsWith('--tag=')) { |
| 71 | options.tag = arg.slice('--tag='.length); |
| 72 | } else if (arg.startsWith('--registry=')) { |
| 73 | options.registry = arg.slice('--registry='.length); |
| 74 | } else if (arg === '--provenance') { |
| 75 | options.provenance = true; |
| 76 | } else if (arg === '--dry-run') { |
| 77 | options.dryRun = true; |
| 78 | } else { |
| 79 | throw new Error(`Unknown argument: ${arg}`); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | if (!options.tag) { |
| 84 | throw new Error('--tag must not be empty'); |
| 85 | } |
| 86 | |
| 87 | return { ...options, registry: options.registry.replace(/\/+$/, '') }; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Every non-private package in the pnpm workspace, i.e. exactly the set that |