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

sff-tool

v0.1.4

Published

Scaffolding Tool - CLI

Downloads

7

Readme

SFF Tool (Scaffolding Tool)

SFF-Tool es un CLI escrito en Node JS, nos permite generar código a partir de plantillas y de funciones de node js, tiene como objetivo estructura un proyecto, conservando el estilo de arquitectura o patron dado.

Motivación

Diseña un código una vez y permite que este CLI construya la estructura que puede ser repetible, escalable y mantenible. Puedes diseñar una forma de generar código sin limitarse a los CLI que existe actualmente. No existirá limitaciones sobre lo que podrás definir.

Instalar de forma Global

npm install sff-tool -g
sff-tool -v

Iniciar

Para iniciar debes construir la estructura de carpetas para el scaffolding, debe estar a nivel de tu proyecto o nivel superior, usa el siguiente comando:

sff-tool -c

Definiciones de carpetas

Scaffolds

En esta carpeta se diseñan las entradas que se requiren para la generación del código, son input para las ejecuciones del script del comando. Esta función debe tener la siguiente estructura:

scaffolds/react-component.js

module.exports = {
  templates: ["index"],
  command: "generater-component",
  questions:
    [
      {
        name: "component",
        type: "input",
        message: "¿Nombre del component?",
        transformer: (data) => {
          return data.charAt(0).toUpperCase() + data.slice(1)
        }
      }
    ]
};
  • El atributo questions es el prompt del modulo Inquirer.
  • El atributo command hace referencia al script de la carpeta commands
  • Y el atributo templates es un arreglos donde se mapea las variables de entrada con un .tpl que esta definido en la carpeta templates.

Commands

La carpeta commands es donde se guarda las funciones que se deben ejecutar según varias entradas.

commands/generater-component.js

module.exports = (shell, temps, answers) => {

    const dir = "src/component/"+answers['component'];
    shell.mkdir("-p", dir);
    shell.ShellString(temps["index"]).to(dir+"/index.js");

    return "OK";
}

ARGUMENTOS

  • shell: este objecto hace referencia al modulo Shell donde puedes realizar diferentes instrucciones de comandos.
  • temps: es una lista mapeada de todos los templates.
  • answers: es un mapa que contiene las respuestas del prompt.

Templates

En este directorio encontramos todos los templates que puede ser usados para generar código o esqueletos. Un .tpl tiene la siguiente forma:

templates/index.tpl

import react from "react";

class {{component}}Component extends react.Component {
    construct(){

    }
    render(){
        return <p />
    }
}

Las variables de las entradas del prompt, y son definidas con las llaves. Son archivos planos.

¿Cómo lanzar el scaffolding?

El nombre del archivo que se tiene en la carpeta scaffolds es el nombre del comando que se debe lanzar, ejemplo:

sff-tool react-component

Donde react-component hace referencia a scaffolds/react-component.js

NOTA: Puedes ver todos los comandos usando:

sff-tool --help