Skip to content

Commit acb4663

Browse files
authored
Merge pull request #2891 from cdr/jsjoeio/replace-shfmt
feat: add prettier-plugin-sh
2 parents 3f3a619 + d053898 commit acb4663

19 files changed

+52
-43
lines changed

ci/build/build-packages.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ release_gcp() {
4040
# Generates deb and rpm packages.
4141
release_nfpm() {
4242
local nfpm_config
43-
nfpm_config="$(envsubst < ./ci/build/nfpm.yaml)"
43+
nfpm_config="$(envsubst <./ci/build/nfpm.yaml)"
4444

4545
# The underscores are convention for .deb.
4646
nfpm pkg -f <(echo "$nfpm_config") --target "release-packages/code-server_${VERSION}_$ARCH.deb"

ci/build/build-release.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ bundle_code_server() {
4949

5050
# Adds the commit to package.json
5151
jq --slurp '.[0] * .[1]' package.json <(
52-
cat << EOF
52+
cat <<EOF
5353
{
5454
"commit": "$(git rev-parse HEAD)",
5555
"scripts": {
5656
"postinstall": "./postinstall.sh"
5757
}
5858
}
5959
EOF
60-
) > "$RELEASE_PATH/package.json"
60+
) >"$RELEASE_PATH/package.json"
6161
rsync yarn.lock "$RELEASE_PATH"
6262
rsync ci/build/npm-postinstall.sh "$RELEASE_PATH/postinstall.sh"
6363

@@ -89,18 +89,18 @@ bundle_vscode() {
8989

9090
# Adds the commit and date to product.json
9191
jq --slurp '.[0] * .[1]' "$VSCODE_SRC_PATH/product.json" <(
92-
cat << EOF
92+
cat <<EOF
9393
{
9494
"commit": "$(git rev-parse HEAD)",
9595
"date": $(jq -n 'now | todate')
9696
}
9797
EOF
98-
) > "$VSCODE_OUT_PATH/product.json"
98+
) >"$VSCODE_OUT_PATH/product.json"
9999

100100
# We remove the scripts field so that later on we can run
101101
# yarn to fetch node_modules if necessary without build scripts running.
102102
# We cannot use --no-scripts because we still want dependent package scripts to run.
103-
jq 'del(.scripts)' < "$VSCODE_SRC_PATH/package.json" > "$VSCODE_OUT_PATH/package.json"
103+
jq 'del(.scripts)' <"$VSCODE_SRC_PATH/package.json" >"$VSCODE_OUT_PATH/package.json"
104104

105105
pushd "$VSCODE_OUT_PATH"
106106
symlink_asar

ci/build/build-standalone-release.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ main() {
1212
# we use the same version it's using so we instead run a script with yarn that
1313
# will print the path to node.
1414
local node_path
15-
node_path="$(yarn -s node <<< 'console.info(process.execPath)')"
15+
node_path="$(yarn -s node <<<'console.info(process.execPath)')"
1616

1717
mkdir -p "$RELEASE_PATH/bin"
1818
rsync ./ci/build/code-server.sh "$RELEASE_PATH/bin/code-server"

ci/build/code-server.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ _realpath() {
1111
cd "$(dirname "$script")"
1212

1313
while [ -L "$(basename "$script")" ]; do
14-
if [ -L "./node" ] && [ -L "./code-server" ] &&
15-
[ -f "package.json" ] &&
16-
cat package.json | grep -q '^ "name": "code-server",$'; then
14+
if [ -L "./node" ] && [ -L "./code-server" ] \
15+
&& [ -f "package.json" ] \
16+
&& cat package.json | grep -q '^ "name": "code-server",$'; then
1717
echo "***** Please use the script in bin/code-server instead!" >&2
1818
echo "***** This script will soon be removed!" >&2
1919
echo "***** See the release notes at https://github.com/cdr/code-server/releases/tag/v3.4.0" >&2

ci/build/release-github-draft.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ main() {
1010
hub release create \
1111
--file - \
1212
-t "$(git rev-parse HEAD)" \
13-
--draft "v$VERSION" << EOF
13+
--draft "v$VERSION" <<EOF
1414
v$VERSION
1515
1616
VS Code v$(vscode_version)

ci/dev/fmt.sh

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

7-
shfmt -i 2 -w -sr $(git ls-files "*.sh" | grep -v "lib/vscode")
8-
97
local prettierExts
108
prettierExts=(
119
"*.js"
@@ -18,18 +16,19 @@ main() {
1816
"*.toml"
1917
"*.yaml"
2018
"*.yml"
19+
"*.sh"
2120
)
2221
prettier --write --loglevel=warn $(
2322
git ls-files "${prettierExts[@]}" | grep -v "lib/vscode" | grep -v 'helm-chart'
2423
)
2524

26-
doctoc --title '# FAQ' docs/FAQ.md > /dev/null
27-
doctoc --title '# Setup Guide' docs/guide.md > /dev/null
28-
doctoc --title '# Install' docs/install.md > /dev/null
29-
doctoc --title '# npm Install Requirements' docs/npm.md > /dev/null
30-
doctoc --title '# Contributing' docs/CONTRIBUTING.md > /dev/null
31-
doctoc --title '# Contributor Covenant Code of Conduct' docs/CODE_OF_CONDUCT.md > /dev/null
32-
doctoc --title '# iPad' docs/ipad.md > /dev/null
25+
doctoc --title '# FAQ' docs/FAQ.md >/dev/null
26+
doctoc --title '# Setup Guide' docs/guide.md >/dev/null
27+
doctoc --title '# Install' docs/install.md >/dev/null
28+
doctoc --title '# npm Install Requirements' docs/npm.md >/dev/null
29+
doctoc --title '# Contributing' docs/CONTRIBUTING.md >/dev/null
30+
doctoc --title '# Contributor Covenant Code of Conduct' docs/CODE_OF_CONDUCT.md >/dev/null
31+
doctoc --title '# iPad' docs/ipad.md >/dev/null
3332

3433
if [[ ${CI-} && $(git ls-files --other --modified --exclude-standard) ]]; then
3534
echo "Files need generation or are formatted incorrectly:"

ci/dev/gen_icons.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ main() {
3535
# This escapes all newlines so that sed will accept them.
3636
favicon_dark_style="$(printf "%s\n" "$favicon_dark_style" | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\\n/g')"
3737
sed "$(
38-
cat -n << EOF
38+
cat -n <<EOF
3939
s%<rect id="favicon"%$favicon_dark_style<rect id="favicon"%
4040
EOF
41-
)" favicon.svg > favicon-dark-support.svg
41+
)" favicon.svg >favicon-dark-support.svg
4242
}
4343

4444
main "$@"

ci/dev/lint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ main() {
88
stylelint $(git ls-files "*.css" | grep -v "lib/vscode")
99
tsc --noEmit --skipLibCheck
1010
shellcheck -e SC2046,SC2164,SC2154,SC1091,SC1090,SC2002 $(git ls-files "*.sh" | grep -v "lib/vscode")
11-
if command -v helm && helm kubeval --help > /dev/null; then
11+
if command -v helm && helm kubeval --help >/dev/null; then
1212
helm kubeval ci/helm-chart
1313
fi
1414

ci/dev/update-vscode.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ main() {
3333

3434
# Check if the remote exists
3535
# if it doesn't, we add it
36-
if ! git config remote.vscode.url > /dev/null; then
36+
if ! git config remote.vscode.url >/dev/null; then
3737
echo "Could not find 'vscode' as a remote"
3838
echo "Adding with: git remote add vscode https://github.com/microsoft/vscode.git"
3939
git remote add vscode https://github.com/microsoft/vscode.git
@@ -52,7 +52,7 @@ main() {
5252
fi
5353

5454
# Check that they have jq installed
55-
if ! command -v jq &> /dev/null; then
55+
if ! command -v jq &>/dev/null; then
5656
echo "jq could not be found."
5757
echo "We use this when looking up the exact version to update to in the package.json in VS Code."
5858
echo -e "See docs here: https://stedolan.github.io/jq/download/"
@@ -71,7 +71,7 @@ main() {
7171
git fetch vscode
7272

7373
# Check if GitHub CLI is installed
74-
if ! command -v gh &> /dev/null; then
74+
if ! command -v gh &>/dev/null; then
7575
echo "GitHub CLI could not be found."
7676
echo "If you install it before you run this script next time, we'll open a draft PR for you!"
7777
echo -e "See docs here: https://github.com/cli/cli#installation\n"

ci/images/centos7/Dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ ENV PATH=/usr/local/go/bin:$GOPATH/bin:$PATH
2626

2727
# Install Go dependencies
2828
ENV GO111MODULE=on
29-
RUN go get mvdan.cc/sh/v3/cmd/shfmt
3029
RUN go get github.com/goreleaser/nfpm/cmd/[email protected]
3130

3231
RUN curl -fsSL https://get.docker.com | sh

ci/images/debian10/Dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ ENV PATH=/usr/local/go/bin:$GOPATH/bin:$PATH
4242

4343
# Install Go dependencies
4444
ENV GO111MODULE=on
45-
RUN go get mvdan.cc/sh/v3/cmd/shfmt
4645
RUN go get github.com/goreleaser/nfpm/cmd/[email protected]
4746

4847
RUN VERSION="$(curl -fsSL https://storage.googleapis.com/kubernetes-release/release/stable.txt)" && \

ci/lib.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
set -euo pipefail
33

44
pushd() {
5-
builtin pushd "$@" > /dev/null
5+
builtin pushd "$@" >/dev/null
66
}
77

88
popd() {
9-
builtin popd > /dev/null
9+
builtin popd >/dev/null
1010
}
1111

1212
pkg_json_version() {
@@ -75,7 +75,7 @@ download_artifact() {
7575
local tmp_file
7676
tmp_file="$(mktemp)"
7777

78-
curl -fsSL "$(get_artifact_url "$artifact_name")" > "$tmp_file"
78+
curl -fsSL "$(get_artifact_url "$artifact_name")" >"$tmp_file"
7979
unzip -q -o "$tmp_file" -d "$dst"
8080
rm "$tmp_file"
8181
}

ci/release-image/entrypoint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -eu
66
eval "$(fixuid -q)"
77

88
if [ "${DOCKER_USER-}" ] && [ "$DOCKER_USER" != "$USER" ]; then
9-
echo "$DOCKER_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/nopasswd > /dev/null
9+
echo "$DOCKER_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/nopasswd >/dev/null
1010
# Unfortunately we cannot change $HOME as we cannot move any bind mounts
1111
# nor can we bind mount $HOME into a new home as that requires a privileged container.
1212
sudo usermod --login "$DOCKER_USER" coder

ci/steps/build-docker-image.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ main() {
88
./ci/release-image/build.sh
99

1010
mkdir -p release-images
11-
docker save "codercom/code-server-$ARCH:$VERSION" > "release-images/code-server-$ARCH-$VERSION.tar"
11+
docker save "codercom/code-server-$ARCH:$VERSION" >"release-images/code-server-$ARCH-$VERSION.tar"
1212
}
1313

1414
main "$@"

ci/steps/publish-npm.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ main() {
66
source ./ci/lib.sh
77

88
if [[ ${CI-} ]]; then
9-
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
9+
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >~/.npmrc
1010
fi
1111

1212
download_artifact npm-package ./release-npm-package

docs/CONTRIBUTING.md

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ There are several differences, however. You must:
3636
- Use Node.js version 12.x (or greater)
3737
- Have [yarn](https://classic.yarnpkg.com/en/) installed (which is used to install JS packages and run development scripts)
3838
- Have [nfpm](https://github.com/goreleaser/nfpm) (which is used to build `.deb` and `.rpm` packages and [jq](https://stedolan.github.io/jq/) (used to build code-server releases) installed
39-
- Have [shfmt](https://pkg.go.dev/mvdan.cc/sh/v3) installed to run `yarn fmt` (requires Go is installed on your system)
4039

4140
The [CI container](../ci/images/debian10/Dockerfile) is a useful reference for all
4241
of the dependencies code-server uses.

install.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ usage() {
1313
"
1414
fi
1515

16-
cath << EOF
16+
cath <<EOF
1717
Installs code-server for Linux, macOS and FreeBSD.
1818
It tries to use the system package manager if possible.
1919
After successful installation it explains how to start using code-server.
@@ -81,7 +81,7 @@ echo_latest_version() {
8181

8282
echo_npm_postinstall() {
8383
echoh
84-
cath << EOF
84+
cath <<EOF
8585
The npm package has been installed successfully!
8686
Please extend your path to use code-server:
8787
PATH="$NPM_BIN_DIR:\$PATH"
@@ -92,7 +92,7 @@ EOF
9292

9393
echo_standalone_postinstall() {
9494
echoh
95-
cath << EOF
95+
cath <<EOF
9696
Standalone release has been installed into $STANDALONE_INSTALL_PREFIX/lib/code-server-$VERSION
9797
Please extend your path to use code-server:
9898
PATH="$STANDALONE_INSTALL_PREFIX/bin:\$PATH"
@@ -103,7 +103,7 @@ EOF
103103

104104
echo_systemd_postinstall() {
105105
echoh
106-
cath << EOF
106+
cath <<EOF
107107
To have systemd start code-server now and restart on boot:
108108
sudo systemctl enable --now code-server@\$USER
109109
Or, if you don't want/need a background service you can run:
@@ -509,7 +509,7 @@ arch() {
509509
}
510510

511511
command_exists() {
512-
command -v "$@" > /dev/null
512+
command -v "$@" >/dev/null
513513
}
514514

515515
sh_c() {
@@ -571,7 +571,7 @@ prefix() {
571571
fifo="$(mktemp -d)/fifo"
572572
mkfifo "$fifo"
573573
sed -e "s#^#$PREFIX: #" "$fifo" &
574-
"$@" > "$fifo" 2>&1
574+
"$@" >"$fifo" 2>&1
575575
}
576576

577577
main "$@"

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@
6363
"istanbul-badges-readme": "^1.2.0",
6464
"leaked-handles": "^5.2.0",
6565
"parcel-bundler": "^1.12.4",
66-
"prettier": "^2.0.5",
66+
"prettier": "^2.2.1",
67+
"prettier-plugin-sh": "^0.6.0",
6768
"stylelint": "^13.0.0",
6869
"stylelint-config-recommended": "^3.0.0",
6970
"ts-node": "^9.0.0",

yarn.lock

+13-1
Original file line numberDiff line numberDiff line change
@@ -5202,6 +5202,11 @@ [email protected]:
52025202
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
52035203
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==
52045204

5205+
mvdan-sh@^0.5.0:
5206+
version "0.5.0"
5207+
resolved "https://registry.yarnpkg.com/mvdan-sh/-/mvdan-sh-0.5.0.tgz#fa76f611a103595ad0f04f5d18e582892c46e87c"
5208+
integrity sha512-UWbdl4LHd2fUnaEcOUFVWRdWGLkNoV12cKVIPiirYd8qM5VkCoCTXErlDubevrkEG7kGohvjRxAlTQmOqG80tw==
5209+
52055210
nan@^2.12.1:
52065211
version "2.14.2"
52075212
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.2.tgz#f5376400695168f4cc694ac9393d0c9585eeea19"
@@ -6306,7 +6311,14 @@ prettier-linter-helpers@^1.0.0:
63066311
dependencies:
63076312
fast-diff "^1.1.2"
63086313

6309-
prettier@^2.0.5:
6314+
prettier-plugin-sh@^0.6.0:
6315+
version "0.6.0"
6316+
resolved "https://registry.yarnpkg.com/prettier-plugin-sh/-/prettier-plugin-sh-0.6.0.tgz#021c22597a5a866c346095cd7f6c662a49dea249"
6317+
integrity sha512-y+SSThg/8mrGGkcAolWpociiTZlH7nlIUtqZl1dueyhngof8rD48tUHVQqvIaCx21T/0+9TyzsTEsVviPjR5og==
6318+
dependencies:
6319+
mvdan-sh "^0.5.0"
6320+
6321+
prettier@^2.2.1:
63106322
version "2.2.1"
63116323
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5"
63126324
integrity sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==

0 commit comments

Comments
 (0)