apperol 0.0.2 → 0.0.3
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/README.md +5 -2
- data/lib/apperol/app_json.rb +47 -0
- data/lib/apperol/cli.rb +13 -16
- data/lib/apperol/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 212cef4edea40eee0f1b4489f04d831ca500d320
|
4
|
+
data.tar.gz: 6bb4f8faf965a79e2856f9ad62439726ce7b6220
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4492e1388a1373e8f359998366a0262ba3fe7cc8331545389d81705a77f65475a0e60c865b5dd13ca7c70d06fbf77dc2115904e5f1d095bf48077b21f17af21c
|
7
|
+
data.tar.gz: fd2dcad0f541185c7c2801d54215c141a100fa3e525c3ce02043200d1f7c28cba400353ec7804c8af8d461b5cda4a7425d844bdfe77be9fe810950ccb4f6d3ae
|
data/README.md
CHANGED
@@ -29,10 +29,8 @@ Usage: apperol [options] [app_extension]
|
|
29
29
|
-s, --stack stack Stack for app on heroku
|
30
30
|
-b, --branch branch Branch to setup app from
|
31
31
|
-r, --repo repo GitHub repository source
|
32
|
-
-o, --org org GitHub org where the current repo is located
|
33
32
|
-u, --user user GitHub user where the current repo is located
|
34
33
|
-h, --help Displays Help
|
35
|
-
|
36
34
|
```
|
37
35
|
|
38
36
|
## Information
|
@@ -41,6 +39,11 @@ Usage: apperol [options] [app_extension]
|
|
41
39
|
- Apperol CLI will have many options based on `env` part of the `app.json`
|
42
40
|
- Apperol CLI uses heroku org by default, use `-r user/repo` to specify yours.
|
43
41
|
|
42
|
+
## Lack of tests
|
43
|
+
|
44
|
+
I know it is bad but they will come before v1.0.0 .
|
45
|
+
If you dislike this, see next section.
|
46
|
+
|
44
47
|
## Contributing
|
45
48
|
|
46
49
|
1. Fork it ( https://github.com/ys/apperol/fork )
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Apperol
|
2
|
+
class AppJson
|
3
|
+
def initialize(file_path = 'app.json')
|
4
|
+
@file_path = file_path
|
5
|
+
end
|
6
|
+
|
7
|
+
def env
|
8
|
+
__json__["env"].map do |key, definition|
|
9
|
+
AppJson::Env.new(key, definition)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def __json__
|
14
|
+
@__json__ ||= JSON.parse(File.read(@file_path))
|
15
|
+
end
|
16
|
+
|
17
|
+
class Env
|
18
|
+
attr_reader :key, :definition
|
19
|
+
def initialize(key, definition)
|
20
|
+
@key = key
|
21
|
+
@definition = definition
|
22
|
+
end
|
23
|
+
|
24
|
+
def value
|
25
|
+
definition.is_a?(String) ? definition : definition["value"]
|
26
|
+
end
|
27
|
+
|
28
|
+
def description
|
29
|
+
definition.is_a?(String) ? key : definition["description"]
|
30
|
+
end
|
31
|
+
|
32
|
+
def needs_value?
|
33
|
+
required? && !has_value?
|
34
|
+
end
|
35
|
+
|
36
|
+
def has_value?
|
37
|
+
!(value.nil? || value.strip.empty?)
|
38
|
+
end
|
39
|
+
|
40
|
+
def required?
|
41
|
+
definition.is_a?(String) ||
|
42
|
+
definition["required"].nil? ||
|
43
|
+
definition["required"]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/apperol/cli.rb
CHANGED
@@ -6,6 +6,8 @@ require "optparse"
|
|
6
6
|
require "netrc"
|
7
7
|
require "spinning_cursor"
|
8
8
|
|
9
|
+
require_relative "app_json"
|
10
|
+
|
9
11
|
module Apperol
|
10
12
|
class CLI
|
11
13
|
EX_USAGE = 64
|
@@ -15,16 +17,10 @@ module Apperol
|
|
15
17
|
|
16
18
|
parser = OptionParser.new do|opts|
|
17
19
|
opts.banner = "Usage: apperol [options] [app_extension]"
|
18
|
-
app_json
|
19
|
-
option_key_name = key.downcase.gsub("_", "-")
|
20
|
-
|
21
|
-
|
22
|
-
value = definition.is_a?(String) ? definition : definition["value"]
|
23
|
-
@options[option_key_key] = value
|
24
|
-
required = definition.is_a?(String) || definition["required"].nil? || definition["required"] ? " required" : ""
|
25
|
-
description = definition.is_a?(String) ? key : definition["description"]
|
26
|
-
opts.on("--#{option_key_name} value", "#{description} (Default: '#{value}' #{required}) ") do |value|
|
27
|
-
@options[option_key_key] = value
|
20
|
+
app_json.env.each do |env_value|
|
21
|
+
option_key_name = env_value.key.downcase.gsub("_", "-")
|
22
|
+
opts.on("--#{option_key_name} value", "#{env_value.description} (Default: '#{env_value.value}' #{env_value.required?}) ") do |value|
|
23
|
+
@options[env_value.key] = value
|
28
24
|
end
|
29
25
|
end
|
30
26
|
opts.on("-p", "--personal", "Force app in personal apps instead of orgs") do
|
@@ -143,12 +139,13 @@ module Apperol
|
|
143
139
|
overrides: { env: {}}
|
144
140
|
}
|
145
141
|
required_not_filled = []
|
146
|
-
app_json
|
147
|
-
value = @options[key
|
148
|
-
|
149
|
-
|
142
|
+
app_json.env.each do |env_value|
|
143
|
+
value = @options[env_value.key]
|
144
|
+
value_empty = value.nil? || value.strip.empty?
|
145
|
+
if env_value.needs_value? && value_empty
|
146
|
+
required_not_filled << env_value.key
|
150
147
|
end
|
151
|
-
payload[:overrides][:env][key] = value
|
148
|
+
payload[:overrides][:env][env_value.key] = value unless value_empty
|
152
149
|
end
|
153
150
|
unless required_not_filled.empty?
|
154
151
|
$stderr.puts("error: Required fields not filled. Please specify them. #{required_not_filled}")
|
@@ -251,7 +248,7 @@ module Apperol
|
|
251
248
|
$stderr.puts("No app.json file here")
|
252
249
|
exit 1
|
253
250
|
end
|
254
|
-
@app_json ||=
|
251
|
+
@app_json ||= AppJson.new("app.json")
|
255
252
|
end
|
256
253
|
end
|
257
254
|
end
|
data/lib/apperol/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apperol
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yannick
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- apperol.gemspec
|
83
83
|
- bin/apperol
|
84
84
|
- lib/apperol.rb
|
85
|
+
- lib/apperol/app_json.rb
|
85
86
|
- lib/apperol/cli.rb
|
86
87
|
- lib/apperol/version.rb
|
87
88
|
homepage: https://github.com/ys/apperol
|