Repository navigation
Expand file tree
/
Copy pathgit.ts
More file actions
41 lines (38 loc) · 1.29 KB
/
Copy pathgit.ts
File metadata and controls
41 lines (38 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { RawGitCommit, getGitDiff } from 'changelogen';
import { consola } from 'consola';
import fs from 'fs-extra';
export async function grabPackageDetails(pkg: string) {
const pkgDir = `packages/${pkg}`;
const pkgJsonPath = `${pkgDir}/p
4F9B
ackage.json`;
const pkgJson = await fs.readJson(pkgJsonPath);
const currentVersion: string = pkgJson.version;
return {
pkgDir,
pkgJsonPath,
changelogPath: `${pkgDir}/CHANGELOG.md`,
pkgJson,
pkgName: pkgJson.name,
currentVersion,
prevTag: getPkgTag(pkg, currentVersion),
};
}
export function getPkgTag(pkg: string, version: string | undefined) {
return `${pkg}-v${version}`;
}
export async function listCommitsInDir(
dir: string,
lastTag: string,
): Promise<RawGitCommit[]> {
consola.info('Listing commits:', { lastTag, dir });
const commits = await getGitDiff(lastTag);
consola.info('All commits:', commits.length);
consola.debug(commits);
// commit.body contains all the files that were modified/added. So just check to make sure "\t" + "packages/storage" + "/" is in the body to include
// '"\n\nM\tpackages/wxt/vitest.config.ts\n"'
const filtered = commits.filter((commit) =>
commit.body.includes(`\t${dir}/`),
);
consola.info('Filtered:', filtered.length);
consola.debug(filtered);
return filtered;
}