dotenv-sync 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b02e9462d0390c20b7d34aa33ba5c049f102bf84
4
- data.tar.gz: c9ae0ea8edc992bbde2148bc0b346ac12cb860c3
3
+ metadata.gz: e1e441e6e49904c9d2666f7cd8adf95849076005
4
+ data.tar.gz: d77ebd70e530109d051d8bbd7e9ce5b9867dd80a
5
5
  SHA512:
6
- metadata.gz: f129ee0b0592460be1fb71e1cee694282ce3ae341ebba56c267679c999c9ed8414c7b9988cff4a691f712a733a2d866aaa19d247e788a869fd3142526e8f6188
7
- data.tar.gz: 9091c22e319a27bcad226a379ae700e0945c2a5a01f6ad3ec0f81c0ab2ba7de2526728a3b5610d40ad6ffc169f89bfb08036d496bdb0ec1348bc3206fa788cfd
6
+ metadata.gz: 42357a7d1e303fc001327885ebc4002562a7a39f4474f13625da7b6e26b293dab16edc35259d57463f299c39a0e54255c14ff591fa434fb6a2650d207e470697
7
+ data.tar.gz: 296c1f0ac1558d11893e268f7c3e571b2f34ab4d3fc15553f1c6ff42ed30fe747dbe68c9e521c2964efbb1a15088ca7dbf5c9d05475968e632e443959f41461c
data/.gitignore CHANGED
@@ -120,4 +120,46 @@
120
120
  /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160704-23542-x5q8i
121
121
  # Dotenv syncing
122
122
  /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160704-23542-pxcwjq
123
- /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160704-23542-jexlno
123
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160704-23542-jexlno
124
+ # Dotenv syncing
125
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2867-1ac2bnv
126
+ # Dotenv syncing
127
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2867-wrb7sd
128
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2867-1g1t8m3
129
+ # Dotenv syncing
130
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2867-9svacm
131
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2867-1u4m03v
132
+ # Dotenv syncing
133
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2867-jlhqdj
134
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2867-1a3kcuu
135
+ # Dotenv syncing
136
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2867-1fn9k45
137
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2867-oqf5fr
138
+ # Dotenv syncing
139
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2909-i1qw1
140
+ # Dotenv syncing
141
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2909-14uyd56
142
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2909-eg0ogd
143
+ # Dotenv syncing
144
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2909-alvi48
145
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2909-87aai8
146
+ # Dotenv syncing
147
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2909-1v5dyt
148
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2909-e8jgjb
149
+ # Dotenv syncing
150
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2909-1t8qkgv
151
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2909-di8x5t
152
+ # Dotenv syncing
153
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2925-15tu0cv
154
+ # Dotenv syncing
155
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2925-1oh539b
156
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2925-g3nhyd
157
+ # Dotenv syncing
158
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2925-llt3nb
159
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2925-1memalx
160
+ # Dotenv syncing
161
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2925-1o3evp1
162
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2925-nzud1j
163
+ # Dotenv syncing
164
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2925-1f53g9s
165
+ /var/folders/gt/k34d1gd555vcr5x0wtz5gf_r0000gn/T/20160717-2925-4ncar9
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Dotenv::Sync
1
+ # dotenv-sync
2
2
 
3
- Dotenv-sync is a small utility that lets you sync `.env` secrets in your repo.
3
+ dotenv-sync is a small utility that lets you sync `.env` secrets in your repo.
4
4
 
