@salefronts/cli 1.0.2 → 1.1.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.
@@ -0,0 +1,48 @@
1
+ #!/bin/bash
2
+
3
+ set -euo pipefail # Safe mode
4
+
5
+ # Ensure required dependencies are installed
6
+ for cmd in yq; do
7
+ if ! command -v "$cmd" >/dev/null 2>&1; then
8
+ echo "❌ Error: $cmd is required but not installed."
9
+ exit 1
10
+ fi
11
+ done
12
+
13
+ # Prompt or get file argument
14
+ if [ -z "${1:-}" ]; then
15
+ echo -n "📄 Enter path to the secret file (e.g., secret.yaml): "
16
+ read -r SECRET_FILE
17
+ else
18
+ SECRET_FILE=$1
19
+ fi
20
+
21
+ # Check file exists
22
+ if [ ! -f "$SECRET_FILE" ]; then
23
+ echo "❌ Error: File not found: $SECRET_FILE"
24
+ exit 1
25
+ fi
26
+
27
+ # Validate kind
28
+ KIND=$(yq eval '.kind' "$SECRET_FILE")
29
+ if [ "$KIND" != "Secret" ]; then
30
+ echo "❌ Error: File is not a Kubernetes Secret (found kind: $KIND)"
31
+ exit 1
32
+ fi
33
+
34
+ # Determine env filename
35
+ BASENAME=$(basename "$SECRET_FILE")
36
+ DIRNAME=$(dirname "$SECRET_FILE")
37
+
38
+ if [ "$BASENAME" = "secret.yaml" ]; then
39
+ ENV_PATH="$DIRNAME/.env"
40
+ else
41
+ NAME_PREFIX=$(echo "$BASENAME" | sed -E 's/-?secret\.ya?ml$//' | sed -E 's/\..*$//')
42
+ ENV_PATH="$DIRNAME/.env-$NAME_PREFIX"
43
+ fi
44
+
45
+ # Convert stringData to .env format
46
+ yq -o=json '.stringData // {}' "$SECRET_FILE" | jq -r 'to_entries[] | "\(.key)=\(.value)"' > "$ENV_PATH"
47
+
48
+ echo "✅ Done! Generated .env file at: $ENV_PATH"
package/commands/help.js CHANGED
@@ -16,6 +16,7 @@ function showHelp() {
16
16
  console.log(' uuidv7 Generate a UUID v7');
17
17
  console.log(' seal Seal Kubernetes secrets');
18
18
  console.log(' unseal Unseal Kubernetes secrets');
19
+ console.log(' env Generate .env file from K8s secret.yaml');
19
20
  console.log(' tag Tagging version for the latest commit on main')
20
21
  }
21
22
 
package/commands/seal.sh CHANGED
@@ -59,8 +59,10 @@ else
59
59
  # Convert to associative arrays for easier comparison and maintain order
60
60
  declare -A k8s_secret_map
61
61
  while IFS= read -r line; do
62
+ [[ -z "$line" ]] && continue # skip empty lines
62
63
  key=$(echo "$line" | awk '{print $1}')
63
64
  value=$(echo "$line" | cut -d' ' -f2-)
65
+ [[ -z "$key" ]] && continue # skip lines with empty key
64
66
  k8s_secret_map["$key"]="$value"
65
67
  done <<< "$K8S_SECRET_DATA"
66
68
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salefronts/cli",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "bin": {
5
5
  "sf": "bin/sf"
6
6
  },
@@ -0,0 +1,10 @@
1
+ {
2
+ "folders": [
3
+ {
4
+ "path": "."
5
+ },
6
+ {
7
+ "path": "."
8
+ }
9
+ ]
10
+ }