Skip to content

enva-projects/enva-creator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

enva-creator

Enva-Creator is responsible for generating files and folders based on variables which are being asked users.

Installation

$ npm i -g @enva/creator
$ yarn global add @enva/creator

Usage

First you need to create a folder with the name of .enva and put a folder called creator in it. After that you can use enva-creator in 2 different concepts: standAlone and withController.

StandAlone

For example you create component.enva file in the .enva/creator:

<%
  $NAME = ask('What is the name of the component?');
%>

import React from 'react';

export default function <=$NAME>(){
  return (<></>)
}

<%
  output($NAME + '.js');
%>

And after that do:

import envaCreator from '@enva/creator';

envaCreator('component');

WithController

Create a folder inside the .enva/creator and put a file called controller.enva in it.

Controller is responsible for asking questions and deciding which file to execute. For example:

// .enva/creator/component/controller.enva

$NAME = ask('What is the component name?');
$TYPE = ask('What is the type of it?');

// Will create dir with the name of $NAME
dir($NAME);

if($TYPE === 'functional'){
  // Will execute and put functional.enva inside $NAME
  exec('functional.enva', {
    NAME: $NAME
  }, $NAME);
} else {
  exec('class.enva', {
    NAME: $NAME
  }, $NAME);
}
// .enva/creator/component/functional.enva

import React from 'react';

export default function <=$$NAME>(){
  return (<></>);
}

<%
  output('index.js');
%>
// .enva/creator/component/class.enva

import React from 'react';

export default class <=$$NAME>{
  constructor(props){
    super(props);
  }
  render(){
    return (<></>);
  }
}

<%
  output('index.js');
%>

Use with @enva/cli

Install @enva/creator and add this to the .envarc:

{
  "plugins": [
    {
      "name": "@enva/creator",
      "command": "ec"
    }
  ]
}

And after that it will be available like:

$ enva ec <FILENAME>

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published