@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 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 { format } from "prettier";
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
- return format(code, PRETTIER_OPTIONS);
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 PRETTIER_OPTIONS;
7561
- var init_format = __esm(() => {
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
- async getContractInfo(contractId) {
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
- const url = `${this.baseUrl}/v2/contracts/interface/${address}/${contractName}`;
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(`Contract not found: ${contractId}`);
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 contract: ${error.message}`);
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 [address, contractName] = contractId.split(".");
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
- try {
15629
- const response2 = await gotWithRetry(url, {
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, format2 = (open, close) => {
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 = format2(0, 0);
21362
- bold = format2(1, 22);
21363
- dim = format2(2, 22);
21364
- italic = format2(3, 23);
21365
- underline = format2(4, 24);
21366
- overline = format2(53, 55);
21367
- inverse = format2(7, 27);
21368
- hidden = format2(8, 28);
21369
- strikethrough = format2(9, 29);
21370
- black = format2(30, 39);
21371
- red = format2(31, 39);
21372
- green = format2(32, 39);
21373
- yellow = format2(33, 39);
21374
- blue = format2(34, 39);
21375
- magenta = format2(35, 39);
21376
- cyan = format2(36, 39);
21377
- white = format2(37, 39);
21378
- gray = format2(90, 39);
21379
- bgBlack = format2(40, 49);
21380
- bgRed = format2(41, 49);
21381
- bgGreen = format2(42, 49);
21382
- bgYellow = format2(43, 49);
21383
- bgBlue = format2(44, 49);
21384
- bgMagenta = format2(45, 49);
21385
- bgCyan = format2(46, 49);
21386
- bgWhite = format2(47, 49);
21387
- bgGray = format2(100, 49);
21388
- redBright = format2(91, 39);
21389
- greenBright = format2(92, 39);
21390
- yellowBright = format2(93, 39);
21391
- blueBright = format2(94, 39);
21392
- magentaBright = format2(95, 39);
21393
- cyanBright = format2(96, 39);
21394
- whiteBright = format2(97, 39);
21395
- bgRedBright = format2(101, 49);
21396
- bgGreenBright = format2(102, 49);
21397
- bgYellowBright = format2(103, 49);
21398
- bgBlueBright = format2(104, 49);
21399
- bgMagentaBright = format2(105, 49);
21400
- bgCyanBright = format2(106, 49);
21401
- bgWhiteBright = format2(107, 49);
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.0.0",
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
- esbuild: "^0.19.0",
28354
- prettier: "^3.1.0"
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: ">=18"
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=8F249D0A949F885B64756E2164756E21
28409
+ //# debugId=0279498E591F574C64756E2164756E21
28389
28410
  //# sourceMappingURL=cli.js.map