|
11 | 11 | */
|
12 | 12 |
|
13 | 13 | const exec = require('child_process').execSync;
|
| 14 | +const spawn = require('child_process').spawnSync; |
14 | 15 | const fs = require('fs');
|
15 | 16 | const fetch = require('node-fetch');
|
16 | 17 | const semver = require('semver');
|
@@ -134,22 +135,19 @@ class VersionManager {
|
134 | 135 | return;
|
135 | 136 | }
|
136 | 137 |
|
137 |
| - let sinceIndex = process.argv.findIndex(arg => arg === '--since'); |
138 |
| - let since = sinceIndex >= 0 ? process.argv[sinceIndex + 1] : '$(git describe --tags --abbrev=0)'; |
139 |
| - let res = exec(`git diff ${since}..HEAD --name-only packages ':!**/dev/**' ':!**/docs/**' ':!**/test/**' ':!**/stories/**' ':!**/chromatic/**'`, {encoding: 'utf8'}); |
140 |
| - |
141 |
| - for (let line of res.trim().split('\n')) { |
142 |
| - let parts = line.split('/').slice(1, 3); |
143 |
| - if (!parts[0].startsWith('@')) { |
144 |
| - parts.pop(); |
145 |
| - } |
146 |
| - |
147 |
| - let name = parts.join('/'); |
148 |
| - try { |
149 |
| - let pkg = JSON.parse(fs.readFileSync(`packages/${name}/package.json`, 'utf8')); |
150 |
| - this.changedPackages.add(name); |
151 |
| - } catch (err) { |
152 |
| - console.log(err); |
| 138 | + // Diff each package individually. Some packages might have been skipped during last release, |
| 139 | + // so we cannot simply look at the last tag on the whole repo. |
| 140 | + for (let name in this.workspacePackages) { |
| 141 | + let filePath = this.workspacePackages[name].location + '/package.json'; |
| 142 | + let pkg = JSON.parse(fs.readFileSync(filePath, 'utf8')); |
| 143 | + if (!pkg.private) { |
| 144 | + // Diff this package since the last published version, according to the package.json. |
| 145 | + // We create a git tag for each package version. |
| 146 | + let tag = `${pkg.name}@${pkg.version}`; |
| 147 | + let res = spawn('git', ['diff', '--exit-code', tag + '..HEAD', this.workspacePackages[name].location, ':!**/docs/**', ':!**/test/**', ':!**/stories/**', ':!**/chromatic/**']); |
| 148 | + if (res.status !== 0) { |
| 149 | + this.changedPackages.add(name); |
| 150 | + } |
153 | 151 | }
|
154 | 152 | }
|
155 | 153 |
|
|
0 commit comments