Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update prettier and doctoc #5605

Merged
merged 12 commits into from
Oct 13, 2022
43 changes: 28 additions & 15 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,47 @@ concurrency:
# will skip running `yarn install` if it successfully fetched from cache

jobs:
fmt:
prettier:
name: Format with Prettier
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Run prettier with actionsx/prettier
uses: actionsx/prettier@v2
with:
args: --check --loglevel=warn .
code-asher marked this conversation as resolved.
Show resolved Hide resolved

doctoc:
code-asher marked this conversation as resolved.
Show resolved Hide resolved
name: Doctoc markdown files
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v26.1
with:
files: |
docs/**

- name: Install Node.js v16
if: steps.changed-files.outputs.any_changed == 'true'
uses: actions/setup-node@v3
with:
node-version: "16"
cache: "yarn"

- name: Fetch dependencies from cache
id: cache-node-modules
uses: actions/cache@v3
with:
path: "**/node_modules"
key: yarn-build-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-build-

- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: SKIP_SUBMODULE_DEPS=1 yarn --frozen-lockfile
- name: Install doctoc
run: yarn global add doctoc@2.0.0
jsjoeio marked this conversation as resolved.
Show resolved Hide resolved

- name: Format files with Prettier
run: yarn fmt
- name: Run doctoc
if: steps.changed-files.outputs.any_changed == 'true'
run: yarn doctoc

