(opts)
| 91 | } |
| 92 | |
| 93 | const main = async (opts) => { |
| 94 | const { test, otp, dryRun, smokePublish, packDestination } = opts |
| 95 | |
| 96 | const hasPackDest = !!packDestination |
| 97 | const publishes = await getPublishes({ force: smokePublish }) |
| 98 | |
| 99 | if (!publishes.length) { |
| 100 | throw new Error( |
| 101 | 'Nothing to publish, exiting.\n' + |
| 102 | 'All packages to publish should have their version bumped before running this script.' |
| 103 | ) |
| 104 | } |
| 105 | |
| 106 | const table = new Table({ head: ['name', 'version', 'tag'] }) |
| 107 | for (const publish of publishes) { |
| 108 | table.push([publish.name, publish.version, publish.tag]) |
| 109 | } |
| 110 | |
| 111 | const preformOperations = hasPackDest ? ['publish', 'pack'] : ['publish'] |
| 112 | |
| 113 | const confirmMessage = [ |
| 114 | `Ready to ${preformOperations.join(',')} the following packages:`, |
| 115 | table.toString(), |
| 116 | smokePublish ? null : 'Ok to proceed? ', |
| 117 | ].filter(Boolean).join('\n') |
| 118 | |
| 119 | if (smokePublish) { |
| 120 | log.info(confirmMessage) |
| 121 | } else { |
| 122 | const confirm = await read({ prompt: confirmMessage, default: 'y' }) |
| 123 | if (confirm.trim().toLowerCase().charAt(0) !== 'y') { |
| 124 | throw new Error('Aborted') |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | await git('clean', '-fd') |
| 129 | await resetdeps() |
| 130 | await npm('ls', '--omit=dev', { quiet: true }) |
| 131 | await npm('rm', '--global', '--force', 'npm') |
| 132 | await npm('link', '--force', '--ignore-scripts') |
| 133 | |
| 134 | if (test) { |
| 135 | await npm('run', 'lint-all', '--ignore-scripts') |
| 136 | await npm('run', 'postlint', '--ignore-scripts') |
| 137 | await npm('run', 'test-all', '--ignore-scripts') |
| 138 | } |
| 139 | |
| 140 | await npm('prune', '--omit=dev', '--no-save', '--no-audit', '--no-fund') |
| 141 | await npm('install', '-w', 'docs', '--ignore-scripts', '--no-audit', '--no-fund') |
| 142 | |
| 143 | if (smokePublish) { |
| 144 | log.info(`Skipping git dirty check due to local smoke publish test being run`) |
| 145 | } else { |
| 146 | await git.dirty() |
| 147 | } |
| 148 | |
| 149 | let count = -1 |
| 150 |
no test coverage detected