paternator
helper for create easyli component on canopy
Last updated 3 years ago by korvus .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install paternator 
SYNC missed versions from official npm registry.

README

Allow to create easily a component automatically inside a react architecture, or any javascript package project.

Installation

npm install paternator -D

:::info -E is for dev dependencies. :::

-D is for dev dependencies.

setup paternator

You got two choices.

  • 1 Into your package.json file, from your project:
  "paternator": {
    "models": "models/files.js",
    "path": "app/"
  },

This usage is much faster, prefer it.

  • 2 Inside a json in your project, named conf.paternator.json
{
	"paternator": {
		"models": ["models/files.js", "an/other/pattern.tpl"],
		"path": "app/"
	}
}

models : (string) path to the special file (see bellow) wich contains all the files to duplicate.

path : (string or array) folder path where all the patern will be duplicate. If you pass an array, it mean you have differents pattern available. Then, you will be abble to choose the pattern of your choices by a dialog box.

files.js (models)

files.js contain a kind of "map" / "plan" of the files you want to generate automatically.

It's a json object, where each json will be the future files.

Each json object have two parts, both are strings. First is the name of the futur file, second its content.

Example :

exports.entrance = ['index.js',`
import React from 'react';
import s from './[name].css';

const [Name] = ({ id }) => (
  <div>
  </div>
);

[Name].propTypes = {
  id: React.PropTypes.number.isRequired,
};

export default [Name];
`];

exports.index = ['[name].css',`
	body{background: #fff;}
`];

This example generate two files, one js file and a css file. The CSS file will have the component name. For using the name to the variables, you just have to use the mask [name], or [Name] if you want it with a majuscule on the first letter. You can also duplicate a full structure if you feel like it by using a path with /. Example:

exports.entrance = ['this/is-a/directory/index.js',`...etc

Use

When you will duplicate the package by CLI, component's name will be asked. From that, a folder with the component's name will be generate automatically to your folder target. Inside this folder, you will found all the files you set up in your models.

I invite to make a npm script shortcut for a better use.

  "scripts": {
    "paternator": "node node_modules/paternator"
  },

resources

https://github.com/korvus/paternator

Current Tags

  • 2.1.8                                ...           latest (3 years ago)

14 Versions

  • 2.1.8                                ...           3 years ago
  • 2.1.7                                ...           3 years ago
  • 2.1.6                                ...           3 years ago
  • 2.1.5                                ...           3 years ago
  • 2.1.4                                ...           3 years ago
  • 2.1.3                                ...           3 years ago
  • 2.1.2                                ...           3 years ago
  • 2.1.1                                ...           3 years ago
  • 2.1.0                                ...           3 years ago
  • 2.0.4                                ...           3 years ago
  • 2.0.3                                ...           3 years ago
  • 2.0.2                                ...           3 years ago
  • 2.0.1                                ...           3 years ago
  • 2.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |