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

xcaffolder

v0.1.3

Published

**_xcaffolder_** is a simple tool to create quick scaffolds that may include folders structure and files. The idea is allowing the user to define folders and files in a JavaScript template generator, without having to depend on more complex tools like Yeo

Downloads

1

Readme

xcaffolder

xcaffolder is a simple tool to create quick scaffolds that may include folders structure and files. The idea is allowing the user to define folders and files in a JavaScript template generator, without having to depend on more complex tools like Yeoman or similar generators.

Installation

npm i -g xcaffolder

The config file

In order to work properly, xcaffolder needs a really simple JSON config file called .xcaffoldrc. For the time being, it consists of just one key, pointing to the dir where the user stores the template generators.

The template generator

This is just a JS module that exports two things:

  1. A function called generateTemplate, which receives params (sent by xcaffolder) and returns an object or an array containing the folder structure or files list, respectively.
  2. A string indicating the path in which these files and folders should be created.

A basic example, without any params:

module.exports = {
  generateTemplate: () => {
    return [
      'schema.gql',
      'resolver.js'
    ]
  },
  path: 'example/path/',
}

A more complex example, with a base dir, which name is set through params:

module.exports = {
  generateTemplate: ([ baseDir ]) => {
    return {
      [baseDir]: [
        'schema.gql',
        'resolver.js'
      ]
    }
  },
  path: 'example/path/',
}

As you would expect, you may process the generator params any way you need, since it's just a JavaScript function, as long a you return an array or object that can be understood by xcaffolder.

The arguments

For the time being, the only way of sending arguments to the template generator is from the command line, as a comma-separated list, so basically you can just send strings and numbers. I made it like this because the idea is to send just a few arguments, like the base dir or maybe a couple filenames. If in future versions I see the need to send more arguments, I will have to rethink this.

You can send arguments like this:

xcaffolder baseDir,aFilename,anotherFilename

And you will receive them like this:

module.exports = {
  generateTemplate: ([ baseDir, file1, file2 ]) => {
    return {
      [baseDir]: [ // 'baseDir'
        file1,     // 'aFilename'
        file2      // 'anotherFilename'
      ]
    }
  },
  path: 'example/path/',
}

Which will create the following structure:

example/path/baseDir
example/path/baseDir/aFilename
example/path/baseDir/anotherFilename

Running xcaffolder

Running xcaffolder is quite straightforward. All you need is the .xcaffoldrc config file, a folder with at least one template generator and you're ready to go!

You should run it from the folder containing the config file, otherwise xcaffolder wouldn't be able to find the templates generators folder.

Besides the arguments list that is passed to the generator, you may also add the "-d" option, which will make xcaffolder run in "dry mode". This option will output a preview of the structure that will be generated, without actually creating it.

Features future me may implement

  • Files content templates
  • Better way of sending cli arguments

Collaborating

Don't hesitate to contact me at paulmdorr.me/contact if you have suggestions or questions. Also, feel free to create a new issue or make a pull request on the github repo!