@kaynooo/cli-dev 0.7.0 → 0.7.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 +1 -1
- package/dist/cli.js +24 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ Fish completes it through the bin itself: `dev __complete`, installed for every
|
|
|
26
26
|
|
|
27
27
|
The password is read from `crypto.getRandomValues` and written as `openssl rand -hex|-base64` does, `base64url` being that base64 with `+/` swapped for `-_` and the padding dropped. `--copy` also puts the password on the clipboard through `wl-copy` (or xclip, xsel, pbcopy) and says `copied to clipboard` on stderr; without it the clipboard is left alone.
|
|
28
28
|
|
|
29
|
-
`--bcrypt` hashes at cost 10. Bun writes bcrypt hashes with the `$2b$` prefix where `htpasswd -B` writes `$2y$`: the algorithm is identical, so `dev` rewrites the prefix to `$2y$`, the one Apache, nginx and traefik basic auth all accept (`$2b$` is accepted by fewer of them). With a generated password the hash prints on stdout, the password on stderr, and it is the password that `--copy` copies, as the password it replaces did.
|
|
29
|
+
`--bcrypt -` asks for the password masked on a terminal, or reads it from stdin, which keeps it out of the shell history. `--bcrypt` hashes at cost 10. Bun writes bcrypt hashes with the `$2b$` prefix where `htpasswd -B` writes `$2y$`: the algorithm is identical, so `dev` rewrites the prefix to `$2y$`, the one Apache, nginx and traefik basic auth all accept (`$2b$` is accepted by fewer of them). With a generated password the hash prints on stdout, the password on stderr, and it is the password that `--copy` copies, as the password it replaces did.
|
|
30
30
|
|
|
31
31
|
## Notes
|
|
32
32
|
|
package/dist/cli.js
CHANGED
|
@@ -213,7 +213,27 @@ var init_format = __esm(() => {
|
|
|
213
213
|
// ../kit/src/help.ts
|
|
214
214
|
import process5 from "process";
|
|
215
215
|
function usageLine(usage, colors = paint(process5.stdout)) {
|
|
216
|
-
|
|
216
|
+
const lines = usage.replace(USAGE_PREFIX, "").split(`
|
|
217
|
+
`);
|
|
218
|
+
const blank = lines.indexOf("");
|
|
219
|
+
const synopses = blank === -1 ? lines : lines.slice(0, blank);
|
|
220
|
+
const details = blank === -1 ? [] : lines.slice(blank + 1);
|
|
221
|
+
const colon = synopses[0].indexOf(": ");
|
|
222
|
+
const inline = synopses[0].slice(colon + 2);
|
|
223
|
+
const summary = colon === -1 ? details.shift() : `${inline.charAt(0).toUpperCase()}${inline.slice(1)}`;
|
|
224
|
+
if (colon !== -1)
|
|
225
|
+
synopses[0] = synopses[0].slice(0, colon);
|
|
226
|
+
const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
|
|
227
|
+
`)}`;
|
|
228
|
+
const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
|
|
229
|
+
const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
|
|
230
|
+
return [head, ...lead, ...rest].join(`
|
|
231
|
+
`);
|
|
232
|
+
}
|
|
233
|
+
function prose(line, colors) {
|
|
234
|
+
if (colors.cyan("x") === "x")
|
|
235
|
+
return line;
|
|
236
|
+
return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
|
|
217
237
|
}
|
|
218
238
|
function helpText(usage, options, colors = paint(process5.stdout), { examples = [], exits = [] } = {}) {
|
|
219
239
|
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
@@ -262,13 +282,14 @@ function optionRows(options, colors = paint(process5.stdout)) {
|
|
|
262
282
|
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
263
283
|
return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
264
284
|
}
|
|
265
|
-
var OPTIONAL, USAGE_PREFIX, FULL_STOP, MAX_INLINE_CHOICES = 24;
|
|
285
|
+
var OPTIONAL, USAGE_PREFIX, FULL_STOP, PROSE_MARKS, MAX_INLINE_CHOICES = 24;
|
|
266
286
|
var init_help = __esm(() => {
|
|
267
287
|
init_mode();
|
|
268
288
|
init_style();
|
|
269
289
|
OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
270
290
|
USAGE_PREFIX = /^usage:\s*/i;
|
|
271
291
|
FULL_STOP = /\.$/;
|
|
292
|
+
PROSE_MARKS = /`([^`\n]+)`|(?<![\w-])(--[a-z][\w-]*|-[a-z](?![\w-]))/gi;
|
|
272
293
|
});
|
|
273
294
|
|
|
274
295
|
// ../kit/src/text.ts
|
|
@@ -1879,7 +1900,7 @@ function printRows(rows) {
|
|
|
1879
1900
|
}
|
|
1880
1901
|
var PASSWORD_USAGE = `dev password [length] [format] [-b|--bcrypt [password]] [--copy]: a random password of <length> bytes (default ${DEFAULT_LENGTH}) as hex, base64 (default) or base64url
|
|
1881
1902
|
|
|
1882
|
-
Printed on stdout
|
|
1903
|
+
Printed on stdout, and copied with --copy. With --bcrypt the bcrypt hash (cost 10) prints, of the password given (- asks for it masked on a terminal, or reads stdin, keeping it out of the shell history) or of a generated one, which prints on stderr and is the one --copy copies. The hash has the $2y$ prefix htpasswd -B writes.`;
|
|
1883
1904
|
var PASSWORD_EXITS = [[0, "it printed the password or hash"], [2, "a usage error"], [130, "the prompt was cancelled"]];
|
|
1884
1905
|
var PASSWORD_OPTIONS = {
|
|
1885
1906
|
bcrypt: { type: "string", short: "b", optional: { bare: "", accepts: STDIN_OR_VALUE }, description: "print the bcrypt hash of the password given, or of a generated one" },
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-dev",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.1",
|
|
5
5
|
"description": "dev: small developer utilities in one bin: random passwords and bcrypt hashes, JWT decoding, timestamps, UUIDs and ULIDs, base64, URL parts and file hashes.",
|
|
6
6
|
"author": "Kaynooo <contact@kaynooo.fr>",
|
|
7
7
|
"license": "MIT",
|