Skip to content

Commit 58bc099

Browse files
committed
feat: add all config files for npm package
1 parent d271799 commit 58bc099

12 files changed

Lines changed: 440 additions & 31 deletions

File tree

PUBLISHING.md

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
# Publishing @meshsdk/midnight-setup to npm
2+
3+
## Prerequisites
4+
5+
1. **npm Account**: You need an npm account. Create one at [npmjs.com](https://www.npmjs.com/signup)
6+
2. **Organization**: Create the `@meshsdk` organization on npm (if not already created)
7+
3. **Login**: Login to npm from the terminal
8+
9+
```bash
10+
npm login
11+
```
12+
13+
## Publishing Steps
14+
15+
### 1. Build the Package
16+
17+
```bash
18+
# From the root directory
19+
yarn build:all
20+
21+
# Or just build the library package
22+
cd packages/api
23+
yarn build
24+
```
25+
26+
### 2. Test the Package Locally (Optional)
27+
28+
Before publishing, you can test the package locally:
29+
30+
```bash
31+
cd packages/api
32+
33+
# Create a tarball
34+
npm pack
35+
36+
# This creates a file like: meshsdk-midnight-setup-1.0.0.tgz
37+
# You can install this in another project to test:
38+
# npm install /path/to/meshsdk-midnight-setup-1.0.0.tgz
39+
```
40+
41+
### 3. Update Version (if needed)
42+
43+
```bash
44+
cd packages/api
45+
46+
# Update version (patch, minor, or major)
47+
npm version patch # 1.0.0 -> 1.0.1
48+
npm version minor # 1.0.0 -> 1.1.0
49+
npm version major # 1.0.0 -> 2.0.0
50+
```
51+
52+
### 4. Publish to npm
53+
54+
```bash
55+
cd packages/api
56+
57+
# Publish to npm
58+
npm publish
59+
60+
# For first-time publishing of a scoped package
61+
npm publish --access public
62+
```
63+
64+
### 5. Verify the Package
65+
66+
After publishing, verify it's available:
67+
68+
```bash
69+
npm view @meshsdk/midnight-setup
70+
```
71+
72+
Try installing it in a test project:
73+
74+
```bash
75+
npm install @meshsdk/midnight-setup
76+
```
77+
78+
## Publishing Checklist
79+
80+
Before publishing, make sure:
81+
82+
- [ ] All tests pass
83+
- [ ] Build completes successfully (`yarn build:all`)
84+
- [ ] README.md is complete and up-to-date
85+
- [ ] package.json has correct version number
86+
- [ ] package.json has correct repository URLs
87+
- [ ] LICENSE file is included
88+
- [ ] No sensitive information in the package
89+
- [ ] .npmignore is properly configured
90+
- [ ] TypeScript types are being exported correctly
91+
92+
## Automated Publishing with GitHub Actions (Optional)
93+
94+
You can automate publishing with GitHub Actions:
95+
96+
```yaml
97+
# .github/workflows/publish.yml
98+
name: Publish to npm
99+
100+
on:
101+
release:
102+
types: [created]
103+
104+
jobs:
105+
publish:
106+
runs-on: ubuntu-latest
107+
steps:
108+
- uses: actions/checkout@v3
109+
- uses: actions/setup-node@v3
110+
with:
111+
node-version: '22'
112+
registry-url: 'https://registry.npmjs.org'
113+
114+
- name: Install dependencies
115+
run: yarn install
116+
117+
- name: Build
118+
run: yarn build:all
119+
120+
- name: Publish to npm
121+
run: |
122+
cd packages/api
123+
npm publish --access public
124+
env:
125+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
126+
```
127+
128+
## Package Contents
129+
130+
The published package will include:
131+
132+
- `dist/` - Compiled JavaScript and TypeScript definitions
133+
- `README.md` - Documentation
134+
- `LICENSE` - MIT License
135+
- `package.json` - Package metadata
136+
137+
Files excluded (via `.npmignore`):
138+
- `src/` - Source TypeScript files
139+
- `tsconfig*.json` - TypeScript configuration
140+
- Test files
141+
- Development configurations
142+
143+
## Update Repository URLs
144+
145+
Before publishing, make sure to update the repository URLs in `packages/api/package.json`:
146+
147+
```json
148+
{
149+
"homepage": "https://github.com/MeshJS/midnight-setup",
150+
"repository": {
151+
"type": "git",
152+
"url": "https://github.com/MeshJS/midnight-setup.git"
153+
},
154+
"bugs": {
155+
"url": "https://github.com/MeshJS/midnight-setup/issues"
156+
}
157+
}
158+
```
159+
160+
## Post-Publishing
161+
162+
After publishing:
163+
164+
1. **Tag the Release on GitHub**:
165+
```bash
166+
git tag -a v1.0.0 -m "Release v1.0.0"
167+
git push origin v1.0.0
168+
```
169+
170+
2. **Create a GitHub Release**: Go to your GitHub repository and create a release with the changelog
171+
172+
3. **Announce**: Share on social media, Discord, etc.
173+
174+
4. **Update Documentation**: Update any external documentation with the new version
175+
176+
## Troubleshooting
177+
178+
### Error: 403 Forbidden
179+
180+
- Make sure you're logged in: `npm whoami`
181+
- Verify you have permissions for the `@meshsdk` organization
182+
- For first publish of scoped package, use `--access public`
183+
184+
### Error: Version Already Exists
185+
186+
- You can't republish the same version
187+
- Update the version number in package.json
188+
189+
### Error: Missing Dependencies
190+
191+
- Make sure all dependencies are properly listed in package.json
192+
- Use `peerDependencies` for large packages that users should install separately
193+
194+
## Support
195+
196+
For issues or questions:
197+
- GitHub Issues: https://github.com/MeshJS/midnight-setup/issues
198+
- Discord: https://discord.gg/meshjs
199+

README.md

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
# Midnight Setup - MeshJS Toolkit
2+
3+
<div align="center">
4+
<h1>@meshsdk/midnight-setup</h1>
5+
<p><strong>Complete development setup for building Midnight Network dApps</strong></p>
6+
7+
[![npm version](https://img.shields.io/npm/v/@meshsdk/midnight-setup.svg)](https://www.npmjs.com/package/@meshsdk/midnight-setup)
8+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9+
[![TypeScript](https://img.shields.io/badge/TypeScript-5.8-blue)](https://www.typescriptlang.org/)
10+
</div>
11+
12+
---
13+
14+
## 🚀 What is this?
15+
16+
This monorepo contains the complete Midnight Setup toolkit for building decentralized applications on the Midnight Network. It includes:
17+
18+
- **📦 @meshsdk/midnight-setup** - Main npm package with smart contract, API, and types
19+
- **🖥️ UI Package** - Example React application demonstrating usage
20+
- **⚙️ CLI Package** - Command-line tools for development
21+
- **📜 Contract Package** - Compact smart contract source
22+
23+
## 📦 Installation
24+
25+
Install the main package:
26+
27+
```bash
28+
npm install @meshsdk/midnight-setup
29+
```
30+
31+
Or with yarn:
32+
33+
```bash
34+
yarn add @meshsdk/midnight-setup
35+
```
36+
37+
See the [complete documentation](./packages/api/README.md) for usage examples.
38+
39+
## 🏗️ Development
40+
41+
This is a Yarn workspace monorepo. To work on this project:
42+
43+
### Prerequisites
44+
45+
- Node.js ≥ 22
46+
- Yarn 4.9.2+
47+
- Midnight Network tools (compact compiler)
48+
49+
### Setup
50+
51+
```bash
52+
# Install dependencies
53+
yarn install
54+
55+
# Build all packages
56+
yarn build:all
57+
58+
# Build individual packages
59+
cd packages/contract && yarn build
60+
cd packages/api && yarn build
61+
cd packages/cli && yarn build
62+
cd packages/ui && yarn build
63+
```
64+
65+
### Package Structure
66+
67+
```
68+
.
69+
├── packages/
70+
│ ├── api/ # @meshsdk/midnight-setup (publishable)
71+
│ ├── contract/ # Smart contract compilation
72+
│ ├── cli/ # CLI tools (internal)
73+
│ └── ui/ # Example React app (internal)
74+
└── compact/ # Compact compiler workspace
75+
```
76+
77+
### Scripts
78+
79+
```bash
80+
# Build all packages
81+
yarn build:all
82+
83+
# Clean build artifacts
84+
yarn clean
85+
86+
# Clean cache
87+
yarn clean:cache
88+
```
89+
90+
## 📚 Packages
91+
92+
### @meshsdk/midnight-setup
93+
94+
The main package that users install. Contains:
95+
- Compiled smart contract
96+
- TypeScript API for contract interaction
97+
- Complete type definitions
98+
- Wallet integration utilities
99+
100+
**Location**: `packages/api`
101+
**Status**: ✅ Publishable to npm
102+
103+
### Example UI
104+
105+
React application demonstrating how to use the library.
106+
107+
**Location**: `packages/ui`
108+
**Status**: 🔒 Private (development only)
109+
110+
**Features**:
111+
- Wallet connection
112+
- Contract deployment
113+
- Contract joining
114+
- State reading
115+
- Beautiful UI with Tailwind CSS
116+
117+
**Run locally**:
118+
```bash
119+
cd packages/ui
120+
yarn dev
121+
```
122+
123+
### CLI Tools
124+
125+
Command-line interface for contract operations.
126+
127+
**Location**: `packages/cli`
128+
**Status**: 🔒 Private (development only)
129+
130+
### Contract
131+
132+
Compact smart contract source and compilation.
133+
134+
**Location**: `packages/contract`
135+
**Status**: 🔒 Private (compilation only)
136+
137+
## 🎯 Features
138+
139+
-**Type-Safe**: Full TypeScript support with strict typing
140+
-**Easy to Use**: Simple API for deploying and joining contracts
141+
-**Well Documented**: Comprehensive README and examples
142+
-**Production Ready**: Built with best practices
143+
-**Extensible**: Easy to customize for your needs
144+
-**Modern Stack**: React 19, Vite, TypeScript 5.8
145+
146+
## 🔧 Technologies
147+
148+
- **Midnight Network**: Blockchain platform
149+
- **Compact**: Smart contract language
150+
- **TypeScript**: Type-safe development
151+
- **React**: UI library
152+
- **Vite**: Build tool
153+
- **Tailwind CSS**: Styling
154+
- **RxJS**: Reactive programming
155+
- **Pino**: Logging
156+
157+
## 📖 Documentation
158+
159+
- [Library Documentation](./packages/api/README.md) - How to use @meshsdk/midnight-setup
160+
- [Publishing Guide](./PUBLISHING.md) - How to publish to npm
161+
- [Midnight Network Docs](https://docs.midnight.network) - Official Midnight documentation
162+
163+
## 🤝 Contributing
164+
165+
Contributions are welcome! Please feel free to submit a Pull Request.
166+
167+
1. Fork the repository
168+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
169+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
170+
4. Push to the branch (`git push origin feature/amazing-feature`)
171+
5. Open a Pull Request
172+
173+
## 📄 License
174+
175+
MIT © [MeshJS Team](https://github.com/MeshJS)
176+
177+
See [LICENSE](./LICENSE) for more information.
178+
179+
## 🔗 Links
180+
181+
- [MeshJS Website](https://meshjs.dev)
182+
- [MeshJS GitHub](https://github.com/MeshJS)
183+
- [Midnight Network](https://midnight.network)
184+
- [npm Package](https://www.npmjs.com/package/@meshsdk/midnight-setup)
185+
186+
## 💬 Support
187+
188+
- 🐛 [Report Issues](https://github.com/MeshJS/midnight-setup/issues)
189+
- 💬 [Discord Community](https://discord.gg/meshjs)
190+
- 🐦 [Twitter](https://twitter.com/meshsdk)
191+
192+
---
193+
194+
<div align="center">
195+
<p>Built with ❤️ by the MeshJS Team</p>
196+
<p>Powered by Midnight Network</p>
197+
</div>
198+

0 commit comments

Comments
 (0)