From 82bb82849a75194da8668f12b0a31859e34180de Mon Sep 17 00:00:00 2001 From: jan Date: Fri, 23 Sep 2022 14:02:34 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20format=20YAML-files=20in=20build?= =?UTF-8?q?=20process?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/bug.yml | 60 ++++++++++---------- .github/ISSUE_TEMPLATE/bug_de.yml | 58 +++++++++---------- .github/ISSUE_TEMPLATE/config.yml | 2 +- .github/ISSUE_TEMPLATE/feature.yml | 24 ++++---- .github/ISSUE_TEMPLATE/feature_de.yml | 24 ++++---- .github/ISSUE_TEMPLATE/other.yml | 12 ++-- .github/dependabot.old.yml | 60 ++++++++++---------- .github/workflows/build-deploy.yml | 14 ++--- .github/workflows/build.yml | 26 ++++----- .github/workflows/pr.yml | 2 +- scripts/{sort.ts => format.ts} | 81 ++++++++++++++++++--------- tsconfig.json | 27 ++------- 12 files changed, 198 insertions(+), 192 deletions(-) rename scripts/{sort.ts => format.ts} (50%) diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index 941f3f5001..81e01fa1c2 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -1,57 +1,57 @@ name: Bug report description: Create a Bug report -title: "[BUG]: " -labels: ["bug"] +title: '[BUG]: ' +labels: ['bug'] body: - type: textarea id: description attributes: - label: What happened? - description: | - Please describe as detailed as possible how exactly the bug looks like. - - The more detailed, the better we can help you. + label: What happened? + description: | + Please describe as detailed as possible how exactly the bug looks like. + + The more detailed, the better we can help you. validations: - required: true + required: true - type: textarea id: reproduce attributes: - label: How to reproduce? - description: Explain here, what you did when the error occurred. - value: | - 1. Go to '...' - 2. Click on '...' - 3. Scroll down to '...' - 4. ... - 5. The error occurred + label: How to reproduce? + description: Explain here, what you did when the error occurred. + value: | + 1. Go to '...' + 2. Click on '...' + 3. Scroll down to '...' + 4. ... + 5. The error occurred validations: - required: true + required: true - type: textarea id: expected attributes: - label: Expected behavior - description: What did you expect to happen? What behaviour did you expect from LSSM? + label: Expected behavior + description: What did you expect to happen? What behaviour did you expect from LSSM? validations: - required: true + required: true - type: textarea id: system attributes: - label: System - description: Please fill out - value: | - - OS: [e.g. Windows 10] - - Browser and version: [e.g. Firefox 101.3] - - LSSM-Version: [e.g. 4.6.1+20220917.1751 [stable]] - - Game-Version: [e.g. missionchief.co.uk] + label: System + description: Please fill out + value: | + - OS: [e.g. Windows 10] + - Browser and version: [e.g. Firefox 101.3] + - LSSM-Version: [e.g. 4.6.1+20220917.1751 [stable]] + - Game-Version: [e.g. missionchief.co.uk] validations: - required: true + required: true - type: textarea id: additional attributes: - label: Additional - description: You can use this section for any other information that may be relevant, such as Screenshots or Logs. + label: Additional + description: You can use this section for any other information that may be relevant, such as Screenshots or Logs. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug_de.yml b/.github/ISSUE_TEMPLATE/bug_de.yml index 2c7fede36d..8f14cdd3c8 100644 --- a/.github/ISSUE_TEMPLATE/bug_de.yml +++ b/.github/ISSUE_TEMPLATE/bug_de.yml @@ -1,56 +1,56 @@ name: Fehlermeldung 🇩🇪 description: Fehlermeldung auf deutsch erstellen -title: "[BUG]: " -labels: ["bug"] +title: '[BUG]: ' +labels: ['bug'] body: - type: textarea id: description attributes: - label: What happened? - description: | - Füge hier eine detaillierte Beschreibung ein, was genau passiert. - - Je detaillierter, desto besser! + label: What happened? + description: | + Füge hier eine detaillierte Beschreibung ein, was genau passiert. + + Je detaillierter, desto besser! validations: - required: true + required: true - type: textarea id: reproduce attributes: - label: Wie kann man den Fehler reproduzieren? - description: Beschreibe hier, wenn möglich, was du gemacht hast, als der Fehler auftrat. - value: | - 1. Auf '...' klicken - 2. '...' eingeben - 3. ... - 4. Das Fehlverhalten tritt auf + label: Wie kann man den Fehler reproduzieren? + description: Beschreibe hier, wenn möglich, was du gemacht hast, als der Fehler auftrat. + value: | + 1. Auf '...' klicken + 2. '...' eingeben + 3. ... + 4. Das Fehlverhalten tritt auf validations: - required: true + required: true - type: textarea id: expected attributes: - label: Erwartetes Verhalten - description: Welches Verhalten hättest du erwartet? + label: Erwartetes Verhalten + description: Welches Verhalten hättest du erwartet? validations: - required: true + required: true - type: textarea id: system attributes: - label: System - description: Bitte fülle diese Informationen aus - value: | - - Betriebssystem: [z.B. Windows 10] - - Browser und version: [z.B. Firefox 101.3] - - LSSM-Version: [z.B. 4.6.1+20220917.1751 [stable]] - - Spiel-Version: [z.B. leitstellenspiel.de] + label: System + description: Bitte fülle diese Informationen aus + value: | + - Betriebssystem: [z.B. Windows 10] + - Browser und version: [z.B. Firefox 101.3] + - LSSM-Version: [z.B. 4.6.1+20220917.1751 [stable]] + - Spiel-Version: [z.B. leitstellenspiel.de] validations: - required: true + required: true - type: textarea id: additional attributes: - label: Sonstiges - description: Hier kannst du bei Bedarf weitere Infos oder Screenshots hinzufügen. + label: Sonstiges + description: Hier kannst du bei Bedarf weitere Infos oder Screenshots hinzufügen. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 3ba13e0cec..ec4bb386bc 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1 +1 @@ -blank_issues_enabled: false +blank_issues_enabled: false \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature.yml b/.github/ISSUE_TEMPLATE/feature.yml index c0f9972db6..7110c5779b 100644 --- a/.github/ISSUE_TEMPLATE/feature.yml +++ b/.github/ISSUE_TEMPLATE/feature.yml @@ -1,33 +1,33 @@ name: Feature request description: Create a feature request -title: "[Feature request]: " +title: '[Feature request]: ' body: - type: textarea id: description attributes: - label: Is your feature related to a problem? - description: | - Write a clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + label: Is your feature related to a problem? + description: | + Write a clear and concise description of what the problem is. Ex. I'm always frustrated when [...] validations: - required: true + required: true - type: textarea id: feature attributes: - label: Solution / Feature - description: Give us a clear and concise description of what you want to happen. + label: Solution / Feature + description: Give us a clear and concise description of what you want to happen. validations: - required: true + required: true - type: textarea id: alternatives attributes: - label: Alternatives - description: A clear and concise description of any alternative solutions or features you've considered. + label: Alternatives + description: A clear and concise description of any alternative solutions or features you've considered. - type: textarea id: additional attributes: - label: Additional - description: You can use this section for any other information that may be relevant, such as Screenshots. + label: Additional + description: You can use this section for any other information that may be relevant, such as Screenshots. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_de.yml b/.github/ISSUE_TEMPLATE/feature_de.yml index 34d52fce49..c3fa46b443 100644 --- a/.github/ISSUE_TEMPLATE/feature_de.yml +++ b/.github/ISSUE_TEMPLATE/feature_de.yml @@ -1,33 +1,33 @@ name: Feature Vorschlag 🇩🇪 description: Mache einen Vorschlag für ein Feature -title: "[Feature request]: " +title: '[Feature request]: ' body: - type: textarea id: description attributes: - label: Geht deine Idee aus einer Problemstellung hervor? - description: | - Schreibe uns, was der Hintergrund für deine Idee ist. Damit können wir sie besser verstehen. + label: Geht deine Idee aus einer Problemstellung hervor? + description: | + Schreibe uns, was der Hintergrund für deine Idee ist. Damit können wir sie besser verstehen. validations: - required: true + required: true - type: textarea id: feature attributes: - label: Lösung / Feature - description: Was soll das Feature können / was soll passieren? + label: Lösung / Feature + description: Was soll das Feature können / was soll passieren? validations: - required: true + required: true - type: textarea id: alternatives attributes: - label: Alternativen - description: Hast du bereits über alternative Lösungen nachgedacht? Vielleicht können wir diese mit einbauen. + label: Alternativen + description: Hast du bereits über alternative Lösungen nachgedacht? Vielleicht können wir diese mit einbauen. - type: textarea id: additional attributes: - label: Sonstiges - description: Hier kannst du weitere Punkte anfügen, die deine Idee besser verständlich machen (z.B. Screenshots o.ä.) + label: Sonstiges + description: Hier kannst du weitere Punkte anfügen, die deine Idee besser verständlich machen (z.B. Screenshots o.ä.) \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/other.yml b/.github/ISSUE_TEMPLATE/other.yml index 845d2720e5..95504174ba 100644 --- a/.github/ISSUE_TEMPLATE/other.yml +++ b/.github/ISSUE_TEMPLATE/other.yml @@ -5,10 +5,10 @@ body: - type: textarea id: description attributes: - label: Hello world! - description: | - Yes, the title is intended! Simply describe your request here. As always, the more detailed the better! - - Ja, der Titel ist gewollt! Beschreibe hier einfach dein Anliegen. Es gilt wie immer: Je detaillierter, desto besser! + label: Hello world! + description: | + Yes, the title is intended! Simply describe your request here. As always, the more detailed the better! + + Ja, der Titel ist gewollt! Beschreibe hier einfach dein Anliegen. Es gilt wie immer: Je detaillierter, desto besser! validations: - required: true + required: true \ No newline at end of file diff --git a/.github/dependabot.old.yml b/.github/dependabot.old.yml index 3380766159..9aa4a5db45 100644 --- a/.github/dependabot.old.yml +++ b/.github/dependabot.old.yml @@ -1,33 +1,33 @@ # disabled in favor of renovate version: 2 updates: - - package-ecosystem: "npm" - directory: "/" # Location of package manifests - schedule: - interval: "daily" - time: "03:00" - timezone: "Europe/Berlin" - assignees: - - "Suchty112" - commit-message: - prefix: "⬆️" - include: "scope" - reviewers: - - "Suchty112" - - "kdev" - target-branch: "dev" - - package-ecosystem: "npm" - directory: "/docs/.vuepress" # Location of package manifests - schedule: - interval: "daily" - time: "03:00" - timezone: "Europe/Berlin" - assignees: - - "Suchty112" - commit-message: - prefix: "⬆️" - include: "scope" - reviewers: - - "Suchty112" - - "kdev" - target-branch: "dev" + - package-ecosystem: 'npm' + directory: '/' # Location of package manifests + schedule: + interval: 'daily' + time: '03:00' + timezone: 'Europe/Berlin' + assignees: + - 'Suchty112' + commit-message: + prefix: '⬆️' + include: 'scope' + reviewers: + - 'Suchty112' + - 'kdev' + target-branch: 'dev' + - package-ecosystem: 'npm' + directory: '/docs/.vuepress' # Location of package manifests + schedule: + interval: 'daily' + time: '03:00' + timezone: 'Europe/Berlin' + assignees: + - 'Suchty112' + commit-message: + prefix: '⬆️' + include: 'scope' + reviewers: + - 'Suchty112' + - 'kdev' + target-branch: 'dev' \ No newline at end of file diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index 2fff40d163..9577396897 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -2,9 +2,9 @@ name: Build and Deploy on: push: - branches: - - 'master' - - 'dev' + branches: + - 'master' + - 'dev' jobs: build: @@ -26,9 +26,8 @@ jobs: - name: Unzip artifact run: | - unzip dist.zip -d ${{ github.workspace }}/dist - rm dist.zip - + unzip dist.zip -d ${{ github.workspace }}/dist + rm dist.zip - name: list content of dist if: ${{ github.ref == 'refs/heads/dev' }} @@ -46,5 +45,4 @@ jobs: - name: Deployment if: ${{ success() }} - run: rsync -ruthz --stats --progress -e "ssh -p 22" ./dist/dist/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.DEPLOY_DIR }}/${{ needs.build.outputs.type }} - + run: rsync -ruthz --stats --progress -e "ssh -p 22" ./dist/dist/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.DEPLOY_DIR }}/${{ needs.build.outputs.type }} \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7361b6a92d..d051610106 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,13 +2,13 @@ name: Build Project on: workflow_call: - outputs: - type: - description: 'Type of build' - value: ${{ jobs.build.outputs.type }} - version: - description: 'Version of build' - value: ${{ jobs.build.outputs.version }} + outputs: + type: + description: 'Type of build' + value: ${{ jobs.build.outputs.type }} + version: + description: 'Version of build' + value: ${{ jobs.build.outputs.version }} jobs: build: @@ -45,10 +45,10 @@ jobs: uses: actions/cache@v3 id: yarn-cache with: - path: | - ${{ steps.yarn-cache-dir.outputs.dir }} - **/node_modules - **/.eslintcache + path: | + ${{ steps.yarn-cache-dir.outputs.dir }} + **/node_modules + **/.eslintcache key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock', '.yarnrc.yml') }} restore-keys: | ${{ runner.os }}-yarn- @@ -67,8 +67,8 @@ jobs: - name: '[⬆] update emojis' run: ./node_modules/.bin/ts-node scripts/utils/fetchEmojis.ts - - name: '[🚨] sort JSONs' - run: ./node_modules/.bin/ts-node scripts/sort.ts || exit 1 + - name: '[🚨] format JSON & YAML files' + run: ./node_modules/.bin/ts-node scripts/format.ts || exit 1 - name: '[🚨] run ESLint' run: ./scripts/lint_fix.sh || exit 1 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 35164359ed..d451724daf 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -5,4 +5,4 @@ on: [pull_request] jobs: build: uses: ./.github/workflows/build.yml - secrets: inherit + secrets: inherit \ No newline at end of file diff --git a/scripts/sort.ts b/scripts/format.ts similarity index 50% rename from scripts/sort.ts rename to scripts/format.ts index 195c68829e..42d1e43d05 100644 --- a/scripts/sort.ts +++ b/scripts/format.ts @@ -8,10 +8,21 @@ import tsconfig from '../tsconfig.json'; const ROOT_PATH = path.join(__dirname, '..'); -fs.writeFileSync( - path.join(ROOT_PATH, 'tsconfig.json'), - JSON.stringify(sortJSON(tsconfig, true), null, 4) -); +const format = (content: string, format: 'json' | 'yaml'): string => + prettier + .format(content, { + arrowParens: 'avoid', + endOfLine: 'lf', + parser: format, + quoteProps: 'consistent', + singleQuote: true, + tabWidth: 4, + trailingComma: 'es5', + }) + .trimEnd(); + +const formatJSON = (json: object, sortArray: boolean): string => + format(JSON.stringify(sortJSON(json, sortArray)), 'json'); const excluded = [ path.join(ROOT_PATH, 'src', 'libraries.json'), @@ -37,9 +48,27 @@ const getJsons = (folder: string): string[] => { return jsons; }; +const getYamls = (folder: string): string[] => { + const yamls = [] as string[]; + if (/node_modules/u.test(folder)) return []; + fs.readdirSync(folder, { withFileTypes: true }).forEach(item => { + if (item.isDirectory()) + yamls.push(...getYamls(`${folder}/${item.name}`)); + else if (item.isFile() && item.name.endsWith('.yml')) + yamls.push(`${folder}/${item.name}`); + }); + return yamls; +}; + +fs.writeFileSync( + path.join(ROOT_PATH, 'tsconfig.json'), + formatJSON(tsconfig, true) +); + let currentFile = ''; try { - let fileCounter = 0; + let fileCounterJSON = 0; + let fileCounterYAML = 0; [ '.github', 'build', @@ -50,38 +79,34 @@ try { 'src', 'static', 'typings', - ].forEach(folder => + ].forEach(folder => { getJsons(path.join(ROOT_PATH, folder)).forEach(file => { if (file === path.join(ROOT_PATH, './src/utils/emojis.json')) return; + currentFile = file; const sortArray = false; fs.writeFileSync( file, - prettier - .format( - JSON.stringify( - sortJSON( - JSON.parse(fs.readFileSync(file).toString()), - sortArray - ) - ), - { - arrowParens: 'avoid', - endOfLine: 'lf', - parser: 'json', - quoteProps: 'consistent', - singleQuote: true, - tabWidth: 4, - trailingComma: 'es5', - } - ) - .trimEnd() + formatJSON( + JSON.parse(fs.readFileSync(file).toString()), + sortArray + ) ); - fileCounter++; - }) + fileCounterJSON++; + }); + getYamls(path.join(ROOT_PATH, folder)).forEach(file => { + currentFile = file; + fs.writeFileSync( + file, + format(fs.readFileSync(file).toString(), 'yaml') + ); + fileCounterYAML++; + }); + }); + console.log( + `✨ formatted ${fileCounterJSON} JSON and ${fileCounterYAML} YAML files!` ); - console.log(`✨ sorted ${fileCounter} JSON files!`); } catch (e) { console.error(currentFile, e); process.exit(1); diff --git a/tsconfig.json b/tsconfig.json index 01413088cb..f4323f6c93 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,36 +7,19 @@ "esModuleInterop": true, "importHelpers": true, "jsx": "preserve", - "lib": [ - "esnext", - "dom", - "dom.iterable", - "scripthost", - "es5" - ], + "lib": ["esnext", "dom", "dom.iterable", "scripthost", "es5"], "module": "ESNext", "moduleResolution": "node", "outDir": "typings/dist", "paths": { - "@stores/*": [ - "../src/stores/*" - ], - "typings/*": [ - "../typings/*" - ] + "@stores/*": ["../src/stores/*"], + "typings/*": ["../typings/*"] }, "resolveJsonModule": true, "sourceMap": true, "strict": true, "target": "es2017", - "types": [ - "webpack-env", - "vue", - "jquery", - "node" - ] + "types": ["webpack-env", "vue", "jquery", "node"] }, - "exclude": [ - "node_modules" - ] + "exclude": ["node_modules"] } \ No newline at end of file