Adds git clone to manually fetch the main repository for creating release metadata

This commit is contained in:
Karsa
2023-05-24 09:31:13 +02:00
parent 8b2c9f7d40
commit 4f559b06e4
+14 -6
View File
@@ -5,6 +5,13 @@ import fs from 'fs';
import path from 'path';
import { readSvgDirectory } from './helpers.mjs';
const gitTmpPath = '/tmp/lucide-icons';
if (fs.existsSync(gitTmpPath)) {
fs.rmSync(gitTmpPath, { recursive: true, force: true });
}
await simpleGit().clone(`https://${process.env.GITHUB_API_KEY}@github.com/lucide-icons/lucide.git`, gitTmpPath);
const git = simpleGit(gitTmpPath);
const currentDir = process.cwd();
const ICONS_DIR = path.resolve(currentDir, '../icons');
const iconJsonFiles = readSvgDirectory(ICONS_DIR, '.json');
@@ -34,10 +41,11 @@ export const updateReleaseMetadataWithCommit = (metadata, date, release) => {
};
export const fetchAllReleases = async () => {
await simpleGit().fetch(['--tags', '--all']);
await git.fetch('--tags')
const tags = await Promise.all(
(
await simpleGit().raw('show-ref', '--tags', '-d')
await git.raw('show-ref', '--tags', '-d')
)
.trim()
.split(/\n/)
@@ -47,7 +55,7 @@ export const fetchAllReleases = async () => {
return { version: null, date: null };
}
const { version = null } = semver.coerce(ref.replace('refs/tags/', '')) ?? {};
const date = (await simpleGit().show(['-s', '--format=%cI', commit])).trim();
const date = (await git.show(['-s', '--format=%cI', commit])).trim();
return { version, date };
}),
);
@@ -55,7 +63,7 @@ export const fetchAllReleases = async () => {
return tags.filter(({ version }) => semver.valid(version));
};
simpleGit().clean(CleanOptions.FORCE);
git.clean(CleanOptions.FORCE);
const findRelease = (date, releases) => {
let closestRelease = null;
@@ -68,8 +76,8 @@ const findRelease = (date, releases) => {
};
const fetchCommits = async (name) => {
const file = `../icons/${name}.svg`;
const { all: commits = {} } = await simpleGit().log(['--reverse', '--follow', '--', file]);
const file = `icons/${name}.svg`;
const { all: commits = {} } = await git.log(['--reverse', '--follow', '--', file]);
return commits;
};