@myrialabs/clopen 0.1.6 → 0.1.8

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/README.md CHANGED
@@ -38,11 +38,17 @@ bun add -g @myrialabs/clopen
38
38
 
39
39
  ### Update
40
40
 
41
+ ```bash
42
+ clopen update
43
+ ```
44
+
45
+ Or manually via Bun:
46
+
41
47
  ```bash
42
48
  bun add -g @myrialabs/clopen
43
49
  ```
44
50
 
45
- Same command as installation Bun will update to the latest version.
51
+ You can also update from the **Settings > General > Updates** section in the web UI.
46
52
 
47
53
  ### Usage
48
54
 
@@ -283,6 +283,7 @@ export class GitService {
283
283
 
284
284
  const args = [
285
285
  'log',
286
+ '--topo-order',
286
287
  `--format=${format}`,
287
288
  `--max-count=${limit + 1}`, // +1 to check if there are more
288
289
  `--skip=${skip}`
package/bin/clopen.ts CHANGED
@@ -30,6 +30,7 @@ interface CLIOptions {
30
30
  host?: string;
31
31
  help?: boolean;
32
32
  version?: boolean;
33
+ update?: boolean;
33
34
  }
34
35
 
35
36
  // Get version from package.json
@@ -90,6 +91,10 @@ Clopen - Modern web UI for Claude Code
90
91
 
91
92
  USAGE:
92
93
  clopen [OPTIONS]
94
+ clopen update
95
+
96
+ COMMANDS:
97
+ update Update clopen to the latest version
93
98
 
94
99
  OPTIONS:
95
100
  -p, --port <number> Port to run the server on (default: ${DEFAULT_PORT})
@@ -101,6 +106,7 @@ EXAMPLES:
101
106
  clopen # Start with default settings (port ${DEFAULT_PORT})
102
107
  clopen --port 9150 # Start on port 9150
103
108
  clopen --host 0.0.0.0 # Bind to all network interfaces
109
+ clopen update # Update to the latest version
104
110
  clopen --version # Show version
105
111
 
106
112
  For more information, visit: https://github.com/myrialabs/clopen
@@ -157,6 +163,10 @@ function parseArguments(): CLIOptions {
157
163
  break;
158
164
  }
159
165
 
166
+ case 'update':
167
+ options.update = true;
168
+ break;
169
+
160
170
  default:
161
171
  console.error(`❌ Error: Unknown option "${arg}"`);
162
172
  console.log('Run "clopen --help" for usage information');
@@ -167,6 +177,79 @@ function parseArguments(): CLIOptions {
167
177
  return options;
168
178
  }
169
179
 
180
+ /** Simple semver comparison: returns true if latest > current */
181
+ function isNewerVersion(current: string, latest: string): boolean {
182
+ const currentParts = current.split('.').map(Number);
183
+ const latestParts = latest.split('.').map(Number);
184
+
185
+ for (let i = 0; i < 3; i++) {
186
+ const c = currentParts[i] || 0;
187
+ const l = latestParts[i] || 0;
188
+ if (l > c) return true;
189
+ if (l < c) return false;
190
+ }
191
+ return false;
192
+ }
193
+
194
+ async function runUpdate() {
195
+ const currentVersion = getVersion();
196
+ console.log(`\x1b[36mClopen\x1b[0m v${currentVersion}\n`);
197
+
198
+ // Check for latest version
199
+ updateLoading('Checking for updates...');
200
+
201
+ let latestVersion: string;
202
+ try {
203
+ const response = await fetch('https://registry.npmjs.org/@myrialabs/clopen/latest');
204
+ if (!response.ok) {
205
+ stopLoading();
206
+ console.error(`❌ Failed to check for updates (HTTP ${response.status})`);
207
+ process.exit(1);
208
+ }
209
+ const data = await response.json() as { version: string };
210
+ latestVersion = data.version;
211
+ } catch (err) {
212
+ stopLoading();
213
+ console.error('❌ Failed to reach npm registry:', err instanceof Error ? err.message : err);
214
+ process.exit(1);
215
+ }
216
+
217
+ stopLoading();
218
+
219
+ if (!isNewerVersion(currentVersion, latestVersion)) {
220
+ console.log(`✓ Already up to date (v${currentVersion})`);
221
+ process.exit(0);
222
+ }
223
+
224
+ console.log(` New version available: v${currentVersion} → \x1b[32mv${latestVersion}\x1b[0m\n`);
225
+
226
+ // Run update
227
+ updateLoading(`Updating to v${latestVersion}...`);
228
+
229
+ const proc = Bun.spawn(['bun', 'add', '-g', '@myrialabs/clopen@latest'], {
230
+ stdout: 'pipe',
231
+ stderr: 'pipe'
232
+ });
233
+
234
+ const [stdout, stderr] = await Promise.all([
235
+ new Response(proc.stdout).text(),
236
+ new Response(proc.stderr).text()
237
+ ]);
238
+
239
+ const exitCode = await proc.exited;
240
+ stopLoading();
241
+
242
+ if (exitCode !== 0) {
243
+ const output = (stdout + '\n' + stderr).trim();
244
+ console.error('❌ Update failed:');
245
+ console.error(output);
246
+ process.exit(exitCode);
247
+ }
248
+
249
+ console.log(`✓ Updated to v${latestVersion}`);
250
+ console.log('\n Restart clopen to apply the update.');
251
+ }
252
+
170
253
  async function setupEnvironment() {
171
254
  // Check if .env exists, if not copy from .env.example
172
255
  if (!existsSync(ENV_FILE)) {
@@ -295,6 +378,12 @@ async function main() {
295
378
  process.exit(0);
296
379
  }
297
380
 
381
+ // Run update if requested
382
+ if (options.update) {
383
+ await runUpdate();
384
+ process.exit(0);
385
+ }
386
+
298
387
  // 1. Setup environment variables
299
388
  await setupEnvironment();
300
389