Skip to content

Commit

Permalink
feat(notify): options.rc
Browse files Browse the repository at this point in the history
  • Loading branch information
Airkro committed Jun 25, 2024
1 parent 828a25e commit a35e3f3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion packages/notify/lib/action.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function action({ name }) {
return false;
}

const { markdown, levels } = createContent(all);
const { markdown, levels } = await createContent(all);

logger.json({ levels });

Expand Down
21 changes: 13 additions & 8 deletions packages/notify/lib/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const {
PROJECT_WEB_URL,
} = process.env;

function getVersion({ isLatest, version }) {
function getVersion({ isLatest, version, rc }) {
let name = npm_package_version;

if (version !== true) {
Expand All @@ -33,7 +33,9 @@ function getVersion({ isLatest, version }) {
} catch {}
}

return isLatest ? ['latest', name].join(' / ') : name;
const ver = rc ? `${name}-rc${CI_BUILD_NUMBER}` : name;

return isLatest ? ['latest', ver].join(' / ') : ver;
}

export function dingtalk({ markdown, token }) {
Expand Down Expand Up @@ -119,7 +121,7 @@ const configs = {
},
};

function getlog(from, to) {
async function getlog(from, to) {
console.log({ from, to });

return gitlog({
Expand All @@ -129,7 +131,7 @@ function getlog(from, to) {
});
}

function getLogs() {
async function getLogs() {
try {
if (!GIT_PREVIOUS_COMMIT) {
throw new Error('GIT_PREVIOUS_COMMIT is null');
Expand Down Expand Up @@ -159,14 +161,15 @@ const DEPOT_URL = `${PROJECT_WEB_URL}/d/${DEPOT_NAME}`;

const headerPattern = /^(\w*)(?:\((\S*)\))?:\s?(.*)$/;

function getCommits() {
async function getCommits() {
const io =
!GIT_PREVIOUS_COMMIT || (GIT_COMMIT && GIT_COMMIT === GIT_PREVIOUS_COMMIT)
? []
: sortBy(
Object.entries(
groupBy(
getLogs().map(({ abbrevHash, hash, subject }) => ({
// eslint-disable-next-line unicorn/no-await-expression-member
(await getLogs()).map(({ abbrevHash, hash, subject }) => ({
hash,
abbrevHash,
message: sync(subject, { headerPattern }),
Expand Down Expand Up @@ -233,16 +236,17 @@ function short(hash) {
return hash.slice(0, 7);
}

export function createContent({
export async function createContent({
project = '未命名项目',
type,
manual = true,
banner,
isLatest = false,
image,
version = true,
rc = false,
}) {
const levels = getCommits();
const levels = await getCommits();

return {
levels: levels
Expand Down Expand Up @@ -356,6 +360,7 @@ export function createContent({
value: `版本编号:${getVersion({
isLatest,
version,
rc,
})}`,
},
],
Expand Down
4 changes: 2 additions & 2 deletions packages/notify/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bring-it/notify",
"version": "0.3.4",
"version": "0.3.6",
"description": "Send releases notifications",
"license": "MIT",
"author": {
Expand Down Expand Up @@ -42,7 +42,7 @@
"devDependencies": {
"conventional-commits-parser": "^5.0.0",
"fast-clean": "^1.3.2",
"gitlog": "^4.0.8",
"gitlog": "^5.0.1",
"lodash": "^4.17.21",
"mdast-util-to-markdown": "^2.1.0",
"semver": "^7.6.2"
Expand Down
18 changes: 6 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a35e3f3

Please sign in to comment.