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 🙏

© 2026 – Pkg Stats / Ryan Hefner

generate-structure

v0.0.7

Published

[![Dependency Status](https://david-dm.org/tugaybaltaci/generate-structure.svg)](https://david-dm.org/tugaybaltaci/generate-structure) [![devDependency Status](https://david-dm.org/tugaybaltaci/generate-structure/dev-status.svg)](https://david-dm.org/tuga

Readme

Dependency Status devDependency Status npm version Downloads

Structure Generator

Structure generator lets you create multiple code templates/structures to use continuously in your projects.

You can create any code template in any language. You just need to have NodeJS.

Note: This repository is still work in progress.

Install

via npm

npm install generate-structure

via yarn

yarn add generate-structure

Usage

There are several ways to use structure generator.

1. Javascript (NodeJS)

Javascript way is allows you to change options like variableTemplate or initial variables.

const GenerateStructure = require('generate-structure');

// GenerateStructure(name: string, templatePath: string, variables: object, options: object)
const generator = new GenerateStructure("test", "example-templates/test.html", {
  // variables
  foo: 'bar'
}, {
  // options
  variableTemplate: '%var%' // `var` is keyword of variable
});

generator.run();

2. CLI

If you don't need to change options then you can use CLI tools.

via npx

$ npx generate-structure [name] -t [templatePath]

via yarn

$ yarn generate-structure [name] -t [templatePath]

via package.json scripts

  "scripts": {
    "generate:component": "npx generate-structure -t path/to/template.html"
  }

This allows you to use command like yarn generate:component component-name to create template.

Using global

$ yarn global add generate-structure

or

$ npm -g i generate-structure

and run

$ generate-structure -t [path/to/template.html] [name]

Creating Template

Writing template is very simple. You have 3 tags to create a template.

  • gs:root
  • gs:file
  • gs:script

What will happend?

| input | output | | - | - | | Input | Input |

Root

gs:root tag accepts single attribute for now. It is out attribute which defines root folder of structure.

<gs:root out="test/%name%-folder">
  <gs:file name="..."></gs:file>
  <gs:file name="..."></gs:file>
  <gs:file name="..."></gs:file>
  <gs:script></gs:script>
</gs:root>

File

gs:file tag accepts single attribute which is name. name attribute defines file name and you can use variables in.

<gs:file name="%name%.js">
  function %name%Func() {
    return "test ok"
  }
</gs:file>

<gs:file name="%name%.css">
  /* This is a css file */
  .%name%Class {
    /* your css */
  }
</gs:file>

<gs:file name="%name%.html">
  <!-- This is an html file. I hope that will be included in output. -->
  <div class="%name%Class" onload="%name%Func();">
    <h1>Hello world.</h1>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ab mollitia quis voluptatum molestiae, animi molestias aut. Cum dignissimos maxime minima tempora. Asperiores dolor ipsam modi aliquid ea nobis blanditiis sint?</p>
    <img src="%name%.png" alt="%name%">
    <p>
      Eius excepturi itaque distinctio explicabo necessitatibus nemo impedit dicta amet, doloremque provident adipisci delectus porro eligendi architecto laudantium enim officiis? Natus quae ducimus dolores necessitatibus excepturi quam asperiores saepe odit?
    </p>
  </div>
</gs:file>

Script

StructureGenerator has a simple API that lets you create or modify variables with javascript in gs:script tag.

StructureGenerator object has 3 properties;

| variable | description | |-|-| | name | Represents file name | getVariable | Brings the variable by given name | setVariable | Defines a variable according to given key and value

<gs:script>
  // These variables can use in everywhere of template including filename.

  const {name, getVariable, setVariable} = StructureGenerator;
  const capName = name.split('-').map(x => x.charAt(0).toUpperCase() + x.slice(1)).join('');

  // Set new variable named `capName`
  setVariable('capName', capName);
</gs:script>

Dependencies

| package | version | description | |-|-|-| | "command-line-args" | ^5.0.2 | For use cli tool, I'm still working on. | "shelljs" | ^0.8.3 | For creating and modifying files or folders.