@salefronts/cli 1.2.1 → 1.4.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/acp.js +34 -0
- package/commands/decode.js +2 -2
- package/commands/encode.js +32 -5
- package/commands/help.js +2 -1
- package/commands/seal.sh +5 -0
- package/commands/unseal.sh +5 -0
- package/package.json +1 -1
package/commands/acp.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execSync } = require("child_process");
|
|
4
|
+
|
|
5
|
+
function run(cmd) {
|
|
6
|
+
return execSync(cmd, { encoding: "utf-8", stdio: "inherit" });
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
module.exports = function (args) {
|
|
10
|
+
const message = args[0];
|
|
11
|
+
|
|
12
|
+
if (!message) {
|
|
13
|
+
console.error("Usage: sf acp <commit-message>");
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
run("git add .");
|
|
19
|
+
execSync(`git commit -m "${message.replace(/"/g, '\\"')}"`, {
|
|
20
|
+
encoding: "utf-8",
|
|
21
|
+
stdio: "inherit",
|
|
22
|
+
});
|
|
23
|
+
} catch {
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
run("git push");
|
|
29
|
+
} catch {
|
|
30
|
+
console.error("Push failed, undoing commit...");
|
|
31
|
+
execSync("git reset --soft HEAD~1", { encoding: "utf-8", stdio: "inherit" });
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
};
|
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/help.js
CHANGED
|
@@ -19,7 +19,8 @@ function showHelp() {
|
|
|
19
19
|
console.log(' seal Seal Kubernetes secrets');
|
|
20
20
|
console.log(' unseal Unseal Kubernetes secrets');
|
|
21
21
|
console.log(' env Generate .env file from K8s secret.yaml');
|
|
22
|
-
console.log(' tag Tagging version for the latest commit on main')
|
|
22
|
+
console.log(' tag Tagging version for the latest commit on main');
|
|
23
|
+
console.log(' acp Git add, commit, and push (undo commit if push fails)');
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
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
|