generated from sapphiredev/sapphire-template
-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…603) BREAKING CHANGE: `MimeTypes` has been removed in favor of the `MimeType` string union type consists of all IANA media types
- Loading branch information
Showing
14 changed files
with
2,218 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Automatic Data Update | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 2 * * *' | ||
|
||
jobs: | ||
DataUpdater: | ||
name: Automatic Data Update | ||
runs-on: ubuntu-latest | ||
if: github.repository_owner == 'sapphiredev' | ||
steps: | ||
- name: Checkout Project | ||
uses: actions/checkout@v4 | ||
- name: Install dependencies | ||
uses: sapphiredev/.github/actions/install-yarn-dependencies@main | ||
with: | ||
node-version: 20 | ||
- name: Run plugin-api MIME type sync | ||
run: yarn workspace @sapphire/plugin-api sync-mime-types | ||
- name: Run prettier on the code | ||
run: yarn format | ||
- name: Commit any changes and create a pull request | ||
env: | ||
GITHUB_USER: github-actions[bot] | ||
GITHUB_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
git add .; | ||
if git diff-index --quiet HEAD --; then | ||
echo "No changes to commit, exiting with code 0" | ||
exit 0; | ||
else | ||
git remote set-url origin "https://${GITHUB_TOKEN}:[email protected]/${GITHUB_REPOSITORY}.git"; | ||
git config --local user.email "${GITHUB_EMAIL}"; | ||
git config --local user.name "${GITHUB_USER}"; | ||
git checkout -b update-iana-mime-type/$(date +%F-%H-%M); | ||
git commit -sam "feat: update mime types"; | ||
git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD) | ||
gh pr create -t "feat: update mime types" -b "*bleep bloop* I updated the IANA mime type list" -B main; | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { writeFile } from 'node:fs/promises'; | ||
|
||
const output = new URL('../src/lib/utils/MimeType.ts', import.meta.url); | ||
|
||
const response = await fetch('https://www.iana.org/assignments/media-types/media-types.xml'); | ||
const text = await response.text(); | ||
|
||
const fileTypeTemplateRegex = /<file type="template">(\w+\/.+?)<\/file>/g; | ||
const outputLines = ['export type MimeType =']; | ||
|
||
let result: RegExpExecArray | null; | ||
while ((result = fileTypeTemplateRegex.exec(text))) { | ||
outputLines.push(`\t| '${result[1]}'`); | ||
} | ||
|
||
outputLines.push('\t| `X-${string}/${string}`;'); | ||
outputLines.push(''); | ||
|
||
await writeFile(output, outputLines.join('\n'), 'utf8'); | ||
console.log(`Successfully written to ${output.href}: ${outputLines.length - 3} mime types total`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.