From 56993f5100d2dc125ed7e5b7d3c330e4e0ff6a22 Mon Sep 17 00:00:00 2001 From: LitoMore Date: Sun, 11 Feb 2024 12:52:10 +0800 Subject: [PATCH] Optimize disclaimer formatting (#10439) --- .github/workflows/publish.yml | 8 +++--- DISCLAIMER.md | 6 ++-- scripts/release/reformat-markdown.js | 41 ++++++++++++++++++++++++++++ scripts/release/reformat-readme.js | 33 ---------------------- 4 files changed, 48 insertions(+), 40 deletions(-) create mode 100644 scripts/release/reformat-markdown.js delete mode 100644 scripts/release/reformat-readme.js diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index dcdc82f03..bdd3c9c26 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -52,8 +52,8 @@ jobs: uses: ./.github/actions/get-version - name: Install dependencies run: npm i - - name: Reformat README to regular markdown - run: node ./scripts/release/reformat-readme.js "${{ steps.get-version.outputs.version }}" + - name: Reformat to regular markdown + run: node ./scripts/release/reformat-markdown.js "${{ steps.get-version.outputs.version }}" - name: Update SDK Typescript definitions run: node ./scripts/release/update-sdk-ts-defs.js - name: Build NodeJS package @@ -74,8 +74,8 @@ jobs: uses: kceb/git-message-action@v2 - id: get-version uses: ./.github/actions/get-version - - name: Replace CDN theme image links from README - run: node ./scripts/release/reformat-readme.js "${{ steps.get-version.outputs.version }}" + - name: Reformat to regular markdown + run: node ./scripts/release/reformat-markdown.js "${{ steps.get-version.outputs.version }}" - name: Configure GIT credentials run: | git config user.name "${GITHUB_ACTOR}" diff --git a/DISCLAIMER.md b/DISCLAIMER.md index 5edf56378..9ff134576 100644 --- a/DISCLAIMER.md +++ b/DISCLAIMER.md @@ -11,10 +11,10 @@ Simple Icons asks that its users read this disclaimer fully before including an ## Licenses, Copyrights & Trademarks -> **Note**\ +> [!IMPORTANT]\ > The addition of licenses to Simple Icons is an ongoing project. Hence, the absence of licence data for a particular icon does not imply that the icon is not released under a license. -> **Note**\ +> [!NOTE]\ > Simple Icons is released under CC0 - though that doesn't mean to imply that all icons within the project are also CC0. Please see individual licenses where available. Simple Icons provides data on the license under which icons are available. We ask users to carefully consider this when using an icon. As licenses are subject to change we also ask our users to regularly check if the license of the icons they use have been changed. @@ -29,7 +29,7 @@ Simple Icons cannot be held responsible for any legal activity raised by a brand ## Brand Guidelines -> **Note**\ +> [!NOTE]\ > The addition of guidelines to Simple Icons is an ongoing project. In the meantime, users of Simple Icons are instead encouraged to check the `source` URL as, in some cases, the icon will have been sourced from official guidelines. The lack of a `guidelines` entry for a particular brand does not imply that the brand has no guidelines. Simple Icons provides a link to a brand's _branding guidelines_ (or similar) if the brand provides one. We ask our users read these guidelines and ensure their usage of the brand's icon is in accordance with them. As guidelines are subject to change we also ask our users to regularly check if the brand guidelines of the icons they use have been updated. diff --git a/scripts/release/reformat-markdown.js b/scripts/release/reformat-markdown.js new file mode 100644 index 000000000..2606a58da --- /dev/null +++ b/scripts/release/reformat-markdown.js @@ -0,0 +1,41 @@ +/** + * @fileoverview + * Rewrite some Markdown files. + */ + +import path from 'node:path'; +import { writeFile, readFile } from 'node:fs/promises'; +import { getDirnameFromImportMeta } from '../../sdk.mjs'; + +const LINKS_BRANCH = process.argv[2] || 'develop'; + +const __dirname = getDirnameFromImportMeta(import.meta.url); + +const rootDir = path.resolve(__dirname, '..', '..'); +const readmeFile = path.resolve(rootDir, 'README.md'); +const disclaimerFile = path.resolve(rootDir, 'DISCLAIMER.md'); + +const reformat = async (filePath) => { + const fileContent = await readFile(filePath, 'utf8'); + await writeFile( + filePath, + fileContent + // Replace all CDN links with raw links + .replace( + /https:\/\/cdn.simpleicons.org\/(.+)\/000\/fff/g, + `https://raw.githubusercontent.com/simple-icons/simple-icons/${LINKS_BRANCH}/icons/$1.svg`, + ) + // Replace all GitHub blockquotes with regular markdown + // Reference: https://github.com/orgs/community/discussions/16925 + .replace( + /\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\](?!\()/g, + function (str, $0) { + const capital = $0.substr(0, 1); + const body = $0.substr(1).toLowerCase(); + return `**${capital + body}**`; + }, + ), + ); +}; + +await Promise.all([reformat(readmeFile), reformat(disclaimerFile)]); diff --git a/scripts/release/reformat-readme.js b/scripts/release/reformat-readme.js deleted file mode 100644 index 6d19aac11..000000000 --- a/scripts/release/reformat-readme.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @fileoverview - * Reformat README to regular markdown. - */ - -import path from 'node:path'; -import { writeFile, readFile } from 'node:fs/promises'; -import { getDirnameFromImportMeta } from '../../sdk.mjs'; - -const LINKS_BRANCH = process.argv[2] || 'develop'; - -const __dirname = getDirnameFromImportMeta(import.meta.url); - -const rootDir = path.resolve(__dirname, '..', '..'); -const readmeFile = path.resolve(rootDir, 'README.md'); - -const readme = await readFile(readmeFile, 'utf8'); -await writeFile( - readmeFile, - readme - .replace( - /https:\/\/cdn.simpleicons.org\/(.+)\/000\/fff/g, - `https://raw.githubusercontent.com/simple-icons/simple-icons/${LINKS_BRANCH}/icons/$1.svg`, - ) - .replace( - /\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\](?!\()/g, - function (str, $0) { - const capital = $0.substr(0, 1); - const body = $0.substr(1).toLowerCase(); - return `**${capital + body}**`; - }, - ), -);