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

lazerpath

v1.2.2

Published

LazerPath helps you to quickly create your project structure and fill it with predefined templates.

Downloads

18

Readme

lazerpath

LazerPath helps you to quickly create your project structure and fill it with predefined templates.

LazerPath should be installed globally

$ npm i -g lazerpath

Options:

  -v, --version  output the version number
  -t, --test     test your paths, no file or folder will be created
  -h, --help     output usage information

You'll need to add a lazerpath.config.js file into the folder you want to process.

Basic Example

Assuming you are into the src folder of a React project,
create a lazerpath.config.js file with the following content.

exports.paths = {
    '/components': {
        '/Header': {
            'Header.js' : '',
            'Header.css': '',
            '/Nav'      : {
                'Nav.js' : '',
                'Nav.css': ''
            }
        },
        '/Main'  : {
            'Main.js' : '',
            'Main.css': ''
        },
        '/Footer': {
            'Footer.js' : '',
            'Footer.css': '',
        }
    },
    '/containers': {},
    '/hoc'       : {},
};

Then run the command "lazerpath" from the terminal,

and you'll get the following structure:

If you try to run the command again you'll get the following messages:

Rules are so simple:
A folder name must always starts with a slash and it must be an object.
An empty object will produce an empty folder.

Valid folder:   '/components': {}
Invalid folder: 'components': {}

A folder can contain files or other folders

'/Header': {
    'Header.js' : '',
    'Header.css': '',
    '/Nav'      : {
        'Nav.js' : '',
        'Nav.css': ''
    }
}

A file can be empty

'Header.js' : ''

Or you can fill it

'Header.js' : 'const my_var = "My Awesome Var";'

You can assign a template to a file

const fs = require('fs');
const mytemplate = fs.readFileSync('/path/to/template/', 'utf8');

'Header.js' : mytemplate

You can also search and replace any part of a template
Template:

import React, {Component} from 'react';
import './MY_COMPONENT.css';

class MY_COMPONENT extends Component {

    render () {
    
        return (
            <div>
                <h1>Title</h1>
            </div>
        );
    }
}

export default MY_COMPONENT;

lazerpath.config.js file:

const fs = require('fs');
const mytemplate = fs.readFileSync('/path/to/template/', 'utf8');

'/Nav': {
    'Nav.js' : [mytemplate, {
        'MY_COMPONENT': 'Nav',
        'Title'       : 'My Awesome Nav Title'
    }],
    'Nav.css': ''
}

Result:

import React, {Component} from 'react';
import './Nav.css';

class Nav extends Component {

    render () {
    
        return (
            <div>
                <h1>My Awesome Nav Title</h1>
            </div>
        );
    }
}

export default Nav;

Explanation:

'Nav.js' : [mytemplate, {
        'MY_COMPONENT': 'Nav',
        'Title'       : 'My Awesome Nav Title'
    }]

In this case the value for the ket 'Nav.js' is not a simple template but an array,
the first array argument is the template file, the second argument is an object where the keys are the parts to search, and the values te parts to replace.

Advanced Example

Here's a complete example

const fs = require('fs');
const mytemplate = fs.readFileSync('./template.js', 'utf8');

exports.paths = {
    '/components': {
        '/Header': {
            'Header.js' : mytemplate,
            'Header.css': '',
            '/Nav'      : {
                'Nav.js' : [mytemplate, {
                    'MY_COMPONENT': 'Nav',
                    'Title'       : 'Nav Title'
                }],
                'Nav.css': ''
            }
        },
        '/Main'  : {
            'Main.js' : [mytemplate, {
                'MY_COMPONENT': 'Main'
            }],
            'Main.css': ''
        },
        '/Footer': {
            'Footer.js' : [mytemplate, {
                'MY_COMPONENT': 'Footer',
            }],
            'Footer.css': '',
        }
    },
    '/containers': {},
    '/hoc'       : {}
};

Test Mode

If you want to test your configuration file before to actually create the paths,
use the command "lazerpath -t" or "lazerpath --test"
lazerpathterminaltest