@writechoice/mint-cli 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/PUBLISH.md +386 -0
- package/README.md +324 -0
- package/bin/cli.js +44 -0
- package/package.json +51 -0
- package/src/commands/validate/links.js +1183 -0
- package/src/index.js +5 -0
- package/src/utils/helpers.js +218 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 WriteChoice
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/PUBLISH.md
ADDED
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
# Publishing Guide
|
|
2
|
+
|
|
3
|
+
This guide covers how to publish the `@writechoice/mint-cli` package to npm and manage new versions.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
### 1. npm Account
|
|
8
|
+
- Create an account at [npmjs.com](https://www.npmjs.com/signup)
|
|
9
|
+
- Verify your email address
|
|
10
|
+
- (Optional but recommended) Enable two-factor authentication
|
|
11
|
+
|
|
12
|
+
### 2. npm CLI Login
|
|
13
|
+
```bash
|
|
14
|
+
npm login
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Enter your credentials when prompted:
|
|
18
|
+
- Username
|
|
19
|
+
- Password
|
|
20
|
+
- Email
|
|
21
|
+
- (If 2FA is enabled) One-time password
|
|
22
|
+
|
|
23
|
+
Verify you're logged in:
|
|
24
|
+
```bash
|
|
25
|
+
npm whoami
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Initial Publication
|
|
29
|
+
|
|
30
|
+
### Step 1: Prepare the Package
|
|
31
|
+
|
|
32
|
+
1. **Update package.json metadata**:
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"name": "@writechoice/mint-cli",
|
|
36
|
+
"version": "1.0.0",
|
|
37
|
+
"description": "CLI tool for Mintlify documentation validation and utilities",
|
|
38
|
+
"author": "Your Name <your.email@example.com>",
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "https://github.com/yourusername/writechoice-mint-cli.git"
|
|
43
|
+
},
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/yourusername/writechoice-mint-cli/issues"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://github.com/yourusername/writechoice-mint-cli#readme",
|
|
48
|
+
"keywords": [
|
|
49
|
+
"mintlify",
|
|
50
|
+
"documentation",
|
|
51
|
+
"validation",
|
|
52
|
+
"cli",
|
|
53
|
+
"mdx",
|
|
54
|
+
"links"
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
2. **Test the package locally**:
|
|
60
|
+
```bash
|
|
61
|
+
# Install dependencies
|
|
62
|
+
npm install
|
|
63
|
+
|
|
64
|
+
# Install Playwright browsers
|
|
65
|
+
npx playwright install chromium
|
|
66
|
+
|
|
67
|
+
# Test the CLI
|
|
68
|
+
node bin/cli.js check links --help
|
|
69
|
+
|
|
70
|
+
# Link globally for testing
|
|
71
|
+
npm link
|
|
72
|
+
writechoice check links --help
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
3. **Check what will be published**:
|
|
76
|
+
```bash
|
|
77
|
+
npm pack --dry-run
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
This shows which files will be included. Make sure:
|
|
81
|
+
- Source files are included (`src/`, `bin/`)
|
|
82
|
+
- Test files are excluded
|
|
83
|
+
- `node_modules/` is excluded (via `.gitignore`)
|
|
84
|
+
- `README.md`, `LICENSE`, and `package.json` are included
|
|
85
|
+
|
|
86
|
+
### Step 2: Publish to npm
|
|
87
|
+
|
|
88
|
+
1. **Publish as a public scoped package**:
|
|
89
|
+
```bash
|
|
90
|
+
npm publish --access public
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The `--access public` flag is required for scoped packages (@writechoice/...) the first time.
|
|
94
|
+
|
|
95
|
+
2. **Verify the publication**:
|
|
96
|
+
- Check on npm: https://www.npmjs.com/package/@writechoice/mint-cli
|
|
97
|
+
- Test installation:
|
|
98
|
+
```bash
|
|
99
|
+
npm install -g @writechoice/mint-cli
|
|
100
|
+
writechoice check links --help
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Publishing New Versions
|
|
104
|
+
|
|
105
|
+
### Semantic Versioning
|
|
106
|
+
|
|
107
|
+
Follow [Semantic Versioning](https://semver.org/) (SemVer):
|
|
108
|
+
- **MAJOR** version (1.0.0 → 2.0.0): Breaking changes
|
|
109
|
+
- **MINOR** version (1.0.0 → 1.1.0): New features, backwards compatible
|
|
110
|
+
- **PATCH** version (1.0.0 → 1.0.1): Bug fixes, backwards compatible
|
|
111
|
+
|
|
112
|
+
### Update Workflow
|
|
113
|
+
|
|
114
|
+
#### 1. Make Your Changes
|
|
115
|
+
```bash
|
|
116
|
+
# Create a feature branch
|
|
117
|
+
git checkout -b feature/new-validation-type
|
|
118
|
+
|
|
119
|
+
# Make your changes
|
|
120
|
+
# ... edit files ...
|
|
121
|
+
|
|
122
|
+
# Commit changes
|
|
123
|
+
git add .
|
|
124
|
+
git commit -m "Add new validation type for images"
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### 2. Update Version Number
|
|
128
|
+
|
|
129
|
+
Use npm's version command (automatically updates package.json and creates a git tag):
|
|
130
|
+
|
|
131
|
+
**For a patch (bug fixes):**
|
|
132
|
+
```bash
|
|
133
|
+
npm version patch
|
|
134
|
+
# 1.0.0 → 1.0.1
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**For a minor release (new features):**
|
|
138
|
+
```bash
|
|
139
|
+
npm version minor
|
|
140
|
+
# 1.0.0 → 1.1.0
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**For a major release (breaking changes):**
|
|
144
|
+
```bash
|
|
145
|
+
npm version major
|
|
146
|
+
# 1.0.0 → 2.0.0
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Or specify the exact version:
|
|
150
|
+
```bash
|
|
151
|
+
npm version 1.2.3
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
This command will:
|
|
155
|
+
1. Update `package.json` version
|
|
156
|
+
2. Create a git commit with the version change
|
|
157
|
+
3. Create a git tag (e.g., `v1.0.1`)
|
|
158
|
+
|
|
159
|
+
#### 3. Update Changelog (Optional but Recommended)
|
|
160
|
+
|
|
161
|
+
Create or update `CHANGELOG.md`:
|
|
162
|
+
```markdown
|
|
163
|
+
# Changelog
|
|
164
|
+
|
|
165
|
+
## [1.1.0] - 2024-01-20
|
|
166
|
+
|
|
167
|
+
### Added
|
|
168
|
+
- New image validation feature
|
|
169
|
+
- Support for SVG files
|
|
170
|
+
|
|
171
|
+
### Fixed
|
|
172
|
+
- Fixed anchor parsing for special characters
|
|
173
|
+
- Improved error messages for 404s
|
|
174
|
+
|
|
175
|
+
### Changed
|
|
176
|
+
- Updated default concurrency to 30
|
|
177
|
+
|
|
178
|
+
## [1.0.0] - 2024-01-15
|
|
179
|
+
|
|
180
|
+
### Initial Release
|
|
181
|
+
- Link validation for MDX files
|
|
182
|
+
- Auto-fix for incorrect anchors
|
|
183
|
+
- Browser automation with Playwright
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
#### 4. Test the New Version
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
# Link locally and test
|
|
190
|
+
npm link
|
|
191
|
+
writechoice check links docs.example.com -v
|
|
192
|
+
|
|
193
|
+
# Run any tests
|
|
194
|
+
npm test
|
|
195
|
+
|
|
196
|
+
# Test with dry-run on real documentation
|
|
197
|
+
writechoice check links docs.example.com --dry-run
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
#### 5. Push Changes and Tags
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
# Push commits
|
|
204
|
+
git push origin main
|
|
205
|
+
|
|
206
|
+
# Push tags
|
|
207
|
+
git push origin --tags
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
#### 6. Publish to npm
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
npm publish
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
No need for `--access public` after the first publication.
|
|
217
|
+
|
|
218
|
+
#### 7. Verify Publication
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
# Check the npm page
|
|
222
|
+
npm view @writechoice/mint-cli
|
|
223
|
+
|
|
224
|
+
# Test installation
|
|
225
|
+
npm install -g @writechoice/mint-cli@latest
|
|
226
|
+
writechoice --version
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Quick Reference
|
|
230
|
+
|
|
231
|
+
### Common npm Commands
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
# Check current version
|
|
235
|
+
npm version
|
|
236
|
+
|
|
237
|
+
# View package info
|
|
238
|
+
npm view @writechoice/mint-cli
|
|
239
|
+
|
|
240
|
+
# View all published versions
|
|
241
|
+
npm view @writechoice/mint-cli versions
|
|
242
|
+
|
|
243
|
+
# Unpublish a version (within 72 hours, use carefully!)
|
|
244
|
+
npm unpublish @writechoice/mint-cli@1.0.1
|
|
245
|
+
|
|
246
|
+
# Deprecate a version (recommended over unpublish)
|
|
247
|
+
npm deprecate @writechoice/mint-cli@1.0.0 "Please upgrade to 1.0.1 due to critical bug"
|
|
248
|
+
|
|
249
|
+
# Add a dist-tag (like 'beta', 'next')
|
|
250
|
+
npm dist-tag add @writechoice/mint-cli@1.1.0-beta.1 beta
|
|
251
|
+
|
|
252
|
+
# Publish a beta version
|
|
253
|
+
npm version 1.1.0-beta.1
|
|
254
|
+
npm publish --tag beta
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## Pre-release Versions
|
|
258
|
+
|
|
259
|
+
For testing before a stable release:
|
|
260
|
+
|
|
261
|
+
### 1. Create a Beta Version
|
|
262
|
+
```bash
|
|
263
|
+
# Update to beta version
|
|
264
|
+
npm version 1.1.0-beta.1
|
|
265
|
+
|
|
266
|
+
# Publish with beta tag
|
|
267
|
+
npm publish --tag beta
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### 2. Install Beta Version
|
|
271
|
+
```bash
|
|
272
|
+
# Install specific beta version
|
|
273
|
+
npm install -g @writechoice/mint-cli@1.1.0-beta.1
|
|
274
|
+
|
|
275
|
+
# Install latest beta
|
|
276
|
+
npm install -g @writechoice/mint-cli@beta
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### 3. Promote Beta to Stable
|
|
280
|
+
```bash
|
|
281
|
+
# Remove beta suffix
|
|
282
|
+
npm version 1.1.0
|
|
283
|
+
|
|
284
|
+
# Publish as latest
|
|
285
|
+
npm publish
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## Automation with GitHub Actions
|
|
289
|
+
|
|
290
|
+
Consider automating releases with GitHub Actions:
|
|
291
|
+
|
|
292
|
+
```yaml
|
|
293
|
+
# .github/workflows/publish.yml
|
|
294
|
+
name: Publish to npm
|
|
295
|
+
|
|
296
|
+
on:
|
|
297
|
+
release:
|
|
298
|
+
types: [created]
|
|
299
|
+
|
|
300
|
+
jobs:
|
|
301
|
+
publish:
|
|
302
|
+
runs-on: ubuntu-latest
|
|
303
|
+
steps:
|
|
304
|
+
- uses: actions/checkout@v3
|
|
305
|
+
|
|
306
|
+
- uses: actions/setup-node@v3
|
|
307
|
+
with:
|
|
308
|
+
node-version: '18'
|
|
309
|
+
registry-url: 'https://registry.npmjs.org'
|
|
310
|
+
|
|
311
|
+
- run: npm ci
|
|
312
|
+
|
|
313
|
+
- run: npm test
|
|
314
|
+
|
|
315
|
+
- run: npm publish --access public
|
|
316
|
+
env:
|
|
317
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
## Troubleshooting
|
|
321
|
+
|
|
322
|
+
### "You must be logged in to publish packages"
|
|
323
|
+
```bash
|
|
324
|
+
npm login
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### "You do not have permission to publish"
|
|
328
|
+
- Check if you own the `@writechoice` scope on npm
|
|
329
|
+
- Ask the scope owner to add you as a collaborator
|
|
330
|
+
|
|
331
|
+
### "Package name too similar to existing package"
|
|
332
|
+
- Choose a different name or scope
|
|
333
|
+
- Or request ownership of the abandoned package
|
|
334
|
+
|
|
335
|
+
### "Version already exists"
|
|
336
|
+
```bash
|
|
337
|
+
# Increment version again
|
|
338
|
+
npm version patch
|
|
339
|
+
|
|
340
|
+
# Or specify a new version
|
|
341
|
+
npm version 1.0.2
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
## Best Practices
|
|
345
|
+
|
|
346
|
+
1. **Always test before publishing**
|
|
347
|
+
- Link locally with `npm link`
|
|
348
|
+
- Test all CLI commands
|
|
349
|
+
- Check that files are correctly included with `npm pack --dry-run`
|
|
350
|
+
|
|
351
|
+
2. **Follow semantic versioning**
|
|
352
|
+
- Breaking changes = major version
|
|
353
|
+
- New features = minor version
|
|
354
|
+
- Bug fixes = patch version
|
|
355
|
+
|
|
356
|
+
3. **Maintain a changelog**
|
|
357
|
+
- Document all changes
|
|
358
|
+
- Make it easy for users to see what's new
|
|
359
|
+
|
|
360
|
+
4. **Use git tags**
|
|
361
|
+
- Tag each release with `v{version}` (e.g., `v1.0.0`)
|
|
362
|
+
- `npm version` does this automatically
|
|
363
|
+
|
|
364
|
+
5. **Test installations**
|
|
365
|
+
- Install the published package globally
|
|
366
|
+
- Verify it works as expected
|
|
367
|
+
|
|
368
|
+
6. **Consider using prerelease versions**
|
|
369
|
+
- Beta test with `1.0.0-beta.1` before stable release
|
|
370
|
+
- Use tags: `npm publish --tag beta`
|
|
371
|
+
|
|
372
|
+
7. **Document breaking changes**
|
|
373
|
+
- Clearly indicate breaking changes in changelog
|
|
374
|
+
- Consider migration guides for major versions
|
|
375
|
+
|
|
376
|
+
8. **Deprecate old versions**
|
|
377
|
+
- Use `npm deprecate` instead of unpublishing
|
|
378
|
+
- Provide upgrade instructions
|
|
379
|
+
|
|
380
|
+
## Useful Links
|
|
381
|
+
|
|
382
|
+
- [npm Documentation](https://docs.npmjs.com/)
|
|
383
|
+
- [Semantic Versioning](https://semver.org/)
|
|
384
|
+
- [npm version command](https://docs.npmjs.com/cli/v10/commands/npm-version)
|
|
385
|
+
- [npm publish command](https://docs.npmjs.com/cli/v10/commands/npm-publish)
|
|
386
|
+
- [Creating and publishing scoped packages](https://docs.npmjs.com/creating-and-publishing-scoped-public-packages)
|