2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-20 20:00:40 +03:00

chore(ci): fix release action;

* chore(ci): Add release-it script;
* fix(utils): redesigned logic for obtaining the global link;;
* chore(git): updated .gitignore;
chore(npm): updated .npmignore;
* chore(git): fix husky prepare script;
* chore(github): reworked npm release action step;
* chore(ci): add CHANGELOG.md contributors section generator;
* chore(deps): add `auto-changelog` to package.json;
This commit is contained in:
Dmitriy Mozgovoy
2022-12-20 20:45:24 +02:00
committed by GitHub
parent f12d01eed1
commit 46085e6ffc
10 changed files with 275 additions and 30 deletions
+47
View File
@@ -0,0 +1,47 @@
import fs from 'fs/promises';
import path from 'path';
import {renderContributorsList} from './contributors.js';
import asyncReplace from 'string-replace-async';
import {fileURLToPath} from "url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const injectContributors = async (infile, injector) => {
console.log(`Checking contributors sections in ${infile}`);
infile = path.resolve(__dirname, infile);
const content = String(await fs.readFile(infile));
const headerRE = /^##\s+\[([-_\d.\w]+)]\s+-.+/mig;
const contributorsRE = /^\s*### Contributors/mi;
let tag;
let index = 0;
const newContent = await asyncReplace(content, headerRE, async (match, nextTag, offset) => {
const releaseContent = content.slice(index, offset);
const hasContributorsSection = contributorsRE.test(releaseContent);
const currentTag = tag;
tag = nextTag;
index = offset + match.length;
if(currentTag && !hasContributorsSection) {
console.log(`Adding contributors for ${currentTag}`);
return (await injector(currentTag)) + match;
}
return match;
});
await fs.writeFile(infile, newContent);
}
await injectContributors(
'../CHANGELOG.md',
(tag) => renderContributorsList(tag, true, path.resolve(__dirname, '../templates/contributors.hbs')
));