mobilestacks 0.1.23 → 0.1.26
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/README.md +192 -188
- package/dist/cli/index.js +87 -44
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +50 -31
- package/dist/config/{config-loading.d.ts → ConfigLoading.d.ts} +1 -1
- package/dist/config/ConfigLoading.d.ts.map +1 -0
- package/dist/config/{config-loading.js → ConfigLoading.js} +14 -7
- package/dist/core/{runtime-environment.d.ts → RuntimeEnvironment.d.ts} +11 -8
- package/dist/core/RuntimeEnvironment.d.ts.map +1 -0
- package/dist/core/RuntimeEnvironment.js +69 -0
- package/dist/core/{tasks-definitions.d.ts → TasksDefinitions.d.ts} +5 -2
- package/dist/core/TasksDefinitions.d.ts.map +1 -0
- package/dist/core/{tasks-definitions.js → TasksDefinitions.js} +8 -0
- package/dist/core/dsl.d.ts +13 -17
- package/dist/core/dsl.d.ts.map +1 -1
- package/dist/core/dsl.js +15 -14
- package/dist/core/env.js +1 -1
- package/dist/core/extender.d.ts +2 -1
- package/dist/core/extender.d.ts.map +1 -1
- package/dist/core/extender.js +3 -0
- package/dist/core/simnet.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/tasks/CallContractFunction.d.ts +2 -0
- package/dist/tasks/CallContractFunction.d.ts.map +1 -0
- package/dist/tasks/{call-contract-function.js → CallContractFunction.js} +12 -11
- package/dist/tasks/DeployContract.d.ts +2 -0
- package/dist/tasks/DeployContract.d.ts.map +1 -0
- package/dist/tasks/DeployContract.js +51 -0
- package/dist/tasks/ExampleTask.d.ts +2 -0
- package/dist/tasks/ExampleTask.d.ts.map +1 -0
- package/dist/tasks/ExecuteContract.d.ts +2 -0
- package/dist/tasks/ExecuteContract.d.ts.map +1 -0
- package/dist/tasks/ExecuteContract.js +97 -0
- package/dist/tasks/FaucetRequest.d.ts +2 -0
- package/dist/tasks/FaucetRequest.d.ts.map +1 -0
- package/dist/tasks/FaucetRequest.js +23 -0
- package/dist/tasks/GetBalance.d.ts +2 -0
- package/dist/tasks/GetBalance.d.ts.map +1 -0
- package/dist/tasks/GetBalance.js +37 -0
- package/dist/tasks/GetContractInfo.d.ts +2 -0
- package/dist/tasks/GetContractInfo.d.ts.map +1 -0
- package/dist/tasks/{get-contract-info.js → GetContractInfo.js} +10 -10
- package/dist/tasks/GetTxHistory.d.ts +2 -0
- package/dist/tasks/GetTxHistory.d.ts.map +1 -0
- package/dist/tasks/GetTxHistory.js +36 -0
- package/dist/tasks/ListAccounts.d.ts +2 -0
- package/dist/tasks/ListAccounts.d.ts.map +1 -0
- package/dist/tasks/ListAccounts.js +31 -0
- package/dist/tasks/SendStx.d.ts +2 -0
- package/dist/tasks/SendStx.d.ts.map +1 -0
- package/dist/tasks/SendStx.js +43 -0
- package/dist/tasks/VerifyContract.d.ts +2 -0
- package/dist/tasks/VerifyContract.d.ts.map +1 -0
- package/dist/tasks/{verify-contract.js → VerifyContract.js} +13 -16
- package/dist/tasks/utils.d.ts +22 -0
- package/dist/tasks/utils.d.ts.map +1 -0
- package/dist/tasks/utils.js +88 -0
- package/dist/types/config.d.ts +1 -1
- package/package.json +3 -3
- package/dist/config/config-loading.d.ts.map +0 -1
- package/dist/core/dsl.test.d.ts +0 -2
- package/dist/core/dsl.test.d.ts.map +0 -1
- package/dist/core/dsl.test.js +0 -45
- package/dist/core/runtime-environment.d.ts.map +0 -1
- package/dist/core/runtime-environment.js +0 -67
- package/dist/core/tasks-definitions.d.ts.map +0 -1
- package/dist/tasks/call-contract-function.d.ts +0 -2
- package/dist/tasks/call-contract-function.d.ts.map +0 -1
- package/dist/tasks/deploy-contract.d.ts +0 -2
- package/dist/tasks/deploy-contract.d.ts.map +0 -1
- package/dist/tasks/deploy-contract.js +0 -59
- package/dist/tasks/example-task.d.ts +0 -2
- package/dist/tasks/example-task.d.ts.map +0 -1
- package/dist/tasks/execute-contract.d.ts +0 -2
- package/dist/tasks/execute-contract.d.ts.map +0 -1
- package/dist/tasks/execute-contract.js +0 -76
- package/dist/tasks/faucet-request.d.ts +0 -2
- package/dist/tasks/faucet-request.d.ts.map +0 -1
- package/dist/tasks/faucet-request.js +0 -25
- package/dist/tasks/get-balance.d.ts +0 -2
- package/dist/tasks/get-balance.d.ts.map +0 -1
- package/dist/tasks/get-balance.js +0 -46
- package/dist/tasks/get-contract-info.d.ts +0 -2
- package/dist/tasks/get-contract-info.d.ts.map +0 -1
- package/dist/tasks/get-tx-history.d.ts +0 -2
- package/dist/tasks/get-tx-history.d.ts.map +0 -1
- package/dist/tasks/get-tx-history.js +0 -49
- package/dist/tasks/list-accounts.d.ts +0 -2
- package/dist/tasks/list-accounts.d.ts.map +0 -1
- package/dist/tasks/list-accounts.js +0 -30
- package/dist/tasks/send-stx.d.ts +0 -2
- package/dist/tasks/send-stx.d.ts.map +0 -1
- package/dist/tasks/send-stx.js +0 -57
- package/dist/tasks/verify-contract.d.ts +0 -2
- package/dist/tasks/verify-contract.d.ts.map +0 -1
- /package/dist/tasks/{example-task.js → ExampleTask.js} +0 -0
package/README.md
CHANGED
|
@@ -1,188 +1,192 @@
|
|
|
1
|
-
# mobilestacks
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
npx mobilestacks
|
|
47
|
-
npx mobilestacks
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
|
58
|
-
|
|
|
59
|
-
| `
|
|
60
|
-
| `
|
|
61
|
-
| `
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
task
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
subtask
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
//
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
##
|
|
187
|
-
|
|
188
|
-
|
|
1
|
+
# mobilestacks
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/mobilestacks)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
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.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install mobilestacks
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
Scaffold a new project:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npx mobilestacks init
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
This generates a config file, a sample Clarity contract, and an example task.
|
|
23
|
+
|
|
24
|
+
## Configuration
|
|
25
|
+
|
|
26
|
+
All config lives in `mobilestacks.config.ts`:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
export default {
|
|
30
|
+
networks: {
|
|
31
|
+
mainnet: { url: 'https://api.mainnet.hiro.so', name: 'mainnet' },
|
|
32
|
+
testnet: { url: 'https://api.testnet.hiro.so', name: 'testnet' },
|
|
33
|
+
},
|
|
34
|
+
defaultNetwork: 'testnet',
|
|
35
|
+
wallet: {
|
|
36
|
+
privateKey: process.env.STACKS_PRIVATE_KEY,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Secrets can live in `.env`; they override config values automatically.
|
|
42
|
+
|
|
43
|
+
## CLI
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npx mobilestacks # list all tasks
|
|
47
|
+
npx mobilestacks deploycontract # deploy a contract
|
|
48
|
+
npx mobilestacks getbalance # check STX balance
|
|
49
|
+
npx mobilestacks sendstx # send STX
|
|
50
|
+
npx mobilestacks faucetrequest # get testnet tokens
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Missing required params are prompted interactively. Run any task with `--help` for options.
|
|
54
|
+
|
|
55
|
+
### Built-in Tasks
|
|
56
|
+
|
|
57
|
+
| Task | What it does |
|
|
58
|
+
| ---- | ------------ |
|
|
59
|
+
| `deploycontract` | Deploy a `.clar` file to mainnet/testnet |
|
|
60
|
+
| `sendstx` | Transfer STX to an address |
|
|
61
|
+
| `getbalance` | Check STX balance for any address |
|
|
62
|
+
| `faucetrequest` | Request testnet STX from the faucet |
|
|
63
|
+
| `listaccounts` | List derived wallet accounts |
|
|
64
|
+
| `gettxhistory` | Fetch recent transactions |
|
|
65
|
+
| `callcontractfunction` | Call a read-only contract function |
|
|
66
|
+
| `getcontractinfo` | Fetch deployed contract metadata |
|
|
67
|
+
| `verifycontract` | Diff on-chain source against a local file |
|
|
68
|
+
|
|
69
|
+
## Writing Tasks
|
|
70
|
+
|
|
71
|
+
Drop a file in `src/tasks/`; it is auto-discovered:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import { task } from 'mobilestacks';
|
|
75
|
+
import { z } from 'zod';
|
|
76
|
+
|
|
77
|
+
task('greet', 'Say hello')
|
|
78
|
+
.addParam('name', 'Who to greet', { schema: z.string().min(1) })
|
|
79
|
+
.setAction((args, env) => {
|
|
80
|
+
return `Hello, ${args.name}! (network: ${env.config.defaultNetwork})`;
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Subtasks and workflows are also supported:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
import { subtask, runWorkflow } from 'mobilestacks';
|
|
88
|
+
|
|
89
|
+
subtask('deploy:validate', 'Pre-deploy check', 'deploycontract').setAction((args, env) => {
|
|
90
|
+
// validate deployment inputs
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
await runWorkflow(
|
|
94
|
+
[
|
|
95
|
+
{ taskName: 'deploycontract', args: { contractName: 'sample-contract' } },
|
|
96
|
+
{ taskName: 'verifycontract', args: { contractName: 'sample-contract' } },
|
|
97
|
+
],
|
|
98
|
+
env,
|
|
99
|
+
);
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Extending the Runtime
|
|
103
|
+
|
|
104
|
+
Add custom properties to the runtime environment, available in every task:
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
import { extendEnvironment } from 'mobilestacks';
|
|
108
|
+
|
|
109
|
+
extendEnvironment((env) => {
|
|
110
|
+
env.formatSTX = (micro: number) => `${(micro / 1e6).toFixed(6)} STX`;
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Testing with Simnet
|
|
115
|
+
|
|
116
|
+
Test contracts locally using the Clarinet SDK. No devnet is needed:
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
import { describe, it, expect, beforeAll } from 'vitest';
|
|
120
|
+
import { Simnet } from 'mobilestacks';
|
|
121
|
+
import { Cl } from '@stacks/transactions';
|
|
122
|
+
|
|
123
|
+
describe('My Contract', () => {
|
|
124
|
+
let simnet: Simnet;
|
|
125
|
+
|
|
126
|
+
beforeAll(async () => {
|
|
127
|
+
simnet = await Simnet.init();
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('calls hello-world', () => {
|
|
131
|
+
const deployer = simnet.getDeployer();
|
|
132
|
+
const { result } = simnet.callPublic('sample-contract', 'hello-world', [], deployer);
|
|
133
|
+
expect(result).toStrictEqual(Cl.ok(Cl.stringAscii('Hello, Stacks!')));
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Setup
|
|
139
|
+
|
|
140
|
+
Contract tests need a `Clarinet.toml` and test accounts. Run the setup script once:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
npm run setup:simnet
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Then run tests:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
npm test
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Programmatic API
|
|
153
|
+
|
|
154
|
+
Use mobilestacks as a library:
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
import { task, subtask, extendEnvironment, Simnet, RuntimeEnvironment } from 'mobilestacks';
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Project Structure
|
|
161
|
+
|
|
162
|
+
```text
|
|
163
|
+
src/
|
|
164
|
+
cli/ CLI entry point and init scaffolding
|
|
165
|
+
core/ DSL, Simnet, RuntimeEnvironment, task registry
|
|
166
|
+
tasks/ Built-in tasks
|
|
167
|
+
types/ Zod schemas and TypeScript types
|
|
168
|
+
index.ts Public API
|
|
169
|
+
tests/ Vitest test files
|
|
170
|
+
contracts/ Clarity contracts
|
|
171
|
+
Clarinet.toml Clarinet project manifest
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Contributing
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
git clone https://github.com/Wizbisy/mobilestacks.git
|
|
178
|
+
cd mobilestacks
|
|
179
|
+
npm install
|
|
180
|
+
npm run setup:simnet
|
|
181
|
+
npm test
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
|
|
185
|
+
|
|
186
|
+
## Security
|
|
187
|
+
|
|
188
|
+
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.
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
|
|
192
|
+
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 config_loading_1 = require("../config/config-loading");
|
|
10
|
-
const runtime_environment_1 = require("../core/runtime-environment");
|
|
11
|
-
const tasks_definitions_1 = require("../core/tasks-definitions");
|
|
12
|
-
const init_1 = require("./init");
|
|
13
|
-
const inquirer_1 = __importDefault(require("inquirer"));
|
|
14
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
15
11
|
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const ConfigLoading_1 = require("../config/ConfigLoading");
|
|
13
|
+
const RuntimeEnvironment_1 = require("../core/RuntimeEnvironment");
|
|
14
|
+
const TasksDefinitions_1 = require("../core/TasksDefinitions");
|
|
15
|
+
const init_1 = require("./init");
|
|
16
16
|
const tasksDir = path_1.default.join(__dirname, '../tasks');
|
|
17
17
|
fs_1.default.readdirSync(tasksDir)
|
|
18
|
-
.filter(
|
|
19
|
-
.
|
|
20
|
-
|
|
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(
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
80
|
+
TasksDefinitions_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(
|
|
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(
|
|
46
|
-
console.log(chalk_1.default.white('\nDocs: ') + chalk_1.default.underline('https://github.com/
|
|
89
|
+
console.log(` ${chalk_1.default.green('mobilestacks deploycontract --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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
task.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
cmd.option(optStr, param.description, param.defaultValue);
|
|
59
|
-
}
|
|
93
|
+
TasksDefinitions_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
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
const config = (0,
|
|
81
|
-
const env = new
|
|
122
|
+
const config = (0, ConfigLoading_1.loadConfig)();
|
|
123
|
+
const env = new RuntimeEnvironment_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
|
|
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!'));
|
package/dist/cli/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AAmBA,wBAAsB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAmG7C"}
|