()
| 205 | run(); |
| 206 | |
| 207 | async function run() { |
| 208 | let packages = exec('yarn workspaces list --json') |
| 209 | .toString() |
| 210 | .split(require('os').EOL) |
| 211 | .filter(Boolean) |
| 212 | .map(x => JSON.parse(x)); |
| 213 | |
| 214 | let commitsByLibrary = new Map(); |
| 215 | let libraryTags = new Map(); |
| 216 | |
| 217 | for (let {location} of packages) { |
| 218 | let filePath = location + '/package.json'; |
| 219 | let pkg = JSON.parse(fs.readFileSync(filePath, 'utf8')); |
| 220 | if (pkg.private) { |
| 221 | continue; |
| 222 | } |
| 223 | |
| 224 | let library = packageToLibrary(pkg.name); |
| 225 | if (!library) { |
| 226 | if (!pkg.name.startsWith('@spectrum-icons/')) { |
| 227 | console.warn(`⚠ No library mapping for ${pkg.name} — skipped`); |
| 228 | } |
| 229 | continue; |
| 230 | } |
| 231 | |
| 232 | let tag = resolveTag(pkg.name, pkg.version); |
| 233 | if (!tag) { |
| 234 | console.warn(`⚠ No tag found for ${pkg.name}@${pkg.version} — skipped`); |
| 235 | continue; |
| 236 | } |
| 237 | |
| 238 | // Track the first tag seen per library as the anchor for git log ranges. |
| 239 | if (!libraryTags.has(library)) { |
| 240 | libraryTags.set(library, tag); |
| 241 | } |
| 242 | |
| 243 | let args = [ |
| 244 | 'log', |
| 245 | `${tag}..HEAD`, |
| 246 | '--pretty="%H%x00%aI%x00%an%x00%s"', |
| 247 | location, |
| 248 | |
| 249 | // filter out non-code changes |
| 250 | ':!**/test/**', |
| 251 | ':!**/stories/**', |
| 252 | ':!**/chromatic/**' |
| 253 | ]; |
| 254 | |
| 255 | let res = spawn('git', args, {encoding: 'utf8'}); |
| 256 | if (res.stdout.length === 0) { |
| 257 | continue; |
| 258 | } |
| 259 | |
| 260 | if (!commitsByLibrary.has(library)) { |
| 261 | commitsByLibrary.set(library, new Map()); |
| 262 | } |
| 263 | let bucket = commitsByLibrary.get(library); |
| 264 |
no test coverage detected