Last active
April 3, 2022 09:10
-
-
Save malted/884377fc51fc92f64c3eb9f02b0d5278 to your computer and use it in GitHub Desktop.
Initialise a Sveltekit project & push to a new repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -d "$1" ]; then # If the directory exists | |
if [ "$(ls -A $1)" ]; then | |
# The directory exists & contains files | |
echo "$1 is not empty. Exiting." | |
exit 0 | |
else | |
# The directory exists & is empty | |
rmdir $1 | |
fi | |
fi | |
if [ -z $1 ]; then | |
echo "Project name not specified. Exiting." | |
exit 0 | |
fi | |
echo "Enter your Github username: " # Require all user input at the start of the script. I'm looking at you, yay. | |
read usr | |
npm init svelte@next $1 | |
cd $1 | |
npm install | |
npm install -D @sveltejs/adapter-static@next | |
echo "import adapter from '@sveltejs/adapter-static'; | |
export default { | |
kit: { | |
adapter: adapter({ | |
// default options are shown | |
pages: 'build', | |
assets: 'build', | |
fallback: null | |
}) | |
} | |
}; | |
" >| svelte.config.js | |
# You may or may not want to do this. The build directory is listed in the gitignore anyway. | |
#npm run build | |
if [ "`curl https://github.com/repos/$usr/$1`" = "Not Found" ]; then | |
gh repo create $1 --public --confirm | |
rm -rf $1 # the confirm flag creates unneeded git init files. It is only being used to not present a prompt for the user. | |
fi | |
if [ -d "$1/.git" ]; then | |
rm -rf $1/.git; | |
fi | |
git init | |
git add * | |
git commit -m "Initial commit" | |
git branch -M main | |
git remote add origin "https://github.com/$usr/$1.git" | |
git push -u origin main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment