[feat] add run scripts

This commit is contained in:
jay 2023-02-26 23:48:36 +08:00
parent 2c9f2134cf
commit 279d90df27
5 changed files with 162 additions and 2 deletions

View File

@ -12,16 +12,19 @@
{{- $gitUser = promptString "gitUser" -}} {{- $gitUser = promptString "gitUser" -}}
{{- end -}} {{- end -}}
{{- $jsLinter := promptString "jsLinter" "js linter standard,eslint" -}} {{- $jsLinter := promptString "jsLinter" "standard" -}}
{{- if eq $jsLinter "" -}} {{- if eq $jsLinter "" -}}
{{- $jsLinter = "standard" -}} {{- $jsLinter = "standard" -}}
{{- end -}} {{- end -}}
{{- $jsFixer := promptString "jsFixer" "js fixer standard,prettier" -}} {{- $jsFixer := promptString "jsFixer" "standard" -}}
{{- if eq $jsFixer "" -}} {{- if eq $jsFixer "" -}}
{{- $jsFixer = "standard" -}} {{- $jsFixer = "standard" -}}
{{- end -}} {{- end -}}
{{- $installGo := promptBool "installGo" true -}}
{{- $installNode := promptBool "installNode" true -}}
[data.gitconfig] [data.gitconfig]
email = {{ $email | quote }} email = {{ $email | quote }}
username = {{ $gitUser | quote }} username = {{ $gitUser | quote }}
@ -29,3 +32,7 @@
[data.nvim] [data.nvim]
js_linter = {{ $jsLinter | quote }} js_linter = {{ $jsLinter | quote }}
js_fixer = {{ $jsFixer | quote }} js_fixer = {{ $jsFixer | quote }}
[data.dev]
golang = {{ $installGo }}
nodejs = {{ $installNode }}

View File

@ -0,0 +1,14 @@
#!/bin/bash
PATH="$HOME/apps/go/bin:$HOME/apps/node/bin:$PATH"
if command -v npm > /dev/null; then
npm i -g typescript typescript-language-server jsctags dockerfile-language-server-nodejs
fi
if command -v go > /dev/null; then
go install github.com/sourcegraph/go-langserver@latest
go install github.com/jstemmer/gotags@latest
go install github.com/cweill/gotests/gotests@latest
fi

View File

@ -0,0 +1,24 @@
#!/bin/bash
readonly wanted_packages=(
git
svn
zsh
nvim
tmux
curl
wget
)
missing_packages=()
for package in "${wanted_packages[@]}"; do
if ! command -v "${package}" > /dev/null ; then
missing_packages+=("${package}")
fi
done
if [[ ${#missing_packages[@]} -gt 0 ]]; then
>&2 echo "missing packages ${missing_packages[*]}"
exit 1
fi

View File

@ -0,0 +1,109 @@
#!/bin/bash
set -x
GO_VERSION="1.20.1"
NODE_VERSION="18.14.2"
ARCH="{{ .chezmoi.arch }}"
OSTYPE="{{ .chezmoi.os }}"
if [ ! -d "$HOME/apps" ]; then
if ! mkdir -p "$HOME/apps" ; then
>&2 echo "make directory failed"
exit 1
fi
fi
function install_golang {
local tmpDir=$(mktemp -d)
local url="https://go.dev/dl/go$GO_VERSION.$OSTYPE-$ARCH.tar.gz"
# download
if ! wget -O "$tmpDir/go.tar.gz" "$url" ; then
rm -rf "$tmpDir"
>&2 echo "download golang binary failed"
return 1
fi
if ! tar zxf "$tmpDir/go.tar.gz" -C "$tmpDir" ;then
rm -rf "$tmpDir"
>&2 echo "untar golang binary failed"
return 1
fi
mv "$tmpDir/go" "$HOME/apps/go-${GO_VERSION}"
ln -sf "$HOME/apps/go-${GO_VERSION}" "$HOME/apps/go"
rm -rf "$tmpDir"
}
function install_nodejs {
local tmpDir=$(mktemp -d)
local arch=""
case "$ARCH" in
"amd64")
arch="x64"
;;
"arm64")
arch="arm64"
;;
*)
>&2 echo "arch ($ARCH) not support"
return 1
;;
esac
local url="https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-${OSTYPE}-${arch}.tar.xz"
if ! wget -O "$tmpDir/node.tar.xz" "$url" ; then
rm -rf "$tmpDir"
>&2 echo "download nodejs binary failed"
return 1
fi
if ! tar xJf "$tmpDir/node.tar.xz" -C "$tmpDir" ; then
rm -rf "$tmpDir"
>&2 echo "untar nodejs binary failed"
return 1
fi
dirs=$(find "$tmpDir" -type d -mindepth 1 -maxdepth 1 -name 'node*')
mv "$dirs" "$HOME/apps/node-v${NODE_VERSION}"
ln -sf "$HOME/apps/node-v${NODE_VERSION}" "$HOME/apps/node"
rm -rf "$tmpDir"
}
function install_rust {
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --profile default -y
}
{{ if .dev.golang }}
echo "start install golang ${GO_VERSION}..."
if ! install_golang ; then
>&2 echo "install golang failed"
exit 1
fi
{{ end }}
{{ if .dev.nodejs }}
echo "start install nodejs v${NODE_VERSION}..."
if ! install_nodejs ; then
>&2 echo "install nodejs failed"
exit 1
fi
{{ end }}
{{ if .dev.rust }}
echo "start install rust..."
if ! install_rust ; then
>&2 echo "install rust failed"
exit 1
fi
{{ end }}

View File

@ -0,0 +1,6 @@
#!/bin/bash
if ! git clone https://github.com/zdharma-continuum/zinit.git ~/.zinit/bin; then
>&2 echo "clone zinit into ~/.zinit/bin failed"
exit 1
fi