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

makestuff

v1.3.2

Published

Tiny scaffolding tool for your project

Downloads

12

Readme

makestuff.js

Makestuff is a tiny tool that allows you to create and execute your own simple scaffolding rules for project. You can automatically create boring boilerplate stuff in your project.


Example:

You have an old AngularJS project and you need to create components, modules, routing configs etc, so you need to write a lot of boilerplate code for each file.

Let's try to automate the component generation process!

  • Install the library. npm i -g makestuff
  • In your project root create the file called makesuff.config.js with the following content:
module.exports = {
    commands: [
        {
            // name of your CLI command
            name: "ng-component",
            description: "Generates an AngularJS component",
            // create a directory for your component
            createDirectory: true,
            // You can define your own CLI options.
            // You can use this options in your rules to create files conditionally
            options: {
                name: "-s, --styles",
                description: "create an empty styles file",
            },
            // description of output files
            output: [
                {
                    templatePath: "./templates/component.ejs",
                    name: `component.js`
                },
                {
                    // you can specify only file name, in this case Makestuff will create the empty file for you
                    // this is only a small subset of all features, see the detailed description below
                    name: "_styles.scss",
                    // use the option created above to create files conditionally
                    when: (data) => data.command.optionEnabled("styles")
                }
            ]
        }
    ]
};
  • create the directory called templates
  • create the file templates/component.ejs with the following content:
const template = `<b>Hello, world!</b>`;
const dependencies = [];

class <%=name.pascalCase%>Component {
    constructor() {
    }

    $onInit() {
    }

    $onChanges() {
    }

    $onDestroy() {
    }
}

<%=name.pascalCase%>Component.$inject = dependencies;
<%=name.pascalCase%>Component.controller = <%=name.pascalCase%>Component;
<%=name.pascalCase%>Component.template = template;

export <%=name.pascalCase%>Component;
  • go to your project root and type makestuff ng-component /path/to/your/project/MyFirstTest if you want to generate only component with template, or type makestuff ng-component /path/to/your/project/MyFirstTest --styles if you want to generate component with the additional scss file
  • go to /path/to/your/project/MyFirstTest and check the result! Open the component.js and you'll see somenting like this:
const template = `<b>Hello, world!</b>`;
const dependencies = [];

class MyFirstTestComponent {
    constructor() {
    }

    $onInit() {
    }

    $onChanges() {
    }

    $onDestroy() {
    }
}

MyFirstTestComponent.$inject = dependencies;
MyFirstTestComponent.controller = MyFirstTestComponent;
MyFirstTestComponent.template = template;
  • Voilà! Now you don't have to write all this boring shit manually!

How it works?

TBD

Extended config example

// projectRoot/makestuff.js
const componentGenerator = {
   name: "component", // name for your command
   description: "Generate the component", // description for CLI help
   namingConvention: "PascalCase", // by default
   createDirectory: true, // by default. Tells the engine to create the folder, name based on naming convention
   // Create some extra variables for the command. They will be exposed to the templates inside the object called `custom`
   templateVars: function(input, predefinedVars) {
       // predefinedVars contains a lot of thigns like name in the different cases etc.
       return {
           myOwnVar: 123
       };
   },
   // You can define your own CLI options.
   // You can use this options in your rules to create files conditionally
   options: {
       name: "-s, --styles",
       description: "create an empty styles file",
   },
   // Tells the generator where to put the result files
   output: [
       {
           templatePath: "./templates/component.ejs",
           // yes, you can use function to generate names.
           // In this case you will have access to predefinedVars (fist parameter)
           name: data => `${data.dashedName}.component.ts`
       },
       {
           template: "some file content",
           name: data => `${data.dashedName}.ts`
       },
       {
           name: data => `${data.dashedName}.html` // just create emplty file
       },
       {
           // you can specify only file name, in this case Makestuff will create the empty file for you
           name: "_styles.scss",
           when: (data) => data.command.optionEnabled("styles")
       }
   ],

}

module.exports = {
    commands: [
        componentGenerator
    ]
};