-
Notifications
You must be signed in to change notification settings - Fork 678
build: setup monorepo npm workspace for dependent packages #2478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
87118a6
aaab8b4
5601453
d85e8ce
3fdec0e
0a444a5
37fe12b
a2205af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,48 +41,31 @@ jobs: | |
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| - run: npm --version | ||
| - run: npm install --verbose | ||
| working-directory: packages/${{ matrix.package }} | ||
| - name: Link dependent packages (*nix) | ||
| if: matrix.os == 'ubuntu-latest' | ||
| working-directory: packages/${{ matrix.package }} | ||
| - name: Install dependencies | ||
| run: | | ||
| # depending on which package we are testing, also npm link up dependent packages within this monorepo | ||
| case "$PWD" in | ||
| */webhook) pushd ../types && npm i && popd && npm link ../types;; | ||
| */web-api) pushd ../types && npm i && popd && npm link ../types && pushd ../logger && npm i && popd && npm link ../logger;; | ||
| */oauth) pushd ../logger && npm i && popd && npm link ../logger && pushd ../web-api && npm i && popd && npm link ../web-api;; | ||
| */socket-mode) pushd ../logger && npm i && popd && npm link ../logger && pushd ../web-api && npm i && popd && npm link ../web-api;; | ||
| *) ;; # default | ||
| esac | ||
| - name: Link dependent packages (Windows) | ||
| if: matrix.os == 'windows-latest' | ||
| working-directory: packages/${{ matrix.package }} | ||
| npm install --verbose | ||
| - name: Build packages | ||
| run: | | ||
| # Build packages without internal dependencies | ||
| npm run build --workspace=@slack/cli-hooks | ||
| npm run build --workspace=@slack/cli-test | ||
|
|
||
| # Build base dependencies | ||
| npm run build --workspace=@slack/logger | ||
| npm run build --workspace=@slack/types | ||
|
|
||
| # Build packages requiring base dependencies | ||
| npm run build --workspace=@slack/web-api | ||
| npm run build --workspace=@slack/webhook | ||
|
|
||
| # Build packages that depend on the Web API | ||
| npm run build --workspace=@slack/oauth | ||
| npm run build --workspace=@slack/rtm-api | ||
| npm run build --workspace=@slack/socket-mode | ||
|
Comment on lines
+47
to
+64
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗣️ note: #2482 is an example of changing dependencies between packages being resolved as expected! In that example, changes to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is also so much easier to read and maintain! |
||
| - name: Run tests | ||
| run: | | ||
| # depending on which package we are testing, also npm link up dependent packages within this monorepo | ||
| # NOTE: the following is PowerShell | ||
| echo "$pwd" | ||
| switch -Wildcard ( "$pwd" ) | ||
| { | ||
| '*\webhook' | ||
| { | ||
| pushd ..\types && npm i && popd && npm link ..\types | ||
| } | ||
| '*\web-api' | ||
| { | ||
| pushd ..\types && npm i && popd && npm link ..\types && pushd ..\logger && npm i && popd && npm link ..\logger | ||
| } | ||
| '*\oauth' | ||
| { | ||
| pushd ..\logger && npm i && popd && npm link ..\logger && pushd ..\web-api && npm i && popd && npm link ..\web-api | ||
| } | ||
| '*\socket-mode' | ||
| { | ||
| pushd ..\logger && npm i && popd && npm link ..\logger && pushd ..\web-api && npm i && popd && npm link ..\web-api | ||
| } | ||
| } | ||
| - run: npm test | ||
| working-directory: packages/${{ matrix.package }} | ||
| npm run lint | ||
| npm test --workspace=@slack/${{ matrix.package }} | ||
| - name: Check for coverage report existence | ||
| id: check_coverage | ||
| uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,14 @@ | |
| } | ||
| } | ||
| }, | ||
| "files": { | ||
| "includes": [ | ||
| "packages/**", | ||
| "!!packages/client", | ||
| "!!packages/events-api", | ||
| "!!packages/interactive-messages" | ||
| ] | ||
| }, | ||
| "formatter": { | ||
| "enabled": true, | ||
| "formatWithErrors": false, | ||
|
|
@@ -44,5 +52,30 @@ | |
| "enabled": true, | ||
| "clientKind": "git", | ||
| "useIgnoreFile": true | ||
| } | ||
| }, | ||
| "overrides": [ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❤️ |
||
| { | ||
| "includes": ["packages/web-api/src/types/response/**/*.ts"], | ||
| "linter": { | ||
| "rules": { | ||
| "complexity": { | ||
| "noBannedTypes": "off" | ||
| }, | ||
| "suspicious": { | ||
| "noExplicitAny": "off" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "includes": ["packages/web-api/src/index.ts"], | ||
| "assist": { | ||
| "actions": { | ||
| "source": { | ||
| "organizeImports": "off" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| { | ||
| "name": "@slack", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "type": "module", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/slackapi/node-slack-sdk.git" | ||
| }, | ||
| "workspaces": [ | ||
| "packages/cli-hooks", | ||
| "packages/cli-test", | ||
| "packages/logger", | ||
| "packages/oauth", | ||
| "packages/rtm-api", | ||
| "packages/socket-mode", | ||
| "packages/types", | ||
| "packages/web-api", | ||
| "packages/webhook" | ||
| ], | ||
| "scripts": { | ||
| "lint": "npx @biomejs/biome check packages", | ||
| "lint:fix": "npx @biomejs/biome check --write packages" | ||
| }, | ||
|
Comment on lines
+21
to
+24
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🪵 note: Linting becomes a global task with impressive speeds of This is a noticed change to the maintenance tasks I think, but
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🌲 note: I'm so open to adding more
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's keep this PR minimal and scoped, but we can always add more to I think a root-level
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mwbrooks Nice callout! A shared |
||
| "devDependencies": { | ||
| "@biomejs/biome": "^2.0.5" | ||
| } | ||
| } | ||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,14 +28,12 @@ | |
| "url": "https://github.com/slackapi/node-slack-sdk/issues" | ||
| }, | ||
| "scripts": { | ||
| "prepare": "npm run build", | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗣️ note: The This helps prevent installation and build errors between packages on an initial install. Otherwise, packages are built when dependencies are installed with the AFAICT this isn't a breaking change since the |
||
| "build": "npm run build:clean && tsc", | ||
| "build:clean": "shx rm -rf ./dist ./coverage", | ||
| "docs": "npx typedoc --plugin typedoc-plugin-markdown", | ||
| "lint": "npx @biomejs/biome check .", | ||
| "lint:fix": "npx @biomejs/biome check --write .", | ||
| "test": "npm run lint && npm run coverage", | ||
| "coverage": "npm run build && c8 --config ./test/.c8rc.json npm run test:mocha", | ||
| "docs": "npx typedoc --plugin typedoc-plugin-markdown", | ||
| "prepack": "npm run build", | ||
| "test": "npm run coverage", | ||
| "test:mocha": "mocha --config ./test/.mocharc.json src/*.spec.ts src/**/*.spec.ts", | ||
| "watch": "npx nodemon --watch 'src' --ext 'ts' --exec npm run build" | ||
| }, | ||
|
|
@@ -47,7 +45,6 @@ | |
| "jsonwebtoken": "^9" | ||
| }, | ||
| "devDependencies": { | ||
| "@biomejs/biome": "^2.0.5", | ||
| "@types/chai": "^4", | ||
| "@types/mocha": "^10", | ||
| "@types/sinon": "^21", | ||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📠 note: Apologies for noise in these changes, but a lot of formatting happened I fear.