mobilestacks 0.1.23 → 0.1.24

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.
Files changed (39) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +189 -188
  3. package/dist/cli/index.js +83 -40
  4. package/dist/cli/init.d.ts.map +1 -1
  5. package/dist/cli/init.js +50 -31
  6. package/dist/config/config-loading.d.ts.map +1 -1
  7. package/dist/config/config-loading.js +14 -7
  8. package/dist/core/dsl.d.ts +12 -16
  9. package/dist/core/dsl.d.ts.map +1 -1
  10. package/dist/core/dsl.js +11 -10
  11. package/dist/core/env.js +1 -1
  12. package/dist/core/extender.d.ts +1 -0
  13. package/dist/core/extender.d.ts.map +1 -1
  14. package/dist/core/extender.js +3 -0
  15. package/dist/core/runtime-environment.d.ts +10 -7
  16. package/dist/core/runtime-environment.d.ts.map +1 -1
  17. package/dist/core/runtime-environment.js +38 -36
  18. package/dist/core/simnet.d.ts.map +1 -1
  19. package/dist/core/tasks-definitions.d.ts +3 -0
  20. package/dist/core/tasks-definitions.d.ts.map +1 -1
  21. package/dist/core/tasks-definitions.js +8 -0
  22. package/dist/tasks/call-contract-function.js +12 -11
  23. package/dist/tasks/deploy-contract.js +22 -30
  24. package/dist/tasks/execute-contract.js +55 -34
  25. package/dist/tasks/faucet-request.js +10 -12
  26. package/dist/tasks/get-balance.js +21 -30
  27. package/dist/tasks/get-contract-info.js +9 -9
  28. package/dist/tasks/get-tx-history.js +16 -29
  29. package/dist/tasks/list-accounts.js +16 -15
  30. package/dist/tasks/send-stx.js +13 -27
  31. package/dist/tasks/utils.d.ts +22 -0
  32. package/dist/tasks/utils.d.ts.map +1 -0
  33. package/dist/tasks/utils.js +88 -0
  34. package/dist/tasks/verify-contract.js +12 -15
  35. package/dist/types/config.d.ts +1 -1
  36. package/package.json +71 -71
  37. package/dist/core/dsl.test.d.ts +0 -2
  38. package/dist/core/dsl.test.d.ts.map +0 -1
  39. package/dist/core/dsl.test.js +0 -45
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 mobilestacks contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 mobilestacks contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,188 +1,189 @@
1
- # mobilestacks
2
-
3
- A Hardhat-style development framework for Stacks. Write, test, and deploy Clarity smart contracts with a task-based CLI, local Simnet testing, and a pluggable runtime.
4
-
5
- ## Install
6
-
7
- ```bash
8
- npm install mobilestacks
9
- ```
10
-
11
- ## Quick Start
12
-
13
- Scaffold a new project:
14
-
15
- ```bash
16
- npx mobilestacks init
17
- ```
18
-
19
- This generates a config file, a sample Clarity contract, and an example task.
20
-
21
- ## Configuration
22
-
23
- All config lives in `mobilestacks.config.ts`:
24
-
25
- ```ts
26
- export default {
27
- networks: {
28
- mainnet: { url: "https://api.mainnet.hiro.so", name: "mainnet" },
29
- testnet: { url: "https://api.testnet.hiro.so", name: "testnet" },
30
- },
31
- defaultNetwork: "testnet",
32
- wallet: {
33
- privateKey: process.env.STACKS_PRIVATE_KEY,
34
- },
35
- };
36
- ```
37
-
38
- Secrets can live in `.env` they override config values automatically.
39
-
40
- ## CLI
41
-
42
- ```bash
43
- npx mobilestacks # list all tasks
44
- npx mobilestacks deploy-contract # deploy a contract
45
- npx mobilestacks get-balance # check STX balance
46
- npx mobilestacks send-stx # send STX
47
- npx mobilestacks faucet-request # get testnet tokens
48
- ```
49
-
50
- Missing params are prompted interactively. Run any task with `--help` for options.
51
-
52
- ### Built-in Tasks
53
-
54
- | Task | What it does |
55
- | ---- | ------------ |
56
- | `deploy-contract` | Deploy a `.clar` file to mainnet/testnet |
57
- | `send-stx` | Transfer STX to an address |
58
- | `get-balance` | Check STX balance for any address |
59
- | `faucet-request` | Request testnet STX from the faucet |
60
- | `list-accounts` | List derived wallet accounts |
61
- | `get-tx-history` | Fetch recent transactions |
62
- | `call-contract-function` | Call a read-only contract function |
63
- | `get-contract-info` | Fetch deployed contract metadata |
64
- | `verify-contract` | Diff on-chain source against a local file |
65
-
66
- ## Writing Tasks
67
-
68
- Drop a file in `src/tasks/` it's auto-discovered:
69
-
70
- ```ts
71
- import { task } from "mobilestacks";
72
- import { z } from "zod";
73
-
74
- task("greet", "Say hello")
75
- .addParam("name", "Who to greet", { schema: z.string().min(1) })
76
- .setAction(async (args, env) => {
77
- return `Hello, ${args.name}! (network: ${env.config.defaultNetwork})`;
78
- });
79
- ```
80
-
81
- Subtasks and workflows are also supported:
82
-
83
- ```ts
84
- import { subtask, runWorkflow } from "mobilestacks";
85
-
86
- // subtask tied to a parent
87
- subtask("deploy:validate", "Pre-deploy check", "deploy-contract")
88
- .setAction(async (args, env) => { /* ... */ });
89
-
90
- // run tasks in sequence
91
- await runWorkflow([
92
- { taskName: "deploy-contract", args: { /* ... */ } },
93
- { taskName: "verify-contract", args: { /* ... */ } },
94
- ], env);
95
- ```
96
-
97
- ## Extending the Runtime
98
-
99
- Add custom properties to the runtime environment, available in every task:
100
-
101
- ```ts
102
- import { extendEnvironment } from "mobilestacks";
103
-
104
- extendEnvironment((env) => {
105
- env.formatSTX = (micro: number) => `${(micro / 1e6).toFixed(6)} STX`;
106
- });
107
- ```
108
-
109
- ## Testing with Simnet
110
-
111
- Test contracts locally using the Clarinet SDK — no devnet needed:
112
-
113
- ```ts
114
- import { describe, it, expect, beforeAll } from "vitest";
115
- import { Simnet } from "mobilestacks";
116
- import { Cl } from "@stacks/transactions";
117
-
118
- describe("My Contract", () => {
119
- let simnet: Simnet;
120
-
121
- beforeAll(async () => {
122
- simnet = await Simnet.init();
123
- });
124
-
125
- it("calls hello-world", () => {
126
- const deployer = simnet.getDeployer();
127
- const { result } = simnet.callPublic("sample-contract", "hello-world", [], deployer);
128
- expect(result).toStrictEqual(Cl.ok(Cl.stringAscii("Hello, Stacks!")));
129
- });
130
- });
131
- ```
132
-
133
- ### Setup
134
-
135
- Contract tests need a `Clarinet.toml` and test accounts. Run the setup script once:
136
-
137
- ```bash
138
- npm run setup:simnet
139
- ```
140
-
141
- Then run tests:
142
-
143
- ```bash
144
- npm test
145
- ```
146
-
147
- ## Programmatic API
148
-
149
- Use mobilestacks as a library:
150
-
151
- ```ts
152
- import { task, subtask, extendEnvironment, Simnet, RuntimeEnvironment } from "mobilestacks";
153
- ```
154
-
155
- ## Project Structure
156
-
157
- ```
158
- ├── src/
159
- │ ├── cli/ # CLI entry point + init scaffolding
160
- │ ├── core/ # DSL, Simnet, RuntimeEnvironment, task registry
161
- │ ├── tasks/ # Built-in tasks (auto-loaded)
162
- │ ├── types/ # Zod schemas + TypeScript types
163
- │ └── index.ts # Public API
164
- ├── tests/ # Vitest test files
165
- ├── contracts/ # Clarity contracts
166
- ├── Clarinet.toml # Clarinet project manifest
167
- └── mobilestacks.config.ts
168
- ```
169
-
170
- ## Contributing
171
-
172
- ```bash
173
- git clone https://github.com/Wizbisy/mobilestacks.git
174
- cd mobilestacks
175
- npm install
176
- npm run setup:simnet # generate test accounts
177
- npm test # run all tests
178
- ```
179
-
180
- See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
181
-
182
- ## Security
183
-
184
- Private keys and seed phrases are never logged. Output is scanned for secrets and masked automatically. Keep your `.env` out of version control.
185
-
186
- ## License
187
-
188
- MIT
1
+ # mobilestacks
2
+
3
+ A Hardhat-style development framework for Stacks. Write, test, and deploy Clarity smart contracts with a task-based CLI, local Simnet testing, and a pluggable runtime.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install mobilestacks
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ Scaffold a new project:
14
+
15
+ ```bash
16
+ npx mobilestacks init
17
+ ```
18
+
19
+ This generates a config file, a sample Clarity contract, and an example task.
20
+
21
+ ## Configuration
22
+
23
+ All config lives in `mobilestacks.config.ts`:
24
+
25
+ ```ts
26
+ export default {
27
+ networks: {
28
+ mainnet: { url: 'https://api.mainnet.hiro.so', name: 'mainnet' },
29
+ testnet: { url: 'https://api.testnet.hiro.so', name: 'testnet' },
30
+ },
31
+ defaultNetwork: 'testnet',
32
+ wallet: {
33
+ privateKey: process.env.STACKS_PRIVATE_KEY,
34
+ },
35
+ };
36
+ ```
37
+
38
+ Secrets can live in `.env`; they override config values automatically.
39
+
40
+ ## CLI
41
+
42
+ ```bash
43
+ npx mobilestacks # list all tasks
44
+ npx mobilestacks deploy-contract # deploy a contract
45
+ npx mobilestacks get-balance # check STX balance
46
+ npx mobilestacks send-stx # send STX
47
+ npx mobilestacks faucet-request # get testnet tokens
48
+ ```
49
+
50
+ Missing required params are prompted interactively. Run any task with `--help` for options.
51
+
52
+ ### Built-in Tasks
53
+
54
+ | Task | What it does |
55
+ | ---- | ------------ |
56
+ | `deploy-contract` | Deploy a `.clar` file to mainnet/testnet |
57
+ | `send-stx` | Transfer STX to an address |
58
+ | `get-balance` | Check STX balance for any address |
59
+ | `faucet-request` | Request testnet STX from the faucet |
60
+ | `list-accounts` | List derived wallet accounts |
61
+ | `get-tx-history` | Fetch recent transactions |
62
+ | `call-contract-function` | Call a read-only contract function |
63
+ | `get-contract-info` | Fetch deployed contract metadata |
64
+ | `verify-contract` | Diff on-chain source against a local file |
65
+
66
+ ## Writing Tasks
67
+
68
+ Drop a file in `src/tasks/`; it is auto-discovered:
69
+
70
+ ```ts
71
+ import { task } from 'mobilestacks';
72
+ import { z } from 'zod';
73
+
74
+ task('greet', 'Say hello')
75
+ .addParam('name', 'Who to greet', { schema: z.string().min(1) })
76
+ .setAction((args, env) => {
77
+ return `Hello, ${args.name}! (network: ${env.config.defaultNetwork})`;
78
+ });
79
+ ```
80
+
81
+ Subtasks and workflows are also supported:
82
+
83
+ ```ts
84
+ import { subtask, runWorkflow } from 'mobilestacks';
85
+
86
+ subtask('deploy:validate', 'Pre-deploy check', 'deploy-contract').setAction((args, env) => {
87
+ // validate deployment inputs
88
+ });
89
+
90
+ await runWorkflow(
91
+ [
92
+ { taskName: 'deploy-contract', args: { contractName: 'sample-contract' } },
93
+ { taskName: 'verify-contract', args: { contractName: 'sample-contract' } },
94
+ ],
95
+ env,
96
+ );
97
+ ```
98
+
99
+ ## Extending the Runtime
100
+
101
+ Add custom properties to the runtime environment, available in every task:
102
+
103
+ ```ts
104
+ import { extendEnvironment } from 'mobilestacks';
105
+
106
+ extendEnvironment((env) => {
107
+ env.formatSTX = (micro: number) => `${(micro / 1e6).toFixed(6)} STX`;
108
+ });
109
+ ```
110
+
111
+ ## Testing with Simnet
112
+
113
+ Test contracts locally using the Clarinet SDK. No devnet is needed:
114
+
115
+ ```ts
116
+ import { describe, it, expect, beforeAll } from 'vitest';
117
+ import { Simnet } from 'mobilestacks';
118
+ import { Cl } from '@stacks/transactions';
119
+
120
+ describe('My Contract', () => {
121
+ let simnet: Simnet;
122
+
123
+ beforeAll(async () => {
124
+ simnet = await Simnet.init();
125
+ });
126
+
127
+ it('calls hello-world', () => {
128
+ const deployer = simnet.getDeployer();
129
+ const { result } = simnet.callPublic('sample-contract', 'hello-world', [], deployer);
130
+ expect(result).toStrictEqual(Cl.ok(Cl.stringAscii('Hello, Stacks!')));
131
+ });
132
+ });
133
+ ```
134
+
135
+ ### Setup
136
+
137
+ Contract tests need a `Clarinet.toml` and test accounts. Run the setup script once:
138
+
139
+ ```bash
140
+ npm run setup:simnet
141
+ ```
142
+
143
+ Then run tests:
144
+
145
+ ```bash
146
+ npm test
147
+ ```
148
+
149
+ ## Programmatic API
150
+
151
+ Use mobilestacks as a library:
152
+
153
+ ```ts
154
+ import { task, subtask, extendEnvironment, Simnet, RuntimeEnvironment } from 'mobilestacks';
155
+ ```
156
+
157
+ ## Project Structure
158
+
159
+ ```text
160
+ src/
161
+ cli/ CLI entry point and init scaffolding
162
+ core/ DSL, Simnet, RuntimeEnvironment, task registry
163
+ tasks/ Built-in tasks
164
+ types/ Zod schemas and TypeScript types
165
+ index.ts Public API
166
+ tests/ Vitest test files
167
+ contracts/ Clarity contracts
168
+ Clarinet.toml Clarinet project manifest
169
+ ```
170
+
171
+ ## Contributing
172
+
173
+ ```bash
174
+ git clone https://github.com/Wizbisy/mobilestacks.git
175
+ cd mobilestacks
176
+ npm install
177
+ npm run setup:simnet
178
+ npm test
179
+ ```
180
+
181
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
182
+
183
+ ## Security
184
+
185
+ Private keys and seed phrases are never logged. Output is scanned for sensitive fields and masked automatically when tasks return transaction IDs. Keep your `.env` out of version control.
186
+
187
+ ## License
188
+
189
+ MIT
package/dist/cli/index.js CHANGED
@@ -6,24 +6,66 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const commander_1 = require("commander");
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const inquirer_1 = __importDefault(require("inquirer"));
11
+ const path_1 = __importDefault(require("path"));
9
12
  const config_loading_1 = require("../config/config-loading");
