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 🙏

© 2025 – Pkg Stats / Ryan Hefner

create-tree

v1.3.0

Published

Help to creating a work dir tree.

Readme

create-tree

Create-tree is a tool that helps us to create a working directory.

examples

Once you install create-tree through npm, you can use the create-tree command in npm script.

Add create-tree to you npm script command.

package.json:

{
  "scripts": {
    "ctree": "create-tree",
  }
}

Also, you need to provide a ctree.config.js in root path.

ctree.config.js:

let folder = {
	'page': {
		'module': {
			'mod': {},
			'utils': {},
			'preloadindex.inline': 'js',
			'firstscreenindex.inline': 'js',
			'index.async': 'js',
			'index': 'shtml'
		}
	}
}

module.exports = {folder}

Then, just run npm run ctree, you will create a directory structure in root path like this:

example directory

update

  • 2017-4-24: you can now provide a list of ext, create-tree can generate all files of this ext's list.
let folder = {
	'index': ['html', 'css', 'js']
}

module.exports = {folder}

configuration

All configurations of create-tree are written in ctree.config.js.This config file should put in where you want to create this directory structure and run create-tree npm script command.

Config you own directory structure

Every ctree.config.js should exports the folder object to specify the directory structure that you want to create.

In folder object:

  • create a foder: key stand for foder's name and value must be a Object.
  • create a file: key stand for file's name and value must be a String which stand for this file's ext.

example

ctree.config.js:

let folder = {
	'modules': {},
	'index': 'js'
}

module.exports = {folder}

With the configuration above, we can create a folder named 'modules' and index.js in current path.

Also, if the folder or file already exists, create-tree will skip them.

Dynamically replace folder's or file's name

You can replace some folders or files's name when running the npm script, the only thing you need to do is to provide the replacement arguments.

example

ctree.config.js:

let folder = {
	'src': {
		'pages': {
			'modules': {}
		}
	}
}

module.exports = {folder}

If you want to replace folder's name from 'module' to 'index' dynamically, you just need to provide an arguments to npm script like this:

npm run ctree -- "src.pages.modules:index"

alias

Like the example above, sometimes the item we want to replace is very deep. It's very boring to tap a long string like "src.pages.modules:index" everytime.

Create-tree has a alias function to avoid that by exports an alias Object.

ctree.config.js:

let folder = {
	'src': {
		'pages': {
			'modules': {}
		}
	}
}

module.exports = {
	folder: folder,
	alias: {
		module: 'src.page.module'
	}
}

Then, we can replace 'module' to 'index' like this:

npm run ctree -- --module index

Actually, you can let this command shorter using the npm script.

generate file's default content with templates

You can provide some file's templates in folder: ctree_tpl, then specify which file need this template to generate its' content.

Notice that the file and its' template must has a same name and ext.

examples

ctree.config.js:

let folder = {
	'page': {
		'module': {
			'index': 'shtml'
		}
	}
}

module.exports = {
	folder: folder,
	templates: [
		"/page/module/index.shtml"
	]
}

installation

Notice: the nodejs version must >= 6.0.0

With npm:

npm install create-tree