diff --git a/.github/FUNDING.yaml b/.github/FUNDING.yaml index 0077747..f8c7f67 100644 --- a/.github/FUNDING.yaml +++ b/.github/FUNDING.yaml @@ -1,3 +1,4 @@ +# Thanks for considering supporting this project! 🎉 github: [phosphor-icons, rektdeckard] patreon: phosphoricons buy_me_a_coffee: phosphoricons diff --git a/.github/logo.png b/.github/logo.png index 8be2ed6..7a424e7 100644 Binary files a/.github/logo.png and b/.github/logo.png differ diff --git a/.github/workflows/sync-docs.yaml b/.github/workflows/sync-docs.yaml index f0e5f08..54a4bc2 100644 --- a/.github/workflows/sync-docs.yaml +++ b/.github/workflows/sync-docs.yaml @@ -4,6 +4,7 @@ on: push: paths: - 'README.md' + - '.github/FUNDING.yaml' branches: - master workflow_dispatch: # Allows manual triggering @@ -84,8 +85,7 @@ jobs: git checkout -b $BRANCH # Commit and push changes - git add README.md - git commit -m "chore(docs): sync readme section" + git commit -am "chore(docs): sync readme section" git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ matrix.repository }}.git" $BRANCH # Create PR using the GitHub CLI diff --git a/README.md b/README.md index bd04166..d8a76fe 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Phosphor Icons - + diff --git a/scripts/sync-docs.ts b/scripts/sync-docs.ts index 5bfb926..0735ee6 100644 --- a/scripts/sync-docs.ts +++ b/scripts/sync-docs.ts @@ -1,25 +1,52 @@ import fs from "node:fs"; import path from "node:path"; -const SYNC_SECTIONS = ["LINKS"]; +const README_PATH = "README.md"; +const FUNDING_PATH = ".github/FUNDING.yaml"; +const LOGO_PATH = ".github/logo.png"; + +const SYNC_SECTIONS = ["LOGO", "OVERVIEW", "LINKS"]; +const SYNC_FILES: Array> = [ + [FUNDING_PATH, ".github/FUNDING.yml"], + LOGO_PATH, +]; // These files will be replaced in the target repository (function main() { const targetRepo = process.argv[process.argv.length - 1]; if (!targetRepo) throw new Error("Target repository not provided"); - const targetReadmePath = path.resolve(__dirname, `../../${targetRepo}/README.md`); - if (!fs.existsSync(targetReadmePath)) throw new Error(`README.md not found in ${targetRepo}`); - const readmePath = path.resolve(__dirname, "../README.md"); + const readmePath = path.resolve(__dirname, `../${README_PATH}`); const readmeContent = fs.readFileSync(readmePath, "utf8"); - for (const section of SYNC_SECTIONS) { - const sectionContent = extractSection(readmeContent, section); - if (!sectionContent) continue; + const targetReadmePath = path.resolve(__dirname, `../../${targetRepo}/${README_PATH}`); + if (!fs.existsSync(targetReadmePath)) throw new Error(`README.md not found in ${targetRepo}`); - const targetReadmeContent = fs.readFileSync(targetReadmePath, "utf8"); - const updatedDocsContent = updateSection(targetReadmeContent, section, sectionContent); - fs.writeFileSync(targetReadmePath, updatedDocsContent); + for (const section of SYNC_SECTIONS) { + const readmeSection = extractSection(readmeContent, section); + if (readmeSection) { + const targetReadmeContent = fs.readFileSync(targetReadmePath, "utf8"); + const updatedDocsContent = updateSection(targetReadmeContent, section, readmeSection); + fs.writeFileSync(targetReadmePath, updatedDocsContent); + } + } + + for (const file of SYNC_FILES) { + const fileName = Array.isArray(file) ? file[0] : file; + const filePath = path.resolve(__dirname, `../${fileName}`); + const fileContent = fs.readFileSync(filePath, "utf8"); + + if (Array.isArray(file)) { + for (const alias of file) { + const targetPath = path.resolve(__dirname, `../../${targetRepo}/${alias}`); + if (fs.existsSync(targetPath)) { + fs.rmSync(targetPath); + } + } + } + + const targetPath = path.resolve(__dirname, `../../${targetRepo}/${fileName}`); + fs.writeFileSync(targetPath, fileContent); // Overwrites the target file if it exists } })();