Skip to content

Commit 2067211

Browse files
committed
move to prettier
1 parent 8f6723e commit 2067211

File tree

12 files changed

+69961
-50381
lines changed

12 files changed

+69961
-50381
lines changed

.download.js

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,6 @@
11
const fs = require('fs/promises');
22
const path = require('path');
33
const jsdom = require('jsdom');
4-
const { js: beautifyJs, css: beautifyCss } = require('js-beautify');
5-
6-
const BEAUTIFIER_OPTIONS = {
7-
indent_size: '4',
8-
indent_char: ' ',
9-
max_preserve_newlines: '1',
10-
preserve_newlines: true,
11-
keep_array_indentation: true,
12-
break_chained_methods: true,
13-
indent_scripts: 'normal',
14-
brace_style: 'collapse',
15-
space_before_conditional: true,
16-
unescape_strings: false,
17-
jslint_happy: true,
18-
end_with_newline: false,
19-
wrap_line_length: '110',
20-
indent_inner_html: true,
21-
comma_first: false,
22-
e4x: false,
23-
indent_empty_lines: false,
24-
};
254

265
const PATH = path.resolve(__dirname);
276

@@ -48,23 +27,21 @@ fetch(GAME)
4827
return files;
4928
})
5029
.then(async ({ js, css }) => ({
51-
js: await fetch(`${GAME}${js}`)
52-
.then(res => res.text())
53-
.then(js => beautifyJs(js, BEAUTIFIER_OPTIONS)),
54-
css: await fetch(`${GAME}${css}`)
55-
.then(res => res.text())
56-
.then(css => beautifyCss(css, BEAUTIFIER_OPTIONS)),
30+
js: await fetch(`${GAME}${js}`).then(res => res.text()),
31+
css: await fetch(`${GAME}${css}`).then(res => res.text()),
5732
jsPath: js,
5833
cssPath: css,
5934
}))
60-
.then(({ js, css, jsPath, cssPath }) => Promise.all([
61-
fs
62-
.writeFile(path.resolve(PATH, 'application.js' + suffix), js)
63-
.then(() => jsPath),
64-
fs
65-
.writeFile(path.resolve(PATH, 'application.css' + suffix), css)
66-
.then(() => cssPath),
67-
]))
35+
.then(({ js, css, jsPath, cssPath }) =>
36+
Promise.all([
37+
fs
38+
.writeFile(path.resolve(PATH, `application${suffix}.js`), js)
39+
.then(() => jsPath),
40+
fs
41+
.writeFile(path.resolve(PATH, `application${suffix}.css`), css)
42+
.then(() => cssPath),
43+
])
44+
)
6845
.then(([jsPath, cssPath]) =>
6946
fs
7047
.readFile(path.resolve(PATH, 'README.md'))
@@ -77,12 +54,6 @@ fetch(GAME)
7754
/<!--\s*automated\s-->(.|\n)*?<!--\s*\/automated\s*-->/,
7855
`
7956
<!-- automated -->
80-
## Beautify options
81-
Tool: [js-beautify](https://github.com/beautify-web/js-beautify)
82-
\`\`\`json
83-
${JSON.stringify(BEAUTIFIER_OPTIONS, null, 4)}
84-
\`\`\`
85-
8657
## JS
8758
| Attribute | Value |
8859
| --------- | ----- |
@@ -96,6 +67,11 @@ ${JSON.stringify(BEAUTIFIER_OPTIONS, null, 4)}
9667
| File | [${cssPath.replace(/^\/assets\//, '')}](${GAME}${cssPath}) |
9768
| Server | ${GAME} |
9869
| Time | ${timestamp} |
70+
71+
## Pretty-print
72+
Tool: [prettier](https://prettier.io)
73+
Options: [.prettierrc.json](./.prettierrc.json)
74+
9975
<!-- /automated -->
10076
`.trim()
10177
)

.github/workflows/download.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
schedule:
66
- cron: '0 8-18/2 * * 1-5' # At minute 0 past every 2nd hour from 8 through 18 on every day-of-week from Monday through Friday.
7-
- cron: '0 0 * * *' # Every day at midnight
7+
- cron: '0 0 * * *' # Every day at midnight
88

