@salefronts/cli 1.4.0 → 1.6.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 +3 -2
- package/commands/core.js +20 -0
- package/commands/help.js +2 -1
- package/commands/key.js +20 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,8 +21,9 @@ sf help
|
|
|
21
21
|
|
|
22
22
|
## Publishing
|
|
23
23
|
|
|
24
|
-
Increase the version inside the package.json
|
|
24
|
+
- Increase the version inside the package.json
|
|
25
|
+
- Generate an access token in npm: check bypass 2FA
|
|
25
26
|
|
|
26
27
|
```bash
|
|
27
|
-
npm publish --access public
|
|
28
|
+
export NPM_TOKEN=<token here> && npm publish --access public
|
|
28
29
|
```
|
package/commands/core.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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 subcommand = args[0];
|
|
11
|
+
|
|
12
|
+
if (subcommand === "pull") {
|
|
13
|
+
run("HUSKY=0 git subrepo pull src/core");
|
|
14
|
+
} else if (subcommand === "push") {
|
|
15
|
+
run("HUSKY=0 git subrepo push src/core");
|
|
16
|
+
} else {
|
|
17
|
+
console.error("Usage: sf core <pull|push>");
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
};
|
package/commands/help.js
CHANGED
|
@@ -8,6 +8,7 @@ function showHelp() {
|
|
|
8
8
|
console.log('Usage: sf <command>\n');
|
|
9
9
|
console.log('Available commands:');
|
|
10
10
|
console.log(' jwt Generate JWT tokens');
|
|
11
|
+
console.log(' key Generate an uppercase alphanumeric key');
|
|
11
12
|
console.log(' keypair Generate public/private key pairs');
|
|
12
13
|
console.log(' passphrase Generate secure passphrases');
|
|
13
14
|
console.log(' secret Generate a random secret');
|
|
@@ -26,4 +27,4 @@ function showHelp() {
|
|
|
26
27
|
module.exports = async function () {
|
|
27
28
|
showHelp();
|
|
28
29
|
process.exit(0);
|
|
29
|
-
}
|
|
30
|
+
}
|
package/commands/key.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const crypto = require('crypto');
|
|
2
|
+
|
|
3
|
+
const ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
|
4
|
+
const KEY_LENGTH = 16;
|
|
5
|
+
|
|
6
|
+
module.exports = function () {
|
|
7
|
+
try {
|
|
8
|
+
const bytes = crypto.randomBytes(KEY_LENGTH);
|
|
9
|
+
let key = '';
|
|
10
|
+
|
|
11
|
+
for (const byte of bytes) {
|
|
12
|
+
key += ALPHABET[byte % ALPHABET.length];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
console.log(key);
|
|
16
|
+
} catch (err) {
|
|
17
|
+
console.error('Error generating key:', err.message);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
};
|