forked from seam-xyz/Miniapp-Builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseam-magic.sh
executable file
·129 lines (115 loc) · 6.68 KB
/
seam-magic.sh
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
echo "'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''',,,,,'''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''',;;;;;;:;''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''',;::,''''',::'''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''',;:;''''''''';c,''''''''''''''''''
.......''''''''.''''...'..''..',;:::;;,,cl;''.''.'...';:,'''''''......'''..
'''''''''''...'''''.''..'''';oOKXNNXXKKKNXd''''..''.'';:,''''''''''''.'''''
.................'......'.,dKWMMMWWWWMMMMWKc.'.....,;,cc'.'...'........''..
.........................,xNMMMMKdooddONMMWx,....,;:lodl;,'................
.........................cXMMMMNx::,..,oXWWKc....':oxkkdc;'................
.........................oNMMWWKd;'....'c0WNd'...';:oxoc;,'................
.........................lNMWW0kOkc,.....;ll;......,l:,,'..................
.........................;OWW0xKWWN0doc,...........;:'.....................
..........................:kOxKWMMMMMWN0dc'.......,:,......................
...........................:lkNWMMMMMMMMMNOc'....,:;.......................
.........................';c,,lkNWMMMMMMMMMNx,..':;........................
.........................;c,...':d0WWWWMMWMWWO;':;.........................
........................,c,.......,oKWWMMMMMMWkc;..........................
.......................,c;..........;lOWMMMMMMXl...........................
......................'::':o:.........;0MMMMMMXl...........................
......................;c';0WXo........'xMMMMMMXc...........................
.....................'c:.,OWWNd'......,kMWWMWWO,...........................
.....................;c'..oNMMNk:...,;dNMWWWWXc............................
....................'c:...;KMMMWN0xkKNWMMMMWKc.............................
....................,c;...'xWMMWWMMMWWMMMWKd;..............................
....................;c,....;dxolldO0Okkxoc,................................
....................;c,.........';:,'......................................
''''''''''''''''..'.,c;''''''',::;'.''..''''''''.'''''''''.'''.''''''''''''
''''''''''''''''''''':c;,,,;;:;,'''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''',;::;:;,,'''''''''''''''''''''''''''''''''''''''''''''
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,;;,,,,,,,;;,,,,;,,;;,,,,,,,;;,,,,,,,,,,,,,,,,,;;,,,,,,,,;,,,,,,,;,,,,,,
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
"
echo "Welcome to the Seam Miniapp Builder! Let's create a new miniapp together."
echo "[1/3] What's your Seam username? "
read -r username
echo "[2/3] What should your app be called?"
read -r name
# Extract the first word from the input
shortName=$(echo $name | awk '{print toupper(substr($1,1,1)) tolower(substr($1,2))}')
echo "[3/3] What's the description of your app?"
read -r description
echo "Awesome! Sewing your $name app together..."
# Add the new block to the types dictionary
output="src/blocks/types.tsx"
echo "$OSTYPE"
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sed -i -e '$ d' $output
elif [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' -e '$ d' $output
else
sed -i -e '$ d' $output
fi
echo " \"$shortName\": {
type: \"$shortName\",
displayName: \"$name\",
displayDescription: \"$description\",
icon: \"${shortName}Icon\", // TODO: insert your app icon here
deprecated: false,
doesBlockPost: true,
doesBlockEdit: true,
createdBy: \"$username\",
fullscreenEdit: false,
},
};" >> $output
echo "✅ Added $name to types.tsx"
# Create a template file for the new block
newBlock="src/blocks/${shortName}App.tsx"
cp "src/blocks/BlockTemplate.txt" $newBlock
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s/%NAME%/${shortName}/g" $newBlock
echo "✅ Created ${shortName}App.tsx for your new block"
else
sed -i "s/%NAME%/${shortName}/g" $newBlock
echo "✅ Created ${shortName}App.tsx for your new block"
fi
# Add the new block to the block factory
feedPlaceholder="\/\/ new feed components go here"
composerPlaceholder="\/\/ new composer components go here"
importBlock="import { ${shortName}FeedComponent, ${shortName}ComposerComponent } from \'./${shortName}App\'
"
newFeedComponentCase="case \"$shortName\": return \<${shortName}FeedComponent model={model} \/\>;\\n $feedPlaceholder"
newComposerComponentCase="case \"$shortName\": return ${shortName}ComposerComponent(props);\\n $composerPlaceholder"
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s/${feedPlaceholder}/${newFeedComponentCase}/g" "src/blocks/BlockFactory.tsx"
sed -i '' "s/${composerPlaceholder}/${newComposerComponentCase}/g" "src/blocks/BlockFactory.tsx"
sed -i '' '1i\
'"$importBlock"'
' "src/blocks/BlockFactory.tsx"
else
sed -i "s/${feedPlaceholder}/${newFeedComponentCase}/g" "src/blocks/BlockFactory.tsx"
sed -i "s/${composerPlaceholder}/${newComposerComponentCase}/g" "src/blocks/BlockFactory.tsx"
sed -i '1i\
'"$importBlock"'
' "src/blocks/BlockFactory.tsx"
fi
echo "✅ Added ${name} to the BlockFactory.tsx"
echo "
█████╗ ██████╗ ██████╗ ██████╗ ███████╗ █████╗ ██████╗ ██╗ ██╗██╗
██╔══██╗██╔══██╗██╔══██╗ ██╔══██╗██╔════╝██╔══██╗██╔══██╗╚██╗ ██╔╝██║
███████║██████╔╝██████╔╝ ██████╔╝█████╗ ███████║██║ ██║ ╚████╔╝ ██║
██╔══██║██╔═══╝ ██╔═══╝ ██╔══██╗██╔══╝ ██╔══██║██║ ██║ ╚██╔╝ ╚═╝
██║ ██║██║ ██║ ██║ ██║███████╗██║ ██║██████╔╝ ██║ ██╗
╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝
"
if [[ "$OSTYPE" == "darwin"* ]]; then
open $newBlock
fi
echo "When you're ready, run yarn start to see your block in action!"