@salefronts/cli 1.2.1 → 1.3.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.
@@ -14,7 +14,7 @@ async function decodeBase64() {
14
14
  console.error('❌ Aborted: text is required.');
15
15
  return;
16
16
  }
17
- console.log(Buffer.from(text, 'base64').toString('utf-8'));
17
+ console.log(`✅ Base64 decoded output:\n${Buffer.from(text, 'base64').toString('utf-8')}`);
18
18
  }
19
19
 
20
20
  async function decodeURIText() {
@@ -23,7 +23,7 @@ async function decodeURIText() {
23
23
  console.error('❌ Aborted: text is required.');
24
24
  return;
25
25
  }
26
- console.log(decodeURIComponent(text));
26
+ console.log(`✅ URI decoded output:\n${decodeURIComponent(text)}`);
27
27
  }
28
28
 
29
29
  module.exports = async function () {
@@ -1,4 +1,6 @@
1
1
  const readline = require('readline');
2
+ const fs = require('fs/promises');
3
+ const path = require('path');
2
4
 
3
5
  function ask(question) {
4
6
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
@@ -9,12 +11,37 @@ function ask(question) {
9
11
  }
10
12
 
11
13
  async function encodeBase64() {
12
- const text = await ask('📝 Text to encode in Base64: ');
13
- if (!text) {
14
- console.error('❌ Aborted: text is required.');
14
+ const input = await ask('📝 Text or file path to encode in Base64: ');
15
+ if (!input) {
16
+ console.error('❌ Aborted: input is required.');
15
17
  return;
16
18
  }
17
- console.log(Buffer.from(text, 'utf-8').toString('base64'));
19
+
20
+ try {
21
+ let content;
22
+
23
+ if (/^\/(?:[a-zA-Z0-9._,-]+\/)*[a-zA-Z0-9._,-]+\.[a-zA-Z0-9.]+$/.test(input)) {
24
+ const resolvedPath = path.resolve(input);
25
+ try {
26
+ const stat = await fs.stat(resolvedPath);
27
+ if (stat.isFile()) {
28
+ content = await fs.readFile(resolvedPath);
29
+ console.log(`📂 Encoding file: ${resolvedPath}`);
30
+ } else {
31
+ console.error(`❌ Not a file`);
32
+ }
33
+ } catch (err) {
34
+ console.error(`❌ Error reading file: ${err.message}`);
35
+ }
36
+ } else {
37
+ content = Buffer.from(input, 'utf-8');
38
+ }
39
+
40
+ const encoded = content.toString('base64');
41
+ console.log(`✅ Base64 encoded output:\n${encoded}`);
42
+ } catch (err) {
43
+ console.error(`❌ Error: ${err.message}`);
44
+ }
18
45
  }
19
46
 
20
47
  async function encodeURIText() {
@@ -23,7 +50,7 @@ async function encodeURIText() {
23
50
  console.error('❌ Aborted: text is required.');
24
51
  return;
25
52
  }
26
- console.log(encodeURIComponent(text));
53
+ console.log(`✅ URI encoded output:\n${encodeURIComponent(text)}`);
27
54
  }
28
55
 
29
56
  module.exports = async function () {
package/commands/seal.sh CHANGED
@@ -44,6 +44,11 @@ fi
44
44
  # Get the current Kubernetes cluster name
45
45
  CLUSTER_NAME=$(kubectl config current-context)
46
46
 
47
+ if ! kubectl version >/dev/null 2>&1; then
48
+ echo "❌ Cannot connect to Kubernetes cluster. Check your context or credentials."
49
+ exit 1
50
+ fi
51
+
47
52
  if ! kubectl get secret "$SECRET_NAME" -n "$NAMESPACE" >/dev/null 2>&1; then
48
53
  echo "❗ Secret does not exist in cluster."
49
54
  changes_detected=true
@@ -39,6 +39,11 @@ fetch_secret() {
39
39
  exit 1
40
40
  fi
41
41
 
42
+ if ! kubectl version >/dev/null 2>&1; then
43
+ echo "❌ Cannot connect to Kubernetes cluster. Check your context or credentials."
44
+ exit 1
45
+ fi
46
+
42
47
  echo "📡 Fetching secret: $secret_name from namespace: $secret_namespace"
43
48
 
44
49
  # Fetch the secret from Kubernetes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salefronts/cli",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "bin": {
5
5
  "sf": "bin/sf"
6
6
  },