changesets-get-github-info 0.6.0
Install from the command line:
Learn more about npm packages
$ npm install @fond-of/changesets-get-github-info@0.6.0
Install via package.json:
"@fond-of/changesets-get-github-info": "0.6.0"
About this version
Get the GitHub username and PR number from a commit. Intended for use with changesets.
Note: This assumes you already have changesets setup.
To use @fond-of/changesets-get-github-info
, you'll need to install it and you'll probably also want dotenv
to provide a GitHub personal access token via a .env
file.
yarn add --dev @fond-of/changesets-get-github-info dotenv
or
npm install --save-dev @fond-of/changesets-get-github-info dotenv
Then you can use it in your .changeset/config.js
like this.
require("dotenv").config();
const { getInfo } = require("@fond-of/changesets-get-github-info");
// ...
const getReleaseLine = async (changeset, type) => {
const [firstLine, ...futureLines] = changeset.summary
.split("\n")
.map((l) => l.trimRight());
// getInfo exposes the GH username and PR number if you want them directly
// but it also exposes a set of links for the commit, PR and GH username
let { user, pull, links } = await getInfo({
// replace this with your own repo
repo: "Noviny/changesets",
commit: changeset.commit,
});
let returnVal = `- ${links.commit}${
links.pull === null ? "" : ` ${links.pull}`
}${links.user === null ? "" : ` Thanks ${links.user}!`}: ${firstLine}`;
if (futureLines.length > 0) {
returnVal += `\n${futureLines.map((l) => ` ${l}`).join("\n")}`;
}
return returnVal;
};
// ...
You'll need to get a GitHub personal access token with read:user
and repo:status
permissions, and add it to a .env
file.
GITHUB_TOKEN=token_here
You can now bump your packages and changelogs with changeset version
and it'll have the GitHub info. 🎉
type Info = {
user: string | null;
pull: number | null;
links: {
commit: string;
pull: string | null;
user: string | null;
};
};
type Options = {
commit: string;
repo: string;
};
export function getInfo(options: Options): Info {
// magic...
}
Details
- changesets-get-github-info
- fond-of
- 4 months ago
- MIT
- 4 dependencies
Assets
- changesets-get-github-info-0.6.0.tgz
Download activity
- Total downloads 0
- Last 30 days 0
- Last week 0
- Today 0