| 62 | |
| 63 | class VersionManager { |
| 64 | constructor() { |
| 65 | let workspaceLookup = {}; |
| 66 | // Get dependency tree from yarn workspaces |
| 67 | this.workspacePackages = exec('yarn workspaces list --json -v') |
| 68 | .toString() |
| 69 | .split('\n') |
| 70 | .map(line => { |
| 71 | try { |
| 72 | let result = JSON.parse(line); |
| 73 | workspaceLookup[result.location] = result.name; |
| 74 | return result; |
| 75 | } catch (e) { |
| 76 | // ignore empty lines |
| 77 | } |
| 78 | }) |
| 79 | .filter(Boolean) |
| 80 | .reduce((acc, item) => { |
| 81 | acc[item.name] = item; |
| 82 | acc[item.name].workspaceDependencies = item.workspaceDependencies.map( |
| 83 | dep => workspaceLookup[dep] |
| 84 | ); |
| 85 | return acc; |
| 86 | }, {}); |
| 87 | this.existingPackages = new Set(); |
| 88 | this.changedPackages = new Set(); |
| 89 | this.versionBumps = {}; |
| 90 | this.releasedPackages = new Map(); |
| 91 | } |
| 92 | |
| 93 | async run() { |
| 94 | await this.getExistingPackages(); |