mirror of
https://github.com/sbrow/envr.git
synced 2025-12-29 23:47:39 -05:00
feat: Implemented sync command.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
## TODOS
|
## TODOS
|
||||||
|
|
||||||
- [ ] `envr sync` - Restore missing .env files, and update backed up ones.
|
- [x] `envr sync` - Restore missing .env files, and update backed up ones.
|
||||||
- [x] `envr scan` - Search for missing / moved .env files.
|
- [x] `envr scan` - Search for missing / moved .env files.
|
||||||
|
|||||||
17
mod.nu
17
mod.nu
@@ -177,7 +177,6 @@ export def "envr init" [
|
|||||||
source: $source
|
source: $source
|
||||||
priv_key: $identity
|
priv_key: $identity
|
||||||
pub_key: $'($identity).pub'
|
pub_key: $'($identity).pub'
|
||||||
# TODO: scan settings
|
|
||||||
scan: {
|
scan: {
|
||||||
matcher: '\.env'
|
matcher: '\.env'
|
||||||
exclude: '*.envrc'
|
exclude: '*.envrc'
|
||||||
@@ -209,17 +208,21 @@ def files [] {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update your env backups
|
# Update or restore your env backups
|
||||||
export def "envr sync" [] {
|
export def "envr sync" [] {
|
||||||
let $files = (files);
|
let $files = (files);
|
||||||
|
|
||||||
$files | each { |it|
|
$files | each { |it|
|
||||||
# TODO: Check for file existence
|
if ($it.path | path type | $in == 'file') {
|
||||||
# TODO: If file exists and sha changed: `envr backup $it.path`
|
if (open $it.path | hash sha256 | $in != $it.sha256) {
|
||||||
# TODO: If file doesn't exist: `envr restore $it.path`
|
envr backup $it.path
|
||||||
|
} else {
|
||||||
|
'Nothing to do!'
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
envr restore $it.path
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
'TODO: Need to implement'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Search for .env files and select ones to back up.
|
# Search for .env files and select ones to back up.
|
||||||
|
|||||||
Reference in New Issue
Block a user