Skip to content

Commit 5459954

Browse files
committed
chore: add workspace aliases
1 parent 488f556 commit 5459954

File tree

5 files changed

+25
-14
lines changed

5 files changed

+25
-14
lines changed

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,20 @@ To run the same command in _all_ workspaces, use `yarn workspaces`. For instance
5454
yarn workspaces run test
5555
```
5656

57-
Typing out the full workspace name can get tedious. You can place aliases in your `.bashrc` or `.profile` to save time:
57+
Typing out the full workspace name can get tedious. We've added some convenient scripts to run commands on a specific package:
58+
59+
- `yarn common`: runs the command in the common package
60+
- `yarn server`: runs the command in the server package
61+
- `yarn types`: runs the command in the types package
62+
- `yarn web`: runs the command in the web package
63+
64+
For example, to run tests only for the web package, you can run:
5865

5966
```console
60-
alias @uw="yarn workspace @upswyng/web "
67+
yarn web test
6168
```
6269

63-
Now you only need `@uw start` to start the web dev server.
70+
The above is the equivalent of `yarn workspace @upswyng/web test`.
6471

6572
### Running tests
6673

package.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,22 @@
8080
"name": "upswyng",
8181
"private": true,
8282
"scripts": {
83-
"build:local-packages": "yarn workspace @upswyng/types build && yarn workspace @upswyng/common build",
84-
"build:server": "yarn build:local-packages && yarn workspace @upswyng/server build",
85-
"build:web": "yarn build:local-packages && yarn workspace @upswyng/web build",
83+
"build:local-packages": "yarn types build && yarn common build",
84+
"build:server": "yarn build:local-packages && yarn server build",
85+
"build:web": "yarn build:local-packages && yarn web build",
8686
"build:local-db": "docker compose up --build -d && mongorestore --port 27018 --username upswyng-dev-user --password upswyng123 -d upswyng-dev ./packages/server/localdb/mongodump",
8787
"clean": "node clean.js",
88+
"common": "yarn workspace @upswyng/common",
8889
"reset": "node clean.js --reset && docker compose down -v",
8990
"heroku-postbuild": "yarn build:web && yarn build:server",
9091
"lint": "tsc --noEmit && eslint \"packages/**/src/**/*.{js,jsx,ts,tsx}\" --fix",
9192
"lint:ci": "tsc --noEmit && eslint \"packages/**/src/**/*.{js,jsx,ts,tsx}\" --quiet",
92-
"test": "concurrently -n common,server -c yellow,blue \"yarn workspace @upswyng/common test:unit\" \"yarn workspace @upswyng/server test\" && yarn workspace @upswyng/web test",
93-
"test:ci": "concurrently -n common,server -c yellow,blue \"yarn workspace @upswyng/common test:unit\" \"yarn workspace @upswyng/server test\" --kill-others-on-fail && yarn workspace @upswyng/web test",
94-
"start:local": "./start_local.sh"
93+
"test": "concurrently -n common,server -c yellow,blue \"yarn common test:unit\" \"yarn server test\" && yarn web test",
94+
"test:ci": "concurrently -n common,server -c yellow,blue \"yarn common test:unit\" \"yarn server test\" --kill-others-on-fail && yarn web test",
95+
"start:local": "./start_local.sh",
96+
"server": "yarn workspace @upswyng/server",
97+
"types": "yarn workspace @upswyng/types",
98+
"web": "yarn workspace @upswyng/web"
9599
},
96100
"version": "0.1.0",
97101
"workspaces": [

packages/server/Procfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# https://github.com/heroku/heroku-buildpack-multi-procfile
2-
web: yarn workspace @upswyng/server start:server
3-
worker: yarn workspace @upswyng/server start:worker
2+
web: yarn server start:server
3+
worker: yarn server start:worker

packages/server/src/bin/e2e_setup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ SETUP_SCRIPT="${DIR}/../../__build__/bin/setup_categories"
1818

1919
# see if the category setup script exists, if not, build it
2020
if ! test -f "$SETUP_SCRIPT"; then
21-
TARGETS=setupCategories yarn workspace @upswyng/server build:bin
21+
TARGETS=setupCategories yarn server build:bin
2222
fi
2323

2424
# setup categories
@@ -35,4 +35,4 @@ read -r REDIS_PID <"${DIR}/../../cypress/.redispid"
3535
read -r REDIS_URI <"${DIR}/../../cypress/.redisuri"
3636

3737
REDIS_URL=$REDIS_URI DATABASE_URL=$MONGODB_URI DATABASE_NAME="" DATABASE_USER="" DATABASE_PASSWORD="" PORT=43637 \
38-
yarn workspace @upswyng/server dev
38+
yarn server dev

start_local.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ fi
3030
docker top upswyng-dev-db > /dev/null 2>&1 || yarn build:local-db
3131

3232
# Start development servers for server and web packages concurrently
33-
concurrently -n server,web -c yellow,blue "yarn workspace @upswyng/server dev" "yarn workspace @upswyng/web start"
33+
concurrently -n server,web -c yellow,blue "yarn server dev" "yarn web start"

0 commit comments

Comments
 (0)