From 0c3bc7c592812d319186d46d0cf9121bdd61cc9f Mon Sep 17 00:00:00 2001 From: PeachScript Date: Mon, 31 Jul 2023 10:46:42 +0800 Subject: [PATCH 1/6] refactor: enable dist hash by default --- packages/preset-dumi/src/plugins/features/init.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/preset-dumi/src/plugins/features/init.ts b/packages/preset-dumi/src/plugins/features/init.ts index 3d5af71420..05e6b20d6c 100644 --- a/packages/preset-dumi/src/plugins/features/init.ts +++ b/packages/preset-dumi/src/plugins/features/init.ts @@ -40,6 +40,9 @@ export default (api: IApi) => { memo.alias['@'] = api.paths.absSrcPath; memo.alias['@@'] = api.paths.absTmpPath; + // enable dist hash by default + memo.hash = true; + return memo; }); } From d6a0eeb48d4baa32646c56be1e2ee60e6b940b58 Mon Sep 17 00:00:00 2001 From: PeachScript Date: Mon, 31 Jul 2023 11:13:38 +0800 Subject: [PATCH 2/6] ci: update build script --- .github/workflows/preview-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml index 24fe66f237..33cf568dc1 100644 --- a/.github/workflows/preview-build.yml +++ b/.github/workflows/preview-build.yml @@ -17,7 +17,7 @@ jobs: run: | yarn yarn build - yarn doc:build + yarn docs:build - run: | zip -r dist.zip dist @@ -31,7 +31,7 @@ jobs: - name: build mobile run: | - DUMI_THEME=./packages/theme-mobile yarn doc:build + DUMI_THEME=./packages/theme-mobile yarn docs:build - run: | zip -r dist-mobile.zip dist From e6414572e1d8cad6481184b169d83729f43ae182 Mon Sep 17 00:00:00 2001 From: PeachScript Date: Mon, 31 Jul 2023 11:21:23 +0800 Subject: [PATCH 3/6] ci: set node version --- .github/workflows/preview-build.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml index 33cf568dc1..fd37bb8f2a 100644 --- a/.github/workflows/preview-build.yml +++ b/.github/workflows/preview-build.yml @@ -1,12 +1,13 @@ name: Preview Build -on: +on: pull_request: types: [opened, synchronize, reopened] jobs: build-preview: runs-on: ubuntu-latest + container: node:12 steps: - uses: actions/checkout@v2 @@ -28,10 +29,10 @@ jobs: name: dist path: dist.zip retention-days: 5 - + - name: build mobile run: | - DUMI_THEME=./packages/theme-mobile yarn docs:build + DUMI_THEME=./packages/theme-mobile yarn docs:build - run: | zip -r dist-mobile.zip dist From ec674d2478c9c3814020562af7e57ff1135323e8 Mon Sep 17 00:00:00 2001 From: PeachScript Date: Mon, 31 Jul 2023 11:25:06 +0800 Subject: [PATCH 4/6] ci: set node version --- .github/workflows/preview-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml index fd37bb8f2a..4d45f46fcb 100644 --- a/.github/workflows/preview-build.yml +++ b/.github/workflows/preview-build.yml @@ -7,7 +7,7 @@ on: jobs: build-preview: runs-on: ubuntu-latest - container: node:12 + container: node:14 steps: - uses: actions/checkout@v2 From 8bd904bc2762a35038db574c31c8fe7afde5f21b Mon Sep 17 00:00:00 2001 From: PeachScript Date: Mon, 31 Jul 2023 11:29:15 +0800 Subject: [PATCH 5/6] ci: remove useless preview ci --- .github/workflows/preview-build.yml | 56 ----------- .github/workflows/preview-deploy.yml | 137 --------------------------- .github/workflows/preview-start.yml | 31 ------ 3 files changed, 224 deletions(-) delete mode 100644 .github/workflows/preview-build.yml delete mode 100644 .github/workflows/preview-deploy.yml delete mode 100644 .github/workflows/preview-start.yml diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml deleted file mode 100644 index 4d45f46fcb..0000000000 --- a/.github/workflows/preview-build.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: Preview Build - -on: - pull_request: - types: [opened, synchronize, reopened] - -jobs: - build-preview: - runs-on: ubuntu-latest - container: node:14 - - steps: - - uses: actions/checkout@v2 - with: - ref: ${{ github.event.pull_request.head.sha }} - - - name: build - run: | - yarn - yarn build - yarn docs:build - - - run: | - zip -r dist.zip dist - - - name: upload dist artifact - uses: actions/upload-artifact@v2 - with: - name: dist - path: dist.zip - retention-days: 5 - - - name: build mobile - run: | - DUMI_THEME=./packages/theme-mobile yarn docs:build - - - run: | - zip -r dist-mobile.zip dist - - - name: upload dist artifact - uses: actions/upload-artifact@v2 - with: - name: dist-mobile - path: dist-mobile.zip - retention-days: 5 - - - name: Save PR number - if: ${{ always() }} - run: echo ${{ github.event.number }} > ./pr-id.txt - - - name: Upload PR number - if: ${{ always() }} - uses: actions/upload-artifact@v2 - with: - name: pr - path: ./pr-id.txt diff --git a/.github/workflows/preview-deploy.yml b/.github/workflows/preview-deploy.yml deleted file mode 100644 index a9ed096b24..0000000000 --- a/.github/workflows/preview-deploy.yml +++ /dev/null @@ -1,137 +0,0 @@ -name: Preview Deploy - -on: - workflow_run: - workflows: ["Preview Build"] - types: - - completed - -jobs: - success: - runs-on: ubuntu-latest - if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' - steps: - - name: download pr artifact - uses: dawidd6/action-download-artifact@v2 - with: - workflow: ${{ github.event.workflow_run.workflow_id }} - name: pr - - name: save PR id - id: pr - run: echo "::set-output name=id::$( - - - body-include: '' - number: ${{ steps.pr.outputs.id }} - - run: | - rm -rf dist/ - - name: download dist artifact - uses: dawidd6/action-download-artifact@v2 - with: - workflow: ${{ github.event.workflow_run.workflow_id }} - workflow_conclusion: success - name: dist-mobile - - run: | - unzip dist-mobile.zip - - name: upload surge service - id: deploy-mobile - run: | - export DEPLOY_DOMAIN=https://dumi-mobile-preview-pr-${{ steps.pr.outputs.id }}.surge.sh - npx surge --project ./dist --domain $DEPLOY_DOMAIN --token ${{ secrets.SURGE_TOKEN }} - - name: update status comment - uses: actions-cool/maintain-one-comment@v1.1.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - body: | - 🎊 PR Mobile Preview has been successfully built and deployed to https://dumi-mobile-preview-pr-${{ steps.pr.outputs.id }}.surge.sh - - - - - body-include: '' - number: ${{ steps.pr.outputs.id }} - - name: The job failed - if: ${{ failure() }} - uses: actions-cool/maintain-one-comment@v1.1.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - body: | - 😭 Deploy PR Preview failed. - - - - - body-include: '' - number: ${{ steps.pr.outputs.id }} - - name: The job mobile failed - if: ${{ failure() }} - uses: actions-cool/maintain-one-comment@v1.1.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - body: | - 😭 Deploy PR Mobile Preview failed. - - - - - body-include: '' - number: ${{ steps.pr.outputs.id }} - - failed: - runs-on: ubuntu-latest - if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'failure' - steps: - - name: download pr artifact - uses: dawidd6/action-download-artifact@v2 - with: - workflow: ${{ github.event.workflow_run.workflow_id }} - name: pr - - name: save PR id - id: pr - run: echo "::set-output name=id::$( - - - body-include: '' - number: ${{ steps.pr.outputs.id }} - - name: The job mobile failed - if: ${{ failure() }} - uses: actions-cool/maintain-one-comment@v1.1.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - body: | - 😭 Deploy PR Mobile Preview failed. - - - - - body-include: '' - number: ${{ steps.pr.outputs.id }} diff --git a/.github/workflows/preview-start.yml b/.github/workflows/preview-start.yml deleted file mode 100644 index 3a98781a39..0000000000 --- a/.github/workflows/preview-start.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Preview Start - -on: pull_request_target - -jobs: - preview: - runs-on: ubuntu-latest - steps: - - name: create - uses: actions-cool/maintain-one-comment@v1.1.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - body: | - ⚡️ Deploying PR Preview... - - - - - body-include: '' - - - name: create mobile - uses: actions-cool/maintain-one-comment@v1.1.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - body: | - ⚡️ Deploying PR Mobile Preview... - - - - - body-include: '' From dace20edb680c26666605425fd36a5aaa5fd108f Mon Sep 17 00:00:00 2001 From: PeachScript Date: Mon, 31 Jul 2023 11:36:45 +0800 Subject: [PATCH 6/6] refactor: correct logic --- packages/preset-dumi/src/plugins/features/init.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/preset-dumi/src/plugins/features/init.ts b/packages/preset-dumi/src/plugins/features/init.ts index 05e6b20d6c..52eab2364b 100644 --- a/packages/preset-dumi/src/plugins/features/init.ts +++ b/packages/preset-dumi/src/plugins/features/init.ts @@ -35,15 +35,15 @@ export default (api: IApi) => { }); // re-enable @ & @@ umi default alias for integrated mode - if (isIntegrateUmi || api.args?.dumi) { - api.modifyDefaultConfig(memo => { + api.modifyDefaultConfig(memo => { + if (isIntegrateUmi || api.args?.dumi) { memo.alias['@'] = api.paths.absSrcPath; memo.alias['@@'] = api.paths.absTmpPath; + } - // enable dist hash by default - memo.hash = true; + // enable dist hash by default + memo.hash = true; - return memo; - }); - } + return memo; + }); };