From 3cc34c195fed7aca456c8eb4dd141ca131e654ac Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 22 Dec 2023 13:44:50 +0800 Subject: [PATCH] feat(notify): bin --- .github/workflows/bring-it.yaml | 4 ---- packages/notify/.best-shot/config.mjs | 1 + packages/notify/lib/action.mjs | 3 +-- packages/notify/lib/bin.mjs | 4 ++++ packages/notify/package.json | 5 ++++- packages/utils/index.mjs | 2 +- 6 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 packages/notify/lib/bin.mjs diff --git a/.github/workflows/bring-it.yaml b/.github/workflows/bring-it.yaml index d6f9a7d..f30c317 100644 --- a/.github/workflows/bring-it.yaml +++ b/.github/workflows/bring-it.yaml @@ -37,7 +37,3 @@ jobs: with: npm-token: ${{ secrets.NPM_TOKEN }} publish-command: npx -p @bring-it/npm@latest bring-it npm - custom-command: | - cd packages - mkdir -p cli/dist - touch $_/cli.mjs diff --git a/packages/notify/.best-shot/config.mjs b/packages/notify/.best-shot/config.mjs index 8969f64..cbe59f1 100644 --- a/packages/notify/.best-shot/config.mjs +++ b/packages/notify/.best-shot/config.mjs @@ -4,6 +4,7 @@ export const config = { path: 'dist', module: true, }, + copy: ['./lib/bin.mjs'], entry: { sub: './lib/cmd.mjs', }, diff --git a/packages/notify/lib/action.mjs b/packages/notify/lib/action.mjs index 8ebae51..15717fc 100644 --- a/packages/notify/lib/action.mjs +++ b/packages/notify/lib/action.mjs @@ -32,8 +32,7 @@ export async function action({ mode }) { for (const { DingTalkRobotToken: token, levels: lv } of all.subscribe) { if ( token && - lv?.length && - levels.some((level) => lv.includes(level)) + (!lv || (lv?.length && levels.some((level) => lv.includes(level)))) ) { dingtalk({ markdown, token }); } diff --git a/packages/notify/lib/bin.mjs b/packages/notify/lib/bin.mjs new file mode 100644 index 0000000..21d7ee5 --- /dev/null +++ b/packages/notify/lib/bin.mjs @@ -0,0 +1,4 @@ +#!/usr/bin/env node + +/* eslint-disable n/shebang */ +import '@bring-it/cli/dist/cli.mjs'; diff --git a/packages/notify/package.json b/packages/notify/package.json index 1a3e98b..8c9145c 100644 --- a/packages/notify/package.json +++ b/packages/notify/package.json @@ -1,6 +1,6 @@ { "name": "@bring-it/notify", - "version": "0.2.9", + "version": "0.2.10", "description": "Send releases notifications", "license": "MIT", "author": { @@ -27,6 +27,9 @@ "bugs": { "url": "https://github.com/airkro/bring-it/issues" }, + "bin": { + "bring-it": "dist/bin.mjs" + }, "main": "dist/sub.mjs", "files": [ "dist" diff --git a/packages/utils/index.mjs b/packages/utils/index.mjs index 6f310e2..5069c0a 100644 --- a/packages/utils/index.mjs +++ b/packages/utils/index.mjs @@ -68,7 +68,7 @@ function readJSON(configName, logger) { if (BRANCH_NAME) { const { branches, ...rest } = json; - return { ...rest, ...branches[BRANCH_NAME] }; + return { ...rest, ...branches?.[BRANCH_NAME] }; } return json;