GithubHelp home page GithubHelp logo

mix_generator's Introduction

Mix Generator—An alternative project generator for Mix

Generate skeleton directories and files for new Elixir projects of various styles. This is the same idea as mix new, mix nerves.new, mix phoenix.new, but all under one roof. It is also open ended—anyone can write a new template, and anyone can publish a template for others to use.

Install

$ mix archive.install hex mix_templates
$ mix archive.install hex mix_generator

Then you can install templates using:

$ mix template.install «template-name»

How do you find templates?

$ mix template.hex

Use

  • $ mix gen --help | -h

    Show this information

  • $ mix gen --list | -l

    Show locally installed templates. Same as mix template list

  • $ mix gen «template-name» --help

    See specific information for «template-name»

  • $ mix gen «template-name» «project-name» [ options ... ]

    Generate a new project called «project-name» using the template «template-name». This will be created in a directory with the same name as the project. By default, this directory will be created under the current directory. This can be overridden with the --into option, which specifies a new containing directory.

Options:

As well as --into «dir» each individual template may define its own set of options. For example, the project template will have its own options for creating supervised apps and so on.

Use mix gen «template-name» --help to see a list of these options.

Examples

$ mix gen project simple_app

$ mix gen project super_app --supervised --into ~/projects/

mix_generator's People

Contributors

danielberkompas avatar mbramson avatar pragdave avatar tokubass avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mix_generator's Issues

Template is still generated if a child template fails

We ran into some confusion when we attempted to generate one of our hierarchical templates into an existing directory.

This template has 3 layers of hierarchy. The lowest-level template failed with Error: Updating an existing project is not yet supported but the rest of the child templates proceeded to generate successfully because the maybe_invoke_based_on func sets the :force option after generating a based_on template.

This made it appear like the gen was successful and it took some time to realize why some things were missing from the generated output.

Perhaps there are some use cases where this is desirable, but from my perspective, I'd prefer to see the mix task fail more completely when any of the templates fail to generate.

MixTemplates.Specs.accumulate_specs/1 is accumulate_specs/2

After mix archive.installing mix_generator and mix_templates (and then installing the project template via mix template.install), running mix gen project myapp results in this error:

[aseigo@localhost src]$ mix gen project foo
** (UndefinedFunctionError) function MixTemplates.Specs.accumulate_specs/1 is undefined or private. Did you mean one of:

  * accumulate_specs/2

MixTemplates.Specs.accumulate_specs(Mix.Gen.Template.Project)
lib/mix/tasks/gen.ex:155: Mix.Tasks.Gen.build_options/2
lib/mix/tasks/gen.ex:137: Mix.Tasks.Gen.generate_project/4
(mix) lib/mix/task.ex:294: Mix.Task.run_task/3
(mix) lib/mix/cli.ex:58: Mix.CLI.run_task/2

And indeed, in MixTemplates.Specs we see:

def accumulate_specs(template, base_option_specs) do

but in build_options(template, args) in lib/mix/tasks/gen.ex there is:

specs = Specs.accumulate_specs(template)

.... not sure if you want to provide a default for base_option_specs or pass in an empty list from build_options (otherwise I'd throw you a one-liner patch :)

Error when installing archive

Hey,
Trying to install your generator, but installer blows up. Perhaps that has something to do with using Elixir 1.7.0-dev version. Here's the stacktrace:

mix archive.install hex mix_templates
==> Elixir.Mix.Local.Installer.Fetcher
Resolving Hex dependencies...
Dependency resolution completed:
  mix_templates 0.2.1
  private 0.1.1
* Getting mix_templates (Hex package)
  Checking package (https://repo.hex.pm/tarballs/mix_templates-0.2.1.tar)
  Using locally cached package
* Getting private (Hex package)
  Checking package (https://repo.hex.pm/tarballs/private-0.1.1.tar)
  Using locally cached package
==> private
Compiling 1 file (.ex)
Generated private app
==> mix_templates
Compiling 8 files (.ex)
warning: variable "url" is unused
  lib/mix/tasks/template.hex.ex:79

** (ArgumentError) argument error
    :erlang.get_module_info(Hex.API.Package, :deprecated)
    (hex) Hex.API.Package.__info__/1
    (mix) lib/mix/tasks/xref.ex:335: Mix.Tasks.Xref.load_exports_and_deprecated/1
    (mix) lib/mix/tasks/xref.ex:326: Mix.Tasks.Xref.load_exports_and_deprecated_into_acc/2
    (elixir) lib/enum.ex:1901: Enum."-reduce/3-lists^foldl/2-0-"/3
    (mix) lib/mix/tasks/xref.ex:295: anonymous fn/2 in Mix.Tasks.Xref.source_warnings/2
    (elixir) lib/enum.ex:1901: Enum."-reduce/3-lists^foldl/2-0-"/3
    (mix) lib/mix/tasks/xref.ex:291: Mix.Tasks.Xref.source_warnings/2

mix template.hex blowing up

installed the generator and templates ... then got this

Are you sure you want to install "mix_generator-0.1.9.ez"? [Yn] y
* creating /home/john/.mix/archives/mix_generator-0.1.9
john@John-Ubuntu:~/git$ mix template.hex
** (UndefinedFunctionError) function Hex.API.Package.search/1 is undefined or private. Did you mean one of:

      * search/2

    (hex) Hex.API.Package.search("gen_template")
    lib/mix/tasks/template.hex.ex:15: Mix.Tasks.Template.Hex.run/1
    (mix) lib/mix/task.ex:301: Mix.Task.run_task/3
    (mix) lib/mix/cli.ex:75: Mix.CLI.run_task/2
    (elixir) lib/code.ex:376: Code.require_file/2

What is the "Private" module for?

I'm sure it's just a closed-source helper, but what does this module actually provide? Is it required that users of mix_generator have access to the module? Should potential contributors know what it's doing? In either case, I'd appreciate some documentation about it somewhere in the readme potentially.

I ask only out of curiosity; if you'd rather it stay secret, that's totally fine. 😄

Options for a template are not showing when `--help` is passed

So I installed the mix_generator and mix_templates mixtures.
Then installed the project template:

mix gen --list

Locally installed templates:
project:
        Simple template for projects (with optional app and supervision)

Even made a little project - worked just fine.

Tried to see the available options as per the README.md documentation with mix gen project --help.

I get

ERROR: missing name of project

It doesn't parse the --help option. By the way mix template project --help doesn't work either.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.