Skip to content

Commit

Permalink
fix(package): update repository URL format to use 'git+' prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Shuunen committed Dec 7, 2024
1 parent 647d33c commit 22810ae
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"private": false,
"repository": {
"type": "git",
"url": "https://github.com/Shuunen/repo-checker.git"
"url": "git+https://github.com/Shuunen/repo-checker.git"
},
"scripts": {
"build": "pnpm build:app && pnpm mark && echo build success",
Expand Down
1 change: 1 addition & 0 deletions src/__snapshots__/check.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ exports[`check B repo-checker folder succeed 1`] = `
"package-json-has-a-keywords-property",
"package-json-has-a-private-property",
"package-json-has-a-repository-property",
"package-json-has-a-repository-url-starting-with-git-plus",
"package-json-has-a-author-property",
"package-json-has-a-name-property",
"package-json-has-a-version-property",
Expand Down
1 change: 1 addition & 0 deletions src/files/__snapshots__/package.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ exports[`package A on repo checker 1`] = `
"package-json-has-a-keywords-property",
"package-json-has-a-private-property",
"package-json-has-a-repository-property",
"package-json-has-a-repository-url-starting-with-git-plus",
"package-json-has-a-author-property",
"package-json-has-a-name-property",
"package-json-has-a-version-property",
Expand Down
7 changes: 6 additions & 1 deletion src/files/package.file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,12 @@ export class PackageJsonFile extends FileBase {
this.couldContains('a "homepage" property', this.regexForStringProp('homepage'))
this.couldContains('a "keywords" property', this.regexForArrayProp('keywords'))
this.couldContains('a "private" property', this.regexForBooleanProp('private'))
this.couldContains('a "repository" property', this.regexForObjectProp('repository'))
const hasRepository = this.couldContains('a "repository" property', this.regexForObjectProp('repository'))
if (hasRepository) {
const hasPlus = this.couldContains('a repository url starting with git plus', /"repository": [^u]+url": "git\+https/gu, 1, 'like "repository": "git+https..."', true)
/* c8 ignore next */
if (!hasPlus && this.canFix) this.fileContent = this.fileContent.replace(/(?<base>"repository": [^u]+url": ")(?<url>[^"]+")/gu, '$<base>git+$<url>')
}
this.shouldContains('a "author" property', this.regexForStringProp('author'))
this.shouldContains('a "name" property', this.regexForStringProp('name'))
this.shouldContains('a "version" property', this.regexForStringProp('version'))
Expand Down

0 comments on commit 22810ae

Please sign in to comment.