lint-helm:
name: Lint Helm chart
Expand Down
5 changes: 4 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
lib/vscode
lib/vscode
helm-chart
test/scripts
test/e2e/extensions/test-extension
21 changes: 1 addition & 20 deletions ci/dev/fmt.sh → ci/dev/doctoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,6 @@ set -euo pipefail
main() {
cd "$(dirname "$0")/../.."

local prettierExts
prettierExts=(
"*.js"
"*.ts"
"*.tsx"
"*.html"
"*.json"
"*.css"
"*.md"
"*.toml"
"*.yaml"
"*.yml"
"*.sh"
)
prettier --write --loglevel=warn $(
git ls-files "${prettierExts[@]}" | grep -v "lib/vscode" | grep -v 'helm-chart'
)

doctoc --title '# FAQ' docs/FAQ.md > /dev/null
doctoc --title '# Setup Guide' docs/guide.md > /dev/null
doctoc --title '# Install' docs/install.md > /dev/null
Expand All @@ -32,12 +14,11 @@ main() {
doctoc --title '# iPad' docs/ipad.md > /dev/null
doctoc --title '# Termux' docs/termux.md > /dev/null

# TODO: replace with a method that generates fewer false positives.
if [[ ${CI-} && $(git ls-files --other --modified --exclude-standard) ]]; then
echo "Files need generation or are formatted incorrectly:"
git -c color.ui=always status | grep --color=no '\[31m'
echo "Please run the following locally:"
echo " yarn fmt"
echo " yarn doctoc"
exit 1
fi
}
Expand Down
18 changes: 9 additions & 9 deletions ci/release-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ COPY release-packages/code-server*.deb /tmp/
FROM debian:11

RUN apt-get update \
&& apt-get install -y \
&& apt-get install -y \
curl \
dumb-init \
zsh \
Expand All @@ -29,15 +29,15 @@ RUN sed -i "s/# en_US.UTF-8/en_US.UTF-8/" /etc/locale.gen \
&& locale-gen
ENV LANG=en_US.UTF-8

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

RUN ARCH="$(dpkg --print-architecture)" && \
curl -fsSL "https://github.com/boxboat/fixuid/releases/download/v0.5/fixuid-0.5-linux-$ARCH.tar.gz" | tar -C /usr/local/bin -xzf - && \
chown root:root /usr/local/bin/fixuid && \
chmod 4755 /usr/local/bin/fixuid && \
mkdir -p /etc/fixuid && \
printf "user: coder\ngroup: coder\n" > /etc/fixuid/config.yml
RUN ARCH="$(dpkg --print-architecture)" \
&& curl -fsSL "https://github.com/boxboat/fixuid/releases/download/v0.5/fixuid-0.5-linux-$ARCH.tar.gz" | tar -C /usr/local/bin -xzf - \
jsjoeio marked this conversation as resolved.
Show resolved Hide resolved
&& chown root:root /usr/local/bin/fixuid \
&& chmod 4755 /usr/local/bin/fixuid \
&& mkdir -p /etc/fixuid \
&& printf "user: coder\ngroup: coder\n" > /etc/fixuid/config.yml

COPY ci/release-image/entrypoint.sh /usr/bin/entrypoint.sh
RUN --mount=from=packages,src=/tmp,dst=/tmp/packages dpkg -i /tmp/packages/code-server*$(dpkg --print-architecture).deb
Expand Down
13 changes: 13 additions & 0 deletions docs/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
<!-- prettier-ignore-start -->
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
# Contributor Covenant Code of Conduct

- [Contributor Covenant Code of Conduct](#contributor-covenant-code-of-conduct)
- [Our Pledge](#our-pledge)
- [Our Standards](#our-standards)
- [Our Responsibilities](#our-responsibilities)
- [Scope](#scope)
- [Enforcement](#enforcement)
- [Attribution](#attribution)

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

# Contributor Covenant Code of Conduct

Expand Down
2 changes: 2 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- prettier-ignore-start -->
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
# Contributing
Expand All @@ -24,6 +25,7 @@
- [Currently Known Issues](#currently-known-issues)

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

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

Expand Down
2 changes: 2 additions & 0 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- prettier-ignore-start -->
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
# FAQ
Expand Down Expand Up @@ -33,6 +34,7 @@
- [How do I change the port?](#how-do-i-change-the-port)

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

## Questions?

Expand Down
2 changes: 2 additions & 0 deletions docs/MAINTAINING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- prettier-ignore-start -->
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
# Maintaining
Expand All @@ -24,6 +25,7 @@
- [Troubleshooting](#troubleshooting)

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

This document is meant to serve current and future maintainers of code-server,
as well as share our workflow for maintaining the project.
Expand Down
5 changes: 3 additions & 2 deletions docs/guide.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- prettier-ignore-start -->
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
# Setup Guide
Expand All @@ -22,6 +23,7 @@
- [Option 2: ngrok tunnel](#option-2-ngrok-tunnel)

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

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

```console
```shell
code-asher marked this conversation as resolved.
Show resolved Hide resolved
# This is the same as the above SSH command, but it runs in the background
# continuously. Be sure to add `mutagen daemon start` to your ~/.bashrc to
# start the mutagen daemon when you open a shell.

code-asher marked this conversation as resolved.
Show resolved Hide resolved
mutagen forward create --name=code-server tcp:127.0.0.1:8080 < instance-ip > :tcp:127.0.0.1:8080
```

Expand Down
2 changes: 2 additions & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- prettier-ignore-start -->
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
# Install
Expand All @@ -24,6 +25,7 @@
- [Debian, Ubuntu](#debian-ubuntu-1)

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

This document demonstrates how to install `code-server` on various distros and
operating systems.
Expand Down
2 changes: 2 additions & 0 deletions docs/ipad.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- prettier-ignore-start -->
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
# iPad
Expand All @@ -13,6 +14,7 @@
- [Sharing a self-signed certificate with an iPad](#sharing-a-self-signed-certificate-with-an-ipad)

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

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

Expand Down
2 changes: 2 additions & 0 deletions docs/npm.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- prettier-ignore-start -->
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
# npm Install Requirements
Expand All @@ -15,6 +16,7 @@
- [Debugging install issues with npm](#debugging-install-issues-with-npm)

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

If you're installing code-server via `npm`, you'll need to install additional
dependencies required to build the native modules used by VS Code. This article
Expand Down
2 changes: 2 additions & 0 deletions docs/termux.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- prettier-ignore-start -->
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
# Termux
Expand All @@ -14,6 +15,7 @@
- [Working with PRoot](#working-with-proot)

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

## Install

Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"clean": "./ci/build/clean.sh",
"build": "./ci/build/build-code-server.sh",
"build:vscode": "./ci/build/build-vscode.sh",
"doctoc": "./ci/dev/doctoc.sh",
"release": "./ci/build/build-release.sh",
"release:standalone": "./ci/build/build-standalone-release.sh",
"release:prep": "./ci/build/release-prep.sh",
Expand All @@ -22,11 +23,12 @@
"test:native": "./ci/dev/test-native.sh",
"test:scripts": "./ci/dev/test-scripts.sh",
"package": "./ci/build/build-packages.sh",
"prettier": "prettier --write --loglevel=warn .",
"postinstall": "./ci/dev/postinstall.sh",
"publish:npm": "./ci/steps/publish-npm.sh",
"publish:docker": "./ci/steps/docker-buildx-push.sh",
"_audit": "./ci/dev/audit.sh",
"fmt": "./ci/dev/fmt.sh",
"fmt": "yarn prettier && ./ci/dev/doctoc.sh",
"lint:scripts": "./ci/dev/lint-scripts.sh",
"lint:ts": "eslint --max-warnings=0 --fix $(git ls-files '*.ts' '*.js' | grep -v 'lib/vscode')",
"test": "echo 'Run yarn test:unit or yarn test:e2e' && exit 1",
Expand Down Expand Up @@ -59,7 +61,7 @@
"eslint-import-resolver-typescript": "^2.5.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.2.1",
"prettier": "2.3.2",
"prettier-plugin-sh": "^0.12.0",
"ts-node": "^10.0.0",
"typescript": "^4.6.2"
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2583,7 +2583,7 @@ prettier-plugin-sh@^0.12.0:
dependencies:
mvdan-sh "^0.10.1"

prettier@^2.2.1:
prettier@2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.3.2.tgz#ef280a05ec253712e486233db5c6f23441e7342d"
integrity sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==
Expand Down