Yeoman generator that scaffolds Superset visualization plugins and packages with proper structure and boilerplate code
npx @tessl/cli install tessl/npm-superset-ui--generator-superset@0.18.0Generator Superset is a Yeoman generator that provides scaffolding capabilities for creating Superset visualization plugins and packages. It automates the creation of properly structured React-based chart components with TypeScript support, complete with testing infrastructure, build configuration, and development tooling.
npm install -g yo && npm install -g @superset-ui/generator-supersetThe package provides Yeoman generators that are executed through the yo command-line tool:
yo @superset-ui/supersetThe generators extend the yeoman-generator base class and are not directly imported as modules.
# Install prerequisites
npm install -g yo
npm install -g @superset-ui/generator-superset
# Create a new directory for your plugin
mkdir my-superset-plugin
cd my-superset-plugin
# Run the generator
yo @superset-ui/superset
# Follow the interactive prompts to configure your pluginThe generator will prompt for:
Generator Superset follows the Yeoman generator architecture with two main components:
The generated projects follow Superset's conventions for plugin structure, using TypeScript, React, and modern build tooling.
Main generator class that serves as the entry point for the scaffolding process.
class AppGenerator extends Generator {
async prompting(): Promise<void>;
configuring(): void;
}Methods:
prompting() - Displays welcome message and sets up optionsconfiguring() - Composes with the plugin-chart generatorOptions:
skipInstall - Boolean flag to skip npm package installationCore generator that creates the complete chart plugin scaffold with interactive prompts and file generation.
class PluginChartGenerator extends Generator {
async prompting(): Promise<void>;
writing(): void;
}Methods:
prompting() - Gathers user input through interactive promptswriting() - Generates all scaffold files from templatesPrompt Configuration:
interface PromptAnswers {
packageName: string; // Package name in kebab-case
pluginName: string; // Display name in Start Case
description: string; // Package description
chartType: 'regular' | 'timeseries'; // Chart type selection
}Generated File Structure: The generator creates a complete plugin project with the following files:
.gitignore - Git ignore configurationbabel.config.js - Babel transpilation configurationjest.config.js - Jest testing configurationpackage.json - NPM package configurationpackage-lock.json - NPM dependency lock fileREADME.md - Project documentationtsconfig.json - TypeScript configurationsrc/index.ts - Main plugin exportsrc/plugin/buildQuery.ts - Query building logicsrc/plugin/controlPanel.ts - Chart control panel configurationsrc/plugin/index.ts - Plugin registrationsrc/plugin/transformProps.ts - Data transformation logicsrc/types.ts - TypeScript type definitionssrc/[PluginName].tsx - Main React componenttest/index.test.ts - Main test filetest/__mocks__/mockExportString.js - Test mockstest/plugin/buildQuery.test.ts - Query builder teststest/plugin/transformProps.test.ts - Transform logic teststypes/external.d.ts - External type definitionssrc/images/thumbnail.png - Plugin thumbnail imageThe generator uses ERB-style templates with parameter substitution for dynamic file generation.
interface TemplateParams {
packageName: string; // User-provided package name
pluginName: string; // User-provided plugin display name
description: string; // User-provided description
chartType: string; // Selected chart type
packageLabel: string; // Generated UpperCamelCase class name
}Template Operations:
.erb extension are processed with template parametersThe generated projects include specific dependencies for Superset plugin development:
Runtime Dependencies:
interface GeneratorDependencies {
chalk: string; // Terminal styling (^4.0.0)
lodash: string; // Utility functions (^4.17.11)
"yeoman-generator": string; // Generator framework (^4.0.0)
yosay: string; // Welcome messages (^2.0.2)
}Generated Project Dependencies:
# Create new plugin directory
mkdir superset-plugin-chart-my-chart
cd superset-plugin-chart-my-chart
# Run generator
yo @superset-ui/superset
# Example prompt responses:
# Package name: superset-plugin-chart-my-chart
# Plugin name: My Chart
# Description: Custom chart plugin for Superset
# Chart type: Regular chartWhile primarily designed for CLI usage, the generators can be composed programmatically:
const Generator = require('yeoman-generator');
const AppGenerator = require('@superset-ui/generator-superset/generators/app');
class CustomGenerator extends Generator {
configuring() {
this.composeWith(AppGenerator, {
skipInstall: true
});
}
}The generators inherit standard Yeoman error handling behavior:
Common resolution steps:
yo) must be globally installed