npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

enchup

v0.0.8

Published

Provide commands to create scripts (components) according to templates and config

Downloads

5

Readme

Enchup

Gitter

1. Overview

Easy way to setup application and provide commands to create scripts (components) according to templates and config.

npm install -g enchup

Available commands:

  • setup [options] [repository]
  • init [repository]
  • info [component]
  • create [options] [template]

2. Commands

2.1 Setup

Setup enchup config and templates from repository. Supports only github repositories (format - %username%/%reponame%)

enchup setup <repository>

Flags:

  • -f --force - clean and backup configs and remove templates before setup if they already exists

Could be used at already existing application.

2.2 Init

Initialize application to current directory. Similar to git clone [repository] but remove .git after cloning. Directory should be empty.

enchup init <repository>

2.3 Info

Show all available components or information about certain component: path, parameters map and components list.

enchup info
enchup info [component]

2.4 Create

Create components according to enchup config and templates. All components are described at enchup.yml.

create <component> <parameters> [template]

Flags:

  • -f --force - override components if already exists
  • -c --continue - do not override existing components. Important for components that includes other components

For additional information about component use enchup info [component]

3. Enchup file system

 |-enchup/
    |-enchup.yml
    |-user-enchup.yml
    |
    |-templates/
  • enchup/enchup.yml - main config
  • enchup/user-enchup.yml - user enchup config. Should be ignored by cvs
  • enchup/templates - Handlebars templates for components

4. Enchup config: enchup.yml

4.1 Config overview

There are three main blocks at enchup.yml:

  • parameters
  • base
  • components

4.2 Parameters

Any data that will be available for template rendering.

4.3 Base

Base path for all components

4.4 Components

Array of components that could be created by enchup.

For example:


base: /src/js
components:
  controller: /:screen/controllers/:controller.js
  view: /:screen/view/:view.html

  screen:
    map: screen:controller:route
    components:
      - controller
      - view

  landing:
    map: screen:controller:route
    provide:
        controller: :screen
    components:
      - controller
      - template:landing

Components could be described as string or object. At example above:

  • controller - described as string where all parameters are in path
  • screen - described as object.

Options for definition as object are:

  • map - parameters that should be described when run enchup create command
  • path - component path
  • components - list of the components and its template that also will be created
  • provide - additional parameters list. Could be added as constants or links for specified parameters

Run enchup info [component] to get detailed info about how to create component.

enchup create controller user:profile

Will create script /user/controllers/profile.js with controller's default template /enchup/templates/controller.hbs

enchup create screen user:profile:/profile.html

Will create scripts:

  • /user/controllers/profile.js with controller's default template /enchup/templates/controller.hbs
  • /user/templates/profile.html with default view's default template /enchup/templates/view.hbs
enchup create landing frankland:/frankland.html

Will create scripts:

  • /frankland/controllers/frankland.js with controller's default template /enchup/templates/controller.hbs
  • /frankland/view/frankland.html with template landing /enchup/templates/landing.hbs or if not exist

5. Custom config: user-enchup.yml

This is just user's enchup config that should be ignored by vcs. Need for developers's paramaters such as: {{ name }}, {{ email }}, {{ homepage }} etc.

6. Templates

6.1 Overview

Enchup is trying to find tempalate at /enchup/templates/<template>.hbs. If template is not described for component then template's name will be same as component's name.

Handlebars is using for template rendering. There are available few helpers:

  • ucfirst - lowercase expression's value and uppercase first word
  • uppercase - uppercase expression's value
  • lowercase - lowercase expression's value
  • tail - split expression's value by '/' symbol and use last one
  • dots - lowercase and replace '/' by '.'

For example: You have component controller that is described as controller: /app/controllers/:screen/:controller and you use command enchup create controller user:profile/friends In this case template "{{ tail controller }}" will be rendered as "friends" and "{{ ucfirst (tail controller }})" will be rendered as "Friends"

All components parameters are available at template. And there is one always existing parameter - {{ date }}.

Also there are parameters object form enchup.yml and all from user-enchup.yml available at templates.

6.2 Example

According to this config:

components:
  controller: /:screen/controllers/:controller.js

and this template:

/**
 * @date {{ date }}
 * @author {{ author }}
 * @version {{ version }}
 * @application {{ application }}
 */
import BaseController from 'valent/base/controller';
import { Controller } from 'valent';
import {{ ucfirst (tail controller) }}Template from './{{ tail controller }}.html';

class {{ ucfirst (tail controller) }}Controller extends BaseController  {
  constructor(Scope) {
    super(Scope);
  }

  getName() {
    return '{{ screen }}.{{ controller }}';
  }
}


Controller('{{ screen }}.{{ controller }}')
  .route('{{ screen }}/{{ tail controller }}.html')
  .template({{ ucfirst (tail controller) }}Template)
  .src({{ ucfirst (tail controller) }}Controller);

and this command:

enchup create controller user:profile

Enchup will create this script:

/**
 * @date 2015-03-18 11:45:10
 * @author tuchk4
 * @version
 * @application
 */
import BaseController from 'valent/base/controller';
import { Controller } from 'valent';
import ProfileTemplate from './profile.html';

class ProfileController extends BaseController  {
  constructor(Scope) {
    super(Scope);
  }

  getName() {
    return 'user.profile';
  }
}


Controller('user.profile')
  .route('/user/profile.html')
  .template(ProfileTemplate)
  .src(ProfileController);

7. API

All commands available from api.

var Enchup = require('enchup')

Enchup.setup(repository, option);
Enchup.init(repository, options);
Enchup.info(component);
Enchup.create(component, parameters, template, options);

8. Future plans

  • rewrite code on ES6
  • add -d --dry-run option
  • think again about enchup functions: remove unneeded and add more useful
  • bug fixing

9. Yo

You are welcome for contributing and bug reporting :) Help to make enchup better <3 Also you are welcome to any questions and discussing at glitter chat.

Gitter