@redredchen01/env-manager 0.2.0 → 1.0.0

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.
@@ -33,6 +33,7 @@ run() {
33
33
  case "$1" in
34
34
  --help|-h) show_help; return 0 ;;
35
35
  --output|-o) shift; output="${1:?--output requires a file}" ;;
36
+ --json) ;; # no-op: handled by dispatcher
36
37
  -*) echo "Error: unknown option '$1'" >&2; return 1 ;;
37
38
  *) file="$1" ;;
38
39
  esac
@@ -62,6 +63,12 @@ run() {
62
63
  local count
63
64
  count="$(grep -c '=' "$output" 2>/dev/null || echo 0)"
64
65
  echo "($count variables)"
66
+
67
+ if [ "${OUTPUT_JSON:-}" = "true" ]; then
68
+ local data_json
69
+ data_json=$(printf '{"file":"%s","status":"decrypted"}' "$output")
70
+ foundry::pipe::emit_json "ok" "$COMMAND_NAME" "$data_json"
71
+ fi
65
72
  else
66
73
  echo "Error: decryption failed (wrong passphrase?)." >&2
67
74
  [ -f "$output" ] && rm "$output"
@@ -37,6 +37,7 @@ run() {
37
37
  --help|-h) show_help; return 0 ;;
38
38
  --keys-only) keys_only=true ;;
39
39
  --values) show_values=true ;;
40
+ --json) ;; # no-op: handled by dispatcher
40
41
  -*) echo "Error: unknown option '$1'" >&2; return 1 ;;
41
42
  *)
42
43
  if [ -z "$file1" ]; then file1="$1"
@@ -125,6 +126,16 @@ run() {
125
126
  if [ -z "$only_in_1" ] && [ -z "$only_in_2" ] && [ -z "$changed" ]; then
126
127
  echo "Files are identical (same keys and values)."
127
128
  fi
129
+
130
+ if [ "${OUTPUT_JSON:-}" = "true" ]; then
131
+ local data_json differences
132
+ differences=0
133
+ [ -n "$only_in_1" ] && differences=$((differences + $(printf '%s' "$only_in_1" | grep -c .)))
134
+ [ -n "$only_in_2" ] && differences=$((differences + $(printf '%s' "$only_in_2" | grep -c .)))
135
+ [ -n "$changed" ] && differences=$((differences + $(printf '%s' "$changed" | grep -c .)))
136
+ data_json=$(printf '{"file1":"%s","file2":"%s","differences":%s}' "$file1" "$file2" "$differences")
137
+ foundry::pipe::emit_json "ok" "$COMMAND_NAME" "$data_json"
138
+ fi
128
139
  }
129
140
 
130
141
  _extract_keys() {
@@ -40,6 +40,7 @@ run() {
40
40
  --help|-h) show_help; return 0 ;;
41
41
  --output|-o) shift; output="${1:?--output requires a file}" ;;
42
42
  --delete) delete_original=true ;;
43
+ --json) ;; # no-op: handled by dispatcher
43
44
  -*) echo "Error: unknown option '$1'" >&2; return 1 ;;
44
45
  *) file="$1" ;;
45
46
  esac
@@ -67,6 +68,12 @@ run() {
67
68
  fi
68
69
  echo ""
69
70
  echo "To decrypt: env-manager decrypt $output"
71
+
72
+ if [ "${OUTPUT_JSON:-}" = "true" ]; then
73
+ local data_json
74
+ data_json=$(printf '{"file":"%s","status":"encrypted"}' "$output")
75
+ foundry::pipe::emit_json "ok" "$COMMAND_NAME" "$data_json"
76
+ fi
70
77
  else
71
78
  echo "Error: encryption failed." >&2
72
79
  [ -f "$output" ] && rm "$output"
@@ -38,6 +38,7 @@ run() {
38
38
  --output) shift; output="${1:?--output requires a file}" ;;
39
39
  --force) force=true ;;
40
40
  --no-prompt) no_prompt=true ;;
41
+ --json) ;; # no-op: handled by dispatcher
41
42
  *) echo "Error: unknown option '$1'" >&2; return 1 ;;
42
43
  esac
43
44
  shift
@@ -55,6 +56,11 @@ run() {
55
56
  local count
56
57
  count="$(grep -c '=' "$output" 2>/dev/null || echo 0)"
57
58
  echo "Created: $output ($count variables from $example)"
59
+ if [ "${OUTPUT_JSON:-}" = "true" ]; then
60
+ local data_json
61
+ data_json=$(printf '{"file":"%s","status":"created"}' "$output")
62
+ foundry::pipe::emit_json "ok" "$COMMAND_NAME" "$data_json"
63
+ fi
58
64
  return 0
59
65
  fi
60
66
 
@@ -92,4 +98,10 @@ run() {
92
98
  echo -e "$result" > "$output"
93
99
  echo ""
94
100
  echo "Created: $output"
101
+
102
+ if [ "${OUTPUT_JSON:-}" = "true" ]; then
103
+ local data_json
104
+ data_json=$(printf '{"file":"%s","status":"created"}' "$output")
105
+ foundry::pipe::emit_json "ok" "$COMMAND_NAME" "$data_json"
106
+ fi
95
107
  }
@@ -41,6 +41,7 @@ run() {
41
41
  --reveal) reveal=true ;;
42
42
  --keys) keys_only=true ;;
