callkaro-cli-unofficial 0.5.0 → 0.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 +14 -0
- package/dist/commands/accounts.js +45 -4
- package/dist/commands/admin.js +517 -0
- package/dist/commands/dashboardApiCmd.js +5 -1
- package/dist/index.js +147 -0
- package/dist/lib/adminApi.js +323 -0
- package/dist/lib/adminAuth.js +388 -0
- package/dist/lib/api.js +41 -14
- package/dist/lib/config.js +143 -9
- package/dist/lib/looseJson.js +43 -0
- package/package.json +1 -1
package/dist/lib/looseJson.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.readJsonFile = readJsonFile;
|
|
4
4
|
exports.stripBom = stripBom;
|
|
5
|
+
exports.repairPosixPath = repairPosixPath;
|
|
5
6
|
exports.parseLooseJson = parseLooseJson;
|
|
6
7
|
const fs_1 = require("fs");
|
|
7
8
|
/**
|
|
@@ -25,6 +26,48 @@ const NUMBER = /^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/;
|
|
|
25
26
|
/** Characters that end a bare value / a bare key at the current nesting level. */
|
|
26
27
|
const VALUE_STOP = ',}]';
|
|
27
28
|
const KEY_STOP = ':,}';
|
|
29
|
+
/**
|
|
30
|
+
* Repair a POSIX path argument that Git Bash turned into a Windows path.
|
|
31
|
+
*
|
|
32
|
+
* MSYS2 (Git Bash on Windows) rewrites an argument that looks like an absolute
|
|
33
|
+
* POSIX path into a Windows one, so
|
|
34
|
+
*
|
|
35
|
+
* ck dashboard api GET /v1/call-analyzers
|
|
36
|
+
*
|
|
37
|
+
* arrives in `process.argv` as `C:/Program Files/Git/v1/call-analyzers` — the
|
|
38
|
+
* leading slash is replaced by the shell's own root and the original path
|
|
39
|
+
* follows it. The argument is then refused with "path must start with /",
|
|
40
|
+
* which reads like a CLI bug rather than a shell quirk.
|
|
41
|
+
*
|
|
42
|
+
* The repair finds the known route segment as a whole path segment and takes
|
|
43
|
+
* the path from there. Boundaries matter: `monitoring` must not match the
|
|
44
|
+
* segment `monitor`, and a segment must not match in the middle of a name.
|
|
45
|
+
*
|
|
46
|
+
* Only the listed segments are repaired: a path that contains none of them is
|
|
47
|
+
* left alone, and the caller's own "must start with /" check then reports it.
|
|
48
|
+
* Guessing a split point would turn a wrong path into a different wrong path,
|
|
49
|
+
* silently.
|
|
50
|
+
*/
|
|
51
|
+
function repairPosixPath(raw, segments) {
|
|
52
|
+
if (raw.startsWith('/'))
|
|
53
|
+
return raw;
|
|
54
|
+
for (const segment of segments) {
|
|
55
|
+
let from = 0;
|
|
56
|
+
for (;;) {
|
|
57
|
+
const i = raw.indexOf(segment, from);
|
|
58
|
+
if (i < 0)
|
|
59
|
+
break;
|
|
60
|
+
const before = raw[i - 1];
|
|
61
|
+
const after = raw[i + segment.length];
|
|
62
|
+
const leftOk = i === 0 || before === '/' || before === '\\' || before === ':';
|
|
63
|
+
const rightOk = after === undefined || after === '/' || after === '?' || after === '&';
|
|
64
|
+
if (leftOk && rightOk)
|
|
65
|
+
return '/' + raw.slice(i);
|
|
66
|
+
from = i + 1;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return raw;
|
|
70
|
+
}
|
|
28
71
|
/**
|
|
29
72
|
* Parse `raw` as JSON, repairing shell-stripped quotes if the strict parse fails.
|
|
30
73
|
*
|