Skip to content

Commit 71a127a

Browse files
authored
refactor: update prettier and doctoc (#5605)
* docs: add toc to CODE OF CONDUCT * chore: add prettier ignore blocks to docs * chore: update styles for Dockerfile * refactor: separate prettier, doctoc This does a couple things: - update `.prettierignore` - split `prettier` and `doctoc` commands. you can still run with `yarn fmt` - delete `fmt.sh` and add `doctoc.sh` By doing so, we can run tasks in parallel in CI and we should also have less false positives than before with `yarn fmt` locally. * refactor: update prettier job, add doctoc This modifies the prettier job to use actionsx/prettier. It also adds a job for `doctoc`. * chore: upgrade to prettier 2.7.1 * chore: pin doctoc to 2.0.0 * fixup!: add .pc to prettierignore * feat: add --cache to prettier cmd
1 parent d4707d1 commit 71a127a

15 files changed

+88
-60
lines changed

Diff for: .github/workflows/build.yaml

+28-15
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,47 @@ concurrency:
2222
# will skip running `yarn install` if it successfully fetched from cache
2323

2424
jobs:
25-
fmt:
25+
prettier:
2626
name: Format with Prettier
2727
runs-on: ubuntu-latest
2828
timeout-minutes: 5
2929
steps:
3030
- name: Checkout repo
3131
uses: actions/checkout@v3
3232

33+
- name: Run prettier with actionsx/prettier
34+
uses: actionsx/prettier@v2
35+
with:
36+
args: --check --loglevel=warn .
37+
38+
doctoc:
39+
name: Doctoc markdown files
40+
runs-on: ubuntu-latest
41+
timeout-minutes: 5
42+
steps:
43+
- name: Checkout repo
44+
uses: actions/checkout@v3
45+
46+
- name: Get changed files
47+
id: changed-files
48+
uses: tj-actions/[email protected]
49+
with:
50+
files: |
51+
docs/**
52+
3353
- name: Install Node.js v16
54+
if: steps.changed-files.outputs.any_changed == 'true'
3455
uses: actions/setup-node@v3
3556
with:
3657
node-version: "16"
58+
cache: "yarn"
3759

38-
- name: Fetch dependencies from cache
39-
id: cache-node-modules
40-
uses: actions/cache@v3
41-
with:
42-
path: "**/node_modules"
43-
key: yarn-build-${{ hashFiles('**/yarn.lock') }}
44-
restore-keys: |
45-
yarn-build-
46-
47-
- name: Install dependencies
48-
if: steps.cache-node-modules.outputs.cache-hit != 'true'
49-
run: SKIP_SUBMODULE_DEPS=1 yarn --frozen-lockfile
60+
- name: Install doctoc
61+
run: yarn global add [email protected]
5062

51-
- name: Format files with Prettier
52-
run: yarn fmt
63+
- name: Run doctoc
64+
if: steps.changed-files.outputs.any_changed == 'true'
65+
run: yarn doctoc
5366

5467
lint-helm:
5568
name: Lint Helm chart

Diff for: .prettierignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
lib/vscode
1+
lib/vscode
2+
helm-chart
3+
test/scripts
4+
test/e2e/extensions/test-extension
5+
.pc

Diff for: ci/dev/fmt.sh renamed to ci/dev/doctoc.sh

+1-20
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,6 @@ set -euo pipefail
44
main() {
55
cd "$(dirname "$0")/../.."
66

7-
local prettierExts
8-
prettierExts=(
9-
"*.js"
10-
"*.ts"
11-
"*.tsx"
12-
"*.html"
13-
"*.json"
14-
"*.css"
15-
"*.md"
16-
"*.toml"
17-
"*.yaml"
18-
"*.yml"
19-
"*.sh"
20-
)
21-
prettier --write --loglevel=warn $(
22-
git ls-files "${prettierExts[@]}" | grep -v "lib/vscode" | grep -v 'helm-chart'
23-
)
24-
257
doctoc --title '# FAQ' docs/FAQ.md > /dev/null
268
doctoc --title '# Setup Guide' docs/guide.md > /dev/null
279
doctoc --title '# Install' docs/install.md > /dev/null
@@ -32,12 +14,11 @@ main() {
3214
doctoc --title '# iPad' docs/ipad.md > /dev/null
3315
doctoc --title '# Termux' docs/termux.md > /dev/null
3416

35-
# TODO: replace with a method that generates fewer false positives.
3617
if [[ ${CI-} && $(git ls-files --other --modified --exclude-standard) ]]; then
3718
echo "Files need generation or are formatted incorrectly:"
3819
git -c color.ui=always status | grep --color=no '\[31m'
3920
echo "Please run the following locally:"
40-
echo " yarn fmt"
21+
echo " yarn doctoc"
4122
exit 1
4223
fi
4324
}

Diff for: ci/release-image/Dockerfile

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ COPY release-packages/code-server*.deb /tmp/
66
FROM debian:11
77

88
RUN apt-get update \
9-
&& apt-get install -y \
9+
&& apt-get install -y \
1010
curl \
1111
dumb-init \
1212
zsh \
@@ -29,15 +29,15 @@ RUN sed -i "s/# en_US.UTF-8/en_US.UTF-8/" /etc/locale.gen \
2929
&& locale-gen
3030
ENV LANG=en_US.UTF-8
3131

32-
RUN adduser --gecos '' --disabled-password coder && \
33-
echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd
32+
RUN adduser --gecos '' --disabled-password coder \
33+
&& echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd
3434

35-
RUN ARCH="$(dpkg --print-architecture)" && \
36-
curl -fsSL "https://github.com/boxboat/fixuid/releases/download/v0.5/fixuid-0.5-linux-$ARCH.tar.gz" | tar -C /usr/local/bin -xzf - && \
37-
chown root:root /usr/local/bin/fixuid && \
38-
chmod 4755 /usr/local/bin/fixuid && \
39-
mkdir -p /etc/fixuid && \
40-
printf "user: coder\ngroup: coder\n" > /etc/fixuid/config.yml
35+
RUN ARCH="$(dpkg --print-architecture)" \
36+
&& curl -fsSL "https://github.com/boxboat/fixuid/releases/download/v0.5/fixuid-0.5-linux-$ARCH.tar.gz" | tar -C /usr/local/bin -xzf - \
37+
&& chown root:root /usr/local/bin/fixuid \
38+
&& chmod 4755 /usr/local/bin/fixuid \
39+
&& mkdir -p /etc/fixuid \
40+
&& printf "user: coder\ngroup: coder\n" > /etc/fixuid/config.yml
4141

4242
COPY ci/release-image/entrypoint.sh /usr/bin/entrypoint.sh
4343
RUN --mount=from=packages,src=/tmp,dst=/tmp/packages dpkg -i /tmp/packages/code-server*$(dpkg --print-architecture).deb

Diff for: docs/CODE_OF_CONDUCT.md

+13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1+
<!-- prettier-ignore-start -->
12
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
23
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
4+
# Contributor Covenant Code of Conduct
5+
6+
- [Contributor Covenant Code of Conduct](#contributor-covenant-code-of-conduct)
7+
- [Our Pledge](#our-pledge)
8+
- [Our Standards](#our-standards)
9+
- [Our Responsibilities](#our-responsibilities)
10+
- [Scope](#scope)
11+
- [Enforcement](#enforcement)
12+
- [Attribution](#attribution)
13+
14+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
15+
<!-- prettier-ignore-end -->
316

417
# Contributor Covenant Code of Conduct
518

Diff for: docs/CONTRIBUTING.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- prettier-ignore-start -->
12
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
23
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
34
# Contributing
@@ -24,6 +25,7 @@
2425
- [Currently Known Issues](#currently-known-issues)
2526

2627
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
28+
<!-- prettier-ignore-end -->
2729

2830
- [Detailed CI and build process docs](../ci)
2931

Diff for: docs/FAQ.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- prettier-ignore-start -->
12
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
23
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
34
# FAQ
@@ -33,6 +34,7 @@
3334
- [How do I change the port?](#how-do-i-change-the-port)
3435

3536
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
37+
<!-- prettier-ignore-end -->
3638

3739
## Questions?
3840

Diff for: docs/MAINTAINING.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- prettier-ignore-start -->
12
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
23
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
34
# Maintaining
@@ -24,6 +25,7 @@
2425
- [Troubleshooting](#troubleshooting)
2526

2627
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
28+
<!-- prettier-ignore-end -->
2729

2830
This document is meant to serve current and future maintainers of code-server,
2931
as well as share our workflow for maintaining the project.

Diff for: docs/guide.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- prettier-ignore-start -->
12
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
23
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
34
# Setup Guide
@@ -22,6 +23,7 @@
2223
- [Option 2: ngrok tunnel](#option-2-ngrok-tunnel)
2324

2425
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
26+
<!-- prettier-ignore-end -->
2527

2628
This article will walk you through exposing code-server securely once you've
2729
completed the [installation process](install.md).
@@ -89,11 +91,10 @@ we recommend using another method, such as [Let's Encrypt](#let-encrypt) instead
8991
using [mutagen](https://mutagen.io/documentation/introduction/installation)
9092
to do so. Once you've installed mutagen, you can port forward as follows:
9193

92-
```console
94+
```shell
9395
# This is the same as the above SSH command, but it runs in the background
9496
# continuously. Be sure to add `mutagen daemon start` to your ~/.bashrc to
9597
# start the mutagen daemon when you open a shell.
96-
9798
mutagen forward create --name=code-server tcp:127.0.0.1:8080 < instance-ip > :tcp:127.0.0.1:8080
9899
```
99100

Diff for: docs/install.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- prettier-ignore-start -->
12
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
23
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
34
# Install
@@ -24,6 +25,7 @@
2425
- [Debian, Ubuntu](#debian-ubuntu-1)
2526

2627
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
28+
<!-- prettier-ignore-end -->
2729

2830
This document demonstrates how to install `code-server` on various distros and
2931
operating systems.

Diff for: docs/ipad.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- prettier-ignore-start -->
12
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
23
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
34
# iPad
@@ -13,6 +14,7 @@
1314
- [Sharing a self-signed certificate with an iPad](#sharing-a-self-signed-certificate-with-an-ipad)
1415

1516
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
17+
<!-- prettier-ignore-end -->
1618

1719
Once you've installed code-server, you can access it from an iPad.
1820

Diff for: docs/npm.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- prettier-ignore-start -->
12
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
23
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
34
# npm Install Requirements
@@ -15,6 +16,7 @@
1516
- [Debugging install issues with npm](#debugging-install-issues-with-npm)
1617

1718
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
19+
<!-- prettier-ignore-end -->
1820

1921
If you're installing code-server via `npm`, you'll need to install additional
2022
dependencies required to build the native modules used by VS Code. This article

Diff for: docs/termux.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- prettier-ignore-start -->
12
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
23
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
34
# Termux
@@ -14,6 +15,7 @@
1415
- [Working with PRoot](#working-with-proot)
1516

1617
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
18+
<!-- prettier-ignore-end -->
1719

1820
## Install
1921

Diff for: package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"clean": "./ci/build/clean.sh",
1313
"build": "./ci/build/build-code-server.sh",
1414
"build:vscode": "./ci/build/build-vscode.sh",
15+
"doctoc": "./ci/dev/doctoc.sh",
1516
"release": "./ci/build/build-release.sh",
1617
"release:standalone": "./ci/build/build-standalone-release.sh",
1718
"release:prep": "./ci/build/release-prep.sh",
@@ -22,11 +23,12 @@
2223
"test:native": "./ci/dev/test-native.sh",
2324
"test:scripts": "./ci/dev/test-scripts.sh",
2425
"package": "./ci/build/build-packages.sh",
26+
"prettier": "prettier --write --loglevel=warn --cache .",
2527
"postinstall": "./ci/dev/postinstall.sh",
2628
"publish:npm": "./ci/steps/publish-npm.sh",
2729
"publish:docker": "./ci/steps/docker-buildx-push.sh",
2830
"_audit": "./ci/dev/audit.sh",
29-
"fmt": "./ci/dev/fmt.sh",
31+
"fmt": "yarn prettier && ./ci/dev/doctoc.sh",
3032
"lint:scripts": "./ci/dev/lint-scripts.sh",
3133
"lint:ts": "eslint --max-warnings=0 --fix $(git ls-files '*.ts' '*.js' | grep -v 'lib/vscode')",
3234
"test": "echo 'Run yarn test:unit or yarn test:e2e' && exit 1",
@@ -53,13 +55,13 @@
5355
"@typescript-eslint/eslint-plugin": "^5.23.0",
5456
"@typescript-eslint/parser": "^5.23.0",
5557
"audit-ci": "^6.0.0",
56-
"doctoc": "^2.0.0",
58+
"doctoc": "2.0.0",
5759
"eslint": "^7.7.0",
5860
"eslint-config-prettier": "^8.5.0",
5961
"eslint-import-resolver-typescript": "^2.5.0",
6062
"eslint-plugin-import": "^2.18.2",
6163
"eslint-plugin-prettier": "^4.0.0",
62-
"prettier": "^2.2.1",
64+
"prettier": "2.7.1",
6365
"prettier-plugin-sh": "^0.12.0",
6466
"ts-node": "^10.0.0",
6567
"typescript": "^4.6.2"

Diff for: yarn.lock

+10-10
Original file line numberDiff line numberDiff line change
@@ -952,16 +952,16 @@ dir-glob@^3.0.1:
952952
dependencies:
953953
path-type "^4.0.0"
954954

955-
doctoc@^2.0.0:
956-
version "2.0.1"
957-
resolved "https://registry.yarnpkg.com/doctoc/-/doctoc-2.0.1.tgz#d5aee2bce65a438ff8717d9e51df3d540caa3b78"
958-
integrity sha512-JsxnSVZtLCThKehjFPBDhP1+ZLmdfXQynZH/0ABAwrnd1Zf3AV6LigC9oWJyaZ+c6RXCDnlGUNJ7I+1v8VaaRg==
955+
956+
version "2.0.0"
957+
resolved "https://registry.yarnpkg.com/doctoc/-/doctoc-2.0.0.tgz#3c5c51ba89acb9b8e1924cc429500d6de2dfb90e"
958+
integrity sha512-thvCndtwVPe3GCDUG09NYPu9D72Ons3MFh/Fe5A3bePMHGa1XSMgJWyL04bkxa0DyyaylEB2UrqigbQM0fcj7w==
959959
dependencies:
960960
"@textlint/markdown-to-ast" "~6.1.7"
961961
anchor-markdown-header "~0.5.7"
962962
htmlparser2 "~4.1.0"
963963
minimist "~1.2.5"
964-
underscore "~1.12.1"
964+
underscore "~1.10.2"
965965
update-section "~0.3.3"
966966

967967
doctrine@^2.1.0:
@@ -2583,10 +2583,10 @@ prettier-plugin-sh@^0.12.0:
25832583
dependencies:
25842584
mvdan-sh "^0.10.1"
25852585

2586-
prettier@^2.2.1:
2587-
version "2.3.2"
2588-
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.3.2.tgz#ef280a05ec253712e486233db5c6f23441e7342d"
2589-
integrity sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==
2586+
prettier@2.7.1:
2587+
version "2.7.1"
2588+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64"
2589+
integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==
25902590

25912591
progress@^2.0.0:
25922592
version "2.0.3"
@@ -3288,7 +3288,7 @@ unbox-primitive@^1.0.0:
32883288
has-symbols "^1.0.2"
32893289
which-boxed-primitive "^1.0.2"
32903290

3291-
underscore@^1.13.1, underscore@~1.12.1:
3291+
underscore@^1.13.1, underscore@~1.10.2:
32923292
version "1.13.1"
32933293
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.1.tgz#0c1c6bd2df54b6b69f2314066d65b6cde6fcf9d1"
32943294
integrity sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g==

0 commit comments

Comments
 (0)