🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@ossjs/release

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ossjs/release - npm Package Compare versions

Comparing version
0.8.1
to
0.9.0
+7
bin/build/_virtual/rolldown_runtime.js
import { createRequire } from "node:module";
//#region rolldown:runtime
var __require = /* @__PURE__ */ createRequire(import.meta.url);
//#endregion
export { __require };
import { log } from "./logger.js";
import { Config } from "./utils/get-config.js";
import { BuilderCallback } from "yargs";
//#region src/Command.d.ts
interface DefaultArgv {
_: (number | string)[];
}
declare abstract class Command<Argv extends Record<string, any> = {}> {
protected readonly config: Config;
protected readonly argv: DefaultArgv & Argv;
static readonly command: string;
static readonly description: string;
static readonly builder: BuilderCallback<{}, any>;
protected log: typeof log;
constructor(config: Config, argv: DefaultArgv & Argv);
run: () => Promise<void>;
}
//#endregion
export { Command, DefaultArgv };
import { Command } from "../Command.js";
import { ReleaseContext } from "../utils/create-context.js";
import { ParsedCommitWithHash } from "../utils/git/parse-commits.js";
import { GitHubRelease } from "../utils/github/get-github-release.js";
import { BuilderCallback } from "yargs";
//#region src/commands/notes.d.ts
interface Argv {
_: [path: string, tag: string];
}
declare class Notes extends Command<Argv> {
static command: string;
static description: string;
static builder: BuilderCallback<{}, Argv>;
run: () => Promise<undefined>;
static generateReleaseNotes(context: ReleaseContext, commits: ParsedCommitWithHash[]): Promise<string>;
static createRelease(context: ReleaseContext, notes: string): Promise<GitHubRelease>;
}
//#endregion
export { Notes };
import { Command } from "../Command.js";
import { BuilderCallback } from "yargs";
//#region src/commands/publish.d.ts
interface PublishArgv {
profile: string;
dryRun?: boolean;
}
type RevertAction = () => Promise<void>;
declare class Publish extends Command<PublishArgv> {
static command: string;
static description: string;
static builder: BuilderCallback<{}, PublishArgv>;
private profile;
private context;
/**
* The list of clean-up functions to invoke if release fails.
*/
private revertQueue;
run: () => Promise<void>;
/**
* Execute the release script specified in the configuration.
*/
private runReleaseScript;
/**
* Revert those changes that were marked as revertable.
*/
private revertChanges;
/**
* Create a release commit in Git.
*/
private createReleaseCommit;
/**
* Create a release tag in Git.
*/
private createReleaseTag;
/**
* Generate release notes from the given commits.
*/
private generateReleaseNotes;
/**
* Push the release commit and tag to the remote.
*/
private pushToRemote;
/**
* Create a new GitHub release.
*/
private createGitHubRelease;
/**
* Comment on referenced GitHub issues and pull requests.
*/
private commentOnIssues;
}
//#endregion
export { Publish, RevertAction };
import { Command } from "../Command.js";
import { BuilderCallback } from "yargs";
//#region src/commands/show.d.ts
interface Argv {
_: [path: string, tag?: string];
}
declare enum ReleaseStatus {
/**
* Release is public and available for everybody to see
* on the GitHub releases page.
*/
Public = "public",
/**
* Release is pushed to GitHub but is marked as draft.
*/
Draft = "draft",
/**
* Release is local, not present on GitHub.
*/
Unpublished = "unpublished",
}
declare class Show extends Command<Argv> {
static command: string;
static description: string;
static builder: BuilderCallback<{}, Argv>;
run: () => Promise<void>;
/**
* Returns tag pointer by the given tag name.
* If no tag name was given, looks up the latest release tag
* and returns its pointer.
*/
private getTagPointer;
}
//#endregion
export { ReleaseStatus, Show };
//#region src/logger.d.ts
declare const log: any;
//#endregion
export { log };
//#region src/utils/bump-package-json.d.ts
declare function bumpPackageJson(version: string): void;
//#endregion
export { bumpPackageJson };
import { readPackageJson } from "./read-package-json.js";
import { writePackageJson } from "./write-package-json.js";
//#region src/utils/bump-package-json.ts
function bumpPackageJson(version) {
const packageJson = readPackageJson();
packageJson.version = version;
writePackageJson(packageJson);
}
//#endregion
export { bumpPackageJson };
import { GitInfo } from "#/src/utils/git/getInfo.js";
import { TagPointer } from "#/src/utils/git/getTag.js";
//#region src/utils/create-context.d.ts
interface ReleaseContext {
repo: GitInfo;
latestRelease?: TagPointer;
nextRelease: {
version: string;
readonly tag: string;
publishedAt: Date;
};
}
interface ReleaseContextInput {
repo: GitInfo;
latestRelease?: TagPointer;
nextRelease: {
version: string;
publishedAt: Date;
};
}
declare function createContext(input: ReleaseContextInput): ReleaseContext;
//#endregion
export { ReleaseContext, ReleaseContextInput, createContext };
//#region src/utils/create-context.ts
function createContext(input) {
const context = {
repo: input.repo,
latestRelease: input.latestRelease || void 0,
nextRelease: {
...input.nextRelease,
tag: null
}
};
Object.defineProperty(context.nextRelease, "tag", { get() {
return `v${context.nextRelease.version}`;
} });
return context;
}
//#endregion
export { createContext };
import { ReleaseContext } from "./create-context.js";
//#region src/utils/create-release-comment.d.ts
interface ReleaseCommentInput {
context: ReleaseContext;
releaseUrl: string;
}
declare function createReleaseComment(input: ReleaseCommentInput): string;
//#endregion
export { ReleaseCommentInput, createReleaseComment };
import { readPackageJson } from "./read-package-json.js";
//#region src/utils/create-release-comment.ts
function createReleaseComment(input) {
const { context, releaseUrl } = input;
const packageJson = readPackageJson();
return `## Released: ${context.nextRelease.tag} 🎉
This has been released in ${context.nextRelease.tag}!
- 📄 [**Release notes**](${releaseUrl})
- 📦 [npm package](https://www.npmjs.com/package/${packageJson.name}/v/${context.nextRelease.version})
Make sure to always update to the latest version (\`npm i ${packageJson.name}@latest\`) to get the newest features and bug fixes.
---
_Predictable release automation by [@ossjs/release](https://github.com/ossjs/release)_.`;
}
//#endregion
export { createReleaseComment };
//#region src/utils/env.d.ts
declare function demandGitHubToken(): Promise<void>;
declare function demandNpmToken(): Promise<void>;
//#endregion
export { demandGitHubToken, demandNpmToken };
import { ChildProcess, ExecOptions } from "node:child_process";
import { DeferredPromise } from "@open-draft/deferred-promise";
//#region src/utils/exec-async.d.ts
type ExecAsyncFn = {
(command: string, options?: ExecOptions): DeferredPromiseWithIo<ExecAsyncPromisePayload>;
mockContext(options: ExecOptions): void;
restoreContext(): void;
contextOptions: ExecOptions;
};
interface DeferredPromiseWithIo<T> extends DeferredPromise<T> {
io: ChildProcess;
}
interface ExecAsyncPromisePayload {
stdout: string;
stderr: string;
}
declare const execAsync: ExecAsyncFn;
//#endregion
export { ExecAsyncFn, ExecAsyncPromisePayload, execAsync };
import { exec } from "node:child_process";
import { DeferredPromise } from "@open-draft/deferred-promise";
//#region src/utils/exec-async.ts
const DEFAULT_CONTEXT = { cwd: process.cwd() };
const execAsync = ((command, options = {}) => {
const commandPromise = new DeferredPromise();
const io = exec(command, {
...execAsync.contextOptions,
...options
}, (error, stdout, stderr) => {
if (error) return commandPromise.reject(error);
commandPromise.resolve({
stdout: stdout.toString(),
stderr: stderr.toString()
});
});
Reflect.set(commandPromise, "io", io);
return commandPromise;
});
execAsync.mockContext = (options) => {
execAsync.contextOptions = options;
};
execAsync.restoreContext = () => {
execAsync.contextOptions = DEFAULT_CONTEXT;
};
execAsync.restoreContext();
//#endregion
export { execAsync };
//#region src/utils/format-date.d.ts
declare function formatDate(date: Date): string;
//#endregion
export { formatDate };
//#region src/utils/format-date.ts
function formatDate(date) {
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, "0");
const day = date.getDate().toString().padStart(2, "0");
return `${year}-${month}-${day}`;
}
//#endregion
export { formatDate };
//#region src/utils/get-config.d.ts
interface Config {
profiles: Array<ReleaseProfile>;
}
interface ReleaseProfile {
name: string;
/**
* The publish script command.
* @example npm publish $NEXT_VERSION
* @example pnpm publish --no-git-checks
*/
use: string;
/**
* Indicate a pre-release version.
* Treat breaking changes as minor release versions.
*/
prerelease?: boolean;
}
declare function getConfig(): Config;
//#endregion
export { Config, ReleaseProfile, getConfig };
import { __require } from "../_virtual/rolldown_runtime.js";
import * as path from "node:path";
import { invariant } from "outvariant";
//#region src/utils/get-config.ts
function getConfig() {
const configPath = path.resolve(process.cwd(), "release.config.json");
const config = __require(configPath);
validateConfig(config);
return config;
}
function validateConfig(config) {
invariant(Array.isArray(config.profiles), "Failed to parse Release configuration: expected a root-level \"tags\" property to be an array but got %j", config.profiles);
invariant(config.profiles.length > 0, "Failed to parse Release configuration: expected at least one profile to be defined");
}
//#endregion
export { getConfig };
import { ParsedCommitWithHash } from "./git/parse-commits.js";
import * as semver from "semver";
//#region src/utils/get-next-release-type.d.ts
interface GetNextReleaseTypeOptions {
prerelease?: boolean;
}
/**
* Returns true if the given parsed commit represents a breaking change.
* @see https://www.conventionalcommits.org/en/v1.0.0/#summary
*/
declare function isBreakingChange(commit: ParsedCommitWithHash): boolean;
declare function getNextReleaseType(commits: ParsedCommitWithHash[], options?: GetNextReleaseTypeOptions): semver.ReleaseType | null;
//#endregion
export { getNextReleaseType, isBreakingChange };
import "./git/parse-commits.js";
import "semver";
//#region src/utils/get-next-release-type.ts
/**
* Returns true if the given parsed commit represents a breaking change.
* @see https://www.conventionalcommits.org/en/v1.0.0/#summary
*/
function isBreakingChange(commit) {
if (commit.typeAppendix === "!") return true;
if (commit.footer && commit.footer.includes("BREAKING CHANGE:")) return true;
return false;
}
function getNextReleaseType(commits, options) {
const ranges = [null, null];
for (const commit of commits) {
if (isBreakingChange(commit)) return options?.prerelease ? "minor" : "major";
switch (commit.type) {
case "feat":
ranges[0] = "minor";
break;
case "fix":
ranges[1] = "patch";
break;
}
}
/**
* @fixme Commit messages can also append "!" to the scope
* to indicate that the commit is a breaking change.
* @see https://www.conventionalcommits.org/en/v1.0.0/#summary
*
* Unfortunately, "conventional-commits-parser" does not support that.
*/
return ranges[0] || ranges[1];
}
//#endregion
export { getNextReleaseType, isBreakingChange };
import * as semver from "semver";
//#region src/utils/get-next-version.d.ts
declare function getNextVersion(previousVersion: string, releaseType: semver.ReleaseType): string;
//#endregion
export { getNextVersion };
import { invariant } from "outvariant";
import * as semver from "semver";
//#region src/utils/get-next-version.ts
function getNextVersion(previousVersion, releaseType) {
const nextVersion = semver.inc(previousVersion, releaseType);
invariant(nextVersion, "Failed to calculate the next version from \"%s\" using release type \"%s\"", previousVersion, releaseType);
return nextVersion;
}
//#endregion
export { getNextVersion };
import { ParsedCommitWithHash } from "./parse-commits.js";
//#region src/utils/git/commit.d.ts
interface CommitOptions {
message: string;
files?: string[];
allowEmpty?: boolean;
date?: Date;
}
declare function commit({
files,
message,
allowEmpty,
date
}: CommitOptions): Promise<ParsedCommitWithHash>;
//#endregion
export { CommitOptions, commit };
//#region src/utils/git/create-tag.d.ts
declare function createTag(tag: string): Promise<string>;
//#endregion
export { createTag };
import { execAsync } from "../exec-async.js";
//#region src/utils/git/create-tag.ts
async function createTag(tag) {
await execAsync(`git tag ${tag}`);
return (await execAsync(`git describe --tags --abbrev=0`).then(({ stdout }) => stdout)).trim();
}
//#endregion
export { createTag };
import { Commit } from "git-log-parser";
//#region src/utils/git/get-commit.d.ts
declare function getCommit(hash: string): Promise<Commit | undefined>;
//#endregion
export { getCommit };
import { execAsync } from "../exec-async.js";
import { array } from "get-stream";
import gitLogParser from "git-log-parser";
//#region src/utils/git/get-commit.ts
async function getCommit(hash) {
Object.assign(gitLogParser.fields, {
hash: "H",
message: "B"
});
return (await array(gitLogParser.parse({
_: hash,
n: 1
}, { cwd: execAsync.contextOptions.cwd })))?.[0];
}
//#endregion
export { getCommit };
import * as gitLogParser$1 from "git-log-parser";
//#region src/utils/git/get-commits.d.ts
interface GetCommitsOptions {
since?: string;
until?: string;
}
/**
* Return the list of parsed commits within the given range.
*/
declare function getCommits({
since,
until
}?: GetCommitsOptions): Promise<gitLogParser$1.Commit[]>;
//#endregion
export { getCommits };
import { execAsync } from "../exec-async.js";
import { array } from "get-stream";
import * as gitLogParser$1 from "git-log-parser";
//#region src/utils/git/get-commits.ts
/**
* Return the list of parsed commits within the given range.
*/
function getCommits({ since, until = "HEAD" } = {}) {
Object.assign(gitLogParser$1.fields, {
hash: "H",
message: "B"
});
const range = since ? `${since}..${until}` : until;
const skip = range === until && until !== "HEAD" ? 1 : void 0;
return array(gitLogParser$1.parse({
_: range,
skip
}, { cwd: execAsync.contextOptions.cwd }));
}
//#endregion
export { getCommits };
//#region src/utils/git/get-current-branch.d.ts
declare function getCurrentBranch(): Promise<string>;
//#endregion
export { getCurrentBranch };
import { execAsync } from "../exec-async.js";
//#region src/utils/git/get-current-branch.ts
async function getCurrentBranch() {
const { stdout } = await execAsync("git rev-parse --abbrev-ref HEAD");
return stdout.trim();
}
//#endregion
export { getCurrentBranch };
//#region src/utils/git/get-info.d.ts
interface GitInfo {
owner: string;
name: string;
remote: string;
url: string;
}
declare function getInfo(): Promise<GitInfo>;
declare function parseOriginUrl(origin: string): [string, string];
//#endregion
export { GitInfo, getInfo, parseOriginUrl };
import { execAsync } from "../exec-async.js";
import { invariant } from "outvariant";
//#region src/utils/git/get-info.ts
async function getInfo() {
const remote = await execAsync(`git config --get remote.origin.url`).then(({ stdout }) => stdout.trim());
const [owner, name] = parseOriginUrl(remote);
invariant(remote, "Failed to extract Git info: expected an origin URL but got %s.", remote);
invariant(owner, "Failed to extract Git info: expected repository owner but got %s.", owner);
invariant(name, "Failed to extract Git info: expected repository name but got %s.", name);
return {
remote,
owner,
name,
url: new URL(`https://github.com/${owner}/${name}/`).href
};
}
function parseOriginUrl(origin) {
if (origin.startsWith("git@")) {
const match = /:(.+?)\/(.+)\.git$/g.exec(origin);
invariant(match, "Failed to parse origin URL \"%s\": invalid URL structure.", origin);
return [match[1], match[2]];
}
if (/^http(s)?:\/\//.test(origin)) {
const url = new URL(origin);
const match = /\/(.+?)\/(.+?)(\.git)?$/.exec(url.pathname);
invariant(match, "Failed to parse origin URL \"%s\": invalid URL structure.", origin);
return [match[1], match[2]];
}
invariant(false, "Failed to extract repository owner/name: given origin URL \"%s\" is of unknown scheme (Git/HTTP/HTTPS).", origin);
}
//#endregion
export { getInfo, parseOriginUrl };
import { TagPointer } from "./get-tag.js";
//#region src/utils/git/get-latest-release.d.ts
declare function byReleaseVersion(left: string, right: string): number;
declare function getLatestRelease(tags: string[]): Promise<TagPointer | undefined>;
//#endregion
export { byReleaseVersion, getLatestRelease };
import { getTag } from "./get-tag.js";
import * as semver from "semver";
//#region src/utils/git/get-latest-release.ts
function byReleaseVersion(left, right) {
return semver.rcompare(left, right);
}
async function getLatestRelease(tags) {
const [latestTag] = tags.filter((tag) => {
return semver.valid(tag);
}).sort(byReleaseVersion);
if (!latestTag) return;
return getTag(latestTag);
}
//#endregion
export { byReleaseVersion, getLatestRelease };
//#region src/utils/git/get-tag.d.ts
interface TagPointer {
tag: string;
hash: string;
}
/**
* Get tag pointer by tag name.
*/
declare function getTag(tag: string): Promise<TagPointer | undefined>;
//#endregion
export { TagPointer, getTag };
import { execAsync } from "../exec-async.js";
import { until } from "until-async";
//#region src/utils/git/get-tag.ts
/**
* Get tag pointer by tag name.
*/
async function getTag(tag) {
const [commitHashError, commitHashData] = await until(() => {
return execAsync(`git rev-list -n 1 ${tag}`);
});
if (commitHashError) return;
return {
tag,
hash: commitHashData.stdout.trim()
};
}
//#endregion
export { getTag };
//#region src/utils/git/get-tags.d.ts
/**
* Return the list of tags present on the current Git branch.
*/
declare function getTags(): Promise<Array<string>>;
//#endregion
export { getTags };
import { execAsync } from "../exec-async.js";
//#region src/utils/git/get-tags.ts
/**
* Return the list of tags present on the current Git branch.
*/
async function getTags() {
return (await execAsync("git tag --merged").then(({ stdout }) => stdout)).split("\n").filter(Boolean);
}
//#endregion
export { getTags };
import { Commit } from "git-log-parser";
import { Commit as Commit$1 } from "conventional-commits-parser";
//#region src/utils/git/parse-commits.d.ts
type ParsedCommitWithHash = Commit$1 & {
hash: string;
typeAppendix?: '!' | (string & {});
};
declare function parseCommits(commits: Commit[]): Promise<Array<ParsedCommitWithHash>>;
//#endregion
export { ParsedCommitWithHash, parseCommits };
import { invariant } from "outvariant";
import { DeferredPromise } from "@open-draft/deferred-promise";
import { PassThrough } from "node:stream";
import { CommitParser, parseCommitsStream } from "conventional-commits-parser";
//#region src/utils/git/parse-commits.ts
const COMMIT_HEADER_APPENDIX_REGEXP = /^(.+)(!)(:)/g;
async function parseCommits(commits) {
const through = new PassThrough();
const commitMap = /* @__PURE__ */ new Map();
for (const commit of commits) {
commitMap.set(commit.subject, commit);
const message = joinCommit(commit.subject, commit.body);
through.write(message, "utf8");
}
through.end();
const commitParser = new CommitParser();
const parsingStreamPromise = new DeferredPromise();
parsingStreamPromise.finally(() => {
through.destroy();
});
const parsedCommits = [];
through.pipe(parseCommitsStream()).on("error", (error) => parsingStreamPromise.reject(error)).on("data", (parsedCommit) => {
let resolvedParsingResult = parsedCommit;
if (!parsedCommit.header) return;
let typeAppendix;
if (COMMIT_HEADER_APPENDIX_REGEXP.test(parsedCommit.header)) {
const headerWithoutAppendix = parsedCommit.header.replace(COMMIT_HEADER_APPENDIX_REGEXP, "$1$3");
resolvedParsingResult = commitParser.parse(joinCommit(headerWithoutAppendix, parsedCommit.body));
typeAppendix = "!";
}
const originalCommit = commitMap.get(parsedCommit.header);
invariant(originalCommit, "Failed to parse commit \"%s\": no original commit found associated with header", parsedCommit.header);
const commit = Object.assign({}, resolvedParsingResult, {
hash: originalCommit.hash,
typeAppendix
});
parsedCommits.push(commit);
}).on("end", () => parsingStreamPromise.resolve(parsedCommits));
return parsingStreamPromise;
}
function joinCommit(subject, body) {
return [subject, body].filter(Boolean).join("\n");
}
//#endregion
export { parseCommits };
//#region src/utils/git/push.d.ts
declare function push(): Promise<void>;
//#endregion
export { push };
//#region src/utils/github/create-comment.d.ts
declare function createComment(issueId: string, body: string): Promise<void>;
//#endregion
export { createComment };
import { getInfo } from "../git/get-info.js";
import { invariant } from "outvariant";
//#region src/utils/github/create-comment.ts
async function createComment(issueId, body) {
const repo = await getInfo();
const response = await fetch(`https://api.github.com/repos/${repo.owner}/${repo.name}/issues/${issueId}/comments`, {
method: "POST",
headers: {
Authorization: `token ${process.env.GITHUB_TOKEN}`,
"Content-Type": "application/json"
},
body: JSON.stringify({ body })
});
invariant(response.ok, "Failed to create GitHub comment for \"%s\" issue.", issueId);
}
//#endregion
export { createComment };
import { ReleaseContext } from "../create-context.js";
import { GitHubRelease } from "./get-github-release.js";
//#region src/utils/github/create-github-release.d.ts
/**
* Create a new GitHub release with the given release notes.
* This is only called if there's no existing GitHub release
* for the next release tag.
* @return {string} The URL of the newly created release.
*/
declare function createGitHubRelease(context: ReleaseContext, notes: string): Promise<GitHubRelease>;
//#endregion
export { createGitHubRelease };
import { log } from "../../logger.js";
import { getGitHubRelease } from "./get-github-release.js";
import { format } from "outvariant";
import { lt } from "semver";
//#region src/utils/github/create-github-release.ts
/**
* Create a new GitHub release with the given release notes.
* This is only called if there's no existing GitHub release
* for the next release tag.
* @return {string} The URL of the newly created release.
*/
async function createGitHubRelease(context, notes) {
const { repo } = context;
log.info(format("creating a new GitHub release at \"%s/%s\"...", repo.owner, repo.name));
const latestGitHubRelease = await getGitHubRelease("latest").catch((error) => {
log.error(`Failed to fetch the latest GitHub release:`, error);
});
const shouldMarkAsLatest = latestGitHubRelease ? lt(latestGitHubRelease.tag_name || "0.0.0", context.nextRelease.tag) : void 0;
/**
* @see https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#create-a-release
*/
const response = await fetch(`https://api.github.com/repos/${repo.owner}/${repo.name}/releases`, {
method: "POST",
headers: {
Accept: "application/json",
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
tag_name: context.nextRelease.tag,
name: context.nextRelease.tag,
body: notes,
make_latest: shouldMarkAsLatest?.toString()
})
});
if (response.status === 401) throw new Error("Failed to create a new GitHub release: provided GITHUB_TOKEN does not have sufficient permissions to perform this operation. Please check your token and update it if necessary.");
if (response.status !== 201) throw new Error(format("Failed to create a new GitHub release: GitHub API responded with status code %d.", response.status, await response.text()));
return response.json();
}
//#endregion
export { createGitHubRelease };
import { ParsedCommitWithHash } from "../git/parse-commits.js";
//#region src/utils/github/get-commit-authors.d.ts
interface GetCommitAuthorsQuery {
repository: {
pullRequest: {
url: string;
author: {
login: string;
};
commits: {
nodes: Array<{
commit: {
authors: {
nodes: Array<{
user: {
login: string;
};
}>;
};
};
}>;
};
};
};
}
/**
* Get a list of GitHub usernames who have contributed
* to the given release commit. This analyzes all the commit
* authors in the pull request referenced by the given commit.
*/
declare function getCommitAuthors(commit: ParsedCommitWithHash): Promise<Set<string>>;
//#endregion
export { GetCommitAuthorsQuery, getCommitAuthors };
import { log } from "../../logger.js";
import { getInfo } from "../git/get-info.js";
import { format } from "outvariant";
//#region src/utils/github/get-commit-authors.ts
/**
* Get a list of GitHub usernames who have contributed
* to the given release commit. This analyzes all the commit
* authors in the pull request referenced by the given commit.
*/
async function getCommitAuthors(commit) {
const issueRefs = /* @__PURE__ */ new Set();
for (const ref of commit.references) if (ref.issue) issueRefs.add(ref.issue);
if (issueRefs.size === 0) return /* @__PURE__ */ new Set();
const repo = await getInfo();
const queue = [];
const authors = /* @__PURE__ */ new Set();
function addAuthor(login) {
if (!login) return;
authors.add(login);
}
for (const issueId of issueRefs) {
const authorLoginPromise = new Promise(async (resolve, reject) => {
const response = await fetch(`https://api.github.com/graphql`, {
method: "POST",
headers: {
Agent: "ossjs/release",
Accept: "application/json",
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
query: `
query GetCommitAuthors($owner: String!, $repo: String!, $pullRequestId: Int!) {
repository(owner: $owner name: $repo) {
pullRequest(number: $pullRequestId) {
url
author {
login
}
commits(first: 100) {
nodes {
commit {
authors(first: 100) {
nodes {
user {
login
}
}
}
}
}
}
}
}
}
`,
variables: {
owner: repo.owner,
repo: repo.name,
pullRequestId: Number(issueId)
}
})
});
if (!response.ok) return reject(new Error(format("GitHub API responded with %d.", response.status)));
const json = await response.json();
const data = json.data;
if (json.errors) return reject(new Error(format("GitHub API responded with %d error(s): %j", json.errors.length, json.errors)));
addAuthor(data.repository.pullRequest.author.login);
for (const commit$1 of data.repository.pullRequest.commits.nodes) for (const author of commit$1.commit.authors.nodes)
/**
* @note In some situations, GitHub will return "user: null"
* for the commit user. Nobody to add to the authors then.
*/
if (author.user != null) addAuthor(author.user.login);
resolve();
});
queue.push(authorLoginPromise.catch((error) => {
log.error(format("Failed to extract the authors for the issue #%d:", issueId, error.message));
}));
}
await Promise.allSettled(queue);
return authors;
}
//#endregion
export { getCommitAuthors };
//#region src/utils/github/get-github-release.d.ts
interface GitHubRelease {
tag_name: string;
html_url: string;
}
declare function getGitHubRelease(tag: string | ('latest' & {})): Promise<GitHubRelease | undefined>;
//#endregion
export { GitHubRelease, getGitHubRelease };
import { getInfo } from "../git/get-info.js";
import { invariant } from "outvariant";
//#region src/utils/github/get-github-release.ts
async function getGitHubRelease(tag) {
const repo = await getInfo();
const response = await fetch(tag === "latest" ? `https://api.github.com/repos/${repo.owner}/${repo.name}/releases/latest` : `https://api.github.com/repos/${repo.owner}/${repo.name}/releases/tags/${tag}`, { headers: {
Accept: "application/json",
Authorization: `token ${process.env.GITHUB_TOKEN}`
} });
if (response.status === 404) return;
invariant(response.ok, "Failed to fetch GitHub release for tag \"%s\": server responded with %d.\n\n%s", tag, response.status);
return response.json();
}
//#endregion
export { getGitHubRelease };
//#region src/utils/github/validate-access-token.d.ts
declare const requiredGitHubTokenScopes: string[];
declare const GITHUB_NEW_TOKEN_URL: string;
/**
* Check whether the given GitHub access token has sufficient permissions
* for this library to create and publish a new release.
*/
declare function validateAccessToken(accessToken: string): Promise<void>;
//#endregion
export { GITHUB_NEW_TOKEN_URL, requiredGitHubTokenScopes, validateAccessToken };
import { invariant } from "outvariant";
//#region src/utils/github/validate-access-token.ts
const requiredGitHubTokenScopes = [
"repo",
"admin:repo_hook",
"admin:org_hook"
];
const GITHUB_NEW_TOKEN_URL = `https://github.com/settings/tokens/new?scopes=${requiredGitHubTokenScopes.join(",")}`;
/**
* Check whether the given GitHub access token has sufficient permissions
* for this library to create and publish a new release.
*/
async function validateAccessToken(accessToken) {
const response = await fetch("https://api.github.com", { headers: { Authorization: `Bearer ${accessToken}` } });
const permissions = response.headers.get("x-oauth-scopes")?.split(",").map((scope) => scope.trim()) || [];
invariant(response.ok, "Failed to verify GitHub token permissions: GitHub API responded with %d %s. Please double-check your \"GITHUB_TOKEN\" environmental variable and try again.", response.status, response.statusText);
invariant(permissions.length > 0, "Failed to verify GitHub token permissions: GitHub API responded with an empty \"X-OAuth-Scopes\" header.");
const missingScopes = requiredGitHubTokenScopes.filter((scope) => {
return !permissions.includes(scope);
});
if (missingScopes.length > 0) invariant(false, "Provided \"GITHUB_TOKEN\" environment variable has insufficient permissions: missing scopes \"%s\". Please generate a new GitHub personal access token from this URL: %s", missingScopes.join(`", "`), GITHUB_NEW_TOKEN_URL);
}
//#endregion
export { GITHUB_NEW_TOKEN_URL, requiredGitHubTokenScopes, validateAccessToken };
//#region src/utils/read-package-json.d.ts
declare function readPackageJson(): Record<string, any>;
//#endregion
export { readPackageJson };
import { execAsync } from "./exec-async.js";
import * as path from "node:path";
import * as fs from "node:fs";
//#region src/utils/read-package-json.ts
function readPackageJson() {
const packageJsonPath = path.resolve(execAsync.contextOptions.cwd.toString(), "package.json");
return JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
}
//#endregion
export { readPackageJson };
import { ParsedCommitWithHash } from "../git/parse-commits.js";
//#region src/utils/release-notes/get-release-notes.d.ts
type ReleaseNoteType = 'breaking' | 'feat' | 'fix';
type GroupedCommits = Map<ReleaseNoteType, Set<ParsedCommitWithHash>>;
type ReleaseNoteCommit = ParsedCommitWithHash & {
[key: string]: any;
authors: Set<string>;
};
type ReleaseNotes = Map<ReleaseNoteType, Set<ReleaseNoteCommit>>;
declare function getReleaseNotes(commits: ParsedCommitWithHash[]): Promise<ReleaseNotes>;
declare function groupCommitsByReleaseType(commits: ParsedCommitWithHash[]): Promise<GroupedCommits>;
declare function injectReleaseContributors(groups: GroupedCommits): Promise<ReleaseNotes>;
//#endregion
export { GroupedCommits, ReleaseNoteCommit, ReleaseNoteType, ReleaseNotes, getReleaseNotes, groupCommitsByReleaseType, injectReleaseContributors };
import { isBreakingChange } from "../get-next-release-type.js";
import { getCommitAuthors } from "../github/get-commit-authors.js";
//#region src/utils/release-notes/get-release-notes.ts
const IGNORED_COMMIT_TYPES = ["chore"];
async function getReleaseNotes(commits) {
const groupedNotes = await groupCommitsByReleaseType(commits);
return await injectReleaseContributors(groupedNotes);
}
async function groupCommitsByReleaseType(commits) {
const groups = /* @__PURE__ */ new Map();
for (const commit of commits) {
const { type, merge } = commit;
if (!type || merge || IGNORED_COMMIT_TYPES.includes(type)) continue;
const noteType = isBreakingChange(commit) ? "breaking" : type;
const prevCommits = groups.get(noteType) || /* @__PURE__ */ new Set();
groups.set(noteType, prevCommits.add(commit));
}
return groups;
}
async function injectReleaseContributors(groups) {
const notes = /* @__PURE__ */ new Map();
for (const [releaseType, commits] of groups) {
notes.set(releaseType, /* @__PURE__ */ new Set());
for (const commit of commits) {
const authors = await getCommitAuthors(commit);
if (authors) {
const releaseCommit = Object.assign({}, commit, { authors });
notes.get(releaseType)?.add(releaseCommit);
}
}
}
return notes;
}
//#endregion
export { getReleaseNotes, groupCommitsByReleaseType, injectReleaseContributors };
import { ParsedCommitWithHash } from "../git/parse-commits.js";
//#region src/utils/release-notes/get-release-refs.d.ts
declare function getReleaseRefs(commits: ParsedCommitWithHash[]): Promise<Set<string>>;
interface IssueOrPullRequest {
html_url: string;
pull_request: Record<string, string> | null;
body: string | null;
}
//#endregion
export { IssueOrPullRequest, getReleaseRefs };
import { getInfo } from "../git/get-info.js";
import createIssueParser from "issue-parser";
//#region src/utils/release-notes/get-release-refs.ts
const parser = createIssueParser("github");
function extractIssueIds(text, repo) {
const ids = /* @__PURE__ */ new Set();
const parsed = parser(text);
for (const action of parsed.actions.close) if (action.slug == null || action.slug === `${repo.owner}/${repo.name}`) ids.add(action.issue);
return ids;
}
async function getReleaseRefs(commits) {
const repo = await getInfo();
const issueIds = /* @__PURE__ */ new Set();
for (const commit of commits) {
for (const ref of commit.references) if (ref.issue) issueIds.add(ref.issue);
if (commit.body) extractIssueIds(commit.body, repo).forEach((id) => issueIds.add(id));
}
const issuesFromCommits = await Promise.all(Array.from(issueIds).map(fetchIssue));
for (const issue of issuesFromCommits) {
if (!issue.pull_request || !issue.body) continue;
extractIssueIds(issue.body, repo).forEach((id) => issueIds.add(id));
}
return issueIds;
}
async function fetchIssue(id) {
const repo = await getInfo();
return await (await fetch(`https://api.github.com/repos/${repo.owner}/${repo.name}/issues/${id}`, { headers: { Authorization: `Bearer ${process.env.GITHUB_TOKEN}` } })).json();
}
//#endregion
export { getReleaseRefs };
import { ReleaseContext } from "../create-context.js";
import { ReleaseNotes } from "./get-release-notes.js";
//#region src/utils/release-notes/to-markdown.d.ts
/**
* Generate a Markdown string for the given release notes.
*/
declare function toMarkdown(context: ReleaseContext, notes: ReleaseNotes): string;
declare function printAuthors(authors: Set<string>): string | undefined;
//#endregion
export { printAuthors, toMarkdown };
import { formatDate } from "../format-date.js";
//#region src/utils/release-notes/to-markdown.ts
/**
* Generate a Markdown string for the given release notes.
*/
function toMarkdown(context, notes) {
const markdown = [];
const releaseDate = formatDate(context.nextRelease.publishedAt);
markdown.push(`## ${context.nextRelease.tag} (${releaseDate})`);
const sections = {
breaking: [],
feat: [],
fix: []
};
for (const [noteType, commits] of notes) {
const section = sections[noteType];
if (!section) continue;
for (const commit of commits) {
const releaseItem = createReleaseItem(commit, noteType === "breaking");
if (releaseItem) section.push(...releaseItem);
}
}
if (sections.breaking.length > 0) {
markdown.push("", "### ⚠️ BREAKING CHANGES");
markdown.push(...sections.breaking);
}
if (sections.feat.length > 0) {
markdown.push("", "### Features", "");
markdown.push(...sections.feat);
}
if (sections.fix.length > 0) {
markdown.push("", "### Bug Fixes", "");
markdown.push(...sections.fix);
}
return markdown.join("\n");
}
function createReleaseItem(commit, includeCommitNotes = false) {
const { subject, scope, hash } = commit;
if (!subject) return [];
const commitLine = [[
"-",
scope && `**${scope}:**`,
subject,
`(${hash})`,
printAuthors(commit.authors)
].filter(Boolean).join(" ")];
if (includeCommitNotes) {
const notes = commit.notes.reduce((all, note) => {
return all.concat("", note.text);
}, []);
if (notes.length > 0) {
commitLine.unshift("");
commitLine.push(...notes);
}
}
return commitLine;
}
function printAuthors(authors) {
if (authors.size === 0) return;
return Array.from(authors).map((login) => `@${login}`).join(" ");
}
//#endregion
export { printAuthors, toMarkdown };
//#region src/utils/write-package-json.d.ts
declare function writePackageJson(nextContent: Record<string, any>): void;
//#endregion
export { writePackageJson };
import { execAsync } from "./exec-async.js";
import * as path from "node:path";
import * as fs from "node:fs";
//#region src/utils/write-package-json.ts
function writePackageJson(nextContent) {
const packageJsonPath = path.resolve(execAsync.contextOptions.cwd.toString(), "package.json");
fs.writeFileSync(
packageJsonPath,
/**
* @fixme Do not alter the indentation.
*/
JSON.stringify(nextContent, null, 2)
);
}
//#endregion
export { writePackageJson };
#!/usr/bin/env node
import('./build/index.js')
+18
-20

