@writechoice/mint-cli 0.0.2 → 0.0.4

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.
Files changed (3) hide show
  1. package/README.md +41 -0
  2. package/bin/cli.js +61 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -40,6 +40,26 @@ npm link
40
40
 
41
41
  ## Usage
42
42
 
43
+ ### Check Version
44
+
45
+ Check the installed version:
46
+
47
+ ```bash
48
+ writechoice --version
49
+ # or
50
+ writechoice -V
51
+ ```
52
+
53
+ ### Update to Latest Version
54
+
55
+ Update to the latest version from npm:
56
+
57
+ ```bash
58
+ writechoice update
59
+ ```
60
+
61
+ The CLI also automatically checks for updates and displays a notification when a new version is available.
62
+
43
63
  ### Validate Links
44
64
 
45
65
  Validate all internal links and anchors in your MDX documentation:
@@ -213,6 +233,27 @@ writechoice check links docs.example.com -o my_report.json
213
233
  writechoice check links docs.example.com --fix-from-report my_report.json
214
234
  ```
215
235
 
236
+ ## Updates
237
+
238
+ The CLI automatically checks for new versions and displays a notification when an update is available:
239
+
240
+ ```
241
+ ┌─────────────────────────────────────────────────┐
242
+ │ Update available: 0.0.2 → 0.0.3 │
243
+ │ Run: writechoice update │
244
+ └─────────────────────────────────────────────────┘
245
+ ```
246
+
247
+ To update manually:
248
+
249
+ ```bash
250
+ # Using the built-in update command (recommended)
251
+ writechoice update
252
+
253
+ # Or using npm directly
254
+ npm install -g @writechoice/mint-cli@latest
255
+ ```
256
+
216
257
  ## Configuration
217
258
 
218
259
  ### Excluded Directories
package/bin/cli.js CHANGED
@@ -4,6 +4,7 @@ import { Command } from "commander";
4
4
  import { fileURLToPath } from "url";
5
5
  import { dirname, join } from "path";
6
6
  import { readFileSync } from "fs";
7
+ import { execSync } from "child_process";
7
8
 
8
9
  const __filename = fileURLToPath(import.meta.url);
9
10
  const __dirname = dirname(__filename);
@@ -16,7 +17,7 @@ const program = new Command();
16
17
  program
17
18
  .name("writechoice")
18
19
  .description("CLI tool for Mintlify documentation validation and utilities")
19
- .version(packageJson.version);
20
+ .version(packageJson.version, "-v, --version", "Output the current version");
20
21
 
21
22
  // Validate command
22
23
  const check = program.command("check").description("Validation commands for documentation");
@@ -41,4 +42,63 @@ check
41
42
  await validateLinks(baseUrl, options);
42
43
  });
43
44
 
45
+ // Update command
46
+ program
47
+ .command("update")
48
+ .description("Update @writechoice/mint-cli to the latest version")
49
+ .action(async () => {
50
+ console.log("Checking for updates...");
51
+
52
+ try {
53
+ // Get latest version from npm
54
+ const latestVersion = execSync(`npm view ${packageJson.name} version`, { encoding: "utf-8" }).trim();
55
+
56
+ const currentVersion = packageJson.version;
57
+
58
+ if (latestVersion === currentVersion) {
59
+ console.log(`✓ You're already on the latest version (${currentVersion})`);
60
+ return;
61
+ }
62
+
63
+ console.log(`\nUpdate available: ${currentVersion} → ${latestVersion}`);
64
+ console.log(`\nUpdating ${packageJson.name}...`);
65
+
66
+ // Update the package
67
+ execSync(`npm install -g ${packageJson.name}@latest`, {
68
+ stdio: "inherit",
69
+ });
70
+
71
+ console.log(`\n✓ Successfully updated to version ${latestVersion}`);
72
+ } catch (error) {
73
+ console.error("Error checking for updates:", error.message);
74
+ console.log("\nYou can manually update with:");
75
+ console.log(` npm install -g ${packageJson.name}@latest`);
76
+ process.exit(1);
77
+ }
78
+ });
79
+
80
+ // Check for updates on every command (non-blocking)
81
+ async function checkForUpdates() {
82
+ try {
83
+ const latestVersion = execSync(`npm view ${packageJson.name} version 2>/dev/null`, {
84
+ encoding: "utf-8",
85
+ timeout: 2000,
86
+ }).trim();
87
+
88
+ const currentVersion = packageJson.version;
89
+
90
+ if (latestVersion && latestVersion !== currentVersion) {
91
+ console.log(`\n┌─────────────────────────────────────────────────┐`);
92
+ console.log(`│ Update available: ${currentVersion} → ${latestVersion.padEnd(24)} │`);
93
+ console.log(`│ Run: writechoice update │`);
94
+ console.log(`└─────────────────────────────────────────────────┘\n`);
95
+ }
96
+ } catch (error) {
97
+ // Silently fail - don't interrupt the user
98
+ }
99
+ }
100
+
101
+ // Run update check in background (don't block execution)
102
+ checkForUpdates();
103
+
44
104
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@writechoice/mint-cli",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "CLI tool for Mintlify documentation validation and utilities",
5
5
  "main": "src/index.js",
6
6
  "type": "module",