43
43
  --sort) do_sort=true ;;
44
+ --json) ;; # no-op: handled by dispatcher
44
45
  -*) echo "Error: unknown option '$1'" >&2; return 1 ;;
45
46
  *) file="$1" ;;
46
47
  esac
@@ -87,4 +88,10 @@ run() {
87
88
 
88
89
  echo ""
89
90
  echo "($count variables in $file)"
91
+
92
+ if [ "${OUTPUT_JSON:-}" = "true" ]; then
93
+ local data_json
94
+ data_json=$(printf '{"file":"%s","variables":%s}' "$file" "$count")
95
+ foundry::pipe::emit_json "ok" "$COMMAND_NAME" "$data_json"
96
+ fi
90
97
  }
@@ -38,6 +38,7 @@ run() {
38
38
  --target) shift; target="${1:?--target requires a file}" ;;
39
39
  --preserve) preserve=true ;;
40
40
  --dry-run) dry_run=true ;;
41
+ --json) ;; # no-op: handled by dispatcher
41
42
  *) echo "Error: unknown option '$1'" >&2; return 1 ;;
42
43
  esac
43
44
  shift
@@ -84,9 +85,21 @@ run() {
84
85
  echo ""
85
86
  echo -e "$output"
86
87
  echo "(Dry run — no file written)"
88
+
89
+ if [ "${OUTPUT_JSON:-}" = "true" ]; then
90
+ local data_json
91
+ data_json=$(printf '{"source":"%s","target":"%s","synced":%s}' "$source" "$target" "$total")
92
+ foundry::pipe::emit_json "ok" "$COMMAND_NAME" "$data_json"
93
+ fi
87
94
  return 0
88
95
  fi
89
96
 
90
97
  echo -e "$output" > "$target"
91
98
  echo "Written: $target ($total keys, $added new)"
99
+
100
+ if [ "${OUTPUT_JSON:-}" = "true" ]; then
101
+ local data_json
102
+ data_json=$(printf '{"source":"%s","target":"%s","synced":%s}' "$source" "$target" "$total")
103
+ foundry::pipe::emit_json "ok" "$COMMAND_NAME" "$data_json"
104
+ fi
92
105
  }
@@ -39,6 +39,7 @@ run() {
39
39
  --example) shift; example="${1:?--example requires a file}" ;;
40
40
  --strict) strict=true ;;
41
41
  --no-empty) no_empty=true ;;
42
+ --json) ;; # no-op: handled by dispatcher
42
43
  -*) echo "Error: unknown option '$1'" >&2; return 1 ;;
43
44
  *) file="$1" ;;
44
45
  esac
@@ -111,6 +112,18 @@ run() {
111
112
 
112
113
  # Summary
113
114
  echo "Result: $errors errors, $warnings warnings"
115
+
116
+ if [ "${OUTPUT_JSON:-}" = "true" ]; then
117
+ local data_json valid_val
118
+ if [ "$errors" -gt 0 ]; then
119
+ valid_val="false"
120
+ else
121
+ valid_val="true"
122
+ fi
123
+ data_json=$(printf '{"file":"%s","valid":%s,"errors":%s}' "$file" "$valid_val" "$errors")
124
+ foundry::pipe::emit_json "ok" "$COMMAND_NAME" "$data_json"
125
+ fi
126
+
114
127
  [ "$errors" -gt 0 ] && return 1
115
128
  echo "✓ Validation passed."
116
129
  return 0
package/cli/main.sh CHANGED
@@ -11,6 +11,8 @@ if [ -d "$CLI_CORE" ]; then
11
11
  source "${CLI_CORE}/logger.sh"
12
12
  source "${CLI_CORE}/config.sh"
13
13
  source "${CLI_CORE}/version.sh"
14
+ source "${CLI_CORE}/pipe.sh"
15
+ source "${CLI_CORE}/error.sh"
14
16
  fi
15
17
 
16
18
  export SKILL_NAME="env-manager"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redredchen01/env-manager",
3
- "version": "0.2.0",
3
+ "version": "1.0.0",
4
4
  "description": "CLI toolkit for .env file management — diff, validate, sync, encrypt/decrypt",
5
5
  "bin": {
6
6
  "env-manager": "./bin/env-manager.sh"