npm package: @pikacodey/npm-publish-test
Description: A dummy package for testing npm publishing from CI
Author: pikacodey
Latest version: 1.0.2

# NPM Publish Test Package

A dummy npm package for testing automated publishing to the public npm registry from CI systems.

## Features

- Simple utility functions for testing
- Automated publishing via GitHub Actions
- Proper package structure and metadata

## Installation

```bash
npm install @your-username/npm-publish-test
```

## Usage

```javascript
const { greet, add, getTimestamp } = require('@your-username/npm-publish-test');

console.log(greet('World')); // Hello, World!
console.log(add(2, 3)); // 5
console.log(getTimestamp()); // 2024-01-01T12:00:00.000Z
```

## Setup Instructions for NPM Publishing

### 1. Create NPM Account and Package

1. **Create an npm account** at [npmjs.com](https://www.npmjs.com) if you don't have one
2. **Login to npm** from your terminal:
   ```bash
   npm login
   ```
3. **Create a new package** on npmjs.com:
   - Go to [npmjs.com](https://www.npmjs.com)
   - Click "Add Package" → "Create a Package"
   - Choose a unique package name (replace `@your-username/npm-publish-test` in package.json)
   - Set visibility to "Public"

### 2. Generate NPM Token

1. **Go to npm account settings**:
   - Visit [npmjs.com](https://www.npmjs.com)
   - Click on your profile → "Access Tokens"

2. **Create a new token**:
   - Click "Generate New Token"
   - Choose "Automation" token type (for CI/CD)
   - Set expiration (recommend 1 year or custom)
   - Copy the generated token (starts with `npm_`)

### 3. Configure GitHub Repository

1. **Update package.json**:
   - Replace `@your-username/npm-publish-test` with your actual package name
   - Update author information
   - Update repository URLs

2. **Add NPM token to GitHub Secrets**:
   - Go to your GitHub repository
   - Navigate to Settings → Secrets and variables → Actions
   - Click "New repository secret"
   - Name: `NPM_TOKEN`
   - Value: Paste your npm automation token

### 4. Publishing Methods

#### Method 1: Tag-based Publishing (Recommended)
```bash
# Create and push a tag
git tag v1.0.0
git push origin v1.0.0
```
The GitHub Action will automatically publish when a tag starting with 'v' is pushed.

#### Method 2: Manual Publishing
- Go to GitHub repository → Actions tab
- Select "Publish to npm" workflow
- Click "Run workflow"
- Enter version number (e.g., 1.0.0)

### 5. Verify Publishing

1. **Check npm registry**:
   ```bash
   npm view @your-username/npm-publish-test
   ```

2. **Install and test**:
   ```bash
   npm install @your-username/npm-publish-test
   ```

## Package Structure

```
npm-publish-test/
├── .github/
│   └── workflows/
│       └── publish.yml    # GitHub Actions workflow
├── index.js              # Main package file
├── package.json          # Package metadata
├── LICENSE               # MIT license
└── README.md             # This file
```

## Important Notes

- **Package name**: Must be unique on npm registry
- **Scoped packages**: Use `@username/package-name` format for scoped packages
- **Versioning**: Follow semantic versioning (semver)
- **Token security**: Never commit npm tokens to code
- **Testing**: Always test locally before publishing

## Troubleshooting

### Common Issues

1. **"Package already exists"**: Choose a different package name
2. **"Authentication failed"**: Verify NPM_TOKEN secret is correct
3. **"Version already published"**: Increment version number
4. **"Permission denied"**: Ensure you own the package or have publish rights

### Useful Commands

```bash
# Check if logged in
npm whoami

# View package info
npm view <package-name>

# Unpublish (within 72 hours)
npm unpublish <package-name>@<version>

# Update package
npm version patch  # or minor, major
```

## License

MIT License - see LICENSE file for details.
# npm-publish-test