Skip to content

Commit

Permalink
feat: 初见新 polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnAngela committed Jan 22, 2024
1 parent 2dbc996 commit b347104
Show file tree
Hide file tree
Showing 9 changed files with 220 additions and 2,633 deletions.
4 changes: 1 addition & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ src/**/*.json linguist-generated=false
src/*.json linguist-generated=false
src/**/*.yaml linguist-generated=false
src/*.yaml linguist-generated=false

# From generatePolyfill
src/gadgets/libPolyfill/MediaWiki:Gadget-libPolyfill.js linguist-generated=true
src/gadgets/libPolyfill/MediaWiki:Gadget-libPolyfill.*.js linguist-generated=true

# From ganerateCommitsHistory
src/global/zh/MediaWiki:GHIAHistory.json linguist-generated=true
Expand Down
88 changes: 88 additions & 0 deletions .github/workflows/generatePolyfill.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Generate Polyfill

on:
push:
paths:
- scripts/generatePolyfill/config.yaml
- scripts/generatePolyfill/index.js
merge_group:
pull_request:
paths:
- scripts/generatePolyfill/config.yaml
- scripts/generatePolyfill/index.js
workflow_dispatch:
schedule:
- cron: 0 23 * * 0 # Every 07:00 CST Mon

concurrency:
group: ${{ github.workflow_ref }}-${{ github.ref }}

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

permissions:
actions: read
checks: read
contents: write
deployments: read
issues: write
discussions: read
packages: read
pages: read
pull-requests: read
repository-projects: read
security-events: write
statuses: write

jobs:
generatePolyfill:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Checkout main repo
with:
fetch-depth: 0
show-progress: false
- name: Get toe polyfill config
id: polyfillConfig
run: |
echo "TARGET_POLYFILL_VERSION=$(yq '.TARGET_POLYFILL_VERSION' scripts/generatePolyfill/config.yaml)" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
- uses: actions/checkout@v4
name: Checkout polyfill.io
with:
show-progress: false
repository: JakeChampion/polyfill-service
path: polyfill-service
sparse-checkout: |
polyfill-libraries/${{ steps.polyfillConfig.outputs.TARGET_POLYFILL_VERSION }}/
polyfill-libraries/${{ steps.polyfillConfig.outputs.TARGET_POLYFILL_VERSION }}.json
sparse-checkout-cone-mode: false
- name: Move polyfill.io
id: polyfill
run: |
POLYFILL_PATH="${{ runner.temp }}/$(uuidgen)"
echo "POLYFILL_PATH=$POLYFILL_PATH" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
mv polyfill-service/polyfill-libraries/${{ steps.polyfillConfig.outputs.TARGET_POLYFILL_VERSION }}.json $POLYFILL_PATH/main.json
mv polyfill-service/polyfill-libraries/${{ steps.polyfillConfig.outputs.TARGET_POLYFILL_VERSION }}/ $POLYFILL_PATH/library
rm -rf polyfill-service
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
check-latest: true
cache: npm
- name: Installing the dependencies
uses: AnnAngela/cached_node-modules@v2
with:
command: npm run ci
- name: Git config
run: node scripts/postCommit/prepareGit.js
- name: Gadget-polyfill generator
run: node scripts/generatePolyfill/index.js
env:
POLYFILL_PATH: ${{ steps.polyfill.outputs.POLYFILL_PATH }}
- name: Show git status & push
id: output
run: node scripts/postCommit/push.js
3 changes: 1 addition & 2 deletions .github/workflows/postCommit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ jobs:
if: always() && needs.skipCI.result == 'success' && needs.skipCI.outputs.skip != 'true'
steps:
- uses: actions/checkout@v4
name: Checkout main repo
with:
fetch-depth: 0
show-progress: false
Expand All @@ -113,8 +114,6 @@ jobs:
run: node scripts/browserify/index.js
- name: Auto prefetch
run: node scripts/prefetch/index.js
- name: Gadget-polyfill generator
run: node scripts/generatePolyfill/index.js
- name: Gadgets-definition Generator
run: node scripts/generateGadgetsDefinition/index.js
- name: Conventional Commits scopes generator
Expand Down
7 changes: 2 additions & 5 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const ignores = [
"**/dist/**",
"**/.*/**",
"node_modules",
"src/gadgets/libPolyfill/MediaWiki:Gadget-libPolyfill.*.js",
];

const srcESlintrcFiles = (await readDir("./src")).filter((n) => path.basename(n) === ".eslintrc.yaml");
Expand All @@ -34,7 +35,6 @@ const fileSpec = {
browser: {
files: [
"src/**/*",
"scripts/generatePolyfill/template.js",
],
ignores,
},
Expand All @@ -43,10 +43,7 @@ const fileSpec = {
"scripts/**/*",
"eslint.config.js",
],
ignores: [
...ignores,
"scripts/generatePolyfill/template.js",
],
ignores,
},
};

Expand Down
15 changes: 15 additions & 0 deletions scripts/generatePolyfill/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
TARGET_CHROMIUM_VERSION: 86

TARGET_POLYFILL_VERSION: 3.111.0

TARGET_ALIASES:
- default
- dom4
- es2015
- es2016
- es2017
- es2018
- es2019
- es2020
- es2021
- es2022
Loading

0 comments on commit b347104

Please sign in to comment.