This guide will help you publish the EdgeCraft package to npm.
- npm account: Create one at npmjs.com
- npm CLI: Already installed with Node.js
- Git: For version control
npm loginEnter your npm credentials when prompted.
Check if "edgecraft" is available:
npm search edgecraftIf the name is taken, update package.json with a different name or use a scoped package:
{
"name": "@yourusername/edgecraft",
...
}Before publishing, update these fields:
{
"author": "Your Name <your.email@example.com>",
"repository": {
"type": "git",
"url": "https://github.com/yourusername/edgecraft.git"
},
"bugs": {
"url": "https://github.com/yourusername/edgecraft/issues"
},
"homepage": "https://github.com/yourusername/edgecraft#readme"
}npm installnpm run buildThis will:
- Compile TypeScript to JavaScript
- Generate type declarations
- Create both CommonJS and ES Module bundles
- Output everything to the
dist/folder
Verify that the build was successful:
ls dist/
# Should show: index.js, index.esm.js, index.d.ts, and .map files# Build the package
npm run build
# Publish to npm
npm publishFor scoped packages (if using @yourusername/edgecraft):
npm publish --access public- Update the version in
package.json:
# Patch release (0.1.0 -> 0.1.1)
npm version patch
# Minor release (0.1.0 -> 0.2.0)
npm version minor
# Major release (0.1.0 -> 1.0.0)
npm version major- Publish:
npm publish# In the edgecraft directory
npm link
# In a test project directory
npm link edgecraft
# Now you can import it
# import { EdgeCraft } from 'edgecraft';Create a tarball to see what will be published:
npm packThis creates a .tgz file. You can:
- Extract it to verify contents
- Install it in another project:
npm install ./edgecraft-0.1.0.tgz
Create .github/workflows/publish.yml:
name: Publish Package
on:
release:
types: [created]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm test
- run: npm run build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}Then:
- Go to npmjs.com → Account Settings → Access Tokens
- Create a new token
- Add it to GitHub repository secrets as
NPM_TOKEN
npm view edgecraftIn a new project:
npm install edgecraftgit tag v0.1.0
git push origin v0.1.0Follow Semantic Versioning:
- PATCH (0.1.1): Bug fixes
- MINOR (0.2.0): New features (backward compatible)
- MAJOR (1.0.0): Breaking changes
Use a scoped package: @yourusername/edgecraft
Run npm login again or check your npm account.
Make sure package.json has all required dependencies listed.
Check .npmignore - it controls what files are excluded.
Only these are included by default:
dist/README.mdLICENSEpackage.json
- Always build before publishing: Run
npm run build - Test the package: Use
npm packto verify contents - Update changelog: Document what changed
- Tag releases: Use git tags for versions
- Write good docs: Keep README.md updated
- Use semantic versioning: Follow semver rules
- Test in real projects: Before major releases
- All tests pass:
npm test - Build succeeds:
npm run build - README.md is updated
- Version number is correct in package.json
- CHANGELOG.md is updated (if you have one)
- Examples work with the new version
- No sensitive data in the package
- License is correct
- Git commits are pushed
Share your package:
# Install it in a project
npm install edgecraft
# Use it
import { EdgeCraft } from 'edgecraft';
const graph = new EdgeCraft({
container: '#graph',
data: myGraphData
});- npm documentation: https://docs.npmjs.com/
- npm support: https://www.npmjs.com/support
- Semantic Versioning: https://semver.org/
Good luck with your package! 🚀