codekin 0.3.3 → 0.3.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.
package/README.md CHANGED
@@ -31,11 +31,13 @@ Open the printed URL in your browser, enter your Codekin Web token when prompted
31
31
 
32
32
  ```bash
33
33
  codekin token # Print your access URL at any time
34
+ codekin config # Update API keys and settings
34
35
  codekin service status # Check whether the service is running
35
36
  codekin service install # (Re-)install the background service
36
37
  codekin service uninstall # Remove the background service
37
38
  codekin start # Run in foreground (for debugging)
38
39
  codekin setup --regenerate # Generate a new auth token
40
+ codekin uninstall # Remove Codekin entirely
39
41
  ```
40
42
 
41
43
  ## Features
@@ -64,11 +66,11 @@ codekin service install
64
66
  ## Uninstall
65
67
 
66
68
  ```bash
67
- codekin service uninstall
68
- npm uninstall -g codekin
69
- rm -rf ~/.config/codekin ~/.codekin
69
+ codekin uninstall
70
70
  ```
71
71
 
72
+ This removes the background service, config files, and the npm package.
73
+
72
74
  ## Configuration
73
75
 
74
76
  All configuration lives in `~/.config/codekin/env`. Edit this file to override defaults, then restart the service with `codekin service install`.
package/bin/codekin.mjs CHANGED
@@ -8,11 +8,13 @@
8
8
  * codekin service install Install + start background service
9
9
  * codekin service uninstall Remove background service
10
10
  * codekin service status Show service status
11
+ * codekin config Update API keys and settings
11
12
  * codekin token Print access URL with auth token
13
+ * codekin uninstall Remove Codekin entirely
12
14
  */
13
15
 
14
16
  import { execSync, execFileSync, spawnSync } from 'child_process'
15
- import { existsSync, mkdirSync, readFileSync, writeFileSync, chmodSync, createReadStream } from 'fs'
17
+ import { existsSync, mkdirSync, readFileSync, writeFileSync, chmodSync, createReadStream, rmSync } from 'fs'
16
18
  import { homedir, platform } from 'os'
17
19
  import { join, dirname } from 'path'
18
20
  import { fileURLToPath } from 'url'
@@ -372,6 +374,45 @@ function serviceDispatch(action) {
372
374
  }
373
375
  }
374
376
 
377
+ // ---------------------------------------------------------------------------
378
+ // Uninstall
379
+ // ---------------------------------------------------------------------------
380
+
381
+ async function cmdUninstall() {
382
+ const answer = await prompt('This will remove Codekin entirely (service, config, npm package). Continue? [y/N] ')
383
+ if (answer.toLowerCase() !== 'y') {
384
+ console.log('Aborted.')
385
+ return
386
+ }
387
+
388
+ // 1. Stop and remove background service
389
+ console.log('\nRemoving background service...')
390
+ try {
391
+ serviceDispatch('uninstall')
392
+ } catch {
393
+ // Service may not be installed — that's fine
394
+ }
395
+
396
+ // 2. Remove config directories
397
+ const configDir = CONFIG_DIR
398
+ const codekinDir = join(homedir(), '.codekin')
399
+
400
+ if (existsSync(configDir)) {
401
+ rmSync(configDir, { recursive: true, force: true })
402
+ console.log(`Removed ${configDir}`)
403
+ }
404
+ if (existsSync(codekinDir)) {
405
+ rmSync(codekinDir, { recursive: true, force: true })
406
+ console.log(`Removed ${codekinDir}`)
407
+ }
408
+
409
+ // 3. Uninstall npm package
410
+ console.log('\nUninstalling codekin npm package...')
411
+ spawnSync('npm', ['uninstall', '-g', 'codekin'], { stdio: 'inherit' })
412
+
413
+ console.log('\nCodekin has been completely removed.')
414
+ }
415
+
375
416
  // ---------------------------------------------------------------------------
376
417
  // Entry point
377
418
  // ---------------------------------------------------------------------------
@@ -383,8 +424,12 @@ if (cmd === 'start') {
383
424
  cmdStart()
384
425
  } else if (cmd === 'setup') {
385
426
  await cmdSetup({ regenerate: args.includes('--regenerate') })
427
+ } else if (cmd === 'config') {
428
+ await cmdSetup()
386
429
  } else if (cmd === 'token') {
387
430
  cmdToken()
431
+ } else if (cmd === 'uninstall') {
432
+ await cmdUninstall()
388
433
  } else if (cmd === 'service') {
389
434
  const action = args[1]
390
435
  if (!['install', 'uninstall', 'status'].includes(action)) {
@@ -399,9 +444,11 @@ Usage:
399
444
  codekin start Run server in foreground
400
445
  codekin setup First-time setup wizard
401
446
  codekin setup --regenerate Regenerate auth token
447
+ codekin config Update API keys and settings
402
448
  codekin service install Install + start background service
403
449
  codekin service uninstall Remove background service
404
450
  codekin service status Show service status
405
451
  codekin token Print access URL with auth token
452
+ codekin uninstall Remove Codekin entirely
406
453
  `)
407
454
  }