create-mn-app 0.2.3 → 0.2.4
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 +67 -317
- package/dist/cli.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# create-mn-app
|
|
1
|
+
# create-mn-app
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Scaffold Midnight Network applications.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/create-mn-app)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -11,383 +11,133 @@ cd my-app
|
|
|
11
11
|
npm run setup
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
##
|
|
14
|
+
## Features
|
|
15
15
|
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
- 🚀 **Fast Setup** - From zero to working app in 60 seconds
|
|
23
|
-
- � **Helpful Errors** - Clear error messages with actionable solutions
|
|
24
|
-
- 📦 **ES Modules** - Modern JavaScript module system
|
|
25
|
-
- 🐳 **Docker Integration** - Automated proof server setup
|
|
16
|
+
- Interactive project setup with template selection
|
|
17
|
+
- Auto-detects package manager (npm/yarn/pnpm/bun)
|
|
18
|
+
- Environment health checks
|
|
19
|
+
- TypeScript with hot reloading
|
|
20
|
+
- Pre-configured Compact contracts
|
|
21
|
+
- Secure wallet generation
|
|
26
22
|
|
|
27
|
-
##
|
|
23
|
+
## Quick Start
|
|
28
24
|
|
|
29
|
-
### Interactive Mode
|
|
25
|
+
### Interactive Mode
|
|
30
26
|
|
|
31
27
|
```bash
|
|
32
28
|
npx create-mn-app
|
|
33
29
|
```
|
|
34
30
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
1. **Enter your project name** - Choose a descriptive name for your app
|
|
38
|
-
2. **Select a template** - Pick from available templates or see what's coming soon
|
|
39
|
-
3. **Choose configuration** - Package manager, git, and other options
|
|
40
|
-
|
|
41
|
-
### Command Line Mode
|
|
31
|
+
### CLI Mode
|
|
42
32
|
|
|
43
33
|
```bash
|
|
44
|
-
# Create with defaults
|
|
45
|
-
npx create-mn-app my-midnight-app
|
|
46
|
-
|
|
47
|
-
# Create with specific template
|
|
48
34
|
npx create-mn-app my-app --template hello-world
|
|
49
|
-
|
|
50
|
-
# Use specific package manager
|
|
51
|
-
npx create-mn-app my-app --use-pnpm
|
|
52
|
-
|
|
53
|
-
# Navigate and setup
|
|
54
35
|
cd my-app
|
|
55
36
|
npm run setup
|
|
56
37
|
```
|
|
57
38
|
|
|
58
|
-
##
|
|
59
|
-
|
|
60
|
-
Your generated project includes:
|
|
61
|
-
|
|
62
|
-
- 📝 **Hello World Contract** - A simple Compact contract to get started
|
|
63
|
-
- 🔐 **Wallet Setup** - Auto-generated wallet with secure seed phrase
|
|
64
|
-
- 🛠️ **Development Environment** - Pre-configured TypeScript, nodemon, and build tools
|
|
65
|
-
- 📚 **Provider Setup** - Midnight network providers (indexer, proof, state, ZK config)
|
|
66
|
-
- 🎨 **Interactive CLI** - Test your contracts with a user-friendly command-line interface
|
|
67
|
-
- 📋 **Environment Config** - `.env` file with network configuration
|
|
68
|
-
- 🔄 **Git Ready** - Initialized git repository with proper `.gitignore`
|
|
69
|
-
|
|
70
|
-
## 📚 Available Commands
|
|
71
|
-
|
|
72
|
-
Once your project is created, you can run:
|
|
73
|
-
|
|
74
|
-
### `npm run setup`
|
|
75
|
-
|
|
76
|
-
Complete setup pipeline:
|
|
77
|
-
|
|
78
|
-
1. Compiles Compact contracts
|
|
79
|
-
2. Builds TypeScript to JavaScript
|
|
80
|
-
3. Deploys contracts to the network
|
|
81
|
-
|
|
82
|
-
### `npm run health-check`
|
|
83
|
-
|
|
84
|
-
🏥 Verify your development environment:
|
|
85
|
-
|
|
86
|
-
- ✓ Node.js version (18+)
|
|
87
|
-
- ✓ Docker availability
|
|
88
|
-
- ✓ Environment configuration
|
|
89
|
-
- ✓ Wallet setup
|
|
90
|
-
- ✓ Dependencies installed
|
|
91
|
-
- ✓ Project built correctly
|
|
92
|
-
|
|
93
|
-
Run this command before development to catch issues early!
|
|
39
|
+
## Templates
|
|
94
40
|
|
|
95
|
-
###
|
|
41
|
+
### Hello World (Default)
|
|
96
42
|
|
|
97
|
-
|
|
43
|
+
Basic message storage contract demonstrating state management and deployment.
|
|
98
44
|
|
|
99
|
-
|
|
100
|
-
-
|
|
101
|
-
- Retrieve stored messages
|
|
102
|
-
- Test contract functionality
|
|
103
|
-
|
|
104
|
-
### `npm run check-balance`
|
|
105
|
-
|
|
106
|
-
Checks your wallet balance. Useful for verifying if test tokens from the faucet have arrived before deploying.
|
|
107
|
-
|
|
108
|
-
### `npm run compile`
|
|
109
|
-
|
|
110
|
-
Compiles your Compact smart contracts from `contracts/` to `contracts/managed/`
|
|
111
|
-
|
|
112
|
-
### `npm run build`
|
|
113
|
-
|
|
114
|
-
Builds your TypeScript source code to JavaScript in the `dist/` directory
|
|
115
|
-
|
|
116
|
-
### `npm run deploy`
|
|
117
|
-
|
|
118
|
-
Deploys your compiled contract to the Midnight testnet
|
|
119
|
-
|
|
120
|
-
## Project Structure
|
|
121
|
-
|
|
122
|
-
```
|
|
123
|
-
my-midnight-app/
|
|
124
|
-
├── contracts/
|
|
125
|
-
│ ├── hello-world.compact # Your Compact smart contract
|
|
126
|
-
│ └── managed/ # Compiled contract output
|
|
127
|
-
├── src/
|
|
128
|
-
│ ├── cli.ts # Interactive CLI application
|
|
129
|
-
│ ├── deploy.ts # Contract deployment script
|
|
130
|
-
│ ├── providers/
|
|
131
|
-
│ │ └── midnight-providers.ts # Network provider configuration
|
|
132
|
-
│ └── utils/
|
|
133
|
-
│ └── environment.ts # Environment management
|
|
134
|
-
├── .env # Environment variables & wallet seed
|
|
135
|
-
├── .gitignore
|
|
136
|
-
├── package.json
|
|
137
|
-
├── tsconfig.json
|
|
138
|
-
└── nodemon.json
|
|
45
|
+
```bash
|
|
46
|
+
npx create-mn-app my-app
|
|
139
47
|
```
|
|
140
48
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
Choose from various templates to kickstart your Midnight project:
|
|
144
|
-
|
|
145
|
-
### ✅ Available Now
|
|
146
|
-
|
|
147
|
-
#### **Hello World** (Default)
|
|
148
|
-
|
|
149
|
-
A simple message storage contract demonstrating:
|
|
49
|
+
### Counter DApp
|
|
150
50
|
|
|
151
|
-
-
|
|
152
|
-
- Public and private data
|
|
153
|
-
- Contract deployment
|
|
154
|
-
- Interactive testing
|
|
51
|
+
Real-world example from midnightntwrk with increment/decrement state and zkProofs.
|
|
155
52
|
|
|
156
53
|
```bash
|
|
157
|
-
npx create-mn-app my-app --template
|
|
54
|
+
npx create-mn-app my-app --template counter
|
|
158
55
|
```
|
|
159
56
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
Real-world example from midnightntwrk demonstrating:
|
|
57
|
+
Cloned from [midnightntwrk/example-counter](https://github.com/midnightntwrk/example-counter). Requires Node.js 22+, Docker, and Compact compiler.
|
|
163
58
|
|
|
164
|
-
|
|
165
|
-
- Zero-knowledge proofs on testnet
|
|
166
|
-
- Compact compiler integration
|
|
167
|
-
- Full CLI interface
|
|
59
|
+
After creation:
|
|
168
60
|
|
|
169
61
|
```bash
|
|
170
|
-
|
|
62
|
+
cd my-app
|
|
63
|
+
npm install
|
|
64
|
+
# Follow setup instructions displayed
|
|
171
65
|
```
|
|
172
66
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
**Requirements:** Node.js 22+, Docker, Compact compiler
|
|
176
|
-
|
|
177
|
-
### 🔜 Coming Soon
|
|
178
|
-
|
|
179
|
-
#### **Bulletin Board (Bboard)**
|
|
180
|
-
|
|
181
|
-
Bulletin board with multi-user interactions and privacy patterns
|
|
67
|
+
### Coming Soon
|
|
182
68
|
|
|
183
|
-
|
|
69
|
+
- Bulletin Board - Multi-user interactions with privacy patterns
|
|
70
|
+
- DEX - Decentralized exchange using FungibleToken
|
|
71
|
+
- Midnight Kitties - NFT-based full stack DApp
|
|
184
72
|
|
|
185
|
-
|
|
73
|
+
## Requirements
|
|
186
74
|
|
|
187
|
-
|
|
75
|
+
- Node.js 22+
|
|
76
|
+
- Docker (for proof server)
|
|
77
|
+
- npm/yarn/pnpm/bun
|
|
78
|
+
- Compact Compiler (for Counter template - auto-guided installation)
|
|
188
79
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
_These templates are under development. Star the repo to stay updated!_
|
|
192
|
-
|
|
193
|
-
## ⚙️ Requirements
|
|
194
|
-
|
|
195
|
-
- **Node.js** 22.0.0 or higher (required for all templates)
|
|
196
|
-
- **Docker** (for running the proof server)
|
|
197
|
-
- **npm**, **yarn**, **pnpm**, or **bun** package manager
|
|
198
|
-
- **Compact Compiler** (required for Counter and future templates - CLI will guide installation)
|
|
199
|
-
|
|
200
|
-
> **Note:** The CLI automatically checks Node.js version on startup and will guide you if an upgrade is needed.
|
|
201
|
-
|
|
202
|
-
## 📦 Package Manager Options
|
|
203
|
-
|
|
204
|
-
The CLI automatically detects your preferred package manager! It checks:
|
|
205
|
-
|
|
206
|
-
1. Lock files in your directory (package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lockb)
|
|
207
|
-
2. Environment variables set by your package manager
|
|
208
|
-
3. Available package managers on your system
|
|
209
|
-
|
|
210
|
-
You can also explicitly specify:
|
|
211
|
-
|
|
212
|
-
```bash
|
|
213
|
-
# npm
|
|
214
|
-
npx create-mn-app my-app --use-npm
|
|
215
|
-
|
|
216
|
-
# Yarn
|
|
217
|
-
npx create-mn-app my-app --use-yarn
|
|
218
|
-
|
|
219
|
-
# pnpm
|
|
220
|
-
npx create-mn-app my-app --use-pnpm
|
|
221
|
-
|
|
222
|
-
# Bun
|
|
223
|
-
npx create-mn-app my-app --use-bun
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
All commands in the success message will use your chosen package manager! 🎉
|
|
227
|
-
|
|
228
|
-
## ⚙️ CLI Options
|
|
80
|
+
## CLI Options
|
|
229
81
|
|
|
230
82
|
```bash
|
|
231
83
|
npx create-mn-app [project-name] [options]
|
|
232
84
|
|
|
233
|
-
Arguments:
|
|
234
|
-
project-name Name of your project (interactive prompt if omitted)
|
|
235
|
-
|
|
236
85
|
Options:
|
|
237
|
-
-t, --template <name> Template
|
|
238
|
-
--use-npm Use npm
|
|
239
|
-
--use-yarn Use Yarn
|
|
240
|
-
--use-pnpm Use pnpm
|
|
241
|
-
--use-bun Use bun
|
|
86
|
+
-t, --template <name> Template: hello-world, counter
|
|
87
|
+
--use-npm Use npm
|
|
88
|
+
--use-yarn Use Yarn
|
|
89
|
+
--use-pnpm Use pnpm
|
|
90
|
+
--use-bun Use bun
|
|
242
91
|
--skip-install Skip dependency installation
|
|
243
92
|
--skip-git Skip git initialization
|
|
244
|
-
--verbose Show detailed output
|
|
245
|
-
-h, --help
|
|
246
|
-
-V, --version
|
|
93
|
+
--verbose Show detailed output
|
|
94
|
+
-h, --help Help
|
|
95
|
+
-V, --version Version
|
|
247
96
|
```
|
|
248
97
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
```bash
|
|
252
|
-
# Interactive mode (recommended)
|
|
253
|
-
npx create-mn-app
|
|
254
|
-
|
|
255
|
-
# With project name
|
|
256
|
-
npx create-mn-app my-midnight-dapp
|
|
257
|
-
|
|
258
|
-
# Specific template and package manager
|
|
259
|
-
npx create-mn-app my-dex --template dex --use-pnpm
|
|
260
|
-
|
|
261
|
-
# Skip installation (for CI/CD)
|
|
262
|
-
npx create-mn-app my-app --skip-install --skip-git
|
|
98
|
+
## Project Structure
|
|
263
99
|
|
|
264
|
-
# Verbose output for debugging
|
|
265
|
-
npx create-mn-app my-app --verbose
|
|
266
100
|
```
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
INDEXER_WS_URL=wss://indexer.testnet.midnight.network
|
|
280
|
-
PROOF_SERVER_URL=http://localhost:6300
|
|
101
|
+
my-app/
|
|
102
|
+
├── contracts/
|
|
103
|
+
│ ├── hello-world.compact
|
|
104
|
+
│ └── managed/
|
|
105
|
+
├── src/
|
|
106
|
+
│ ├── cli.ts
|
|
107
|
+
│ ├── deploy.ts
|
|
108
|
+
│ ├── providers/
|
|
109
|
+
│ └── utils/
|
|
110
|
+
├── .env
|
|
111
|
+
├── package.json
|
|
112
|
+
└── tsconfig.json
|
|
281
113
|
```
|
|
282
114
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
## 🔧 Troubleshooting
|
|
115
|
+
## Troubleshooting
|
|
286
116
|
|
|
287
117
|
### Node.js version error
|
|
288
118
|
|
|
289
|
-
If you see "Node.js Version Error":
|
|
290
|
-
|
|
291
|
-
```bash
|
|
292
|
-
# Check your version
|
|
293
|
-
node --version
|
|
294
|
-
|
|
295
|
-
# Install Node.js 22+ from https://nodejs.org
|
|
296
|
-
# Or use nvm:
|
|
297
|
-
nvm install 22
|
|
298
|
-
nvm use 22
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
The CLI automatically checks for Node.js 22+ before running!
|
|
302
|
-
|
|
303
|
-
### Environment issues
|
|
304
|
-
|
|
305
|
-
Run the health check to diagnose problems:
|
|
306
|
-
|
|
307
|
-
```bash
|
|
308
|
-
cd my-app
|
|
309
|
-
npm run health-check
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
This will show you exactly what needs to be fixed. ✨
|
|
313
|
-
|
|
314
|
-
### Waiting for faucet funds
|
|
315
|
-
|
|
316
|
-
If your deployment is waiting for funds from the testnet faucet:
|
|
317
|
-
|
|
318
119
|
```bash
|
|
319
|
-
#
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
# Option 2: Stop and check manually
|
|
323
|
-
# Press Ctrl+C to stop, then:
|
|
324
|
-
npm run check-balance
|
|
325
|
-
|
|
326
|
-
# Once funded, deploy:
|
|
327
|
-
npm run deploy
|
|
120
|
+
node --version # Check version
|
|
121
|
+
nvm install 22 && nvm use 22 # Install Node.js 22+
|
|
328
122
|
```
|
|
329
123
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
### Port 6300 already in use
|
|
333
|
-
|
|
334
|
-
If you see "Bind for 0.0.0.0:6300 failed: port is already allocated":
|
|
124
|
+
### Port 6300 in use
|
|
335
125
|
|
|
336
126
|
```bash
|
|
337
|
-
# Stop the existing proof server
|
|
338
127
|
docker ps
|
|
339
128
|
docker stop <container-id>
|
|
340
|
-
|
|
341
|
-
# Or run on a different port (update .env accordingly)
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
### Module resolution errors
|
|
345
|
-
|
|
346
|
-
Make sure you're using Node.js 18+ and the project was created with the latest version:
|
|
347
|
-
|
|
348
|
-
```bash
|
|
349
|
-
node --version
|
|
350
|
-
npx create-mn-app@latest my-app
|
|
351
129
|
```
|
|
352
130
|
|
|
353
|
-
###
|
|
354
|
-
|
|
355
|
-
Ensure Docker Desktop is running before starting the development server:
|
|
356
|
-
|
|
357
|
-
```bash
|
|
358
|
-
docker --version
|
|
359
|
-
|
|
360
|
-
# If not installed, get it from:
|
|
361
|
-
# https://docker.com
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
### Permission errors
|
|
365
|
-
|
|
366
|
-
If you encounter EACCES errors:
|
|
367
|
-
|
|
368
|
-
```bash
|
|
369
|
-
# Fix npm permissions (recommended)
|
|
370
|
-
# See: https://docs.npmjs.com/resolving-eacces-permissions-errors
|
|
371
|
-
|
|
372
|
-
# Or use a version manager like nvm (better solution)
|
|
373
|
-
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
## Learn More
|
|
131
|
+
### Waiting for faucet funds
|
|
377
132
|
|
|
378
|
-
-
|
|
379
|
-
- 🚀 [Getting Started Guide](https://docs.midnight.network/getting-started)
|
|
380
|
-
- 💬 [Midnight Discord Community](https://discord.gg/midnight)
|
|
381
|
-
- 🐙 [GitHub Repository](https://github.com/Olanetsoft/create-mn-app)
|
|
133
|
+
Testnet faucet typically takes 2-5 minutes. The deploy script will auto-detect when funds arrive.
|
|
382
134
|
|
|
383
|
-
##
|
|
135
|
+
## Links
|
|
384
136
|
|
|
385
|
-
|
|
137
|
+
- [Midnight Docs](https://docs.midnight.network)
|
|
138
|
+
- [Discord Community](https://discord.gg/midnight)
|
|
139
|
+
- [GitHub](https://github.com/Olanetsoft/create-mn-app)
|
|
386
140
|
|
|
387
141
|
## License
|
|
388
142
|
|
|
389
|
-
MIT ©
|
|
390
|
-
|
|
391
|
-
---
|
|
392
|
-
|
|
393
|
-
Built with ❤️ for the Midnight Network community 🌙✨
|
|
143
|
+
MIT ©
|
package/dist/cli.js
CHANGED
|
@@ -13,7 +13,7 @@ error_handler_js_1.ErrorHandler.checkNodeVersion(22);
|
|
|
13
13
|
program
|
|
14
14
|
.name("create-mn-app")
|
|
15
15
|
.description("Create a new Midnight Network application")
|
|
16
|
-
.version("0.2.
|
|
16
|
+
.version("0.2.4")
|
|
17
17
|
.argument("[project-directory]", "Directory name for your project")
|
|
18
18
|
.option("-t, --template <name>", "Template to use (hello-world, counter, bboard, dex, midnight-kitties)")
|
|
19
19
|
.option("--use-npm", "Use npm explicitly")
|
|
@@ -24,7 +24,7 @@ program
|
|
|
24
24
|
.option("--skip-git", "Skip git repository initialization")
|
|
25
25
|
.option("--verbose", "Show detailed output")
|
|
26
26
|
.action(async (projectDirectory, options) => {
|
|
27
|
-
console.log(chalk_1.default.bold.cyan("\ncreate-mn-app") + chalk_1.default.gray(" v0.2.
|
|
27
|
+
console.log(chalk_1.default.bold.cyan("\ncreate-mn-app") + chalk_1.default.gray(" v0.2.4\n"));
|
|
28
28
|
try {
|
|
29
29
|
await (0, create_app_js_1.createApp)(projectDirectory, options);
|
|
30
30
|
}
|