Skip to content

Commit 2bbc811

Browse files
committed
chore: update lockfile linting process
- Replaced the inline linting command for package-lock.json with a dedicated script (lint-lockfile.mjs) to check for git+ssh:// URLs, ensuring compatibility with CI/CD environments. - The new script provides clear error messages and instructions if such URLs are found, enhancing the development workflow.
1 parent 7e03af2 commit 2bbc811

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"test:server:coverage": "npm run test:cov --workspace=apps/server",
4646
"test:packages": "npm run test -w @automaker/types -w @automaker/utils -w @automaker/prompts -w @automaker/platform -w @automaker/model-resolver -w @automaker/dependency-resolver -w @automaker/git-utils --if-present",
4747
"test:all": "npm run test:packages && npm run test:server",
48-
"lint:lockfile": "! grep -q 'git+ssh://' package-lock.json || (echo 'Error: package-lock.json contains git+ssh:// URLs. Run: git config --global url.\"https://github.com/\".insteadOf \"[email protected]:\"' && exit 1)",
48+
"lint:lockfile": "node scripts/lint-lockfile.mjs",
4949
"format": "prettier --write .",
5050
"format:check": "prettier --check .",
5151
"prepare": "husky && npm run build:packages"

scripts/lint-lockfile.mjs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Script to check for git+ssh:// URLs in package-lock.json
5+
* This ensures compatibility with CI/CD environments that don't support SSH.
6+
*/
7+
8+
import { readFileSync } from 'fs';
9+
import { join } from 'path';
10+
11+
const lockfilePath = join(process.cwd(), 'package-lock.json');
12+
13+
try {
14+
const content = readFileSync(lockfilePath, 'utf8');
15+
16+
// Check for git+ssh:// URLs
17+
if (content.includes('git+ssh://')) {
18+
console.error('Error: package-lock.json contains git+ssh:// URLs.');
19+
console.error('Run: git config --global url."https://github.com/".insteadOf "[email protected]:"');
20+
console.error('Or run: npm run fix:lockfile');
21+
process.exit(1);
22+
}
23+
24+
console.log('✓ No git+ssh:// URLs found in package-lock.json');
25+
process.exit(0);
26+
} catch (error) {
27+
if (error.code === 'ENOENT') {
28+
console.error('Error: package-lock.json not found');
29+
process.exit(1);
30+
}
31+
console.error('Error checking package-lock.json:', error.message);
32+
process.exit(1);
33+
}

0 commit comments

Comments
 (0)