@salefronts/cli 1.2.0 → 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.
- package/commands/decode.js +2 -2
- package/commands/encode.js +32 -5
- package/commands/seal.sh +5 -0
- package/commands/unseal.sh +5 -0
- package/commands/version.js +14 -0
- package/package.json +1 -1
- package/sf-cli.code-workspace +0 -10
package/commands/decode.js
CHANGED
|
@@ -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 () {
|
package/commands/encode.js
CHANGED
|
@@ -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
|
|
13
|
-
if (!
|
|
14
|
-
console.error('❌ Aborted:
|
|
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
|
-
|
|
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
|
package/commands/unseal.sh
CHANGED
|
@@ -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
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { readFileSync } = require('fs');
|
|
4
|
+
const { join } = require('path');
|
|
5
|
+
|
|
6
|
+
module.exports = function () {
|
|
7
|
+
try {
|
|
8
|
+
const pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf8'));
|
|
9
|
+
console.log(pkg.version);
|
|
10
|
+
} catch (err) {
|
|
11
|
+
console.error('❌ Could not read version:', err.message);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
}
|
package/package.json
CHANGED