-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from ghiscoding/chore/unit-test-part2
fix(version): add missing code conventional-preset legacy loading
- Loading branch information
Showing
49 changed files
with
1,232 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"use strict"; | ||
|
||
const execa = require("execa"); | ||
|
||
module.exports.gitCheckout = gitCheckout; | ||
|
||
function gitCheckout(cwd, args) { | ||
return execa("git", ["checkout", ...args], { cwd }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "@lerna-test/git-checkout", | ||
"version": "0.0.0-test-only", | ||
"description": "A local test helper", | ||
"main": "index.js", | ||
"private": true, | ||
"license": "MIT", | ||
"dependencies": { | ||
"execa": "^5.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"use strict"; | ||
|
||
const execa = require("execa"); | ||
|
||
module.exports.gitMerge = gitMerge; | ||
|
||
function gitMerge(cwd, args) { | ||
return execa("git", ["merge", ...args], { cwd }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "@lerna-test/git-merge", | ||
"version": "0.0.0-test-only", | ||
"description": "A local test helper", | ||
"main": "index.js", | ||
"private": true, | ||
"license": "MIT", | ||
"dependencies": { | ||
"execa": "^5.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"use strict"; | ||
|
||
const cp = require("child_process"); | ||
|
||
module.exports.gitStatus = gitStatus; | ||
|
||
function gitStatus(cwd) { | ||
return cp.spawnSync("git", ["status", "--porcelain"], { cwd, encoding: "utf8" }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "@lerna-test/git-status", | ||
"version": "0.0.0-test-only", | ||
"description": "A local test helper", | ||
"main": "index.js", | ||
"private": true, | ||
"license": "MIT", | ||
"dependencies": { | ||
"execa": "^5.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"use strict"; | ||
|
||
const execa = require("execa"); | ||
|
||
module.exports.gitTag = gitTag; | ||
|
||
function gitTag(cwd, tagName) { | ||
return execa("git", ["tag", tagName, "-m", tagName], { cwd }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "@lerna-test/git-tag", | ||
"version": "0.0.0-test-only", | ||
"description": "A local test helper", | ||
"main": "index.js", | ||
"private": true, | ||
"license": "MIT", | ||
"dependencies": { | ||
"execa": "^5.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"use strict"; | ||
|
||
const normalizeNewline = require("normalize-newline"); | ||
const gitSHA = require("../serialize-git-sha"); | ||
|
||
// expect.addSnapshotSerializer(require("@lerna-test/serialize-changelog")); | ||
module.exports = { | ||
serialize(str) { | ||
return gitSHA | ||
.serialize(normalizeNewline(str)) | ||
.replace(/(\[.*?\])\(.*\/compare\/(.*?)\)/g, "$1(/compare/$2)") | ||
.replace(/(\[.*?\])\(.*\/commits\/GIT_HEAD\)/g, "$1(COMMIT_URL)") | ||
.replace(/\(\d{4}-\d{2}-\d{2}\)/g, "(YYYY-MM-DD)"); | ||
}, | ||
test(val) { | ||
return val != null && typeof val === "string"; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "@lerna-test/serialize-changelog", | ||
"version": "0.0.0-test-only", | ||
"description": "A local test helper", | ||
"main": "index.js", | ||
"private": true, | ||
"license": "MIT", | ||
"dependencies": { | ||
"@lerna-test/serialize-git-sha": "file:../serialize-git-sha", | ||
"normalize-newline": "^3.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"use strict"; | ||
|
||
// expect.addSnapshotSerializer(require("@lerna-test/serialize-git-sha")); | ||
module.exports = { | ||
serialize(str) { | ||
return ( | ||
str | ||
// short SHA tends to be in the path diff comparisons | ||
.replace(/\b[0-9a-f]{7,8}\b/g, "SHA") | ||
// full SHA corresponds to gitHead property in package.json files | ||
.replace(/\b[0-9a-f]{40}\b/g, "GIT_HEAD") | ||
); | ||
}, | ||
test(val) { | ||
return val != null && typeof val === "string" && /[0-9a-f]{7,40}/.test(val); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "@lerna-test/serialize-git-sha", | ||
"version": "0.0.0-test-only", | ||
"description": "A local test helper", | ||
"main": "index.js", | ||
"private": true, | ||
"license": "MIT", | ||
"dependencies": {} | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/core/src/conventional-commits/__tests__/__fixtures__/changelog-missing/lerna.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"command": { | ||
"publish": { | ||
"conventionalCommits": true | ||
} | ||
}, | ||
"version": "1.0.0" | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/core/src/conventional-commits/__tests__/__fixtures__/changelog-missing/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "changelog-missing", | ||
"repository": "lerna/changelog-missing", | ||
"version": "0.0.0-root" | ||
} |
5 changes: 5 additions & 0 deletions
5
...entional-commits/__tests__/__fixtures__/changelog-missing/packages/package-1/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "package-1", | ||
"repository": "lerna/changelog-missing", | ||
"version": "1.0.0" | ||
} |
8 changes: 8 additions & 0 deletions
8
...entional-commits/__tests__/__fixtures__/changelog-missing/packages/package-2/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "package-2", | ||
"repository": "lerna/changelog-missing", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"package-1": "^1.0.0" | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/core/src/conventional-commits/__tests__/__fixtures__/fixed/CHANGELOG.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Change Log | ||
|
||
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
<a name="1.0.0"></a> | ||
|
||
# 1.0.0 (YYYY-MM-DD) | ||
|
||
### Features | ||
|
||
* I should be placed in the CHANGELOG |
8 changes: 8 additions & 0 deletions
8
packages/core/src/conventional-commits/__tests__/__fixtures__/fixed/lerna.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"command": { | ||
"publish": { | ||
"conventionalCommits": true | ||
} | ||
}, | ||
"version": "1.0.0" | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/core/src/conventional-commits/__tests__/__fixtures__/fixed/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "conventional-commits-fixed", | ||
"repository": "lerna/conventional-commits-fixed", | ||
"version": "0.0.0-root" | ||
} |
12 changes: 12 additions & 0 deletions
12
...nventional-commits/__tests__/__fixtures__/fixed/packages/package-1/CHANGELOG.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Change Log | ||
|
||
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
<a name="1.0.0"></a> | ||
|
||
# 1.0.0 (YYYY-MM-DD) | ||
|
||
### Features | ||
|
||
* I should be placed in the CHANGELOG |
5 changes: 5 additions & 0 deletions
5
...ore/src/conventional-commits/__tests__/__fixtures__/fixed/packages/package-1/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "package-1", | ||
"repository": "lerna/conventional-commits-fixed", | ||
"version": "1.0.0" | ||
} |
12 changes: 12 additions & 0 deletions
12
...nventional-commits/__tests__/__fixtures__/fixed/packages/package-2/CHANGELOG.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Change Log | ||
|
||
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
<a name="1.0.0"></a> | ||
|
||
# 1.0.0 (YYYY-MM-DD) | ||
|
||
### Features | ||
|
||
* I should be placed in the CHANGELOG |
8 changes: 8 additions & 0 deletions
8
...ore/src/conventional-commits/__tests__/__fixtures__/fixed/packages/package-2/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "package-2", | ||
"repository": "lerna/conventional-commits-fixed", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"package-1": "^1.0.0" | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...re/src/conventional-commits/__tests__/__fixtures__/fixed/scripts/config-builder-preset.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"use strict"; | ||
|
||
// https://git.io/vx5iq (conventional-changelog-angular/conventional-recommended-bump.js, etc) | ||
const parserOpts = require("./parser-opts"); | ||
const writerOpts = require("./writer-opts"); | ||
const whatBump = require("./what-bump"); | ||
|
||
// https://git.io/fhyKK | ||
module.exports = presetOpts; | ||
|
||
function presetOpts(param) { | ||
if (typeof param !== "function") { | ||
return Promise.resolve( | ||
Object.assign(param, { | ||
parserOpts, | ||
writerOpts, | ||
whatBump, | ||
}) | ||
); | ||
} | ||
|
||
process.nextTick(param, null, { | ||
parserOpts, | ||
writerOpts, | ||
whatBump, | ||
}); | ||
} |
7 changes: 7 additions & 0 deletions
7
...ges/core/src/conventional-commits/__tests__/__fixtures__/fixed/scripts/erroring-preset.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"use strict"; | ||
|
||
module.exports = { | ||
recommendedBumpOpts: { | ||
whatBump: "I should be a function", | ||
}, | ||
}; |
17 changes: 17 additions & 0 deletions
17
...e/src/conventional-commits/__tests__/__fixtures__/fixed/scripts/legacy-callback-preset.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"use strict"; | ||
|
||
// https://git.io/vx5iq (conventional-changelog-angular/conventional-recommended-bump.js, etc) | ||
const parserOpts = require("./parser-opts"); | ||
const writerOpts = require("./writer-opts"); | ||
const whatBump = require("./what-bump"); | ||
|
||
// https://git.io/fhyKK | ||
module.exports = presetOpts; | ||
|
||
function presetOpts(cb) { | ||
process.nextTick(cb, null, { | ||
parserOpts, | ||
writerOpts, | ||
whatBump, | ||
}); | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/core/src/conventional-commits/__tests__/__fixtures__/fixed/scripts/local-preset.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"use strict"; | ||
|
||
// https://git.io/vx5iq (conventional-changelog-angular/conventional-recommended-bump.js, etc) | ||
const parserOpts = require("./parser-opts"); | ||
const writerOpts = require("./writer-opts"); | ||
const whatBump = require("./what-bump"); | ||
|
||
module.exports = { | ||
conventionalChangelog: { | ||
parserOpts, | ||
writerOpts, | ||
}, | ||
recommendedBumpOpts: { | ||
parserOpts, | ||
whatBump, | ||
}, | ||
}; |
17 changes: 17 additions & 0 deletions
17
packages/core/src/conventional-commits/__tests__/__fixtures__/fixed/scripts/null-preset.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"use strict"; | ||
|
||
// https://git.io/vx5iq (conventional-changelog-angular/conventional-recommended-bump.js, etc) | ||
const parserOpts = require("./parser-opts"); | ||
const writerOpts = require("./writer-opts"); | ||
const whatBump = require("./null-what-bump"); | ||
|
||
module.exports = { | ||
conventionalChangelog: { | ||
parserOpts, | ||
writerOpts, | ||
}, | ||
recommendedBumpOpts: { | ||
parserOpts, | ||
whatBump, | ||
}, | ||
}; |
31 changes: 31 additions & 0 deletions
31
...ages/core/src/conventional-commits/__tests__/__fixtures__/fixed/scripts/null-what-bump.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"use strict"; | ||
|
||
module.exports = whatBump; | ||
|
||
function whatBump(commits) { | ||
let level = null; | ||
let breakings = 0; | ||
let features = 0; | ||
|
||
commits.forEach((commit) => { | ||
if (commit.notes.length > 0) { | ||
breakings += commit.notes.length; | ||
level = 0; | ||
} else if (commit.type === "feat") { | ||
features += 1; | ||
if (level === 2) { | ||
level = 1; | ||
} | ||
} else if (commit.type === "fix") { | ||
level = 2; | ||
} | ||
}); | ||
|
||
return { | ||
level, | ||
reason: | ||
breakings === 1 | ||
? `There are ${breakings} BREAKING CHANGE and ${features} features` | ||
: `There are ${breakings} BREAKING CHANGES and ${features} features`, | ||
}; | ||
} |
12 changes: 12 additions & 0 deletions
12
...ages/core/src/conventional-commits/__tests__/__fixtures__/fixed/scripts/old-api-preset.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"use strict"; | ||
|
||
// https://git.io/vx5iq (conventional-changelog-angular/conventional-recommended-bump.js, etc) | ||
const parserOpts = require("./parser-opts"); | ||
const writerOpts = require("./writer-opts"); | ||
const whatBump = require("./what-bump"); | ||
|
||
module.exports = { | ||
parserOpts, | ||
writerOpts, | ||
whatBump, | ||
}; |
9 changes: 9 additions & 0 deletions
9
packages/core/src/conventional-commits/__tests__/__fixtures__/fixed/scripts/parser-opts.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"use strict"; | ||
|
||
module.exports = { | ||
headerPattern: /^(\w*)(?:\((.*)\))?: (.*)$/, | ||
headerCorrespondence: [`type`, `scope`, `subject`], | ||
noteKeywords: [`BREAKING CHANGE`], | ||
revertPattern: /^revert:\s([\s\S]*?)\s*This reverts commit (\w*)\./, | ||
revertCorrespondence: [`header`, `hash`], | ||
}; |
Oops, something went wrong.