From d3a4d897865aeafadb2de361250c3f962cf99cee Mon Sep 17 00:00:00 2001 From: Misite Bao Date: Tue, 30 May 2023 05:40:54 +0800 Subject: [PATCH] chore: add `Prettier` as format tool (#2689) --- .github/workflows/format-markdown-files.yml | 37 +++++++++++++++++++++ .prettierignore | 3 ++ .prettierrc.yml | 6 ++++ Taskfile.yaml | 33 +++++++++++++++--- v2/.prettierignore | 1 + v2/.prettierrc.yml | 6 ++++ v2/Taskfile.yaml | 17 ++++++++++ v3/.prettierignore | 1 + v3/.prettierrc.yml | 6 ++++ v3/Taskfile.yaml | 18 ++++++++-- website/.prettierignore | 2 ++ website/Taskfile.yml | 8 +++++ website/prettier.config.js | 11 ++++++ 13 files changed, 141 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/format-markdown-files.yml create mode 100644 .prettierignore create mode 100644 .prettierrc.yml create mode 100644 v2/.prettierignore create mode 100644 v2/.prettierrc.yml create mode 100644 v2/Taskfile.yaml create mode 100644 v3/.prettierignore create mode 100644 v3/.prettierrc.yml create mode 100644 website/.prettierignore create mode 100644 website/prettier.config.js diff --git a/.github/workflows/format-markdown-files.yml b/.github/workflows/format-markdown-files.yml new file mode 100644 index 000000000..d30546428 --- /dev/null +++ b/.github/workflows/format-markdown-files.yml @@ -0,0 +1,37 @@ +name: Format Markdown Files + +on: + workflow_dispatch: + push: + branches: [master] + +jobs: + format_markdown_files: + runs-on: ubuntu-latest + if: github.repository == 'wailsapp/wails' + steps: + - uses: actions/checkout@v3 + + - name: Setup Nodejs + uses: actions/setup-node@v2 + with: + node-version: 18.x + + - name: Install Task + uses: arduino/setup-task@v1 + with: + version: 3.x + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Format All Markdown Files + run: task format-all-md + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v4 + with: + commit-message: "docs: format document" + title: "docs: format document" + body: "- [x] Format all Markdown(x) documents" + branch: chore/format-markdown-files + delete-branch: true + draft: false diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..52b962c55 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +website +v2 +v3 \ No newline at end of file diff --git a/.prettierrc.yml b/.prettierrc.yml new file mode 100644 index 000000000..685d8b6e7 --- /dev/null +++ b/.prettierrc.yml @@ -0,0 +1,6 @@ +overrides: + - files: + - "**/*.md" + options: + printWidth: 80 + proseWrap: always diff --git a/Taskfile.yaml b/Taskfile.yaml index 73fef3cc0..7cc165825 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -2,8 +2,19 @@ version: "3" -vars: - GREETING: Hello, World! +includes: + website: + taskfile: website + dir: website + + v2: + taskfile: v2 + dir: v2 + optional: true + v3: + taskfile: v3 + dir: v3 + optional: true tasks: contributors:check: @@ -18,7 +29,19 @@ tasks: cmds: - npx -y all-contributors-cli generate - release: - dir: v2/tools/release + format:md: cmds: - - go run release.go {{.CLI_ARGS}} + - npx prettier --write "**/*.md" + + format: + cmds: + - task: format:md + + format-all-md: + cmds: + - task: format:md + - task: website:format:md + - task: v2:format:md + # - task: v2:website:format + - task: v3:format:md + # - task: v3:website:format:md diff --git a/v2/.prettierignore b/v2/.prettierignore new file mode 100644 index 000000000..94c6af38e --- /dev/null +++ b/v2/.prettierignore @@ -0,0 +1 @@ +website \ No newline at end of file diff --git a/v2/.prettierrc.yml b/v2/.prettierrc.yml new file mode 100644 index 000000000..685d8b6e7 --- /dev/null +++ b/v2/.prettierrc.yml @@ -0,0 +1,6 @@ +overrides: + - files: + - "**/*.md" + options: + printWidth: 80 + proseWrap: always diff --git a/v2/Taskfile.yaml b/v2/Taskfile.yaml new file mode 100644 index 000000000..32a32e0f8 --- /dev/null +++ b/v2/Taskfile.yaml @@ -0,0 +1,17 @@ +# https://taskfile.dev + +version: "3" + +tasks: + release: + dir: tools/release + cmds: + - go run release.go {{.CLI_ARGS}} + + format:md: + cmds: + - npx prettier --write "**/*.md" + + format: + cmds: + - task: format:md diff --git a/v3/.prettierignore b/v3/.prettierignore new file mode 100644 index 000000000..94c6af38e --- /dev/null +++ b/v3/.prettierignore @@ -0,0 +1 @@ +website \ No newline at end of file diff --git a/v3/.prettierrc.yml b/v3/.prettierrc.yml new file mode 100644 index 000000000..685d8b6e7 --- /dev/null +++ b/v3/.prettierrc.yml @@ -0,0 +1,6 @@ +overrides: + - files: + - "**/*.md" + options: + printWidth: 80 + proseWrap: always diff --git a/v3/Taskfile.yaml b/v3/Taskfile.yaml index 27c63dbab..74b300ce8 100644 --- a/v3/Taskfile.yaml +++ b/v3/Taskfile.yaml @@ -1,9 +1,14 @@ # https://taskfile.dev -version: '3' +version: "3" + +includes: + website: + taskfile: ./website + dir: ./website + optional: true tasks: - build-runtime-debug: dir: internal/runtime internal: true @@ -78,7 +83,6 @@ tasks: cmds: - npm install - install-runtime-deps: dir: internal/runtime internal: true @@ -200,3 +204,11 @@ tasks: cmds: - task: reinstall-cli - echo "Generated templates" + + format:md: + cmds: + - npx prettier --write "**/*.md" + + format: + cmds: + - task: format:md diff --git a/website/.prettierignore b/website/.prettierignore new file mode 100644 index 000000000..124df96de --- /dev/null +++ b/website/.prettierignore @@ -0,0 +1,2 @@ +i18n +versioned_docs \ No newline at end of file diff --git a/website/Taskfile.yml b/website/Taskfile.yml index 5a28355f8..53b38857a 100644 --- a/website/Taskfile.yml +++ b/website/Taskfile.yml @@ -45,3 +45,11 @@ tasks: deps: [install] cmds: - npx crowdin pull -b v2 --export-only-approved + + format:md: + cmds: + - npx prettier --write "**/*.{md,mdx}" + + format: + cmds: + - task: format:md diff --git a/website/prettier.config.js b/website/prettier.config.js new file mode 100644 index 000000000..b37197c8f --- /dev/null +++ b/website/prettier.config.js @@ -0,0 +1,11 @@ +module.exports = { + overrides: [ + { + files: "**/*.{md,mdx}", + options: { + printWidth: 80, + proseWrap: "always", + }, + }, + ], +};