@salefronts/cli 1.1.0 → 1.2.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.
package/README.md CHANGED
@@ -17,4 +17,12 @@ To get the list of command use this command line:
17
17
 
18
18
  ```bash
19
19
  sf help
20
+ ```
21
+
22
+ ## Publishing
23
+
24
+ Increase the version inside the package.json
25
+
26
+ ```bash
27
+ npm publish --access public
20
28
  ```
@@ -0,0 +1,39 @@
1
+ const readline = require('readline');
2
+
3
+ function ask(question) {
4
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
5
+ return new Promise(resolve => rl.question(question, answer => {
6
+ rl.close();
7
+ resolve(answer.trim());
8
+ }));
9
+ }
10
+
11
+ async function decodeBase64() {
12
+ const text = await ask('📝 Text to decode in Base64: ');
13
+ if (!text) {
14
+ console.error('❌ Aborted: text is required.');
15
+ return;
16
+ }
17
+ console.log(Buffer.from(text, 'base64').toString('utf-8'));
18
+ }
19
+
20
+ async function decodeURIText() {
21
+ const text = await ask('📝 Text to decode in URI: ');
22
+ if (!text) {
23
+ console.error('❌ Aborted: text is required.');
24
+ return;
25
+ }
26
+ console.log(decodeURIComponent(text));
27
+ }
28
+
29
+ module.exports = async function () {
30
+ const [,, cmd, format] = process.argv;
31
+
32
+ if (format === 'base64') {
33
+ await decodeBase64();
34
+ } else if (format === 'uri') {
35
+ await decodeURIText();
36
+ } else {
37
+ console.error('❌ Missing decode <format>. Valid formats: uri | base64');
38
+ }
39
+ }
@@ -0,0 +1,39 @@
1
+ const readline = require('readline');
2
+
3
+ function ask(question) {
4
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
5
+ return new Promise(resolve => rl.question(question, answer => {
6
+ rl.close();
7
+ resolve(answer.trim());
8
+ }));
9
+ }
10
+
11
+ async function encodeBase64() {
12
+ const text = await ask('📝 Text to encode in Base64: ');
13
+ if (!text) {
14
+ console.error('❌ Aborted: text is required.');
15
+ return;
16
+ }
17
+ console.log(Buffer.from(text, 'utf-8').toString('base64'));
18
+ }
19
+
20
+ async function encodeURIText() {
21
+ const text = await ask('📝 Text to encode in URI: ');
22
+ if (!text) {
23
+ console.error('❌ Aborted: text is required.');
24
+ return;
25
+ }
26
+ console.log(encodeURIComponent(text));
27
+ }
28
+
29
+ module.exports = async function () {
30
+ const [,, cmd, format] = process.argv;
31
+
32
+ if (format === 'base64') {
33
+ await encodeBase64();
34
+ } else if (format === 'uri') {
35
+ await encodeURIText();
36
+ } else {
37
+ console.error('❌ Missing encode <format>. Valid formats: uri | base64');
38
+ }
39
+ }
package/commands/help.js CHANGED
@@ -11,9 +11,11 @@ function showHelp() {
11
11
  console.log(' keypair Generate public/private key pairs');
12
12
  console.log(' passphrase Generate secure passphrases');
13
13
  console.log(' secret Generate a random secret');
14
- console.log(' ssh Generate SSH key');;
14
+ console.log(' ssh Generate SSH key');
15
15
  console.log(' uuidv4 Generate a UUID v4');
16
16
  console.log(' uuidv7 Generate a UUID v7');
17
+ console.log(' encode Encode string to different formats');
18
+ console.log(' decode Decode string from different formats');
17
19
  console.log(' seal Seal Kubernetes secrets');
18
20
  console.log(' unseal Unseal Kubernetes secrets');
19
21
  console.log(' env Generate .env file from K8s secret.yaml');
package/commands/seal.sh CHANGED
@@ -54,8 +54,8 @@ else
54
54
 
55
55
  # Extract `stringData` from input file while preserving order
56
56
  FILE_SECRET_JSON=$(yq eval -o=json '.stringData // {}' "$SECRET_FILE")
57
- FILE_SECRET_DATA=$(echo "$FILE_SECRET_JSON" | jq -r 'to_entries | map("\(.key) \(.value)") | .[]')
58
-
57
+ FILE_SECRET_DATA=$(echo "$FILE_SECRET_JSON" | jq -r 'to_entries | map("\(.key) \(.value|tostring)") | .[]')
58
+
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salefronts/cli",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "bin": {
5
5
  "sf": "bin/sf"
6
6
  },