99
jobs:
1010
download:
@@ -51,6 +51,10 @@ jobs:
5151
run: |
5252
yarn download
5353
54+
- name: Run prettier
55+
run: |
56+
yarn prettier:write
57+
5458
- name: Show changes
5559
run: |
5660
git status
@@ -59,8 +63,8 @@ jobs:
5963
- name: Create diff to mx version
6064
run: |
6165
set -e
62-
git --no-pager diff --no-index application.js application.js.alt | tee alt_js.diff || true
63-
git --no-pager diff --no-index application.css application.css.alt |tee alt_css.diff || true
66+
git --no-pager diff --no-index application.js application.alt.js | tee alt_js.diff || true
67+
git --no-pager diff --no-index application.css application.alt.css |tee alt_css.diff || true
6468
exit 0
6569
6670
- name: Check if there are changes

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66

77
node_modules/*
88

9-
application.js.alt
10-
application.css.alt
9+
application.alt.js
10+
application.alt.css

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.yarn/
2+
node_modules/
3+
.pnp*
4+
.idea/

.prettierrc.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"arrowParens": "avoid",
3+
"endOfLine": "lf",
4+
"quoteProps": "consistent",
5+
"singleQuote": true,
6+
"tabWidth": 4,
7+
"trailingComma": "es5",
8+
"experimentalTernaries": true
9+
}

README.md

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,28 @@
11
# LSSD
2+
23
Für mich und andere Entwickler eine kleine Übersicht der Einsätze aller Spiele sowie der js und css datei :)
34

45
<!-- automated -->
5-
## Beautify options
6-
Tool: [js-beautify](https://github.com/beautify-web/js-beautify)
7-
```json
8-
{
9-
"indent_size": "4",
10-
"indent_char": " ",
11-
"max_preserve_newlines": "1",
12-
"preserve_newlines": true,
13-
"keep_array_indentation": true,
14-
"break_chained_methods": true,
15-
"indent_scripts": "normal",
16-
"brace_style": "collapse",
17-
"space_before_conditional": true,
18-
"unescape_strings": false,
19-
"jslint_happy": true,
20-
"end_with_newline": false,
21-
"wrap_line_length": "110",
22-
"indent_inner_html": true,
23-
"comma_first": false,
24-
"e4x": false,
25-
"indent_empty_lines": false
26-
}
27-
```
286

297
## JS
30-
| Attribute | Value |
31-
| --------- | ----- |
8+
9+
| Attribute | Value |
10+
| --------- | ------------------------------------------------------------------------------------------------------------------------------------ |
3211
| File | [application-afffe98eeaf9f638e2789c09e91a3a60.js](https://missionchief.co.uk/assets/application-afffe98eeaf9f638e2789c09e91a3a60.js) |
33-
| Server | https://missionchief.co.uk |
34-
| Time | 2025-01-19T23:42:32.921Z |
12+
| Server | https://missionchief.co.uk |
13+
| Time | 2025-01-19T23:54:12.822Z |
3514

3615
## CSS
37-
| Attribute | Value |
38-
| --------- | ----- |
16+
17+
| Attribute | Value |
18+
| --------- | -------------------------------------------------------------------------------------------------------------------------------------- |
3919
| File | [application-f5c2974eb24c1122f61b11891d93c7ba.css](https://missionchief.co.uk/assets/application-f5c2974eb24c1122f61b11891d93c7ba.css) |
40-
| Server | https://missionchief.co.uk |
41-
| Time | 2025-01-19T23:42:32.921Z |
20+
| Server | https://missionchief.co.uk |
21+
| Time | 2025-01-19T23:54:12.822Z |
22+
23+
## Pretty-print
24+
25+
Tool: [prettier](https://prettier.io)
26+
Options: [.prettierrc.json](./.prettierrc.json)
27+
4228
<!-- /automated -->

0 commit comments

Comments
 (0)