From 3f1928ebe554bd55b5418be8179f7ebd79c31ae4 Mon Sep 17 00:00:00 2001 From: splincode Date: Fri, 27 Sep 2024 17:09:54 +0300 Subject: [PATCH] feat: add colored logger --- .github/workflows/assign-author.yml | 18 +++++++ .github/workflows/auto-merge.yml | 53 ++++++++++++++++++++ .github/workflows/ci.yml | 8 +-- .github/workflows/deploy.yml | 10 ++-- .github/workflows/pr.yml | 68 -------------------------- .github/workflows/ready-to-merge.yml | 21 ++++++++ .github/workflows/release.yml | 8 +-- libs/ng-morph/src/utils/colored-log.ts | 26 ++++++++++ libs/ng-morph/src/utils/index.ts | 1 + 9 files changed, 134 insertions(+), 79 deletions(-) create mode 100644 .github/workflows/assign-author.yml create mode 100644 .github/workflows/auto-merge.yml delete mode 100644 .github/workflows/pr.yml create mode 100644 .github/workflows/ready-to-merge.yml create mode 100644 libs/ng-morph/src/utils/colored-log.ts diff --git a/.github/workflows/assign-author.yml b/.github/workflows/assign-author.yml new file mode 100644 index 00000000..10c8ef36 --- /dev/null +++ b/.github/workflows/assign-author.yml @@ -0,0 +1,18 @@ +name: 🤖 PR author as an assignee +on: + pull_request: + +jobs: + assign: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.2.0 + - uses: taiga-family/ci/actions/setup/variables@v1.87.5 + - uses: toshimaru/auto-author-assign@v2.1.1 + if: env.IS_OWNER_MODE == 'true' + with: + repo-token: ${{ secrets.TAIGA_FAMILY_BOT_PAT }} + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml new file mode 100644 index 00000000..a273a8a0 --- /dev/null +++ b/.github/workflows/auto-merge.yml @@ -0,0 +1,53 @@ +name: 🤖 PR auto merge +on: + pull_request: + +env: + PR_JOBS_NAME: '[ "ci" ]' + +jobs: + setup: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.2.0 + - uses: taiga-family/ci/actions/setup/variables@v1.87.5 + - id: jobs + run: | + if [[ "${{ env.IS_TAIGA_FAMILY_BOT_PR_AUTHOR }}" == "true" ]]; then + echo "value=$PR_JOBS_NAME" >> $GITHUB_OUTPUT + else + echo "value=[]" >> $GITHUB_OUTPUT + fi + outputs: + jobs: ${{ steps.jobs.outputs.value }} + + wait: + needs: [setup] + runs-on: ubuntu-latest + strategy: + fail-fast: true + jobs: + value: ${{ fromJSON(needs.setup.outputs.jobs) }} + steps: + - uses: taiga-family/ci/actions/run/wait-job@v1.87.5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + job: ${{ jobs.value }} + + approve: + needs: [wait] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.2.0 + - uses: taiga-family/ci/actions/setup/variables@v1.87.5 + - uses: taiga-family/ci/actions/auto/approve/double@v1.87.5 + with: + token1: ${{ secrets.GITHUB_TOKEN }} + token2: ${{ secrets.TAIGA_FAMILY_APPROVE_BOT_PAT }} + - uses: taiga-family/ci/actions/run/merge@v1.87.5 + with: + token: ${{ secrets.TAIGA_FAMILY_BOT_PAT }} + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b2ef263..efdc7d7d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,8 +10,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4.2.0 - - uses: taiga-family/ci/actions/setup/variables@v1.87.3 - - uses: taiga-family/ci/actions/setup/node@v1.87.3 + - uses: taiga-family/ci/actions/setup/variables@v1.87.5 + - uses: taiga-family/ci/actions/setup/node@v1.87.5 - run: | if [[ "${{ env.SUPPORT_AUTO_PUSH }}" == "true" ]]; then npm run prettier -- --write @@ -27,10 +27,10 @@ jobs: npm run build npm test - - uses: taiga-family/ci/actions/auto/push@v1.87.3 + - uses: taiga-family/ci/actions/auto/push@v1.87.5 with: token: ${{ secrets.TAIGA_FAMILY_BOT_PAT }} concurrency: - group: ci-${{ github.workflow }}-${{ github.ref }} + group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 8b27b927..1b84b672 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -9,10 +9,14 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4.2.0 - - uses: taiga-family/ci/actions/setup/variables@v1.87.3 - - uses: taiga-family/ci/actions/setup/node@v1.87.3 + - uses: taiga-family/ci/actions/setup/variables@v1.87.5 + - uses: taiga-family/ci/actions/setup/node@v1.87.5 - run: npm run build:demo - - uses: taiga-family/ci/actions/deploy/github-pages@v1.87.3 + - uses: taiga-family/ci/actions/deploy/github-pages@v1.87.5 with: token: ${{ secrets.TAIGA_FAMILY_BOT_PAT }} folder: dist/apps/demo + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml deleted file mode 100644 index f27c0fd9..00000000 --- a/.github/workflows/pr.yml +++ /dev/null @@ -1,68 +0,0 @@ -name: 🤖 PR validation -on: pull_request - -env: - JOBS_NAME: '[ "ci" ]' - -jobs: - setup: - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.matrix.outputs.value }} - steps: - - uses: actions/checkout@v4.2.0 - - uses: taiga-family/ci/actions/setup/variables@v1.87.3 - - id: matrix - if: env.IS_TAIGA_FAMILY_BOT_PR_AUTHOR == 'true' - run: echo "value=$JOBS_NAME" >> $GITHUB_OUTPUT - - wait: - needs: [setup] - runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: - value: ${{ fromJSON(needs.setup.outputs.matrix) }} - steps: - - uses: taiga-family/ci/actions/run/wait-job@v1.87.3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - job: ${{ matrix.value }} - - approve: - needs: [wait] - runs-on: ubuntu-latest - steps: - - uses: taiga-family/ci/actions/auto/approve/double@v1.87.3 - with: - token1: ${{ secrets.GITHUB_TOKEN }} - token2: ${{ secrets.TAIGA_FAMILY_APPROVE_BOT_PAT }} - - uses: taiga-family/ci/actions/run/merge@v1.87.3 - with: - token: ${{ secrets.TAIGA_FAMILY_BOT_PAT }} - - label-when-approved: - name: Label when approved - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4.2.0 - - uses: taiga-family/ci/actions/setup/variables@v1.87.3 - - uses: taiga-family/ci/actions/auto/label-when-approved@v1.87.3 - with: - approvals: 1 - token: ${{ secrets.GITHUB_TOKEN }} - - assign-author: - name: PR author as an assignee - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4.2.0 - - uses: taiga-family/ci/actions/setup/variables@v1.87.3 - - uses: toshimaru/auto-author-assign@v2.1.1 - if: env.IS_OWNER_MODE == 'true' - with: - repo-token: ${{ secrets.TAIGA_FAMILY_BOT_PAT }} - -concurrency: - group: pr-${{ github.head_ref }} - cancel-in-progress: true diff --git a/.github/workflows/ready-to-merge.yml b/.github/workflows/ready-to-merge.yml new file mode 100644 index 00000000..7d1f1fe1 --- /dev/null +++ b/.github/workflows/ready-to-merge.yml @@ -0,0 +1,21 @@ +name: 🤖 PR is ready to merge +on: + pull_request_review: + types: [submitted] + +jobs: + label-when-approved: + name: Label when approved + runs-on: ubuntu-latest + if: github.event.review.state == 'APPROVED' + steps: + - uses: actions/checkout@v4.2.0 + - uses: taiga-family/ci/actions/setup/variables@v1.87.5 + - uses: taiga-family/ci/actions/auto/label-when-approved@v1.87.5 + with: + approvals: 1 + token: ${{ secrets.GITHUB_TOKEN }} + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e00e274a..43e27cb8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,18 +20,18 @@ jobs: if: "!contains(github.event.head_commit.message, 'chore(release)')" steps: - uses: actions/checkout@v4.2.0 - - uses: taiga-family/ci/actions/run/release-it@v1.87.3 + - uses: taiga-family/ci/actions/run/release-it@v1.87.5 with: ref: ${{ github.ref }} mode: ${{ github.event.inputs.mode }} npmToken: ${{ secrets.NPM_TOKEN }} githubToken: ${{ secrets.TAIGA_FAMILY_BOT_PAT }} - - uses: taiga-family/ci/actions/run/read-package-json@v1.87.3 + - uses: taiga-family/ci/actions/run/read-package-json@v1.87.5 id: info - name: Announce to Telegram - uses: taiga-family/ci/actions/messenger/telegram/announce@v1.87.3 + uses: taiga-family/ci/actions/messenger/telegram/announce@v1.87.5 with: chatId: ${{ secrets.TAIGA_TELEGRAM_CHAT_ID }} topicId: ${{ secrets.TAIGA_TELEGRAM_CHAT_THREAD_ID }} @@ -40,5 +40,5 @@ jobs: textLink: ${{ steps.info.outputs.name }} concurrency: - group: release-${{ github.workflow }}-${{ github.ref }} + group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true diff --git a/libs/ng-morph/src/utils/colored-log.ts b/libs/ng-morph/src/utils/colored-log.ts new file mode 100644 index 00000000..bc91e989 --- /dev/null +++ b/libs/ng-morph/src/utils/colored-log.ts @@ -0,0 +1,26 @@ +export function processLog(message: string): void { + console.info('\x1B[36m%s\x1B[0m', message); +} + +export function errorLog(message: string): void { + console.info('\x1B[31m%s\x1B[0m', message); +} + +export function successLog(message: string): void { + console.info('\x1B[32m%s\x1B[0m', message); +} + +export function infoLog(message: string): void { + console.info('\x1B[34m%s\x1B[0m', message); +} + +export function titleLog(message: string): void { + console.info('\x1B[35m', message); +} + +export const SMALL_TAB_SYMBOL = ' '; // @note: if you use \t then we have big gaps +export const START_SYMBOL = '🚀'; +export const FINISH_SYMBOL = '🏆'; +export const REPLACE_SYMBOL = '⚡️'; +export const PROCESSING_SYMBOL = '> '; +export const SUCCESS_SYMBOL = '✅ '; diff --git a/libs/ng-morph/src/utils/index.ts b/libs/ng-morph/src/utils/index.ts index 7735a9d7..652a5260 100644 --- a/libs/ng-morph/src/utils/index.ts +++ b/libs/ng-morph/src/utils/index.ts @@ -1,5 +1,6 @@ export * from './array-flat'; export * from './coerce-array'; +export * from './colored-log'; export * from './filter-primitive'; export * from './get-declaration-creator'; export * from './get-declaration-editor';