2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00

chore(ci): add tag resolution for npm releases based on package version; (#6404)

This commit is contained in:
Dmitriy Mozgovoy
2024-05-19 20:34:58 +03:00
committed by GitHub
parent 870e0a76f6
commit 097b0d18e9
4 changed files with 66 additions and 35 deletions
+1 -34
View File
@@ -1,41 +1,8 @@
import util from "util";
import cp from "child_process";
import Handlebars from "handlebars";
import fs from "fs/promises";
import prettyBytes from 'pretty-bytes';
import {gzipSize} from 'gzip-size';
const exec = util.promisify(cp.exec);
const getBlobHistory = async (filepath, maxCount= 5) => {
const log = (await exec(
`git log --max-count=${maxCount} --no-walk --tags=v* --oneline --format=%H%d -- ${filepath}`
)).stdout;
const commits = [];
let match;
const regexp = /^(\w+) \(tag: (v?[.\d]+)\)$/gm;
while((match = regexp.exec(log))) {
commits.push({
sha: match[1],
tag: match[2],
size: await getBlobSize(filepath, match[1])
})
}
return commits;
}
const getBlobSize = async (filepath, sha ='HEAD') => {
const size = (await exec(
`git cat-file -s ${sha}:${filepath}`
)).stdout;
return size ? +size : 0;
}
import {getBlobHistory} from './repo.js';
const generateFileReport = async (files) => {
const stat = {};