chore: fix file name

This commit is contained in:
元凛
2022-02-15 13:38:07 +08:00
parent d874829fb1
commit 0a220d0ec9
7 changed files with 2 additions and 2 deletions

23
scripts/check-commit.js Executable file
View File

@@ -0,0 +1,23 @@
const chalk = require('chalk');
const simpleGit = require('simple-git/promise');
const cwd = process.cwd();
const git = simpleGit(cwd);
async function checkCommit({ files }) {
if (files.length) {
console.log(chalk.yellow('🙄 You forgot something to commit.'));
files.forEach(({ path: filePath }) => {
console.log(' -', chalk.red(filePath));
});
console.log('');
process.exit(1);
}
}
async function run() {
const status = await git.status();
await checkCommit(status);
}
run();

14
scripts/pub.sh Normal file
View File

@@ -0,0 +1,14 @@
echo "[TEST] check format"
npm run format-check
echo "[TEST] test package"
npm run package
echo "[TEST] test commit"
npm run check-commit
echo "[Action] do tag"
npm run tag
echo "[Action] do release"
npm run release

54
scripts/release.js Normal file
View File

@@ -0,0 +1,54 @@
const chalk = require('chalk');
const open = require('open');
const newGithubReleaseUrl = require('new-github-release-url');
const { readFileSync } = require('fs');
const path = require('path');
let tag = '';
const CHANGELOG_NAME = 'CHANGELOG.md';
const user = 'actions-cool';
const repo = 'issues-helper';
function getChangelog(content) {
const lines = content.split('\n');
const changeLog = [];
const pin = /^## /;
let begin = false;
for (let i = 0; i < lines.length; i += 1) {
const line = lines[i];
if (begin && pin.test(line)) {
break;
}
if (begin && line) {
changeLog.push(line);
}
if (!begin) {
begin = pin.test(line);
if (begin) {
tag = line.substring(3, line.length).trim();
}
}
}
return changeLog.join('\n');
}
const changelogPath = path.join(__dirname, '..', CHANGELOG_NAME);
const changelog = readFileSync(changelogPath, 'utf-8');
const body = getChangelog(changelog);
async function run() {
const url = newGithubReleaseUrl({
user,
repo,
tag,
body: body,
});
await open(url);
console.log(chalk.yellow('🚀 Please check tag and changelog. Then click publish!'));
}
run();

70
scripts/tag.js Normal file
View File

@@ -0,0 +1,70 @@
const chalk = require('chalk');
const simpleGit = require('simple-git/promise');
const { execSync } = require('child_process');
const { readFileSync } = require('fs');
const path = require('path');
const CHANGELOG_NAME = 'CHANGELOG.md';
const CHANGELOG_PATH = path.join(__dirname, '..', CHANGELOG_NAME);
const CHANGELOG = readFileSync(CHANGELOG_PATH, 'utf-8');
const cwd = process.cwd();
const git = simpleGit(cwd);
async function run() {
execSync(`git pull`);
const data = await git.tags();
const tags = data.all;
let tag = tags.reverse()[0];
console.log(chalk.green(`[Git Query] tag: ${tag}`));
const tagChangelog = getChangelogTag(CHANGELOG);
if (tagChangelog && tag != tagChangelog) {
console.log(chalk.yellow(`[Git Action] Push new ${tagChangelog} tag!`));
execSync(`git tag ${tagChangelog}`);
execSync(`git push origin ${tagChangelog}:${tagChangelog}`);
execSync(`git pull`);
tag = tagChangelog;
} else {
console.log(chalk.yellow('🙄 Please add new release changelog first.'));
console.log('');
process.exit(1);
}
const tagSimple = tag.startsWith('v') ? tag.substring(0, 2) : tag.substring(0, 1);
console.log(chalk.green(`[Git Query] tagSimple: ${tagSimple}`));
if (tags.includes(tagSimple)) {
console.log(chalk.yellow(`[Git Action] Delete ${tagSimple} tag`));
execSync(`git push origin :refs/tags/${tagSimple}`);
}
console.log(chalk.yellow(`[Git Action] Add new simple ${tagSimple} tag`));
execSync(`git push origin ${tag}:${tagSimple}`);
console.log(chalk.green('🎉 Done!'));
}
function getChangelogTag(content) {
const lines = content.split('\n');
const pin = /^## /;
let begin = false;
let tag = '';
for (let i = 0; i < lines.length; i += 1) {
const line = lines[i];
if (begin && pin.test(line)) {
break;
}
if (!begin) {
begin = pin.test(line);
if (begin) {
tag = line.substring(3, line.length);
}
}
}
return tag.trim();
}
run();

111
scripts/update-users.js Normal file
View File