@@ -1,20 +0,18 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Command = void 0;
const logger_1 = require("./logger");
class Command {
config;
argv;
static command;
static description;
static builder = () => { };
log;
constructor(config, argv) {
this.config = config;
this.argv = argv;
this.log = logger_1.log;
}
run = async () => { };
}
exports.Command = Command;
//# sourceMappingURL=Command.js.map
import { log } from "./logger.js";
//#region src/Command.ts
var Command = class {
static command;
static description;
static builder = () => {};
log;
constructor(config, argv) {
this.config = config;
this.argv = argv;
this.log = log;
}
run = async () => {};
};
//#endregion
export { Command };

@@ -1,96 +0,83 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Notes = void 0;
const outvariant_1 = require("outvariant");
const env_1 = require("../utils/env");
const createGitHubRelease_1 = require("../utils/github/createGitHubRelease");
const Command_1 = require("../Command");
const getInfo_1 = require("../utils/git/getInfo");
const parseCommits_1 = require("../utils/git/parseCommits");
const getReleaseNotes_1 = require("../utils/release-notes/getReleaseNotes");
const toMarkdown_1 = require("../utils/release-notes/toMarkdown");
const getCommits_1 = require("../utils/git/getCommits");
const getTag_1 = require("../utils/git/getTag");
const getCommit_1 = require("../utils/git/getCommit");
const getLatestRelease_1 = require("../utils/git/getLatestRelease");
const getTags_1 = require("../utils/git/getTags");
const getGitHubRelease_1 = require("../utils/github/getGitHubRelease");
class Notes extends Command_1.Command {
static command = 'notes';
static description = 'Generate GitHub release notes for the given release version.';
static builder = (yargs) => {
return yargs.usage('$ notes [tag]').positional('tag', {
type: 'string',
desciption: 'Release tag',
demandOption: true,
});
};
run = async () => {
await (0, env_1.demandGitHubToken)().catch((error) => {
this.log.error(error.message);
process.exit(1);
});
const repo = await (0, getInfo_1.getInfo)();
const [, tagInput] = this.argv._;
const tagName = tagInput.startsWith('v') ? tagInput : `v${tagInput}`;
const version = tagInput.replace(/^v/, '');
// Check if there's an existing GitHub release for the given tag.
const existingRelease = await (0, getGitHubRelease_1.getGitHubRelease)(tagName);
if (existingRelease) {
this.log.warn((0, outvariant_1.format)('found existing GitHub release for "%s": %s', tagName, existingRelease.html_url));
return process.exit(1);
}
this.log.info((0, outvariant_1.format)('creating GitHub release for version "%s" in "%s/%s"...', tagName, repo.owner, repo.name));
// Retrieve the information about the given release version.
const tagPointer = await (0, getTag_1.getTag)(tagName);
(0, outvariant_1.invariant)(tagPointer, 'Failed to create GitHub release: unknown tag "%s". Please make sure you are providing an existing release tag.', tagName);
this.log.info((0, outvariant_1.format)('found release tag "%s" (%s)', tagPointer.tag, tagPointer.hash));
const releaseCommit = await (0, getCommit_1.getCommit)(tagPointer.hash);
(0, outvariant_1.invariant)(releaseCommit, 'Failed to create GitHub release: unable to retrieve the commit by tag "%s" (%s).', tagPointer.tag, tagPointer.hash);
// Retrieve the pointer to the previous release.
const tags = await (0, getTags_1.getTags)().then((tags) => {
return tags.sort(getLatestRelease_1.byReleaseVersion);
});
const tagReleaseIndex = tags.indexOf(tagPointer.tag);
const previousReleaseTag = tags[tagReleaseIndex + 1];
const previousRelease = previousReleaseTag
? await (0, getTag_1.getTag)(previousReleaseTag)
: undefined;
if (previousRelease?.hash) {
this.log.info((0, outvariant_1.format)('found preceding release "%s" (%s)', previousRelease.tag, previousRelease.hash));
}
else {
this.log.info((0, outvariant_1.format)('found no released preceding "%s": analyzing all commits until "%s"...', tagPointer.tag, tagPointer.hash));
}
// Get commits list between the given release and the previous release.
const commits = await (0, getCommits_1.getCommits)({
since: previousRelease?.hash,
until: tagPointer.hash,
}).then(parseCommits_1.parseCommits);
const context = {
repo,
nextRelease: {
version,
tag: tagPointer.tag,
publishedAt: releaseCommit.author.date,
},
latestRelease: previousRelease,
};
// Generate release notes for the commits.
const releaseNotes = await Notes.generateReleaseNotes(context, commits);
this.log.info((0, outvariant_1.format)('generated release notes:\n%s', releaseNotes));
// Create GitHub release.
const release = await Notes.createRelease(context, releaseNotes);
this.log.info((0, outvariant_1.format)('created GitHub release: %s', release.html_url));
};
static async generateReleaseNotes(context, commits) {
const releaseNotes = await (0, getReleaseNotes_1.getReleaseNotes)(commits);
const markdown = (0, toMarkdown_1.toMarkdown)(context, releaseNotes);
return markdown;
}
static async createRelease(context, notes) {
return (0, createGitHubRelease_1.createGitHubRelease)(context, notes);
}
}
exports.Notes = Notes;
//# sourceMappingURL=notes.js.map
import { Command } from "../Command.js";
import { getTag } from "../utils/git/get-tag.js";
import { byReleaseVersion } from "../utils/git/get-latest-release.js";
import { getTags } from "../utils/git/get-tags.js";
import { getCommit } from "../utils/git/get-commit.js";
import { getInfo } from "../utils/git/get-info.js";
import { demandGitHubToken } from "../utils/env.js";
import { parseCommits } from "../utils/git/parse-commits.js";
import { getCommits } from "../utils/git/get-commits.js";
import { getGitHubRelease } from "../utils/github/get-github-release.js";
import { createGitHubRelease } from "../utils/github/create-github-release.js";
import { getReleaseNotes } from "../utils/release-notes/get-release-notes.js";
import { toMarkdown } from "../utils/release-notes/to-markdown.js";
import { format, invariant } from "outvariant";
//#region src/commands/notes.ts
var Notes = class Notes extends Command {
static command = "notes";
static description = "Generate GitHub release notes for the given release version.";
static builder = (yargs) => {
return yargs.usage("$ notes [tag]").positional("tag", {
type: "string",
desciption: "Release tag",
demandOption: true
});
};
run = async () => {
await demandGitHubToken().catch((error) => {
this.log.error(error.message);
process.exit(1);
});
const repo = await getInfo();
const [, tagInput] = this.argv._;
const tagName = tagInput.startsWith("v") ? tagInput : `v${tagInput}`;
const version = tagInput.replace(/^v/, "");
const existingRelease = await getGitHubRelease(tagName);
if (existingRelease) {
this.log.warn(format("found existing GitHub release for \"%s\": %s", tagName, existingRelease.html_url));
return process.exit(1);
}
this.log.info(format("creating GitHub release for version \"%s\" in \"%s/%s\"...", tagName, repo.owner, repo.name));
const tagPointer = await getTag(tagName);
invariant(tagPointer, "Failed to create GitHub release: unknown tag \"%s\". Please make sure you are providing an existing release tag.", tagName);
this.log.info(format("found release tag \"%s\" (%s)", tagPointer.tag, tagPointer.hash));
const releaseCommit = await getCommit(tagPointer.hash);
invariant(releaseCommit, "Failed to create GitHub release: unable to retrieve the commit by tag \"%s\" (%s).", tagPointer.tag, tagPointer.hash);
const tags = await getTags().then((tags$1) => {
return tags$1.sort(byReleaseVersion);
});
const tagReleaseIndex = tags.indexOf(tagPointer.tag);
const previousReleaseTag = tags[tagReleaseIndex + 1];
const previousRelease = previousReleaseTag ? await getTag(previousReleaseTag) : void 0;
if (previousRelease?.hash) this.log.info(format("found preceding release \"%s\" (%s)", previousRelease.tag, previousRelease.hash));
else this.log.info(format("found no released preceding \"%s\": analyzing all commits until \"%s\"...", tagPointer.tag, tagPointer.hash));
const commits = await getCommits({
since: previousRelease?.hash,
until: tagPointer.hash
}).then(parseCommits);
const context = {
repo,
nextRelease: {
version,
tag: tagPointer.tag,
publishedAt: releaseCommit.author.date
},
latestRelease: previousRelease
};
const releaseNotes = await Notes.generateReleaseNotes(context, commits);
this.log.info(format("generated release notes:\n%s", releaseNotes));
const release = await Notes.createRelease(context, releaseNotes);
this.log.info(format("created GitHub release: %s", release.html_url));
};
static async generateReleaseNotes(context, commits) {
const releaseNotes = await getReleaseNotes(commits);
return toMarkdown(context, releaseNotes);
}
static async createRelease(context, notes) {
return createGitHubRelease(context, notes);
}
};
//#endregion
export { Notes };

