@secondlayer/cli 1.2.3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +493 -334
- package/dist/cli.js.map +26 -24
- package/package.json +7 -9
package/dist/cli.js
CHANGED
|
@@ -2122,6 +2122,31 @@ var require_commander = __commonJS((exports) => {
|
|
|
2122
2122
|
exports.InvalidOptionArgumentError = InvalidArgumentError;
|
|
2123
2123
|
});
|
|
2124
2124
|
|
|
2125
|
+
// src/lib/fs.ts
|
|
2126
|
+
import { readFile, writeFile, mkdir, unlink, stat } from "node:fs/promises";
|
|
2127
|
+
async function readJsonFile(path) {
|
|
2128
|
+
const text = await readFile(path, "utf-8");
|
|
2129
|
+
return JSON.parse(text);
|
|
2130
|
+
}
|
|
2131
|
+
async function writeTextFile(path, content) {
|
|
2132
|
+
await writeFile(path, content, "utf-8");
|
|
2133
|
+
}
|
|
2134
|
+
async function fileExists(path) {
|
|
2135
|
+
try {
|
|
2136
|
+
await stat(path);
|
|
2137
|
+
return true;
|
|
2138
|
+
} catch {
|
|
2139
|
+
return false;
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
async function ensureDir(path) {
|
|
2143
|
+
await mkdir(path, { recursive: true });
|
|
2144
|
+
}
|
|
2145
|
+
async function removeFile(path) {
|
|
2146
|
+
await unlink(path);
|
|
2147
|
+
}
|
|
2148
|
+
var init_fs = () => {};
|
|
2149
|
+
|
|
2125
2150
|
// src/lib/config.ts
|
|
2126
2151
|
var exports_config = {};
|
|
2127
2152
|
__export(exports_config, {
|
|
@@ -2151,7 +2176,7 @@ function resolveApiUrl(config) {
|
|
|
2151
2176
|
return API_URLS[config.network] || API_URLS.local;
|
|
2152
2177
|
}
|
|
2153
2178
|
async function ensureConfigDir() {
|
|
2154
|
-
await
|
|
2179
|
+
await ensureDir(CONFIG_DIR);
|
|
2155
2180
|
}
|
|
2156
2181
|
function resolvePath(path) {
|
|
2157
2182
|
if (path.startsWith("~/")) {
|
|
@@ -2213,13 +2238,12 @@ function migrateConfig(raw) {
|
|
|
2213
2238
|
return migrated;
|
|
2214
2239
|
}
|
|
2215
2240
|
async function loadConfig() {
|
|
2216
|
-
const file = Bun.file(CONFIG_PATH);
|
|
2217
2241
|
let config;
|
|
2218
|
-
if (!await
|
|
2242
|
+
if (!await fileExists(CONFIG_PATH)) {
|
|
2219
2243
|
config = { ...DEFAULT_CONFIG };
|
|
2220
2244
|
} else {
|
|
2221
2245
|
try {
|
|
2222
|
-
const raw = await
|
|
2246
|
+
const raw = await readJsonFile(CONFIG_PATH);
|
|
2223
2247
|
const migrated = migrateConfig(raw);
|
|
2224
2248
|
config = ConfigSchema.parse(migrated);
|
|
2225
2249
|
} catch (error) {
|
|
@@ -2274,12 +2298,12 @@ function applyEnvOverrides(config) {
|
|
|
2274
2298
|
return result;
|
|
2275
2299
|
}
|
|
2276
2300
|
async function configExists() {
|
|
2277
|
-
return await
|
|
2301
|
+
return await fileExists(CONFIG_PATH);
|
|
2278
2302
|
}
|
|
2279
2303
|
async function saveConfig(config) {
|
|
2280
2304
|
const validated = ConfigSchema.parse(config);
|
|
2281
2305
|
await ensureConfigDir();
|
|
2282
|
-
await
|
|
2306
|
+
await writeTextFile(CONFIG_PATH, JSON.stringify(validated, null, 2) + `
|
|
2283
2307
|
`);
|
|
2284
2308
|
}
|
|
2285
2309
|
async function setConfigValue(key, value) {
|
|
@@ -2327,9 +2351,8 @@ async function resetConfig() {
|
|
|
2327
2351
|
await saveConfig({ ...DEFAULT_CONFIG });
|
|
2328
2352
|
}
|
|
2329
2353
|
async function clearConfig() {
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
await Bun.$`rm ${CONFIG_PATH}`.quiet();
|
|
2354
|
+
if (await fileExists(CONFIG_PATH)) {
|
|
2355
|
+
await removeFile(CONFIG_PATH);
|
|
2333
2356
|
}
|
|
2334
2357
|
}
|
|
2335
2358
|
function getConfigPath() {
|
|
@@ -2359,6 +2382,7 @@ function isDefaultValue(config, key) {
|
|
|
2359
2382
|
}
|
|
2360
2383
|
var PortsSchema, NodeSchema, DatabaseSchema, NetworkSchema, API_URLS, ConfigSchema, CONFIG_DIR, CONFIG_PATH, LOCAL_WEBHOOK_URL = "http://localhost:3900/webhook", DEFAULT_CONFIG;
|
|
2361
2384
|
var init_config = __esm(() => {
|
|
2385
|
+
init_fs();
|
|
2362
2386
|
PortsSchema = z.object({
|
|
2363
2387
|
api: z.number().int().min(1).max(65535).default(3800),
|
|
2364
2388
|
indexer: z.number().int().min(1).max(65535).default(3700),
|
|
@@ -4515,6 +4539,7 @@ __export(exports_api_client, {
|
|
|
4515
4539
|
pauseAllStreams: () => pauseAllStreams,
|
|
4516
4540
|
listViewsApi: () => listViewsApi,
|
|
4517
4541
|
listStreams: () => listStreams,
|
|
4542
|
+
handleApiError: () => handleApiError,
|
|
4518
4543
|
getViewApi: () => getViewApi,
|
|
4519
4544
|
getStream: () => getStream,
|
|
4520
4545
|
getQueueStats: () => getQueueStats,
|
|
@@ -4529,6 +4554,14 @@ __export(exports_api_client, {
|
|
|
4529
4554
|
});
|
|
4530
4555
|
import { SecondLayer } from "@secondlayer/sdk";
|
|
4531
4556
|
import { ApiError } from "@secondlayer/sdk";
|
|
4557
|
+
function handleApiError(err, action) {
|
|
4558
|
+
if (err instanceof ApiError && err.status === 401) {
|
|
4559
|
+
console.error("Error: Authentication required. Run: sl auth login");
|
|
4560
|
+
process.exit(1);
|
|
4561
|
+
}
|
|
4562
|
+
console.error(`Error: Failed to ${action}: ${err}`);
|
|
4563
|
+
process.exit(1);
|
|
4564
|
+
}
|
|
4532
4565
|
async function getClient() {
|
|
4533
4566
|
const config = await loadConfig();
|
|
4534
4567
|
const baseUrl = resolveApiUrl(config);
|
|
@@ -5962,7 +5995,7 @@ __export(exports_node_impl, {
|
|
|
5962
5995
|
runSetupWizard: () => runSetupWizard,
|
|
5963
5996
|
restartNode: () => restartNode
|
|
5964
5997
|
});
|
|
5965
|
-
import { input as
|
|
5998
|
+
import { input as input3, select as select3, confirm as confirm6 } from "@inquirer/prompts";
|
|
5966
5999
|
async function runSetupWizard() {
|
|
5967
6000
|
console.log("");
|
|
5968
6001
|
console.log(blue("Stacks Node Setup Wizard"));
|
|
@@ -5980,7 +6013,7 @@ async function runSetupWizard() {
|
|
|
5980
6013
|
}
|
|
5981
6014
|
success("Docker is running");
|
|
5982
6015
|
console.log("");
|
|
5983
|
-
const installPath = await
|
|
6016
|
+
const installPath = await input3({
|
|
5984
6017
|
message: "Where is stacks-blockchain-docker installed?",
|
|
5985
6018
|
validate: async (value) => {
|
|
5986
6019
|
if (!value.trim())
|
|
@@ -6010,7 +6043,7 @@ async function runSetupWizard() {
|
|
|
6010
6043
|
default: true
|
|
6011
6044
|
});
|
|
6012
6045
|
if (!customPort) {
|
|
6013
|
-
const portInput = await
|
|
6046
|
+
const portInput = await input3({
|
|
6014
6047
|
message: "Enter custom indexer port:",
|
|
6015
6048
|
default: "3700",
|
|
6016
6049
|
validate: (value) => {
|
|
@@ -7516,8 +7549,8 @@ var require_fill_range = __commonJS((exports, module) => {
|
|
|
7516
7549
|
return typeof value === "number" || typeof value === "string" && value !== "";
|
|
7517
7550
|
};
|
|
7518
7551
|
var isNumber = (num) => Number.isInteger(+num);
|
|
7519
|
-
var zeros = (
|
|
7520
|
-
let value = `${
|
|
7552
|
+
var zeros = (input4) => {
|
|
7553
|
+
let value = `${input4}`;
|
|
7521
7554
|
let index = -1;
|
|
7522
7555
|
if (value[0] === "-")
|
|
7523
7556
|
value = value.slice(1);
|
|
@@ -7533,27 +7566,27 @@ var require_fill_range = __commonJS((exports, module) => {
|
|
|
7533
7566
|
}
|
|
7534
7567
|
return options.stringify === true;
|
|
7535
7568
|
};
|
|
7536
|
-
var pad = (
|
|
7569
|
+
var pad = (input4, maxLength, toNumber) => {
|
|
7537
7570
|
if (maxLength > 0) {
|
|
7538
|
-
let dash =
|
|
7571
|
+
let dash = input4[0] === "-" ? "-" : "";
|
|
7539
7572
|
if (dash)
|
|
7540
|
-
|
|
7541
|
-
|
|
7573
|
+
input4 = input4.slice(1);
|
|
7574
|
+
input4 = dash + input4.padStart(dash ? maxLength - 1 : maxLength, "0");
|
|
7542
7575
|
}
|
|
7543
7576
|
if (toNumber === false) {
|
|
7544
|
-
return String(
|
|
7577
|
+
return String(input4);
|
|
7545
7578
|
}
|
|
7546
|
-
return
|
|
7579
|
+
return input4;
|
|
7547
7580
|
};
|
|
7548
|
-
var toMaxLen = (
|
|
7549
|
-
let negative =
|
|
7581
|
+
var toMaxLen = (input4, maxLength) => {
|
|
7582
|
+
let negative = input4[0] === "-" ? "-" : "";
|
|
7550
7583
|
if (negative) {
|
|
7551
|
-
|
|
7584
|
+
input4 = input4.slice(1);
|
|
7552
7585
|
maxLength--;
|
|
7553
7586
|
}
|
|
7554
|
-
while (
|
|
7555
|
-
|
|
7556
|
-
return negative ? "-" +
|
|
7587
|
+
while (input4.length < maxLength)
|
|
7588
|
+
input4 = "0" + input4;
|
|
7589
|
+
return negative ? "-" + input4 : input4;
|
|
7557
7590
|
};
|
|
7558
7591
|
var toSequence = (parts, options, maxLen) => {
|
|
7559
7592
|
parts.negatives.sort((a, b2) => a < b2 ? -1 : a > b2 ? 1 : 0);
|
|
@@ -7922,25 +7955,25 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
7922
7955
|
CHAR_NO_BREAK_SPACE,
|
|
7923
7956
|
CHAR_ZERO_WIDTH_NOBREAK_SPACE
|
|
7924
7957
|
} = require_constants();
|
|
7925
|
-
var parse2 = (
|
|
7926
|
-
if (typeof
|
|
7958
|
+
var parse2 = (input4, options = {}) => {
|
|
7959
|
+
if (typeof input4 !== "string") {
|
|
7927
7960
|
throw new TypeError("Expected a string");
|
|
7928
7961
|
}
|
|
7929
7962
|
const opts = options || {};
|
|
7930
7963
|
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
7931
|
-
if (
|
|
7932
|
-
throw new SyntaxError(`Input length (${
|
|
7964
|
+
if (input4.length > max) {
|
|
7965
|
+
throw new SyntaxError(`Input length (${input4.length}), exceeds max characters (${max})`);
|
|
7933
7966
|
}
|
|
7934
|
-
const ast = { type: "root", input:
|
|
7967
|
+
const ast = { type: "root", input: input4, nodes: [] };
|
|
7935
7968
|
const stack = [ast];
|
|
7936
7969
|
let block = ast;
|
|
7937
7970
|
let prev = ast;
|
|
7938
7971
|
let brackets = 0;
|
|
7939
|
-
const length =
|
|
7972
|
+
const length = input4.length;
|
|
7940
7973
|
let index = 0;
|
|
7941
7974
|
let depth = 0;
|
|
7942
7975
|
let value;
|
|
7943
|
-
const advance = () =>
|
|
7976
|
+
const advance = () => input4[index++];
|
|
7944
7977
|
const push = (node) => {
|
|
7945
7978
|
if (node.type === "text" && prev.type === "dot") {
|
|
7946
7979
|
prev.type = "text";
|
|
@@ -8135,10 +8168,10 @@ var require_braces = __commonJS((exports, module) => {
|
|
|
8135
8168
|
var compile = require_compile();
|
|
8136
8169
|
var expand = require_expand();
|
|
8137
8170
|
var parse2 = require_parse();
|
|
8138
|
-
var braces = (
|
|
8171
|
+
var braces = (input4, options = {}) => {
|
|
8139
8172
|
let output = [];
|
|
8140
|
-
if (Array.isArray(
|
|
8141
|
-
for (const pattern of
|
|
8173
|
+
if (Array.isArray(input4)) {
|
|
8174
|
+
for (const pattern of input4) {
|
|
8142
8175
|
const result = braces.create(pattern, options);
|
|
8143
8176
|
if (Array.isArray(result)) {
|
|
8144
8177
|
output.push(...result);
|
|
@@ -8147,31 +8180,31 @@ var require_braces = __commonJS((exports, module) => {
|
|
|
8147
8180
|
}
|
|
8148
8181
|
}
|
|
8149
8182
|
} else {
|
|
8150
|
-
output = [].concat(braces.create(
|
|
8183
|
+
output = [].concat(braces.create(input4, options));
|
|
8151
8184
|
}
|
|
8152
8185
|
if (options && options.expand === true && options.nodupes === true) {
|
|
8153
8186
|
output = [...new Set(output)];
|
|
8154
8187
|
}
|
|
8155
8188
|
return output;
|
|
8156
8189
|
};
|
|
8157
|
-
braces.parse = (
|
|
8158
|
-
braces.stringify = (
|
|
8159
|
-
if (typeof
|
|
8160
|
-
return stringify2(braces.parse(
|
|
8190
|
+
braces.parse = (input4, options = {}) => parse2(input4, options);
|
|
8191
|
+
braces.stringify = (input4, options = {}) => {
|
|
8192
|
+
if (typeof input4 === "string") {
|
|
8193
|
+
return stringify2(braces.parse(input4, options), options);
|
|
8161
8194
|
}
|
|
8162
|
-
return stringify2(
|
|
8195
|
+
return stringify2(input4, options);
|
|
8163
8196
|
};
|
|
8164
|
-
braces.compile = (
|
|
8165
|
-
if (typeof
|
|
8166
|
-
|
|
8197
|
+
braces.compile = (input4, options = {}) => {
|
|
8198
|
+
if (typeof input4 === "string") {
|
|
8199
|
+
input4 = braces.parse(input4, options);
|
|
8167
8200
|
}
|
|
8168
|
-
return compile(
|
|
8201
|
+
return compile(input4, options);
|
|
8169
8202
|
};
|
|
8170
|
-
braces.expand = (
|
|
8171
|
-
if (typeof
|
|
8172
|
-
|
|
8203
|
+
braces.expand = (input4, options = {}) => {
|
|
8204
|
+
if (typeof input4 === "string") {
|
|
8205
|
+
input4 = braces.parse(input4, options);
|
|
8173
8206
|
}
|
|
8174
|
-
let result = expand(
|
|
8207
|
+
let result = expand(input4, options);
|
|
8175
8208
|
if (options.noempty === true) {
|
|
8176
8209
|
result = result.filter(Boolean);
|
|
8177
8210
|
}
|
|
@@ -8180,11 +8213,11 @@ var require_braces = __commonJS((exports, module) => {
|
|
|
8180
8213
|
}
|
|
8181
8214
|
return result;
|
|
8182
8215
|
};
|
|
8183
|
-
braces.create = (
|
|
8184
|
-
if (
|
|
8185
|
-
return [
|
|
8216
|
+
braces.create = (input4, options = {}) => {
|
|
8217
|
+
if (input4 === "" || input4.length < 3) {
|
|
8218
|
+
return [input4];
|
|
8186
8219
|
}
|
|
8187
|
-
return options.expand !== true ? braces.compile(
|
|
8220
|
+
return options.expand !== true ? braces.compile(input4, options) : braces.expand(input4, options);
|
|
8188
8221
|
};
|
|
8189
8222
|
module.exports = braces;
|
|
8190
8223
|
});
|
|
@@ -8362,26 +8395,26 @@ var require_utils2 = __commonJS((exports) => {
|
|
|
8362
8395
|
}
|
|
8363
8396
|
return win32 === true || path.sep === "\\";
|
|
8364
8397
|
};
|
|
8365
|
-
exports.escapeLast = (
|
|
8366
|
-
const idx =
|
|
8398
|
+
exports.escapeLast = (input4, char, lastIdx) => {
|
|
8399
|
+
const idx = input4.lastIndexOf(char, lastIdx);
|
|
8367
8400
|
if (idx === -1)
|
|
8368
|
-
return
|
|
8369
|
-
if (
|
|
8370
|
-
return exports.escapeLast(
|
|
8371
|
-
return `${
|
|
8401
|
+
return input4;
|
|
8402
|
+
if (input4[idx - 1] === "\\")
|
|
8403
|
+
return exports.escapeLast(input4, char, idx - 1);
|
|
8404
|
+
return `${input4.slice(0, idx)}\\${input4.slice(idx)}`;
|
|
8372
8405
|
};
|
|
8373
|
-
exports.removePrefix = (
|
|
8374
|
-
let output =
|
|
8406
|
+
exports.removePrefix = (input4, state = {}) => {
|
|
8407
|
+
let output = input4;
|
|
8375
8408
|
if (output.startsWith("./")) {
|
|
8376
8409
|
output = output.slice(2);
|
|
8377
8410
|
state.prefix = "./";
|
|
8378
8411
|
}
|
|
8379
8412
|
return output;
|
|
8380
8413
|
};
|
|
8381
|
-
exports.wrapOutput = (
|
|
8414
|
+
exports.wrapOutput = (input4, state = {}, options = {}) => {
|
|
8382
8415
|
const prepend = options.contains ? "" : "^";
|
|
8383
8416
|
const append = options.contains ? "" : "$";
|
|
8384
|
-
let output = `${prepend}(?:${
|
|
8417
|
+
let output = `${prepend}(?:${input4})${append}`;
|
|
8385
8418
|
if (state.negated === true) {
|
|
8386
8419
|
output = `(?:^(?!${output}).*$)`;
|
|
8387
8420
|
}
|
|
@@ -8417,14 +8450,14 @@ var require_scan = __commonJS((exports, module) => {
|
|
|
8417
8450
|
token.depth = token.isGlobstar ? Infinity : 1;
|
|
8418
8451
|
}
|
|
8419
8452
|
};
|
|
8420
|
-
var scan = (
|
|
8453
|
+
var scan = (input4, options) => {
|
|
8421
8454
|
const opts = options || {};
|
|
8422
|
-
const length =
|
|
8455
|
+
const length = input4.length - 1;
|
|
8423
8456
|
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
8424
8457
|
const slashes = [];
|
|
8425
8458
|
const tokens = [];
|
|
8426
8459
|
const parts = [];
|
|
8427
|
-
let str =
|
|
8460
|
+
let str = input4;
|
|
8428
8461
|
let index = -1;
|
|
8429
8462
|
let start = 0;
|
|
8430
8463
|
let lastIndex = 0;
|
|
@@ -8647,7 +8680,7 @@ var require_scan = __commonJS((exports, module) => {
|
|
|
8647
8680
|
}
|
|
8648
8681
|
const state = {
|
|
8649
8682
|
prefix,
|
|
8650
|
-
input:
|
|
8683
|
+
input: input4,
|
|
8651
8684
|
start,
|
|
8652
8685
|
base,
|
|
8653
8686
|
glob,
|
|
@@ -8671,7 +8704,7 @@ var require_scan = __commonJS((exports, module) => {
|
|
|
8671
8704
|
for (let idx = 0;idx < slashes.length; idx++) {
|
|
8672
8705
|
const n = prevIndex ? prevIndex + 1 : start;
|
|
8673
8706
|
const i = slashes[idx];
|
|
8674
|
-
const value =
|
|
8707
|
+
const value = input4.slice(n, i);
|
|
8675
8708
|
if (opts.tokens) {
|
|
8676
8709
|
if (idx === 0 && start !== 0) {
|
|
8677
8710
|
tokens[idx].isPrefix = true;
|
|
@@ -8687,8 +8720,8 @@ var require_scan = __commonJS((exports, module) => {
|
|
|
8687
8720
|
}
|
|
8688
8721
|
prevIndex = i;
|
|
8689
8722
|
}
|
|
8690
|
-
if (prevIndex && prevIndex + 1 <
|
|
8691
|
-
const value =
|
|
8723
|
+
if (prevIndex && prevIndex + 1 < input4.length) {
|
|
8724
|
+
const value = input4.slice(prevIndex + 1);
|
|
8692
8725
|
parts.push(value);
|
|
8693
8726
|
if (opts.tokens) {
|
|
8694
8727
|
tokens[tokens.length - 1].value = value;
|
|
@@ -8731,14 +8764,14 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
|
8731
8764
|
var syntaxError = (type, char) => {
|
|
8732
8765
|
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
8733
8766
|
};
|
|
8734
|
-
var parse2 = (
|
|
8735
|
-
if (typeof
|
|
8767
|
+
var parse2 = (input4, options) => {
|
|
8768
|
+
if (typeof input4 !== "string") {
|
|
8736
8769
|
throw new TypeError("Expected a string");
|
|
8737
8770
|
}
|
|
8738
|
-
|
|
8771
|
+
input4 = REPLACEMENTS[input4] || input4;
|
|
8739
8772
|
const opts = { ...options };
|
|
8740
8773
|
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
8741
|
-
let len =
|
|
8774
|
+
let len = input4.length;
|
|
8742
8775
|
if (len > max) {
|
|
8743
8776
|
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
8744
8777
|
}
|
|
@@ -8775,7 +8808,7 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
|
8775
8808
|
opts.noextglob = opts.noext;
|
|
8776
8809
|
}
|
|
8777
8810
|
const state = {
|
|
8778
|
-
input:
|
|
8811
|
+
input: input4,
|
|
8779
8812
|
index: -1,
|
|
8780
8813
|
start: 0,
|
|
8781
8814
|
dot: opts.dot === true,
|
|
@@ -8791,17 +8824,17 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
|
8791
8824
|
globstar: false,
|
|
8792
8825
|
tokens
|
|
8793
8826
|
};
|
|
8794
|
-
|
|
8795
|
-
len =
|
|
8827
|
+
input4 = utils.removePrefix(input4, state);
|
|
8828
|
+
len = input4.length;
|
|
8796
8829
|
const extglobs = [];
|
|
8797
8830
|
const braces = [];
|
|
8798
8831
|
const stack = [];
|
|
8799
8832
|
let prev = bos;
|
|
8800
8833
|
let value;
|
|
8801
8834
|
const eos = () => state.index === len - 1;
|
|
8802
|
-
const peek = state.peek = (n = 1) =>
|
|
8803
|
-
const advance = state.advance = () =>
|
|
8804
|
-
const remaining = () =>
|
|
8835
|
+
const peek = state.peek = (n = 1) => input4[state.index + n];
|
|
8836
|
+
const advance = state.advance = () => input4[++state.index] || "";
|
|
8837
|
+
const remaining = () => input4.slice(state.index + 1);
|
|
8805
8838
|
const consume = (value2 = "", num = 0) => {
|
|
8806
8839
|
state.consumed += value2;
|
|
8807
8840
|
state.index += num;
|
|
@@ -8891,9 +8924,9 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
|
8891
8924
|
push({ type: "paren", extglob: true, value, output });
|
|
8892
8925
|
decrement("parens");
|
|
8893
8926
|
};
|
|
8894
|
-
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(
|
|
8927
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input4)) {
|
|
8895
8928
|
let backslashes = false;
|
|
8896
|
-
let output =
|
|
8929
|
+
let output = input4.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
8897
8930
|
if (first === "\\") {
|
|
8898
8931
|
backslashes = true;
|
|
8899
8932
|
return m;
|
|
@@ -8927,8 +8960,8 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
|
8927
8960
|
});
|
|
8928
8961
|
}
|
|
8929
8962
|
}
|
|
8930
|
-
if (output ===
|
|
8931
|
-
state.output =
|
|
8963
|
+
if (output === input4 && opts.contains === true) {
|
|
8964
|
+
state.output = input4;
|
|
8932
8965
|
return state;
|
|
8933
8966
|
}
|
|
8934
8967
|
state.output = utils.wrapOutput(output, state, options);
|
|
@@ -9287,7 +9320,7 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
|
9287
9320
|
continue;
|
|
9288
9321
|
}
|
|
9289
9322
|
while (rest.slice(0, 3) === "/**") {
|
|
9290
|
-
const after =
|
|
9323
|
+
const after = input4[state.index + 4];
|
|
9291
9324
|
if (after && after !== "/") {
|
|
9292
9325
|
break;
|
|
9293
9326
|
}
|
|
@@ -9410,14 +9443,14 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
|
9410
9443
|
}
|
|
9411
9444
|
return state;
|
|
9412
9445
|
};
|
|
9413
|
-
parse2.fastpaths = (
|
|
9446
|
+
parse2.fastpaths = (input4, options) => {
|
|
9414
9447
|
const opts = { ...options };
|
|
9415
9448
|
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
9416
|
-
const len =
|
|
9449
|
+
const len = input4.length;
|
|
9417
9450
|
if (len > max) {
|
|
9418
9451
|
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
9419
9452
|
}
|
|
9420
|
-
|
|
9453
|
+
input4 = REPLACEMENTS[input4] || input4;
|
|
9421
9454
|
const win32 = utils.isWindows(options);
|
|
9422
9455
|
const {
|
|
9423
9456
|
DOT_LITERAL,
|
|
@@ -9472,7 +9505,7 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
|
9472
9505
|
}
|
|
9473
9506
|
}
|
|
9474
9507
|
};
|
|
9475
|
-
const output = utils.removePrefix(
|
|
9508
|
+
const output = utils.removePrefix(input4, state);
|
|
9476
9509
|
let source = create(output);
|
|
9477
9510
|
if (source && opts.strictSlashes !== true) {
|
|
9478
9511
|
source += `${SLASH_LITERAL}?`;
|
|
@@ -9492,7 +9525,7 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
9492
9525
|
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
9493
9526
|
var picomatch = (glob, options, returnState = false) => {
|
|
9494
9527
|
if (Array.isArray(glob)) {
|
|
9495
|
-
const fns = glob.map((
|
|
9528
|
+
const fns = glob.map((input4) => picomatch(input4, options, returnState));
|
|
9496
9529
|
const arrayMatcher = (str) => {
|
|
9497
9530
|
for (const isMatch of fns) {
|
|
9498
9531
|
const state2 = isMatch(str);
|
|
@@ -9517,9 +9550,9 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
9517
9550
|
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
9518
9551
|
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
9519
9552
|
}
|
|
9520
|
-
const matcher = (
|
|
9521
|
-
const { isMatch, match, output } = picomatch.test(
|
|
9522
|
-
const result = { glob, state, regex, posix, input:
|
|
9553
|
+
const matcher = (input4, returnObject = false) => {
|
|
9554
|
+
const { isMatch, match, output } = picomatch.test(input4, regex, options, { glob, posix });
|
|
9555
|
+
const result = { glob, state, regex, posix, input: input4, output, match, isMatch };
|
|
9523
9556
|
if (typeof opts.onResult === "function") {
|
|
9524
9557
|
opts.onResult(result);
|
|
9525
9558
|
}
|
|
@@ -9527,7 +9560,7 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
9527
9560
|
result.isMatch = false;
|
|
9528
9561
|
return returnObject ? result : false;
|
|
9529
9562
|
}
|
|
9530
|
-
if (isIgnored(
|
|
9563
|
+
if (isIgnored(input4)) {
|
|
9531
9564
|
if (typeof opts.onIgnore === "function") {
|
|
9532
9565
|
opts.onIgnore(result);
|
|
9533
9566
|
}
|
|
@@ -9544,33 +9577,33 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
9544
9577
|
}
|
|
9545
9578
|
return matcher;
|
|
9546
9579
|
};
|
|
9547
|
-
picomatch.test = (
|
|
9548
|
-
if (typeof
|
|
9580
|
+
picomatch.test = (input4, regex, options, { glob, posix } = {}) => {
|
|
9581
|
+
if (typeof input4 !== "string") {
|
|
9549
9582
|
throw new TypeError("Expected input to be a string");
|
|
9550
9583
|
}
|
|
9551
|
-
if (
|
|
9584
|
+
if (input4 === "") {
|
|
9552
9585
|
return { isMatch: false, output: "" };
|
|
9553
9586
|
}
|
|
9554
9587
|
const opts = options || {};
|
|
9555
9588
|
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
9556
|
-
let match =
|
|
9557
|
-
let output = match && format ? format(
|
|
9589
|
+
let match = input4 === glob;
|
|
9590
|
+
let output = match && format ? format(input4) : input4;
|
|
9558
9591
|
if (match === false) {
|
|
9559
|
-
output = format ? format(
|
|
9592
|
+
output = format ? format(input4) : input4;
|
|
9560
9593
|
match = output === glob;
|
|
9561
9594
|
}
|
|
9562
9595
|
if (match === false || opts.capture === true) {
|
|
9563
9596
|
if (opts.matchBase === true || opts.basename === true) {
|
|
9564
|
-
match = picomatch.matchBase(
|
|
9597
|
+
match = picomatch.matchBase(input4, regex, options, posix);
|
|
9565
9598
|
} else {
|
|
9566
9599
|
match = regex.exec(output);
|
|
9567
9600
|
}
|
|
9568
9601
|
}
|
|
9569
9602
|
return { isMatch: Boolean(match), match, output };
|
|
9570
9603
|
};
|
|
9571
|
-
picomatch.matchBase = (
|
|
9604
|
+
picomatch.matchBase = (input4, glob, options, posix = utils.isWindows(options)) => {
|
|
9572
9605
|
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
9573
|
-
return regex.test(path.basename(
|
|
9606
|
+
return regex.test(path.basename(input4));
|
|
9574
9607
|
};
|
|
9575
9608
|
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
9576
9609
|
picomatch.parse = (pattern, options) => {
|
|
@@ -9578,7 +9611,7 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
9578
9611
|
return pattern.map((p) => picomatch.parse(p, options));
|
|
9579
9612
|
return parse2(pattern, { ...options, fastpaths: false });
|
|
9580
9613
|
};
|
|
9581
|
-
picomatch.scan = (
|
|
9614
|
+
picomatch.scan = (input4, options) => scan(input4, options);
|
|
9582
9615
|
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
9583
9616
|
if (returnOutput === true) {
|
|
9584
9617
|
return state.output;
|
|
@@ -9596,16 +9629,16 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
9596
9629
|
}
|
|
9597
9630
|
return regex;
|
|
9598
9631
|
};
|
|
9599
|
-
picomatch.makeRe = (
|
|
9600
|
-
if (!
|
|
9632
|
+
picomatch.makeRe = (input4, options = {}, returnOutput = false, returnState = false) => {
|
|
9633
|
+
if (!input4 || typeof input4 !== "string") {
|
|
9601
9634
|
throw new TypeError("Expected a non-empty string");
|
|
9602
9635
|
}
|
|
9603
9636
|
let parsed = { negated: false, fastpaths: true };
|
|
9604
|
-
if (options.fastpaths !== false && (
|
|
9605
|
-
parsed.output = parse2.fastpaths(
|
|
9637
|
+
if (options.fastpaths !== false && (input4[0] === "." || input4[0] === "*")) {
|
|
9638
|
+
parsed.output = parse2.fastpaths(input4, options);
|
|
9606
9639
|
}
|
|
9607
9640
|
if (!parsed.output) {
|
|
9608
|
-
parsed = parse2(
|
|
9641
|
+
parsed = parse2(input4, options);
|
|
9609
9642
|
}
|
|
9610
9643
|
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
9611
9644
|
};
|
|
@@ -9751,10 +9784,10 @@ var require_micromatch = __commonJS((exports, module) => {
|
|
|
9751
9784
|
}
|
|
9752
9785
|
return [].concat(patterns).every((p) => picomatch(p, options)(str));
|
|
9753
9786
|
};
|
|
9754
|
-
micromatch.capture = (glob,
|
|
9787
|
+
micromatch.capture = (glob, input4, options) => {
|
|
9755
9788
|
let posix = utils.isWindows(options);
|
|
9756
9789
|
let regex = picomatch.makeRe(String(glob), { ...options, capture: true });
|
|
9757
|
-
let match = regex.exec(posix ? utils.toPosixSlashes(
|
|
9790
|
+
let match = regex.exec(posix ? utils.toPosixSlashes(input4) : input4);
|
|
9758
9791
|
if (match) {
|
|
9759
9792
|
return match.slice(1).map((v) => v === undefined ? "" : v);
|
|
9760
9793
|
}
|
|
@@ -10089,12 +10122,12 @@ var require_stream = __commonJS((exports) => {
|
|
|
10089
10122
|
var require_string = __commonJS((exports) => {
|
|
10090
10123
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10091
10124
|
exports.isEmpty = exports.isString = undefined;
|
|
10092
|
-
function isString(
|
|
10093
|
-
return typeof
|
|
10125
|
+
function isString(input4) {
|
|
10126
|
+
return typeof input4 === "string";
|
|
10094
10127
|
}
|
|
10095
10128
|
exports.isString = isString;
|
|
10096
|
-
function isEmpty(
|
|
10097
|
-
return
|
|
10129
|
+
function isEmpty(input4) {
|
|
10130
|
+
return input4 === "";
|
|
10098
10131
|
}
|
|
10099
10132
|
exports.isEmpty = isEmpty;
|
|
10100
10133
|
});
|
|
@@ -10124,8 +10157,8 @@ var require_tasks = __commonJS((exports) => {
|
|
|
10124
10157
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10125
10158
|
exports.convertPatternGroupToTask = exports.convertPatternGroupsToTasks = exports.groupPatternsByBaseDirectory = exports.getNegativePatternsAsPositive = exports.getPositivePatterns = exports.convertPatternsToTasks = exports.generate = undefined;
|
|
10126
10159
|
var utils = require_utils3();
|
|
10127
|
-
function generate(
|
|
10128
|
-
const patterns = processPatterns(
|
|
10160
|
+
function generate(input4, settings) {
|
|
10161
|
+
const patterns = processPatterns(input4, settings);
|
|
10129
10162
|
const ignore = processPatterns(settings.ignore, settings);
|
|
10130
10163
|
const positivePatterns = getPositivePatterns(patterns);
|
|
10131
10164
|
const negativePatterns = getNegativePatternsAsPositive(patterns, ignore);
|
|
@@ -10136,8 +10169,8 @@ var require_tasks = __commonJS((exports) => {
|
|
|
10136
10169
|
return staticTasks.concat(dynamicTasks);
|
|
10137
10170
|
}
|
|
10138
10171
|
exports.generate = generate;
|
|
10139
|
-
function processPatterns(
|
|
10140
|
-
let patterns =
|
|
10172
|
+
function processPatterns(input4, settings) {
|
|
10173
|
+
let patterns = input4;
|
|
10141
10174
|
if (settings.braceExpansion) {
|
|
10142
10175
|
patterns = utils.pattern.expandPatternsWithBraceExpansion(patterns);
|
|
10143
10176
|
}
|
|
@@ -10216,7 +10249,7 @@ var require_async = __commonJS((exports) => {
|
|
|
10216
10249
|
callSuccessCallback(callback, lstat);
|
|
10217
10250
|
return;
|
|
10218
10251
|
}
|
|
10219
|
-
settings.fs.stat(path, (statError,
|
|
10252
|
+
settings.fs.stat(path, (statError, stat2) => {
|
|
10220
10253
|
if (statError !== null) {
|
|
10221
10254
|
if (settings.throwErrorOnBrokenSymbolicLink) {
|
|
10222
10255
|
callFailureCallback(callback, statError);
|
|
@@ -10226,9 +10259,9 @@ var require_async = __commonJS((exports) => {
|
|
|
10226
10259
|
return;
|
|
10227
10260
|
}
|
|
10228
10261
|
if (settings.markSymbolicLink) {
|
|
10229
|
-
|
|
10262
|
+
stat2.isSymbolicLink = () => true;
|
|
10230
10263
|
}
|
|
10231
|
-
callSuccessCallback(callback,
|
|
10264
|
+
callSuccessCallback(callback, stat2);
|
|
10232
10265
|
});
|
|
10233
10266
|
});
|
|
10234
10267
|
}
|
|
@@ -10251,11 +10284,11 @@ var require_sync = __commonJS((exports) => {
|
|
|
10251
10284
|
return lstat;
|
|
10252
10285
|
}
|
|
10253
10286
|
try {
|
|
10254
|
-
const
|
|
10287
|
+
const stat2 = settings.fs.statSync(path);
|
|
10255
10288
|
if (settings.markSymbolicLink) {
|
|
10256
|
-
|
|
10289
|
+
stat2.isSymbolicLink = () => true;
|
|
10257
10290
|
}
|
|
10258
|
-
return
|
|
10291
|
+
return stat2;
|
|
10259
10292
|
} catch (error2) {
|
|
10260
10293
|
if (!settings.throwErrorOnBrokenSymbolicLink) {
|
|
10261
10294
|
return lstat;
|
|
@@ -10314,14 +10347,14 @@ var require_out = __commonJS((exports) => {
|
|
|
10314
10347
|
var sync = require_sync();
|
|
10315
10348
|
var settings_1 = require_settings();
|
|
10316
10349
|
exports.Settings = settings_1.default;
|
|
10317
|
-
function
|
|
10350
|
+
function stat2(path, optionsOrSettingsOrCallback, callback) {
|
|
10318
10351
|
if (typeof optionsOrSettingsOrCallback === "function") {
|
|
10319
10352
|
async.read(path, getSettings(), optionsOrSettingsOrCallback);
|
|
10320
10353
|
return;
|
|
10321
10354
|
}
|
|
10322
10355
|
async.read(path, getSettings(optionsOrSettingsOrCallback), callback);
|
|
10323
10356
|
}
|
|
10324
|
-
exports.stat =
|
|
10357
|
+
exports.stat = stat2;
|
|
10325
10358
|
function statSync(path, optionsOrSettings) {
|
|
10326
10359
|
const settings = getSettings(optionsOrSettings);
|
|
10327
10360
|
return sync.read(path, settings);
|
|
@@ -12093,8 +12126,8 @@ var require_out4 = __commonJS((exports, module) => {
|
|
|
12093
12126
|
const provider = new _Provider(settings);
|
|
12094
12127
|
return tasks.map(provider.read, provider);
|
|
12095
12128
|
}
|
|
12096
|
-
function assertPatternsInput(
|
|
12097
|
-
const source = [].concat(
|
|
12129
|
+
function assertPatternsInput(input4) {
|
|
12130
|
+
const source = [].concat(input4);
|
|
12098
12131
|
const isValidSource = source.every((item) => utils.string.isString(item) && !utils.string.isEmpty(item));
|
|
12099
12132
|
if (!isValidSource) {
|
|
12100
12133
|
throw new TypeError("Patterns must be a string (non empty) or an array of strings");
|
|
@@ -16749,23 +16782,23 @@ var require_client_request = __commonJS((exports, module) => {
|
|
|
16749
16782
|
var kPendingAgentPromise = Symbol("pendingAgentPromise");
|
|
16750
16783
|
|
|
16751
16784
|
class ClientRequest extends Writable {
|
|
16752
|
-
constructor(
|
|
16785
|
+
constructor(input4, options, callback) {
|
|
16753
16786
|
super({
|
|
16754
16787
|
autoDestroy: false,
|
|
16755
16788
|
emitClose: false
|
|
16756
16789
|
});
|
|
16757
|
-
if (typeof
|
|
16758
|
-
|
|
16759
|
-
} else if (
|
|
16760
|
-
|
|
16790
|
+
if (typeof input4 === "string") {
|
|
16791
|
+
input4 = urlToHttpOptions(new URL2(input4));
|
|
16792
|
+
} else if (input4 instanceof URL2) {
|
|
16793
|
+
input4 = urlToHttpOptions(input4);
|
|
16761
16794
|
} else {
|
|
16762
|
-
|
|
16795
|
+
input4 = { ...input4 };
|
|
16763
16796
|
}
|
|
16764
16797
|
if (typeof options === "function" || options === undefined) {
|
|
16765
16798
|
callback = options;
|
|
16766
|
-
options =
|
|
16799
|
+
options = input4;
|
|
16767
16800
|
} else {
|
|
16768
|
-
options = Object.assign(
|
|
16801
|
+
options = Object.assign(input4, options);
|
|
16769
16802
|
}
|
|
16770
16803
|
if (options.h2session) {
|
|
16771
16804
|
this[kSession] = options.h2session;
|
|
@@ -17260,19 +17293,19 @@ var require_auto = __commonJS((exports, module) => {
|
|
|
17260
17293
|
};
|
|
17261
17294
|
};
|
|
17262
17295
|
var defaultResolveProtocol = createResolveProtocol(cache, queue);
|
|
17263
|
-
module.exports = async (
|
|
17264
|
-
if (typeof
|
|
17265
|
-
|
|
17266
|
-
} else if (
|
|
17267
|
-
|
|
17296
|
+
module.exports = async (input4, options, callback) => {
|
|
17297
|
+
if (typeof input4 === "string") {
|
|
17298
|
+
input4 = urlToHttpOptions(new URL2(input4));
|
|
17299
|
+
} else if (input4 instanceof URL2) {
|
|
17300
|
+
input4 = urlToHttpOptions(input4);
|
|
17268
17301
|
} else {
|
|
17269
|
-
|
|
17302
|
+
input4 = { ...input4 };
|
|
17270
17303
|
}
|
|
17271
17304
|
if (typeof options === "function" || options === undefined) {
|
|
17272
17305
|
callback = options;
|
|
17273
|
-
options =
|
|
17306
|
+
options = input4;
|
|
17274
17307
|
} else {
|
|
17275
|
-
options = Object.assign(
|
|
17308
|
+
options = Object.assign(input4, options);
|
|
17276
17309
|
}
|
|
17277
17310
|
options.ALPNProtocols = options.ALPNProtocols || ["h2", "http/1.1"];
|
|
17278
17311
|
if (!Array.isArray(options.ALPNProtocols) || options.ALPNProtocols.length === 0) {
|
|
@@ -17985,7 +18018,7 @@ var init_options = __esm(() => {
|
|
|
17985
18018
|
enableUnixSockets: false
|
|
17986
18019
|
};
|
|
17987
18020
|
Options = class Options {
|
|
17988
|
-
constructor(
|
|
18021
|
+
constructor(input4, options, defaults) {
|
|
17989
18022
|
Object.defineProperty(this, "_unixOptions", {
|
|
17990
18023
|
enumerable: true,
|
|
17991
18024
|
configurable: true,
|
|
@@ -18010,10 +18043,10 @@ var init_options = __esm(() => {
|
|
|
18010
18043
|
writable: true,
|
|
18011
18044
|
value: undefined
|
|
18012
18045
|
});
|
|
18013
|
-
assert.any([dist_default.string, dist_default.urlInstance, dist_default.object, dist_default.undefined],
|
|
18046
|
+
assert.any([dist_default.string, dist_default.urlInstance, dist_default.object, dist_default.undefined], input4);
|
|
18014
18047
|
assert.any([dist_default.object, dist_default.undefined], options);
|
|
18015
18048
|
assert.any([dist_default.object, dist_default.undefined], defaults);
|
|
18016
|
-
if (
|
|
18049
|
+
if (input4 instanceof Options || options instanceof Options) {
|
|
18017
18050
|
throw new TypeError("The defaults must be passed as the third argument");
|
|
18018
18051
|
}
|
|
18019
18052
|
this._internals = cloneInternals(defaults?._internals ?? defaults ?? defaultInternals);
|
|
@@ -18021,25 +18054,25 @@ var init_options = __esm(() => {
|
|
|
18021
18054
|
this._merging = false;
|
|
18022
18055
|
this._unixOptions = undefined;
|
|
18023
18056
|
try {
|
|
18024
|
-
if (dist_default.plainObject(
|
|
18057
|
+
if (dist_default.plainObject(input4)) {
|
|
18025
18058
|
try {
|
|
18026
|
-
this.merge(
|
|
18059
|
+
this.merge(input4);
|
|
18027
18060
|
this.merge(options);
|
|
18028
18061
|
} finally {
|
|
18029
|
-
this.url =
|
|
18062
|
+
this.url = input4.url;
|
|
18030
18063
|
}
|
|
18031
18064
|
} else {
|
|
18032
18065
|
try {
|
|
18033
18066
|
this.merge(options);
|
|
18034
18067
|
} finally {
|
|
18035
18068
|
if (options?.url !== undefined) {
|
|
18036
|
-
if (
|
|
18069
|
+
if (input4 === undefined) {
|
|
18037
18070
|
this.url = options.url;
|
|
18038
18071
|
} else {
|
|
18039
18072
|
throw new TypeError("The `url` option is mutually exclusive with the `input` argument");
|
|
18040
18073
|
}
|
|
18041
|
-
} else if (
|
|
18042
|
-
this.url =
|
|
18074
|
+
} else if (input4 !== undefined) {
|
|
18075
|
+
this.url = input4;
|
|
18043
18076
|
}
|
|
18044
18077
|
}
|
|
18045
18078
|
}
|
|
@@ -21297,8 +21330,8 @@ import path3 from "node:path";
|
|
|
21297
21330
|
import process5 from "node:process";
|
|
21298
21331
|
async function pathExists(path22, type) {
|
|
21299
21332
|
try {
|
|
21300
|
-
const
|
|
21301
|
-
return type === "file" ?
|
|
21333
|
+
const stat2 = await fs5.stat(path22);
|
|
21334
|
+
return type === "file" ? stat2.isFile() : stat2.isDirectory();
|
|
21302
21335
|
} catch {
|
|
21303
21336
|
return false;
|
|
21304
21337
|
}
|
|
@@ -22643,10 +22676,10 @@ function requireStyle() {
|
|
|
22643
22676
|
const c2 = requireKleur();
|
|
22644
22677
|
const figures = requireFigures();
|
|
22645
22678
|
const styles3 = Object.freeze({
|
|
22646
|
-
password: { scale: 1, render: (
|
|
22647
|
-
emoji: { scale: 2, render: (
|
|
22648
|
-
invisible: { scale: 0, render: (
|
|
22649
|
-
default: { scale: 1, render: (
|
|
22679
|
+
password: { scale: 1, render: (input4) => "*".repeat(input4.length) },
|
|
22680
|
+
emoji: { scale: 2, render: (input4) => "\uD83D\uDE03".repeat(input4.length) },
|
|
22681
|
+
invisible: { scale: 0, render: (input4) => "" },
|
|
22682
|
+
default: { scale: 1, render: (input4) => `${input4}` }
|
|
22650
22683
|
});
|
|
22651
22684
|
const render = (type) => styles3[type] || styles3.default;
|
|
22652
22685
|
const symbols = Object.freeze({
|
|
@@ -24654,7 +24687,7 @@ function requirePrompts$1() {
|
|
|
24654
24687
|
onSubmit: toSelected
|
|
24655
24688
|
});
|
|
24656
24689
|
};
|
|
24657
|
-
const byTitle = (
|
|
24690
|
+
const byTitle = (input4, choices) => Promise.resolve(choices.filter((item) => item.title.slice(0, input4.length).toLowerCase() === input4.toLowerCase()));
|
|
24658
24691
|
$.autocomplete = (args) => {
|
|
24659
24692
|
args.suggest = args.suggest || byTitle;
|
|
24660
24693
|
args.choices = [].concat(args.choices || []);
|
|
@@ -24998,8 +25031,8 @@ function requirePosix() {
|
|
|
24998
25031
|
}
|
|
24999
25032
|
};
|
|
25000
25033
|
posix.sync = sync;
|
|
25001
|
-
const checkStat = (
|
|
25002
|
-
const checkMode = (
|
|
25034
|
+
const checkStat = (stat2, options2) => stat2.isFile() && checkMode(stat2, options2);
|
|
25035
|
+
const checkMode = (stat2, options2) => {
|
|
25003
25036
|
const myUid = options2.uid ?? process.getuid?.();
|
|
25004
25037
|
const myGroups = options2.groups ?? process.getgroups?.() ?? [];
|
|
25005
25038
|
const myGid = options2.gid ?? process.getgid?.() ?? myGroups[0];
|
|
@@ -25007,9 +25040,9 @@ function requirePosix() {
|
|
|
25007
25040
|
throw new Error("cannot get uid or gid");
|
|
25008
25041
|
}
|
|
25009
25042
|
const groups = new Set([myGid, ...myGroups]);
|
|
25010
|
-
const mod =
|
|
25011
|
-
const uid2 =
|
|
25012
|
-
const gid =
|
|
25043
|
+
const mod = stat2.mode;
|
|
25044
|
+
const uid2 = stat2.uid;
|
|
25045
|
+
const gid = stat2.gid;
|
|
25013
25046
|
const u2 = parseInt("100", 8);
|
|
25014
25047
|
const g2 = parseInt("010", 8);
|
|
25015
25048
|
const o2 = parseInt("001", 8);
|
|
@@ -25065,7 +25098,7 @@ function requireWin32() {
|
|
|
25065
25098
|
}
|
|
25066
25099
|
return false;
|
|
25067
25100
|
};
|
|
25068
|
-
const checkStat = (
|
|
25101
|
+
const checkStat = (stat2, path5, options2) => stat2.isFile() && checkPathExt(path5, options2);
|
|
25069
25102
|
return win32;
|
|
25070
25103
|
}
|
|
25071
25104
|
function requireOptions() {
|
|
@@ -25943,12 +25976,12 @@ var init_figures = __esm(() => {
|
|
|
25943
25976
|
import tty2 from "node:tty";
|
|
25944
25977
|
var hasColors, format = (open, close) => {
|
|
25945
25978
|
if (!hasColors) {
|
|
25946
|
-
return (
|
|
25979
|
+
return (input4) => input4;
|
|
25947
25980
|
}
|
|
25948
25981
|
const openCode = `\x1B[${open}m`;
|
|
25949
25982
|
const closeCode = `\x1B[${close}m`;
|
|
25950
|
-
return (
|
|
25951
|
-
const string =
|
|
25983
|
+
return (input4) => {
|
|
25984
|
+
const string = input4 + "";
|
|
25952
25985
|
let index = string.indexOf(closeCode);
|
|
25953
25986
|
if (index === -1) {
|
|
25954
25987
|
return openCode + string + closeCode;
|
|
@@ -26204,15 +26237,15 @@ var require_windows = __commonJS((exports, module) => {
|
|
|
26204
26237
|
}
|
|
26205
26238
|
return false;
|
|
26206
26239
|
}
|
|
26207
|
-
function checkStat(
|
|
26208
|
-
if (!
|
|
26240
|
+
function checkStat(stat2, path5, options3) {
|
|
26241
|
+
if (!stat2.isSymbolicLink() && !stat2.isFile()) {
|
|
26209
26242
|
return false;
|
|
26210
26243
|
}
|
|
26211
26244
|
return checkPathExt(path5, options3);
|
|
26212
26245
|
}
|
|
26213
26246
|
function isexe(path5, options3, cb) {
|
|
26214
|
-
fs7.stat(path5, function(er,
|
|
26215
|
-
cb(er, er ? false : checkStat(
|
|
26247
|
+
fs7.stat(path5, function(er, stat2) {
|
|
26248
|
+
cb(er, er ? false : checkStat(stat2, path5, options3));
|
|
26216
26249
|
});
|
|
26217
26250
|
}
|
|
26218
26251
|
function sync(path5, options3) {
|
|
@@ -26226,20 +26259,20 @@ var require_mode = __commonJS((exports, module) => {
|
|
|
26226
26259
|
isexe.sync = sync;
|
|
26227
26260
|
var fs7 = __require("fs");
|
|
26228
26261
|
function isexe(path5, options3, cb) {
|
|
26229
|
-
fs7.stat(path5, function(er,
|
|
26230
|
-
cb(er, er ? false : checkStat(
|
|
26262
|
+
fs7.stat(path5, function(er, stat2) {
|
|
26263
|
+
cb(er, er ? false : checkStat(stat2, options3));
|
|
26231
26264
|
});
|
|
26232
26265
|
}
|
|
26233
26266
|
function sync(path5, options3) {
|
|
26234
26267
|
return checkStat(fs7.statSync(path5), options3);
|
|
26235
26268
|
}
|
|
26236
|
-
function checkStat(
|
|
26237
|
-
return
|
|
26269
|
+
function checkStat(stat2, options3) {
|
|
26270
|
+
return stat2.isFile() && checkMode(stat2, options3);
|
|
26238
26271
|
}
|
|
26239
|
-
function checkMode(
|
|
26240
|
-
var mod =
|
|
26241
|
-
var uid2 =
|
|
26242
|
-
var gid =
|
|
26272
|
+
function checkMode(stat2, options3) {
|
|
26273
|
+
var mod = stat2.mode;
|
|
26274
|
+
var uid2 = stat2.uid;
|
|
26275
|
+
var gid = stat2.gid;
|
|
26243
26276
|
var myUid = options3.uid !== undefined ? options3.uid : process.getuid && process.getuid();
|
|
26244
26277
|
var myGid = options3.gid !== undefined ? options3.gid : process.getgid && process.getgid();
|
|
26245
26278
|
var u2 = parseInt("100", 8);
|
|
@@ -28058,16 +28091,16 @@ var init_options2 = __esm(() => {
|
|
|
28058
28091
|
var concatenateShell = (file, commandArguments, options3) => options3.shell && commandArguments.length > 0 ? [[file, ...commandArguments].join(" "), [], options3] : [file, commandArguments, options3];
|
|
28059
28092
|
|
|
28060
28093
|
// ../../node_modules/strip-final-newline/index.js
|
|
28061
|
-
function stripFinalNewline(
|
|
28062
|
-
if (typeof
|
|
28063
|
-
return stripFinalNewlineString(
|
|
28094
|
+
function stripFinalNewline(input4) {
|
|
28095
|
+
if (typeof input4 === "string") {
|
|
28096
|
+
return stripFinalNewlineString(input4);
|
|
28064
28097
|
}
|
|
28065
|
-
if (!(ArrayBuffer.isView(
|
|
28098
|
+
if (!(ArrayBuffer.isView(input4) && input4.BYTES_PER_ELEMENT === 1)) {
|
|
28066
28099
|
throw new Error("Input must be a string or a Uint8Array");
|
|
28067
28100
|
}
|
|
28068
|
-
return stripFinalNewlineBinary(
|
|
28101
|
+
return stripFinalNewlineBinary(input4);
|
|
28069
28102
|
}
|
|
28070
|
-
var stripFinalNewlineString = (
|
|
28103
|
+
var stripFinalNewlineString = (input4) => input4.at(-1) === LF ? input4.slice(0, input4.at(-2) === CR ? -2 : -1) : input4, stripFinalNewlineBinary = (input4) => input4.at(-1) === LF_BINARY ? input4.subarray(0, input4.at(-2) === CR_BINARY ? -2 : -1) : input4, LF = `
|
|
28071
28104
|
`, LF_BINARY, CR = "\r", CR_BINARY;
|
|
28072
28105
|
var init_strip_final_newline = __esm(() => {
|
|
28073
28106
|
LF_BINARY = LF.codePointAt(0);
|
|
@@ -29368,21 +29401,21 @@ var init_native = __esm(() => {
|
|
|
29368
29401
|
});
|
|
29369
29402
|
|
|
29370
29403
|
// ../../node_modules/execa/lib/stdio/input-option.js
|
|
29371
|
-
var handleInputOptions = ({ input:
|
|
29372
|
-
...handleInputOption(
|
|
29404
|
+
var handleInputOptions = ({ input: input4, inputFile }, fdNumber) => fdNumber === 0 ? [
|
|
29405
|
+
...handleInputOption(input4),
|
|
29373
29406
|
...handleInputFileOption(inputFile)
|
|
29374
|
-
] : [], handleInputOption = (
|
|
29375
|
-
type: getInputType(
|
|
29376
|
-
value:
|
|
29407
|
+
] : [], handleInputOption = (input4) => input4 === undefined ? [] : [{
|
|
29408
|
+
type: getInputType(input4),
|
|
29409
|
+
value: input4,
|
|
29377
29410
|
optionName: "input"
|
|
29378
|
-
}], getInputType = (
|
|
29379
|
-
if (isReadableStream(
|
|
29411
|
+
}], getInputType = (input4) => {
|
|
29412
|
+
if (isReadableStream(input4, { checkOpen: false })) {
|
|
29380
29413
|
return "nodeStream";
|
|
29381
29414
|
}
|
|
29382
|
-
if (typeof
|
|
29415
|
+
if (typeof input4 === "string") {
|
|
29383
29416
|
return "string";
|
|
29384
29417
|
}
|
|
29385
|
-
if (isUint8Array(
|
|
29418
|
+
if (isUint8Array(input4)) {
|
|
29386
29419
|
return "uint8Array";
|
|
29387
29420
|
}
|
|
29388
29421
|
throw new Error("The `input` option must be a string, a Uint8Array or a Node.js Readable stream.");
|
|
@@ -32498,7 +32531,7 @@ var init_command2 = __esm(() => {
|
|
|
32498
32531
|
var setScriptSync = (boundExeca, createNested, boundOptions) => {
|
|
32499
32532
|
boundExeca.sync = createNested(mapScriptSync, boundOptions);
|
|
32500
32533
|
boundExeca.s = boundExeca.sync;
|
|
32501
|
-
}, mapScriptAsync = ({ options: options3 }) => getScriptOptions(options3), mapScriptSync = ({ options: options3 }) => ({ ...getScriptOptions(options3), isSync: true }), getScriptOptions = (options3) => ({ options: { ...getScriptStdinOption(options3), ...options3 } }), getScriptStdinOption = ({ input:
|
|
32534
|
+
}, mapScriptAsync = ({ options: options3 }) => getScriptOptions(options3), mapScriptSync = ({ options: options3 }) => ({ ...getScriptOptions(options3), isSync: true }), getScriptOptions = (options3) => ({ options: { ...getScriptStdinOption(options3), ...options3 } }), getScriptStdinOption = ({ input: input4, inputFile, stdio }) => input4 === undefined && inputFile === undefined && stdio === undefined ? { stdin: "inherit" } : {}, deepScriptOptions;
|
|
32502
32535
|
var init_script = __esm(() => {
|
|
32503
32536
|
deepScriptOptions = { preferLocal: true };
|
|
32504
32537
|
});
|
|
@@ -32608,20 +32641,20 @@ __export(exports_generate, {
|
|
|
32608
32641
|
});
|
|
32609
32642
|
import path11 from "path";
|
|
32610
32643
|
import { toCamelCase as toCamelCase4 } from "@secondlayer/stacks/clarity";
|
|
32611
|
-
function isContractAddress(
|
|
32644
|
+
function isContractAddress(input4) {
|
|
32612
32645
|
const contractIdPattern = /^(SP|ST|SM|SN)[A-Z0-9]{38,}\.[a-zA-Z][a-zA-Z0-9-]*$/;
|
|
32613
|
-
return contractIdPattern.test(
|
|
32646
|
+
return contractIdPattern.test(input4);
|
|
32614
32647
|
}
|
|
32615
32648
|
async function parseInputs(inputs) {
|
|
32616
32649
|
const files = [];
|
|
32617
32650
|
const contractIds = [];
|
|
32618
|
-
for (const
|
|
32619
|
-
if (isContractAddress(
|
|
32620
|
-
contractIds.push(
|
|
32651
|
+
for (const input4 of inputs) {
|
|
32652
|
+
if (isContractAddress(input4)) {
|
|
32653
|
+
contractIds.push(input4);
|
|
32621
32654
|
continue;
|
|
32622
32655
|
}
|
|
32623
|
-
if (
|
|
32624
|
-
const matches = await import_fast_glob.default(
|
|
32656
|
+
if (input4.includes("*") || input4.includes("?")) {
|
|
32657
|
+
const matches = await import_fast_glob.default(input4, { cwd: process.cwd(), absolute: true });
|
|
32625
32658
|
for (const file of matches) {
|
|
32626
32659
|
if (file.endsWith(".clar")) {
|
|
32627
32660
|
files.push(file);
|
|
@@ -32629,8 +32662,8 @@ async function parseInputs(inputs) {
|
|
|
32629
32662
|
}
|
|
32630
32663
|
continue;
|
|
32631
32664
|
}
|
|
32632
|
-
if (
|
|
32633
|
-
const absolutePath = path11.resolve(process.cwd(),
|
|
32665
|
+
if (input4.endsWith(".clar")) {
|
|
32666
|
+
const absolutePath = path11.resolve(process.cwd(), input4);
|
|
32634
32667
|
files.push(absolutePath);
|
|
32635
32668
|
}
|
|
32636
32669
|
}
|
|
@@ -32859,7 +32892,7 @@ async function init2() {
|
|
|
32859
32892
|
console.log(source_default.yellow("⚠ secondlayer.config.ts already exists"));
|
|
32860
32893
|
return;
|
|
32861
32894
|
} catch {}
|
|
32862
|
-
const hasClarinetProject = await
|
|
32895
|
+
const hasClarinetProject = await fileExists2("./Clarinet.toml");
|
|
32863
32896
|
let config;
|
|
32864
32897
|
if (hasClarinetProject) {
|
|
32865
32898
|
config = `import { defineConfig } from '@secondlayer/cli';
|
|
@@ -32883,7 +32916,7 @@ export default defineConfig({
|
|
|
32883
32916
|
console.log(source_default.green("✓ Created `secondlayer.config.ts`"));
|
|
32884
32917
|
console.log("\nRun `secondlayer generate` to generate type-safe interfaces, functions, and hooks!");
|
|
32885
32918
|
}
|
|
32886
|
-
async function
|
|
32919
|
+
async function fileExists2(filePath) {
|
|
32887
32920
|
try {
|
|
32888
32921
|
await fs8.access(filePath);
|
|
32889
32922
|
return true;
|
|
@@ -32913,11 +32946,12 @@ var {
|
|
|
32913
32946
|
// package.json
|
|
32914
32947
|
var package_default = {
|
|
32915
32948
|
name: "@secondlayer/cli",
|
|
32916
|
-
version: "1.
|
|
32917
|
-
description: "CLI for
|
|
32949
|
+
version: "1.3.0",
|
|
32950
|
+
description: "CLI for streams, views, and real-time blockchain indexing on Stacks",
|
|
32918
32951
|
type: "module",
|
|
32919
32952
|
bin: {
|
|
32920
|
-
secondlayer: "./dist/cli.js"
|
|
32953
|
+
secondlayer: "./dist/cli.js",
|
|
32954
|
+
sl: "./dist/cli.js"
|
|
32921
32955
|
},
|
|
32922
32956
|
main: "./dist/index.js",
|
|
32923
32957
|
types: "./dist/index.d.ts",
|
|
@@ -32953,10 +32987,10 @@ var package_default = {
|
|
|
32953
32987
|
license: "MIT",
|
|
32954
32988
|
dependencies: {
|
|
32955
32989
|
"@inquirer/prompts": "^8.2.0",
|
|
32956
|
-
"@secondlayer/sdk": "^0.3.
|
|
32957
|
-
"@secondlayer/shared": "^0.2.
|
|
32990
|
+
"@secondlayer/sdk": "^0.3.1",
|
|
32991
|
+
"@secondlayer/shared": "^0.2.3",
|
|
32958
32992
|
"@secondlayer/stacks": "workspace:*",
|
|
32959
|
-
"@secondlayer/views": "^0.2.
|
|
32993
|
+
"@secondlayer/views": "^0.2.3",
|
|
32960
32994
|
"@biomejs/js-api": "^0.7.0",
|
|
32961
32995
|
"@biomejs/wasm-nodejs": "^1.9.0",
|
|
32962
32996
|
esbuild: "^0.19.0",
|
|
@@ -32974,9 +33008,6 @@ var package_default = {
|
|
|
32974
33008
|
"fast-glob": "^3.3.3",
|
|
32975
33009
|
got: "^13.0.0",
|
|
32976
33010
|
react: "^19.1.0"
|
|
32977
|
-
},
|
|
32978
|
-
engines: {
|
|
32979
|
-
node: ">=20.19.0"
|
|
32980
33011
|
}
|
|
32981
33012
|
};
|
|
32982
33013
|
|
|
@@ -33282,34 +33313,38 @@ async function printConfigTree(cfg) {
|
|
|
33282
33313
|
const resolvedDataDir = getDataDir(cfg);
|
|
33283
33314
|
const dataDirDisplay = cfg.dataDir === resolvedDataDir ? cfg.dataDir : `${cfg.dataDir} ${dim(`→ ${resolvedDataDir}`)}`;
|
|
33284
33315
|
printValue("dataDir", dataDirDisplay, isDefaultValue(cfg, "dataDir"));
|
|
33285
|
-
|
|
33286
|
-
|
|
33287
|
-
|
|
33288
|
-
|
|
33289
|
-
|
|
33290
|
-
|
|
33291
|
-
|
|
33292
|
-
|
|
33293
|
-
|
|
33294
|
-
|
|
33295
|
-
|
|
33296
|
-
|
|
33297
|
-
|
|
33298
|
-
|
|
33299
|
-
|
|
33300
|
-
|
|
33316
|
+
if (cfg.network === "local") {
|
|
33317
|
+
console.log("");
|
|
33318
|
+
console.log(blue("node:"));
|
|
33319
|
+
if (cfg.node) {
|
|
33320
|
+
printValue(" installPath", cfg.node.installPath, false, 2);
|
|
33321
|
+
printValue(" network", cfg.node.network, cfg.node.network === "mainnet", 2);
|
|
33322
|
+
} else {
|
|
33323
|
+
console.log(dim(" (not configured)"));
|
|
33324
|
+
try {
|
|
33325
|
+
const detected = await detectStacksNodes();
|
|
33326
|
+
if (detected.length > 0) {
|
|
33327
|
+
console.log("");
|
|
33328
|
+
console.log(dim(` Detected ${detected.length} node${detected.length > 1 ? "s" : ""}:`));
|
|
33329
|
+
for (const node of detected.slice(0, 3)) {
|
|
33330
|
+
const status = node.running ? green("●") : dim("○");
|
|
33331
|
+
console.log(dim(` ${status} ${node.path} (${node.network})`));
|
|
33332
|
+
}
|
|
33333
|
+
console.log(dim(" Run 'sl init' to configure"));
|
|
33334
|
+
}
|
|
33335
|
+
} catch {}
|
|
33336
|
+
}
|
|
33337
|
+
console.log("");
|
|
33338
|
+
console.log(blue("ports:"));
|
|
33339
|
+
printValue(" api", cfg.ports.api, cfg.ports.api === defaults.ports.api, 2);
|
|
33340
|
+
printValue(" indexer", cfg.ports.indexer, cfg.ports.indexer === defaults.ports.indexer, 2);
|
|
33341
|
+
printValue(" webhook", cfg.ports.webhook, cfg.ports.webhook === defaults.ports.webhook, 2);
|
|
33342
|
+
console.log("");
|
|
33343
|
+
console.log(blue("database:"));
|
|
33344
|
+
printValue(" type", cfg.database.type, cfg.database.type === "docker", 2);
|
|
33345
|
+
if (cfg.database.url) {
|
|
33346
|
+
printValue(" url", maskUrl(cfg.database.url), false, 2);
|
|
33301
33347
|
}
|
|
33302
|
-
}
|
|
33303
|
-
console.log("");
|
|
33304
|
-
console.log(blue("ports:"));
|
|
33305
|
-
printValue(" api", cfg.ports.api, cfg.ports.api === defaults.ports.api, 2);
|
|
33306
|
-
printValue(" indexer", cfg.ports.indexer, cfg.ports.indexer === defaults.ports.indexer, 2);
|
|
33307
|
-
printValue(" webhook", cfg.ports.webhook, cfg.ports.webhook === defaults.ports.webhook, 2);
|
|
33308
|
-
console.log("");
|
|
33309
|
-
console.log(blue("database:"));
|
|
33310
|
-
printValue(" type", cfg.database.type, cfg.database.type === "docker", 2);
|
|
33311
|
-
if (cfg.database.url) {
|
|
33312
|
-
printValue(" url", maskUrl(cfg.database.url), false, 2);
|
|
33313
33348
|
}
|
|
33314
33349
|
console.log("");
|
|
33315
33350
|
}
|
|
@@ -33409,6 +33444,7 @@ async function runWizard() {
|
|
|
33409
33444
|
message: "How do you want to use Stacks Streams?",
|
|
33410
33445
|
choices: [
|
|
33411
33446
|
{ name: "Hosted mainnet (recommended — zero setup)", value: "mainnet" },
|
|
33447
|
+
{ name: "Hosted testnet", value: "testnet" },
|
|
33412
33448
|
{ name: "Local development (run your own node + services)", value: "local" }
|
|
33413
33449
|
]
|
|
33414
33450
|
});
|
|
@@ -33655,9 +33691,9 @@ function printSummary(config) {
|
|
|
33655
33691
|
}
|
|
33656
33692
|
console.log();
|
|
33657
33693
|
console.log(" Next steps:");
|
|
33658
|
-
console.log(" sl
|
|
33694
|
+
console.log(" sl local start # Start dev services");
|
|
33659
33695
|
if (config.node) {
|
|
33660
|
-
console.log(" sl
|
|
33696
|
+
console.log(" sl stack start # Start your Stacks node");
|
|
33661
33697
|
}
|
|
33662
33698
|
console.log(" sl streams new <name> # Create a new stream config");
|
|
33663
33699
|
console.log();
|
|
@@ -33699,7 +33735,7 @@ import { join as join3 } from "node:path";
|
|
|
33699
33735
|
function generateStreamTemplate(name, webhookUrl) {
|
|
33700
33736
|
return {
|
|
33701
33737
|
name,
|
|
33702
|
-
webhookUrl: webhookUrl || "https://
|
|
33738
|
+
webhookUrl: webhookUrl || "https://example.com/webhook",
|
|
33703
33739
|
filters: [
|
|
33704
33740
|
{
|
|
33705
33741
|
type: "contract_call",
|
|
@@ -33720,25 +33756,28 @@ function generateStreamTemplate(name, webhookUrl) {
|
|
|
33720
33756
|
// src/commands/new.ts
|
|
33721
33757
|
init_output();
|
|
33722
33758
|
init_config();
|
|
33759
|
+
init_fs();
|
|
33723
33760
|
var STREAMS_DIR2 = "streams";
|
|
33724
33761
|
function registerNewCommand(program2) {
|
|
33725
33762
|
program2.command("new <name>").description("Generate a new stream configuration file").option("-o, --output <path>", "Output path (default: streams/<name>.json)").action(async (name, options) => {
|
|
33726
33763
|
try {
|
|
33727
33764
|
const config = await loadConfig();
|
|
33728
33765
|
const outputPath = options.output || join3(STREAMS_DIR2, `${name}.json`);
|
|
33729
|
-
|
|
33730
|
-
if (await file.exists()) {
|
|
33766
|
+
if (await fileExists(outputPath)) {
|
|
33731
33767
|
warn(`File already exists: ${outputPath}`);
|
|
33732
33768
|
process.exit(1);
|
|
33733
33769
|
}
|
|
33734
33770
|
const dir = outputPath.substring(0, outputPath.lastIndexOf("/"));
|
|
33735
33771
|
if (dir) {
|
|
33736
|
-
await
|
|
33772
|
+
await ensureDir(dir);
|
|
33737
33773
|
}
|
|
33738
33774
|
const template = generateStreamTemplate(name, config.defaultWebhookUrl);
|
|
33739
|
-
await
|
|
33775
|
+
await writeTextFile(outputPath, JSON.stringify(template, null, 2) + `
|
|
33740
33776
|
`);
|
|
33741
33777
|
success(`Created ${outputPath}`);
|
|
33778
|
+
if (!config.defaultWebhookUrl) {
|
|
33779
|
+
warn("Edit the webhookUrl before registering — it must be a reachable HTTPS endpoint");
|
|
33780
|
+
}
|
|
33742
33781
|
console.log(`
|
|
33743
33782
|
Edit the file to configure your stream, then run:`);
|
|
33744
33783
|
console.log(` sl streams register ${outputPath}`);
|
|
@@ -33779,8 +33818,7 @@ function registerListCommand(program2) {
|
|
|
33779
33818
|
console.log(dim(`
|
|
33780
33819
|
${total} stream(s) total`));
|
|
33781
33820
|
} catch (err) {
|
|
33782
|
-
|
|
33783
|
-
process.exit(1);
|
|
33821
|
+
handleApiError(err, "list streams");
|
|
33784
33822
|
}
|
|
33785
33823
|
});
|
|
33786
33824
|
}
|
|
@@ -33820,8 +33858,7 @@ ${dim("Filters:")}`);
|
|
|
33820
33858
|
${dim("Options:")}`);
|
|
33821
33859
|
console.log(JSON.stringify(stream.options, null, 2));
|
|
33822
33860
|
} catch (err) {
|
|
33823
|
-
|
|
33824
|
-
process.exit(1);
|
|
33861
|
+
handleApiError(err, "get stream");
|
|
33825
33862
|
}
|
|
33826
33863
|
});
|
|
33827
33864
|
}
|
|
@@ -33829,16 +33866,16 @@ ${dim("Options:")}`);
|
|
|
33829
33866
|
// src/commands/register.ts
|
|
33830
33867
|
init_api_client();
|
|
33831
33868
|
init_output();
|
|
33869
|
+
init_fs();
|
|
33832
33870
|
import { CreateStreamSchema } from "@secondlayer/shared/schemas";
|
|
33833
33871
|
function registerRegisterCommand(program2) {
|
|
33834
33872
|
program2.command("register <file>").description("Register a stream from a JSON configuration file").option("-u, --update", "Update existing stream if name matches").action(async (filePath, options) => {
|
|
33835
33873
|
try {
|
|
33836
|
-
|
|
33837
|
-
if (!await file.exists()) {
|
|
33874
|
+
if (!await fileExists(filePath)) {
|
|
33838
33875
|
error(`File not found: ${filePath}`);
|
|
33839
33876
|
process.exit(1);
|
|
33840
33877
|
}
|
|
33841
|
-
const content = await
|
|
33878
|
+
const content = await readJsonFile(filePath);
|
|
33842
33879
|
const parsed = CreateStreamSchema.safeParse(content);
|
|
33843
33880
|
if (!parsed.success) {
|
|
33844
33881
|
error("Invalid stream configuration:");
|
|
@@ -33875,8 +33912,7 @@ function registerRegisterCommand(program2) {
|
|
|
33875
33912
|
console.log(dim(`
|
|
33876
33913
|
Save the webhook secret - it won't be shown again!`));
|
|
33877
33914
|
} catch (err) {
|
|
33878
|
-
|
|
33879
|
-
process.exit(1);
|
|
33915
|
+
handleApiError(err, "register stream");
|
|
33880
33916
|
}
|
|
33881
33917
|
});
|
|
33882
33918
|
}
|
|
@@ -33902,8 +33938,7 @@ function registerDeleteCommand(program2) {
|
|
|
33902
33938
|
await deleteStream(id);
|
|
33903
33939
|
success(`Deleted stream: ${stream.name}`);
|
|
33904
33940
|
} catch (err) {
|
|
33905
|
-
|
|
33906
|
-
process.exit(1);
|
|
33941
|
+
handleApiError(err, "delete stream");
|
|
33907
33942
|
}
|
|
33908
33943
|
});
|
|
33909
33944
|
}
|
|
@@ -33955,8 +33990,7 @@ Examples:`));
|
|
|
33955
33990
|
}
|
|
33956
33991
|
await setSingleStream(id, state);
|
|
33957
33992
|
} catch (err) {
|
|
33958
|
-
|
|
33959
|
-
process.exit(1);
|
|
33993
|
+
handleApiError(err, "set stream state");
|
|
33960
33994
|
}
|
|
33961
33995
|
});
|
|
33962
33996
|
}
|
|
@@ -34115,8 +34149,7 @@ function registerLogsCommand(program2) {
|
|
|
34115
34149
|
await showRecentLogs(resolveApiUrl(config), fullId, parseInt(options.limit), config, options.status);
|
|
34116
34150
|
}
|
|
34117
34151
|
} catch (err) {
|
|
34118
|
-
|
|
34119
|
-
process.exit(1);
|
|
34152
|
+
handleApiError(err, "get logs");
|
|
34120
34153
|
}
|
|
34121
34154
|
});
|
|
34122
34155
|
}
|
|
@@ -34310,8 +34343,7 @@ Examples:`));
|
|
|
34310
34343
|
Jobs will be processed by the worker in block order.`));
|
|
34311
34344
|
console.log(dim("Use 'sl streams logs <id> -f' to monitor progress."));
|
|
34312
34345
|
} catch (err) {
|
|
34313
|
-
|
|
34314
|
-
process.exit(1);
|
|
34346
|
+
handleApiError(err, "start replay");
|
|
34315
34347
|
}
|
|
34316
34348
|
});
|
|
34317
34349
|
}
|
|
@@ -34396,8 +34428,7 @@ function registerRotateSecretCommand(program2) {
|
|
|
34396
34428
|
console.log(dim(`
|
|
34397
34429
|
Save the webhook secret - it won't be shown again!`));
|
|
34398
34430
|
} catch (err) {
|
|
34399
|
-
|
|
34400
|
-
process.exit(1);
|
|
34431
|
+
handleApiError(err, "rotate secret");
|
|
34401
34432
|
}
|
|
34402
34433
|
});
|
|
34403
34434
|
}
|
|
@@ -34427,6 +34458,10 @@ function registerStatusCommand(program2) {
|
|
|
34427
34458
|
headers: authHeaders(config)
|
|
34428
34459
|
});
|
|
34429
34460
|
if (!response.ok) {
|
|
34461
|
+
if (response.status === 401) {
|
|
34462
|
+
console.error("Error: Authentication required. Run: sl auth login");
|
|
34463
|
+
process.exit(1);
|
|
34464
|
+
}
|
|
34430
34465
|
throw new Error(`HTTP ${response.status}`);
|
|
34431
34466
|
}
|
|
34432
34467
|
const status = await response.json();
|
|
@@ -34442,7 +34477,7 @@ function registerStatusCommand(program2) {
|
|
|
34442
34477
|
console.log("");
|
|
34443
34478
|
if (config.network === "local") {
|
|
34444
34479
|
console.log(dim(" API service is not running."));
|
|
34445
|
-
console.log(dim(" Start with: sl
|
|
34480
|
+
console.log(dim(" Start with: sl local start"));
|
|
34446
34481
|
} else {
|
|
34447
34482
|
console.log(dim(` Can't reach ${config.network} API at ${resolveApiUrl(config)}`));
|
|
34448
34483
|
console.log(dim(" Check your connection or try again."));
|
|
@@ -34792,7 +34827,7 @@ async function showOverview(_limit) {
|
|
|
34792
34827
|
error(`Failed to query database: ${err}`);
|
|
34793
34828
|
console.log(dim(`
|
|
34794
34829
|
Make sure PostgreSQL is running.`));
|
|
34795
|
-
console.log(dim("Run 'sl
|
|
34830
|
+
console.log(dim("Run 'sl local start' to start all services."));
|
|
34796
34831
|
process.exit(1);
|
|
34797
34832
|
}
|
|
34798
34833
|
}
|
|
@@ -34932,7 +34967,7 @@ async function resetDatabase(skipConfirm) {
|
|
|
34932
34967
|
console.log("");
|
|
34933
34968
|
success("Database reset complete");
|
|
34934
34969
|
console.log("");
|
|
34935
|
-
console.log(dim("Run 'sl
|
|
34970
|
+
console.log(dim("Run 'sl local restart' to restart the indexer for fresh sync."));
|
|
34936
34971
|
console.log("");
|
|
34937
34972
|
process.exit(0);
|
|
34938
34973
|
} catch (err) {
|
|
@@ -34981,13 +35016,13 @@ async function resyncDatabase(skipConfirm, backfill) {
|
|
|
34981
35016
|
}
|
|
34982
35017
|
console.log(green(" ✓ Indexer stopped"));
|
|
34983
35018
|
console.log("");
|
|
34984
|
-
info("Run 'sl
|
|
35019
|
+
info("Run 'sl local restart' to start fresh sync");
|
|
34985
35020
|
} else {
|
|
34986
35021
|
console.log("");
|
|
34987
35022
|
success("Database reset complete");
|
|
34988
35023
|
console.log("");
|
|
34989
35024
|
if (!backfill) {
|
|
34990
|
-
console.log(dim("Indexer not running. Start with 'sl
|
|
35025
|
+
console.log(dim("Indexer not running. Start with 'sl local start' to begin sync."));
|
|
34991
35026
|
}
|
|
34992
35027
|
}
|
|
34993
35028
|
if (backfill) {
|
|
@@ -35439,6 +35474,7 @@ export default defineView({
|
|
|
35439
35474
|
// src/commands/views.ts
|
|
35440
35475
|
init_api_client();
|
|
35441
35476
|
init_config();
|
|
35477
|
+
init_fs();
|
|
35442
35478
|
function registerViewsCommand(program2) {
|
|
35443
35479
|
const views = program2.command("views").description("Manage materialized views");
|
|
35444
35480
|
views.command("new <name>").description("Scaffold a new view definition file").action(async (name) => {
|
|
@@ -35452,9 +35488,9 @@ function registerViewsCommand(program2) {
|
|
|
35452
35488
|
mkdirSync(dir, { recursive: true });
|
|
35453
35489
|
}
|
|
35454
35490
|
const content = generateViewTemplate(name);
|
|
35455
|
-
await
|
|
35491
|
+
await writeTextFile(filePath, content);
|
|
35456
35492
|
success(`Created ${filePath}`);
|
|
35457
|
-
info(`Next:
|
|
35493
|
+
info(`Next: sl views deploy views/${name}.ts`);
|
|
35458
35494
|
});
|
|
35459
35495
|
views.command("dev <file>").description("Watch a view file and auto-redeploy on change").action(async (file) => {
|
|
35460
35496
|
await requireLocalNetwork();
|
|
@@ -35526,19 +35562,16 @@ Stopped watching.`);
|
|
|
35526
35562
|
validateViewDefinition(def);
|
|
35527
35563
|
if (config.network !== "local") {
|
|
35528
35564
|
info(`Bundling for remote deploy (${config.network})...`);
|
|
35529
|
-
const
|
|
35530
|
-
|
|
35531
|
-
|
|
35565
|
+
const esbuild = await import("esbuild");
|
|
35566
|
+
const buildResult = await esbuild.build({
|
|
35567
|
+
entryPoints: [absPath],
|
|
35568
|
+
bundle: true,
|
|
35569
|
+
platform: "node",
|
|
35532
35570
|
format: "esm",
|
|
35533
|
-
external: ["@secondlayer/views"]
|
|
35571
|
+
external: ["@secondlayer/views"],
|
|
35572
|
+
write: false
|
|
35534
35573
|
});
|
|
35535
|
-
|
|
35536
|
-
for (const msg of buildResult.logs) {
|
|
35537
|
-
error(String(msg));
|
|
35538
|
-
}
|
|
35539
|
-
process.exit(1);
|
|
35540
|
-
}
|
|
35541
|
-
const handlerCode = await buildResult.outputs[0].text();
|
|
35574
|
+
const handlerCode = new TextDecoder().decode(buildResult.outputFiles[0].contents);
|
|
35542
35575
|
const result = await deployViewApi({
|
|
35543
35576
|
name: def.name,
|
|
35544
35577
|
version: def.version,
|
|
@@ -35600,8 +35633,7 @@ Stopped watching.`);
|
|
|
35600
35633
|
console.log(dim(`
|
|
35601
35634
|
${data.length} view(s) total`));
|
|
35602
35635
|
} catch (err) {
|
|
35603
|
-
|
|
35604
|
-
process.exit(1);
|
|
35636
|
+
handleApiError(err, "list views");
|
|
35605
35637
|
}
|
|
35606
35638
|
});
|
|
35607
35639
|
views.command("status <name>").description("Show detailed view status").action(async (name) => {
|
|
@@ -35632,8 +35664,7 @@ Table endpoints:`));
|
|
|
35632
35664
|
}
|
|
35633
35665
|
}
|
|
35634
35666
|
} catch (err) {
|
|
35635
|
-
|
|
35636
|
-
process.exit(1);
|
|
35667
|
+
handleApiError(err, "get view status");
|
|
35637
35668
|
}
|
|
35638
35669
|
});
|
|
35639
35670
|
views.command("reindex <name>").description("Reindex a view from historical blocks").option("--from <block>", "Start block height").option("--to <block>", "End block height").action(async (name, options) => {
|
|
@@ -35646,8 +35677,7 @@ Table endpoints:`));
|
|
|
35646
35677
|
success(result.message);
|
|
35647
35678
|
info(`From block ${result.fromBlock} to ${result.toBlock}`);
|
|
35648
35679
|
} catch (err) {
|
|
35649
|
-
|
|
35650
|
-
process.exit(1);
|
|
35680
|
+
handleApiError(err, "reindex view");
|
|
35651
35681
|
}
|
|
35652
35682
|
});
|
|
35653
35683
|
views.command("query <name> <table>").description("Query a view table").option("--sort <column>", "Sort by column").option("--order <dir>", "Sort direction (asc|desc)", "asc").option("--limit <n>", "Max rows to return", "20").option("--offset <n>", "Skip first N rows").option("--fields <cols>", "Comma-separated columns to include").option("--filter <kv...>", "Filter as key=value (supports .gte/.lte/.gt/.lt/.neq suffixes)").option("--count", "Return row count only").option("--json", "Output as JSON").action(async (name, table, options) => {
|
|
@@ -35702,8 +35732,7 @@ Table endpoints:`));
|
|
|
35702
35732
|
console.log(dim(`
|
|
35703
35733
|
${rows.length} row(s)`));
|
|
35704
35734
|
} catch (err) {
|
|
35705
|
-
|
|
35706
|
-
process.exit(1);
|
|
35735
|
+
handleApiError(err, "query view");
|
|
35707
35736
|
}
|
|
35708
35737
|
});
|
|
35709
35738
|
views.command("delete <name>").description("Delete a view and its data").option("-y, --yes", "Skip confirmation").action(async (name, options) => {
|
|
@@ -35721,8 +35750,7 @@ ${rows.length} row(s)`));
|
|
|
35721
35750
|
const result = await deleteViewApi(name);
|
|
35722
35751
|
success(result.message);
|
|
35723
35752
|
} catch (err) {
|
|
35724
|
-
|
|
35725
|
-
process.exit(1);
|
|
35753
|
+
handleApiError(err, "delete view");
|
|
35726
35754
|
}
|
|
35727
35755
|
});
|
|
35728
35756
|
}
|
|
@@ -35781,7 +35809,7 @@ async function stackStart(options) {
|
|
|
35781
35809
|
if (options.node) {
|
|
35782
35810
|
const nodePath = config.node?.installPath;
|
|
35783
35811
|
if (!nodePath) {
|
|
35784
|
-
warn("No node configured, skipping. Run 'sl
|
|
35812
|
+
warn("No node configured, skipping. Run 'sl setup' to configure.");
|
|
35785
35813
|
} else if (await isNodeRunning()) {
|
|
35786
35814
|
info("Node already running");
|
|
35787
35815
|
} else {
|
|
@@ -36058,14 +36086,115 @@ async function checkHealth() {
|
|
|
36058
36086
|
|
|
36059
36087
|
// src/commands/doctor.ts
|
|
36060
36088
|
init_config();
|
|
36089
|
+
init_api_client();
|
|
36061
36090
|
init_network();
|
|
36062
36091
|
init_output();
|
|
36063
36092
|
function registerDoctorCommand(program2) {
|
|
36064
36093
|
program2.command("doctor").description("Run diagnostics on the full stack").option("--json", "Output as JSON").action(async (options) => {
|
|
36065
|
-
await
|
|
36094
|
+
const config = await loadConfig();
|
|
36095
|
+
if (config.network === "local") {
|
|
36096
|
+
await runLocalDoctor(options.json);
|
|
36097
|
+
} else {
|
|
36098
|
+
await runHostedDoctor(options.json);
|
|
36099
|
+
}
|
|
36066
36100
|
});
|
|
36067
36101
|
}
|
|
36068
|
-
async function
|
|
36102
|
+
async function runHostedDoctor(jsonOutput) {
|
|
36103
|
+
const config = await loadConfig();
|
|
36104
|
+
const apiUrl = resolveApiUrl(config);
|
|
36105
|
+
const issues = [];
|
|
36106
|
+
const results = { network: config.network, apiUrl };
|
|
36107
|
+
let apiHealthy = false;
|
|
36108
|
+
let statusData = null;
|
|
36109
|
+
try {
|
|
36110
|
+
const res = await fetch(`${apiUrl}/status`, { headers: authHeaders(config) });
|
|
36111
|
+
apiHealthy = res.ok;
|
|
36112
|
+
if (res.ok) {
|
|
36113
|
+
statusData = await res.json();
|
|
36114
|
+
} else if (res.status === 401) {
|
|
36115
|
+
issues.push("Authentication failed. Run: sl auth login");
|
|
36116
|
+
} else {
|
|
36117
|
+
issues.push(`API returned HTTP ${res.status}`);
|
|
36118
|
+
}
|
|
36119
|
+
} catch {
|
|
36120
|
+
issues.push(`Cannot reach API at ${apiUrl}`);
|
|
36121
|
+
}
|
|
36122
|
+
results.apiHealthy = apiHealthy;
|
|
36123
|
+
let authOk = false;
|
|
36124
|
+
let account = null;
|
|
36125
|
+
try {
|
|
36126
|
+
const res = await fetch(`${apiUrl}/api/accounts/me`, { headers: authHeaders(config) });
|
|
36127
|
+
if (res.ok) {
|
|
36128
|
+
authOk = true;
|
|
36129
|
+
account = await res.json();
|
|
36130
|
+
} else if (res.status === 401) {
|
|
36131
|
+
issues.push("Not authenticated. Run: sl auth login");
|
|
36132
|
+
}
|
|
36133
|
+
} catch {}
|
|
36134
|
+
results.authOk = authOk;
|
|
36135
|
+
results.account = account;
|
|
36136
|
+
if (jsonOutput) {
|
|
36137
|
+
console.log(JSON.stringify({ ...results, status: statusData, issues }, null, 2));
|
|
36138
|
+
return;
|
|
36139
|
+
}
|
|
36140
|
+
console.log("");
|
|
36141
|
+
console.log(blue("Network"));
|
|
36142
|
+
console.log(` ${config.network} ${dim(`(${apiUrl})`)}`);
|
|
36143
|
+
console.log("");
|
|
36144
|
+
console.log(blue("API"));
|
|
36145
|
+
console.log(` ${apiHealthy ? green("✓") : red("✗")} ${apiHealthy ? green("reachable") : red("unreachable")}`);
|
|
36146
|
+
console.log("");
|
|
36147
|
+
console.log(blue("Auth"));
|
|
36148
|
+
if (authOk && account) {
|
|
36149
|
+
console.log(` ${green("✓")} Authenticated`);
|
|
36150
|
+
console.log(formatKeyValue([
|
|
36151
|
+
[" Email", account.email ?? dim("unknown")],
|
|
36152
|
+
[" Plan", account.plan ?? dim("unknown")]
|
|
36153
|
+
]));
|
|
36154
|
+
} else {
|
|
36155
|
+
console.log(` ${red("✗")} Not authenticated`);
|
|
36156
|
+
}
|
|
36157
|
+
console.log("");
|
|
36158
|
+
if (statusData) {
|
|
36159
|
+
const progress = statusData.indexProgress;
|
|
36160
|
+
if (progress?.length) {
|
|
36161
|
+
console.log(blue("Index Progress"));
|
|
36162
|
+
for (const p of progress) {
|
|
36163
|
+
const behind = p.highestSeenBlock - p.lastIndexedBlock;
|
|
36164
|
+
const behindStr = behind > 0 ? yellow(` (${behind} behind)`) : green(" (synced)");
|
|
36165
|
+
console.log(` ${p.network}: block ${p.lastIndexedBlock}${behindStr}`);
|
|
36166
|
+
}
|
|
36167
|
+
console.log("");
|
|
36168
|
+
}
|
|
36169
|
+
const streams = statusData.streams;
|
|
36170
|
+
if (streams) {
|
|
36171
|
+
console.log(blue("Streams"));
|
|
36172
|
+
console.log(formatKeyValue([
|
|
36173
|
+
[" Total", streams.total.toString()],
|
|
36174
|
+
[" Active", green(streams.active.toString())],
|
|
36175
|
+
[" Paused", yellow(streams.paused.toString())],
|
|
36176
|
+
[" Error", streams.error > 0 ? red(streams.error.toString()) : "0"]
|
|
36177
|
+
]));
|
|
36178
|
+
console.log("");
|
|
36179
|
+
}
|
|
36180
|
+
}
|
|
36181
|
+
console.log(blue("Issues"));
|
|
36182
|
+
if (issues.length === 0) {
|
|
36183
|
+
console.log(` ${green("None")}`);
|
|
36184
|
+
} else {
|
|
36185
|
+
for (const issue of issues) {
|
|
36186
|
+
console.log(` ${red("•")} ${issue}`);
|
|
36187
|
+
}
|
|
36188
|
+
}
|
|
36189
|
+
console.log("");
|
|
36190
|
+
if (issues.length > 0) {
|
|
36191
|
+
warn(`${issues.length} issue(s) found`);
|
|
36192
|
+
} else {
|
|
36193
|
+
success("All checks passed");
|
|
36194
|
+
}
|
|
36195
|
+
console.log("");
|
|
36196
|
+
}
|
|
36197
|
+
async function runLocalDoctor(jsonOutput) {
|
|
36069
36198
|
const config = await loadConfig();
|
|
36070
36199
|
const report = await checkHealth();
|
|
36071
36200
|
if (jsonOutput) {
|
|
@@ -36173,6 +36302,7 @@ async function runDoctor(jsonOutput) {
|
|
|
36173
36302
|
init_config();
|
|
36174
36303
|
init_api_client();
|
|
36175
36304
|
init_output();
|
|
36305
|
+
import { input as input2 } from "@inquirer/prompts";
|
|
36176
36306
|
function registerAuthCommand(program2) {
|
|
36177
36307
|
const auth = program2.command("auth").description("Manage authentication and API keys");
|
|
36178
36308
|
auth.command("login").description("Login with email via magic link").action(async () => {
|
|
@@ -36182,12 +36312,10 @@ function registerAuthCommand(program2) {
|
|
|
36182
36312
|
error("No API URL configured. Set network with: sl config set network testnet");
|
|
36183
36313
|
process.exit(1);
|
|
36184
36314
|
}
|
|
36185
|
-
|
|
36186
|
-
|
|
36187
|
-
|
|
36188
|
-
|
|
36189
|
-
process.exit(1);
|
|
36190
|
-
}
|
|
36315
|
+
const email = await input2({
|
|
36316
|
+
message: "Email:",
|
|
36317
|
+
validate: (v) => v.includes("@") || "Enter a valid email"
|
|
36318
|
+
});
|
|
36191
36319
|
try {
|
|
36192
36320
|
const mlRes = await fetch(`${apiUrl}/api/auth/magic-link`, {
|
|
36193
36321
|
method: "POST",
|
|
@@ -36203,12 +36331,10 @@ function registerAuthCommand(program2) {
|
|
|
36203
36331
|
throw new Error(msg);
|
|
36204
36332
|
}
|
|
36205
36333
|
console.log(dim("Check your email for a login token."));
|
|
36206
|
-
|
|
36207
|
-
|
|
36208
|
-
|
|
36209
|
-
|
|
36210
|
-
process.exit(1);
|
|
36211
|
-
}
|
|
36334
|
+
const token = await input2({
|
|
36335
|
+
message: "Token:",
|
|
36336
|
+
validate: (v) => v.trim().length > 0 || "Token is required"
|
|
36337
|
+
});
|
|
36212
36338
|
const verifyRes = await fetch(`${apiUrl}/api/auth/verify`, {
|
|
36213
36339
|
method: "POST",
|
|
36214
36340
|
headers: { "Content-Type": "application/json" },
|
|
@@ -36416,22 +36542,6 @@ async function rotateKey(options) {
|
|
|
36416
36542
|
process.exit(1);
|
|
36417
36543
|
}
|
|
36418
36544
|
}
|
|
36419
|
-
function readLine() {
|
|
36420
|
-
return new Promise((resolve2) => {
|
|
36421
|
-
let data = "";
|
|
36422
|
-
process.stdin.setEncoding("utf-8");
|
|
36423
|
-
process.stdin.on("data", (chunk) => {
|
|
36424
|
-
data += chunk;
|
|
36425
|
-
if (data.includes(`
|
|
36426
|
-
`)) {
|
|
36427
|
-
process.stdin.removeAllListeners("data");
|
|
36428
|
-
process.stdin.pause();
|
|
36429
|
-
resolve2(data.trim());
|
|
36430
|
-
}
|
|
36431
|
-
});
|
|
36432
|
-
process.stdin.resume();
|
|
36433
|
-
});
|
|
36434
|
-
}
|
|
36435
36545
|
// src/commands/local.ts
|
|
36436
36546
|
init_config();
|
|
36437
36547
|
init_dev_state();
|
|
@@ -36718,9 +36828,58 @@ function formatWebhookSummary2(jsonStr) {
|
|
|
36718
36828
|
return null;
|
|
36719
36829
|
}
|
|
36720
36830
|
}
|
|
36831
|
+
// src/commands/whoami.ts
|
|
36832
|
+
init_config();
|
|
36833
|
+
init_api_client();
|
|
36834
|
+
init_output();
|
|
36835
|
+
function registerWhoamiCommand(program2) {
|
|
36836
|
+
program2.command("whoami").description("Show current authenticated account").action(async () => {
|
|
36837
|
+
const config = await loadConfig();
|
|
36838
|
+
const apiUrl = resolveApiUrl(config);
|
|
36839
|
+
const token = config.sessionToken ?? config.apiKey;
|
|
36840
|
+
if (!token) {
|
|
36841
|
+
error("Not authenticated. Run: sl auth login");
|
|
36842
|
+
process.exit(1);
|
|
36843
|
+
}
|
|
36844
|
+
try {
|
|
36845
|
+
const res = await fetch(`${apiUrl}/api/accounts/me`, {
|
|
36846
|
+
headers: authHeaders(config)
|
|
36847
|
+
});
|
|
36848
|
+
if (res.status === 401) {
|
|
36849
|
+
error("Not authenticated. Run: sl auth login");
|
|
36850
|
+
process.exit(1);
|
|
36851
|
+
}
|
|
36852
|
+
if (!res.ok) {
|
|
36853
|
+
throw new Error(`HTTP ${res.status}`);
|
|
36854
|
+
}
|
|
36855
|
+
const data = await res.json();
|
|
36856
|
+
console.log(formatKeyValue([
|
|
36857
|
+
["Email", data.email],
|
|
36858
|
+
["Plan", data.plan],
|
|
36859
|
+
["Network", config.network],
|
|
36860
|
+
["API", dim(apiUrl)]
|
|
36861
|
+
]));
|
|
36862
|
+
} catch (err) {
|
|
36863
|
+
error(`Failed to fetch account: ${err}`);
|
|
36864
|
+
process.exit(1);
|
|
36865
|
+
}
|
|
36866
|
+
});
|
|
36867
|
+
}
|
|
36721
36868
|
// src/cli.ts
|
|
36722
36869
|
var { version } = package_default;
|
|
36723
|
-
program.name("secondlayer").alias("sl").description("SecondLayer CLI for Stacks
|
|
36870
|
+
program.name("secondlayer").alias("sl").description("SecondLayer CLI — streams, views, and real-time indexing for Stacks").version(version).option("--network <network>", "Override network (local, testnet, mainnet)");
|
|
36871
|
+
program.hook("preAction", (thisCommand) => {
|
|
36872
|
+
const net3 = thisCommand.opts().network;
|
|
36873
|
+
if (net3)
|
|
36874
|
+
process.env.STACKS_NETWORK = net3;
|
|
36875
|
+
});
|
|
36876
|
+
program.addHelpText("after", `
|
|
36877
|
+
Quickstart:
|
|
36878
|
+
$ sl setup # Configure network + auth
|
|
36879
|
+
$ sl streams new my-stream # Scaffold a stream config
|
|
36880
|
+
$ sl streams register streams/my-stream.json
|
|
36881
|
+
$ sl status # Check system health
|
|
36882
|
+
`);
|
|
36724
36883
|
program.command("generate [files...]").aliases(["gen", "codegen"]).description("Generate TypeScript interfaces from Clarity contracts").option("-c, --config <path>", "Path to config file").option("-o, --out <path>", "Output file path (required when using direct files)").option("-k, --api-key <key>", "Hiro API key (or set HIRO_API_KEY env var)").option("-w, --watch", "Watch for changes").action(async (files, options3) => {
|
|
36725
36884
|
const { generate: generate2 } = await Promise.resolve().then(() => (init_generate(), exports_generate));
|
|
36726
36885
|
await generate2(files, options3);
|
|
@@ -36731,7 +36890,6 @@ program.command("init").description("Initialize a new secondlayer.config.ts file
|
|
|
36731
36890
|
});
|
|
36732
36891
|
registerStreamsCommand(program);
|
|
36733
36892
|
registerViewsCommand(program);
|
|
36734
|
-
registerLogsCommand(program);
|
|
36735
36893
|
registerStatusCommand(program);
|
|
36736
36894
|
registerLocalCommand(program);
|
|
36737
36895
|
registerStackCommand(program);
|
|
@@ -36741,8 +36899,9 @@ registerDoctorCommand(program);
|
|
|
36741
36899
|
registerSetupCommand(program);
|
|
36742
36900
|
registerConfigCommand(program);
|
|
36743
36901
|
registerAuthCommand(program);
|
|
36902
|
+
registerWhoamiCommand(program);
|
|
36744
36903
|
registerWebhookCommand(program);
|
|
36745
36904
|
program.parse();
|
|
36746
36905
|
|
|
36747
|
-
//# debugId=
|
|
36906
|
+
//# debugId=60D5693CFE5DECA264756E2164756E21
|
|
36748
36907
|
//# sourceMappingURL=cli.js.map
|