Skip to content

Commit b062b4e

Browse files
authored
[DX-1704]add prettier to the code for formatting (#5600)
* add prettier
1 parent cc1ffee commit b062b4e

File tree

11 files changed

+327
-210
lines changed

11 files changed

+327
-210
lines changed

.github/workflows/prettier.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# This GitHub Action is triggered on pull requests to:
2+
# 1. Format changed files using Prettier.
3+
# 2. Automatically install Prettier and its Go template plugin.
4+
# 3. Identify all files changed in the pull request.
5+
# 4. Format the changed files according to Prettier's rules, respecting the .prettierignore file.
6+
# 5. Commit any changes made to the files back to the repository.
7+
# 6. Optionally, check that the files are properly formatted after linting.
8+
#
9+
# This action helps ensure code quality and consistency in documentation and source files.
10+
name: "PR files Formatting"
11+
on:
12+
pull_request:
13+
14+
jobs:
15+
docs_linter:
16+
runs-on: ubuntu-latest
17+
name: Format PR files with Prettier
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
ref: ${{ github.head_ref }} # Automatically checks out the PR branch
23+
24+
- uses: actions/setup-node@v4
25+
with:
26+
node-version: 20
27+
28+
# Install Prettier and dependencies
29+
- name: Install dependencies
30+
run: |
31+
npm install prettier@3.3.3 prettier-plugin-go-template
32+
33+
# Fetch the base branch and compare changes
34+
- name: Get changed files
35+
id: changed-files
36+
uses: tj-actions/changed-files@v45
37+
38+
- name: Lint all changed files
39+
env:
40+
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
41+
run: |
42+
for file in ${ALL_CHANGED_FILES}; do
43+
npx prettier --config .prettierrc --write "$file"
44+
echo "$file was changed"
45+
done
46+
47+
# Auto commit the changes if any
48+
- uses: stefanzweifel/git-auto-commit-action@v5
49+
with:
50+
commit_message: save formatted content
51+
52+
- name: Check all changed files are linted
53+
env:
54+
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
55+
run: |
56+
for file in ${ALL_CHANGED_FILES}; do
57+
npx prettier --config .prettierrc --check "$file"
58+
echo "$file was linted"
59+
done

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ resources
1111
.vscode/launch.json*
1212
check-pages-*.txt
1313
.venv/
14+
node_modules/
15+
node_modules
16+
package-lock.json
17+
package.json
18+
changed-files.txt

.prettierignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Ignore artifacts:
2+
tyk-docs/public
3+
tyk-docs/resources
4+
tyk-docs/themes/tykio/layouts/_default/list.netlify.json
5+
tyk-docs/themes/tykio/layouts/_default/list.pagesurl.json
6+
tyk-docs/themes/tykio/layouts/_default/list.urlcheck.json
7+
.gitignore
8+
.prettierignore
9+
.prettierrc
10+
changed-files.txt
11+
.github

.prettierrc

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"plugins": [
3+
"prettier-plugin-go-template"
4+
],
5+
"printWidth": 120,
6+
"proseWrap": "always",
7+
"tabWidth": 2,
8+
"useTabs": true,
9+
"overrides": [
10+
{
11+
"files": [
12+
"*.html"
13+
],
14+
"options": {
15+
"parser": "go-template",
16+
"goTemplateBracketSpacing": true,
17+
"bracketSameLine": true
18+
}
19+
},
20+
{
21+
"files": [
22+
"*.js",
23+
"*.ts"
24+
],
25+
"options": {
26+
"singleQuote": false
27+
}
28+
}
29+
]
30+
}

tyk-docs/themes/tykio/layouts/partials/developer-support/latest-releases/release-summary.html

+123-120
Original file line numberDiff line numberDiff line change
@@ -2,126 +2,129 @@
22
{{- $components := .components -}}
33

44
{{- with $section -}}
5+
{{ $slug := replace $section " " "-" }}
56

6-
{{ $slug := replace $section " " "-" }}
77

8-
<h2 id="{{- $slug -}}">{{- $section -}}</h2>
8+
<h2 id="{{- $slug -}}">{{- $section -}}</h2>
99