10
13
  const runtime_environment_1 = require("../core/runtime-environment");
11
14
  const tasks_definitions_1 = require("../core/tasks-definitions");
12
15
  const init_1 = require("./init");
13
- const inquirer_1 = __importDefault(require("inquirer"));
14
- const fs_1 = __importDefault(require("fs"));
15
- const path_1 = __importDefault(require("path"));
16
16
  const tasksDir = path_1.default.join(__dirname, '../tasks');
17
17
  fs_1.default.readdirSync(tasksDir)
18
- .filter(f => (f.endsWith('.ts') || f.endsWith('.js')) && !f.endsWith('.d.ts') && !f.includes('.test.'))
19
- .forEach(f => {
20
- require(path_1.default.join(tasksDir, f));
18
+ .filter((fileName) => {
19
+ return ((fileName.endsWith('.ts') || fileName.endsWith('.js')) &&
20
+ !fileName.endsWith('.d.ts') &&
21
+ !fileName.includes('.test.'));
22
+ })
23
+ .forEach((fileName) => {
24
+ require(path_1.default.join(tasksDir, fileName));
21
25
  });
26
+ function getProvidedOptions(argv) {
27
+ return new Set(argv
28
+ .filter((arg) => arg.startsWith('--'))
29
+ .map((arg) => arg.slice(2).split('=')[0])
30
+ .filter(Boolean));
31
+ }
32
+ function parseBoolean(value) {
33
+ if (typeof value === 'boolean')
34
+ return value;
35
+ if (typeof value === 'string') {
36
+ const normalized = value.toLowerCase();
37
+ if (['true', '1', 'yes', 'y'].includes(normalized))
38
+ return true;
39
+ if (['false', '0', 'no', 'n'].includes(normalized))
40
+ return false;
41
+ }
42
+ return Boolean(value);
43
+ }
44
+ function coerceParamValue(param, value) {
45
+ if (value === undefined)
46
+ return value;
47
+ if (param.type === 'number') {
48
+ const parsed = Number(value);
49
+ if (Number.isNaN(parsed)) {
50
+ throw new Error(`Parameter '${param.name}' must be a number.`);
51
+ }
52
+ return parsed;
53
+ }
54
+ if (param.type === 'boolean') {
55
+ return parseBoolean(value);
56
+ }
57
+ return value;
58
+ }
59
+ function getPackageVersion() {
60
+ const packagePath = path_1.default.resolve(__dirname, '../../package.json');
61
+ const packageFile = JSON.parse(fs_1.default.readFileSync(packagePath, 'utf8'));
62
+ return packageFile.version || '0.0.0';
63
+ }
22
64
  const program = new commander_1.Command();
23
65
  program
24
66
  .name('mobilestacks')
25
67
  .description('Professional Task Runner for Stacks')
26
- .version('0.1.0');
68
+ .version(getPackageVersion());
27
69
  program
28
70
  .command('init')
29
71
  .description('Scaffold a new mobilestacks project and config')
@@ -35,55 +77,56 @@ program.action(() => {
35
77
  console.log(chalk_1.default.bold.blue('\nMobilestacks - Professional Task Runner for Stacks\n'));
36
78
  console.log(chalk_1.default.white('USAGE: ') + chalk_1.default.green('mobilestacks <task> [options]\n'));
37
79
  console.log(chalk_1.default.bold('Available tasks:'));
38
- tasks_definitions_1.TaskDefinitions.getInstance().getAllTasks().forEach(task => {
39
- const params = task.params.map(p => chalk_1.default.yellow(`--${p.name}`)).join(' ');
40
- console.log(' ' + chalk_1.default.cyan(task.name) + ' ' + params);
41
- console.log(' ' + chalk_1.default.gray(task.description));
80
+ tasks_definitions_1.TaskDefinitions.getInstance()
81
+ .getAllTasks()
82
+ .forEach((task) => {
83
+ const params = task.params.map((param) => chalk_1.default.yellow(`--${param.name}`)).join(' ');
84
+ console.log(` ${chalk_1.default.cyan(task.name)} ${params}`);
85
+ console.log(` ${chalk_1.default.gray(task.description)}`);
42
86
  });
43
- console.log('\n' + chalk_1.default.white('Use ') + chalk_1.default.green('mobilestacks <task> --help') + chalk_1.default.white(' for more info on a task.'));
87
+ console.log(`\n${chalk_1.default.white('Use ')}${chalk_1.default.green('mobilestacks <task> --help')}${chalk_1.default.white(' for more info on a task.')}`);
44
88
  console.log(chalk_1.default.white('\nExample:'));
45
- console.log(' ' + chalk_1.default.green('mobilestacks deploy-contract --contractName my-contract --file ./contracts/my-contract.clar --network testnet'));
46
- console.log(chalk_1.default.white('\nDocs: ') + chalk_1.default.underline('https://github.com/your-org/mobilestacks#readme'));
89
+ console.log(` ${chalk_1.default.green('mobilestacks deploy-contract --contractName my-contract --file ./contracts/my-contract.clar --network testnet')}`);
90
+ console.log(chalk_1.default.white('\nDocs: ') + chalk_1.default.underline('https://github.com/Wizbisy/mobilestacks#readme'));
47
91
  program.help({ error: false });
48
92
  });
49
- tasks_definitions_1.TaskDefinitions.getInstance().getAllTasks().forEach(task => {
50
- const cmd = program.command(task.name)
51
- .description(task.description);
52
- task.params.forEach(param => {
53
- const optStr = `--${param.name} <value>`;
54
- if (param.required !== false) {
55
- cmd.option(optStr, param.description);
56
- }
57
- else {
58
- cmd.option(optStr, param.description, param.defaultValue);
59
- }
93
+ tasks_definitions_1.TaskDefinitions.getInstance()
94
+ .getAllTasks()
95
+ .forEach((task) => {
96
+ const cmd = program.command(task.name).description(task.description);
97
+ task.params.forEach((param) => {
98
+ const optStr = param.type === 'boolean' ? `--${param.name}` : `--${param.name} <value>`;
99
+ cmd.option(optStr, param.description, param.defaultValue);
60
100
  });
61
101
  cmd.action(async (opts) => {
62
102
  try {
63
- const argsString = process.argv.slice(3).join(' ');
64
- const unprovided = task.params.filter(p => !argsString.includes(`--${p.name}`));
65
- if (unprovided.length > 0 && process.stdout.isTTY) {
66
- const answers = await inquirer_1.default.prompt(unprovided.map(p => ({
67
- type: p.type === 'boolean' ? 'confirm' : 'input',
68
- name: p.name,
69
- message: p.description,
70
- default: opts[p.name] !== undefined ? opts[p.name] : p.defaultValue
103
+ const providedOptions = getProvidedOptions(process.argv.slice(3));
104
+ const missingRequiredParams = task.params.filter((param) => {
105
+ return param.required !== false && !providedOptions.has(param.name);
106
+ });
107
+ if (missingRequiredParams.length > 0 && process.stdout.isTTY) {
108
+ const answers = await inquirer_1.default.prompt(missingRequiredParams.map((param) => ({
109
+ type: param.type === 'boolean' ? 'confirm' : 'input',
110
+ name: param.name,
111
+ message: param.description,
112
+ default: opts[param.name] !== undefined ? opts[param.name] : param.defaultValue,
71
113
  })));
72
114
  Object.assign(opts, answers);
73
115
  }
74
- task.params.forEach(p => {
75
- if (opts[p.name] && p.type === 'number')
76
- opts[p.name] = Number(opts[p.name]);
77
- if (opts[p.name] && p.type === 'boolean')
78
- opts[p.name] = Boolean(opts[p.name]);
116
+ task.params.forEach((param) => {
117
+ opts[param.name] = coerceParamValue(param, opts[param.name]);
118
+ if (param.required !== false && (opts[param.name] === undefined || opts[param.name] === '')) {
119
+ throw new Error(`Missing required parameter '${param.name}'.`);
120
+ }
79
121
  });
80
122
  const config = (0, config_loading_1.loadConfig)();
81
123
  const env = new runtime_environment_1.RuntimeEnvironment(config);
124
+ await env.ready;
82
125
  const result = await task.action(opts, env);
83
- if (typeof result === 'object') {
126
+ if (typeof result === 'object' && result !== null) {
84
127
  const resObj = result;
85
128
  if (resObj.txid) {
86
- console.log(chalk_1.default.yellowBright('Transaction broadcasted to mempool! (Check explorer for final confirmation)'));
129
+ console.log(chalk_1.default.yellowBright('Transaction broadcasted to mempool. Check explorer for final confirmation.'));
87
130
  }
88
131
  else {
89
132
  console.log(chalk_1.default.greenBright('Success!'));
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AAIA,wBAAsB,OAAO,kBA6E5B"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AAmBA,wBAAsB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAmG7C"}