-
Notifications
You must be signed in to change notification settings - Fork 0
/
init
executable file
·55 lines (45 loc) · 1.41 KB
/
init
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
#!/usr/bin/env bash
set -e
only_repo=$(echo $GITHUB_REPOSITORY | cut -d'/' -f2)
shard_name=${only_repo%.cr}
snek_name=$(echo $shard_name | sed 's/-/_/g')
constant_name=$(echo $shard_name | sed -r 's/(^|_|-)([a-z])/\U\2/g')
echo "Deleting template specific files"
rm -f README.md LICENSE
echo "Merging template with crystal init lib"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config user.name "${GITHUB_ACTOR}"
crystal init lib $snek_name
cp -rn $snek_name/* .
cp -rn $snek_name/.?* .
rm -rf $snek_name/
echo "Fixing Github Reference in README.md"
sed -i "s~github:.*~github: ${GITHUB_REPOSITORY}~" README.md
sed -i "s~your-github-user/\w*~${GITHUB_REPOSITORY}~" README.md
sed -i "s~your-github-user~${GITHUB_ACTOR}~" README.md
echo "Adding default dependencies to shard.yml"
cat <<EOF >> shard.yml
dependencies:
habitat:
github: luckyframework/habitat
development_dependencies:
ameba:
github: crystal-ameba/ameba
version: ~> 0.14
spectator:
github: icy-arctic-fox/spectator
version: ~> 0.10
EOF
echo "Installing spectator to specs"
echo 'require "spectator"' >> spec/spec_helper.cr
cat <<EOF > spec/${snek_name}_spec.cr
require "./spec_helper"
Spectator.describe ${constant_name} do
it "should have a version" do
expect(${constant_name}::VERSION).to be_a(String)
end
end
EOF
echo "Removing install specific files"
rm -f .github/workflows/init.yml
rm -f .github/workflows/init