Skip to content

Commit

Permalink
conventional-release.js 파일에서 simple-git 패키지 dependency 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
shine1594 committed Jul 30, 2021
1 parent a80af3c commit 7249f84
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
27 changes: 12 additions & 15 deletions src/conventional-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ const conventionalChangelogConfig = require("conventional-changelog-conventional
const conventionalGithubReleaser = require("./conventional-github-releaser");
const _ = require("fxjs");
const gitRawCommits = require("git-raw-commits");
const simpleGit = require("simple-git");
const git = simpleGit();

const getLatestVersion = async (app) =>
const getLatestVersion = (app, tags) =>
_.go(
await git.tags(),
tags,
_.sel("all"),
_.filter((a) => a.startsWith(app)),
_.last,
Expand Down Expand Up @@ -52,10 +50,13 @@ const getRecommendation = (parser_options = {}, whatBump = whatBumpAngular) =>
);
});

const applyRecommendation = async (app, recommendation) => {
const [major, minor, patch] = _.map(
Number,
_.split(".", await getLatestVersion(app))
const applyRecommendation = (app, latest_tag, recommendation) => {
const [major, minor, patch] = _.go(
latest_tag,
_.split("@"),
_.last,
_.split("."),
_.map(Number)
);
const { releaseType } = recommendation;
if (releaseType === "major") return `${major + 1}.0.0`;
Expand All @@ -71,21 +72,17 @@ const whatBumpFor = _.curry((app, commits) => {
return whatBumpAngular(scope_filtered_commits);
});

const getCommitHashForTag = async (tag) =>
_.go(await git.raw("show-ref", tag), _.split(" "), _.head);

const getNextVersion = async (app, from) => {
const from_hash = await getCommitHashForTag(from);
const getNextVersion = async (app, from, hash) => {
const parser_options = _.pick(
["headerPattern", "breakingHeaderPattern"],
(await conventionalChangelogConfig()).conventionalChangelog.parserOpts
);
const recommendation = await getRecommendation(parser_options, (commits) => {
const from_index = commits.findIndex((c) => c.hash === from_hash);
const from_index = commits.findIndex((c) => c.hash === hash);
const filtered_commits = _.slice(0, from_index, commits);
return whatBumpFor(app, filtered_commits);
});
return applyRecommendation(app, recommendation);
return applyRecommendation(app, from, recommendation);
};

const npmVersion = async (app, version) => {
Expand Down
10 changes: 8 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ async function init(github) {
});
}

const getCommitHashOfTag = (ref) => _.go(ref, _.split(" "), _.head);

async function main(app, ref, git) {
const latest_version = await getLatestVersion(app);
const latest_version = await getLatestVersion(app, await git.tags());
const latest_tag = `${app}@${latest_version}`;
const next_version = await getNextVersion(app, latest_tag);
const next_version = await getNextVersion(
app,
latest_tag,
getCommitHashOfTag(await git.raw("show-ref", latest_tag))
);
const next_tag = `${app}@${next_version}`;
const merge_commit_message_body = generateMergeCommitBody(
await getCommits(latest_tag)
Expand Down

0 comments on commit 7249f84

Please sign in to comment.