### mix igniter.install Source: https://hexdocs.pm/igniter_new/api-reference.html Installs a package and executes its associated Igniter installers. ```APIDOC ## MIX igniter.install ### Description Installs a package or list of packages and triggers any defined Igniter installers to configure the package automatically. ### Method CLI Command ### Endpoint mix igniter.install [package_name] ### Parameters #### Path Parameters - **package_name** (string) - Required - The name of the package to install. ### Request Example mix igniter.install phoenix ### Response #### Success Response (0) - **status** (string) - Package installed and configured. ``` -------------------------------- ### Install Dependencies with Igniter Source: https://hexdocs.pm/igniter/Igniter.Util.Install.html The install function handles the installation of a provided list of dependencies. It accepts dependencies as a comma-separated string, a list of strings, or a list of tuples specifying versions. ```elixir import Igniter.Util.Install # Example usage with a list of tuples deps = [{:ash, "~> 3.0"}, {:ash_postgres, "~> 2.0"}] install(deps, [], Igniter.new()) ``` -------------------------------- ### Install Packages with Igniter (Elixir) Source: https://hexdocs.pm/igniter/Mix.Tasks.Igniter.Install.html Installs one or more packages using the `mix igniter.install` command. This task can fetch packages from Hex, Git repositories, or local paths, and supports version pinning and environment-specific installations. It also allows for options like `--dry-run` and `--yes` to control the installation behavior. ```bash mix igniter.install package1 package2 package3 mix igniter.install package@version mix igniter.install package@git:git_url mix igniter.install package@github:project/repo mix igniter.install package@github:project/repo@ref mix igniter.install package@path:path/to/dep mix igniter.install org/package@version mix igniter.install package@git:git_url@ref mix igniter.install --only dev package mix igniter.install --dry-run package mix igniter.install --yes package mix igniter.install --yes-to-deps package mix igniter.install --verbose package mix igniter.install --example package ``` -------------------------------- ### Install Packages with Igniter Source: https://hexdocs.pm/igniter/Mix.Tasks.Igniter.Install.html This section describes how to install packages using the `mix igniter.install` command, including different package format specifications and options. ```APIDOC ## MIX IGNITER.INSTALL ### Description Install a package or packages, running any Igniter installers. ### Method Mix Task ### Endpoint mix igniter.install [package1] [package2] ... ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Package Formats - `package`: Installs the latest version, pinned at the major or minor version. - `package@version`: Installs at a specified version. Generic versions (e.g., `3.0`) are pinned by major/minor version. Specific versions (e.g., `3.0.1`) are pinned exactly with `==`. - `package@git:git_url`: Installs from a Git URL. - `package@github:project/repo`: Installs from a GitHub repository. - `package@github:project/repo@ref`: Installs from a GitHub repository at a specific ref (tag, branch, commit). - `package@path:path/to/dep`: Installs from a local path. - `org/package`: Installs from a private Hex organization. Can be combined with other format specifiers. Additionally, a Git ref can be specified with `git` or `github` URLs: `package@git:git_url@ref`. ### Options - `--only `: Install packages in specific environments (e.g., `--only dev`, `--only dev,test`). ### Switches - `--dry-run`: Run the task without making any changes. - `--yes`: Automatically answer yes to all prompts. - `--yes-to-deps`: Automatically answer yes to prompts about installing new dependencies. - `--verbose`: Display additional output. - `--example`: Request that installed packages include initial example code. `argv` values are also passed to the igniter installer tasks of installed packages. ``` -------------------------------- ### Install Package Source: https://hexdocs.pm/igniter/Igniter.html Installs a package into the project, simulating the execution of `mix igniter.install`. It accepts the package name, optional arguments for the install command, and options. The `append?` option can be used to append the package instead of prepending. ```Elixir Igniter.install(igniter, "ash") Igniter.install(igniter, "ash_authentication@2.0", ["--authentication-strategies", "password,magic_link"]) ``` -------------------------------- ### mix igniter.new Source: https://hexdocs.pm/igniter_new/Mix.Tasks.Igniter.New.html Initializes a new project using mix new and integrates Igniter, supporting custom installers and dependency installation. ```APIDOC ## mix igniter.new ### Description Creates a new project using `mix new` and adds `igniter` to the project. It supports passing options to underlying installers and configuring project structure. ### Method CLI Command ### Endpoint mix igniter.new [project_name] ### Parameters #### Options - **--install** (string) - Optional - Comma-separated list of dependencies to install using `mix igniter.install`. - **--example** (boolean) - Optional - Request example code to be added during installation. - **--with** (string) - Optional - The command to use instead of `new` (e.g., `phx.new`). - **--with-args** (string) - Optional - Additional arguments to pass to the installer provided in `--with`. - **--yes / -y** (boolean) - Optional - Skips confirmations during installers. - **--no-installer-version-check** (boolean) - Optional - Skip the version check for the latest igniter_new version. - **--no-git** (boolean) - Optional - Skip initializing a git repository. - **--module** (string) - Optional - The base module name to use for the project. - **--sup** (boolean) - Optional - Generates an OTP application skeleton with a supervision tree. - **--umbrella** (boolean) - Optional - Generates an umbrella project. ### Request Example `mix igniter.new my_project --install foo,bar,baz --with=phx.new --with-args="--no-ecto"` ### Response #### Success Response (0) - **status** (string) - Project created and dependencies installed successfully. ``` -------------------------------- ### Igniter Setup Source: https://hexdocs.pm/igniter/Mix.Tasks.Igniter.Setup.html Creates or updates a .igniter.exs file, used to configure Igniter for end user's preferences. ```APIDOC ## mix igniter.setup ### Description Creates or updates a .igniter.exs file, used to configure Igniter for end user's preferences. ### Method MIX Task ### Endpoint N/A (Mix Task) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```bash mix igniter.setup ``` ### Response #### Success Response (0) Creates or updates the `.igniter.exs` configuration file. #### Response Example ```json { "message": ".igniter.exs file created/updated successfully." } ``` ``` -------------------------------- ### Install Igniter Mix Archive Source: https://hexdocs.pm/igniter Installs the Igniter archive globally, allowing the use of `mix igniter.new` to generate new Elixir projects. ```bash mix archive.install hex igniter_new ``` -------------------------------- ### Igniter Task Installer Check Source: https://hexdocs.pm/igniter/Igniter.Mix.Task.html A boolean callback to indicate if the task functions as an installer. ```elixir @callback installer?() :: boolean() ``` -------------------------------- ### New Igniter Instance Source: https://hexdocs.pm/igniter/Igniter.html Initializes and returns a new instance of the Igniter. This is the starting point for most Igniter operations. ```Elixir @spec new() :: t() ``` -------------------------------- ### Igniter Custom Resource Generator Example Source: https://hexdocs.pm/igniter An example of a custom Mix task written with Igniter for library authors. This task extends the `ash.gen.resource` task to create a module with additional custom logic and file generation. ```elixir defmodule Mix.Tasks.MyApp.Gen.Resource do use Igniter.Mix.Task @impl Igniter.Mix.Task def igniter(igniter) do [resource | _] = igniter.args.argv resource = Igniter.Code.Module.parse(resource) my_special_thing = Module.concat([resource, SpecialThing]) location = Igniter.Code.Module.proper_location(my_special_thing) igniter |> Igniter.compose_task("ash.gen.resource", igniter.args.argv) |> Igniter.Project.Module.create_module(my_special_thing, """ # this is the special thing for #{inspect()} """) end end ``` -------------------------------- ### Setup Test Igniter Project Source: https://hexdocs.pm/igniter/Igniter.Test.html Functions to set up test igniter environments. `phx_test_project/1` mimics a new Phoenix project, while `test_project/1` creates an igniter with specified files. ```Elixir phx_test_project(opts \\ []) Sets up a test igniter that mimics a new phoenix project ``` ```Elixir test_project(opts \\ []) Sets up a test igniter that has only the files passed to it. @spec test_project(opts :: Keyword.t()) :: Igniter.t() ## __Starting point All of the files of an empty mix project are added by default. You can specify more or overwrite files with the `:files` option. ## __Limitations You cannot install new dependencies, or use dependencies your own project does not have. If you need to do that kind of thing, you will have to do a test that uses tools like `System.cmd` in a temporary directory. ## __Options * `files` - A map of file paths to file contents. The file paths should be relative to the project root. * `app_name` - The name of the application. Defaults to `:test`. ``` -------------------------------- ### Install IgniterToolbox Dependency Source: https://hexdocs.pm/igniter_toolbox/index.html This snippet shows how to add the igniter_toolbox dependency to your project's mix.exs file. This is the first step to using the toolbox. ```elixir def deps do [ {:igniter_toolbox, "~> 0.1.0"} ] end ``` -------------------------------- ### Generate Task Documentation via CLI Source: https://hexdocs.pm/igniter/documenting-tasks.html Use the --scribe flag when running any Igniter-enabled mix task to automatically generate a markdown guide at the specified file path. ```bash mix your.task --scribe documentation/tutorials/your-guide.md ``` -------------------------------- ### Add Dependencies with Igniter Source: https://hexdocs.pm/igniter/Mix.Tasks.Igniter.Add.html This command adds specified dependencies to your `mix.exs` file and fetches them. It's useful when you want to add a dependency without immediately running its installer. ```APIDOC ## mix igniter.add ### Description Adds the provided dependencies to your `mix.exs` file. This task also fetches the dependencies after completion. ### Method Mix Task ### Endpoint N/A (Mix Task) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```bash mix igniter.add dep1 dep2 ``` ### Response #### Success Response (200) Dependencies are added to `mix.exs` and fetched. #### Response Example ``` * adding dep1 * adding dep2 ``` ``` -------------------------------- ### Run Igniter Upgrades Source: https://hexdocs.pm/igniter/Igniter.Upgrades.html Executes all defined upgrades sequentially from a specified starting point to an ending point. It takes the igniter instance, start and end versions, an upgrade map, and optional configuration settings as input. This function is crucial for managing version changes and applying necessary data or configuration migrations. ```Elixir Igniter.Upgrades.run(igniter, from, to, upgrade_map, opts) ``` -------------------------------- ### Get Igniter Module Name Source: https://hexdocs.pm/igniter/Igniter.Project.Module.html Constructs a full module name by prepending the project's module name prefix to a given suffix. ```Elixir module_name(igniter, suffix) ``` -------------------------------- ### Generate New Mix Project with Igniter (Elixir) Source: https://hexdocs.pm/igniter/readme.html Creates a new Elixir project using `mix igniter.new`. This command can optionally install specific dependencies like Ash or Ecto, or integrate with existing project generators like `mix phx.new`. ```bash mix igniter.new app_name --install ash ``` ```bash mix igniter.new app_name --install ash,ecto ``` ```bash mix igniter.new app_name --install ash --with phx.new --with-args="--no-ecto --no-html" ``` -------------------------------- ### Create New Project with Igniter Source: https://hexdocs.pm/igniter_new/Mix.Tasks.Igniter.New.html Creates a new Elixir project using `mix new` and integrates the `igniter` dependency. Supports installing additional dependencies, using custom project generators (e.g., `phx.new`), and passing arguments to these generators. It also allows skipping git initialization and version checks. ```bash mix igniter.new my_project --install foo,bar,baz --with=phx.new --with-args="--no-ecto" ``` -------------------------------- ### Get Igniter Module Name Prefix Source: https://hexdocs.pm/igniter/Igniter.Project.Module.html Retrieves the module name prefix based on the current project's mix configuration. ```Elixir module_name_prefix(igniter) ``` -------------------------------- ### Add Dependencies to mix.exs with Igniter Source: https://hexdocs.pm/igniter/Mix.Tasks.Igniter.Add.html Adds specified dependencies to the mix.exs file and fetches them. This is useful when you want to add a dependency without running its installer. The `igniter.install` task also modifies `mix.exs`. ```bash mix igniter.add dep1 dep2 ``` -------------------------------- ### Get Idiomatic File Location for Module Source: https://hexdocs.pm/igniter/Igniter.Code.Module.html Returns the standard file path for a given module within the project's source directory (defaults to 'lib/'). This function is deprecated; use `Igniter.Project.Module.proper_location/3`. ```elixir @spec proper_location(module(), source_folder :: String.t()) :: Path.t() ``` -------------------------------- ### Get Proper Module File Location Source: https://hexdocs.pm/igniter/Igniter.Code.Module.html Determines the idiomatic file location for a given module name, typically starting with 'lib/'. This function is deprecated. ```elixir proper_location(module_name, source_folder \\ "lib") ``` -------------------------------- ### Get Test Support Location (Deprecated) Source: https://hexdocs.pm/igniter/Igniter.Code.Module.html This function returns the test support location for a given module. It is deprecated and users should use `Igniter.Project.Module.proper_location/3` instead. It constructs the path starting with 'test/support/' and removes the module name prefix. ```Elixir @spec proper_test_support_location(module()) :: Path.t() ``` -------------------------------- ### Igniter.Scribe.start_document/4 Source: https://hexdocs.pm/igniter/documenting-tasks.html Initializes the documentation generation process with a title and an introductory text block. ```APIDOC ## start_document/4 ### Description Initializes the documentation with a title and introduction. Only the first call to this function is honored. ### Method Elixir Function ### Parameters - **igniter** (Igniter.t) - Required - The Igniter struct - **title** (String.t) - Required - The main title for the document - **contents** (String.t) - Required - Introduction text - **opts** (Keyword.t) - Optional - Configuration options such as :app_name ### Request Example ```elixir igniter |> Igniter.Scribe.start_document("Manual Installation", "Guide text", app_name: :my_app) ``` ``` -------------------------------- ### POST /igniter/test/project Source: https://hexdocs.pm/igniter/Igniter.Test.html Initializes a test igniter environment for verifying file operations. ```APIDOC ## POST /igniter/test/project ### Description Sets up a test igniter that has only the files passed to it, allowing for isolated testing of file creation, movement, and modification. ### Method POST ### Endpoint /igniter/test/project ### Parameters #### Request Body - **files** (map) - Optional - A map of file paths to file contents. - **app_name** (string) - Optional - The name of the application, defaults to 'test'. ### Response #### Success Response (200) - **igniter** (Igniter.t) - The initialized test igniter struct. ``` -------------------------------- ### Initialize Igniter Configuration Source: https://hexdocs.pm/igniter/configuring-igniter.html Creates or updates the .igniter.exs configuration file in the project root to manage Igniter settings. ```bash mix igniter.setup ``` -------------------------------- ### GET /igniter/code/string/string? Source: https://hexdocs.pm/igniter/Igniter.Code.String.html Checks if the current node in the zipper is a literal string. ```APIDOC ## GET /igniter/code/string/string? ### Description Returns true if the node represents a literal string, false otherwise. ### Method GET ### Endpoint /igniter/code/string/string? ### Parameters #### Request Body - **zipper** (Sourceror.Zipper.t) - Required - The zipper node to inspect. ### Response #### Success Response (200) - **result** (boolean) - Returns true if the node is a string, false otherwise. ``` -------------------------------- ### GET /exist_live_socket Source: https://hexdocs.pm/igniter_js/IgniterJs.Parsers.Javascript.Parser.html Checks for the existence of a LiveSocket variable in the provided JavaScript source. ```APIDOC ## GET /exist_live_socket ### Description Check if a LiveSocket var exists in the given file or content and returns a tuple. ### Method GET ### Endpoint /exist_live_socket ### Parameters #### Query Parameters - **file_path_or_content** (string) - Required - The source content or file path. - **type** (atom) - Optional - Input type: :content or :path. ### Response #### Success Response (200) - **result** (tuple) - A tuple indicating the presence of the LiveSocket variable. ``` -------------------------------- ### mix igniter.add Source: https://hexdocs.pm/igniter_new/Mix.Tasks.Igniter.Add.html Adds specified dependencies to the mix.exs file and fetches them. ```APIDOC ## MIX igniter.add ### Description Adds the provided dependencies to `mix.exs`. This task is useful for adding dependencies without running their specific installers. It automatically fetches the dependencies after they are added. ### Method CLI Task ### Endpoint mix igniter.add [dependencies] ### Parameters #### Path Parameters - **dependencies** (list) - Required - A space-separated list of dependencies to add to the project. ### Request Example ```bash mix igniter.add dep1 dep2 ``` ### Response #### Success Response - **status** (string) - Dependencies added and fetched successfully. ``` -------------------------------- ### GET /igniter/diff Source: https://hexdocs.pm/igniter/Igniter.Test.html Retrieves the current diff of the igniter, showing pending file changes. ```APIDOC ## GET /igniter/diff ### Description Return the current igniter diff, representing the pending changes to the file system. ### Method GET ### Endpoint /igniter/diff ### Parameters #### Query Parameters - **only** (string) - Optional - Filter the diff to a specific file path. ### Response #### Success Response (200) - **diff** (string) - The formatted diff string. ``` -------------------------------- ### Bump Project Version with IgniterToolbox Source: https://hexdocs.pm/igniter_toolbox/Mix.Tasks.Bump.html Prepares a new release by bumping the project version, updating the changelog, and creating a git tag. Supports patch, minor, and major version bumps. Requires Git and a VERSION file. ```bash mix bump # 0.1.2 -> 0.1.3 (patch by default) mix bump patch # 0.1.2 -> 0.1.3 mix bump minor # 0.1.2 -> 0.2.0 mix bump major # 0.1.2 -> 1.0.0 ``` ```bash git push origin main --tags ``` -------------------------------- ### Get Web Module Name Source: https://hexdocs.pm/igniter/Igniter.Libs.Phoenix.html Retrieves the web module name for the current application. ```APIDOC ## GET /websites/hexdocs_pm_igniter/web_module_name ### Description Returns the web module name for the current app. ### Method GET ### Endpoint /websites/hexdocs_pm_igniter/web_module_name ### Parameters #### Query Parameters - **igniter** (module()) - Required - The Igniter instance. - **suffix** (String.t()) - Optional - A suffix to append to the web module name. ### Request Example ```json { "igniter": "Igniter", "suffix": "Controller" } ``` ### Response #### Success Response (200) - **web_module_name** (String.t()) - The name of the web module. #### Response Example ```json { "web_module_name": "MyAppWeb.Controller" } ``` ``` -------------------------------- ### Get Endpoints for Router Source: https://hexdocs.pm/igniter/Igniter.Libs.Phoenix.html Retrieves a list of endpoints associated with a specific Phoenix router. ```APIDOC ## GET /websites/hexdocs_pm_igniter/endpoints_for_router ### Description Gets the list of endpoints that use a given router. ### Method GET ### Endpoint /websites/hexdocs_pm_igniter/endpoints_for_router ### Parameters #### Query Parameters - **igniter** (module()) - Required - The Igniter instance. - **router** (module()) - Required - The router module to query. ### Request Example ```json { "igniter": "Igniter", "router": "MyAppWeb.Router" } ``` ### Response #### Success Response (200) - **endpoints** ([module()]) - A list of endpoint modules associated with the router. #### Response Example ```json { "endpoints": ["MyAppWeb.Endpoint"] } ``` ``` -------------------------------- ### Create Igniter Module Source: https://hexdocs.pm/igniter/Igniter.Project.Module.html Creates a new file and module in its appropriate project location. It accepts the igniter instance, module name, contents, and optional settings like location. ```Elixir create_module(igniter, module_name, contents, opts \\ []) ``` -------------------------------- ### mix igniter.new Source: https://hexdocs.pm/igniter_new/api-reference.html Creates a new project using mix new and integrates Igniter. ```APIDOC ## MIX igniter.new ### Description Creates a new project using `mix new` and adds `igniter` as a dependency to the generated project. ### Method CLI Command ### Endpoint mix igniter.new [project_name] ### Parameters #### Path Parameters - **project_name** (string) - Required - The name of the project to create. ### Request Example mix igniter.new my_app ### Response #### Success Response (0) - **status** (string) - Project created successfully with Igniter configured. ``` -------------------------------- ### Get Endpoints for Router Source: https://hexdocs.pm/igniter/Igniter.Libs.Phoenix.html Retrieves a list of endpoints associated with a specific router module. ```elixir @spec endpoints_for_router(igniter :: Igniter.t(), router :: module()) :: {Igniter.t(), [module()]} ``` -------------------------------- ### Configure Elixir application settings Source: https://hexdocs.pm/igniter/Igniter.Project.Config.html Demonstrates how to use the configure function to set a configuration value. It shows passing raw code using Sourceror to ensure proper AST formatting. ```elixir igniter |> Igniter.Project.Config.configure( "fake.exs", :tailwind, [:default, :args], {:code, Sourceror.parse_string!(""" ~w(--config=tailwind.config.js --input=css/app.css --output=../output/assets/app.css) """)} ) ``` -------------------------------- ### GET /var_exists Source: https://hexdocs.pm/igniter_js/IgniterJs.Parsers.Javascript.Parser.html Checks for the existence of a specific variable or identifier within the provided JavaScript source. ```APIDOC ## GET /var_exists ### Description Checks if a specific variable exists within the given file or content and returns a boolean value. ### Method GET ### Endpoint /var_exists ### Parameters #### Query Parameters - **file_path_or_content** (string) - Required - The raw JavaScript content or the file system path. - **type** (atom) - Optional - Specifies if the input is :content or :path. Defaults to :content. ### Request Example Parser.exist_live_socket?("window.liveSocket", :content) ### Response #### Success Response (200) - **exists** (boolean) - True if the variable is found, false otherwise. #### Response Example true ``` -------------------------------- ### GET /statistics Source: https://hexdocs.pm/igniter_js/IgniterJs.Parsers.Javascript.Parser.html Retrieves statistical information about JavaScript source code such as function counts, classes, and imports. ```APIDOC ## GET /statistics ### Description Analyzes JavaScript source code to return metrics including the number of functions, classes, debugger statements, imports, try-catch blocks, and throw statements. ### Method GET ### Endpoint /statistics ### Parameters #### Query Parameters - **file_path_or_content** (string) - Required - The raw JavaScript content or the file system path. - **type** (atom) - Optional - Specifies if the input is :content or :path. Defaults to :content. ### Request Example Parser.statistics("const x = 1;", :content) ### Response #### Success Response (200) - **data** (map) - A map containing counts of functions, classes, imports, etc. #### Response Example {:ok, :statistics, %{functions: 1, classes: 0, imports: 0}} ``` -------------------------------- ### relative_to_cwd Function Source: https://hexdocs.pm/igniter/Igniter.Util.BackwardsCompat.html Provides a function to get the relative path from the current working directory, similar to `Path.relative_to_cwd/2`. ```APIDOC ## relative_to_cwd/2 ### Description Returns the path relative to the current working directory. ### Method N/A (Function within a module) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```elixir Igniter.Util.BackwardsCompat.relative_to_cwd("some/path") ``` ### Response #### Success Response (200) - **String** - The relative path. #### Response Example ```elixir "path/to/file" ``` ``` -------------------------------- ### mix igniter.add Source: https://hexdocs.pm/igniter_new/api-reference.html Adds dependencies to the mix.exs file. ```APIDOC ## MIX igniter.add ### Description Adds the specified dependencies to the project's `mix.exs` file. ### Method CLI Command ### Endpoint mix igniter.add [deps] ### Parameters #### Path Parameters - **deps** (list) - Required - The list of dependencies to add. ### Request Example mix igniter.add jason ### Response #### Success Response (0) - **status** (string) - Dependencies added to mix.exs. ``` -------------------------------- ### POST /igniter/modules/create Source: https://hexdocs.pm/igniter/Igniter.Project.Module.html Creates a new file and module within the project structure at the appropriate location. ```APIDOC ## POST /igniter/modules/create ### Description Creates a new file and module in its appropriate location based on the provided configuration. ### Method POST ### Endpoint /igniter/modules/create ### Parameters #### Request Body - **igniter** (Igniter.t) - Required - The current igniter state. - **module_name** (module) - Required - The name of the module to create. - **contents** (String.t) - Required - The initial content of the module. - **opts** (Keyword.t) - Optional - Options including :location (see location_type/0). ### Request Example { "module_name": "MyApp.NewModule", "contents": "defmodule MyApp.NewModule do\nend", "opts": { "location": ":source_folder" } } ### Response #### Success Response (200) - **igniter** (Igniter.t) - The updated igniter state. #### Response Example { "status": "success", "igniter": "" } ``` -------------------------------- ### POST /upgrades/run Source: https://hexdocs.pm/igniter/Igniter.Upgrades.html Executes a series of upgrade tasks defined in an upgrade map to transition a project from one version to another. ```APIDOC ## POST /upgrades/run ### Description Runs all defined upgrade tasks sequentially to transition the project state from the 'from' version to the 'to' version. ### Method POST ### Endpoint /upgrades/run ### Parameters #### Request Body - **igniter** (Object) - Required - The current igniter project context. - **from** (String) - Required - The starting version string. - **to** (String) - Required - The target version string. - **upgrade_map** (Map) - Required - A mapping of version transitions to specific upgrade functions. - **opts** (KeywordList) - Optional - Additional configuration options for the upgrade process. ### Request Example { "igniter": "...", "from": "0.7.6", "to": "0.7.7", "upgrade_map": {}, "opts": [] } ### Response #### Success Response (200) - **igniter** (Object) - The updated igniter project context after upgrades are applied. #### Response Example { "status": "success", "igniter": "..." } ``` -------------------------------- ### Manipulate Keyword Lists Source: https://hexdocs.pm/igniter/Igniter.Code.Keyword.html Functions for getting, setting, and removing keys within keyword list structures using zippers. ```APIDOC ## get_key(zipper, key) ### Description Moves the zipper to the value of a specific key in a keyword list. ### Method FUNCTION ### Parameters - **zipper** (Sourceror.Zipper.t) - Required - The current zipper location. - **key** (atom) - Required - The key to locate. ### Response - **Success** ({:ok, zipper} | :error) - Returns the zipper at the key's value or :error if not found. --- ## put_in_keyword(zipper, path, value, updater) ### Description Puts a value at a specific path into a nested keyword list, creating the path if it does not exist. ### Parameters - **zipper** (Sourceror.Zipper.t) - Required - The current zipper location. - **path** ([atom]) - Required - A list of atoms representing the nested path. - **value** (term) - Required - The value to set. - **updater** (function) - Optional - A function to call if the key already exists. ### Response - **Result** ({:ok, zipper} | :error | {:error, String.t} | {:warning, String.t}) - The updated zipper or error/warning status. ``` -------------------------------- ### Elixir Module Attributes for Documentation Source: https://hexdocs.pm/igniter/documenting-tasks.html Demonstrates using Elixir module attributes like @manual_lead_in, @dependency_setup, and @formatter_setup to store documentation strings. These attributes help keep documentation organized and reusable within modules, especially for igniter functions. ```elixir defmodule Mix.Tasks.YourLibrary.Install do @manual_lead_in """ This guide walks you through manually installing YourLibrary. """ @dependency_setup """ Install required dependencies and configure them for your project. """ @formatter_setup """ Configure code formatting for your DSL. """ # Use these throughout your igniter/1 function end ``` -------------------------------- ### Get Module Name Prefix Source: https://hexdocs.pm/igniter/Igniter.Code.Module.html Retrieves the module name prefix based on the mix project's configuration. This function is deprecated. ```elixir module_name_prefix() ``` ```elixir module_name_prefix(igniter) ``` -------------------------------- ### Test Igniter Project File Generation Source: https://hexdocs.pm/igniter/Igniter.Test.html Uses the test_project helper to simulate file creation within an Igniter project. It accepts a map of file paths to their respective content, allowing for unit testing of code generation logic. ```elixir test_project(files: %{ "lib/foo.ex" => """ defmodule MyApp.Foo do use Ash.Resource end """ }) ``` -------------------------------- ### Implementing Custom Argument Parsing Source: https://hexdocs.pm/igniter/Igniter.Mix.Task.Info.html Shows how to implement the parse_argv/1 callback to perform custom validation or additional parsing logic using the positional_args! and options! macros. ```elixir @impl Igniter.Mix.Task def parse_argv(argv) do {positional, argv_flags} = positional_args!(argv) options = options!(argv_flags) %Igniter.Mix.Task.Args{ argv: argv, argv_flags: argv_flags, positional: positional, options: options } end ``` -------------------------------- ### Get Igniter Diff Source: https://hexdocs.pm/igniter/Igniter.Test.html Returns or prints the current diff of an igniter. The `diff/2` function returns the diff as a string, while `puts_diff/2` prints it and returns the igniter. ```Elixir diff(igniter, opts \\ []) Return the current `igniter` diff. @spec diff(Igniter.t(), opts :: Keyword.t()) :: String.t() ## __Options * `:only` - Only return the diff for this file or files ``` ```Elixir puts_diff(igniter, opts \\ []) Print the current `igniter` diff, returning the `igniter`. This is primarily used for debugging purposes. @spec puts_diff(Igniter.t(), opts :: Keyword.t()) :: Igniter.t() ## __Options * `:label` - A label to print before the diff * `:only` - Only print the diff for this file or files ``` -------------------------------- ### Get Proper Test Support File Location Source: https://hexdocs.pm/igniter/Igniter.Code.Module.html Determines the file location for a module's test support file, typically in 'test/support/'. This function is deprecated. ```elixir proper_test_support_location(module_name) ``` -------------------------------- ### List Ecto Repositories with Igniter Source: https://hexdocs.pm/igniter/Igniter.Libs.Ecto.html Lists all Ecto repositories configured within the Igniter project. Returns the Igniter state and a list of repository modules. ```elixir Igniter.Libs.Ecto.list_repos(igniter) ``` -------------------------------- ### Get Module Name from Suffix Source: https://hexdocs.pm/igniter/Igniter.Code.Module.html Constructs a full module name by prepending the current project's module name prefix to a given suffix. This function is deprecated. ```elixir module_name(suffix) ``` ```elixir module_name(igniter, suffix) ``` -------------------------------- ### Writing an Igniter Upgrader Task Source: https://hexdocs.pm/igniter/upgrades.html To create an upgrader, provide an igniter task named `your_package.upgrade` within your package. This task accepts `from` and `to` arguments representing the old and new package versions. The suggested approach is to use `mix igniter.gen.task`. ```bash mix igniter.gen.task your_package.upgrade --upgrade ``` -------------------------------- ### Apply Changes and Fetch Dependencies Source: https://hexdocs.pm/igniter/Igniter.html Applies current changes to the `mix.exs` in Igniter and fetches dependencies. Returns remaining changes if successful. Supports options like `:error_on_abort?` and `:yes` for automated execution. ```Elixir apply_and_fetch_dependencies(igniter, opts \\ []) ``` -------------------------------- ### Get Project Module Name Prefix Source: https://hexdocs.pm/igniter/Igniter.Code.Module.html Retrieves the module name prefix based on the current mix project's configuration. This function is deprecated; use `Igniter.Project.Module.module_name_prefix/1` instead. ```elixir @spec module_name_prefix() :: module() ``` -------------------------------- ### Get Proper Test File Location Source: https://hexdocs.pm/igniter/Igniter.Code.Module.html Determines the file location for a module's test file, following `mix test` conventions (e.g., 'test/my_module_test.exs'). This function is deprecated. ```elixir proper_test_location(module_name) ``` -------------------------------- ### mix igniter.add_extension Source: https://hexdocs.pm/igniter/Mix.Tasks.Igniter.AddExtension.html Adds an extension to the .igniter.exs configuration file. ```APIDOC ## mix igniter.add_extension ### Description Adds an extension to your `.igniter.exs` configuration file. The extension can be a module name or the string 'phoenix', which maps to `Igniter.Extensions.Phoenix`. ### Method CLI Command ### Endpoint mix igniter.add_extension [extension] ### Parameters #### Path Parameters - **extension** (string) - Required - The module name of the extension or 'phoenix'. ### Request Example `mix igniter.add_extension phoenix` ### Response #### Success Response (0) - **status** (integer) - Returns 0 on successful configuration update. ``` -------------------------------- ### select(prompt, items, opts \\ []) Source: https://hexdocs.pm/igniter/Igniter.Util.IO.html Prompts the user to select an item from a list. The prompt is repeated until a valid item is selected. Supports custom display options. ```APIDOC ## select(prompt, items, opts \\ []) ### Description Prompts the user to select from a list, repeating until an item is selected. ### Method N/A (Function Call) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```elixir items = ["apple", "banana", "cherry"] selected_item = Igniter.Util.IO.select("Choose a fruit:", items) ``` ### Response #### Success Response (200) - **selected_item** (string) - The item selected by the user. #### Response Example ```json { "selected_item": "banana" } ``` ### Options - `display` : A function that takes an item and returns a string to display. ``` -------------------------------- ### add_dep/3 Source: https://hexdocs.pm/igniter/Igniter.Project.Deps.html Adds a dependency to the mix.exs file with configurable options. ```APIDOC ## POST /igniter/deps/add ### Description Adds a new dependency to the mix.exs file. Supports options for automatic confirmation, appending, and handling existing dependencies. ### Method POST ### Parameters #### Request Body - **igniter** (Igniter.t) - Required - The current igniter project state. - **dep** (tuple) - Required - The dependency definition (e.g., {:my_dependency, "~> X.Y.Z"}). - **opts** (keyword) - Optional - Options including :yes?, :append?, :error?, and :on_exists. ### Request Example { "dep": ["my_dependency", "~> 1.0.0"], "opts": { "on_exists": "skip" } } ### Response #### Success Response (200) - **igniter** (Igniter.t) - The updated igniter project state. ``` -------------------------------- ### Move Zipper to Attribute Definition Source: https://hexdocs.pm/igniter/Igniter.Code.Module.html Moves the Sourceror zipper to the definition of a specified attribute within a module. This is useful for inspecting or modifying attribute definitions. Example shows moving to `@doc` and `@session_options`. ```elixir @spec move_to_attribute_definition(Sourceror.Zipper.t(), atom()) :: {:ok, Sourceror.Zipper.t()} | :error ``` -------------------------------- ### Create a Custom Igniter Generator Task Source: https://hexdocs.pm/igniter/writing-generators.html Demonstrates how to implement a custom Mix task using Igniter.Mix.Task to generate files and update configuration files like config.exs. ```elixir defmodule Mix.Tasks.YourLib.Gen.YourThing do use Igniter.Mix.Task @impl Igniter.Mix.Task def igniter(igniter) do [module_name | _] = igniter.args.argv module_name = Igniter.Project.Module.parse(module_name) path = Igniter.Project.Module.proper_location(igniter, module_name) app_name = Igniter.Project.Application.app_name(igniter) igniter |> Igniter.create_new_file(path, """ defmodule #{inspect(module_name)} do use YourLib.Thing ...some_code end """) |> Igniter.Project.Config.configure( "config.exs", app_name, [:list_of_things], [module_name], updater: &Igniter.Code.List.prepend_new_to_list(&1, module_name) ) end end ``` -------------------------------- ### Get Idiomatic Test File Location for Module Source: https://hexdocs.pm/igniter/Igniter.Code.Module.html Returns the standard file path for a module's test file, following `mix test` conventions (e.g., 'test/my_module_test.exs'). This function is deprecated; use `Igniter.Project.Module.proper_location/3`. ```elixir @spec proper_test_location(module()) :: Path.t() ``` -------------------------------- ### Igniter.Scribe.section/3 Source: https://hexdocs.pm/igniter/documenting-tasks.html Creates a new section in the generated documentation with a header, explanation, and a callback to perform changes. ```APIDOC ## section/3 ### Description Creates a new section in the documentation with a header, explanation, and the actual changes performed by the callback. ### Method Elixir Function ### Parameters - **igniter** (Igniter.t) - Required - The Igniter struct - **header** (String.t) - Required - The section header text - **explanation** (String.t) - Required - Descriptive text explaining the section - **callback** (Function) - Required - A function that receives the igniter and performs changes ### Request Example ```elixir igniter |> Igniter.Scribe.section("Setup", "Explanation", fn igniter -> ... end) ``` ``` -------------------------------- ### Get Project Module Name Prefix with Igniter Context Source: https://hexdocs.pm/igniter/Igniter.Code.Module.html Retrieves the module name prefix based on the mix project's configuration, using the provided igniter context. This function is deprecated; use `Igniter.Project.Module.module_name_prefix/1` instead. ```elixir @spec module_name_prefix(Igniter.t()) :: module() ``` -------------------------------- ### Configure a new configuration value if not set Source: https://hexdocs.pm/igniter/Igniter.Project.Config.html Sets a configuration value in a specified file only if that configuration path does not already exist. ```APIDOC ## POST /api/config/configure_new ### Description Sets a config value in the given configuration file, if it is not already set. ### Method POST ### Endpoint /api/config/configure_new ### Parameters #### Request Body - **igniter** (object) - Required - The Igniter instance. - **file_path** (string) - Required - The path to the configuration file. - **app_name** (string) - Required - The application name (atom). - **config_path** (array) - Required - The path to the configuration key. - **value** (any) - Required - The value to set. - **opts** (object) - Optional - Options for configuration. ### Request Example ```json { "igniter": { ... }, "file_path": "config/config.exs", "app_name": :my_app, "config_path": ["api", "key"], "value": "default_api_key" } ``` ### Response #### Success Response (200) - **igniter** (object) - The updated Igniter instance. #### Response Example ```json { "igniter": { ... } } ``` ``` -------------------------------- ### Generate Test Case with IgniterToolbox Source: https://hexdocs.pm/igniter_toolbox/index.html Demonstrates the usage of the `mix igniter.gen.test_case` task. This task generates a new test case by copying an existing test within a specified describe block. It requires the path to the test file, a search string for the describe block, and the description for the new test. It handles single matches, multiple matches, and no matches by creating a new describe block. ```bash mix igniter.gen.test_case PATH SEARCH DESCRIPTION # Example: mix igniter.gen.test_case test/user_test.exs "create" "returns error when email invalid" --yes ``` ```bash # Example with multiple matches: # Multiple matches in test/user_test.exs: # - Line 10: create/1 # - Line 45: create_admin/1 ``` ```bash # Example when no describe block matches: mix igniter.gen.test_case test/user_test.exs "new_feature" "handles edge case" --yes ``` -------------------------------- ### Get Key from Keyword List (Igniter) Source: https://hexdocs.pm/igniter/Igniter.Code.Keyword.html Moves the zipper to the value of a specified key within a keyword list. It returns {:ok, zipper} if the key is found and the zipper is updated, or :error if the key is not present or the node is not a list. ```elixir @spec get_key(Sourceror.Zipper.t(), atom()) :: {:ok, Sourceror.Zipper.t()} | :error ``` -------------------------------- ### Configure a group of configuration values Source: https://hexdocs.pm/igniter/Igniter.Project.Config.html Configures multiple configuration settings at once, treating them as a group. This is useful for setting related configuration options together. ```APIDOC ## POST /api/config/configure_group ### Description Configures a "group" of configurations, which is multiple configurations set at one time. If the app + the shared prefix is already configured, then each configuration is added individually, and the `comment` for the group is ignored. ### Method POST ### Endpoint /api/config/configure_group ### Parameters #### Request Body - **igniter** (object) - Required - The Igniter instance. - **file_path** (string) - Required - The path to the configuration file. - **app_name** (string) - Required - The application name (atom). - **shared_prefix** (array) - Required - A shared prefix for the configuration group. - **items** (array) - Required - A list of configuration items to set within the group. Each item can be a tuple of `{[term()], term()}` or `{[term()], term(), Keyword.t()}`. - **opts** (object) - Optional - Options for the configuration group. - **comment** (string) - Optional - A comment string to add above the group. ### Request Example ```json { "igniter": { ... }, "file_path": "config/config.exs", "app_name": :my_app, "shared_prefix": ["database"], "items": [ {[[:default, :username]], "admin"}, {[[:default, :password]], "secret", [keyword: :value]}, {[[:default, :pool_size]], 10, [updater: fn zipper -> {:ok, zipper} end]} ], "opts": { "comment": "Database connection settings" } } ``` ### Response #### Success Response (200) - **igniter** (object) - The updated Igniter instance. #### Response Example ```json { "igniter": { ... } } ``` ``` -------------------------------- ### Get Dependency Declaration from mix.exs with Igniter Source: https://hexdocs.pm/igniter/Igniter.Project.Deps.html Retrieves the current dependency declaration for a given dependency name from the `mix.exs` file. It returns an `{:ok, nil | String.t()}` tuple if the dependency is found or not present, and `{:error, String.t()}` if an error occurs during retrieval. ```elixir @spec get_dep(Igniter.t(), name :: atom()) :: {:ok, nil | String.t()} | {:error, String.t()} ``` -------------------------------- ### Igniter Task Entrypoint Callback Source: https://hexdocs.pm/igniter/Igniter.Mix.Task.html The main entrypoint for Igniter tasks. This callback accepts and returns an Igniter struct, serving as the primary function to execute task logic. ```elixir @callback igniter(igniter :: Igniter.t()) :: Igniter.t() """ Main entrypoint for tasks. This callback accepts and returns an Igniter struct. """ ``` -------------------------------- ### Get CSS Properties for Selector - Igniter CSS Source: https://hexdocs.pm/igniter_css/IgniterCss.Parsers.Parser.html Retrieves the CSS properties associated with a specific selector within a stylesheet. If the selector exists, it returns a map of its properties; otherwise, it returns nil. Requires CSS code and the selector string as input. ```elixir iex> IgniterCss.Parsers.CSS.Parser.get_selector_properties(css_code, ".header") %{"color" => "blue", "font-size" => "16px"} iex> IgniterCss.Parsers.CSS.Parser.get_selector_properties(css_code, "#nonexistent") nil ``` -------------------------------- ### Copy Template File with Assignments Source: https://hexdocs.pm/igniter/Igniter.html Copies an EEx template file from a source path to a target path, applying provided assignments and options. Accepts the same options as `create_new_file/4`. ```Elixir @spec copy_template( igniter :: t(), source :: Path.t(), target :: Path.t(), assigns :: Keyword.t(), opts :: Keyword.t() ) :: t() Copies an EEx template file from the source path to the target path. Accepts the same options as `create_new_file/4`. ```