Skip to content

Commit e57d7ba

Browse files
committed
chore: add workspace aliases
1 parent 7c73507 commit e57d7ba

File tree

5 files changed

+23
-12
lines changed

5 files changed

+23
-12
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: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,20 @@
8383
"build:local-packages": "yarn workspace @upswyng/types build && yarn workspace @upswyng/common build",
8484
"build:server": "yarn build:local-packages && yarn workspace @upswyng/server build",
8585
"build:web": "yarn build:local-packages && yarn workspace @upswyng/web build",
86-
"build:local-db": "docker-compose up --build -d && npm run restore:db",
86+
"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
"restore:db": "mongorestore --port 27018 --username upswyng-dev-user --password upswyng123 -d upswyng-dev ./packages/server/localdb/mongodump",
8888
"clean": "node clean.js",
89+
"common": "yarn workspace @upswyng/common",
8990
"reset": "node clean.js --reset && docker compose down -v",
9091
"heroku-postbuild": "yarn build:web && yarn build:server",
9192
"lint": "tsc --noEmit && eslint \"packages/**/src/**/*.{js,jsx,ts,tsx}\" --fix",
9293
"lint:ci": "tsc --noEmit && eslint \"packages/**/src/**/*.{js,jsx,ts,tsx}\" --quiet",
93-
"test": "concurrently -n common,server -c yellow,blue \"yarn workspace @upswyng/common test:unit\" \"yarn workspace @upswyng/server test\" && yarn workspace @upswyng/web test",
94-
"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",
95-
"start:local": "./start_local.sh"
94+
"test": "concurrently -n common,server -c yellow,blue \"yarn common test:unit\" \"yarn server test\" && yarn web test",
95+
"test:ci": "concurrently -n common,server -c yellow,blue \"yarn common test:unit\" \"yarn server test\" --kill-others-on-fail && yarn web test",
96+
"start:local": "./start_local.sh",
97+
"server": "yarn workspace @upswyng/server",
98+
"types": "yarn workspace @upswyng/types",
99+
"web": "yarn workspace @upswyng/web"
96100
},
97101
"version": "0.1.0",
98102
"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)