📄 changelog¶
📊 Analysis Summary¶
| Metric | Count |
|---|---|
| 🔧 Functions | 3 |
| 📦 Imports | 6 |
| 📊 Variables & Constants | 2 |
| ⚡ Async/Await Patterns | 3 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 scripts/changelog.ts
📦 Imports¶
| Name | Source |
|---|---|
CommitInfo |
@vueuse/metadata |
ContributorInfo |
@vueuse/metadata |
md5 |
md5 |
Git |
simple-git |
functions |
../packages/metadata/metadata |
uniq |
./utils |
Variables & Constants¶
| Name | Type | Kind | Value | Exported |
|---|---|---|---|---|
cache |
CommitInfo[] \| undefined |
let/var | *not shown* |
✗ |
whitelistCommits |
Set<string> |
const | new Set<string>([ // This commit adds NO_SIDE_EFFECTS annotations to pure fun... |
✗ |
Async/Await Patterns¶
| Type | Function | Await Expressions | Promise Chains |
|---|---|---|---|
| async-function | getChangeLog |
git.log({ maxCount: count }), git.raw(['diff-tree', '--no-commit-id', '--name... | none |
| async-function | getContributorsAt |
git.raw(['log', '--pretty=format:"%an|%ae"', '--', path]) | none |
| async-function | getFunctionContributors |
Promise.all(functions.map(async (i) => { return [i.name, await getContributor... | Promise.all |
Functions¶
getChangeLog(count: number): Promise<CommitInfo[]>¶
Parameters:
countnumber
Returns: Promise<CommitInfo[]>
Calls:
(await git.log({ maxCount: count })).all.filtergit.logi.message.includesi.message.startsWithwhitelistCommits.haslog.message.includeslog.message.split(' ')[2].trimgit.rawraw.replace(/\\/g, '/').trim().splituniq (from ./utils)files .map(i => i.match(/^packages\/\w+\/(\w+)\/\w+\.ts$/)?.[1]) .filterlogs.filter
Code
export async function getChangeLog(count = 200) {
if (cache)
return cache
const logs = (await git.log({ maxCount: count })).all.filter((i) => {
return i.message.includes('chore: release')
|| i.message.includes('!')
|| i.message.startsWith('feat')
|| i.message.startsWith('fix')
|| whitelistCommits.has(i.hash)
}) as CommitInfo[]
for (const log of logs) {
if (log.message.includes('chore: release')) {
log.version = log.message.split(' ')[2].trim()
continue
}
const raw = await git.raw(['diff-tree', '--no-commit-id', '--name-only', '-r', log.hash])
delete log.body
const files = raw.replace(/\\/g, '/').trim().split('\n')
log.functions = uniq(
files
.map(i => i.match(/^packages\/\w+\/(\w+)\/\w+\.ts$/)?.[1])
.filter(Boolean),
)
}
const result = logs.filter(i => i.functions?.length || i.version)
cache = result
return result
}
getContributorsAt(path: string): Promise<ContributorInfo[]>¶
Parameters:
pathstring
Returns: Promise<ContributorInfo[]>
Calls:
(await git.raw(['log', '--pretty=format:"%an|%ae"', '--', path])) .split('\n') .mapi.slice(1, -1).splitlist .filter(i => i[1]) .forEachmd5 (from md5)Object.values(map).sortconsole.error
Code
export async function getContributorsAt(path: string) {
try {
const list = (await git.raw(['log', '--pretty=format:"%an|%ae"', '--', path]))
.split('\n')
.map(i => i.slice(1, -1).split('|') as [string, string])
const map: Record<string, ContributorInfo> = {}
list
.filter(i => i[1])
.forEach((i) => {
if (!map[i[1]]) {
map[i[1]] = {
name: i[0],
count: 0,
hash: md5(i[1]),
}
}
map[i[1]].count++
})
return Object.values(map).sort((a, b) => b.count - a.count)
}
catch (e) {
console.error(e)
return []
}
}
getFunctionContributors(): Promise<{ [k: string]: ContributorInfo[]; }>¶
Returns: Promise<{ [k: string]: ContributorInfo[]; }>
Calls:
Promise.allfunctions.mapgetContributorsAtObject.fromEntries
Code
Generated by Syntax Scribe