@cmdctrl/cursor-cli 0.2.0 → 0.2.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AAmCA,wBAAsB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CA0D5C"}
|
package/dist/commands/update.js
CHANGED
|
@@ -4,6 +4,10 @@ exports.update = update;
|
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
const path_1 = require("path");
|
|
7
|
+
const daemon_sdk_1 = require("@cmdctrl/daemon-sdk");
|
|
8
|
+
const stop_1 = require("./stop");
|
|
9
|
+
const configManager = new daemon_sdk_1.ConfigManager('cursor-cli');
|
|
10
|
+
// Get the current version from package.json
|
|
7
11
|
function getCurrentVersion() {
|
|
8
12
|
try {
|
|
9
13
|
const pkg = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, '..', '..', 'package.json'), 'utf-8'));
|
|
@@ -19,6 +23,7 @@ function getCurrentVersion() {
|
|
|
19
23
|
}
|
|
20
24
|
}
|
|
21
25
|
}
|
|
26
|
+
// Fetch the latest version from npm registry
|
|
22
27
|
async function getLatestVersion(packageName) {
|
|
23
28
|
try {
|
|
24
29
|
const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`);
|
|
@@ -34,6 +39,7 @@ async function getLatestVersion(packageName) {
|
|
|
34
39
|
async function update() {
|
|
35
40
|
const packageName = '@cmdctrl/cursor-cli';
|
|
36
41
|
const currentVersion = getCurrentVersion();
|
|
42
|
+
const wasRunning = configManager.isDaemonRunning();
|
|
37
43
|
console.log(`Current version: ${currentVersion}`);
|
|
38
44
|
console.log(`Checking for updates...`);
|
|
39
45
|
const latestVersion = await getLatestVersion(packageName);
|
|
@@ -45,6 +51,13 @@ async function update() {
|
|
|
45
51
|
console.log(`Already up to date (v${currentVersion}).`);
|
|
46
52
|
return;
|
|
47
53
|
}
|
|
54
|
+
// Stop daemon before updating so the old process doesn't hold stale code
|
|
55
|
+
if (wasRunning) {
|
|
56
|
+
console.log('Stopping daemon before update...');
|
|
57
|
+
(0, stop_1.stop)();
|
|
58
|
+
// Wait for stop to complete (uses setTimeout internally)
|
|
59
|
+
await new Promise((resolve) => setTimeout(resolve, 3000));
|
|
60
|
+
}
|
|
48
61
|
console.log(`Updating ${packageName}: v${currentVersion} → v${latestVersion}`);
|
|
49
62
|
try {
|
|
50
63
|
(0, child_process_1.execSync)(`npm install -g ${packageName}@latest`, {
|
|
@@ -56,6 +69,7 @@ async function update() {
|
|
|
56
69
|
console.error(` sudo npm install -g ${packageName}@latest`);
|
|
57
70
|
process.exit(1);
|
|
58
71
|
}
|
|
72
|
+
// Verify the update
|
|
59
73
|
try {
|
|
60
74
|
const result = (0, child_process_1.execSync)(`cmdctrl-cursor-cli --version`, { encoding: 'utf-8' }).trim();
|
|
61
75
|
console.log(`\nUpdated successfully to v${result}`);
|
|
@@ -63,7 +77,15 @@ async function update() {
|
|
|
63
77
|
catch {
|
|
64
78
|
console.log(`\nUpdate installed. Run 'cmdctrl-cursor-cli --version' to verify.`);
|
|
65
79
|
}
|
|
66
|
-
|
|
67
|
-
|
|
80
|
+
// Restart daemon if it was running before update
|
|
81
|
+
if (wasRunning) {
|
|
82
|
+
console.log('Restarting daemon...');
|
|
83
|
+
const child = (0, child_process_1.spawn)('cmdctrl-cursor-cli', ['start'], {
|
|
84
|
+
detached: true,
|
|
85
|
+
stdio: 'ignore',
|
|
86
|
+
});
|
|
87
|
+
child.unref();
|
|
88
|
+
console.log('Daemon restarted.');
|
|
89
|
+
}
|
|
68
90
|
}
|
|
69
91
|
//# sourceMappingURL=update.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":";;AAmCA,wBA0DC;AA7FD,iDAAgD;AAChD,2BAAkC;AAClC,+BAA4B;AAC5B,oDAAoD;AACpD,iCAA8B;AAE9B,MAAM,aAAa,GAAG,IAAI,0BAAa,CAAC,YAAY,CAAC,CAAC;AAEtD,4CAA4C;AAC5C,SAAS,iBAAiB;IACxB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,iBAAY,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;QAC3F,OAAO,GAAG,CAAC,OAAO,CAAC;IACrB,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,iBAAY,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;YACrF,OAAO,GAAG,CAAC,OAAO,CAAC;QACrB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;AACH,CAAC;AAED,6CAA6C;AAC7C,KAAK,UAAU,gBAAgB,CAAC,WAAmB;IACjD,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,8BAA8B,WAAW,SAAS,CAAC,CAAC;QACjF,IAAI,CAAC,QAAQ,CAAC,EAAE;YAAE,OAAO,IAAI,CAAC;QAC9B,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAyB,CAAC;QAC1D,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IAC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;QAC7D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,oBAAoB;IACpB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAA,wBAAQ,EAAC,8BAA8B,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACtF,OAAO,CAAC,GAAG,CAAC,8BAA8B,MAAM,EAAE,CAAC,CAAC;IACtD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,GAAG,CAAC,mEAAmE,CAAC,CAAC;IACnF,CAAC;IAED,iDAAiD;IACjD,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;QACpC,MAAM,KAAK,GAAG,IAAA,qBAAK,EAAC,oBAAoB,EAAE,CAAC,OAAO,CAAC,EAAE;YACnD,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,QAAQ;SAChB,CAAC,CAAC;QACH,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACnC,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
package/src/commands/update.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { execSync } from 'child_process';
|
|
1
|
+
import { execSync, spawn } from 'child_process';
|
|
2
2
|
import { readFileSync } from 'fs';
|
|
3
3
|
import { join } from 'path';
|
|
4
|
+
import { ConfigManager } from '@cmdctrl/daemon-sdk';
|
|
5
|
+
import { stop } from './stop';
|
|
4
6
|
|
|
7
|
+
const configManager = new ConfigManager('cursor-cli');
|
|
8
|
+
|
|
9
|
+
// Get the current version from package.json
|
|
5
10
|
function getCurrentVersion(): string {
|
|
6
11
|
try {
|
|
7
12
|
const pkg = JSON.parse(readFileSync(join(__dirname, '..', '..', 'package.json'), 'utf-8'));
|
|
@@ -16,6 +21,7 @@ function getCurrentVersion(): string {
|
|
|
16
21
|
}
|
|
17
22
|
}
|
|
18
23
|
|
|
24
|
+
// Fetch the latest version from npm registry
|
|
19
25
|
async function getLatestVersion(packageName: string): Promise<string | null> {
|
|
20
26
|
try {
|
|
21
27
|
const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`);
|
|
@@ -30,6 +36,7 @@ async function getLatestVersion(packageName: string): Promise<string | null> {
|
|
|
30
36
|
export async function update(): Promise<void> {
|
|
31
37
|
const packageName = '@cmdctrl/cursor-cli';
|
|
32
38
|
const currentVersion = getCurrentVersion();
|
|
39
|
+
const wasRunning = configManager.isDaemonRunning();
|
|
33
40
|
|
|
34
41
|
console.log(`Current version: ${currentVersion}`);
|
|
35
42
|
console.log(`Checking for updates...`);
|
|
@@ -46,6 +53,14 @@ export async function update(): Promise<void> {
|
|
|
46
53
|
return;
|
|
47
54
|
}
|
|
48
55
|
|
|
56
|
+
// Stop daemon before updating so the old process doesn't hold stale code
|
|
57
|
+
if (wasRunning) {
|
|
58
|
+
console.log('Stopping daemon before update...');
|
|
59
|
+
stop();
|
|
60
|
+
// Wait for stop to complete (uses setTimeout internally)
|
|
61
|
+
await new Promise((resolve) => setTimeout(resolve, 3000));
|
|
62
|
+
}
|
|
63
|
+
|
|
49
64
|
console.log(`Updating ${packageName}: v${currentVersion} → v${latestVersion}`);
|
|
50
65
|
|
|
51
66
|
try {
|
|
@@ -58,6 +73,7 @@ export async function update(): Promise<void> {
|
|
|
58
73
|
process.exit(1);
|
|
59
74
|
}
|
|
60
75
|
|
|
76
|
+
// Verify the update
|
|
61
77
|
try {
|
|
62
78
|
const result = execSync(`cmdctrl-cursor-cli --version`, { encoding: 'utf-8' }).trim();
|
|
63
79
|
console.log(`\nUpdated successfully to v${result}`);
|
|
@@ -65,6 +81,14 @@ export async function update(): Promise<void> {
|
|
|
65
81
|
console.log(`\nUpdate installed. Run 'cmdctrl-cursor-cli --version' to verify.`);
|
|
66
82
|
}
|
|
67
83
|
|
|
68
|
-
|
|
69
|
-
|
|
84
|
+
// Restart daemon if it was running before update
|
|
85
|
+
if (wasRunning) {
|
|
86
|
+
console.log('Restarting daemon...');
|
|
87
|
+
const child = spawn('cmdctrl-cursor-cli', ['start'], {
|
|
88
|
+
detached: true,
|
|
89
|
+
stdio: 'ignore',
|
|
90
|
+
});
|
|
91
|
+
child.unref();
|
|
92
|
+
console.log('Daemon restarted.');
|
|
93
|
+
}
|
|
70
94
|
}
|