MobDev.Plugin.Scaffold (mob_dev v0.5.17)

Copy Markdown View Source

Pure templates + name conversions behind mix mob.new_plugin.

Inputs are a snake_case plugin name (e.g. "mob_demo_widget") and a tier (0–2). Output is a list of {relative_path, content_string} pairs the Mix task writes to disk. All conversions live here so the task stays thin and the templates are unit-testable without filesystem I/O.

Templates mirror the three on-device-verified prototypes (mob_palette_demo, mob_demo_haptic_extras, mob_demo_signature_pad) so a freshly scaffolded plugin compiles + activates by the same path the prototypes already prove.

Summary

Functions

Returns the file list for a given tier + name. Each entry is {relative_path, content}. relative_path is relative to the plugin's root directory.

Converts "mob_demo_widget""MobDemoWidget".

Validates a plugin name (must be a snake_case atom-friendly identifier).

Validates a tier (0, 1, or 2).

Types

file()

@type file() :: {Path.t(), String.t()}

tier()

@type tier() :: 0 | 1 | 2

Functions

files_for(int, name)

@spec files_for(tier(), String.t()) :: [file()]

Returns the file list for a given tier + name. Each entry is {relative_path, content}. relative_path is relative to the plugin's root directory.

module_name(name)

@spec module_name(String.t()) :: String.t()

Converts "mob_demo_widget""MobDemoWidget".

validate_name(name)

@spec validate_name(String.t()) :: :ok | {:error, String.t()}

Validates a plugin name (must be a snake_case atom-friendly identifier).

validate_tier(t)

@spec validate_tier(integer()) :: :ok | {:error, String.t()}

Validates a tier (0, 1, or 2).