raithon-cli 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/raithon/cli/version.rb +1 -3
- data/lib/raithon/cli.rb +137 -0
- data/lib/raithon.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4102124070611cb8cf29ae580fa97fe6e2fd4663be7d5cd0e49a1830fa5c2434
|
|
4
|
+
data.tar.gz: edf3b2a574443bb3df5fc8a0955012941ffb3dc66d29966904c644dfa31855f1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c3345c06eb6c7eec6d66117e205d2a56ef5516d047180e09453f893b2550a4239a7aa0ba8ef1a399a078ed8e2aa791d4eb7cf89a5b8fede31d48b56f5c9c5d44
|
|
7
|
+
data.tar.gz: 8df15393e41b39e47f72415ddd4b81e90fe79f0879014ab2523b8fae1226e78f8f7e0bea3229bb784b8847a1159889869f399468d4574cda6e93b41a2b51eb7f
|
data/lib/raithon/cli/version.rb
CHANGED
data/lib/raithon/cli.rb
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "thor"
|
|
4
|
+
require "fileutils"
|
|
5
|
+
require "raithon-core"
|
|
6
|
+
|
|
7
|
+
module Raithon
|
|
8
|
+
class CLI < Thor
|
|
9
|
+
desc "new APP_NAME", "Create a new Raithon application"
|
|
10
|
+
def new(app_name)
|
|
11
|
+
@app_name = app_name
|
|
12
|
+
|
|
13
|
+
say "Creating Raithon app: #{app_name}"
|
|
14
|
+
create_structure
|
|
15
|
+
say "Application #{app_name} created successfully."
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def app_path(*paths)
|
|
21
|
+
File.join(@app_name, *paths)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def create_structure
|
|
25
|
+
create_root
|
|
26
|
+
create_app_folders
|
|
27
|
+
create_config_files
|
|
28
|
+
create_lib_file
|
|
29
|
+
create_gitignore
|
|
30
|
+
create_gemfile
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def create_root
|
|
34
|
+
FileUtils.mkdir_p(@app_name)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def create_app_folders
|
|
38
|
+
%w[
|
|
39
|
+
app/controllers
|
|
40
|
+
app/models
|
|
41
|
+
app/views
|
|
42
|
+
config
|
|
43
|
+
lib
|
|
44
|
+
].each do |path|
|
|
45
|
+
FileUtils.mkdir_p(app_path(path))
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
File.write(
|
|
49
|
+
app_path("app/controllers/application_controller.rb"),
|
|
50
|
+
<<~RUBY
|
|
51
|
+
# frozen_string_literal: true
|
|
52
|
+
|
|
53
|
+
class ApplicationController
|
|
54
|
+
def index
|
|
55
|
+
"Welcome to Raithon!"
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
RUBY
|
|
59
|
+
)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def create_config_files
|
|
63
|
+
File.write(
|
|
64
|
+
app_path("config/application.rb"),
|
|
65
|
+
<<~RUBY
|
|
66
|
+
# frozen_string_literal: true
|
|
67
|
+
|
|
68
|
+
require "raithon-core"
|
|
69
|
+
|
|
70
|
+
module #{camelize(@app_name)}
|
|
71
|
+
class Application < Raithon::Core::Application
|
|
72
|
+
def boot
|
|
73
|
+
puts "Booting \#{self.class.name}..."
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
RUBY
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
File.write(
|
|
81
|
+
app_path("config/routes.rb"),
|
|
82
|
+
<<~RUBY
|
|
83
|
+
# frozen_string_literal: true
|
|
84
|
+
|
|
85
|
+
# Define your routes here
|
|
86
|
+
#
|
|
87
|
+
# Example:
|
|
88
|
+
# get "/", to: "application#index"
|
|
89
|
+
RUBY
|
|
90
|
+
)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def create_lib_file
|
|
94
|
+
File.write(
|
|
95
|
+
app_path("lib/#{@app_name}.rb"),
|
|
96
|
+
<<~RUBY
|
|
97
|
+
# frozen_string_literal: true
|
|
98
|
+
|
|
99
|
+
module #{camelize(@app_name)}
|
|
100
|
+
# Your Raithon app code goes here
|
|
101
|
+
end
|
|
102
|
+
RUBY
|
|
103
|
+
)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def create_gitignore
|
|
107
|
+
File.write(
|
|
108
|
+
app_path(".gitignore"),
|
|
109
|
+
<<~TXT
|
|
110
|
+
/log/*
|
|
111
|
+
/tmp/*
|
|
112
|
+
.env
|
|
113
|
+
TXT
|
|
114
|
+
)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def create_gemfile
|
|
118
|
+
File.write(
|
|
119
|
+
app_path("Gemfile"),
|
|
120
|
+
<<~RUBY
|
|
121
|
+
# frozen_string_literal: true
|
|
122
|
+
|
|
123
|
+
source "https://rubygems.org"
|
|
124
|
+
|
|
125
|
+
gem "raithon-core", "~> 0.1.0"
|
|
126
|
+
RUBY
|
|
127
|
+
)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# ----------------------------
|
|
131
|
+
# Helpers
|
|
132
|
+
# ----------------------------
|
|
133
|
+
def camelize(str)
|
|
134
|
+
str.split("_").map(&:capitalize).join
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
data/lib/raithon.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: raithon-cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sensei James
|
|
@@ -50,6 +50,7 @@ files:
|
|
|
50
50
|
- bin/raithon
|
|
51
51
|
- lib/raithon-cli.rb
|
|
52
52
|
- lib/raithon.rb
|
|
53
|
+
- lib/raithon/cli.rb
|
|
53
54
|
- lib/raithon/cli/cli.rb
|
|
54
55
|
- lib/raithon/cli/version.rb
|
|
55
56
|
homepage: https://rubygems.org/gems/raithon-cli
|