@persistmemory/cli 0.2.1 → 0.2.3
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/bin.js +29 -9
- package/dist/bin.js.map +2 -2
- package/dist/index.js +29 -9
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1525,7 +1525,7 @@ function shortDate(iso) {
|
|
|
1525
1525
|
}
|
|
1526
1526
|
|
|
1527
1527
|
// src/help.ts
|
|
1528
|
-
var VERSION = true ? "0.2.
|
|
1528
|
+
var VERSION = true ? "0.2.3" : versionFromManifest();
|
|
1529
1529
|
var PACKAGE = "@persistmemory/cli";
|
|
1530
1530
|
var HELP = `
|
|
1531
1531
|
pm \u2014 PersistMemory from your terminal
|
|
@@ -1744,7 +1744,17 @@ async function startLoopback(options = {}) {
|
|
|
1744
1744
|
// This page is one-use and holds a result; nothing should keep it.
|
|
1745
1745
|
"cache-control": "no-store",
|
|
1746
1746
|
// It never loads anything, so it is not allowed to.
|
|
1747
|
-
"content-security-policy": "default-src 'none'; style-src 'unsafe-inline'"
|
|
1747
|
+
"content-security-policy": "default-src 'none'; style-src 'unsafe-inline'",
|
|
1748
|
+
/*
|
|
1749
|
+
Not kept alive, because a kept socket keeps the PROCESS alive.
|
|
1750
|
+
|
|
1751
|
+
`server.close()` stops new connections and leaves established ones
|
|
1752
|
+
open, and a browser holds this one open by default — so `pm auth login`
|
|
1753
|
+
printed "Signed in" and then sat there until somebody pressed Ctrl+C.
|
|
1754
|
+
The page is the last thing this server ever serves; there is nothing to
|
|
1755
|
+
reuse the connection for.
|
|
1756
|
+
*/
|
|
1757
|
+
connection: "close"
|
|
1748
1758
|
});
|
|
1749
1759
|
response.end(donePage(callback));
|
|
1750
1760
|
resolveCallback?.(callback);
|
|
@@ -1776,7 +1786,9 @@ async function startLoopback(options = {}) {
|
|
|
1776
1786
|
},
|
|
1777
1787
|
close() {
|
|
1778
1788
|
clearTimeout(timer);
|
|
1789
|
+
server.closeAllConnections?.();
|
|
1779
1790
|
server.close();
|
|
1791
|
+
server.unref();
|
|
1780
1792
|
}
|
|
1781
1793
|
};
|
|
1782
1794
|
}
|
|
@@ -2062,7 +2074,7 @@ async function clientFor(resolved, deps) {
|
|
|
2062
2074
|
});
|
|
2063
2075
|
}
|
|
2064
2076
|
async function currentCredential(resolved, deps) {
|
|
2065
|
-
const credential = resolved.credential;
|
|
2077
|
+
const credential = resolved.fromEnvironment ? resolved.credential : readCredentials(deps.paths)[resolved.profile] ?? resolved.credential;
|
|
2066
2078
|
if (!credential) throw new NotSignedIn();
|
|
2067
2079
|
if (!isExpired(credential, deps.now?.() ?? Date.now())) return credential;
|
|
2068
2080
|
if (!credential.refreshToken || !resolved.clientId) {
|
|
@@ -2083,14 +2095,18 @@ async function currentCredential(resolved, deps) {
|
|
|
2083
2095
|
|
|
2084
2096
|
// src/context.ts
|
|
2085
2097
|
import { createInterface } from "node:readline";
|
|
2086
|
-
async function askOnTty(prompt) {
|
|
2098
|
+
async function askOnTty(prompt, input = process.stdin, output = process.stdout) {
|
|
2087
2099
|
return new Promise((resolve8) => {
|
|
2088
|
-
const readline = createInterface({ input
|
|
2100
|
+
const readline = createInterface({ input, output });
|
|
2101
|
+
let answered = false;
|
|
2089
2102
|
readline.question(prompt, (answer3) => {
|
|
2090
|
-
|
|
2103
|
+
answered = true;
|
|
2091
2104
|
resolve8(answer3.trim());
|
|
2105
|
+
readline.close();
|
|
2106
|
+
});
|
|
2107
|
+
readline.once("close", () => {
|
|
2108
|
+
if (!answered) resolve8("");
|
|
2092
2109
|
});
|
|
2093
|
-
readline.once("close", () => resolve8(""));
|
|
2094
2110
|
});
|
|
2095
2111
|
}
|
|
2096
2112
|
var ETX = "";
|
|
@@ -2101,11 +2117,15 @@ async function readSecretFromTty(prompt) {
|
|
|
2101
2117
|
if (!input.isTTY) {
|
|
2102
2118
|
return new Promise((resolve8) => {
|
|
2103
2119
|
const readline = createInterface({ input });
|
|
2120
|
+
let answered = false;
|
|
2104
2121
|
readline.once("line", (line) => {
|
|
2105
|
-
|
|
2122
|
+
answered = true;
|
|
2106
2123
|
resolve8(line.trim());
|
|
2124
|
+
readline.close();
|
|
2125
|
+
});
|
|
2126
|
+
readline.once("close", () => {
|
|
2127
|
+
if (!answered) resolve8("");
|
|
2107
2128
|
});
|
|
2108
|
-
readline.once("close", () => resolve8(""));
|
|
2109
2129
|
});
|
|
2110
2130
|
}
|
|
2111
2131
|
process.stdout.write(prompt);
|