omnikey-cli 1.0.4 → 1.0.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/dist/index.js CHANGED
@@ -5,6 +5,7 @@ const commander_1 = require("commander");
5
5
  const onboard_1 = require("./onboard");
6
6
  const daemon_1 = require("./daemon");
7
7
  const killDaemon_1 = require("./killDaemon");
8
+ const removeConfig_1 = require("./removeConfig");
8
9
  const program = new commander_1.Command();
9
10
  program
10
11
  .name('omnikey')
@@ -33,4 +34,10 @@ program
33
34
  const port = Number(options.port) || 7071;
34
35
  (0, killDaemon_1.killDaemon)(port);
35
36
  });
37
+ program
38
+ .command('remove-config')
39
+ .description('Remove the .omnikey config directory and the SQLite database from your home directory')
40
+ .action(() => {
41
+ (0, removeConfig_1.removeConfigAndDb)();
42
+ });
36
43
  program.parseAsync(process.argv);
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.removeConfigAndDb = removeConfigAndDb;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ /**
10
+ * Removes the ~/.omnikey config directory and the default SQLite database file in the user's home directory.
11
+ */
12
+ function removeConfigAndDb() {
13
+ const homeDir = process.env.HOME || process.env.USERPROFILE || '.';
14
+ const configDir = path_1.default.join(homeDir, '.omnikey');
15
+ const sqlitePath = path_1.default.join(homeDir, 'omnikey-selfhosted.sqlite');
16
+ // Remove .omnikey directory
17
+ if (fs_1.default.existsSync(configDir)) {
18
+ try {
19
+ fs_1.default.rmSync(configDir, { recursive: true, force: true });
20
+ console.log(`Removed config directory: ${configDir}`);
21
+ }
22
+ catch (e) {
23
+ console.error(`Failed to remove config directory: ${e}`);
24
+ }
25
+ }
26
+ else {
27
+ console.log(`Config directory does not exist: ${configDir}`);
28
+ }
29
+ // Remove SQLite database
30
+ if (fs_1.default.existsSync(sqlitePath)) {
31
+ try {
32
+ fs_1.default.rmSync(sqlitePath);
33
+ console.log(`Removed SQLite database: ${sqlitePath}`);
34
+ }
35
+ catch (e) {
36
+ console.error(`Failed to remove SQLite database: ${e}`);
37
+ }
38
+ }
39
+ else {
40
+ console.log(`SQLite database does not exist: ${sqlitePath}`);
41
+ }
42
+ }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public",
5
5
  "registry": "https://registry.npmjs.org/"
6
6
  },
7
- "version": "1.0.4",
7
+ "version": "1.0.5",
8
8
  "description": "CLI for onboarding users to Omnikey AI and configuring OPENAI_API_KEY. Use Yarn for install/build.",
9
9
  "engines": {
10
10
  "node": ">=14.0.0",
package/src/index.ts CHANGED
@@ -4,6 +4,7 @@ import { onboard } from './onboard';
4
4
 
5
5
  import { startDaemon } from './daemon';
6
6
  import { killDaemon } from './killDaemon';
7
+ import { removeConfigAndDb } from './removeConfig';
7
8
 
8
9
  const program = new Command();
9
10
 
@@ -38,4 +39,13 @@ program
38
39
  killDaemon(port);
39
40
  });
40
41
 
42
+ program
43
+ .command('remove-config')
44
+ .description(
45
+ 'Remove the .omnikey config directory and the SQLite database from your home directory',
46
+ )
47
+ .action(() => {
48
+ removeConfigAndDb();
49
+ });
50
+
41
51
  program.parseAsync(process.argv);
@@ -0,0 +1,35 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+
4
+ /**
5
+ * Removes the ~/.omnikey config directory and the default SQLite database file in the user's home directory.
6
+ */
7
+ export function removeConfigAndDb() {
8
+ const homeDir = process.env.HOME || process.env.USERPROFILE || '.';
9
+ const configDir = path.join(homeDir, '.omnikey');
10
+ const sqlitePath = path.join(homeDir, 'omnikey-selfhosted.sqlite');
11
+
12
+ // Remove .omnikey directory
13
+ if (fs.existsSync(configDir)) {
14
+ try {
15
+ fs.rmSync(configDir, { recursive: true, force: true });
16
+ console.log(`Removed config directory: ${configDir}`);
17
+ } catch (e) {
18
+ console.error(`Failed to remove config directory: ${e}`);
19
+ }
20
+ } else {
21
+ console.log(`Config directory does not exist: ${configDir}`);
22
+ }
23
+
24
+ // Remove SQLite database
25
+ if (fs.existsSync(sqlitePath)) {
26
+ try {
27
+ fs.rmSync(sqlitePath);
28
+ console.log(`Removed SQLite database: ${sqlitePath}`);
29
+ } catch (e) {
30
+ console.error(`Failed to remove SQLite database: ${e}`);
31
+ }
32
+ } else {
33
+ console.log(`SQLite database does not exist: ${sqlitePath}`);
34
+ }
35
+ }