🎉 Initial commit

master
KaKi87 5 months ago
commit 168bf4fe66
  1. 1
      .gitignore
  2. 0
      data/.gitkeep
  3. 42
      downloadData.js
  4. 17
      getKeywordTable.js
  5. 60
      getVersionTable.js
  6. 1
      lib/keywordRegexp.js
  7. 12
      lib/pathExists.js

1
.gitignore vendored

@ -0,0 +1 @@
data

@ -0,0 +1,42 @@
import axiod from 'https://deno.land/x/axiod@0.24/mod.ts';
import pathExists from './lib/pathExists.js';
const
client = axiod.create({ baseURL: 'https://api.github.com/repos/go-gitea/gitea' }),
data = [];
{
let chunk, page = 1;
do {
({
data: chunk
} = await client.get('releases', { params: { 'per_page': 100, 'page': page++ } }));
data.push(...chunk);
}
while(chunk && chunk.length);
}
await Deno.writeTextFile('./data/index.json', JSON.stringify(data, null, 4));
for(let i = 0; i < data.length; i++){
const
{ [i]: { id }, length } = data,
filePath = `./data/${id}.json`;
if(!await pathExists(filePath))
await Deno.writeTextFile(
filePath,
JSON.stringify(
(await client.get(
`releases/${id}`,
{
headers: {
'authorization': `token ${Deno.env.get('TOKEN')}`
}
}
)).data,
null,
4
)
);
console.log(`${i+1}/${length} (${((i+1) / length * 100).toFixed(2)}%)`);
}

@ -0,0 +1,17 @@
import AsciiTable from 'https://dev.jspm.io/npm:ascii-table@0.0.9';
import keywordRegexp from './lib/keywordRegexp.js';
const
index = JSON.parse(await Deno.readTextFile('./data/index.json')),
data = await Promise.all(index.map(async ({ id }) => JSON.parse(await Deno.readTextFile(`./data/${id}.json`)))),
table = new AsciiTable().setHeading('Keyword', 'Version count'),
keyword = {};
for(const { body } of data){
if(body)
[...body.matchAll(keywordRegexp)].map(([, item]) => item).forEach(item => keyword[item] = (keyword[item] || 0) + 1);
}
Object.entries(keyword).sort(([, a], [, b]) => b - a).map(item => table.addRow(...item));
console.log(table.toString());

@ -0,0 +1,60 @@
import AsciiTable from 'https://dev.jspm.io/npm:ascii-table@0.0.9';
import keywordRegexp from './lib/keywordRegexp.js';
import * as semver from 'https://deno.land/x/semver@v1.4.0/mod.ts';
const
index = JSON.parse(await Deno.readTextFile('./data/index.json')),
data = await Promise.all(index.map(async ({ id }) => JSON.parse(await Deno.readTextFile(`./data/${id}.json`)))),
items = data.filter(item => !item['tag_name'].includes('-')).sort((a, b) => a.id - b.id),
table = new AsciiTable().setHeading('ID', 'Actual version', 'Expected version', 'Actual increment', 'Expected increment');
{
let version;
for(let i = 0; i < items.length; i++){
const {
id,
'tag_name': tagName,
body
} = items[i];
if(body){
const keywords = [...body.matchAll(keywordRegexp)].map(([, item]) => item);
if(keywords.length){
const actualIncrement = i > 0 ? semver.diff(items[i-1]['tag_name'].slice(1), tagName.slice(1)) : undefined;
let increment = 'patch';
if([
'FEATURE',
'ENHANCEMENT',
'TRANSLATION',
'FEATURES',
'ENHANCEMENTS',
'API'
].some(item => keywords.includes(item)))
increment = 'minor';
if([
'BREAKING'
].some(item => keywords.includes(item)))
increment = 'major';
version = version ? semver.inc(version, increment) : '1.0.0';
const displayVersion = `v${version}`;
table.addRow(
id,
tagName,
tagName === displayVersion ? '(same)' : displayVersion,
actualIncrement,
actualIncrement === increment ? '(same)' : increment
);
}
else
table.addRow(id, tagName, 'N/A', 'N/A', 'N/A');
}
else
table.addRow(id, tagName, 'N/A', 'N/A', 'N/A');
}
console.log(table.toString());
}

@ -0,0 +1 @@
export default /(?:\*\s|-\s|<details><summary>)([A-Z]+)(?:<\/summary>|\r|\n)/g;

@ -0,0 +1,12 @@
export default async path => {
try {
await Deno.stat(path);
return true;
}
catch(error){
if(error.constructor.name === 'NotFound')
return false;
else
throw error;
}
};