10-
{{- with $components -}}
11-
<div class="container mt-4">
12-
<div class="row justify-content-start">
13-
{{ range $index, $component := $components }}
14-
{{/* Determine license type */}}
15-
{{- $license := "Licensed" -}}
16-
{{- $licensed := .data.licensed -}}
17-
{{- $releaseNotesPath := .data.releaseNotesPath -}}
18-
{{- if not $licensed -}}
19-
{{- $license = "Open Source" -}}
20-
{{ end }}
21-
22-
{{/* Get latest and lts data */}}
23-
{{- $lts := false -}}
24-
{{- $ltsData := "" -}}
25-
{{- with .data.lts -}}
26-
{{- $ltsData = index $component.data $component.data.lts -}}
27-
{{- if $ltsData -}}
28-
{{- $lts = true -}}
29-
{{ end }}
30-
{{ end }}
31-
{{- $latest := false -}}
32-
{{- $latestData := "" -}}
33-
{{- with .data.latest -}}
34-
{{- $latestData = index $component.data $component.data.latest -}}
35-
{{- if $latestData -}}
36-
{{- $latest = true -}}
37-
{{ end }}
38-
{{ end }}
39-
<div class="col-md-4 mb-4">
40-
<div class="card h-100 release-card border-0">
41-
<!-- header -->
42-
<div class="card-header bg-dark text-white">
43-
{{- $title := $component.name -}}
44-
{{- with $component.data.latest -}}
45-
{{- $title = printf "%s v%s" $title $component.data.latest -}}
46-
{{- if $component.data.lts -}}
47-
{{- $title = printf "%s | v%s LTS" $title $component.data.lts -}}
48-
{{- end -}}
49-
{{- end -}}
50-
{{- $title -}}
51-
</div>
52-
<!-- body -->
53-
<div class="card-body">
54-
<div class="row">
55-
<div class="col-md-12 mt-0 mb-0">
56-
<p class="release-text">
57-
Click to <a href="{{ $component.data.home | relURL }}"> discover more</a>
58-
</p>
59-
</div>
60-
<div class="col-md-12"></hr></div>
61-
{{- with $latestData.docker -}}
62-
<div class="col-md-6">
63-
{{- if $latest -}}
64-
<p class="release-title mb-0 mt-0">Docker</p>
65-
<a href="{{ $latestData.docker}}"
66-
target="_blank"
67-
rel="nopener noreferrer"
68-
class="release-link mb-0"
69-
>
70-
Latest {{ $component.data.latest}}
71-
</a>
72-
{{- end -}}
73-
{{- if $lts -}}
74-
<a href="{{ $ltsData.docker }}"
75-
target="_blank"
76-
rel="nopener noreferrer"
77-
class="release-link mb-0"
78-
>
79-
LTS {{ $component.data.lts}}
80-
</a>
81-
{{- end -}}
82-
</div>
83-
{{ end }}
84-
{{- if not $licensed -}}
85-
<div class="col-md-6">
86-
<p class="release-title mb-0 mt-0">GitHub</p>
87-
{{- if $latest -}}
88-
<a href="{{- $latestData.tag -}}"
89-
target="_blank"
90-
rel="nopener noreferrer"
91-
class="release-link mb-0"
92-
>
93-
Latest {{ $component.data.latest}}
94-
</a>
95-
{{- end -}}
96-
{{- if $lts -}}
97-
<a href="{{- $ltsData.tag -}}"
98-
target="_blank"
99-
rel="noopener noreferrer"
100-
class="release-link mb-0"
101-
>
102-
LTS {{ $component.data.lts -}}
103-
</a>
104-
{{- end -}}
105-
</div>
106-
{{- end -}}
107-
</div>
108-
</div>
109-
110-
<!-- Footer -->
111-
<div class="card-footer bg-transparent border-0 p-0 d-flex">
112-
<a
113-
href="{{ $releaseNotesPath | relURL }}"
114-
target="_blank"
115-
rel="noopener noreferrer"
116-
class="home_btn release-btn btn-block w-100 text-center"
117-
>
118-
Release Notes
119-
</a>
120-
</div>
121-
</div>
122-
</div>
123-
{{ end }}
124-
</div>
125-
</div>
126-
{{ end }}
127-
{{ end }}
10+
{{- with $components -}}
11+
<div class="container mt-4">
12+
<div class="row justify-content-start">
13+
{{ range $index, $component := $components }}
14+
{{/* Determine license type */}}
15+
{{- $license := "Licensed" -}}
16+
{{- $licensed := .data.licensed -}}
17+
{{- $releaseNotesPath := .data.releaseNotesPath -}}
18+
{{- if not $licensed -}}
19+
{{- $license = "Open Source" -}}
20+
{{ end }}
21+
22+
{{/* Get latest and lts data */}}
23+
{{- $lts := false -}}
24+
{{- $ltsData := "" -}}
25+
{{- with .data.lts -}}
26+
{{- $ltsData = index $component.data $component.data.lts -}}
27+
{{- if $ltsData -}}
28+
{{- $lts = true -}}
29+
{{ end }}
30+
{{ end }}
31+
{{- $latest := false -}}
32+
{{- $latestData := "" -}}
33+
{{- with .data.latest -}}
34+
{{- $latestData = index $component.data $component.data.latest -}}
35+
{{- if $latestData -}}
36+
{{- $latest = true -}}
37+
{{ end }}
38+
{{ end }}
39+
<div class="col-md-4 mb-4">
40+
<div class="card h-100 release-card border-0">
41+
<!-- header -->
42+
<div class="card-header bg-dark text-white">
43+
{{- $title := $component.name -}}
44+
{{- with $component.data.latest -}}
45+
{{- $title = printf "%s v%s" $title $component.data.latest -}}
46+
{{- if $component.data.lts -}}
47+
{{- $title = printf "%s | v%s LTS" $title $component.data.lts -}}
48+
{{- end -}}
49+
{{- end -}}
50+
{{- $title -}}
51+
</div>
52+
<!-- body -->
53+
<div class="card-body">
54+
<div class="row">
55+
<div class="col-md-12 mt-0 mb-0">
56+
<p class="release-text">
57+
Click to <a href="{{ $component.data.home | relURL }}"> discover more</a>
58+
</p>
59+
</div>
60+
<div class="col-md-12"><hr /></div>
61+
{{- with $latestData.docker -}}
62+
<div class="col-md-6">
63+
{{- if $latest -}}
64+
<p class="release-title mb-0 mt-0">Docker</p>
65+
<a
66+
href="{{ $latestData.docker }}"
67+
target="_blank"
68+
rel="nopener noreferrer"
69+
class="release-link mb-0">
70+
Latest
71+
{{ $component.data.latest }}
72+
</a>
73+
{{- end -}}
74+
{{- if $lts -}}
75+
<a
76+
href="{{ $ltsData.docker }}"
77+
target="_blank"
78+
rel="nopener noreferrer"
79+
class="release-link mb-0">
80+
LTS
81+
{{ $component.data.lts }}
82+
</a>
83+
{{- end -}}
84+
</div>
85+
{{ end }}
86+
{{- if not $licensed -}}
87+
<div class="col-md-6">
88+
<p class="release-title mb-0 mt-0">GitHub</p>
89+
{{- if $latest -}}
90+
<a
91+
href="{{- $latestData.tag -}}"
92+
target="_blank"
93+
rel="nopener noreferrer"
94+
class="release-link mb-0">
95+
Latest
96+
{{ $component.data.latest }}
97+
</a>
98+
{{- end -}}
99+
{{- if $lts -}}
100+
<a
101+
href="{{- $ltsData.tag -}}"
102+
target="_blank"
103+
rel="noopener noreferrer"
104+
class="release-link mb-0">
105+
LTS
106+
{{ $component.data.lts -}}
107+
</a>
108+
{{- end -}}
109+
</div>
110+
{{- end -}}
111+
</div>
112+
</div>
113+
114+
<!-- Footer -->
115+
<div class="card-footer bg-transparent border-0 p-0 d-flex">
116+
<a
117+
href="{{ $releaseNotesPath | relURL }}"
118+
target="_blank"
119+
rel="noopener noreferrer"
120+
class="home_btn release-btn btn-block w-100 text-center">
121+
Release Notes
122+
</a>
123+
</div>
124+
</div>
125+
</div>
126+
{{ end }}
127+
</div>
128+
</div>
129+
{{ end }}
130+
{{ end }}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<div class="links-container">
2-
<label for="extend-links"><span>...</span></label>
3-
<input type="checkbox" class="extend-links" id="extend-links"></input>
4-
<div>
5-
{{- partial "menu_top_external.html" . -}}
6-
</div>
2+
<label for="extend-links"><span>...</span></label>
3+
<input type="checkbox" class="extend-links" id="extend-links" />
4+
<div>
5+
{{- partial "menu_top_external.html" . -}}
6+
</div>
77
</div>
88

99
{{- partial "menu_top_ctas.html" . -}}

0 commit comments

Comments
 (0)