dotenv-android 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +2 -0
- data/lib/dotenv-android/cli.rb +9 -2
- data/lib/dotenv-android/generator.rb +4 -14
- data/lib/dotenv-android/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d22e91e44e04625949928ec8e9a0c55612faeca178a4d9cd5461b7fbc7ff0db
|
4
|
+
data.tar.gz: 7a73cba66ce0b45c73b400e9d382fb908893c2abff44ca1bd74840b53e18aae3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 205123bb2fe02d01e6de518d64200a3c8478f92039d3086368ac4f5666c7b16e1980b61ff4b2bcaeb082a2a185928432628c4f230f93a4e3979788c54624f815
|
7
|
+
data.tar.gz: 58ec434f9e4069be26933fb7a7f5d9ecf2fe15a46c1366b3ab01324e792c70ad4400992ef81df1e0a652e08940561822a55fd8d77be10c90fe99880fba622978
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -40,6 +40,8 @@ export PATH="$PATH:~/.rbenv/shims/"
|
|
40
40
|
dotenv-android --source app/src/main/java/com/example/myapplication/ --package PACKAGE_NAME
|
41
41
|
```
|
42
42
|
|
43
|
+
> Tip: You can put the package name in your `.env` file with key `PACKAGE_NAME` as well instead of as a CLI option.
|
44
|
+
|
43
45
|
In your `app/build.gradle` file, add the following to the bottom of the file:
|
44
46
|
```
|
45
47
|
task generateEnv(type:Exec) {
|
data/lib/dotenv-android/cli.rb
CHANGED
@@ -25,6 +25,8 @@ module DotEnvAndroid
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def parse_options
|
28
|
+
Dotenv.load('.env')
|
29
|
+
|
28
30
|
options = Options.new
|
29
31
|
options.verbose = false
|
30
32
|
options.debug = false
|
@@ -48,7 +50,7 @@ module DotEnvAndroid
|
|
48
50
|
options.verbose = true
|
49
51
|
options.debug = true
|
50
52
|
end
|
51
|
-
opts.on('--package
|
53
|
+
opts.on('--package', 'Package name to add to the top of the generated Env.kt file (example: com.yourdomain.app, or PACKAGE_NAME environment variable found in .env)') do |package_name| # rubocop:disable Metrics/LineLength
|
52
54
|
options.package_name = package_name
|
53
55
|
end
|
54
56
|
opts.on('-o', '--out FILE', 'Output file (example: Path/Env.kt)') do |out|
|
@@ -66,13 +68,18 @@ module DotEnvAndroid
|
|
66
68
|
|
67
69
|
opt_parser.parse!(ARGV)
|
68
70
|
|
71
|
+
if options.package_name.nil?
|
72
|
+
options.package_name = ENV["PACKAGE_NAME"]
|
73
|
+
|
74
|
+
@ui.fail("Cannot find package name in .env file with key, PACKAGE_NAME, or as a CLI argument") if options.package_name.nil?
|
75
|
+
end
|
76
|
+
|
69
77
|
options
|
70
78
|
end
|
71
79
|
|
72
80
|
def assert_options
|
73
81
|
prefix = '[ERROR]'
|
74
82
|
@ui.fail("#{prefix} --source required") unless @options.source
|
75
|
-
@ui.fail("#{prefix} --package required") unless @options.package_name
|
76
83
|
end
|
77
84
|
end
|
78
85
|
end
|
@@ -15,7 +15,7 @@ module DotEnvAndroid
|
|
15
15
|
|
16
16
|
@ui = DotEnvAndroid::UI.new(@options.verbose, @options.debug)
|
17
17
|
|
18
|
-
|
18
|
+
Dotenv.load('.env')
|
19
19
|
end
|
20
20
|
|
21
21
|
def start
|
@@ -67,9 +67,9 @@ module DotEnvAndroid
|
|
67
67
|
values = {}
|
68
68
|
|
69
69
|
requests.each do |request|
|
70
|
-
@ui.
|
70
|
+
@ui.warning("Environment variable #{request} not found in .env") unless ENV[request]
|
71
71
|
|
72
|
-
values[request] =
|
72
|
+
values[request] = ENV[request]
|
73
73
|
end
|
74
74
|
|
75
75
|
@ui.debug("Values: #{values}")
|
@@ -77,17 +77,7 @@ module DotEnvAndroid
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def package_header
|
80
|
-
|
81
|
-
|
82
|
-
unless @options.package_name.include? '.'
|
83
|
-
package_name = @all_env_vars[@options.package_name]
|
84
|
-
@ui.fail("Cannot find package name in .env file with key, #{@options.package_name}") if package_name.nil?
|
85
|
-
package_name_header = "package #{package_name}"
|
86
|
-
end
|
87
|
-
|
88
|
-
@ui.debug("Package name header: #{package_name_header}")
|
89
|
-
|
90
|
-
package_name_header
|
80
|
+
return "package #{@options.package_name}"
|
91
81
|
end
|
92
82
|
|
93
83
|
def generate_output(env_variables)
|