pterocli 1.1.5 → 1.2.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/dist/cli.js +56 -37
- package/package.json +4 -1
package/dist/cli.js
CHANGED
|
@@ -163,9 +163,9 @@ var require_main = __commonJS({
|
|
|
163
163
|
const attrs = _instructions(result, key);
|
|
164
164
|
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
165
165
|
break;
|
|
166
|
-
} catch (
|
|
166
|
+
} catch (error47) {
|
|
167
167
|
if (i + 1 >= length) {
|
|
168
|
-
throw
|
|
168
|
+
throw error47;
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
}
|
|
@@ -193,13 +193,13 @@ var require_main = __commonJS({
|
|
|
193
193
|
let uri;
|
|
194
194
|
try {
|
|
195
195
|
uri = new URL(dotenvKey);
|
|
196
|
-
} catch (
|
|
197
|
-
if (
|
|
196
|
+
} catch (error47) {
|
|
197
|
+
if (error47.code === "ERR_INVALID_URL") {
|
|
198
198
|
const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
|
|
199
199
|
err.code = "INVALID_DOTENV_KEY";
|
|
200
200
|
throw err;
|
|
201
201
|
}
|
|
202
|
-
throw
|
|
202
|
+
throw error47;
|
|
203
203
|
}
|
|
204
204
|
const key = uri.password;
|
|
205
205
|
if (!key) {
|
|
@@ -345,10 +345,10 @@ var require_main = __commonJS({
|
|
|
345
345
|
const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
|
|
346
346
|
aesgcm.setAuthTag(authTag);
|
|
347
347
|
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
348
|
-
} catch (
|
|
349
|
-
const isRange =
|
|
350
|
-
const invalidKeyLength =
|
|
351
|
-
const decryptionFailed =
|
|
348
|
+
} catch (error47) {
|
|
349
|
+
const isRange = error47 instanceof RangeError;
|
|
350
|
+
const invalidKeyLength = error47.message === "Invalid key length";
|
|
351
|
+
const decryptionFailed = error47.message === "Unsupported state or unable to authenticate data";
|
|
352
352
|
if (isRange || invalidKeyLength) {
|
|
353
353
|
const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
|
354
354
|
err.code = "INVALID_DOTENV_KEY";
|
|
@@ -358,7 +358,7 @@ var require_main = __commonJS({
|
|
|
358
358
|
err.code = "DECRYPTION_FAILED";
|
|
359
359
|
throw err;
|
|
360
360
|
} else {
|
|
361
|
-
throw
|
|
361
|
+
throw error47;
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
364
|
}
|
|
@@ -461,6 +461,7 @@ var require_cli_options = __commonJS({
|
|
|
461
461
|
|
|
462
462
|
// src/cli.ts
|
|
463
463
|
import { parseArgs } from "util";
|
|
464
|
+
import * as readline from "readline";
|
|
464
465
|
|
|
465
466
|
// node_modules/zod/v4/classic/external.js
|
|
466
467
|
var external_exports = {};
|
|
@@ -1675,10 +1676,10 @@ var initializer = (inst, def) => {
|
|
|
1675
1676
|
};
|
|
1676
1677
|
var $ZodError = $constructor("$ZodError", initializer);
|
|
1677
1678
|
var $ZodRealError = $constructor("$ZodError", initializer, { Parent: Error });
|
|
1678
|
-
function flattenError(
|
|
1679
|
+
function flattenError(error47, mapper = (issue2) => issue2.message) {
|
|
1679
1680
|
const fieldErrors = {};
|
|
1680
1681
|
const formErrors = [];
|
|
1681
|
-
for (const sub of
|
|
1682
|
+
for (const sub of error47.issues) {
|
|
1682
1683
|
if (sub.path.length > 0) {
|
|
1683
1684
|
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
1684
1685
|
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
@@ -1688,10 +1689,10 @@ function flattenError(error46, mapper = (issue2) => issue2.message) {
|
|
|
1688
1689
|
}
|
|
1689
1690
|
return { formErrors, fieldErrors };
|
|
1690
1691
|
}
|
|
1691
|
-
function formatError(
|
|
1692
|
+
function formatError(error47, mapper = (issue2) => issue2.message) {
|
|
1692
1693
|
const fieldErrors = { _errors: [] };
|
|
1693
|
-
const processError = (
|
|
1694
|
-
for (const issue2 of
|
|
1694
|
+
const processError = (error48) => {
|
|
1695
|
+
for (const issue2 of error48.issues) {
|
|
1695
1696
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1696
1697
|
issue2.errors.map((issues) => processError({ issues }));
|
|
1697
1698
|
} else if (issue2.code === "invalid_key") {
|
|
@@ -1718,14 +1719,14 @@ function formatError(error46, mapper = (issue2) => issue2.message) {
|
|
|
1718
1719
|
}
|
|
1719
1720
|
}
|
|
1720
1721
|
};
|
|
1721
|
-
processError(
|
|
1722
|
+
processError(error47);
|
|
1722
1723
|
return fieldErrors;
|
|
1723
1724
|
}
|
|
1724
|
-
function treeifyError(
|
|
1725
|
+
function treeifyError(error47, mapper = (issue2) => issue2.message) {
|
|
1725
1726
|
const result = { errors: [] };
|
|
1726
|
-
const processError = (
|
|
1727
|
+
const processError = (error48, path = []) => {
|
|
1727
1728
|
var _a, _b;
|
|
1728
|
-
for (const issue2 of
|
|
1729
|
+
for (const issue2 of error48.issues) {
|
|
1729
1730
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1730
1731
|
issue2.errors.map((issues) => processError({ issues }, issue2.path));
|
|
1731
1732
|
} else if (issue2.code === "invalid_key") {
|
|
@@ -1760,7 +1761,7 @@ function treeifyError(error46, mapper = (issue2) => issue2.message) {
|
|
|
1760
1761
|
}
|
|
1761
1762
|
}
|
|
1762
1763
|
};
|
|
1763
|
-
processError(
|
|
1764
|
+
processError(error47);
|
|
1764
1765
|
return result;
|
|
1765
1766
|
}
|
|
1766
1767
|
function toDotPath(_path) {
|
|
@@ -1781,9 +1782,9 @@ function toDotPath(_path) {
|
|
|
1781
1782
|
}
|
|
1782
1783
|
return segs.join("");
|
|
1783
1784
|
}
|
|
1784
|
-
function prettifyError(
|
|
1785
|
+
function prettifyError(error47) {
|
|
1785
1786
|
const lines = [];
|
|
1786
|
-
const issues = [...
|
|
1787
|
+
const issues = [...error47.issues].sort((a, b) => (a.path ?? []).length - (b.path ?? []).length);
|
|
1787
1788
|
for (const issue2 of issues) {
|
|
1788
1789
|
lines.push(`\u2716 ${issue2.message}`);
|
|
1789
1790
|
if (issue2.path?.length)
|
|
@@ -13060,9 +13061,6 @@ function createServerContext(options) {
|
|
|
13060
13061
|
};
|
|
13061
13062
|
}
|
|
13062
13063
|
|
|
13063
|
-
// src/cli.ts
|
|
13064
|
-
import * as readline from "readline";
|
|
13065
|
-
|
|
13066
13064
|
// node_modules/dotenv/config.js
|
|
13067
13065
|
(function() {
|
|
13068
13066
|
require_main().config(
|
|
@@ -13075,6 +13073,9 @@ import * as readline from "readline";
|
|
|
13075
13073
|
})();
|
|
13076
13074
|
|
|
13077
13075
|
// src/cli.ts
|
|
13076
|
+
import { join } from "path";
|
|
13077
|
+
import { tmpdir } from "os";
|
|
13078
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
13078
13079
|
var { values, positionals } = parseArgs({
|
|
13079
13080
|
args: process.argv,
|
|
13080
13081
|
options: {
|
|
@@ -13118,20 +13119,39 @@ var socket = new WebSocket(socketUrl, {
|
|
|
13118
13119
|
origin: API_URL
|
|
13119
13120
|
}
|
|
13120
13121
|
});
|
|
13122
|
+
socket.addEventListener("open", () => {
|
|
13123
|
+
socket.send(JSON.stringify({ event: "auth", args: [token] }));
|
|
13124
|
+
});
|
|
13125
|
+
var historyFile = join(tmpdir(), "ptcli_history");
|
|
13126
|
+
if (!existsSync(historyFile)) {
|
|
13127
|
+
writeFileSync(historyFile, "");
|
|
13128
|
+
}
|
|
13129
|
+
var history = readFileSync(historyFile, "utf-8").split("\n").filter(Boolean);
|
|
13121
13130
|
var rl = readline.createInterface({
|
|
13122
13131
|
input: process.stdin,
|
|
13123
13132
|
output: process.stdout,
|
|
13124
13133
|
prompt: "> ",
|
|
13125
|
-
terminal: true
|
|
13126
|
-
|
|
13127
|
-
|
|
13128
|
-
|
|
13129
|
-
|
|
13134
|
+
terminal: true,
|
|
13135
|
+
history,
|
|
13136
|
+
historySize: 100
|
|
13137
|
+
});
|
|
13138
|
+
function log(...args) {
|
|
13139
|
+
readline.clearLine(process.stdout, 0);
|
|
13140
|
+
readline.cursorTo(process.stdout, 0);
|
|
13141
|
+
console.log(...args);
|
|
13142
|
+
rl.prompt();
|
|
13143
|
+
}
|
|
13144
|
+
function error46(...args) {
|
|
13145
|
+
readline.clearLine(process.stdout, 0);
|
|
13146
|
+
readline.cursorTo(process.stdout, 0);
|
|
13147
|
+
console.error(...args);
|
|
13148
|
+
rl.prompt();
|
|
13149
|
+
}
|
|
13130
13150
|
socket.addEventListener("message", (msg) => {
|
|
13131
13151
|
const json2 = JSON.parse(msg.data);
|
|
13132
13152
|
const parseResult = external_exports.safeParse(websocketResponseSchema, json2);
|
|
13133
13153
|
if (!parseResult.success) {
|
|
13134
|
-
|
|
13154
|
+
error46(`Error parsing socket event: ${parseResult.error.message}`);
|
|
13135
13155
|
return;
|
|
13136
13156
|
}
|
|
13137
13157
|
const data = parseResult.data;
|
|
@@ -13139,17 +13159,13 @@ socket.addEventListener("message", (msg) => {
|
|
|
13139
13159
|
socket.send(JSON.stringify({ event: "send logs", args: [null] }));
|
|
13140
13160
|
}
|
|
13141
13161
|
if (data.event == "console output") {
|
|
13142
|
-
|
|
13143
|
-
readline.clearLine(process.stdout, 0);
|
|
13144
|
-
console.log(data.args[0]);
|
|
13145
|
-
rl.prompt(true);
|
|
13162
|
+
log(data.args[0]);
|
|
13146
13163
|
}
|
|
13147
13164
|
});
|
|
13148
13165
|
socket.addEventListener("close", (e) => {
|
|
13149
|
-
|
|
13166
|
+
error46(e.reason);
|
|
13150
13167
|
});
|
|
13151
13168
|
rl.on("line", (line) => {
|
|
13152
|
-
console.log("found line", line);
|
|
13153
13169
|
socket.send(
|
|
13154
13170
|
JSON.stringify({
|
|
13155
13171
|
event: "send command",
|
|
@@ -13157,3 +13173,6 @@ rl.on("line", (line) => {
|
|
|
13157
13173
|
})
|
|
13158
13174
|
);
|
|
13159
13175
|
});
|
|
13176
|
+
rl.addListener("history", (history2) => {
|
|
13177
|
+
writeFileSync(historyFile, history2.join("\n"));
|
|
13178
|
+
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pterocli",
|
|
3
3
|
"module": "src/cli.ts",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "tsup",
|
|
@@ -24,5 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@types/node": "^25.2.3"
|
|
27
|
+
},
|
|
28
|
+
"allowScripts": {
|
|
29
|
+
"esbuild@0.27.3": true
|
|
27
30
|
}
|
|
28
31
|
}
|