portkeeper 1.1.5 → 1.1.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "portkeeper",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "A comprehensive port management tool for developers with CLI and GUI interfaces",
5
5
  "main": "dist/cli/index.js",
6
6
  "type": "module",
@@ -24,7 +24,7 @@
24
24
  "build": "npm run build:cli && npm run build:gui",
25
25
  "build:npm": "npm run build:cli && npm run build:gui",
26
26
  "prepublishOnly": "npm run build:npm",
27
- "postinstall": "node scripts/postinstall-simple.js",
27
+ "postinstall": "node scripts/postinstall.cjs",
28
28
  "fix:electron": "npm rebuild better-sqlite3 --runtime=electron --target=28.0.0 --dist-url=https://electronjs.org/headers --abi=119",
29
29
  "fix:node": "npm rebuild better-sqlite3",
30
30
  "build:cli": "tsc -p tsconfig.cli.json",
@@ -1,11 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { execSync } from 'child_process';
4
- import { existsSync } from 'fs';
5
- import { join } from 'path';
6
- import chalk from 'chalk';
3
+ const { execSync } = require('child_process');
4
+ const { existsSync } = require('fs');
5
+ const { join } = require('path');
7
6
 
8
- export function ensureElectron() {
7
+ function ensureElectron() {
9
8
  // Check if Electron is installed
10
9
  const electronPaths = [
11
10
  './node_modules/electron',
@@ -17,8 +16,8 @@ export function ensureElectron() {
17
16
  const hasElectron = electronPaths.some(path => existsSync(path));
18
17
 
19
18
  if (!hasElectron) {
20
- console.log(chalk.yellow('\n📦 Electron is not installed. Installing now...'));
21
- console.log(chalk.gray('This is a one-time setup (~100MB download)\n'));
19
+ console.log('\n📦 Electron is not installed. Installing now...');
20
+ console.log('This is a one-time setup (~100MB download)\n');
22
21
 
23
22
  try {
24
23
  // Install electron as an optional dependency
@@ -28,18 +27,18 @@ export function ensureElectron() {
28
27
  });
29
28
 
30
29
  // Rebuild native modules for Electron
31
- console.log(chalk.gray('\nRebuilding native modules for Electron...'));
30
+ console.log('\nRebuilding native modules for Electron...');
32
31
  execSync(
33
32
  'npm rebuild better-sqlite3 --runtime=electron --target=28.0.0 --dist-url=https://electronjs.org/headers --abi=119',
34
33
  { stdio: 'inherit' }
35
34
  );
36
35
 
37
- console.log(chalk.green('\n✅ Electron installed successfully!'));
36
+ console.log('\n✅ Electron installed successfully!');
38
37
  return true;
39
38
  } catch (error) {
40
- console.error(chalk.red('\n❌ Failed to install Electron:'), error.message);
41
- console.log(chalk.yellow('\nPlease install manually with:'));
42
- console.log(chalk.white(' npm install -g electron@28.0.0'));
39
+ console.error('\n❌ Failed to install Electron:', error.message);
40
+ console.log('\nPlease install manually with:');
41
+ console.log(' npm install -g electron@28.0.0');
43
42
  return false;
44
43
  }
45
44
  }
@@ -47,7 +46,10 @@ export function ensureElectron() {
47
46
  return true;
48
47
  }
49
48
 
49
+ // Export for use in other scripts
50
+ module.exports = { ensureElectron };
51
+
50
52
  // Run if called directly
51
- if (import.meta.url === `file://${process.argv[1]}`) {
53
+ if (require.main === module) {
52
54
  ensureElectron();
53
55
  }
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }
@@ -1,49 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { execSync } from 'child_process';
4
- import { existsSync } from 'fs';
5
- import chalk from 'chalk';
6
-
7
- console.log(chalk.blue('🔧 Setting up portkeeper...'));
8
-
9
- try {
10
- // Always rebuild for Node.js first
11
- console.log(chalk.gray('Rebuilding native modules for Node.js...'));
12
- execSync('npm rebuild better-sqlite3', {
13
- stdio: 'inherit',
14
- cwd: process.env.INIT_CWD || process.cwd()
15
- });
16
- console.log(chalk.green('✅ Native modules prepared for CLI'));
17
-
18
- // Check if Electron is installed
19
- const hasElectron = existsSync('./node_modules/electron');
20
-
21
- if (hasElectron) {
22
- console.log(chalk.gray('\nElectron detected. Preparing GUI support...'));
23
- try {
24
- // Create a separate build for Electron
25
- execSync(
26
- 'npm rebuild better-sqlite3 --runtime=electron --target=28.0.0 --dist-url=https://electronjs.org/headers --abi=119',
27
- {
28
- stdio: 'inherit',
29
- cwd: process.env.INIT_CWD || process.cwd()
30
- }
31
- );
32
- console.log(chalk.green('✅ Native modules prepared for GUI'));
33
- } catch (electronError) {
34
- console.log(chalk.yellow('⚠️ Could not prepare Electron modules. GUI may require manual setup.'));
35
- }
36
- }
37
-
38
- console.log(chalk.green('\n✨ Portkeeper installation complete!'));
39
- console.log(chalk.gray('\nUsage:'));
40
- console.log(chalk.white(' portman --help ') + chalk.gray('Show all available commands'));
41
- console.log(chalk.white(' portman list ') + chalk.gray('List all managed ports'));
42
- console.log(chalk.white(' portman gui ') + chalk.gray('Launch the GUI (requires Electron)'));
43
-
44
- } catch (error) {
45
- console.error(chalk.red('❌ Setup failed:'), error.message);
46
- console.log(chalk.yellow('\nYou may need to manually rebuild native modules:'));
47
- console.log(chalk.gray(' npm rebuild better-sqlite3'));
48
- process.exit(1);
49
- }