worclaude 1.2.3 → 1.2.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "worclaude",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "description": "CLI tool that scaffolds a comprehensive Claude Code workflow into any project",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,4 +1,5 @@
1
1
  import path from 'node:path';
2
+ import { execSync } from 'node:child_process';
2
3
  import inquirer from 'inquirer';
3
4
  import ora from 'ora';
4
5
  import {
@@ -15,10 +16,62 @@ import { hashFile } from '../utils/hash.js';
15
16
  import { writeFile, fileExists, listFilesRecursive } from '../utils/file.js';
16
17
  import * as display from '../utils/display.js';
17
18
 
19
+ async function getLatestNpmVersion() {
20
+ try {
21
+ return execSync('npm view worclaude version', { encoding: 'utf-8' }).trim();
22
+ } catch {
23
+ return null;
24
+ }
25
+ }
26
+
27
+ async function selfUpdate(latestVersion) {
28
+ const spinner = ora(`Updating worclaude to v${latestVersion}...`).start();
29
+ try {
30
+ execSync('npm install -g worclaude@latest', { encoding: 'utf-8', stdio: 'pipe' });
31
+ spinner.succeed(`worclaude updated to v${latestVersion}.`);
32
+ return true;
33
+ } catch (err) {
34
+ spinner.fail('Self-update failed.');
35
+ display.error(err.message);
36
+ display.info('Try manually: npm install -g worclaude@latest');
37
+ return false;
38
+ }
39
+ }
40
+
18
41
  export async function upgradeCommand() {
19
42
  const projectRoot = process.cwd();
20
43
 
21
- // 1. Check prerequisite
44
+ // 1. Check for CLI self-update from npm
45
+ const cliVersion = await getPackageVersion();
46
+ const latestVersion = await getLatestNpmVersion();
47
+
48
+ if (latestVersion && latestVersion !== cliVersion) {
49
+ display.newline();
50
+ display.info(
51
+ `New worclaude version available: ${display.dimColor(`v${cliVersion}`)} → ${display.green(`v${latestVersion}`)}`
52
+ );
53
+ const { doUpdate } = await inquirer.prompt([
54
+ {
55
+ type: 'list',
56
+ name: 'doUpdate',
57
+ message: 'Update worclaude CLI?',
58
+ choices: [
59
+ { name: 'Yes, update and continue', value: true },
60
+ { name: 'No, continue with current version', value: false },
61
+ ],
62
+ },
63
+ ]);
64
+
65
+ if (doUpdate) {
66
+ const updated = await selfUpdate(latestVersion);
67
+ if (updated) {
68
+ display.info('Re-run `worclaude upgrade` to apply the new workflow files.');
69
+ return;
70
+ }
71
+ }
72
+ }
73
+
74
+ // 2. Check prerequisite
22
75
  if (!(await workflowMetaExists(projectRoot))) {
23
76
  display.error('No workflow installation found.');
24
77
  display.info('Run `worclaude init` to set up the workflow first.');
@@ -32,7 +85,7 @@ export async function upgradeCommand() {
32
85
  return;
33
86
  }
34
87
 
35
- // 2. Version comparison
88
+ // 3. Version comparison
36
89
  const currentVersion = await getPackageVersion();
37
90
  const installedVersion = meta.version;
38
91
 
@@ -41,10 +94,10 @@ export async function upgradeCommand() {
41
94
  return;
42
95
  }
43
96
 
44
- // 3. Categorize files
97
+ // 4. Categorize files
45
98
  const categories = await categorizeFiles(projectRoot, meta);
46
99
 
47
- // 4. Preview
100
+ // 5. Preview
48
101
  display.sectionHeader(`WORCLAUDE UPGRADE (v${installedVersion} → v${currentVersion})`);
49
102
  display.newline();
50
103
 
@@ -105,7 +158,7 @@ export async function upgradeCommand() {
105
158
  display.newline();
106
159
  }
107
160
 
108
- // 5. Confirm
161
+ // 6. Confirm
109
162
  const { proceed } = await inquirer.prompt([
110
163
  {
111
164
  type: 'list',
@@ -123,7 +176,7 @@ export async function upgradeCommand() {
123
176
  return;
124
177
  }
125
178
 
126
- // 6. Execute
179
+ // 7. Execute
127
180
  const spinner = ora('Upgrading...').start();
128
181
 
129
182
  try {
@@ -180,7 +233,7 @@ export async function upgradeCommand() {
180
233
 
181
234
  spinner.succeed(`Upgrade complete! (${installedVersion} → ${currentVersion})`);
182
235
 
183
- // 7. Display report
236
+ // 8. Display report
184
237
  display.newline();
185
238
  if (categories.autoUpdate.length > 0) {
186
239
  display.barLine(`Updated: ${categories.autoUpdate.length} files`);