-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Start of stuff * Add a changeset * Add types as a dep to changelog-git and replace custom getChangelogEntry file with changelog-github * Add another changeset
- Loading branch information
Showing
12 changed files
with
185 additions
and
57 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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
{ | ||
"changelog": "./getChangelogEntry.js", | ||
"changelog": [ | ||
"@changesets/changelog-github", | ||
{ "repo": "atlassian/changesets" } | ||
], | ||
"commit": false, | ||
"access": "public" | ||
} |
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 @@ | ||
--- | ||
"@changesets/get-github-info": patch | ||
--- | ||
|
||
Convert internals to TypeScript |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
--- | ||
"@changesets/get-github-info": minor | ||
--- | ||
|
||
Add backticks around commits to be more similar to how commits are shown in GitHub comments |
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,6 @@ | ||
--- | ||
"@changesets/changelog-git": minor | ||
"@changesets/changelog-github": minor | ||
--- | ||
|
||
Create package |
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
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": "@changesets/changelog-git", | ||
"version": "0.0.0", | ||
"description": "A changelog entry generator for git that writes hashes", | ||
"main": "dist/changelog-git.cjs.js", | ||
"module": "dist/changelog-git.esm.js", | ||
"license": "MIT", | ||
"repository": "https://github.com/changesets/changesets/tree/master/packages/changelog-git", | ||
"dependencies": { | ||
"@changesets/types": "^0.3.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,45 @@ | ||
import { | ||
NewChangesetWithCommit, | ||
VersionType, | ||
ChangelogFunctions, | ||
ModCompWithWorkspace | ||
} from "@changesets/types"; | ||
|
||
const getReleaseLine = async ( | ||
changeset: NewChangesetWithCommit, | ||
_type: VersionType | ||
) => { | ||
const [firstLine, ...futureLines] = changeset.summary | ||
.split("\n") | ||
.map(l => l.trimRight()); | ||
|
||
let returnVal = `- ${ | ||
changeset.commit ? `${changeset.commit}: ` : "" | ||
}${firstLine}\n${futureLines.map(l => ` ${l}`).join("\n")}`; | ||
|
||
return returnVal; | ||
}; | ||
|
||
const getDependencyReleaseLine = async ( | ||
changesets: NewChangesetWithCommit[], | ||
dependenciesUpdated: ModCompWithWorkspace[] | ||
) => { | ||
if (dependenciesUpdated.length === 0) return ""; | ||
|
||
const changesetLinks = changesets.map( | ||
changeset => `- Updated dependencies [${changeset.commit}]` | ||
); | ||
|
||
const updatedDepenenciesList = dependenciesUpdated.map( | ||
dependency => ` - ${dependency.name}@${dependency.newVersion}` | ||
); | ||
|
||
return [...changesetLinks, ...updatedDepenenciesList].join("\n"); | ||
}; | ||
|
||
const defaultChangelogFunctions: ChangelogFunctions = { | ||
getReleaseLine, | ||
getDependencyReleaseLine | ||
}; | ||
|
||
export default defaultChangelogFunctions; |
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,14 @@ | ||
{ | ||
"name": "@changesets/changelog-github", | ||
"version": "0.0.0", | ||
"description": "A changelog entry generator for GitHub that links to commits, PRs and users", | ||
"main": "dist/changelog-github.cjs.js", | ||
"module": "dist/changelog-github.esm.js", | ||
"license": "MIT", | ||
"repository": "https://github.com/changesets/changesets/tree/master/packages/changelog-github", | ||
"dependencies": { | ||
"@changesets/get-github-info": "^0.2.1", | ||
"@changesets/types": "^0.3.0", | ||
"dotenv": "^8.1.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,67 @@ | ||
import { ChangelogFunctions } from "@changesets/types"; | ||
// @ts-ignore | ||
import { config } from "dotenv"; | ||
import { getInfo } from "@changesets/get-github-info"; | ||
|
||
config(); | ||
|
||
const changelogFunctions: ChangelogFunctions = { | ||
getDependencyReleaseLine: async ( | ||
changesets, | ||
dependenciesUpdated, | ||
options | ||
) => { | ||
if (!options.repo) { | ||
throw new Error( | ||
'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]' | ||
); | ||
} | ||
if (dependenciesUpdated.length === 0) return ""; | ||
|
||
const changesetLink = `- Updated dependencies [${(await Promise.all( | ||
changesets.map(async cs => { | ||
if (cs.commit) { | ||
let { links } = await getInfo({ | ||
repo: options.repo, | ||
commit: cs.commit | ||
}); | ||
return links.commit; | ||
} | ||
}) | ||
)) | ||
.filter(_ => _) | ||
.join(", ")}]:`; | ||
|
||
const updatedDepenenciesList = dependenciesUpdated.map( | ||
dependency => ` - ${dependency.name}@${dependency.newVersion}` | ||
); | ||
|
||
return [changesetLink, ...updatedDepenenciesList].join("\n"); | ||
}, | ||
getReleaseLine: async (changeset, type, options) => { | ||
if (!options.repo) { | ||
throw new Error( | ||
'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]' | ||
); | ||
} | ||
const [firstLine, ...futureLines] = changeset.summary | ||
.split("\n") | ||
.map(l => l.trimRight()); | ||
|
||
if (changeset.commit) { | ||
let { links } = await getInfo({ | ||
repo: options.repo, | ||
commit: changeset.commit | ||
}); | ||
return `\n\n- ${links.commit}${ | ||
links.pull === null ? "" : ` ${links.pull}` | ||
}${ | ||
links.user === null ? "" : ` Thanks ${links.user}!` | ||
} - ${firstLine}\n${futureLines.map(l => ` ${l}`).join("\n")}`; | ||
} else { | ||
return `\n\n- ${firstLine}\n${futureLines.map(l => ` ${l}`).join("\n")}`; | ||
} | ||
} | ||
}; | ||
|
||
export default changelogFunctions; |
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
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