forked from mint-lang/mint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscaffold.cr
91 lines (78 loc) · 1.88 KB
/
scaffold.cr
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
module Mint
class Scaffold
MAIN =
<<-MAIN
component Main {
style base {
font-family: sans;
font-weight: bold;
font-size: 50px;
justify-content: center;
align-items: center;
display: flex;
height: 100vh;
width: 100vw;
}
fun render : Html {
<div::base>
<{ "Hello Mint!" }>
</div>
}
}
MAIN
GIT_IGNORE =
<<-GIT_IGNORE
.mint
dist
GIT_IGNORE
TEST =
<<-TEST
suite "Main" {
test "Greets Mint" {
with Test.Html {
<Main/>
|> start()
|> assertTextOf("div", "Hello Mint!")
}
}
}
TEST
getter path, name
def self.run(name : String)
path = File.expand_path(name)
name = File.basename(path)
new(path, name).run
end
def initialize(@path : String, @name : String)
end
def run
terminal.print "#{COG} Creating directory structure...\n"
source_file_name = "source"
tests_file_name = "tests"
FileUtils.mkdir_p path
FileUtils.cd path
FileUtils.mkdir source_file_name if !File.exists? source_file_name
FileUtils.mkdir tests_file_name if !File.exists? tests_file_name
terminal.print "#{COG} Writing initial files...\n\n"
File.write(File.join(source_file_name, "Main.mint"), MAIN)
File.write(File.join(tests_file_name, "Main.mint"), TEST)
File.write("mint.json", json.to_pretty_json)
File.write(".gitignore", GIT_IGNORE)
Installer.new
end
def json
{
"name" => name,
"source-directories" => [
"source",
],
"test-directories" => [
"tests",
],
}
end
private def terminal
Render::Terminal::STDOUT
end
end
end