Skip to content

Generate components, helpers, modifiers and services in v1/v2 apps/addons.

License

Notifications You must be signed in to change notification settings

bertdeblock/gember

Repository files navigation

🫚 gember

CI NPM Version

Generate components, helpers, modifiers and services in v1/v2 apps/addons.

Uses scaffdog underneath.

NOTE: Only supports .gjs (default) and .gts files for components.

Installation

npm
npm install -D @bertdeblock/gember
bun
bun add -D @bertdeblock/gember
pnpm
pnpm add -D @bertdeblock/gember
yarn
yarn add -D @bertdeblock/gember

Usage

Generating components
pnpm gember component --help # for all available options

# examples:
pnpm gember component foo
pnpm gember component foo --class-based # or `--class`
pnpm gember component foo --path="src/-private"
pnpm gember component foo --typescript # or `--ts`
Generating helpers
pnpm gember helper --help # for all available options

# examples:
pnpm gember helper foo
pnpm gember helper foo --class-based # or `--class`
pnpm gember helper foo --path="src/-private"
pnpm gember helper foo --typescript # or `--ts`
Generating modifiers
pnpm gember modifier --help # for all available options

# examples:
pnpm gember modifier foo
pnpm gember modifier foo --class-based # or `--class`
pnpm gember modifier foo --path="src/-private"
pnpm gember modifier foo --typescript # or `--ts`
Generating services
pnpm gember service --help # for all available options

# examples:
pnpm gember service foo
pnpm gember service foo --path="src/-private"
pnpm gember service foo --typescript # or `--ts`

Configuration

gember supports the following config files:

  • gember.config.js
  • gember.config.cjs
  • gember.config.mjs

A gember config file must export a gember config object, or a sync/async function that returns a gember config object:

// gember.config.js

export default {};

// or:
export default () => ({});

// or:
export default async () => ({});

Configuration Signature

export type Config = {
  generators?: {
    component?: {
      classBased?: boolean;
      path?: string;
      typescript?: boolean;
    };
    helper?: {
      classBased?: boolean;
      path?: string;
      typescript?: boolean;
    };
    modifier?: {
      classBased?: boolean;
      path?: string;
      typescript?: boolean;
    };
    service?: {
      path?: string;
      typescript?: boolean;
    };
  };

  hooks?: {
    // A hook that will be executed post running a generator:
    postGenerate?: (info: {
      documentName: DocumentName;
      entityName: string;
      files: File[];
    }) => Promise<void> | void;
  };

  // Use TypeScript by default for all generators:
  typescript?: boolean;
};