Sync packages when deploying monorepos with firebase using yarn or bolt workspaces
Have you ever have a problem when deploying
npmpackage withmonoreposinsidefirebase functions? You are really lucky then! Skip this library!
If you have problem resolving your package since it is only virtually present as a symlink inside your
monorepothen you should try@rxdi/firelink
This repository is a complete replacement for
firebasefunction.
The only purpose is to
copymapped modules insidepackage.jsonbefore working withfirebaseCLI. This way when deploying applicationnpmwill install packages locallyfile:./.packages/databaseinstead from global registry.
- No dependencies
firebasecommand replacement- Created with Typescript
- 7 KB bundle
Using npm
npm i -g @rxdi/firelinkUsing binary
wget https://github.com/rxdi/firelink/raw/master/binaries/firelink-linuxGive it permission to execute
chmod +x firelink-linux./firelink-linuxAlias
sudo ln -s ./firelink-linux /bin/firelink
There are multiple binaries for mac, windows and linux
There is only one tested in linux so keep in mind that for mac and windows may not work!
If the binaries don't work in mac or windows please install it via npm globally with npm i -g @rxdi/firelink
The tool assumes @group/package-name naming convention
{
"fireDependencies": {
"@graphql/database": "../../packages/database",
"@graphql/shared": "../../packages/shared",
"@graphql/introspection": "../../packages/introspection"
}
}firelink deployThe same as firebase deploy the only differance is that it will COPY monorepos replace package.json > dependencies with appropriate local file structure and then will revert changes after firebase script exit
firelink --leave-changesThis command will create package.temp.json which is original configuration before modifications
firelink --revert-changesReverts changes from package.temp.json to original package.json and deleting package.temp.json
If command firelink --leave-changes is executed multiple times package.temp.json will remain the same as the first time command firelink --leave-changes is executed.
Example:
Before
{
"dependencies": {
"@graphql/database": "^1.0.0",
"@graphql/shared": "^1.0.0",
"@graphql/introspection": "^1.0.0"
}
}After
{
"dependencies": {
"@graphql/database": "file:./.packages/database",
"@graphql/shared": "file:./.packages/shared",
"@graphql/introspection": "file:./.packages/introspection"
}
}Default runner is command firebase but you can change it for example to gcloud or serverless by defining fireConfig inside package.json
{
"fireConfig": {
"runner": "firebase",
"outFolderName": ".packages",
"outFolderLocation": ".",
"excludes": ["node_modules"]
}
}excludes property can exclude some folders or files from being copied it accepts Array from string
For example we may want to install dependencies of the packages when deploying using local npm path, so we want to not waste time duplicating node modules
Equivalent of excludes inside package.json .fireignore can be specified as a file inside a directory where the command firelink will be executed. .fireignore behaviour is the same as .gitignore
If you do not wish to use .fireignore file name the name can be specified from fireConfig.excludesFileName
By default packages will be saved in .packages folder and current directory will be used
U can change that by specifiyng properties outFolderName and outFolderLocation inside fireConfig
Check example folder inside this repository
You can put even dir command
{
"fireConfig": {
"runner": "dir"
}
}When executing firelink you will be referenced to dir function so you will get list of folders inside current directory.
dist node_modules package.json README.md src tsconfig.json yarn.lock