A schema for Flipper Expressions
The structure for flipper Expressions is defined in schemas/schema.json using JSON Schema (draft-07).
To learn more about JSON Schema, read Understanding JSON Schema or the Ajv JSON schema validator docs.
- Describe arguments by creating a new file in
schemas/namedNewName.schema.json. You can copy an existing function that has similar semantics to get started. - Add the new function in
schemas/schema.jsontodefinitions/function. - Create a new file in
examples/namedNewName.jsonwith valid and invalid examples for the new function. See other examples for inspiration. - Run
yarn testand ensure tests pass.
Implement the expression in @flippercloud/flipper:
- Add
lib/flipper/expressions/new_name.rbto @flippercloud/flipper. - Run
rspecto ensure tests pass.
See this commit that adds Min/Max functions for a concrete example.
Published to npm as @flippercloud/expressions.
- Install dependencies if you haven't:
npm install. This is required — withoutnode_modules,npm run buildresolvesvitefrom yourPATH(e.g. avite_rubyshim) instead of the project's Vite, and the build fails with confusing Ruby errors. - Bump
versioninpackage.json. - Publish:
npm publish. The build runs automatically (viaprepack/prepare), andpublishConfig.accessis set topublic, so no--access publicflag is needed. - Verify:
npm view @flippercloud/expressions versionshould match the version you bumped to. - Tag the release:
git tag v$(node -p "require('./package.json').version")andgit push --tags.
The @flippercloud org requires two-factor auth to publish. If you have a TOTP authenticator, npm publish --otp=<code> works. If you only have a passkey (no TOTP code), create a granular access token with read/write on the @flippercloud scope and "bypass two-factor authentication" enabled, then put it in ~/.npmrc:
//registry.npmjs.org/:_authToken=npm_xxxxxxxx
Never commit a token — keep it in ~/.npmrc, not the project's .npmrc.