budibase icon indicating copy to clipboard operation
budibase copied to clipboard

Budibase CLI - Create Plugin/Component

Open shogunpurple opened this issue 2 years ago • 1 comments

Specs: https://budibase.atlassian.net/wiki/spaces/PROD/pages/45940739/Custom+Datasources, https://budibase.atlassian.net/wiki/spaces/PROD/pages/46792705/Custom+Components

When I'm using the budibase CLI, I want to be able to generate a new skeleton of a component or datasource in the directory I am currently in.

Commands:

  • budi plugin init --component/datasource funky-component

The CLI will check if you are currently in the directory of a plugin/component (look for package.json) and if not error.

COS

  • budi plugin --init - creates a new plugin skeleton in the current directory.
  • budi component --init - creates a new component skeleton in the current directory.
  • Define the NPM build script in the skeleton
  • Allow definition of budibase version on skeleton creation

shogunpurple avatar Jul 28 '22 10:07 shogunpurple

Some notes around plugin creation: GOALS

  1. Single file that exports the functionality and the schema - plugin.js/main.js
  2. Skeleton comes with schema.json which default exports schema for datasource/component
  3. Single JS file for datasources/components with schema etc in it (built and minified) but we include the package.json and schema.json + the js file in a tarball (support prebuilds down the line)
  4. Skeleton has both TS and JS base impls - CLI asks which one user wants, deletes the other file - build needs to account for this
  5. There is a specific datasource.js/ts and component.svelte
  6. Build step should be the same for both datasources and components, this is needed for datasources to handle Typescript and to make sure that the node_modules get included correctly. Rollup initially, Esbuild down the line perhaps
  7. CJS bundle for datasources, IIFE for components - build can run this based on the schema.json
  8. We handle the importing of tarballs and the usage of it for datasources and components
  9. Verify, a post build step - built in, this isn't a separate CLI command, its just part of the build, use JOI to verify the schema.
  10. Enrichment feature, Typescript in svelte, typecast the stuff gotten from context
  11. Should we include BBUI - is there a good case for using BBUI components inside a custom component, should components not be granular and add BBUI components to a block inside Budibase

mike12345567 avatar Aug 09 '22 15:08 mike12345567