From 4f559b06e4b15d210f1927d45890ee24427365d2 Mon Sep 17 00:00:00 2001 From: Karsa Date: Wed, 24 May 2023 09:31:13 +0200 Subject: [PATCH] Adds git clone to manually fetch the main repository for creating release metadata --- scripts/writeReleaseMetadata.mjs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/scripts/writeReleaseMetadata.mjs b/scripts/writeReleaseMetadata.mjs index 95ee09100..31d0a5560 100644 --- a/scripts/writeReleaseMetadata.mjs +++ b/scripts/writeReleaseMetadata.mjs @@ -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; };