dorky 2.3.6 → 2.3.8

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.
Files changed (2) hide show
  1. package/README.md +344 -55
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -14,89 +14,378 @@
14
14
 
15
15
  ![Made with love in India](https://madewithlove.now.sh/in?heart=true&template=for-the-badge) `&& ` ![javascript](https://img.shields.io/badge/JavaScript-323330?style=for-the-badge&logo=javascript&logoColor=F7DF1E)
16
16
 
17
- Let us assume that we need to create a project.
17
+ ## Overview
18
18
 
19
- The project obviously contains some code and some secret variables like database information, API keys, etc. This data cannot be shared on public VCS (GitHub), but at times is required to be accessible remotely to be shared among reliable sources.
19
+ Manage sensitive project files like environment variables, configuration files, and API keys without committing them to public version control. **dorky** securely stores your sensitive files on AWS S3 or Google Drive, making them accessible to authorized team members.
20
20
 
21
- Anyhow, we shall store it on a private storage, using **dorky**, that stores it on a S3 or Google-Drive.
21
+ ## Installation
22
22
 
23
- ## AWS S3
23
+ ```bash
24
+ npm install -g dorky
25
+ ```
24
26
 
25
- ### Steps to use with S3:
27
+ Or use with npx:
26
28
 
27
- > Create a S3 bucket, AWS_ACCESS_KEY and AWS_SECRET_KEY.
29
+ ```bash
30
+ npx dorky --help
31
+ ```
28
32
 
29
- ![Dorky Usage](dorky-usage-aws.svg "Dorky usage")
33
+ ## Prerequisites
34
+
35
+ ### AWS S3
36
+
37
+ 1. Create an S3 bucket in your AWS account
38
+ 2. Create an IAM user with programmatic access
39
+ 3. Attach the following IAM policy to the user (replace `your-bucket-name` with your actual bucket name):
40
+
41
+ ```json
42
+ {
43
+ "Version": "2012-10-17",
44
+ "Statement": [
45
+ {
46
+ "Effect": "Allow",
47
+ "Action": [
48
+ "s3:PutObject",
49
+ "s3:GetObject",
50
+ "s3:DeleteObject",
51
+ "s3:ListBucket"
52
+ ],
53
+ "Resource": [
54
+ "arn:aws:s3:::your-bucket-name",
55
+ "arn:aws:s3:::your-bucket-name/*"
56
+ ]
57
+ }
58
+ ]
59
+ }
60
+ ```
61
+
62
+ 4. Generate AWS credentials (Access Key ID and Secret Access Key) for the IAM user
63
+ 5. Set up environment variables:
64
+
65
+ ```bash
66
+ export AWS_ACCESS_KEY="your-access-key"
67
+ export AWS_SECRET_KEY="your-secret-key"
68
+ export AWS_REGION="us-east-1"
69
+ export BUCKET_NAME="your-bucket-name"
70
+ ```
30
71
 
31
- > Please use your own repository, this repository `sample_project` is just for demonstration.
72
+ ### Google Drive
32
73
 
33
- #### To list files in the project.
74
+ 1. Create a Google Cloud Project
75
+ 2. Enable Google Drive API
76
+ 3. Download OAuth 2.0 credentials
77
+ 4. Save credentials as `google-drive-credentials.json` in your project root
34
78
 
35
- 1. Initialize dorky setup in the root folder of your project, using `dorky --init aws`.
36
- 2. List the files using `dorky --list`.
37
- > This command will not list the files that are excluded in `.dorkyignore`.
79
+ ## Quick Start
38
80
 
39
- #### To push files to S3 bucket.
81
+ ### AWS S3 Setup
40
82
 
41
- 1. Initialize dorky setup in the root folder of your project, using `dorky --init aws`.
42
- 2. List the files using `dorky --list`, (make sure to add excluded file or folder patterns to .dorkyignore, to minimize the list).
43
- 3. Add files to stage-1 using `dorky --add file-name`.
44
- 4. Push files to S3 bucket using `dorky --push`.
83
+ ![Dorky Usage](dorky-usage-aws.svg "Dorky usage")
45
84
 
46
- #### To remove a file from project.
85
+ ```bash
86
+ # Navigate to your project
87
+ cd your-project
47
88
 
48
- 1. Remove files using `dorky --rm file-name`. [Removes file from stage-1 <local>]
49
- 2. Push files to S3 bucket using `dorky --push`. [Removes file from S3 bucket <remote>]
89
+ # Initialize dorky with AWS
90
+ dorky --init aws
50
91
 
51
- #### To pull files from S3 bucket.
92
+ # List files that can be added
93
+ dorky --list
52
94
 
53
- 1. Use `dorky --pull` to pull the files from S3 bucket.
95
+ # Add sensitive files
96
+ dorky --add .env config.yml
54
97
 
55
- ## Google Drive
98
+ # Push to S3
99
+ dorky --push
100
+ ```
56
101
 
57
- ### Steps to use with Google Drive:
102
+ ### Google Drive Setup
58
103
 
59
104
  ![Dorky Usage](dorky-usage-google-drive.svg "Dorky usage")
60
105
 
61
- > Please use your own repository, this repository `sample_project` is just for demonstration.
106
+ ```bash
107
+ # Navigate to your project
108
+ cd your-project
109
+
110
+ # Initialize dorky with Google Drive
111
+ dorky --init google-drive
112
+
113
+ # Authenticate (browser window will open)
114
+ # Follow the OAuth flow
115
+
116
+ # List files that can be added
117
+ dorky --list
118
+
119
+ # Add sensitive files
120
+ dorky --add .env secrets.json
121
+
122
+ # Push to Google Drive
123
+ dorky --push
124
+ ```
125
+
126
+ ## Usage
127
+
128
+ ### Initialize a Project
129
+
130
+ ```bash
131
+ # For AWS S3
132
+ dorky --init aws
133
+
134
+ # For Google Drive
135
+ dorky --init google-drive
136
+ ```
137
+
138
+ This creates:
139
+
140
+ - `.dorky/` folder with metadata and credentials
141
+ - `.dorkyignore` file for exclusion patterns
142
+ - Updates `.gitignore` to protect credentials
143
+
144
+ ### List Files
145
+
146
+ ```bash
147
+ # List local files (shows what can be added)
148
+ dorky --list
149
+
150
+ # List remote files (shows what's in storage)
151
+ dorky --list remote
152
+ ```
153
+
154
+ ### Add Files to Stage
155
+
156
+ ```bash
157
+ # Add single file
158
+ dorky --add .env
159
+
160
+ # Add multiple files
161
+ dorky --add .env config.yml secrets.json
162
+
163
+ # Add files with specific patterns
164
+ dorky --add .env.production .env.staging
165
+ ```
166
+
167
+ ### Remove Files from Stage
168
+
169
+ ```bash
170
+ # Remove single file
171
+ dorky --rm .env
172
+
173
+ # Remove multiple files
174
+ dorky --rm .env config.yml
175
+ ```
176
+
177
+ ### Push Files to Storage
178
+
179
+ ```bash
180
+ # Push all staged files
181
+ dorky --push
182
+ ```
183
+
184
+ This command:
185
+
186
+ - Uploads new files
187
+ - Updates modified files (based on hash comparison)
188
+ - Skips unchanged files
189
+
190
+ ### Pull Files from Storage
191
+
192
+ ```bash
193
+ # Pull all tracked files
194
+ dorky --pull
195
+ ```
196
+
197
+ This command:
198
+
199
+ - Downloads all tracked files from storage
200
+ - Creates necessary directories
201
+ - Overwrites local files
202
+
203
+ ## Configuration
204
+
205
+ ### .dorkyignore
206
+
207
+ Exclude files and directories from dorky scanning:
208
+
209
+ ```
210
+ node_modules/
211
+ .git/
212
+ dist/
213
+ build/
214
+ *.log
215
+ coverage/
216
+ ```
217
+
218
+ ### Directory Structure
219
+
220
+ After initialization:
221
+
222
+ ```
223
+ your-project/
224
+ ├── .dorky/
225
+ │ ├── credentials.json # Storage credentials (auto-ignored by git)
226
+ │ └── metadata.json # Tracked files metadata
227
+ ├── .dorkyignore # Exclusion patterns
228
+ └── .gitignore # Updated automatically
229
+ ```
230
+
231
+ ## Common Workflows
232
+
233
+ ### Workflow 1: Initial Setup for Team
234
+
235
+ ```bash
236
+ # Team lead initializes and pushes files
237
+ dorky --init aws
238
+ dorky --add .env config/secrets.yml
239
+ dorky --push
240
+
241
+ # Team members pull files
242
+ git clone <repository>
243
+ cd <repository>
244
+ # Set up AWS credentials in environment
245
+ dorky --pull
246
+ ```
247
+
248
+ ### Workflow 2: Update Sensitive Configuration
249
+
250
+ ```bash
251
+ # Modify your .env file locally
252
+ vim .env
253
+
254
+ # Add updated file
255
+ dorky --add .env
256
+
257
+ # Push changes
258
+ dorky --push
259
+ ```
260
+
261
+ ### Workflow 3: Clean Up Tracked Files
262
+
263
+ ```bash
264
+ # Remove from staging
265
+ dorky --rm old-config.yml
266
+
267
+ # Push to remove from remote
268
+ dorky --push
269
+ ```
270
+
271
+ ## Examples
272
+
273
+ ### Example 1: Managing Environment Files
274
+
275
+ ```bash
276
+ # Initialize with AWS
277
+ dorky --init aws
278
+
279
+ # Add environment files for different stages
280
+ dorky --add .env.development .env.staging .env.production
281
+
282
+ # Check what will be uploaded
283
+ dorky --list
284
+
285
+ # Upload to S3
286
+ dorky --push
287
+
288
+ # View remote files
289
+ dorky --list remote
290
+ ```
291
+
292
+ ### Example 2: Managing API Keys
293
+
294
+ ```bash
295
+ # Initialize with Google Drive
296
+ dorky --init google-drive
297
+
298
+ # Add API key files
299
+ dorky --add config/api-keys.json secrets/tokens.yml
300
+
301
+ # Push to Google Drive
302
+ dorky --push
303
+
304
+ # On another machine, pull the files
305
+ dorky --pull
306
+ ```
307
+
308
+ ## Features
309
+
310
+ - ✅ AWS S3 storage integration
311
+ - ✅ Google Drive storage integration
312
+ - ✅ List remote files in dorky bucket
313
+ - ✅ Auto detect .env and .config files
314
+ - ✅ Automatic .gitignore updates to ignore credentials
315
+ - ✅ Handle reauthentication for Google Drive
316
+ - ✅ Token refresh for Google Drive authentication
317
+ - ✅ Ignore dorky files in dorky itself
318
+ - ✅ File hash validation to skip unchanged files
319
+ - ✅ Mime-type detection for file uploads
320
+ - ✅ Recursive folder creation on pull
321
+
322
+ ## How It Works
323
+
324
+ 1. **Initialization**: Creates `.dorky/` folder with metadata and credentials
325
+ 2. **File Tracking**: Maintains a hash-based registry of files in `metadata.json`
326
+ 3. **Smart Uploads**: Only uploads files that have changed (based on MD5 hash)
327
+ 4. **Auto-detection**: Highlights `.env` and `.config` files during listing
328
+ 5. **Security**: Automatically updates `.gitignore` to protect credentials
329
+
330
+ ## Security Best Practices
331
+
332
+ - ✅ Never commit `.dorky/credentials.json` to version control
333
+ - ✅ Use environment variables for AWS credentials
334
+ - ✅ Rotate access keys regularly
335
+ - ✅ Use IAM roles with minimal required permissions
336
+ - ✅ Review `.dorkyignore` before adding files
337
+ - ✅ Keep `google-drive-credentials.json` secure
338
+
339
+ ## Troubleshooting
340
+
341
+ ### AWS S3 Issues
342
+
343
+ **Error: Missing credentials**
344
+
345
+ ```bash
346
+ # Set environment variables
347
+ export AWS_ACCESS_KEY="your-key"
348
+ export AWS_SECRET_KEY="your-secret"
349
+ export AWS_REGION="us-east-1"
350
+ export BUCKET_NAME="your-bucket"
351
+ ```
352
+
353
+ ### Google Drive Issues
354
+
355
+ **Error: Invalid credentials**
356
+
357
+ ```bash
358
+ # Re-authenticate
359
+ dorky --init google-drive
360
+ ```
62
361
 
63
- #### To list files in the project.
362
+ **Error: Token expired**
64
363
 
65
- 1. Initialize dorky setup in the root folder of your project, using `dorky --init google-drive`.
66
- 2. List the files using `dorky --list`.
67
- > This command will not list the files that are excluded in `.dorkyignore`.
364
+ - dorky automatically refreshes tokens
365
+ - If issues persist, delete `.dorky/credentials.json` and re-authenticate
68
366
 
69
- #### To push files to Google Drive.
367
+ ## Contributing
70
368
 
71
- 1. Initialize dorky setup in the root folder of your project, using `dorky --init google-drive`.
72
- 2. List the files using `dorky --list`, (make sure to add excluded file or folder patterns to .dorkyignore, to minimize the list).
73
- 3. Add files to stage-1 using `dorky --add file-name`.
74
- 4. Push files to Google Drive using `dorky --push`.
369
+ Contributions are welcome! Please feel free to submit a Pull Request.
75
370
 
76
- #### To remove a file from project.
371
+ ## License
77
372
 
78
- 1. Remove files using `dorky --rm file-name`. [Removes file from stage-1 <local>]
79
- 2. Push files to Google Drive using `dorky --push`. [Removes file from Google Drive <remote>]
373
+ ISC License - see [LICENSE](LICENSE) file for details.
80
374
 
81
- #### To pull files from Google Drive.
375
+ ## Support
82
376
 
83
- 1. Use `dorky --pull` to pull the files from Google Drive.
377
+ - 📦 [npm package](https://npmjs.com/package/dorky)
378
+ - 🐛 [Report issues](https://github.com/trishantpahwa/dorky/issues)
379
+ - 🌐 [Website](https://dorky.trishantpahwa.me/)
84
380
 
85
- ## To-Do
381
+ ## Roadmap
86
382
 
87
- [*] List remote files in dorky bucket.
88
- [*] Auto detect .env and .config files.
89
- [*] Update node version to latest LTS.
90
- [*] Ignore dorky files in dorky itself.
91
- [*] Update .gitignore automatically, to ignore .dorky/credentials.json.
92
- [*] Handle reauthentication loop for google-drive. (Bug fix release)
93
- [ ] Fix error while adding a file that does not exist, it does give an error but still prints that an entry is added.
94
- [ ] Update README. (Bug fix release)
95
- [ ] Fix issue when the file is added again with the same contents, it still adds it, not checks it with the hash.
96
- [ ] Handle invalid access token for google-drive.
97
- [ ] Extension for VS Code to list and highlight them like git. (Major release)
98
- [ ] Unintialize dorky setup. (Bug fix release)
99
- [ ] MCP server. (Minor release)
100
- [ ] Encryption of files. (Minor release)
101
- [ ] Add stages for variables. (Major release)
383
+ - [x] Update README with AWS IAM policy (bug fix release)
384
+ - [ ] Handle invalid access token for Google Drive (edge cases)
385
+ - [ ] Extension for VS Code to list and highlight them like git (Major release)
386
+ - [ ] Uninitialize dorky setup (Bug fix release)
387
+ - [ ] MCP server (Minor release)
388
+ - [ ] Encryption of files (Minor release)
389
+ - [ ] Add stages for variables (Major release)
390
+ - [ ] Migrate dorky project to another storage (partially implemented)
102
391
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dorky",
3
- "version": "2.3.6",
3
+ "version": "2.3.8",
4
4
  "description": "DevOps Records Keeper.",
5
5
  "bin": {
6
6
  "dorky": "bin/index.js"