@@ -0,0 +1,111 @@
const { readFileSync, writeFileSync } = require('fs');
const { stripIndent } = require('common-tags');
// **************************************************************************
let { users } = require('../USERS.js');
users.sort((a, b) => getCurrentName(a).localeCompare(getCurrentName(b)));
// **************************************************************************
const DEFAULT_WIDTH = 46;
// **************************************************************************
let table = '';
let row = users.length / 4;
let lastNo = users.length % 4;
if (lastNo != 0) row += 1;
for (let j = 1; j <= row; j++) {
let data = '';
data = stripIndent`
<tr>
<td align="center" width="180">${getImg(users[(j - 1) * 4])}</td>
<td align="center" width="180">${getImg(users[(j - 1) * 4 + 1])}</td>
<td align="center" width="180">${getImg(users[(j - 1) * 4 + 2])}</td>
<td align="center" width="180">${getImg(users[(j - 1) * 4 + 3])}</td>
</tr>
<tr>
<td align="center" width="180">${getName(users[(j - 1) * 4])}</td>
<td align="center" width="180">${getName(users[(j - 1) * 4 + 1])}</td>
<td align="center" width="180">${getName(users[(j - 1) * 4 + 2])}</td>
<td align="center" width="180">${getName(users[(j - 1) * 4 + 3])}</td>
</tr>
`;
table += data;
}
table = `<table>
${table}
</table>
`;
// **************************************************************************
const point = '<table>';
const cnPoint = `## 图标`;
const enPoint = `## Badge`;
// **************************************************************************
const cn = readFileSync('./README.md', 'utf8');
const cnIn = cn.indexOf(point);
const cnAfterIn = cn.indexOf(cnPoint);
const cnBefore = cn.substring(0, cnIn);
const cnAfter = cn.substring(cnAfterIn, cn.length);
const newcn = cnBefore + table + cnAfter;
writeFileSync('./README.md', newcn);
console.log(`🎉 Done cn`);
// **************************************************************************
const en = readFileSync('./README.en-US.md', 'utf8');
const enIn = en.indexOf(point);
const enAfterIn = en.indexOf(enPoint);
const enBefore = en.substring(0, enIn);
const enAfter = en.substring(enAfterIn, en.length);
const newen = enBefore + table + enAfter;
writeFileSync('./README.en-US.md', newen);
console.log(`🎉 Done en`);
// **************************************************************************
function getImg(o) {
if (o) {
return `
<a href="${o.url}">
<img src="${o.logo}"${getImgWidth(o)}/>
</a>
`;
}
return ``;
}
function getImgWidth(o) {
if (o) {
let width = o.width;
if (width === 'auto') {
width = '';
} else {
width = width ? width : DEFAULT_WIDTH;
}
return ` width="${width}"`;
}
return '';
}
function getName(o) {
if (o) {
return `<a href="${o.url}">${o.url.split('/').slice(-1)[0]}</a>`;
}
return ``;
}
function getCurrentName(o) {
if (o) {
return o.url.split('/').slice(-1)[0];
}
return ``;
}
// **************************************************************************

44
scripts/update-version.js Normal file
View File

@@ -0,0 +1,44 @@
const { readFileSync, writeFileSync } = require('fs');
const last = /@v2/g;
const now = `@v3`;
let readme = readFileSync('./README.md', 'utf-8');
readme = readme.replace(last, now);
writeFileSync('./README.md', readme);
console.log('readme done!');
let readmeen = readFileSync('./README.en-US.md', 'utf-8');
readmeen = readmeen.replace(last, now);
writeFileSync('./README.en-US.md', readmeen);
console.log('readmeen done!');
let index = readFileSync('./web/docs/index.md', 'utf-8');
index = index.replace(last, now);
writeFileSync('./web/docs/index.md', index);
console.log('index done!');
let indexen = readFileSync('./web/docs/index.en-US.md', 'utf-8');
indexen = indexen.replace(last, now);
writeFileSync('./web/docs/index.en-US.md', indexen);
console.log('indexen done!');
let base = readFileSync('./web/docs/base.md', 'utf-8');
base = base.replace(last, now);
writeFileSync('./web/docs/base.md', base);
console.log('base done!');
let baseen = readFileSync('./web/docs/base.en-US.md', 'utf-8');
baseen = baseen.replace(last, now);
writeFileSync('./web/docs/base.en-US.md', baseen);
console.log('baseen done!');
let adv = readFileSync('./web/docs/advanced.md', 'utf-8');
adv = adv.replace(last, now);
writeFileSync('./web/docs/advanced.md', adv);
console.log('adv done!');
let adven = readFileSync('./web/docs/advanced.en-US.md', 'utf-8');
adven = adven.replace(last, now);
writeFileSync('./web/docs/advanced.en-US.md', adven);
console.log('adven done!');