Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    slush-reframepublic

    Slush-reframe Build Status NPM version

    Reframe generator

    Getting Started

    Install slush-reframe globally:

    $ npm install -g slush slush-reframe

    Usage

    Test locally

    Clone the repo and link it (symlink)

    git clone https://github.com/kristianmandrup/slush-reframe.git`
    cd slush-reframe
    npm install
    npm link

    Then go make some new folder and run the generator

    slush reframe

    Create new Re-frame project

    Create a new re-frame project using:

    re-frame-template

    $ lein new re-frame <project-name>

    Note that you can also customize which additional libs to integrate:

    $ lein new re-frame <project-name> +garden +re-com +routes +test

    Populate re-frame project with domain files

    $ cd <project-name>

    Run the generator from within the new project folder:

    $ slush reframe

    Answer the prompts:

    - Name your domain model? todo
     
    - Domain types?
    x item
    x list
     
    - Files?
    x handlers
    x queries
    x subscribers
    x utils
    x views
     
    - Container namespace? app
     
    - Destination path? src/cljs/domain
    + src/cljs/domain/todo/item
    + src/cljs/domain/todo/item/handlers.cljs
    + src/cljs/domain/todo/item/queries.cljs
    + src/cljs/domain/todo/item/subscribers.cljs
    + src/cljs/domain/todo/item/utils.cljs
    + src/cljs/domain/todo/item/views.cljs
     
    + src/cljs/domain/todo/list
    + src/cljs/domain/todo/list/handlers.cljs
    + src/cljs/domain/todo/list/queries.cljs
    + src/cljs/domain/todo/list/subscribers.cljs
    + src/cljs/domain/todo/list/utils.cljs
    + src/cljs/domain/todo/list/views.cljs
     
    + src/cljs/domain/todo/list
    + src/cljs/domain/todo/handlers.cljs
    + src/cljs/domain/todo/queries.cljs
    + src/cljs/domain/todo/subscribers.cljs
    + src/cljs/domain/todo/utils.cljs
    + src/cljs/domain/todo/views.cljs

    These domain files should create a solid foundation for building your domain logic, divided into logical parts that work well with re-frame. The functions and files generated follow conventions that make it easy to navigate and understand your project/code structure.

    Please feel free to customize the templates of the slush generator to best fit your needs...

    Development

    See: building-slush-generator

    The entry point is slushfile.js which configures the tasks, here just the default task domain.

    let tasks = {};
    tasks.default = require('./domain')({});
    gulp.task('default', tasks.default);

    Each sub generator should have its own folder that is linked in slushfile.js in the same fashion as shown above (ie via require).

    The entry point for the domain file sub-generator is domain/index.js Here we ask some questions via prompts which returns with a map of answers. The prompts are handled by inquirer.

    It then either aborts via done or continues depending on the answer to the moveon question.

    inquirer.prompt(prompts,
      function (answers) {
        if (!answers.moveon) {
            return done();
        }
        require('./create-domain-files')(answers);
      }
    );

    Creating and writing domain files

    In create-domain-files.js we first populates answers with a req map of require statements for each type of domain file. The full answers map is available for any template used. These require statements are used in the root templates.

    module.exports = function(answers) {
      answers.req = {};
      for (file in ['handlers', 'queries', 'subscribers', 'utils', 'views']) {
        // ... 

    An output file is generated by:

    • loading a set of templates via gulp.src
    • transferring the answers map Object to the template
    • optionally renaming the name of the file to be output
    • resolving conflict (file already exists)
    • piping file to destination
    function createDomainFiles(type, answers, done) {
      var fileDestination = answers.location + '/' + answers.namespace '/' + answers.domain);
     
      gulp.src(__dirname + '/templates/root/')
          .pipe(template(answers))
          .pipe(rename(function (file) {
              // ... optional rename
          .pipe(conflict('./'))
          .pipe(gulp.dest('./' + fileDestination))

    Customize as you see fit!

    Getting To Know Slush

    Slush is a tool that uses Gulp for project scaffolding.

    Slush does not contain anything "out of the box", except the ability to locate installed slush generators and to run them with liftoff.

    To find out more about Slush, check out the documentation.

    Contributing

    See the CONTRIBUTING Guidelines

    Support

    If you have any problem or suggestion please open an issue here.

    License

    The MIT License

    Copyright (c) 2016, Kristian Mandrup

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    install

    npm i slush-reframe

    Downloadsweekly downloads

    7

    version

    0.1.2

    license

    MIT

    repository

    github.com

    last publish

    collaborators

    • avatar