Skip to content

Commit 45452bc

Browse files
authored
build: setup monorepo npm workspace for dependent packages (#2478)
1 parent a1112e3 commit 45452bc

24 files changed

Lines changed: 204 additions & 248 deletions

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,3 +206,11 @@ updates:
206206
- "github_actions"
207207
schedule:
208208
interval: "monthly"
209+
210+
- package-ecosystem: "npm"
211+
directory: "/"
212+
labels:
213+
- "dependencies"
214+
- "javascript"
215+
schedule:
216+
interval: "weekly"

.github/maintainers_guide.md

Lines changed: 91 additions & 97 deletions
Large diffs are not rendered by default.

.github/workflows/ci-build.yml

Lines changed: 23 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -41,48 +41,31 @@ jobs:
4141
with:
4242
node-version: ${{ matrix.node-version }}
4343
- run: npm --version
44-
- run: npm install --verbose
45-
working-directory: packages/${{ matrix.package }}
46-
- name: Link dependent packages (*nix)
47-
if: matrix.os == 'ubuntu-latest'
48-
working-directory: packages/${{ matrix.package }}
44+
- name: Install dependencies
4945
run: |
50-
# depending on which package we are testing, also npm link up dependent packages within this monorepo
51-
case "$PWD" in
52-
*/webhook) pushd ../types && npm i && popd && npm link ../types;;
53-
*/web-api) pushd ../types && npm i && popd && npm link ../types && pushd ../logger && npm i && popd && npm link ../logger;;
54-
*/oauth) pushd ../logger && npm i && popd && npm link ../logger && pushd ../web-api && npm i && popd && npm link ../web-api;;
55-
*/socket-mode) pushd ../logger && npm i && popd && npm link ../logger && pushd ../web-api && npm i && popd && npm link ../web-api;;
56-
*) ;; # default
57-
esac
58-
- name: Link dependent packages (Windows)
59-
if: matrix.os == 'windows-latest'
60-
working-directory: packages/${{ matrix.package }}
46+
npm install --verbose
47+
- name: Build packages
48+
run: |
49+
# Build packages without internal dependencies
50+
npm run build --workspace=@slack/cli-hooks
51+
npm run build --workspace=@slack/cli-test
52+
53+
# Build base dependencies
54+
npm run build --workspace=@slack/logger
55+
npm run build --workspace=@slack/types
56+
57+
# Build packages requiring base dependencies
58+
npm run build --workspace=@slack/web-api
59+
npm run build --workspace=@slack/webhook
60+
61+
# Build packages that depend on the Web API
62+
npm run build --workspace=@slack/oauth
63+
npm run build --workspace=@slack/rtm-api
64+
npm run build --workspace=@slack/socket-mode
65+
- name: Run tests
6166
run: |
62-
# depending on which package we are testing, also npm link up dependent packages within this monorepo
63-
# NOTE: the following is PowerShell
64-
echo "$pwd"
65-
switch -Wildcard ( "$pwd" )
66-
{
67-
'*\webhook'
68-
{
69-
pushd ..\types && npm i && popd && npm link ..\types
70-
}
71-
'*\web-api'
72-
{
73-
pushd ..\types && npm i && popd && npm link ..\types && pushd ..\logger && npm i && popd && npm link ..\logger
74-
}
75-
'*\oauth'
76-
{
77-
pushd ..\logger && npm i && popd && npm link ..\logger && pushd ..\web-api && npm i && popd && npm link ..\web-api
78-
}
79-
'*\socket-mode'
80-
{
81-
pushd ..\logger && npm i && popd && npm link ..\logger && pushd ..\web-api && npm i && popd && npm link ..\web-api
82-
}
83-
}
84-
- run: npm test
85-
working-directory: packages/${{ matrix.package }}
67+
npm run lint
68+
npm test --workspace=@slack/${{ matrix.package }}
8669
- name: Check for coverage report existence
8770
id: check_coverage
8871
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0

