blix-cli 0.1.1
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 +7 -0
- data/LICENSE +21 -0
- data/README.md +31 -0
- data/bin/blix +5 -0
- data/lib/blix/cli.rb +20 -0
- data/lib/blix/cli/application.rb +191 -0
- data/lib/blix/cli/commands.rb +41 -0
- data/lib/blix/cli/operation.rb +58 -0
- data/lib/blix/cli/operations/command.rb +40 -0
- data/lib/blix/cli/operations/directory.rb +28 -0
- data/lib/blix/cli/operations/file.rb +37 -0
- data/lib/blix/cli/operations/null.rb +28 -0
- data/lib/blix/cli/version.rb +5 -0
- data/templates/Gemfile +33 -0
- data/templates/Guardfile +51 -0
- data/templates/README.md +1 -0
- data/templates/app-application.rb +28 -0
- data/templates/app-controllers-application_controller.rb +15 -0
- data/templates/app-views-layouts-application.html.erb +44 -0
- data/templates/app-views-welcome.html.erb +7 -0
- data/templates/assets-css-application.scss +5 -0
- data/templates/assets-js-application.js +21 -0
- data/templates/assets-js-application.webpack.js +19 -0
- data/templates/assets-js-components-app.vue +7 -0
- data/templates/bin-bundle +74 -0
- data/templates/bin-console +9 -0
- data/templates/config-application.yml +6 -0
- data/templates/config.ru +44 -0
- data/templates/features-application.feature +6 -0
- data/templates/features-support-setup.rb +16 -0
- data/templates/webpack.config.js +43 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 88694f58ecd0d9eb180dc327de01eec27f298898e3f181a65da05671c2228583
|
4
|
+
data.tar.gz: be7908719094dbb3788715e9bc8f77087a6c3f96400bef4d48ffa920c9208eb3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2a925258c78bc9343ae4be13e222354af6c51a32cb7d0fd8d3c8f2d578032e6929910b86d13e2e31e485724cb18d32deb10f8cdc7252fcf18caa4db4e6fffc5b
|
7
|
+
data.tar.gz: 002310f1df39eb2e658e026054d4024c1b254cab2156cf86c5ca95b7dfb6d576ed9cc620a1a5644ec9914fd647d6147c9b9ea7b6b2ff6bfe7ade4436368c2576
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Clive Andrews
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Blix::Cli
|
2
|
+
|
3
|
+
This provides the `blix` command which allows a blix REST framework environment to be
|
4
|
+
created and updated.
|
5
|
+
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'blix-cli'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install blix-cli
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
commands:
|
26
|
+
|
27
|
+
$ blix help # help information
|
28
|
+
|
29
|
+
$ blix new appname # create a new blix application in directory appname
|
30
|
+
|
31
|
+
$ blix update # update application
|
data/bin/blix
ADDED
data/lib/blix/cli.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
|
5
|
+
module Blix
|
6
|
+
module Cli
|
7
|
+
class Error < StandardError; end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
require_relative 'cli/version'
|
13
|
+
require_relative 'cli/operation'
|
14
|
+
require_relative 'cli/operations/null'
|
15
|
+
require_relative 'cli/operations/directory'
|
16
|
+
require_relative 'cli/operations/file'
|
17
|
+
require_relative 'cli/operations/command'
|
18
|
+
require_relative 'cli/application'
|
19
|
+
|
20
|
+
require_relative 'cli/commands'
|
@@ -0,0 +1,191 @@
|
|
1
|
+
require 'open3'
|
2
|
+
require 'liquid'
|
3
|
+
|
4
|
+
module Blix
|
5
|
+
module Cli
|
6
|
+
|
7
|
+
|
8
|
+
class Application
|
9
|
+
|
10
|
+
DIR_LIST = %w(
|
11
|
+
app assets config doc features lib bin spec www
|
12
|
+
app/controllers app/managers app/models app/views app/views/layouts
|
13
|
+
assets/css assets/js
|
14
|
+
config/assets
|
15
|
+
features/support
|
16
|
+
www/assets
|
17
|
+
)
|
18
|
+
|
19
|
+
FILE_LIST = %w(
|
20
|
+
app/application.rb
|
21
|
+
app/controllers/application_controller.rb
|
22
|
+
app/views/layouts/application.html.erb
|
23
|
+
app/views/welcome.html.erb
|
24
|
+
assets/css/application.scss
|
25
|
+
assets/js/application.js
|
26
|
+
config/application.yml
|
27
|
+
features/support/setup.rb
|
28
|
+
features/application.feature
|
29
|
+
config.ru
|
30
|
+
Gemfile
|
31
|
+
README.md
|
32
|
+
Guardfile
|
33
|
+
bin/console
|
34
|
+
bin/bundle
|
35
|
+
)
|
36
|
+
|
37
|
+
WEBPACK_FILES = %w(
|
38
|
+
webpack.config.js
|
39
|
+
assets/js/application.webpack.js
|
40
|
+
)
|
41
|
+
|
42
|
+
VUE_FILES = %w(
|
43
|
+
assets/js/components/app.vue
|
44
|
+
)
|
45
|
+
|
46
|
+
TEMPLATE_DIR = File.absolute_path(File.dirname(__FILE__) + '/../../../templates')
|
47
|
+
|
48
|
+
attr_reader :options, :root
|
49
|
+
|
50
|
+
def initialize(root, options={})
|
51
|
+
@root = root
|
52
|
+
@options = Thor::CoreExt::HashWithIndifferentAccess.new.merge options
|
53
|
+
@options[:vuebasic] = options[:vue] && !options[:webpack]
|
54
|
+
end
|
55
|
+
|
56
|
+
# ensure that the directory exists.
|
57
|
+
def ensure_directory(name)
|
58
|
+
path = File.join(root,name)
|
59
|
+
if File.exist?(path)
|
60
|
+
if File.directory?(path)
|
61
|
+
NullOperation.new("have directory #{path}")
|
62
|
+
else
|
63
|
+
raise Error, "cannot create directory:#{path}"
|
64
|
+
end
|
65
|
+
else
|
66
|
+
DirectoryOperation.new(path)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def get_template(name)
|
71
|
+
template_name = name.gsub('/','-')
|
72
|
+
template_path = File.join(TEMPLATE_DIR,template_name)
|
73
|
+
if File.file?( template_path )
|
74
|
+
File.read( template_path )
|
75
|
+
template = Liquid::Template.parse(File.read( template_path ))
|
76
|
+
template.render(options)
|
77
|
+
else
|
78
|
+
nil
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# ensure that the file exists.
|
83
|
+
def ensure_file(name)
|
84
|
+
path = File.join(root,name)
|
85
|
+
new_contents = get_template(name)
|
86
|
+
if File.exist?(path)
|
87
|
+
if File.file?(path)
|
88
|
+
old_contents = File.read(path)
|
89
|
+
if (old_contents != new_contents) && (options[:overwrite] || confirm("overwrite file #{path}"))
|
90
|
+
FileOperation.new(path, new_contents )
|
91
|
+
else
|
92
|
+
NullOperation.new("have file #{path}")
|
93
|
+
end
|
94
|
+
else
|
95
|
+
raise Error, "cannot create file:#{path}"
|
96
|
+
end
|
97
|
+
else
|
98
|
+
FileOperation.new(path, new_contents )
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def check_command(name, version=nil)
|
103
|
+
std, err, stat = Open3.capture3("#{name} --version")
|
104
|
+
raise Error, err unless stat.success?
|
105
|
+
raise Error, "need #{name} version #{version} or higher" if version && (std < version)
|
106
|
+
true
|
107
|
+
end
|
108
|
+
|
109
|
+
VALID_RESPONSE = ['yes','y','no','n']
|
110
|
+
|
111
|
+
def confirm(message)
|
112
|
+
return true if options[:y]
|
113
|
+
resp = nil
|
114
|
+
loop do
|
115
|
+
print message + '? (y/n): '
|
116
|
+
resp = VALID_RESPONSE.index $stdin.gets.chomp.strip.downcase
|
117
|
+
break if resp
|
118
|
+
end
|
119
|
+
resp < 2 # the yes responses.
|
120
|
+
end
|
121
|
+
|
122
|
+
# add a node package unless it exists.
|
123
|
+
def node_package(package)
|
124
|
+
if File.exist? File.join(root,'node_modules',package)
|
125
|
+
NullOperation.new("have node package #{package}")
|
126
|
+
else
|
127
|
+
CommandOperation.new(root, "npm install #{package} --save-dev", "install #{package}")
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
# setup webpack
|
132
|
+
# npm init -y # created package.json file
|
133
|
+
# npm install webpack webpack-cli --save-dev
|
134
|
+
# npm install coffeescript coffee-loader --save-dev
|
135
|
+
#
|
136
|
+
def webpack
|
137
|
+
|
138
|
+
check_command("node", '4.0.0')
|
139
|
+
check_command("npm", '6.0.0')
|
140
|
+
|
141
|
+
CommandOperation.new(root, 'npm init -y', 'initialise node.js') unless File.exist?(File.join(root,'package.json'))
|
142
|
+
node_package('webpack')
|
143
|
+
node_package('webpack-cli')
|
144
|
+
node_package('coffeescript')
|
145
|
+
node_package('coffee-loader')
|
146
|
+
|
147
|
+
|
148
|
+
if options[:vue]
|
149
|
+
node_package('vue')
|
150
|
+
node_package('vue-template-compiler')
|
151
|
+
node_package('vue-loader')
|
152
|
+
node_package('vue-style-loader')
|
153
|
+
node_package('vue-router')
|
154
|
+
node_package('css-loader')
|
155
|
+
node_package('sass-loader')
|
156
|
+
ensure_directory('assets/js/components')
|
157
|
+
VUE_FILES.sort.each{|p| ensure_file(p) }
|
158
|
+
end
|
159
|
+
|
160
|
+
WEBPACK_FILES.sort.each{|p| ensure_file(p) }
|
161
|
+
end
|
162
|
+
|
163
|
+
# generate a new application framework
|
164
|
+
def framework
|
165
|
+
ensure_directory('')
|
166
|
+
DIR_LIST.sort.each{|p| ensure_directory(p) }
|
167
|
+
FILE_LIST.sort.each{|p| ensure_file(p) }
|
168
|
+
CommandOperation.new(File.join(root,'bin'), 'chmod a+x *', 'set permissions on bin dir')
|
169
|
+
end
|
170
|
+
|
171
|
+
# setup the environment for the given options.
|
172
|
+
def setup
|
173
|
+
framework
|
174
|
+
|
175
|
+
if options[:webpack]
|
176
|
+
webpack
|
177
|
+
end
|
178
|
+
|
179
|
+
if (options[:'dry-run'])
|
180
|
+
puts "dry run .."
|
181
|
+
Operation.describe_all
|
182
|
+
else
|
183
|
+
Operation.execute_all
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
module Blix
|
3
|
+
module Cli
|
4
|
+
class Commands < Thor
|
5
|
+
|
6
|
+
desc 'new NAME', 'create a new blix application'
|
7
|
+
option :'dry-run', :type => :boolean, :desc=>'do not perform any updates to the system'
|
8
|
+
option :overwrite, :type => :boolean, :desc=>'overwrite files if they already exist!'
|
9
|
+
option :webpack, :type => :boolean, :desc=>'initialize webpack environment'
|
10
|
+
option :vue, :type => :boolean, :desc=>'initialize vue.js environment'
|
11
|
+
option :y, :type => :boolean, :desc=>'answer yes to all confirm prompts'
|
12
|
+
|
13
|
+
def new(name)
|
14
|
+
|
15
|
+
raise Error, "invalid path" unless name =~ /^[a-zA-Z_\-\.0-9]+$/
|
16
|
+
|
17
|
+
app = Application.new(name, options)
|
18
|
+
app.setup
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
#-------------------------------------------------------------------------
|
23
|
+
|
24
|
+
desc 'update', 'update an application directory'
|
25
|
+
option :'dry-run', :type => :boolean, :desc=>'do not perform any updates to the system'
|
26
|
+
option :overwrite, :type => :boolean, :desc=>'overwrite files if they already exist!'
|
27
|
+
option :webpack, :type => :boolean, :desc=>'initialize webpack environment'
|
28
|
+
option :vue, :type => :boolean, :desc=>'initialize vue.js environment'
|
29
|
+
option :y, :type => :boolean, :desc=>'answer yes to all confirm prompts'
|
30
|
+
|
31
|
+
def update
|
32
|
+
|
33
|
+
app = Application.new('.', options)
|
34
|
+
app.setup
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Blix
|
2
|
+
module Cli
|
3
|
+
|
4
|
+
class Operation
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def list
|
8
|
+
@@_list ||= []
|
9
|
+
end
|
10
|
+
|
11
|
+
def reset!
|
12
|
+
list.clear
|
13
|
+
end
|
14
|
+
|
15
|
+
def execute_all
|
16
|
+
list.each(&:perform)
|
17
|
+
end
|
18
|
+
|
19
|
+
def describe_all
|
20
|
+
list.each(&:describe)
|
21
|
+
end
|
22
|
+
|
23
|
+
alias :old_new :new
|
24
|
+
|
25
|
+
def new(*args)
|
26
|
+
|
27
|
+
o = old_new(*args)
|
28
|
+
self.list << o
|
29
|
+
o
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
def description
|
35
|
+
''
|
36
|
+
end
|
37
|
+
|
38
|
+
def describe
|
39
|
+
puts description
|
40
|
+
end
|
41
|
+
|
42
|
+
def perform
|
43
|
+
puts description
|
44
|
+
run
|
45
|
+
end
|
46
|
+
|
47
|
+
def run
|
48
|
+
end
|
49
|
+
|
50
|
+
def undo
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
|
4
|
+
module Blix
|
5
|
+
module Cli
|
6
|
+
|
7
|
+
# create a file system directory
|
8
|
+
class CommandOperation < Operation
|
9
|
+
|
10
|
+
attr_reader :path, :command
|
11
|
+
|
12
|
+
def initialize(path, command, desc)
|
13
|
+
@path = path
|
14
|
+
@command = command
|
15
|
+
@desc = desc
|
16
|
+
end
|
17
|
+
|
18
|
+
def description
|
19
|
+
@desc || "run command: #{command}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def run
|
23
|
+
Dir.chdir(path) do
|
24
|
+
std, err, stat = Open3.capture3("#{command}")
|
25
|
+
unless stat.success?
|
26
|
+
puts "----------------------------------------"
|
27
|
+
puts err
|
28
|
+
puts "----------------------------------------"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def undo
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Blix
|
2
|
+
module Cli
|
3
|
+
|
4
|
+
# create a file system directory
|
5
|
+
class DirectoryOperation < Operation
|
6
|
+
|
7
|
+
attr_reader :path
|
8
|
+
|
9
|
+
def initialize(path)
|
10
|
+
@path = path
|
11
|
+
end
|
12
|
+
|
13
|
+
def description
|
14
|
+
"create directory #{path}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def run
|
18
|
+
Dir.mkdir(path)
|
19
|
+
end
|
20
|
+
|
21
|
+
def undo
|
22
|
+
Dir.rmdir(path)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Blix
|
2
|
+
module Cli
|
3
|
+
|
4
|
+
# create a file system directory
|
5
|
+
class FileOperation < Operation
|
6
|
+
|
7
|
+
attr_reader :path, :content
|
8
|
+
|
9
|
+
def initialize(path, content, overwrite=false)
|
10
|
+
@path = path
|
11
|
+
@content = content
|
12
|
+
@overwrite = overwrite
|
13
|
+
end
|
14
|
+
|
15
|
+
def description
|
16
|
+
str = if File.file?(path)
|
17
|
+
"overwrite file "
|
18
|
+
else
|
19
|
+
"create file "
|
20
|
+
end
|
21
|
+
str += path
|
22
|
+
str += "*" if content
|
23
|
+
str
|
24
|
+
end
|
25
|
+
|
26
|
+
def run
|
27
|
+
File.write(path, content || '')
|
28
|
+
end
|
29
|
+
|
30
|
+
def undo
|
31
|
+
#File.unlink(path)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Blix
|
2
|
+
module Cli
|
3
|
+
|
4
|
+
# create a file system directory
|
5
|
+
class NullOperation < Operation
|
6
|
+
|
7
|
+
attr_reader :message
|
8
|
+
|
9
|
+
def initialize(message)
|
10
|
+
@message = message
|
11
|
+
end
|
12
|
+
|
13
|
+
def description
|
14
|
+
message
|
15
|
+
end
|
16
|
+
|
17
|
+
def run
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
def undo
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
data/templates/Gemfile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem "json"
|
4
|
+
gem "puma"
|
5
|
+
gem "blix-rest"
|
6
|
+
gem "blix-assets"
|
7
|
+
|
8
|
+
|
9
|
+
# test / development gems
|
10
|
+
group :development do
|
11
|
+
gem 'rspec'
|
12
|
+
gem 'rack-test', :require=>"rack/test"
|
13
|
+
gem 'cucumber'
|
14
|
+
|
15
|
+
# support the asset pipeline
|
16
|
+
gem 'sprockets' , "~> 4.x"
|
17
|
+
gem 'therubyracer'
|
18
|
+
gem 'execjs'
|
19
|
+
gem 'sass' # for compression
|
20
|
+
gem 'sassc'
|
21
|
+
gem 'uglifier'
|
22
|
+
gem 'autoprefixer-rails' , "~> 8.x"
|
23
|
+
gem 'coffee-script'
|
24
|
+
gem 'guard' , require: false
|
25
|
+
gem 'guard-livereload' , require: false
|
26
|
+
gem "rack-livereload"
|
27
|
+
{%- if vuebasic %}
|
28
|
+
gem 'vue-compiler'
|
29
|
+
{%- endif %}
|
30
|
+
{%- if webpack %}
|
31
|
+
gem 'sprockets-webpackit'
|
32
|
+
{%- endif %}
|
33
|
+
end
|
data/templates/Guardfile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# More info at https://github.com/guard/guard#readme
|
2
|
+
|
3
|
+
## Uncomment and set this to only include directories you want to watch
|
4
|
+
# directories %w(app lib config test spec features)
|
5
|
+
|
6
|
+
## Uncomment to clear the screen before every task
|
7
|
+
# clearing :on
|
8
|
+
|
9
|
+
## Guard internally checks for changes in the Guardfile and exits.
|
10
|
+
## If you want Guard to automatically start up again, run guard in a
|
11
|
+
## shell loop, e.g.:
|
12
|
+
##
|
13
|
+
## $ while bundle exec guard; do echo "Restarting Guard..."; done
|
14
|
+
##
|
15
|
+
## Note: if you are using the `directories` clause above and you are not
|
16
|
+
## watching the project directory ('.'), then you will want to move
|
17
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
18
|
+
#
|
19
|
+
# $ mkdir config
|
20
|
+
# $ mv Guardfile config/
|
21
|
+
# $ ln -s config/Guardfile .
|
22
|
+
#
|
23
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
guard 'livereload' do
|
28
|
+
|
29
|
+
|
30
|
+
# application server code
|
31
|
+
|
32
|
+
watch(%r{app/views/.+\.(erb|haml|slim)$})
|
33
|
+
watch(%r{app/(controllers|models|managers)/.+\.rb})
|
34
|
+
watch(%r{lib/.+\.rb})
|
35
|
+
|
36
|
+
|
37
|
+
# Assets Pipeline
|
38
|
+
|
39
|
+
watch(%r{assets/\w+/(.+\.(scss|css|js|html|png|jpg|coffee|hbs|es6|ts|vue)).*}) { |m| "/assets/#{m[3]}" }
|
40
|
+
|
41
|
+
# resources
|
42
|
+
|
43
|
+
watch(%r{www/.+\.(css|js|html)})
|
44
|
+
|
45
|
+
# configuration
|
46
|
+
|
47
|
+
{%- if webpack %}
|
48
|
+
watch(%r{webpack.config.js})
|
49
|
+
{%- endif %}
|
50
|
+
|
51
|
+
end
|
data/templates/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Document your Application here
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'blix/rest'
|
4
|
+
require 'blix/utils'
|
5
|
+
require 'blix/assets'
|
6
|
+
|
7
|
+
require_relative 'controllers/application_controller.rb'
|
8
|
+
|
9
|
+
class Application
|
10
|
+
|
11
|
+
VERSION = '0.1.1'
|
12
|
+
|
13
|
+
class << self
|
14
|
+
|
15
|
+
# get the application configuration as specified in the
|
16
|
+
# configuration yml file.
|
17
|
+
def config
|
18
|
+
@config ||= Blix::YamlConfig.new(:name => 'application')
|
19
|
+
end
|
20
|
+
|
21
|
+
# perform any initialization for your application here .. eg set up your
|
22
|
+
# database.
|
23
|
+
|
24
|
+
def initialize(*args); end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class ApplicationController < Blix::Rest::Controller
|
2
|
+
|
3
|
+
get '/version' do
|
4
|
+
{ :version=>Application::VERSION }
|
5
|
+
end
|
6
|
+
|
7
|
+
get '/welcome' , :accept=>:html do
|
8
|
+
render_erb :welcome, :layout=>'layouts/application'
|
9
|
+
end
|
10
|
+
|
11
|
+
get '/*', :accept=>:html do
|
12
|
+
redirect_to path_for('/welcome')
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html class="no-js" lang="">
|
3
|
+
|
4
|
+
<head>
|
5
|
+
<meta charset="utf-8">
|
6
|
+
<title>My Blix Application</title>
|
7
|
+
<meta name="description" content="">
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
9
|
+
|
10
|
+
<meta property="og:title" content="">
|
11
|
+
<meta property="og:type" content="">
|
12
|
+
<meta property="og:url" content="">
|
13
|
+
<meta property="og:image" content="">
|
14
|
+
|
15
|
+
<link rel="manifest" href="site.webmanifest">
|
16
|
+
<link rel="apple-touch-icon" href="icon.png">
|
17
|
+
<!-- Place favicon.ico in the root directory -->
|
18
|
+
|
19
|
+
<!-- CSS -->
|
20
|
+
<%= asset_tag('/assets/application.css') %>
|
21
|
+
|
22
|
+
<meta name="theme-color" content="#fafafa">
|
23
|
+
</head>
|
24
|
+
|
25
|
+
<body>
|
26
|
+
|
27
|
+
<!-- Add your site or application content here -->
|
28
|
+
|
29
|
+
<%= yield %>
|
30
|
+
|
31
|
+
<!-- Scripts-->
|
32
|
+
<script>
|
33
|
+
rootUrl="<%= full_path('/')%>";
|
34
|
+
</script>
|
35
|
+
{%- if vuebasic %}
|
36
|
+
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
|
37
|
+
{%- endif %}
|
38
|
+
<%= asset_tag('/assets/application.js') %>
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
</body>
|
43
|
+
|
44
|
+
</html>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
{%- if webpack -%}
|
2
|
+
//= require application.webpack.js
|
3
|
+
{%- else -%}
|
4
|
+
// application javascript here
|
5
|
+
{%- endif %}
|
6
|
+
//
|
7
|
+
|
8
|
+
{%- if vuebasic %}
|
9
|
+
{% raw %}
|
10
|
+
|
11
|
+
|
12
|
+
var app = new Vue({
|
13
|
+
el: '#app',
|
14
|
+
template:'<h1>{{ message }}</h1>',
|
15
|
+
data: {
|
16
|
+
message: 'Welcome to Basic Blix Vue!'
|
17
|
+
}
|
18
|
+
})
|
19
|
+
|
20
|
+
{% endraw %}
|
21
|
+
{%- endif %}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
// this is the starting point for your application webpack bundle
|
2
|
+
|
3
|
+
{% if vue -%}
|
4
|
+
|
5
|
+
{% raw %}
|
6
|
+
|
7
|
+
import Vue from 'vue/dist/vue.common.js'
|
8
|
+
import App from './components/app.vue'
|
9
|
+
|
10
|
+
new Vue({
|
11
|
+
el: '#app',
|
12
|
+
template:'<h1>{{ message }}</h1>',
|
13
|
+
data: {
|
14
|
+
message: 'Welcome to Blix Vue Application!'
|
15
|
+
}
|
16
|
+
})
|
17
|
+
|
18
|
+
{% endraw %}
|
19
|
+
{% endif %}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
ROOT = ::File.expand_path('../..', __FILE__)
|
4
|
+
ENV['RACK_ENV'] = 'production'
|
5
|
+
|
6
|
+
|
7
|
+
# add all your assets to be compiled to this list
|
8
|
+
|
9
|
+
ASSETS = %w(
|
10
|
+
application.js
|
11
|
+
application.css
|
12
|
+
)
|
13
|
+
|
14
|
+
# if your application is mounted under a path in the live environment
|
15
|
+
# then enter the path here.
|
16
|
+
|
17
|
+
MOUNT_PATH = ''
|
18
|
+
|
19
|
+
DEST = 'www/assets'
|
20
|
+
|
21
|
+
|
22
|
+
require 'bundler'
|
23
|
+
Bundler.setup(:default, :development)
|
24
|
+
|
25
|
+
require 'sprockets'
|
26
|
+
require 'blix/assets'
|
27
|
+
require 'uglifier'
|
28
|
+
|
29
|
+
{%- if vuebasic %}
|
30
|
+
require 'vue/sprockets'
|
31
|
+
Vue::Compiler.set_options :version => '2.6'
|
32
|
+
VueSprocketsCompiler.set_root %w[app]
|
33
|
+
{%- endif %}
|
34
|
+
|
35
|
+
{%- if webpack %}
|
36
|
+
require 'sprockets/webpackit'
|
37
|
+
{%- endif %}
|
38
|
+
|
39
|
+
environment = Sprockets::Environment.new
|
40
|
+
|
41
|
+
require "autoprefixer-rails"
|
42
|
+
|
43
|
+
environment.append_path 'assets/js'
|
44
|
+
environment.append_path 'assets/css'
|
45
|
+
|
46
|
+
environment.js_compressor = Uglifier.new(:harmony => true)
|
47
|
+
environment.css_compressor = :scss
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
AutoprefixerRails.install(environment)
|
52
|
+
|
53
|
+
Blix::AssetManager.set_path_root( MOUNT_PATH )
|
54
|
+
|
55
|
+
ASSETS.each do |name|
|
56
|
+
print "processing #{name} ...."
|
57
|
+
|
58
|
+
str = environment[name].to_s
|
59
|
+
|
60
|
+
if File.extname(name) == ".css"
|
61
|
+
engine = Sass::Engine.new(str, :syntax => :scss, :style => :compressed)
|
62
|
+
str = engine.render
|
63
|
+
end
|
64
|
+
|
65
|
+
Blix::AssetManager.write_asset(DEST,name,str)
|
66
|
+
puts "done"
|
67
|
+
end
|
68
|
+
|
69
|
+
# SW_FILE = "sw.js"
|
70
|
+
# SW_DEST = File.join(Dir.pwd,"www")
|
71
|
+
#
|
72
|
+
# print "processing service worker : #{SW_FILE} ...."
|
73
|
+
# File.write( File.join(SW_DEST,SW_FILE),environment[SW_FILE].to_s)
|
74
|
+
# puts "done"
|
data/templates/config.ru
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
MODE = ENV['RACK_ENV']
|
2
|
+
|
3
|
+
require_relative 'app/application'
|
4
|
+
|
5
|
+
Application.initialize
|
6
|
+
|
7
|
+
if MODE=='production'
|
8
|
+
|
9
|
+
use Rack::Static, :urls => ['/static', '/assets'], :root => 'www'
|
10
|
+
|
11
|
+
elsif MODE=='development'
|
12
|
+
|
13
|
+
puts 'development mode'
|
14
|
+
|
15
|
+
require 'rack-livereload'
|
16
|
+
require 'sprockets'
|
17
|
+
|
18
|
+
{%- if vuebasic %}
|
19
|
+
require 'vue/sprockets'
|
20
|
+
Vue::Compiler.set_options :version => '2.6'
|
21
|
+
VueSprocketsCompiler.set_root %w[app]
|
22
|
+
{%- endif %}
|
23
|
+
|
24
|
+
{%- if webpack %}
|
25
|
+
require 'sprockets/webpackit'
|
26
|
+
{%- endif %}
|
27
|
+
|
28
|
+
use Rack::Static, :urls => ['/static'], :root => 'www'
|
29
|
+
use Rack::Reloader
|
30
|
+
use Rack::LiveReload, :no_swf=>true
|
31
|
+
|
32
|
+
map '/assets' do
|
33
|
+
environment = Sprockets::Environment.new
|
34
|
+
environment.append_path 'assets/js'
|
35
|
+
environment.append_path 'assets/css'
|
36
|
+
|
37
|
+
run environment
|
38
|
+
end
|
39
|
+
|
40
|
+
else # test
|
41
|
+
;
|
42
|
+
end
|
43
|
+
|
44
|
+
run Blix::Rest::Server.new
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.setup(:default, :test)
|
3
|
+
|
4
|
+
require 'blix/rest/cucumber'
|
5
|
+
require_relative '../../app/application'
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
# the application get loaded from config.ru automatically
|
10
|
+
# when the first test is run.
|
11
|
+
|
12
|
+
# need to setup the database here and not in config.ru for
|
13
|
+
# the tests because we need it setup for the clear database
|
14
|
+
# hook which is run before the first test.
|
15
|
+
|
16
|
+
Application.initialize
|
@@ -0,0 +1,43 @@
|
|
1
|
+
const path = require('path');
|
2
|
+
|
3
|
+
{% if vue -%}
|
4
|
+
const VueLoaderPlugin = require('vue-loader/lib/plugin');
|
5
|
+
{% endif %}
|
6
|
+
|
7
|
+
module.exports = {
|
8
|
+
module: {
|
9
|
+
rules: [
|
10
|
+
{
|
11
|
+
test: /\.coffee$/,
|
12
|
+
loader: 'coffee-loader',
|
13
|
+
},
|
14
|
+
{% if vue -%}
|
15
|
+
{
|
16
|
+
test: /\.vue$/,
|
17
|
+
loader: 'vue-loader'
|
18
|
+
},
|
19
|
+
{
|
20
|
+
test: /\.css$/,
|
21
|
+
use: [
|
22
|
+
'vue-style-loader',
|
23
|
+
'css-loader'
|
24
|
+
]
|
25
|
+
},
|
26
|
+
{
|
27
|
+
test: /\.scss$/,
|
28
|
+
use: [
|
29
|
+
'vue-style-loader',
|
30
|
+
'css-loader',
|
31
|
+
'sass-loader'
|
32
|
+
]
|
33
|
+
},
|
34
|
+
{% endif %}
|
35
|
+
],
|
36
|
+
},
|
37
|
+
{% if vue -%}
|
38
|
+
plugins: [
|
39
|
+
new VueLoaderPlugin()
|
40
|
+
]
|
41
|
+
{% endif %}
|
42
|
+
|
43
|
+
};
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: blix-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Clive Andrews
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-09-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: liquid
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Command line utilities for blix framework
|
56
|
+
email:
|
57
|
+
- gems@realitybites.eu
|
58
|
+
executables:
|
59
|
+
- blix
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files:
|
62
|
+
- README.md
|
63
|
+
- LICENSE
|
64
|
+
files:
|
65
|
+
- LICENSE
|
66
|
+
- README.md
|
67
|
+
- bin/blix
|
68
|
+
- lib/blix/cli.rb
|
69
|
+
- lib/blix/cli/application.rb
|
70
|
+
- lib/blix/cli/commands.rb
|
71
|
+
- lib/blix/cli/operation.rb
|
72
|
+
- lib/blix/cli/operations/command.rb
|
73
|
+
- lib/blix/cli/operations/directory.rb
|
74
|
+
- lib/blix/cli/operations/file.rb
|
75
|
+
- lib/blix/cli/operations/null.rb
|
76
|
+
- lib/blix/cli/version.rb
|
77
|
+
- templates/Gemfile
|
78
|
+
- templates/Guardfile
|
79
|
+
- templates/README.md
|
80
|
+
- templates/app-application.rb
|
81
|
+
- templates/app-controllers-application_controller.rb
|
82
|
+
- templates/app-views-layouts-application.html.erb
|
83
|
+
- templates/app-views-welcome.html.erb
|
84
|
+
- templates/assets-css-application.scss
|
85
|
+
- templates/assets-js-application.js
|
86
|
+
- templates/assets-js-application.webpack.js
|
87
|
+
- templates/assets-js-components-app.vue
|
88
|
+
- templates/bin-bundle
|
89
|
+
- templates/bin-console
|
90
|
+
- templates/config-application.yml
|
91
|
+
- templates/config.ru
|
92
|
+
- templates/features-application.feature
|
93
|
+
- templates/features-support-setup.rb
|
94
|
+
- templates/webpack.config.js
|
95
|
+
homepage: https://github.com/realbite/blix-cli
|
96
|
+
licenses:
|
97
|
+
- MIT
|
98
|
+
metadata: {}
|
99
|
+
post_install_message:
|
100
|
+
rdoc_options: []
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
requirements: []
|
114
|
+
rubygems_version: 3.1.4
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: Command line utilities for managing blix framework environments
|
118
|
+
test_files: []
|