Skip to content

Commit 4cb3feb

Browse files
committed
feat: add workflow conversion and publishing support
- Add new `useEdgeConnection` hook for handling edge styling and connections - Implement `convertWorkflowToReactFlow` utility for serverless workflow conversion - Add publishing scripts and documentation (PUBLISHING.md, QUICK_PUBLISH.md) - Update package.json build configuration and main entry point - Include example workflow editor component - Add EdgeStyles.css for enhanced edge visualization
1 parent fb3f2ab commit 4cb3feb

File tree

10 files changed

+1576
-6
lines changed

10 files changed

+1576
-6
lines changed

src/lib/PUBLISHING.md

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
# Publishing Guide for Serverless Workflow Builder Library
2+
3+
This guide explains how to publish the `serverless-workflow-builder-lib` to npm.
4+
5+
## Prerequisites
6+
7+
1. **npm Account**: Create an account at [npmjs.com](https://www.npmjs.com/)
8+
2. **npm CLI**: Ensure you have npm installed and are logged in
9+
```bash
10+
npm login
11+
```
12+
3. **Git Repository**: Ensure your code is committed and pushed to a Git repository
13+
14+
## Pre-Publishing Checklist
15+
16+
- [ ] Update version in `package.json`
17+
- [ ] Update `README.md` with latest features
18+
- [ ] Update `USAGE.md` with any new APIs
19+
- [ ] Test the library in the test application
20+
- [ ] Commit all changes to Git
21+
- [ ] Create a Git tag for the version
22+
23+
## Publishing Steps
24+
25+
### 1. Prepare for Publishing
26+
27+
First, navigate to the library directory:
28+
```bash
29+
cd src/lib
30+
```
31+
32+
### 2. Update Version
33+
34+
Use npm's version command to bump the version:
35+
36+
```bash
37+
# For patch releases (bug fixes)
38+
npm version patch
39+
40+
# For minor releases (new features)
41+
npm version minor
42+
43+
# For major releases (breaking changes)
44+
npm version major
45+
```
46+
47+
This will:
48+
- Update the version in `package.json`
49+
- Create a Git commit with the version change
50+
- Create a Git tag
51+
- Run the build script
52+
53+
### 3. Build the Library
54+
55+
The build process is automatically triggered by the version command, but you can also run it manually:
56+
57+
```bash
58+
npm run build
59+
```
60+
61+
This will:
62+
- Clean the `dist` directory
63+
- Copy all source files to `dist`
64+
- Copy documentation files
65+
- Prepare the `package.json` for publishing
66+
67+
### 4. Test the Build
68+
69+
Before publishing, test the built package:
70+
71+
```bash
72+
# Navigate to dist directory
73+
cd dist
74+
75+
# Test the package locally
76+
npm pack
77+
78+
# This creates a .tgz file you can test in another project
79+
```
80+
81+
### 5. Publish to npm
82+
83+
From the `dist` directory:
84+
85+
```bash
86+
npm publish
87+
```
88+
89+
For the first publication, you might need:
90+
```bash
91+
npm publish --access public
92+
```
93+
94+
### 6. Verify Publication
95+
96+
Check that your package is available:
97+
- Visit `https://www.npmjs.com/package/serverless-workflow-builder-lib`
98+
- Test installation: `npm install serverless-workflow-builder-lib`
99+
100+
## Publishing Workflow
101+
102+
### For Regular Updates
103+
104+
```bash
105+
# 1. Make your changes
106+
git add .
107+
git commit -m "feat: add new feature"
108+
109+
# 2. Update version and publish
110+
npm version patch # or minor/major
111+
cd dist
112+
npm publish
113+
cd ..
114+
115+
# 3. Push changes
116+
git push origin main --tags
117+
```
118+
119+
### For Beta/Alpha Releases
120+
121+
```bash
122+
# Update to pre-release version
123+
npm version prerelease --preid=beta
124+
125+
# Publish with beta tag
126+
cd dist
127+
npm publish --tag beta
128+
```
129+
130+
## Package Structure
131+
132+
The published package will have this structure:
133+
134+
```
135+
serverless-workflow-builder-lib/
136+
├── index.js # Main entry point
137+
├── components/ # React components
138+
│ ├── nodes/
139+
│ └── common/
140+
├── hooks/ # Custom React hooks
141+
├── styles/ # CSS files
142+
├── utils/ # Utility functions
143+
├── README.md # Documentation
144+
├── USAGE.md # Usage examples
145+
└── package.json # Package configuration
146+
```
147+
148+
## Troubleshooting
149+
150+
### Common Issues
151+
152+
1. **Permission Denied**
153+
```bash
154+
npm login
155+
# Ensure you're logged in with correct credentials
156+
```
157+
158+
2. **Package Name Conflict**
159+
- Check if the package name is available on npm
160+
- Consider scoped packages: `@your-org/serverless-workflow-builder-lib`
161+
162+
3. **Build Failures**
163+
```bash
164+
# Clean and rebuild
165+
rm -rf dist
166+
npm run build
167+
```
168+
169+
4. **Version Conflicts**
170+
```bash
171+
# Check current version
172+
npm view serverless-workflow-builder-lib version
173+
174+
# Ensure your version is higher
175+
npm version patch --force
176+
```
177+
178+
### Best Practices
179+
180+
1. **Semantic Versioning**: Follow [semver](https://semver.org/)
181+
- `MAJOR.MINOR.PATCH`
182+
- Breaking changes = major
183+
- New features = minor
184+
- Bug fixes = patch
185+
186+
2. **Testing**: Always test in the test application before publishing
187+
188+
3. **Documentation**: Keep README and USAGE files up to date
189+
190+
4. **Git Tags**: Use meaningful commit messages and proper tagging
191+
192+
5. **Changelog**: Consider maintaining a CHANGELOG.md file
193+
194+
## Automation (Optional)
195+
196+
For automated publishing, you can set up GitHub Actions:
197+
198+
```yaml
199+
# .github/workflows/publish.yml
200+
name: Publish to npm
201+
202+
on:
203+
push:
204+
tags:
205+
- 'v*'
206+
207+
jobs:
208+
publish:
209+
runs-on: ubuntu-latest
210+
steps:
211+
- uses: actions/checkout@v2
212+
- uses: actions/setup-node@v2
213+
with:
214+
node-version: '18'
215+
registry-url: 'https://registry.npmjs.org'
216+
- run: cd src/lib && npm run build
217+
- run: cd src/lib/dist && npm publish
218+
env:
219+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
220+
```
221+
222+
## Support
223+
224+
For issues with publishing:
225+
1. Check npm documentation
226+
2. Verify package.json configuration
227+
3. Test locally before publishing
228+
4. Use npm's support channels if needed

src/lib/QUICK_PUBLISH.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Quick Publishing Guide
2+
3+
## Immediate Steps to Publish
4+
5+
### 1. Prerequisites
6+
```bash
7+
# Login to npm (if not already logged in)
8+
npm login
9+
```
10+
11+
### 2. Update Repository URLs (Optional)
12+
Edit `package.json` and replace `your-username` with your actual GitHub username:
13+
- Repository URL
14+
- Bugs URL
15+
- Homepage URL
16+
17+
### 3. Publish Now
18+
```bash
19+
# Navigate to library directory
20+
cd src/lib
21+
22+
# Build the library
23+
npm run build
24+
25+
# Navigate to dist and publish
26+
cd dist
27+
npm publish --access public
28+
```
29+
30+
### 4. Verify
31+
Check your package at: `https://www.npmjs.com/package/serverless-workflow-builder-lib`
32+
33+
## For Future Updates
34+
35+
```bash
36+
# Make changes, then:
37+
cd src/lib
38+
npm version patch # or minor/major
39+
cd dist
40+
npm publish
41+
```
42+
43+
## Test Installation
44+
```bash
45+
npm install serverless-workflow-builder-lib
46+
```
47+
48+
That's it! Your library is now published and ready to use.

0 commit comments

Comments
 (0)