| 170 | } |
| 171 | |
| 172 | getChangedPackages() { |
| 173 | let packagesIndex = process.argv.findIndex(arg => arg === '--add' || arg === '--only'); |
| 174 | if (packagesIndex >= 0) { |
| 175 | for (let pkg of process.argv.slice(packagesIndex + 1)) { |
| 176 | this.changedPackages.add(pkg); |
| 177 | } |
| 178 | if (process.argv[packagesIndex] === '--only') { |
| 179 | return; |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | // Diff each package individually. Some packages might have been skipped during last release, |
| 184 | // so we cannot simply look at the last tag on the whole repo. |
| 185 | for (let name in this.workspacePackages) { |
| 186 | let filePath = this.workspacePackages[name].location + '/package.json'; |
| 187 | let pkg = JSON.parse(fs.readFileSync(filePath, 'utf8')); |
| 188 | if (isSkipped(pkg)) { |
| 189 | console.log('skip', name); |
| 190 | continue; |
| 191 | } |
| 192 | |
| 193 | if (!pkg.private) { |
| 194 | // Diff this package since the last published version, according to the package.json. |
| 195 | // We create a git tag for each package version. |
| 196 | let tag = `${pkg.name}@${pkg.version}`; |
| 197 | let res = spawn('git', [ |
| 198 | 'diff', |
| 199 | '--exit-code', |
| 200 | tag + '..HEAD', |
| 201 | this.workspacePackages[name].location, |
| 202 | ':!**/docs/**', |
| 203 | ':!**/test/**', |
| 204 | ':!**/stories/**', |
| 205 | ':!**/chromatic/**' |
| 206 | ]); |
| 207 | if (res.status !== 0) { |
| 208 | this.changedPackages.add(name); |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | async getVersionBumps() { |
| 215 | return new Promise(resolve => { |