5
5
  This assumes you use [dotenv](https://github.com/bkeepers/dotenv) to manage and load your environment variables locally and relies on the fact that _dotenv_ supports environment specific dotenv files.
6
6
 
@@ -12,10 +12,14 @@ dotenv-sync assumes you have two seperate files:
12
12
  .env.local - contatins only the secrets and is not shared on git directly
13
13
  ```
14
14
 
15
- This gem then uses a shared secret keyfile which can be managed in any way __important to not commit this file__,
15
+ This gem then uses a shared secret keyfile `.env-key` __which should not be commited__,
16
16
  to encrypt and decrypt the `.env.local` file and share it in the repo as `.env-encrypted`.
17
17
 
18
- You can use _1Password for teams_ or _Vault_ for sharing your secret key file.
18
+ You can use _1Password for teams_ or _Vault_ for sharing your secret keyfile.
19
+
20
+ ### Overview
21
+ ![](/docs/dotenv-sync.png)
22
+
19
23
 
20
24
  ## Installation
21
25
 
@@ -41,6 +45,7 @@ Dotenv-sync provides a command line file with several commands to run.
41
45
  dotenv-sync [command] # Runs the command while loading the env variables from .env (based on the dotenv gem)
42
46
  dotenv-sync generate_key # Generate a new key file
43
47
  dotenv-sync pull # Update your .env.local file from the encrypted version
48
+ dotenv-sync merge # Update your .env.local file from the encrypted version (retains local changes)
44
49
  dotenv-sync push # Update the encrypted file from your version of .env.local
45
50
  dotenv-sync sort [DOTENV_FILE=.env] # Sorts your .env file
46
51
  dotenv-sync help [COMMAND] # Describe available commands or one specific command
@@ -50,7 +55,7 @@ dotenv-sync help [COMMAND] # Describe available commands or one specif
50
55
  When initializing a new project you need to run `dotenv-sync generate_key` followed by `dotenv-sync push` to create the key which should be securely shared and the `.env-encrypted` file which can be commited.
51
56
 
52
57
  ### Subsequent uses
53
- If you're updating `.env.local` and want to share a change run `dotenv-sync push` and commit the change `.env-encrypted` file.
58
+ If you're updating `.env.local` and want to share a change run `dotenv-sync push` and then commit the changed `.env-encrypted` file.
54
59
 
55
60
  If you're pulling a change from git and see that `.env-encypted` changed run `dotenv-sync pull` to update your local `.env.local`
56
61
 
Binary file
@@ -38,6 +38,14 @@ module Dotenv
38
38
  Syncer.new(options).pull
39
39
  end
40
40
 
41
+ option :key, desc: "The keyfile", default: Syncer::DEFAULT_KEY_FILE, aliases: :k
42
+ option :encrypted, desc: "The shared encrypted file", default: Syncer::DEFAULT_ENCRYPTED_FILE, aliases: :e
43
+ option :secret, desc: "The private secret file", default: Syncer::DEFAULT_SECRET_FILE, aliases: :s
44
+ desc "merge", "Update your .env.local file from the encrypted version (preserving local changes)"
45
+ def merge
46
+ Syncer.new(options).merge
47
+ end
48
+
41
49
  option :key, desc: "The keyfile", default: Syncer::DEFAULT_KEY_FILE, aliases: :k
42
50
  option :encrypted, desc: "The shared encrypted file", default: Syncer::DEFAULT_ENCRYPTED_FILE, aliases: :e
43
51
  option :secret, desc: "The private secret file", default: Syncer::DEFAULT_SECRET_FILE, aliases: :s
@@ -43,6 +43,28 @@ module Dotenv
43
43
  end
44
44
 
45
45
  def pull
46
+ data = load_data
47
+ write(@secret_filename, data)
48
+ puts "Successfully decrypted #{@secret_filename}"
49
+ data
50
+ end
51
+
52
+ def merge
53
+ existing_data = read(@secret_filename)
54
+ merged_data = merge_lines(load_data, existing_data)
55
+ write(@secret_filename, merged_data)
56
+ puts "Successfully merged #{@secret_filename}"
57
+ merged_data
58
+ end
59
+
60
+ def merge_lines(left, right)
61
+ left_lines = left.lines.map(&:strip)
62
+ right_lines = right.lines.map(&:strip)
63
+ merged = left_lines + (right_lines - left_lines)
64
+ sort_lines(merged)
65
+ end
66
+
67
+ def load_data
46
68
  validate_file! @encrypted_filename
47
69
  key = read_key!
48
70
  data = read_64 @encrypted_filename
@@ -51,9 +73,6 @@ module Dotenv
51
73
  cipher.iv = iv
52
74
  cipher.key = key
53
75
  data = cipher.update(encrypted) + cipher.final
54
- write(@secret_filename, data)
55
- puts "Successfully decrypted #{@secret_filename}"
56
- data
57
76
  end
58
77
 
59
78
  def sort(filename)
@@ -1,5 +1,5 @@
1
1
  module Dotenv
2
2
  module Sync
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotenv-sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - yonbergman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-04 00:00:00.000000000 Z
11
+ date: 2016-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -85,6 +85,7 @@ files:
85
85
  - bin/console
86
86
  - bin/dotenv-sync
87
87
  - bin/setup
88
+ - docs/dotenv-sync.png
88
89
  - dotenv-sync.gemspec
89
90
  - lib/dotenv/sync.rb
90
91
  - lib/dotenv/sync/command_line.rb