Add npm package infrastructure for global CLI installation#6
Conversation
- Made src/cli/liku.js executable (chmod +x) - Enhanced package.json with repository, bugs, homepage, engines, and os fields - Added comprehensive npm global installation instructions to README.md - Updated QUICKSTART.md with npm install options - Created CONTRIBUTING.md for development workflow guide - Created INSTALLATION.md with platform-specific installation guides - Added documentation section to README.md linking to all guides - Verified npm link workflow works correctly Co-authored-by: TayDa64 <976929+TayDa64@users.noreply.github.com>
- 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>
- Created GitHub Actions workflow for automated npm publishing on releases - Added RELEASE_PROCESS.md with comprehensive release guidelines - Updated PUBLISHING.md with automated workflow documentation - Updated README.md to include release process documentation - Workflow includes version checking, testing, and automatic commenting - Supports both automated (via releases) and manual publishing Co-authored-by: TayDa64 <976929+TayDa64@users.noreply.github.com>
- Fixed changelog filename references to match actual file (changelog.md) - Added comment in .npmignore explaining .github/ exclusion for transparency - Ensured consistency across documentation Co-authored-by: TayDa64 <976929+TayDa64@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This pull request configures copilot-liku-cli as a production-ready npm package with global CLI installation support. Users will be able to install the package globally via npm install -g copilot-liku-cli and run the liku command from any directory. The PR adds comprehensive documentation, GitHub Actions automation for npm publishing, and package configuration optimizations.
Changes:
- Added
binentry in package.json pointing to executable CLI entry point with proper shebang - Created GitHub Actions workflow for automated npm publishing on releases with version checking and package verification
- Added comprehensive documentation (INSTALLATION.md, CONTRIBUTING.md, PUBLISHING.md, RELEASE_PROCESS.md) covering installation methods, development workflows, and release procedures
- Enhanced package.json with repository metadata, Node ≥22/npm ≥10 engine constraints, OS compatibility, and explicit
filesproperty - Added .npmignore to exclude development files and reduce package size to ~145 KB
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Added bin entry, repository metadata, engine constraints, OS compatibility, and files list for npm packaging |
| src/cli/liku.js | New CLI entry point with shebang, command registry, argument parsing, and help system |
| .github/workflows/publish-npm.yml | Automated npm publishing workflow triggered on releases with tests, version checking, and comment creation |
| INSTALLATION.md | Platform-specific installation instructions for macOS/Linux/Windows with troubleshooting guide |
| CONTRIBUTING.md | Developer setup guide with npm link workflow for local development |
| PUBLISHING.md | Complete npm publishing guide covering manual and automated workflows |
| RELEASE_PROCESS.md | Versioning and release management procedures |
| README.md | Updated with global npm installation instructions and documentation index |
| QUICKSTART.md | Added global install option alongside local development setup |
| .npmignore | Package optimization to exclude test files, development artifacts, and large documentation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| github.rest.issues.createComment({ | ||
| issue_number: context.issue.number, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: `🎉 Successfully published \`${packageJson.name}@${packageJson.version}\` to npm!\n\nInstall with:\n\`\`\`bash\nnpm install -g ${packageJson.name}\n\`\`\`` |
There was a problem hiding this comment.
The workflow attempts to create a comment on a release, but releases don't have an issue_number. The context.issue.number will be undefined for release events. You should use the release ID instead. Replace issue_number: context.issue.number with a proper release comment mechanism or use the GitHub Releases API to add a comment to the release body.
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: `🎉 Successfully published \`${packageJson.name}@${packageJson.version}\` to npm!\n\nInstall with:\n\`\`\`bash\nnpm install -g ${packageJson.name}\n\`\`\`` | |
| const release = context.payload.release; | |
| const successMessage = `🎉 Successfully published \`${packageJson.name}@${packageJson.version}\` to npm!\n\nInstall with:\n\`\`\`bash\nnpm install -g ${packageJson.name}\n\`\`\``; | |
| const updatedBody = (release.body || '') + '\n\n' + successMessage; | |
| await github.rest.repos.updateRelease({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| release_id: release.id, | |
| body: updatedBody, |
|
|
||
| ### 2. Update Changelog | ||
|
|
||
| Document changes in `changelog.md`: |
There was a problem hiding this comment.
The documentation references changelog.md which 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.
| Document changes in `changelog.md`: | |
| Document changes in `CHANGELOG.md`: |
| registry-url: 'https://registry.npmjs.org' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci || npm install |
There was a problem hiding this comment.
The fallback from npm ci to npm install using || could mask errors. If npm ci fails due to a package-lock.json mismatch or corruption, it will silently fall back to npm install, which could install different dependency versions than expected. Consider either ensuring package-lock.json is committed and up-to-date, or use npm ci without fallback for reproducible builds.
| run: npm ci || npm install | |
| run: | | |
| if [ -f package-lock.json ]; then | |
| npm ci | |
| else | |
| npm install | |
| fi |
| - name: Check if version already published | ||
| id: check-version | ||
| run: | | ||
| PACKAGE_NAME=$(node -p "require('./package.json').name") | ||
| PACKAGE_VERSION=$(node -p "require('./package.json').version") | ||
|
|
||
| if npm view "$PACKAGE_NAME@$PACKAGE_VERSION" version 2>/dev/null; then | ||
| echo "⚠️ Version $PACKAGE_VERSION is already published" | ||
| echo "already_published=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "✅ Version $PACKAGE_VERSION is not published yet" | ||
| echo "already_published=false" >> $GITHUB_OUTPUT | ||
| fi | ||
| continue-on-error: true |
There was a problem hiding this comment.
The version check step has continue-on-error: true, which means if the check itself fails (e.g., npm registry is down), the workflow will continue and attempt to publish anyway, potentially causing an error later. Consider removing continue-on-error or adding explicit error handling to ensure the workflow behaves correctly when the npm registry is unavailable.
| ```bash | ||
| gh release create v1.0.0 \ | ||
| --title "v1.0.0 - Release Name" \ | ||
| --notes-file RELEASE_NOTES.md |
There was a problem hiding this comment.
The documentation references a file RELEASE_NOTES.md that doesn't exist in the repository. This will cause the gh release create command to fail if a user follows these instructions. Either create this file, or update the example to use a different approach (like using --notes with inline text or referencing an existing file like changelog.md).
| --notes-file RELEASE_NOTES.md | |
| --notes-file changelog.md |
| runs-on: ubuntu-latest | ||
|
|
||
| permissions: | ||
| contents: read |
There was a problem hiding this comment.
The workflow needs write permissions for contents and/or issues to create comments. Currently, it only has contents: read and id-token: write. Add contents: write to the permissions section to allow creating release comments or updating release descriptions.
| contents: read | |
| contents: write |
|
|
||
| - name: Run tests | ||
| run: npm test | ||
| continue-on-error: true |
There was a problem hiding this comment.
Tests are set to continue-on-error: true, meaning the workflow will publish to npm even if tests fail. This is risky and could publish broken versions. Either remove continue-on-error: true or add a clear comment explaining why test failures should be ignored during publication.
| continue-on-error: true |
| - [ ] All planned features/fixes are merged to `main` | ||
| - [ ] All tests are passing | ||
| - [ ] Documentation is up to date | ||
| - [ ] changelog.md is updated with release notes |
There was a problem hiding this comment.
The documentation references changelog.md which 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.
| "license": "MIT", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/TayDa64/copilot-Liku-cli.git" |
There was a problem hiding this comment.
There's an inconsistency in the repository URL capitalization. package.json uses copilot-Liku-cli.git while README.md uses copilot-Liku-cli (without .git). While GitHub handles this, it's better to be consistent. Either both should include .git or neither should.
| "url": "https://github.com/TayDa64/copilot-Liku-cli.git" | |
| "url": "https://github.com/TayDa64/copilot-Liku-cli" |
| "node": ">=22.0.0", | ||
| "npm": ">=10.0.0" |
There was a problem hiding this comment.
The engines constraint requires Node.js >=22.0.0, which is a very recent version (released in April 2024). This may limit adoption significantly. Unless there are specific features from Node 22 that are required, consider using a lower version constraint like >=18.0.0 (LTS) or >=20.0.0 to allow more users to install the package.
| "node": ">=22.0.0", | |
| "npm": ">=10.0.0" | |
| "node": ">=18.0.0", | |
| "npm": ">=8.0.0" |
Configures
copilot-liku-clias a production-ready npm package with automated publishing. Users can install globally withnpm install -g copilot-liku-cliand runlikufrom any directory.Package Configuration
src/cli/liku.jsexecutable (already had correct shebang)package.jsonwith repository metadata, engine constraints (Node ≥22, npm ≥10), OS compatibility, and explicitfilesproperty.npmignoreto optimize package size (145 KB packed, 71 files)CI/CD Automation
Created
.github/workflows/publish-npm.ymltriggered on GitHub releases:NPM_TOKENsecretDocumentation
New guides:
INSTALLATION.md- Platform-specific instructions (macOS/Linux/Windows) with Homebrew/Scoop placeholdersCONTRIBUTING.md- Development workflow usingnpm linkPUBLISHING.md- npm publishing procedures (manual and automated)RELEASE_PROCESS.md- Versioning and release managementUpdated:
README.md- npm global install instructions and documentation indexQUICKSTART.md- Global install optionUsage
After publication:
For local development:
To publish, set
NPM_TOKENin repository secrets and create a GitHub release. Workflow handles the rest.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.