@@ -1,329 +0,294 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Publish = void 0;
const until_1 = require("@open-draft/until");
const outvariant_1 = require("outvariant");
const Command_1 = require("../Command");
const createContext_1 = require("../utils/createContext");
const getInfo_1 = require("../utils/git/getInfo");
const getNextReleaseType_1 = require("../utils/getNextReleaseType");
const getNextVersion_1 = require("../utils/getNextVersion");
const getCommits_1 = require("../utils/git/getCommits");
const getCurrentBranch_1 = require("../utils/git/getCurrentBranch");
const getLatestRelease_1 = require("../utils/git/getLatestRelease");
const bumpPackageJson_1 = require("../utils/bumpPackageJson");
const getTags_1 = require("../utils/git/getTags");
const execAsync_1 = require("../utils/execAsync");
const commit_1 = require("../utils/git/commit");
const createTag_1 = require("../utils/git/createTag");
const push_1 = require("../utils/git/push");
const getReleaseRefs_1 = require("../utils/release-notes/getReleaseRefs");
const parseCommits_1 = require("../utils/git/parseCommits");
const createComment_1 = require("../utils/github/createComment");
const createReleaseComment_1 = require("../utils/createReleaseComment");
const env_1 = require("../utils/env");
const notes_1 = require("./notes");
class Publish extends Command_1.Command {
static command = 'publish';
static description = 'Publish the package';
static builder = (yargs) => {
return yargs
.usage('$0 publish [options]')
.option('profile', {
alias: 'p',
type: 'string',
default: 'latest',
demandOption: true,
})
.option('dry-run', {
alias: 'd',
type: 'boolean',
default: false,
demandOption: false,
description: 'Print command steps without executing them',
});
};
profile = null;
context = null;
/**
* The list of clean-up functions to invoke if release fails.
*/
revertQueue = [];
run = async () => {
const profileName = this.argv.profile;
const profileDefinition = this.config.profiles.find((definedProfile) => {
return definedProfile.name === profileName;
});
(0, outvariant_1.invariant)(profileDefinition, 'Failed to publish: no profile found by name "%s". Did you forget to define it in "release.config.json"?', profileName);
this.profile = profileDefinition;
await (0, env_1.demandGitHubToken)().catch((error) => {
this.log.error(error.message);
process.exit(1);
});
await (0, env_1.demandNpmToken)().catch((error) => {
this.log.error(error.message);
process.exit(1);
});
this.revertQueue = [];
// Extract repository information (remote/owner/name).
const repo = await (0, getInfo_1.getInfo)().catch((error) => {
console.error(error);
throw new Error('Failed to get Git repository information');
});
const branchName = await (0, getCurrentBranch_1.getCurrentBranch)().catch((error) => {
console.error(error);
throw new Error('Failed to get the current branch name');
});
this.log.info((0, outvariant_1.format)('preparing release for "%s/%s" from branch "%s"...', repo.owner, repo.name, branchName));
/**
* Get the latest release.
* @note This refers to the latest release tag at the current
* state of the branch. Since Release doesn't do branch analysis,
* this doesn't guarantee the latest release in general
* (consider backport releases where you checkout an old SHA).
*/
const tags = await (0, getTags_1.getTags)();
const latestRelease = await (0, getLatestRelease_1.getLatestRelease)(tags);
if (latestRelease) {
this.log.info((0, outvariant_1.format)('found latest release: %s (%s)', latestRelease.tag, latestRelease.hash));
}
else {
this.log.info('found no previous releases, creating the first one...');
}
const rawCommits = await (0, getCommits_1.getCommits)({
since: latestRelease?.hash,
});
this.log.info((0, outvariant_1.format)('found %d new %s:\n%s', rawCommits.length, rawCommits.length > 1 ? 'commits' : 'commit', rawCommits
.map((commit) => (0, outvariant_1.format)(' - %s %s', commit.hash, commit.subject))
.join('\n')));
const commits = await (0, parseCommits_1.parseCommits)(rawCommits);
this.log.info((0, outvariant_1.format)('successfully parsed %d commit(s)!', commits.length));
if (commits.length === 0) {
this.log.warn('no commits since the latest release, skipping...');
return;
}
// Get the next release type and version number.
const nextReleaseType = (0, getNextReleaseType_1.getNextReleaseType)(commits, {
prerelease: this.profile.prerelease,
});
if (!nextReleaseType) {
this.log.warn('committed changes do not bump version, skipping...');
return;
}
const prevVersion = latestRelease?.tag || 'v0.0.0';
const nextVersion = (0, getNextVersion_1.getNextVersion)(prevVersion, nextReleaseType);
this.context = (0, createContext_1.createContext)({
repo,
latestRelease,
nextRelease: {
version: nextVersion,
publishedAt: new Date(),
},
});
this.log.info((0, outvariant_1.format)('release type "%s": %s -> %s', nextReleaseType, prevVersion.replace(/^v/, ''), this.context.nextRelease.version));
// Bump the version in package.json without committing it.
if (this.argv.dryRun) {
this.log.warn((0, outvariant_1.format)('skip version bump in package.json in dry-run mode (next: %s)', nextVersion));
}
else {
(0, bumpPackageJson_1.bumpPackageJson)(nextVersion);
this.log.info((0, outvariant_1.format)('bumped version in package.json to: %s', nextVersion));
}
// Execute the publishing script.
await this.runReleaseScript();
const result = await (0, until_1.until)(async () => {
await this.createReleaseCommit();
await this.createReleaseTag();
await this.pushToRemote();
const releaseNotes = await this.generateReleaseNotes(commits);
const releaseUrl = await this.createGitHubRelease(releaseNotes);
return {
releaseUrl,
};
});
// Handle any errors during the release process the same way.
if (result.error) {
this.log.error(result.error.message);
/**
* @todo Suggest a standalone command to repeat the commit/tag/release
* part of the publishing. The actual publish script was called anyway,
* so the package has been published at this point, just the Git info
* updates are missing.
*/
this.log.error('release failed, reverting changes...');
// Revert changes in case of errors.
await this.revertChanges();
return process.exit(1);
}
// Comment on each relevant GitHub issue.
await this.commentOnIssues(commits, result.data.releaseUrl);
if (this.argv.dryRun) {
this.log.warn((0, outvariant_1.format)('release "%s" completed in dry-run mode!', this.context.nextRelease.tag));
return;
}
this.log.info((0, outvariant_1.format)('release "%s" completed!', this.context.nextRelease.tag));
};
/**
* Execute the release script specified in the configuration.
*/
async runReleaseScript() {
const env = {
RELEASE_VERSION: this.context.nextRelease.version,
};
this.log.info((0, outvariant_1.format)('preparing to run the publishing script with:\n%j', env));
if (this.argv.dryRun) {
this.log.warn('skip executing publishing script in dry-run mode');
return;
}
this.log.info((0, outvariant_1.format)('executing publishing script for profile "%s": %s'), this.profile.name, this.profile.use);
const releaseScriptPromise = (0, execAsync_1.execAsync)(this.profile.use, {
env: {
...process.env,
...env,
},
});
// Forward the publish script's stdio to the logger.
releaseScriptPromise.io.stdout?.pipe(process.stdout);
releaseScriptPromise.io.stderr?.pipe(process.stderr);
await releaseScriptPromise.catch((error) => {
this.log.error(error);
this.log.error('Failed to publish: the publish script errored. See the original error above.');
process.exit(releaseScriptPromise.io.exitCode || 1);
});
this.log.info('published successfully!');
}
/**
* Revert those changes that were marked as revertable.
*/
async revertChanges() {
let revert;
while ((revert = this.revertQueue.pop())) {
await revert();
}
}
/**
* Create a release commit in Git.
*/
async createReleaseCommit() {
const message = `chore(release): ${this.context.nextRelease.tag}`;
if (this.argv.dryRun) {
this.log.warn((0, outvariant_1.format)('skip creating a release commit in dry-run mode: "%s"', message));
return;
}
const commitResult = await (0, until_1.until)(() => {
return (0, commit_1.commit)({
files: ['package.json'],
message,
});
});
(0, outvariant_1.invariant)(commitResult.error == null, 'Failed to create release commit!\n', commitResult.error);
this.log.info((0, outvariant_1.format)('created a release commit at "%s"!', commitResult.data.hash));
this.revertQueue.push(async () => {
this.log.info('reverting the release commit...');
const hasChanges = await (0, execAsync_1.execAsync)('git diff');
if (hasChanges) {
this.log.info('detected uncommitted changes, stashing...');
await (0, execAsync_1.execAsync)('git stash');
}
await (0, execAsync_1.execAsync)('git reset --hard HEAD~1').finally(async () => {
if (hasChanges) {
this.log.info('unstashing uncommitted changes...');
await (0, execAsync_1.execAsync)('git stash pop');
}
});
});
}
/**
* Create a release tag in Git.
*/
async createReleaseTag() {
const nextTag = this.context.nextRelease.tag;
if (this.argv.dryRun) {
this.log.warn((0, outvariant_1.format)('skip creating a release tag in dry-run mode: %s', nextTag));
return;
}
const tagResult = await (0, until_1.until)(async () => {
const tag = await (0, createTag_1.createTag)(nextTag);
await (0, execAsync_1.execAsync)(`git push origin ${tag}`);
return tag;
});
(0, outvariant_1.invariant)(tagResult.error == null, 'Failed to tag the release!\n', tagResult.error);
this.revertQueue.push(async () => {
const tagToRevert = this.context.nextRelease.tag;
this.log.info((0, outvariant_1.format)('reverting the release tag "%s"...', tagToRevert));
await (0, execAsync_1.execAsync)(`git tag -d ${tagToRevert}`);
await (0, execAsync_1.execAsync)(`git push --delete origin ${tagToRevert}`);
});
this.log.info((0, outvariant_1.format)('created release tag "%s"!', tagResult.data));
}
/**
* Generate release notes from the given commits.
*/
async generateReleaseNotes(commits) {
this.log.info((0, outvariant_1.format)('generating release notes for %d commits...', commits.length));
const releaseNotes = await notes_1.Notes.generateReleaseNotes(this.context, commits);
this.log.info(`generated release notes:\n\n${releaseNotes}\n`);
return releaseNotes;
}
/**
* Push the release commit and tag to the remote.
*/
async pushToRemote() {
if (this.argv.dryRun) {
this.log.warn('skip pushing release to Git in dry-run mode');
return;
}
const pushResult = await (0, until_1.until)(() => (0, push_1.push)());
(0, outvariant_1.invariant)(pushResult.error == null, 'Failed to push changes to origin!\n', pushResult.error);
this.log.info((0, outvariant_1.format)('pushed changes to "%s" (origin)!', this.context.repo.remote));
}
/**
* Create a new GitHub release.
*/
async createGitHubRelease(releaseNotes) {
this.log.info('creating a new GitHub release...');
if (this.argv.dryRun) {
this.log.warn('skip creating a GitHub release in dry-run mode');
return '#';
}
const release = await notes_1.Notes.createRelease(this.context, releaseNotes);
const { html_url: releaseUrl } = release;
this.log.info((0, outvariant_1.format)('created release: %s', releaseUrl));
return releaseUrl;
}
/**
* Comment on referenced GitHub issues and pull requests.
*/
async commentOnIssues(commits, releaseUrl) {
this.log.info('commenting on referenced GitHib issues...');
const referencedIssueIds = await (0, getReleaseRefs_1.getReleaseRefs)(commits);
const issuesCount = referencedIssueIds.size;
const releaseCommentText = (0, createReleaseComment_1.createReleaseComment)({
context: this.context,
releaseUrl,
});
if (issuesCount === 0) {
this.log.info('no referenced GitHub issues, nothing to comment!');
return;
}
this.log.info((0, outvariant_1.format)('found %d referenced GitHub issues!', issuesCount));
const issuesNoun = issuesCount === 1 ? 'issue' : 'issues';
const issuesDisplayList = Array.from(referencedIssueIds)
.map((id) => ` - ${id}`)
.join('\n');
if (this.argv.dryRun) {
this.log.warn((0, outvariant_1.format)('skip commenting on %d GitHub %s:\n%s', issuesCount, issuesNoun, issuesDisplayList));
return;
}
this.log.info((0, outvariant_1.format)('commenting on %d GitHub %s:\n%s', issuesCount, issuesNoun, issuesDisplayList));
const commentPromises = [];
for (const issueId of referencedIssueIds) {
commentPromises.push((0, createComment_1.createComment)(issueId, releaseCommentText).catch((error) => {
this.log.error((0, outvariant_1.format)('commenting on issue "%s" failed: %s', error.message));
}));
}
await Promise.allSettled(commentPromises);
}
}
exports.Publish = Publish;
//# sourceMappingURL=publish.js.map
import { Command } from "../Command.js";
import "../utils/get-config.js";
import { execAsync } from "../utils/exec-async.js";
import { getLatestRelease } from "../utils/git/get-latest-release.js";
import { getTags } from "../utils/git/get-tags.js";
import { getInfo } from "../utils/git/get-info.js";
import { demandGitHubToken, demandNpmToken } from "../utils/env.js";
import { createContext } from "../utils/create-context.js";
import { parseCommits } from "../utils/git/parse-commits.js";
import { getNextReleaseType } from "../utils/get-next-release-type.js";
import { getNextVersion } from "../utils/get-next-version.js";
import { getCommits } from "../utils/git/get-commits.js";
import { getCurrentBranch } from "../utils/git/get-current-branch.js";
import { bumpPackageJson } from "../utils/bump-package-json.js";
import { commit } from "../utils/git/commit.js";
import { createTag } from "../utils/git/create-tag.js";
import { push } from "../utils/git/push.js";
import { getReleaseRefs } from "../utils/release-notes/get-release-refs.js";
import { createComment } from "../utils/github/create-comment.js";
import { createReleaseComment } from "../utils/create-release-comment.js";
import { Notes } from "./notes.js";
import "yargs";
import { format, invariant } from "outvariant";
import { until } from "until-async";
//#region src/commands/publish.ts
var Publish = class extends Command {
static command = "publish";
static description = "Publish the package";
static builder = (yargs$1) => {
return yargs$1.usage("$0 publish [options]").option("profile", {
alias: "p",
type: "string",
default: "latest",
demandOption: true
}).option("dry-run", {
alias: "d",
type: "boolean",
default: false,
demandOption: false,
description: "Print command steps without executing them"
});
};
profile = null;
context = null;
/**
* The list of clean-up functions to invoke if release fails.
*/
revertQueue = [];
run = async () => {
const profileName = this.argv.profile;
const profileDefinition = this.config.profiles.find((definedProfile) => {
return definedProfile.name === profileName;
});
invariant(profileDefinition, "Failed to publish: no profile found by name \"%s\". Did you forget to define it in \"release.config.json\"?", profileName);
this.profile = profileDefinition;
await demandGitHubToken().catch((error) => {
this.log.error(error.message);
process.exit(1);
});
await demandNpmToken().catch((error) => {
this.log.error(error.message);
process.exit(1);
});
this.revertQueue = [];
const repo = await getInfo().catch((error) => {
console.error(error);
throw new Error("Failed to get Git repository information");
});
const branchName = await getCurrentBranch().catch((error) => {
console.error(error);
throw new Error("Failed to get the current branch name");
});
this.log.info(format("preparing release for \"%s/%s\" from branch \"%s\"...", repo.owner, repo.name, branchName));
/**
* Get the latest release.
* @note This refers to the latest release tag at the current
* state of the branch. Since Release doesn't do branch analysis,
* this doesn't guarantee the latest release in general
* (consider backport releases where you checkout an old SHA).
*/
const tags = await getTags();
const latestRelease = await getLatestRelease(tags);
if (latestRelease) this.log.info(format("found latest release: %s (%s)", latestRelease.tag, latestRelease.hash));
else this.log.info("found no previous releases, creating the first one...");
const rawCommits = await getCommits({ since: latestRelease?.hash });
this.log.info(format("found %d new %s:\n%s", rawCommits.length, rawCommits.length > 1 ? "commits" : "commit", rawCommits.map((commit$1) => format(" - %s %s", commit$1.hash, commit$1.subject)).join("\n")));
const commits = await parseCommits(rawCommits);
this.log.info(format("successfully parsed %d commit(s)!", commits.length));
if (commits.length === 0) {
this.log.warn("no commits since the latest release, skipping...");
return;
}
const nextReleaseType = getNextReleaseType(commits, { prerelease: this.profile.prerelease });
if (!nextReleaseType) {
this.log.warn("committed changes do not bump version, skipping...");
return;
}
const prevVersion = latestRelease?.tag || "v0.0.0";
const nextVersion = getNextVersion(prevVersion, nextReleaseType);
this.context = createContext({
repo,
latestRelease,
nextRelease: {
version: nextVersion,
publishedAt: /* @__PURE__ */ new Date()
}
});
this.log.info(format("release type \"%s\": %s -> %s", nextReleaseType, prevVersion.replace(/^v/, ""), this.context.nextRelease.version));
if (this.argv.dryRun) this.log.warn(format("skip version bump in package.json in dry-run mode (next: %s)", nextVersion));
else {
bumpPackageJson(nextVersion);
this.log.info(format("bumped version in package.json to: %s", nextVersion));
}
await this.runReleaseScript();
const [resultError, resultData] = await until(async () => {
await this.createReleaseCommit();
await this.createReleaseTag();
await this.pushToRemote();
const releaseNotes = await this.generateReleaseNotes(commits);
return { releaseUrl: await this.createGitHubRelease(releaseNotes) };
});
if (resultError) {
this.log.error(resultError.message);
/**
* @todo Suggest a standalone command to repeat the commit/tag/release
* part of the publishing. The actual publish script was called anyway,
* so the package has been published at this point, just the Git info
* updates are missing.
*/
this.log.error("release failed, reverting changes...");
await this.revertChanges();
return process.exit(1);
}
await this.commentOnIssues(commits, resultData.releaseUrl);
if (this.argv.dryRun) {
this.log.warn(format("release \"%s\" completed in dry-run mode!", this.context.nextRelease.tag));
return;
}
this.log.info(format("release \"%s\" completed!", this.context.nextRelease.tag));
};
/**
* Execute the release script specified in the configuration.
*/
async runReleaseScript() {
const env = { RELEASE_VERSION: this.context.nextRelease.version };
this.log.info(format("preparing to run the publishing script with:\n%j", env));
if (this.argv.dryRun) {
this.log.warn("skip executing publishing script in dry-run mode");
return;
}
this.log.info(format("executing publishing script for profile \"%s\": %s"), this.profile.name, this.profile.use);
const releaseScriptPromise = execAsync(this.profile.use, { env: {
...process.env,
...env
} });
releaseScriptPromise.io.stdout?.pipe(process.stdout);
releaseScriptPromise.io.stderr?.pipe(process.stderr);
await releaseScriptPromise.catch((error) => {
this.log.error(error);
this.log.error("Failed to publish: the publish script errored. See the original error above.");
process.exit(releaseScriptPromise.io.exitCode || 1);
});
this.log.info("published successfully!");
}
/**
* Revert those changes that were marked as revertable.
*/
async revertChanges() {
let revert;
while (revert = this.revertQueue.pop()) await revert();
}
/**
* Create a release commit in Git.
*/
async createReleaseCommit() {
const message = `chore(release): ${this.context.nextRelease.tag}`;
if (this.argv.dryRun) {
this.log.warn(format("skip creating a release commit in dry-run mode: \"%s\"", message));
return;
}
const [commitError, commitData] = await until(() => {
return commit({
files: ["package.json"],
message
});
});
invariant(commitError == null, "Failed to create release commit!\n", commitError);
this.log.info(format("created a release commit at \"%s\"!", commitData.hash));
this.revertQueue.push(async () => {
this.log.info("reverting the release commit...");
const hasChanges = await execAsync("git diff");
if (hasChanges) {
this.log.info("detected uncommitted changes, stashing...");
await execAsync("git stash");
}
await execAsync("git reset --hard HEAD~1").finally(async () => {
if (hasChanges) {
this.log.info("unstashing uncommitted changes...");
await execAsync("git stash pop");
}
});
});
}
/**
* Create a release tag in Git.
*/
async createReleaseTag() {
const nextTag = this.context.nextRelease.tag;
if (this.argv.dryRun) {
this.log.warn(format("skip creating a release tag in dry-run mode: %s", nextTag));
return;
}
const [tagError, tagData] = await until(async () => {
const tag = await createTag(nextTag);
await execAsync(`git push origin ${tag}`);
return tag;
});
invariant(tagError == null, "Failed to tag the release!\n", tagError);
this.revertQueue.push(async () => {
const tagToRevert = this.context.nextRelease.tag;
this.log.info(format("reverting the release tag \"%s\"...", tagToRevert));
await execAsync(`git tag -d ${tagToRevert}`);
await execAsync(`git push --delete origin ${tagToRevert}`);
});
this.log.info(format("created release tag \"%s\"!", tagData));
}
/**
* Generate release notes from the given commits.
*/
async generateReleaseNotes(commits) {
this.log.info(format("generating release notes for %d commits...", commits.length));
const releaseNotes = await Notes.generateReleaseNotes(this.context, commits);
this.log.info(`generated release notes:\n\n${releaseNotes}\n`);
return releaseNotes;
}
/**
* Push the release commit and tag to the remote.
*/
async pushToRemote() {
if (this.argv.dryRun) {
this.log.warn("skip pushing release to Git in dry-run mode");
return;
}
const [pushError] = await until(() => push());
invariant(pushError == null, "Failed to push changes to origin!\n", pushError);
this.log.info(format("pushed changes to \"%s\" (origin)!", this.context.repo.remote));
}
/**
* Create a new GitHub release.
*/
async createGitHubRelease(releaseNotes) {
this.log.info("creating a new GitHub release...");
if (this.argv.dryRun) {
this.log.warn("skip creating a GitHub release in dry-run mode");
return "#";
}
const { html_url: releaseUrl } = await Notes.createRelease(this.context, releaseNotes);
this.log.info(format("created release: %s", releaseUrl));
return releaseUrl;
}
/**
* Comment on referenced GitHub issues and pull requests.
*/
async commentOnIssues(commits, releaseUrl) {
this.log.info("commenting on referenced GitHib issues...");
const referencedIssueIds = await getReleaseRefs(commits);
const issuesCount = referencedIssueIds.size;
const releaseCommentText = createReleaseComment({
context: this.context,
releaseUrl
});
if (issuesCount === 0) {
this.log.info("no referenced GitHub issues, nothing to comment!");
return;
}
this.log.info(format("found %d referenced GitHub issues!", issuesCount));
const issuesNoun = issuesCount === 1 ? "issue" : "issues";
const issuesDisplayList = Array.from(referencedIssueIds).map((id) => ` - ${id}`).join("\n");
if (this.argv.dryRun) {
this.log.warn(format("skip commenting on %d GitHub %s:\n%s", issuesCount, issuesNoun, issuesDisplayList));
return;
}
this.log.info(format("commenting on %d GitHub %s:\n%s", issuesCount, issuesNoun, issuesDisplayList));
const commentPromises = [];
for (const issueId of referencedIssueIds) commentPromises.push(createComment(issueId, releaseCommentText).catch((error) => {
this.log.error(format("commenting on issue \"%s\" failed: %s", error.message));
}));
await Promise.allSettled(commentPromises);
}
};
//#endregion
export { Publish };

