@keynv/cli 0.1.0-rc.7 → 0.1.0-rc.8
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/index.js +1146 -804
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
3
|
import 'crypto';
|
|
4
|
-
import { readFileSync, existsSync, statSync,
|
|
4
|
+
import { readFileSync, existsSync, statSync, writeFileSync, unlinkSync, mkdirSync, rmSync, readdirSync } from 'fs';
|
|
5
5
|
import { homedir } from 'os';
|
|
6
|
-
import { isAbsolute, resolve, join, dirname } from 'path';
|
|
6
|
+
import { isAbsolute, resolve, join, dirname, basename } from 'path';
|
|
7
7
|
import { Entry } from '@napi-rs/keyring';
|
|
8
8
|
import { styleText } from 'util';
|
|
9
9
|
import j2, { stdin, stdout } from 'process';
|
|
@@ -1056,7 +1056,7 @@ var require_lib = __commonJS({
|
|
|
1056
1056
|
var VERSION, AGENT;
|
|
1057
1057
|
var init_version = __esm({
|
|
1058
1058
|
"src/version.ts"() {
|
|
1059
|
-
VERSION = "0.1.0-rc.
|
|
1059
|
+
VERSION = "0.1.0-rc.8" ;
|
|
1060
1060
|
AGENT = `keynv-cli/${VERSION}`;
|
|
1061
1061
|
}
|
|
1062
1062
|
});
|
|
@@ -5716,6 +5716,137 @@ var init_format = __esm({
|
|
|
5716
5716
|
"src/ui/format.ts"() {
|
|
5717
5717
|
}
|
|
5718
5718
|
});
|
|
5719
|
+
function parseEnvFile(content, filename) {
|
|
5720
|
+
const normalized = content.charCodeAt(0) === 65279 ? content.slice(1) : content;
|
|
5721
|
+
const lines = normalized.split(/\r?\n/);
|
|
5722
|
+
const entries = [];
|
|
5723
|
+
for (let i = 0; i < lines.length; i++) {
|
|
5724
|
+
const raw = lines[i] ?? "";
|
|
5725
|
+
const lineNo = i + 1;
|
|
5726
|
+
const trimmed = raw.trim();
|
|
5727
|
+
if (trimmed.length === 0) continue;
|
|
5728
|
+
if (trimmed.startsWith("#")) continue;
|
|
5729
|
+
let body = trimmed;
|
|
5730
|
+
if (body.startsWith("export ")) {
|
|
5731
|
+
body = body.slice("export ".length).trimStart();
|
|
5732
|
+
}
|
|
5733
|
+
const eq = body.indexOf("=");
|
|
5734
|
+
if (eq <= 0) {
|
|
5735
|
+
throw new EnvFileParseError(filename, lineNo, "expected 'KEY=value'");
|
|
5736
|
+
}
|
|
5737
|
+
const name = body.slice(0, eq).trim();
|
|
5738
|
+
if (!KEY_RE2.test(name)) {
|
|
5739
|
+
throw new EnvFileParseError(
|
|
5740
|
+
filename,
|
|
5741
|
+
lineNo,
|
|
5742
|
+
`invalid key '${name}' (must match /^[A-Za-z_][A-Za-z0-9_]*$/)`
|
|
5743
|
+
);
|
|
5744
|
+
}
|
|
5745
|
+
let valueRaw = body.slice(eq + 1);
|
|
5746
|
+
let value;
|
|
5747
|
+
const valueLeading = valueRaw.replace(/^\s+/, "");
|
|
5748
|
+
const firstCh = valueLeading.charAt(0);
|
|
5749
|
+
if (firstCh === '"' || firstCh === "'") {
|
|
5750
|
+
const close = valueLeading.lastIndexOf(firstCh);
|
|
5751
|
+
if (close === 0) {
|
|
5752
|
+
throw new EnvFileParseError(filename, lineNo, `unclosed ${firstCh} quote`);
|
|
5753
|
+
}
|
|
5754
|
+
const after = valueLeading.slice(close + 1).trim();
|
|
5755
|
+
if (after.length > 0) {
|
|
5756
|
+
throw new EnvFileParseError(
|
|
5757
|
+
filename,
|
|
5758
|
+
lineNo,
|
|
5759
|
+
`unexpected content after closing ${firstCh}`
|
|
5760
|
+
);
|
|
5761
|
+
}
|
|
5762
|
+
value = valueLeading.slice(1, close);
|
|
5763
|
+
} else {
|
|
5764
|
+
value = valueRaw.replace(/\s+$/, "");
|
|
5765
|
+
value = value.replace(/^\s+/, "");
|
|
5766
|
+
}
|
|
5767
|
+
entries.push({
|
|
5768
|
+
name,
|
|
5769
|
+
value,
|
|
5770
|
+
isAlias: parseAlias(value) !== null,
|
|
5771
|
+
line: lineNo
|
|
5772
|
+
});
|
|
5773
|
+
}
|
|
5774
|
+
return entries;
|
|
5775
|
+
}
|
|
5776
|
+
function findEnvFile(startDir) {
|
|
5777
|
+
let dir = resolve(startDir);
|
|
5778
|
+
for (let i = 0; i < 64; i++) {
|
|
5779
|
+
const candidate = join(dir, ENV_FILE_BASENAME);
|
|
5780
|
+
if (existsSync(candidate)) {
|
|
5781
|
+
try {
|
|
5782
|
+
if (statSync(candidate).isFile()) return candidate;
|
|
5783
|
+
} catch {
|
|
5784
|
+
}
|
|
5785
|
+
}
|
|
5786
|
+
const parent = dirname(dir);
|
|
5787
|
+
if (parent === dir) return null;
|
|
5788
|
+
dir = parent;
|
|
5789
|
+
}
|
|
5790
|
+
return null;
|
|
5791
|
+
}
|
|
5792
|
+
function loadEnvFile(opts) {
|
|
5793
|
+
if (opts.disabled) return null;
|
|
5794
|
+
const pickExplicit = opts.explicitPath ?? opts.envVarOverride;
|
|
5795
|
+
let path = null;
|
|
5796
|
+
if (pickExplicit !== void 0) {
|
|
5797
|
+
path = isAbsolute(pickExplicit) ? pickExplicit : resolve(opts.cwd, pickExplicit);
|
|
5798
|
+
if (!existsSync(path)) throw new EnvFileNotFoundError(path);
|
|
5799
|
+
} else {
|
|
5800
|
+
path = findEnvFile(opts.cwd);
|
|
5801
|
+
}
|
|
5802
|
+
if (path === null) return null;
|
|
5803
|
+
const stat = statSync(path);
|
|
5804
|
+
if (stat.size > MAX_FILE_BYTES) {
|
|
5805
|
+
throw new EnvFileTooLargeError(path, stat.size);
|
|
5806
|
+
}
|
|
5807
|
+
const content = readFileSync(path, "utf8");
|
|
5808
|
+
const entries = parseEnvFile(content, path);
|
|
5809
|
+
return { path, entries };
|
|
5810
|
+
}
|
|
5811
|
+
var MAX_FILE_BYTES, KEY_RE2, ENV_FILE_BASENAME, EnvFileParseError, EnvFileNotFoundError, EnvFileTooLargeError;
|
|
5812
|
+
var init_envFile = __esm({
|
|
5813
|
+
"src/exec/envFile.ts"() {
|
|
5814
|
+
init_dist();
|
|
5815
|
+
MAX_FILE_BYTES = 1e6;
|
|
5816
|
+
KEY_RE2 = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
5817
|
+
ENV_FILE_BASENAME = ".keynv.env";
|
|
5818
|
+
EnvFileParseError = class extends Error {
|
|
5819
|
+
constructor(file, line, reason) {
|
|
5820
|
+
super(`${file}:${line}: ${reason}`);
|
|
5821
|
+
this.file = file;
|
|
5822
|
+
this.line = line;
|
|
5823
|
+
this.reason = reason;
|
|
5824
|
+
this.name = "EnvFileParseError";
|
|
5825
|
+
}
|
|
5826
|
+
file;
|
|
5827
|
+
line;
|
|
5828
|
+
reason;
|
|
5829
|
+
};
|
|
5830
|
+
EnvFileNotFoundError = class extends Error {
|
|
5831
|
+
constructor(path) {
|
|
5832
|
+
super(`env file not found: ${path}`);
|
|
5833
|
+
this.path = path;
|
|
5834
|
+
this.name = "EnvFileNotFoundError";
|
|
5835
|
+
}
|
|
5836
|
+
path;
|
|
5837
|
+
};
|
|
5838
|
+
EnvFileTooLargeError = class extends Error {
|
|
5839
|
+
constructor(path, bytes) {
|
|
5840
|
+
super(`env file ${path} is ${bytes} bytes (max ${MAX_FILE_BYTES})`);
|
|
5841
|
+
this.path = path;
|
|
5842
|
+
this.bytes = bytes;
|
|
5843
|
+
this.name = "EnvFileTooLargeError";
|
|
5844
|
+
}
|
|
5845
|
+
path;
|
|
5846
|
+
bytes;
|
|
5847
|
+
};
|
|
5848
|
+
}
|
|
5849
|
+
});
|
|
5719
5850
|
|
|
5720
5851
|
// src/ui/helpers/tty.ts
|
|
5721
5852
|
var tty_exports = {};
|
|
@@ -6095,7 +6226,7 @@ var require_src = __commonJS({
|
|
|
6095
6226
|
var ESC2 = "\x1B";
|
|
6096
6227
|
var CSI2 = `${ESC2}[`;
|
|
6097
6228
|
var beep = "\x07";
|
|
6098
|
-
var
|
|
6229
|
+
var cursor = {
|
|
6099
6230
|
to(x, y) {
|
|
6100
6231
|
if (!y) return `${CSI2}${x + 1}G`;
|
|
6101
6232
|
return `${CSI2}${y + 1};${x + 1}H`;
|
|
@@ -6134,13 +6265,13 @@ var require_src = __commonJS({
|
|
|
6134
6265
|
lines(count) {
|
|
6135
6266
|
let clear = "";
|
|
6136
6267
|
for (let i = 0; i < count; i++)
|
|
6137
|
-
clear += this.line + (i < count - 1 ?
|
|
6268
|
+
clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
6138
6269
|
if (count)
|
|
6139
|
-
clear +=
|
|
6270
|
+
clear += cursor.left;
|
|
6140
6271
|
return clear;
|
|
6141
6272
|
}
|
|
6142
6273
|
};
|
|
6143
|
-
module.exports = { cursor
|
|
6274
|
+
module.exports = { cursor, scroll, erase, beep };
|
|
6144
6275
|
}
|
|
6145
6276
|
});
|
|
6146
6277
|
function d(r, t, s) {
|
|
@@ -6884,6 +7015,413 @@ ${c2}
|
|
|
6884
7015
|
} }).prompt();
|
|
6885
7016
|
}
|
|
6886
7017
|
});
|
|
7018
|
+
function findProjectRoot(startDir) {
|
|
7019
|
+
let dir = resolve(startDir);
|
|
7020
|
+
for (let i = 0; i < 64; i++) {
|
|
7021
|
+
for (const marker of PROJECT_MARKERS) {
|
|
7022
|
+
const candidate = join(dir, marker);
|
|
7023
|
+
if (existsSync(candidate)) {
|
|
7024
|
+
return buildRoot(dir, marker);
|
|
7025
|
+
}
|
|
7026
|
+
}
|
|
7027
|
+
if (existsSync(join(dir, GIT_MARKER))) {
|
|
7028
|
+
return buildRoot(dir, GIT_MARKER);
|
|
7029
|
+
}
|
|
7030
|
+
const parent = dirname(dir);
|
|
7031
|
+
if (parent === dir) return null;
|
|
7032
|
+
dir = parent;
|
|
7033
|
+
}
|
|
7034
|
+
return null;
|
|
7035
|
+
}
|
|
7036
|
+
function buildRoot(dir, marker) {
|
|
7037
|
+
let suggestedName = basename(dir);
|
|
7038
|
+
let scripts = null;
|
|
7039
|
+
let invalid = false;
|
|
7040
|
+
if (marker === "package.json" || existsSync(join(dir, "package.json"))) {
|
|
7041
|
+
try {
|
|
7042
|
+
const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
|
|
7043
|
+
if (typeof pkg.name === "string" && pkg.name.length > 0) {
|
|
7044
|
+
suggestedName = pkg.name.replace(/^@[^/]+\//, "");
|
|
7045
|
+
}
|
|
7046
|
+
if (pkg.scripts && typeof pkg.scripts === "object") {
|
|
7047
|
+
scripts = Object.fromEntries(
|
|
7048
|
+
Object.entries(pkg.scripts).filter(
|
|
7049
|
+
([, v2]) => typeof v2 === "string"
|
|
7050
|
+
)
|
|
7051
|
+
);
|
|
7052
|
+
}
|
|
7053
|
+
} catch {
|
|
7054
|
+
invalid = true;
|
|
7055
|
+
}
|
|
7056
|
+
}
|
|
7057
|
+
return { path: dir, suggestedName, marker, packageJsonScripts: scripts, packageJsonInvalid: invalid };
|
|
7058
|
+
}
|
|
7059
|
+
function findEnvFiles(rootDir) {
|
|
7060
|
+
let entries;
|
|
7061
|
+
try {
|
|
7062
|
+
entries = readdirSync(rootDir);
|
|
7063
|
+
} catch {
|
|
7064
|
+
return [];
|
|
7065
|
+
}
|
|
7066
|
+
const hits = [];
|
|
7067
|
+
for (const name of entries) {
|
|
7068
|
+
if (!ENV_GLOB.test(name)) continue;
|
|
7069
|
+
if (ENV_EXAMPLE.test(name)) continue;
|
|
7070
|
+
if (name === KEYNV_ENV_BASENAME) continue;
|
|
7071
|
+
const full = join(rootDir, name);
|
|
7072
|
+
try {
|
|
7073
|
+
if (!statSync(full).isFile()) continue;
|
|
7074
|
+
} catch {
|
|
7075
|
+
continue;
|
|
7076
|
+
}
|
|
7077
|
+
const suffixMatch = name.match(/^\.env\.(.+)$/);
|
|
7078
|
+
const suffix = suffixMatch ? suffixMatch[1] : null;
|
|
7079
|
+
hits.push({ path: full, name, suffix, suggestedEnv: suggestedEnvForSuffix(suffix) });
|
|
7080
|
+
}
|
|
7081
|
+
hits.sort((a, b2) => {
|
|
7082
|
+
if (a.suffix === null) return -1;
|
|
7083
|
+
if (b2.suffix === null) return 1;
|
|
7084
|
+
return a.name.localeCompare(b2.name);
|
|
7085
|
+
});
|
|
7086
|
+
return hits;
|
|
7087
|
+
}
|
|
7088
|
+
function suggestedEnvForSuffix(suffix) {
|
|
7089
|
+
if (suffix === null) return "dev";
|
|
7090
|
+
switch (suffix) {
|
|
7091
|
+
case "local":
|
|
7092
|
+
case "development":
|
|
7093
|
+
case "dev":
|
|
7094
|
+
return "dev";
|
|
7095
|
+
case "production":
|
|
7096
|
+
case "prod":
|
|
7097
|
+
return "prod";
|
|
7098
|
+
case "staging":
|
|
7099
|
+
case "stage":
|
|
7100
|
+
return "staging";
|
|
7101
|
+
case "test":
|
|
7102
|
+
return "test";
|
|
7103
|
+
case "preview":
|
|
7104
|
+
return "preview";
|
|
7105
|
+
default:
|
|
7106
|
+
return suffix;
|
|
7107
|
+
}
|
|
7108
|
+
}
|
|
7109
|
+
function hasExistingKeynvEnv(rootDir) {
|
|
7110
|
+
return existsSync(join(rootDir, KEYNV_ENV_BASENAME));
|
|
7111
|
+
}
|
|
7112
|
+
var PROJECT_MARKERS, GIT_MARKER, ENV_GLOB, ENV_EXAMPLE, KEYNV_ENV_BASENAME;
|
|
7113
|
+
var init_detect = __esm({
|
|
7114
|
+
"src/init/detect.ts"() {
|
|
7115
|
+
PROJECT_MARKERS = [
|
|
7116
|
+
"package.json",
|
|
7117
|
+
"pyproject.toml",
|
|
7118
|
+
"Cargo.toml",
|
|
7119
|
+
"go.mod",
|
|
7120
|
+
"pnpm-workspace.yaml",
|
|
7121
|
+
"deno.json",
|
|
7122
|
+
"deno.jsonc",
|
|
7123
|
+
"requirements.txt"
|
|
7124
|
+
];
|
|
7125
|
+
GIT_MARKER = ".git";
|
|
7126
|
+
ENV_GLOB = /^\.env(\.[A-Za-z0-9_-]+)?$/;
|
|
7127
|
+
ENV_EXAMPLE = /^\.env\.(example|sample|template)$/;
|
|
7128
|
+
KEYNV_ENV_BASENAME = ".keynv.env";
|
|
7129
|
+
}
|
|
7130
|
+
});
|
|
7131
|
+
|
|
7132
|
+
// src/init/heuristics.ts
|
|
7133
|
+
function shannonEntropyBits(s) {
|
|
7134
|
+
if (s.length === 0) return 0;
|
|
7135
|
+
const counts = /* @__PURE__ */ new Map();
|
|
7136
|
+
for (const ch of s) counts.set(ch, (counts.get(ch) ?? 0) + 1);
|
|
7137
|
+
let h2 = 0;
|
|
7138
|
+
for (const c2 of counts.values()) {
|
|
7139
|
+
const p2 = c2 / s.length;
|
|
7140
|
+
h2 -= p2 * Math.log2(p2);
|
|
7141
|
+
}
|
|
7142
|
+
return h2;
|
|
7143
|
+
}
|
|
7144
|
+
function nameMatchesLiteralPrefix(name) {
|
|
7145
|
+
const upper = name.toUpperCase();
|
|
7146
|
+
return NAME_LITERAL_PREFIX.some((p2) => upper.startsWith(p2));
|
|
7147
|
+
}
|
|
7148
|
+
function nameMatchesSecretSuffix(name) {
|
|
7149
|
+
const upper = name.toUpperCase();
|
|
7150
|
+
for (const { suffix, hint } of NAME_SECRET_SUFFIXES) {
|
|
7151
|
+
if (upper.endsWith(suffix) || upper.endsWith(`_${suffix}`)) {
|
|
7152
|
+
return { matched: true, hint };
|
|
7153
|
+
}
|
|
7154
|
+
}
|
|
7155
|
+
return { matched: false, hint: "" };
|
|
7156
|
+
}
|
|
7157
|
+
function classifyEntry(name, value) {
|
|
7158
|
+
const upper = name.toUpperCase();
|
|
7159
|
+
if (NAME_LITERAL_EXACT.has(upper)) {
|
|
7160
|
+
return { verdict: "literal", hint: "common config var" };
|
|
7161
|
+
}
|
|
7162
|
+
if (nameMatchesLiteralPrefix(name)) {
|
|
7163
|
+
return { verdict: "literal", hint: "public env (build-time bundled)" };
|
|
7164
|
+
}
|
|
7165
|
+
if (value.length === 0) {
|
|
7166
|
+
return { verdict: "literal", hint: "empty" };
|
|
7167
|
+
}
|
|
7168
|
+
for (const { re, hint } of VALUE_PATTERNS) {
|
|
7169
|
+
if (re.test(value)) return { verdict: "secret", hint };
|
|
7170
|
+
}
|
|
7171
|
+
const suffix = nameMatchesSecretSuffix(name);
|
|
7172
|
+
if (suffix.matched) {
|
|
7173
|
+
return { verdict: "secret", hint: suffix.hint };
|
|
7174
|
+
}
|
|
7175
|
+
if (NAME_DB_URL.test(name)) {
|
|
7176
|
+
return { verdict: "secret", hint: "database URL" };
|
|
7177
|
+
}
|
|
7178
|
+
if (value.length >= 32) {
|
|
7179
|
+
const bits = shannonEntropyBits(value);
|
|
7180
|
+
if (bits >= 3.5) {
|
|
7181
|
+
return { verdict: "secret", hint: `${value.length}-char random-looking string` };
|
|
7182
|
+
}
|
|
7183
|
+
}
|
|
7184
|
+
return { verdict: "ambiguous", hint: "" };
|
|
7185
|
+
}
|
|
7186
|
+
function previewValue(value, max = 40) {
|
|
7187
|
+
if (value.length === 0) return "(empty)";
|
|
7188
|
+
if (value.length <= max) return value;
|
|
7189
|
+
return `${value.slice(0, max - 1)}\u2026`;
|
|
7190
|
+
}
|
|
7191
|
+
var NAME_LITERAL_EXACT, NAME_LITERAL_PREFIX, NAME_SECRET_SUFFIXES, NAME_DB_URL, VALUE_PATTERNS;
|
|
7192
|
+
var init_heuristics = __esm({
|
|
7193
|
+
"src/init/heuristics.ts"() {
|
|
7194
|
+
NAME_LITERAL_EXACT = /* @__PURE__ */ new Set([
|
|
7195
|
+
"NODE_ENV",
|
|
7196
|
+
"PORT",
|
|
7197
|
+
"HOST",
|
|
7198
|
+
"HOSTNAME",
|
|
7199
|
+
"DEBUG",
|
|
7200
|
+
"LOG_LEVEL",
|
|
7201
|
+
"LOGLEVEL",
|
|
7202
|
+
"TZ",
|
|
7203
|
+
"LANG",
|
|
7204
|
+
"LC_ALL",
|
|
7205
|
+
"PATH",
|
|
7206
|
+
"HOME",
|
|
7207
|
+
"USER",
|
|
7208
|
+
"SHELL",
|
|
7209
|
+
"PWD",
|
|
7210
|
+
"CI",
|
|
7211
|
+
"NODE_OPTIONS",
|
|
7212
|
+
"NPM_CONFIG_LOGLEVEL",
|
|
7213
|
+
"TS_NODE_PROJECT"
|
|
7214
|
+
]);
|
|
7215
|
+
NAME_LITERAL_PREFIX = ["NEXT_PUBLIC_", "VITE_", "REACT_APP_", "PUBLIC_", "EXPO_PUBLIC_"];
|
|
7216
|
+
NAME_SECRET_SUFFIXES = [
|
|
7217
|
+
{ suffix: "PRIVATE_KEY", hint: "private key" },
|
|
7218
|
+
{ suffix: "API_KEY", hint: "API key" },
|
|
7219
|
+
{ suffix: "ACCESS_KEY", hint: "access key" },
|
|
7220
|
+
{ suffix: "SECRET_KEY", hint: "secret key" },
|
|
7221
|
+
{ suffix: "SECRET", hint: "secret" },
|
|
7222
|
+
{ suffix: "PASSWORD", hint: "password" },
|
|
7223
|
+
{ suffix: "PASSPHRASE", hint: "passphrase" },
|
|
7224
|
+
{ suffix: "TOKEN", hint: "token" },
|
|
7225
|
+
{ suffix: "KEY", hint: "key" },
|
|
7226
|
+
{ suffix: "CREDENTIALS", hint: "credentials" },
|
|
7227
|
+
{ suffix: "AUTH", hint: "auth" },
|
|
7228
|
+
{ suffix: "DSN", hint: "connection string" }
|
|
7229
|
+
];
|
|
7230
|
+
NAME_DB_URL = /^(DATABASE|DB|POSTGRES|MYSQL|MONGO|REDIS)_URL$/i;
|
|
7231
|
+
VALUE_PATTERNS = [
|
|
7232
|
+
{ re: /^sk-proj-/, hint: "OpenAI project key" },
|
|
7233
|
+
{ re: /^sk-[A-Za-z0-9]{20,}/, hint: "OpenAI key" },
|
|
7234
|
+
{ re: /^sk_live_/, hint: "Stripe live key" },
|
|
7235
|
+
{ re: /^sk_test_/, hint: "Stripe test key" },
|
|
7236
|
+
{ re: /^pk_live_/, hint: "Stripe publishable (often public, double-check)" },
|
|
7237
|
+
{ re: /^xoxb-/, hint: "Slack bot token" },
|
|
7238
|
+
{ re: /^xoxp-/, hint: "Slack user token" },
|
|
7239
|
+
{ re: /^ghp_[A-Za-z0-9]{30,}/, hint: "GitHub personal access token" },
|
|
7240
|
+
{ re: /^github_pat_/, hint: "GitHub fine-grained PAT" },
|
|
7241
|
+
{ re: /^gho_/, hint: "GitHub OAuth token" },
|
|
7242
|
+
{ re: /^AKIA[0-9A-Z]{16}$/, hint: "AWS access key id" },
|
|
7243
|
+
{ re: /^ASIA[0-9A-Z]{16}$/, hint: "AWS temporary key id" },
|
|
7244
|
+
{ re: /^AIza[0-9A-Za-z_-]{35}$/, hint: "Google API key" },
|
|
7245
|
+
{ re: /^ya29\./, hint: "Google OAuth access token" },
|
|
7246
|
+
{ re: /^eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/, hint: "JWT" },
|
|
7247
|
+
{ re: /^-----BEGIN [A-Z ]+PRIVATE KEY-----/, hint: "PEM private key" },
|
|
7248
|
+
{ re: /^([a-z]+):\/\/[^@]+:[^@]+@/i, hint: "connection string with credentials" }
|
|
7249
|
+
];
|
|
7250
|
+
}
|
|
7251
|
+
});
|
|
7252
|
+
|
|
7253
|
+
// src/init/scriptWrap.ts
|
|
7254
|
+
function analyzeScript(name, command) {
|
|
7255
|
+
const trimmed = command.trim();
|
|
7256
|
+
if (trimmed.startsWith("keynv ") || trimmed.startsWith("keynv ")) {
|
|
7257
|
+
return {
|
|
7258
|
+
name,
|
|
7259
|
+
original: command,
|
|
7260
|
+
wrapped: command,
|
|
7261
|
+
verdict: "skip-already-wrapped",
|
|
7262
|
+
hint: "already wrapped"
|
|
7263
|
+
};
|
|
7264
|
+
}
|
|
7265
|
+
const firstWord = extractFirstCommandWord(trimmed);
|
|
7266
|
+
if (firstWord === null) {
|
|
7267
|
+
return {
|
|
7268
|
+
name,
|
|
7269
|
+
original: command,
|
|
7270
|
+
wrapped: `${KEYNV_PREFIX} ${command}`,
|
|
7271
|
+
verdict: "skip-unknown",
|
|
7272
|
+
hint: "cannot parse"
|
|
7273
|
+
};
|
|
7274
|
+
}
|
|
7275
|
+
const wrapped = `${KEYNV_PREFIX} ${command}`;
|
|
7276
|
+
if (ENV_AWARE_TOOLS.has(firstWord)) {
|
|
7277
|
+
return { name, original: command, wrapped, verdict: "wrap", hint: `${firstWord} reads env` };
|
|
7278
|
+
}
|
|
7279
|
+
if (NON_ENV_TOOLS.has(firstWord)) {
|
|
7280
|
+
return {
|
|
7281
|
+
name,
|
|
7282
|
+
original: command,
|
|
7283
|
+
wrapped,
|
|
7284
|
+
verdict: "skip-no-env-tool",
|
|
7285
|
+
hint: `${firstWord} doesn't need env`
|
|
7286
|
+
};
|
|
7287
|
+
}
|
|
7288
|
+
return {
|
|
7289
|
+
name,
|
|
7290
|
+
original: command,
|
|
7291
|
+
wrapped,
|
|
7292
|
+
verdict: "skip-unknown",
|
|
7293
|
+
hint: `unrecognized: ${firstWord}`
|
|
7294
|
+
};
|
|
7295
|
+
}
|
|
7296
|
+
function extractFirstCommandWord(s) {
|
|
7297
|
+
const tokens = s.split(/\s+/).filter((t) => t.length > 0);
|
|
7298
|
+
let i = 0;
|
|
7299
|
+
while (i < tokens.length) {
|
|
7300
|
+
const t = tokens[i];
|
|
7301
|
+
if (/^[A-Za-z_][A-Za-z0-9_]*=/.test(t)) {
|
|
7302
|
+
i++;
|
|
7303
|
+
continue;
|
|
7304
|
+
}
|
|
7305
|
+
if (t === "cross-env") {
|
|
7306
|
+
i++;
|
|
7307
|
+
while (i < tokens.length && /^[A-Za-z_][A-Za-z0-9_]*=/.test(tokens[i])) i++;
|
|
7308
|
+
continue;
|
|
7309
|
+
}
|
|
7310
|
+
if (t === "dotenv") {
|
|
7311
|
+
const dashDash = tokens.indexOf("--", i + 1);
|
|
7312
|
+
if (dashDash >= 0) {
|
|
7313
|
+
i = dashDash + 1;
|
|
7314
|
+
continue;
|
|
7315
|
+
}
|
|
7316
|
+
i++;
|
|
7317
|
+
while (i < tokens.length && tokens[i].startsWith("-")) i++;
|
|
7318
|
+
continue;
|
|
7319
|
+
}
|
|
7320
|
+
if (t === "sh" || t === "bash" || t === "zsh") {
|
|
7321
|
+
return null;
|
|
7322
|
+
}
|
|
7323
|
+
return t.replace(/^.*\//, "");
|
|
7324
|
+
}
|
|
7325
|
+
return null;
|
|
7326
|
+
}
|
|
7327
|
+
function planScriptWrap(scripts) {
|
|
7328
|
+
const recommended = [];
|
|
7329
|
+
const skipped = [];
|
|
7330
|
+
const unknown = [];
|
|
7331
|
+
for (const [name, command] of Object.entries(scripts)) {
|
|
7332
|
+
const analysis = analyzeScript(name, command);
|
|
7333
|
+
switch (analysis.verdict) {
|
|
7334
|
+
case "wrap":
|
|
7335
|
+
recommended.push(analysis);
|
|
7336
|
+
break;
|
|
7337
|
+
case "skip-unknown":
|
|
7338
|
+
unknown.push(analysis);
|
|
7339
|
+
break;
|
|
7340
|
+
default:
|
|
7341
|
+
skipped.push(analysis);
|
|
7342
|
+
}
|
|
7343
|
+
}
|
|
7344
|
+
return { recommended, skipped, unknown };
|
|
7345
|
+
}
|
|
7346
|
+
function applyWraps(original, selectedScriptNames) {
|
|
7347
|
+
const out = { ...original };
|
|
7348
|
+
const selection = new Set(selectedScriptNames);
|
|
7349
|
+
for (const [name, command] of Object.entries(original)) {
|
|
7350
|
+
if (!selection.has(name)) continue;
|
|
7351
|
+
const trimmed = command.trim();
|
|
7352
|
+
if (trimmed.startsWith("keynv ") || trimmed.startsWith("keynv ")) continue;
|
|
7353
|
+
out[name] = `${KEYNV_PREFIX} ${command}`;
|
|
7354
|
+
}
|
|
7355
|
+
return out;
|
|
7356
|
+
}
|
|
7357
|
+
var KEYNV_PREFIX, ENV_AWARE_TOOLS, NON_ENV_TOOLS;
|
|
7358
|
+
var init_scriptWrap = __esm({
|
|
7359
|
+
"src/init/scriptWrap.ts"() {
|
|
7360
|
+
KEYNV_PREFIX = "keynv exec --";
|
|
7361
|
+
ENV_AWARE_TOOLS = /* @__PURE__ */ new Set([
|
|
7362
|
+
"node",
|
|
7363
|
+
"tsx",
|
|
7364
|
+
"ts-node",
|
|
7365
|
+
"bun",
|
|
7366
|
+
"deno",
|
|
7367
|
+
"next",
|
|
7368
|
+
"nuxt",
|
|
7369
|
+
"vite",
|
|
7370
|
+
"remix",
|
|
7371
|
+
"astro",
|
|
7372
|
+
"gatsby",
|
|
7373
|
+
"nest",
|
|
7374
|
+
"webpack",
|
|
7375
|
+
"rollup",
|
|
7376
|
+
"parcel",
|
|
7377
|
+
"vitest",
|
|
7378
|
+
"jest",
|
|
7379
|
+
"mocha",
|
|
7380
|
+
"cypress",
|
|
7381
|
+
"playwright",
|
|
7382
|
+
"storybook",
|
|
7383
|
+
"tsc-watch",
|
|
7384
|
+
"pm2",
|
|
7385
|
+
"forever",
|
|
7386
|
+
"nodemon",
|
|
7387
|
+
"concurrently",
|
|
7388
|
+
"pytest",
|
|
7389
|
+
"python",
|
|
7390
|
+
"python3",
|
|
7391
|
+
"gunicorn",
|
|
7392
|
+
"uvicorn",
|
|
7393
|
+
"celery",
|
|
7394
|
+
"flask",
|
|
7395
|
+
"django-admin",
|
|
7396
|
+
"manage.py",
|
|
7397
|
+
"rails",
|
|
7398
|
+
"rake",
|
|
7399
|
+
"go",
|
|
7400
|
+
"cargo",
|
|
7401
|
+
"air"
|
|
7402
|
+
]);
|
|
7403
|
+
NON_ENV_TOOLS = /* @__PURE__ */ new Set([
|
|
7404
|
+
"eslint",
|
|
7405
|
+
"biome",
|
|
7406
|
+
"prettier",
|
|
7407
|
+
"tsc",
|
|
7408
|
+
"tslint",
|
|
7409
|
+
"stylelint",
|
|
7410
|
+
"rm",
|
|
7411
|
+
"cp",
|
|
7412
|
+
"mv",
|
|
7413
|
+
"mkdir",
|
|
7414
|
+
"echo",
|
|
7415
|
+
"cat",
|
|
7416
|
+
"find",
|
|
7417
|
+
"grep",
|
|
7418
|
+
"sort",
|
|
7419
|
+
"uniq",
|
|
7420
|
+
"sed",
|
|
7421
|
+
"awk"
|
|
7422
|
+
]);
|
|
7423
|
+
}
|
|
7424
|
+
});
|
|
6887
7425
|
|
|
6888
7426
|
// src/ui/helpers/cancel.ts
|
|
6889
7427
|
function unwrap(value) {
|
|
@@ -6925,6 +7463,419 @@ var init_pickProject = __esm({
|
|
|
6925
7463
|
}
|
|
6926
7464
|
});
|
|
6927
7465
|
|
|
7466
|
+
// src/ui/flows/init.ts
|
|
7467
|
+
var init_exports = {};
|
|
7468
|
+
__export(init_exports, {
|
|
7469
|
+
UserCancelled: () => UserCancelled,
|
|
7470
|
+
runInitFlow: () => runInitFlow
|
|
7471
|
+
});
|
|
7472
|
+
async function runInitFlow(client, opts) {
|
|
7473
|
+
ge("keynv init");
|
|
7474
|
+
const root = findProjectRoot(opts.cwd);
|
|
7475
|
+
if (root === null) {
|
|
7476
|
+
me(
|
|
7477
|
+
"Couldn't find a project root (no package.json, pyproject.toml, Cargo.toml, go.mod, or .git anywhere up the tree). Run `keynv init` inside a project directory."
|
|
7478
|
+
);
|
|
7479
|
+
return { exitCode: 1 };
|
|
7480
|
+
}
|
|
7481
|
+
if (root.packageJsonInvalid) {
|
|
7482
|
+
R2.warn(`package.json at ${root.path} is not valid JSON \u2014 script wrapping will be skipped.`);
|
|
7483
|
+
}
|
|
7484
|
+
const envFiles = findEnvFiles(root.path);
|
|
7485
|
+
if (envFiles.length === 0 && !hasExistingKeynvEnv(root.path)) {
|
|
7486
|
+
R2.info(
|
|
7487
|
+
`No .env files found in ${root.path}. There's nothing to migrate yet \u2014 create a .keynv.env by hand or run \`keynv exec\` once you have one.`
|
|
7488
|
+
);
|
|
7489
|
+
ye("Nothing to do.");
|
|
7490
|
+
return { exitCode: 0 };
|
|
7491
|
+
}
|
|
7492
|
+
const intoExisting = hasExistingKeynvEnv(root.path);
|
|
7493
|
+
Se(
|
|
7494
|
+
[
|
|
7495
|
+
`Project root: ${root.path}`,
|
|
7496
|
+
`Marker: ${root.marker}`,
|
|
7497
|
+
envFiles.length > 0 ? `Found env files: ${envFiles.map((f) => f.name).join(", ")}` : "Found env files: (none)",
|
|
7498
|
+
intoExisting ? "Existing .keynv.env detected \u2014 will merge new entries in." : ""
|
|
7499
|
+
].filter(Boolean).join("\n"),
|
|
7500
|
+
"Detected"
|
|
7501
|
+
);
|
|
7502
|
+
const merged = mergeEnvFiles(envFiles);
|
|
7503
|
+
if (merged.length === 0) {
|
|
7504
|
+
R2.info("All env files were empty (only comments/blanks). Nothing to upload.");
|
|
7505
|
+
ye("Done.");
|
|
7506
|
+
return { exitCode: 0 };
|
|
7507
|
+
}
|
|
7508
|
+
const projectChoice = await pickOrCreateProject(client, root.suggestedName);
|
|
7509
|
+
if (projectChoice === null) {
|
|
7510
|
+
me("No project selected.");
|
|
7511
|
+
return { exitCode: 130 };
|
|
7512
|
+
}
|
|
7513
|
+
const envName = await pickEnvForUpload(client, projectChoice, envFiles);
|
|
7514
|
+
if (envName === null) {
|
|
7515
|
+
me("No environment selected.");
|
|
7516
|
+
return { exitCode: 130 };
|
|
7517
|
+
}
|
|
7518
|
+
const choices = merged.map((e2) => {
|
|
7519
|
+
const verdict = classifyEntry(e2.name, e2.value);
|
|
7520
|
+
const hint = verdict.hint || (e2.isAlias ? "looks like an alias literal" : "no signal");
|
|
7521
|
+
const preview2 = e2.isAlias ? e2.value : previewValue(e2.value, 32);
|
|
7522
|
+
return {
|
|
7523
|
+
name: e2.name,
|
|
7524
|
+
value: e2.value,
|
|
7525
|
+
isAlias: e2.isAlias,
|
|
7526
|
+
verdict: verdict.verdict,
|
|
7527
|
+
label: `${e2.name} ${preview2}`,
|
|
7528
|
+
hint,
|
|
7529
|
+
sourceLine: e2.sourceLine,
|
|
7530
|
+
source: e2.source
|
|
7531
|
+
};
|
|
7532
|
+
});
|
|
7533
|
+
const initialSecretSelection = choices.filter((c2) => c2.verdict === "secret" && !c2.isAlias).map((c2) => c2.name);
|
|
7534
|
+
const selectedSecretNames = unwrap(
|
|
7535
|
+
await ve({
|
|
7536
|
+
message: "Mark which keys are secrets (vault-uploaded). Unchecked keys stay as literals.",
|
|
7537
|
+
options: choices.map((c2) => ({
|
|
7538
|
+
value: c2.name,
|
|
7539
|
+
label: c2.label,
|
|
7540
|
+
hint: c2.isAlias ? `${c2.hint} \u2014 already aliased; will pass through` : c2.hint
|
|
7541
|
+
})),
|
|
7542
|
+
initialValues: initialSecretSelection,
|
|
7543
|
+
required: false
|
|
7544
|
+
})
|
|
7545
|
+
);
|
|
7546
|
+
const selected = new Set(selectedSecretNames);
|
|
7547
|
+
let scriptWrapSelection = [];
|
|
7548
|
+
let scriptPlan = root.packageJsonScripts ? planScriptWrap(root.packageJsonScripts) : null;
|
|
7549
|
+
if (!opts.noScripts && scriptPlan && scriptPlan.recommended.length > 0) {
|
|
7550
|
+
const wrapAnswer = unwrap(
|
|
7551
|
+
await ve({
|
|
7552
|
+
message: "Wrap package.json scripts with `keynv exec`? (recommended)",
|
|
7553
|
+
options: [
|
|
7554
|
+
...scriptPlan.recommended.map((a) => ({
|
|
7555
|
+
value: a.name,
|
|
7556
|
+
label: `${a.name} \u2192 ${a.wrapped}`,
|
|
7557
|
+
hint: a.hint
|
|
7558
|
+
})),
|
|
7559
|
+
...scriptPlan.unknown.map((a) => ({
|
|
7560
|
+
value: a.name,
|
|
7561
|
+
label: `${a.name} \u2192 ${a.wrapped}`,
|
|
7562
|
+
hint: `unknown tool \u2014 opt in if you know it reads env`
|
|
7563
|
+
}))
|
|
7564
|
+
],
|
|
7565
|
+
initialValues: scriptPlan.recommended.map((a) => a.name),
|
|
7566
|
+
required: false
|
|
7567
|
+
})
|
|
7568
|
+
);
|
|
7569
|
+
scriptWrapSelection = wrapAnswer;
|
|
7570
|
+
} else if (opts.noScripts) {
|
|
7571
|
+
scriptPlan = null;
|
|
7572
|
+
}
|
|
7573
|
+
const envFileFateRaw = unwrap(
|
|
7574
|
+
await Ee({
|
|
7575
|
+
message: "After upload, what about the original .env files?",
|
|
7576
|
+
options: [
|
|
7577
|
+
{ value: "delete", label: "Delete (recommended \u2014 eliminates the leak vector)" },
|
|
7578
|
+
{ value: "gitignore", label: "Keep but make sure .gitignore covers them" }
|
|
7579
|
+
],
|
|
7580
|
+
initialValue: "delete"
|
|
7581
|
+
})
|
|
7582
|
+
);
|
|
7583
|
+
const planSummary = [
|
|
7584
|
+
`Project: ${projectChoice.name}${projectChoice.created ? " (will be created)" : ""}`,
|
|
7585
|
+
`Environment: ${envName}`,
|
|
7586
|
+
`Secrets to vault: ${selected.size}`,
|
|
7587
|
+
`Literals in file: ${merged.length - selected.size}`,
|
|
7588
|
+
`Script wraps: ${scriptWrapSelection.length}`,
|
|
7589
|
+
`Original .env: ${envFileFateRaw === "delete" ? "delete" : "keep + gitignore"}`,
|
|
7590
|
+
opts.dryRun ? "Dry-run: no changes will be made." : ""
|
|
7591
|
+
].filter(Boolean).join("\n");
|
|
7592
|
+
Se(planSummary, "About to apply");
|
|
7593
|
+
const proceed = unwrap(await ue({ message: "Proceed?", initialValue: true }));
|
|
7594
|
+
if (!proceed) {
|
|
7595
|
+
me("Aborted.");
|
|
7596
|
+
return { exitCode: 130 };
|
|
7597
|
+
}
|
|
7598
|
+
if (opts.dryRun) {
|
|
7599
|
+
ye("Dry-run complete \u2014 no changes were made.");
|
|
7600
|
+
return { exitCode: 0 };
|
|
7601
|
+
}
|
|
7602
|
+
let projectId2;
|
|
7603
|
+
if (projectChoice.created) {
|
|
7604
|
+
const s = ft();
|
|
7605
|
+
s.start(`Creating project "${projectChoice.name}"`);
|
|
7606
|
+
try {
|
|
7607
|
+
const created = await client.request("/v1/projects", {
|
|
7608
|
+
method: "POST",
|
|
7609
|
+
body: {
|
|
7610
|
+
name: projectChoice.name,
|
|
7611
|
+
environments: [{ name: envName, tier: "non-production", require_approval: false }]
|
|
7612
|
+
}
|
|
7613
|
+
});
|
|
7614
|
+
projectId2 = created.id;
|
|
7615
|
+
s.stop(`Created project ${created.name}`);
|
|
7616
|
+
} catch (err) {
|
|
7617
|
+
s.error(`Failed to create project: ${err instanceof Error ? err.message : String(err)}`);
|
|
7618
|
+
return { exitCode: 1 };
|
|
7619
|
+
}
|
|
7620
|
+
} else {
|
|
7621
|
+
projectId2 = projectChoice.id;
|
|
7622
|
+
}
|
|
7623
|
+
const uploaded = [];
|
|
7624
|
+
const failed = [];
|
|
7625
|
+
if (selected.size > 0) {
|
|
7626
|
+
const s = ft();
|
|
7627
|
+
s.start(`Uploading ${selected.size} secrets`);
|
|
7628
|
+
let i = 0;
|
|
7629
|
+
for (const entry2 of merged) {
|
|
7630
|
+
if (!selected.has(entry2.name)) continue;
|
|
7631
|
+
i++;
|
|
7632
|
+
s.message(`Uploading (${i}/${selected.size}) ${entry2.name}`);
|
|
7633
|
+
const aliasKey = entry2.name.toLowerCase().replace(/_/g, "-");
|
|
7634
|
+
try {
|
|
7635
|
+
await client.request(`/v1/projects/${projectId2}/secrets`, {
|
|
7636
|
+
method: "POST",
|
|
7637
|
+
body: { env: envName, key: aliasKey, value: entry2.value }
|
|
7638
|
+
});
|
|
7639
|
+
const alias2 = buildAlias({ project: projectChoice.name, environment: envName, key: aliasKey });
|
|
7640
|
+
if (alias2 === null) {
|
|
7641
|
+
failed.push({
|
|
7642
|
+
name: entry2.name,
|
|
7643
|
+
reason: `produced an invalid alias for project=${projectChoice.name} env=${envName} key=${aliasKey}`
|
|
7644
|
+
});
|
|
7645
|
+
} else {
|
|
7646
|
+
uploaded.push({ name: entry2.name, aliasLiteral: alias2.literal });
|
|
7647
|
+
}
|
|
7648
|
+
} catch (err) {
|
|
7649
|
+
failed.push({ name: entry2.name, reason: err instanceof Error ? err.message : String(err) });
|
|
7650
|
+
}
|
|
7651
|
+
}
|
|
7652
|
+
if (failed.length === 0) {
|
|
7653
|
+
s.stop(`Uploaded ${uploaded.length} secrets`);
|
|
7654
|
+
} else {
|
|
7655
|
+
s.error(`${uploaded.length}/${selected.size} uploaded; ${failed.length} failed`);
|
|
7656
|
+
for (const f of failed) R2.warn(` ${f.name}: ${f.reason}`);
|
|
7657
|
+
}
|
|
7658
|
+
}
|
|
7659
|
+
const literals = merged.filter((e2) => !selected.has(e2.name));
|
|
7660
|
+
const successUploads = new Map(uploaded.map((u) => [u.name, u.aliasLiteral]));
|
|
7661
|
+
const keynvEnvPath = join(root.path, ".keynv.env");
|
|
7662
|
+
let writtenLines;
|
|
7663
|
+
try {
|
|
7664
|
+
writtenLines = composeKeynvEnv({
|
|
7665
|
+
uploadedAliases: successUploads,
|
|
7666
|
+
literals,
|
|
7667
|
+
mergeWithExisting: intoExisting ? readFileSync(keynvEnvPath, "utf8") : null
|
|
7668
|
+
});
|
|
7669
|
+
writeFileSync(keynvEnvPath, `${writtenLines.join("\n")}
|
|
7670
|
+
`);
|
|
7671
|
+
R2.success(
|
|
7672
|
+
`${intoExisting ? "Updated" : "Wrote"} ${keynvEnvPath} (${successUploads.size + literals.length} entries)`
|
|
7673
|
+
);
|
|
7674
|
+
} catch (err) {
|
|
7675
|
+
R2.error(`Failed to write .keynv.env: ${err instanceof Error ? err.message : String(err)}`);
|
|
7676
|
+
return { exitCode: 1 };
|
|
7677
|
+
}
|
|
7678
|
+
if (scriptWrapSelection.length > 0 && root.packageJsonScripts) {
|
|
7679
|
+
try {
|
|
7680
|
+
updatePackageJsonScripts(
|
|
7681
|
+
join(root.path, "package.json"),
|
|
7682
|
+
root.packageJsonScripts,
|
|
7683
|
+
scriptWrapSelection
|
|
7684
|
+
);
|
|
7685
|
+
R2.success(`Wrapped ${scriptWrapSelection.length} script(s) in package.json`);
|
|
7686
|
+
} catch (err) {
|
|
7687
|
+
R2.warn(
|
|
7688
|
+
`Could not update package.json scripts: ${err instanceof Error ? err.message : String(err)}`
|
|
7689
|
+
);
|
|
7690
|
+
}
|
|
7691
|
+
}
|
|
7692
|
+
if (envFileFateRaw === "delete") {
|
|
7693
|
+
for (const f of envFiles) {
|
|
7694
|
+
try {
|
|
7695
|
+
unlinkSync(f.path);
|
|
7696
|
+
R2.success(`Removed ${f.name}`);
|
|
7697
|
+
} catch (err) {
|
|
7698
|
+
R2.warn(`Could not remove ${f.name}: ${err instanceof Error ? err.message : String(err)}`);
|
|
7699
|
+
}
|
|
7700
|
+
}
|
|
7701
|
+
} else {
|
|
7702
|
+
const gitignorePath = join(root.path, ".gitignore");
|
|
7703
|
+
try {
|
|
7704
|
+
ensureGitignoreEntries(gitignorePath, envFiles.map((f) => f.name));
|
|
7705
|
+
R2.success(`Updated .gitignore (${envFiles.length} entries ensured)`);
|
|
7706
|
+
} catch (err) {
|
|
7707
|
+
R2.warn(`Could not update .gitignore: ${err instanceof Error ? err.message : String(err)}`);
|
|
7708
|
+
}
|
|
7709
|
+
}
|
|
7710
|
+
ye(
|
|
7711
|
+
failed.length > 0 ? `Done with ${failed.length} failure(s) \u2014 see warnings above.` : `Done. Try: ${scriptWrapSelection.includes("dev") ? "npm run dev" : "keynv exec -- <your command>"}`
|
|
7712
|
+
);
|
|
7713
|
+
return { exitCode: failed.length > 0 ? 1 : 0 };
|
|
7714
|
+
}
|
|
7715
|
+
function mergeEnvFiles(files) {
|
|
7716
|
+
const map = /* @__PURE__ */ new Map();
|
|
7717
|
+
for (const f of files) {
|
|
7718
|
+
let entries;
|
|
7719
|
+
try {
|
|
7720
|
+
entries = parseEnvFile(readFileSync(f.path, "utf8"), f.path);
|
|
7721
|
+
} catch (err) {
|
|
7722
|
+
R2.warn(`${f.name}: ${err instanceof Error ? err.message : String(err)} \u2014 skipping file`);
|
|
7723
|
+
continue;
|
|
7724
|
+
}
|
|
7725
|
+
for (const e2 of entries) {
|
|
7726
|
+
const existing = map.get(e2.name);
|
|
7727
|
+
if (existing) {
|
|
7728
|
+
existing.shadowedBy.push(f.name);
|
|
7729
|
+
existing.value = e2.value;
|
|
7730
|
+
existing.isAlias = e2.isAlias;
|
|
7731
|
+
} else {
|
|
7732
|
+
map.set(e2.name, {
|
|
7733
|
+
name: e2.name,
|
|
7734
|
+
value: e2.value,
|
|
7735
|
+
isAlias: e2.isAlias,
|
|
7736
|
+
source: f.name,
|
|
7737
|
+
sourceLine: e2.line,
|
|
7738
|
+
shadowedBy: []
|
|
7739
|
+
});
|
|
7740
|
+
}
|
|
7741
|
+
}
|
|
7742
|
+
}
|
|
7743
|
+
return [...map.values()];
|
|
7744
|
+
}
|
|
7745
|
+
async function pickOrCreateProject(client, suggestedName) {
|
|
7746
|
+
const projects = await listProjects(client);
|
|
7747
|
+
const value = unwrap(
|
|
7748
|
+
await Ee({
|
|
7749
|
+
message: "Use which keynv project?",
|
|
7750
|
+
options: [
|
|
7751
|
+
{ value: "__new", label: `+ Create new: "${suggestedName}"` },
|
|
7752
|
+
...projects.map((p2) => ({ value: p2.id, label: p2.name, hint: p2.id }))
|
|
7753
|
+
]
|
|
7754
|
+
})
|
|
7755
|
+
);
|
|
7756
|
+
if (value === "__new") {
|
|
7757
|
+
const name = unwrap(
|
|
7758
|
+
await Re({
|
|
7759
|
+
message: "Project name",
|
|
7760
|
+
initialValue: suggestedName,
|
|
7761
|
+
validate: (v2) => v2 && /^[a-z0-9][a-z0-9-]{0,47}$/.test(v2) ? void 0 : "lowercase letters, digits, dashes; up to 48 chars"
|
|
7762
|
+
})
|
|
7763
|
+
);
|
|
7764
|
+
return { id: "", name, created: true };
|
|
7765
|
+
}
|
|
7766
|
+
const match = projects.find((p2) => p2.id === value);
|
|
7767
|
+
if (!match) return null;
|
|
7768
|
+
return { id: match.id, name: match.name, created: false };
|
|
7769
|
+
}
|
|
7770
|
+
async function pickEnvForUpload(client, project, envFiles) {
|
|
7771
|
+
const firstSuffix = envFiles[0]?.suffix ?? null;
|
|
7772
|
+
const suggested = suggestedEnvForSuffix(firstSuffix);
|
|
7773
|
+
if (project.created) {
|
|
7774
|
+
const value2 = unwrap(
|
|
7775
|
+
await Re({
|
|
7776
|
+
message: "Environment to create",
|
|
7777
|
+
initialValue: suggested,
|
|
7778
|
+
validate: (v2) => v2 && /^[a-z0-9][a-z0-9-]{0,23}$/.test(v2) ? void 0 : "lowercase letters, digits, dashes; up to 24 chars"
|
|
7779
|
+
})
|
|
7780
|
+
);
|
|
7781
|
+
return value2;
|
|
7782
|
+
}
|
|
7783
|
+
const detail = await client.request(`/v1/projects/${project.id}`);
|
|
7784
|
+
if (detail.environments.length === 0) {
|
|
7785
|
+
me(
|
|
7786
|
+
`Project "${project.name}" has no environments yet, and we can't add one from init in this version. Create one with \`keynv project create\` (or pick a different project).`
|
|
7787
|
+
);
|
|
7788
|
+
return null;
|
|
7789
|
+
}
|
|
7790
|
+
if (detail.environments.length === 1) {
|
|
7791
|
+
return detail.environments[0]?.name ?? null;
|
|
7792
|
+
}
|
|
7793
|
+
const value = unwrap(
|
|
7794
|
+
await Ee({
|
|
7795
|
+
message: "Upload to which environment?",
|
|
7796
|
+
options: detail.environments.map((e2) => ({
|
|
7797
|
+
value: e2.name,
|
|
7798
|
+
label: e2.name,
|
|
7799
|
+
hint: e2.tier
|
|
7800
|
+
})),
|
|
7801
|
+
initialValue: detail.environments.find((e2) => e2.name === suggested)?.name
|
|
7802
|
+
})
|
|
7803
|
+
);
|
|
7804
|
+
return value;
|
|
7805
|
+
}
|
|
7806
|
+
function composeKeynvEnv(opts) {
|
|
7807
|
+
const { uploadedAliases, literals, mergeWithExisting } = opts;
|
|
7808
|
+
const lines = [];
|
|
7809
|
+
if (mergeWithExisting !== null) {
|
|
7810
|
+
const trimmed = mergeWithExisting.replace(/\n+$/, "");
|
|
7811
|
+
if (trimmed.length > 0) {
|
|
7812
|
+
lines.push(...trimmed.split("\n"));
|
|
7813
|
+
lines.push("");
|
|
7814
|
+
}
|
|
7815
|
+
lines.push(`# >>> keynv init ${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)} >>>`);
|
|
7816
|
+
} else {
|
|
7817
|
+
lines.push("# .keynv.env \u2014 alias references to vault secrets.");
|
|
7818
|
+
lines.push("# Safe to commit: this file contains references, not values.");
|
|
7819
|
+
lines.push("# Auto-loaded by `keynv exec`. See https://keynv.dev/docs/keynv-env");
|
|
7820
|
+
lines.push("");
|
|
7821
|
+
}
|
|
7822
|
+
if (uploadedAliases.size > 0) {
|
|
7823
|
+
lines.push("# Vault-resolved (real values live on the keynv server)");
|
|
7824
|
+
for (const [name, alias2] of uploadedAliases) {
|
|
7825
|
+
lines.push(`${name}=${alias2}`);
|
|
7826
|
+
}
|
|
7827
|
+
}
|
|
7828
|
+
if (literals.length > 0) {
|
|
7829
|
+
if (uploadedAliases.size > 0) lines.push("");
|
|
7830
|
+
lines.push("# Plain literals (passed through unchanged)");
|
|
7831
|
+
for (const e2 of literals) {
|
|
7832
|
+
const value = needsQuoting(e2.value) ? `"${e2.value.replace(/"/g, '\\"')}"` : e2.value;
|
|
7833
|
+
lines.push(`${e2.name}=${value}`);
|
|
7834
|
+
}
|
|
7835
|
+
}
|
|
7836
|
+
if (mergeWithExisting !== null) {
|
|
7837
|
+
lines.push(`# <<< keynv init <<<`);
|
|
7838
|
+
}
|
|
7839
|
+
return lines;
|
|
7840
|
+
}
|
|
7841
|
+
function needsQuoting(value) {
|
|
7842
|
+
return /\s/.test(value) || value.includes("#") || value.length === 0;
|
|
7843
|
+
}
|
|
7844
|
+
function updatePackageJsonScripts(path, originalScripts, selectedNames) {
|
|
7845
|
+
const raw = readFileSync(path, "utf8");
|
|
7846
|
+
const indentMatch = raw.match(/^([ \t]+)"/m);
|
|
7847
|
+
const indent = indentMatch ? indentMatch[1] : " ";
|
|
7848
|
+
const trailingNewline = raw.endsWith("\n");
|
|
7849
|
+
const pkg = JSON.parse(raw);
|
|
7850
|
+
const updated = applyWraps(originalScripts, selectedNames);
|
|
7851
|
+
pkg.scripts = updated;
|
|
7852
|
+
const out = JSON.stringify(pkg, null, indent);
|
|
7853
|
+
writeFileSync(path, trailingNewline ? `${out}
|
|
7854
|
+
` : out);
|
|
7855
|
+
}
|
|
7856
|
+
function ensureGitignoreEntries(path, basenames) {
|
|
7857
|
+
let existing = "";
|
|
7858
|
+
if (existsSync(path)) existing = readFileSync(path, "utf8");
|
|
7859
|
+
const existingLines = new Set(existing.split("\n").map((l) => l.trim()));
|
|
7860
|
+
const toAdd = basenames.filter((n) => !existingLines.has(n));
|
|
7861
|
+
if (toAdd.length === 0) return;
|
|
7862
|
+
const sep = existing.length === 0 || existing.endsWith("\n") ? "" : "\n";
|
|
7863
|
+
const block = ["", "# added by keynv init", ...toAdd, ""].join("\n");
|
|
7864
|
+
writeFileSync(path, `${existing}${sep}${block}`);
|
|
7865
|
+
}
|
|
7866
|
+
var init_init = __esm({
|
|
7867
|
+
"src/ui/flows/init.ts"() {
|
|
7868
|
+
init_dist();
|
|
7869
|
+
init_dist5();
|
|
7870
|
+
init_envFile();
|
|
7871
|
+
init_detect();
|
|
7872
|
+
init_heuristics();
|
|
7873
|
+
init_scriptWrap();
|
|
7874
|
+
init_cancel();
|
|
7875
|
+
init_pickProject();
|
|
7876
|
+
}
|
|
7877
|
+
});
|
|
7878
|
+
|
|
6928
7879
|
// src/ui/helpers/pickSecret.ts
|
|
6929
7880
|
async function listSecrets(client, projectId2) {
|
|
6930
7881
|
const data = await client.request(
|
|
@@ -7060,14 +8011,14 @@ async function runSecretMenu(client, project, alias2) {
|
|
|
7060
8011
|
async function copyToClipboard(value) {
|
|
7061
8012
|
const platform = process.platform;
|
|
7062
8013
|
const cmd = platform === "darwin" ? ["pbcopy", []] : platform === "win32" ? ["clip", []] : ["xclip", ["-selection", "clipboard"]];
|
|
7063
|
-
return new Promise((
|
|
8014
|
+
return new Promise((resolve3) => {
|
|
7064
8015
|
try {
|
|
7065
8016
|
const child = spawn(cmd[0], cmd[1], { stdio: ["pipe", "ignore", "ignore"] });
|
|
7066
|
-
child.on("error", () =>
|
|
7067
|
-
child.on("exit", (code) =>
|
|
8017
|
+
child.on("error", () => resolve3(false));
|
|
8018
|
+
child.on("exit", (code) => resolve3(code === 0));
|
|
7068
8019
|
child.stdin.end(value);
|
|
7069
8020
|
} catch {
|
|
7070
|
-
|
|
8021
|
+
resolve3(false);
|
|
7071
8022
|
}
|
|
7072
8023
|
});
|
|
7073
8024
|
}
|
|
@@ -7187,24 +8138,24 @@ var require_lib2 = __commonJS({
|
|
|
7187
8138
|
const currentChar = sql.charCodeAt(position);
|
|
7188
8139
|
const nextChar = sql.charCodeAt(position + 1);
|
|
7189
8140
|
if (currentChar === charCode.singleQuote) {
|
|
7190
|
-
for (let
|
|
7191
|
-
if (sql.charCodeAt(
|
|
7192
|
-
|
|
7193
|
-
else if (sql.charCodeAt(
|
|
7194
|
-
return
|
|
8141
|
+
for (let cursor = position + 1; cursor < sql.length; cursor++) {
|
|
8142
|
+
if (sql.charCodeAt(cursor) === charCode.backslash)
|
|
8143
|
+
cursor++;
|
|
8144
|
+
else if (sql.charCodeAt(cursor) === charCode.singleQuote)
|
|
8145
|
+
return cursor + 1;
|
|
7195
8146
|
}
|
|
7196
8147
|
return sql.length;
|
|
7197
8148
|
}
|
|
7198
8149
|
if (currentChar === charCode.backtick) {
|
|
7199
8150
|
const length = sql.length;
|
|
7200
|
-
for (let
|
|
7201
|
-
if (sql.charCodeAt(
|
|
8151
|
+
for (let cursor = position + 1; cursor < length; cursor++) {
|
|
8152
|
+
if (sql.charCodeAt(cursor) !== charCode.backtick)
|
|
7202
8153
|
continue;
|
|
7203
|
-
if (sql.charCodeAt(
|
|
7204
|
-
|
|
8154
|
+
if (sql.charCodeAt(cursor + 1) === charCode.backtick) {
|
|
8155
|
+
cursor++;
|
|
7205
8156
|
continue;
|
|
7206
8157
|
}
|
|
7207
|
-
return
|
|
8158
|
+
return cursor + 1;
|
|
7208
8159
|
}
|
|
7209
8160
|
return length;
|
|
7210
8161
|
}
|
|
@@ -7247,11 +8198,11 @@ var require_lib2 = __commonJS({
|
|
|
7247
8198
|
if (lower === 115 && matchesWord(sql, position, "set", length))
|
|
7248
8199
|
return position + 3;
|
|
7249
8200
|
if (lower === 107 && matchesWord(sql, position, "key", length)) {
|
|
7250
|
-
let
|
|
7251
|
-
while (
|
|
7252
|
-
|
|
7253
|
-
if (matchesWord(sql,
|
|
7254
|
-
return
|
|
8201
|
+
let cursor = position + 3;
|
|
8202
|
+
while (cursor < length && isWhitespace(sql.charCodeAt(cursor)))
|
|
8203
|
+
cursor++;
|
|
8204
|
+
if (matchesWord(sql, cursor, "update", length))
|
|
8205
|
+
return cursor + 6;
|
|
7255
8206
|
}
|
|
7256
8207
|
}
|
|
7257
8208
|
return -1;
|
|
@@ -23813,7 +24764,7 @@ var require_named_placeholders = __commonJS({
|
|
|
23813
24764
|
}
|
|
23814
24765
|
return s;
|
|
23815
24766
|
}
|
|
23816
|
-
function
|
|
24767
|
+
function join5(tree) {
|
|
23817
24768
|
if (tree.length === 1) {
|
|
23818
24769
|
return tree;
|
|
23819
24770
|
}
|
|
@@ -23839,7 +24790,7 @@ var require_named_placeholders = __commonJS({
|
|
|
23839
24790
|
if (cache2 && (tree = cache2.get(query))) {
|
|
23840
24791
|
return toArrayParams(tree, paramsObj);
|
|
23841
24792
|
}
|
|
23842
|
-
tree =
|
|
24793
|
+
tree = join5(parse(query));
|
|
23843
24794
|
if (cache2) {
|
|
23844
24795
|
cache2.set(query, tree);
|
|
23845
24796
|
}
|
|
@@ -23995,11 +24946,11 @@ var require_connection = __commonJS({
|
|
|
23995
24946
|
const config = this.config;
|
|
23996
24947
|
tracePromise(
|
|
23997
24948
|
connectChannel,
|
|
23998
|
-
() => new Promise((
|
|
24949
|
+
() => new Promise((resolve3, reject) => {
|
|
23999
24950
|
let onConnect, onError;
|
|
24000
24951
|
onConnect = (param) => {
|
|
24001
24952
|
this.removeListener("error", onError);
|
|
24002
|
-
|
|
24953
|
+
resolve3(param);
|
|
24003
24954
|
};
|
|
24004
24955
|
onError = (err) => {
|
|
24005
24956
|
this.removeListener("connect", onConnect);
|
|
@@ -24424,9 +25375,9 @@ var require_connection = __commonJS({
|
|
|
24424
25375
|
} else if (shouldTrace(queryChannel)) {
|
|
24425
25376
|
tracePromise(
|
|
24426
25377
|
queryChannel,
|
|
24427
|
-
() => new Promise((
|
|
25378
|
+
() => new Promise((resolve3, reject) => {
|
|
24428
25379
|
cmdQuery.once("error", reject);
|
|
24429
|
-
cmdQuery.once("end", () =>
|
|
25380
|
+
cmdQuery.once("end", () => resolve3());
|
|
24430
25381
|
this.addCommand(cmdQuery);
|
|
24431
25382
|
}),
|
|
24432
25383
|
() => {
|
|
@@ -24573,12 +25524,12 @@ var require_connection = __commonJS({
|
|
|
24573
25524
|
} else if (shouldTrace(executeChannel)) {
|
|
24574
25525
|
tracePromise(
|
|
24575
25526
|
executeChannel,
|
|
24576
|
-
() => new Promise((
|
|
25527
|
+
() => new Promise((resolve3, reject) => {
|
|
24577
25528
|
prepareAndExecute((err) => {
|
|
24578
25529
|
executeCommand.emit("error", err);
|
|
24579
25530
|
});
|
|
24580
25531
|
executeCommand.once("error", reject);
|
|
24581
|
-
executeCommand.once("end", () =>
|
|
25532
|
+
executeCommand.once("end", () => resolve3());
|
|
24582
25533
|
}),
|
|
24583
25534
|
() => {
|
|
24584
25535
|
const server = getServerContext(this.config);
|
|
@@ -24843,13 +25794,13 @@ var require_capture_local_err = __commonJS({
|
|
|
24843
25794
|
var require_make_done_cb = __commonJS({
|
|
24844
25795
|
"../../node_modules/.pnpm/mysql2@3.22.3_@types+node@24.12.3/node_modules/mysql2/lib/promise/make_done_cb.js"(exports, module) {
|
|
24845
25796
|
var { applyCapturedStack } = require_capture_local_err();
|
|
24846
|
-
function makeDoneCb(
|
|
25797
|
+
function makeDoneCb(resolve3, reject, stackHolder) {
|
|
24847
25798
|
return function(err, rows, fields) {
|
|
24848
25799
|
if (err) {
|
|
24849
25800
|
applyCapturedStack(err, stackHolder);
|
|
24850
25801
|
reject(err);
|
|
24851
25802
|
} else {
|
|
24852
|
-
|
|
25803
|
+
resolve3([rows, fields]);
|
|
24853
25804
|
}
|
|
24854
25805
|
};
|
|
24855
25806
|
}
|
|
@@ -24872,8 +25823,8 @@ var require_prepared_statement_info = __commonJS({
|
|
|
24872
25823
|
const stackHolder = captureStackHolder(
|
|
24873
25824
|
_PromisePreparedStatementInfo.prototype.execute
|
|
24874
25825
|
);
|
|
24875
|
-
return new this.Promise((
|
|
24876
|
-
const done = makeDoneCb(
|
|
25826
|
+
return new this.Promise((resolve3, reject) => {
|
|
25827
|
+
const done = makeDoneCb(resolve3, reject, stackHolder);
|
|
24877
25828
|
if (parameters) {
|
|
24878
25829
|
s.execute(parameters, done);
|
|
24879
25830
|
} else {
|
|
@@ -24882,9 +25833,9 @@ var require_prepared_statement_info = __commonJS({
|
|
|
24882
25833
|
});
|
|
24883
25834
|
}
|
|
24884
25835
|
close() {
|
|
24885
|
-
return new this.Promise((
|
|
25836
|
+
return new this.Promise((resolve3) => {
|
|
24886
25837
|
this.statement.close();
|
|
24887
|
-
|
|
25838
|
+
resolve3();
|
|
24888
25839
|
});
|
|
24889
25840
|
}
|
|
24890
25841
|
};
|
|
@@ -24955,8 +25906,8 @@ var require_connection2 = __commonJS({
|
|
|
24955
25906
|
"Callback function is not available with promise clients."
|
|
24956
25907
|
);
|
|
24957
25908
|
}
|
|
24958
|
-
return new this.Promise((
|
|
24959
|
-
const done = makeDoneCb(
|
|
25909
|
+
return new this.Promise((resolve3, reject) => {
|
|
25910
|
+
const done = makeDoneCb(resolve3, reject, stackHolder);
|
|
24960
25911
|
if (params !== void 0) {
|
|
24961
25912
|
c2.query(query, params, done);
|
|
24962
25913
|
} else {
|
|
@@ -24972,8 +25923,8 @@ var require_connection2 = __commonJS({
|
|
|
24972
25923
|
"Callback function is not available with promise clients."
|
|
24973
25924
|
);
|
|
24974
25925
|
}
|
|
24975
|
-
return new this.Promise((
|
|
24976
|
-
const done = makeDoneCb(
|
|
25926
|
+
return new this.Promise((resolve3, reject) => {
|
|
25927
|
+
const done = makeDoneCb(resolve3, reject, stackHolder);
|
|
24977
25928
|
if (params !== void 0) {
|
|
24978
25929
|
c2.execute(query, params, done);
|
|
24979
25930
|
} else {
|
|
@@ -24982,8 +25933,8 @@ var require_connection2 = __commonJS({
|
|
|
24982
25933
|
});
|
|
24983
25934
|
}
|
|
24984
25935
|
end() {
|
|
24985
|
-
return new this.Promise((
|
|
24986
|
-
this.connection.end(
|
|
25936
|
+
return new this.Promise((resolve3) => {
|
|
25937
|
+
this.connection.end(resolve3);
|
|
24987
25938
|
});
|
|
24988
25939
|
}
|
|
24989
25940
|
async [Symbol.asyncDispose]() {
|
|
@@ -24996,16 +25947,16 @@ var require_connection2 = __commonJS({
|
|
|
24996
25947
|
const stackHolder = captureStackHolder(
|
|
24997
25948
|
_PromiseConnection.prototype.beginTransaction
|
|
24998
25949
|
);
|
|
24999
|
-
return new this.Promise((
|
|
25000
|
-
const done = makeDoneCb(
|
|
25950
|
+
return new this.Promise((resolve3, reject) => {
|
|
25951
|
+
const done = makeDoneCb(resolve3, reject, stackHolder);
|
|
25001
25952
|
c2.beginTransaction(done);
|
|
25002
25953
|
});
|
|
25003
25954
|
}
|
|
25004
25955
|
commit() {
|
|
25005
25956
|
const c2 = this.connection;
|
|
25006
25957
|
const stackHolder = captureStackHolder(_PromiseConnection.prototype.commit);
|
|
25007
|
-
return new this.Promise((
|
|
25008
|
-
const done = makeDoneCb(
|
|
25958
|
+
return new this.Promise((resolve3, reject) => {
|
|
25959
|
+
const done = makeDoneCb(resolve3, reject, stackHolder);
|
|
25009
25960
|
c2.commit(done);
|
|
25010
25961
|
});
|
|
25011
25962
|
}
|
|
@@ -25014,21 +25965,21 @@ var require_connection2 = __commonJS({
|
|
|
25014
25965
|
const stackHolder = captureStackHolder(
|
|
25015
25966
|
_PromiseConnection.prototype.rollback
|
|
25016
25967
|
);
|
|
25017
|
-
return new this.Promise((
|
|
25018
|
-
const done = makeDoneCb(
|
|
25968
|
+
return new this.Promise((resolve3, reject) => {
|
|
25969
|
+
const done = makeDoneCb(resolve3, reject, stackHolder);
|
|
25019
25970
|
c2.rollback(done);
|
|
25020
25971
|
});
|
|
25021
25972
|
}
|
|
25022
25973
|
ping() {
|
|
25023
25974
|
const c2 = this.connection;
|
|
25024
25975
|
const stackHolder = captureStackHolder(_PromiseConnection.prototype.ping);
|
|
25025
|
-
return new this.Promise((
|
|
25976
|
+
return new this.Promise((resolve3, reject) => {
|
|
25026
25977
|
c2.ping((err) => {
|
|
25027
25978
|
if (err) {
|
|
25028
25979
|
applyCapturedStack(err, stackHolder);
|
|
25029
25980
|
reject(err);
|
|
25030
25981
|
} else {
|
|
25031
|
-
|
|
25982
|
+
resolve3(true);
|
|
25032
25983
|
}
|
|
25033
25984
|
});
|
|
25034
25985
|
});
|
|
@@ -25036,13 +25987,13 @@ var require_connection2 = __commonJS({
|
|
|
25036
25987
|
reset() {
|
|
25037
25988
|
const c2 = this.connection;
|
|
25038
25989
|
const stackHolder = captureStackHolder(_PromiseConnection.prototype.reset);
|
|
25039
|
-
return new this.Promise((
|
|
25990
|
+
return new this.Promise((resolve3, reject) => {
|
|
25040
25991
|
c2.reset((err) => {
|
|
25041
25992
|
if (err) {
|
|
25042
25993
|
applyCapturedStack(err, stackHolder);
|
|
25043
25994
|
reject(err);
|
|
25044
25995
|
} else {
|
|
25045
|
-
|
|
25996
|
+
resolve3();
|
|
25046
25997
|
}
|
|
25047
25998
|
});
|
|
25048
25999
|
});
|
|
@@ -25050,13 +26001,13 @@ var require_connection2 = __commonJS({
|
|
|
25050
26001
|
connect() {
|
|
25051
26002
|
const c2 = this.connection;
|
|
25052
26003
|
const stackHolder = captureStackHolder(_PromiseConnection.prototype.connect);
|
|
25053
|
-
return new this.Promise((
|
|
26004
|
+
return new this.Promise((resolve3, reject) => {
|
|
25054
26005
|
c2.connect((err, param) => {
|
|
25055
26006
|
if (err) {
|
|
25056
26007
|
applyCapturedStack(err, stackHolder);
|
|
25057
26008
|
reject(err);
|
|
25058
26009
|
} else {
|
|
25059
|
-
|
|
26010
|
+
resolve3(param);
|
|
25060
26011
|
}
|
|
25061
26012
|
});
|
|
25062
26013
|
});
|
|
@@ -25065,7 +26016,7 @@ var require_connection2 = __commonJS({
|
|
|
25065
26016
|
const c2 = this.connection;
|
|
25066
26017
|
const promiseImpl = this.Promise;
|
|
25067
26018
|
const stackHolder = captureStackHolder(_PromiseConnection.prototype.prepare);
|
|
25068
|
-
return new this.Promise((
|
|
26019
|
+
return new this.Promise((resolve3, reject) => {
|
|
25069
26020
|
c2.prepare(options, (err, statement) => {
|
|
25070
26021
|
if (err) {
|
|
25071
26022
|
applyCapturedStack(err, stackHolder);
|
|
@@ -25075,7 +26026,7 @@ var require_connection2 = __commonJS({
|
|
|
25075
26026
|
statement,
|
|
25076
26027
|
promiseImpl
|
|
25077
26028
|
);
|
|
25078
|
-
|
|
26029
|
+
resolve3(wrappedStatement);
|
|
25079
26030
|
}
|
|
25080
26031
|
});
|
|
25081
26032
|
});
|
|
@@ -25085,13 +26036,13 @@ var require_connection2 = __commonJS({
|
|
|
25085
26036
|
const stackHolder = captureStackHolder(
|
|
25086
26037
|
_PromiseConnection.prototype.changeUser
|
|
25087
26038
|
);
|
|
25088
|
-
return new this.Promise((
|
|
26039
|
+
return new this.Promise((resolve3, reject) => {
|
|
25089
26040
|
c2.changeUser(options, (err) => {
|
|
25090
26041
|
if (err) {
|
|
25091
26042
|
applyCapturedStack(err, stackHolder);
|
|
25092
26043
|
reject(err);
|
|
25093
26044
|
} else {
|
|
25094
|
-
|
|
26045
|
+
resolve3();
|
|
25095
26046
|
}
|
|
25096
26047
|
});
|
|
25097
26048
|
});
|
|
@@ -25553,12 +26504,12 @@ var require_pool2 = __commonJS({
|
|
|
25553
26504
|
}
|
|
25554
26505
|
getConnection() {
|
|
25555
26506
|
const corePool = this.pool;
|
|
25556
|
-
return new this.Promise((
|
|
26507
|
+
return new this.Promise((resolve3, reject) => {
|
|
25557
26508
|
corePool.getConnection((err, coreConnection) => {
|
|
25558
26509
|
if (err) {
|
|
25559
26510
|
reject(err);
|
|
25560
26511
|
} else {
|
|
25561
|
-
|
|
26512
|
+
resolve3(new PromisePoolConnection(coreConnection, this.Promise));
|
|
25562
26513
|
}
|
|
25563
26514
|
});
|
|
25564
26515
|
});
|
|
@@ -25574,8 +26525,8 @@ var require_pool2 = __commonJS({
|
|
|
25574
26525
|
"Callback function is not available with promise clients."
|
|
25575
26526
|
);
|
|
25576
26527
|
}
|
|
25577
|
-
return new this.Promise((
|
|
25578
|
-
const done = makeDoneCb(
|
|
26528
|
+
return new this.Promise((resolve3, reject) => {
|
|
26529
|
+
const done = makeDoneCb(resolve3, reject, stackHolder);
|
|
25579
26530
|
if (args !== void 0) {
|
|
25580
26531
|
corePool.query(sql, args, done);
|
|
25581
26532
|
} else {
|
|
@@ -25591,8 +26542,8 @@ var require_pool2 = __commonJS({
|
|
|
25591
26542
|
"Callback function is not available with promise clients."
|
|
25592
26543
|
);
|
|
25593
26544
|
}
|
|
25594
|
-
return new this.Promise((
|
|
25595
|
-
const done = makeDoneCb(
|
|
26545
|
+
return new this.Promise((resolve3, reject) => {
|
|
26546
|
+
const done = makeDoneCb(resolve3, reject, stackHolder);
|
|
25596
26547
|
if (args) {
|
|
25597
26548
|
corePool.execute(sql, args, done);
|
|
25598
26549
|
} else {
|
|
@@ -25603,13 +26554,13 @@ var require_pool2 = __commonJS({
|
|
|
25603
26554
|
end() {
|
|
25604
26555
|
const corePool = this.pool;
|
|
25605
26556
|
const stackHolder = captureStackHolder(_PromisePool.prototype.end);
|
|
25606
|
-
return new this.Promise((
|
|
26557
|
+
return new this.Promise((resolve3, reject) => {
|
|
25607
26558
|
corePool.end((err) => {
|
|
25608
26559
|
if (err) {
|
|
25609
26560
|
applyCapturedStack(err, stackHolder);
|
|
25610
26561
|
reject(err);
|
|
25611
26562
|
} else {
|
|
25612
|
-
|
|
26563
|
+
resolve3();
|
|
25613
26564
|
}
|
|
25614
26565
|
});
|
|
25615
26566
|
});
|
|
@@ -26034,12 +26985,12 @@ var require_pool_cluster2 = __commonJS({
|
|
|
26034
26985
|
}
|
|
26035
26986
|
getConnection() {
|
|
26036
26987
|
const corePoolNamespace = this.poolNamespace;
|
|
26037
|
-
return new this.Promise((
|
|
26988
|
+
return new this.Promise((resolve3, reject) => {
|
|
26038
26989
|
corePoolNamespace.getConnection((err, coreConnection) => {
|
|
26039
26990
|
if (err) {
|
|
26040
26991
|
reject(err);
|
|
26041
26992
|
} else {
|
|
26042
|
-
|
|
26993
|
+
resolve3(new PromisePoolConnection(coreConnection, this.Promise));
|
|
26043
26994
|
}
|
|
26044
26995
|
});
|
|
26045
26996
|
});
|
|
@@ -26054,8 +27005,8 @@ var require_pool_cluster2 = __commonJS({
|
|
|
26054
27005
|
"Callback function is not available with promise clients."
|
|
26055
27006
|
);
|
|
26056
27007
|
}
|
|
26057
|
-
return new this.Promise((
|
|
26058
|
-
const done = makeDoneCb(
|
|
27008
|
+
return new this.Promise((resolve3, reject) => {
|
|
27009
|
+
const done = makeDoneCb(resolve3, reject, stackHolder);
|
|
26059
27010
|
corePoolNamespace.query(sql, values, done);
|
|
26060
27011
|
});
|
|
26061
27012
|
}
|
|
@@ -26069,8 +27020,8 @@ var require_pool_cluster2 = __commonJS({
|
|
|
26069
27020
|
"Callback function is not available with promise clients."
|
|
26070
27021
|
);
|
|
26071
27022
|
}
|
|
26072
|
-
return new this.Promise((
|
|
26073
|
-
const done = makeDoneCb(
|
|
27023
|
+
return new this.Promise((resolve3, reject) => {
|
|
27024
|
+
const done = makeDoneCb(resolve3, reject, stackHolder);
|
|
26074
27025
|
corePoolNamespace.execute(sql, values, done);
|
|
26075
27026
|
});
|
|
26076
27027
|
}
|
|
@@ -26108,9 +27059,9 @@ var require_promise = __commonJS({
|
|
|
26108
27059
|
"no Promise implementation available.Use promise-enabled node version or pass userland Promise implementation as parameter, for example: { Promise: require('bluebird') }"
|
|
26109
27060
|
);
|
|
26110
27061
|
}
|
|
26111
|
-
return new thePromise((
|
|
27062
|
+
return new thePromise((resolve3, reject) => {
|
|
26112
27063
|
coreConnection.once("connect", () => {
|
|
26113
|
-
|
|
27064
|
+
resolve3(new PromiseConnection(coreConnection, thePromise));
|
|
26114
27065
|
});
|
|
26115
27066
|
coreConnection.once("error", (err) => {
|
|
26116
27067
|
applyCapturedStack(err, stackHolder);
|
|
@@ -26137,7 +27088,7 @@ var require_promise = __commonJS({
|
|
|
26137
27088
|
}
|
|
26138
27089
|
getConnection(pattern, selector) {
|
|
26139
27090
|
const corePoolCluster = this.poolCluster;
|
|
26140
|
-
return new this.Promise((
|
|
27091
|
+
return new this.Promise((resolve3, reject) => {
|
|
26141
27092
|
corePoolCluster.getConnection(
|
|
26142
27093
|
pattern,
|
|
26143
27094
|
selector,
|
|
@@ -26145,7 +27096,7 @@ var require_promise = __commonJS({
|
|
|
26145
27096
|
if (err) {
|
|
26146
27097
|
reject(err);
|
|
26147
27098
|
} else {
|
|
26148
|
-
|
|
27099
|
+
resolve3(new PromisePoolConnection(coreConnection, this.Promise));
|
|
26149
27100
|
}
|
|
26150
27101
|
}
|
|
26151
27102
|
);
|
|
@@ -26159,8 +27110,8 @@ var require_promise = __commonJS({
|
|
|
26159
27110
|
"Callback function is not available with promise clients."
|
|
26160
27111
|
);
|
|
26161
27112
|
}
|
|
26162
|
-
return new this.Promise((
|
|
26163
|
-
const done = makeDoneCb(
|
|
27113
|
+
return new this.Promise((resolve3, reject) => {
|
|
27114
|
+
const done = makeDoneCb(resolve3, reject, stackHolder);
|
|
26164
27115
|
corePoolCluster.query(sql, args, done);
|
|
26165
27116
|
});
|
|
26166
27117
|
}
|
|
@@ -26174,8 +27125,8 @@ var require_promise = __commonJS({
|
|
|
26174
27125
|
"Callback function is not available with promise clients."
|
|
26175
27126
|
);
|
|
26176
27127
|
}
|
|
26177
|
-
return new this.Promise((
|
|
26178
|
-
const done = makeDoneCb(
|
|
27128
|
+
return new this.Promise((resolve3, reject) => {
|
|
27129
|
+
const done = makeDoneCb(resolve3, reject, stackHolder);
|
|
26179
27130
|
corePoolCluster.execute(sql, args, done);
|
|
26180
27131
|
});
|
|
26181
27132
|
}
|
|
@@ -26188,13 +27139,13 @@ var require_promise = __commonJS({
|
|
|
26188
27139
|
end() {
|
|
26189
27140
|
const corePoolCluster = this.poolCluster;
|
|
26190
27141
|
const stackHolder = captureStackHolder(_PromisePoolCluster.prototype.end);
|
|
26191
|
-
return new this.Promise((
|
|
27142
|
+
return new this.Promise((resolve3, reject) => {
|
|
26192
27143
|
corePoolCluster.end((err) => {
|
|
26193
27144
|
if (err) {
|
|
26194
27145
|
applyCapturedStack(err, stackHolder);
|
|
26195
27146
|
reject(err);
|
|
26196
27147
|
} else {
|
|
26197
|
-
|
|
27148
|
+
resolve3();
|
|
26198
27149
|
}
|
|
26199
27150
|
});
|
|
26200
27151
|
});
|
|
@@ -29269,7 +30220,7 @@ var require_dist = __commonJS({
|
|
|
29269
30220
|
function parse(stream, callback) {
|
|
29270
30221
|
const parser = new parser_1.Parser();
|
|
29271
30222
|
stream.on("data", (buffer) => parser.parse(buffer, callback));
|
|
29272
|
-
return new Promise((
|
|
30223
|
+
return new Promise((resolve3) => stream.on("end", () => resolve3()));
|
|
29273
30224
|
}
|
|
29274
30225
|
exports.parse = parse;
|
|
29275
30226
|
}
|
|
@@ -29994,12 +30945,12 @@ var require_client2 = __commonJS({
|
|
|
29994
30945
|
this._connect(callback);
|
|
29995
30946
|
return;
|
|
29996
30947
|
}
|
|
29997
|
-
return new this._Promise((
|
|
30948
|
+
return new this._Promise((resolve3, reject) => {
|
|
29998
30949
|
this._connect((error) => {
|
|
29999
30950
|
if (error) {
|
|
30000
30951
|
reject(error);
|
|
30001
30952
|
} else {
|
|
30002
|
-
|
|
30953
|
+
resolve3(this);
|
|
30003
30954
|
}
|
|
30004
30955
|
});
|
|
30005
30956
|
});
|
|
@@ -30345,8 +31296,8 @@ var require_client2 = __commonJS({
|
|
|
30345
31296
|
readTimeout = config.query_timeout || this.connectionParameters.query_timeout;
|
|
30346
31297
|
query = new Query2(config, values, callback);
|
|
30347
31298
|
if (!query.callback) {
|
|
30348
|
-
result = new this._Promise((
|
|
30349
|
-
query.callback = (err, res) => err ? reject(err) :
|
|
31299
|
+
result = new this._Promise((resolve3, reject) => {
|
|
31300
|
+
query.callback = (err, res) => err ? reject(err) : resolve3(res);
|
|
30350
31301
|
}).catch((err) => {
|
|
30351
31302
|
Error.captureStackTrace(err);
|
|
30352
31303
|
throw err;
|
|
@@ -30423,8 +31374,8 @@ var require_client2 = __commonJS({
|
|
|
30423
31374
|
if (cb) {
|
|
30424
31375
|
this.connection.once("end", cb);
|
|
30425
31376
|
} else {
|
|
30426
|
-
return new this._Promise((
|
|
30427
|
-
this.connection.once("end",
|
|
31377
|
+
return new this._Promise((resolve3) => {
|
|
31378
|
+
this.connection.once("end", resolve3);
|
|
30428
31379
|
});
|
|
30429
31380
|
}
|
|
30430
31381
|
}
|
|
@@ -30472,8 +31423,8 @@ var require_pg_pool = __commonJS({
|
|
|
30472
31423
|
const cb = function(err, client) {
|
|
30473
31424
|
err ? rej(err) : res(client);
|
|
30474
31425
|
};
|
|
30475
|
-
const result = new Promise2(function(
|
|
30476
|
-
res =
|
|
31426
|
+
const result = new Promise2(function(resolve3, reject) {
|
|
31427
|
+
res = resolve3;
|
|
30477
31428
|
rej = reject;
|
|
30478
31429
|
}).catch((err) => {
|
|
30479
31430
|
Error.captureStackTrace(err);
|
|
@@ -30534,7 +31485,7 @@ var require_pg_pool = __commonJS({
|
|
|
30534
31485
|
if (typeof Promise2.try === "function") {
|
|
30535
31486
|
return Promise2.try(f);
|
|
30536
31487
|
}
|
|
30537
|
-
return new Promise2((
|
|
31488
|
+
return new Promise2((resolve3) => resolve3(f()));
|
|
30538
31489
|
}
|
|
30539
31490
|
_isFull() {
|
|
30540
31491
|
return this._clients.length >= this.options.max;
|
|
@@ -30926,8 +31877,8 @@ var require_query4 = __commonJS({
|
|
|
30926
31877
|
NativeQuery.prototype._getPromise = function() {
|
|
30927
31878
|
if (this._promise) return this._promise;
|
|
30928
31879
|
this._promise = new Promise(
|
|
30929
|
-
function(
|
|
30930
|
-
this._once("end",
|
|
31880
|
+
function(resolve3, reject) {
|
|
31881
|
+
this._once("end", resolve3);
|
|
30931
31882
|
this._once("error", reject);
|
|
30932
31883
|
}.bind(this)
|
|
30933
31884
|
);
|
|
@@ -31104,12 +32055,12 @@ var require_client3 = __commonJS({
|
|
|
31104
32055
|
this._connect(callback);
|
|
31105
32056
|
return;
|
|
31106
32057
|
}
|
|
31107
|
-
return new this._Promise((
|
|
32058
|
+
return new this._Promise((resolve3, reject) => {
|
|
31108
32059
|
this._connect((error) => {
|
|
31109
32060
|
if (error) {
|
|
31110
32061
|
reject(error);
|
|
31111
32062
|
} else {
|
|
31112
|
-
|
|
32063
|
+
resolve3(this);
|
|
31113
32064
|
}
|
|
31114
32065
|
});
|
|
31115
32066
|
});
|
|
@@ -31133,8 +32084,8 @@ var require_client3 = __commonJS({
|
|
|
31133
32084
|
query = new NativeQuery(config, values, callback);
|
|
31134
32085
|
if (!query.callback) {
|
|
31135
32086
|
let resolveOut, rejectOut;
|
|
31136
|
-
result = new this._Promise((
|
|
31137
|
-
resolveOut =
|
|
32087
|
+
result = new this._Promise((resolve3, reject) => {
|
|
32088
|
+
resolveOut = resolve3;
|
|
31138
32089
|
rejectOut = reject;
|
|
31139
32090
|
}).catch((err) => {
|
|
31140
32091
|
Error.captureStackTrace(err);
|
|
@@ -31194,8 +32145,8 @@ var require_client3 = __commonJS({
|
|
|
31194
32145
|
}
|
|
31195
32146
|
let result;
|
|
31196
32147
|
if (!cb) {
|
|
31197
|
-
result = new this._Promise(function(
|
|
31198
|
-
cb = (err) => err ? reject(err) :
|
|
32148
|
+
result = new this._Promise(function(resolve3, reject) {
|
|
32149
|
+
cb = (err) => err ? reject(err) : resolve3();
|
|
31199
32150
|
});
|
|
31200
32151
|
}
|
|
31201
32152
|
this.native.end(function() {
|
|
@@ -36302,7 +37253,7 @@ var require_Command = __commonJS({
|
|
|
36302
37253
|
}
|
|
36303
37254
|
}
|
|
36304
37255
|
initPromise() {
|
|
36305
|
-
const promise = new Promise((
|
|
37256
|
+
const promise = new Promise((resolve3, reject) => {
|
|
36306
37257
|
if (!this.transformed) {
|
|
36307
37258
|
this.transformed = true;
|
|
36308
37259
|
const transformer = _Command._transformer.argument[this.name];
|
|
@@ -36311,7 +37262,7 @@ var require_Command = __commonJS({
|
|
|
36311
37262
|
}
|
|
36312
37263
|
this.stringifyArguments();
|
|
36313
37264
|
}
|
|
36314
|
-
this.resolve = this._convertValue(
|
|
37265
|
+
this.resolve = this._convertValue(resolve3);
|
|
36315
37266
|
this.reject = (err) => {
|
|
36316
37267
|
this._clearTimers();
|
|
36317
37268
|
if (this.errorStack) {
|
|
@@ -36344,11 +37295,11 @@ var require_Command = __commonJS({
|
|
|
36344
37295
|
/**
|
|
36345
37296
|
* Convert the value from buffer to the target encoding.
|
|
36346
37297
|
*/
|
|
36347
|
-
_convertValue(
|
|
37298
|
+
_convertValue(resolve3) {
|
|
36348
37299
|
return (value) => {
|
|
36349
37300
|
try {
|
|
36350
37301
|
this._clearTimers();
|
|
36351
|
-
|
|
37302
|
+
resolve3(this.transformReply(value));
|
|
36352
37303
|
this.isResolved = true;
|
|
36353
37304
|
} catch (err) {
|
|
36354
37305
|
this.reject(err);
|
|
@@ -36626,13 +37577,13 @@ var require_autoPipelining = __commonJS({
|
|
|
36626
37577
|
if (client.isCluster && !client.slots.length) {
|
|
36627
37578
|
if (client.status === "wait")
|
|
36628
37579
|
client.connect().catch(lodash_1.noop);
|
|
36629
|
-
return (0, standard_as_callback_1.default)(new Promise(function(
|
|
37580
|
+
return (0, standard_as_callback_1.default)(new Promise(function(resolve3, reject) {
|
|
36630
37581
|
client.delayUntilReady((err) => {
|
|
36631
37582
|
if (err) {
|
|
36632
37583
|
reject(err);
|
|
36633
37584
|
return;
|
|
36634
37585
|
}
|
|
36635
|
-
executeWithAutoPipelining(client, functionName, commandName, args, null).then(
|
|
37586
|
+
executeWithAutoPipelining(client, functionName, commandName, args, null).then(resolve3, reject);
|
|
36636
37587
|
});
|
|
36637
37588
|
}), callback);
|
|
36638
37589
|
}
|
|
@@ -36653,13 +37604,13 @@ var require_autoPipelining = __commonJS({
|
|
|
36653
37604
|
pipeline[exports.kExec] = true;
|
|
36654
37605
|
setImmediate(executeAutoPipeline, client, slotKey);
|
|
36655
37606
|
}
|
|
36656
|
-
const autoPipelinePromise = new Promise(function(
|
|
37607
|
+
const autoPipelinePromise = new Promise(function(resolve3, reject) {
|
|
36657
37608
|
pipeline[exports.kCallbacks].push(function(err, value) {
|
|
36658
37609
|
if (err) {
|
|
36659
37610
|
reject(err);
|
|
36660
37611
|
return;
|
|
36661
37612
|
}
|
|
36662
|
-
|
|
37613
|
+
resolve3(value);
|
|
36663
37614
|
});
|
|
36664
37615
|
if (functionName === "call") {
|
|
36665
37616
|
args.unshift(commandName);
|
|
@@ -36894,8 +37845,8 @@ var require_Pipeline = __commonJS({
|
|
|
36894
37845
|
this[name] = redis[name];
|
|
36895
37846
|
this[name + "Buffer"] = redis[name + "Buffer"];
|
|
36896
37847
|
});
|
|
36897
|
-
this.promise = new Promise((
|
|
36898
|
-
this.resolve =
|
|
37848
|
+
this.promise = new Promise((resolve3, reject) => {
|
|
37849
|
+
this.resolve = resolve3;
|
|
36899
37850
|
this.reject = reject;
|
|
36900
37851
|
});
|
|
36901
37852
|
const _this = this;
|
|
@@ -37195,13 +38146,13 @@ var require_transaction = __commonJS({
|
|
|
37195
38146
|
if (this.isCluster && !this.redis.slots.length) {
|
|
37196
38147
|
if (this.redis.status === "wait")
|
|
37197
38148
|
this.redis.connect().catch(utils_1.noop);
|
|
37198
|
-
return (0, standard_as_callback_1.default)(new Promise((
|
|
38149
|
+
return (0, standard_as_callback_1.default)(new Promise((resolve3, reject) => {
|
|
37199
38150
|
this.redis.delayUntilReady((err) => {
|
|
37200
38151
|
if (err) {
|
|
37201
38152
|
reject(err);
|
|
37202
38153
|
return;
|
|
37203
38154
|
}
|
|
37204
|
-
this.exec(pipeline).then(
|
|
38155
|
+
this.exec(pipeline).then(resolve3, reject);
|
|
37205
38156
|
});
|
|
37206
38157
|
}), callback);
|
|
37207
38158
|
}
|
|
@@ -38330,7 +39281,7 @@ var require_cluster = __commonJS({
|
|
|
38330
39281
|
* Connect to a cluster
|
|
38331
39282
|
*/
|
|
38332
39283
|
connect() {
|
|
38333
|
-
return new Promise((
|
|
39284
|
+
return new Promise((resolve3, reject) => {
|
|
38334
39285
|
if (this.status === "connecting" || this.status === "connect" || this.status === "ready") {
|
|
38335
39286
|
reject(new Error("Redis is already connecting/connected"));
|
|
38336
39287
|
return;
|
|
@@ -38359,7 +39310,7 @@ var require_cluster = __commonJS({
|
|
|
38359
39310
|
this.retryAttempts = 0;
|
|
38360
39311
|
this.executeOfflineCommands();
|
|
38361
39312
|
this.resetNodesRefreshInterval();
|
|
38362
|
-
|
|
39313
|
+
resolve3();
|
|
38363
39314
|
};
|
|
38364
39315
|
let closeListener = void 0;
|
|
38365
39316
|
const refreshListener = () => {
|
|
@@ -38969,7 +39920,7 @@ var require_cluster = __commonJS({
|
|
|
38969
39920
|
});
|
|
38970
39921
|
}
|
|
38971
39922
|
resolveSrv(hostname) {
|
|
38972
|
-
return new Promise((
|
|
39923
|
+
return new Promise((resolve3, reject) => {
|
|
38973
39924
|
this.options.resolveSrv(hostname, (err, records) => {
|
|
38974
39925
|
if (err) {
|
|
38975
39926
|
return reject(err);
|
|
@@ -38983,7 +39934,7 @@ var require_cluster = __commonJS({
|
|
|
38983
39934
|
if (!group.records.length) {
|
|
38984
39935
|
sortedKeys.shift();
|
|
38985
39936
|
}
|
|
38986
|
-
self2.dnsLookup(record.name).then((host) =>
|
|
39937
|
+
self2.dnsLookup(record.name).then((host) => resolve3({
|
|
38987
39938
|
host,
|
|
38988
39939
|
port: record.port
|
|
38989
39940
|
}), tryFirstOne);
|
|
@@ -38993,14 +39944,14 @@ var require_cluster = __commonJS({
|
|
|
38993
39944
|
});
|
|
38994
39945
|
}
|
|
38995
39946
|
dnsLookup(hostname) {
|
|
38996
|
-
return new Promise((
|
|
39947
|
+
return new Promise((resolve3, reject) => {
|
|
38997
39948
|
this.options.dnsLookup(hostname, (err, address) => {
|
|
38998
39949
|
if (err) {
|
|
38999
39950
|
debug2("failed to resolve hostname %s to IP: %s", hostname, err.message);
|
|
39000
39951
|
reject(err);
|
|
39001
39952
|
} else {
|
|
39002
39953
|
debug2("resolved hostname %s to IP %s", hostname, address);
|
|
39003
|
-
|
|
39954
|
+
resolve3(address);
|
|
39004
39955
|
}
|
|
39005
39956
|
});
|
|
39006
39957
|
});
|
|
@@ -39155,7 +40106,7 @@ var require_StandaloneConnector = __commonJS({
|
|
|
39155
40106
|
if (options.tls) {
|
|
39156
40107
|
Object.assign(connectionOptions, options.tls);
|
|
39157
40108
|
}
|
|
39158
|
-
return new Promise((
|
|
40109
|
+
return new Promise((resolve3, reject) => {
|
|
39159
40110
|
process.nextTick(() => {
|
|
39160
40111
|
if (!this.connecting) {
|
|
39161
40112
|
reject(new Error(utils_1.CONNECTION_CLOSED_ERROR_MSG));
|
|
@@ -39174,7 +40125,7 @@ var require_StandaloneConnector = __commonJS({
|
|
|
39174
40125
|
this.stream.once("error", (err) => {
|
|
39175
40126
|
this.firstError = err;
|
|
39176
40127
|
});
|
|
39177
|
-
|
|
40128
|
+
resolve3(this.stream);
|
|
39178
40129
|
});
|
|
39179
40130
|
});
|
|
39180
40131
|
}
|
|
@@ -39330,7 +40281,7 @@ var require_SentinelConnector = __commonJS({
|
|
|
39330
40281
|
const error = new Error(errorMsg);
|
|
39331
40282
|
if (typeof retryDelay === "number") {
|
|
39332
40283
|
eventEmitter("error", error);
|
|
39333
|
-
await new Promise((
|
|
40284
|
+
await new Promise((resolve3) => setTimeout(resolve3, retryDelay));
|
|
39334
40285
|
return connectToNext();
|
|
39335
40286
|
} else {
|
|
39336
40287
|
throw error;
|
|
@@ -40647,7 +41598,7 @@ var require_Redis = __commonJS({
|
|
|
40647
41598
|
* if the connection fails, times out, or if Redis is already connecting/connected.
|
|
40648
41599
|
*/
|
|
40649
41600
|
connect(callback) {
|
|
40650
|
-
const promise = new Promise((
|
|
41601
|
+
const promise = new Promise((resolve3, reject) => {
|
|
40651
41602
|
if (this.status === "connecting" || this.status === "connect" || this.status === "ready") {
|
|
40652
41603
|
reject(new Error("Redis is already connecting/connected"));
|
|
40653
41604
|
return;
|
|
@@ -40726,7 +41677,7 @@ var require_Redis = __commonJS({
|
|
|
40726
41677
|
}
|
|
40727
41678
|
const connectionReadyHandler = function() {
|
|
40728
41679
|
_this.removeListener("close", connectionCloseHandler);
|
|
40729
|
-
|
|
41680
|
+
resolve3();
|
|
40730
41681
|
};
|
|
40731
41682
|
var connectionCloseHandler = function() {
|
|
40732
41683
|
_this.removeListener("ready", connectionReadyHandler);
|
|
@@ -40820,10 +41771,10 @@ var require_Redis = __commonJS({
|
|
|
40820
41771
|
monitor: true,
|
|
40821
41772
|
lazyConnect: false
|
|
40822
41773
|
});
|
|
40823
|
-
return (0, standard_as_callback_1.default)(new Promise(function(
|
|
41774
|
+
return (0, standard_as_callback_1.default)(new Promise(function(resolve3, reject) {
|
|
40824
41775
|
monitorInstance.once("error", reject);
|
|
40825
41776
|
monitorInstance.once("monitoring", function() {
|
|
40826
|
-
|
|
41777
|
+
resolve3(monitorInstance);
|
|
40827
41778
|
});
|
|
40828
41779
|
}), callback);
|
|
40829
41780
|
}
|
|
@@ -41645,6 +42596,7 @@ async function runMenu() {
|
|
|
41645
42596
|
const value = await Ee({
|
|
41646
42597
|
message: "What now?",
|
|
41647
42598
|
options: [
|
|
42599
|
+
{ value: "init", label: "Initialize this project (migrate .env)", hint: "keynv init" },
|
|
41648
42600
|
{ value: "projects", label: "Projects" },
|
|
41649
42601
|
{ value: "secrets", label: "Secrets" },
|
|
41650
42602
|
{ value: "members", label: "Members" },
|
|
@@ -41683,7 +42635,10 @@ async function runMenu() {
|
|
|
41683
42635
|
ye("Logged out.");
|
|
41684
42636
|
return 0;
|
|
41685
42637
|
}
|
|
41686
|
-
if (choice === "
|
|
42638
|
+
if (choice === "init") {
|
|
42639
|
+
const { runInitFlow: runInitFlow2 } = await Promise.resolve().then(() => (init_init(), init_exports));
|
|
42640
|
+
await runInitFlow2(client, { cwd: process.cwd(), dryRun: false, noScripts: false });
|
|
42641
|
+
} else if (choice === "projects") await runProjectsFlow(client);
|
|
41687
42642
|
else if (choice === "secrets") await runSecretsFlow(client);
|
|
41688
42643
|
else if (choice === "members") await runMembersFlow(client);
|
|
41689
42644
|
else if (choice === "audit") await runAuditFlow(client);
|
|
@@ -43496,134 +44451,7 @@ var AuditVerifyCommand = class extends Command {
|
|
|
43496
44451
|
|
|
43497
44452
|
// src/commands/exec.ts
|
|
43498
44453
|
init_http();
|
|
43499
|
-
|
|
43500
|
-
// src/exec/envFile.ts
|
|
43501
|
-
init_dist();
|
|
43502
|
-
var MAX_FILE_BYTES = 1e6;
|
|
43503
|
-
var KEY_RE2 = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
43504
|
-
var ENV_FILE_BASENAME = ".keynv.env";
|
|
43505
|
-
var EnvFileParseError = class extends Error {
|
|
43506
|
-
constructor(file, line, reason) {
|
|
43507
|
-
super(`${file}:${line}: ${reason}`);
|
|
43508
|
-
this.file = file;
|
|
43509
|
-
this.line = line;
|
|
43510
|
-
this.reason = reason;
|
|
43511
|
-
this.name = "EnvFileParseError";
|
|
43512
|
-
}
|
|
43513
|
-
file;
|
|
43514
|
-
line;
|
|
43515
|
-
reason;
|
|
43516
|
-
};
|
|
43517
|
-
var EnvFileNotFoundError = class extends Error {
|
|
43518
|
-
constructor(path) {
|
|
43519
|
-
super(`env file not found: ${path}`);
|
|
43520
|
-
this.path = path;
|
|
43521
|
-
this.name = "EnvFileNotFoundError";
|
|
43522
|
-
}
|
|
43523
|
-
path;
|
|
43524
|
-
};
|
|
43525
|
-
var EnvFileTooLargeError = class extends Error {
|
|
43526
|
-
constructor(path, bytes) {
|
|
43527
|
-
super(`env file ${path} is ${bytes} bytes (max ${MAX_FILE_BYTES})`);
|
|
43528
|
-
this.path = path;
|
|
43529
|
-
this.bytes = bytes;
|
|
43530
|
-
this.name = "EnvFileTooLargeError";
|
|
43531
|
-
}
|
|
43532
|
-
path;
|
|
43533
|
-
bytes;
|
|
43534
|
-
};
|
|
43535
|
-
function parseEnvFile(content, filename) {
|
|
43536
|
-
const normalized = content.charCodeAt(0) === 65279 ? content.slice(1) : content;
|
|
43537
|
-
const lines = normalized.split(/\r?\n/);
|
|
43538
|
-
const entries = [];
|
|
43539
|
-
for (let i = 0; i < lines.length; i++) {
|
|
43540
|
-
const raw = lines[i] ?? "";
|
|
43541
|
-
const lineNo = i + 1;
|
|
43542
|
-
const trimmed = raw.trim();
|
|
43543
|
-
if (trimmed.length === 0) continue;
|
|
43544
|
-
if (trimmed.startsWith("#")) continue;
|
|
43545
|
-
let body = trimmed;
|
|
43546
|
-
if (body.startsWith("export ")) {
|
|
43547
|
-
body = body.slice("export ".length).trimStart();
|
|
43548
|
-
}
|
|
43549
|
-
const eq = body.indexOf("=");
|
|
43550
|
-
if (eq <= 0) {
|
|
43551
|
-
throw new EnvFileParseError(filename, lineNo, "expected 'KEY=value'");
|
|
43552
|
-
}
|
|
43553
|
-
const name = body.slice(0, eq).trim();
|
|
43554
|
-
if (!KEY_RE2.test(name)) {
|
|
43555
|
-
throw new EnvFileParseError(
|
|
43556
|
-
filename,
|
|
43557
|
-
lineNo,
|
|
43558
|
-
`invalid key '${name}' (must match /^[A-Za-z_][A-Za-z0-9_]*$/)`
|
|
43559
|
-
);
|
|
43560
|
-
}
|
|
43561
|
-
let valueRaw = body.slice(eq + 1);
|
|
43562
|
-
let value;
|
|
43563
|
-
const valueLeading = valueRaw.replace(/^\s+/, "");
|
|
43564
|
-
const firstCh = valueLeading.charAt(0);
|
|
43565
|
-
if (firstCh === '"' || firstCh === "'") {
|
|
43566
|
-
const close = valueLeading.lastIndexOf(firstCh);
|
|
43567
|
-
if (close === 0) {
|
|
43568
|
-
throw new EnvFileParseError(filename, lineNo, `unclosed ${firstCh} quote`);
|
|
43569
|
-
}
|
|
43570
|
-
const after = valueLeading.slice(close + 1).trim();
|
|
43571
|
-
if (after.length > 0) {
|
|
43572
|
-
throw new EnvFileParseError(
|
|
43573
|
-
filename,
|
|
43574
|
-
lineNo,
|
|
43575
|
-
`unexpected content after closing ${firstCh}`
|
|
43576
|
-
);
|
|
43577
|
-
}
|
|
43578
|
-
value = valueLeading.slice(1, close);
|
|
43579
|
-
} else {
|
|
43580
|
-
value = valueRaw.replace(/\s+$/, "");
|
|
43581
|
-
value = value.replace(/^\s+/, "");
|
|
43582
|
-
}
|
|
43583
|
-
entries.push({
|
|
43584
|
-
name,
|
|
43585
|
-
value,
|
|
43586
|
-
isAlias: parseAlias(value) !== null,
|
|
43587
|
-
line: lineNo
|
|
43588
|
-
});
|
|
43589
|
-
}
|
|
43590
|
-
return entries;
|
|
43591
|
-
}
|
|
43592
|
-
function findEnvFile(startDir) {
|
|
43593
|
-
let dir = resolve(startDir);
|
|
43594
|
-
for (let i = 0; i < 64; i++) {
|
|
43595
|
-
const candidate = join(dir, ENV_FILE_BASENAME);
|
|
43596
|
-
if (existsSync(candidate)) {
|
|
43597
|
-
try {
|
|
43598
|
-
if (statSync(candidate).isFile()) return candidate;
|
|
43599
|
-
} catch {
|
|
43600
|
-
}
|
|
43601
|
-
}
|
|
43602
|
-
const parent = dirname(dir);
|
|
43603
|
-
if (parent === dir) return null;
|
|
43604
|
-
dir = parent;
|
|
43605
|
-
}
|
|
43606
|
-
return null;
|
|
43607
|
-
}
|
|
43608
|
-
function loadEnvFile(opts) {
|
|
43609
|
-
if (opts.disabled) return null;
|
|
43610
|
-
const pickExplicit = opts.explicitPath ?? opts.envVarOverride;
|
|
43611
|
-
let path = null;
|
|
43612
|
-
if (pickExplicit !== void 0) {
|
|
43613
|
-
path = isAbsolute(pickExplicit) ? pickExplicit : resolve(opts.cwd, pickExplicit);
|
|
43614
|
-
if (!existsSync(path)) throw new EnvFileNotFoundError(path);
|
|
43615
|
-
} else {
|
|
43616
|
-
path = findEnvFile(opts.cwd);
|
|
43617
|
-
}
|
|
43618
|
-
if (path === null) return null;
|
|
43619
|
-
const stat = statSync(path);
|
|
43620
|
-
if (stat.size > MAX_FILE_BYTES) {
|
|
43621
|
-
throw new EnvFileTooLargeError(path, stat.size);
|
|
43622
|
-
}
|
|
43623
|
-
const content = readFileSync(path, "utf8");
|
|
43624
|
-
const entries = parseEnvFile(content, path);
|
|
43625
|
-
return { path, entries };
|
|
43626
|
-
}
|
|
44454
|
+
init_envFile();
|
|
43627
44455
|
|
|
43628
44456
|
// src/exec/resolve.ts
|
|
43629
44457
|
init_dist();
|
|
@@ -43984,14 +44812,14 @@ function spawnPrivileged(opts) {
|
|
|
43984
44812
|
}, opts.timeoutS * 1e3);
|
|
43985
44813
|
timer.unref();
|
|
43986
44814
|
}
|
|
43987
|
-
return new Promise((
|
|
44815
|
+
return new Promise((resolve3, reject) => {
|
|
43988
44816
|
child.on("error", (err) => {
|
|
43989
44817
|
if (timer) clearTimeout(timer);
|
|
43990
44818
|
reject(err);
|
|
43991
44819
|
});
|
|
43992
44820
|
child.on("close", (code, signal) => {
|
|
43993
44821
|
if (timer) clearTimeout(timer);
|
|
43994
|
-
|
|
44822
|
+
resolve3({
|
|
43995
44823
|
exitCode: code ?? 0,
|
|
43996
44824
|
signal,
|
|
43997
44825
|
durationMs: Date.now() - startedAt
|
|
@@ -44209,552 +45037,67 @@ function signalNumber(sig) {
|
|
|
44209
45037
|
return map[sig] ?? null;
|
|
44210
45038
|
}
|
|
44211
45039
|
|
|
44212
|
-
//
|
|
44213
|
-
|
|
44214
|
-
|
|
44215
|
-
|
|
44216
|
-
|
|
44217
|
-
|
|
44218
|
-
"
|
|
44219
|
-
"**/.env.*",
|
|
44220
|
-
"**/*.env",
|
|
44221
|
-
// raw key material
|
|
44222
|
-
"*.pem",
|
|
44223
|
-
"*.key",
|
|
44224
|
-
"*.p12",
|
|
44225
|
-
"*.pfx",
|
|
44226
|
-
"**/*.pem",
|
|
44227
|
-
"**/*.key",
|
|
44228
|
-
"**/*.p12",
|
|
44229
|
-
"**/*.pfx",
|
|
44230
|
-
// SSH private keys
|
|
44231
|
-
"id_rsa",
|
|
44232
|
-
"id_rsa.*",
|
|
44233
|
-
"id_ed25519",
|
|
44234
|
-
"id_ed25519.*",
|
|
44235
|
-
"id_ecdsa",
|
|
44236
|
-
"id_ecdsa.*",
|
|
44237
|
-
"**/id_rsa",
|
|
44238
|
-
"**/id_rsa.*",
|
|
44239
|
-
"**/id_ed25519",
|
|
44240
|
-
"**/id_ed25519.*",
|
|
44241
|
-
"**/id_ecdsa",
|
|
44242
|
-
"**/id_ecdsa.*",
|
|
44243
|
-
// Generic credential containers
|
|
44244
|
-
"*credentials*",
|
|
44245
|
-
"*.kdbx",
|
|
44246
|
-
"**/*credentials*",
|
|
44247
|
-
"**/*.kdbx",
|
|
44248
|
-
// Cloud provider credential paths (typically under ~/, but also
|
|
44249
|
-
// appear at project roots in dev setups)
|
|
44250
|
-
".aws/credentials",
|
|
44251
|
-
"**/.aws/credentials",
|
|
44252
|
-
".aws/config",
|
|
44253
|
-
"**/.aws/config",
|
|
44254
|
-
".gcp/**/key.json",
|
|
44255
|
-
"**/.gcp/**/key.json",
|
|
44256
|
-
"**/google-services.json",
|
|
44257
|
-
"**/service-account*.json",
|
|
44258
|
-
".azure/**",
|
|
44259
|
-
"**/.azure/**",
|
|
44260
|
-
".kube/config",
|
|
44261
|
-
"**/.kube/config",
|
|
44262
|
-
".docker/config.json",
|
|
44263
|
-
"**/.docker/config.json"
|
|
44264
|
-
];
|
|
44265
|
-
var KEYNV_FILE_ALLOW_PATTERNS = [
|
|
44266
|
-
".keynv.env",
|
|
44267
|
-
"**/.keynv.env"
|
|
44268
|
-
];
|
|
44269
|
-
function gitignoreBlock() {
|
|
44270
|
-
return [...KEYNV_FILE_DENY_PATTERNS, ...KEYNV_FILE_ALLOW_PATTERNS.map((p2) => `!${p2}`)];
|
|
44271
|
-
}
|
|
44272
|
-
var KEYNV_BEGIN = "# >>> keynv >>>";
|
|
44273
|
-
var KEYNV_END = "# <<< keynv <<<";
|
|
44274
|
-
function readJsonOrEmpty(path) {
|
|
44275
|
-
if (!existsSync(path))
|
|
44276
|
-
return {};
|
|
44277
|
-
try {
|
|
44278
|
-
return JSON.parse(readFileSync(path, "utf8"));
|
|
44279
|
-
} catch {
|
|
44280
|
-
return {};
|
|
44281
|
-
}
|
|
44282
|
-
}
|
|
44283
|
-
function ensureDir(path) {
|
|
44284
|
-
const dir = dirname(path);
|
|
44285
|
-
if (!existsSync(dir))
|
|
44286
|
-
mkdirSync(dir, { recursive: true });
|
|
44287
|
-
}
|
|
44288
|
-
function writeJson(path, value) {
|
|
44289
|
-
ensureDir(path);
|
|
44290
|
-
writeFileSync(path, `${JSON.stringify(value, null, 2)}
|
|
44291
|
-
`, { mode: 420 });
|
|
44292
|
-
}
|
|
44293
|
-
function ensureKeynvBlock(path, lines) {
|
|
44294
|
-
const existing = existsSync(path) ? readFileSync(path, "utf8") : "";
|
|
44295
|
-
const marked = existing.split("\n");
|
|
44296
|
-
const beginIdx = marked.findIndex((l) => l.trim() === KEYNV_BEGIN);
|
|
44297
|
-
const endIdx = marked.findIndex((l) => l.trim() === KEYNV_END);
|
|
44298
|
-
const block = [KEYNV_BEGIN, ...lines, KEYNV_END];
|
|
44299
|
-
let next;
|
|
44300
|
-
if (beginIdx >= 0 && endIdx > beginIdx) {
|
|
44301
|
-
next = [...marked.slice(0, beginIdx), ...block, ...marked.slice(endIdx + 1)];
|
|
44302
|
-
} else {
|
|
44303
|
-
next = existing.length > 0 && !existing.endsWith("\n") ? [...marked, "", ...block] : [...marked[marked.length - 1] === "" ? marked.slice(0, -1) : marked, ...block, ""];
|
|
44304
|
-
}
|
|
44305
|
-
const out = next.join("\n");
|
|
44306
|
-
if (out === existing)
|
|
44307
|
-
return false;
|
|
44308
|
-
ensureDir(path);
|
|
44309
|
-
writeFileSync(path, out, { mode: 420 });
|
|
44310
|
-
return true;
|
|
44311
|
-
}
|
|
44312
|
-
function removeKeynvBlock(path) {
|
|
44313
|
-
if (!existsSync(path))
|
|
44314
|
-
return false;
|
|
44315
|
-
const lines = readFileSync(path, "utf8").split("\n");
|
|
44316
|
-
const beginIdx = lines.findIndex((l) => l.trim() === KEYNV_BEGIN);
|
|
44317
|
-
const endIdx = lines.findIndex((l) => l.trim() === KEYNV_END);
|
|
44318
|
-
if (beginIdx < 0 || endIdx <= beginIdx)
|
|
44319
|
-
return false;
|
|
44320
|
-
const next = [...lines.slice(0, beginIdx), ...lines.slice(endIdx + 1)];
|
|
44321
|
-
while (next.length > 0 && next[next.length - 1] === "")
|
|
44322
|
-
next.pop();
|
|
44323
|
-
writeFileSync(path, `${next.join("\n")}${next.length ? "\n" : ""}`, { mode: 420 });
|
|
44324
|
-
return true;
|
|
44325
|
-
}
|
|
44326
|
-
|
|
44327
|
-
// ../../packages/integrations/dist/aider.js
|
|
44328
|
-
var AIDER_IGNORE_REL = ".aiderignore";
|
|
44329
|
-
var aider = {
|
|
44330
|
-
name: "aider",
|
|
44331
|
-
displayName: "Aider",
|
|
44332
|
-
async detect(opts = {}) {
|
|
44333
|
-
const cwd = opts.cwd ?? process.cwd();
|
|
44334
|
-
return existsSync(join(cwd, AIDER_IGNORE_REL)) || existsSync(join(cwd, ".aider.conf.yml")) || existsSync(join(homedir(), ".aider.conf.yml"));
|
|
44335
|
-
},
|
|
44336
|
-
async install(opts = {}) {
|
|
44337
|
-
const cwd = opts.cwd ?? process.cwd();
|
|
44338
|
-
const path = join(cwd, AIDER_IGNORE_REL);
|
|
44339
|
-
if (opts.dryRun) {
|
|
44340
|
-
return {
|
|
44341
|
-
agent: "aider",
|
|
44342
|
-
applied: false,
|
|
44343
|
-
changes: [{ path, action: "update" }],
|
|
44344
|
-
summary: `[dry-run] would write ${path}`
|
|
44345
|
-
};
|
|
44346
|
-
}
|
|
44347
|
-
const changed = ensureKeynvBlock(path, gitignoreBlock());
|
|
44348
|
-
return {
|
|
44349
|
-
agent: "aider",
|
|
44350
|
-
applied: true,
|
|
44351
|
-
changes: [{ path, action: changed ? "update" : "skip" }],
|
|
44352
|
-
summary: changed ? `wrote ${KEYNV_FILE_DENY_PATTERNS.length} patterns to ${AIDER_IGNORE_REL}` : "unchanged"
|
|
44353
|
-
};
|
|
44354
|
-
},
|
|
44355
|
-
async uninstall(opts = {}) {
|
|
44356
|
-
const cwd = opts.cwd ?? process.cwd();
|
|
44357
|
-
const path = join(cwd, AIDER_IGNORE_REL);
|
|
44358
|
-
if (opts.dryRun) {
|
|
44359
|
-
return {
|
|
44360
|
-
agent: "aider",
|
|
44361
|
-
applied: false,
|
|
44362
|
-
changes: [{ path, action: "update" }],
|
|
44363
|
-
summary: `[dry-run] would remove keynv block from ${AIDER_IGNORE_REL}`
|
|
44364
|
-
};
|
|
44365
|
-
}
|
|
44366
|
-
const changed = removeKeynvBlock(path);
|
|
44367
|
-
return {
|
|
44368
|
-
agent: "aider",
|
|
44369
|
-
applied: true,
|
|
44370
|
-
changes: [{ path, action: changed ? "update" : "skip" }],
|
|
44371
|
-
summary: changed ? "removed keynv block" : "no keynv block found"
|
|
44372
|
-
};
|
|
44373
|
-
}
|
|
44374
|
-
};
|
|
44375
|
-
var SETTINGS_PATH_REL = ".claude/settings.local.json";
|
|
44376
|
-
var KEYNV_DENY_TAG = "__keynv_managed__";
|
|
44377
|
-
function denyEntriesForReadTool() {
|
|
44378
|
-
return KEYNV_FILE_DENY_PATTERNS.map((p2) => `Read(${p2})`);
|
|
44379
|
-
}
|
|
44380
|
-
function allowEntriesForReadTool() {
|
|
44381
|
-
return KEYNV_FILE_ALLOW_PATTERNS.map((p2) => `Read(${p2})`);
|
|
44382
|
-
}
|
|
44383
|
-
var claudeCode = {
|
|
44384
|
-
name: "claude-code",
|
|
44385
|
-
displayName: "Claude Code",
|
|
44386
|
-
async detect(opts = {}) {
|
|
44387
|
-
const cwd = opts.cwd ?? process.cwd();
|
|
44388
|
-
return existsSync(join(cwd, ".claude"));
|
|
44389
|
-
},
|
|
44390
|
-
async install(opts = {}) {
|
|
44391
|
-
const cwd = opts.cwd ?? process.cwd();
|
|
44392
|
-
const path = join(cwd, SETTINGS_PATH_REL);
|
|
44393
|
-
const settings = readJsonOrEmpty(path);
|
|
44394
|
-
const denyToAdd = denyEntriesForReadTool();
|
|
44395
|
-
const allowToAdd = allowEntriesForReadTool();
|
|
44396
|
-
const existingDeny = new Set(settings.permissions?.deny ?? []);
|
|
44397
|
-
const existingAllow = new Set(settings.permissions?.allow ?? []);
|
|
44398
|
-
const newlyAdded = [];
|
|
44399
|
-
for (const entry2 of denyToAdd) {
|
|
44400
|
-
if (!existingDeny.has(entry2)) {
|
|
44401
|
-
existingDeny.add(entry2);
|
|
44402
|
-
newlyAdded.push(entry2);
|
|
44403
|
-
}
|
|
44404
|
-
}
|
|
44405
|
-
for (const entry2 of allowToAdd) {
|
|
44406
|
-
if (!existingAllow.has(entry2)) {
|
|
44407
|
-
existingAllow.add(entry2);
|
|
44408
|
-
}
|
|
44409
|
-
}
|
|
44410
|
-
settings.permissions = {
|
|
44411
|
-
...settings.permissions,
|
|
44412
|
-
allow: [...existingAllow].sort((a, b2) => a.localeCompare(b2)),
|
|
44413
|
-
deny: [...existingDeny].sort((a, b2) => a.localeCompare(b2))
|
|
44414
|
-
};
|
|
44415
|
-
settings.hooks = settings.hooks ?? {};
|
|
44416
|
-
const post = settings.hooks["PostToolUse"] ?? [];
|
|
44417
|
-
const alreadyHooked = post.some((entry2) => (entry2.hooks ?? []).some((h2) => h2.command?.includes("keynv redact-stream")));
|
|
44418
|
-
if (!alreadyHooked) {
|
|
44419
|
-
post.push({
|
|
44420
|
-
matcher: "Bash",
|
|
44421
|
-
hooks: [{ type: "command", command: "keynv redact-stream" }]
|
|
44422
|
-
});
|
|
44423
|
-
settings.hooks["PostToolUse"] = post;
|
|
44424
|
-
}
|
|
44425
|
-
settings[KEYNV_DENY_TAG] = {
|
|
44426
|
-
deny_added: denyToAdd,
|
|
44427
|
-
allow_added: allowToAdd,
|
|
44428
|
-
hook_added: true
|
|
44429
|
-
};
|
|
44430
|
-
const changes = [];
|
|
44431
|
-
if (opts.dryRun) {
|
|
44432
|
-
changes.push({
|
|
44433
|
-
path,
|
|
44434
|
-
action: existsSync(path) ? "update" : "create",
|
|
44435
|
-
note: `would add ${newlyAdded.length} deny entries${alreadyHooked ? "" : " + PostToolUse(Bash) \u2192 keynv redact-stream"}`
|
|
44436
|
-
});
|
|
44437
|
-
} else {
|
|
44438
|
-
writeJson(path, settings);
|
|
44439
|
-
changes.push({
|
|
44440
|
-
path,
|
|
44441
|
-
action: existsSync(path) ? "update" : "create",
|
|
44442
|
-
note: `${newlyAdded.length} new deny entries${alreadyHooked ? "" : " + redact hook"}`
|
|
44443
|
-
});
|
|
44444
|
-
}
|
|
44445
|
-
return {
|
|
44446
|
-
agent: "claude-code",
|
|
44447
|
-
applied: !opts.dryRun,
|
|
44448
|
-
changes,
|
|
44449
|
-
summary: opts.dryRun ? `[dry-run] ${path}: would add ${newlyAdded.length} permission denies + redact hook` : `installed: ${newlyAdded.length} new denies; redact hook ${alreadyHooked ? "kept" : "added"}.`
|
|
44450
|
-
};
|
|
44451
|
-
},
|
|
44452
|
-
async uninstall(opts = {}) {
|
|
44453
|
-
const cwd = opts.cwd ?? process.cwd();
|
|
44454
|
-
const path = join(cwd, SETTINGS_PATH_REL);
|
|
44455
|
-
if (!existsSync(path)) {
|
|
44456
|
-
return {
|
|
44457
|
-
agent: "claude-code",
|
|
44458
|
-
applied: false,
|
|
44459
|
-
changes: [{ path, action: "skip", note: "no settings file" }],
|
|
44460
|
-
summary: "nothing to uninstall"
|
|
44461
|
-
};
|
|
44462
|
-
}
|
|
44463
|
-
const settings = readJsonOrEmpty(path);
|
|
44464
|
-
const tracker = settings[KEYNV_DENY_TAG];
|
|
44465
|
-
const removedDeny = [];
|
|
44466
|
-
const permissions = settings.permissions;
|
|
44467
|
-
if (tracker?.deny_added && permissions && Array.isArray(permissions.deny)) {
|
|
44468
|
-
const remove = new Set(tracker.deny_added);
|
|
44469
|
-
const before = permissions.deny;
|
|
44470
|
-
permissions.deny = before.filter((entry2) => {
|
|
44471
|
-
if (remove.has(entry2)) {
|
|
44472
|
-
removedDeny.push(entry2);
|
|
44473
|
-
return false;
|
|
44474
|
-
}
|
|
44475
|
-
return true;
|
|
44476
|
-
});
|
|
44477
|
-
if (permissions.deny.length === 0)
|
|
44478
|
-
delete permissions.deny;
|
|
44479
|
-
}
|
|
44480
|
-
if (tracker?.allow_added && permissions && Array.isArray(permissions.allow)) {
|
|
44481
|
-
const remove = new Set(tracker.allow_added);
|
|
44482
|
-
permissions.allow = permissions.allow.filter((entry2) => !remove.has(entry2));
|
|
44483
|
-
if (permissions.allow.length === 0)
|
|
44484
|
-
delete permissions.allow;
|
|
44485
|
-
}
|
|
44486
|
-
const hooks = settings.hooks;
|
|
44487
|
-
if (tracker?.hook_added && hooks && Array.isArray(hooks.PostToolUse)) {
|
|
44488
|
-
const filtered = hooks.PostToolUse.filter((entry2) => !(entry2.hooks ?? []).some((h2) => h2.command?.includes("keynv redact-stream")));
|
|
44489
|
-
hooks.PostToolUse = filtered;
|
|
44490
|
-
if (filtered.length === 0)
|
|
44491
|
-
delete hooks.PostToolUse;
|
|
44492
|
-
}
|
|
44493
|
-
delete settings[KEYNV_DENY_TAG];
|
|
44494
|
-
if (opts.dryRun) {
|
|
44495
|
-
return {
|
|
44496
|
-
agent: "claude-code",
|
|
44497
|
-
applied: false,
|
|
44498
|
-
changes: [
|
|
44499
|
-
{ path, action: "update", note: `would remove ${removedDeny.length} denies + hook` }
|
|
44500
|
-
],
|
|
44501
|
-
summary: `[dry-run] would remove ${removedDeny.length} denies`
|
|
44502
|
-
};
|
|
44503
|
-
}
|
|
44504
|
-
writeJson(path, settings);
|
|
44505
|
-
return {
|
|
44506
|
-
agent: "claude-code",
|
|
44507
|
-
applied: true,
|
|
44508
|
-
changes: [{ path, action: "update" }],
|
|
44509
|
-
summary: `removed ${removedDeny.length} denies + hook`
|
|
44510
|
-
};
|
|
44511
|
-
}
|
|
44512
|
-
};
|
|
44513
|
-
var CODEX_IGNORE_REL = ".codex/.deny";
|
|
44514
|
-
var codexCli = {
|
|
44515
|
-
name: "codex",
|
|
44516
|
-
displayName: "Codex CLI",
|
|
44517
|
-
async detect(opts = {}) {
|
|
44518
|
-
const cwd = opts.cwd ?? process.cwd();
|
|
44519
|
-
return existsSync(join(cwd, ".codex")) || existsSync(join(homedir(), ".codex"));
|
|
44520
|
-
},
|
|
44521
|
-
async install(opts = {}) {
|
|
44522
|
-
const cwd = opts.cwd ?? process.cwd();
|
|
44523
|
-
const path = join(cwd, CODEX_IGNORE_REL);
|
|
44524
|
-
if (opts.dryRun) {
|
|
44525
|
-
return {
|
|
44526
|
-
agent: "codex",
|
|
44527
|
-
applied: false,
|
|
44528
|
-
changes: [{ path, action: "update" }],
|
|
44529
|
-
summary: `[dry-run] would write ${CODEX_IGNORE_REL}`
|
|
44530
|
-
};
|
|
44531
|
-
}
|
|
44532
|
-
const changed = ensureKeynvBlock(path, gitignoreBlock());
|
|
44533
|
-
return {
|
|
44534
|
-
agent: "codex",
|
|
44535
|
-
applied: true,
|
|
44536
|
-
changes: [{ path, action: changed ? "update" : "skip" }],
|
|
44537
|
-
summary: changed ? `wrote ${CODEX_IGNORE_REL}; consider adding 'alias codex="keynv exec -- codex"' to your shell rc` : "unchanged"
|
|
44538
|
-
};
|
|
44539
|
-
},
|
|
44540
|
-
async uninstall(opts = {}) {
|
|
44541
|
-
const cwd = opts.cwd ?? process.cwd();
|
|
44542
|
-
const path = join(cwd, CODEX_IGNORE_REL);
|
|
44543
|
-
if (opts.dryRun) {
|
|
44544
|
-
return {
|
|
44545
|
-
agent: "codex",
|
|
44546
|
-
applied: false,
|
|
44547
|
-
changes: [{ path, action: "update" }],
|
|
44548
|
-
summary: `[dry-run] would remove keynv block from ${CODEX_IGNORE_REL}`
|
|
44549
|
-
};
|
|
44550
|
-
}
|
|
44551
|
-
const changed = removeKeynvBlock(path);
|
|
44552
|
-
return {
|
|
44553
|
-
agent: "codex",
|
|
44554
|
-
applied: true,
|
|
44555
|
-
changes: [{ path, action: changed ? "update" : "skip" }],
|
|
44556
|
-
summary: changed ? "removed keynv block" : "no keynv block found"
|
|
44557
|
-
};
|
|
44558
|
-
}
|
|
44559
|
-
};
|
|
44560
|
-
var CURSOR_IGNORE_REL = ".cursorignore";
|
|
44561
|
-
var cursor = {
|
|
44562
|
-
name: "cursor",
|
|
44563
|
-
displayName: "Cursor",
|
|
44564
|
-
async detect(opts = {}) {
|
|
44565
|
-
const cwd = opts.cwd ?? process.cwd();
|
|
44566
|
-
return existsSync(join(cwd, ".cursor")) || existsSync(join(cwd, ".cursorrules"));
|
|
44567
|
-
},
|
|
44568
|
-
async install(opts = {}) {
|
|
44569
|
-
const cwd = opts.cwd ?? process.cwd();
|
|
44570
|
-
const path = join(cwd, CURSOR_IGNORE_REL);
|
|
44571
|
-
if (opts.dryRun) {
|
|
44572
|
-
return {
|
|
44573
|
-
agent: "cursor",
|
|
44574
|
-
applied: false,
|
|
44575
|
-
changes: [
|
|
44576
|
-
{
|
|
44577
|
-
path,
|
|
44578
|
-
action: "update",
|
|
44579
|
-
note: `would add ${KEYNV_FILE_DENY_PATTERNS.length} ignore patterns`
|
|
44580
|
-
}
|
|
44581
|
-
],
|
|
44582
|
-
summary: `[dry-run] would write ${path}`
|
|
44583
|
-
};
|
|
44584
|
-
}
|
|
44585
|
-
const changed = ensureKeynvBlock(path, gitignoreBlock());
|
|
44586
|
-
return {
|
|
44587
|
-
agent: "cursor",
|
|
44588
|
-
applied: true,
|
|
44589
|
-
changes: [{ path, action: changed ? "update" : "skip" }],
|
|
44590
|
-
summary: changed ? `wrote ${KEYNV_FILE_DENY_PATTERNS.length} patterns to ${CURSOR_IGNORE_REL}` : "unchanged"
|
|
44591
|
-
};
|
|
44592
|
-
},
|
|
44593
|
-
async uninstall(opts = {}) {
|
|
44594
|
-
const cwd = opts.cwd ?? process.cwd();
|
|
44595
|
-
const path = join(cwd, CURSOR_IGNORE_REL);
|
|
44596
|
-
if (opts.dryRun) {
|
|
44597
|
-
return {
|
|
44598
|
-
agent: "cursor",
|
|
44599
|
-
applied: false,
|
|
44600
|
-
changes: [{ path, action: "update" }],
|
|
44601
|
-
summary: `[dry-run] would remove keynv block from ${CURSOR_IGNORE_REL}`
|
|
44602
|
-
};
|
|
44603
|
-
}
|
|
44604
|
-
const changed = removeKeynvBlock(path);
|
|
44605
|
-
return {
|
|
44606
|
-
agent: "cursor",
|
|
44607
|
-
applied: true,
|
|
44608
|
-
changes: [{ path, action: changed ? "update" : "skip" }],
|
|
44609
|
-
summary: changed ? "removed keynv block" : "no keynv block found"
|
|
44610
|
-
};
|
|
44611
|
-
}
|
|
44612
|
-
};
|
|
44613
|
-
var OPENCODE_IGNORE_REL = ".opencode/.keynv-deny";
|
|
44614
|
-
var opencode = {
|
|
44615
|
-
name: "opencode",
|
|
44616
|
-
displayName: "OpenCode",
|
|
44617
|
-
async detect(opts = {}) {
|
|
44618
|
-
const cwd = opts.cwd ?? process.cwd();
|
|
44619
|
-
return existsSync(join(cwd, ".opencode")) || existsSync(join(homedir(), ".opencode"));
|
|
44620
|
-
},
|
|
44621
|
-
async install(opts = {}) {
|
|
44622
|
-
const cwd = opts.cwd ?? process.cwd();
|
|
44623
|
-
const path = join(cwd, OPENCODE_IGNORE_REL);
|
|
44624
|
-
if (opts.dryRun) {
|
|
44625
|
-
return {
|
|
44626
|
-
agent: "opencode",
|
|
44627
|
-
applied: false,
|
|
44628
|
-
changes: [{ path, action: "update" }],
|
|
44629
|
-
summary: `[dry-run] would write ${OPENCODE_IGNORE_REL}`
|
|
44630
|
-
};
|
|
44631
|
-
}
|
|
44632
|
-
const changed = ensureKeynvBlock(path, gitignoreBlock());
|
|
44633
|
-
return {
|
|
44634
|
-
agent: "opencode",
|
|
44635
|
-
applied: true,
|
|
44636
|
-
changes: [{ path, action: changed ? "update" : "skip" }],
|
|
44637
|
-
summary: changed ? `wrote ${OPENCODE_IGNORE_REL}; full hook/MCP integration TBD` : "unchanged"
|
|
44638
|
-
};
|
|
44639
|
-
},
|
|
44640
|
-
async uninstall(opts = {}) {
|
|
44641
|
-
const cwd = opts.cwd ?? process.cwd();
|
|
44642
|
-
const path = join(cwd, OPENCODE_IGNORE_REL);
|
|
44643
|
-
if (opts.dryRun) {
|
|
44644
|
-
return {
|
|
44645
|
-
agent: "opencode",
|
|
44646
|
-
applied: false,
|
|
44647
|
-
changes: [{ path, action: "update" }],
|
|
44648
|
-
summary: `[dry-run] would remove keynv block from ${OPENCODE_IGNORE_REL}`
|
|
44649
|
-
};
|
|
44650
|
-
}
|
|
44651
|
-
const changed = removeKeynvBlock(path);
|
|
44652
|
-
return {
|
|
44653
|
-
agent: "opencode",
|
|
44654
|
-
applied: true,
|
|
44655
|
-
changes: [{ path, action: changed ? "update" : "skip" }],
|
|
44656
|
-
summary: changed ? "removed keynv block" : "no keynv block found"
|
|
44657
|
-
};
|
|
44658
|
-
}
|
|
44659
|
-
};
|
|
44660
|
-
|
|
44661
|
-
// ../../packages/integrations/dist/index.js
|
|
44662
|
-
var REGISTRY = [claudeCode, cursor, opencode, codexCli, aider];
|
|
44663
|
-
function findIntegration(name) {
|
|
44664
|
-
return REGISTRY.find((i) => i.name === name) ?? null;
|
|
44665
|
-
}
|
|
44666
|
-
|
|
44667
|
-
// src/commands/install.ts
|
|
44668
|
-
function printReport(stdout, report) {
|
|
44669
|
-
stdout.write(`[${report.agent}] ${report.summary}
|
|
44670
|
-
`);
|
|
44671
|
-
for (const change of report.changes) {
|
|
44672
|
-
const note = change.note ? `: ${change.note}` : "";
|
|
44673
|
-
stdout.write(` ${change.action.padEnd(7)} ${change.path}${note}
|
|
44674
|
-
`);
|
|
44675
|
-
}
|
|
44676
|
-
}
|
|
44677
|
-
var InstallCommand = class extends Command {
|
|
44678
|
-
static paths = [["install"]];
|
|
45040
|
+
// src/commands/init.ts
|
|
45041
|
+
init_http();
|
|
45042
|
+
init_tty();
|
|
45043
|
+
init_init();
|
|
45044
|
+
init_cancel();
|
|
45045
|
+
var InitCommand = class extends Command {
|
|
45046
|
+
static paths = [["init"]];
|
|
44679
45047
|
static usage = Command.Usage({
|
|
44680
|
-
description: "
|
|
45048
|
+
description: "Migrate an existing project from .env to keynv.",
|
|
44681
45049
|
details: `
|
|
44682
|
-
|
|
44683
|
-
|
|
44684
|
-
|
|
45050
|
+
Walks the current directory's .env files, prompts you to mark which
|
|
45051
|
+
keys are real secrets, uploads those to the keynv vault, writes a
|
|
45052
|
+
.keynv.env file with alias references, and (optionally) wraps your
|
|
45053
|
+
package.json scripts with \`keynv exec\`.
|
|
45054
|
+
|
|
45055
|
+
Safe to re-run: existing .keynv.env entries are preserved; new
|
|
45056
|
+
entries are appended below a marker.
|
|
45057
|
+
|
|
45058
|
+
Requires an interactive terminal (clack TUI). For scripted
|
|
45059
|
+
migration, use the lower-level \`keynv project\` and \`keynv secret\`
|
|
45060
|
+
commands directly.
|
|
44685
45061
|
`,
|
|
44686
45062
|
examples: [
|
|
44687
|
-
["
|
|
44688
|
-
["Preview
|
|
44689
|
-
["
|
|
44690
|
-
["List supported integrations", "$0 install list"]
|
|
45063
|
+
["Walk the current project", "$0 init"],
|
|
45064
|
+
["Preview without writing or uploading", "$0 init --dry-run"],
|
|
45065
|
+
["Skip the package.json script-wrapping step", "$0 init --no-scripts"]
|
|
44691
45066
|
]
|
|
44692
45067
|
});
|
|
44693
|
-
|
|
44694
|
-
|
|
44695
|
-
|
|
45068
|
+
dryRun = options_exports.Boolean("--dry-run", false, {
|
|
45069
|
+
description: "Show what would be done without writing files or uploading secrets."
|
|
45070
|
+
});
|
|
45071
|
+
noScripts = options_exports.Boolean("--no-scripts", false, {
|
|
45072
|
+
description: "Skip the package.json script-wrapping step."
|
|
45073
|
+
});
|
|
44696
45074
|
async execute() {
|
|
44697
|
-
if (
|
|
44698
|
-
this.context.stdout.write("Supported integrations:\n");
|
|
44699
|
-
for (const i of REGISTRY) {
|
|
44700
|
-
this.context.stdout.write(` ${i.name.padEnd(14)} ${i.displayName}
|
|
44701
|
-
`);
|
|
44702
|
-
}
|
|
44703
|
-
return 0;
|
|
44704
|
-
}
|
|
44705
|
-
if (this.all) {
|
|
44706
|
-
const cwd = process.cwd();
|
|
44707
|
-
let any = false;
|
|
44708
|
-
for (const integration2 of REGISTRY) {
|
|
44709
|
-
const detected = await integration2.detect({ cwd });
|
|
44710
|
-
if (!detected) continue;
|
|
44711
|
-
any = true;
|
|
44712
|
-
const report2 = await integration2.install({ cwd, dryRun: this.dryRun });
|
|
44713
|
-
printReport(this.context.stdout, report2);
|
|
44714
|
-
}
|
|
44715
|
-
if (!any) {
|
|
44716
|
-
this.context.stdout.write("no integrations detected in this directory\n");
|
|
44717
|
-
}
|
|
44718
|
-
return 0;
|
|
44719
|
-
}
|
|
44720
|
-
if (!this.agent) {
|
|
45075
|
+
if (!isInteractive()) {
|
|
44721
45076
|
this.context.stderr.write(
|
|
44722
|
-
"keynv
|
|
45077
|
+
"keynv init requires an interactive terminal. Use the lower-level commands (`keynv project`, `keynv secret`) for scripted setup.\n"
|
|
44723
45078
|
);
|
|
44724
|
-
return
|
|
45079
|
+
return 1;
|
|
44725
45080
|
}
|
|
44726
|
-
const
|
|
44727
|
-
|
|
44728
|
-
|
|
44729
|
-
|
|
44730
|
-
`
|
|
44731
|
-
);
|
|
45081
|
+
const client = new ApiClient();
|
|
45082
|
+
await client.ensureHydrated();
|
|
45083
|
+
if (!client.isLoggedIn) {
|
|
45084
|
+
this.context.stderr.write("keynv: not logged in. Run `keynv login` first.\n");
|
|
44732
45085
|
return 1;
|
|
44733
45086
|
}
|
|
44734
|
-
|
|
44735
|
-
|
|
44736
|
-
|
|
44737
|
-
|
|
44738
|
-
|
|
44739
|
-
|
|
44740
|
-
|
|
44741
|
-
|
|
44742
|
-
|
|
44743
|
-
|
|
44744
|
-
|
|
44745
|
-
|
|
44746
|
-
async execute() {
|
|
44747
|
-
const integration = findIntegration(this.agent);
|
|
44748
|
-
if (!integration) {
|
|
44749
|
-
this.context.stderr.write(
|
|
44750
|
-
`keynv: unknown integration '${this.agent}'. Try \`keynv install list\`.
|
|
44751
|
-
`
|
|
44752
|
-
);
|
|
45087
|
+
try {
|
|
45088
|
+
const outcome = await runInitFlow(client, {
|
|
45089
|
+
cwd: process.cwd(),
|
|
45090
|
+
dryRun: this.dryRun,
|
|
45091
|
+
noScripts: this.noScripts
|
|
45092
|
+
});
|
|
45093
|
+
return outcome.exitCode;
|
|
45094
|
+
} catch (err) {
|
|
45095
|
+
if (err instanceof UserCancelled) return 130;
|
|
45096
|
+
const e2 = err;
|
|
45097
|
+
this.context.stderr.write(`keynv: ${e2.message}
|
|
45098
|
+
`);
|
|
44753
45099
|
return 1;
|
|
44754
45100
|
}
|
|
44755
|
-
const report = await integration.uninstall({ cwd: process.cwd(), dryRun: this.dryRun });
|
|
44756
|
-
printReport(this.context.stdout, report);
|
|
44757
|
-
return 0;
|
|
44758
45101
|
}
|
|
44759
45102
|
};
|
|
44760
45103
|
|
|
@@ -44770,7 +45113,7 @@ async function promptHidden(prompt) {
|
|
|
44770
45113
|
process.stdin.setRawMode(true);
|
|
44771
45114
|
process.stdin.resume();
|
|
44772
45115
|
process.stdin.setEncoding("utf8");
|
|
44773
|
-
return new Promise((
|
|
45116
|
+
return new Promise((resolve3) => {
|
|
44774
45117
|
let buf = "";
|
|
44775
45118
|
const onData = (chunk) => {
|
|
44776
45119
|
for (const ch of chunk) {
|
|
@@ -44779,7 +45122,7 @@ async function promptHidden(prompt) {
|
|
|
44779
45122
|
process.stdin.pause();
|
|
44780
45123
|
process.stdin.removeListener("data", onData);
|
|
44781
45124
|
process.stdout.write("\n");
|
|
44782
|
-
|
|
45125
|
+
resolve3(buf);
|
|
44783
45126
|
return;
|
|
44784
45127
|
}
|
|
44785
45128
|
if (ch === "") {
|
|
@@ -44797,10 +45140,10 @@ async function promptHidden(prompt) {
|
|
|
44797
45140
|
}
|
|
44798
45141
|
async function promptLine(prompt) {
|
|
44799
45142
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
44800
|
-
return new Promise((
|
|
45143
|
+
return new Promise((resolve3) => {
|
|
44801
45144
|
rl.question(prompt, (answer) => {
|
|
44802
45145
|
rl.close();
|
|
44803
|
-
|
|
45146
|
+
resolve3(answer.trim());
|
|
44804
45147
|
});
|
|
44805
45148
|
});
|
|
44806
45149
|
}
|
|
@@ -45191,9 +45534,9 @@ streaming-mode limitation in @keynv/redactor).
|
|
|
45191
45534
|
`
|
|
45192
45535
|
});
|
|
45193
45536
|
async execute() {
|
|
45194
|
-
return new Promise((
|
|
45537
|
+
return new Promise((resolve3, reject) => {
|
|
45195
45538
|
const transform = createRedactStream();
|
|
45196
|
-
this.context.stdin.pipe(transform).pipe(this.context.stdout).on("error", reject).on("finish", () =>
|
|
45539
|
+
this.context.stdin.pipe(transform).pipe(this.context.stdout).on("error", reject).on("finish", () => resolve3(0));
|
|
45197
45540
|
this.context.stdin.on("error", reject);
|
|
45198
45541
|
});
|
|
45199
45542
|
}
|
|
@@ -45683,7 +46026,7 @@ var sshTester = {
|
|
|
45683
46026
|
async test(secret, target) {
|
|
45684
46027
|
const start = Date.now();
|
|
45685
46028
|
const { Client: Client2 } = await import('ssh2');
|
|
45686
|
-
return new Promise((
|
|
46029
|
+
return new Promise((resolve3) => {
|
|
45687
46030
|
const client = new Client2();
|
|
45688
46031
|
let settled = false;
|
|
45689
46032
|
const settle = (result) => {
|
|
@@ -45694,7 +46037,7 @@ var sshTester = {
|
|
|
45694
46037
|
client.end();
|
|
45695
46038
|
} catch {
|
|
45696
46039
|
}
|
|
45697
|
-
|
|
46040
|
+
resolve3(result);
|
|
45698
46041
|
};
|
|
45699
46042
|
client.once("ready", () => {
|
|
45700
46043
|
client.exec("true", (err, stream) => {
|
|
@@ -45760,12 +46103,12 @@ function sanitizeResult(result, secret) {
|
|
|
45760
46103
|
|
|
45761
46104
|
// ../../packages/testers/dist/run.js
|
|
45762
46105
|
function withTimeout(promise, ms) {
|
|
45763
|
-
return new Promise((
|
|
46106
|
+
return new Promise((resolve3, reject) => {
|
|
45764
46107
|
const t = setTimeout(() => reject(new Error(`tester timed out after ${ms}ms`)), ms);
|
|
45765
46108
|
t.unref();
|
|
45766
46109
|
promise.then((v2) => {
|
|
45767
46110
|
clearTimeout(t);
|
|
45768
|
-
|
|
46111
|
+
resolve3(v2);
|
|
45769
46112
|
}, (err) => {
|
|
45770
46113
|
clearTimeout(t);
|
|
45771
46114
|
reject(err);
|
|
@@ -45999,10 +46342,9 @@ cli.register(MemberListCommand);
|
|
|
45999
46342
|
cli.register(AuditListCommand);
|
|
46000
46343
|
cli.register(AuditVerifyCommand);
|
|
46001
46344
|
cli.register(ExecCommand);
|
|
46345
|
+
cli.register(InitCommand);
|
|
46002
46346
|
cli.register(RedactCommand);
|
|
46003
46347
|
cli.register(RedactStreamCommand);
|
|
46004
|
-
cli.register(InstallCommand);
|
|
46005
|
-
cli.register(UninstallCommand);
|
|
46006
46348
|
cli.register(TestCommand);
|
|
46007
46349
|
cli.register(UICommand);
|
|
46008
46350
|
var argv = process.argv.slice(2);
|