@secondlayer/cli 8.1.0 → 8.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +83 -36
- package/dist/cli.js.map +3 -3
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -12923,12 +12923,12 @@ __export(exports_dev_state, {
|
|
|
12923
12923
|
clearDevState: () => clearDevState
|
|
12924
12924
|
});
|
|
12925
12925
|
import { homedir as homedir4 } from "node:os";
|
|
12926
|
-
import { join as
|
|
12926
|
+
import { join as join9 } from "node:path";
|
|
12927
12927
|
function getLogsDir() {
|
|
12928
12928
|
return LOGS_DIR;
|
|
12929
12929
|
}
|
|
12930
12930
|
function getLogFile(service) {
|
|
12931
|
-
return
|
|
12931
|
+
return join9(LOGS_DIR, `${service}.log`);
|
|
12932
12932
|
}
|
|
12933
12933
|
async function ensureDirs() {
|
|
12934
12934
|
await Bun.$`mkdir -p ${STATE_DIR}`.quiet();
|
|
@@ -12985,9 +12985,9 @@ async function isDevRunning() {
|
|
|
12985
12985
|
}
|
|
12986
12986
|
var STATE_DIR, DEV_STATE_PATH, LOGS_DIR;
|
|
12987
12987
|
var init_dev_state = __esm(() => {
|
|
12988
|
-
STATE_DIR =
|
|
12989
|
-
DEV_STATE_PATH =
|
|
12990
|
-
LOGS_DIR =
|
|
12988
|
+
STATE_DIR = join9(homedir4(), ".secondlayer");
|
|
12989
|
+
DEV_STATE_PATH = join9(STATE_DIR, "dev.json");
|
|
12990
|
+
LOGS_DIR = join9(STATE_DIR, "logs");
|
|
12991
12991
|
});
|
|
12992
12992
|
|
|
12993
12993
|
// src/lib/network.ts
|
|
@@ -13378,10 +13378,10 @@ var init_manager = __esm(() => {
|
|
|
13378
13378
|
});
|
|
13379
13379
|
|
|
13380
13380
|
// src/services/indexer.ts
|
|
13381
|
-
import { dirname as
|
|
13381
|
+
import { dirname as dirname7, resolve as resolve3 } from "node:path";
|
|
13382
13382
|
async function startIndexer(options2) {
|
|
13383
13383
|
const port = options2.port ?? 3700;
|
|
13384
|
-
const rootDir =
|
|
13384
|
+
const rootDir = dirname7(dirname7(dirname7(dirname7(import.meta.dir))));
|
|
13385
13385
|
const indexerPath = resolve3(rootDir, "packages/indexer/src/index.ts");
|
|
13386
13386
|
await serviceManager.start(SERVICE_NAME, ["bun", "run", "--watch", indexerPath], {
|
|
13387
13387
|
port,
|
|
@@ -13398,9 +13398,9 @@ var init_indexer = __esm(() => {
|
|
|
13398
13398
|
});
|
|
13399
13399
|
|
|
13400
13400
|
// src/services/worker.ts
|
|
13401
|
-
import { dirname as
|
|
13401
|
+
import { dirname as dirname8, resolve as resolve4 } from "node:path";
|
|
13402
13402
|
async function startWorker(options2) {
|
|
13403
|
-
const rootDir =
|
|
13403
|
+
const rootDir = dirname8(dirname8(dirname8(dirname8(import.meta.dir))));
|
|
13404
13404
|
const workerPath = resolve4(rootDir, "packages/worker/src/index.ts");
|
|
13405
13405
|
await serviceManager.start(SERVICE_NAME2, ["bun", "run", "--watch", workerPath], {
|
|
13406
13406
|
onStdout: options2.onLog,
|
|
@@ -13413,10 +13413,10 @@ var init_worker = __esm(() => {
|
|
|
13413
13413
|
});
|
|
13414
13414
|
|
|
13415
13415
|
// src/services/api.ts
|
|
13416
|
-
import { dirname as
|
|
13416
|
+
import { dirname as dirname9, resolve as resolve5 } from "node:path";
|
|
13417
13417
|
async function startApi(options2) {
|
|
13418
13418
|
const port = options2.port ?? 3800;
|
|
13419
|
-
const rootDir =
|
|
13419
|
+
const rootDir = dirname9(dirname9(dirname9(dirname9(import.meta.dir))));
|
|
13420
13420
|
const apiPath = resolve5(rootDir, "packages/api/src/index.ts");
|
|
13421
13421
|
await serviceManager.start(SERVICE_NAME3, ["bun", "run", "--watch", apiPath], {
|
|
13422
13422
|
port,
|
|
@@ -13433,9 +13433,9 @@ var init_api2 = __esm(() => {
|
|
|
13433
13433
|
});
|
|
13434
13434
|
|
|
13435
13435
|
// src/services/subgraph-processor.ts
|
|
13436
|
-
import { dirname as
|
|
13436
|
+
import { dirname as dirname10, resolve as resolve6 } from "node:path";
|
|
13437
13437
|
async function startSubgraphProcessor(options2) {
|
|
13438
|
-
const rootDir =
|
|
13438
|
+
const rootDir = dirname10(dirname10(dirname10(dirname10(import.meta.dir))));
|
|
13439
13439
|
const servicePath = resolve6(rootDir, "packages/subgraphs/src/service.ts");
|
|
13440
13440
|
await serviceManager.start(SERVICE_NAME4, ["bun", "run", "--watch", servicePath], {
|
|
13441
13441
|
env: {
|
|
@@ -13471,7 +13471,7 @@ __export(exports_dev_impl, {
|
|
|
13471
13471
|
isDevAlreadyRunning: () => isDevAlreadyRunning
|
|
13472
13472
|
});
|
|
13473
13473
|
import { mkdirSync as mkdirSync4 } from "node:fs";
|
|
13474
|
-
import { dirname as
|
|
13474
|
+
import { dirname as dirname11, join as join10, resolve as resolve7 } from "node:path";
|
|
13475
13475
|
async function isDevAlreadyRunning() {
|
|
13476
13476
|
if (await isDevRunning()) {
|
|
13477
13477
|
const running = await getRunningServices();
|
|
@@ -13549,7 +13549,7 @@ async function runBackground(options2) {
|
|
|
13549
13549
|
startedAt: new Date().toISOString()
|
|
13550
13550
|
};
|
|
13551
13551
|
try {
|
|
13552
|
-
const packagesDir =
|
|
13552
|
+
const packagesDir = dirname11(dirname11(dirname11(dirname11(import.meta.dir))));
|
|
13553
13553
|
const env = { DATABASE_URL: databaseUrl, DEV_MODE: "true" };
|
|
13554
13554
|
const apiLogFile = getLogFile("api");
|
|
13555
13555
|
const apiProc = Bun.spawn(["bun", "run", resolve7(packagesDir, "packages/api/src/index.ts")], {
|
|
@@ -13899,7 +13899,7 @@ async function restartDev() {
|
|
|
13899
13899
|
await clearDevState();
|
|
13900
13900
|
await clearLogs();
|
|
13901
13901
|
const config = await loadConfig();
|
|
13902
|
-
const packagesDir =
|
|
13902
|
+
const packagesDir = dirname11(dirname11(dirname11(dirname11(import.meta.dir))));
|
|
13903
13903
|
const env = state.env;
|
|
13904
13904
|
const newState = {
|
|
13905
13905
|
services: {},
|
|
@@ -14080,7 +14080,7 @@ async function ensureDevPostgres(dataDir) {
|
|
|
14080
14080
|
if (check.stdout.toString().trim()) {
|
|
14081
14081
|
return false;
|
|
14082
14082
|
}
|
|
14083
|
-
const pgDataDir =
|
|
14083
|
+
const pgDataDir = join10(dataDir, "postgres");
|
|
14084
14084
|
mkdirSync4(pgDataDir, { recursive: true });
|
|
14085
14085
|
const stopped = await Bun.$`docker ps -aq -f name=secondlayer-dev-postgres`.quiet().nothrow();
|
|
14086
14086
|
if (stopped.stdout.toString().trim()) {
|
|
@@ -14096,7 +14096,7 @@ async function ensureDevPostgres(dataDir) {
|
|
|
14096
14096
|
throw new Error("PostgreSQL failed to start");
|
|
14097
14097
|
}
|
|
14098
14098
|
async function runMigrations(databaseUrl) {
|
|
14099
|
-
const packagesDir =
|
|
14099
|
+
const packagesDir = dirname11(dirname11(dirname11(dirname11(import.meta.dir))));
|
|
14100
14100
|
const migrateScript = resolve7(packagesDir, "packages/shared/src/db/migrate.ts");
|
|
14101
14101
|
const result = await Bun.$`DATABASE_URL=${databaseUrl} bun run ${migrateScript}`.quiet().nothrow();
|
|
14102
14102
|
if (result.exitCode !== 0) {
|
|
@@ -21874,7 +21874,7 @@ var init_commands = __esm(() => {
|
|
|
21874
21874
|
});
|
|
21875
21875
|
|
|
21876
21876
|
// ../../node_modules/@antfu/ni/dist/shared/ni.B5qNAuoI.mjs
|
|
21877
|
-
import path4, { join as
|
|
21877
|
+
import path4, { join as join12, dirname as dirname13, resolve as resolve9 } from "node:path";
|
|
21878
21878
|
import process$1 from "node:process";
|
|
21879
21879
|
import require$$0 from "readline";
|
|
21880
21880
|
import require$$2 from "events";
|
|
@@ -24889,7 +24889,7 @@ function requireLib() {
|
|
|
24889
24889
|
return lib;
|
|
24890
24890
|
hasRequiredLib = 1;
|
|
24891
24891
|
const { isexe, sync: isexeSync } = requireCjs();
|
|
24892
|
-
const { join:
|
|
24892
|
+
const { join: join13, delimiter, sep, posix: posix2 } = require$$1$2;
|
|
24893
24893
|
const isWindows = process.platform === "win32";
|
|
24894
24894
|
const rSlash = new RegExp(`[${posix2.sep}${sep === posix2.sep ? "" : sep}]`.replace(/(\\)/g, "\\$1"));
|
|
24895
24895
|
const rRel = new RegExp(`^\\.${rSlash.source}`);
|
|
@@ -24916,7 +24916,7 @@ function requireLib() {
|
|
|
24916
24916
|
const getPathPart = (raw, cmd) => {
|
|
24917
24917
|
const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
|
|
24918
24918
|
const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
|
|
24919
|
-
return prefix +
|
|
24919
|
+
return prefix + join13(pathPart, cmd);
|
|
24920
24920
|
};
|
|
24921
24921
|
const which = async (cmd, opt = {}) => {
|
|
24922
24922
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
@@ -25065,7 +25065,7 @@ var init_ni_B5qNAuoI = __esm(() => {
|
|
|
25065
25065
|
options2 = {};
|
|
25066
25066
|
libExports = requireLib();
|
|
25067
25067
|
which = /* @__PURE__ */ getDefaultExportFromCjs(libExports);
|
|
25068
|
-
CLI_TEMP_DIR =
|
|
25068
|
+
CLI_TEMP_DIR = join12(os4.tmpdir(), "antfu-ni");
|
|
25069
25069
|
customRcPath = process$1.env.NI_CONFIG_FILE;
|
|
25070
25070
|
home = process$1.platform === "win32" ? process$1.env.USERPROFILE : process$1.env.HOME;
|
|
25071
25071
|
defaultRcPath = path4.join(home || "~/", ".nirc");
|
|
@@ -32354,7 +32354,7 @@ var {
|
|
|
32354
32354
|
// package.json
|
|
32355
32355
|
var package_default = {
|
|
32356
32356
|
name: "@secondlayer/cli",
|
|
32357
|
-
version: "8.
|
|
32357
|
+
version: "8.2.0",
|
|
32358
32358
|
repository: {
|
|
32359
32359
|
type: "git",
|
|
32360
32360
|
url: "git+https://github.com/ryanwaits/secondlayer.git",
|
|
@@ -32403,8 +32403,8 @@ var package_default = {
|
|
|
32403
32403
|
dependencies: {
|
|
32404
32404
|
"@inquirer/prompts": "^8.2.0",
|
|
32405
32405
|
"@secondlayer/bundler": "^0.3.7",
|
|
32406
|
-
"@secondlayer/sdk": "^5.
|
|
32407
|
-
"@secondlayer/shared": "^6.
|
|
32406
|
+
"@secondlayer/sdk": "^5.9.0",
|
|
32407
|
+
"@secondlayer/shared": "^6.11.0",
|
|
32408
32408
|
"@secondlayer/stacks": "^2.3.0",
|
|
32409
32409
|
"@secondlayer/subgraphs": "^3.5.0",
|
|
32410
32410
|
"@biomejs/js-api": "^0.7.0",
|
|
@@ -36336,6 +36336,8 @@ Examples:
|
|
|
36336
36336
|
// src/commands/streams.ts
|
|
36337
36337
|
init_output();
|
|
36338
36338
|
init_resolve_auth();
|
|
36339
|
+
import { mkdir as mkdir3, writeFile as writeFile3 } from "node:fs/promises";
|
|
36340
|
+
import { dirname as dirname6, join as join8 } from "node:path";
|
|
36339
36341
|
import { createStreamsClient } from "@secondlayer/sdk";
|
|
36340
36342
|
var DEFAULT_BASE_URL = "https://api.secondlayer.tools";
|
|
36341
36343
|
var VALID_TYPES = [
|
|
@@ -36365,6 +36367,18 @@ function client() {
|
|
|
36365
36367
|
apiKey: readApiKey()
|
|
36366
36368
|
});
|
|
36367
36369
|
}
|
|
36370
|
+
function dumpsClient(dumpsUrl) {
|
|
36371
|
+
const dumpsBaseUrl = dumpsUrl ?? process.env.SL_STREAMS_DUMPS_URL;
|
|
36372
|
+
if (!dumpsBaseUrl) {
|
|
36373
|
+
error("No dumps URL. Pass --dumps-url <url> or set SL_STREAMS_DUMPS_URL (the public bulk bucket base; see GET /public/streams/dumps/manifest).");
|
|
36374
|
+
process.exit(1);
|
|
36375
|
+
}
|
|
36376
|
+
return createStreamsClient({
|
|
36377
|
+
baseUrl: process.env.SL_API_URL ?? DEFAULT_BASE_URL,
|
|
36378
|
+
apiKey: resolveEnvKey() ?? "",
|
|
36379
|
+
dumpsBaseUrl
|
|
36380
|
+
});
|
|
36381
|
+
}
|
|
36368
36382
|
function parseTypes(value) {
|
|
36369
36383
|
if (!value)
|
|
36370
36384
|
return;
|
|
@@ -36470,6 +36484,39 @@ Examples:
|
|
|
36470
36484
|
process.exit(1);
|
|
36471
36485
|
}
|
|
36472
36486
|
});
|
|
36487
|
+
streams.command("pull").description("Download finalized bulk parquet dumps to a local dir (verifies sha256)").requiredOption("--to <dir>", "output directory").option("--dumps-url <url>", "public dumps base URL (or SL_STREAMS_DUMPS_URL)").option("--from-block <n>", "only files covering blocks >= n").option("--to-block <n>", "only files covering blocks <= n").addHelpText("after", `
|
|
36488
|
+
Examples:
|
|
36489
|
+
$ sl streams pull --to ./dump
|
|
36490
|
+
$ sl streams pull --to ./dump --from-block 150000 --to-block 200000`).action(async (options2) => {
|
|
36491
|
+
try {
|
|
36492
|
+
const fromBlock = parseHeight(options2.fromBlock, "--from-block");
|
|
36493
|
+
const toBlock = parseHeight(options2.toBlock, "--to-block");
|
|
36494
|
+
const dumps = dumpsClient(options2.dumpsUrl).dumps;
|
|
36495
|
+
const manifest = await dumps.list();
|
|
36496
|
+
const files = manifest.files.filter((f) => (fromBlock === undefined || f.to_block >= fromBlock) && (toBlock === undefined || f.from_block <= toBlock));
|
|
36497
|
+
if (files.length === 0) {
|
|
36498
|
+
note("# no dump files match the requested range");
|
|
36499
|
+
return;
|
|
36500
|
+
}
|
|
36501
|
+
note(`# downloading ${files.length} file(s) to ${options2.to}`);
|
|
36502
|
+
for (const file of files) {
|
|
36503
|
+
const bytes = await dumps.download(file);
|
|
36504
|
+
const dest = join8(options2.to, file.path);
|
|
36505
|
+
await mkdir3(dirname6(dest), { recursive: true });
|
|
36506
|
+
await writeFile3(dest, bytes);
|
|
36507
|
+
process.stderr.write(`# ${file.path} (${file.row_count} rows, ${bytes.byteLength} bytes)
|
|
36508
|
+
`);
|
|
36509
|
+
}
|
|
36510
|
+
writeData(JSON.stringify({
|
|
36511
|
+
files: files.length,
|
|
36512
|
+
to: options2.to,
|
|
36513
|
+
latest_finalized_cursor: manifest.latest_finalized_cursor
|
|
36514
|
+
}, null, 2));
|
|
36515
|
+
} catch (err) {
|
|
36516
|
+
error(err instanceof Error ? err.message : String(err));
|
|
36517
|
+
process.exit(1);
|
|
36518
|
+
}
|
|
36519
|
+
});
|
|
36473
36520
|
streams.command("canonical <height>").description("Canonical block metadata at a given height").action(async (heightArg) => {
|
|
36474
36521
|
try {
|
|
36475
36522
|
const height = parseHeight(heightArg, "<height>");
|
|
@@ -37722,9 +37769,9 @@ init_output();
|
|
|
37722
37769
|
|
|
37723
37770
|
// src/lib/project-file.ts
|
|
37724
37771
|
import { existsSync as existsSync5 } from "node:fs";
|
|
37725
|
-
import { mkdir as
|
|
37772
|
+
import { mkdir as mkdir4, readFile as readFile3, writeFile as writeFile4 } from "node:fs/promises";
|
|
37726
37773
|
import { homedir as homedir5 } from "node:os";
|
|
37727
|
-
import { dirname as
|
|
37774
|
+
import { dirname as dirname12, join as join11, parse as parsePath2, resolve as resolve8 } from "node:path";
|
|
37728
37775
|
import { z as z3 } from "zod/v4";
|
|
37729
37776
|
var ProjectFileSchema = z3.object({
|
|
37730
37777
|
slug: z3.string().min(1)
|
|
@@ -37736,7 +37783,7 @@ async function readActiveProject(cwd, globalDefault) {
|
|
|
37736
37783
|
const home = resolve8(homedir5());
|
|
37737
37784
|
const fsRoot = parsePath2(dir).root;
|
|
37738
37785
|
while (true) {
|
|
37739
|
-
const candidate =
|
|
37786
|
+
const candidate = join11(dir, DIRNAME, FILENAME);
|
|
37740
37787
|
if (existsSync5(candidate)) {
|
|
37741
37788
|
try {
|
|
37742
37789
|
const raw = await readFile3(candidate, "utf8");
|
|
@@ -37744,11 +37791,11 @@ async function readActiveProject(cwd, globalDefault) {
|
|
|
37744
37791
|
return { slug: parsed.slug, resolvedFrom: candidate };
|
|
37745
37792
|
} catch {}
|
|
37746
37793
|
}
|
|
37747
|
-
if (existsSync5(
|
|
37794
|
+
if (existsSync5(join11(dir, ".git")))
|
|
37748
37795
|
break;
|
|
37749
37796
|
if (dir === home || dir === fsRoot)
|
|
37750
37797
|
break;
|
|
37751
|
-
const parent =
|
|
37798
|
+
const parent = dirname12(dir);
|
|
37752
37799
|
if (parent === dir)
|
|
37753
37800
|
break;
|
|
37754
37801
|
dir = parent;
|
|
@@ -37756,16 +37803,16 @@ async function readActiveProject(cwd, globalDefault) {
|
|
|
37756
37803
|
if (globalDefault) {
|
|
37757
37804
|
return {
|
|
37758
37805
|
slug: globalDefault,
|
|
37759
|
-
resolvedFrom:
|
|
37806
|
+
resolvedFrom: join11(homedir5(), ".secondlayer", "config.json")
|
|
37760
37807
|
};
|
|
37761
37808
|
}
|
|
37762
37809
|
return null;
|
|
37763
37810
|
}
|
|
37764
37811
|
async function writeActiveProject(slug, cwd) {
|
|
37765
|
-
const dir =
|
|
37766
|
-
await
|
|
37767
|
-
const file =
|
|
37768
|
-
await
|
|
37812
|
+
const dir = join11(resolve8(cwd), DIRNAME);
|
|
37813
|
+
await mkdir4(dir, { recursive: true });
|
|
37814
|
+
const file = join11(dir, FILENAME);
|
|
37815
|
+
await writeFile4(file, `${JSON.stringify({ slug }, null, 2)}
|
|
37769
37816
|
`, "utf8");
|
|
37770
37817
|
return file;
|
|
37771
37818
|
}
|
|
@@ -38020,5 +38067,5 @@ program.commandsGroup("Account:");
|
|
|
38020
38067
|
registerAccountCommand(program);
|
|
38021
38068
|
program.parse();
|
|
38022
38069
|
|
|
38023
|
-
//# debugId=
|
|
38070
|
+
//# debugId=D600955BDB8E00F064756E2164756E21
|
|
38024
38071
|
//# sourceMappingURL=cli.js.map
|