@kaynooo/cli-db 0.13.4 → 0.13.5
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/dist/cli.js +18 -7
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#!/
|
|
2
|
-
// @bun
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
// @bun 2>/dev/null; exec bun --config=/dev/null "$0" "$@"
|
|
3
3
|
var __esm = (fn, res, err) => () => {
|
|
4
4
|
if (fn)
|
|
5
5
|
try {
|
|
@@ -591,11 +591,20 @@ function wholeNumber(value, name, fallback, min = 1) {
|
|
|
591
591
|
badUsage(`${name.startsWith("<") ? name : `--${name}`} takes a whole number from ${min}, not ${value}`);
|
|
592
592
|
return number;
|
|
593
593
|
}
|
|
594
|
+
function durationMs(text, unit) {
|
|
595
|
+
if (BARE_DURATION.test(text))
|
|
596
|
+
return Number(text) * UNIT_MS[unit];
|
|
597
|
+
if (!DURATION.test(text))
|
|
598
|
+
return 0;
|
|
599
|
+
let ms = 0;
|
|
600
|
+
for (const [, amount, part] of text.matchAll(DURATION_PART))
|
|
601
|
+
ms += Number(amount) * UNIT_MS[part];
|
|
602
|
+
return ms;
|
|
603
|
+
}
|
|
594
604
|
function duration(value, name, fallback, unit = "s") {
|
|
595
605
|
if (value === undefined)
|
|
596
606
|
return fallback;
|
|
597
|
-
const
|
|
598
|
-
const ms = match === null ? 0 : Number(match[1]) * UNIT_MS[match[2] ?? unit];
|
|
607
|
+
const ms = durationMs(value.trim(), unit);
|
|
599
608
|
if (ms < 1)
|
|
600
609
|
badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
|
|
601
610
|
return ms;
|
|
@@ -611,12 +620,14 @@ async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
|
|
|
611
620
|
fail(`no file ${path}`);
|
|
612
621
|
return file.text();
|
|
613
622
|
}
|
|
614
|
-
var WHOLE, DURATION, UNIT_MS;
|
|
623
|
+
var WHOLE, BARE_DURATION, DURATION, DURATION_PART, UNIT_MS;
|
|
615
624
|
var init_input = __esm(() => {
|
|
616
625
|
init_args();
|
|
617
626
|
WHOLE = /^\d+$/;
|
|
618
|
-
|
|
619
|
-
|
|
627
|
+
BARE_DURATION = /^\d+(?:\.\d+)?$/;
|
|
628
|
+
DURATION = /^(?:\d+(?:\.\d+)?(?:ms|min|[smhd]))+$/;
|
|
629
|
+
DURATION_PART = /(\d+(?:\.\d+)?)(ms|min|[smhd])/g;
|
|
630
|
+
UNIT_MS = { ms: 1, s: 1000, m: 60000, min: 60000, h: 3600000, d: 86400000 };
|
|
620
631
|
});
|
|
621
632
|
|
|
622
633
|
// ../kit/src/args.ts
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-db",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.13.
|
|
4
|
+
"version": "0.13.5",
|
|
5
5
|
"description": "db: run read-only SQL against Postgres, MySQL and MariaDB from the terminal without ever showing the connection credentials.",
|
|
6
6
|
"author": "Kaynooo <contact@kaynooo.fr>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"registry": "https://git.kaynooo.fr/api/packages/kaynooo/npm/"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "$npm_execpath build src/cli.ts --target bun --outdir dist",
|
|
27
|
+
"build": "$npm_execpath build src/cli.ts --target bun --outdir dist && $npm_execpath ../../scripts/shell-shebang.ts",
|
|
28
28
|
"db": "$npm_execpath src/cli.ts"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@kaynooo/cli-kit": "0.46.
|
|
31
|
+
"@kaynooo/cli-kit": "0.46.4"
|
|
32
32
|
}
|
|
33
33
|
}
|