forked from github/copilot-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Add npm package infrastructure for global CLI installation #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a9f7928
Initial plan
Copilot 42e9cc7
Make liku globally runnable with npm package setup
Copilot 908ff59
Add npm package publishing configuration and guides
Copilot 56e8c3c
Add automated release and publishing workflow
Copilot e4ffc26
Address code review feedback
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add npm package publishing configuration and guides
- Added .npmignore to exclude unnecessary files from npm package - Added files property to package.json to explicitly control package contents - Created PUBLISHING.md with comprehensive npm publishing guide - Updated README.md to include publishing guide in documentation - Verified package size (145 KB packed, 555 KB unpacked) - Tested all CLI commands work correctly after npm link Co-authored-by: TayDa64 <976929+TayDa64@users.noreply.github.com>
- Loading branch information
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Test files | ||
| scripts/test-*.js | ||
| scripts/*.ps1 | ||
|
|
||
| # Documentation (most can be included, but some might be too large) | ||
| FINAL_SUMMARY.txt | ||
| GPT-reports.md | ||
| IMPLEMENTATION_SUMMARY.md | ||
| baseline-app.md | ||
| changelog.md | ||
| OVERLAY_PROOF.png | ||
|
|
||
| # Project management | ||
| .github/ | ||
| .git/ | ||
| .gitignore | ||
|
|
||
| # Development files | ||
| *.swp | ||
| *.swo | ||
| .DS_Store | ||
| Thumbs.db | ||
| .vscode/ | ||
| .idea/ | ||
|
|
||
| # Build artifacts | ||
| out/ | ||
| build/ | ||
| dist/ | ||
| *.log | ||
|
|
||
| # Specific directories | ||
| ultimate-ai-system/ | ||
| docs/ | ||
|
|
||
| # Keep these important files for npm users | ||
| # README.md | ||
| # LICENSE.md | ||
| # QUICKSTART.md | ||
| # INSTALLATION.md | ||
| # CONTRIBUTING.md | ||
| # ARCHITECTURE.md | ||
| # CONFIGURATION.md | ||
| # TESTING.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,306 @@ | ||
| # Publishing Guide | ||
|
|
||
| This guide covers how to publish the Copilot-Liku CLI to npm. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| Before publishing, ensure you have: | ||
|
|
||
| 1. **npm account**: Create one at [npmjs.com](https://www.npmjs.com/signup) | ||
| 2. **npm login**: Run `npm login` and authenticate | ||
| 3. **Access rights**: If publishing to an organization, ensure you have publishing rights | ||
| 4. **Clean repository**: All changes committed, tests passing | ||
|
|
||
| ## Pre-Publication Checklist | ||
|
|
||
| ### 1. Version Update | ||
|
|
||
| Update the version in `package.json` following [Semantic Versioning](https://semver.org/): | ||
|
|
||
| ```bash | ||
| # For a patch release (bug fixes) | ||
| npm version patch | ||
|
|
||
| # For a minor release (new features, backwards compatible) | ||
| npm version minor | ||
|
|
||
| # For a major release (breaking changes) | ||
| npm version major | ||
| ``` | ||
|
|
||
| This will: | ||
| - Update `package.json` | ||
| - Create a git tag | ||
| - Commit the change | ||
|
|
||
| ### 2. Update Changelog | ||
|
|
||
| Document changes in `changelog.md`: | ||
| ```markdown | ||
| ## [1.0.0] - 2024-XX-XX | ||
|
|
||
| ### Added | ||
| - Global npm installation support | ||
| - Comprehensive installation guides | ||
|
|
||
| ### Changed | ||
| - Updated package.json with repository metadata | ||
|
|
||
| ### Fixed | ||
| - Made CLI executable on all platforms | ||
| ``` | ||
|
|
||
| ### 3. Verify Package Contents | ||
|
|
||
| Check what will be published: | ||
| ```bash | ||
| npm pack --dry-run | ||
| ``` | ||
|
|
||
| Review the output to ensure: | ||
| - All necessary source files are included | ||
| - Documentation files are included | ||
| - Test files and development artifacts are excluded | ||
| - `.npmignore` is working correctly | ||
|
|
||
| ### 4. Test Installation Locally | ||
|
|
||
| Test the package locally before publishing: | ||
|
|
||
| ```bash | ||
| # Create a tarball | ||
| npm pack | ||
|
|
||
| # Install globally from the tarball | ||
| npm install -g copilot-liku-cli-0.0.1.tgz | ||
|
|
||
| # Test the command | ||
| liku --version | ||
| liku --help | ||
|
|
||
| # Uninstall when done testing | ||
| npm uninstall -g copilot-liku-cli | ||
| ``` | ||
|
|
||
| ### 5. Run Tests | ||
|
|
||
| Ensure all tests pass: | ||
| ```bash | ||
| npm test | ||
| npm run test:ui | ||
| ``` | ||
|
|
||
| ## Publishing to npm | ||
|
|
||
| ### First-Time Publication | ||
|
|
||
| For the first publication to npm: | ||
|
|
||
| ```bash | ||
| # Login to npm | ||
| npm login | ||
|
|
||
| # Publish the package (public) | ||
| npm publish --access public | ||
|
|
||
| # Or for a scoped package | ||
| npm publish --access public | ||
| ``` | ||
|
|
||
| ### Subsequent Releases | ||
|
|
||
| For version updates: | ||
|
|
||
| ```bash | ||
| # 1. Update version | ||
| npm version patch # or minor, or major | ||
|
|
||
| # 2. Push tags | ||
| git push origin main --tags | ||
|
|
||
| # 3. Publish | ||
| npm publish | ||
| ``` | ||
|
|
||
| ## Automated Publishing with GitHub Actions | ||
|
|
||
| To automate publishing on GitHub releases, create `.github/workflows/publish.yml`: | ||
|
|
||
| ```yaml | ||
| name: Publish to npm | ||
|
|
||
| on: | ||
| release: | ||
| types: [published] | ||
|
|
||
| jobs: | ||
| publish: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v3 | ||
| with: | ||
| node-version: '22' | ||
| registry-url: 'https://registry.npmjs.org' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Run tests | ||
| run: npm test | ||
|
|
||
| - name: Publish to npm | ||
| run: npm publish --access public | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| ``` | ||
|
|
||
| Then: | ||
| 1. Create an npm access token at https://www.npmjs.com/settings/YOUR-USERNAME/tokens | ||
| 2. Add it as `NPM_TOKEN` in GitHub repository secrets | ||
| 3. Create a GitHub release to trigger publication | ||
|
|
||
| ## Post-Publication | ||
|
|
||
| ### 1. Verify Publication | ||
|
|
||
| ```bash | ||
| # Check on npm | ||
| npm view copilot-liku-cli | ||
|
|
||
| # Test installation | ||
| npm install -g copilot-liku-cli | ||
| liku --version | ||
| ``` | ||
|
|
||
| ### 2. Update Documentation | ||
|
|
||
| Update installation instructions if needed: | ||
| - README.md | ||
| - INSTALLATION.md | ||
| - QUICKSTART.md | ||
|
|
||
| ### 3. Announce Release | ||
|
|
||
| - Create a GitHub release with release notes | ||
| - Update project status documentation | ||
| - Share on relevant channels | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Error: Package name already exists | ||
|
|
||
| If someone else has registered the name: | ||
| 1. Choose a different name in `package.json` | ||
| 2. Or request transfer of the package if it's unused | ||
|
|
||
| ### Error: Permission denied | ||
|
|
||
| Ensure you're logged in: | ||
| ```bash | ||
| npm whoami # Check who you're logged in as | ||
| npm login # Login if needed | ||
| ``` | ||
|
|
||
| ### Error: Failed to publish | ||
|
|
||
| Check: | ||
| - Version isn't already published: `npm view copilot-liku-cli versions` | ||
| - You have publish permissions | ||
| - Package name is available | ||
|
|
||
| ### Version Already Published | ||
|
|
||
| If you need to fix a published version: | ||
| 1. **Never unpublish** recent versions (npm policy) | ||
| 2. Publish a patch version instead: `npm version patch && npm publish` | ||
|
|
||
| ## Package Maintenance | ||
|
|
||
| ### Deprecating a Version | ||
|
|
||
| If a version has issues: | ||
| ```bash | ||
| npm deprecate copilot-liku-cli@0.0.1 "Critical bug, use 0.0.2 instead" | ||
| ``` | ||
|
|
||
| ### Unpublishing | ||
|
|
||
| **Only for mistakes within 24 hours:** | ||
| ```bash | ||
| npm unpublish copilot-liku-cli@0.0.1 | ||
| ``` | ||
|
|
||
| ⚠️ **Warning:** Unpublishing after 24 hours or if the package is widely used is against npm policy. | ||
|
|
||
| ## Package Registry Alternatives | ||
|
|
||
| ### GitHub Package Registry | ||
|
|
||
| To publish to GitHub Packages instead: | ||
|
|
||
| 1. Update `.npmrc`: | ||
| ``` | ||
| @TayDa64:registry=https://npm.pkg.github.com | ||
| ``` | ||
|
|
||
| 2. Update `package.json`: | ||
| ```json | ||
| { | ||
| "name": "@TayDa64/copilot-liku-cli", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/TayDa64/copilot-Liku-cli.git" | ||
| }, | ||
| "publishConfig": { | ||
| "registry": "https://npm.pkg.github.com" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| 3. Authenticate with GitHub token: | ||
| ```bash | ||
| npm login --registry=https://npm.pkg.github.com | ||
| ``` | ||
|
|
||
| ## Beta/Prerelease Versions | ||
|
|
||
| For testing before official release: | ||
|
|
||
| ```bash | ||
| # Create a prerelease version | ||
| npm version prerelease --preid=beta | ||
|
|
||
| # Publish with beta tag | ||
| npm publish --tag beta | ||
|
|
||
| # Users install with | ||
| npm install -g copilot-liku-cli@beta | ||
| ``` | ||
|
|
||
| ## Best Practices | ||
|
|
||
| 1. **Use semantic versioning** consistently | ||
| 2. **Test thoroughly** before publishing | ||
| 3. **Maintain a changelog** for users | ||
| 4. **Never publish secrets** or credentials | ||
| 5. **Use .npmignore** to exclude unnecessary files | ||
| 6. **Document breaking changes** clearly | ||
| 7. **Respond to issues** from npm users | ||
| 8. **Keep dependencies updated** for security | ||
|
|
||
| ## Resources | ||
|
|
||
| - [npm Publishing Guide](https://docs.npmjs.com/packages-and-modules/contributing-packages-to-the-registry) | ||
| - [Semantic Versioning](https://semver.org/) | ||
| - [npm CLI Documentation](https://docs.npmjs.com/cli/v10) | ||
| - [Creating npm Packages](https://docs.npmjs.com/creating-node-js-modules) | ||
|
|
||
| ## Support | ||
|
|
||
| For issues with publishing: | ||
| - Check [npm status](https://status.npmjs.org/) | ||
| - Review [npm documentation](https://docs.npmjs.com/) | ||
| - Contact [npm support](https://www.npmjs.com/support) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation references
changelog.mdwhich is excluded from the npm package via.npmignore. Either include changelog.md in the package by removing it from .npmignore, or update the documentation to reference CHANGELOG.md with a capital name or use GitHub releases for changelog information instead.