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

@tomilenko/custom-template-generator

v0.2.6

Published

generate file template

Downloads

6

Readme

notice

This is FORK of custom-template-generator https://www.npmjs.com/package/custom-template-generator

  • Implement the same functionality with TypesScript

custom-template-generator

npm version Downloads/week Donate

Prerequisites

This project has a dependencies that require Node to be installed. For help to install Node, go to:

https://nodejs.org

Table of Contents

Installation

BEFORE YOU INSTALL: please read the prerequisites

npm install @tomilenko/custom-template-generator

Once the plugin has been installed, just need to add this line:


import Generator from '@tomilenko/custom-template-generator';

Usage

import Generator from '@tomilenko/custom-template-generator';

const options = {
    customTemplatesUrl: __dirname + '/templates/',
    type: 'components',
    name: "button",
    dest: 'test',
    template: 'component',
    autoIndent: true
};
new Generator(options);

Options

Scaffold | Type | Usage --- |--- | --- name | string | Name of the generated file/component/project customTemplatesUrl | string | Location of the custom templates folder type | string | Location of the custom types of templates folder dest | string | Destination of generated templates files template | string | Template name autoIndent | boolean | Default set to false, will indent the whole file. Only works with js and ts files. isSingleFile | boolean | Default set to false. If you need to generate one file template wrapInFolder | boolean | Default set to true autoIndentExtensions | array | The list of extensions file to indent. Default ['js', 'ts'] data | object | This custom meta data can be injected in the custom template using '{}'

Directories structure

You should have use the next templates directory structure:

./templates - type - template

For example:

./templates - - projects - expressProject - testProject - components - componentOne - componentTwo

Meta data

The meta data helps customize your templates, here are some options:

Name | Description --- |--- name | Component name Name | capitalized component name

Demo

In this repository, use the demo folder to test the generator. Here is the folder hierarchy:

To help customized the file name {component} will be replace by the componentName defined in the generator parameters.

The following template {component}.interface.ts:

// Angular imports
import { ElementRef, Renderer } from '@angular/core';
// Custom imports
import { {Name}Config } from './config/{name}.config';

export interface {Name}Interface<T> {
    /*
     * Model from the {name}.
     */
    model: T;
    /*
     * Stores config for the {name}.
     */
    readonly options: {Name}Config;
    /*
     * init
     */
    ngOnInit(): void;
}

By running this function

new Generator({
    componentName: "button",
    customTemplatesUrl: './templates/',
    dest: 'src',
    templateName: 'component'
});

Will generate this file

// Angular imports
import { ElementRef, Renderer } from '@angular/core';
// Custom imports
import { ButtonConfig } from './config/button.config';

export interface ButtonInterface<T> {
    /*
     * Model from the button.
     */
    model: T;
    /*
     * Stores config for the button.
     */
    readonly options: ButtonConfig;
    /*
     * init
     */
    ngOnInit(): void;
}

License

MIT