@salefronts/cli 1.1.0 → 1.2.1
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 +8 -0
- package/commands/decode.js +39 -0
- package/commands/encode.js +39 -0
- package/commands/help.js +3 -1
- package/commands/seal.sh +2 -2
- package/commands/version.js +14 -0
- package/package.json +1 -1
- package/sf-cli.code-workspace +0 -10
package/README.md
CHANGED
|
@@ -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
|
|
@@ -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