biome.json

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
}
88
}
99
},
10+
"files": {
11+
"includes": [
12+
"packages/**",
13+
"!!packages/client",
14+
"!!packages/events-api",
15+
"!!packages/interactive-messages"
16+
]
17+
},
1018
"formatter": {
1119
"enabled": true,
1220
"formatWithErrors": false,
@@ -44,5 +52,30 @@
4452
"enabled": true,
4553
"clientKind": "git",
4654
"useIgnoreFile": true
47-
}
55+
},
56+
"overrides": [
57+
{
58+
"includes": ["packages/web-api/src/types/response/**/*.ts"],
59+
"linter": {
60+
"rules": {
61+
"complexity": {
62+
"noBannedTypes": "off"
63+
},
64+
"suspicious": {
65+
"noExplicitAny": "off"
66+
}
67+
}
68+
}
69+
},
70+
{
71+
"includes": ["packages/web-api/src/index.ts"],
72+
"assist": {
73+
"actions": {
74+
"source": {
75+
"organizeImports": "off"
76+
}
77+
}
78+
}
79+
}
80+
]
4881
}

package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "@slack",
3+
"version": "0.0.0",
4+
"private": true,
5+
"type": "module",
6+
"repository": {
7+
"type": "git",
8+
"url": "git+https://github.com/slackapi/node-slack-sdk.git"
9+
},
10+
"workspaces": [
11+
"packages/cli-hooks",
12+
"packages/cli-test",
13+
"packages/logger",
14+
"packages/oauth",
15+
"packages/rtm-api",
16+
"packages/socket-mode",
17+
"packages/types",
18+
"packages/web-api",
19+
"packages/webhook"
20+
],
21+
"scripts": {
22+
"lint": "npx @biomejs/biome check packages",
23+
"lint:fix": "npx @biomejs/biome check --write packages"
24+
},
25+
"devDependencies": {
26+
"@biomejs/biome": "^2.0.5"
27+
}
28+
}

packages/cli-hooks/biome.json

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

packages/cli-hooks/package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,9 @@
3535
"url": "https://github.com/slackapi/node-slack-sdk/issues"
3636
},
3737
"scripts": {
38-
"prebuild": "shx rm -rf ./coverage",
3938
"build": "shx chmod +x src/*.js",
39+
"prebuild": "shx rm -rf ./coverage",
4040
"prelint": "tsc --noemit --module es2022 --maxNodeModuleJsDepth 0 --project ./jsconfig.json",
41-
"lint": "npx @biomejs/biome check .",
42-
"lint:fix": "npx @biomejs/biome check --write .",
43-
"pretest": "npm run lint",
4441
"test": "c8 --config ./test/.c8rc.json mocha --config ./test/.mocharc.json src/*.spec.js"
4542
},
4643
"bin": {
@@ -55,7 +52,6 @@
5552
"semver": "^7.5.4"
5653
},
5754
"devDependencies": {
58-
"@biomejs/biome": "^2.0.5",
5955
"@types/minimist": "^1.2.5",
6056
"@types/mocha": "^10.0.6",
6157
"@types/node": "^25.0.3",

packages/cli-test/biome.json

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

packages/cli-test/package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,15 @@
2828
"build": "npm run build:clean && tsc",
2929
"build:clean": "shx rm -rf ./dist ./coverage",
3030
"docs": "npx typedoc --plugin typedoc-plugin-markdown",
31-
"lint": "npx @biomejs/biome check .",
32-
"lint:fix": "npx @biomejs/biome check --write .",
33-
"prepare": "npm run build",
3431
"mocha": "cross-env SLACK_CLI_PATH=/doesnt/matter mocha --config ./test/.mocharc.json src/*.spec.ts src/**/*.spec.ts src/**/**/*.spec.ts",
35-
"test": "npm run lint && npm run build && c8 --config ./test/.c8rc.json npm run mocha"
32+
"prepack": "npm run build",
33+
"test": "npm run build && c8 --config ./test/.c8rc.json npm run mocha"
3634
},
3735
"dependencies": {
3836
"tree-kill": "^1.2.2",
3937
"winston": "^3.8.2"
4038
},
4139
"devDependencies": {
42-
"@biomejs/biome": "^2.0.5",
4340
"@tsconfig/recommended": "^1.0.6",
4441
"@types/chai": "^4.3.16",
4542
"@types/mocha": "^10.0.6",

packages/logger/biome.json

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

0 commit comments

Comments
 (0)