From 3eafcf94b78eef86db9d4e4f95f945761130567b Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Mon, 15 Mar 2021 15:13:44 -0700 Subject: [PATCH 1/3] refactor: remove shfmt --- ci/dev/fmt.sh | 2 -- ci/images/centos7/Dockerfile | 1 - ci/images/debian10/Dockerfile | 1 - docs/CONTRIBUTING.md | 20 ++++++++++---------- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/ci/dev/fmt.sh b/ci/dev/fmt.sh index 139c0ea0..cd589954 100755 --- a/ci/dev/fmt.sh +++ b/ci/dev/fmt.sh @@ -4,8 +4,6 @@ set -euo pipefail main() { cd "$(dirname "$0")/../.." - shfmt -i 2 -w -sr $(git ls-files "*.sh" | grep -v "lib/vscode") - local prettierExts prettierExts=( "*.js" diff --git a/ci/images/centos7/Dockerfile b/ci/images/centos7/Dockerfile index a37e590b..3a82dcf7 100644 --- a/ci/images/centos7/Dockerfile +++ b/ci/images/centos7/Dockerfile @@ -26,7 +26,6 @@ ENV PATH=/usr/local/go/bin:$GOPATH/bin:$PATH # Install Go dependencies ENV GO111MODULE=on -RUN go get mvdan.cc/sh/v3/cmd/shfmt RUN go get github.com/goreleaser/nfpm/cmd/nfpm@v1.9.0 RUN curl -fsSL https://get.docker.com | sh diff --git a/ci/images/debian10/Dockerfile b/ci/images/debian10/Dockerfile index 5e4a5f85..20977641 100644 --- a/ci/images/debian10/Dockerfile +++ b/ci/images/debian10/Dockerfile @@ -42,7 +42,6 @@ ENV PATH=/usr/local/go/bin:$GOPATH/bin:$PATH # Install Go dependencies ENV GO111MODULE=on -RUN go get mvdan.cc/sh/v3/cmd/shfmt RUN go get github.com/goreleaser/nfpm/cmd/nfpm@v1.9.0 RUN VERSION="$(curl -fsSL https://storage.googleapis.com/kubernetes-release/release/stable.txt)" && \ diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 98c88d1b..5f9d6133 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -2,15 +2,16 @@ # Contributing -- [Pull Requests](#pull-requests) -- [Requirements](#requirements) -- [Development Workflow](#development-workflow) - - [Updating VS Code](#updating-vs-code) - - [Notes about Changes](#notes-about-changes) -- [Build](#build) -- [Structure](#structure) - - [Modifications to VS Code](#modifications-to-vs-code) - - [Currently Known Issues](#currently-known-issues) +- [Contributing](#contributing) + - [Pull Requests](#pull-requests) + - [Requirements](#requirements) + - [Development Workflow](#development-workflow) + - [Updating VS Code](#updating-vs-code) + - [Notes about Changes](#notes-about-changes) + - [Build](#build) + - [Structure](#structure) + - [Modifications to VS Code](#modifications-to-vs-code) + - [Currently Known Issues](#currently-known-issues) @@ -36,7 +37,6 @@ There are several differences, however. You must: - Use Node.js version 12.x (or greater) - Have [yarn](https://classic.yarnpkg.com/en/) installed (which is used to install JS packages and run development scripts) - 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 -- Have [shfmt](https://pkg.go.dev/mvdan.cc/sh/v3) installed to run `yarn fmt` (requires Go is installed on your system) The [CI container](../ci/images/debian10/Dockerfile) is a useful reference for all of the dependencies code-server uses. From 0ba53b6adf917097258105455cbc1b580d7a6d9e Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Mon, 15 Mar 2021 15:14:26 -0700 Subject: [PATCH 2/3] feat: add prettier-plugin-sh --- ci/dev/fmt.sh | 1 + package.json | 3 ++- yarn.lock | 14 +++++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ci/dev/fmt.sh b/ci/dev/fmt.sh index cd589954..4e9464fd 100755 --- a/ci/dev/fmt.sh +++ b/ci/dev/fmt.sh @@ -16,6 +16,7 @@ main() { "*.toml" "*.yaml" "*.yml" + "*.sh" ) prettier --write --loglevel=warn $( git ls-files "${prettierExts[@]}" | grep -v "lib/vscode" | grep -v 'helm-chart' diff --git a/package.json b/package.json index 033a3f73..9df7b19f 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,8 @@ "istanbul-badges-readme": "^1.2.0", "leaked-handles": "^5.2.0", "parcel-bundler": "^1.12.4", - "prettier": "^2.0.5", + "prettier": "^2.2.1", + "prettier-plugin-sh": "^0.6.0", "stylelint": "^13.0.0", "stylelint-config-recommended": "^3.0.0", "ts-node": "^9.0.0", diff --git a/yarn.lock b/yarn.lock index 3b6246e3..5cfd19cb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5202,6 +5202,11 @@ ms@2.1.2: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== +mvdan-sh@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/mvdan-sh/-/mvdan-sh-0.5.0.tgz#fa76f611a103595ad0f04f5d18e582892c46e87c" + integrity sha512-UWbdl4LHd2fUnaEcOUFVWRdWGLkNoV12cKVIPiirYd8qM5VkCoCTXErlDubevrkEG7kGohvjRxAlTQmOqG80tw== + nan@^2.12.1: version "2.14.2" resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.2.tgz#f5376400695168f4cc694ac9393d0c9585eeea19" @@ -6306,7 +6311,14 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier@^2.0.5: +prettier-plugin-sh@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/prettier-plugin-sh/-/prettier-plugin-sh-0.6.0.tgz#021c22597a5a866c346095cd7f6c662a49dea249" + integrity sha512-y+SSThg/8mrGGkcAolWpociiTZlH7nlIUtqZl1dueyhngof8rD48tUHVQqvIaCx21T/0+9TyzsTEsVviPjR5og== + dependencies: + mvdan-sh "^0.5.0" + +prettier@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5" integrity sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q== From d05389880ac35c538acf3c4c0f2d66a86853efe9 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Mon, 15 Mar 2021 15:36:31 -0700 Subject: [PATCH 3/3] chore: update formatting w/new prettier sh plugin --- ci/build/build-packages.sh | 2 +- ci/build/build-release.sh | 10 +++++----- ci/build/build-standalone-release.sh | 2 +- ci/build/code-server.sh | 6 +++--- ci/build/release-github-draft.sh | 2 +- ci/dev/fmt.sh | 14 +++++++------- ci/dev/gen_icons.sh | 4 ++-- ci/dev/lint.sh | 2 +- ci/dev/update-vscode.sh | 6 +++--- ci/lib.sh | 6 +++--- ci/release-image/entrypoint.sh | 2 +- ci/steps/build-docker-image.sh | 2 +- ci/steps/publish-npm.sh | 2 +- docs/CONTRIBUTING.md | 19 +++++++++---------- install.sh | 12 ++++++------ 15 files changed, 45 insertions(+), 46 deletions(-) diff --git a/ci/build/build-packages.sh b/ci/build/build-packages.sh index a5ef794e..06f78aff 100755 --- a/ci/build/build-packages.sh +++ b/ci/build/build-packages.sh @@ -40,7 +40,7 @@ release_gcp() { # Generates deb and rpm packages. release_nfpm() { local nfpm_config - nfpm_config="$(envsubst < ./ci/build/nfpm.yaml)" + nfpm_config="$(envsubst <./ci/build/nfpm.yaml)" # The underscores are convention for .deb. nfpm pkg -f <(echo "$nfpm_config") --target "release-packages/code-server_${VERSION}_$ARCH.deb" diff --git a/ci/build/build-release.sh b/ci/build/build-release.sh index a806dc98..c3136712 100755 --- a/ci/build/build-release.sh +++ b/ci/build/build-release.sh @@ -49,7 +49,7 @@ bundle_code_server() { # Adds the commit to package.json jq --slurp '.[0] * .[1]' package.json <( - cat << EOF + cat < "$RELEASE_PATH/package.json" + ) >"$RELEASE_PATH/package.json" rsync yarn.lock "$RELEASE_PATH" rsync ci/build/npm-postinstall.sh "$RELEASE_PATH/postinstall.sh" @@ -89,18 +89,18 @@ bundle_vscode() { # Adds the commit and date to product.json jq --slurp '.[0] * .[1]' "$VSCODE_SRC_PATH/product.json" <( - cat << EOF + cat < "$VSCODE_OUT_PATH/product.json" + ) >"$VSCODE_OUT_PATH/product.json" # We remove the scripts field so that later on we can run # yarn to fetch node_modules if necessary without build scripts running. # We cannot use --no-scripts because we still want dependent package scripts to run. - jq 'del(.scripts)' < "$VSCODE_SRC_PATH/package.json" > "$VSCODE_OUT_PATH/package.json" + jq 'del(.scripts)' <"$VSCODE_SRC_PATH/package.json" >"$VSCODE_OUT_PATH/package.json" pushd "$VSCODE_OUT_PATH" symlink_asar diff --git a/ci/build/build-standalone-release.sh b/ci/build/build-standalone-release.sh index df6cdc56..e85678a2 100755 --- a/ci/build/build-standalone-release.sh +++ b/ci/build/build-standalone-release.sh @@ -12,7 +12,7 @@ main() { # we use the same version it's using so we instead run a script with yarn that # will print the path to node. local node_path - node_path="$(yarn -s node <<< 'console.info(process.execPath)')" + node_path="$(yarn -s node <<<'console.info(process.execPath)')" mkdir -p "$RELEASE_PATH/bin" rsync ./ci/build/code-server.sh "$RELEASE_PATH/bin/code-server" diff --git a/ci/build/code-server.sh b/ci/build/code-server.sh index deb36ac3..cb71c182 100755 --- a/ci/build/code-server.sh +++ b/ci/build/code-server.sh @@ -11,9 +11,9 @@ _realpath() { cd "$(dirname "$script")" while [ -L "$(basename "$script")" ]; do - if [ -L "./node" ] && [ -L "./code-server" ] && - [ -f "package.json" ] && - cat package.json | grep -q '^ "name": "code-server",$'; then + if [ -L "./node" ] && [ -L "./code-server" ] \ + && [ -f "package.json" ] \ + && cat package.json | grep -q '^ "name": "code-server",$'; then echo "***** Please use the script in bin/code-server instead!" >&2 echo "***** This script will soon be removed!" >&2 echo "***** See the release notes at https://github.com/cdr/code-server/releases/tag/v3.4.0" >&2 diff --git a/ci/build/release-github-draft.sh b/ci/build/release-github-draft.sh index 28bbb301..fb4e9720 100755 --- a/ci/build/release-github-draft.sh +++ b/ci/build/release-github-draft.sh @@ -10,7 +10,7 @@ main() { hub release create \ --file - \ -t "$(git rev-parse HEAD)" \ - --draft "v$VERSION" << EOF + --draft "v$VERSION" < /dev/null - doctoc --title '# Setup Guide' docs/guide.md > /dev/null - doctoc --title '# Install' docs/install.md > /dev/null - doctoc --title '# npm Install Requirements' docs/npm.md > /dev/null - doctoc --title '# Contributing' docs/CONTRIBUTING.md > /dev/null - doctoc --title '# Contributor Covenant Code of Conduct' docs/CODE_OF_CONDUCT.md > /dev/null - doctoc --title '# iPad' docs/ipad.md > /dev/null + 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 + doctoc --title '# npm Install Requirements' docs/npm.md >/dev/null + doctoc --title '# Contributing' docs/CONTRIBUTING.md >/dev/null + doctoc --title '# Contributor Covenant Code of Conduct' docs/CODE_OF_CONDUCT.md >/dev/null + doctoc --title '# iPad' docs/ipad.md >/dev/null if [[ ${CI-} && $(git ls-files --other --modified --exclude-standard) ]]; then echo "Files need generation or are formatted incorrectly:" diff --git a/ci/dev/gen_icons.sh b/ci/dev/gen_icons.sh index 9d27486d..7617d5e6 100755 --- a/ci/dev/gen_icons.sh +++ b/ci/dev/gen_icons.sh @@ -35,10 +35,10 @@ main() { # This escapes all newlines so that sed will accept them. favicon_dark_style="$(printf "%s\n" "$favicon_dark_style" | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\\n/g')" sed "$( - cat -n << EOF + cat -n < favicon-dark-support.svg + )" favicon.svg >favicon-dark-support.svg } main "$@" diff --git a/ci/dev/lint.sh b/ci/dev/lint.sh index 9ba576e0..1a0c7d20 100755 --- a/ci/dev/lint.sh +++ b/ci/dev/lint.sh @@ -8,7 +8,7 @@ main() { stylelint $(git ls-files "*.css" | grep -v "lib/vscode") tsc --noEmit --skipLibCheck shellcheck -e SC2046,SC2164,SC2154,SC1091,SC1090,SC2002 $(git ls-files "*.sh" | grep -v "lib/vscode") - if command -v helm && helm kubeval --help > /dev/null; then + if command -v helm && helm kubeval --help >/dev/null; then helm kubeval ci/helm-chart fi diff --git a/ci/dev/update-vscode.sh b/ci/dev/update-vscode.sh index 0c05a490..285eabd0 100755 --- a/ci/dev/update-vscode.sh +++ b/ci/dev/update-vscode.sh @@ -33,7 +33,7 @@ main() { # Check if the remote exists # if it doesn't, we add it - if ! git config remote.vscode.url > /dev/null; then + if ! git config remote.vscode.url >/dev/null; then echo "Could not find 'vscode' as a remote" echo "Adding with: git remote add vscode https://github.com/microsoft/vscode.git" git remote add vscode https://github.com/microsoft/vscode.git @@ -52,7 +52,7 @@ main() { fi # Check that they have jq installed - if ! command -v jq &> /dev/null; then + if ! command -v jq &>/dev/null; then echo "jq could not be found." echo "We use this when looking up the exact version to update to in the package.json in VS Code." echo -e "See docs here: https://stedolan.github.io/jq/download/" @@ -71,7 +71,7 @@ main() { git fetch vscode # Check if GitHub CLI is installed - if ! command -v gh &> /dev/null; then + if ! command -v gh &>/dev/null; then echo "GitHub CLI could not be found." echo "If you install it before you run this script next time, we'll open a draft PR for you!" echo -e "See docs here: https://github.com/cli/cli#installation\n" diff --git a/ci/lib.sh b/ci/lib.sh index 96a413f1..cebc3d75 100755 --- a/ci/lib.sh +++ b/ci/lib.sh @@ -2,11 +2,11 @@ set -euo pipefail pushd() { - builtin pushd "$@" > /dev/null + builtin pushd "$@" >/dev/null } popd() { - builtin popd > /dev/null + builtin popd >/dev/null } pkg_json_version() { @@ -75,7 +75,7 @@ download_artifact() { local tmp_file tmp_file="$(mktemp)" - curl -fsSL "$(get_artifact_url "$artifact_name")" > "$tmp_file" + curl -fsSL "$(get_artifact_url "$artifact_name")" >"$tmp_file" unzip -q -o "$tmp_file" -d "$dst" rm "$tmp_file" } diff --git a/ci/release-image/entrypoint.sh b/ci/release-image/entrypoint.sh index 48a17a31..1c8c8bff 100755 --- a/ci/release-image/entrypoint.sh +++ b/ci/release-image/entrypoint.sh @@ -6,7 +6,7 @@ set -eu eval "$(fixuid -q)" if [ "${DOCKER_USER-}" ] && [ "$DOCKER_USER" != "$USER" ]; then - echo "$DOCKER_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/nopasswd > /dev/null + echo "$DOCKER_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/nopasswd >/dev/null # Unfortunately we cannot change $HOME as we cannot move any bind mounts # nor can we bind mount $HOME into a new home as that requires a privileged container. sudo usermod --login "$DOCKER_USER" coder diff --git a/ci/steps/build-docker-image.sh b/ci/steps/build-docker-image.sh index 16653a0e..8ae5855b 100755 --- a/ci/steps/build-docker-image.sh +++ b/ci/steps/build-docker-image.sh @@ -8,7 +8,7 @@ main() { ./ci/release-image/build.sh mkdir -p release-images - docker save "codercom/code-server-$ARCH:$VERSION" > "release-images/code-server-$ARCH-$VERSION.tar" + docker save "codercom/code-server-$ARCH:$VERSION" >"release-images/code-server-$ARCH-$VERSION.tar" } main "$@" diff --git a/ci/steps/publish-npm.sh b/ci/steps/publish-npm.sh index 7bd497d0..934a5dec 100755 --- a/ci/steps/publish-npm.sh +++ b/ci/steps/publish-npm.sh @@ -6,7 +6,7 @@ main() { source ./ci/lib.sh if [[ ${CI-} ]]; then - echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc + echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >~/.npmrc fi download_artifact npm-package ./release-npm-package diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 5f9d6133..15c997fd 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -2,16 +2,15 @@ # Contributing -- [Contributing](#contributing) - - [Pull Requests](#pull-requests) - - [Requirements](#requirements) - - [Development Workflow](#development-workflow) - - [Updating VS Code](#updating-vs-code) - - [Notes about Changes](#notes-about-changes) - - [Build](#build) - - [Structure](#structure) - - [Modifications to VS Code](#modifications-to-vs-code) - - [Currently Known Issues](#currently-known-issues) +- [Pull Requests](#pull-requests) +- [Requirements](#requirements) +- [Development Workflow](#development-workflow) + - [Updating VS Code](#updating-vs-code) + - [Notes about Changes](#notes-about-changes) +- [Build](#build) +- [Structure](#structure) + - [Modifications to VS Code](#modifications-to-vs-code) + - [Currently Known Issues](#currently-known-issues) diff --git a/install.sh b/install.sh index 0b37747c..6da274a3 100755 --- a/install.sh +++ b/install.sh @@ -13,7 +13,7 @@ usage() { " fi - cath << EOF + cath < /dev/null + command -v "$@" >/dev/null } sh_c() { @@ -571,7 +571,7 @@ prefix() { fifo="$(mktemp -d)/fifo" mkfifo "$fifo" sed -e "s#^#$PREFIX: #" "$fifo" & - "$@" > "$fifo" 2>&1 + "$@" >"$fifo" 2>&1 } main "$@"