DalaNew.ProjectGenerator (dala_new v0.4.0)

Copy Markdown View Source

Generates a new Dala project from EEx templates in priv/templates/dala.new/.

## Naming conventions

Given app_name = "my_cool_app" and the default bundle prefix:

  • module_name"MyCoolApp"
  • display_name"MyCoolApp"
  • bundle_id"com.example.my_cool_app"
  • java_package"com.example.my_cool_app"
  • lib_name"mycoolapp" (no underscores, for System.loadLibrary)
  • java_path"com/example/my_cool_app" (for directory structure)

Bundle prefix

The reverse-DNS prefix for the bundle ID defaults to com.example, the universal "must change before shipping" placeholder. Override at generation time with the DALA_BUNDLE_PREFIX env var:

DALA_BUNDLE_PREFIX=net.acme mix dala.new my_cool_app
# → bundle_id = "net.acme.my_cool_app"

We deliberately do not use com.dala — that's our reverse-DNS namespace, and Apple/Google enforce ownership at submission time, so a project that ships with com.dala.* would have to be renamed before reaching either store.

Summary

Functions

Returns the EEx template assigns map for app_name.

File names (relative to project root) that must be emitted executable.

Static file names (relative to project root) that must be emitted executable.

Generates a new project at dest_dir/<app_name> from the bundled templates.

Generates a LiveView-wrapped Dala project at dest_dir/<app_name>.

Delegates to DalaNew.LiveViewGenerator.liveview_phoenix_owned?/3 (kept here for back-compat — tests and external callers reference this module).

Functions

assigns(app_name, opts \\ [])

@spec assigns(
  String.t(),
  keyword()
) :: map()

Returns the EEx template assigns map for app_name.

Options:

  • :local — when true, generates path: deps pointing to local dala/dala_dev repos instead of hex version constraints. Paths are resolved from the DALA_DIR and DALA_DEV_DIR environment variables, falling back to ../dala and ../dala_dev relative to the generated project location.

bundle_prefix()

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

executable_files()

File names (relative to project root) that must be emitted executable.

executable_static()

Static file names (relative to project root) that must be emitted executable.

expand_path(rel, assigns)

find_templates(dir)

generate(app_name, dest_dir \\ ".", opts \\ [])

@spec generate(String.t(), String.t(), keyword()) ::
  {:ok, String.t()} | {:error, term()}

Generates a new project at dest_dir/<app_name> from the bundled templates.

Returns {:ok, project_dir} or {:error, reason}.

liveview_generate(app_name, dest_dir \\ ".", opts \\ [])

@spec liveview_generate(String.t(), String.t(), keyword()) ::
  {:ok, String.t()} | {:error, term()}

Generates a LiveView-wrapped Dala project at dest_dir/<app_name>.

Delegates to DalaNew.LiveViewGenerator.generate/3, which owns the whole --liveview pipeline (phx.new subprocess, boilerplate copy with the Phoenix-owned blocklist, and bridge patches).

liveview_phoenix_owned?(path, root, opts)

@spec liveview_phoenix_owned?(String.t(), String.t(), keyword()) :: boolean()

Delegates to DalaNew.LiveViewGenerator.liveview_phoenix_owned?/3 (kept here for back-compat — tests and external callers reference this module).

liveview_port(bundle_id)

@spec liveview_port(String.t()) :: pos_integer()

platform_included?(path, root, no_ios, no_android)

static_root()

templates_root()