@elytro/cli 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +142 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -521,6 +521,7 @@ var PUBLIC_RPC = {
|
|
|
521
521
|
1: "https://ethereum-rpc.publicnode.com",
|
|
522
522
|
10: "https://optimism-rpc.publicnode.com",
|
|
523
523
|
42161: "https://arbitrum-one-rpc.publicnode.com",
|
|
524
|
+
8453: "https://base-rpc.publicnode.com",
|
|
524
525
|
11155111: "https://ethereum-sepolia-rpc.publicnode.com",
|
|
525
526
|
11155420: "https://optimism-sepolia-rpc.publicnode.com"
|
|
526
527
|
};
|
|
@@ -528,6 +529,7 @@ var PUBLIC_BUNDLER = {
|
|
|
528
529
|
1: "https://public.pimlico.io/v2/1/rpc",
|
|
529
530
|
10: "https://public.pimlico.io/v2/10/rpc",
|
|
530
531
|
42161: "https://public.pimlico.io/v2/42161/rpc",
|
|
532
|
+
8453: "https://public.pimlico.io/v2/8453/rpc",
|
|
531
533
|
11155111: "https://public.pimlico.io/v2/11155111/rpc",
|
|
532
534
|
11155420: "https://public.pimlico.io/v2/11155420/rpc"
|
|
533
535
|
};
|
|
@@ -541,6 +543,7 @@ var ALCHEMY_NETWORK = {
|
|
|
541
543
|
1: "eth-mainnet",
|
|
542
544
|
10: "opt-mainnet",
|
|
543
545
|
42161: "arb-mainnet",
|
|
546
|
+
8453: "base-mainnet",
|
|
544
547
|
11155111: "eth-sepolia",
|
|
545
548
|
11155420: "opt-sepolia"
|
|
546
549
|
};
|
|
@@ -548,6 +551,7 @@ var PIMLICO_SLUG = {
|
|
|
548
551
|
1: "ethereum",
|
|
549
552
|
10: "optimism",
|
|
550
553
|
42161: "arbitrum",
|
|
554
|
+
8453: "base",
|
|
551
555
|
11155111: "sepolia",
|
|
552
556
|
11155420: "optimism-sepolia"
|
|
553
557
|
};
|
|
@@ -584,6 +588,12 @@ var CHAIN_META = [
|
|
|
584
588
|
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
585
589
|
blockExplorer: "https://arbiscan.io"
|
|
586
590
|
},
|
|
591
|
+
{
|
|
592
|
+
id: 8453,
|
|
593
|
+
name: "Base",
|
|
594
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
595
|
+
blockExplorer: "https://basescan.org"
|
|
596
|
+
},
|
|
587
597
|
{
|
|
588
598
|
id: 11155111,
|
|
589
599
|
name: "Sepolia",
|
|
@@ -4221,9 +4231,139 @@ function registerConfigCommand(program2, ctx) {
|
|
|
4221
4231
|
});
|
|
4222
4232
|
}
|
|
4223
4233
|
|
|
4234
|
+
// src/commands/update.ts
|
|
4235
|
+
import { execSync } from "child_process";
|
|
4236
|
+
|
|
4237
|
+
// src/version.ts
|
|
4238
|
+
import { createRequire } from "module";
|
|
4239
|
+
function resolveVersion() {
|
|
4240
|
+
if (true) {
|
|
4241
|
+
return "0.5.1";
|
|
4242
|
+
}
|
|
4243
|
+
try {
|
|
4244
|
+
const require2 = createRequire(import.meta.url);
|
|
4245
|
+
const pkg = require2("../package.json");
|
|
4246
|
+
return pkg.version;
|
|
4247
|
+
} catch {
|
|
4248
|
+
return "0.0.0";
|
|
4249
|
+
}
|
|
4250
|
+
}
|
|
4251
|
+
var VERSION = resolveVersion();
|
|
4252
|
+
|
|
4253
|
+
// src/commands/update.ts
|
|
4254
|
+
import ora6 from "ora";
|
|
4255
|
+
import chalk2 from "chalk";
|
|
4256
|
+
import { realpathSync } from "fs";
|
|
4257
|
+
import { fileURLToPath } from "url";
|
|
4258
|
+
var PACKAGE_NAME = "@elytro/cli";
|
|
4259
|
+
var NPM_REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
|
|
4260
|
+
async function fetchLatestVersion() {
|
|
4261
|
+
const res = await fetch(NPM_REGISTRY_URL);
|
|
4262
|
+
if (!res.ok) {
|
|
4263
|
+
throw new Error(`npm registry returned ${res.status}`);
|
|
4264
|
+
}
|
|
4265
|
+
const data = await res.json();
|
|
4266
|
+
return data.version;
|
|
4267
|
+
}
|
|
4268
|
+
function compareSemver(a, b) {
|
|
4269
|
+
const pa = a.split(".").map(Number);
|
|
4270
|
+
const pb = b.split(".").map(Number);
|
|
4271
|
+
for (let i = 0; i < 3; i++) {
|
|
4272
|
+
if ((pa[i] ?? 0) < (pb[i] ?? 0)) return -1;
|
|
4273
|
+
if ((pa[i] ?? 0) > (pb[i] ?? 0)) return 1;
|
|
4274
|
+
}
|
|
4275
|
+
return 0;
|
|
4276
|
+
}
|
|
4277
|
+
function detectPackageManager() {
|
|
4278
|
+
try {
|
|
4279
|
+
const scriptPath = realpathSync(fileURLToPath(import.meta.url));
|
|
4280
|
+
if (scriptPath.includes("/.bun/")) return "bun";
|
|
4281
|
+
if (scriptPath.includes("/pnpm/") || scriptPath.includes("/pnpm-global/"))
|
|
4282
|
+
return "pnpm";
|
|
4283
|
+
if (scriptPath.includes("/yarn/global/")) return "yarn";
|
|
4284
|
+
} catch {
|
|
4285
|
+
}
|
|
4286
|
+
const ua = process.env.npm_config_user_agent ?? "";
|
|
4287
|
+
if (ua.startsWith("bun")) return "bun";
|
|
4288
|
+
if (ua.startsWith("pnpm")) return "pnpm";
|
|
4289
|
+
if (ua.startsWith("yarn")) return "yarn";
|
|
4290
|
+
return "npm";
|
|
4291
|
+
}
|
|
4292
|
+
function buildInstallCommand(pm, version) {
|
|
4293
|
+
const pkg = `${PACKAGE_NAME}@${version}`;
|
|
4294
|
+
switch (pm) {
|
|
4295
|
+
case "yarn":
|
|
4296
|
+
return `yarn global add ${pkg}`;
|
|
4297
|
+
case "pnpm":
|
|
4298
|
+
return `pnpm add -g ${pkg}`;
|
|
4299
|
+
case "bun":
|
|
4300
|
+
return `bun add -g ${pkg}`;
|
|
4301
|
+
default:
|
|
4302
|
+
return `npm install -g ${pkg}`;
|
|
4303
|
+
}
|
|
4304
|
+
}
|
|
4305
|
+
function registerUpdateCommand(program2) {
|
|
4306
|
+
const updateCmd = program2.command("update").alias("upgrade").description("Check for updates and upgrade to the latest version");
|
|
4307
|
+
updateCmd.command("check").description("Check if a newer version is available (no install)").action(async () => {
|
|
4308
|
+
try {
|
|
4309
|
+
const latest = await fetchLatestVersion();
|
|
4310
|
+
const cmp = compareSemver(VERSION, latest);
|
|
4311
|
+
outputResult({
|
|
4312
|
+
currentVersion: VERSION,
|
|
4313
|
+
latestVersion: latest,
|
|
4314
|
+
updateAvailable: cmp < 0,
|
|
4315
|
+
...cmp < 0 ? {
|
|
4316
|
+
upgradeCommand: buildInstallCommand(
|
|
4317
|
+
detectPackageManager(),
|
|
4318
|
+
latest
|
|
4319
|
+
)
|
|
4320
|
+
} : {}
|
|
4321
|
+
});
|
|
4322
|
+
} catch (err) {
|
|
4323
|
+
outputError(
|
|
4324
|
+
-32e3,
|
|
4325
|
+
`Failed to check for updates: ${err.message}`
|
|
4326
|
+
);
|
|
4327
|
+
}
|
|
4328
|
+
});
|
|
4329
|
+
updateCmd.action(async () => {
|
|
4330
|
+
const spinner = ora6("Checking for updates\u2026").start();
|
|
4331
|
+
try {
|
|
4332
|
+
const latest = await fetchLatestVersion();
|
|
4333
|
+
const cmp = compareSemver(VERSION, latest);
|
|
4334
|
+
if (cmp >= 0) {
|
|
4335
|
+
spinner.succeed(chalk2.green(`Already up to date (v${VERSION})`));
|
|
4336
|
+
outputResult({
|
|
4337
|
+
currentVersion: VERSION,
|
|
4338
|
+
latestVersion: latest,
|
|
4339
|
+
updateAvailable: false
|
|
4340
|
+
});
|
|
4341
|
+
return;
|
|
4342
|
+
}
|
|
4343
|
+
spinner.text = `Updating ${chalk2.gray(`v${VERSION}`)} \u2192 ${chalk2.green(`v${latest}`)}\u2026`;
|
|
4344
|
+
const pm = detectPackageManager();
|
|
4345
|
+
const cmd = buildInstallCommand(pm, latest);
|
|
4346
|
+
execSync(cmd, { stdio: "pipe" });
|
|
4347
|
+
spinner.succeed(chalk2.green(`Updated to v${latest}`));
|
|
4348
|
+
outputResult({
|
|
4349
|
+
previousVersion: VERSION,
|
|
4350
|
+
currentVersion: latest,
|
|
4351
|
+
updateAvailable: false,
|
|
4352
|
+
packageManager: pm
|
|
4353
|
+
});
|
|
4354
|
+
} catch (err) {
|
|
4355
|
+
spinner.fail("Update failed");
|
|
4356
|
+
outputError(-32e3, `Update failed: ${err.message}`);
|
|
4357
|
+
}
|
|
4358
|
+
});
|
|
4359
|
+
}
|
|
4360
|
+
|
|
4224
4361
|
// src/index.ts
|
|
4225
4362
|
var program = new Command();
|
|
4226
|
-
program.name("elytro").description("Elytro \u2014 ERC-4337 Smart Account Wallet CLI").version(
|
|
4363
|
+
program.name("elytro").description("Elytro \u2014 ERC-4337 Smart Account Wallet CLI").version(VERSION).addHelpText(
|
|
4364
|
+
"after",
|
|
4365
|
+
"\nLearn how to use Elytro skills: https://github.com/Elytro-eth/skills\n"
|
|
4366
|
+
);
|
|
4227
4367
|
async function main() {
|
|
4228
4368
|
let ctx = null;
|
|
4229
4369
|
try {
|
|
@@ -4234,6 +4374,7 @@ async function main() {
|
|
|
4234
4374
|
registerQueryCommand(program, ctx);
|
|
4235
4375
|
registerSecurityCommand(program, ctx);
|
|
4236
4376
|
registerConfigCommand(program, ctx);
|
|
4377
|
+
registerUpdateCommand(program);
|
|
4237
4378
|
await program.parseAsync(process.argv);
|
|
4238
4379
|
} catch (err) {
|
|
4239
4380
|
outputError(-32e3, sanitizeErrorMessage(err.message));
|