Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

templates #3

Closed
akoenig opened this issue Jan 20, 2015 · 7 comments
Closed

templates #3

akoenig opened this issue Jan 20, 2015 · 7 comments

Comments

@akoenig
Copy link

akoenig commented Jan 20, 2015

@danielstjules, what do you think of a template feature? Something where you can define CommonJS-style modules for repeating filter/map/reduce tasks, like:

~/.config/pjs/templates/debug-log.js

module.exports = function template (pjs) {
    return pjs
        .filter(function (item) {
            return !!~item.indexOf('DEBUG');
        })
        .map(function (item) {
            return "Found debug entry: " + item;
        });

        // omitting "reduce" here ...
};

could be used in pjs as:

tail -f ~/logs/*.log | pjs -t debug-log
@danielstjules
Copy link
Owner

Interesting idea! Do you think there's major benefits over just letting people define their own alias?

alias debug="pjs -e -f \"!!~$.indexOf('DEBUG')\" -m '\"Found debug entry: \" + $'"

@akoenig
Copy link
Author

akoenig commented Jan 20, 2015

They are easier to read and extendable with the help of the npm ecosystem :) A template author could use external modules for doing crazy manipulations (for example).

The consequence will be that pjs should provide an install step where all the dependencies will be fetched.

@danielstjules
Copy link
Owner

Hm, I like that idea. Though I don't think I'd have pjs run an install step. That would mean either:

  • Keep a node_modules in the templates dir, and parse each template for require statements, installing modules as necessary. This isn't ideal as it doesn't handle versioning.
  • Require some sort of package.json somewhere from which the user must run npm install, and load from there. This isn't great, as it imposes some messy organization/configuration.
  • Or require that templates themselves be modules. Then they could be installed via pjs install pjs-template-name, which would simply run npm install in the .config/pjs directory.

I'm undecided as to which solution would be ideal. Of course, the alternative to any of the above would be to let the user manage their own dependencies for their templates, installing them globally under their user just as pjs is done.

@danielstjules
Copy link
Owner

@akoenig any thoughts on the above?

@akoenig
Copy link
Author

akoenig commented Jan 22, 2015

Hm, hard to say how to handle this scenario. I think that I tend to install pjs templates globally (like yeoman generators) which might have the positive effect of creating a new pjs-* ecosystem with useful template modules .. hehe

@bradparks
Copy link

sounds like a good idea to me as well!

@danielstjules
Copy link
Owner

Closing because I don't think anyone actually uses this project haha Though PRs are certainly welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants