This release introduces the handoff cli and typescript API.
0.6.0 introduces two major new tools that will make it much easier to integrate Handoff with existing projects and data pipelines. This release also reorganizes the Handoff code to make the pipeline significantly more robust, easier to extend, and easier to use in existing projects. Our goal with this release is to establish a stable Typescript API as we approach a 1.0 release.
Handoff now comes with a CLI toolchain that allows you to run Handoff commands in any context. This CLI replaces the installer from previous versions to scaffold up projects in a directory.
npm i -g handoff-app
handoff-app <command>
env
variableshandoff-app --help
for a full list of commandsHandoff now exposes a full typescript API published as commonjs modules. This API will allow you to use Handoff in your Node 16+ javascript or typescript projects. With just a few lines of code you can have Handoff run programmatically.
This API supersedes and replaces the plugin architecture introduced in 0.5.0. The API call structure is maintained, but now the API can be used directly in existing Node applications and can be used with typescript.
Here's a simple example that will fetch the data down. This example expects a DEV_ACCESS_TOKEN and a FIGMA_PROJECT_ID env variable, or those to be provided in process.env
. If not supplied, they will be prompted for when the pipeline is run.
1import Handoff from "handoff-app"; 2const handoff = new Handoff({ 3 title: "Handoff Bootstrap", 4 integration: { 5 name: "bootstrap", 6 version: "5.3", 7 }, 8}); 9await handoff.fetch();
1// This hook will execute after the integration step and allow you to extract 2// data from the pipeline and write it to a file 3handoff.postIntegration( 4 (documentationObject: DocumentationObject, data: HookReturn[]) => { 5 const colors = documentationObject.design.color.map((color) => { 6 return { 7 name: color.name, 8 value: color.value, 9 }; 10 }); 11 data.push({ 12 filename: "colors.json", 13 data: JSON.stringify(colors, null, 2), 14 }); 15 return data; 16 } 17);