This Nx-based monorepo contains a series of tools made by Kishan Sambhi (kss22) for DoCSoc at Imperial College London for the committee of academic year 2024-2025. They are designed to help the committee manage their responsibilities and make their lives easier, by providing tools to automate and simplify common tasks.
The repo is structured as an Nx monorepo (I recommend you look at the Nx documentation for more information on how to use it). You can also have a look at the Nx readme at the bottom of this document.
clickup/calendar-sync
: A rust tool that syncs the DoCSoc ClickUp calendar with the DoCSoc Google Calendar. It is designed to be run as a cron job on a server. (application)common/util
: A set of common utilities used by other tools written in TypeScript (library)email/mailmerge
: A TypeScript library that can be used to generate emails from templates and send them. It is designed to be used in conjunction with theemail/mailmerge-cli
tool, but can be used by itself (library)email/mailmerge-cli
: A TypeScript CLI tool that can be used to generate emails from templates, regenerate them after modifying the results, upload them to Outlook drafts and send them. (library & application)collection/
: A Next.js Application that allows us to manage merchandise collections securely. Designed to be ran as a docker container with a Postgres DB. (application)
Each tool's directory has a README with more information on how to use it.
Note
You should use build-local
when working on just the TypeScript code, as build
will build all tools (TypeScript and Rust) to /dist/
, including Next.js production builds, whereas build-local
only compiles TypeScript libraries like those in common
and mailmerge
, and does so in-place (instead of copying even libraries over to /dist/
).
npx nx run-many -t build-local
npx nx run-many -t build
build
builds all tools (TypeScript and Rust) to /dist/
, build-local
builds the typescript tools to dist/
folders in each tool's directory.
You should use build-local
when working on just the TypeScript code.
You can run tasks for a specific tool by running, for example:
npx nx build collection
npx nx test mailmerge
npx nx run eactivities:test # alternate syntax for running tasks
# etc.
Where build
is the task and collection
is the tool.
It may help to install the NX Console plugin to view all available tasks.
npx nx run-many -t build
NOTE: See Nuclino for cargo & npm registry login details.
It is assumed you have already logged into the npm and cargo registries.
npx nx release
This will build & release all libraries (so everything bar collection
)
You can get API documentation for all TypeScript libraries in the repo by running:
npm run docs
This will output the documentation to ./docs/
in the repo root.
npx nx run-many -t lint
npx nx run-many -t test
The plugin @monodon/rust
has been added to Nx to allow for Rust projects to be built and run in the monorepo. This is used by the calendar-sync
tool.
The plugin has create a Cargo workspace in the root of the monorepo as such, and all builds for all packages are done in the root of the monorepo and sent to dist
in the repo root.
The NX plugin @nx-tools/nx-container
has been added to allow for Docker images to be built and run in the monorepo. This is used by the collection
tool.
E.g. to build collection
as a Docker image docsoc/collection
:
npx nx container collection
The NX plugin @nx-tools/nx-prisma
has been added to allow the use of prisma.
Prisma command can be run following this pattern:
If the original command is, for example prisma studio
, then the command to run it in the monorepo is npx nx prisma-studio <project>
.
E.g. to run prisma studio
for the collection
project:
npx nx prisma-studio collection
# this also works:
cd collection
npx nx prisma-studio # autodetets the project
This i because they pull their deps in from the root package.json
: this way, we only need to maintain one dependency list for common deps like React, etc.
✨ This workspace has been generated by Nx, Smart Monorepos · Fast CI. ✨
Enhance your Nx experience by installing Nx Console for your favorite editor. Nx Console provides an interactive UI to view your projects, run tasks, generate code, and more! Available for VSCode, IntelliJ and comes with a LSP for Vim users.
Add Nx plugins to leverage their code generators and automated, inferred tasks.
# Add plugin
npx nx add @nx/react
# Use code generator
npx nx generate @nx/react:app demo
# Run development server
npx nx serve demo
# View project details
npx nx show project demo --web
Run npx nx list
to get a list of available plugins and whether they have generators. Then run npx nx list <plugin-name>
to see what generators are available.
Learn more about code generators and inferred tasks in the docs.
To execute tasks with Nx use the following syntax:
npx nx <target> <project> <...options>
You can also run multiple targets:
npx nx run-many -t <target1> <target2>
..or add -p
to filter specific projects
npx nx run-many -t <target1> <target2> -p <proj1> <proj2>
Targets can be defined in the package.json
or projects.json
. Learn more in the docs.
Nx comes with local caching already built-in (check your nx.json
). On CI you might want to go a step further.
Run npx nx graph
to show the graph of the workspace.
It will show tasks that you can run with Nx.