A package can run a Function when someone installs it, and it can open a Custom App afterward. Add a setup Function to the equipment request package from Package and publish Metadata components, then choose the Custom App that opens after the package installs.
Requirements
- Complete Package and publish Metadata components, or have a Rippling project with a published package version.
- Open the project that you packaged, with its dependencies installed.
- Use a CLI context for your Developer account that has
packages.read-writeaccess. The commands below usedeveloper-accountas the context name. Replace it with yours.
Run a Function after the package installs
Add the Function to your project:
rippling project add function --name setup-equipment-requests
The CLI creates functions/setup-equipment-requests.ts, which exports SetupEquipmentRequests, and adds it to the manifest, rippling.manifest.ts.
The CLI also creates functions/setup-equipment-requests.handler.ts, where your setup logic goes.
The starter handler returns a message, so you can try the flow before you add logic.
The Function runs with the permissions of the person who installs the package.
Installing an unmanaged package again can run it again, so write it to be safe to repeat.
Next, import the Function in package.manifest.ts and pass it as postInstallFunction.
Leave version as the CLI saved it, because --bump updates it.
Your number can differ from the one shown here.
import { definePackageManifest } from '@rippling/rippling-sdk';
import manifest from './rippling.manifest';
import { SetupEquipmentRequests } from './functions/setup-equipment-requests';
export default definePackageManifest({
package: {
"key": "equipment_requests_demo",
"name": "Equipment Requests Demo",
"type": "unmanaged",
"description": "A package of custom Rippling components."
},
version: "0.1.0",
manifest,
postInstallFunction: SetupEquipmentRequests,
});
Create and publish the next version. The CLI includes the Function in the version and sets it as the post-install Function:
rippling --context developer-account project package . --bump --force-publish --json
To try it, install the new version in a sandbox that doesn't have the package yet, as in Install the package in a second sandbox.
If the Function fails, the installation status is COMPLETE_WITH_WARNINGS and the installed components stay in place.
Choose the Custom App that opens after the package installs
By default, installing the package opens the first Custom App in it, if there is one. To choose a different one, add a Custom App to your project:
rippling project add custom-app --name equipment-requests
The CLI creates custom-apps/equipment-requests.ts, which exports EquipmentRequests.
Import it in package.manifest.ts and pass it as postInstallLandingComponent:
import { definePackageManifest } from '@rippling/rippling-sdk';
import manifest from './rippling.manifest';
import { SetupEquipmentRequests } from './functions/setup-equipment-requests';
import { EquipmentRequests } from './custom-apps/equipment-requests';
export default definePackageManifest({
package: {
"key": "equipment_requests_demo",
"name": "Equipment Requests Demo",
"type": "unmanaged",
"description": "A package of custom Rippling components."
},
version: "0.1.1",
manifest,
postInstallFunction: SetupEquipmentRequests,
postInstallLandingComponent: EquipmentRequests,
});
Then create and publish a new version:
rippling --context developer-account project package . --bump --force-publish --json
Fix post-install settings on a draft
If a post-install setting is invalid, the CLI creates the version but stops before it publishes it. To correct the settings on that draft without creating another version:
- In
package.manifest.ts, setversionto the draft's version. - Update
postInstallFunctionorpostInstallLandingComponent. - Run:
rippling --context developer-account project package . --settings-only
A setting that you omit stays unchanged.
Set a setting to null to clear the post-install Function, or to reset the Custom App that opens to the default.
This command updates the settings on a draft and leaves the draft's components as they are. To add a Function or Custom App, or to change a published version, create a new version.