@clarigen/cli 2.1.0 → 2.1.2

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/run-cli.cjs CHANGED
@@ -1,39 +1,11 @@
1
1
  #!/usr/bin/env node
2
+ "use strict";
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
- var __defProps = Object.defineProperties;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
7
  var __getProtoOf = Object.getPrototypeOf;
10
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
11
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
- var __spreadValues = (a, b) => {
14
- for (var prop in b || (b = {}))
15
- if (__hasOwnProp.call(b, prop))
16
- __defNormalProp(a, prop, b[prop]);
17
- if (__getOwnPropSymbols)
18
- for (var prop of __getOwnPropSymbols(b)) {
19
- if (__propIsEnum.call(b, prop))
20
- __defNormalProp(a, prop, b[prop]);
21
- }
22
- return a;
23
- };
24
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
- var __objRest = (source, exclude) => {
26
- var target = {};
27
- for (var prop in source)
28
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
- target[prop] = source[prop];
30
- if (source != null && __getOwnPropSymbols)
31
- for (var prop of __getOwnPropSymbols(source)) {
32
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
- target[prop] = source[prop];
34
- }
35
- return target;
36
- };
37
9
  var __copyProps = (to, from, except, desc) => {
38
10
  if (from && typeof from === "object" || typeof from === "function") {
39
11
  for (let key of __getOwnPropNames(from))
@@ -42,11 +14,14 @@ var __copyProps = (to, from, except, desc) => {
42
14
  }
43
15
  return to;
44
16
  };
45
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
46
- var __publicField = (obj, key, value) => {
47
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
48
- return value;
49
- };
17
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
50
25
 
51
26
  // src/run-cli.ts
52
27
  var import_clipanion6 = require("clipanion");
@@ -61,12 +36,14 @@ var import_zod2 = require("zod");
61
36
  var import_pino = require("pino");
62
37
  var import_pino_pretty = __toESM(require("pino-pretty"), 1);
63
38
  var colorizedClarigen = `\x1B[33m[Clarigen]\x1B[0m`;
64
- var logger = (0, import_pino.pino)((0, import_pino_pretty.default)({
65
- colorize: true,
66
- ignore: "pid,hostname,time",
67
- messageFormat: `${colorizedClarigen} {msg}`,
68
- minimumLevel: "debug"
69
- }));
39
+ var logger = (0, import_pino.pino)(
40
+ (0, import_pino_pretty.default)({
41
+ colorize: true,
42
+ ignore: "pid,hostname,time",
43
+ messageFormat: `${colorizedClarigen} {msg}`,
44
+ minimumLevel: "debug"
45
+ })
46
+ );
70
47
  logger.level = "info";
71
48
  var log = logger;
72
49
 
@@ -75,8 +52,7 @@ var import_core = require("@clarigen/core");
75
52
  var import_promises = require("fs/promises");
76
53
  var import_path = require("path");
77
54
  function encodeVariableName(name) {
78
- if (/^[A-Z\-_]*$/.test(name))
79
- return name.replaceAll("-", "_");
55
+ if (/^[A-Z\-_]*$/.test(name)) return name.replaceAll("-", "_");
80
56
  return (0, import_core.toCamelCase)(name);
81
57
  }
82
58
  async function fileExists(filename) {
@@ -168,26 +144,25 @@ var Config = class {
168
144
  var _a, _b;
169
145
  const singlePath = (_a = this.configFile[type]) == null ? void 0 : _a.output;
170
146
  const multiPath = ((_b = this.configFile[type]) == null ? void 0 : _b.outputs) || [];
171
- if (singlePath !== void 0)
172
- return [singlePath];
147
+ if (singlePath !== void 0) return [singlePath];
173
148
  return multiPath;
174
149
  }
175
150
  outputResolve(type, filePath) {
176
151
  const outputs = this.getOutputs(type);
177
- if (!this.supports(type))
178
- return null;
152
+ if (!this.supports(type)) return null;
179
153
  return outputs.map((path) => {
180
154
  return (0, import_path2.resolve)(this.cwd, path, filePath || "");
181
155
  });
182
156
  }
183
157
  async writeOutput(type, contents, filePath) {
184
158
  const paths = this.outputResolve(type, filePath);
185
- if (paths === null)
186
- return null;
187
- await Promise.all(paths.map(async (path) => {
188
- await writeFile(path, contents);
189
- log.debug(`Generated ${type} file at ${(0, import_path2.relative)(this.cwd, path)}`);
190
- }));
159
+ if (paths === null) return null;
160
+ await Promise.all(
161
+ paths.map(async (path) => {
162
+ await writeFile(path, contents);
163
+ log.debug(`Generated ${type} file at ${(0, import_path2.relative)(this.cwd, path)}`);
164
+ })
165
+ );
191
166
  return paths;
192
167
  }
193
168
  supports(type) {
@@ -215,8 +190,7 @@ function configFilePath(cwd) {
215
190
  }
216
191
  var sessionConfig;
217
192
  async function getConfig(cwd) {
218
- if (typeof sessionConfig !== "undefined")
219
- return sessionConfig;
193
+ if (typeof sessionConfig !== "undefined") return sessionConfig;
220
194
  const path = configFilePath(cwd);
221
195
  if (await fileExists(path)) {
222
196
  const toml = await (0, import_promises3.readFile)(path, "utf-8");
@@ -249,6 +223,7 @@ var BaseCommand = class extends import_clipanion.Command {
249
223
  logger.level = "debug";
250
224
  }
251
225
  }
226
+ // eslint-disable-next-line @typescript-eslint/require-await
252
227
  async catch(error) {
253
228
  if (error instanceof import_zod3.ZodError) {
254
229
  logger.error(error.issues, "Your configuration file is invalid.");
@@ -264,6 +239,10 @@ var BaseCommand = class extends import_clipanion.Command {
264
239
 
265
240
  // src/commands/session-info.ts
266
241
  var SessionInfoCommand = class extends BaseCommand {
242
+ static paths = [["session-info"]];
243
+ static usage = import_clipanion2.Command.Usage({
244
+ description: "Log info about this project's Clarinet session"
245
+ });
267
246
  cwd = import_clipanion2.Option.String({ required: false });
268
247
  async execute() {
269
248
  this.preexecute();
@@ -271,10 +250,6 @@ var SessionInfoCommand = class extends BaseCommand {
271
250
  logger.info(config);
272
251
  }
273
252
  };
274
- __publicField(SessionInfoCommand, "paths", [["session-info"]]);
275
- __publicField(SessionInfoCommand, "usage", import_clipanion2.Command.Usage({
276
- description: "Log info about this project's Clarinet session"
277
- }));
278
253
 
279
254
  // src/commands/default-command.ts
280
255
  var import_clipanion3 = require("clipanion");
@@ -293,12 +268,10 @@ var import_core3 = require("@clarigen/core");
293
268
  var jsTypeFromAbiType = (val, isArgument = false) => {
294
269
  if ((0, import_core2.isClarityAbiPrimitive)(val)) {
295
270
  if (val === "uint128") {
296
- if (isArgument)
297
- return "number | bigint";
271
+ if (isArgument) return "number | bigint";
298
272
  return "bigint";
299
273
  } else if (val === "int128") {
300
- if (isArgument)
301
- return "number | bigint";
274
+ if (isArgument) return "number | bigint";
302
275
  return "bigint";
303
276
  } else if (val === "bool") {
304
277
  return "boolean";
@@ -366,7 +339,50 @@ function _hash(...words) {
366
339
  }
367
340
  return h;
368
341
  }
369
- var RESERVED = _hash("break", "do", "in", "typeof", "case", "else", "instanceof", "var", "catch", "export", "new", "void", "class", "extends", "return", "while", "const", "finally", "super", "with", "continue", "for", "switch", "yield", "debugger", "function", "this", "default", "if", "throw", "delete", "import", "try", "enum", "await", "null", "true", "false");
342
+ var RESERVED = _hash(
343
+ // Keywords, ES6 11.6.2.1, http://www.ecma-international.org/ecma-262/6.0/index.html#sec-keywords
344
+ "break",
345
+ "do",
346
+ "in",
347
+ "typeof",
348
+ "case",
349
+ "else",
350
+ "instanceof",
351
+ "var",
352
+ "catch",
353
+ "export",
354
+ "new",
355
+ "void",
356
+ "class",
357
+ "extends",
358
+ "return",
359
+ "while",
360
+ "const",
361
+ "finally",
362
+ "super",
363
+ "with",
364
+ "continue",
365
+ "for",
366
+ "switch",
367
+ "yield",
368
+ "debugger",
369
+ "function",
370
+ "this",
371
+ "default",
372
+ "if",
373
+ "throw",
374
+ "delete",
375
+ "import",
376
+ "try",
377
+ // Future Reserved Words, ES6 11.6.2.2
378
+ // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-future-reserved-words
379
+ "enum",
380
+ "await",
381
+ // NullLiteral & BooleanLiteral
382
+ "null",
383
+ "true",
384
+ "false"
385
+ );
370
386
 
371
387
  // src/files/base.ts
372
388
  var import_core5 = require("@clarigen/core");
@@ -374,10 +390,12 @@ var import_core5 = require("@clarigen/core");
374
390
  // src/files/accounts.ts
375
391
  function generateAccountsCode(accounts) {
376
392
  const sortedAccounts = sortAccounts(accounts);
377
- const namedAccounts = Object.fromEntries(sortedAccounts.map((a) => {
378
- const _a = a, { name } = _a, rest = __objRest(_a, ["name"]);
379
- return [name, rest];
380
- }));
393
+ const namedAccounts = Object.fromEntries(
394
+ sortedAccounts.map((a) => {
395
+ const { name, ...rest } = a;
396
+ return [name, rest];
397
+ })
398
+ );
381
399
  return JSON.stringify(namedAccounts);
382
400
  }
383
401
  function sortAccounts(accounts) {
@@ -393,10 +411,12 @@ function sortAccounts(accounts) {
393
411
  // src/files/identifiers.ts
394
412
  var import_core4 = require("@clarigen/core");
395
413
  function generateIdentifiers(session) {
396
- const identifiers = Object.fromEntries(sortContracts(session.contracts).map((c) => {
397
- const contractName = (0, import_core4.getContractName)(c.contract_id);
398
- return [contractName, c.contract_id];
399
- }));
414
+ const identifiers = Object.fromEntries(
415
+ sortContracts(session.contracts).map((c) => {
416
+ const contractName = (0, import_core4.getContractName)(c.contract_id);
417
+ return [contractName, c.contract_id];
418
+ })
419
+ );
400
420
  return identifiers;
401
421
  }
402
422
  function generateIdentifiersCode(session) {
@@ -409,7 +429,7 @@ var import_util = require("util");
409
429
  function generateContractMeta(contract, constants) {
410
430
  const abi = contract.contract_interface;
411
431
  const functionLines = [];
412
- const _a = abi, { functions, maps, variables, non_fungible_tokens } = _a, rest = __objRest(_a, ["functions", "maps", "variables", "non_fungible_tokens"]);
432
+ const { functions, maps, variables, non_fungible_tokens, ...rest } = abi;
413
433
  functions.forEach((func) => {
414
434
  let functionLine = `${(0, import_core5.toCamelCase)(func.name)}: `;
415
435
  const funcDef = JSON.stringify(func);
@@ -444,7 +464,8 @@ function generateContractMeta(contract, constants) {
444
464
  }
445
465
  var TYPE_IMPORTS = `import type { TypedAbiArg, TypedAbiFunction, TypedAbiMap, TypedAbiVariable, Response } from '@clarigen/core';`;
446
466
  function generateBaseFile(session) {
447
- const combined = session.contracts.map((c, i) => __spreadProps(__spreadValues({}, c), {
467
+ const combined = session.contracts.map((c, i) => ({
468
+ ...c,
448
469
  constants: session.variables[i]
449
470
  }));
450
471
  const contractDefs = sortContracts(combined).map((contract) => {
@@ -487,14 +508,20 @@ Uint8Array.prototype[import_util.inspect.custom] = function(depth, options) {
487
508
  };
488
509
  function serialize(obj) {
489
510
  return (0, import_util.inspect)(obj, {
511
+ // showHidden: false,
512
+ // depth: 100,
513
+ // colors: false,
490
514
  showHidden: false,
515
+ // iterableLimit: 100000,
491
516
  compact: false,
517
+ // trailingComma: true,
492
518
  depth: 100,
493
519
  colors: false,
494
520
  maxArrayLength: Infinity,
495
521
  maxStringLength: Infinity,
496
522
  breakLength: Infinity,
497
523
  numericSeparator: true
524
+ // strAbbreviateSize: 100000,
498
525
  });
499
526
  }
500
527
  function serializeLines(key, lines) {
@@ -514,7 +541,9 @@ function getVariablesV2(contract, simnet, verbose) {
514
541
  const fakeId = `${(0, import_core6.getContractName)(contract.contract_id)}-vars`;
515
542
  logger.debug(`Deploying ${contract.contract_id} for variables.`);
516
543
  if (!contract.source) {
517
- logger.debug(`Contract ${(0, import_core6.getContractName)(contract.contract_id)} has no source. Skipping variables.`);
544
+ logger.debug(
545
+ `Contract ${(0, import_core6.getContractName)(contract.contract_id)} has no source. Skipping variables.`
546
+ );
518
547
  return {};
519
548
  }
520
549
  if (contract.contract_interface.variables.length === 0) {
@@ -538,9 +567,14 @@ function getVariablesV2(contract, simnet, verbose) {
538
567
 
539
568
  ${varFn}`;
540
569
  try {
541
- const receipt = simnet.deployContract(fakeId, fullSrc, {
542
- clarityVersion: 2
543
- }, deployer);
570
+ const receipt = simnet.deployContract(
571
+ fakeId,
572
+ fullSrc,
573
+ {
574
+ clarityVersion: 3
575
+ },
576
+ deployer
577
+ );
544
578
  const result = receipt.result;
545
579
  const varsAbi = {
546
580
  tuple: []
@@ -588,24 +622,26 @@ async function getSession(config) {
588
622
  balance: resultCV.toString()
589
623
  };
590
624
  });
591
- const contracts = (await Promise.all([...interfaces.entries()].map(async ([contract_id, contract_interface]) => {
592
- var _a, _b, _c;
593
- if (contract_id.startsWith(import_core7.MAINNET_BURN_ADDRESS) && ((_a = config.esm) == null ? void 0 : _a.include_boot_contracts) !== true || contract_id.startsWith(import_core7.TESTNET_BURN_ADDRESS)) {
594
- return void 0;
595
- }
596
- const name = (0, import_core7.getContractName)(contract_id, false);
597
- const contractPathDef = (_c = (_b = config.clarinet.contracts) == null ? void 0 : _b[name]) == null ? void 0 : _c.path;
598
- let source;
599
- if (contractPathDef) {
600
- const contractPathFull = config.joinFromClarinet(contractPathDef);
601
- source = await (0, import_promises4.readFile)(contractPathFull, "utf-8");
602
- }
603
- return {
604
- contract_id,
605
- contract_interface,
606
- source: source ?? ""
607
- };
608
- }))).filter((x) => x !== void 0);
625
+ const contracts = (await Promise.all(
626
+ [...interfaces.entries()].map(async ([contract_id, contract_interface]) => {
627
+ var _a, _b, _c;
628
+ if (contract_id.startsWith(import_core7.MAINNET_BURN_ADDRESS) && ((_a = config.esm) == null ? void 0 : _a.include_boot_contracts) !== true || contract_id.startsWith(import_core7.TESTNET_BURN_ADDRESS)) {
629
+ return void 0;
630
+ }
631
+ const name = (0, import_core7.getContractName)(contract_id, false);
632
+ const contractPathDef = (_c = (_b = config.clarinet.contracts) == null ? void 0 : _b[name]) == null ? void 0 : _c.path;
633
+ let source;
634
+ if (contractPathDef) {
635
+ const contractPathFull = config.joinFromClarinet(contractPathDef);
636
+ source = await (0, import_promises4.readFile)(contractPathFull, "utf-8");
637
+ }
638
+ return {
639
+ contract_id,
640
+ contract_interface,
641
+ source: source ?? ""
642
+ };
643
+ })
644
+ )).filter((x) => x !== void 0);
609
645
  const session = {
610
646
  session_id: 0,
611
647
  accounts: allAccounts,
@@ -617,6 +653,7 @@ async function getSession(config) {
617
653
  accounts: allAccounts,
618
654
  contracts,
619
655
  variables
656
+ // variables: [],
620
657
  };
621
658
  }
622
659
 
@@ -638,8 +675,7 @@ function getContractTxs(batches) {
638
675
  function getDeploymentContract(contractName, deployment) {
639
676
  const txs = flatBatch(deployment.plan.batches);
640
677
  for (const tx of txs) {
641
- if (!isContractTx(tx))
642
- continue;
678
+ if (!isContractTx(tx)) continue;
643
679
  if ("requirement-publish" in tx) {
644
680
  const [_, name] = tx["requirement-publish"]["contract-id"].split(".");
645
681
  if (name === contractName) {
@@ -691,12 +727,9 @@ function getIdentifier(tx) {
691
727
  throw new Error(`Unable to find ID for contract.`);
692
728
  }
693
729
  function isContractTx(tx) {
694
- if ("contract-call" in tx)
695
- return false;
696
- if ("btc-transfer" in tx)
697
- return false;
698
- if ("emulated-contract-call" in tx)
699
- return false;
730
+ if ("contract-call" in tx) return false;
731
+ if ("btc-transfer" in tx) return false;
732
+ if ("emulated-contract-call" in tx) return false;
700
733
  return true;
701
734
  }
702
735
 
@@ -710,16 +743,18 @@ async function parseDeployment(path) {
710
743
  }
711
744
  var DEPLOYMENT_NETWORKS = ["devnet", "simnet", "testnet", "mainnet"];
712
745
  async function getDeployments(config) {
713
- const entries = await Promise.all(DEPLOYMENT_NETWORKS.map(async (network) => {
714
- const file = `default.${network}-plan.yaml`;
715
- const path = (0, import_path3.join)((0, import_path3.dirname)(config.clarinetFile()), "deployments", file);
716
- let plan;
717
- try {
718
- plan = await parseDeployment(path);
719
- } catch (_) {
720
- }
721
- return [network, plan];
722
- }));
746
+ const entries = await Promise.all(
747
+ DEPLOYMENT_NETWORKS.map(async (network) => {
748
+ const file = `default.${network}-plan.yaml`;
749
+ const path = (0, import_path3.join)((0, import_path3.dirname)(config.clarinetFile()), "deployments", file);
750
+ let plan;
751
+ try {
752
+ plan = await parseDeployment(path);
753
+ } catch (_) {
754
+ }
755
+ return [network, plan];
756
+ })
757
+ );
723
758
  return Object.fromEntries(entries);
724
759
  }
725
760
  async function generateESMFile({
@@ -750,24 +785,28 @@ function insertNetworkId(deployments, identifier, network) {
750
785
  }
751
786
  function collectContractDeployments(session, deployments, config) {
752
787
  var _a;
753
- const full = Object.fromEntries(sortContracts(session.contracts).map((contract) => {
754
- const contractName = (0, import_core8.getContractName)(contract.contract_id);
755
- const contractDeployments = Object.fromEntries(DEPLOYMENT_NETWORKS.map((network) => {
756
- const deployment = deployments[network];
757
- if (typeof deployment === "undefined") {
758
- return [network, null];
759
- }
760
- try {
761
- const contractName2 = contract.contract_id.split(".")[1];
762
- const tx = getDeploymentContract(contractName2, deployment);
763
- const id = getIdentifier(tx);
764
- return [network, id];
765
- } catch (_) {
766
- return [network, null];
767
- }
768
- }));
769
- return [contractName, contractDeployments];
770
- }));
788
+ const full = Object.fromEntries(
789
+ sortContracts(session.contracts).map((contract) => {
790
+ const contractName = (0, import_core8.getContractName)(contract.contract_id);
791
+ const contractDeployments = Object.fromEntries(
792
+ DEPLOYMENT_NETWORKS.map((network) => {
793
+ const deployment = deployments[network];
794
+ if (typeof deployment === "undefined") {
795
+ return [network, null];
796
+ }
797
+ try {
798
+ const contractName2 = contract.contract_id.split(".")[1];
799
+ const tx = getDeploymentContract(contractName2, deployment);
800
+ const id = getIdentifier(tx);
801
+ return [network, id];
802
+ } catch (_) {
803
+ return [network, null];
804
+ }
805
+ })
806
+ );
807
+ return [contractName, contractDeployments];
808
+ })
809
+ );
771
810
  const deployer = session.accounts.find((a) => a.name === "deployer");
772
811
  (_a = config.clarinet.project.requirements) == null ? void 0 : _a.forEach(({ contract_id }) => {
773
812
  insertNetworkId(full, contract_id, "mainnet");
@@ -784,8 +823,7 @@ function collectContractDeployments(session, deployments, config) {
784
823
  return full;
785
824
  }
786
825
  function collectDeploymentFiles(deployments, clarinetFolder, cwd) {
787
- if (!deployments.simnet)
788
- return [];
826
+ if (!deployments.simnet) return [];
789
827
  const simnet = deployments.simnet;
790
828
  const txs = getContractTxs(simnet.plan.batches);
791
829
  const entries = txs.map((tx) => {
@@ -800,8 +838,7 @@ function collectDeploymentFiles(deployments, clarinetFolder, cwd) {
800
838
  }
801
839
  function generateSimnetCode(config, deployments, _session) {
802
840
  var _a;
803
- if (!((_a = config.esm) == null ? void 0 : _a.include_accounts))
804
- return "";
841
+ if (!((_a = config.esm) == null ? void 0 : _a.include_accounts)) return "";
805
842
  const clarinetFolder = (0, import_path3.dirname)(config.clarinetFile());
806
843
  const files = collectDeploymentFiles(deployments, clarinetFolder, config.cwd);
807
844
  return `
@@ -811,8 +848,7 @@ export const simnetDeployment = ${JSON.stringify(files)};
811
848
  async function afterESM(config) {
812
849
  var _a;
813
850
  const command = (_a = config.esm) == null ? void 0 : _a.after;
814
- if (!command)
815
- return;
851
+ if (!command) return;
816
852
  logger.debug(`Running after ESM command: ${command}`);
817
853
  const parts = command.split(" ");
818
854
  const [cmd, ...args2] = parts;
@@ -879,7 +915,9 @@ async function watch(config, cwd) {
879
915
  process.stdout.moveCursor(0, -1);
880
916
  process.stdout.clearLine(1);
881
917
  const elapsed = Date.now() - start;
882
- logger.info(`Types generated (${(elapsed / 1e3).toFixed(2)}s). Watching for changes...`);
918
+ logger.info(
919
+ `Types generated (${(elapsed / 1e3).toFixed(2)}s). Watching for changes...`
920
+ );
883
921
  running = false;
884
922
  });
885
923
  });
@@ -888,6 +926,16 @@ async function watch(config, cwd) {
888
926
  });
889
927
  }
890
928
  var DefaultCommand = class extends BaseCommand {
929
+ static paths = [import_clipanion3.Command.Default, ["generate"]];
930
+ // static description = 'Generate types for your Clarity contracts';
931
+ static usage = import_clipanion3.Command.Usage({
932
+ description: "Generate types for your Clarity contracts",
933
+ examples: [
934
+ ["Basic usage:", "clarigen"],
935
+ ["When your `Clarigen.toml` is in a different directory:", "clarigen /path/to/your/project"],
936
+ ["Watch for changes and regenerate types:", "clarigen --watch"]
937
+ ]
938
+ });
891
939
  cwd = import_clipanion3.Option.String({
892
940
  required: false
893
941
  });
@@ -905,15 +953,6 @@ var DefaultCommand = class extends BaseCommand {
905
953
  }
906
954
  }
907
955
  };
908
- __publicField(DefaultCommand, "paths", [import_clipanion3.Command.Default, ["generate"]]);
909
- __publicField(DefaultCommand, "usage", import_clipanion3.Command.Usage({
910
- description: "Generate types for your Clarity contracts",
911
- examples: [
912
- ["Basic usage:", "clarigen"],
913
- ["When your `Clarigen.toml` is in a different directory:", "clarigen /path/to/your/project"],
914
- ["Watch for changes and regenerate types:", "clarigen --watch"]
915
- ]
916
- }));
917
956
 
918
957
  // src/commands/docs-command.ts
919
958
  var import_clipanion4 = require("clipanion");
@@ -1017,8 +1056,7 @@ function findItemNameFromLine(line) {
1017
1056
  }
1018
1057
  for (const type of VAR_TYPES) {
1019
1058
  const prefix = `(define-${type} `;
1020
- if (!line.startsWith(prefix))
1021
- continue;
1059
+ if (!line.startsWith(prefix)) continue;
1022
1060
  const startString = line.slice(prefix.length);
1023
1061
  const match = clarityNameMatcher(startString);
1024
1062
  if (!match) {
@@ -1034,11 +1072,9 @@ function findAbiItemByName(abi, name) {
1034
1072
  const fn = abi.functions.find((fn2) => {
1035
1073
  return fn2.name === name;
1036
1074
  });
1037
- if (fn)
1038
- return fn;
1075
+ if (fn) return fn;
1039
1076
  const map = abi.maps.find((m) => m.name === name);
1040
- if (map)
1041
- return map;
1077
+ if (map) return map;
1042
1078
  const v = abi.variables.find((v2) => v2.name === name);
1043
1079
  return v;
1044
1080
  }
@@ -1048,10 +1084,8 @@ function isComment(line) {
1048
1084
  function traceParens(line, count) {
1049
1085
  let newCount = count;
1050
1086
  line.split("").forEach((char) => {
1051
- if (char === "(")
1052
- newCount++;
1053
- if (char === ")")
1054
- newCount--;
1087
+ if (char === "(") newCount++;
1088
+ if (char === ")") newCount--;
1055
1089
  });
1056
1090
  return newCount;
1057
1091
  }
@@ -1072,8 +1106,7 @@ function parseComments(comments, abi) {
1072
1106
  }
1073
1107
  return;
1074
1108
  }
1075
- if (!("args" in abi))
1076
- return;
1109
+ if (!("args" in abi)) return;
1077
1110
  const [_full, name, _separator, rest] = paramMatches;
1078
1111
  const arg = abi.args.find((arg2) => arg2.name === name);
1079
1112
  if (!arg) {
@@ -1101,8 +1134,7 @@ function parseComments(comments, abi) {
1101
1134
  async function afterDocs(config) {
1102
1135
  var _a;
1103
1136
  const command = (_a = config.docs) == null ? void 0 : _a.after;
1104
- if (!command)
1105
- return;
1137
+ if (!command) return;
1106
1138
  logger.debug(`Running after docs command: ${command}`);
1107
1139
  const parts = command.split(" ");
1108
1140
  const [cmd, ...args2] = parts;
@@ -1188,7 +1220,9 @@ ${fn.source.join("\n")}
1188
1220
  \`\`\`
1189
1221
  </details>
1190
1222
  `;
1191
- const sig = `(define-${fn.abi.access.replace("_", "-")} (${fn.abi.name} (${paramSigs.join(" ")}) ${returnType})`;
1223
+ const sig = `(define-${fn.abi.access.replace("_", "-")} (${fn.abi.name} (${paramSigs.join(
1224
+ " "
1225
+ )}) ${returnType})`;
1192
1226
  return `### ${fn.abi.name}
1193
1227
 
1194
1228
  ${link}
@@ -1202,8 +1236,7 @@ ${source}
1202
1236
  ${params}`;
1203
1237
  }
1204
1238
  function mdParams(fn) {
1205
- if (fn.abi.args.length === 0)
1206
- return "";
1239
+ if (fn.abi.args.length === 0) return "";
1207
1240
  const hasDescription = Object.values(fn.comments.params).some((p) => p.comments.length > 0);
1208
1241
  const params = Object.values(fn.comments.params).map((p) => markdownParam(p, hasDescription));
1209
1242
  return `**Parameters:**
@@ -1215,8 +1248,7 @@ ${params.join("\n")}`;
1215
1248
  function markdownParam(param, withDescription) {
1216
1249
  const typeString = (0, import_core9.getTypeString)(param.abi.type);
1217
1250
  const base = `| ${param.abi.name} | ${typeString} |`;
1218
- if (!withDescription)
1219
- return base;
1251
+ if (!withDescription) return base;
1220
1252
  return `${base} ${param.comments.join(" ")} |`;
1221
1253
  }
1222
1254
  function markdownMap(map, contractFile) {
@@ -1294,8 +1326,7 @@ function generateReadme(session, excluded) {
1294
1326
  const contractLines = [];
1295
1327
  sortContracts(session.contracts).forEach((contract) => {
1296
1328
  const name = (0, import_core9.getContractName)(contract.contract_id, false);
1297
- if (excluded[name])
1298
- return;
1329
+ if (excluded[name]) return;
1299
1330
  const fileName = `${name}.md`;
1300
1331
  const line = `- [\`${name}\`](${fileName})`;
1301
1332
  contractLines.push(line);
@@ -1322,63 +1353,69 @@ async function generateDocs({
1322
1353
  if (docsPathExt) {
1323
1354
  log.warn(`Docs output path ('${docsBase}') looks like a file - it needs to be a directory.`);
1324
1355
  }
1325
- const excluded = Object.fromEntries((docs.exclude || []).map((e) => {
1326
- return [e, true];
1327
- }));
1356
+ const excluded = Object.fromEntries(
1357
+ (docs.exclude || []).map((e) => {
1358
+ return [e, true];
1359
+ })
1360
+ );
1328
1361
  log.debug(`Generating docs at path \`${docsBase}\``);
1329
1362
  const docsBaseFolder = config.outputResolve("docs" /* Docs */, "./")[0];
1330
- const paths = await Promise.all(session.contracts.map(async (contract) => {
1331
- var _a, _b;
1332
- const name = (0, import_core10.getContractName)(contract.contract_id, false);
1333
- if (excluded[name])
1334
- return null;
1335
- const docFile = `${name}.md`;
1336
- const contractPathDef = (_b = (_a = config.clarinet.contracts) == null ? void 0 : _a[name]) == null ? void 0 : _b.path;
1337
- let contractFile;
1338
- if (contractPathDef) {
1339
- const contractPathFull = config.joinFromClarinet(contractPathDef);
1340
- contractFile = (0, import_path6.relative)(docsBaseFolder, contractPathFull);
1341
- } else {
1342
- log.debug(`Couldn't find contract file from Clarinet.toml for contract ${name}`);
1343
- }
1344
- const md = generateMarkdown({ contract, contractFile });
1345
- const path = await config.writeOutput("docs" /* Docs */, md, docFile);
1346
- return path[0];
1347
- }));
1363
+ const paths = await Promise.all(
1364
+ session.contracts.map(async (contract) => {
1365
+ var _a, _b;
1366
+ const name = (0, import_core10.getContractName)(contract.contract_id, false);
1367
+ if (excluded[name]) return null;
1368
+ const docFile = `${name}.md`;
1369
+ const contractPathDef = (_b = (_a = config.clarinet.contracts) == null ? void 0 : _a[name]) == null ? void 0 : _b.path;
1370
+ let contractFile;
1371
+ if (contractPathDef) {
1372
+ const contractPathFull = config.joinFromClarinet(contractPathDef);
1373
+ contractFile = (0, import_path6.relative)(docsBaseFolder, contractPathFull);
1374
+ } else {
1375
+ log.debug(`Couldn't find contract file from Clarinet.toml for contract ${name}`);
1376
+ }
1377
+ const md = generateMarkdown({ contract, contractFile });
1378
+ const path = await config.writeOutput("docs" /* Docs */, md, docFile);
1379
+ return path[0];
1380
+ })
1381
+ );
1348
1382
  const readme = generateReadme(session, excluded);
1349
1383
  paths.push((await config.writeOutput("docs" /* Docs */, readme, "README.md"))[0]);
1350
1384
  await afterDocs(config);
1351
1385
  }
1352
1386
  function warnNoDocs() {
1353
- log.warn(`
1387
+ log.warn(
1388
+ `
1354
1389
  Clarigen config file doesn't include an output directory for docs.
1355
1390
 
1356
1391
  To generate docs, specify 'docs.output' in your config file:
1357
1392
 
1358
1393
  [docs]
1359
1394
  output = "docs/"
1360
- `.trimEnd());
1395
+ `.trimEnd()
1396
+ );
1361
1397
  }
1362
1398
 
1363
1399
  // src/commands/docs-command.ts
1364
1400
  var DocsCommand = class extends BaseCommand {
1401
+ static paths = [["docs"]];
1402
+ static usage = BaseCommand.Usage({
1403
+ description: "Generate markdown documentation for your Clarity contracts"
1404
+ });
1365
1405
  cwd = import_clipanion4.Option.String({ required: false });
1366
1406
  async execute() {
1367
1407
  this.preexecute();
1368
1408
  const config = await Config.load(this.cwd);
1369
1409
  const session = await getSession(config);
1370
1410
  await generateDocs({
1371
- session: __spreadProps(__spreadValues({}, session), {
1411
+ session: {
1412
+ ...session,
1372
1413
  variables: []
1373
- }),
1414
+ },
1374
1415
  config
1375
1416
  });
1376
1417
  }
1377
1418
  };
1378
- __publicField(DocsCommand, "paths", [["docs"]]);
1379
- __publicField(DocsCommand, "usage", BaseCommand.Usage({
1380
- description: "Generate markdown documentation for your Clarity contracts"
1381
- }));
1382
1419
 
1383
1420
  // src/commands/init-config-command.ts
1384
1421
  var import_clipanion5 = require("clipanion");
@@ -1419,6 +1456,10 @@ output = "docs"
1419
1456
 
1420
1457
  // src/commands/init-config-command.ts
1421
1458
  var InitConfigCommand = class extends BaseCommand {
1459
+ static paths = [["init-config"], ["init"]];
1460
+ static usage = {
1461
+ description: "Initialize a Clarigen configuration file"
1462
+ };
1422
1463
  cwd = import_clipanion5.Option.String({ required: false });
1423
1464
  overwrite = import_clipanion5.Option.Boolean("--overwrite", false, {
1424
1465
  description: "Overwrite the configuration file if it already exists"
@@ -1435,13 +1476,9 @@ var InitConfigCommand = class extends BaseCommand {
1435
1476
  await (0, import_promises6.writeFile)(path, tomlInit, "utf-8");
1436
1477
  }
1437
1478
  };
1438
- __publicField(InitConfigCommand, "paths", [["init-config"], ["init"]]);
1439
- __publicField(InitConfigCommand, "usage", {
1440
- description: "Initialize a Clarigen configuration file"
1441
- });
1442
1479
 
1443
1480
  // src/generated/version.ts
1444
- var version = "2.1.0";
1481
+ var version = "2.1.2";
1445
1482
 
1446
1483
  // src/run-cli.ts
1447
1484
  var [node, script, ...args] = process.argv;