Once you created a new (cloud) project on forest admin, you can use this package to add code customizations to it.
The workflow to add code customizations is the following:
- Setup the project
- Write your customizations
- Publish your customizations to your project
- Update typings to update typings in your IDE
- Refresh authentication token
- Display logs
Not needed if the project has already a .env file !
If there is no .env
file at the root of the project you need to create one with the following content:
FOREST_ENV_SECRET=your-env-secret
You can found the FOREST_ENV_SECRET
in the forestadmin interface, in the Project Settings
> Environment
section
or ask it to an administrator of the project.
yarn install
or npm install
then build the project
yarn build
or npm run build
You can found in your package.json
some scripts to help you to develop customizations.
You can replace them with your own scripts, by using directly the forest-cloud
command.
Open the src
folder and start writing your customizations in the index.ts
file.
Read the developer guide to learn how to write customizations.
You can use yarn
or npm
and run forestadmin:build:package:publish
script.
This command will build your customizations and publish them to your project.
This shortcut will run the following commands:
yarn run build
or npm run build
npx forest-cloud package
npx forest-cloud publish
build
and build:watch
scripts will update typings automatically.
But if you want to update typings manually, you can run:
npx forest-cloud update-typings
You can also use yarn
or npm
and run forestadmin:update-typings
script.
This command will update typings according to the structure of your database and your current code customizations. The typings are here to provide autocompletion in your IDE to help you write faster and avoid errors in your code.
You should execute this command on a regular basis, to keep your IDE updated with your database structure and customizations.
npx forest-cloud login
You can also use yarn
or npm
and run forestadmin:login
script.
This command triggers an authentication workflow and refresh the authentication token.
An alternative, is to add the FOREST_AUTH_TOKEN
token in your .env
file.
You can create one by going to your account settings.
Then add the following line in your .env
file:
FOREST_AUTH_TOKEN=your-token
npx forest-cloud logs
You can also use yarn
or npm
and run forestadmin:logs
script.
This command will display the logs of your project. It's useful to debug your customizations. By default, it will display the last 30 logs of the current month.