@cmdctrl/cursor-ide 0.1.2 → 0.1.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unregister.d.ts","sourceRoot":"","sources":["../../src/commands/unregister.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"unregister.d.ts","sourceRoot":"","sources":["../../src/commands/unregister.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAsChD"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.unregister = unregister;
|
|
4
4
|
const config_1 = require("../config/config");
|
|
5
5
|
/**
|
|
6
|
-
* Unregister command -
|
|
6
|
+
* Unregister command - deletes device from server and removes local registration data
|
|
7
7
|
*/
|
|
8
8
|
async function unregister() {
|
|
9
9
|
if (!(0, config_1.isRegistered)()) {
|
|
@@ -12,6 +12,32 @@ async function unregister() {
|
|
|
12
12
|
}
|
|
13
13
|
const config = (0, config_1.readConfig)();
|
|
14
14
|
console.log(`Unregistering "${config?.deviceName}" (${config?.deviceId})...`);
|
|
15
|
+
// Delete device from server
|
|
16
|
+
if (config) {
|
|
17
|
+
const credentials = (0, config_1.readCredentials)();
|
|
18
|
+
if (credentials) {
|
|
19
|
+
try {
|
|
20
|
+
const response = await fetch(`${config.serverUrl}/api/devices/${config.deviceId}`, {
|
|
21
|
+
method: 'DELETE',
|
|
22
|
+
headers: {
|
|
23
|
+
'Authorization': `Bearer ${credentials.refreshToken}`,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
if (response.ok || response.status === 204) {
|
|
27
|
+
console.log('Device removed from server.');
|
|
28
|
+
}
|
|
29
|
+
else if (response.status === 404) {
|
|
30
|
+
console.log('Device was already removed from server.');
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
console.warn(`Warning: Failed to remove device from server (HTTP ${response.status}).`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
console.warn('Warning: Could not reach server to remove device.');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
15
41
|
(0, config_1.deleteCredentials)();
|
|
16
42
|
(0, config_1.deleteConfig)();
|
|
17
43
|
console.log('Device unregistered. Run "cmdctrl-cursor-ide register" to register again.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unregister.js","sourceRoot":"","sources":["../../src/commands/unregister.ts"],"names":[],"mappings":";;AAKA,
|
|
1
|
+
{"version":3,"file":"unregister.js","sourceRoot":"","sources":["../../src/commands/unregister.ts"],"names":[],"mappings":";;AAKA,gCAsCC;AA3CD,6CAA8G;AAE9G;;GAEG;AACI,KAAK,UAAU,UAAU;IAC9B,IAAI,CAAC,IAAA,qBAAY,GAAE,EAAE,CAAC;QACpB,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC/B,OAAO;IACT,CAAC;IAED,MAAM,MAAM,GAAG,IAAA,mBAAU,GAAE,CAAC;IAC5B,OAAO,CAAC,GAAG,CAAC,kBAAkB,MAAM,EAAE,UAAU,MAAM,MAAM,EAAE,QAAQ,MAAM,CAAC,CAAC;IAE9E,4BAA4B;IAC5B,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,WAAW,GAAG,IAAA,wBAAe,GAAE,CAAC;QACtC,IAAI,WAAW,EAAE,CAAC;YAChB,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,MAAM,CAAC,SAAS,gBAAgB,MAAM,CAAC,QAAQ,EAAE,EAAE;oBACjF,MAAM,EAAE,QAAQ;oBAChB,OAAO,EAAE;wBACP,eAAe,EAAE,UAAU,WAAW,CAAC,YAAY,EAAE;qBACtD;iBACF,CAAC,CAAC;gBAEH,IAAI,QAAQ,CAAC,EAAE,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;oBAC3C,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;gBAC7C,CAAC;qBAAM,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;oBACnC,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;gBACzD,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,IAAI,CAAC,sDAAsD,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAC;gBAC1F,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,CAAC,IAAI,CAAC,mDAAmD,CAAC,CAAC;YACpE,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAA,0BAAiB,GAAE,CAAC;IACpB,IAAA,qBAAY,GAAE,CAAC;IAEf,OAAO,CAAC,GAAG,CAAC,2EAA2E,CAAC,CAAC;AAC3F,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { readConfig, deleteConfig, deleteCredentials, isRegistered } from '../config/config';
|
|
1
|
+
import { readConfig, readCredentials, deleteConfig, deleteCredentials, isRegistered } from '../config/config';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Unregister command -
|
|
4
|
+
* Unregister command - deletes device from server and removes local registration data
|
|
5
5
|
*/
|
|
6
6
|
export async function unregister(): Promise<void> {
|
|
7
7
|
if (!isRegistered()) {
|
|
@@ -12,6 +12,31 @@ export async function unregister(): Promise<void> {
|
|
|
12
12
|
const config = readConfig();
|
|
13
13
|
console.log(`Unregistering "${config?.deviceName}" (${config?.deviceId})...`);
|
|
14
14
|
|
|
15
|
+
// Delete device from server
|
|
16
|
+
if (config) {
|
|
17
|
+
const credentials = readCredentials();
|
|
18
|
+
if (credentials) {
|
|
19
|
+
try {
|
|
20
|
+
const response = await fetch(`${config.serverUrl}/api/devices/${config.deviceId}`, {
|
|
21
|
+
method: 'DELETE',
|
|
22
|
+
headers: {
|
|
23
|
+
'Authorization': `Bearer ${credentials.refreshToken}`,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
if (response.ok || response.status === 204) {
|
|
28
|
+
console.log('Device removed from server.');
|
|
29
|
+
} else if (response.status === 404) {
|
|
30
|
+
console.log('Device was already removed from server.');
|
|
31
|
+
} else {
|
|
32
|
+
console.warn(`Warning: Failed to remove device from server (HTTP ${response.status}).`);
|
|
33
|
+
}
|
|
34
|
+
} catch {
|
|
35
|
+
console.warn('Warning: Could not reach server to remove device.');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
15
40
|
deleteCredentials();
|
|
16
41
|
deleteConfig();
|
|
17
42
|
|