(input, package_, options, {packageManager, rootDirectory})
| 9 | import {getOidcProvider} from './npm/oidc.js'; |
| 10 | |
| 11 | const prerequisiteTasks = (input, package_, options, {packageManager, rootDirectory}) => { |
| 12 | const isExternalRegistry = npm.isExternalRegistry(package_); |
| 13 | let newVersion; |
| 14 | |
| 15 | const tasks = [ |
| 16 | { |
| 17 | title: 'Ping npm registry', |
| 18 | enabled: () => !package_.private && !isExternalRegistry, |
| 19 | task: async () => npm.checkConnection(), |
| 20 | }, |
| 21 | { |
| 22 | title: `Check ${packageManager.cli} version`, |
| 23 | async task() { |
| 24 | const {stdout: version} = await execa(packageManager.cli, ['--version']); |
| 25 | util.validateEngineVersionSatisfies(packageManager.cli, version); |
| 26 | }, |
| 27 | }, |
| 28 | { |
| 29 | title: 'Verify user is authenticated', |
| 30 | enabled: () => process.env.NODE_ENV !== 'test' && !package_.private, |
| 31 | skip() { |
| 32 | if (getOidcProvider()) { |
| 33 | return 'Environment support for OIDC authentication detected - Skipping whoami check'; |
| 34 | } |
| 35 | }, |
| 36 | async task() { |
| 37 | const externalRegistry = package_.publishConfig?.registry; |
| 38 | const username = await npm.username({externalRegistry}); |
| 39 | |
| 40 | const collaborators = await npm.collaborators(package_); |
| 41 | if (!collaborators) { |
| 42 | return; |
| 43 | } |
| 44 | |
| 45 | const json = JSON.parse(collaborators); |
| 46 | const permissions = json[username]; |
| 47 | if (!permissions || !permissions.includes('write')) { |
| 48 | throw new Error('You do not have write permissions required to publish this package.'); |
| 49 | } |
| 50 | }, |
| 51 | }, |
| 52 | { |
| 53 | title: 'Check git version', |
| 54 | task: async () => git.verifyRecentGitVersion(), |
| 55 | }, |
| 56 | { |
| 57 | title: 'Check git user configuration', |
| 58 | task: async () => git.verifyUserConfigIsSet(), |
| 59 | }, |
| 60 | { |
| 61 | title: 'Check git remote', |
| 62 | task: async () => git.verifyRemoteIsValid(options.remote), |
| 63 | }, |
| 64 | { |
| 65 | title: 'Validate version', |
| 66 | task() { |
| 67 | newVersion = input instanceof Version |
| 68 | ? input |
no outgoing calls
no test coverage detected
searching dependent graphs…