codekin 0.3.3 → 0.3.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/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'
@@ -214,6 +216,9 @@ const LAUNCHD_PLIST = join(homedir(), 'Library', 'LaunchAgents', `${LAUNCHD_LABE
214
216
  function buildPlist() {
215
217
  const { script, runner } = findServerScript()
216
218
  const envVars = readEnvFile()
219
+ // Inject PATH and HOME so launchd service can find gh, node, etc.
220
+ if (!envVars.PATH && process.env.PATH) envVars.PATH = process.env.PATH
221
+ if (!envVars.HOME) envVars.HOME = homedir()
217
222
  const envEntries = Object.entries(envVars)
218
223
  .map(([k, v]) => `\t\t<key>${k}</key>\n\t\t<string>${v}</string>`)
219
224
  .join('\n')
@@ -372,6 +377,45 @@ function serviceDispatch(action) {
372
377
  }
373
378
  }
374
379
 
380
+ // ---------------------------------------------------------------------------
381
+ // Uninstall
382
+ // ---------------------------------------------------------------------------
383
+
384
+ async function cmdUninstall() {
385
+ const answer = await prompt('This will remove Codekin entirely (service, config, npm package). Continue? [y/N] ')
386
+ if (answer.toLowerCase() !== 'y') {
387
+ console.log('Aborted.')
388
+ return
389
+ }
390
+
391
+ // 1. Stop and remove background service
392
+ console.log('\nRemoving background service...')
393
+ try {
394
+ serviceDispatch('uninstall')
395
+ } catch {
396
+ // Service may not be installed — that's fine
397
+ }
398
+
399
+ // 2. Remove config directories
400
+ const configDir = CONFIG_DIR
401
+ const codekinDir = join(homedir(), '.codekin')
402
+
403
+ if (existsSync(configDir)) {
404
+ rmSync(configDir, { recursive: true, force: true })
405
+ console.log(`Removed ${configDir}`)
406
+ }
407
+ if (existsSync(codekinDir)) {
408
+ rmSync(codekinDir, { recursive: true, force: true })
409
+ console.log(`Removed ${codekinDir}`)
410
+ }
411
+
412
+ // 3. Uninstall npm package
413
+ console.log('\nUninstalling codekin npm package...')
414
+ spawnSync('npm', ['uninstall', '-g', 'codekin'], { stdio: 'inherit' })
415
+
416
+ console.log('\nCodekin has been completely removed.')
417
+ }
418
+
375
419
  // ---------------------------------------------------------------------------
376
420
  // Entry point
377
421
  // ---------------------------------------------------------------------------
@@ -383,8 +427,12 @@ if (cmd === 'start') {
383
427
  cmdStart()
384
428
  } else if (cmd === 'setup') {
385
429
  await cmdSetup({ regenerate: args.includes('--regenerate') })
430
+ } else if (cmd === 'config') {
431
+ await cmdSetup()
386
432
  } else if (cmd === 'token') {
387
433
  cmdToken()
434
+ } else if (cmd === 'uninstall') {
435
+ await cmdUninstall()
388
436
  } else if (cmd === 'service') {
389
437
  const action = args[1]
390
438
  if (!['install', 'uninstall', 'status'].includes(action)) {
@@ -399,9 +447,11 @@ Usage:
399
447
  codekin start Run server in foreground
400
448
  codekin setup First-time setup wizard
401
449
  codekin setup --regenerate Regenerate auth token
450
+ codekin config Update API keys and settings
402
451
  codekin service install Install + start background service
403
452
  codekin service uninstall Remove background service
404
453
  codekin service status Show service status
405
454
  codekin token Print access URL with auth token
455
+ codekin uninstall Remove Codekin entirely
406
456
  `)
407
457
  }