xnlogic 1.0.12 → 1.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/xnlogic/cli/application.rb +103 -20
- data/lib/xnlogic/cli.rb +42 -11
- data/lib/xnlogic/version.rb +1 -1
- metadata +45 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 299ab70034659023e913de149bca9617c4bba1a3
|
4
|
+
data.tar.gz: 2c7e6a3c380a1f52280c0fcd173a448ee7d91afb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9089d3094f283cf5e518733bf95a8c6a6c1601d0c8c533092e8c1faeb45f2616e524bad5e15fbb91fa419a656b05a33076b63ef00d70e90cf996337acf470052
|
7
|
+
data.tar.gz: 05b1e39cc0b4c0b8c123d3e3b3cd7e13058fbf26bdecac89963227a7931e203c2277af67bb5eb1268a08e3d7b1f13d32fba8e1077a3bd89aa5482589e66c646f
|
@@ -1,26 +1,101 @@
|
|
1
1
|
require 'pathname'
|
2
|
+
require 'yaml'
|
2
3
|
|
3
4
|
module Xnlogic
|
4
5
|
class CLI::Application
|
5
6
|
attr_reader :options, :app_name, :thor, :base_name, :name, :app, :root
|
6
7
|
|
7
|
-
def initialize(options,
|
8
|
-
@options = options
|
8
|
+
def initialize(options, thor)
|
9
|
+
@options = {}.merge options
|
9
10
|
@app_name = app_name
|
10
11
|
@thor = thor
|
12
|
+
end
|
11
13
|
|
14
|
+
def set_name(app_name)
|
12
15
|
@name = app_name.chomp("/").tr('-', '_') # remove trailing slash if present
|
13
16
|
@root = options.fetch('root', @name)
|
14
17
|
@app = Pathname.pwd.join(root)
|
18
|
+
options[:name] = @name
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
def options_file
|
23
|
+
app + 'config/app_options.yaml'
|
24
|
+
end
|
25
|
+
|
26
|
+
def in_existing_project
|
27
|
+
@root = options.fetch('root', '.')
|
28
|
+
@app = Pathname.pwd.join(root)
|
29
|
+
if options_file.exist?
|
30
|
+
previous_options = YAML.load_file(options_file.to_s)
|
31
|
+
@options = previous_options.merge options
|
32
|
+
@name ||= options[:name]
|
33
|
+
self
|
34
|
+
else
|
35
|
+
Xnlogic.ui.info "Not in an existing project. Please run the 'application' command first."
|
36
|
+
exit 1
|
37
|
+
end
|
15
38
|
end
|
16
39
|
|
17
|
-
def
|
40
|
+
def write_options
|
41
|
+
File.open(options_file.to_s, 'w') do |f|
|
42
|
+
f.puts YAML.dump options
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def application
|
47
|
+
generate_vm_config unless options[:vm_config]
|
48
|
+
generate_application
|
49
|
+
write_options
|
50
|
+
Xnlogic.ui.info "Initializing git repo in #{app}"
|
51
|
+
Dir.chdir(app) { `git init`; `git add .` }
|
52
|
+
|
53
|
+
install_vagrant_note
|
54
|
+
Xnlogic.ui.info ""
|
55
|
+
Xnlogic.ui.info "To start your VM, run the following:"
|
56
|
+
Xnlogic.ui.info ""
|
57
|
+
Xnlogic.ui.info "cd #{root}"
|
58
|
+
Xnlogic.ui.info "vagrant up"
|
59
|
+
Xnlogic.ui.info "vagrant ssh"
|
60
|
+
Xnlogic.ui.info ""
|
61
|
+
Xnlogic.ui.info "Once logged in to the server, try the xn-console and xn-server commands"
|
62
|
+
end
|
63
|
+
|
64
|
+
def vm_config
|
65
|
+
generate_vm_config
|
66
|
+
write_options
|
67
|
+
install_vagrant_note
|
68
|
+
Xnlogic.ui.info ""
|
69
|
+
Xnlogic.ui.info "If you have an existing VM that you are updating, run 'vagrant provision',"
|
70
|
+
Xnlogic.ui.info "otherwise, run 'vagrant up'"
|
71
|
+
Xnlogic.ui.info ""
|
72
|
+
Xnlogic.ui.info "Once that is done, run 'vagrant ssh' to log in to the VM."
|
73
|
+
end
|
74
|
+
|
75
|
+
def deployment
|
76
|
+
generate_deployment
|
77
|
+
write_options
|
78
|
+
Xnlogic.ui.info ""
|
79
|
+
Xnlogic.ui.info "Deployment files generated. You must deploy from within your app by using the xn-deploy command."
|
80
|
+
Xnlogic.ui.info ""
|
81
|
+
end
|
82
|
+
|
83
|
+
def install_vagrant_note
|
84
|
+
if `which vagrant` == ''
|
85
|
+
Xnlogic.ui.info ""
|
86
|
+
Xnlogic.ui.info "Please ensure that the following dependencies are installed on your computer"
|
87
|
+
Xnlogic.ui.info "to continue."
|
88
|
+
Xnlogic.ui.info " - Vagrant: https://www.vagrantup.com/"
|
89
|
+
Xnlogic.ui.info " - VirtualBox: https://www.virtualbox.org/wiki/Downloads"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def template_options
|
18
94
|
namespaced_path = name
|
19
95
|
constant_name = namespaced_path.split('_').map{|p| p[0..0].upcase + p[1..-1] }.join
|
20
96
|
git_user_name = `git config user.name`.chomp
|
21
97
|
git_user_email = `git config user.email`.chomp
|
22
|
-
|
23
|
-
opts = {
|
98
|
+
{
|
24
99
|
:name => name,
|
25
100
|
:namespaced_path => namespaced_path,
|
26
101
|
:constant_name => constant_name,
|
@@ -30,7 +105,10 @@ module Xnlogic
|
|
30
105
|
:vm_memory => options['memory'],
|
31
106
|
:xn_key => options['key'],
|
32
107
|
}
|
108
|
+
end
|
33
109
|
|
110
|
+
def generate_vm_config
|
111
|
+
opts = template_options
|
34
112
|
base_templates = {
|
35
113
|
"Vagrantfile.tt" => "Vagrantfile",
|
36
114
|
"config/vagrant.provision.tt" => "config/vagrant.provision",
|
@@ -38,10 +116,17 @@ module Xnlogic
|
|
38
116
|
"config/transactor.properties" => "config/transactor.properties",
|
39
117
|
}
|
40
118
|
|
119
|
+
Xnlogic.ui.info ""
|
120
|
+
Xnlogic.ui.info "Creating Vagrant configuration"
|
121
|
+
Xnlogic.ui.info ""
|
41
122
|
base_templates.each do |src, dst|
|
42
123
|
thor.template("vagrant/#{src}", app.join(dst), opts)
|
43
124
|
end
|
125
|
+
end
|
44
126
|
|
127
|
+
def generate_application
|
128
|
+
opts = template_options
|
129
|
+
namespaced_path = opts[:namespaced_path]
|
45
130
|
templates = {
|
46
131
|
"gitignore.tt" => ".gitignore",
|
47
132
|
".rspec.tt" => ".rspec",
|
@@ -68,29 +153,27 @@ module Xnlogic
|
|
68
153
|
"spec/gemname/gemname_spec.rb.tt" => "spec/#{namespaced_path}/#{name}_spec.rb",
|
69
154
|
}
|
70
155
|
|
156
|
+
Xnlogic.ui.info ""
|
157
|
+
Xnlogic.ui.info "Creating application templates"
|
158
|
+
Xnlogic.ui.info ""
|
71
159
|
templates.each do |src, dst|
|
72
160
|
thor.template("application/#{src}", app.join(dst), opts)
|
73
161
|
end
|
162
|
+
end
|
74
163
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
164
|
+
def generate_deployment
|
165
|
+
opts = template_options
|
166
|
+
base_templates = {
|
167
|
+
}
|
79
168
|
|
80
169
|
Xnlogic.ui.info ""
|
81
|
-
Xnlogic.ui.info "
|
82
|
-
Xnlogic.ui.info "to continue."
|
83
|
-
Xnlogic.ui.info " - Vagrant: https://www.vagrantup.com/"
|
84
|
-
Xnlogic.ui.info " - VirtualBox: https://www.virtualbox.org/wiki/Downloads"
|
85
|
-
Xnlogic.ui.info ""
|
86
|
-
Xnlogic.ui.info "Then run the following:"
|
170
|
+
Xnlogic.ui.info "Creating Vagrant configuration"
|
87
171
|
Xnlogic.ui.info ""
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
Xnlogic.ui.info ""
|
92
|
-
Xnlogic.ui.info "Once logged in to the server, the project directory is ~/xn.dev"
|
172
|
+
base_templates.each do |src, dst|
|
173
|
+
thor.template("deployment/#{src}", app.join('deployment').join(dst), opts)
|
174
|
+
end
|
93
175
|
end
|
176
|
+
|
94
177
|
end
|
95
178
|
end
|
96
179
|
|
data/lib/xnlogic/cli.rb
CHANGED
@@ -2,6 +2,7 @@ require 'thor'
|
|
2
2
|
|
3
3
|
module Xnlogic
|
4
4
|
class CLI < Thor
|
5
|
+
require 'xnlogic/cli/application'
|
5
6
|
include Thor::Actions
|
6
7
|
|
7
8
|
def self.start(*)
|
@@ -53,20 +54,50 @@ module Xnlogic
|
|
53
54
|
Kernel.exec(command_path, *ARGV[1..-1])
|
54
55
|
end
|
55
56
|
|
57
|
+
|
58
|
+
def self.vm_config_options
|
59
|
+
method_option "key", type: :string, banner:
|
60
|
+
"You must supply an XN key to be able to download the proprietary dependencies needed to boot your application"
|
61
|
+
method_option "cpus", type: :numeric, banner:
|
62
|
+
"Number of Virtual CPUs the Development VM should use"
|
63
|
+
method_option "memory", type: :numeric, banner:
|
64
|
+
"Amount of RAM to allow the Development VM to use (in MB)"
|
65
|
+
method_option "root", type: :string, banner:
|
66
|
+
"Optionally specify a different root directory name"
|
67
|
+
end
|
68
|
+
|
56
69
|
desc "application NAME [OPTIONS]", "Creates a skeleton of an XN Logic application"
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
70
|
+
vm_config_options
|
71
|
+
method_option "vm_config", type: :boolean, default: true, banner:
|
72
|
+
"Generate VM configuration files"
|
73
|
+
method_option "same", type: :boolean, default: false, banner:
|
74
|
+
"Use previous config"
|
75
|
+
def application(name = nil)
|
76
|
+
app = Application.new(options, self)
|
77
|
+
if options['same'] or name.nil?
|
78
|
+
app.in_existing_project
|
79
|
+
else
|
80
|
+
app.set_name(name)
|
81
|
+
end
|
82
|
+
app.application
|
68
83
|
end
|
69
84
|
|
85
|
+
desc "vm_config [OPTIONS]", "Adds Vagrant configuration to the current project"
|
86
|
+
vm_config_options
|
87
|
+
method_option "name", type: :string, banner:
|
88
|
+
"Optionally specify a different project name"
|
89
|
+
def vm_config
|
90
|
+
Application.new(options, self).in_existing_project.vm_config
|
91
|
+
end
|
92
|
+
|
93
|
+
desc "deployment [OPTIONS]", "Adds Vagrant configuration to the current project"
|
94
|
+
vm_config_options
|
95
|
+
method_option "name", type: :string, banner:
|
96
|
+
def deployment
|
97
|
+
Application.new(options, self).in_existing_project.deployment
|
98
|
+
end
|
99
|
+
|
100
|
+
|
70
101
|
def self.source_root
|
71
102
|
File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
72
103
|
end
|
data/lib/xnlogic/version.rb
CHANGED
metadata
CHANGED
@@ -1,71 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xnlogic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darrick Wiebe
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2015-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
15
|
-
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
|
-
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
23
|
requirements:
|
22
|
-
- -
|
24
|
+
- - ">="
|
23
25
|
- !ruby/object:Gem::Version
|
24
26
|
version: '0'
|
25
|
-
prerelease: false
|
26
|
-
type: :runtime
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
|
-
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.7'
|
34
|
-
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
35
37
|
requirements:
|
36
|
-
- - ~>
|
38
|
+
- - "~>"
|
37
39
|
- !ruby/object:Gem::Version
|
38
40
|
version: '1.7'
|
39
|
-
prerelease: false
|
40
|
-
type: :development
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
43
50
|
version_requirements: !ruby/object:Gem::Requirement
|
44
51
|
requirements:
|
45
|
-
- - ~>
|
52
|
+
- - "~>"
|
46
53
|
- !ruby/object:Gem::Version
|
47
54
|
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: ronn
|
48
57
|
requirement: !ruby/object:Gem::Requirement
|
49
58
|
requirements:
|
50
|
-
- - ~>
|
59
|
+
- - "~>"
|
51
60
|
- !ruby/object:Gem::Version
|
52
|
-
version:
|
53
|
-
prerelease: false
|
61
|
+
version: 0.7.3
|
54
62
|
type: :development
|
55
|
-
|
56
|
-
name: xn_gem_release_tasks
|
63
|
+
prerelease: false
|
57
64
|
version_requirements: !ruby/object:Gem::Requirement
|
58
65
|
requirements:
|
59
|
-
- -
|
66
|
+
- - "~>"
|
60
67
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
68
|
+
version: 0.7.3
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: xn_gem_release_tasks
|
62
71
|
requirement: !ruby/object:Gem::Requirement
|
63
72
|
requirements:
|
64
|
-
- -
|
73
|
+
- - ">="
|
65
74
|
- !ruby/object:Gem::Version
|
66
75
|
version: 0.1.8
|
67
|
-
prerelease: false
|
68
76
|
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.1.8
|
69
83
|
description: Build graph applications with XN Logic.
|
70
84
|
email:
|
71
85
|
- dw@xnlogic.com
|
@@ -74,7 +88,7 @@ executables:
|
|
74
88
|
extensions: []
|
75
89
|
extra_rdoc_files: []
|
76
90
|
files:
|
77
|
-
- .gitignore
|
91
|
+
- ".gitignore"
|
78
92
|
- Gemfile
|
79
93
|
- README.md
|
80
94
|
- Rakefile
|
@@ -120,24 +134,24 @@ files:
|
|
120
134
|
homepage: https://xnlogic.com
|
121
135
|
licenses: []
|
122
136
|
metadata: {}
|
123
|
-
post_install_message:
|
137
|
+
post_install_message:
|
124
138
|
rdoc_options: []
|
125
139
|
require_paths:
|
126
140
|
- lib
|
127
141
|
required_ruby_version: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
|
-
- -
|
143
|
+
- - ">="
|
130
144
|
- !ruby/object:Gem::Version
|
131
145
|
version: '0'
|
132
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
147
|
requirements:
|
134
|
-
- -
|
148
|
+
- - ">="
|
135
149
|
- !ruby/object:Gem::Version
|
136
150
|
version: '0'
|
137
151
|
requirements: []
|
138
|
-
rubyforge_project:
|
139
|
-
rubygems_version: 2.
|
140
|
-
signing_key:
|
152
|
+
rubyforge_project:
|
153
|
+
rubygems_version: 2.2.2
|
154
|
+
signing_key:
|
141
155
|
specification_version: 4
|
142
156
|
summary: XN Logic command-line tools
|
143
157
|
test_files: []
|