@clarigen/cli 0.2.5 → 0.3.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.
@@ -8,14 +8,16 @@ const wallet_sdk_1 = require("@stacks/wallet-sdk");
8
8
  async function getClarinetDevConfig(folder) {
9
9
  const baseConfigPath = path_1.resolve(folder, 'settings', 'Devnet.toml');
10
10
  const configContents = await promises_1.readFile(baseConfigPath, { encoding: 'utf-8' });
11
- const config = j_toml_1.parse(configContents, 1.0, '\n', false);
11
+ const config = j_toml_1.parse(configContents, 1.0, '\n', true, {
12
+ longer: true,
13
+ });
12
14
  return config;
13
15
  }
14
16
  exports.getClarinetDevConfig = getClarinetDevConfig;
15
17
  async function getClarinetConfig(folder) {
16
18
  const baseConfigPath = path_1.resolve(folder, 'Clarinet.toml');
17
19
  const configContents = await promises_1.readFile(baseConfigPath, { encoding: 'utf-8' });
18
- const config = j_toml_1.parse(configContents, 1.0, '\n', false);
20
+ const config = j_toml_1.parse(configContents, 1.0, '\n', true);
19
21
  return config;
20
22
  }
21
23
  exports.getClarinetConfig = getClarinetConfig;
@@ -17,7 +17,7 @@ const generateInterface = async ({ provider: _provider, contractFile, contractAd
17
17
  '--costs',
18
18
  '--assets',
19
19
  ]);
20
- if (receipt.stderr) {
20
+ if (native_bin_1.hasStdErr(receipt.stderr)) {
21
21
  throw new Error(`Error on ${contractFile}:
22
22
  ${receipt.stderr}
23
23
  `);
@@ -102,8 +102,18 @@ const generateProjectIndexFile = (config) => {
102
102
  const contractMap = [];
103
103
  let accounts = '';
104
104
  if ('accounts' in config) {
105
+ const accountLines = Object.keys(config.accounts).map((key) => {
106
+ const account = config.accounts[key];
107
+ return `"${key}": {
108
+ mnemonic: "${account.mnemonic}",
109
+ balance: ${account.balance.toString()}n,
110
+ address: "${account.address}",
111
+ },`;
112
+ });
105
113
  accounts = `\n\n// prettier-ignore
106
- export const accounts = ${JSON.stringify(config.accounts, null, 2)};`;
114
+ export const accounts = {
115
+ ${accountLines.join('\n ')}
116
+ };`;
107
117
  }
108
118
  config.contracts.forEach((contract) => {
109
119
  const contractName = core_1.getContractNameFromPath(contract.file);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@clarigen/cli",
3
3
  "description": "A CLI for generating a Typescript interface for a Clarity contract.",
4
4
  "author": "Hank Stoever",
5
- "version": "0.2.5",
5
+ "version": "0.3.2",
6
6
  "license": "MIT",
7
7
  "main": "dist/index.js",
8
8
  "files": [
@@ -21,7 +21,8 @@
21
21
  "build": "rm -rf dist && tsc -b",
22
22
  "test": "tsdx test",
23
23
  "lint": "tsdx lint",
24
- "typecheck": "tsc --noEmit"
24
+ "typecheck": "tsc --noEmit",
25
+ "prepublishOnly": "yarn build"
25
26
  },
26
27
  "bin": {
27
28
  "clarigen": "./bin/run"
@@ -37,7 +38,6 @@
37
38
  "trailingComma": "es5"
38
39
  },
39
40
  "devDependencies": {
40
- "@oclif/config": "^1.17.0",
41
41
  "@oclif/dev-cli": "^1.26.0",
42
42
  "@oclif/errors": "^1.3.4",
43
43
  "@vercel/ncc": "0.27.0",
@@ -45,10 +45,12 @@
45
45
  "ts-node": "^9.1.1"
46
46
  },
47
47
  "dependencies": {
48
- "@clarigen/core": "0.2.3",
49
- "@clarigen/native-bin": "0.2.3",
48
+ "@clarigen/core": "0.3.2",
49
+ "@clarigen/native-bin": "0.3.2",
50
50
  "@ltd/j-toml": "1.12.2",
51
51
  "@oclif/command": "^1.8.0",
52
+ "@oclif/config": "^1.17.0",
53
+ "@oclif/plugin-help": "3.2.3",
52
54
  "@stacks/wallet-sdk": "1.0.0-wallet-sdk.4",
53
55
  "chalk": "4.1.0",
54
56
  "chokidar": "3.5.1",
@@ -57,5 +59,5 @@
57
59
  "publishConfig": {
58
60
  "access": "public"
59
61
  },
60
- "gitHead": "550b08b622ecc3675402efd478d639f135eae9e4"
62
+ "gitHead": "5625d6c342e16966b58c08103f459aaf322158ab"
61
63
  }
@@ -24,12 +24,9 @@ export async function getClarinetDevConfig(
24
24
  ): Promise<ClarinetDevConfig> {
25
25
  const baseConfigPath = resolve(folder, 'settings', 'Devnet.toml');
26
26
  const configContents = await readFile(baseConfigPath, { encoding: 'utf-8' });
27
- const config = (parse(
28
- configContents,
29
- 1.0,
30
- '\n',
31
- false
32
- ) as unknown) as ClarinetDevConfig;
27
+ const config = (parse(configContents, 1.0, '\n', true, {
28
+ longer: true,
29
+ }) as unknown) as ClarinetDevConfig;
33
30
  return config;
34
31
  }
35
32
 
@@ -49,7 +46,7 @@ export async function getClarinetConfig(folder: string) {
49
46
  configContents,
50
47
  1.0,
51
48
  '\n',
52
- false
49
+ true
53
50
  ) as unknown) as ClarinetConfig;
54
51
  return config;
55
52
  }
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  NativeClarityBinProvider,
3
3
  createClarityBin,
4
+ hasStdErr,
4
5
  } from '@clarigen/native-bin';
5
6
  import {
6
7
  ClarityAbi,
@@ -31,7 +32,7 @@ export const generateInterface = async ({
31
32
  '--costs',
32
33
  '--assets',
33
34
  ]);
34
- if (receipt.stderr) {
35
+ if (hasStdErr(receipt.stderr)) {
35
36
  throw new Error(`Error on ${contractFile}:
36
37
  ${receipt.stderr}
37
38
  `);
@@ -133,8 +134,19 @@ export const generateProjectIndexFile = (config: ConfigFile) => {
133
134
 
134
135
  let accounts = '';
135
136
  if ('accounts' in config) {
137
+ const accountLines = Object.keys(config.accounts).map((key) => {
138
+ const account = config.accounts[key];
139
+ return `"${key}": {
140
+ mnemonic: "${account.mnemonic}",
141
+ balance: ${account.balance.toString()}n,
142
+ address: "${account.address}",
143
+ },`;
144
+ });
145
+
136
146
  accounts = `\n\n// prettier-ignore
137
- export const accounts = ${JSON.stringify(config.accounts, null, 2)};`;
147
+ export const accounts = {
148
+ ${accountLines.join('\n ')}
149
+ };`;
138
150
  }
139
151
 
140
152
  config.contracts.forEach((contract) => {