Note: This is my own personal hack, ideally the deployments should be handled by webpack so please be careful if your deployment breaks.
Example repo on how to use yarn workspaces together with the gcloud deploys. Utilizes Typescript references.
This example repo is heavily based off of the work by Tom Medema in tommedema/serverless-mono-example.
- Typescript (with references)
- Lerna
- Yarn Workspaces
The deployments roughly follow the following process:
- copy all the
@0local
packages into the app'sdist
folder underdist/packages
- run the built in script to update all javascript file references from
@0local
to./packages
- replace the
package.json
with apackage.deploy.json
file which doesn't have any references to@0local
- run the
deploy:cmd
script - replace the
package.json
withpackage.dev.json
Note: every time you run yarn install
(or yarn add
) in a deployment app a copy is made of the package.json
file (to package.dev.json
) and a new package.deploy.json
file is generated.
This repo is divided into common packages and deployment modules. Each deployment module is split into apps which are individually deployable.
From the root run
yarn add:module <module-path>
(where <module-path>
is the path for your new module, e.g. ./deploy-module1
)
From the root run
yarn add:app <app-path>
(where <app-path>
is the path for your new app, e.g. ./deploy-module1/app0
)
From the root run
yarn add:package <package-path>
(where <package-path>
is the path for your new app, e.g. ./packages/new-package
)
To run all tests run yarn test
from the root folder.
To run tests in a specific package, run yarn test
from the package's folder.
To build all packages run yarn build
from the root folder
To build a specific package including the packages it references to, run yarn build
from the package folder.
To deploy a specific app, run yarn deploy
from the package folder. To deploy all apps run the same command from the root folder.
- Automatically update the deployment module config to add references for newly added apps
- Automatically update the the base config for newly added deployment modules