File size: 990 Bytes
1dbc34b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env node

/**
 * Script to check for git+ssh:// URLs in package-lock.json
 * This ensures compatibility with CI/CD environments that don't support SSH.
 */

import { readFileSync } from 'fs';
import { join } from 'path';

const lockfilePath = join(process.cwd(), 'package-lock.json');

try {
  const content = readFileSync(lockfilePath, 'utf8');

  // Check for git+ssh:// URLs
  if (content.includes('git+ssh://')) {
    console.error('Error: package-lock.json contains git+ssh:// URLs.');
    console.error('Run: git config --global url."https://github.com/".insteadOf "git@github.com:"');
    console.error('Or run: npm run fix:lockfile');
    process.exit(1);
  }

  console.log('✓ No git+ssh:// URLs found in package-lock.json');
  process.exit(0);
} catch (error) {
  if (error.code === 'ENOENT') {
    console.error('Error: package-lock.json not found');
    process.exit(1);
  }
  console.error('Error checking package-lock.json:', error.message);
  process.exit(1);
}