@@ -1,106 +0,81 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
import { Command } from "../Command.js";
import { execAsync } from "../utils/exec-async.js";
import { getTag } from "../utils/git/get-tag.js";
import { getLatestRelease } from "../utils/git/get-latest-release.js";
import { getTags } from "../utils/git/get-tags.js";
import { getCommit } from "../utils/git/get-commit.js";
import { getInfo } from "../utils/git/get-info.js";
import { demandGitHubToken } from "../utils/env.js";
import { format, invariant } from "outvariant";
//#region src/commands/show.ts
let ReleaseStatus = /* @__PURE__ */ function(ReleaseStatus$1) {
/**
* Release is public and available for everybody to see
* on the GitHub releases page.
*/
ReleaseStatus$1["Public"] = "public";
/**
* Release is pushed to GitHub but is marked as draft.
*/
ReleaseStatus$1["Draft"] = "draft";
/**
* Release is local, not present on GitHub.
*/
ReleaseStatus$1["Unpublished"] = "unpublished";
return ReleaseStatus$1;
}({});
var Show = class extends Command {
static command = "show";
static description = "Show release info";
static builder = (yargs) => {
return yargs.usage("$0 show [tag]").example([["$0 show", "Show the latest release info"], ["$0 show 1.2.3", "Show specific release tag info"]]).positional("tag", {
type: "string",
description: "Release tag",
demandOption: false
});
};
run = async () => {
await demandGitHubToken().catch((error) => {
this.log.error(error.message);
process.exit(1);
});
const [, tag] = this.argv._;
const pointer = await this.getTagPointer(tag?.toString());
this.log.info(format("found tag \"%s\"!", pointer.tag));
const commit = await getCommit(pointer.hash);
invariant(commit, "Failed to retrieve release info for tag \"%s\": cannot find commit associated with the tag.", tag);
const commitOut = await execAsync(`git log -1 ${commit.commit.long}`).then(({ stdout }) => stdout);
this.log.info(commitOut);
const repo = await getInfo();
const releaseResponse = await fetch(`https://api.github.com/repos/${repo.owner}/${repo.name}/releases/tags/${pointer.tag}`, { headers: { Authorization: `token ${process.env.GITHUB_TOKEN}` } });
const isPublishedRelease = releaseResponse.status === 200;
const release = await releaseResponse.json();
const releaseStatus = isPublishedRelease ? release.draft ? ReleaseStatus.Draft : ReleaseStatus.Public : ReleaseStatus.Unpublished;
this.log.info(format("release status: %s", releaseStatus));
if (releaseStatus === ReleaseStatus.Public || releaseStatus === ReleaseStatus.Draft) this.log.info(format("release url: %s", release?.html_url));
if (!isPublishedRelease) this.log.warn(format("release \"%s\" is not published to GitHub!", pointer.tag));
};
/**
* Returns tag pointer by the given tag name.
* If no tag name was given, looks up the latest release tag
* and returns its pointer.
*/
async getTagPointer(tag) {
if (tag) {
this.log.info(format("looking up explicit \"%s\" tag...", tag));
const pointer = await getTag(tag);
invariant(pointer, "Failed to retrieve release tag: tag \"%s\" does not exist.", tag);
return pointer;
}
this.log.info("looking up the latest release tag...");
const tags = await getTags();
invariant(tags.length > 0, "Failed to retrieve release tag: repository has no releases.");
const latestPointer = await getLatestRelease(tags);
invariant(latestPointer, "Failed to retrieve release tag: cannot retrieve releases.");
return latestPointer;
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Show = exports.ReleaseStatus = void 0;
const outvariant_1 = require("outvariant");
const node_fetch_1 = __importDefault(require("node-fetch"));
const Command_1 = require("../Command");
const getTag_1 = require("../utils/git/getTag");
const getLatestRelease_1 = require("../utils/git/getLatestRelease");
const getTags_1 = require("../utils/git/getTags");
const getCommit_1 = require("../utils/git/getCommit");
const getInfo_1 = require("../utils/git/getInfo");
const execAsync_1 = require("../utils/execAsync");
const env_1 = require("../utils/env");
var ReleaseStatus;
(function (ReleaseStatus) {
/**
* Release is public and available for everybody to see
* on the GitHub releases page.
*/
ReleaseStatus["Public"] = "public";
/**
* Release is pushed to GitHub but is marked as draft.
*/
ReleaseStatus["Draft"] = "draft";
/**
* Release is local, not present on GitHub.
*/
ReleaseStatus["Unpublished"] = "unpublished";
})(ReleaseStatus = exports.ReleaseStatus || (exports.ReleaseStatus = {}));
class Show extends Command_1.Command {
static command = 'show';
static description = 'Show release info';
static builder = (yargs) => {
return yargs
.usage('$0 show [tag]')
.example([
['$0 show', 'Show the latest release info'],
['$0 show 1.2.3', 'Show specific release tag info'],
])
.positional('tag', {
type: 'string',
description: 'Release tag',
demandOption: false,
});
};
run = async () => {
await (0, env_1.demandGitHubToken)().catch((error) => {
this.log.error(error.message);
process.exit(1);
});
const [, tag] = this.argv._;
const pointer = await this.getTagPointer(tag?.toString());
this.log.info((0, outvariant_1.format)('found tag "%s"!', pointer.tag));
const commit = await (0, getCommit_1.getCommit)(pointer.hash);
(0, outvariant_1.invariant)(commit, 'Failed to retrieve release info for tag "%s": cannot find commit associated with the tag.', tag);
// Print local Git info about the release commit.
const commitOut = await (0, execAsync_1.execAsync)(`git log -1 ${commit.commit.long}`).then(({ stdout }) => stdout);
this.log.info(commitOut);
// Print the remote GitHub info about the release.
const repo = await (0, getInfo_1.getInfo)();
const releaseResponse = await (0, node_fetch_1.default)(`https://api.github.com/repos/${repo.owner}/${repo.name}/releases/tags/${pointer.tag}`, {
headers: {
Authorization: `token ${process.env.GITHUB_TOKEN}`,
},
});
const isPublishedRelease = releaseResponse.status === 200;
const release = await releaseResponse.json();
const releaseStatus = isPublishedRelease
? release.draft
? ReleaseStatus.Draft
: ReleaseStatus.Public
: ReleaseStatus.Unpublished;
this.log.info((0, outvariant_1.format)('release status: %s', releaseStatus));
if (releaseStatus === ReleaseStatus.Public ||
releaseStatus === ReleaseStatus.Draft) {
this.log.info((0, outvariant_1.format)('release url: %s', release?.html_url));
}
if (!isPublishedRelease) {
this.log.warn((0, outvariant_1.format)('release "%s" is not published to GitHub!', pointer.tag));
}
};
/**
* Returns tag pointer by the given tag name.
* If no tag name was given, looks up the latest release tag
* and returns its pointer.
*/
async getTagPointer(tag) {
if (tag) {
this.log.info((0, outvariant_1.format)('looking up explicit "%s" tag...', tag));
const pointer = await (0, getTag_1.getTag)(tag);
(0, outvariant_1.invariant)(pointer, 'Failed to retrieve release tag: tag "%s" does not exist.', tag);
return pointer;
}
this.log.info('looking up the latest release tag...');
const tags = await (0, getTags_1.getTags)();
(0, outvariant_1.invariant)(tags.length > 0, 'Failed to retrieve release tag: repository has no releases.');
const latestPointer = await (0, getLatestRelease_1.getLatestRelease)(tags);
(0, outvariant_1.invariant)(latestPointer, 'Failed to retrieve release tag: cannot retrieve releases.');
return latestPointer;
}
}
exports.Show = Show;
//# sourceMappingURL=show.js.map
//#endregion
export { ReleaseStatus, Show };

@@ -1,41 +0,14 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const yargs = __importStar(require("yargs"));
const getConfig_1 = require("./utils/getConfig");
// Commands.
const show_1 = require("./commands/show");
const publish_1 = require("./commands/publish");
const notes_1 = require("./commands/notes");
const config = (0, getConfig_1.getConfig)();
yargs
.usage('$0 <command> [options]')
.command(publish_1.Publish.command, publish_1.Publish.description, publish_1.Publish.builder, (argv) => new publish_1.Publish(config, argv).run())
.command(notes_1.Notes.command, notes_1.Notes.description, notes_1.Notes.builder, (argv) => {
return new notes_1.Notes(config, argv).run();
})
.command(show_1.Show.command, show_1.Show.description, show_1.Show.builder, (argv) => new show_1.Show(config, argv).run())
.help().argv;
//# sourceMappingURL=index.js.map
import { getConfig } from "./utils/get-config.js";
import { Show } from "./commands/show.js";
import { Notes } from "./commands/notes.js";
import { Publish } from "./commands/publish.js";
import yargs from "yargs";
//#region src/index.ts
const config = getConfig();
yargs(process.argv.slice(2)).usage("$0 <command> [options]").command(Publish.command, Publish.description, Publish.builder, (argv) => new Publish(config, argv).run()).command(Notes.command, Notes.description, Notes.builder, (argv) => {
return new Notes(config, argv).run();
}).command(Show.command, Show.description, Show.builder, (argv) => new Show(config, argv).run()).help().argv;
//#endregion
export { };

@@ -1,18 +0,16 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.log = void 0;
const pino_1 = __importDefault(require("pino"));
exports.log = (0, pino_1.default)({
base: null,
transport: {
target: 'pino-pretty',
options: {
colorize: true,
timestampKey: false,
},
},
import pino from "pino";
//#region src/logger.ts
const log = pino({
base: null,
transport: {
target: "pino-pretty",
options: {
colorize: true,
timestampKey: false
}
}
});
//# sourceMappingURL=logger.js.map
//#endregion
export { log };

@@ -1,17 +0,16 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.demandNpmToken = exports.demandGitHubToken = void 0;
const outvariant_1 = require("outvariant");
const validateAccessToken_1 = require("./github/validateAccessToken");
import { validateAccessToken } from "./github/validate-access-token.js";
import { invariant } from "outvariant";
//#region src/utils/env.ts
async function demandGitHubToken() {
const { GITHUB_TOKEN } = process.env;
(0, outvariant_1.invariant)(GITHUB_TOKEN, 'Failed to publish the package: the "GITHUB_TOKEN" environment variable is not provided.');
await (0, validateAccessToken_1.validateAccessToken)(GITHUB_TOKEN);
const { GITHUB_TOKEN } = process.env;
invariant(GITHUB_TOKEN, "Failed to publish the package: the \"GITHUB_TOKEN\" environment variable is not provided.");
await validateAccessToken(GITHUB_TOKEN);
}
exports.demandGitHubToken = demandGitHubToken;
async function demandNpmToken() {
const { NODE_AUTH_TOKEN, NPM_AUTH_TOKEN } = process.env;
(0, outvariant_1.invariant)(NODE_AUTH_TOKEN || NPM_AUTH_TOKEN, 'Failed to publish the package: neither "NODE_AUTH_TOKEN" nor "NPM_AUTH_TOKEN" environment variables were provided.');
const { NODE_AUTH_TOKEN, NPM_AUTH_TOKEN } = process.env;
invariant(NODE_AUTH_TOKEN || NPM_AUTH_TOKEN, "Failed to publish the package: neither \"NODE_AUTH_TOKEN\" nor \"NPM_AUTH_TOKEN\" environment variables were provided.");
}
exports.demandNpmToken = demandNpmToken;
//# sourceMappingURL=env.js.map
//#endregion
export { demandGitHubToken, demandNpmToken };

@@ -1,23 +0,21 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.commit = void 0;
const execAsync_1 = require("../execAsync");
const getCommit_1 = require("./getCommit");
const parseCommits_1 = require("./parseCommits");
async function commit({ files, message, allowEmpty, date, }) {
if (files) {
await (0, execAsync_1.execAsync)(`git add ${files.join(' ')}`);
}
const args = [
`-m "${message}"`,
allowEmpty ? '--allow-empty' : '',
date ? `--date "${date.toISOString()}"` : '',
];
await (0, execAsync_1.execAsync)(`git commit ${args.join(' ')}`);
const hash = await (0, execAsync_1.execAsync)('git log --pretty=format:%H -n 1').then(({ stdout }) => stdout);
const commit = (await (0, getCommit_1.getCommit)(hash));
const [commitInfo] = await (0, parseCommits_1.parseCommits)([commit]);
return commitInfo;
import { execAsync } from "../exec-async.js";
import { getCommit } from "./get-commit.js";
import { parseCommits } from "./parse-commits.js";
//#region src/utils/git/commit.ts
async function commit({ files, message, allowEmpty, date }) {
if (files) await execAsync(`git add ${files.join(" ")}`);
const args = [
`-m "${message}"`,
allowEmpty ? "--allow-empty" : "",
date ? `--date "${date.toISOString()}"` : ""
];
await execAsync(`git commit ${args.join(" ")}`);
const hash = await execAsync("git log --pretty=format:%H -n 1").then(({ stdout }) => stdout);
const commit$1 = await getCommit(hash);
const [commitInfo] = await parseCommits([commit$1]);
return commitInfo;
}
exports.commit = commit;
//# sourceMappingURL=commit.js.map
//#endregion
export { commit };

@@ -1,9 +0,9 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.push = void 0;
const execAsync_1 = require("../execAsync");
import { execAsync } from "../exec-async.js";
//#region src/utils/git/push.ts
async function push() {
await (0, execAsync_1.execAsync)(`git push`);
await execAsync(`git push`);
}
exports.push = push;
//# sourceMappingURL=push.js.map
//#endregion
export { push };
{
"type": "module",
"name": "@ossjs/release",
"version": "0.8.1",
"version": "0.9.0",
"description": "Minimalistic, opinionated, and predictable release automation tool.",

@@ -9,43 +10,50 @@ "main": "./bin/build/index.js",

"bin": {
"release": "./bin/cli.sh"
"release": "./bin/cli.js"
},
"engines": {
"node": ">=20.0.0"
},
"files": [
"bin"
],
"imports": {
"#/*": "./*"
},
"exports": {
".": {
"types": "./bin/build/index.ts",
"default": "./bin/build/index.js"
}
},
"devDependencies": {
"@swc/core": "^1.3.81",
"@swc/jest": "^0.2.29",
"@types/jest": "^29.5.4",
"dotenv": "^16.3.1",
"@rolldown/binding-darwin-arm64": "1.0.0-beta.40",
"fs-teardown": "^0.3.2",
"jest": "^29.6.4",
"msw": "^1.2.5",
"msw": "^2.11.3",
"node-git-server": "^1.0.0-beta.30",
"portfinder": "^1.0.28",
"ts-node": "^10.7.0",
"typescript": "^4.6.3"
"prettier": "^3.6.2",
"publint": "^0.3.13",
"tsdown": "^0.15.5",
"typescript": "^5.9.2",
"vitest": "^3.2.4"
},
"dependencies": {
"@open-draft/deferred-promise": "^2.1.0",
"@open-draft/until": "^2.1.0",
"@types/conventional-commits-parser": "^3.0.2",
"@open-draft/deferred-promise": "^2.2.0",
"@types/conventional-commits-parser": "^5.0.1",
"@types/issue-parser": "^3.0.1",
"@types/node": "^16.11.27",
"@types/node-fetch": "2.x",
"@types/rc": "^1.2.1",
"@types/registry-auth-token": "^4.2.1",
"@types/node": "^24.5.2",
"@types/semver": "^7.5.1",
"@types/yargs": "^17.0.10",
"conventional-commits-parser": "^5.0.0",
"conventional-commits-parser": "^6.2.0",
"get-stream": "^6.0.1",
"git-log-parser": "^1.2.0",
"issue-parser": "^6.0.0",
"node-fetch": "2.6.7",
"outvariant": "^1.4.0",
"issue-parser": "^7.0.1",
"outvariant": "^1.4.3",
"pino": "^7.10.0",
"pino-pretty": "^7.6.1",
"rc": "^1.2.8",
"registry-auth-token": "^4.2.1",
"registry-auth-token": "^5.1.0",
"semver": "^7.5.4",
"yargs": "^17.7.2"
"until-async": "^3.0.2",
"yargs": "^18.0.0"
},

@@ -70,8 +78,9 @@ "repository": {

"scripts": {
"start": "pnpm build -- -w",
"build": "tsc -p tsconfig.build.json",
"test": "jest --runInBand",
"prerelease": "pnpm build && pnpm test",
"release": "./bin/cli.sh publish"
"dev": "tsdown -w",
"cli": "./bin/cli.js",
"build": "tsdown",
"test": "vitest",
"lint": "publint",
"release": "pnpm cli publish"
}
}
{"version":3,"file":"Command.js","sourceRoot":"","sources":["../../src/Command.ts"],"names":[],"mappings":";;;AAAA,qCAA8B;AAQ9B,MAAsB,OAAO;IAQN;IACA;IARrB,MAAM,CAAU,OAAO,CAAQ;IAC/B,MAAM,CAAU,WAAW,CAAQ;IACnC,MAAM,CAAU,OAAO,GAA6B,GAAG,EAAE,GAAE,CAAC,CAAA;IAElD,GAAG,CAAY;IAEzB,YACqB,MAAc,EACd,IAAwB;QADxB,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAoB;QAE3C,IAAI,CAAC,GAAG,GAAG,YAAG,CAAA;IAChB,CAAC;IAEM,GAAG,GAAG,KAAK,IAAmB,EAAE,GAAE,CAAC,CAAA;;AAd5C,0BAeC"}
{"version":3,"file":"notes.js","sourceRoot":"","sources":["../../../src/commands/notes.ts"],"names":[],"mappings":";;;AAAA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E,CACvE,IAAI,iBAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,GAAG,EAAE,CAChC;KACA,OAAO,CAAC,aAAK,CAAC,OAAO,EAAE,aAAK,CAAC,WAAW,EAAE,aAAK,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;IACjE,OAAO,IAAI,aAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,GAAG,EAAE,CAAA;AACtC,CAAC,CAAC;KACD,OAAO,CAAC,WAAI,CAAC,OAAO,EAAE,WAAI,CAAC,WAAW,EAAE,WAAI,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAC9D,IAAI,WAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,GAAG,EAAE,CAC7B;KACA,IAAI,EAAE,CAAC,IAAI,CAAA"}
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AAEV,QAAA,GAAG,GAAG,IAAA,cAAI,EAAC;IACtB,IAAI,EAAE,IAAI;IACV,SAAS,EAAE;QACT,MAAM,EAAE,aAAa;QACrB,OAAO,EAAE;YACP,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,KAAK;SACpB;KACF;CACF,CAAC,CAAA"}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bumpPackageJson = void 0;
const readPackageJson_1 = require("./readPackageJson");
const writePackageJson_1 = require("./writePackageJson");
function bumpPackageJson(version) {
const packageJson = (0, readPackageJson_1.readPackageJson)();
packageJson.version = version;
(0, writePackageJson_1.writePackageJson)(packageJson);
}
exports.bumpPackageJson = bumpPackageJson;
//# sourceMappingURL=bumpPackageJson.js.map
{"version":3,"file":"bumpPackageJson.js","sourceRoot":"","sources":["../../../src/utils/bumpPackageJson.ts"],"names":[],"mappings":";;;AACA,uDAAmD;AACnD,yDAAqD;AAErD,SAAgB,eAAe,CAAC,OAAe;IAC7C,MAAM,WAAW,GAAG,IAAA,iCAAe,GAAE,CAAA;IACrC,WAAW,CAAC,OAAO,GAAG,OAAO,CAAA;IAE7B,IAAA,mCAAgB,EAAC,WAAW,CAAC,CAAA;AAC/B,CAAC;AALD,0CAKC"}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createContext = void 0;
function createContext(input) {
const context = {
repo: input.repo,
latestRelease: input.latestRelease || undefined,
nextRelease: {
...input.nextRelease,
tag: null,
},
};
Object.defineProperty(context.nextRelease, 'tag', {
get() {
return `v${context.nextRelease.version}`;
},
});
return context;
}
exports.createContext = createContext;
//# sourceMappingURL=createContext.js.map
{"version":3,"file":"createContext.js","sourceRoot":"","sources":["../../../src/utils/createContext.ts"],"names":[],"mappings":";;;AAsBA,SAAgB,aAAa,CAAC,KAA0B;IACtD,MAAM,OAAO,GAAmB;QAC9B,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,aAAa,EAAE,KAAK,CAAC,aAAa,IAAI,SAAS;QAC/C,WAAW,EAAE;YACX,GAAG,KAAK,CAAC,WAAW;YACpB,GAAG,EAAE,IAAW;SACjB;KACF,CAAA;IAED,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,EAAE;QAChD,GAAG;YACD,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,CAAA;QAC1C,CAAC;KACF,CAAC,CAAA;IAEF,OAAO,OAAO,CAAA;AAChB,CAAC;AAjBD,sCAiBC"}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createReleaseComment = void 0;
const readPackageJson_1 = require("./readPackageJson");
function createReleaseComment(input) {
const { context, releaseUrl } = input;
const packageJson = (0, readPackageJson_1.readPackageJson)();
return `## Released: ${context.nextRelease.tag} 🎉
This has been released in ${context.nextRelease.tag}!
- 📄 [**Release notes**](${releaseUrl})
- 📦 [npm package](https://www.npmjs.com/package/${packageJson.name}/v/${context.nextRelease.version})
Make sure to always update to the latest version (\`npm i ${packageJson.name}@latest\`) to get the newest features and bug fixes.
---
_Predictable release automation by [@ossjs/release](https://github.com/ossjs/release)_.`;
}
exports.createReleaseComment = createReleaseComment;
//# sourceMappingURL=createReleaseComment.js.map
{"version":3,"file":"createReleaseComment.js","sourceRoot":"","sources":["../../../src/utils/createReleaseComment.ts"],"names":[],"mappings":";;;AACA,uDAAmD;AAOnD,SAAgB,oBAAoB,CAAC,KAA0B;IAC7D,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,KAAK,CAAA;IACrC,MAAM,WAAW,GAAG,IAAA,iCAAe,GAAE,CAAA;IAErC,OAAO,gBAAgB,OAAO,CAAC,WAAW,CAAC,GAAG;;4BAEpB,OAAO,CAAC,WAAW,CAAC,GAAG;;2BAExB,UAAU;mDACc,WAAW,CAAC,IAAI,MAAM,OAAO,CAAC,WAAW,CAAC,OAAO;;4DAExC,WAAW,CAAC,IAAI;;;;wFAIY,CAAA;AACxF,CAAC;AAhBD,oDAgBC"}
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../../src/utils/env.ts"],"names":[],"mappings":";;;AAAA,2CAAsC;AACtC,sEAAkE;AAE3D,KAAK,UAAU,iBAAiB;IACrC,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,GAAG,CAAA;IAEpC,IAAA,sBAAS,EACP,YAAY,EACZ,yFAAyF,CAC1F,CAAA;IAED,MAAM,IAAA,yCAAmB,EAAC,YAAY,CAAC,CAAA;AACzC,CAAC;AATD,8CASC;AAEM,KAAK,UAAU,cAAc;IAClC,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,GAAG,CAAA;IAEvD,IAAA,sBAAS,EACP,eAAe,IAAI,cAAc,EACjC,oHAAoH,CACrH,CAAA;AACH,CAAC;AAPD,wCAOC"}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.execAsync = void 0;
const deferred_promise_1 = require("@open-draft/deferred-promise");
const child_process_1 = require("child_process");
const DEFAULT_CONTEXT = {
cwd: process.cwd(),
};
exports.execAsync = ((command, options = {}) => {
const commandPromise = new deferred_promise_1.DeferredPromise();
const io = (0, child_process_1.exec)(command, {
...exports.execAsync.contextOptions,
...options,
}, (error, stdout, stderr) => {
if (error) {
return commandPromise.reject(error);
}
commandPromise.resolve({
stdout,
stderr,
});
});
// Set the reference to the spawned child process
// on the promise so the consumer can either await
// the entire command or tap into child process
// and handle it manually (e.g. forward stdio).
Reflect.set(commandPromise, 'io', io);
return commandPromise;
});
exports.execAsync.mockContext = (options) => {
exports.execAsync.contextOptions = options;
};
exports.execAsync.restoreContext = () => {
exports.execAsync.contextOptions = DEFAULT_CONTEXT;
};
exports.execAsync.restoreContext();
//# sourceMappingURL=execAsync.js.map
{"version":3,"file":"execAsync.js","sourceRoot":"","sources":["../../../src/utils/execAsync.ts"],"names":[],"mappings":";;;AAAA,mEAA8D;AAC9D,iDAAyE;AAsBzE,MAAM,eAAe,GAAyB;IAC5C,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;CACnB,CAAA;AAEY,QAAA,SAAS,GAAgB,CAAC,CAAC,OAAO,EAAE,OAAO,GAAG,EAAE,EAAE,EAAE;IAC/D,MAAM,cAAc,GAAG,IAAI,kCAAe,EAGtC,CAAA;IAEJ,MAAM,EAAE,GAAG,IAAA,oBAAI,EACb,OAAO,EACP;QACE,GAAG,iBAAS,CAAC,cAAc;QAC3B,GAAG,OAAO;KACX,EACD,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;QACxB,IAAI,KAAK,EAAE;YACT,OAAO,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;SACpC;QAED,cAAc,CAAC,OAAO,CAAC;YACrB,MAAM;YACN,MAAM;SACP,CAAC,CAAA;IACJ,CAAC,CACF,CAAA;IAED,iDAAiD;IACjD,kDAAkD;IAClD,+CAA+C;IAC/C,+CAA+C;IAC/C,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,EAAE,EAAE,CAAC,CAAA;IAErC,OAAO,cAAc,CAAA;AACvB,CAAC,CAAC,CAAA;AAEF,iBAAS,CAAC,WAAW,GAAG,CAAC,OAAO,EAAE,EAAE;IAClC,iBAAS,CAAC,cAAc,GAAG,OAAO,CAAA;AACpC,CAAC,CAAA;AAED,iBAAS,CAAC,cAAc,GAAG,GAAG,EAAE;IAC9B,iBAAS,CAAC,cAAc,GAAG,eAAe,CAAA;AAC5C,CAAC,CAAA;AAED,iBAAS,CAAC,cAAc,EAAE,CAAA"}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatDate = void 0;
function formatDate(date) {
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
return `${year}-${month}-${day}`;
}
exports.formatDate = formatDate;
//# sourceMappingURL=formatDate.js.map
{"version":3,"file":"formatDate.js","sourceRoot":"","sources":["../../../src/utils/formatDate.ts"],"names":[],"mappings":";;;AAAA,SAAgB,UAAU,CAAC,IAAU;IACnC,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAA;IAC/B,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IAC/D,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IAEtD,OAAO,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG,EAAE,CAAA;AAClC,CAAC;AAND,gCAMC"}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getConfig = void 0;
const outvariant_1 = require("outvariant");
const path = __importStar(require("path"));
function getConfig() {
const configPath = path.resolve(process.cwd(), 'release.config.json');
const config = require(configPath);
validateConfig(config);
return config;
}
exports.getConfig = getConfig;
function validateConfig(config) {
(0, outvariant_1.invariant)(Array.isArray(config.profiles), 'Failed to parse Release configuration: expected a root-level "tags" property to be an array but got %j', config.profiles);
(0, outvariant_1.invariant)(config.profiles.length > 0, 'Failed to parse Release configuration: expected at least one profile to be defined');
}
//# sourceMappingURL=getConfig.js.map
{"version":3,"file":"getConfig.js","sourceRoot":"","sources":["../../../src/utils/getConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAsC;AACtC,2CAA4B;AAuB5B,SAAgB,SAAS;IACvB,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,qBAAqB,CAAC,CAAA;IACrE,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IAClC,cAAc,CAAC,MAAM,CAAC,CAAA;IAEtB,OAAO,MAAM,CAAA;AACf,CAAC;AAND,8BAMC;AAED,SAAS,cAAc,CAAC,MAAc;IACpC,IAAA,sBAAS,EACP,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAC9B,wGAAwG,EACxG,MAAM,CAAC,QAAQ,CAChB,CAAA;IAED,IAAA,sBAAS,EACP,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAC1B,oFAAoF,CACrF,CAAA;AACH,CAAC"}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNextReleaseType = exports.isBreakingChange = void 0;
/**
* Returns true if the given parsed commit represents a breaking change.
* @see https://www.conventionalcommits.org/en/v1.0.0/#summary
*/
function isBreakingChange(commit) {
if (commit.typeAppendix === '!') {
return true;
}
if (commit.footer && commit.footer.includes('BREAKING CHANGE:')) {
return true;
}
return false;
}
exports.isBreakingChange = isBreakingChange;
function getNextReleaseType(commits, options) {
const ranges = [null, null];
for (const commit of commits) {
if (isBreakingChange(commit)) {
return options?.prerelease ? 'minor' : 'major';
}
// Respect the parsed "type" from the "conventional-commits-parser".
switch (commit.type) {
case 'feat': {
ranges[0] = 'minor';
break;
}
case 'fix': {
ranges[1] = 'patch';
break;
}
}
}
/**
* @fixme Commit messages can also append "!" to the scope
* to indicate that the commit is a breaking change.
* @see https://www.conventionalcommits.org/en/v1.0.0/#summary
*
* Unfortunately, "conventional-commits-parser" does not support that.
*/
return ranges[0] || ranges[1];
}
exports.getNextReleaseType = getNextReleaseType;
//# sourceMappingURL=getNextReleaseType.js.map
{"version":3,"file":"getNextReleaseType.js","sourceRoot":"","sources":["../../../src/utils/getNextReleaseType.ts"],"names":[],"mappings":";;;AAOA;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,MAA4B;IAC3D,IAAI,MAAM,CAAC,YAAY,KAAK,GAAG,EAAE;QAC/B,OAAO,IAAI,CAAA;KACZ;IAED,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE;QAC/D,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AAVD,4CAUC;AAED,SAAgB,kBAAkB,CAChC,OAA+B,EAC/B,OAAmC;IAEnC,MAAM,MAAM,GAAqC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAE7D,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC5B,IAAI,gBAAgB,CAAC,MAAM,CAAC,EAAE;YAC5B,OAAO,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAA;SAC/C;QAED,oEAAoE;QACpE,QAAQ,MAAM,CAAC,IAAI,EAAE;YACnB,KAAK,MAAM,CAAC,CAAC;gBACX,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAA;gBACnB,MAAK;aACN;YAED,KAAK,KAAK,CAAC,CAAC;gBACV,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAA;gBACnB,MAAK;aACN;SACF;KACF;IAED;;;;;;OAMG;IAEH,OAAO,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAA;AAC/B,CAAC;AAlCD,gDAkCC"}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNextVersion = void 0;
const outvariant_1 = require("outvariant");
const semver = __importStar(require("semver"));
function getNextVersion(previousVersion, releaseType) {
const nextVersion = semver.inc(previousVersion, releaseType);
(0, outvariant_1.invariant)(nextVersion, 'Failed to calculate the next version from "%s" using release type "%s"', previousVersion, releaseType);
return nextVersion;
}
exports.getNextVersion = getNextVersion;
//# sourceMappingURL=getNextVersion.js.map
{"version":3,"file":"getNextVersion.js","sourceRoot":"","sources":["../../../src/utils/getNextVersion.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAsC;AACtC,+CAAgC;AAEhC,SAAgB,cAAc,CAC5B,eAAuB,EACvB,WAA+B;IAE/B,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,EAAE,WAAW,CAAC,CAAA;IAE5D,IAAA,sBAAS,EACP,WAAW,EACX,wEAAwE,EACxE,eAAe,EACf,WAAW,CACZ,CAAA;IAED,OAAO,WAAW,CAAA;AACpB,CAAC;AAdD,wCAcC"}
{"version":3,"file":"commit.js","sourceRoot":"","sources":["../../../../src/utils/git/commit.ts"],"names":[],"mappings":";;;AACA,4CAAwC;AACxC,2CAAuC;AACvC,iDAAmE;AAS5D,KAAK,UAAU,MAAM,CAAC,EAC3B,KAAK,EACL,OAAO,EACP,UAAU,EACV,IAAI,GACU;IACd,IAAI,KAAK,EAAE;QACT,MAAM,IAAA,qBAAS,EAAC,WAAW,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;KAC9C;IAED,MAAM,IAAI,GAAa;QACrB,OAAO,OAAO,GAAG;QACjB,UAAU,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE;QACjC,IAAI,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE;KAC7C,CAAA;IAED,MAAM,IAAA,qBAAS,EAAC,cAAc,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAC/C,MAAM,IAAI,GAAG,MAAM,IAAA,qBAAS,EAAC,iCAAiC,CAAC,CAAC,IAAI,CAClE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CACvB,CAAA;IACD,MAAM,MAAM,GAAG,CAAC,MAAM,IAAA,qBAAS,EAAC,IAAI,CAAC,CAAW,CAAA;IAEhD,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,IAAA,2BAAY,EAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IACjD,OAAO,UAAU,CAAA;AACnB,CAAC;AAxBD,wBAwBC"}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createTag = void 0;
const execAsync_1 = require("../execAsync");
async function createTag(tag) {
await (0, execAsync_1.execAsync)(`git tag ${tag}`);
const latestTag = await (0, execAsync_1.execAsync)(`git describe --tags --abbrev=0`).then(({ stdout }) => stdout);
return latestTag.trim();
}
exports.createTag = createTag;
//# sourceMappingURL=createTag.js.map
{"version":3,"file":"createTag.js","sourceRoot":"","sources":["../../../../src/utils/git/createTag.ts"],"names":[],"mappings":";;;AAAA,4CAAwC;AAEjC,KAAK,UAAU,SAAS,CAAC,GAAW;IACzC,MAAM,IAAA,qBAAS,EAAC,WAAW,GAAG,EAAE,CAAC,CAAA;IACjC,MAAM,SAAS,GAAG,MAAM,IAAA,qBAAS,EAAC,gCAAgC,CAAC,CAAC,IAAI,CACtE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CACvB,CAAA;IAED,OAAO,SAAS,CAAC,IAAI,EAAE,CAAA;AACzB,CAAC;AAPD,8BAOC"}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCommit = void 0;
const getStream = __importStar(require("get-stream"));
const git_log_parser_1 = __importDefault(require("git-log-parser"));
const execAsync_1 = require("../execAsync");
async function getCommit(hash) {
Object.assign(git_log_parser_1.default.fields, {
hash: 'H',
message: 'B',
});
const result = await getStream.array(git_log_parser_1.default.parse({
_: hash,
n: 1,
}, {
// Respect the global working directory so this command
// parses commits on test repositories during tests.
cwd: execAsync_1.execAsync.contextOptions.cwd,
}));
return result?.[0];
}
exports.getCommit = getCommit;
//# sourceMappingURL=getCommit.js.map
{"version":3,"file":"getCommit.js","sourceRoot":"","sources":["../../../../src/utils/git/getCommit.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAuC;AACvC,oEAAqD;AACrD,4CAAwC;AAEjC,KAAK,UAAU,SAAS,CAAC,IAAY;IAC1C,MAAM,CAAC,MAAM,CAAC,wBAAY,CAAC,MAAM,EAAE;QACjC,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,GAAG;KACb,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,KAAK,CAClC,wBAAY,CAAC,KAAK,CAChB;QACE,CAAC,EAAE,IAAI;QACP,CAAC,EAAE,CAAC;KACL,EACD;QACE,uDAAuD;QACvD,oDAAoD;QACpD,GAAG,EAAE,qBAAS,CAAC,cAAc,CAAC,GAAG;KAClC,CACF,CACF,CAAA;IAED,OAAO,MAAM,EAAE,CAAC,CAAC,CAAC,CAAA;AACpB,CAAC;AArBD,8BAqBC"}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCommits = void 0;
const getStream = __importStar(require("get-stream"));
const gitLogParser = __importStar(require("git-log-parser"));
const execAsync_1 = require("../execAsync");
/**
* Return the list of parsed commits within the given range.
*/
function getCommits({ since, until = 'HEAD', } = {}) {
Object.assign(gitLogParser.fields, {
hash: 'H',
message: 'B',
});
const range = since ? `${since}..${until}` : until;
// When only the "until" commit is specified, skip the first commit.
const skip = range === until && until !== 'HEAD' ? 1 : undefined;
return getStream.array(gitLogParser.parse({
_: range,
skip,
}, {
cwd: execAsync_1.execAsync.contextOptions.cwd,
}));
}
exports.getCommits = getCommits;
//# sourceMappingURL=getCommits.js.map
{"version":3,"file":"getCommits.js","sourceRoot":"","sources":["../../../../src/utils/git/getCommits.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAuC;AACvC,6DAA8C;AAC9C,4CAAwC;AAOxC;;GAEG;AACH,SAAgB,UAAU,CAAC,EACzB,KAAK,EACL,KAAK,GAAG,MAAM,MACO,EAAE;IACvB,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE;QACjC,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,GAAG;KACb,CAAC,CAAA;IAEF,MAAM,KAAK,GAAW,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAA;IAE1D,oEAAoE;IACpE,MAAM,IAAI,GAAG,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAEhE,OAAO,SAAS,CAAC,KAAK,CACpB,YAAY,CAAC,KAAK,CAChB;QACE,CAAC,EAAE,KAAK;QACR,IAAI;KACL,EACD;QACE,GAAG,EAAE,qBAAS,CAAC,cAAc,CAAC,GAAG;KAClC,CACF,CACF,CAAA;AACH,CAAC;AAzBD,gCAyBC"}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCurrentBranch = void 0;
const execAsync_1 = require("../execAsync");
async function getCurrentBranch() {
const { stdout } = await (0, execAsync_1.execAsync)('git rev-parse --abbrev-ref HEAD');
return stdout.trim();
}
exports.getCurrentBranch = getCurrentBranch;
//# sourceMappingURL=getCurrentBranch.js.map
{"version":3,"file":"getCurrentBranch.js","sourceRoot":"","sources":["../../../../src/utils/git/getCurrentBranch.ts"],"names":[],"mappings":";;;AAAA,4CAAwC;AAEjC,KAAK,UAAU,gBAAgB;IACpC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,qBAAS,EAAC,iCAAiC,CAAC,CAAA;IACrE,OAAO,MAAM,CAAC,IAAI,EAAE,CAAA;AACtB,CAAC;AAHD,4CAGC"}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseOriginUrl = exports.getInfo = void 0;
const outvariant_1 = require("outvariant");
const execAsync_1 = require("../execAsync");
async function getInfo() {
const remote = await (0, execAsync_1.execAsync)(`git config --get remote.origin.url`).then(({ stdout }) => stdout.trim());
const [owner, name] = parseOriginUrl(remote);
(0, outvariant_1.invariant)(remote, 'Failed to extract Git info: expected an origin URL but got %s.', remote);
(0, outvariant_1.invariant)(owner, 'Failed to extract Git info: expected repository owner but got %s.', owner);
(0, outvariant_1.invariant)(name, 'Failed to extract Git info: expected repository name but got %s.', name);
return {
remote,
owner,
name,
url: new URL(`https://github.com/${owner}/${name}/`).href,
};
}
exports.getInfo = getInfo;
function parseOriginUrl(origin) {
if (origin.startsWith('git@')) {
const match = /:(.+?)\/(.+)\.git$/g.exec(origin);
(0, outvariant_1.invariant)(match, 'Failed to parse origin URL "%s": invalid URL structure.', origin);
return [match[1], match[2]];
}
if (/^http(s)?:\/\//.test(origin)) {
const url = new URL(origin);
const match = /\/(.+?)\/(.+?)(\.git)?$/.exec(url.pathname);
(0, outvariant_1.invariant)(match, 'Failed to parse origin URL "%s": invalid URL structure.', origin);
return [match[1], match[2]];
}
(0, outvariant_1.invariant)(false, 'Failed to extract repository owner/name: given origin URL "%s" is of unknown scheme (Git/HTTP/HTTPS).', origin);
}
exports.parseOriginUrl = parseOriginUrl;
//# sourceMappingURL=getInfo.js.map
{"version":3,"file":"getInfo.js","sourceRoot":"","sources":["../../../../src/utils/git/getInfo.ts"],"names":[],"mappings":";;;AAAA,2CAAsC;AACtC,4CAAwC;AASjC,KAAK,UAAU,OAAO;IAC3B,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAS,EAAC,oCAAoC,CAAC,CAAC,IAAI,CACvE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAC9B,CAAA;IACD,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,CAAA;IAE5C,IAAA,sBAAS,EACP,MAAM,EACN,gEAAgE,EAChE,MAAM,CACP,CAAA;IACD,IAAA,sBAAS,EACP,KAAK,EACL,mEAAmE,EACnE,KAAK,CACN,CAAA;IACD,IAAA,sBAAS,EACP,IAAI,EACJ,kEAAkE,EAClE,IAAI,CACL,CAAA;IAED,OAAO;QACL,MAAM;QACN,KAAK;QACL,IAAI;QACJ,GAAG,EAAE,IAAI,GAAG,CAAC,sBAAsB,KAAK,IAAI,IAAI,GAAG,CAAC,CAAC,IAAI;KAC1D,CAAA;AACH,CAAC;AA5BD,0BA4BC;AAED,SAAgB,cAAc,CAAC,MAAc;IAC3C,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;QAC7B,MAAM,KAAK,GAAG,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAEhD,IAAA,sBAAS,EACP,KAAK,EACL,yDAAyD,EACzD,MAAM,CACP,CAAA;QAED,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;KAC5B;IAED,IAAI,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QACjC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAA;QAC3B,MAAM,KAAK,GAAG,yBAAyB,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QAE1D,IAAA,sBAAS,EACP,KAAK,EACL,yDAAyD,EACzD,MAAM,CACP,CAAA;QAED,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;KAC5B;IAED,IAAA,sBAAS,EACP,KAAK,EACL,uGAAuG,EACvG,MAAM,CACP,CAAA;AACH,CAAC;AA/BD,wCA+BC"}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getLatestRelease = exports.byReleaseVersion = void 0;
const semver = __importStar(require("semver"));
const getTag_1 = require("./getTag");
function byReleaseVersion(left, right) {
return semver.rcompare(left, right);
}
exports.byReleaseVersion = byReleaseVersion;
async function getLatestRelease(tags) {
const allTags = tags.filter((tag) => {
return semver.valid(tag);
}).sort(byReleaseVersion);
const [latestTag] = allTags;
if (!latestTag) {
return;
}
return (0, getTag_1.getTag)(latestTag);
}
exports.getLatestRelease = getLatestRelease;
//# sourceMappingURL=getLatestRelease.js.map
{"version":3,"file":"getLatestRelease.js","sourceRoot":"","sources":["../../../../src/utils/git/getLatestRelease.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAgC;AAChC,qCAA6C;AAE7C,SAAgB,gBAAgB,CAAC,IAAY,EAAE,KAAa;IAC1D,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AACrC,CAAC;AAFD,4CAEC;AAEM,KAAK,UAAU,gBAAgB,CACpC,IAAc;IAEd,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE;QAClC,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC1B,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;IACzB,MAAM,CAAC,SAAS,CAAC,GAAG,OAAO,CAAA;IAE3B,IAAI,CAAC,SAAS,EAAE;QACd,OAAM;KACP;IAED,OAAO,IAAA,eAAM,EAAC,SAAS,CAAC,CAAA;AAC1B,CAAC;AAbD,4CAaC"}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTag = void 0;
const until_1 = require("@open-draft/until");
const execAsync_1 = require("../execAsync");
/**
* Get tag pointer by tag name.
*/
async function getTag(tag) {
const commitHashOut = await (0, until_1.until)(() => {
return (0, execAsync_1.execAsync)(`git rev-list -n 1 ${tag}`);
});
// Gracefully handle the errors.
// Getting commit hash by tag name can fail given an unknown tag.
if (commitHashOut.error) {
return undefined;
}
return {
tag,
hash: commitHashOut.data.stdout.trim(),
};
}
exports.getTag = getTag;
//# sourceMappingURL=getTag.js.map
{"version":3,"file":"getTag.js","sourceRoot":"","sources":["../../../../src/utils/git/getTag.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,4CAAwC;AAOxC;;GAEG;AACI,KAAK,UAAU,MAAM,CAAC,GAAW;IACtC,MAAM,aAAa,GAAG,MAAM,IAAA,aAAK,EAAC,GAAG,EAAE;QACrC,OAAO,IAAA,qBAAS,EAAC,qBAAqB,GAAG,EAAE,CAAC,CAAA;IAC9C,CAAC,CAAC,CAAA;IAEF,gCAAgC;IAChC,iEAAiE;IACjE,IAAI,aAAa,CAAC,KAAK,EAAE;QACvB,OAAO,SAAS,CAAA;KACjB;IAED,OAAO;QACL,GAAG;QACH,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;KACvC,CAAA;AACH,CAAC;AAfD,wBAeC"}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTags = void 0;
const execAsync_1 = require("../execAsync");
/**
* Return the list of tags present on the current Git branch.
*/
async function getTags() {
const allTags = await (0, execAsync_1.execAsync)('git tag --merged').then(({ stdout }) => stdout);
return allTags.split('\n').filter(Boolean);
}
exports.getTags = getTags;
//# sourceMappingURL=getTags.js.map
{"version":3,"file":"getTags.js","sourceRoot":"","sources":["../../../../src/utils/git/getTags.ts"],"names":[],"mappings":";;;AAAA,4CAAwC;AAExC;;GAEG;AACI,KAAK,UAAU,OAAO;IAC3B,MAAM,OAAO,GAAG,MAAM,IAAA,qBAAS,EAAC,kBAAkB,CAAC,CAAC,IAAI,CACtD,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CACvB,CAAA;IAED,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;AAC5C,CAAC;AAND,0BAMC"}
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseCommits = void 0;
const node_stream_1 = require("node:stream");
const outvariant_1 = require("outvariant");
const deferred_promise_1 = require("@open-draft/deferred-promise");
const conventional_commits_parser_1 = __importDefault(require("conventional-commits-parser"));
const COMMIT_HEADER_APPENDIX_REGEXP = /^(.+)(!)(:)/g;
async function parseCommits(commits) {
const through = new node_stream_1.PassThrough();
const commitMap = new Map();
for (const commit of commits) {
commitMap.set(commit.subject, commit);
const message = joinCommit(commit.subject, commit.body);
through.write(message, 'utf8');
}
through.end();
const commitParser = (0, conventional_commits_parser_1.default)();
const parsingStreamPromise = new deferred_promise_1.DeferredPromise();
parsingStreamPromise.finally(() => {
through.destroy();
});
const parsedCommits = [];
through
.pipe(commitParser)
.on('error', (error) => parsingStreamPromise.reject(error))
.on('data', (parsedCommit) => {
let resolvedParsingResult = parsedCommit;
if (!parsedCommit.header) {
return;
}
let typeAppendix;
if (COMMIT_HEADER_APPENDIX_REGEXP.test(parsedCommit.header)) {
const headerWithoutAppendix = parsedCommit.header.replace(COMMIT_HEADER_APPENDIX_REGEXP, '$1$3');
resolvedParsingResult = conventional_commits_parser_1.default.sync(joinCommit(headerWithoutAppendix, parsedCommit.body));
typeAppendix = '!';
}
const originalCommit = commitMap.get(parsedCommit.header);
(0, outvariant_1.invariant)(originalCommit, 'Failed to parse commit "%s": no original commit found associated with header', parsedCommit.header);
const commit = Object.assign({}, resolvedParsingResult, {
hash: originalCommit.hash,
typeAppendix,
});
parsedCommits.push(commit);
})
.on('end', () => parsingStreamPromise.resolve(parsedCommits));
return parsingStreamPromise;
}
exports.parseCommits = parseCommits;
function joinCommit(subject, body) {
return [subject, body].filter(Boolean).join('\n');
}
//# sourceMappingURL=parseCommits.js.map
{"version":3,"file":"parseCommits.js","sourceRoot":"","sources":["../../../../src/utils/git/parseCommits.ts"],"names":[],"mappings":";;;;;;AAAA,6CAAyC;AACzC,2CAAsC;AACtC,mEAA8D;AAE9D,8FAAqD;AAQrD,MAAM,6BAA6B,GAAG,cAAc,CAAA;AAE7C,KAAK,UAAU,YAAY,CAChC,OAAiB;IAEjB,MAAM,OAAO,GAAG,IAAI,yBAAW,EAAE,CAAA;IACjC,MAAM,SAAS,GAAwB,IAAI,GAAG,EAAE,CAAA;IAEhD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC5B,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;QACrC,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QACvD,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;KAC/B;IAED,OAAO,CAAC,GAAG,EAAE,CAAA;IAEb,MAAM,YAAY,GAAG,IAAA,qCAAW,GAAE,CAAA;IAElC,MAAM,oBAAoB,GAAG,IAAI,kCAAe,EAE7C,CAAA;IACH,oBAAoB,CAAC,OAAO,CAAC,GAAG,EAAE;QAChC,OAAO,CAAC,OAAO,EAAE,CAAA;IACnB,CAAC,CAAC,CAAA;IAEF,MAAM,aAAa,GAAgC,EAAE,CAAA;IAErD,OAAO;SACJ,IAAI,CAAC,YAAY,CAAC;SAClB,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,oBAAoB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SAC1D,EAAE,CAAC,MAAM,EAAE,CAAC,YAA0B,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MAAM,IAAA,qBAAS,EAAC,UAAU,CAAC,CAAA;AAC7B,CAAC;AAFD,oBAEC"}
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createComment = void 0;
const node_fetch_1 = __importDefault(require("node-fetch"));
const outvariant_1 = require("outvariant");
const getInfo_1 = require("../git/getInfo");
async function createComment(issueId, body) {
const repo = await (0, getInfo_1.getInfo)();
const response = await (0, node_fetch_1.default)(`https://api.github.com/repos/${repo.owner}/${repo.name}/issues/${issueId}/comments`, {
method: 'POST',
headers: {
Authorization: `token ${process.env.GITHUB_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
body,
}),
});
(0, outvariant_1.invariant)(response.ok, 'Failed to create GitHub comment for "%s" issue.', issueId);
}
exports.createComment = createComment;
//# sourceMappingURL=createComment.js.map
{"version":3,"file":"createComment.js","sourceRoot":"","sources":["../../../../src/utils/github/createComment.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA8B;AAC9B,2CAAsC;AACtC,4CAAwC;AAEjC,KAAK,UAAU,aAAa,CACjC,OAAe,EACf,IAAY;IAEZ,MAAM,IAAI,GAAG,MAAM,IAAA,iBAAO,GAAE,CAAA;IAE5B,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAC1B,gCAAgC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,WAAW,OAAO,WAAW,EACpF;QACE,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,aAAa,EAAE,SAAS,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE;YAClD,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,IAAI;SACL,CAAC;KACH,CACF,CAAA;IAED,IAAA,sBAAS,EACP,QAAQ,CAAC,EAAE,EACX,iDAAiD,EACjD,OAAO,CACR,CAAA;AACH,CAAC;AAzBD,sCAyBC"}
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createGitHubRelease = void 0;
const node_fetch_1 = __importDefault(require("node-fetch"));
const outvariant_1 = require("outvariant");
const semver_1 = require("semver");
const getGitHubRelease_1 = require("./getGitHubRelease");
const logger_1 = require("../../logger");
/**
* Create a new GitHub release with the given release notes.
* This is only called if there's no existing GitHub release
* for the next release tag.
* @return {string} The URL of the newly created release.
*/
async function createGitHubRelease(context, notes) {
const { repo } = context;
logger_1.log.info((0, outvariant_1.format)('creating a new GitHub release at "%s/%s"...', repo.owner, repo.name));
// Determine if the next release should be marked as the
// latest release on GitHub. For that, fetch whichever latest
// release exists on GitHub and see if its version is larger
// than the version we are releasing right now.
const latestGitHubRelease = await (0, getGitHubRelease_1.getGitHubRelease)('latest').catch((error) => {
logger_1.log.error(`Failed to fetch the latest GitHub release:`, error);
// We aren't interested in the GET endpoint errors in this context.
return undefined;
});
const shouldMarkAsLatest = latestGitHubRelease
? (0, semver_1.lt)(latestGitHubRelease.tag_name || '0.0.0', context.nextRelease.tag)
: // Undefined is fine, it means GitHub will use its default
// value for the "make_latest" property in the API.
undefined;
/**
* @see https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#create-a-release
*/
const response = await (0, node_fetch_1.default)(`https://api.github.com/repos/${repo.owner}/${repo.name}/releases`, {
method: 'POST',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
tag_name: context.nextRelease.tag,
name: context.nextRelease.tag,
body: notes,
make_latest: shouldMarkAsLatest?.toString(),
}),
});
if (response.status === 401) {
throw new Error('Failed to create a new GitHub release: provided GITHUB_TOKEN does not have sufficient permissions to perform this operation. Please check your token and update it if necessary.');
}
if (response.status !== 201) {
throw new Error((0, outvariant_1.format)('Failed to create a new GitHub release: GitHub API responded with status code %d.', response.status, await response.text()));
}
return response.json();
}
exports.createGitHubRelease = createGitHubRelease;
//# sourceMappingURL=createGitHubRelease.js.map
{"version":3,"file":"createGitHubRelease.js","sourceRoot":"","sources":["../../../../src/utils/github/createGitHubRelease.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA8B;AAC9B,2CAAmC;AACnC,mCAA2B;AAE3B,yDAAyE;AACzE,yCAAkC;AAElC;;;;;GAKG;AACI,KAAK,UAAU,mBAAmB,CACvC,OAAuB,EACvB,KAAa;IAEb,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAA;IAExB,YAAG,CAAC,IAAI,CACN,IAAA,mBAAM,EACJ,6CAA6C,EAC7C,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,IAAI,CACV,CACF,CAAA;IAED,wDAAwD;IACxD,6DAA6D;IAC7D,4DAA4D;IAC5D,+CAA+C;IAC/C,MAAM,mBAAmB,GAAG,MAAM,IAAA,mCAAgB,EAAC,QAAQ,CAAC,CAAC,KAAK,CAChE,CAAC,KAAK,EAAE,EAAE;QACR,YAAG,CAAC,KAAK,CAAC,4CAA4C,EAAE,KAAK,CAAC,CAAA;QAC9D,mEAAmE;QACnE,OAAO,SAAS,CAAA;IAClB,CAAC,CACF,CAAA;IACD,MAAM,kBAAkB,GAAG,mBAAmB;QAC5C,CAAC,CAAC,IAAA,WAAE,EAAC,mBAAmB,CAAC,QAAQ,IAAI,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC;QACtE,CAAC,CAAC,0DAA0D;YAC1D,mDAAmD;YACnD,SAAS,CAAA;IAEb;;OAEG;IACH,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAC1B,gCAAgC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,WAAW,EAClE;QACE,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,MAAM,EAAE,kBAAkB;YAC1B,aAAa,EAAE,UAAU,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE;YACnD,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,QAAQ,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG;YACjC,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG;YAC7B,IAAI,EAAE,KAAK;YACX,WAAW,EAAE,kBAAkB,EAAE,QAAQ,EAAE;SAC5C,CAAC;KACH,CACF,CAAA;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;QAC3B,MAAM,IAAI,KAAK,CACb,kLAAkL,CACnL,CAAA;KACF;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;QAC3B,MAAM,IAAI,KAAK,CACb,IAAA,mBAAM,EACJ,kFAAkF,EAClF,QAAQ,CAAC,MAAM,EACf,MAAM,QAAQ,CAAC,IAAI,EAAE,CACtB,CACF,CAAA;KACF;IAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;AACxB,CAAC;AArED,kDAqEC"}
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCommitAuthors = void 0;
const node_fetch_1 = __importDefault(require("node-fetch"));
const outvariant_1 = require("outvariant");
const getInfo_1 = require("../../utils/git/getInfo");
const logger_1 = require("../../logger");
/**
* Get a list of GitHub usernames who have contributed
* to the given release commit. This analyzes all the commit
* authors in the pull request referenced by the given commit.
*/
async function getCommitAuthors(commit) {
// Extract all GitHub issue references from this commit.
const issueRefs = new Set();
for (const ref of commit.references) {
if (ref.issue) {
issueRefs.add(ref.issue);
}
}
if (issueRefs.size === 0) {
return new Set();
}
const repo = await (0, getInfo_1.getInfo)();
const queue = [];
const authors = new Set();
function addAuthor(login) {
if (!login) {
return;
}
authors.add(login);
}
for (const issueId of issueRefs) {
const authorLoginPromise = new Promise(async (resolve, reject) => {
const response = await (0, node_fetch_1.default)(`https://api.github.com/graphql`, {
method: 'POST',
headers: {
Agent: 'ossjs/release',
Accept: 'application/json',
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: `
query GetCommitAuthors($owner: String!, $repo: String!, $pullRequestId: Int!) {
repository(owner: $owner name: $repo) {
pullRequest(number: $pullRequestId) {
url
author {
login
}
commits(first: 100) {
nodes {
commit {
authors(first: 100) {
nodes {
user {
login
}
}
}
}
}
}
}
}
}
`,
variables: {
owner: repo.owner,
repo: repo.name,
pullRequestId: Number(issueId),
},
}),
});
if (!response.ok) {
return reject(new Error((0, outvariant_1.format)('GitHub API responded with %d.', response.status)));
}
const json = await response.json();
const data = json.data;
if (json.errors) {
return reject(new Error((0, outvariant_1.format)('GitHub API responded with %d error(s): %j', json.errors.length, json.errors)));
}
// Add pull request author.
addAuthor(data.repository.pullRequest.author.login);
// Add each commit author in the pull request.
for (const commit of data.repository.pullRequest.commits.nodes) {
for (const author of commit.commit.authors.nodes) {
/**
* @note In some situations, GitHub will return "user: null"
* for the commit user. Nobody to add to the authors then.
*/
if (author.user != null) {
addAuthor(author.user.login);
}
}
}
resolve();
});
queue.push(authorLoginPromise.catch((error) => {
logger_1.log.error((0, outvariant_1.format)('Failed to extract the authors for the issue #%d:', issueId, error.message));
}));
}
// Extract author GitHub handles in parallel.
await Promise.allSettled(queue);
return authors;
}
exports.getCommitAuthors = getCommitAuthors;
//# sourceMappingURL=getCommitAuthors.js.map
{"version":3,"file":"getCommitAuthors.js","sourceRoot":"","sources":["../../../../src/utils/github/getCommitAuthors.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA8B;AAC9B,2CAAmC;AACnC,qDAAiD;AAEjD,yCAAkC;AAsBlC;;;;GAIG;AACI,KAAK,UAAU,gBAAgB,CACpC,MAA4B;IAE5B,wDAAwD;IACxD,MAAM,SAAS,GAAgB,IAAI,GAAG,EAAE,CAAA;IACxC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,UAAU,EAAE;QACnC,IAAI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? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getGitHubRelease = void 0;
const outvariant_1 = require("outvariant");
const node_fetch_1 = __importDefault(require("node-fetch"));
const getInfo_1 = require("../git/getInfo");
async function getGitHubRelease(tag) {
const repo = await (0, getInfo_1.getInfo)();
const response = await (0, node_fetch_1.default)(tag === 'latest'
? `https://api.github.com/repos/${repo.owner}/${repo.name}/releases/latest`
: `https://api.github.com/repos/${repo.owner}/${repo.name}/releases/tags/${tag}`, {
headers: {
Accept: 'application/json',
Authorization: `token ${process.env.GITHUB_TOKEN}`,
},
});
if (response.status === 404) {
return undefined;
}
(0, outvariant_1.invariant)(response.ok, 'Failed to fetch GitHub release for tag "%s": server responded with %d.\n\n%s', tag, response.status);
return response.json();
}
exports.getGitHubRelease = getGitHubRelease;
//# sourceMappingURL=getGitHubRelease.js.map
{"version":3,"file":"getGitHubRelease.js","sourceRoot":"","sources":["../../../../src/utils/github/getGitHubRelease.ts"],"names":[],"mappings":";;;;;;AAAA,2CAAsC;AACtC,4DAA8B;AAC9B,4CAAwC;AAOjC,KAAK,UAAU,gBAAgB,CACpC,GAA6B;IAE7B,MAAM,IAAI,GAAG,MAAM,IAAA,iBAAO,GAAE,CAAA;IAE5B,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAC1B,GAAG,KAAK,QAAQ;QACd,CAAC,CAAC,gCAAgC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,kBAAkB;QAC3E,CAAC,CAAC,gCAAgC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,kBAAkB,GAAG,EAAE,EAClF;QACE,OAAO,EAAE;YACP,MAAM,EAAE,kBAAkB;YAC1B,aAAa,EAAE,SAAS,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE;SACnD;KACF,CACF,CAAA;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;QAC3B,OAAO,SAAS,CAAA;KACjB;IAED,IAAA,sBAAS,EACP,QAAQ,CAAC,EAAE,EACX,8EAA8E,EAC9E,GAAG,EACH,QAAQ,CAAC,MAAM,CAChB,CAAA;IAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;AACxB,CAAC;AA7BD,4CA6BC"}
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateAccessToken = exports.GITHUB_NEW_TOKEN_URL = exports.requiredGitHubTokenScopes = void 0;
const node_fetch_1 = __importDefault(require("node-fetch"));
const outvariant_1 = require("outvariant");
exports.requiredGitHubTokenScopes = [
'repo',
'admin:repo_hook',
'admin:org_hook',
];
exports.GITHUB_NEW_TOKEN_URL = `https://github.com/settings/tokens/new?scopes=${exports.requiredGitHubTokenScopes.join(',')}`;
/**
* Check whether the given GitHub access token has sufficient permissions
* for this library to create and publish a new release.
*/
async function validateAccessToken(accessToken) {
const response = await (0, node_fetch_1.default)('https://api.github.com', {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});
const permissions = response.headers
.get('x-oauth-scopes')
?.split(',')
.map((scope) => scope.trim()) || [];
// Handle generic error responses.
(0, outvariant_1.invariant)(response.ok, 'Failed to verify GitHub token permissions: GitHub API responded with %d %s. Please double-check your "GITHUB_TOKEN" environmental variable and try again.', response.status, response.statusText);
(0, outvariant_1.invariant)(permissions.length > 0, 'Failed to verify GitHub token permissions: GitHub API responded with an empty "X-OAuth-Scopes" header.');
const missingScopes = exports.requiredGitHubTokenScopes.filter((scope) => {
return !permissions.includes(scope);
});
if (missingScopes.length > 0) {
(0, outvariant_1.invariant)(false, 'Provided "GITHUB_TOKEN" environment variable has insufficient permissions: missing scopes "%s". Please generate a new GitHub personal access token from this URL: %s', missingScopes.join(`", "`), exports.GITHUB_NEW_TOKEN_URL);
}
}
exports.validateAccessToken = validateAccessToken;
//# sourceMappingURL=validateAccessToken.js.map
{"version":3,"file":"validateAccessToken.js","sourceRoot":"","sources":["../../../../src/utils/github/validateAccessToken.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA8B;AAC9B,2CAAsC;AAEzB,QAAA,yBAAyB,GAAa;IACjD,MAAM;IACN,iBAAiB;IACjB,gBAAgB;CACjB,CAAA;AAEY,QAAA,oBAAoB,GAAG,iDAAiD,iCAAyB,CAAC,IAAI,CACjH,GAAG,CACJ,EAAE,CAAA;AAEH;;;GAGG;AACI,KAAK,UAAU,mBAAmB,CAAC,WAAmB;IAC3D,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAAC,wBAAwB,EAAE;QACrD,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,WAAW,EAAE;SACvC;KACF,CAAC,CAAA;IACF,MAAM,WAAW,GACf,QAAQ,CAAC,OAAO;SACb,GAAG,CAAC,gBAAgB,CAAC;QACtB,EAAE,KAAK,CAAC,GAAG,CAAC;SACX,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAA;IAEvC,kCAAkC;IAClC,IAAA,sBAAS,EACP,QAAQ,CAAC,EAAE,EACX,2JAA2J,EAC3J,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,UAAU,CACpB,CAAA;IAED,IAAA,sBAAS,EACP,WAAW,CAAC,MAAM,GAAG,CAAC,EACtB,wGAAwG,CACzG,CAAA;IAED,MAAM,aAAa,GAAG,iCAAyB,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QAC/D,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;IAEF,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;QAC5B,IAAA,sBAAS,EACP,KAAK,EACL,sKAAsK,EACtK,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,EAC1B,4BAAoB,CACrB,CAAA;KACF;AACH,CAAC;AArCD,kDAqCC"}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.readPackageJson = void 0;
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const execAsync_1 = require("./execAsync");
function readPackageJson() {
const packageJsonPath = path.resolve(execAsync_1.execAsync.contextOptions.cwd.toString(), 'package.json');
return JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
}
exports.readPackageJson = readPackageJson;
//# sourceMappingURL=readPackageJson.js.map
{"version":3,"file":"readPackageJson.js","sourceRoot":"","sources":["../../../src/utils/readPackageJson.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAwB;AACxB,2CAA4B;AAC5B,2CAAuC;AAEvC,SAAgB,eAAe;IAC7B,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAClC,qBAAS,CAAC,cAAc,CAAC,GAAI,CAAC,QAAQ,EAAE,EACxC,cAAc,CACf,CAAA;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,CAAA;AAC7D,CAAC;AAPD,0CAOC"}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.injectReleaseContributors = exports.groupCommitsByReleaseType = exports.getReleaseNotes = void 0;
const getNextReleaseType_1 = require("../getNextReleaseType");
const getCommitAuthors_1 = require("../github/getCommitAuthors");
const IGNORED_COMMIT_TYPES = ['chore'];
async function getReleaseNotes(commits) {
const groupedNotes = await groupCommitsByReleaseType(commits);
const notes = await injectReleaseContributors(groupedNotes);
return notes;
}
exports.getReleaseNotes = getReleaseNotes;
async function groupCommitsByReleaseType(commits) {
const groups = new Map();
for (const commit of commits) {
const { type, merge } = commit;
// Skip commits without a type, merge commits, and commit
// types that repesent internal changes (i.e. "chore").
if (!type || merge || IGNORED_COMMIT_TYPES.includes(type)) {
continue;
}
const noteType = (0, getNextReleaseType_1.isBreakingChange)(commit)
? 'breaking'
: type;
const prevCommits = groups.get(noteType) || new Set();
groups.set(noteType, prevCommits.add(commit));
}
return groups;
}
exports.groupCommitsByReleaseType = groupCommitsByReleaseType;
async function injectReleaseContributors(groups) {
const notes = new Map();
for (const [releaseType, commits] of groups) {
notes.set(releaseType, new Set());
for (const commit of commits) {
// Don't parallelize this because then the original
// order of commits may be lost.
const authors = await (0, getCommitAuthors_1.getCommitAuthors)(commit);
if (authors) {
const releaseCommit = Object.assign({}, commit, {
authors,
});
notes.get(releaseType)?.add(releaseCommit);
}
}
}
return notes;
}
exports.injectReleaseContributors = injectReleaseContributors;
//# sourceMappingURL=getReleaseNotes.js.map
{"version":3,"file":"getReleaseNotes.js","sourceRoot":"","sources":["../../../../src/utils/release-notes/getReleaseNotes.ts"],"names":[],"mappings":";;;AAAA,8DAAwD;AAExD,iEAA6D;AAa7D,MAAM,oBAAoB,GAAG,CAAC,OAAO,CAAC,CAAA;AAE/B,KAAK,UAAU,eAAe,CACnC,OAA+B;IAE/B,MAAM,YAAY,GAAG,MAAM,yBAAyB,CAAC,OAAO,CAAC,CAAA;IAC7D,MAAM,KAAK,GAAG,MAAM,yBAAyB,CAAC,YAAY,CAAC,CAAA;IAE3D,OAAO,KAAK,CAAA;AACd,CAAC;AA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WAAW,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC,CAAA;aAC3C;SACF;KACF;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AA5BD,8DA4BC"}
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getReleaseRefs = void 0;
const node_fetch_1 = __importDefault(require("node-fetch"));
const issue_parser_1 = __importDefault(require("issue-parser"));
const getInfo_1 = require("../git/getInfo");
const parser = (0, issue_parser_1.default)('github');
function extractIssueIds(text, repo) {
const ids = new Set();
const parsed = parser(text);
for (const action of parsed.actions.close) {
if (action.slug == null || action.slug === `${repo.owner}/${repo.name}`) {
ids.add(action.issue);
}
}
return ids;
}
async function getReleaseRefs(commits) {
const repo = await (0, getInfo_1.getInfo)();
const issueIds = new Set();
for (const commit of commits) {
// Extract issue ids from the commit messages.
for (const ref of commit.references) {
if (ref.issue) {
issueIds.add(ref.issue);
}
}
// Extract issue ids from the commit bodies.
if (commit.body) {
const bodyIssueIds = extractIssueIds(commit.body, repo);
bodyIssueIds.forEach((id) => issueIds.add(id));
}
}
// Fetch issue detail from each issue referenced in the commit message
// or commit body. Those may include pull request ids that reference
// other issues.
const issuesFromCommits = await Promise.all(Array.from(issueIds).map(fetchIssue));
// Extract issue ids from the pull request descriptions.
for (const issue of issuesFromCommits) {
// Ignore regular issues as they may not close/fix other issues
// by reference (at least on GitHub).
if (!issue.pull_request || !issue.body) {
continue;
}
const descriptionIssueIds = extractIssueIds(issue.body, repo);
descriptionIssueIds.forEach((id) => issueIds.add(id));
}
return issueIds;
}
exports.getReleaseRefs = getReleaseRefs;
async function fetchIssue(id) {
const repo = await (0, getInfo_1.getInfo)();
const response = await (0, node_fetch_1.default)(`https://api.github.com/repos/${repo.owner}/${repo.name}/issues/${id}`, {
headers: {
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
},
});
const resource = (await response.json());
return resource;
}
//# sourceMappingURL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,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;SAC/C;KACF;IAED,sEAAsE;IACtE,oEAAoE;IACpE,gBAAgB;IAChB,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,GAAG,CACzC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CACrC,CAAA;IAED,wDAAwD;IACxD,KAAK,MAAM,KAAK,IAAI,iBAAiB,EAAE;QACrC,+DAA+D;QAC/D,qCAAqC;QACrC,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;YACtC,SAAQ;SACT;QAED,MAAM,mBAAmB,GAAG,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAC7D,mBAAmB,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;KACtD;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC;AAzCD,wCAyCC;AAQD,KAAK,UAAU,UAAU,CAAC,EAAU;IAClC,MAAM,IAAI,GAAG,MAAM,IAAA,iBAAO,GAAE,CAAA;IAC5B,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAC1B,gCAAgC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,WAAW,EAAE,EAAE,EACtE;QACE,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE;SACpD;KACF,CACF,CAAA;IACD,MAAM,QAAQ,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAgC,CAAA;IAEvE,OAAO,QAAQ,CAAA;AACjB,CAAC"}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.printAuthors = exports.toMarkdown = void 0;
const formatDate_1 = require("../formatDate");
/**
* Generate a Markdown string for the given release notes.
*/
function toMarkdown(context, notes) {
const markdown = [];
const releaseDate = (0, formatDate_1.formatDate)(context.nextRelease.publishedAt);
markdown.push(`## ${context.nextRelease.tag} (${releaseDate})`);
const sections = {
breaking: [],
feat: [],
fix: [],
};
for (const [noteType, commits] of notes) {
const section = sections[noteType];
if (!section) {
continue;
}
for (const commit of commits) {
const releaseItem = createReleaseItem(commit, noteType === 'breaking');
if (releaseItem) {
section.push(...releaseItem);
}
}
}
if (sections.breaking.length > 0) {
markdown.push('', '### ⚠️ BREAKING CHANGES');
markdown.push(...sections.breaking);
}
if (sections.feat.length > 0) {
markdown.push('', '### Features', '');
markdown.push(...sections.feat);
}
if (sections.fix.length > 0) {
markdown.push('', '### Bug Fixes', '');
markdown.push(...sections.fix);
}
return markdown.join('\n');
}
exports.toMarkdown = toMarkdown;
function createReleaseItem(commit, includeCommitNotes = false) {
const { subject, scope, hash } = commit;
if (!subject) {
return [];
}
const commitLine = [
[
'-',
scope && `**${scope}:**`,
subject,
`(${hash})`,
printAuthors(commit.authors),
]
.filter(Boolean)
.join(' '),
];
if (includeCommitNotes) {
const notes = commit.notes.reduce((all, note) => {
return all.concat('', note.text);
}, []);
if (notes.length > 0) {
commitLine.unshift('');
commitLine.push(...notes);
}
}
return commitLine;
}
function printAuthors(authors) {
if (authors.size === 0) {
return undefined;
}
return Array.from(authors)
.map((login) => `@${login}`)
.join(' ');
}
exports.printAuthors = printAuthors;
//# sourceMappingURL=toMarkdown.js.map
{"version":3,"file":"toMarkdown.js","sourceRoot":"","sources":["../../../../src/utils/release-notes/toMarkdown.ts"],"names":[],"mappings":";;;AACA,8CAA0C;AAO1C;;GAEG;AACH,SAAgB,UAAU,CACxB,OAAuB,EACvB,KAAmB;IAEnB,MAAM,QAAQ,GAAa,EAAE,CAAA;IAC7B,MAAM,WAAW,GAAG,IAAA,uBAAU,EAAC,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAA;IAE/D,QAAQ,CAAC,IAAI,CAAC,MAAM,OAAO,CAAC,WAAW,CAAC,GAAG,KAA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;AAED,SAAS,iBAAiB,CACxB,MAAyB,EACzB,qBAA8B,KAAK;IAEnC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,CAAA;IAEvC,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,EAAE,CAAA;KACV;IAED,MAAM,UAAU,GAAa;QAC3B;YACE,GAAG;YACH,KAAK,IAAI,KAAK,KAAK,KAAK;YACxB,OAAO;YACP,IAAI,IAAI,GAAG;YACX,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC;SAC7B;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC;KACb,CAAA;IAED,IAAI,kBAAkB,EAAE;QACtB,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAW,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACxD,OAAO,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;QAClC,CAAC,EAAE,EAAE,CAAC,CAAA;QAEN,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YACpB,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;YACtB,UAAU,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAA;SAC1B;KACF;IAED,OAAO,UAAU,CAAA;AACnB,CAAC;AAED,SAAgB,YAAY,CAAC,OAAoB;IAC/C,IAAI,OAAO,CAAC,IAAI,KAAK,CAAC,EAAE;QACtB,OAAO,SAAS,CAAA;KACjB;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;SACvB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC;SAC3B,IAAI,CAAC,GAAG,CAAC,CAAA;AACd,CAAC;AARD,oCAQC"}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.writePackageJson = void 0;
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const execAsync_1 = require("./execAsync");
function writePackageJson(nextContent) {
const packageJsonPath = path.resolve(execAsync_1.execAsync.contextOptions.cwd.toString(), 'package.json');
fs.writeFileSync(packageJsonPath,
/**
* @fixme Do not alter the indentation.
*/
JSON.stringify(nextContent, null, 2));
}
exports.writePackageJson = writePackageJson;
//# sourceMappingURL=writePackageJson.js.map
{"version":3,"file":"writePackageJson.js","sourceRoot":"","sources":["../../../src/utils/writePackageJson.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAwB;AACxB,2CAA4B;AAC5B,2CAAuC;AAEvC,SAAgB,gBAAgB,CAAC,WAAgC;IAC/D,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAClC,qBAAS,CAAC,cAAc,CAAC,GAAI,CAAC,QAAQ,EAAE,EACxC,cAAc,CACf,CAAA;IAED,EAAE,CAAC,aAAa,CACd,eAAe;IACf;;OAEG;IACH,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CACrC,CAAA;AACH,CAAC;AAbD,4CAaC"}
#!/usr/bin/env node
require('./build/index.js')