@keynv/cli 0.1.0-rc.13 → 0.1.0-rc.15
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 +2009 -600
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
|
-
import { randomBytes } from 'crypto';
|
|
4
|
-
import { readFileSync, existsSync, statSync,
|
|
3
|
+
import { createHash, randomBytes } from 'crypto';
|
|
4
|
+
import { readFileSync, writeFileSync, unlinkSync, existsSync, statSync, readdirSync, mkdirSync, rmSync, lstatSync } from 'fs';
|
|
5
5
|
import { hostname, platform, homedir } from 'os';
|
|
6
|
-
import
|
|
6
|
+
import * as nodePath from 'path';
|
|
7
|
+
import { relative, join, isAbsolute, resolve, dirname, basename } from 'path';
|
|
7
8
|
import { Entry } from '@napi-rs/keyring';
|
|
8
|
-
import { styleText } from 'util';
|
|
9
|
+
import { styleText, stripVTControlCharacters } from 'util';
|
|
9
10
|
import j2, { stdin, stdout } from 'process';
|
|
10
11
|
import * as b from 'readline';
|
|
11
12
|
import b__default, { createInterface } from 'readline';
|
|
@@ -19,11 +20,11 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
19
20
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
20
21
|
var __getProtoOf = Object.getPrototypeOf;
|
|
21
22
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
22
|
-
var __require = /* @__PURE__ */ ((
|
|
23
|
+
var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, {
|
|
23
24
|
get: (a, b2) => (typeof require !== "undefined" ? require : a)[b2]
|
|
24
|
-
}) :
|
|
25
|
+
}) : x2)(function(x2) {
|
|
25
26
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
26
|
-
throw Error('Dynamic require of "' +
|
|
27
|
+
throw Error('Dynamic require of "' + x2 + '" is not supported');
|
|
27
28
|
});
|
|
28
29
|
var __esm = (fn, res) => function __init() {
|
|
29
30
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
@@ -301,16 +302,16 @@ var require_lib = __commonJS({
|
|
|
301
302
|
}
|
|
302
303
|
});
|
|
303
304
|
}
|
|
304
|
-
function isArray(spec, { delimiter } = {}) {
|
|
305
|
+
function isArray(spec, { delimiter: delimiter2 } = {}) {
|
|
305
306
|
return makeValidator({
|
|
306
307
|
test: (value, state) => {
|
|
307
308
|
var _a;
|
|
308
309
|
const originalValue = value;
|
|
309
|
-
if (typeof value === `string` && typeof
|
|
310
|
+
if (typeof value === `string` && typeof delimiter2 !== `undefined`) {
|
|
310
311
|
if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) {
|
|
311
312
|
if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`)
|
|
312
313
|
return pushError(state, `Unbound coercion result`);
|
|
313
|
-
value = value.split(
|
|
314
|
+
value = value.split(delimiter2);
|
|
314
315
|
}
|
|
315
316
|
}
|
|
316
317
|
if (!Array.isArray(value))
|
|
@@ -328,8 +329,8 @@ var require_lib = __commonJS({
|
|
|
328
329
|
}
|
|
329
330
|
});
|
|
330
331
|
}
|
|
331
|
-
function isSet(spec, { delimiter } = {}) {
|
|
332
|
-
const isArrayValidator = isArray(spec, { delimiter });
|
|
332
|
+
function isSet(spec, { delimiter: delimiter2 } = {}) {
|
|
333
|
+
const isArrayValidator = isArray(spec, { delimiter: delimiter2 });
|
|
333
334
|
return makeValidator({
|
|
334
335
|
test: (value, state) => {
|
|
335
336
|
var _a, _b;
|
|
@@ -420,16 +421,16 @@ var require_lib = __commonJS({
|
|
|
420
421
|
}
|
|
421
422
|
});
|
|
422
423
|
}
|
|
423
|
-
function isTuple(spec, { delimiter } = {}) {
|
|
424
|
+
function isTuple(spec, { delimiter: delimiter2 } = {}) {
|
|
424
425
|
const lengthValidator = hasExactLength(spec.length);
|
|
425
426
|
return makeValidator({
|
|
426
427
|
test: (value, state) => {
|
|
427
428
|
var _a;
|
|
428
|
-
if (typeof value === `string` && typeof
|
|
429
|
+
if (typeof value === `string` && typeof delimiter2 !== `undefined`) {
|
|
429
430
|
if (typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined`) {
|
|
430
431
|
if (typeof (state === null || state === void 0 ? void 0 : state.coercion) === `undefined`)
|
|
431
432
|
return pushError(state, `Unbound coercion result`);
|
|
432
|
-
value = value.split(
|
|
433
|
+
value = value.split(delimiter2);
|
|
433
434
|
state.coercions.push([(_a = state.p) !== null && _a !== void 0 ? _a : `.`, state.coercion.bind(null, value)]);
|
|
434
435
|
}
|
|
435
436
|
}
|
|
@@ -1056,14 +1057,20 @@ var require_lib = __commonJS({
|
|
|
1056
1057
|
var VERSION, AGENT;
|
|
1057
1058
|
var init_version = __esm({
|
|
1058
1059
|
"src/version.ts"() {
|
|
1059
|
-
VERSION = "0.1.0-rc.
|
|
1060
|
+
VERSION = "0.1.0-rc.15" ;
|
|
1060
1061
|
AGENT = `keynv-cli/${VERSION}`;
|
|
1061
1062
|
}
|
|
1062
1063
|
});
|
|
1063
1064
|
|
|
1064
1065
|
// ../../packages/core/dist/reference/types.js
|
|
1066
|
+
var ALIAS_LIMITS;
|
|
1065
1067
|
var init_types = __esm({
|
|
1066
1068
|
"../../packages/core/dist/reference/types.js"() {
|
|
1069
|
+
ALIAS_LIMITS = {
|
|
1070
|
+
project: { min: 1, max: 48 },
|
|
1071
|
+
environment: { min: 1, max: 24 },
|
|
1072
|
+
key: { min: 1, max: 64 }
|
|
1073
|
+
};
|
|
1067
1074
|
}
|
|
1068
1075
|
});
|
|
1069
1076
|
|
|
@@ -1095,10 +1102,10 @@ function parseAlias(input) {
|
|
|
1095
1102
|
function findAliases(text, opts = {}) {
|
|
1096
1103
|
if (typeof text !== "string" || text.length === 0)
|
|
1097
1104
|
return [];
|
|
1098
|
-
const
|
|
1099
|
-
|
|
1105
|
+
const re2 = opts.mode === "argv" ? ARGV_FIND_RE : TEXT_FIND_RE;
|
|
1106
|
+
re2.lastIndex = 0;
|
|
1100
1107
|
const matches = [];
|
|
1101
|
-
for (const m of text.matchAll(
|
|
1108
|
+
for (const m of text.matchAll(re2)) {
|
|
1102
1109
|
const literal = m[0];
|
|
1103
1110
|
const start = m.index;
|
|
1104
1111
|
if (start === void 0)
|
|
@@ -1127,6 +1134,25 @@ function findAliasesInArgv(argv2) {
|
|
|
1127
1134
|
}
|
|
1128
1135
|
return result;
|
|
1129
1136
|
}
|
|
1137
|
+
function replaceAliases(text, resolve4, opts = {}) {
|
|
1138
|
+
if (typeof text !== "string" || text.length === 0)
|
|
1139
|
+
return text;
|
|
1140
|
+
const matches = findAliases(text, opts);
|
|
1141
|
+
if (matches.length === 0)
|
|
1142
|
+
return text;
|
|
1143
|
+
let out = text;
|
|
1144
|
+
for (let i = matches.length - 1; i >= 0; i--) {
|
|
1145
|
+
const m = matches[i];
|
|
1146
|
+
if (!m)
|
|
1147
|
+
continue;
|
|
1148
|
+
const replacement = resolve4(m);
|
|
1149
|
+
if (replacement.startsWith("@") && PROJECT_RE.test(replacement.slice(1).split(".")[0] ?? "")) {
|
|
1150
|
+
throw new Error(`replaceAliases: resolved value for ${m.literal} looks like an alias (${replacement}). Circular or misconfigured resolution detected.`);
|
|
1151
|
+
}
|
|
1152
|
+
out = out.slice(0, m.start) + replacement + out.slice(m.end);
|
|
1153
|
+
}
|
|
1154
|
+
return out;
|
|
1155
|
+
}
|
|
1130
1156
|
function buildAlias(parts) {
|
|
1131
1157
|
if (!PROJECT_RE.test(parts.project))
|
|
1132
1158
|
return null;
|
|
@@ -1156,6 +1182,15 @@ var init_parser = __esm({
|
|
|
1156
1182
|
});
|
|
1157
1183
|
|
|
1158
1184
|
// ../../packages/core/dist/reference/index.js
|
|
1185
|
+
var reference_exports = {};
|
|
1186
|
+
__export(reference_exports, {
|
|
1187
|
+
ALIAS_LIMITS: () => ALIAS_LIMITS,
|
|
1188
|
+
buildAlias: () => buildAlias,
|
|
1189
|
+
findAliases: () => findAliases,
|
|
1190
|
+
findAliasesInArgv: () => findAliasesInArgv,
|
|
1191
|
+
parseAlias: () => parseAlias,
|
|
1192
|
+
replaceAliases: () => replaceAliases
|
|
1193
|
+
});
|
|
1159
1194
|
var init_reference = __esm({
|
|
1160
1195
|
"../../packages/core/dist/reference/index.js"() {
|
|
1161
1196
|
init_types();
|
|
@@ -1672,7 +1707,7 @@ function addIssueToContext(ctx, issueData) {
|
|
|
1672
1707
|
// then global override map
|
|
1673
1708
|
overrideMap === en_default ? void 0 : en_default
|
|
1674
1709
|
// then global default map
|
|
1675
|
-
].filter((
|
|
1710
|
+
].filter((x2) => !!x2)
|
|
1676
1711
|
});
|
|
1677
1712
|
ctx.common.issues.push(issue);
|
|
1678
1713
|
}
|
|
@@ -1766,10 +1801,10 @@ var init_parseUtil = __esm({
|
|
|
1766
1801
|
});
|
|
1767
1802
|
DIRTY = (value) => ({ status: "dirty", value });
|
|
1768
1803
|
OK = (value) => ({ status: "valid", value });
|
|
1769
|
-
isAborted = (
|
|
1770
|
-
isDirty = (
|
|
1771
|
-
isValid = (
|
|
1772
|
-
isAsync = (
|
|
1804
|
+
isAborted = (x2) => x2.status === "aborted";
|
|
1805
|
+
isDirty = (x2) => x2.status === "dirty";
|
|
1806
|
+
isValid = (x2) => x2.status === "valid";
|
|
1807
|
+
isAsync = (x2) => typeof Promise !== "undefined" && x2 instanceof Promise;
|
|
1773
1808
|
}
|
|
1774
1809
|
});
|
|
1775
1810
|
|
|
@@ -4269,7 +4304,7 @@ var init_types4 = __esm({
|
|
|
4269
4304
|
if (!schema)
|
|
4270
4305
|
return null;
|
|
4271
4306
|
return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
|
|
4272
|
-
}).filter((
|
|
4307
|
+
}).filter((x2) => !!x2);
|
|
4273
4308
|
if (ctx.common.async) {
|
|
4274
4309
|
return Promise.all(items).then((results) => {
|
|
4275
4310
|
return ParseStatus.mergeArray(status, results);
|
|
@@ -4522,7 +4557,7 @@ var init_types4 = __esm({
|
|
|
4522
4557
|
return makeIssue({
|
|
4523
4558
|
data: args,
|
|
4524
4559
|
path: ctx.path,
|
|
4525
|
-
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((
|
|
4560
|
+
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x2) => !!x2),
|
|
4526
4561
|
issueData: {
|
|
4527
4562
|
code: ZodIssueCode.invalid_arguments,
|
|
4528
4563
|
argumentsError: error
|
|
@@ -4533,7 +4568,7 @@ var init_types4 = __esm({
|
|
|
4533
4568
|
return makeIssue({
|
|
4534
4569
|
data: returns,
|
|
4535
4570
|
path: ctx.path,
|
|
4536
|
-
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((
|
|
4571
|
+
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x2) => !!x2),
|
|
4537
4572
|
issueData: {
|
|
4538
4573
|
code: ZodIssueCode.invalid_return_type,
|
|
4539
4574
|
returnTypeError: error
|
|
@@ -5388,7 +5423,7 @@ var init_payload_schemas = __esm({
|
|
|
5388
5423
|
role = external_exports.enum(["lead", "developer", "reader"]);
|
|
5389
5424
|
orgRole = external_exports.enum(["owner", "admin", "developer", "reader"]);
|
|
5390
5425
|
email = external_exports.string().email();
|
|
5391
|
-
version = external_exports.number().int().positive();
|
|
5426
|
+
version = external_exports.coerce.number().int().positive();
|
|
5392
5427
|
empty = external_exports.object({}).strict();
|
|
5393
5428
|
orgId = external_exports.string().min(1);
|
|
5394
5429
|
({
|
|
@@ -5436,10 +5471,12 @@ var init_payload_schemas = __esm({
|
|
|
5436
5471
|
}).strict(),
|
|
5437
5472
|
"secret.deleted": external_exports.object({ project_id: projectId, env, key }).strict(),
|
|
5438
5473
|
"secret.test.invoked": external_exports.object({ alias, tester: external_exports.string(), ok: external_exports.boolean(), latency_ms: external_exports.number() }).strict(),
|
|
5474
|
+
"secret.test.denied": external_exports.object({ alias }).strict(),
|
|
5439
5475
|
"approval.requested": external_exports.object({ alias }).strict(),
|
|
5440
5476
|
"approval.granted": external_exports.object({ alias, granted_by: userId }).strict(),
|
|
5441
5477
|
"approval.denied": external_exports.object({ alias, denied_by: userId }).strict(),
|
|
5442
|
-
"
|
|
5478
|
+
"org.created": external_exports.object({ org_id: orgId, name: external_exports.string().min(1) }).strict(),
|
|
5479
|
+
"org.updated": external_exports.object({ org_id: orgId, name: external_exports.string().min(1) }).strict()
|
|
5443
5480
|
});
|
|
5444
5481
|
}
|
|
5445
5482
|
});
|
|
@@ -5471,15 +5508,16 @@ function entry() {
|
|
|
5471
5508
|
return new Entry(SERVICE, KEY_ACCOUNT);
|
|
5472
5509
|
}
|
|
5473
5510
|
async function loadOrCreateKey() {
|
|
5511
|
+
if (process.env["KEYNV_DISABLE_KEYCHAIN"] === "1") {
|
|
5512
|
+
return loadOrCreateFileKey();
|
|
5513
|
+
}
|
|
5474
5514
|
const e2 = entry();
|
|
5475
5515
|
let stored;
|
|
5476
5516
|
try {
|
|
5477
5517
|
stored = e2.getPassword();
|
|
5478
|
-
} catch
|
|
5479
|
-
const message =
|
|
5480
|
-
throw new Error(
|
|
5481
|
-
`keynv: OS keychain unavailable (${message}). Install libsecret on Linux, or set KEYNV_DISABLE_KEYCHAIN=1 to use a (less secure) file-based key store.`
|
|
5482
|
-
);
|
|
5518
|
+
} catch {
|
|
5519
|
+
const message = process.env["KEYNV_DISABLE_KEYCHAIN"] ? "keynv: OS keychain unavailable. Set KEYNV_DISABLE_KEYCHAIN=1 to use a file-based key store (less secure)." : "keynv: OS keychain unavailable. Install libsecret on Linux, or set KEYNV_DISABLE_KEYCHAIN=1 to use a file-based key store (less secure).";
|
|
5520
|
+
throw new Error(message);
|
|
5483
5521
|
}
|
|
5484
5522
|
if (stored) {
|
|
5485
5523
|
return new Uint8Array(Buffer.from(stored, "base64"));
|
|
@@ -5494,6 +5532,20 @@ async function loadOrCreateKey() {
|
|
|
5494
5532
|
}
|
|
5495
5533
|
return fresh;
|
|
5496
5534
|
}
|
|
5535
|
+
function fileKeyPath() {
|
|
5536
|
+
return process.env["KEYNV_CREDENTIALS_KEY_FILE"] ?? join(homedir(), ".keynv", ".credentials-key");
|
|
5537
|
+
}
|
|
5538
|
+
async function loadOrCreateFileKey() {
|
|
5539
|
+
const path = fileKeyPath();
|
|
5540
|
+
if (existsSync(path)) {
|
|
5541
|
+
const raw = readFileSync(path, "utf8").trim();
|
|
5542
|
+
return new Uint8Array(Buffer.from(raw, "base64"));
|
|
5543
|
+
}
|
|
5544
|
+
const fresh = await crypto_exports.generateKey();
|
|
5545
|
+
if (!existsSync(dirname(path))) mkdirSync(dirname(path), { recursive: true, mode: 448 });
|
|
5546
|
+
writeFileSync(path, Buffer.from(fresh).toString("base64"), { mode: 384 });
|
|
5547
|
+
return fresh;
|
|
5548
|
+
}
|
|
5497
5549
|
async function saveCredentialsBlob(plaintext) {
|
|
5498
5550
|
const key2 = await loadOrCreateKey();
|
|
5499
5551
|
const sealed = await crypto_exports.encryptSecret(Buffer.from(plaintext).toString("utf8"), key2);
|
|
@@ -5534,6 +5586,11 @@ function clearCredentialsFile() {
|
|
|
5534
5586
|
if (existsSync(path)) rmSync(path, { force: true });
|
|
5535
5587
|
const legacy = legacyPath();
|
|
5536
5588
|
if (existsSync(legacy)) rmSync(legacy, { force: true });
|
|
5589
|
+
if (process.env["KEYNV_DISABLE_KEYCHAIN"] === "1") {
|
|
5590
|
+
const keyPath = fileKeyPath();
|
|
5591
|
+
if (existsSync(keyPath)) rmSync(keyPath, { force: true });
|
|
5592
|
+
return true;
|
|
5593
|
+
}
|
|
5537
5594
|
try {
|
|
5538
5595
|
entry().deletePassword();
|
|
5539
5596
|
return true;
|
|
@@ -5656,7 +5713,16 @@ var init_http = __esm({
|
|
|
5656
5713
|
return this.creds;
|
|
5657
5714
|
}
|
|
5658
5715
|
async ensureHydrated() {
|
|
5659
|
-
if (this.hydrated)
|
|
5716
|
+
if (this.hydrated) {
|
|
5717
|
+
try {
|
|
5718
|
+
await this.hydrated;
|
|
5719
|
+
} catch (err) {
|
|
5720
|
+
process.stderr.write(
|
|
5721
|
+
`${err instanceof Error ? err.message : `keynv: credential load failed \u2014 ${String(err)}`}
|
|
5722
|
+
`
|
|
5723
|
+
);
|
|
5724
|
+
}
|
|
5725
|
+
}
|
|
5660
5726
|
}
|
|
5661
5727
|
async setCredentials(creds) {
|
|
5662
5728
|
this.creds = creds;
|
|
@@ -5678,21 +5744,40 @@ var init_http = __esm({
|
|
|
5678
5744
|
headers.authorization = `Bearer ${this.creds.access_token}`;
|
|
5679
5745
|
}
|
|
5680
5746
|
const url = this.creds ? buildUrl(this.creds.server_url, path, opts.query) : path;
|
|
5681
|
-
let res
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5747
|
+
let res;
|
|
5748
|
+
try {
|
|
5749
|
+
res = await fetch(url, {
|
|
5750
|
+
method: opts.method ?? "GET",
|
|
5751
|
+
headers,
|
|
5752
|
+
...opts.body !== void 0 ? { body: JSON.stringify(opts.body) } : {}
|
|
5753
|
+
});
|
|
5754
|
+
} catch (err) {
|
|
5755
|
+
const cause = err instanceof Error ? err.message : String(err);
|
|
5756
|
+
const serverUrl = this.creds?.server_url ?? url;
|
|
5757
|
+
throw new Error(
|
|
5758
|
+
`keynv: cannot reach server '${serverUrl}' \u2014 ${cause}
|
|
5759
|
+
Check the server is running: curl ${serverUrl}/v1/health`
|
|
5760
|
+
);
|
|
5761
|
+
}
|
|
5686
5762
|
if (res.status === 401 && this.creds && opts.authed !== false) {
|
|
5687
5763
|
const refreshed = await tryRefresh(this.creds);
|
|
5688
5764
|
if (refreshed) {
|
|
5689
5765
|
this.creds = refreshed;
|
|
5690
5766
|
headers.authorization = `Bearer ${refreshed.access_token}`;
|
|
5691
|
-
|
|
5692
|
-
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
|
|
5767
|
+
try {
|
|
5768
|
+
res = await fetch(url, {
|
|
5769
|
+
method: opts.method ?? "GET",
|
|
5770
|
+
headers,
|
|
5771
|
+
...opts.body !== void 0 ? { body: JSON.stringify(opts.body) } : {}
|
|
5772
|
+
});
|
|
5773
|
+
} catch (err) {
|
|
5774
|
+
const cause = err instanceof Error ? err.message : String(err);
|
|
5775
|
+
const serverUrl = this.creds?.server_url ?? url;
|
|
5776
|
+
throw new Error(
|
|
5777
|
+
`keynv: cannot reach server '${serverUrl}' \u2014 ${cause}
|
|
5778
|
+
Check the server is running: curl ${serverUrl}/v1/health`
|
|
5779
|
+
);
|
|
5780
|
+
}
|
|
5696
5781
|
}
|
|
5697
5782
|
}
|
|
5698
5783
|
if (res.status === 204) return void 0;
|
|
@@ -5740,8 +5825,7 @@ function handleExecError(stderr, err) {
|
|
|
5740
5825
|
stderr.write(`keynv: ${err.message}
|
|
5741
5826
|
`);
|
|
5742
5827
|
} else {
|
|
5743
|
-
stderr.write(
|
|
5744
|
-
`);
|
|
5828
|
+
stderr.write("keynv: unexpected error\n");
|
|
5745
5829
|
}
|
|
5746
5830
|
return 1;
|
|
5747
5831
|
}
|
|
@@ -5816,7 +5900,7 @@ function parseEnvFile(content, filename) {
|
|
|
5816
5900
|
entries.push({
|
|
5817
5901
|
name,
|
|
5818
5902
|
value,
|
|
5819
|
-
isAlias: parseAlias(value) !== null,
|
|
5903
|
+
isAlias: reference_exports.parseAlias(value) !== null,
|
|
5820
5904
|
line: lineNo
|
|
5821
5905
|
});
|
|
5822
5906
|
}
|
|
@@ -5891,6 +5975,210 @@ var init_envFile = __esm({
|
|
|
5891
5975
|
};
|
|
5892
5976
|
}
|
|
5893
5977
|
});
|
|
5978
|
+
function aiContextBody() {
|
|
5979
|
+
return `## keynv (secrets)
|
|
5980
|
+
|
|
5981
|
+
This project uses [keynv](https://keynv.dev) for secrets. There is a \`.keynv.env\` file at the project root containing **alias references** like \`OPENAI_API_KEY=@projectname.dev.openai-key\` \u2014 these are NOT real values, they are references to secrets stored in the keynv vault.
|
|
5982
|
+
|
|
5983
|
+
### Mental model
|
|
5984
|
+
|
|
5985
|
+
- **\`.keynv.env\`** \u2014 checked into git, contains aliases. Safe to read, edit, commit.
|
|
5986
|
+
- **Vault** \u2014 holds the real values. The \`keynv\` CLI reads it on demand.
|
|
5987
|
+
- **\`keynv exec -- <command>\`** \u2014 forks the command in a subprocess where the real values are injected into env vars. The parent process (where you, the AI agent, run) NEVER sees the real values.
|
|
5988
|
+
- **Redactor** \u2014 pipes subprocess stdout/stderr through a masker before they reach this terminal. Even if a script accidentally echoes a secret, you see \`<REDACTED:...>\` here.
|
|
5989
|
+
|
|
5990
|
+
### What you should do
|
|
5991
|
+
|
|
5992
|
+
When the user asks about secrets or env vars, follow this decision tree:
|
|
5993
|
+
|
|
5994
|
+
| User intent | Run / suggest |
|
|
5995
|
+
|---|---|
|
|
5996
|
+
| "Add a new API key" / "set up a secret" | \`keynv secret create\` (interactive prompt picks project + env + key) |
|
|
5997
|
+
| "I have a \`.env\`, migrate it" | \`keynv init\` (you're seeing this file because that already happened) |
|
|
5998
|
+
| "Run the app / dev server / tests" | \`keynv exec -- <their existing command>\` (auto-loads \`.keynv.env\`) |
|
|
5999
|
+
| "Show me the value of X" | \`keynv secret get @alias\` \u2014 but copy to clipboard, do NOT print the value into chat / terminal |
|
|
6000
|
+
| "Rotate this key" | \`keynv secret rotate @alias\` |
|
|
6001
|
+
| "Add a new env var to the project" | Edit \`.keynv.env\` and add \`NAME=@project.env.key\` (after creating the secret with \`keynv secret create\`) |
|
|
6002
|
+
| "Who has access?" | \`keynv member list <project>\` |
|
|
6003
|
+
|
|
6004
|
+
### Hard rules \u2014 do not violate
|
|
6005
|
+
|
|
6006
|
+
1. **Never print resolved secret values** to the chat, terminal, log, or any file. The user's editor / scrollback / chat history is an attack surface.
|
|
6007
|
+
2. **Never write a \`.env\` file** (or any file) containing real secret values. The whole point of keynv is that those don't exist on disk.
|
|
6008
|
+
3. **Never edit \`.keynv.env\` to substitute resolved values for aliases.** The file should only ever contain \`@project.env.key\` references and plain non-secret literals.
|
|
6009
|
+
4. **Use \`keynv exec --\` to run commands that need env vars.** Don't try to load \`.keynv.env\` yourself by parsing it manually; the wrapper handles resolution + redaction + subprocess isolation.
|
|
6010
|
+
5. **If a tool fails with "blocked by keynv-guard" or similar**, do NOT try to work around it. Tell the user \u2014 that's a sign of a misconfiguration, not an obstacle to bypass.
|
|
6011
|
+
6. **Treat the alias literal (\`@project.env.key\`) as the canonical reference**, never the resolved value. When you write code, configs, or commands that need a secret, write the alias.
|
|
6012
|
+
|
|
6013
|
+
### Quick reference
|
|
6014
|
+
|
|
6015
|
+
\`\`\`bash
|
|
6016
|
+
keynv # interactive TUI menu (pick projects, secrets, members)
|
|
6017
|
+
keynv exec -- <cmd> # run cmd with .keynv.env loaded
|
|
6018
|
+
keynv secret create # walk through creating a new secret
|
|
6019
|
+
keynv secret list <project> # list aliases (no values)
|
|
6020
|
+
keynv whoami # who am I logged in as
|
|
6021
|
+
keynv --help # full command list
|
|
6022
|
+
\`\`\`
|
|
6023
|
+
|
|
6024
|
+
If \`.keynv.env\` is missing or empty, the user probably hasn't run \`keynv init\` yet \u2014 suggest they do so before they paste a secret into a \`.env\`.`;
|
|
6025
|
+
}
|
|
6026
|
+
function renderKeynvBlock() {
|
|
6027
|
+
return `${KEYNV_BLOCK_START}
|
|
6028
|
+
${aiContextBody()}
|
|
6029
|
+
${KEYNV_BLOCK_END}`;
|
|
6030
|
+
}
|
|
6031
|
+
function writeAiContext(rootPath) {
|
|
6032
|
+
const path = join(rootPath, AGENTS_FILE_BASENAME);
|
|
6033
|
+
const block = renderKeynvBlock();
|
|
6034
|
+
if (!existsSync(path)) {
|
|
6035
|
+
const initial = `# Agent guidance for this project
|
|
6036
|
+
|
|
6037
|
+
${block}
|
|
6038
|
+
`;
|
|
6039
|
+
writeFileSync(path, initial);
|
|
6040
|
+
return "created";
|
|
6041
|
+
}
|
|
6042
|
+
const existing = readFileSync(path, "utf8");
|
|
6043
|
+
const startIdx = existing.indexOf(KEYNV_BLOCK_START);
|
|
6044
|
+
const endIdx = existing.indexOf(KEYNV_BLOCK_END);
|
|
6045
|
+
if (startIdx >= 0 && endIdx > startIdx) {
|
|
6046
|
+
const before = existing.slice(0, startIdx);
|
|
6047
|
+
const after = existing.slice(endIdx + KEYNV_BLOCK_END.length);
|
|
6048
|
+
const next = `${before}${block}${after}`;
|
|
6049
|
+
if (next === existing) return "unchanged";
|
|
6050
|
+
writeFileSync(path, next);
|
|
6051
|
+
return "updated";
|
|
6052
|
+
}
|
|
6053
|
+
const sep = existing.length === 0 ? "" : existing.endsWith("\n\n") ? "" : existing.endsWith("\n") ? "\n" : "\n\n";
|
|
6054
|
+
const trailingNewline = existing.endsWith("\n") ? "" : "\n";
|
|
6055
|
+
writeFileSync(path, `${existing}${trailingNewline}${sep}${block}
|
|
6056
|
+
`);
|
|
6057
|
+
return "appended";
|
|
6058
|
+
}
|
|
6059
|
+
var AGENTS_FILE_BASENAME, KEYNV_BLOCK_START, KEYNV_BLOCK_END;
|
|
6060
|
+
var init_ai_context = __esm({
|
|
6061
|
+
"src/init/ai-context.ts"() {
|
|
6062
|
+
AGENTS_FILE_BASENAME = "AGENTS.md";
|
|
6063
|
+
KEYNV_BLOCK_START = "<!-- keynv:start -- generated by `keynv init`; safe to leave intact, will be refreshed on re-run -->";
|
|
6064
|
+
KEYNV_BLOCK_END = "<!-- keynv:end -->";
|
|
6065
|
+
}
|
|
6066
|
+
});
|
|
6067
|
+
function findProjectRoot(startDir) {
|
|
6068
|
+
const result = walkUp(startDir, (dir) => {
|
|
6069
|
+
for (const marker of PROJECT_MARKERS) {
|
|
6070
|
+
if (existsSync(join(dir, marker))) {
|
|
6071
|
+
return { dir, marker };
|
|
6072
|
+
}
|
|
6073
|
+
}
|
|
6074
|
+
if (existsSync(join(dir, GIT_MARKER))) {
|
|
6075
|
+
return { dir, marker: GIT_MARKER };
|
|
6076
|
+
}
|
|
6077
|
+
return null;
|
|
6078
|
+
});
|
|
6079
|
+
if (!result) return null;
|
|
6080
|
+
return buildRoot(result.dir, result.marker);
|
|
6081
|
+
}
|
|
6082
|
+
function buildRoot(dir, marker) {
|
|
6083
|
+
let suggestedName = basename(dir);
|
|
6084
|
+
let scripts = null;
|
|
6085
|
+
let invalid = false;
|
|
6086
|
+
if (marker === "package.json" || existsSync(join(dir, "package.json"))) {
|
|
6087
|
+
try {
|
|
6088
|
+
const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
|
|
6089
|
+
if (typeof pkg.name === "string" && pkg.name.length > 0) {
|
|
6090
|
+
suggestedName = pkg.name.replace(/^@[^/]+\//, "");
|
|
6091
|
+
}
|
|
6092
|
+
if (pkg.scripts && typeof pkg.scripts === "object") {
|
|
6093
|
+
scripts = Object.fromEntries(
|
|
6094
|
+
Object.entries(pkg.scripts).filter(([, v2]) => typeof v2 === "string")
|
|
6095
|
+
);
|
|
6096
|
+
}
|
|
6097
|
+
} catch {
|
|
6098
|
+
invalid = true;
|
|
6099
|
+
}
|
|
6100
|
+
}
|
|
6101
|
+
return {
|
|
6102
|
+
path: dir,
|
|
6103
|
+
suggestedName,
|
|
6104
|
+
marker,
|
|
6105
|
+
packageJsonScripts: scripts,
|
|
6106
|
+
packageJsonInvalid: invalid
|
|
6107
|
+
};
|
|
6108
|
+
}
|
|
6109
|
+
function findEnvFiles(rootDir) {
|
|
6110
|
+
let entries;
|
|
6111
|
+
try {
|
|
6112
|
+
entries = readdirSync(rootDir);
|
|
6113
|
+
} catch {
|
|
6114
|
+
return [];
|
|
6115
|
+
}
|
|
6116
|
+
const hits = [];
|
|
6117
|
+
for (const name of entries) {
|
|
6118
|
+
if (!ENV_GLOB.test(name)) continue;
|
|
6119
|
+
if (ENV_EXAMPLE.test(name)) continue;
|
|
6120
|
+
if (name === KEYNV_ENV_BASENAME) continue;
|
|
6121
|
+
const full = join(rootDir, name);
|
|
6122
|
+
try {
|
|
6123
|
+
if (!statSync(full).isFile()) continue;
|
|
6124
|
+
} catch {
|
|
6125
|
+
continue;
|
|
6126
|
+
}
|
|
6127
|
+
const suffixMatch = name.match(/^\.env\.(.+)$/);
|
|
6128
|
+
const suffix = suffixMatch ? suffixMatch[1] : null;
|
|
6129
|
+
hits.push({ path: full, name, suffix, suggestedEnv: suggestedEnvForSuffix(suffix) });
|
|
6130
|
+
}
|
|
6131
|
+
hits.sort((a, b2) => {
|
|
6132
|
+
if (a.suffix === null) return -1;
|
|
6133
|
+
if (b2.suffix === null) return 1;
|
|
6134
|
+
return a.name.localeCompare(b2.name);
|
|
6135
|
+
});
|
|
6136
|
+
return hits;
|
|
6137
|
+
}
|
|
6138
|
+
function suggestedEnvForSuffix(suffix) {
|
|
6139
|
+
if (suffix === null) return "dev";
|
|
6140
|
+
switch (suffix) {
|
|
6141
|
+
case "local":
|
|
6142
|
+
case "development":
|
|
6143
|
+
case "dev":
|
|
6144
|
+
return "dev";
|
|
6145
|
+
case "production":
|
|
6146
|
+
case "prod":
|
|
6147
|
+
return "prod";
|
|
6148
|
+
case "staging":
|
|
6149
|
+
case "stage":
|
|
6150
|
+
return "staging";
|
|
6151
|
+
case "test":
|
|
6152
|
+
return "test";
|
|
6153
|
+
case "preview":
|
|
6154
|
+
return "preview";
|
|
6155
|
+
default:
|
|
6156
|
+
return suffix;
|
|
6157
|
+
}
|
|
6158
|
+
}
|
|
6159
|
+
function hasExistingKeynvEnv(rootDir) {
|
|
6160
|
+
return existsSync(join(rootDir, KEYNV_ENV_BASENAME));
|
|
6161
|
+
}
|
|
6162
|
+
var PROJECT_MARKERS, GIT_MARKER, ENV_GLOB, ENV_EXAMPLE, KEYNV_ENV_BASENAME;
|
|
6163
|
+
var init_detect = __esm({
|
|
6164
|
+
"src/init/detect.ts"() {
|
|
6165
|
+
init_fs();
|
|
6166
|
+
PROJECT_MARKERS = [
|
|
6167
|
+
"package.json",
|
|
6168
|
+
"pyproject.toml",
|
|
6169
|
+
"Cargo.toml",
|
|
6170
|
+
"go.mod",
|
|
6171
|
+
"pnpm-workspace.yaml",
|
|
6172
|
+
"deno.json",
|
|
6173
|
+
"deno.jsonc",
|
|
6174
|
+
"requirements.txt"
|
|
6175
|
+
];
|
|
6176
|
+
GIT_MARKER = ".git";
|
|
6177
|
+
ENV_GLOB = /^\.env(\.[A-Za-z0-9_-]+)?$/;
|
|
6178
|
+
ENV_EXAMPLE = /^\.env\.(example|sample|template|dist|defaults)$/;
|
|
6179
|
+
KEYNV_ENV_BASENAME = ".keynv.env";
|
|
6180
|
+
}
|
|
6181
|
+
});
|
|
5894
6182
|
|
|
5895
6183
|
// src/init/heuristics.ts
|
|
5896
6184
|
function shannonEntropyBits(s) {
|
|
@@ -5931,8 +6219,8 @@ function classifyEntry(name, value) {
|
|
|
5931
6219
|
if (value.length === 0) {
|
|
5932
6220
|
return { verdict: "literal", hint: "empty" };
|
|
5933
6221
|
}
|
|
5934
|
-
for (const { re, hint } of VALUE_PATTERNS) {
|
|
5935
|
-
if (
|
|
6222
|
+
for (const { re: re2, hint } of VALUE_PATTERNS) {
|
|
6223
|
+
if (re2.test(value)) return { verdict: "secret", hint };
|
|
5936
6224
|
}
|
|
5937
6225
|
const suffix = nameMatchesSecretSuffix(name);
|
|
5938
6226
|
if (suffix.matched) {
|
|
@@ -6033,11 +6321,11 @@ var init_utils = __esm({
|
|
|
6033
6321
|
return input.length - surrogatePairsNr;
|
|
6034
6322
|
};
|
|
6035
6323
|
})();
|
|
6036
|
-
isFullWidth = (
|
|
6037
|
-
return
|
|
6324
|
+
isFullWidth = (x2) => {
|
|
6325
|
+
return x2 === 12288 || x2 >= 65281 && x2 <= 65376 || x2 >= 65504 && x2 <= 65510;
|
|
6038
6326
|
};
|
|
6039
|
-
isWideNotCJKTNotEmoji = (
|
|
6040
|
-
return
|
|
6327
|
+
isWideNotCJKTNotEmoji = (x2) => {
|
|
6328
|
+
return x2 === 8987 || x2 === 9001 || x2 >= 12272 && x2 <= 12287 || x2 >= 12289 && x2 <= 12350 || x2 >= 12441 && x2 <= 12543 || x2 >= 12549 && x2 <= 12591 || x2 >= 12593 && x2 <= 12686 || x2 >= 12688 && x2 <= 12771 || x2 >= 12783 && x2 <= 12830 || x2 >= 12832 && x2 <= 12871 || x2 >= 12880 && x2 <= 19903 || x2 >= 65040 && x2 <= 65049 || x2 >= 65072 && x2 <= 65106 || x2 >= 65108 && x2 <= 65126 || x2 >= 65128 && x2 <= 65131 || x2 >= 127488 && x2 <= 127490 || x2 >= 127504 && x2 <= 127547 || x2 >= 127552 && x2 <= 127560 || x2 >= 131072 && x2 <= 196605 || x2 >= 196608 && x2 <= 262141;
|
|
6041
6329
|
};
|
|
6042
6330
|
}
|
|
6043
6331
|
});
|
|
@@ -6384,14 +6672,14 @@ var require_src = __commonJS({
|
|
|
6384
6672
|
var CSI2 = `${ESC2}[`;
|
|
6385
6673
|
var beep = "\x07";
|
|
6386
6674
|
var cursor = {
|
|
6387
|
-
to(
|
|
6388
|
-
if (!y) return `${CSI2}${
|
|
6389
|
-
return `${CSI2}${y + 1};${
|
|
6675
|
+
to(x2, y) {
|
|
6676
|
+
if (!y) return `${CSI2}${x2 + 1}G`;
|
|
6677
|
+
return `${CSI2}${y + 1};${x2 + 1}H`;
|
|
6390
6678
|
},
|
|
6391
|
-
move(
|
|
6679
|
+
move(x2, y) {
|
|
6392
6680
|
let ret = "";
|
|
6393
|
-
if (
|
|
6394
|
-
else if (
|
|
6681
|
+
if (x2 < 0) ret += `${CSI2}${-x2}D`;
|
|
6682
|
+
else if (x2 > 0) ret += `${CSI2}${x2}C`;
|
|
6395
6683
|
if (y < 0) ret += `${CSI2}${-y}A`;
|
|
6396
6684
|
else if (y > 0) ret += `${CSI2}${y}B`;
|
|
6397
6685
|
return ret;
|
|
@@ -6436,6 +6724,39 @@ function d(r, t, s) {
|
|
|
6436
6724
|
const e2 = r + t, i = Math.max(s.length - 1, 0), n = e2 < 0 ? i : e2 > i ? 0 : e2;
|
|
6437
6725
|
return s[n].disabled ? d(n, t < 0 ? -1 : 1, s) : n;
|
|
6438
6726
|
}
|
|
6727
|
+
function I(r, t, s, e2) {
|
|
6728
|
+
const i = e2.split(`
|
|
6729
|
+
`);
|
|
6730
|
+
let n = 0, o = r;
|
|
6731
|
+
for (const a of i) {
|
|
6732
|
+
if (o <= a.length) break;
|
|
6733
|
+
o -= a.length + 1, n++;
|
|
6734
|
+
}
|
|
6735
|
+
for (n = Math.max(0, Math.min(i.length - 1, n + s)), o = Math.min(o, i[n].length) + t; o < 0 && n > 0; ) n--, o += i[n].length + 1;
|
|
6736
|
+
for (; o > i[n].length && n < i.length - 1; ) o -= i[n].length + 1, n++;
|
|
6737
|
+
o = Math.max(0, Math.min(i[n].length, o));
|
|
6738
|
+
let u = 0;
|
|
6739
|
+
for (let a = 0; a < n; a++) u += i[a].length + 1;
|
|
6740
|
+
return u + o;
|
|
6741
|
+
}
|
|
6742
|
+
function j(r) {
|
|
6743
|
+
if (r.aliases !== void 0) {
|
|
6744
|
+
const t = r.aliases;
|
|
6745
|
+
for (const s in t) {
|
|
6746
|
+
if (!Object.hasOwn(t, s)) continue;
|
|
6747
|
+
const e2 = t[s];
|
|
6748
|
+
h.actions.has(e2) && (h.aliases.has(s) || h.aliases.set(s, e2));
|
|
6749
|
+
}
|
|
6750
|
+
}
|
|
6751
|
+
if (r.messages !== void 0) {
|
|
6752
|
+
const t = r.messages;
|
|
6753
|
+
t.cancel !== void 0 && (h.messages.cancel = t.cancel), t.error !== void 0 && (h.messages.error = t.error);
|
|
6754
|
+
}
|
|
6755
|
+
if (r.withGuide !== void 0 && (h.withGuide = r.withGuide !== false), r.date !== void 0) {
|
|
6756
|
+
const t = r.date;
|
|
6757
|
+
t.monthNames !== void 0 && (h.date.monthNames = [...t.monthNames]), t.messages !== void 0 && (t.messages.required !== void 0 && (h.date.messages.required = t.messages.required), t.messages.invalidMonth !== void 0 && (h.date.messages.invalidMonth = t.messages.invalidMonth), t.messages.invalidDay !== void 0 && (h.date.messages.invalidDay = t.messages.invalidDay), t.messages.afterMin !== void 0 && (h.date.messages.afterMin = t.messages.afterMin), t.messages.beforeMax !== void 0 && (h.date.messages.beforeMax = t.messages.beforeMax));
|
|
6758
|
+
}
|
|
6759
|
+
}
|
|
6439
6760
|
function C(r, t) {
|
|
6440
6761
|
if (typeof r == "string") return h.aliases.get(r) === t;
|
|
6441
6762
|
for (const s of r) if (s !== void 0 && C(s, t)) return true;
|
|
@@ -6481,12 +6802,55 @@ function W(r, t, s, e2 = s, i) {
|
|
|
6481
6802
|
const n = A(r ?? stdout);
|
|
6482
6803
|
return wrapAnsi(t, n - s.length, { hard: true, trim: false }).split(`
|
|
6483
6804
|
`).map((o, u) => {
|
|
6484
|
-
const a = o;
|
|
6805
|
+
const a = i ? i(o, u) : o;
|
|
6485
6806
|
return `${u === 0 ? e2 : s}${a}`;
|
|
6486
6807
|
}).join(`
|
|
6487
6808
|
`);
|
|
6488
6809
|
}
|
|
6489
|
-
|
|
6810
|
+
function B(r, t) {
|
|
6811
|
+
if (r === void 0 || t.length === 0) return 0;
|
|
6812
|
+
const s = t.findIndex((e2) => e2.value === r);
|
|
6813
|
+
return s !== -1 ? s : 0;
|
|
6814
|
+
}
|
|
6815
|
+
function J(r, t) {
|
|
6816
|
+
return (t.label ?? String(t.value)).toLowerCase().includes(r.toLowerCase());
|
|
6817
|
+
}
|
|
6818
|
+
function H(r, t) {
|
|
6819
|
+
if (t) return r ? t : t[0];
|
|
6820
|
+
}
|
|
6821
|
+
function P(r) {
|
|
6822
|
+
return [...r].map((t) => Z[t]);
|
|
6823
|
+
}
|
|
6824
|
+
function tt(r) {
|
|
6825
|
+
const t = new Intl.DateTimeFormat(r, { year: "numeric", month: "2-digit", day: "2-digit" }).formatToParts(new Date(2e3, 0, 15)), s = [];
|
|
6826
|
+
let e2 = "/";
|
|
6827
|
+
for (const i of t) i.type === "literal" ? e2 = i.value.trim() || i.value : (i.type === "year" || i.type === "month" || i.type === "day") && s.push({ type: i.type, len: i.type === "year" ? 4 : 2 });
|
|
6828
|
+
return { segments: s, separator: e2 };
|
|
6829
|
+
}
|
|
6830
|
+
function U(r) {
|
|
6831
|
+
return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
|
|
6832
|
+
}
|
|
6833
|
+
function x(r) {
|
|
6834
|
+
return { year: U(r.year), month: U(r.month), day: U(r.day) };
|
|
6835
|
+
}
|
|
6836
|
+
function $(r, t) {
|
|
6837
|
+
return new Date(r || 2001, t || 1, 0).getDate();
|
|
6838
|
+
}
|
|
6839
|
+
function F(r) {
|
|
6840
|
+
const { year: t, month: s, day: e2 } = x(r);
|
|
6841
|
+
if (!t || t < 0 || t > 9999 || !s || s < 1 || s > 12 || !e2 || e2 < 1) return;
|
|
6842
|
+
const i = new Date(Date.UTC(t, s - 1, e2));
|
|
6843
|
+
if (!(i.getUTCFullYear() !== t || i.getUTCMonth() !== s - 1 || i.getUTCDate() !== e2)) return { year: t, month: s, day: e2 };
|
|
6844
|
+
}
|
|
6845
|
+
function N(r) {
|
|
6846
|
+
const t = F(r);
|
|
6847
|
+
return t ? new Date(Date.UTC(t.year, t.month - 1, t.day)) : void 0;
|
|
6848
|
+
}
|
|
6849
|
+
function st(r, t, s, e2) {
|
|
6850
|
+
const i = s ? { year: s.getUTCFullYear(), month: s.getUTCMonth() + 1, day: s.getUTCDate() } : null, n = e2 ? { year: e2.getUTCFullYear(), month: e2.getUTCMonth() + 1, day: e2.getUTCDate() } : null;
|
|
6851
|
+
return r === "year" ? { min: i?.year ?? 1, max: n?.year ?? 9999 } : r === "month" ? { min: i && t.year === i.year ? i.month : 1, max: n && t.year === n.year ? n.month : 12 } : { min: i && t.year === i.year && t.month === i.month ? i.day : 1, max: n && t.year === n.year && t.month === n.month ? n.day : $(t.year, t.month) };
|
|
6852
|
+
}
|
|
6853
|
+
var import_sisteransi, G, K, h, Y, k, A, L, p, Q, X, Z, et, it, rt, nt, ot, ut, at, ht;
|
|
6490
6854
|
var init_dist4 = __esm({
|
|
6491
6855
|
"../../node_modules/.pnpm/@clack+core@1.3.0/node_modules/@clack/core/dist/index.mjs"() {
|
|
6492
6856
|
init_main();
|
|
@@ -6623,6 +6987,69 @@ var init_dist4 = __esm({
|
|
|
6623
6987
|
}
|
|
6624
6988
|
}
|
|
6625
6989
|
};
|
|
6990
|
+
Q = class extends p {
|
|
6991
|
+
filteredOptions;
|
|
6992
|
+
multiple;
|
|
6993
|
+
isNavigating = false;
|
|
6994
|
+
selectedValues = [];
|
|
6995
|
+
focusedValue;
|
|
6996
|
+
#s = 0;
|
|
6997
|
+
#r = "";
|
|
6998
|
+
#t;
|
|
6999
|
+
#n;
|
|
7000
|
+
#u;
|
|
7001
|
+
get cursor() {
|
|
7002
|
+
return this.#s;
|
|
7003
|
+
}
|
|
7004
|
+
get userInputWithCursor() {
|
|
7005
|
+
if (!this.userInput) return styleText(["inverse", "hidden"], "_");
|
|
7006
|
+
if (this._cursor >= this.userInput.length) return `${this.userInput}\u2588`;
|
|
7007
|
+
const t = this.userInput.slice(0, this._cursor), [s, ...e2] = this.userInput.slice(this._cursor);
|
|
7008
|
+
return `${t}${styleText("inverse", s)}${e2.join("")}`;
|
|
7009
|
+
}
|
|
7010
|
+
get options() {
|
|
7011
|
+
return typeof this.#n == "function" ? this.#n() : this.#n;
|
|
7012
|
+
}
|
|
7013
|
+
constructor(t) {
|
|
7014
|
+
super(t), this.#n = t.options, this.#u = t.placeholder;
|
|
7015
|
+
const s = this.options;
|
|
7016
|
+
this.filteredOptions = [...s], this.multiple = t.multiple === true, this.#t = typeof t.options == "function" ? t.filter : t.filter ?? J;
|
|
7017
|
+
let e2;
|
|
7018
|
+
if (t.initialValue && Array.isArray(t.initialValue) ? this.multiple ? e2 = t.initialValue : e2 = t.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (e2 = [this.options[0].value]), e2) for (const i of e2) {
|
|
7019
|
+
const n = s.findIndex((o) => o.value === i);
|
|
7020
|
+
n !== -1 && (this.toggleSelected(i), this.#s = n);
|
|
7021
|
+
}
|
|
7022
|
+
this.focusedValue = this.options[this.#s]?.value, this.on("key", (i, n) => this.#e(i, n)), this.on("userInput", (i) => this.#i(i));
|
|
7023
|
+
}
|
|
7024
|
+
_isActionKey(t, s) {
|
|
7025
|
+
return t === " " || this.multiple && this.isNavigating && s.name === "space" && t !== void 0 && t !== "";
|
|
7026
|
+
}
|
|
7027
|
+
#e(t, s) {
|
|
7028
|
+
const e2 = s.name === "up", i = s.name === "down", n = s.name === "return", o = this.userInput === "" || this.userInput === " ", u = this.#u, a = this.options, l = u !== void 0 && u !== "" && a.some((f) => !f.disabled && (this.#t ? this.#t(u, f) : true));
|
|
7029
|
+
if (s.name === "tab" && o && l) {
|
|
7030
|
+
this.userInput === " " && this._clearUserInput(), this._setUserInput(u, true), this.isNavigating = false;
|
|
7031
|
+
return;
|
|
7032
|
+
}
|
|
7033
|
+
e2 || i ? (this.#s = d(this.#s, e2 ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#s]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = H(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== void 0 && (s.name === "tab" || this.isNavigating && s.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
|
|
7034
|
+
}
|
|
7035
|
+
deselectAll() {
|
|
7036
|
+
this.selectedValues = [];
|
|
7037
|
+
}
|
|
7038
|
+
toggleSelected(t) {
|
|
7039
|
+
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(t) ? this.selectedValues = this.selectedValues.filter((s) => s !== t) : this.selectedValues = [...this.selectedValues, t] : this.selectedValues = [t]);
|
|
7040
|
+
}
|
|
7041
|
+
#i(t) {
|
|
7042
|
+
if (t !== this.#r) {
|
|
7043
|
+
this.#r = t;
|
|
7044
|
+
const s = this.options;
|
|
7045
|
+
t && this.#t ? this.filteredOptions = s.filter((n) => this.#t?.(t, n)) : this.filteredOptions = [...s];
|
|
7046
|
+
const e2 = B(this.focusedValue, this.filteredOptions);
|
|
7047
|
+
this.#s = d(e2, 0, this.filteredOptions);
|
|
7048
|
+
const i = this.filteredOptions[this.#s];
|
|
7049
|
+
i && !i.disabled ? this.focusedValue = i.value : this.focusedValue = void 0, this.multiple || (this.focusedValue !== void 0 ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
7050
|
+
}
|
|
7051
|
+
}
|
|
7052
|
+
};
|
|
6626
7053
|
X = class extends p {
|
|
6627
7054
|
get cursor() {
|
|
6628
7055
|
return this.value ? 0 : 1;
|
|
@@ -6640,6 +7067,266 @@ var init_dist4 = __esm({
|
|
|
6640
7067
|
});
|
|
6641
7068
|
}
|
|
6642
7069
|
};
|
|
7070
|
+
Z = { Y: { type: "year", len: 4 }, M: { type: "month", len: 2 }, D: { type: "day", len: 2 } };
|
|
7071
|
+
et = class extends p {
|
|
7072
|
+
#s;
|
|
7073
|
+
#r;
|
|
7074
|
+
#t;
|
|
7075
|
+
#n;
|
|
7076
|
+
#u;
|
|
7077
|
+
#e = { segmentIndex: 0, positionInSegment: 0 };
|
|
7078
|
+
#i = true;
|
|
7079
|
+
#o = null;
|
|
7080
|
+
inlineError = "";
|
|
7081
|
+
get segmentCursor() {
|
|
7082
|
+
return { ...this.#e };
|
|
7083
|
+
}
|
|
7084
|
+
get segmentValues() {
|
|
7085
|
+
return { ...this.#t };
|
|
7086
|
+
}
|
|
7087
|
+
get segments() {
|
|
7088
|
+
return this.#s;
|
|
7089
|
+
}
|
|
7090
|
+
get separator() {
|
|
7091
|
+
return this.#r;
|
|
7092
|
+
}
|
|
7093
|
+
get formattedValue() {
|
|
7094
|
+
return this.#c(this.#t);
|
|
7095
|
+
}
|
|
7096
|
+
#c(t) {
|
|
7097
|
+
return this.#s.map((s) => t[s.type]).join(this.#r);
|
|
7098
|
+
}
|
|
7099
|
+
#a() {
|
|
7100
|
+
this._setUserInput(this.#c(this.#t)), this._setValue(N(this.#t) ?? void 0);
|
|
7101
|
+
}
|
|
7102
|
+
constructor(t) {
|
|
7103
|
+
const s = t.format ? { segments: P(t.format), separator: t.separator ?? "/" } : tt(t.locale), e2 = t.separator ?? s.separator, i = t.format ? P(t.format) : s.segments, n = t.initialValue ?? t.defaultValue, o = n ? { year: String(n.getUTCFullYear()).padStart(4, "0"), month: String(n.getUTCMonth() + 1).padStart(2, "0"), day: String(n.getUTCDate()).padStart(2, "0") } : { year: "____", month: "__", day: "__" }, u = i.map((a) => o[a.type]).join(e2);
|
|
7104
|
+
super({ ...t, initialUserInput: u }, false), this.#s = i, this.#r = e2, this.#t = o, this.#n = t.minDate, this.#u = t.maxDate, this.#a(), this.on("cursor", (a) => this.#d(a)), this.on("key", (a, l) => this.#f(a, l)), this.on("finalize", () => this.#g(t));
|
|
7105
|
+
}
|
|
7106
|
+
#h() {
|
|
7107
|
+
const t = Math.max(0, Math.min(this.#e.segmentIndex, this.#s.length - 1)), s = this.#s[t];
|
|
7108
|
+
if (s) return this.#e.positionInSegment = Math.max(0, Math.min(this.#e.positionInSegment, s.len - 1)), { segment: s, index: t };
|
|
7109
|
+
}
|
|
7110
|
+
#l(t) {
|
|
7111
|
+
this.inlineError = "", this.#o = null;
|
|
7112
|
+
const s = this.#h();
|
|
7113
|
+
s && (this.#e.segmentIndex = Math.max(0, Math.min(this.#s.length - 1, s.index + t)), this.#e.positionInSegment = 0, this.#i = true);
|
|
7114
|
+
}
|
|
7115
|
+
#p(t) {
|
|
7116
|
+
const s = this.#h();
|
|
7117
|
+
if (!s) return;
|
|
7118
|
+
const { segment: e2 } = s, i = this.#t[e2.type], n = !i || i.replace(/_/g, "") === "", o = Number.parseInt((i || "0").replace(/_/g, "0"), 10) || 0, u = st(e2.type, x(this.#t), this.#n, this.#u);
|
|
7119
|
+
let a;
|
|
7120
|
+
n ? a = t === 1 ? u.min : u.max : a = Math.max(Math.min(u.max, o + t), u.min), this.#t = { ...this.#t, [e2.type]: a.toString().padStart(e2.len, "0") }, this.#i = true, this.#o = null, this.#a();
|
|
7121
|
+
}
|
|
7122
|
+
#d(t) {
|
|
7123
|
+
if (t) switch (t) {
|
|
7124
|
+
case "right":
|
|
7125
|
+
return this.#l(1);
|
|
7126
|
+
case "left":
|
|
7127
|
+
return this.#l(-1);
|
|
7128
|
+
case "up":
|
|
7129
|
+
return this.#p(1);
|
|
7130
|
+
case "down":
|
|
7131
|
+
return this.#p(-1);
|
|
7132
|
+
}
|
|
7133
|
+
}
|
|
7134
|
+
#f(t, s) {
|
|
7135
|
+
if (s?.name === "backspace" || s?.sequence === "\x7F" || s?.sequence === "\b" || t === "\x7F" || t === "\b") {
|
|
7136
|
+
this.inlineError = "";
|
|
7137
|
+
const e2 = this.#h();
|
|
7138
|
+
if (!e2) return;
|
|
7139
|
+
if (!this.#t[e2.segment.type].replace(/_/g, "")) {
|
|
7140
|
+
this.#l(-1);
|
|
7141
|
+
return;
|
|
7142
|
+
}
|
|
7143
|
+
this.#t[e2.segment.type] = "_".repeat(e2.segment.len), this.#i = true, this.#e.positionInSegment = 0, this.#a();
|
|
7144
|
+
return;
|
|
7145
|
+
}
|
|
7146
|
+
if (s?.name === "tab") {
|
|
7147
|
+
this.inlineError = "";
|
|
7148
|
+
const e2 = this.#h();
|
|
7149
|
+
if (!e2) return;
|
|
7150
|
+
const i = s.shift ? -1 : 1, n = e2.index + i;
|
|
7151
|
+
n >= 0 && n < this.#s.length && (this.#e.segmentIndex = n, this.#e.positionInSegment = 0, this.#i = true);
|
|
7152
|
+
return;
|
|
7153
|
+
}
|
|
7154
|
+
if (t && /^[0-9]$/.test(t)) {
|
|
7155
|
+
const e2 = this.#h();
|
|
7156
|
+
if (!e2) return;
|
|
7157
|
+
const { segment: i } = e2, n = !this.#t[i.type].replace(/_/g, "");
|
|
7158
|
+
if (this.#i && this.#o !== null && !n) {
|
|
7159
|
+
const m = this.#o + t, g = { ...this.#t, [i.type]: m }, _ = this.#m(g, i);
|
|
7160
|
+
if (_) {
|
|
7161
|
+
this.inlineError = _, this.#o = null, this.#i = false;
|
|
7162
|
+
return;
|
|
7163
|
+
}
|
|
7164
|
+
this.inlineError = "", this.#t[i.type] = m, this.#o = null, this.#i = false, this.#a(), e2.index < this.#s.length - 1 && (this.#e.segmentIndex = e2.index + 1, this.#e.positionInSegment = 0, this.#i = true);
|
|
7165
|
+
return;
|
|
7166
|
+
}
|
|
7167
|
+
this.#i && !n && (this.#t[i.type] = "_".repeat(i.len), this.#e.positionInSegment = 0), this.#i = false, this.#o = null;
|
|
7168
|
+
const o = this.#t[i.type], u = o.indexOf("_"), a = u >= 0 ? u : Math.min(this.#e.positionInSegment, i.len - 1);
|
|
7169
|
+
if (a < 0 || a >= i.len) return;
|
|
7170
|
+
let l = o.slice(0, a) + t + o.slice(a + 1), f = false;
|
|
7171
|
+
if (a === 0 && o === "__" && (i.type === "month" || i.type === "day")) {
|
|
7172
|
+
const m = Number.parseInt(t, 10);
|
|
7173
|
+
l = `0${t}`, f = m <= (i.type === "month" ? 1 : 2);
|
|
7174
|
+
}
|
|
7175
|
+
if (i.type === "year" && (l = (o.replace(/_/g, "") + t).padStart(i.len, "_")), !l.includes("_")) {
|
|
7176
|
+
const m = { ...this.#t, [i.type]: l }, g = this.#m(m, i);
|
|
7177
|
+
if (g) {
|
|
7178
|
+
this.inlineError = g;
|
|
7179
|
+
return;
|
|
7180
|
+
}
|
|
7181
|
+
}
|
|
7182
|
+
this.inlineError = "", this.#t[i.type] = l;
|
|
7183
|
+
const y = l.includes("_") ? void 0 : F(this.#t);
|
|
7184
|
+
if (y) {
|
|
7185
|
+
const { year: m, month: g } = y, _ = $(m, g);
|
|
7186
|
+
this.#t = { year: String(Math.max(0, Math.min(9999, m))).padStart(4, "0"), month: String(Math.max(1, Math.min(12, g))).padStart(2, "0"), day: String(Math.max(1, Math.min(_, y.day))).padStart(2, "0") };
|
|
7187
|
+
}
|
|
7188
|
+
this.#a();
|
|
7189
|
+
const T = l.indexOf("_");
|
|
7190
|
+
f ? (this.#i = true, this.#o = t) : T >= 0 ? this.#e.positionInSegment = T : u >= 0 && e2.index < this.#s.length - 1 ? (this.#e.segmentIndex = e2.index + 1, this.#e.positionInSegment = 0, this.#i = true) : this.#e.positionInSegment = Math.min(a + 1, i.len - 1);
|
|
7191
|
+
}
|
|
7192
|
+
}
|
|
7193
|
+
#m(t, s) {
|
|
7194
|
+
const { month: e2, day: i } = x(t);
|
|
7195
|
+
if (s.type === "month" && (e2 < 0 || e2 > 12)) return h.date.messages.invalidMonth;
|
|
7196
|
+
if (s.type === "day" && (i < 0 || i > 31)) return h.date.messages.invalidDay(31, "any month");
|
|
7197
|
+
}
|
|
7198
|
+
#g(t) {
|
|
7199
|
+
const { year: s, month: e2, day: i } = x(this.#t);
|
|
7200
|
+
if (s && e2 && i) {
|
|
7201
|
+
const n = $(s, e2);
|
|
7202
|
+
this.#t = { ...this.#t, day: String(Math.min(i, n)).padStart(2, "0") };
|
|
7203
|
+
}
|
|
7204
|
+
this.value = N(this.#t) ?? t.defaultValue ?? void 0;
|
|
7205
|
+
}
|
|
7206
|
+
};
|
|
7207
|
+
it = class extends p {
|
|
7208
|
+
options;
|
|
7209
|
+
cursor = 0;
|
|
7210
|
+
#s;
|
|
7211
|
+
getGroupItems(t) {
|
|
7212
|
+
return this.options.filter((s) => s.group === t);
|
|
7213
|
+
}
|
|
7214
|
+
isGroupSelected(t) {
|
|
7215
|
+
const s = this.getGroupItems(t), e2 = this.value;
|
|
7216
|
+
return e2 === void 0 ? false : s.every((i) => e2.includes(i.value));
|
|
7217
|
+
}
|
|
7218
|
+
toggleValue() {
|
|
7219
|
+
const t = this.options[this.cursor];
|
|
7220
|
+
if (this.value === void 0 && (this.value = []), t.group === true) {
|
|
7221
|
+
const s = t.value, e2 = this.getGroupItems(s);
|
|
7222
|
+
this.isGroupSelected(s) ? this.value = this.value.filter((i) => e2.findIndex((n) => n.value === i) === -1) : this.value = [...this.value, ...e2.map((i) => i.value)], this.value = Array.from(new Set(this.value));
|
|
7223
|
+
} else {
|
|
7224
|
+
const s = this.value.includes(t.value);
|
|
7225
|
+
this.value = s ? this.value.filter((e2) => e2 !== t.value) : [...this.value, t.value];
|
|
7226
|
+
}
|
|
7227
|
+
}
|
|
7228
|
+
constructor(t) {
|
|
7229
|
+
super(t, false);
|
|
7230
|
+
const { options: s } = t;
|
|
7231
|
+
this.#s = t.selectableGroups !== false, this.options = Object.entries(s).flatMap(([e2, i]) => [{ value: e2, group: true, label: e2 }, ...i.map((n) => ({ ...n, group: e2 }))]), this.value = [...t.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: e2 }) => e2 === t.cursorAt), this.#s ? 0 : 1), this.on("cursor", (e2) => {
|
|
7232
|
+
switch (e2) {
|
|
7233
|
+
case "left":
|
|
7234
|
+
case "up": {
|
|
7235
|
+
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
7236
|
+
const i = this.options[this.cursor]?.group === true;
|
|
7237
|
+
!this.#s && i && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
7238
|
+
break;
|
|
7239
|
+
}
|
|
7240
|
+
case "down":
|
|
7241
|
+
case "right": {
|
|
7242
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
7243
|
+
const i = this.options[this.cursor]?.group === true;
|
|
7244
|
+
!this.#s && i && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
7245
|
+
break;
|
|
7246
|
+
}
|
|
7247
|
+
case "space":
|
|
7248
|
+
this.toggleValue();
|
|
7249
|
+
break;
|
|
7250
|
+
}
|
|
7251
|
+
});
|
|
7252
|
+
}
|
|
7253
|
+
};
|
|
7254
|
+
rt = class extends p {
|
|
7255
|
+
#s = false;
|
|
7256
|
+
#r;
|
|
7257
|
+
focused = "editor";
|
|
7258
|
+
get userInputWithCursor() {
|
|
7259
|
+
if (this.state === "submit") return this.userInput;
|
|
7260
|
+
const t = this.userInput;
|
|
7261
|
+
if (this.cursor >= t.length) return `${t}\u2588`;
|
|
7262
|
+
const s = t.slice(0, this.cursor), e2 = t[this.cursor], i = t.slice(this.cursor + 1);
|
|
7263
|
+
return e2 === `
|
|
7264
|
+
` ? `${s}\u2588
|
|
7265
|
+
${i}` : `${s}${styleText("inverse", e2)}${i}`;
|
|
7266
|
+
}
|
|
7267
|
+
get cursor() {
|
|
7268
|
+
return this._cursor;
|
|
7269
|
+
}
|
|
7270
|
+
#t(t) {
|
|
7271
|
+
if (this.userInput.length === 0) {
|
|
7272
|
+
this._setUserInput(t);
|
|
7273
|
+
return;
|
|
7274
|
+
}
|
|
7275
|
+
this._setUserInput(this.userInput.slice(0, this.cursor) + t + this.userInput.slice(this.cursor));
|
|
7276
|
+
}
|
|
7277
|
+
#n(t) {
|
|
7278
|
+
const s = this.value ?? "";
|
|
7279
|
+
switch (t) {
|
|
7280
|
+
case "up":
|
|
7281
|
+
this._cursor = I(this._cursor, 0, -1, s);
|
|
7282
|
+
return;
|
|
7283
|
+
case "down":
|
|
7284
|
+
this._cursor = I(this._cursor, 0, 1, s);
|
|
7285
|
+
return;
|
|
7286
|
+
case "left":
|
|
7287
|
+
this._cursor = I(this._cursor, -1, 0, s);
|
|
7288
|
+
return;
|
|
7289
|
+
case "right":
|
|
7290
|
+
this._cursor = I(this._cursor, 1, 0, s);
|
|
7291
|
+
return;
|
|
7292
|
+
}
|
|
7293
|
+
}
|
|
7294
|
+
_shouldSubmit(t, s) {
|
|
7295
|
+
if (this.#r) return this.focused === "submit" ? true : (this.#t(`
|
|
7296
|
+
`), this._cursor++, false);
|
|
7297
|
+
const e2 = this.#s;
|
|
7298
|
+
return this.#s = true, e2 ? (this.userInput[this.cursor - 1] === `
|
|
7299
|
+
` && (this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--), true) : (this.#t(`
|
|
7300
|
+
`), this._cursor++, false);
|
|
7301
|
+
}
|
|
7302
|
+
constructor(t) {
|
|
7303
|
+
super(t, false), this.#r = t.showSubmit ?? false, this.on("key", (s, e2) => {
|
|
7304
|
+
if (e2?.name && h.actions.has(e2.name)) {
|
|
7305
|
+
this.#n(e2.name);
|
|
7306
|
+
return;
|
|
7307
|
+
}
|
|
7308
|
+
if (s === " " && this.#r) {
|
|
7309
|
+
this.focused = this.focused === "editor" ? "submit" : "editor";
|
|
7310
|
+
return;
|
|
7311
|
+
}
|
|
7312
|
+
if (e2?.name !== "return") {
|
|
7313
|
+
if (this.#s = false, e2?.name === "backspace" && this.cursor > 0) {
|
|
7314
|
+
this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--;
|
|
7315
|
+
return;
|
|
7316
|
+
}
|
|
7317
|
+
if (e2?.name === "delete" && this.cursor < this.userInput.length) {
|
|
7318
|
+
this._setUserInput(this.userInput.slice(0, this.cursor) + this.userInput.slice(this.cursor + 1));
|
|
7319
|
+
return;
|
|
7320
|
+
}
|
|
7321
|
+
s && (this.#r && this.focused === "submit" && (this.focused = "editor"), this.#t(s ?? ""), this._cursor++);
|
|
7322
|
+
}
|
|
7323
|
+
}), this.on("userInput", (s) => {
|
|
7324
|
+
this._setValue(s);
|
|
7325
|
+
}), this.on("finalize", () => {
|
|
7326
|
+
this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
|
|
7327
|
+
});
|
|
7328
|
+
}
|
|
7329
|
+
};
|
|
6643
7330
|
nt = class extends p {
|
|
6644
7331
|
options;
|
|
6645
7332
|
cursor = 0;
|
|
@@ -6737,6 +7424,21 @@ var init_dist4 = __esm({
|
|
|
6737
7424
|
});
|
|
6738
7425
|
}
|
|
6739
7426
|
};
|
|
7427
|
+
at = class extends p {
|
|
7428
|
+
options;
|
|
7429
|
+
cursor = 0;
|
|
7430
|
+
constructor(t) {
|
|
7431
|
+
super(t, false), this.options = t.options;
|
|
7432
|
+
const s = t.caseSensitive === true, e2 = this.options.map(({ value: [i] }) => s ? i : i?.toLowerCase());
|
|
7433
|
+
this.cursor = Math.max(e2.indexOf(t.initialValue), 0), this.on("key", (i, n) => {
|
|
7434
|
+
if (!i) return;
|
|
7435
|
+
const o = s && n.shift ? i.toUpperCase() : i;
|
|
7436
|
+
if (!e2.includes(o)) return;
|
|
7437
|
+
const u = this.options.find(({ value: [a] }) => s ? a === o : a?.toLowerCase() === i);
|
|
7438
|
+
u && (this.value = u.value, this.state = "submit", this.emit("submit"));
|
|
7439
|
+
});
|
|
7440
|
+
}
|
|
7441
|
+
};
|
|
6740
7442
|
ht = class extends p {
|
|
6741
7443
|
get userInputWithCursor() {
|
|
6742
7444
|
if (this.state === "submit") return this.userInput;
|
|
@@ -6758,10 +7460,130 @@ var init_dist4 = __esm({
|
|
|
6758
7460
|
};
|
|
6759
7461
|
}
|
|
6760
7462
|
});
|
|
7463
|
+
|
|
7464
|
+
// ../../node_modules/.pnpm/@clack+prompts@1.3.0/node_modules/@clack/prompts/dist/index.mjs
|
|
7465
|
+
var dist_exports = {};
|
|
7466
|
+
__export(dist_exports, {
|
|
7467
|
+
S_BAR: () => $2,
|
|
7468
|
+
S_BAR_END: () => E2,
|
|
7469
|
+
S_BAR_END_RIGHT: () => Et,
|
|
7470
|
+
S_BAR_H: () => st2,
|
|
7471
|
+
S_BAR_START: () => lt,
|
|
7472
|
+
S_BAR_START_RIGHT: () => It,
|
|
7473
|
+
S_CHECKBOX_ACTIVE: () => et2,
|
|
7474
|
+
S_CHECKBOX_INACTIVE: () => J2,
|
|
7475
|
+
S_CHECKBOX_SELECTED: () => U2,
|
|
7476
|
+
S_CONNECT_LEFT: () => xt,
|
|
7477
|
+
S_CORNER_BOTTOM_LEFT: () => dt,
|
|
7478
|
+
S_CORNER_BOTTOM_RIGHT: () => $t,
|
|
7479
|
+
S_CORNER_TOP_LEFT: () => Ot,
|
|
7480
|
+
S_CORNER_TOP_RIGHT: () => ct,
|
|
7481
|
+
S_ERROR: () => gt,
|
|
7482
|
+
S_INFO: () => ht2,
|
|
7483
|
+
S_PASSWORD_MASK: () => Gt,
|
|
7484
|
+
S_RADIO_ACTIVE: () => z2,
|
|
7485
|
+
S_RADIO_INACTIVE: () => H2,
|
|
7486
|
+
S_STEP_ACTIVE: () => _t,
|
|
7487
|
+
S_STEP_CANCEL: () => ot2,
|
|
7488
|
+
S_STEP_ERROR: () => ut2,
|
|
7489
|
+
S_STEP_SUBMIT: () => F2,
|
|
7490
|
+
S_SUCCESS: () => pt,
|
|
7491
|
+
S_WARN: () => mt,
|
|
7492
|
+
autocomplete: () => At,
|
|
7493
|
+
autocompleteMultiselect: () => ie,
|
|
7494
|
+
box: () => oe,
|
|
7495
|
+
cancel: () => me,
|
|
7496
|
+
confirm: () => ue,
|
|
7497
|
+
date: () => le,
|
|
7498
|
+
group: () => he,
|
|
7499
|
+
groupMultiselect: () => pe,
|
|
7500
|
+
intro: () => ge,
|
|
7501
|
+
isCI: () => at2,
|
|
7502
|
+
isCancel: () => q,
|
|
7503
|
+
isTTY: () => Tt,
|
|
7504
|
+
limitOptions: () => Y2,
|
|
7505
|
+
log: () => R2,
|
|
7506
|
+
multiline: () => fe,
|
|
7507
|
+
multiselect: () => ve,
|
|
7508
|
+
note: () => Se,
|
|
7509
|
+
outro: () => ye,
|
|
7510
|
+
password: () => Ce,
|
|
7511
|
+
path: () => Te,
|
|
7512
|
+
progress: () => Ie,
|
|
7513
|
+
select: () => Ee,
|
|
7514
|
+
selectKey: () => Ge,
|
|
7515
|
+
settings: () => h,
|
|
7516
|
+
spinner: () => ft,
|
|
7517
|
+
stream: () => K2,
|
|
7518
|
+
symbol: () => M,
|
|
7519
|
+
symbolBar: () => yt,
|
|
7520
|
+
taskLog: () => Me,
|
|
7521
|
+
tasks: () => xe,
|
|
7522
|
+
text: () => Re,
|
|
7523
|
+
unicode: () => tt2,
|
|
7524
|
+
unicodeOr: () => w2,
|
|
7525
|
+
updateSettings: () => j
|
|
7526
|
+
});
|
|
6761
7527
|
function te() {
|
|
6762
7528
|
return j2.platform !== "win32" ? j2.env.TERM !== "linux" : !!j2.env.CI || !!j2.env.WT_SESSION || !!j2.env.TERMINUS_SUBLIME || j2.env.ConEmuTask === "{cmd::Cmder}" || j2.env.TERM_PROGRAM === "Terminus-Sublime" || j2.env.TERM_PROGRAM === "vscode" || j2.env.TERM === "xterm-256color" || j2.env.TERM === "alacritty" || j2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
6763
7529
|
}
|
|
6764
|
-
|
|
7530
|
+
function Mt(t) {
|
|
7531
|
+
return t.label ?? String(t.value ?? "");
|
|
7532
|
+
}
|
|
7533
|
+
function Rt(t, r) {
|
|
7534
|
+
if (!t) return true;
|
|
7535
|
+
const s = (r.label ?? String(r.value ?? "")).toLowerCase(), i = (r.hint ?? "").toLowerCase(), u = String(r.value).toLowerCase(), n = t.toLowerCase();
|
|
7536
|
+
return s.includes(n) || i.includes(n) || u.includes(n);
|
|
7537
|
+
}
|
|
7538
|
+
function se(t, r) {
|
|
7539
|
+
const s = [];
|
|
7540
|
+
for (const i of r) t.includes(i.value) && s.push(i);
|
|
7541
|
+
return s;
|
|
7542
|
+
}
|
|
7543
|
+
function Pt(t, r, s, i) {
|
|
7544
|
+
let u = s, n = s;
|
|
7545
|
+
return i === "center" ? u = Math.floor((r - t) / 2) : i === "right" && (u = r - t - s), n = r - u - t, [u, n];
|
|
7546
|
+
}
|
|
7547
|
+
function ce(t, r) {
|
|
7548
|
+
const s = t.segmentValues, i = t.segmentCursor;
|
|
7549
|
+
if (r === "submit" || r === "cancel") return t.formattedValue;
|
|
7550
|
+
const u = styleText("gray", t.separator);
|
|
7551
|
+
return t.segments.map((n, o) => {
|
|
7552
|
+
const c2 = o === i.segmentIndex && !["submit", "cancel"].includes(r), a = de[n.type];
|
|
7553
|
+
return $e(s[n.type], { isActive: c2, label: a });
|
|
7554
|
+
}).join(u);
|
|
7555
|
+
}
|
|
7556
|
+
function $e(t, r) {
|
|
7557
|
+
const s = !t || t.replace(/_/g, "") === "";
|
|
7558
|
+
return r.isActive ? styleText("inverse", s ? r.label : t.replace(/_/g, " ")) : s ? styleText("dim", r.label) : t.replace(/_/g, styleText("dim", " "));
|
|
7559
|
+
}
|
|
7560
|
+
function Ie({ style: t = "heavy", max: r = 100, size: s = 40, ...i } = {}) {
|
|
7561
|
+
const u = ft(i);
|
|
7562
|
+
let n = 0, o = "";
|
|
7563
|
+
const c2 = Math.max(1, r), a = Math.max(1, s), l = (m) => {
|
|
7564
|
+
switch (m) {
|
|
7565
|
+
case "initial":
|
|
7566
|
+
case "active":
|
|
7567
|
+
return (g) => styleText("magenta", g);
|
|
7568
|
+
case "error":
|
|
7569
|
+
case "cancel":
|
|
7570
|
+
return (g) => styleText("red", g);
|
|
7571
|
+
case "submit":
|
|
7572
|
+
return (g) => styleText("green", g);
|
|
7573
|
+
default:
|
|
7574
|
+
return (g) => styleText("magenta", g);
|
|
7575
|
+
}
|
|
7576
|
+
}, d2 = (m, g) => {
|
|
7577
|
+
const S2 = Math.floor(n / c2 * a);
|
|
7578
|
+
return `${l(m)(Vt[t].repeat(S2))}${styleText("dim", Vt[t].repeat(a - S2))} ${g}`;
|
|
7579
|
+
}, y = (m = "") => {
|
|
7580
|
+
o = m, u.start(d2("initial", m));
|
|
7581
|
+
}, p2 = (m = 1, g) => {
|
|
7582
|
+
n = Math.min(c2, m + n), u.message(d2("active", g ?? o)), o = g ?? o;
|
|
7583
|
+
};
|
|
7584
|
+
return { start: y, stop: u.stop, cancel: u.cancel, error: u.error, clear: u.clear, advance: p2, isCancelled: u.isCancelled, message: (m) => p2(0, m) };
|
|
7585
|
+
}
|
|
7586
|
+
var import_sisteransi2, tt2, at2, Tt, w2, _t, ot2, ut2, F2, lt, $2, E2, It, Et, z2, H2, et2, U2, J2, Gt, st2, ct, xt, $t, dt, Ot, ht2, pt, mt, gt, M, yt, ee, Y2, At, ie, re, ne, ae, oe, ue, le, de, he, pe, R2, me, ge, ye, fe, Q2, ve, we, be, Se, Ce, Te, _e, ft, Vt, it2, Ee, Ge, jt, K2, xe, Oe, Me, Re;
|
|
6765
7587
|
var init_dist5 = __esm({
|
|
6766
7588
|
"../../node_modules/.pnpm/@clack+prompts@1.3.0/node_modules/@clack/prompts/dist/index.mjs"() {
|
|
6767
7589
|
init_dist4();
|
|
@@ -6769,30 +7591,31 @@ var init_dist5 = __esm({
|
|
|
6769
7591
|
init_main();
|
|
6770
7592
|
init_dist3();
|
|
6771
7593
|
import_sisteransi2 = __toESM(require_src());
|
|
6772
|
-
|
|
7594
|
+
tt2 = te();
|
|
6773
7595
|
at2 = () => process.env.CI === "true";
|
|
6774
|
-
|
|
7596
|
+
Tt = (t) => t.isTTY === true;
|
|
7597
|
+
w2 = (t, r) => tt2 ? t : r;
|
|
6775
7598
|
_t = w2("\u25C6", "*");
|
|
6776
7599
|
ot2 = w2("\u25A0", "x");
|
|
6777
7600
|
ut2 = w2("\u25B2", "x");
|
|
6778
|
-
|
|
7601
|
+
F2 = w2("\u25C7", "o");
|
|
6779
7602
|
lt = w2("\u250C", "T");
|
|
6780
|
-
$ = w2("\u2502", "|");
|
|
7603
|
+
$2 = w2("\u2502", "|");
|
|
6781
7604
|
E2 = w2("\u2514", "\u2014");
|
|
6782
|
-
w2("\u2510", "T");
|
|
6783
|
-
w2("\u2518", "\u2014");
|
|
7605
|
+
It = w2("\u2510", "T");
|
|
7606
|
+
Et = w2("\u2518", "\u2014");
|
|
6784
7607
|
z2 = w2("\u25CF", ">");
|
|
6785
|
-
|
|
7608
|
+
H2 = w2("\u25CB", " ");
|
|
6786
7609
|
et2 = w2("\u25FB", "[\u2022]");
|
|
6787
|
-
|
|
6788
|
-
|
|
7610
|
+
U2 = w2("\u25FC", "[+]");
|
|
7611
|
+
J2 = w2("\u25FB", "[ ]");
|
|
6789
7612
|
Gt = w2("\u25AA", "\u2022");
|
|
6790
|
-
|
|
7613
|
+
st2 = w2("\u2500", "-");
|
|
6791
7614
|
ct = w2("\u256E", "+");
|
|
6792
7615
|
xt = w2("\u251C", "+");
|
|
6793
7616
|
$t = w2("\u256F", "+");
|
|
6794
7617
|
dt = w2("\u2570", "+");
|
|
6795
|
-
w2("\u256D", "+");
|
|
7618
|
+
Ot = w2("\u256D", "+");
|
|
6796
7619
|
ht2 = w2("\u25CF", "\u2022");
|
|
6797
7620
|
pt = w2("\u25C6", "*");
|
|
6798
7621
|
mt = w2("\u25B2", "!");
|
|
@@ -6807,20 +7630,20 @@ var init_dist5 = __esm({
|
|
|
6807
7630
|
case "error":
|
|
6808
7631
|
return styleText("yellow", ut2);
|
|
6809
7632
|
case "submit":
|
|
6810
|
-
return styleText("green",
|
|
7633
|
+
return styleText("green", F2);
|
|
6811
7634
|
}
|
|
6812
7635
|
};
|
|
6813
7636
|
yt = (t) => {
|
|
6814
7637
|
switch (t) {
|
|
6815
7638
|
case "initial":
|
|
6816
7639
|
case "active":
|
|
6817
|
-
return styleText("cyan", $);
|
|
7640
|
+
return styleText("cyan", $2);
|
|
6818
7641
|
case "cancel":
|
|
6819
|
-
return styleText("red", $);
|
|
7642
|
+
return styleText("red", $2);
|
|
6820
7643
|
case "error":
|
|
6821
|
-
return styleText("yellow", $);
|
|
7644
|
+
return styleText("yellow", $2);
|
|
6822
7645
|
case "submit":
|
|
6823
|
-
return styleText("green", $);
|
|
7646
|
+
return styleText("green", $2);
|
|
6824
7647
|
}
|
|
6825
7648
|
};
|
|
6826
7649
|
ee = (t, r, s, i, u) => {
|
|
@@ -6846,42 +7669,178 @@ var init_dist5 = __esm({
|
|
|
6846
7669
|
h2.push(G2), f += G2.length;
|
|
6847
7670
|
}
|
|
6848
7671
|
if (f > d2) {
|
|
6849
|
-
let b2 = 0, G2 = 0,
|
|
6850
|
-
const A2 = t - v2,
|
|
6851
|
-
m ? ({ lineCount:
|
|
7672
|
+
let b2 = 0, G2 = 0, x2 = f;
|
|
7673
|
+
const A2 = t - v2, P2 = (N2, D2) => ee(h2, x2, N2, D2, d2);
|
|
7674
|
+
m ? ({ lineCount: x2, removals: b2 } = P2(0, A2), x2 > d2 && ({ lineCount: x2, removals: G2 } = P2(A2 + 1, h2.length))) : ({ lineCount: x2, removals: G2 } = P2(A2 + 1, h2.length), x2 > d2 && ({ lineCount: x2, removals: b2 } = P2(0, A2))), b2 > 0 && (m = true, h2.splice(0, b2)), G2 > 0 && (g = true, h2.splice(h2.length - G2, G2));
|
|
6852
7675
|
}
|
|
6853
7676
|
const C2 = [];
|
|
6854
7677
|
m && C2.push(l);
|
|
6855
7678
|
for (const b2 of h2) for (const G2 of b2) C2.push(G2);
|
|
6856
7679
|
return g && C2.push(l), C2;
|
|
6857
7680
|
};
|
|
7681
|
+
At = (t) => new Q({ options: t.options, initialValue: t.initialValue ? [t.initialValue] : void 0, initialUserInput: t.initialUserInput, placeholder: t.placeholder, filter: t.filter ?? ((r, s) => Rt(r, s)), signal: t.signal, input: t.input, output: t.output, validate: t.validate, render() {
|
|
7682
|
+
const r = t.withGuide ?? h.withGuide, s = r ? [`${styleText("gray", $2)}`, `${M(this.state)} ${t.message}`] : [`${M(this.state)} ${t.message}`], i = this.userInput, u = this.options, n = t.placeholder, o = i === "" && n !== void 0, c2 = (a, l) => {
|
|
7683
|
+
const d2 = Mt(a), y = a.hint && a.value === this.focusedValue ? styleText("dim", ` (${a.hint})`) : "";
|
|
7684
|
+
switch (l) {
|
|
7685
|
+
case "active":
|
|
7686
|
+
return `${styleText("green", z2)} ${d2}${y}`;
|
|
7687
|
+
case "inactive":
|
|
7688
|
+
return `${styleText("dim", H2)} ${styleText("dim", d2)}`;
|
|
7689
|
+
case "disabled":
|
|
7690
|
+
return `${styleText("gray", H2)} ${styleText(["strikethrough", "gray"], d2)}`;
|
|
7691
|
+
}
|
|
7692
|
+
};
|
|
7693
|
+
switch (this.state) {
|
|
7694
|
+
case "submit": {
|
|
7695
|
+
const a = se(this.selectedValues, u), l = a.length > 0 ? ` ${styleText("dim", a.map(Mt).join(", "))}` : "", d2 = r ? styleText("gray", $2) : "";
|
|
7696
|
+
return `${s.join(`
|
|
7697
|
+
`)}
|
|
7698
|
+
${d2}${l}`;
|
|
7699
|
+
}
|
|
7700
|
+
case "cancel": {
|
|
7701
|
+
const a = i ? ` ${styleText(["strikethrough", "dim"], i)}` : "", l = r ? styleText("gray", $2) : "";
|
|
7702
|
+
return `${s.join(`
|
|
7703
|
+
`)}
|
|
7704
|
+
${l}${a}`;
|
|
7705
|
+
}
|
|
7706
|
+
default: {
|
|
7707
|
+
const a = this.state === "error" ? "yellow" : "cyan", l = r ? `${styleText(a, $2)} ` : "", d2 = r ? styleText(a, E2) : "";
|
|
7708
|
+
let y = "";
|
|
7709
|
+
if (this.isNavigating || o) {
|
|
7710
|
+
const v2 = o ? n : i;
|
|
7711
|
+
y = v2 !== "" ? ` ${styleText("dim", v2)}` : "";
|
|
7712
|
+
} else y = ` ${this.userInputWithCursor}`;
|
|
7713
|
+
const p2 = this.filteredOptions.length !== u.length ? styleText("dim", ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "", m = this.filteredOptions.length === 0 && i ? [`${l}${styleText("yellow", "No matches found")}`] : [], g = this.state === "error" ? [`${l}${styleText("yellow", this.error)}`] : [];
|
|
7714
|
+
r && s.push(`${l.trimEnd()}`), s.push(`${l}${styleText("dim", "Search:")}${y}${p2}`, ...m, ...g);
|
|
7715
|
+
const S2 = [`${styleText("dim", "\u2191/\u2193")} to select`, `${styleText("dim", "Enter:")} confirm`, `${styleText("dim", "Type:")} to search`], h2 = [`${l}${S2.join(" \u2022 ")}`, d2], f = this.filteredOptions.length === 0 ? [] : Y2({ cursor: this.cursor, options: this.filteredOptions, columnPadding: r ? 3 : 0, rowPadding: s.length + h2.length, style: (v2, T) => c2(v2, v2.disabled ? "disabled" : T ? "active" : "inactive"), maxItems: t.maxItems, output: t.output });
|
|
7716
|
+
return [...s, ...f.map((v2) => `${l}${v2}`), ...h2].join(`
|
|
7717
|
+
`);
|
|
7718
|
+
}
|
|
7719
|
+
}
|
|
7720
|
+
} }).prompt();
|
|
7721
|
+
ie = (t) => {
|
|
7722
|
+
const r = (i, u, n, o) => {
|
|
7723
|
+
const c2 = n.includes(i.value), a = i.label ?? String(i.value ?? ""), l = i.hint && o !== void 0 && i.value === o ? styleText("dim", ` (${i.hint})`) : "", d2 = c2 ? styleText("green", U2) : styleText("dim", J2);
|
|
7724
|
+
return i.disabled ? `${styleText("gray", J2)} ${styleText(["strikethrough", "gray"], a)}` : u ? `${d2} ${a}${l}` : `${d2} ${styleText("dim", a)}`;
|
|
7725
|
+
}, s = new Q({ options: t.options, multiple: true, placeholder: t.placeholder, filter: t.filter ?? ((i, u) => Rt(i, u)), validate: () => {
|
|
7726
|
+
if (t.required && s.selectedValues.length === 0) return "Please select at least one item";
|
|
7727
|
+
}, initialValue: t.initialValues, signal: t.signal, input: t.input, output: t.output, render() {
|
|
7728
|
+
const i = t.withGuide ?? h.withGuide, u = `${i ? `${styleText("gray", $2)}
|
|
7729
|
+
` : ""}${M(this.state)} ${t.message}
|
|
7730
|
+
`, n = this.userInput, o = t.placeholder, c2 = n === "" && o !== void 0, a = this.isNavigating || c2 ? styleText("dim", c2 ? o : n) : this.userInputWithCursor, l = this.options, d2 = this.filteredOptions.length !== l.length ? styleText("dim", ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "";
|
|
7731
|
+
switch (this.state) {
|
|
7732
|
+
case "submit":
|
|
7733
|
+
return `${u}${i ? `${styleText("gray", $2)} ` : ""}${styleText("dim", `${this.selectedValues.length} items selected`)}`;
|
|
7734
|
+
case "cancel":
|
|
7735
|
+
return `${u}${i ? `${styleText("gray", $2)} ` : ""}${styleText(["strikethrough", "dim"], n)}`;
|
|
7736
|
+
default: {
|
|
7737
|
+
const y = this.state === "error" ? "yellow" : "cyan", p2 = i ? `${styleText(y, $2)} ` : "", m = i ? styleText(y, E2) : "", g = [`${styleText("dim", "\u2191/\u2193")} to navigate`, `${styleText("dim", this.isNavigating ? "Space/Tab:" : "Tab:")} select`, `${styleText("dim", "Enter:")} confirm`, `${styleText("dim", "Type:")} to search`], S2 = this.filteredOptions.length === 0 && n ? [`${p2}${styleText("yellow", "No matches found")}`] : [], h2 = this.state === "error" ? [`${p2}${styleText("yellow", this.error)}`] : [], f = [...`${u}${i ? styleText(y, $2) : ""}`.split(`
|
|
7738
|
+
`), `${p2}${styleText("dim", "Search:")} ${a}${d2}`, ...S2, ...h2], v2 = [`${p2}${g.join(" \u2022 ")}`, m], T = Y2({ cursor: this.cursor, options: this.filteredOptions, style: (C2, b2) => r(C2, b2, this.selectedValues, this.focusedValue), maxItems: t.maxItems, output: t.output, rowPadding: f.length + v2.length });
|
|
7739
|
+
return [...f, ...T.map((C2) => `${p2}${C2}`), ...v2].join(`
|
|
7740
|
+
`);
|
|
7741
|
+
}
|
|
7742
|
+
}
|
|
7743
|
+
} });
|
|
7744
|
+
return s.prompt();
|
|
7745
|
+
};
|
|
7746
|
+
re = [Ot, ct, dt, $t];
|
|
7747
|
+
ne = [lt, It, E2, Et];
|
|
7748
|
+
ae = (t) => t;
|
|
7749
|
+
oe = (t = "", r = "", s) => {
|
|
7750
|
+
const i = s?.output ?? process.stdout, u = A(i), n = 2, o = s?.titlePadding ?? 1, c2 = s?.contentPadding ?? 2, a = s?.width === void 0 || s.width === "auto" ? 1 : Math.min(1, s.width), l = s?.withGuide ?? h.withGuide ? `${$2} ` : "", d2 = s?.formatBorder ?? ae, y = (s?.rounded ? re : ne).map(d2), p2 = d2(st2), m = d2($2), g = dist_default2(l), S2 = dist_default2(r), h2 = u - g;
|
|
7751
|
+
let f = Math.floor(u * a) - g;
|
|
7752
|
+
if (s?.width === "auto") {
|
|
7753
|
+
const P2 = t.split(`
|
|
7754
|
+
`);
|
|
7755
|
+
let N2 = S2 + o * 2;
|
|
7756
|
+
for (const rt2 of P2) {
|
|
7757
|
+
const W2 = dist_default2(rt2) + c2 * 2;
|
|
7758
|
+
W2 > N2 && (N2 = W2);
|
|
7759
|
+
}
|
|
7760
|
+
const D2 = N2 + n;
|
|
7761
|
+
D2 < f && (f = D2);
|
|
7762
|
+
}
|
|
7763
|
+
f % 2 !== 0 && (f < h2 ? f++ : f--);
|
|
7764
|
+
const v2 = f - n, T = v2 - o * 2, C2 = S2 > T ? `${r.slice(0, T - 3)}...` : r, [b2, G2] = Pt(dist_default2(C2), v2, o, s?.titleAlign), x2 = wrapAnsi(t, v2 - c2 * 2, { hard: true, trim: false });
|
|
7765
|
+
i.write(`${l}${y[0]}${p2.repeat(b2)}${C2}${p2.repeat(G2)}${y[1]}
|
|
7766
|
+
`);
|
|
7767
|
+
const A2 = x2.split(`
|
|
7768
|
+
`);
|
|
7769
|
+
for (const P2 of A2) {
|
|
7770
|
+
const [N2, D2] = Pt(dist_default2(P2), v2, c2, s?.contentAlign);
|
|
7771
|
+
i.write(`${l}${m}${" ".repeat(N2)}${P2}${" ".repeat(D2)}${m}
|
|
7772
|
+
`);
|
|
7773
|
+
}
|
|
7774
|
+
i.write(`${l}${y[2]}${p2.repeat(v2)}${y[3]}
|
|
7775
|
+
`);
|
|
7776
|
+
};
|
|
6858
7777
|
ue = (t) => {
|
|
6859
7778
|
const r = t.active ?? "Yes", s = t.inactive ?? "No";
|
|
6860
7779
|
return new X({ active: r, inactive: s, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue ?? true, render() {
|
|
6861
|
-
const i = t.withGuide ?? h.withGuide, u = `${M(this.state)} `, n = i ? `${styleText("gray", $)} ` : "", o = W(t.output, t.message, n, u), c2 = `${i ? `${styleText("gray", $)}
|
|
7780
|
+
const i = t.withGuide ?? h.withGuide, u = `${M(this.state)} `, n = i ? `${styleText("gray", $2)} ` : "", o = W(t.output, t.message, n, u), c2 = `${i ? `${styleText("gray", $2)}
|
|
6862
7781
|
` : ""}${o}
|
|
6863
7782
|
`, a = this.value ? r : s;
|
|
6864
7783
|
switch (this.state) {
|
|
6865
7784
|
case "submit": {
|
|
6866
|
-
const l = i ? `${styleText("gray", $)} ` : "";
|
|
7785
|
+
const l = i ? `${styleText("gray", $2)} ` : "";
|
|
6867
7786
|
return `${c2}${l}${styleText("dim", a)}`;
|
|
6868
7787
|
}
|
|
6869
7788
|
case "cancel": {
|
|
6870
|
-
const l = i ? `${styleText("gray", $)} ` : "";
|
|
7789
|
+
const l = i ? `${styleText("gray", $2)} ` : "";
|
|
6871
7790
|
return `${c2}${l}${styleText(["strikethrough", "dim"], a)}${i ? `
|
|
6872
|
-
${styleText("gray", $)}` : ""}`;
|
|
7791
|
+
${styleText("gray", $2)}` : ""}`;
|
|
6873
7792
|
}
|
|
6874
7793
|
default: {
|
|
6875
|
-
const l = i ? `${styleText("cyan", $)} ` : "", d2 = i ? styleText("cyan", E2) : "";
|
|
6876
|
-
return `${c2}${l}${this.value ? `${styleText("green", z2)} ${r}` : `${styleText("dim",
|
|
6877
|
-
${styleText("cyan", $)} ` : `
|
|
6878
|
-
` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim",
|
|
7794
|
+
const l = i ? `${styleText("cyan", $2)} ` : "", d2 = i ? styleText("cyan", E2) : "";
|
|
7795
|
+
return `${c2}${l}${this.value ? `${styleText("green", z2)} ${r}` : `${styleText("dim", H2)} ${styleText("dim", r)}`}${t.vertical ? i ? `
|
|
7796
|
+
${styleText("cyan", $2)} ` : `
|
|
7797
|
+
` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim", H2)} ${styleText("dim", s)}` : `${styleText("green", z2)} ${s}`}
|
|
6879
7798
|
${d2}
|
|
6880
7799
|
`;
|
|
6881
7800
|
}
|
|
6882
7801
|
}
|
|
6883
7802
|
} }).prompt();
|
|
6884
7803
|
};
|
|
7804
|
+
le = (t) => {
|
|
7805
|
+
const r = t.validate;
|
|
7806
|
+
return new et({ ...t, validate(s) {
|
|
7807
|
+
if (s === void 0) return t.defaultValue !== void 0 ? void 0 : r ? r(s) : h.date.messages.required;
|
|
7808
|
+
const i = (u) => u.toISOString().slice(0, 10);
|
|
7809
|
+
if (t.minDate && i(s) < i(t.minDate)) return h.date.messages.afterMin(t.minDate);
|
|
7810
|
+
if (t.maxDate && i(s) > i(t.maxDate)) return h.date.messages.beforeMax(t.maxDate);
|
|
7811
|
+
if (r) return r(s);
|
|
7812
|
+
}, render() {
|
|
7813
|
+
const s = (t?.withGuide ?? h.withGuide) !== false, i = `${`${s ? `${styleText("gray", $2)}
|
|
7814
|
+
` : ""}${M(this.state)} `}${t.message}
|
|
7815
|
+
`, u = this.state !== "initial" ? this.state : "active", n = ce(this, u), o = this.value instanceof Date ? this.formattedValue : "";
|
|
7816
|
+
switch (this.state) {
|
|
7817
|
+
case "error": {
|
|
7818
|
+
const c2 = this.error ? ` ${styleText("yellow", this.error)}` : "", a = s ? `${styleText("yellow", $2)} ` : "", l = s ? styleText("yellow", E2) : "";
|
|
7819
|
+
return `${i.trim()}
|
|
7820
|
+
${a}${n}
|
|
7821
|
+
${l}${c2}
|
|
7822
|
+
`;
|
|
7823
|
+
}
|
|
7824
|
+
case "submit": {
|
|
7825
|
+
const c2 = o ? ` ${styleText("dim", o)}` : "", a = s ? styleText("gray", $2) : "";
|
|
7826
|
+
return `${i}${a}${c2}`;
|
|
7827
|
+
}
|
|
7828
|
+
case "cancel": {
|
|
7829
|
+
const c2 = o ? ` ${styleText(["strikethrough", "dim"], o)}` : "", a = s ? styleText("gray", $2) : "";
|
|
7830
|
+
return `${i}${a}${c2}${o.trim() ? `
|
|
7831
|
+
${a}` : ""}`;
|
|
7832
|
+
}
|
|
7833
|
+
default: {
|
|
7834
|
+
const c2 = s ? `${styleText("cyan", $2)} ` : "", a = s ? styleText("cyan", E2) : "", l = s ? `${styleText("cyan", $2)} ` : "", d2 = this.inlineError ? `
|
|
7835
|
+
${l}${styleText("yellow", this.inlineError)}` : "";
|
|
7836
|
+
return `${i}${c2}${n}${d2}
|
|
7837
|
+
${a}
|
|
7838
|
+
`;
|
|
7839
|
+
}
|
|
7840
|
+
}
|
|
7841
|
+
} }).prompt();
|
|
7842
|
+
};
|
|
7843
|
+
de = { year: "yyyy", month: "mm", day: "dd" };
|
|
6885
7844
|
he = async (t, r) => {
|
|
6886
7845
|
const s = {}, i = Object.keys(t);
|
|
6887
7846
|
for (const u of i) {
|
|
@@ -6896,7 +7855,74 @@ ${d2}
|
|
|
6896
7855
|
}
|
|
6897
7856
|
return s;
|
|
6898
7857
|
};
|
|
6899
|
-
|
|
7858
|
+
pe = (t) => {
|
|
7859
|
+
const { selectableGroups: r = true, groupSpacing: s = 0 } = t, i = (n, o, c2 = []) => {
|
|
7860
|
+
const a = n.label ?? String(n.value), l = typeof n.group == "string", d2 = l && (c2[c2.indexOf(n) + 1] ?? { group: true }), y = l && d2 && d2.group === true, p2 = l ? r ? `${y ? E2 : $2} ` : " " : "";
|
|
7861
|
+
let m = "";
|
|
7862
|
+
if (s > 0 && !l) {
|
|
7863
|
+
const S2 = `
|
|
7864
|
+
${styleText("cyan", $2)}`;
|
|
7865
|
+
m = `${S2.repeat(s - 1)}${S2} `;
|
|
7866
|
+
}
|
|
7867
|
+
if (o === "active") return `${m}${styleText("dim", p2)}${styleText("cyan", et2)} ${a}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`;
|
|
7868
|
+
if (o === "group-active") return `${m}${p2}${styleText("cyan", et2)} ${styleText("dim", a)}`;
|
|
7869
|
+
if (o === "group-active-selected") return `${m}${p2}${styleText("green", U2)} ${styleText("dim", a)}`;
|
|
7870
|
+
if (o === "selected") {
|
|
7871
|
+
const S2 = l || r ? styleText("green", U2) : "";
|
|
7872
|
+
return `${m}${styleText("dim", p2)}${S2} ${styleText("dim", a)}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`;
|
|
7873
|
+
}
|
|
7874
|
+
if (o === "cancelled") return `${styleText(["strikethrough", "dim"], a)}`;
|
|
7875
|
+
if (o === "active-selected") return `${m}${styleText("dim", p2)}${styleText("green", U2)} ${a}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`;
|
|
7876
|
+
if (o === "submitted") return `${styleText("dim", a)}`;
|
|
7877
|
+
const g = l || r ? styleText("dim", J2) : "";
|
|
7878
|
+
return `${m}${styleText("dim", p2)}${g} ${styleText("dim", a)}`;
|
|
7879
|
+
}, u = t.required ?? true;
|
|
7880
|
+
return new it({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValues: t.initialValues, required: u, cursorAt: t.cursorAt, selectableGroups: r, validate(n) {
|
|
7881
|
+
if (u && (n === void 0 || n.length === 0)) return `Please select at least one option.
|
|
7882
|
+
${styleText("reset", styleText("dim", `Press ${styleText(["gray", "bgWhite", "inverse"], " space ")} to select, ${styleText("gray", styleText(["bgWhite", "inverse"], " enter "))} to submit`))}`;
|
|
7883
|
+
}, render() {
|
|
7884
|
+
const n = t.withGuide ?? h.withGuide, o = `${n ? `${styleText("gray", $2)}
|
|
7885
|
+
` : ""}${M(this.state)} ${t.message}
|
|
7886
|
+
`, c2 = this.value ?? [];
|
|
7887
|
+
switch (this.state) {
|
|
7888
|
+
case "submit": {
|
|
7889
|
+
const a = this.options.filter(({ value: d2 }) => c2.includes(d2)).map((d2) => i(d2, "submitted")), l = a.length === 0 ? "" : ` ${a.join(styleText("dim", ", "))}`;
|
|
7890
|
+
return `${o}${n ? styleText("gray", $2) : ""}${l}`;
|
|
7891
|
+
}
|
|
7892
|
+
case "cancel": {
|
|
7893
|
+
const a = this.options.filter(({ value: l }) => c2.includes(l)).map((l) => i(l, "cancelled")).join(styleText("dim", ", "));
|
|
7894
|
+
return `${o}${n ? `${styleText("gray", $2)} ` : ""}${a.trim() ? `${a}${n ? `
|
|
7895
|
+
${styleText("gray", $2)}` : ""}` : ""}`;
|
|
7896
|
+
}
|
|
7897
|
+
case "error": {
|
|
7898
|
+
const a = this.error.split(`
|
|
7899
|
+
`).map((l, d2) => d2 === 0 ? `${n ? `${styleText("yellow", E2)} ` : ""}${styleText("yellow", l)}` : ` ${l}`).join(`
|
|
7900
|
+
`);
|
|
7901
|
+
return `${o}${n ? `${styleText("yellow", $2)} ` : ""}${this.options.map((l, d2, y) => {
|
|
7902
|
+
const p2 = c2.includes(l.value) || l.group === true && this.isGroupSelected(`${l.value}`), m = d2 === this.cursor;
|
|
7903
|
+
return !m && typeof l.group == "string" && this.options[this.cursor].value === l.group ? i(l, p2 ? "group-active-selected" : "group-active", y) : m && p2 ? i(l, "active-selected", y) : p2 ? i(l, "selected", y) : i(l, m ? "active" : "inactive", y);
|
|
7904
|
+
}).join(`
|
|
7905
|
+
${n ? `${styleText("yellow", $2)} ` : ""}`)}
|
|
7906
|
+
${a}
|
|
7907
|
+
`;
|
|
7908
|
+
}
|
|
7909
|
+
default: {
|
|
7910
|
+
const a = this.options.map((d2, y, p2) => {
|
|
7911
|
+
const m = c2.includes(d2.value) || d2.group === true && this.isGroupSelected(`${d2.value}`), g = y === this.cursor, S2 = !g && typeof d2.group == "string" && this.options[this.cursor].value === d2.group;
|
|
7912
|
+
let h2 = "";
|
|
7913
|
+
return S2 ? h2 = i(d2, m ? "group-active-selected" : "group-active", p2) : g && m ? h2 = i(d2, "active-selected", p2) : m ? h2 = i(d2, "selected", p2) : h2 = i(d2, g ? "active" : "inactive", p2), `${y !== 0 && !h2.startsWith(`
|
|
7914
|
+
`) ? " " : ""}${h2}`;
|
|
7915
|
+
}).join(`
|
|
7916
|
+
${n ? styleText("cyan", $2) : ""}`), l = a.startsWith(`
|
|
7917
|
+
`) ? "" : " ";
|
|
7918
|
+
return `${o}${n ? styleText("cyan", $2) : ""}${l}${a}
|
|
7919
|
+
${n ? styleText("cyan", E2) : ""}
|
|
7920
|
+
`;
|
|
7921
|
+
}
|
|
7922
|
+
}
|
|
7923
|
+
} }).prompt();
|
|
7924
|
+
};
|
|
7925
|
+
R2 = { message: (t = [], { symbol: r = styleText("gray", $2), secondarySymbol: s = styleText("gray", $2), output: i = process.stdout, spacing: u = 1, withGuide: n } = {}) => {
|
|
6900
7926
|
const o = [], c2 = n ?? h.withGuide, a = c2 ? s : "", l = c2 ? `${r} ` : "", d2 = c2 ? `${s} ` : "";
|
|
6901
7927
|
for (let p2 = 0; p2 < u; p2++) o.push(a);
|
|
6902
7928
|
const y = Array.isArray(t) ? t : t.split(`
|
|
@@ -6914,7 +7940,7 @@ ${d2}
|
|
|
6914
7940
|
}, success: (t, r) => {
|
|
6915
7941
|
R2.message(t, { ...r, symbol: styleText("green", pt) });
|
|
6916
7942
|
}, step: (t, r) => {
|
|
6917
|
-
R2.message(t, { ...r, symbol: styleText("green",
|
|
7943
|
+
R2.message(t, { ...r, symbol: styleText("green", F2) });
|
|
6918
7944
|
}, warn: (t, r) => {
|
|
6919
7945
|
R2.message(t, { ...r, symbol: styleText("yellow", mt) });
|
|
6920
7946
|
}, warning: (t, r) => {
|
|
@@ -6934,25 +7960,53 @@ ${d2}
|
|
|
6934
7960
|
`);
|
|
6935
7961
|
};
|
|
6936
7962
|
ye = (t = "", r) => {
|
|
6937
|
-
const s = r?.output ?? process.stdout, i = r?.withGuide ?? h.withGuide ? `${styleText("gray", $)}
|
|
7963
|
+
const s = r?.output ?? process.stdout, i = r?.withGuide ?? h.withGuide ? `${styleText("gray", $2)}
|
|
6938
7964
|
${styleText("gray", E2)} ` : "";
|
|
6939
7965
|
s.write(`${i}${t}
|
|
6940
7966
|
|
|
6941
7967
|
`);
|
|
6942
7968
|
};
|
|
7969
|
+
fe = (t) => new rt({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, showSubmit: t.showSubmit, output: t.output, signal: t.signal, input: t.input, render() {
|
|
7970
|
+
const r = t?.withGuide ?? h.withGuide, s = `${`${r ? `${styleText("gray", $2)}
|
|
7971
|
+
` : ""}${M(this.state)} `}${t.message}
|
|
7972
|
+
`, i = t.placeholder ? styleText("inverse", t.placeholder[0]) + styleText("dim", t.placeholder.slice(1)) : styleText(["inverse", "hidden"], "_"), u = this.userInput ? this.userInputWithCursor : i, n = this.value ?? "", o = t.showSubmit ? `
|
|
7973
|
+
${styleText(this.focused === "submit" ? "cyan" : "dim", "[ submit ]")}` : "";
|
|
7974
|
+
switch (this.state) {
|
|
7975
|
+
case "error": {
|
|
7976
|
+
const c2 = `${styleText("yellow", $2)} `, a = r ? W(t.output, u, c2, void 0) : u, l = styleText("yellow", E2);
|
|
7977
|
+
return `${s}${a}
|
|
7978
|
+
${l} ${styleText("yellow", this.error)}${o}
|
|
7979
|
+
`;
|
|
7980
|
+
}
|
|
7981
|
+
case "submit": {
|
|
7982
|
+
const c2 = `${styleText("gray", $2)} `, a = r ? W(t.output, n, c2, void 0, (l) => styleText("dim", l)) : n ? styleText("dim", n) : "";
|
|
7983
|
+
return `${s}${a}`;
|
|
7984
|
+
}
|
|
7985
|
+
case "cancel": {
|
|
7986
|
+
const c2 = `${styleText("gray", $2)} `, a = r ? W(t.output, n, c2, void 0, (l) => styleText(["strikethrough", "dim"], l)) : n ? styleText(["strikethrough", "dim"], n) : "";
|
|
7987
|
+
return `${s}${a}`;
|
|
7988
|
+
}
|
|
7989
|
+
default: {
|
|
7990
|
+
const c2 = r ? `${styleText("cyan", $2)} ` : "", a = r ? styleText("cyan", E2) : "", l = r ? W(t.output, u, c2) : u;
|
|
7991
|
+
return `${s}${l}
|
|
7992
|
+
${a}${o}
|
|
7993
|
+
`;
|
|
7994
|
+
}
|
|
7995
|
+
}
|
|
7996
|
+
} }).prompt();
|
|
6943
7997
|
Q2 = (t, r) => t.split(`
|
|
6944
7998
|
`).map((s) => r(s)).join(`
|
|
6945
7999
|
`);
|
|
6946
8000
|
ve = (t) => {
|
|
6947
8001
|
const r = (i, u) => {
|
|
6948
8002
|
const n = i.label ?? String(i.value);
|
|
6949
|
-
return u === "disabled" ? `${styleText("gray",
|
|
8003
|
+
return u === "disabled" ? `${styleText("gray", J2)} ${Q2(n, (o) => styleText(["strikethrough", "gray"], o))}${i.hint ? ` ${styleText("dim", `(${i.hint ?? "disabled"})`)}` : ""}` : u === "active" ? `${styleText("cyan", et2)} ${n}${i.hint ? ` ${styleText("dim", `(${i.hint})`)}` : ""}` : u === "selected" ? `${styleText("green", U2)} ${Q2(n, (o) => styleText("dim", o))}${i.hint ? ` ${styleText("dim", `(${i.hint})`)}` : ""}` : u === "cancelled" ? `${Q2(n, (o) => styleText(["strikethrough", "dim"], o))}` : u === "active-selected" ? `${styleText("green", U2)} ${n}${i.hint ? ` ${styleText("dim", `(${i.hint})`)}` : ""}` : u === "submitted" ? `${Q2(n, (o) => styleText("dim", o))}` : `${styleText("dim", J2)} ${Q2(n, (o) => styleText("dim", o))}`;
|
|
6950
8004
|
}, s = t.required ?? true;
|
|
6951
8005
|
return new nt({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValues: t.initialValues, required: s, cursorAt: t.cursorAt, validate(i) {
|
|
6952
8006
|
if (s && (i === void 0 || i.length === 0)) return `Please select at least one option.
|
|
6953
8007
|
${styleText("reset", styleText("dim", `Press ${styleText(["gray", "bgWhite", "inverse"], " space ")} to select, ${styleText("gray", styleText("bgWhite", styleText("inverse", " enter ")))} to submit`))}`;
|
|
6954
8008
|
}, render() {
|
|
6955
|
-
const i = t.withGuide ?? h.withGuide, u = W(t.output, t.message, i ? `${yt(this.state)} ` : "", `${M(this.state)} `), n = `${i ? `${styleText("gray", $)}
|
|
8009
|
+
const i = t.withGuide ?? h.withGuide, u = W(t.output, t.message, i ? `${yt(this.state)} ` : "", `${M(this.state)} `), n = `${i ? `${styleText("gray", $2)}
|
|
6956
8010
|
` : ""}${u}
|
|
6957
8011
|
`, o = this.value ?? [], c2 = (a, l) => {
|
|
6958
8012
|
if (a.disabled) return r(a, "disabled");
|
|
@@ -6961,18 +8015,18 @@ ${styleText("reset", styleText("dim", `Press ${styleText(["gray", "bgWhite", "in
|
|
|
6961
8015
|
};
|
|
6962
8016
|
switch (this.state) {
|
|
6963
8017
|
case "submit": {
|
|
6964
|
-
const a = this.options.filter(({ value: d2 }) => o.includes(d2)).map((d2) => r(d2, "submitted")).join(styleText("dim", ", ")) || styleText("dim", "none"), l = W(t.output, a, i ? `${styleText("gray", $)} ` : "");
|
|
8018
|
+
const a = this.options.filter(({ value: d2 }) => o.includes(d2)).map((d2) => r(d2, "submitted")).join(styleText("dim", ", ")) || styleText("dim", "none"), l = W(t.output, a, i ? `${styleText("gray", $2)} ` : "");
|
|
6965
8019
|
return `${n}${l}`;
|
|
6966
8020
|
}
|
|
6967
8021
|
case "cancel": {
|
|
6968
8022
|
const a = this.options.filter(({ value: d2 }) => o.includes(d2)).map((d2) => r(d2, "cancelled")).join(styleText("dim", ", "));
|
|
6969
|
-
if (a.trim() === "") return `${n}${styleText("gray", $)}`;
|
|
6970
|
-
const l = W(t.output, a, i ? `${styleText("gray", $)} ` : "");
|
|
8023
|
+
if (a.trim() === "") return `${n}${styleText("gray", $2)}`;
|
|
8024
|
+
const l = W(t.output, a, i ? `${styleText("gray", $2)} ` : "");
|
|
6971
8025
|
return `${n}${l}${i ? `
|
|
6972
|
-
${styleText("gray", $)}` : ""}`;
|
|
8026
|
+
${styleText("gray", $2)}` : ""}`;
|
|
6973
8027
|
}
|
|
6974
8028
|
case "error": {
|
|
6975
|
-
const a = i ? `${styleText("yellow", $)} ` : "", l = this.error.split(`
|
|
8029
|
+
const a = i ? `${styleText("yellow", $2)} ` : "", l = this.error.split(`
|
|
6976
8030
|
`).map((p2, m) => m === 0 ? `${i ? `${styleText("yellow", E2)} ` : ""}${styleText("yellow", p2)}` : ` ${p2}`).join(`
|
|
6977
8031
|
`), d2 = n.split(`
|
|
6978
8032
|
`).length, y = l.split(`
|
|
@@ -6983,7 +8037,7 @@ ${l}
|
|
|
6983
8037
|
`;
|
|
6984
8038
|
}
|
|
6985
8039
|
default: {
|
|
6986
|
-
const a = i ? `${styleText("cyan", $)} ` : "", l = n.split(`
|
|
8040
|
+
const a = i ? `${styleText("cyan", $2)} ` : "", l = n.split(`
|
|
6987
8041
|
`).length, d2 = i ? 2 : 1;
|
|
6988
8042
|
return `${n}${a}${Y2({ output: t.output, options: this.options, cursor: this.cursor, maxItems: t.maxItems, columnPadding: a.length, rowPadding: l + d2, style: c2 }).join(`
|
|
6989
8043
|
${a}`)}
|
|
@@ -7004,97 +8058,120 @@ ${i ? styleText("cyan", E2) : ""}
|
|
|
7004
8058
|
`).map(n), ""], c2 = dist_default2(r), a = Math.max(o.reduce((p2, m) => {
|
|
7005
8059
|
const g = dist_default2(m);
|
|
7006
8060
|
return g > p2 ? g : p2;
|
|
7007
|
-
}, 0), c2) + 2, l = o.map((p2) => `${styleText("gray", $)} ${p2}${" ".repeat(a - dist_default2(p2))}${styleText("gray", $)}`).join(`
|
|
7008
|
-
`), d2 = u ? `${styleText("gray", $)}
|
|
8061
|
+
}, 0), c2) + 2, l = o.map((p2) => `${styleText("gray", $2)} ${p2}${" ".repeat(a - dist_default2(p2))}${styleText("gray", $2)}`).join(`
|
|
8062
|
+
`), d2 = u ? `${styleText("gray", $2)}
|
|
7009
8063
|
` : "", y = u ? xt : dt;
|
|
7010
|
-
i.write(`${d2}${styleText("green",
|
|
8064
|
+
i.write(`${d2}${styleText("green", F2)} ${styleText("reset", r)} ${styleText("gray", st2.repeat(Math.max(a - c2 - 1, 1)) + ct)}
|
|
7011
8065
|
${l}
|
|
7012
|
-
${styleText("gray", y +
|
|
8066
|
+
${styleText("gray", y + st2.repeat(a + 2) + $t)}
|
|
7013
8067
|
`);
|
|
7014
8068
|
};
|
|
7015
8069
|
Ce = (t) => new ot({ validate: t.validate, mask: t.mask ?? Gt, signal: t.signal, input: t.input, output: t.output, render() {
|
|
7016
|
-
const r = t.withGuide ?? h.withGuide, s = `${r ? `${styleText("gray", $)}
|
|
8070
|
+
const r = t.withGuide ?? h.withGuide, s = `${r ? `${styleText("gray", $2)}
|
|
7017
8071
|
` : ""}${M(this.state)} ${t.message}
|
|
7018
8072
|
`, i = this.userInputWithCursor, u = this.masked;
|
|
7019
8073
|
switch (this.state) {
|
|
7020
8074
|
case "error": {
|
|
7021
|
-
const n = r ? `${styleText("yellow", $)} ` : "", o = r ? `${styleText("yellow", E2)} ` : "", c2 = u ?? "";
|
|
8075
|
+
const n = r ? `${styleText("yellow", $2)} ` : "", o = r ? `${styleText("yellow", E2)} ` : "", c2 = u ?? "";
|
|
7022
8076
|
return t.clearOnError && this.clear(), `${s.trim()}
|
|
7023
8077
|
${n}${c2}
|
|
7024
8078
|
${o}${styleText("yellow", this.error)}
|
|
7025
8079
|
`;
|
|
7026
8080
|
}
|
|
7027
8081
|
case "submit": {
|
|
7028
|
-
const n = r ? `${styleText("gray", $)} ` : "", o = u ? styleText("dim", u) : "";
|
|
8082
|
+
const n = r ? `${styleText("gray", $2)} ` : "", o = u ? styleText("dim", u) : "";
|
|
7029
8083
|
return `${s}${n}${o}`;
|
|
7030
8084
|
}
|
|
7031
8085
|
case "cancel": {
|
|
7032
|
-
const n = r ? `${styleText("gray", $)} ` : "", o = u ? styleText(["strikethrough", "dim"], u) : "";
|
|
8086
|
+
const n = r ? `${styleText("gray", $2)} ` : "", o = u ? styleText(["strikethrough", "dim"], u) : "";
|
|
7033
8087
|
return `${s}${n}${o}${u && r ? `
|
|
7034
|
-
${styleText("gray", $)}` : ""}`;
|
|
8088
|
+
${styleText("gray", $2)}` : ""}`;
|
|
7035
8089
|
}
|
|
7036
8090
|
default: {
|
|
7037
|
-
const n = r ? `${styleText("cyan", $)} ` : "", o = r ? styleText("cyan", E2) : "";
|
|
8091
|
+
const n = r ? `${styleText("cyan", $2)} ` : "", o = r ? styleText("cyan", E2) : "";
|
|
7038
8092
|
return `${s}${n}${i}
|
|
7039
8093
|
${o}
|
|
7040
8094
|
`;
|
|
7041
8095
|
}
|
|
7042
8096
|
}
|
|
7043
8097
|
} }).prompt();
|
|
8098
|
+
Te = (t) => {
|
|
8099
|
+
const r = t.validate;
|
|
8100
|
+
return At({ ...t, initialUserInput: t.initialValue ?? t.root ?? process.cwd(), maxItems: 5, validate(s) {
|
|
8101
|
+
if (!Array.isArray(s)) {
|
|
8102
|
+
if (!s) return "Please select a path";
|
|
8103
|
+
if (r) return r(s);
|
|
8104
|
+
}
|
|
8105
|
+
}, options() {
|
|
8106
|
+
const s = this.userInput;
|
|
8107
|
+
if (s === "") return [];
|
|
8108
|
+
try {
|
|
8109
|
+
let i;
|
|
8110
|
+
existsSync(s) ? lstatSync(s).isDirectory() && (!t.directory || s.endsWith("/")) ? i = s : i = dirname(s) : i = dirname(s);
|
|
8111
|
+
const u = s.length > 1 && s.endsWith("/") ? s.slice(0, -1) : s;
|
|
8112
|
+
return readdirSync(i).map((n) => {
|
|
8113
|
+
const o = join(i, n), c2 = lstatSync(o);
|
|
8114
|
+
return { name: n, path: o, isDirectory: c2.isDirectory() };
|
|
8115
|
+
}).filter(({ path: n, isDirectory: o }) => n.startsWith(u) && (o || !t.directory)).map((n) => ({ value: n.path }));
|
|
8116
|
+
} catch {
|
|
8117
|
+
return [];
|
|
8118
|
+
}
|
|
8119
|
+
} });
|
|
8120
|
+
};
|
|
7044
8121
|
_e = (t) => styleText("magenta", t);
|
|
7045
|
-
ft = ({ indicator: t = "dots", onCancel: r, output: s = process.stdout, cancelMessage: i, errorMessage: u, frames: n =
|
|
8122
|
+
ft = ({ indicator: t = "dots", onCancel: r, output: s = process.stdout, cancelMessage: i, errorMessage: u, frames: n = tt2 ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], delay: o = tt2 ? 80 : 120, signal: c2, ...a } = {}) => {
|
|
7046
8123
|
const l = at2();
|
|
7047
8124
|
let d2, y, p2 = false, m = false, g = "", S2, h2 = performance.now();
|
|
7048
|
-
const f = A(s), v2 = a?.styleFrame ?? _e, T = (
|
|
7049
|
-
const V2 =
|
|
7050
|
-
m =
|
|
8125
|
+
const f = A(s), v2 = a?.styleFrame ?? _e, T = (I2) => {
|
|
8126
|
+
const V2 = I2 > 1 ? u ?? h.messages.error : i ?? h.messages.cancel;
|
|
8127
|
+
m = I2 === 1, p2 && (W2(V2, I2), m && typeof r == "function" && r());
|
|
7051
8128
|
}, C2 = () => T(2), b2 = () => T(1), G2 = () => {
|
|
7052
8129
|
process.on("uncaughtExceptionMonitor", C2), process.on("unhandledRejection", C2), process.on("SIGINT", b2), process.on("SIGTERM", b2), process.on("exit", T), c2 && c2.addEventListener("abort", b2);
|
|
7053
|
-
},
|
|
8130
|
+
}, x2 = () => {
|
|
7054
8131
|
process.removeListener("uncaughtExceptionMonitor", C2), process.removeListener("unhandledRejection", C2), process.removeListener("SIGINT", b2), process.removeListener("SIGTERM", b2), process.removeListener("exit", T), c2 && c2.removeEventListener("abort", b2);
|
|
7055
8132
|
}, A2 = () => {
|
|
7056
8133
|
if (S2 === void 0) return;
|
|
7057
8134
|
l && s.write(`
|
|
7058
8135
|
`);
|
|
7059
|
-
const
|
|
8136
|
+
const I2 = wrapAnsi(S2, f, { hard: true, trim: false }).split(`
|
|
7060
8137
|
`);
|
|
7061
|
-
|
|
7062
|
-
},
|
|
7063
|
-
const V2 = (performance.now() -
|
|
7064
|
-
return
|
|
7065
|
-
}, D2 = a.withGuide ?? h.withGuide, rt2 = (
|
|
7066
|
-
p2 = true, d2 = R({ output: s }), g =
|
|
8138
|
+
I2.length > 1 && s.write(import_sisteransi2.cursor.up(I2.length - 1)), s.write(import_sisteransi2.cursor.to(0)), s.write(import_sisteransi2.erase.down());
|
|
8139
|
+
}, P2 = (I2) => I2.replace(/\.+$/, ""), N2 = (I2) => {
|
|
8140
|
+
const V2 = (performance.now() - I2) / 1e3, B2 = Math.floor(V2 / 60), L2 = Math.floor(V2 % 60);
|
|
8141
|
+
return B2 > 0 ? `[${B2}m ${L2}s]` : `[${L2}s]`;
|
|
8142
|
+
}, D2 = a.withGuide ?? h.withGuide, rt2 = (I2 = "") => {
|
|
8143
|
+
p2 = true, d2 = R({ output: s }), g = P2(I2), h2 = performance.now(), D2 && s.write(`${styleText("gray", $2)}
|
|
7067
8144
|
`);
|
|
7068
|
-
let V2 = 0,
|
|
8145
|
+
let V2 = 0, B2 = 0;
|
|
7069
8146
|
G2(), y = setInterval(() => {
|
|
7070
8147
|
if (l && g === S2) return;
|
|
7071
8148
|
A2(), S2 = g;
|
|
7072
8149
|
const L2 = v2(n[V2]);
|
|
7073
|
-
let
|
|
7074
|
-
if (l)
|
|
7075
|
-
else if (t === "timer")
|
|
8150
|
+
let Z2;
|
|
8151
|
+
if (l) Z2 = `${L2} ${g}...`;
|
|
8152
|
+
else if (t === "timer") Z2 = `${L2} ${g} ${N2(h2)}`;
|
|
7076
8153
|
else {
|
|
7077
|
-
const kt = ".".repeat(Math.floor(
|
|
7078
|
-
|
|
8154
|
+
const kt = ".".repeat(Math.floor(B2)).slice(0, 3);
|
|
8155
|
+
Z2 = `${L2} ${g}${kt}`;
|
|
7079
8156
|
}
|
|
7080
|
-
const Nt = wrapAnsi(
|
|
7081
|
-
s.write(Nt), V2 = V2 + 1 < n.length ? V2 + 1 : 0,
|
|
8157
|
+
const Nt = wrapAnsi(Z2, f, { hard: true, trim: false });
|
|
8158
|
+
s.write(Nt), V2 = V2 + 1 < n.length ? V2 + 1 : 0, B2 = B2 < 4 ? B2 + 0.125 : 0;
|
|
7082
8159
|
}, o);
|
|
7083
|
-
}, W2 = (
|
|
8160
|
+
}, W2 = (I2 = "", V2 = 0, B2 = false) => {
|
|
7084
8161
|
if (!p2) return;
|
|
7085
8162
|
p2 = false, clearInterval(y), A2();
|
|
7086
|
-
const L2 = V2 === 0 ? styleText("green",
|
|
7087
|
-
g =
|
|
8163
|
+
const L2 = V2 === 0 ? styleText("green", F2) : V2 === 1 ? styleText("red", ot2) : styleText("red", ut2);
|
|
8164
|
+
g = I2 ?? g, B2 || (t === "timer" ? s.write(`${L2} ${g} ${N2(h2)}
|
|
7088
8165
|
`) : s.write(`${L2} ${g}
|
|
7089
|
-
`)),
|
|
8166
|
+
`)), x2(), d2();
|
|
7090
8167
|
};
|
|
7091
|
-
return { start: rt2, stop: (
|
|
7092
|
-
g =
|
|
7093
|
-
}, cancel: (
|
|
8168
|
+
return { start: rt2, stop: (I2 = "") => W2(I2, 0), message: (I2 = "") => {
|
|
8169
|
+
g = P2(I2 ?? g);
|
|
8170
|
+
}, cancel: (I2 = "") => W2(I2, 1), error: (I2 = "") => W2(I2, 2), clear: () => W2("", 0, true), get isCancelled() {
|
|
7094
8171
|
return m;
|
|
7095
8172
|
} };
|
|
7096
8173
|
};
|
|
7097
|
-
|
|
8174
|
+
Vt = { light: w2("\u2500", "-"), heavy: w2("\u2501", "="), block: w2("\u2588", "#") };
|
|
7098
8175
|
it2 = (t, r) => t.includes(`
|
|
7099
8176
|
`) ? t.split(`
|
|
7100
8177
|
`).map((s) => r(s)).join(`
|
|
@@ -7104,7 +8181,7 @@ ${o}
|
|
|
7104
8181
|
const u = s.label ?? String(s.value);
|
|
7105
8182
|
switch (i) {
|
|
7106
8183
|
case "disabled":
|
|
7107
|
-
return `${styleText("gray",
|
|
8184
|
+
return `${styleText("gray", H2)} ${it2(u, (n) => styleText("gray", n))}${s.hint ? ` ${styleText("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
|
|
7108
8185
|
case "selected":
|
|
7109
8186
|
return `${it2(u, (n) => styleText("dim", n))}`;
|
|
7110
8187
|
case "active":
|
|
@@ -7112,25 +8189,25 @@ ${o}
|
|
|
7112
8189
|
case "cancelled":
|
|
7113
8190
|
return `${it2(u, (n) => styleText(["strikethrough", "dim"], n))}`;
|
|
7114
8191
|
default:
|
|
7115
|
-
return `${styleText("dim",
|
|
8192
|
+
return `${styleText("dim", H2)} ${it2(u, (n) => styleText("dim", n))}`;
|
|
7116
8193
|
}
|
|
7117
8194
|
};
|
|
7118
8195
|
return new ut({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue, render() {
|
|
7119
|
-
const s = t.withGuide ?? h.withGuide, i = `${M(this.state)} `, u = `${yt(this.state)} `, n = W(t.output, t.message, u, i), o = `${s ? `${styleText("gray", $)}
|
|
8196
|
+
const s = t.withGuide ?? h.withGuide, i = `${M(this.state)} `, u = `${yt(this.state)} `, n = W(t.output, t.message, u, i), o = `${s ? `${styleText("gray", $2)}
|
|
7120
8197
|
` : ""}${n}
|
|
7121
8198
|
`;
|
|
7122
8199
|
switch (this.state) {
|
|
7123
8200
|
case "submit": {
|
|
7124
|
-
const c2 = s ? `${styleText("gray", $)} ` : "", a = W(t.output, r(this.options[this.cursor], "selected"), c2);
|
|
8201
|
+
const c2 = s ? `${styleText("gray", $2)} ` : "", a = W(t.output, r(this.options[this.cursor], "selected"), c2);
|
|
7125
8202
|
return `${o}${a}`;
|
|
7126
8203
|
}
|
|
7127
8204
|
case "cancel": {
|
|
7128
|
-
const c2 = s ? `${styleText("gray", $)} ` : "", a = W(t.output, r(this.options[this.cursor], "cancelled"), c2);
|
|
8205
|
+
const c2 = s ? `${styleText("gray", $2)} ` : "", a = W(t.output, r(this.options[this.cursor], "cancelled"), c2);
|
|
7129
8206
|
return `${o}${a}${s ? `
|
|
7130
|
-
${styleText("gray", $)}` : ""}`;
|
|
8207
|
+
${styleText("gray", $2)}` : ""}`;
|
|
7131
8208
|
}
|
|
7132
8209
|
default: {
|
|
7133
|
-
const c2 = s ? `${styleText("cyan", $)} ` : "", a = s ? styleText("cyan", E2) : "", l = o.split(`
|
|
8210
|
+
const c2 = s ? `${styleText("cyan", $2)} ` : "", a = s ? styleText("cyan", E2) : "", l = o.split(`
|
|
7134
8211
|
`).length, d2 = s ? 2 : 1;
|
|
7135
8212
|
return `${o}${c2}${Y2({ output: t.output, cursor: this.cursor, options: this.options, maxItems: t.maxItems, columnPadding: c2.length, rowPadding: l + d2, style: (y, p2) => r(y, y.disabled ? "disabled" : p2 ? "active" : "inactive") }).join(`
|
|
7136
8213
|
${c2}`)}
|
|
@@ -7140,30 +8217,157 @@ ${a}
|
|
|
7140
8217
|
}
|
|
7141
8218
|
} }).prompt();
|
|
7142
8219
|
};
|
|
7143
|
-
|
|
8220
|
+
Ge = (t) => {
|
|
8221
|
+
const r = (s, i = "inactive") => {
|
|
8222
|
+
const u = s.label ?? String(s.value);
|
|
8223
|
+
return i === "selected" ? `${styleText("dim", u)}` : i === "cancelled" ? `${styleText(["strikethrough", "dim"], u)}` : i === "active" ? `${styleText(["bgCyan", "gray"], ` ${s.value} `)} ${u}${s.hint ? ` ${styleText("dim", `(${s.hint})`)}` : ""}` : `${styleText(["gray", "bgWhite", "inverse"], ` ${s.value} `)} ${u}${s.hint ? ` ${styleText("dim", `(${s.hint})`)}` : ""}`;
|
|
8224
|
+
};
|
|
8225
|
+
return new at({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue, caseSensitive: t.caseSensitive, render() {
|
|
8226
|
+
const s = t.withGuide ?? h.withGuide, i = `${s ? `${styleText("gray", $2)}
|
|
8227
|
+
` : ""}${M(this.state)} ${t.message}
|
|
8228
|
+
`;
|
|
8229
|
+
switch (this.state) {
|
|
8230
|
+
case "submit": {
|
|
8231
|
+
const u = s ? `${styleText("gray", $2)} ` : "", n = this.options.find((c2) => c2.value === this.value) ?? t.options[0], o = W(t.output, r(n, "selected"), u);
|
|
8232
|
+
return `${i}${o}`;
|
|
8233
|
+
}
|
|
8234
|
+
case "cancel": {
|
|
8235
|
+
const u = s ? `${styleText("gray", $2)} ` : "", n = W(t.output, r(this.options[0], "cancelled"), u);
|
|
8236
|
+
return `${i}${n}${s ? `
|
|
8237
|
+
${styleText("gray", $2)}` : ""}`;
|
|
8238
|
+
}
|
|
8239
|
+
default: {
|
|
8240
|
+
const u = s ? `${styleText("cyan", $2)} ` : "", n = s ? styleText("cyan", E2) : "", o = this.options.map((c2, a) => W(t.output, r(c2, a === this.cursor ? "active" : "inactive"), u)).join(`
|
|
8241
|
+
`);
|
|
8242
|
+
return `${i}${o}
|
|
8243
|
+
${n}
|
|
8244
|
+
`;
|
|
8245
|
+
}
|
|
8246
|
+
}
|
|
8247
|
+
} }).prompt();
|
|
8248
|
+
};
|
|
8249
|
+
jt = `${styleText("gray", $2)} `;
|
|
8250
|
+
K2 = { message: async (t, { symbol: r = styleText("gray", $2) } = {}) => {
|
|
8251
|
+
process.stdout.write(`${styleText("gray", $2)}
|
|
8252
|
+
${r} `);
|
|
8253
|
+
let s = 3;
|
|
8254
|
+
for await (let i of t) {
|
|
8255
|
+
i = i.replace(/\n/g, `
|
|
8256
|
+
${jt}`), i.includes(`
|
|
8257
|
+
`) && (s = 3 + stripVTControlCharacters(i.slice(i.lastIndexOf(`
|
|
8258
|
+
`))).length);
|
|
8259
|
+
const u = stripVTControlCharacters(i).length;
|
|
8260
|
+
s + u < process.stdout.columns ? (s += u, process.stdout.write(i)) : (process.stdout.write(`
|
|
8261
|
+
${jt}${i.trimStart()}`), s = 3 + stripVTControlCharacters(i.trimStart()).length);
|
|
8262
|
+
}
|
|
8263
|
+
process.stdout.write(`
|
|
8264
|
+
`);
|
|
8265
|
+
}, info: (t) => K2.message(t, { symbol: styleText("blue", ht2) }), success: (t) => K2.message(t, { symbol: styleText("green", pt) }), step: (t) => K2.message(t, { symbol: styleText("green", F2) }), warn: (t) => K2.message(t, { symbol: styleText("yellow", mt) }), warning: (t) => K2.warn(t), error: (t) => K2.message(t, { symbol: styleText("red", gt) }) };
|
|
8266
|
+
xe = async (t, r) => {
|
|
8267
|
+
for (const s of t) {
|
|
8268
|
+
if (s.enabled === false) continue;
|
|
8269
|
+
const i = ft(r);
|
|
8270
|
+
i.start(s.title);
|
|
8271
|
+
const u = await s.task(i.message);
|
|
8272
|
+
i.stop(u || s.title);
|
|
8273
|
+
}
|
|
8274
|
+
};
|
|
8275
|
+
Oe = (t) => t.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, "");
|
|
8276
|
+
Me = (t) => {
|
|
8277
|
+
const r = t.output ?? process.stdout, s = A(r), i = styleText("gray", $2), u = t.spacing ?? 1, n = 3, o = t.retainLog === true, c2 = !at2() && Tt(r);
|
|
8278
|
+
r.write(`${i}
|
|
8279
|
+
`), r.write(`${styleText("green", F2)} ${t.title}
|
|
8280
|
+
`);
|
|
8281
|
+
for (let h2 = 0; h2 < u; h2++) r.write(`${i}
|
|
8282
|
+
`);
|
|
8283
|
+
const a = [{ value: "", full: "" }];
|
|
8284
|
+
let l = false;
|
|
8285
|
+
const d2 = (h2) => {
|
|
8286
|
+
if (a.length === 0) return;
|
|
8287
|
+
let f = 0;
|
|
8288
|
+
h2 && (f += u + 2);
|
|
8289
|
+
for (const v2 of a) {
|
|
8290
|
+
const { value: T, result: C2 } = v2;
|
|
8291
|
+
let b2 = C2?.message ?? T;
|
|
8292
|
+
if (b2.length === 0) continue;
|
|
8293
|
+
C2 === void 0 && v2.header !== void 0 && v2.header !== "" && (b2 += `
|
|
8294
|
+
${v2.header}`);
|
|
8295
|
+
const G2 = b2.split(`
|
|
8296
|
+
`).reduce((x2, A2) => A2 === "" ? x2 + 1 : x2 + Math.ceil((A2.length + n) / s), 0);
|
|
8297
|
+
f += G2;
|
|
8298
|
+
}
|
|
8299
|
+
f > 0 && (f += 1, r.write(import_sisteransi2.erase.lines(f)));
|
|
8300
|
+
}, y = (h2, f, v2) => {
|
|
8301
|
+
const T = v2 ? `${h2.full}
|
|
8302
|
+
${h2.value}` : h2.value;
|
|
8303
|
+
h2.header !== void 0 && h2.header !== "" && R2.message(h2.header.split(`
|
|
8304
|
+
`).map((C2) => styleText("bold", C2)), { output: r, secondarySymbol: i, symbol: i, spacing: 0 }), R2.message(T.split(`
|
|
8305
|
+
`).map((C2) => styleText("dim", C2)), { output: r, secondarySymbol: i, symbol: i, spacing: f ?? u });
|
|
8306
|
+
}, p2 = () => {
|
|
8307
|
+
for (const h2 of a) {
|
|
8308
|
+
const { header: f, value: v2, full: T } = h2;
|
|
8309
|
+
(f === void 0 || f.length === 0) && v2.length === 0 || y(h2, void 0, o === true && T.length > 0);
|
|
8310
|
+
}
|
|
8311
|
+
}, m = (h2, f, v2) => {
|
|
8312
|
+
if (d2(false), (v2?.raw !== true || !l) && h2.value !== "" && (h2.value += `
|
|
8313
|
+
`), h2.value += Oe(f), l = v2?.raw === true, t.limit !== void 0) {
|
|
8314
|
+
const T = h2.value.split(`
|
|
8315
|
+
`), C2 = T.length - t.limit;
|
|
8316
|
+
if (C2 > 0) {
|
|
8317
|
+
const b2 = T.splice(0, C2);
|
|
8318
|
+
o && (h2.full += (h2.full === "" ? "" : `
|
|
8319
|
+
`) + b2.join(`
|
|
8320
|
+
`));
|
|
8321
|
+
}
|
|
8322
|
+
h2.value = T.join(`
|
|
8323
|
+
`);
|
|
8324
|
+
}
|
|
8325
|
+
c2 && g();
|
|
8326
|
+
}, g = () => {
|
|
8327
|
+
for (const h2 of a) h2.result ? h2.result.status === "error" ? R2.error(h2.result.message, { output: r, secondarySymbol: i, spacing: 0 }) : R2.success(h2.result.message, { output: r, secondarySymbol: i, spacing: 0 }) : h2.value !== "" && y(h2, 0);
|
|
8328
|
+
}, S2 = (h2, f) => {
|
|
8329
|
+
d2(false), h2.result = f, c2 && g();
|
|
8330
|
+
};
|
|
8331
|
+
return { message(h2, f) {
|
|
8332
|
+
m(a[0], h2, f);
|
|
8333
|
+
}, group(h2) {
|
|
8334
|
+
const f = { header: h2, value: "", full: "" };
|
|
8335
|
+
return a.push(f), { message(v2, T) {
|
|
8336
|
+
m(f, v2, T);
|
|
8337
|
+
}, error(v2) {
|
|
8338
|
+
S2(f, { status: "error", message: v2 });
|
|
8339
|
+
}, success(v2) {
|
|
8340
|
+
S2(f, { status: "success", message: v2 });
|
|
8341
|
+
} };
|
|
8342
|
+
}, error(h2, f) {
|
|
8343
|
+
d2(true), R2.error(h2, { output: r, secondarySymbol: i, spacing: 1 }), f?.showLog !== false && p2(), a.splice(1, a.length - 1), a[0].value = "", a[0].full = "";
|
|
8344
|
+
}, success(h2, f) {
|
|
8345
|
+
d2(true), R2.success(h2, { output: r, secondarySymbol: i, spacing: 1 }), f?.showLog === true && p2(), a.splice(1, a.length - 1), a[0].value = "", a[0].full = "";
|
|
8346
|
+
} };
|
|
8347
|
+
};
|
|
7144
8348
|
Re = (t) => new ht({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, output: t.output, signal: t.signal, input: t.input, render() {
|
|
7145
|
-
const r = t?.withGuide ?? h.withGuide, s = `${`${r ? `${styleText("gray", $)}
|
|
8349
|
+
const r = t?.withGuide ?? h.withGuide, s = `${`${r ? `${styleText("gray", $2)}
|
|
7146
8350
|
` : ""}${M(this.state)} `}${t.message}
|
|
7147
8351
|
`, i = t.placeholder ? styleText("inverse", t.placeholder[0]) + styleText("dim", t.placeholder.slice(1)) : styleText(["inverse", "hidden"], "_"), u = this.userInput ? this.userInputWithCursor : i, n = this.value ?? "";
|
|
7148
8352
|
switch (this.state) {
|
|
7149
8353
|
case "error": {
|
|
7150
|
-
const o = this.error ? ` ${styleText("yellow", this.error)}` : "", c2 = r ? `${styleText("yellow", $)} ` : "", a = r ? styleText("yellow", E2) : "";
|
|
8354
|
+
const o = this.error ? ` ${styleText("yellow", this.error)}` : "", c2 = r ? `${styleText("yellow", $2)} ` : "", a = r ? styleText("yellow", E2) : "";
|
|
7151
8355
|
return `${s.trim()}
|
|
7152
8356
|
${c2}${u}
|
|
7153
8357
|
${a}${o}
|
|
7154
8358
|
`;
|
|
7155
8359
|
}
|
|
7156
8360
|
case "submit": {
|
|
7157
|
-
const o = n ? ` ${styleText("dim", n)}` : "", c2 = r ? styleText("gray", $) : "";
|
|
8361
|
+
const o = n ? ` ${styleText("dim", n)}` : "", c2 = r ? styleText("gray", $2) : "";
|
|
7158
8362
|
return `${s}${c2}${o}`;
|
|
7159
8363
|
}
|
|
7160
8364
|
case "cancel": {
|
|
7161
|
-
const o = n ? ` ${styleText(["strikethrough", "dim"], n)}` : "", c2 = r ? styleText("gray", $) : "";
|
|
8365
|
+
const o = n ? ` ${styleText(["strikethrough", "dim"], n)}` : "", c2 = r ? styleText("gray", $2) : "";
|
|
7162
8366
|
return `${s}${c2}${o}${n.trim() ? `
|
|
7163
8367
|
${c2}` : ""}`;
|
|
7164
8368
|
}
|
|
7165
8369
|
default: {
|
|
7166
|
-
const o = r ? `${styleText("cyan", $)} ` : "", c2 = r ? styleText("cyan", E2) : "";
|
|
8370
|
+
const o = r ? `${styleText("cyan", $2)} ` : "", c2 = r ? styleText("cyan", E2) : "";
|
|
7167
8371
|
return `${s}${o}${u}
|
|
7168
8372
|
${c2}
|
|
7169
8373
|
`;
|
|
@@ -7172,212 +8376,8 @@ ${c2}
|
|
|
7172
8376
|
} }).prompt();
|
|
7173
8377
|
}
|
|
7174
8378
|
});
|
|
7175
|
-
function aiContextBody() {
|
|
7176
|
-
return `## keynv (secrets)
|
|
7177
|
-
|
|
7178
|
-
This project uses [keynv](https://keynv.dev) for secrets. There is a \`.keynv.env\` file at the project root containing **alias references** like \`OPENAI_API_KEY=@projectname.dev.openai-key\` \u2014 these are NOT real values, they are references to secrets stored in the keynv vault.
|
|
7179
8379
|
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
- **\`.keynv.env\`** \u2014 checked into git, contains aliases. Safe to read, edit, commit.
|
|
7183
|
-
- **Vault** \u2014 holds the real values. The \`keynv\` CLI reads it on demand.
|
|
7184
|
-
- **\`keynv exec -- <command>\`** \u2014 forks the command in a subprocess where the real values are injected into env vars. The parent process (where you, the AI agent, run) NEVER sees the real values.
|
|
7185
|
-
- **Redactor** \u2014 pipes subprocess stdout/stderr through a masker before they reach this terminal. Even if a script accidentally echoes a secret, you see \`<REDACTED:...>\` here.
|
|
7186
|
-
|
|
7187
|
-
### What you should do
|
|
7188
|
-
|
|
7189
|
-
When the user asks about secrets or env vars, follow this decision tree:
|
|
7190
|
-
|
|
7191
|
-
| User intent | Run / suggest |
|
|
7192
|
-
|---|---|
|
|
7193
|
-
| "Add a new API key" / "set up a secret" | \`keynv secret create\` (interactive prompt picks project + env + key) |
|
|
7194
|
-
| "I have a \`.env\`, migrate it" | \`keynv init\` (you're seeing this file because that already happened) |
|
|
7195
|
-
| "Run the app / dev server / tests" | \`keynv exec -- <their existing command>\` (auto-loads \`.keynv.env\`) |
|
|
7196
|
-
| "Show me the value of X" | \`keynv secret get @alias\` \u2014 but copy to clipboard, do NOT print the value into chat / terminal |
|
|
7197
|
-
| "Rotate this key" | \`keynv secret rotate @alias\` |
|
|
7198
|
-
| "Add a new env var to the project" | Edit \`.keynv.env\` and add \`NAME=@project.env.key\` (after creating the secret with \`keynv secret create\`) |
|
|
7199
|
-
| "Who has access?" | \`keynv member list <project>\` |
|
|
7200
|
-
|
|
7201
|
-
### Hard rules \u2014 do not violate
|
|
7202
|
-
|
|
7203
|
-
1. **Never print resolved secret values** to the chat, terminal, log, or any file. The user's editor / scrollback / chat history is an attack surface.
|
|
7204
|
-
2. **Never write a \`.env\` file** (or any file) containing real secret values. The whole point of keynv is that those don't exist on disk.
|
|
7205
|
-
3. **Never edit \`.keynv.env\` to substitute resolved values for aliases.** The file should only ever contain \`@project.env.key\` references and plain non-secret literals.
|
|
7206
|
-
4. **Use \`keynv exec --\` to run commands that need env vars.** Don't try to load \`.keynv.env\` yourself by parsing it manually; the wrapper handles resolution + redaction + subprocess isolation.
|
|
7207
|
-
5. **If a tool fails with "blocked by keynv-guard" or similar**, do NOT try to work around it. Tell the user \u2014 that's a sign of a misconfiguration, not an obstacle to bypass.
|
|
7208
|
-
6. **Treat the alias literal (\`@project.env.key\`) as the canonical reference**, never the resolved value. When you write code, configs, or commands that need a secret, write the alias.
|
|
7209
|
-
|
|
7210
|
-
### Quick reference
|
|
7211
|
-
|
|
7212
|
-
\`\`\`bash
|
|
7213
|
-
keynv # interactive TUI menu (pick projects, secrets, members)
|
|
7214
|
-
keynv exec -- <cmd> # run cmd with .keynv.env loaded
|
|
7215
|
-
keynv secret create # walk through creating a new secret
|
|
7216
|
-
keynv secret list <project> # list aliases (no values)
|
|
7217
|
-
keynv whoami # who am I logged in as
|
|
7218
|
-
keynv --help # full command list
|
|
7219
|
-
\`\`\`
|
|
7220
|
-
|
|
7221
|
-
If \`.keynv.env\` is missing or empty, the user probably hasn't run \`keynv init\` yet \u2014 suggest they do so before they paste a secret into a \`.env\`.`;
|
|
7222
|
-
}
|
|
7223
|
-
function renderKeynvBlock() {
|
|
7224
|
-
return `${KEYNV_BLOCK_START}
|
|
7225
|
-
${aiContextBody()}
|
|
7226
|
-
${KEYNV_BLOCK_END}`;
|
|
7227
|
-
}
|
|
7228
|
-
function writeAiContext(rootPath) {
|
|
7229
|
-
const path = join(rootPath, AGENTS_FILE_BASENAME);
|
|
7230
|
-
const block = renderKeynvBlock();
|
|
7231
|
-
if (!existsSync(path)) {
|
|
7232
|
-
const initial = `# Agent guidance for this project
|
|
7233
|
-
|
|
7234
|
-
${block}
|
|
7235
|
-
`;
|
|
7236
|
-
writeFileSync(path, initial);
|
|
7237
|
-
return "created";
|
|
7238
|
-
}
|
|
7239
|
-
const existing = readFileSync(path, "utf8");
|
|
7240
|
-
const startIdx = existing.indexOf(KEYNV_BLOCK_START);
|
|
7241
|
-
const endIdx = existing.indexOf(KEYNV_BLOCK_END);
|
|
7242
|
-
if (startIdx >= 0 && endIdx > startIdx) {
|
|
7243
|
-
const before = existing.slice(0, startIdx);
|
|
7244
|
-
const after = existing.slice(endIdx + KEYNV_BLOCK_END.length);
|
|
7245
|
-
const next = `${before}${block}${after}`;
|
|
7246
|
-
if (next === existing) return "unchanged";
|
|
7247
|
-
writeFileSync(path, next);
|
|
7248
|
-
return "updated";
|
|
7249
|
-
}
|
|
7250
|
-
const sep = existing.length === 0 ? "" : existing.endsWith("\n\n") ? "" : existing.endsWith("\n") ? "\n" : "\n\n";
|
|
7251
|
-
const trailingNewline = existing.endsWith("\n") ? "" : "\n";
|
|
7252
|
-
writeFileSync(path, `${existing}${trailingNewline}${sep}${block}
|
|
7253
|
-
`);
|
|
7254
|
-
return "appended";
|
|
7255
|
-
}
|
|
7256
|
-
var AGENTS_FILE_BASENAME, KEYNV_BLOCK_START, KEYNV_BLOCK_END;
|
|
7257
|
-
var init_aiContext = __esm({
|
|
7258
|
-
"src/init/aiContext.ts"() {
|
|
7259
|
-
AGENTS_FILE_BASENAME = "AGENTS.md";
|
|
7260
|
-
KEYNV_BLOCK_START = "<!-- keynv:start -- generated by `keynv init`; safe to leave intact, will be refreshed on re-run -->";
|
|
7261
|
-
KEYNV_BLOCK_END = "<!-- keynv:end -->";
|
|
7262
|
-
}
|
|
7263
|
-
});
|
|
7264
|
-
function findProjectRoot(startDir) {
|
|
7265
|
-
const result = walkUp(startDir, (dir) => {
|
|
7266
|
-
for (const marker of PROJECT_MARKERS) {
|
|
7267
|
-
if (existsSync(join(dir, marker))) {
|
|
7268
|
-
return { dir, marker };
|
|
7269
|
-
}
|
|
7270
|
-
}
|
|
7271
|
-
if (existsSync(join(dir, GIT_MARKER))) {
|
|
7272
|
-
return { dir, marker: GIT_MARKER };
|
|
7273
|
-
}
|
|
7274
|
-
return null;
|
|
7275
|
-
});
|
|
7276
|
-
if (!result) return null;
|
|
7277
|
-
return buildRoot(result.dir, result.marker);
|
|
7278
|
-
}
|
|
7279
|
-
function buildRoot(dir, marker) {
|
|
7280
|
-
let suggestedName = basename(dir);
|
|
7281
|
-
let scripts = null;
|
|
7282
|
-
let invalid = false;
|
|
7283
|
-
if (marker === "package.json" || existsSync(join(dir, "package.json"))) {
|
|
7284
|
-
try {
|
|
7285
|
-
const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
|
|
7286
|
-
if (typeof pkg.name === "string" && pkg.name.length > 0) {
|
|
7287
|
-
suggestedName = pkg.name.replace(/^@[^/]+\//, "");
|
|
7288
|
-
}
|
|
7289
|
-
if (pkg.scripts && typeof pkg.scripts === "object") {
|
|
7290
|
-
scripts = Object.fromEntries(
|
|
7291
|
-
Object.entries(pkg.scripts).filter(([, v2]) => typeof v2 === "string")
|
|
7292
|
-
);
|
|
7293
|
-
}
|
|
7294
|
-
} catch {
|
|
7295
|
-
invalid = true;
|
|
7296
|
-
}
|
|
7297
|
-
}
|
|
7298
|
-
return {
|
|
7299
|
-
path: dir,
|
|
7300
|
-
suggestedName,
|
|
7301
|
-
marker,
|
|
7302
|
-
packageJsonScripts: scripts,
|
|
7303
|
-
packageJsonInvalid: invalid
|
|
7304
|
-
};
|
|
7305
|
-
}
|
|
7306
|
-
function findEnvFiles(rootDir) {
|
|
7307
|
-
let entries;
|
|
7308
|
-
try {
|
|
7309
|
-
entries = readdirSync(rootDir);
|
|
7310
|
-
} catch {
|
|
7311
|
-
return [];
|
|
7312
|
-
}
|
|
7313
|
-
const hits = [];
|
|
7314
|
-
for (const name of entries) {
|
|
7315
|
-
if (!ENV_GLOB.test(name)) continue;
|
|
7316
|
-
if (ENV_EXAMPLE.test(name)) continue;
|
|
7317
|
-
if (name === KEYNV_ENV_BASENAME) continue;
|
|
7318
|
-
const full = join(rootDir, name);
|
|
7319
|
-
try {
|
|
7320
|
-
if (!statSync(full).isFile()) continue;
|
|
7321
|
-
} catch {
|
|
7322
|
-
continue;
|
|
7323
|
-
}
|
|
7324
|
-
const suffixMatch = name.match(/^\.env\.(.+)$/);
|
|
7325
|
-
const suffix = suffixMatch ? suffixMatch[1] : null;
|
|
7326
|
-
hits.push({ path: full, name, suffix, suggestedEnv: suggestedEnvForSuffix(suffix) });
|
|
7327
|
-
}
|
|
7328
|
-
hits.sort((a, b2) => {
|
|
7329
|
-
if (a.suffix === null) return -1;
|
|
7330
|
-
if (b2.suffix === null) return 1;
|
|
7331
|
-
return a.name.localeCompare(b2.name);
|
|
7332
|
-
});
|
|
7333
|
-
return hits;
|
|
7334
|
-
}
|
|
7335
|
-
function suggestedEnvForSuffix(suffix) {
|
|
7336
|
-
if (suffix === null) return "dev";
|
|
7337
|
-
switch (suffix) {
|
|
7338
|
-
case "local":
|
|
7339
|
-
case "development":
|
|
7340
|
-
case "dev":
|
|
7341
|
-
return "dev";
|
|
7342
|
-
case "production":
|
|
7343
|
-
case "prod":
|
|
7344
|
-
return "prod";
|
|
7345
|
-
case "staging":
|
|
7346
|
-
case "stage":
|
|
7347
|
-
return "staging";
|
|
7348
|
-
case "test":
|
|
7349
|
-
return "test";
|
|
7350
|
-
case "preview":
|
|
7351
|
-
return "preview";
|
|
7352
|
-
default:
|
|
7353
|
-
return suffix;
|
|
7354
|
-
}
|
|
7355
|
-
}
|
|
7356
|
-
function hasExistingKeynvEnv(rootDir) {
|
|
7357
|
-
return existsSync(join(rootDir, KEYNV_ENV_BASENAME));
|
|
7358
|
-
}
|
|
7359
|
-
var PROJECT_MARKERS, GIT_MARKER, ENV_GLOB, ENV_EXAMPLE, KEYNV_ENV_BASENAME;
|
|
7360
|
-
var init_detect = __esm({
|
|
7361
|
-
"src/init/detect.ts"() {
|
|
7362
|
-
init_fs();
|
|
7363
|
-
PROJECT_MARKERS = [
|
|
7364
|
-
"package.json",
|
|
7365
|
-
"pyproject.toml",
|
|
7366
|
-
"Cargo.toml",
|
|
7367
|
-
"go.mod",
|
|
7368
|
-
"pnpm-workspace.yaml",
|
|
7369
|
-
"deno.json",
|
|
7370
|
-
"deno.jsonc",
|
|
7371
|
-
"requirements.txt"
|
|
7372
|
-
];
|
|
7373
|
-
GIT_MARKER = ".git";
|
|
7374
|
-
ENV_GLOB = /^\.env(\.[A-Za-z0-9_-]+)?$/;
|
|
7375
|
-
ENV_EXAMPLE = /^\.env\.(example|sample|template|dist|defaults)$/;
|
|
7376
|
-
KEYNV_ENV_BASENAME = ".keynv.env";
|
|
7377
|
-
}
|
|
7378
|
-
});
|
|
7379
|
-
|
|
7380
|
-
// src/init/scriptWrap.ts
|
|
8380
|
+
// src/init/script-wrap.ts
|
|
7381
8381
|
function analyzeScript(name, command) {
|
|
7382
8382
|
const trimmed = command.trim();
|
|
7383
8383
|
if (trimmed.startsWith("keynv ") || trimmed.startsWith("keynv ")) {
|
|
@@ -7482,8 +8482,8 @@ function applyWraps(original, selectedScriptNames) {
|
|
|
7482
8482
|
return out;
|
|
7483
8483
|
}
|
|
7484
8484
|
var KEYNV_PREFIX, ENV_AWARE_TOOLS, NON_ENV_TOOLS;
|
|
7485
|
-
var
|
|
7486
|
-
"src/init/
|
|
8485
|
+
var init_script_wrap = __esm({
|
|
8486
|
+
"src/init/script-wrap.ts"() {
|
|
7487
8487
|
KEYNV_PREFIX = "keynv exec --";
|
|
7488
8488
|
ENV_AWARE_TOOLS = /* @__PURE__ */ new Set([
|
|
7489
8489
|
"node",
|
|
@@ -7596,6 +8596,14 @@ __export(init_exports, {
|
|
|
7596
8596
|
UserCancelled: () => UserCancelled,
|
|
7597
8597
|
runInitFlow: () => runInitFlow
|
|
7598
8598
|
});
|
|
8599
|
+
function toAliasKey(name) {
|
|
8600
|
+
if (!name) return name;
|
|
8601
|
+
const KEY_RE3 = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/;
|
|
8602
|
+
if (KEY_RE3.test(name)) return name;
|
|
8603
|
+
const normalised = name.toLowerCase().replace(/_/g, "-");
|
|
8604
|
+
if (KEY_RE3.test(normalised)) return normalised;
|
|
8605
|
+
return normalised.replace(/[^a-zA-Z0-9_-]/g, "").slice(0, 64) || "key";
|
|
8606
|
+
}
|
|
7599
8607
|
async function runInitFlow(client, opts) {
|
|
7600
8608
|
ge("keynv init");
|
|
7601
8609
|
const root = findProjectRoot(opts.cwd);
|
|
@@ -7754,13 +8762,13 @@ ${detail}`
|
|
|
7754
8762
|
if (!selected.has(`${env2}|${e2.name}`)) continue;
|
|
7755
8763
|
i++;
|
|
7756
8764
|
s.message(`Uploading (${i}/${totalToUpload}) [${env2}] ${e2.name}`);
|
|
7757
|
-
const aliasKey = e2.name
|
|
8765
|
+
const aliasKey = toAliasKey(e2.name);
|
|
7758
8766
|
try {
|
|
7759
8767
|
await client.request(`/v1/projects/${projectId2}/secrets`, {
|
|
7760
8768
|
method: "POST",
|
|
7761
8769
|
body: { env: env2, key: aliasKey, value: e2.value }
|
|
7762
8770
|
});
|
|
7763
|
-
const alias2 = buildAlias({
|
|
8771
|
+
const alias2 = reference_exports.buildAlias({
|
|
7764
8772
|
project: projectChoice.name,
|
|
7765
8773
|
environment: env2,
|
|
7766
8774
|
key: aliasKey
|
|
@@ -7812,6 +8820,30 @@ ${detail}`
|
|
|
7812
8820
|
R2.error(`Failed to write .keynv.env: ${err instanceof Error ? err.message : String(err)}`);
|
|
7813
8821
|
return { exitCode: 1 };
|
|
7814
8822
|
}
|
|
8823
|
+
const otherEnvsWithAliases = distinctEnvs.filter(
|
|
8824
|
+
(env2) => env2 !== defaultEnv && (uploadedByEnv.get(env2)?.size ?? 0) > 0
|
|
8825
|
+
);
|
|
8826
|
+
for (const env2 of otherEnvsWithAliases) {
|
|
8827
|
+
const envUploaded = uploadedByEnv.get(env2) ?? /* @__PURE__ */ new Map();
|
|
8828
|
+
const envLiterals = (perEnv.get(env2) ?? []).filter((e2) => !selected.has(`${env2}|${e2.name}`));
|
|
8829
|
+
const envFilePath = join(root.path, `.keynv.${env2}.env`);
|
|
8830
|
+
try {
|
|
8831
|
+
const lines = composeKeynvEnv({
|
|
8832
|
+
uploadedAliases: envUploaded,
|
|
8833
|
+
literals: envLiterals,
|
|
8834
|
+
mergeWithExisting: null
|
|
8835
|
+
});
|
|
8836
|
+
writeFileSync(envFilePath, `${lines.join("\n")}
|
|
8837
|
+
`);
|
|
8838
|
+
R2.success(
|
|
8839
|
+
`Wrote .keynv.${env2}.env (${envUploaded.size} secret alias${envUploaded.size === 1 ? "" : "es"} from "${env2}")`
|
|
8840
|
+
);
|
|
8841
|
+
} catch (err) {
|
|
8842
|
+
R2.warn(
|
|
8843
|
+
`Could not write .keynv.${env2}.env: ${err instanceof Error ? err.message : String(err)}`
|
|
8844
|
+
);
|
|
8845
|
+
}
|
|
8846
|
+
}
|
|
7815
8847
|
try {
|
|
7816
8848
|
const outcome = writeAiContext(root.path);
|
|
7817
8849
|
if (outcome === "created") R2.success("Wrote AGENTS.md (so AI agents understand keynv)");
|
|
@@ -7848,7 +8880,8 @@ ${detail}`
|
|
|
7848
8880
|
if (otherEnvs.length > 0) {
|
|
7849
8881
|
const lines = otherEnvs.map((env2) => {
|
|
7850
8882
|
const count = uploadedByEnv.get(env2)?.size ?? 0;
|
|
7851
|
-
|
|
8883
|
+
const hasFile = count > 0;
|
|
8884
|
+
return hasFile ? ` ${env2}: ${count} secret${count === 1 ? "" : "s"} \u2192 .keynv.${env2}.env (use \`keynv exec --from .keynv.${env2}.env -- <cmd>\`)` : ` ${env2}: 0 secrets in vault (no alias file written)`;
|
|
7852
8885
|
});
|
|
7853
8886
|
Se(lines.join("\n"), "Secrets in other envs");
|
|
7854
8887
|
}
|
|
@@ -8076,10 +9109,10 @@ var init_init = __esm({
|
|
|
8076
9109
|
init_dist5();
|
|
8077
9110
|
init_dist();
|
|
8078
9111
|
init_envFile();
|
|
8079
|
-
|
|
9112
|
+
init_ai_context();
|
|
8080
9113
|
init_detect();
|
|
8081
9114
|
init_heuristics();
|
|
8082
|
-
|
|
9115
|
+
init_script_wrap();
|
|
8083
9116
|
init_cancel();
|
|
8084
9117
|
init_pickProject();
|
|
8085
9118
|
}
|
|
@@ -8098,7 +9131,7 @@ var init_tty = __esm({
|
|
|
8098
9131
|
}
|
|
8099
9132
|
});
|
|
8100
9133
|
function sleep(ms) {
|
|
8101
|
-
return new Promise((
|
|
9134
|
+
return new Promise((resolve4) => setTimeout(resolve4, ms));
|
|
8102
9135
|
}
|
|
8103
9136
|
async function errorMessage(res, fallback) {
|
|
8104
9137
|
const text = await res.text();
|
|
@@ -8110,7 +9143,16 @@ async function errorMessage(res, fallback) {
|
|
|
8110
9143
|
return fallback;
|
|
8111
9144
|
}
|
|
8112
9145
|
}
|
|
9146
|
+
function isSafeUrl(urlStr) {
|
|
9147
|
+
try {
|
|
9148
|
+
const parsed = new URL(urlStr);
|
|
9149
|
+
return parsed.protocol === "https:" || parsed.protocol === "http:";
|
|
9150
|
+
} catch {
|
|
9151
|
+
return false;
|
|
9152
|
+
}
|
|
9153
|
+
}
|
|
8113
9154
|
function openBrowser(url) {
|
|
9155
|
+
if (!isSafeUrl(url)) return false;
|
|
8114
9156
|
try {
|
|
8115
9157
|
const os = platform();
|
|
8116
9158
|
const command = os === "win32" ? "cmd" : os === "darwin" ? "open" : "xdg-open";
|
|
@@ -8296,7 +9338,7 @@ async function runSecretMenu(client, project, alias2) {
|
|
|
8296
9338
|
]
|
|
8297
9339
|
})
|
|
8298
9340
|
);
|
|
8299
|
-
const parsed = parseAlias(alias2);
|
|
9341
|
+
const parsed = reference_exports.parseAlias(alias2);
|
|
8300
9342
|
if (!parsed) {
|
|
8301
9343
|
R2.warn(`unparseable alias: ${alias2}`);
|
|
8302
9344
|
return;
|
|
@@ -8340,16 +9382,16 @@ async function runSecretMenu(client, project, alias2) {
|
|
|
8340
9382
|
async function copyToClipboard(value) {
|
|
8341
9383
|
const platform2 = process.platform;
|
|
8342
9384
|
const cmd = platform2 === "darwin" ? ["pbcopy", []] : platform2 === "win32" ? ["clip", []] : ["xclip", ["-selection", "clipboard"]];
|
|
8343
|
-
return new Promise((
|
|
9385
|
+
return new Promise((resolve4) => {
|
|
8344
9386
|
try {
|
|
8345
9387
|
const child = spawn(cmd[0], cmd[1], {
|
|
8346
9388
|
stdio: ["pipe", "ignore", "ignore"]
|
|
8347
9389
|
});
|
|
8348
|
-
child.on("error", () =>
|
|
8349
|
-
child.on("exit", (code) =>
|
|
9390
|
+
child.on("error", () => resolve4(false));
|
|
9391
|
+
child.on("exit", (code) => resolve4(code === 0));
|
|
8350
9392
|
child.stdin.end(value);
|
|
8351
9393
|
} catch {
|
|
8352
|
-
|
|
9394
|
+
resolve4(false);
|
|
8353
9395
|
}
|
|
8354
9396
|
});
|
|
8355
9397
|
}
|
|
@@ -8380,14 +9422,14 @@ async function promptNewSecret(client, project) {
|
|
|
8380
9422
|
}
|
|
8381
9423
|
}
|
|
8382
9424
|
);
|
|
8383
|
-
const built = buildAlias({ project: target.name, environment: env2, key: answers.key });
|
|
9425
|
+
const built = reference_exports.buildAlias({ project: target.name, environment: env2, key: answers.key });
|
|
8384
9426
|
if (!built) return null;
|
|
8385
9427
|
return { alias: built.literal, value: answers.value };
|
|
8386
9428
|
}
|
|
8387
9429
|
async function createSecretInteractive(client, project) {
|
|
8388
9430
|
const built = await promptNewSecret(client, project);
|
|
8389
9431
|
if (!built) return;
|
|
8390
|
-
const parsed = parseAlias(built.alias);
|
|
9432
|
+
const parsed = reference_exports.parseAlias(built.alias);
|
|
8391
9433
|
if (!parsed) {
|
|
8392
9434
|
R2.warn("Invalid alias produced by form; aborting.");
|
|
8393
9435
|
return;
|
|
@@ -14230,8 +15272,8 @@ var require_umd = __commonJS({
|
|
|
14230
15272
|
if (this.unsigned) return this;
|
|
14231
15273
|
return fromBits(this.low, this.high, true);
|
|
14232
15274
|
};
|
|
14233
|
-
LongPrototype.toBytes = function toBytes(
|
|
14234
|
-
return
|
|
15275
|
+
LongPrototype.toBytes = function toBytes(le2) {
|
|
15276
|
+
return le2 ? this.toBytesLE() : this.toBytesBE();
|
|
14235
15277
|
};
|
|
14236
15278
|
LongPrototype.toBytesLE = function toBytesLE() {
|
|
14237
15279
|
var hi = this.high, lo = this.low;
|
|
@@ -14259,8 +15301,8 @@ var require_umd = __commonJS({
|
|
|
14259
15301
|
lo & 255
|
|
14260
15302
|
];
|
|
14261
15303
|
};
|
|
14262
|
-
Long.fromBytes = function fromBytes(bytes, unsigned,
|
|
14263
|
-
return
|
|
15304
|
+
Long.fromBytes = function fromBytes(bytes, unsigned, le2) {
|
|
15305
|
+
return le2 ? Long.fromBytesLE(bytes, unsigned) : Long.fromBytesBE(bytes, unsigned);
|
|
14264
15306
|
};
|
|
14265
15307
|
Long.fromBytesLE = function fromBytesLE(bytes, unsigned) {
|
|
14266
15308
|
return new Long(
|
|
@@ -18396,7 +19438,7 @@ var require_packet = __commonJS({
|
|
|
18396
19438
|
let y = 0;
|
|
18397
19439
|
let m = 0;
|
|
18398
19440
|
let d2 = 0;
|
|
18399
|
-
let
|
|
19441
|
+
let H3 = 0;
|
|
18400
19442
|
let M2 = 0;
|
|
18401
19443
|
let S2 = 0;
|
|
18402
19444
|
let ms = 0;
|
|
@@ -18406,20 +19448,20 @@ var require_packet = __commonJS({
|
|
|
18406
19448
|
d2 = this.readInt8();
|
|
18407
19449
|
}
|
|
18408
19450
|
if (length > 6) {
|
|
18409
|
-
|
|
19451
|
+
H3 = this.readInt8();
|
|
18410
19452
|
M2 = this.readInt8();
|
|
18411
19453
|
S2 = this.readInt8();
|
|
18412
19454
|
}
|
|
18413
19455
|
if (length > 10) {
|
|
18414
19456
|
ms = this.readInt32() / 1e3;
|
|
18415
19457
|
}
|
|
18416
|
-
if (y + m + d2 +
|
|
19458
|
+
if (y + m + d2 + H3 + M2 + S2 + ms === 0) {
|
|
18417
19459
|
return INVALID_DATE;
|
|
18418
19460
|
}
|
|
18419
19461
|
if (timezone === "Z") {
|
|
18420
|
-
return new Date(Date.UTC(y, m - 1, d2,
|
|
19462
|
+
return new Date(Date.UTC(y, m - 1, d2, H3, M2, S2, ms));
|
|
18421
19463
|
}
|
|
18422
|
-
return new Date(y, m - 1, d2,
|
|
19464
|
+
return new Date(y, m - 1, d2, H3, M2, S2, ms);
|
|
18423
19465
|
}
|
|
18424
19466
|
let str = this.readDateTimeString(6, "T", null);
|
|
18425
19467
|
if (!str) {
|
|
@@ -18435,7 +19477,7 @@ var require_packet = __commonJS({
|
|
|
18435
19477
|
let y = 0;
|
|
18436
19478
|
let m = 0;
|
|
18437
19479
|
let d2 = 0;
|
|
18438
|
-
let
|
|
19480
|
+
let H3 = 0;
|
|
18439
19481
|
let M2 = 0;
|
|
18440
19482
|
let S2 = 0;
|
|
18441
19483
|
let ms = 0;
|
|
@@ -18447,11 +19489,11 @@ var require_packet = __commonJS({
|
|
|
18447
19489
|
str = [leftPad(4, y), leftPad(2, m), leftPad(2, d2)].join("-");
|
|
18448
19490
|
}
|
|
18449
19491
|
if (length > 6) {
|
|
18450
|
-
|
|
19492
|
+
H3 = this.readInt8();
|
|
18451
19493
|
M2 = this.readInt8();
|
|
18452
19494
|
S2 = this.readInt8();
|
|
18453
19495
|
str += `${timeSep || " "}${[
|
|
18454
|
-
leftPad(2,
|
|
19496
|
+
leftPad(2, H3),
|
|
18455
19497
|
leftPad(2, M2),
|
|
18456
19498
|
leftPad(2, S2)
|
|
18457
19499
|
].join(":")}`;
|
|
@@ -18479,13 +19521,13 @@ var require_packet = __commonJS({
|
|
|
18479
19521
|
}
|
|
18480
19522
|
const sign = this.readInt8() ? -1 : 1;
|
|
18481
19523
|
let d2 = 0;
|
|
18482
|
-
let
|
|
19524
|
+
let H3 = 0;
|
|
18483
19525
|
let M2 = 0;
|
|
18484
19526
|
let S2 = 0;
|
|
18485
19527
|
let ms = 0;
|
|
18486
19528
|
if (length > 6) {
|
|
18487
19529
|
d2 = this.readInt32();
|
|
18488
|
-
|
|
19530
|
+
H3 = this.readInt8();
|
|
18489
19531
|
M2 = this.readInt8();
|
|
18490
19532
|
S2 = this.readInt8();
|
|
18491
19533
|
}
|
|
@@ -18493,14 +19535,14 @@ var require_packet = __commonJS({
|
|
|
18493
19535
|
ms = this.readInt32();
|
|
18494
19536
|
}
|
|
18495
19537
|
if (convertTtoMs) {
|
|
18496
|
-
|
|
18497
|
-
M2 +=
|
|
19538
|
+
H3 += d2 * 24;
|
|
19539
|
+
M2 += H3 * 60;
|
|
18498
19540
|
S2 += M2 * 60;
|
|
18499
19541
|
ms += S2 * 1e3;
|
|
18500
19542
|
ms *= sign;
|
|
18501
19543
|
return ms;
|
|
18502
19544
|
}
|
|
18503
|
-
return (sign === -1 ? "-" : "") + [leftPad(2, d2 * 24 +
|
|
19545
|
+
return (sign === -1 ? "-" : "") + [leftPad(2, d2 * 24 + H3), leftPad(2, M2), leftPad(2, S2)].join(":") + (ms ? `.${ms}`.replace(/0+$/, "") : "");
|
|
18504
19546
|
}
|
|
18505
19547
|
readLengthCodedString(encoding) {
|
|
18506
19548
|
const len = this.readLengthCodedNumber();
|
|
@@ -18638,7 +19680,7 @@ var require_packet = __commonJS({
|
|
|
18638
19680
|
}
|
|
18639
19681
|
const bufferLength = buffer.length;
|
|
18640
19682
|
function parseGeometry() {
|
|
18641
|
-
let
|
|
19683
|
+
let x2, y, i, j3, numPoints, numRings, num, line;
|
|
18642
19684
|
let result = null;
|
|
18643
19685
|
if (offset + 5 > bufferLength) {
|
|
18644
19686
|
return null;
|
|
@@ -18652,11 +19694,11 @@ var require_packet = __commonJS({
|
|
|
18652
19694
|
if (offset + 16 > bufferLength) {
|
|
18653
19695
|
return null;
|
|
18654
19696
|
}
|
|
18655
|
-
|
|
19697
|
+
x2 = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset);
|
|
18656
19698
|
offset += 8;
|
|
18657
19699
|
y = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset);
|
|
18658
19700
|
offset += 8;
|
|
18659
|
-
result = { x, y };
|
|
19701
|
+
result = { x: x2, y };
|
|
18660
19702
|
break;
|
|
18661
19703
|
case 2:
|
|
18662
19704
|
if (offset + 4 > bufferLength) {
|
|
@@ -18672,11 +19714,11 @@ var require_packet = __commonJS({
|
|
|
18672
19714
|
if (offset + 16 > bufferLength) {
|
|
18673
19715
|
break;
|
|
18674
19716
|
}
|
|
18675
|
-
|
|
19717
|
+
x2 = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset);
|
|
18676
19718
|
offset += 8;
|
|
18677
19719
|
y = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset);
|
|
18678
19720
|
offset += 8;
|
|
18679
|
-
result.push({ x, y });
|
|
19721
|
+
result.push({ x: x2, y });
|
|
18680
19722
|
}
|
|
18681
19723
|
break;
|
|
18682
19724
|
case 3:
|
|
@@ -18700,11 +19742,11 @@ var require_packet = __commonJS({
|
|
|
18700
19742
|
if (offset + 16 > bufferLength) {
|
|
18701
19743
|
break;
|
|
18702
19744
|
}
|
|
18703
|
-
|
|
19745
|
+
x2 = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset);
|
|
18704
19746
|
offset += 8;
|
|
18705
19747
|
y = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset);
|
|
18706
19748
|
offset += 8;
|
|
18707
|
-
line.push({ x, y });
|
|
19749
|
+
line.push({ x: x2, y });
|
|
18708
19750
|
}
|
|
18709
19751
|
result.push(line);
|
|
18710
19752
|
}
|
|
@@ -25095,7 +26137,7 @@ var require_named_placeholders = __commonJS({
|
|
|
25095
26137
|
}
|
|
25096
26138
|
return s;
|
|
25097
26139
|
}
|
|
25098
|
-
function
|
|
26140
|
+
function join8(tree) {
|
|
25099
26141
|
if (tree.length === 1) {
|
|
25100
26142
|
return tree;
|
|
25101
26143
|
}
|
|
@@ -25121,7 +26163,7 @@ var require_named_placeholders = __commonJS({
|
|
|
25121
26163
|
if (cache2 && (tree = cache2.get(query))) {
|
|
25122
26164
|
return toArrayParams(tree, paramsObj);
|
|
25123
26165
|
}
|
|
25124
|
-
tree =
|
|
26166
|
+
tree = join8(parse(query));
|
|
25125
26167
|
if (cache2) {
|
|
25126
26168
|
cache2.set(query, tree);
|
|
25127
26169
|
}
|
|
@@ -25277,11 +26319,11 @@ var require_connection = __commonJS({
|
|
|
25277
26319
|
const config = this.config;
|
|
25278
26320
|
tracePromise(
|
|
25279
26321
|
connectChannel,
|
|
25280
|
-
() => new Promise((
|
|
26322
|
+
() => new Promise((resolve4, reject) => {
|
|
25281
26323
|
let onConnect, onError;
|
|
25282
26324
|
onConnect = (param) => {
|
|
25283
26325
|
this.removeListener("error", onError);
|
|
25284
|
-
|
|
26326
|
+
resolve4(param);
|
|
25285
26327
|
};
|
|
25286
26328
|
onError = (err) => {
|
|
25287
26329
|
this.removeListener("connect", onConnect);
|
|
@@ -25706,9 +26748,9 @@ var require_connection = __commonJS({
|
|
|
25706
26748
|
} else if (shouldTrace(queryChannel)) {
|
|
25707
26749
|
tracePromise(
|
|
25708
26750
|
queryChannel,
|
|
25709
|
-
() => new Promise((
|
|
26751
|
+
() => new Promise((resolve4, reject) => {
|
|
25710
26752
|
cmdQuery.once("error", reject);
|
|
25711
|
-
cmdQuery.once("end", () =>
|
|
26753
|
+
cmdQuery.once("end", () => resolve4());
|
|
25712
26754
|
this.addCommand(cmdQuery);
|
|
25713
26755
|
}),
|
|
25714
26756
|
() => {
|
|
@@ -25855,12 +26897,12 @@ var require_connection = __commonJS({
|
|
|
25855
26897
|
} else if (shouldTrace(executeChannel)) {
|
|
25856
26898
|
tracePromise(
|
|
25857
26899
|
executeChannel,
|
|
25858
|
-
() => new Promise((
|
|
26900
|
+
() => new Promise((resolve4, reject) => {
|
|
25859
26901
|
prepareAndExecute((err) => {
|
|
25860
26902
|
executeCommand.emit("error", err);
|
|
25861
26903
|
});
|
|
25862
26904
|
executeCommand.once("error", reject);
|
|
25863
|
-
executeCommand.once("end", () =>
|
|
26905
|
+
executeCommand.once("end", () => resolve4());
|
|
25864
26906
|
}),
|
|
25865
26907
|
() => {
|
|
25866
26908
|
const server = getServerContext(this.config);
|
|
@@ -26125,13 +27167,13 @@ var require_capture_local_err = __commonJS({
|
|
|
26125
27167
|
var require_make_done_cb = __commonJS({
|
|
26126
27168
|
"../../node_modules/.pnpm/mysql2@3.22.3_@types+node@24.12.3/node_modules/mysql2/lib/promise/make_done_cb.js"(exports, module) {
|
|
26127
27169
|
var { applyCapturedStack } = require_capture_local_err();
|
|
26128
|
-
function makeDoneCb(
|
|
27170
|
+
function makeDoneCb(resolve4, reject, stackHolder) {
|
|
26129
27171
|
return function(err, rows, fields) {
|
|
26130
27172
|
if (err) {
|
|
26131
27173
|
applyCapturedStack(err, stackHolder);
|
|
26132
27174
|
reject(err);
|
|
26133
27175
|
} else {
|
|
26134
|
-
|
|
27176
|
+
resolve4([rows, fields]);
|
|
26135
27177
|
}
|
|
26136
27178
|
};
|
|
26137
27179
|
}
|
|
@@ -26154,8 +27196,8 @@ var require_prepared_statement_info = __commonJS({
|
|
|
26154
27196
|
const stackHolder = captureStackHolder(
|
|
26155
27197
|
_PromisePreparedStatementInfo.prototype.execute
|
|
26156
27198
|
);
|
|
26157
|
-
return new this.Promise((
|
|
26158
|
-
const done = makeDoneCb(
|
|
27199
|
+
return new this.Promise((resolve4, reject) => {
|
|
27200
|
+
const done = makeDoneCb(resolve4, reject, stackHolder);
|
|
26159
27201
|
if (parameters) {
|
|
26160
27202
|
s.execute(parameters, done);
|
|
26161
27203
|
} else {
|
|
@@ -26164,9 +27206,9 @@ var require_prepared_statement_info = __commonJS({
|
|
|
26164
27206
|
});
|
|
26165
27207
|
}
|
|
26166
27208
|
close() {
|
|
26167
|
-
return new this.Promise((
|
|
27209
|
+
return new this.Promise((resolve4) => {
|
|
26168
27210
|
this.statement.close();
|
|
26169
|
-
|
|
27211
|
+
resolve4();
|
|
26170
27212
|
});
|
|
26171
27213
|
}
|
|
26172
27214
|
};
|
|
@@ -26237,8 +27279,8 @@ var require_connection2 = __commonJS({
|
|
|
26237
27279
|
"Callback function is not available with promise clients."
|
|
26238
27280
|
);
|
|
26239
27281
|
}
|
|
26240
|
-
return new this.Promise((
|
|
26241
|
-
const done = makeDoneCb(
|
|
27282
|
+
return new this.Promise((resolve4, reject) => {
|
|
27283
|
+
const done = makeDoneCb(resolve4, reject, stackHolder);
|
|
26242
27284
|
if (params !== void 0) {
|
|
26243
27285
|
c2.query(query, params, done);
|
|
26244
27286
|
} else {
|
|
@@ -26254,8 +27296,8 @@ var require_connection2 = __commonJS({
|
|
|
26254
27296
|
"Callback function is not available with promise clients."
|
|
26255
27297
|
);
|
|
26256
27298
|
}
|
|
26257
|
-
return new this.Promise((
|
|
26258
|
-
const done = makeDoneCb(
|
|
27299
|
+
return new this.Promise((resolve4, reject) => {
|
|
27300
|
+
const done = makeDoneCb(resolve4, reject, stackHolder);
|
|
26259
27301
|
if (params !== void 0) {
|
|
26260
27302
|
c2.execute(query, params, done);
|
|
26261
27303
|
} else {
|
|
@@ -26264,8 +27306,8 @@ var require_connection2 = __commonJS({
|
|
|
26264
27306
|
});
|
|
26265
27307
|
}
|
|
26266
27308
|
end() {
|
|
26267
|
-
return new this.Promise((
|
|
26268
|
-
this.connection.end(
|
|
27309
|
+
return new this.Promise((resolve4) => {
|
|
27310
|
+
this.connection.end(resolve4);
|
|
26269
27311
|
});
|
|
26270
27312
|
}
|
|
26271
27313
|
async [Symbol.asyncDispose]() {
|
|
@@ -26278,16 +27320,16 @@ var require_connection2 = __commonJS({
|
|
|
26278
27320
|
const stackHolder = captureStackHolder(
|
|
26279
27321
|
_PromiseConnection.prototype.beginTransaction
|
|
26280
27322
|
);
|
|
26281
|
-
return new this.Promise((
|
|
26282
|
-
const done = makeDoneCb(
|
|
27323
|
+
return new this.Promise((resolve4, reject) => {
|
|
27324
|
+
const done = makeDoneCb(resolve4, reject, stackHolder);
|
|
26283
27325
|
c2.beginTransaction(done);
|
|
26284
27326
|
});
|
|
26285
27327
|
}
|
|
26286
27328
|
commit() {
|
|
26287
27329
|
const c2 = this.connection;
|
|
26288
27330
|
const stackHolder = captureStackHolder(_PromiseConnection.prototype.commit);
|
|
26289
|
-
return new this.Promise((
|
|
26290
|
-
const done = makeDoneCb(
|
|
27331
|
+
return new this.Promise((resolve4, reject) => {
|
|
27332
|
+
const done = makeDoneCb(resolve4, reject, stackHolder);
|
|
26291
27333
|
c2.commit(done);
|
|
26292
27334
|
});
|
|
26293
27335
|
}
|
|
@@ -26296,21 +27338,21 @@ var require_connection2 = __commonJS({
|
|
|
26296
27338
|
const stackHolder = captureStackHolder(
|
|
26297
27339
|
_PromiseConnection.prototype.rollback
|
|
26298
27340
|
);
|
|
26299
|
-
return new this.Promise((
|
|
26300
|
-
const done = makeDoneCb(
|
|
27341
|
+
return new this.Promise((resolve4, reject) => {
|
|
27342
|
+
const done = makeDoneCb(resolve4, reject, stackHolder);
|
|
26301
27343
|
c2.rollback(done);
|
|
26302
27344
|
});
|
|
26303
27345
|
}
|
|
26304
27346
|
ping() {
|
|
26305
27347
|
const c2 = this.connection;
|
|
26306
27348
|
const stackHolder = captureStackHolder(_PromiseConnection.prototype.ping);
|
|
26307
|
-
return new this.Promise((
|
|
27349
|
+
return new this.Promise((resolve4, reject) => {
|
|
26308
27350
|
c2.ping((err) => {
|
|
26309
27351
|
if (err) {
|
|
26310
27352
|
applyCapturedStack(err, stackHolder);
|
|
26311
27353
|
reject(err);
|
|
26312
27354
|
} else {
|
|
26313
|
-
|
|
27355
|
+
resolve4(true);
|
|
26314
27356
|
}
|
|
26315
27357
|
});
|
|
26316
27358
|
});
|
|
@@ -26318,13 +27360,13 @@ var require_connection2 = __commonJS({
|
|
|
26318
27360
|
reset() {
|
|
26319
27361
|
const c2 = this.connection;
|
|
26320
27362
|
const stackHolder = captureStackHolder(_PromiseConnection.prototype.reset);
|
|
26321
|
-
return new this.Promise((
|
|
27363
|
+
return new this.Promise((resolve4, reject) => {
|
|
26322
27364
|
c2.reset((err) => {
|
|
26323
27365
|
if (err) {
|
|
26324
27366
|
applyCapturedStack(err, stackHolder);
|
|
26325
27367
|
reject(err);
|
|
26326
27368
|
} else {
|
|
26327
|
-
|
|
27369
|
+
resolve4();
|
|
26328
27370
|
}
|
|
26329
27371
|
});
|
|
26330
27372
|
});
|
|
@@ -26332,13 +27374,13 @@ var require_connection2 = __commonJS({
|
|
|
26332
27374
|
connect() {
|
|
26333
27375
|
const c2 = this.connection;
|
|
26334
27376
|
const stackHolder = captureStackHolder(_PromiseConnection.prototype.connect);
|
|
26335
|
-
return new this.Promise((
|
|
27377
|
+
return new this.Promise((resolve4, reject) => {
|
|
26336
27378
|
c2.connect((err, param) => {
|
|
26337
27379
|
if (err) {
|
|
26338
27380
|
applyCapturedStack(err, stackHolder);
|
|
26339
27381
|
reject(err);
|
|
26340
27382
|
} else {
|
|
26341
|
-
|
|
27383
|
+
resolve4(param);
|
|
26342
27384
|
}
|
|
26343
27385
|
});
|
|
26344
27386
|
});
|
|
@@ -26347,7 +27389,7 @@ var require_connection2 = __commonJS({
|
|
|
26347
27389
|
const c2 = this.connection;
|
|
26348
27390
|
const promiseImpl = this.Promise;
|
|
26349
27391
|
const stackHolder = captureStackHolder(_PromiseConnection.prototype.prepare);
|
|
26350
|
-
return new this.Promise((
|
|
27392
|
+
return new this.Promise((resolve4, reject) => {
|
|
26351
27393
|
c2.prepare(options, (err, statement) => {
|
|
26352
27394
|
if (err) {
|
|
26353
27395
|
applyCapturedStack(err, stackHolder);
|
|
@@ -26357,7 +27399,7 @@ var require_connection2 = __commonJS({
|
|
|
26357
27399
|
statement,
|
|
26358
27400
|
promiseImpl
|
|
26359
27401
|
);
|
|
26360
|
-
|
|
27402
|
+
resolve4(wrappedStatement);
|
|
26361
27403
|
}
|
|
26362
27404
|
});
|
|
26363
27405
|
});
|
|
@@ -26367,13 +27409,13 @@ var require_connection2 = __commonJS({
|
|
|
26367
27409
|
const stackHolder = captureStackHolder(
|
|
26368
27410
|
_PromiseConnection.prototype.changeUser
|
|
26369
27411
|
);
|
|
26370
|
-
return new this.Promise((
|
|
27412
|
+
return new this.Promise((resolve4, reject) => {
|
|
26371
27413
|
c2.changeUser(options, (err) => {
|
|
26372
27414
|
if (err) {
|
|
26373
27415
|
applyCapturedStack(err, stackHolder);
|
|
26374
27416
|
reject(err);
|
|
26375
27417
|
} else {
|
|
26376
|
-
|
|
27418
|
+
resolve4();
|
|
26377
27419
|
}
|
|
26378
27420
|
});
|
|
26379
27421
|
});
|
|
@@ -26835,12 +27877,12 @@ var require_pool2 = __commonJS({
|
|
|
26835
27877
|
}
|
|
26836
27878
|
getConnection() {
|
|
26837
27879
|
const corePool = this.pool;
|
|
26838
|
-
return new this.Promise((
|
|
27880
|
+
return new this.Promise((resolve4, reject) => {
|
|
26839
27881
|
corePool.getConnection((err, coreConnection) => {
|
|
26840
27882
|
if (err) {
|
|
26841
27883
|
reject(err);
|
|
26842
27884
|
} else {
|
|
26843
|
-
|
|
27885
|
+
resolve4(new PromisePoolConnection(coreConnection, this.Promise));
|
|
26844
27886
|
}
|
|
26845
27887
|
});
|
|
26846
27888
|
});
|
|
@@ -26856,8 +27898,8 @@ var require_pool2 = __commonJS({
|
|
|
26856
27898
|
"Callback function is not available with promise clients."
|
|
26857
27899
|
);
|
|
26858
27900
|
}
|
|
26859
|
-
return new this.Promise((
|
|
26860
|
-
const done = makeDoneCb(
|
|
27901
|
+
return new this.Promise((resolve4, reject) => {
|
|
27902
|
+
const done = makeDoneCb(resolve4, reject, stackHolder);
|
|
26861
27903
|
if (args !== void 0) {
|
|
26862
27904
|
corePool.query(sql, args, done);
|
|
26863
27905
|
} else {
|
|
@@ -26873,8 +27915,8 @@ var require_pool2 = __commonJS({
|
|
|
26873
27915
|
"Callback function is not available with promise clients."
|
|
26874
27916
|
);
|
|
26875
27917
|
}
|
|
26876
|
-
return new this.Promise((
|
|
26877
|
-
const done = makeDoneCb(
|
|
27918
|
+
return new this.Promise((resolve4, reject) => {
|
|
27919
|
+
const done = makeDoneCb(resolve4, reject, stackHolder);
|
|
26878
27920
|
if (args) {
|
|
26879
27921
|
corePool.execute(sql, args, done);
|
|
26880
27922
|
} else {
|
|
@@ -26885,13 +27927,13 @@ var require_pool2 = __commonJS({
|
|
|
26885
27927
|
end() {
|
|
26886
27928
|
const corePool = this.pool;
|
|
26887
27929
|
const stackHolder = captureStackHolder(_PromisePool.prototype.end);
|
|
26888
|
-
return new this.Promise((
|
|
27930
|
+
return new this.Promise((resolve4, reject) => {
|
|
26889
27931
|
corePool.end((err) => {
|
|
26890
27932
|
if (err) {
|
|
26891
27933
|
applyCapturedStack(err, stackHolder);
|
|
26892
27934
|
reject(err);
|
|
26893
27935
|
} else {
|
|
26894
|
-
|
|
27936
|
+
resolve4();
|
|
26895
27937
|
}
|
|
26896
27938
|
});
|
|
26897
27939
|
});
|
|
@@ -27316,12 +28358,12 @@ var require_pool_cluster2 = __commonJS({
|
|
|
27316
28358
|
}
|
|
27317
28359
|
getConnection() {
|
|
27318
28360
|
const corePoolNamespace = this.poolNamespace;
|
|
27319
|
-
return new this.Promise((
|
|
28361
|
+
return new this.Promise((resolve4, reject) => {
|
|
27320
28362
|
corePoolNamespace.getConnection((err, coreConnection) => {
|
|
27321
28363
|
if (err) {
|
|
27322
28364
|
reject(err);
|
|
27323
28365
|
} else {
|
|
27324
|
-
|
|
28366
|
+
resolve4(new PromisePoolConnection(coreConnection, this.Promise));
|
|
27325
28367
|
}
|
|
27326
28368
|
});
|
|
27327
28369
|
});
|
|
@@ -27336,8 +28378,8 @@ var require_pool_cluster2 = __commonJS({
|
|
|
27336
28378
|
"Callback function is not available with promise clients."
|
|
27337
28379
|
);
|
|
27338
28380
|
}
|
|
27339
|
-
return new this.Promise((
|
|
27340
|
-
const done = makeDoneCb(
|
|
28381
|
+
return new this.Promise((resolve4, reject) => {
|
|
28382
|
+
const done = makeDoneCb(resolve4, reject, stackHolder);
|
|
27341
28383
|
corePoolNamespace.query(sql, values, done);
|
|
27342
28384
|
});
|
|
27343
28385
|
}
|
|
@@ -27351,8 +28393,8 @@ var require_pool_cluster2 = __commonJS({
|
|
|
27351
28393
|
"Callback function is not available with promise clients."
|
|
27352
28394
|
);
|
|
27353
28395
|
}
|
|
27354
|
-
return new this.Promise((
|
|
27355
|
-
const done = makeDoneCb(
|
|
28396
|
+
return new this.Promise((resolve4, reject) => {
|
|
28397
|
+
const done = makeDoneCb(resolve4, reject, stackHolder);
|
|
27356
28398
|
corePoolNamespace.execute(sql, values, done);
|
|
27357
28399
|
});
|
|
27358
28400
|
}
|
|
@@ -27390,9 +28432,9 @@ var require_promise = __commonJS({
|
|
|
27390
28432
|
"no Promise implementation available.Use promise-enabled node version or pass userland Promise implementation as parameter, for example: { Promise: require('bluebird') }"
|
|
27391
28433
|
);
|
|
27392
28434
|
}
|
|
27393
|
-
return new thePromise((
|
|
28435
|
+
return new thePromise((resolve4, reject) => {
|
|
27394
28436
|
coreConnection.once("connect", () => {
|
|
27395
|
-
|
|
28437
|
+
resolve4(new PromiseConnection(coreConnection, thePromise));
|
|
27396
28438
|
});
|
|
27397
28439
|
coreConnection.once("error", (err) => {
|
|
27398
28440
|
applyCapturedStack(err, stackHolder);
|
|
@@ -27419,7 +28461,7 @@ var require_promise = __commonJS({
|
|
|
27419
28461
|
}
|
|
27420
28462
|
getConnection(pattern, selector) {
|
|
27421
28463
|
const corePoolCluster = this.poolCluster;
|
|
27422
|
-
return new this.Promise((
|
|
28464
|
+
return new this.Promise((resolve4, reject) => {
|
|
27423
28465
|
corePoolCluster.getConnection(
|
|
27424
28466
|
pattern,
|
|
27425
28467
|
selector,
|
|
@@ -27427,7 +28469,7 @@ var require_promise = __commonJS({
|
|
|
27427
28469
|
if (err) {
|
|
27428
28470
|
reject(err);
|
|
27429
28471
|
} else {
|
|
27430
|
-
|
|
28472
|
+
resolve4(new PromisePoolConnection(coreConnection, this.Promise));
|
|
27431
28473
|
}
|
|
27432
28474
|
}
|
|
27433
28475
|
);
|
|
@@ -27441,8 +28483,8 @@ var require_promise = __commonJS({
|
|
|
27441
28483
|
"Callback function is not available with promise clients."
|
|
27442
28484
|
);
|
|
27443
28485
|
}
|
|
27444
|
-
return new this.Promise((
|
|
27445
|
-
const done = makeDoneCb(
|
|
28486
|
+
return new this.Promise((resolve4, reject) => {
|
|
28487
|
+
const done = makeDoneCb(resolve4, reject, stackHolder);
|
|
27446
28488
|
corePoolCluster.query(sql, args, done);
|
|
27447
28489
|
});
|
|
27448
28490
|
}
|
|
@@ -27456,8 +28498,8 @@ var require_promise = __commonJS({
|
|
|
27456
28498
|
"Callback function is not available with promise clients."
|
|
27457
28499
|
);
|
|
27458
28500
|
}
|
|
27459
|
-
return new this.Promise((
|
|
27460
|
-
const done = makeDoneCb(
|
|
28501
|
+
return new this.Promise((resolve4, reject) => {
|
|
28502
|
+
const done = makeDoneCb(resolve4, reject, stackHolder);
|
|
27461
28503
|
corePoolCluster.execute(sql, args, done);
|
|
27462
28504
|
});
|
|
27463
28505
|
}
|
|
@@ -27470,13 +28512,13 @@ var require_promise = __commonJS({
|
|
|
27470
28512
|
end() {
|
|
27471
28513
|
const corePoolCluster = this.poolCluster;
|
|
27472
28514
|
const stackHolder = captureStackHolder(_PromisePoolCluster.prototype.end);
|
|
27473
|
-
return new this.Promise((
|
|
28515
|
+
return new this.Promise((resolve4, reject) => {
|
|
27474
28516
|
corePoolCluster.end((err) => {
|
|
27475
28517
|
if (err) {
|
|
27476
28518
|
applyCapturedStack(err, stackHolder);
|
|
27477
28519
|
reject(err);
|
|
27478
28520
|
} else {
|
|
27479
|
-
|
|
28521
|
+
resolve4();
|
|
27480
28522
|
}
|
|
27481
28523
|
});
|
|
27482
28524
|
});
|
|
@@ -30551,7 +31593,7 @@ var require_dist = __commonJS({
|
|
|
30551
31593
|
function parse(stream, callback) {
|
|
30552
31594
|
const parser = new parser_1.Parser();
|
|
30553
31595
|
stream.on("data", (buffer) => parser.parse(buffer, callback));
|
|
30554
|
-
return new Promise((
|
|
31596
|
+
return new Promise((resolve4) => stream.on("end", () => resolve4()));
|
|
30555
31597
|
}
|
|
30556
31598
|
exports.parse = parse;
|
|
30557
31599
|
}
|
|
@@ -31045,28 +32087,28 @@ var require_helper = __commonJS({
|
|
|
31045
32087
|
var isValidEntry = module.exports.isValidEntry = function(entry2) {
|
|
31046
32088
|
var rules = {
|
|
31047
32089
|
// host
|
|
31048
|
-
0: function(
|
|
31049
|
-
return
|
|
32090
|
+
0: function(x2) {
|
|
32091
|
+
return x2.length > 0;
|
|
31050
32092
|
},
|
|
31051
32093
|
// port
|
|
31052
|
-
1: function(
|
|
31053
|
-
if (
|
|
32094
|
+
1: function(x2) {
|
|
32095
|
+
if (x2 === "*") {
|
|
31054
32096
|
return true;
|
|
31055
32097
|
}
|
|
31056
|
-
|
|
31057
|
-
return isFinite(
|
|
32098
|
+
x2 = Number(x2);
|
|
32099
|
+
return isFinite(x2) && x2 > 0 && x2 < 9007199254740992 && Math.floor(x2) === x2;
|
|
31058
32100
|
},
|
|
31059
32101
|
// database
|
|
31060
|
-
2: function(
|
|
31061
|
-
return
|
|
32102
|
+
2: function(x2) {
|
|
32103
|
+
return x2.length > 0;
|
|
31062
32104
|
},
|
|
31063
32105
|
// username
|
|
31064
|
-
3: function(
|
|
31065
|
-
return
|
|
32106
|
+
3: function(x2) {
|
|
32107
|
+
return x2.length > 0;
|
|
31066
32108
|
},
|
|
31067
32109
|
// password
|
|
31068
|
-
4: function(
|
|
31069
|
-
return
|
|
32110
|
+
4: function(x2) {
|
|
32111
|
+
return x2.length > 0;
|
|
31070
32112
|
}
|
|
31071
32113
|
};
|
|
31072
32114
|
for (var idx = 0; idx < fieldNames.length; idx += 1) {
|
|
@@ -31094,8 +32136,8 @@ var require_lib6 = __commonJS({
|
|
|
31094
32136
|
if (err || !helper.usePgPass(stat, file)) {
|
|
31095
32137
|
return cb(void 0);
|
|
31096
32138
|
}
|
|
31097
|
-
var
|
|
31098
|
-
helper.getPassword(connInfo,
|
|
32139
|
+
var st3 = fs.createReadStream(file);
|
|
32140
|
+
helper.getPassword(connInfo, st3, cb);
|
|
31099
32141
|
});
|
|
31100
32142
|
};
|
|
31101
32143
|
module.exports.warnTo = helper.warnTo;
|
|
@@ -31276,12 +32318,12 @@ var require_client2 = __commonJS({
|
|
|
31276
32318
|
this._connect(callback);
|
|
31277
32319
|
return;
|
|
31278
32320
|
}
|
|
31279
|
-
return new this._Promise((
|
|
32321
|
+
return new this._Promise((resolve4, reject) => {
|
|
31280
32322
|
this._connect((error) => {
|
|
31281
32323
|
if (error) {
|
|
31282
32324
|
reject(error);
|
|
31283
32325
|
} else {
|
|
31284
|
-
|
|
32326
|
+
resolve4(this);
|
|
31285
32327
|
}
|
|
31286
32328
|
});
|
|
31287
32329
|
});
|
|
@@ -31627,8 +32669,8 @@ var require_client2 = __commonJS({
|
|
|
31627
32669
|
readTimeout = config.query_timeout || this.connectionParameters.query_timeout;
|
|
31628
32670
|
query = new Query2(config, values, callback);
|
|
31629
32671
|
if (!query.callback) {
|
|
31630
|
-
result = new this._Promise((
|
|
31631
|
-
query.callback = (err, res) => err ? reject(err) :
|
|
32672
|
+
result = new this._Promise((resolve4, reject) => {
|
|
32673
|
+
query.callback = (err, res) => err ? reject(err) : resolve4(res);
|
|
31632
32674
|
}).catch((err) => {
|
|
31633
32675
|
Error.captureStackTrace(err);
|
|
31634
32676
|
throw err;
|
|
@@ -31705,8 +32747,8 @@ var require_client2 = __commonJS({
|
|
|
31705
32747
|
if (cb) {
|
|
31706
32748
|
this.connection.once("end", cb);
|
|
31707
32749
|
} else {
|
|
31708
|
-
return new this._Promise((
|
|
31709
|
-
this.connection.once("end",
|
|
32750
|
+
return new this._Promise((resolve4) => {
|
|
32751
|
+
this.connection.once("end", resolve4);
|
|
31710
32752
|
});
|
|
31711
32753
|
}
|
|
31712
32754
|
}
|
|
@@ -31754,8 +32796,8 @@ var require_pg_pool = __commonJS({
|
|
|
31754
32796
|
const cb = function(err, client) {
|
|
31755
32797
|
err ? rej(err) : res(client);
|
|
31756
32798
|
};
|
|
31757
|
-
const result = new Promise2(function(
|
|
31758
|
-
res =
|
|
32799
|
+
const result = new Promise2(function(resolve4, reject) {
|
|
32800
|
+
res = resolve4;
|
|
31759
32801
|
rej = reject;
|
|
31760
32802
|
}).catch((err) => {
|
|
31761
32803
|
Error.captureStackTrace(err);
|
|
@@ -31816,7 +32858,7 @@ var require_pg_pool = __commonJS({
|
|
|
31816
32858
|
if (typeof Promise2.try === "function") {
|
|
31817
32859
|
return Promise2.try(f);
|
|
31818
32860
|
}
|
|
31819
|
-
return new Promise2((
|
|
32861
|
+
return new Promise2((resolve4) => resolve4(f()));
|
|
31820
32862
|
}
|
|
31821
32863
|
_isFull() {
|
|
31822
32864
|
return this._clients.length >= this.options.max;
|
|
@@ -32208,8 +33250,8 @@ var require_query4 = __commonJS({
|
|
|
32208
33250
|
NativeQuery.prototype._getPromise = function() {
|
|
32209
33251
|
if (this._promise) return this._promise;
|
|
32210
33252
|
this._promise = new Promise(
|
|
32211
|
-
function(
|
|
32212
|
-
this._once("end",
|
|
33253
|
+
function(resolve4, reject) {
|
|
33254
|
+
this._once("end", resolve4);
|
|
32213
33255
|
this._once("error", reject);
|
|
32214
33256
|
}.bind(this)
|
|
32215
33257
|
);
|
|
@@ -32386,12 +33428,12 @@ var require_client3 = __commonJS({
|
|
|
32386
33428
|
this._connect(callback);
|
|
32387
33429
|
return;
|
|
32388
33430
|
}
|
|
32389
|
-
return new this._Promise((
|
|
33431
|
+
return new this._Promise((resolve4, reject) => {
|
|
32390
33432
|
this._connect((error) => {
|
|
32391
33433
|
if (error) {
|
|
32392
33434
|
reject(error);
|
|
32393
33435
|
} else {
|
|
32394
|
-
|
|
33436
|
+
resolve4(this);
|
|
32395
33437
|
}
|
|
32396
33438
|
});
|
|
32397
33439
|
});
|
|
@@ -32415,8 +33457,8 @@ var require_client3 = __commonJS({
|
|
|
32415
33457
|
query = new NativeQuery(config, values, callback);
|
|
32416
33458
|
if (!query.callback) {
|
|
32417
33459
|
let resolveOut, rejectOut;
|
|
32418
|
-
result = new this._Promise((
|
|
32419
|
-
resolveOut =
|
|
33460
|
+
result = new this._Promise((resolve4, reject) => {
|
|
33461
|
+
resolveOut = resolve4;
|
|
32420
33462
|
rejectOut = reject;
|
|
32421
33463
|
}).catch((err) => {
|
|
32422
33464
|
Error.captureStackTrace(err);
|
|
@@ -32476,8 +33518,8 @@ var require_client3 = __commonJS({
|
|
|
32476
33518
|
}
|
|
32477
33519
|
let result;
|
|
32478
33520
|
if (!cb) {
|
|
32479
|
-
result = new this._Promise(function(
|
|
32480
|
-
cb = (err) => err ? reject(err) :
|
|
33521
|
+
result = new this._Promise(function(resolve4, reject) {
|
|
33522
|
+
cb = (err) => err ? reject(err) : resolve4();
|
|
32481
33523
|
});
|
|
32482
33524
|
}
|
|
32483
33525
|
this.native.end(function() {
|
|
@@ -36400,8 +37442,8 @@ var require_common = __commonJS({
|
|
|
36400
37442
|
}
|
|
36401
37443
|
return debug2;
|
|
36402
37444
|
}
|
|
36403
|
-
function extend(namespace,
|
|
36404
|
-
const newDebug = createDebug(this.namespace + (typeof
|
|
37445
|
+
function extend(namespace, delimiter2) {
|
|
37446
|
+
const newDebug = createDebug(this.namespace + (typeof delimiter2 === "undefined" ? ":" : delimiter2) + namespace);
|
|
36405
37447
|
newDebug.log = this.log;
|
|
36406
37448
|
return newDebug;
|
|
36407
37449
|
}
|
|
@@ -37126,8 +38168,8 @@ var require_utils4 = __commonJS({
|
|
|
37126
38168
|
}
|
|
37127
38169
|
exports.wrapMultiResult = wrapMultiResult;
|
|
37128
38170
|
function isInt(value) {
|
|
37129
|
-
const
|
|
37130
|
-
return !isNaN(value) && (
|
|
38171
|
+
const x2 = parseFloat(value);
|
|
38172
|
+
return !isNaN(value) && (x2 | 0) === x2;
|
|
37131
38173
|
}
|
|
37132
38174
|
exports.isInt = isInt;
|
|
37133
38175
|
function packObject(array) {
|
|
@@ -37584,7 +38626,7 @@ var require_Command = __commonJS({
|
|
|
37584
38626
|
}
|
|
37585
38627
|
}
|
|
37586
38628
|
initPromise() {
|
|
37587
|
-
const promise = new Promise((
|
|
38629
|
+
const promise = new Promise((resolve4, reject) => {
|
|
37588
38630
|
if (!this.transformed) {
|
|
37589
38631
|
this.transformed = true;
|
|
37590
38632
|
const transformer = _Command._transformer.argument[this.name];
|
|
@@ -37593,7 +38635,7 @@ var require_Command = __commonJS({
|
|
|
37593
38635
|
}
|
|
37594
38636
|
this.stringifyArguments();
|
|
37595
38637
|
}
|
|
37596
|
-
this.resolve = this._convertValue(
|
|
38638
|
+
this.resolve = this._convertValue(resolve4);
|
|
37597
38639
|
this.reject = (err) => {
|
|
37598
38640
|
this._clearTimers();
|
|
37599
38641
|
if (this.errorStack) {
|
|
@@ -37626,11 +38668,11 @@ var require_Command = __commonJS({
|
|
|
37626
38668
|
/**
|
|
37627
38669
|
* Convert the value from buffer to the target encoding.
|
|
37628
38670
|
*/
|
|
37629
|
-
_convertValue(
|
|
38671
|
+
_convertValue(resolve4) {
|
|
37630
38672
|
return (value) => {
|
|
37631
38673
|
try {
|
|
37632
38674
|
this._clearTimers();
|
|
37633
|
-
|
|
38675
|
+
resolve4(this.transformReply(value));
|
|
37634
38676
|
this.isResolved = true;
|
|
37635
38677
|
} catch (err) {
|
|
37636
38678
|
this.reject(err);
|
|
@@ -37736,9 +38778,9 @@ var require_Command = __commonJS({
|
|
|
37736
38778
|
this.length = 0;
|
|
37737
38779
|
this.items = [];
|
|
37738
38780
|
}
|
|
37739
|
-
push(
|
|
37740
|
-
this.length += Buffer.byteLength(
|
|
37741
|
-
this.items.push(
|
|
38781
|
+
push(x2) {
|
|
38782
|
+
this.length += Buffer.byteLength(x2);
|
|
38783
|
+
this.items.push(x2);
|
|
37742
38784
|
}
|
|
37743
38785
|
toBuffer() {
|
|
37744
38786
|
const result = Buffer.allocUnsafe(this.length);
|
|
@@ -37908,13 +38950,13 @@ var require_autoPipelining = __commonJS({
|
|
|
37908
38950
|
if (client.isCluster && !client.slots.length) {
|
|
37909
38951
|
if (client.status === "wait")
|
|
37910
38952
|
client.connect().catch(lodash_1.noop);
|
|
37911
|
-
return (0, standard_as_callback_1.default)(new Promise(function(
|
|
38953
|
+
return (0, standard_as_callback_1.default)(new Promise(function(resolve4, reject) {
|
|
37912
38954
|
client.delayUntilReady((err) => {
|
|
37913
38955
|
if (err) {
|
|
37914
38956
|
reject(err);
|
|
37915
38957
|
return;
|
|
37916
38958
|
}
|
|
37917
|
-
executeWithAutoPipelining(client, functionName, commandName, args, null).then(
|
|
38959
|
+
executeWithAutoPipelining(client, functionName, commandName, args, null).then(resolve4, reject);
|
|
37918
38960
|
});
|
|
37919
38961
|
}), callback);
|
|
37920
38962
|
}
|
|
@@ -37935,13 +38977,13 @@ var require_autoPipelining = __commonJS({
|
|
|
37935
38977
|
pipeline[exports.kExec] = true;
|
|
37936
38978
|
setImmediate(executeAutoPipeline, client, slotKey);
|
|
37937
38979
|
}
|
|
37938
|
-
const autoPipelinePromise = new Promise(function(
|
|
38980
|
+
const autoPipelinePromise = new Promise(function(resolve4, reject) {
|
|
37939
38981
|
pipeline[exports.kCallbacks].push(function(err, value) {
|
|
37940
38982
|
if (err) {
|
|
37941
38983
|
reject(err);
|
|
37942
38984
|
return;
|
|
37943
38985
|
}
|
|
37944
|
-
|
|
38986
|
+
resolve4(value);
|
|
37945
38987
|
});
|
|
37946
38988
|
if (functionName === "call") {
|
|
37947
38989
|
args.unshift(commandName);
|
|
@@ -38176,8 +39218,8 @@ var require_Pipeline = __commonJS({
|
|
|
38176
39218
|
this[name] = redis[name];
|
|
38177
39219
|
this[name + "Buffer"] = redis[name + "Buffer"];
|
|
38178
39220
|
});
|
|
38179
|
-
this.promise = new Promise((
|
|
38180
|
-
this.resolve =
|
|
39221
|
+
this.promise = new Promise((resolve4, reject) => {
|
|
39222
|
+
this.resolve = resolve4;
|
|
38181
39223
|
this.reject = reject;
|
|
38182
39224
|
});
|
|
38183
39225
|
const _this = this;
|
|
@@ -38477,13 +39519,13 @@ var require_transaction = __commonJS({
|
|
|
38477
39519
|
if (this.isCluster && !this.redis.slots.length) {
|
|
38478
39520
|
if (this.redis.status === "wait")
|
|
38479
39521
|
this.redis.connect().catch(utils_1.noop);
|
|
38480
|
-
return (0, standard_as_callback_1.default)(new Promise((
|
|
39522
|
+
return (0, standard_as_callback_1.default)(new Promise((resolve4, reject) => {
|
|
38481
39523
|
this.redis.delayUntilReady((err) => {
|
|
38482
39524
|
if (err) {
|
|
38483
39525
|
reject(err);
|
|
38484
39526
|
return;
|
|
38485
39527
|
}
|
|
38486
|
-
this.exec(pipeline).then(
|
|
39528
|
+
this.exec(pipeline).then(resolve4, reject);
|
|
38487
39529
|
});
|
|
38488
39530
|
}), callback);
|
|
38489
39531
|
}
|
|
@@ -39612,7 +40654,7 @@ var require_cluster = __commonJS({
|
|
|
39612
40654
|
* Connect to a cluster
|
|
39613
40655
|
*/
|
|
39614
40656
|
connect() {
|
|
39615
|
-
return new Promise((
|
|
40657
|
+
return new Promise((resolve4, reject) => {
|
|
39616
40658
|
if (this.status === "connecting" || this.status === "connect" || this.status === "ready") {
|
|
39617
40659
|
reject(new Error("Redis is already connecting/connected"));
|
|
39618
40660
|
return;
|
|
@@ -39641,7 +40683,7 @@ var require_cluster = __commonJS({
|
|
|
39641
40683
|
this.retryAttempts = 0;
|
|
39642
40684
|
this.executeOfflineCommands();
|
|
39643
40685
|
this.resetNodesRefreshInterval();
|
|
39644
|
-
|
|
40686
|
+
resolve4();
|
|
39645
40687
|
};
|
|
39646
40688
|
let closeListener = void 0;
|
|
39647
40689
|
const refreshListener = () => {
|
|
@@ -40251,7 +41293,7 @@ var require_cluster = __commonJS({
|
|
|
40251
41293
|
});
|
|
40252
41294
|
}
|
|
40253
41295
|
resolveSrv(hostname2) {
|
|
40254
|
-
return new Promise((
|
|
41296
|
+
return new Promise((resolve4, reject) => {
|
|
40255
41297
|
this.options.resolveSrv(hostname2, (err, records) => {
|
|
40256
41298
|
if (err) {
|
|
40257
41299
|
return reject(err);
|
|
@@ -40265,7 +41307,7 @@ var require_cluster = __commonJS({
|
|
|
40265
41307
|
if (!group.records.length) {
|
|
40266
41308
|
sortedKeys.shift();
|
|
40267
41309
|
}
|
|
40268
|
-
self2.dnsLookup(record.name).then((host) =>
|
|
41310
|
+
self2.dnsLookup(record.name).then((host) => resolve4({
|
|
40269
41311
|
host,
|
|
40270
41312
|
port: record.port
|
|
40271
41313
|
}), tryFirstOne);
|
|
@@ -40275,14 +41317,14 @@ var require_cluster = __commonJS({
|
|
|
40275
41317
|
});
|
|
40276
41318
|
}
|
|
40277
41319
|
dnsLookup(hostname2) {
|
|
40278
|
-
return new Promise((
|
|
41320
|
+
return new Promise((resolve4, reject) => {
|
|
40279
41321
|
this.options.dnsLookup(hostname2, (err, address) => {
|
|
40280
41322
|
if (err) {
|
|
40281
41323
|
debug2("failed to resolve hostname %s to IP: %s", hostname2, err.message);
|
|
40282
41324
|
reject(err);
|
|
40283
41325
|
} else {
|
|
40284
41326
|
debug2("resolved hostname %s to IP %s", hostname2, address);
|
|
40285
|
-
|
|
41327
|
+
resolve4(address);
|
|
40286
41328
|
}
|
|
40287
41329
|
});
|
|
40288
41330
|
});
|
|
@@ -40437,7 +41479,7 @@ var require_StandaloneConnector = __commonJS({
|
|
|
40437
41479
|
if (options.tls) {
|
|
40438
41480
|
Object.assign(connectionOptions, options.tls);
|
|
40439
41481
|
}
|
|
40440
|
-
return new Promise((
|
|
41482
|
+
return new Promise((resolve4, reject) => {
|
|
40441
41483
|
process.nextTick(() => {
|
|
40442
41484
|
if (!this.connecting) {
|
|
40443
41485
|
reject(new Error(utils_1.CONNECTION_CLOSED_ERROR_MSG));
|
|
@@ -40456,7 +41498,7 @@ var require_StandaloneConnector = __commonJS({
|
|
|
40456
41498
|
this.stream.once("error", (err) => {
|
|
40457
41499
|
this.firstError = err;
|
|
40458
41500
|
});
|
|
40459
|
-
|
|
41501
|
+
resolve4(this.stream);
|
|
40460
41502
|
});
|
|
40461
41503
|
});
|
|
40462
41504
|
}
|
|
@@ -40612,7 +41654,7 @@ var require_SentinelConnector = __commonJS({
|
|
|
40612
41654
|
const error = new Error(errorMsg);
|
|
40613
41655
|
if (typeof retryDelay === "number") {
|
|
40614
41656
|
eventEmitter("error", error);
|
|
40615
|
-
await new Promise((
|
|
41657
|
+
await new Promise((resolve4) => setTimeout(resolve4, retryDelay));
|
|
40616
41658
|
return connectToNext();
|
|
40617
41659
|
} else {
|
|
40618
41660
|
throw error;
|
|
@@ -41929,7 +42971,7 @@ var require_Redis = __commonJS({
|
|
|
41929
42971
|
* if the connection fails, times out, or if Redis is already connecting/connected.
|
|
41930
42972
|
*/
|
|
41931
42973
|
connect(callback) {
|
|
41932
|
-
const promise = new Promise((
|
|
42974
|
+
const promise = new Promise((resolve4, reject) => {
|
|
41933
42975
|
if (this.status === "connecting" || this.status === "connect" || this.status === "ready") {
|
|
41934
42976
|
reject(new Error("Redis is already connecting/connected"));
|
|
41935
42977
|
return;
|
|
@@ -42008,7 +43050,7 @@ var require_Redis = __commonJS({
|
|
|
42008
43050
|
}
|
|
42009
43051
|
const connectionReadyHandler = function() {
|
|
42010
43052
|
_this.removeListener("close", connectionCloseHandler);
|
|
42011
|
-
|
|
43053
|
+
resolve4();
|
|
42012
43054
|
};
|
|
42013
43055
|
var connectionCloseHandler = function() {
|
|
42014
43056
|
_this.removeListener("ready", connectionReadyHandler);
|
|
@@ -42102,10 +43144,10 @@ var require_Redis = __commonJS({
|
|
|
42102
43144
|
monitor: true,
|
|
42103
43145
|
lazyConnect: false
|
|
42104
43146
|
});
|
|
42105
|
-
return (0, standard_as_callback_1.default)(new Promise(function(
|
|
43147
|
+
return (0, standard_as_callback_1.default)(new Promise(function(resolve4, reject) {
|
|
42106
43148
|
monitorInstance.once("error", reject);
|
|
42107
43149
|
monitorInstance.once("monitoring", function() {
|
|
42108
|
-
|
|
43150
|
+
resolve4(monitorInstance);
|
|
42109
43151
|
});
|
|
42110
43152
|
}), callback);
|
|
42111
43153
|
}
|
|
@@ -42878,7 +43920,15 @@ async function runMenu() {
|
|
|
42878
43920
|
});
|
|
42879
43921
|
if (!q(setup) && setup) {
|
|
42880
43922
|
const { runInitFlow: runInitFlow2 } = await Promise.resolve().then(() => (init_init(), init_exports));
|
|
42881
|
-
await runInitFlow2(client, {
|
|
43923
|
+
const outcome = await runInitFlow2(client, {
|
|
43924
|
+
cwd: process.cwd(),
|
|
43925
|
+
dryRun: false,
|
|
43926
|
+
noScripts: false
|
|
43927
|
+
});
|
|
43928
|
+
if (outcome.exitCode === 0) {
|
|
43929
|
+
ye("All set. Run keynv again anytime to manage secrets.");
|
|
43930
|
+
return 0;
|
|
43931
|
+
}
|
|
42882
43932
|
}
|
|
42883
43933
|
}
|
|
42884
43934
|
}
|
|
@@ -42948,8 +43998,8 @@ var init_menu = __esm({
|
|
|
42948
43998
|
"src/ui/menu.ts"() {
|
|
42949
43999
|
init_dist5();
|
|
42950
44000
|
init_http();
|
|
42951
|
-
init_detect();
|
|
42952
44001
|
init_store();
|
|
44002
|
+
init_detect();
|
|
42953
44003
|
init_version();
|
|
42954
44004
|
init_audit2();
|
|
42955
44005
|
init_login();
|
|
@@ -43963,11 +45013,11 @@ function formatMarkdownish(text, { format, paragraphs }) {
|
|
|
43963
45013
|
|
|
43964
45014
|
`);
|
|
43965
45015
|
}
|
|
43966
|
-
text = text.replace(/(`+)((?:.|[\n])*?)\1/g, ($0, $1, $
|
|
43967
|
-
return format.code($1 + $
|
|
45016
|
+
text = text.replace(/(`+)((?:.|[\n])*?)\1/g, ($0, $1, $22) => {
|
|
45017
|
+
return format.code($1 + $22 + $1);
|
|
43968
45018
|
});
|
|
43969
|
-
text = text.replace(/(\*\*)((?:.|[\n])*?)\1/g, ($0, $1, $
|
|
43970
|
-
return format.bold($1 + $
|
|
45019
|
+
text = text.replace(/(\*\*)((?:.|[\n])*?)\1/g, ($0, $1, $22) => {
|
|
45020
|
+
return format.bold($1 + $22 + $1);
|
|
43971
45021
|
});
|
|
43972
45022
|
return text ? `${text}
|
|
43973
45023
|
` : ``;
|
|
@@ -44749,8 +45799,6 @@ var AuditVerifyCommand = class extends Command {
|
|
|
44749
45799
|
}
|
|
44750
45800
|
}
|
|
44751
45801
|
};
|
|
44752
|
-
|
|
44753
|
-
// src/commands/exec.ts
|
|
44754
45802
|
init_http();
|
|
44755
45803
|
init_envFile();
|
|
44756
45804
|
|
|
@@ -44758,15 +45806,15 @@ init_envFile();
|
|
|
44758
45806
|
init_dist();
|
|
44759
45807
|
async function resolveAllAliases(client, argv2, extraStrings = []) {
|
|
44760
45808
|
const seen = /* @__PURE__ */ new Map();
|
|
44761
|
-
const argvScans = findAliasesInArgv(argv2);
|
|
45809
|
+
const argvScans = reference_exports.findAliasesInArgv(argv2);
|
|
44762
45810
|
for (const { matches } of argvScans) {
|
|
44763
45811
|
for (const m of matches) {
|
|
44764
45812
|
seen.set(m.literal, m);
|
|
44765
45813
|
}
|
|
44766
45814
|
}
|
|
44767
45815
|
for (const s of extraStrings) {
|
|
44768
|
-
for (const m of findAliasesInArgv([s])) {
|
|
44769
|
-
for (const
|
|
45816
|
+
for (const m of reference_exports.findAliasesInArgv([s])) {
|
|
45817
|
+
for (const x2 of m.matches) seen.set(x2.literal, x2);
|
|
44770
45818
|
}
|
|
44771
45819
|
}
|
|
44772
45820
|
if (seen.size === 0) return [];
|
|
@@ -44858,10 +45906,18 @@ var BUILTIN_PATTERNS = [
|
|
|
44858
45906
|
name: "stripe-live-secret-key",
|
|
44859
45907
|
regex: /\bsk_live_[A-Za-z0-9]{24,}\b/g
|
|
44860
45908
|
},
|
|
45909
|
+
{
|
|
45910
|
+
name: "stripe-test-secret-key",
|
|
45911
|
+
regex: /\bsk_test_[A-Za-z0-9]{24,}\b/g
|
|
45912
|
+
},
|
|
44861
45913
|
{
|
|
44862
45914
|
name: "stripe-restricted-live-key",
|
|
44863
45915
|
regex: /\brk_live_[A-Za-z0-9]{24,}\b/g
|
|
44864
45916
|
},
|
|
45917
|
+
{
|
|
45918
|
+
name: "stripe-restricted-test-key",
|
|
45919
|
+
regex: /\brk_test_[A-Za-z0-9]{24,}\b/g
|
|
45920
|
+
},
|
|
44865
45921
|
{
|
|
44866
45922
|
// Negative lookahead skips Anthropic-prefixed keys so the more
|
|
44867
45923
|
// specific anthropic-api-key pattern wins on those.
|
|
@@ -44957,7 +46013,9 @@ function defaultRender(name) {
|
|
|
44957
46013
|
return `<REDACTED:${name}>`;
|
|
44958
46014
|
}
|
|
44959
46015
|
function preview(matched) {
|
|
44960
|
-
|
|
46016
|
+
if (matched.length <= 4)
|
|
46017
|
+
return "****";
|
|
46018
|
+
return `${matched.slice(0, 4)}...`;
|
|
44961
46019
|
}
|
|
44962
46020
|
function escapeRegExp(s) {
|
|
44963
46021
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -44988,8 +46046,8 @@ function redact(text, opts = {}) {
|
|
|
44988
46046
|
for (const literal of opts.literals) {
|
|
44989
46047
|
if (!literal)
|
|
44990
46048
|
continue;
|
|
44991
|
-
const
|
|
44992
|
-
for (const m of text.matchAll(
|
|
46049
|
+
const re2 = new RegExp(escapeRegExp(literal), "g");
|
|
46050
|
+
for (const m of text.matchAll(re2)) {
|
|
44993
46051
|
if (m.index === void 0)
|
|
44994
46052
|
continue;
|
|
44995
46053
|
raw.push({
|
|
@@ -45099,7 +46157,9 @@ var ENV_ALLOWLIST = [
|
|
|
45099
46157
|
"WINDIR",
|
|
45100
46158
|
"COMSPEC",
|
|
45101
46159
|
"APPDATA",
|
|
45102
|
-
"LOCALAPPDATA"
|
|
46160
|
+
"LOCALAPPDATA",
|
|
46161
|
+
"PATHEXT"
|
|
46162
|
+
// needed so child processes can resolve executables by name
|
|
45103
46163
|
];
|
|
45104
46164
|
function spawnPrivileged(opts) {
|
|
45105
46165
|
const startedAt = Date.now();
|
|
@@ -45108,6 +46168,11 @@ function spawnPrivileged(opts) {
|
|
|
45108
46168
|
const v2 = process.env[name];
|
|
45109
46169
|
if (v2 !== void 0) env2[name] = v2;
|
|
45110
46170
|
}
|
|
46171
|
+
const nmBin = findNodeModulesBin(process.cwd());
|
|
46172
|
+
if (nmBin) {
|
|
46173
|
+
const existingPath = env2.PATH ?? "";
|
|
46174
|
+
env2.PATH = existingPath.startsWith(nmBin + nodePath.delimiter) ? existingPath : nmBin + nodePath.delimiter + existingPath;
|
|
46175
|
+
}
|
|
45111
46176
|
if (opts.injectedEnv) {
|
|
45112
46177
|
for (const [k2, v2] of Object.entries(opts.injectedEnv)) env2[k2] = v2;
|
|
45113
46178
|
}
|
|
@@ -45133,14 +46198,33 @@ function spawnPrivileged(opts) {
|
|
|
45133
46198
|
]);
|
|
45134
46199
|
let spawnCmd = opts.command;
|
|
45135
46200
|
let spawnArgs = opts.args;
|
|
45136
|
-
|
|
45137
|
-
|
|
45138
|
-
|
|
46201
|
+
let windowsVerbatimArguments = false;
|
|
46202
|
+
if (process.platform === "win32") {
|
|
46203
|
+
const comspec = env2.COMSPEC ?? process.env.COMSPEC ?? "cmd.exe";
|
|
46204
|
+
if (WIN_BUILTINS.has(opts.command.toLowerCase())) {
|
|
46205
|
+
spawnCmd = comspec;
|
|
46206
|
+
spawnArgs = ["/d", "/s", "/c", opts.command, ...opts.args];
|
|
46207
|
+
} else {
|
|
46208
|
+
const resolved = resolveWindowsCmd(opts.command, env2);
|
|
46209
|
+
if (resolved !== null) {
|
|
46210
|
+
const ext = nodePath.extname(resolved).toLowerCase();
|
|
46211
|
+
if (ext === ".cmd" || ext === ".bat") {
|
|
46212
|
+
const q2 = (s) => s.includes(" ") ? `"${s}"` : s;
|
|
46213
|
+
const inner = [q2(resolved), ...opts.args.map(q2)].join(" ");
|
|
46214
|
+
spawnCmd = comspec;
|
|
46215
|
+
spawnArgs = ["/d", "/s", "/c", `"${inner}"`];
|
|
46216
|
+
windowsVerbatimArguments = true;
|
|
46217
|
+
} else {
|
|
46218
|
+
spawnCmd = resolved;
|
|
46219
|
+
}
|
|
46220
|
+
}
|
|
46221
|
+
}
|
|
45139
46222
|
}
|
|
45140
46223
|
const child = spawn(spawnCmd, spawnArgs, {
|
|
45141
46224
|
env: env2,
|
|
45142
46225
|
stdio,
|
|
45143
|
-
detached: false
|
|
46226
|
+
detached: false,
|
|
46227
|
+
windowsVerbatimArguments
|
|
45144
46228
|
});
|
|
45145
46229
|
const literals = opts.resolved.map((r) => r.value).filter((v2) => v2.length > 0);
|
|
45146
46230
|
if (!opts.noRedact && child.stdout) {
|
|
@@ -45161,14 +46245,14 @@ function spawnPrivileged(opts) {
|
|
|
45161
46245
|
}, opts.timeoutS * 1e3);
|
|
45162
46246
|
timer.unref();
|
|
45163
46247
|
}
|
|
45164
|
-
return new Promise((
|
|
46248
|
+
return new Promise((resolve4, reject) => {
|
|
45165
46249
|
child.on("error", (err) => {
|
|
45166
46250
|
if (timer) clearTimeout(timer);
|
|
45167
46251
|
reject(err);
|
|
45168
46252
|
});
|
|
45169
46253
|
child.on("close", (code, signal) => {
|
|
45170
46254
|
if (timer) clearTimeout(timer);
|
|
45171
|
-
|
|
46255
|
+
resolve4({
|
|
45172
46256
|
exitCode: code ?? 0,
|
|
45173
46257
|
signal,
|
|
45174
46258
|
durationMs: Date.now() - startedAt
|
|
@@ -45176,6 +46260,34 @@ function spawnPrivileged(opts) {
|
|
|
45176
46260
|
});
|
|
45177
46261
|
});
|
|
45178
46262
|
}
|
|
46263
|
+
function resolveWindowsCmd(command, subprocessEnv) {
|
|
46264
|
+
if (nodePath.extname(command)) return null;
|
|
46265
|
+
if (command.includes("/") || command.includes("\\")) return null;
|
|
46266
|
+
const pathExt = (process.env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").map((e2) => e2.toLowerCase()).filter(Boolean);
|
|
46267
|
+
const pathStr = subprocessEnv.PATH ?? process.env.PATH ?? "";
|
|
46268
|
+
const pathDirs = pathStr.split(nodePath.delimiter).filter(Boolean);
|
|
46269
|
+
for (const dir of pathDirs) {
|
|
46270
|
+
for (const ext of pathExt) {
|
|
46271
|
+
try {
|
|
46272
|
+
const full = nodePath.join(dir, command + ext);
|
|
46273
|
+
if (existsSync(full)) return full;
|
|
46274
|
+
} catch {
|
|
46275
|
+
}
|
|
46276
|
+
}
|
|
46277
|
+
}
|
|
46278
|
+
return null;
|
|
46279
|
+
}
|
|
46280
|
+
function findNodeModulesBin(cwd) {
|
|
46281
|
+
let dir = nodePath.resolve(cwd);
|
|
46282
|
+
for (let i = 0; i < 20; i++) {
|
|
46283
|
+
const candidate = nodePath.join(dir, "node_modules", ".bin");
|
|
46284
|
+
if (existsSync(candidate)) return candidate;
|
|
46285
|
+
const parent = nodePath.dirname(dir);
|
|
46286
|
+
if (parent === dir) break;
|
|
46287
|
+
dir = parent;
|
|
46288
|
+
}
|
|
46289
|
+
return null;
|
|
46290
|
+
}
|
|
45179
46291
|
|
|
45180
46292
|
// src/commands/exec.ts
|
|
45181
46293
|
var ExecCommand = class extends Command {
|
|
@@ -45232,6 +46344,10 @@ spelled \`--from\` to avoid the collision.)
|
|
|
45232
46344
|
quiet = options_exports.Boolean("--quiet", false, {
|
|
45233
46345
|
description: `Suppress the "loaded N vars from ${ENV_FILE_BASENAME}" status line.`
|
|
45234
46346
|
});
|
|
46347
|
+
// Option.Rest: keynv options (e.g. --no-env-file) are parsed before `--`.
|
|
46348
|
+
// Everything after `--` is captured in rest verbatim, including subprocess
|
|
46349
|
+
// flags like `--port 3005` and `-v`. Always use `--` to separate keynv
|
|
46350
|
+
// options from the subprocess command.
|
|
45235
46351
|
rest = options_exports.Rest();
|
|
45236
46352
|
async execute() {
|
|
45237
46353
|
if (!this.rest || this.rest.length === 0) {
|
|
@@ -45274,6 +46390,13 @@ spelled \`--from\` to avoid the collision.)
|
|
|
45274
46390
|
);
|
|
45275
46391
|
return 2;
|
|
45276
46392
|
}
|
|
46393
|
+
if (!envFileLoaded && !this.noEnvFile && !this.envFile && !process.env.KEYNV_ENV_FILE) {
|
|
46394
|
+
this.context.stderr.write(
|
|
46395
|
+
`keynv: no ${ENV_FILE_BASENAME} found in this directory or any parent.
|
|
46396
|
+
Run \`keynv init\` in your project root to migrate secrets and create one.
|
|
46397
|
+
`
|
|
46398
|
+
);
|
|
46399
|
+
}
|
|
45277
46400
|
const viaEnvSpecs = [];
|
|
45278
46401
|
for (const spec of this.viaEnv ?? []) {
|
|
45279
46402
|
const eq = spec.indexOf("=");
|
|
@@ -45349,13 +46472,14 @@ spelled \`--from\` to avoid the collision.)
|
|
|
45349
46472
|
const displayPath = relative(process.cwd(), envFileLoaded.path) || envFileLoaded.path;
|
|
45350
46473
|
const parts = [];
|
|
45351
46474
|
if (aliasEntries.length > 0) {
|
|
45352
|
-
parts.push(aliasEntries.map((e2) => `${e2.name}=${e2.value}`).join(", ")
|
|
46475
|
+
parts.push(`${aliasEntries.map((e2) => `${e2.name}=${e2.value}`).join(", ")} (vault)`);
|
|
45353
46476
|
}
|
|
45354
46477
|
if (plainEntries.length > 0) {
|
|
45355
|
-
parts.push(plainEntries.map((e2) => e2.name).join(", ")
|
|
46478
|
+
parts.push(`${plainEntries.map((e2) => e2.name).join(", ")} (plain)`);
|
|
45356
46479
|
}
|
|
45357
46480
|
this.context.stderr.write(
|
|
45358
|
-
`keynv: loaded ${displayPath}
|
|
46481
|
+
`keynv: loaded ${displayPath}${parts.length > 0 ? ` \u2014 ${parts.join("; ")}` : ""}
|
|
46482
|
+
`
|
|
45359
46483
|
);
|
|
45360
46484
|
}
|
|
45361
46485
|
const timeoutS = this.timeout ? Number.parseInt(this.timeout, 10) : void 0;
|
|
@@ -45398,6 +46522,8 @@ function signalNumber(sig) {
|
|
|
45398
46522
|
init_dist();
|
|
45399
46523
|
init_http();
|
|
45400
46524
|
init_envFile();
|
|
46525
|
+
init_ai_context();
|
|
46526
|
+
init_detect();
|
|
45401
46527
|
init_heuristics();
|
|
45402
46528
|
init_init();
|
|
45403
46529
|
init_cancel();
|
|
@@ -45414,7 +46540,8 @@ async function resolveProjectId(client, input) {
|
|
|
45414
46540
|
return input;
|
|
45415
46541
|
}
|
|
45416
46542
|
const data = await client.request("/v1/projects");
|
|
45417
|
-
const
|
|
46543
|
+
const lowerInput = input.toLowerCase();
|
|
46544
|
+
const match = data.projects.find((p2) => p2.name.toLowerCase() === lowerInput);
|
|
45418
46545
|
if (!match) throw new Error(`project not found: ${input}`);
|
|
45419
46546
|
return match.id;
|
|
45420
46547
|
}
|
|
@@ -45547,6 +46674,14 @@ var ProjectDeleteCommand = class extends Command {
|
|
|
45547
46674
|
};
|
|
45548
46675
|
|
|
45549
46676
|
// src/commands/init.ts
|
|
46677
|
+
function toAliasKey2(name) {
|
|
46678
|
+
if (!name) return name;
|
|
46679
|
+
const KEY_RE3 = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/;
|
|
46680
|
+
if (KEY_RE3.test(name)) return name;
|
|
46681
|
+
const normalised = name.toLowerCase().replace(/_/g, "-");
|
|
46682
|
+
if (KEY_RE3.test(normalised)) return normalised;
|
|
46683
|
+
return normalised.replace(/[^a-zA-Z0-9_-]/g, "").slice(0, 64) || "key";
|
|
46684
|
+
}
|
|
45550
46685
|
var InitCommand = class extends Command {
|
|
45551
46686
|
static paths = [["init"]];
|
|
45552
46687
|
static usage = Command.Usage({
|
|
@@ -45565,15 +46700,16 @@ mappings that would be written to .keynv.env, then exits without
|
|
|
45565
46700
|
touching any files or making any network calls. Use it to preview
|
|
45566
46701
|
what init will do before committing.
|
|
45567
46702
|
|
|
45568
|
-
|
|
45569
|
-
|
|
45570
|
-
|
|
46703
|
+
For scripted migration, use \`--env-file\` or \`--secret\` flags, or
|
|
46704
|
+
\`--yes\` to auto-scan the project directory and set up without
|
|
46705
|
+
any prompts.
|
|
45571
46706
|
`,
|
|
45572
46707
|
examples: [
|
|
45573
46708
|
["Walk the current project", "$0 init"],
|
|
45574
46709
|
["Preview without writing or uploading", "$0 init --dry-run"],
|
|
45575
46710
|
["Skip the package.json script-wrapping step", "$0 init --no-scripts"],
|
|
45576
|
-
["Non-interactive (CI/CD)", "$0 init --env-file .env --project myproject --env dev"]
|
|
46711
|
+
["Non-interactive (CI/CD)", "$0 init --env-file .env --project myproject --env dev"],
|
|
46712
|
+
["Auto-scan & set up without prompts (CI/CD)", "$0 init --yes"]
|
|
45577
46713
|
]
|
|
45578
46714
|
});
|
|
45579
46715
|
dryRun = options_exports.Boolean("--dry-run", false, {
|
|
@@ -45594,6 +46730,9 @@ commands directly.
|
|
|
45594
46730
|
secret = options_exports.Array("--secret", {
|
|
45595
46731
|
description: "KEY=value secret to upload (non-interactive). Can be specified multiple times."
|
|
45596
46732
|
});
|
|
46733
|
+
yes = options_exports.Boolean("--yes", false, {
|
|
46734
|
+
description: "Auto-scan .env files, classify, and set up without prompts. Implies non-interactive mode."
|
|
46735
|
+
});
|
|
45597
46736
|
async execute() {
|
|
45598
46737
|
const client = new ApiClient();
|
|
45599
46738
|
await client.ensureHydrated();
|
|
@@ -45603,13 +46742,13 @@ commands directly.
|
|
|
45603
46742
|
}
|
|
45604
46743
|
const hasEnvFile = this.envFile != null;
|
|
45605
46744
|
const hasSecrets = this.secret != null && this.secret.length > 0;
|
|
45606
|
-
const isNonInteractive = hasEnvFile || hasSecrets;
|
|
46745
|
+
const isNonInteractive = hasEnvFile || hasSecrets || this.dryRun || this.yes;
|
|
45607
46746
|
if (isNonInteractive) {
|
|
45608
46747
|
return this.runNonInteractive(client);
|
|
45609
46748
|
}
|
|
45610
46749
|
if (!isInteractive()) {
|
|
45611
46750
|
this.context.stderr.write(
|
|
45612
|
-
"keynv init requires an interactive terminal. Use --env-file or --secret for scripted setup.\n"
|
|
46751
|
+
"keynv init requires an interactive terminal. Use --dry-run, --env-file, or --secret for scripted setup.\n"
|
|
45613
46752
|
);
|
|
45614
46753
|
return 1;
|
|
45615
46754
|
}
|
|
@@ -45629,6 +46768,9 @@ commands directly.
|
|
|
45629
46768
|
}
|
|
45630
46769
|
}
|
|
45631
46770
|
async runNonInteractive(client) {
|
|
46771
|
+
if (this.yes && !this.envFile && !this.secret) {
|
|
46772
|
+
return this.runAutoScan(client);
|
|
46773
|
+
}
|
|
45632
46774
|
const projectName = this.project;
|
|
45633
46775
|
if (!projectName) {
|
|
45634
46776
|
this.context.stderr.write("keynv: --project is required in non-interactive mode.\n");
|
|
@@ -45678,34 +46820,147 @@ commands directly.
|
|
|
45678
46820
|
return 0;
|
|
45679
46821
|
}
|
|
45680
46822
|
if (this.dryRun) {
|
|
45681
|
-
this.
|
|
45682
|
-
|
|
46823
|
+
if (this.envFile || this.secret && this.secret.length > 0) {
|
|
46824
|
+
this.context.stdout.write(
|
|
46825
|
+
`keynv: dry-run \u2014 would upload ${secrets.length} secret(s) to project ${projectName} (${projectId2}) in env ${envName}
|
|
45683
46826
|
`
|
|
46827
|
+
);
|
|
46828
|
+
for (const { name } of secrets) {
|
|
46829
|
+
const aliasKey = toAliasKey2(name);
|
|
46830
|
+
this.context.stdout.write(` ${name}=@${projectName}.${envName}.${aliasKey}
|
|
46831
|
+
`);
|
|
46832
|
+
}
|
|
46833
|
+
return 0;
|
|
46834
|
+
}
|
|
46835
|
+
this.context.stdout.write(
|
|
46836
|
+
"keynv: dry-run mode \u2014 no --env-file or --secret provided. Nothing to scan.\n"
|
|
45684
46837
|
);
|
|
46838
|
+
return 0;
|
|
46839
|
+
}
|
|
46840
|
+
const secretsWithKeys = secrets.map((s) => ({ ...s, aliasKey: toAliasKey2(s.name) }));
|
|
46841
|
+
return this.uploadSecrets(client, projectId2, projectName, envName, secretsWithKeys);
|
|
46842
|
+
}
|
|
46843
|
+
/**
|
|
46844
|
+
* Auto-scan mode (--yes without explicit --env-file). Finds .env files
|
|
46845
|
+
* in the project root, classifies entries, creates a project, uploads
|
|
46846
|
+
* secrets, and writes .keynv.env — all without prompts.
|
|
46847
|
+
*/
|
|
46848
|
+
async runAutoScan(client) {
|
|
46849
|
+
const root = findProjectRoot(process.cwd());
|
|
46850
|
+
if (!root) {
|
|
46851
|
+
this.context.stderr.write("keynv: no project root found (no package.json, .git, etc.).\n");
|
|
46852
|
+
return 1;
|
|
46853
|
+
}
|
|
46854
|
+
const envFiles = findEnvFiles(root.path);
|
|
46855
|
+
if (envFiles.length === 0) {
|
|
46856
|
+
this.context.stdout.write("keynv: no .env files found. Nothing to migrate.\n");
|
|
46857
|
+
return 0;
|
|
46858
|
+
}
|
|
46859
|
+
const projectName = this.project ?? root.suggestedName;
|
|
46860
|
+
const envName = this.env ?? suggestedEnvForSuffix(envFiles[0]?.suffix ?? null);
|
|
46861
|
+
const secrets = [];
|
|
46862
|
+
for (const f of envFiles) {
|
|
46863
|
+
try {
|
|
46864
|
+
const entries = parseEnvFile(readFileSync(f.path, "utf8"), f.path);
|
|
46865
|
+
for (const e2 of entries) {
|
|
46866
|
+
if (classifyEntry(e2.name, e2.value).verdict === "secret") {
|
|
46867
|
+
secrets.push({ name: e2.name, value: e2.value });
|
|
46868
|
+
}
|
|
46869
|
+
}
|
|
46870
|
+
} catch {
|
|
46871
|
+
this.context.stderr.write(`keynv: warning \u2014 could not parse ${f.name}, skipping.
|
|
46872
|
+
`);
|
|
46873
|
+
}
|
|
46874
|
+
}
|
|
46875
|
+
if (secrets.length === 0) {
|
|
46876
|
+
this.context.stdout.write("keynv: no secrets detected in .env files. Nothing to upload.\n");
|
|
46877
|
+
return 0;
|
|
46878
|
+
}
|
|
46879
|
+
this.context.stdout.write(
|
|
46880
|
+
`keynv: auto-scan found ${secrets.length} secret(s) across ${envFiles.length} file(s).
|
|
46881
|
+
`
|
|
46882
|
+
);
|
|
46883
|
+
if (this.dryRun) {
|
|
45685
46884
|
for (const { name } of secrets) {
|
|
45686
|
-
const aliasKey = name
|
|
46885
|
+
const aliasKey = toAliasKey2(name);
|
|
45687
46886
|
this.context.stdout.write(` ${name}=@${projectName}.${envName}.${aliasKey}
|
|
45688
46887
|
`);
|
|
45689
46888
|
}
|
|
45690
46889
|
return 0;
|
|
45691
46890
|
}
|
|
46891
|
+
let projectId2;
|
|
46892
|
+
try {
|
|
46893
|
+
projectId2 = await resolveProjectId(client, projectName);
|
|
46894
|
+
} catch {
|
|
46895
|
+
const created = await client.request("/v1/projects", {
|
|
46896
|
+
method: "POST",
|
|
46897
|
+
body: {
|
|
46898
|
+
name: projectName,
|
|
46899
|
+
environments: [{ name: envName, tier: "non-production", require_approval: false }]
|
|
46900
|
+
}
|
|
46901
|
+
});
|
|
46902
|
+
projectId2 = created.id;
|
|
46903
|
+
this.context.stdout.write(`keynv: created project "${projectName}" (${projectId2}).
|
|
46904
|
+
`);
|
|
46905
|
+
}
|
|
46906
|
+
const secretsWithKeys = secrets.map((s) => ({ ...s, aliasKey: toAliasKey2(s.name) }));
|
|
46907
|
+
const result = await this.uploadSecrets(
|
|
46908
|
+
client,
|
|
46909
|
+
projectId2,
|
|
46910
|
+
projectName,
|
|
46911
|
+
envName,
|
|
46912
|
+
secretsWithKeys
|
|
46913
|
+
);
|
|
46914
|
+
if (result !== 0) return result;
|
|
46915
|
+
const aliasLines = secretsWithKeys.map((s) => `# ${s.name}
|
|
46916
|
+
${s.name}=@${projectName}.${envName}.${s.aliasKey}`).join("\n");
|
|
46917
|
+
const keynvEnvPath = join(root.path, ".keynv.env");
|
|
46918
|
+
writeFileSync(keynvEnvPath, `# Auto-generated by keynv init --yes
|
|
46919
|
+
${aliasLines}
|
|
46920
|
+
`);
|
|
46921
|
+
this.context.stdout.write(`keynv: wrote ${keynvEnvPath}
|
|
46922
|
+
`);
|
|
46923
|
+
try {
|
|
46924
|
+
const outcome = writeAiContext(root.path);
|
|
46925
|
+
if (outcome === "created") this.context.stdout.write("keynv: wrote AGENTS.md\n");
|
|
46926
|
+
} catch {
|
|
46927
|
+
this.context.stdout.write("keynv: warning \u2014 could not write AGENTS.md.\n");
|
|
46928
|
+
}
|
|
46929
|
+
for (const f of envFiles) {
|
|
46930
|
+
unlinkSync(f.path);
|
|
46931
|
+
this.context.stdout.write(`keynv: removed ${f.name} (secrets migrated to vault).
|
|
46932
|
+
`);
|
|
46933
|
+
}
|
|
46934
|
+
this.context.stdout.write(
|
|
46935
|
+
"keynv: done. Use `keynv exec` to run commands with resolved secrets.\n"
|
|
46936
|
+
);
|
|
46937
|
+
return 0;
|
|
46938
|
+
}
|
|
46939
|
+
/**
|
|
46940
|
+
* Upload secrets to the vault and print the result. Shared between
|
|
46941
|
+
* runNonInteractive and runAutoScan.
|
|
46942
|
+
*/
|
|
46943
|
+
async uploadSecrets(client, projectId2, projectName, envName, secrets) {
|
|
45692
46944
|
let uploaded = 0;
|
|
45693
46945
|
const failed = [];
|
|
45694
|
-
for (const
|
|
45695
|
-
const
|
|
45696
|
-
|
|
46946
|
+
for (const s of secrets) {
|
|
46947
|
+
const alias2 = reference_exports.buildAlias({
|
|
46948
|
+
project: projectName,
|
|
46949
|
+
environment: envName,
|
|
46950
|
+
key: s.aliasKey
|
|
46951
|
+
});
|
|
45697
46952
|
if (!alias2) {
|
|
45698
|
-
failed.push(
|
|
46953
|
+
failed.push({ name: s.name, reason: `invalid alias key: ${s.aliasKey}` });
|
|
45699
46954
|
continue;
|
|
45700
46955
|
}
|
|
45701
46956
|
try {
|
|
45702
46957
|
await client.request(`/v1/projects/${projectId2}/secrets`, {
|
|
45703
46958
|
method: "POST",
|
|
45704
|
-
body: { env: envName, key: aliasKey, value }
|
|
46959
|
+
body: { env: envName, key: s.aliasKey, value: s.value }
|
|
45705
46960
|
});
|
|
45706
46961
|
uploaded++;
|
|
45707
46962
|
} catch (err) {
|
|
45708
|
-
failed.push(
|
|
46963
|
+
failed.push({ name: s.name, reason: err instanceof Error ? err.message : String(err) });
|
|
45709
46964
|
}
|
|
45710
46965
|
}
|
|
45711
46966
|
this.context.stdout.write(
|
|
@@ -45713,7 +46968,7 @@ commands directly.
|
|
|
45713
46968
|
`
|
|
45714
46969
|
);
|
|
45715
46970
|
if (failed.length > 0) {
|
|
45716
|
-
for (const f of failed) this.context.stderr.write(` failed: ${f}
|
|
46971
|
+
for (const f of failed) this.context.stderr.write(` failed: ${f.name} \u2014 ${f.reason}
|
|
45717
46972
|
`);
|
|
45718
46973
|
return 1;
|
|
45719
46974
|
}
|
|
@@ -45735,7 +46990,7 @@ async function promptHidden(prompt) {
|
|
|
45735
46990
|
process.stdin.setRawMode(true);
|
|
45736
46991
|
process.stdin.resume();
|
|
45737
46992
|
process.stdin.setEncoding("utf8");
|
|
45738
|
-
return new Promise((
|
|
46993
|
+
return new Promise((resolve4) => {
|
|
45739
46994
|
let buf = "";
|
|
45740
46995
|
const onData = (chunk) => {
|
|
45741
46996
|
for (const ch of chunk) {
|
|
@@ -45744,7 +46999,7 @@ async function promptHidden(prompt) {
|
|
|
45744
46999
|
process.stdin.pause();
|
|
45745
47000
|
process.stdin.removeListener("data", onData);
|
|
45746
47001
|
process.stdout.write("\n");
|
|
45747
|
-
|
|
47002
|
+
resolve4(buf);
|
|
45748
47003
|
return;
|
|
45749
47004
|
}
|
|
45750
47005
|
if (ch === "") {
|
|
@@ -45762,10 +47017,10 @@ async function promptHidden(prompt) {
|
|
|
45762
47017
|
}
|
|
45763
47018
|
async function promptLine(prompt) {
|
|
45764
47019
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
45765
|
-
return new Promise((
|
|
47020
|
+
return new Promise((resolve4) => {
|
|
45766
47021
|
rl.question(prompt, (answer) => {
|
|
45767
47022
|
rl.close();
|
|
45768
|
-
|
|
47023
|
+
resolve4(answer.trim());
|
|
45769
47024
|
});
|
|
45770
47025
|
});
|
|
45771
47026
|
}
|
|
@@ -45794,7 +47049,7 @@ var LoginCommand = class extends Command {
|
|
|
45794
47049
|
token = options_exports.String("--token", { description: "CLI token for headless auth." });
|
|
45795
47050
|
email = options_exports.String("--email", { description: "Email address." });
|
|
45796
47051
|
password = options_exports.String("--password", {
|
|
45797
|
-
description: "Password
|
|
47052
|
+
description: "Password. WARNING: passing passwords via --password leaks them to process listings (ps). Use interactive prompt or pipe via stdin instead."
|
|
45798
47053
|
});
|
|
45799
47054
|
async execute() {
|
|
45800
47055
|
const finalServerUrl = this.server ?? DEFAULT_SERVER_URL;
|
|
@@ -45826,7 +47081,15 @@ var LoginCommand = class extends Command {
|
|
|
45826
47081
|
}
|
|
45827
47082
|
}
|
|
45828
47083
|
const email2 = this.email ?? await promptLine("email: ");
|
|
45829
|
-
|
|
47084
|
+
let password;
|
|
47085
|
+
if (this.password) {
|
|
47086
|
+
this.context.stderr.write(
|
|
47087
|
+
"keynv: WARNING: --password leaks credentials to process listings. Use interactive prompt or pipe via stdin instead.\n"
|
|
47088
|
+
);
|
|
47089
|
+
password = this.password;
|
|
47090
|
+
} else {
|
|
47091
|
+
password = await promptHidden("password: ");
|
|
47092
|
+
}
|
|
45830
47093
|
let res;
|
|
45831
47094
|
try {
|
|
45832
47095
|
res = await fetch(new URL("/v1/auth/login", finalServerUrl).toString(), {
|
|
@@ -46152,9 +47415,9 @@ here (see the streaming-mode limitation in the redactor package).
|
|
|
46152
47415
|
`
|
|
46153
47416
|
});
|
|
46154
47417
|
async execute() {
|
|
46155
|
-
return new Promise((
|
|
47418
|
+
return new Promise((resolve4, reject) => {
|
|
46156
47419
|
const transform = createRedactStream();
|
|
46157
|
-
this.context.stdin.pipe(transform).pipe(this.context.stdout).on("error", reject).on("finish", () =>
|
|
47420
|
+
this.context.stdin.pipe(transform).pipe(this.context.stdout).on("error", reject).on("finish", () => resolve4(0));
|
|
46158
47421
|
this.context.stdin.on("error", reject);
|
|
46159
47422
|
});
|
|
46160
47423
|
}
|
|
@@ -46217,7 +47480,7 @@ var SecretCreateCommand = class extends Command {
|
|
|
46217
47480
|
throw err;
|
|
46218
47481
|
}
|
|
46219
47482
|
}
|
|
46220
|
-
const parsed = parseAlias(alias2);
|
|
47483
|
+
const parsed = reference_exports.parseAlias(alias2);
|
|
46221
47484
|
if (!parsed) {
|
|
46222
47485
|
this.context.stderr.write(`keynv: invalid alias '${alias2}'.
|
|
46223
47486
|
${ALIAS_FORMAT_HINT}
|
|
@@ -46234,10 +47497,13 @@ var SecretCreateCommand = class extends Command {
|
|
|
46234
47497
|
value = await promptHidden("value: ");
|
|
46235
47498
|
}
|
|
46236
47499
|
const projectId2 = await resolveProjectId(client, parsed.project);
|
|
46237
|
-
await client.request(
|
|
46238
|
-
|
|
46239
|
-
|
|
46240
|
-
|
|
47500
|
+
await client.request(
|
|
47501
|
+
`/v1/projects/${projectId2}/secrets`,
|
|
47502
|
+
{
|
|
47503
|
+
method: "POST",
|
|
47504
|
+
body: { env: parsed.environment, key: parsed.key, value }
|
|
47505
|
+
}
|
|
47506
|
+
);
|
|
46241
47507
|
this.context.stdout.write(`created ${parsed.literal}
|
|
46242
47508
|
`);
|
|
46243
47509
|
return 0;
|
|
@@ -46268,7 +47534,7 @@ var SecretGetCommand = class extends Command {
|
|
|
46268
47534
|
}
|
|
46269
47535
|
if (!alias2) return 1;
|
|
46270
47536
|
}
|
|
46271
|
-
const parsed = parseAlias(alias2);
|
|
47537
|
+
const parsed = reference_exports.parseAlias(alias2);
|
|
46272
47538
|
if (!parsed) {
|
|
46273
47539
|
this.context.stderr.write(`keynv: invalid alias '${alias2}'.
|
|
46274
47540
|
${ALIAS_FORMAT_HINT}
|
|
@@ -46320,7 +47586,15 @@ var SecretListCommand = class extends Command {
|
|
|
46320
47586
|
throw err;
|
|
46321
47587
|
}
|
|
46322
47588
|
}
|
|
46323
|
-
|
|
47589
|
+
let resolvedProjectName = projectName;
|
|
47590
|
+
if (projectName.startsWith("@")) {
|
|
47591
|
+
const parsed = reference_exports.parseAlias(projectName);
|
|
47592
|
+
if (parsed) {
|
|
47593
|
+
resolvedProjectName = parsed.project;
|
|
47594
|
+
} else {
|
|
47595
|
+
resolvedProjectName = projectName.slice(1).split(".")[0] ?? projectName;
|
|
47596
|
+
}
|
|
47597
|
+
}
|
|
46324
47598
|
const projectId2 = await resolveProjectId(client, resolvedProjectName);
|
|
46325
47599
|
const data = await client.request(`/v1/projects/${projectId2}/secrets`);
|
|
46326
47600
|
if (this.json) {
|
|
@@ -46366,7 +47640,7 @@ var SecretRotateCommand = class extends Command {
|
|
|
46366
47640
|
}
|
|
46367
47641
|
if (!alias2) return 1;
|
|
46368
47642
|
}
|
|
46369
|
-
const parsed = parseAlias(alias2);
|
|
47643
|
+
const parsed = reference_exports.parseAlias(alias2);
|
|
46370
47644
|
if (!parsed) {
|
|
46371
47645
|
this.context.stderr.write(`keynv: invalid alias '${alias2}'.
|
|
46372
47646
|
${ALIAS_FORMAT_HINT}
|
|
@@ -46402,6 +47676,7 @@ var SecretDeleteCommand = class extends Command {
|
|
|
46402
47676
|
static paths = [["secret", "delete"]];
|
|
46403
47677
|
static usage = Command.Usage({ description: "Soft-delete a secret." });
|
|
46404
47678
|
alias = options_exports.String({ required: false });
|
|
47679
|
+
force = options_exports.Boolean("--force", false);
|
|
46405
47680
|
async execute() {
|
|
46406
47681
|
try {
|
|
46407
47682
|
const client = new ApiClient();
|
|
@@ -46417,17 +47692,35 @@ var SecretDeleteCommand = class extends Command {
|
|
|
46417
47692
|
}
|
|
46418
47693
|
if (!alias2) return 1;
|
|
46419
47694
|
}
|
|
46420
|
-
const parsed = parseAlias(alias2);
|
|
47695
|
+
const parsed = reference_exports.parseAlias(alias2);
|
|
46421
47696
|
if (!parsed) {
|
|
46422
47697
|
this.context.stderr.write(`keynv: invalid alias '${alias2}'.
|
|
46423
47698
|
${ALIAS_FORMAT_HINT}
|
|
46424
47699
|
`);
|
|
46425
47700
|
return 1;
|
|
46426
47701
|
}
|
|
47702
|
+
if (!this.force) {
|
|
47703
|
+
if (isInteractive()) {
|
|
47704
|
+
const { confirm } = await Promise.resolve().then(() => (init_dist5(), dist_exports));
|
|
47705
|
+
const ok = await confirm({
|
|
47706
|
+
message: `Delete secret ${parsed.literal}?`
|
|
47707
|
+
});
|
|
47708
|
+
if (!ok) {
|
|
47709
|
+
this.context.stderr.write("Cancelled.\n");
|
|
47710
|
+
return 130;
|
|
47711
|
+
}
|
|
47712
|
+
} else {
|
|
47713
|
+
this.context.stderr.write("keynv: refusing to delete without --force\n");
|
|
47714
|
+
return 2;
|
|
47715
|
+
}
|
|
47716
|
+
}
|
|
46427
47717
|
const projectId2 = await resolveProjectId(client, parsed.project);
|
|
46428
|
-
await client.request(
|
|
46429
|
-
|
|
46430
|
-
|
|
47718
|
+
await client.request(
|
|
47719
|
+
`/v1/projects/${projectId2}/secrets/${parsed.environment}/${parsed.key}`,
|
|
47720
|
+
{
|
|
47721
|
+
method: "DELETE"
|
|
47722
|
+
}
|
|
47723
|
+
);
|
|
46431
47724
|
this.context.stdout.write(`deleted ${parsed.literal}
|
|
46432
47725
|
`);
|
|
46433
47726
|
return 0;
|
|
@@ -46495,9 +47788,9 @@ Non-interactive with --yes to skip prompts.
|
|
|
46495
47788
|
"# KEYNV_ARGON2_MEMORY_KIB=46080",
|
|
46496
47789
|
"# KEYNV_ARGON2_TIME_COST=3"
|
|
46497
47790
|
].join("\n");
|
|
46498
|
-
const { writeFileSync:
|
|
46499
|
-
|
|
46500
|
-
|
|
47791
|
+
const { writeFileSync: writeFileSync5 } = await import('fs');
|
|
47792
|
+
writeFileSync5(outPath, `${contents}
|
|
47793
|
+
`, { mode: 384 });
|
|
46501
47794
|
this.context.stdout.write(`Wrote ${outPath}
|
|
46502
47795
|
|
|
46503
47796
|
`);
|
|
@@ -46562,7 +47855,7 @@ services:
|
|
|
46562
47855
|
volumes:
|
|
46563
47856
|
keynv-data:
|
|
46564
47857
|
`;
|
|
46565
|
-
|
|
47858
|
+
writeFileSync5("docker-compose.yml", composeContent, { mode: 384 });
|
|
46566
47859
|
this.context.stdout.write(
|
|
46567
47860
|
"\nWrote docker-compose.yml (update Litestream S3 config before deploying).\n"
|
|
46568
47861
|
);
|
|
@@ -46576,6 +47869,60 @@ init_dist();
|
|
|
46576
47869
|
|
|
46577
47870
|
// ../../packages/testers/dist/http.js
|
|
46578
47871
|
init_zod();
|
|
47872
|
+
|
|
47873
|
+
// ../../packages/testers/dist/ssrf.js
|
|
47874
|
+
var PRIVATE_CIDRS = [
|
|
47875
|
+
/^0\./,
|
|
47876
|
+
/^10\./,
|
|
47877
|
+
/^127\./,
|
|
47878
|
+
/^169\.254\./,
|
|
47879
|
+
/^172\.(1[6-9]|2\d|3[01])\./,
|
|
47880
|
+
/^192\.0[0-2]\./,
|
|
47881
|
+
/^192\.168\./,
|
|
47882
|
+
/^198\.51\.100\./,
|
|
47883
|
+
/^203\.0\.113\./,
|
|
47884
|
+
/^224\./,
|
|
47885
|
+
/^240\./
|
|
47886
|
+
];
|
|
47887
|
+
var BLOCKED_HOSTNAMES = /* @__PURE__ */ new Set([
|
|
47888
|
+
"localhost",
|
|
47889
|
+
"metadata.google.internal",
|
|
47890
|
+
"metadata.internal",
|
|
47891
|
+
"instance-data"
|
|
47892
|
+
]);
|
|
47893
|
+
function isLoopbackAllowed() {
|
|
47894
|
+
return !!process.env["KEYNV_ALLOW_LOOPBACK_TESTERS"];
|
|
47895
|
+
}
|
|
47896
|
+
function isBlockedHost(host) {
|
|
47897
|
+
const lower = host.toLowerCase();
|
|
47898
|
+
if (BLOCKED_HOSTNAMES.has(lower)) {
|
|
47899
|
+
if (isLoopbackAllowed() && lower === "localhost")
|
|
47900
|
+
return false;
|
|
47901
|
+
return true;
|
|
47902
|
+
}
|
|
47903
|
+
if (lower === "0.0.0.0" || lower === "[::]" || lower === "[::1]")
|
|
47904
|
+
return !isLoopbackAllowed();
|
|
47905
|
+
for (const re2 of PRIVATE_CIDRS) {
|
|
47906
|
+
if (re2.test(lower)) {
|
|
47907
|
+
if (isLoopbackAllowed() && /^127\./.test(lower))
|
|
47908
|
+
return false;
|
|
47909
|
+
return true;
|
|
47910
|
+
}
|
|
47911
|
+
}
|
|
47912
|
+
return false;
|
|
47913
|
+
}
|
|
47914
|
+
function isBlockedUrl(urlStr) {
|
|
47915
|
+
try {
|
|
47916
|
+
const parsed = new URL(urlStr);
|
|
47917
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:")
|
|
47918
|
+
return true;
|
|
47919
|
+
return isBlockedHost(parsed.hostname);
|
|
47920
|
+
} catch {
|
|
47921
|
+
return true;
|
|
47922
|
+
}
|
|
47923
|
+
}
|
|
47924
|
+
|
|
47925
|
+
// ../../packages/testers/dist/http.js
|
|
46579
47926
|
var Target = external_exports.object({
|
|
46580
47927
|
url: external_exports.string().url(),
|
|
46581
47928
|
method: external_exports.enum(["GET", "POST", "HEAD"]).default("GET"),
|
|
@@ -46594,6 +47941,13 @@ var httpTester = {
|
|
|
46594
47941
|
type: "http",
|
|
46595
47942
|
schema: Target,
|
|
46596
47943
|
async test(secret, target) {
|
|
47944
|
+
if (isBlockedUrl(target.url)) {
|
|
47945
|
+
return {
|
|
47946
|
+
ok: false,
|
|
47947
|
+
latency_ms: 0,
|
|
47948
|
+
error: "Target URL is blocked (private/internal IP or metadata endpoint)."
|
|
47949
|
+
};
|
|
47950
|
+
}
|
|
46597
47951
|
const start = Date.now();
|
|
46598
47952
|
const headers = {};
|
|
46599
47953
|
switch (target.auth) {
|
|
@@ -46647,12 +48001,20 @@ var Target2 = external_exports.object({
|
|
|
46647
48001
|
host: external_exports.string().min(1),
|
|
46648
48002
|
port: external_exports.coerce.number().int().min(1).max(65535).default(3306),
|
|
46649
48003
|
database: external_exports.string().min(1).optional(),
|
|
46650
|
-
user: external_exports.string().min(1)
|
|
48004
|
+
user: external_exports.string().min(1),
|
|
48005
|
+
ssl: external_exports.coerce.boolean().optional()
|
|
46651
48006
|
});
|
|
46652
48007
|
var mysqlTester = {
|
|
46653
48008
|
type: "mysql",
|
|
46654
48009
|
schema: Target2,
|
|
46655
48010
|
async test(secret, target) {
|
|
48011
|
+
if (isBlockedHost(target.host)) {
|
|
48012
|
+
return {
|
|
48013
|
+
ok: false,
|
|
48014
|
+
latency_ms: 0,
|
|
48015
|
+
error: "Target host is blocked (private/internal IP or metadata endpoint)."
|
|
48016
|
+
};
|
|
48017
|
+
}
|
|
46656
48018
|
const start = Date.now();
|
|
46657
48019
|
const mysql = await Promise.resolve().then(() => __toESM(require_promise()));
|
|
46658
48020
|
const conn = await mysql.createConnection({
|
|
@@ -46661,6 +48023,7 @@ var mysqlTester = {
|
|
|
46661
48023
|
...target.database ? { database: target.database } : {},
|
|
46662
48024
|
user: target.user,
|
|
46663
48025
|
password: secret.value,
|
|
48026
|
+
...target.ssl !== false ? { ssl: {} } : {},
|
|
46664
48027
|
connectTimeout: 5e3
|
|
46665
48028
|
}).catch((err) => {
|
|
46666
48029
|
return {
|
|
@@ -46700,6 +48063,13 @@ var postgresTester = {
|
|
|
46700
48063
|
type: "postgres",
|
|
46701
48064
|
schema: Target3,
|
|
46702
48065
|
async test(secret, target) {
|
|
48066
|
+
if (isBlockedHost(target.host)) {
|
|
48067
|
+
return {
|
|
48068
|
+
ok: false,
|
|
48069
|
+
latency_ms: 0,
|
|
48070
|
+
error: "Target host is blocked (private/internal IP or metadata endpoint)."
|
|
48071
|
+
};
|
|
48072
|
+
}
|
|
46703
48073
|
const start = Date.now();
|
|
46704
48074
|
const { Client: Client2 } = await Promise.resolve().then(() => (init_esm(), esm_exports));
|
|
46705
48075
|
const client = new Client2({
|
|
@@ -46708,7 +48078,7 @@ var postgresTester = {
|
|
|
46708
48078
|
database: target.database,
|
|
46709
48079
|
user: target.user,
|
|
46710
48080
|
password: secret.value,
|
|
46711
|
-
ssl: target.ssl ??
|
|
48081
|
+
ssl: target.ssl ?? true,
|
|
46712
48082
|
connectionTimeoutMillis: 5e3,
|
|
46713
48083
|
statement_timeout: 5e3
|
|
46714
48084
|
});
|
|
@@ -46747,6 +48117,13 @@ var redisTester = {
|
|
|
46747
48117
|
type: "redis",
|
|
46748
48118
|
schema: Target4,
|
|
46749
48119
|
async test(secret, target) {
|
|
48120
|
+
if (isBlockedHost(target.host)) {
|
|
48121
|
+
return {
|
|
48122
|
+
ok: false,
|
|
48123
|
+
latency_ms: 0,
|
|
48124
|
+
error: "Target host is blocked (private/internal IP or metadata endpoint)."
|
|
48125
|
+
};
|
|
48126
|
+
}
|
|
46750
48127
|
const start = Date.now();
|
|
46751
48128
|
const { default: Redis } = await Promise.resolve().then(() => __toESM(require_built3()));
|
|
46752
48129
|
const client = new Redis({
|
|
@@ -46790,15 +48167,28 @@ var Target5 = external_exports.object({
|
|
|
46790
48167
|
* 'password' uses secret.value as a password; 'key' uses
|
|
46791
48168
|
* secret.value as a PEM-encoded private key.
|
|
46792
48169
|
*/
|
|
46793
|
-
auth: external_exports.enum(["password", "key"]).default("password")
|
|
48170
|
+
auth: external_exports.enum(["password", "key"]).default("password"),
|
|
48171
|
+
/**
|
|
48172
|
+
* Expected SHA-256 fingerprint of the server host public key
|
|
48173
|
+
* (base64, no padding). When set, the connection is rejected if
|
|
48174
|
+
* the key does not match — preventing MITM attacks.
|
|
48175
|
+
*/
|
|
48176
|
+
host_key_sha256: external_exports.string().min(1).optional()
|
|
46794
48177
|
});
|
|
46795
48178
|
var sshTester = {
|
|
46796
48179
|
type: "ssh",
|
|
46797
48180
|
schema: Target5,
|
|
46798
48181
|
async test(secret, target) {
|
|
48182
|
+
if (isBlockedHost(target.host)) {
|
|
48183
|
+
return {
|
|
48184
|
+
ok: false,
|
|
48185
|
+
latency_ms: 0,
|
|
48186
|
+
error: "Target host is blocked (private/internal IP or metadata endpoint)."
|
|
48187
|
+
};
|
|
48188
|
+
}
|
|
46799
48189
|
const start = Date.now();
|
|
46800
48190
|
const { Client: Client2 } = await import('ssh2');
|
|
46801
|
-
return new Promise((
|
|
48191
|
+
return new Promise((resolve4) => {
|
|
46802
48192
|
const client = new Client2();
|
|
46803
48193
|
let settled = false;
|
|
46804
48194
|
const settle = (result) => {
|
|
@@ -46809,7 +48199,7 @@ var sshTester = {
|
|
|
46809
48199
|
client.end();
|
|
46810
48200
|
} catch {
|
|
46811
48201
|
}
|
|
46812
|
-
|
|
48202
|
+
resolve4(result);
|
|
46813
48203
|
};
|
|
46814
48204
|
client.once("ready", () => {
|
|
46815
48205
|
client.exec("true", (err, stream) => {
|
|
@@ -46834,13 +48224,30 @@ var sshTester = {
|
|
|
46834
48224
|
settle({ ok: false, latency_ms: Date.now() - start, error: err.message });
|
|
46835
48225
|
});
|
|
46836
48226
|
try {
|
|
46837
|
-
|
|
48227
|
+
const connectOpts = {
|
|
46838
48228
|
host: target.host,
|
|
46839
48229
|
port: target.port,
|
|
46840
48230
|
username: target.user,
|
|
46841
|
-
...target.auth === "password" ? { password: secret.value } : { privateKey: secret.value },
|
|
46842
48231
|
readyTimeout: 5e3
|
|
46843
|
-
}
|
|
48232
|
+
};
|
|
48233
|
+
if (target.auth === "password") {
|
|
48234
|
+
connectOpts.password = secret.value;
|
|
48235
|
+
} else {
|
|
48236
|
+
connectOpts.privateKey = secret.value;
|
|
48237
|
+
}
|
|
48238
|
+
if (target.host_key_sha256) {
|
|
48239
|
+
const expected = target.host_key_sha256;
|
|
48240
|
+
connectOpts.hostVerifier = (key2) => {
|
|
48241
|
+
if (typeof key2 === "string") {
|
|
48242
|
+
return createHash("sha256").update(key2, "utf8").digest("base64").replace(/=+$/, "") === expected;
|
|
48243
|
+
}
|
|
48244
|
+
if (Buffer.isBuffer(key2)) {
|
|
48245
|
+
return createHash("sha256").update(key2).digest("base64").replace(/=+$/, "") === expected;
|
|
48246
|
+
}
|
|
48247
|
+
return false;
|
|
48248
|
+
};
|
|
48249
|
+
}
|
|
48250
|
+
client.connect(connectOpts);
|
|
46844
48251
|
} catch (err) {
|
|
46845
48252
|
settle({
|
|
46846
48253
|
ok: false,
|
|
@@ -46853,6 +48260,8 @@ var sshTester = {
|
|
|
46853
48260
|
};
|
|
46854
48261
|
|
|
46855
48262
|
// ../../packages/testers/dist/types.js
|
|
48263
|
+
init_zod();
|
|
48264
|
+
external_exports.enum(["postgres", "mysql", "redis", "ssh", "http"]);
|
|
46856
48265
|
var DEFAULT_TIMEOUT_MS = 5e3;
|
|
46857
48266
|
|
|
46858
48267
|
// ../../packages/testers/dist/sanitize.js
|
|
@@ -46875,12 +48284,12 @@ function sanitizeResult(result, secret) {
|
|
|
46875
48284
|
|
|
46876
48285
|
// ../../packages/testers/dist/run.js
|
|
46877
48286
|
function withTimeout(promise, ms) {
|
|
46878
|
-
return new Promise((
|
|
48287
|
+
return new Promise((resolve4, reject) => {
|
|
46879
48288
|
const t = setTimeout(() => reject(new Error(`tester timed out after ${ms}ms`)), ms);
|
|
46880
48289
|
t.unref();
|
|
46881
48290
|
promise.then((v2) => {
|
|
46882
48291
|
clearTimeout(t);
|
|
46883
|
-
|
|
48292
|
+
resolve4(v2);
|
|
46884
48293
|
}, (err) => {
|
|
46885
48294
|
clearTimeout(t);
|
|
46886
48295
|
reject(err);
|
|
@@ -46915,7 +48324,7 @@ function formatZodIssues(error) {
|
|
|
46915
48324
|
}
|
|
46916
48325
|
|
|
46917
48326
|
// ../../packages/testers/dist/index.js
|
|
46918
|
-
var
|
|
48327
|
+
var testers = [
|
|
46919
48328
|
postgresTester,
|
|
46920
48329
|
mysqlTester,
|
|
46921
48330
|
redisTester,
|
|
@@ -46965,7 +48374,7 @@ the error message.
|
|
|
46965
48374
|
description: "Override the default 5s timeout (in seconds)."
|
|
46966
48375
|
});
|
|
46967
48376
|
async execute() {
|
|
46968
|
-
const parsedAlias = parseAlias(this.alias);
|
|
48377
|
+
const parsedAlias = reference_exports.parseAlias(this.alias);
|
|
46969
48378
|
if (!parsedAlias) {
|
|
46970
48379
|
this.context.stderr.write(`keynv: invalid alias '${this.alias}'
|
|
46971
48380
|
`);
|
|
@@ -46973,12 +48382,12 @@ the error message.
|
|
|
46973
48382
|
}
|
|
46974
48383
|
if (!this.as) {
|
|
46975
48384
|
this.context.stderr.write(
|
|
46976
|
-
`keynv: --as is required (one of: ${
|
|
48385
|
+
`keynv: --as is required (one of: ${testers.map((t) => t.type).join(", ")})
|
|
46977
48386
|
`
|
|
46978
48387
|
);
|
|
46979
48388
|
return 2;
|
|
46980
48389
|
}
|
|
46981
|
-
const tester =
|
|
48390
|
+
const tester = testers.find((t) => t.type === this.as);
|
|
46982
48391
|
if (!tester) {
|
|
46983
48392
|
this.context.stderr.write(`keynv: unknown tester '${this.as}'
|
|
46984
48393
|
`);
|
|
@@ -47108,7 +48517,7 @@ if (argv.length === 0) {
|
|
|
47108
48517
|
process.exit(0);
|
|
47109
48518
|
}
|
|
47110
48519
|
} else {
|
|
47111
|
-
cli.
|
|
48520
|
+
cli.run(argv).then((code) => process.exit(code ?? 0)).catch((err) => {
|
|
47112
48521
|
process.stderr.write(`${fmtError(err)}
|
|
47113
48522
|
`);
|
|
47114
48523
|
process.exit(1);
|