mina-dotenv 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -1
- data/lib/mina/dotenv/tasks.rb +24 -6
- data/lib/mina/dotenv/utils.rb +38 -0
- data/lib/mina/dotenv/version.rb +1 -1
- data/mina-dotenv.gemspec +1 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 294faeee8d753dc2546dd043a593cc802e5ec003
|
4
|
+
data.tar.gz: 5ab80b5ce301f478067801fc8c3c063212c22bee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 667f9096c89ac4a5013fac1b837952a1ba49d4ef7b00586fc8cc10f0c91f413f86fed03dc783c2159150565a250da236d003c0ab2bca67cdbb85e56c08a39c50
|
7
|
+
data.tar.gz: 8a125d9df8527cd2bf26924d02b15f55e62edc788278ced4d573c6cb0f5b006b123335e636f8696da711b0a771e400ec8b6de563f2a2b3e4625ea1f7c146b568
|
data/README.md
CHANGED
@@ -86,7 +86,13 @@ If no local `.env` file is found a blank one will be created on the server.
|
|
86
86
|
|
87
87
|
### Pull
|
88
88
|
|
89
|
-
The pull task uses
|
89
|
+
The pull task uses [scp](https://en.wikipedia.org/wiki/Secure_copy) to retrieve the `.env` file from the server.
|
90
|
+
|
91
|
+
__Note:__ It will take all configuration from your `deploy.rb` file!
|
92
|
+
|
93
|
+
__Important:__ It will add the downloaded file to your `.gitignore` file!
|
94
|
+
|
95
|
+
It is intended to be used from the terminal like this:
|
90
96
|
|
91
97
|
```
|
92
98
|
mina dotenv:pull
|
data/lib/mina/dotenv/tasks.rb
CHANGED
@@ -15,15 +15,33 @@ namespace :dotenv do
|
|
15
15
|
desc 'Copies the remote .env file to the current directory'
|
16
16
|
task :pull do
|
17
17
|
scp_download(remote_dotenv_path, dotenv_location)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
Mina::Dotenv::Utils.add_to_gitignore(dotenv_location)
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'Creates empty .env files, adds defaults to .gitignore and deploy.rb'
|
22
|
+
task :init do
|
23
|
+
add_default_to_gitignore
|
24
|
+
add_to_deploy_script
|
25
|
+
create_default_files
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
27
29
|
def remote_dotenv_path
|
28
30
|
"#{deploy_to}/#{shared_path}/.env"
|
29
31
|
end
|
32
|
+
|
33
|
+
def add_default_to_gitignore
|
34
|
+
Mina::Dotenv::Utils.add_to_gitignore('!.env')
|
35
|
+
Mina::Dotenv::Utils.add_to_gitignore('.env.*')
|
36
|
+
end
|
37
|
+
|
38
|
+
def add_to_deploy_script
|
39
|
+
file = 'config/deploy.rb'
|
40
|
+
line = 'require \'mina/dotenv\''
|
41
|
+
Mina::Dotenv::Utils.prepend_to_file(file, line)
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_default_files
|
45
|
+
Mina::Dotenv::Utils.create_file('.env')
|
46
|
+
Mina::Dotenv::Utils.create_file('.env.production')
|
47
|
+
end
|
data/lib/mina/dotenv/utils.rb
CHANGED
@@ -5,6 +5,44 @@ module Mina
|
|
5
5
|
return '' unless File.exist?(file_path)
|
6
6
|
File.open(file_path, 'r').read
|
7
7
|
end
|
8
|
+
|
9
|
+
def self.append_to_file(file, string, force: false)
|
10
|
+
add_to_file(file, string, before: true, force: force)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.prepend_to_file(file, string, force: false)
|
14
|
+
add_to_file(file, string, force: force)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.add_to_file(file, string, before: true, force: false)
|
18
|
+
return unless File.exist?(file)
|
19
|
+
return if !force && file_contains?(file, string)
|
20
|
+
|
21
|
+
file_content = File.read(file)
|
22
|
+
|
23
|
+
File.open(file, 'w') do |f|
|
24
|
+
f.puts(string) if before
|
25
|
+
f.puts file_content
|
26
|
+
f.puts(string) unless before
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.file_contains?(file, regex)
|
31
|
+
File.foreach(file).grep(Regexp.new(regex)).any?
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.add_to_gitignore(path)
|
35
|
+
gitignore_path = '.gitignore'
|
36
|
+
return if file_contains?(gitignore_path, path)
|
37
|
+
append_to_file(gitignore_path, path)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.create_file(path, content = '')
|
41
|
+
return if File.exist?(path)
|
42
|
+
File.open(path, 'w') do |f|
|
43
|
+
f.puts(content)
|
44
|
+
end
|
45
|
+
end
|
8
46
|
end
|
9
47
|
end
|
10
48
|
end
|
data/lib/mina/dotenv/version.rb
CHANGED
data/mina-dotenv.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mina-dotenv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stanko Krtalić Rusendić
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mina
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -105,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
119
|
version: '0'
|
106
120
|
requirements: []
|
107
121
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.4.5
|
122
|
+
rubygems_version: 2.4.5.1
|
109
123
|
signing_key:
|
110
124
|
specification_version: 4
|
111
125
|
summary: Dotenv tasks for mina
|