|
1 | 1 | # FastKit - Package Manager Usage Guide |
2 | 2 |
|
3 | | -This document explains how to use FastKit with both npm and pnpm package managers. |
| 3 | +**FastKit** is a development toolkit that supports both `npm` and `pnpm` for installation, development, and publishing workflows. |
4 | 4 |
|
5 | | -## Installation |
| 5 | +📦 Available on npm: |
| 6 | +[@nexgenstudiodev/fastkit](https://www.npmjs.com/package/@nexgenstudiodev/fastkit) |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## 📥 Installation |
6 | 11 |
|
7 | 12 | ### Using npm |
8 | 13 | ```bash |
9 | | -npm install @abhishek-nexgen-dev/fastkit |
| 14 | +npm install @nexgenstudiodev/fastkit |
10 | 15 | ``` |
11 | 16 |
|
12 | | -### Using pnpm |
13 | | -```bash |
14 | | -pnpm add @abhishek-nexgen-dev/fastkit |
15 | | -``` |
16 | 17 |
|
17 | | -### Using yarn |
| 18 | +### Using npm |
| 19 | + |
18 | 20 | ```bash |
19 | | -yarn add @abhishek-nexgen-dev/fastkit |
| 21 | +pnpm add @nexgenstudiodev/fastkit |
20 | 22 | ``` |
21 | 23 |
|
22 | | -## Development Scripts |
| 24 | +### Using yarn |
23 | 25 |
|
24 | | -### For npm users |
25 | 26 | ```bash |
26 | | -# Install dependencies |
27 | | -npm install |
28 | | - |
29 | | -# Build the project |
30 | | -npm run build |
31 | | - |
32 | | -# Clean build artifacts |
33 | | -npm run clean |
34 | | - |
35 | | -# Rebuild (clean + build) |
36 | | -npm run rebuild |
37 | | - |
38 | | -# Start development server |
39 | | -npm run start:dev |
| 27 | +yarn add @nexgenstudiodev/fastkit |
| 28 | +``` |
40 | 29 |
|
41 | | -# Format code |
42 | | -npm run format |
43 | 30 |
|
44 | | -# Lint code |
45 | | -npm run lint |
| 31 | +# 🔧 Development Scripts |
46 | 32 |
|
47 | | -# Fix linting issues |
48 | | -npm run lint:fix |
| 33 | +The following scripts are available via `npm run <script>` or `pnpm run <script>`: |
49 | 34 |
|
50 | | -# Publish to npm |
51 | | -npm run publish:npm |
| 35 | +| Script | Description | |
| 36 | +|-----------------|--------------------------------------------------------| |
| 37 | +| `build` | Compile TypeScript to JavaScript using `tsc` | |
| 38 | +| `clean` | Delete the `dist` directory using `rimraf` | |
| 39 | +| `rebuild` | Clean and then build (npm version) | |
| 40 | +| `rebuild:pnpm` | Clean and then build (pnpm version) | |
| 41 | +| `lint` | Run ESLint on all `.ts` and `.tsx` files in `src/` | |
| 42 | +| `lint:fix` | Automatically fix linting issues | |
| 43 | +| `test` | Run tests with Jest | |
| 44 | +| `test:watch` | Watch files and re-run tests on change | |
| 45 | +| `test:coverage` | Run tests and generate coverage report | |
| 46 | +| `start:dev` | Start development mode using `ts-node-dev` | |
| 47 | +| `format` | Format all supported files in `src/` using Prettier | |
| 48 | +| `prepublishOnly`| Format, lint, and build before publishing (npm lifecycle hook) | |
| 49 | +| `publish:npm` | Publish the package to npm (with public access) | |
| 50 | +| `publish:pnpm` | Publish the package using pnpm (skip git checks) | |
| 51 | +| `version:patch` | Bump patch version using npm | |
| 52 | +| `version:minor` | Bump minor version using npm | |
| 53 | +| `version:major` | Bump major version using npm | |
52 | 54 |
|
53 | | -# Version bumping |
54 | | -npm run version:patch |
55 | | -npm run version:minor |
56 | | -npm run version:major |
57 | | -``` |
| 55 | +--- |
58 | 56 |
|
59 | | -### For pnpm users |
60 | | -```bash |
61 | | -# Install dependencies |
62 | | -pnpm install |
| 57 | +# 🚀 Publishing Workflow |
63 | 58 |
|
64 | | -# Build the project |
65 | | -pnpm run build |
| 59 | +### Using npm |
| 60 | +1. Make your changes |
| 61 | +2. Run tests: `npm test` |
| 62 | +3. Build the project: `npm run build` |
| 63 | +4. Bump version: |
| 64 | + - `npm run version:patch` (or use `version:minor` / `version:major`) |
| 65 | +5. Publish: `npm run publish:npm` |
66 | 66 |
|
67 | | -# Clean build artifacts |
68 | | -pnpm run clean |
| 67 | +### Using pnpm |
| 68 | +1. Make your changes |
| 69 | +2. Run tests: `pnpm test` |
| 70 | +3. Build the project: `pnpm run build` |
| 71 | +4. Bump version: |
| 72 | + - `npm run version:patch` (or use `version:minor` / `version:major`) |
| 73 | +5. Publish: `pnpm run publish:pnpm` |
69 | 74 |
|
70 | | -# Rebuild (clean + build) - pnpm optimized |
71 | | -pnpm run rebuild:pnpm |
| 75 | +--- |
72 | 76 |
|
73 | | -# Start development server |
74 | | -pnpm run start:dev |
| 77 | +# ⚙️ Configuration Files |
75 | 78 |
|
76 | | -# Format code |
77 | | -pnpm run format |
| 79 | +| File | Description | |
| 80 | +|------------------|---------------------------------| |
| 81 | +| `package.json` | Project configuration (shared) | |
| 82 | +| `.pnpmrc` | pnpm-specific config | |
| 83 | +| `.npmignore` | Exclude files from npm package | |
| 84 | +| `pnpm-lock.yaml` | pnpm lockfile (auto-generated) | |
| 85 | +| `package-lock.json` | npm lockfile (auto-generated) | |
78 | 86 |
|
79 | | -# Lint code |
80 | | -pnpm run lint |
| 87 | +--- |
81 | 88 |
|
82 | | -# Fix linting issues |
83 | | -pnpm run lint:fix |
| 89 | +# ✅ Best Practices |
84 | 90 |
|
85 | | -# Publish to npm |
86 | | -pnpm run publish:pnpm |
| 91 | +- Use a single package manager throughout your project |
| 92 | +- Commit lockfiles to ensure consistent builds |
| 93 | +- Use correct CLI scripts based on your manager |
| 94 | +- Use npm for version management |
| 95 | +- Use either npm or pnpm to publish, **not both** |
87 | 96 |
|
88 | | -# Version bumping (still uses npm for version management) |
89 | | -npm run version:patch |
90 | | -npm run version:minor |
91 | | -npm run version:major |
92 | | -``` |
| 97 | +--- |
93 | 98 |
|
94 | | -## Publishing Workflow |
| 99 | +# 📊 Package Manager Comparison |
95 | 100 |
|
96 | | -### Using npm |
97 | | -1. Make your changes |
98 | | -2. Run tests: `npm test` |
99 | | -3. Build: `npm run build` |
100 | | -4. Bump version: `npm run version:patch` (or minor/major) |
101 | | -5. Publish: `npm run publish:npm` |
| 101 | +| Feature | npm | pnpm | |
| 102 | +|-----------------|------------|--------------| |
| 103 | +| Speed | Moderate | Fast | |
| 104 | +| Disk Usage | High | Low | |
| 105 | +| Node Modules | Full copy | Symlinked | |
| 106 | +| Lockfile | package-lock.json | pnpm-lock.yaml | |
| 107 | +| Workspace Support | ✅ | ✅ | |
| 108 | +| Compatibility | Universal | Growing | |
102 | 109 |
|
103 | | -### Using pnpm |
104 | | -1. Make your changes |
105 | | -2. Run tests: `pnpm test` |
106 | | -3. Build: `pnpm run build` |
107 | | -4. Bump version: `npm run version:patch` (or minor/major) |
108 | | -5. Publish: `pnpm run publish:pnpm` |
109 | 110 |
|
110 | | -## Configuration Files |
| 111 | +# 🛠️ Troubleshooting |
111 | 112 |
|
112 | | -- **package.json**: Main package configuration (works with both) |
113 | | -- **.pnpmrc**: pnpm-specific configuration |
114 | | -- **.npmignore**: Files to exclude from npm package |
115 | | -- **pnpm-lock.yaml**: pnpm lockfile (auto-generated) |
116 | | -- **package-lock.json**: npm lockfile (auto-generated) |
| 113 | +## Common Issues |
117 | 114 |
|
118 | | -## Best Practices |
| 115 | +### Mixed lockfiles |
| 116 | +Delete both `pnpm-lock.yaml` and `package-lock.json`, then reinstall dependencies. |
119 | 117 |
|
120 | | -1. **Choose one package manager** for your project and stick with it |
121 | | -2. **Commit lockfiles** to ensure reproducible builds |
122 | | -3. **Use the correct scripts** for your chosen package manager |
123 | | -4. **Version management** should use npm commands regardless of package manager |
124 | | -5. **Publishing** can use either npm or pnpm commands |
| 118 | +### Permission errors |
| 119 | +Use `npm login` or configure your npm registry properly. |
125 | 120 |
|
126 | | -## Package Manager Comparison |
| 121 | +### Version conflicts |
| 122 | +Bump the version before attempting to publish. |
127 | 123 |
|
128 | | -| Feature | npm | pnpm | |
129 | | -|---------|-----|------| |
130 | | -| Speed | Moderate | Fast | |
131 | | -| Disk Usage | High | Low (symlinks) | |
132 | | -| Node Modules | Full copy | Symlinked | |
133 | | -| Lockfile | package-lock.json | pnpm-lock.yaml | |
134 | | -| Workspace Support | ✅ | ✅ | |
135 | | -| Compatibility | Universal | Growing | |
| 124 | +### Build errors |
| 125 | +Try: |
| 126 | +- Checking for syntax errors or missing dependencies |
| 127 | +- Deleting `node_modules` and reinstalling packages |
| 128 | +- Ensuring your TypeScript configuration is correct |
| 129 | +- Running `npm run clean` before building again |
136 | 130 |
|
137 | | -## Troubleshooting |
138 | 131 |
|
139 | | -### Common Issues |
| 132 | +```bash |
| 133 | +npm run clean |
| 134 | +npm run build |
| 135 | +``` |
140 | 136 |
|
141 | | -1. **Mixed lockfiles**: Delete both lockfiles and reinstall with your chosen package manager |
142 | | -2. **Permission errors**: Use `npm login` or configure registry authentication |
143 | | -3. **Version conflicts**: Ensure version is bumped before publishing |
144 | | -4. **Build errors**: Run `npm run clean` then `npm run build` |
145 | 137 |
|
146 | 138 | ### Environment Setup |
147 | 139 |
|
| 140 | + |
148 | 141 | ```bash |
149 | 142 | # Check versions |
150 | 143 | node --version |
151 | 144 | npm --version |
152 | 145 | pnpm --version |
153 | 146 |
|
154 | | -# Configure npm registry (if needed) |
| 147 | +# Configure registries |
155 | 148 | npm config set registry https://registry.npmjs.org/ |
156 | | - |
157 | | -# Configure pnpm registry (if needed) |
158 | 149 | pnpm config set registry https://registry.npmjs.org/ |
159 | | -``` |
160 | | - |
161 | | -## Links |
162 | | - |
163 | | -- [npm Documentation](https://docs.npmjs.com/) |
164 | | -- [pnpm Documentation](https://pnpm.io/) |
165 | | -- [Package on npm](https://www.npmjs.com/package/@abhishek-nexgen-dev/fastkit) |
166 | | -- [GitHub Repository](https://github.com/NexGenStudioDev/FastKit) |
| 150 | +``` |
0 commit comments