Skip to content

Commit a4a6254

Browse files
authored
refactor: split into monorepo with core library and action packages (#19)
* refactor: split into monorepo with core library and action packages Extract Slack message composition and posting logic into a standalone `@sixt/slack-message` core package with zero dependencies (native fetch only). The GitHub Action is refactored to depend on the core package for block composition and message posting, removing the `@slack/web-api` dependency entirely. - packages/core: @sixt/slack-message with compose(), postMessage(), and block builder functions - packages/action: GitHub Action using @actions/core + core package - Upgrade Jest 26 -> 29, @vercel/ncc 0.26 -> 0.38 for Node 18+ compatibility - All 43 existing tests preserved and passing * chore: update all dependencies to latest versions - TypeScript 4.1 → 5.9 - ESLint 7 → 9 (migrate .eslintrc.js to flat config eslint.config.js) - @typescript-eslint 4 → 8 - Jest 29.7 (latest 29.x, ts-jest doesn't support 30 yet) - Prettier 2 → 3 - nock 13 → 14 - @actions/core 1.9 → 1.11 (latest CJS-compatible) - @actions/github 4 → 6 (latest CJS-compatible, .rest.* API) - @vercel/ncc 0.38 (already updated) - Drop @slack/web-api, eslint-config-prettier/typescript, jest-circus - 0 npm audit vulnerabilities (down from 31) - Bundle size 894KB → 602KB * ci: add e2e test workflow for manual validation workflow_dispatch workflow that posts test messages to a Slack channel, covering: basic messages, field enrichment, buttons + changelog, mention injection, and custom blocks. * fix: branch field not clickable on pull request events The ref check used `ref.includes('pulls')` but PR refs are `refs/pull/N/merge` (singular), so the condition never matched. Changed to `ref.includes('pull/')`. * feat: add field() and link() helpers to core package Convenience functions so core package callers can produce the same rich mrkdwn formatting (bold labels, 2-column grid, clickable links) as the GitHub Action without manual string construction. * chore: commit core package dist for git dependency consumers Remove packages/core/dist from .gitignore so that consumers installing @sixt/slack-message as a git dependency get the pre-built output. * feat: add core tests, return ts from postMessage, fix orphaned divider - Add 46 unit tests for core package covering block builders, compose(), mention/injectMention, iconForStatus, and postMessage - postMessage now returns { ts, channel } for threading/updating - Divider is only added when footerText is provided (no orphan) - Export PostMessageResult type * chore: remove e2e test workflow * chore: drop source maps from core dist * fix: validate postMessage response, remove redundant re-export - Replace non-null assertions with explicit validation in postMessage - Remove redundant iconForStatus re-export from action client - Update test helper to import iconForStatus from core package * feat: add /core subpath export for clean consumer imports * ci: add github packages publishing for @sixt/slack-message - Add publishConfig, files, repository, prepublishOnly to core package - Add workflow_dispatch publish workflow (manual trigger with version input) - Published package is 3.4KB — just dist/ with zero dependencies Consumers add to .npmrc: @Sixt:registry=https://npm.pkg.github.com Then install normally: npm install @sixt/slack-message * fix: simplify publish workflow, remove git push step
1 parent 4cf3b1f commit a4a6254

48 files changed

Lines changed: 4227 additions & 11785 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/publish-core.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Publish @sixt/slack-message
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
version:
6+
description: 'Version to publish (e.g. 0.2.0)'
7+
required: true
8+
9+
jobs:
10+
publish:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
packages: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: 20
20+
registry-url: https://npm.pkg.github.com
21+
22+
- run: npm ci
23+
- run: npm test -w @sixt/slack-message
24+
- run: npm version ${{ inputs.version }} --no-git-tag-version -w packages/core
25+
- run: npm publish -w packages/core
26+
env:
27+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,6 @@ out
117117
.yarn/install-state.gz
118118
.pnp.*
119119

120-
# ncc
121-
lib
120+
# Build output
121+
lib
122+
packages/action/lib

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ inputs:
7272
required: false
7373
runs:
7474
using: 'node20'
75-
main: 'dist/index.js'
75+
main: 'packages/action/dist/index.js'

dist/index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

eslint.config.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const tseslint = require('typescript-eslint');
2+
const prettier = require('eslint-plugin-prettier');
3+
const jest = require('eslint-plugin-jest');
4+
5+
module.exports = tseslint.config(
6+
{
7+
ignores: ['**/coverage/**', '**/dist/**', '**/lib/**', '**/node_modules/**'],
8+
},
9+
...tseslint.configs.recommended,
10+
{
11+
files: ['**/*.ts'],
12+
plugins: {
13+
prettier,
14+
},
15+
rules: {
16+
'prettier/prettier': 'error',
17+
},
18+
},
19+
{
20+
files: ['**/__tests__/**/*.ts'],
21+
plugins: {
22+
jest,
23+
},
24+
...jest.configs['flat/recommended'],
25+
rules: {
26+
...jest.configs['flat/recommended'].rules,
27+
'@typescript-eslint/no-require-imports': 'off',
28+
},
29+
},
30+
);

jest.config.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
11
module.exports = {
2-
clearMocks: true,
3-
moduleFileExtensions: ['js', 'ts'],
4-
testEnvironment: 'node',
5-
testMatch: ['**/*.test.ts'],
6-
testRunner: 'jest-circus/runner',
7-
transform: {
8-
'^.+\\.ts$': 'ts-jest',
9-
},
10-
verbose: true,
11-
coverageDirectory: './coverage/',
12-
collectCoverage: true,
13-
preset: 'ts-jest',
14-
globalSetup: './__tests__/setupTest.ts',
2+
projects: ['<rootDir>/packages/core', '<rootDir>/packages/action'],
153
};

0 commit comments

Comments
 (0)