Archived
1
0

Format and lint

This commit is contained in:
Anmol Sethi
2020-02-14 19:46:00 -05:00
parent 80b1b1b672
commit 4aa15401c3
31 changed files with 260 additions and 141 deletions

View File

@ -26,7 +26,7 @@ class Builder {
this.ensureArgument("rootPath", this.rootPath)
this.codeServerVersion = this.ensureArgument(
"codeServerVersion",
process.env.VERSION || require(path.join(this.rootPath, "package.json")).version
process.env.VERSION || require(path.join(this.rootPath, "package.json")).version,
)
}
@ -208,7 +208,7 @@ class Builder {
await Promise.all([
fs.move(
path.join(this.vscodeSourcePath, `out-vscode${process.env.MINIFY ? "-min" : ""}`),
path.join(vscodeBuildPath, "out")
path.join(vscodeBuildPath, "out"),
),
fs.copy(path.join(this.vscodeSourcePath, ".build/extensions"), path.join(vscodeBuildPath, "extensions")),
])
@ -225,7 +225,7 @@ class Builder {
return Promise.all(
["node_modules", "package.json", "yarn.lock"].map((fileName) => {
return fs.copy(path.join(sourcePath, fileName), path.join(buildPath, fileName))
})
}),
)
})
@ -240,8 +240,8 @@ class Builder {
...merge,
},
null,
2
)
2,
),
)
})
@ -290,7 +290,7 @@ class Builder {
await fs.copyFile(path.join(this.vscodeSourcePath, "LICENSE.txt"), path.join(archivePath, "LICENSE.txt"))
await fs.copyFile(
path.join(this.vscodeSourcePath, "ThirdPartyNotices.txt"),
path.join(archivePath, "ThirdPartyNotices.txt")
path.join(archivePath, "ThirdPartyNotices.txt"),
)
if ((await this.target()) === "darwin") {

View File

@ -3,15 +3,35 @@
set -euo pipefail
main() {
shfmt -i 2 -w -s -sr $$(git ls-files "*.sh")
prettier --write --loglevel=warn $$(git ls-files "*.js" "*.ts" "*.tsx" "*.html" "*.json" "*.css" "*.md" "*.toml" "*.yaml" "*.yml")
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 " make fmt"
exit 1
fi
if [[ ${CI-} ]]; then
cd "$(dirname "$0")/.."
./ci/vscode.sh
fi
shfmt -i 2 -w -s -sr $(git ls-files "*.sh")
local prettierExts
prettierExts=(
"*.js"
"*.ts"
"*.tsx"
"*.html"
"*.json"
"*.css"
"*.md"
"*.toml"
"*.yaml"
"*.yml"
)
prettier --write --loglevel=warn $(git ls-files "${prettierExts[@]}")
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"
exit 1
fi
}
main "$@"

View File

@ -9,4 +9,7 @@ RUN curl -L https://github.com/mvdan/sh/releases/download/v3.0.1/shfmt_v3.0.1_li
COPY entrypoint.sh /bin/entrypoint.sh
ENV PAGER=cat
ENV CI=true
ENTRYPOINT ["dumb-init", "/bin/entrypoint.sh"]

View File

@ -3,8 +3,14 @@
set -euo pipefail
main() {
eslint --max-warnings=0 --fix $$(git ls-files "*.ts" "*.tsx" "*.js")
stylelint --fix $$(git ls-files "*.css")
if [[ ${CI-} ]]; then
cd "$(dirname "$0")/.."
./ci/vscode.sh
fi
eslint --max-warnings=0 --fix $(git ls-files "*.ts" "*.tsx" "*.js")
stylelint --fix $(git ls-files "*.css")
tsc --noEmit
}
main "$@"

View File

@ -8,7 +8,7 @@ function main() {
cd "$(dirname "${0}")/.."
local code_server_version=${VERSION:-${TRAVIS_TAG:-${DRONE_TAG:-}}}
if [[ -z $code_server_version ]] ; then
if [[ -z $code_server_version ]]; then
code_server_version=$(grep version ./package.json | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[:space:]')
fi
export VERSION=$code_server_version
@ -17,33 +17,33 @@ function main() {
export YARN_CACHE_FOLDER
# Always minify and package on tags since that's when releases are pushed.
if [[ -n ${DRONE_TAG:-} || -n ${TRAVIS_TAG:-} ]] ; then
if [[ -n ${DRONE_TAG:-} || -n ${TRAVIS_TAG:-} ]]; then
export MINIFY="true"
export PACKAGE="true"
fi
yarn build
yarn binary
if [[ -n ${PACKAGE:-} ]] ; then
if [[ -n ${PACKAGE:-} ]]; then
yarn package
fi
cd binaries
if [[ -n ${STRIP_BIN_TARGET:-} ]] ; then
if [[ -n ${STRIP_BIN_TARGET:-} ]]; then
# In this case provide plainly named binaries.
for binary in code-server* ; do
for binary in code-server*; do
echo "Moving $binary to code-server"
mv "$binary" code-server
done
elif [[ -n ${DRONE_TAG:-} || -n ${TRAVIS_TAG:-} ]] ; then
elif [[ -n ${DRONE_TAG:-} || -n ${TRAVIS_TAG:-} ]]; then
# Prepare directory for uploading binaries on release.
for binary in code-server* ; do
for binary in code-server*; do
mkdir -p "../binary-upload"
local prefix="code-server-$code_server_version-"
local target="${binary#$prefix}"
if [[ $target == "linux-x86_64" ]] ; then
if [[ $target == "linux-x86_64" ]]; then
echo "Copying $binary to ../binary-upload/latest-linux"
cp "$binary" "../binary-upload/latest-linux"
fi

View File

@ -1,6 +1,4 @@
{
"extends": "../tsconfig.json",
"include": [
"./**/*.ts"
]
"include": ["./**/*.ts"]
}

View File

@ -10,7 +10,7 @@ main() {
git submodule update --init
# If the patch fails to apply, then it's likely already applied
yarn vscode:patch &>/dev/null || true
yarn vscode:patch &> /dev/null || true
# Install VS Code dependencies.
(cd lib/vscode && yarn)