@secondlayer/cli 1.0.0 → 1.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 +106 -85
- package/dist/cli.js.map +4 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.js +55 -21
- package/dist/index.js.map +5 -5
- package/dist/plugin-manager.js +45 -15
- package/dist/plugin-manager.js.map +3 -3
- package/package.json +5 -4
package/dist/cli.js
CHANGED
|
@@ -7550,23 +7550,53 @@ function isDirectFileContract(c) {
|
|
|
7550
7550
|
// src/utils/format.ts
|
|
7551
7551
|
var exports_format = {};
|
|
7552
7552
|
__export(exports_format, {
|
|
7553
|
-
formatCode: () => formatCode
|
|
7554
|
-
PRETTIER_OPTIONS: () => PRETTIER_OPTIONS
|
|
7553
|
+
formatCode: () => formatCode
|
|
7555
7554
|
});
|
|
7556
|
-
import {
|
|
7555
|
+
import { Biome, Distribution } from "@biomejs/js-api";
|
|
7556
|
+
async function getBiome() {
|
|
7557
|
+
if (!biome) {
|
|
7558
|
+
biome = await Biome.create({
|
|
7559
|
+
distribution: Distribution.NODE
|
|
7560
|
+
});
|
|
7561
|
+
biome.applyConfiguration({
|
|
7562
|
+
formatter: {
|
|
7563
|
+
enabled: true,
|
|
7564
|
+
indentStyle: "tab",
|
|
7565
|
+
lineWidth: 80
|
|
7566
|
+
},
|
|
7567
|
+
javascript: {
|
|
7568
|
+
formatter: {
|
|
7569
|
+
semicolons: "always",
|
|
7570
|
+
quoteStyle: "single"
|
|
7571
|
+
}
|
|
7572
|
+
},
|
|
7573
|
+
organizeImports: {
|
|
7574
|
+
enabled: true
|
|
7575
|
+
},
|
|
7576
|
+
linter: {
|
|
7577
|
+
enabled: true
|
|
7578
|
+
},
|
|
7579
|
+
assists: {
|
|
7580
|
+
enabled: true
|
|
7581
|
+
}
|
|
7582
|
+
});
|
|
7583
|
+
biome.registerProjectFolder();
|
|
7584
|
+
}
|
|
7585
|
+
return biome;
|
|
7586
|
+
}
|
|
7557
7587
|
async function formatCode(code) {
|
|
7558
|
-
|
|
7588
|
+
const b = await getBiome();
|
|
7589
|
+
const linted = b.lintContent(code, {
|
|
7590
|
+
filePath: "generated.ts",
|
|
7591
|
+
fixFileMode: "SafeFixes"
|
|
7592
|
+
});
|
|
7593
|
+
const formatted = b.formatContent(linted.content, {
|
|
7594
|
+
filePath: "generated.ts"
|
|
7595
|
+
});
|
|
7596
|
+
return formatted.content;
|
|
7559
7597
|
}
|
|
7560
|
-
var
|
|
7561
|
-
var init_format =
|
|
7562
|
-
PRETTIER_OPTIONS = {
|
|
7563
|
-
parser: "typescript",
|
|
7564
|
-
singleQuote: true,
|
|
7565
|
-
semi: true,
|
|
7566
|
-
printWidth: 100,
|
|
7567
|
-
trailingComma: "es5"
|
|
7568
|
-
};
|
|
7569
|
-
});
|
|
7598
|
+
var biome = null;
|
|
7599
|
+
var init_format = () => {};
|
|
7570
7600
|
|
|
7571
7601
|
// src/core/plugin-manager.ts
|
|
7572
7602
|
import { promises as fs } from "fs";
|
|
@@ -15597,12 +15627,14 @@ class StacksApiClient {
|
|
|
15597
15627
|
StacksApiClient.hasWarnedAboutApiKey = true;
|
|
15598
15628
|
}
|
|
15599
15629
|
}
|
|
15600
|
-
|
|
15630
|
+
parseContractId(contractId) {
|
|
15601
15631
|
const [address, contractName] = contractId.split(".");
|
|
15602
15632
|
if (!address || !contractName) {
|
|
15603
15633
|
throw new Error(`Invalid contract ID format: ${contractId}. Expected format: ADDRESS.CONTRACT_NAME`);
|
|
15604
15634
|
}
|
|
15605
|
-
|
|
15635
|
+
return { address, contractName };
|
|
15636
|
+
}
|
|
15637
|
+
async fetchWithErrorHandling(url, resourceType, resourceId) {
|
|
15606
15638
|
try {
|
|
15607
15639
|
const response2 = await gotWithRetry(url, {
|
|
15608
15640
|
headers: this.headers,
|
|
@@ -15611,36 +15643,24 @@ class StacksApiClient {
|
|
|
15611
15643
|
return response2.body;
|
|
15612
15644
|
} catch (error) {
|
|
15613
15645
|
if (error.response?.statusCode === 404) {
|
|
15614
|
-
throw new Error(
|
|
15646
|
+
throw new Error(`${resourceType} not found: ${resourceId}`);
|
|
15615
15647
|
}
|
|
15616
15648
|
if (error.response?.statusCode === 429) {
|
|
15617
15649
|
throw new Error("Rate limited. Please provide an API key in your config.");
|
|
15618
15650
|
}
|
|
15619
|
-
throw new Error(`Failed to fetch
|
|
15651
|
+
throw new Error(`Failed to fetch ${resourceType.toLowerCase()}: ${error.message}`);
|
|
15620
15652
|
}
|
|
15621
15653
|
}
|
|
15654
|
+
async getContractInfo(contractId) {
|
|
15655
|
+
const { address, contractName } = this.parseContractId(contractId);
|
|
15656
|
+
const url = `${this.baseUrl}/v2/contracts/interface/${address}/${contractName}`;
|
|
15657
|
+
return this.fetchWithErrorHandling(url, "Contract", contractId);
|
|
15658
|
+
}
|
|
15622
15659
|
async getContractSource(contractId) {
|
|
15623
|
-
const
|
|
15624
|
-
if (!address || !contractName) {
|
|
15625
|
-
throw new Error(`Invalid contract ID format: ${contractId}. Expected format: ADDRESS.CONTRACT_NAME`);
|
|
15626
|
-
}
|
|
15660
|
+
const { address, contractName } = this.parseContractId(contractId);
|
|
15627
15661
|
const url = `${this.baseUrl}/v2/contracts/source/${address}/${contractName}`;
|
|
15628
|
-
|
|
15629
|
-
|
|
15630
|
-
headers: this.headers,
|
|
15631
|
-
responseType: "json"
|
|
15632
|
-
});
|
|
15633
|
-
const data = response2.body;
|
|
15634
|
-
return data.source;
|
|
15635
|
-
} catch (error) {
|
|
15636
|
-
if (error.response?.statusCode === 404) {
|
|
15637
|
-
throw new Error(`Contract source not found: ${contractId}`);
|
|
15638
|
-
}
|
|
15639
|
-
if (error.response?.statusCode === 429) {
|
|
15640
|
-
throw new Error("Rate limited. Please provide an API key in your config.");
|
|
15641
|
-
}
|
|
15642
|
-
throw new Error(`Failed to fetch contract source: ${error.message}`);
|
|
15643
|
-
}
|
|
15662
|
+
const data = await this.fetchWithErrorHandling(url, "Contract source", contractId);
|
|
15663
|
+
return data.source;
|
|
15644
15664
|
}
|
|
15645
15665
|
}
|
|
15646
15666
|
var gotWithRetry, API_URLS;
|
|
@@ -21331,7 +21351,7 @@ var init_figures = __esm(() => {
|
|
|
21331
21351
|
|
|
21332
21352
|
// ../../node_modules/yoctocolors/base.js
|
|
21333
21353
|
import tty2 from "node:tty";
|
|
21334
|
-
var hasColors,
|
|
21354
|
+
var hasColors, format = (open, close) => {
|
|
21335
21355
|
if (!hasColors) {
|
|
21336
21356
|
return (input) => input;
|
|
21337
21357
|
}
|
|
@@ -21358,47 +21378,47 @@ var hasColors, format2 = (open, close) => {
|
|
|
21358
21378
|
}, reset, bold, dim, italic, underline, overline, inverse, hidden, strikethrough, black, red, green, yellow, blue, magenta, cyan, white, gray, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bgGray, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright;
|
|
21359
21379
|
var init_base = __esm(() => {
|
|
21360
21380
|
hasColors = tty2?.WriteStream?.prototype?.hasColors?.() ?? false;
|
|
21361
|
-
reset =
|
|
21362
|
-
bold =
|
|
21363
|
-
dim =
|
|
21364
|
-
italic =
|
|
21365
|
-
underline =
|
|
21366
|
-
overline =
|
|
21367
|
-
inverse =
|
|
21368
|
-
hidden =
|
|
21369
|
-
strikethrough =
|
|
21370
|
-
black =
|
|
21371
|
-
red =
|
|
21372
|
-
green =
|
|
21373
|
-
yellow =
|
|
21374
|
-
blue =
|
|
21375
|
-
magenta =
|
|
21376
|
-
cyan =
|
|
21377
|
-
white =
|
|
21378
|
-
gray =
|
|
21379
|
-
bgBlack =
|
|
21380
|
-
bgRed =
|
|
21381
|
-
bgGreen =
|
|
21382
|
-
bgYellow =
|
|
21383
|
-
bgBlue =
|
|
21384
|
-
bgMagenta =
|
|
21385
|
-
bgCyan =
|
|
21386
|
-
bgWhite =
|
|
21387
|
-
bgGray =
|
|
21388
|
-
redBright =
|
|
21389
|
-
greenBright =
|
|
21390
|
-
yellowBright =
|
|
21391
|
-
blueBright =
|
|
21392
|
-
magentaBright =
|
|
21393
|
-
cyanBright =
|
|
21394
|
-
whiteBright =
|
|
21395
|
-
bgRedBright =
|
|
21396
|
-
bgGreenBright =
|
|
21397
|
-
bgYellowBright =
|
|
21398
|
-
bgBlueBright =
|
|
21399
|
-
bgMagentaBright =
|
|
21400
|
-
bgCyanBright =
|
|
21401
|
-
bgWhiteBright =
|
|
21381
|
+
reset = format(0, 0);
|
|
21382
|
+
bold = format(1, 22);
|
|
21383
|
+
dim = format(2, 22);
|
|
21384
|
+
italic = format(3, 23);
|
|
21385
|
+
underline = format(4, 24);
|
|
21386
|
+
overline = format(53, 55);
|
|
21387
|
+
inverse = format(7, 27);
|
|
21388
|
+
hidden = format(8, 28);
|
|
21389
|
+
strikethrough = format(9, 29);
|
|
21390
|
+
black = format(30, 39);
|
|
21391
|
+
red = format(31, 39);
|
|
21392
|
+
green = format(32, 39);
|
|
21393
|
+
yellow = format(33, 39);
|
|
21394
|
+
blue = format(34, 39);
|
|
21395
|
+
magenta = format(35, 39);
|
|
21396
|
+
cyan = format(36, 39);
|
|
21397
|
+
white = format(37, 39);
|
|
21398
|
+
gray = format(90, 39);
|
|
21399
|
+
bgBlack = format(40, 49);
|
|
21400
|
+
bgRed = format(41, 49);
|
|
21401
|
+
bgGreen = format(42, 49);
|
|
21402
|
+
bgYellow = format(43, 49);
|
|
21403
|
+
bgBlue = format(44, 49);
|
|
21404
|
+
bgMagenta = format(45, 49);
|
|
21405
|
+
bgCyan = format(46, 49);
|
|
21406
|
+
bgWhite = format(47, 49);
|
|
21407
|
+
bgGray = format(100, 49);
|
|
21408
|
+
redBright = format(91, 39);
|
|
21409
|
+
greenBright = format(92, 39);
|
|
21410
|
+
yellowBright = format(93, 39);
|
|
21411
|
+
blueBright = format(94, 39);
|
|
21412
|
+
magentaBright = format(95, 39);
|
|
21413
|
+
cyanBright = format(96, 39);
|
|
21414
|
+
whiteBright = format(97, 39);
|
|
21415
|
+
bgRedBright = format(101, 49);
|
|
21416
|
+
bgGreenBright = format(102, 49);
|
|
21417
|
+
bgYellowBright = format(103, 49);
|
|
21418
|
+
bgBlueBright = format(104, 49);
|
|
21419
|
+
bgMagentaBright = format(105, 49);
|
|
21420
|
+
bgCyanBright = format(106, 49);
|
|
21421
|
+
bgWhiteBright = format(107, 49);
|
|
21402
21422
|
});
|
|
21403
21423
|
|
|
21404
21424
|
// ../../node_modules/yoctocolors/index.js
|
|
@@ -28309,7 +28329,7 @@ var {
|
|
|
28309
28329
|
// package.json
|
|
28310
28330
|
var package_default = {
|
|
28311
28331
|
name: "@secondlayer/cli",
|
|
28312
|
-
version: "1.
|
|
28332
|
+
version: "1.2.0",
|
|
28313
28333
|
description: "CLI for generating type-safe contract interfaces for the Stacks blockchain",
|
|
28314
28334
|
type: "module",
|
|
28315
28335
|
bin: {
|
|
@@ -28350,8 +28370,9 @@ var package_default = {
|
|
|
28350
28370
|
dependencies: {
|
|
28351
28371
|
"@secondlayer/clarity-types": "^0.5.0",
|
|
28352
28372
|
"@stacks/transactions": "7.0.6",
|
|
28353
|
-
|
|
28354
|
-
|
|
28373
|
+
"@biomejs/js-api": "^0.7.0",
|
|
28374
|
+
"@biomejs/wasm-nodejs": "^1.9.0",
|
|
28375
|
+
esbuild: "^0.19.0"
|
|
28355
28376
|
},
|
|
28356
28377
|
devDependencies: {
|
|
28357
28378
|
"@antfu/ni": "^24.4.0",
|
|
@@ -28368,7 +28389,7 @@ var package_default = {
|
|
|
28368
28389
|
react: "^19.1.0"
|
|
28369
28390
|
},
|
|
28370
28391
|
engines: {
|
|
28371
|
-
node: ">=
|
|
28392
|
+
node: ">=20.19.0"
|
|
28372
28393
|
}
|
|
28373
28394
|
};
|
|
28374
28395
|
|
|
@@ -28385,5 +28406,5 @@ program.command("init").description("Initialize a new secondlayer.config.ts file
|
|
|
28385
28406
|
});
|
|
28386
28407
|
program.parse();
|
|
28387
28408
|
|
|
28388
|
-
//# debugId=
|
|
28409
|
+
//# debugId=0279498E591F574C64756E2164756E21
|
|
28389
28410
|
//# sourceMappingURL=cli.js.map
|