-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathastro-starter
More file actions
executable file
·63 lines (47 loc) · 3.16 KB
/
astro-starter
File metadata and controls
executable file
·63 lines (47 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
set -eu -o pipefail # fail on error and report it, debug all lines
export GUM_SPIN_SPINNER=pulse
gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Welcome to $(gum style --foreground 212 'Astro Starter')."
NAME=$(gum input --char-limit=32 --placeholder "Pick a project name")
printf "Project $(gum style --foreground 212 "$NAME") initiated!"
sleep 2; clear
if [ $# -eq 0 ]; then
FETCH_TEMPLATES=$(gum spin --spinner pulse --title "Fetching list of Astro templates..." --show-output -- svn ls https://github.com/withastro/astro.git/branches/main/examples | grep "/$" | sed "s,/$,,")
TEMPLATE=$(gum choose $FETCH_TEMPLATES --height=20)
pnpm create astro@latest $NAME --no-install --git --typescript strict --template $TEMPLATE; clear
else
pnpm create astro@latest $NAME --no-install --git --typescript strict --template $1; clear
fi
cd $NAME
gum spin --title "Installing commit tools..." -- pnpm add -D husky commitizen cz-git @commitlint/{config-conventional,cli}
pnpm husky install && pnpm husky add .husky/commit-msg 'pnpm commitlint --edit ${1}'
npm pkg set scripts.prepare="husky install" scripts.cz="cz" config.commitizen.path="./node_modules/cz-git"
gum spin --title "Downloading commit configs..." -- svn export https://github.com/mdizo/dev-scripts.git/branches/main/astro/.commitlintrc.cjs . --force
git add .
git commit -m "chore: :hammer: add + configure tools for better commit messages"
ESLINT="eslint eslint-config-standard-with-typescript eslint-config-prettier"
ESLINT_PLUGINS=(eslint-plugin-{jsx-a11y,astro,prettier})
PRETTIER="prettier prettier-config-standard prettier-plugin-astro"
STYLELINT="stylelint stylelint-gamut stylelint-config-standard-scss stylelint-config-clean-order"
POSTCSS="postcss-html postcss-scss"
LANG="sass"
MISC="lint-staged"
gum spin --title "Setting up project tooling..." -- pnpm add -D $ESLINT ${ESLINT_PLUGINS[@]} $PRETTIER $STYLELINT $LANG $MISC $POSTCSS
gum spin --title "Downloading configs..." -- svn export https://github.com/mdizo/dev-scripts.git/branches/main/astro/ . --force
pnpm husky add .husky/pre-commit 'pnpm lint-staged'
npm pkg set browserslist[]="defaults and supports es6-module" browserslist[]="maintained node versions"
npm pkg set scripts.lint:format="prettier --write \"**/*.{js,jsx,ts,tsx,md,mdx,astro,css,scss}\""
npm pkg set scripts.lint:js="eslint --fix \"src/**/*.{js,ts,jsx,tsx,astro}\""
npm pkg set scripts.lint:css="stylelint --cache --fix \"src/**/*.{astro,css,scss}\""
npm pkg set scripts.lint="pnpm lint:format && pnpm lint:js && pnpm lint:css"
npm pkg set scripts.build-types="tsc --noEmit --pretty"
echo -e '\n# lint cache\n.eslintcache\n.stylelintcache' >> .gitignore
# inject readme
cp README.md 02-copy.md
cat 01-inject-readme.md 02-copy.md > README.md && rm 01-inject-readme.md 02-copy.md
pnpm astro sync # build astro types
pnpm prettier -w ".*.{cjs,mjs}" "*.config.{cjs,mjs}" "**/*.{js,jsx,ts,tsx,md,mdx,astro,css,scss}" # format project files
pnpm stylelint "**/*.{astro,css,scss}" --fix # autofix style formatting
git add .
git commit -m "chore: :hammer: add + configure lang and linters to enforce code styles" --no-verify # commit without hooks
git branch -m master main