New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

generathor-testing

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

generathor-testing

Use this to generate whatever you want from whatever

  • 1.0.10
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Generathor Logo

Generathor

Generathor is a tool to create files based on different sources.

Why use Generathor?

When you create multiple files based on something you can make some mistakes. So, the best way to create those files is to find a way to create them automatically.

How does it work?

There are two things to keep in mind for Generathor to work: Sources and Templates.

Sources

We use sources to load data. To create new ways to load data, you need to create a class that extends our base Source class.

const { Source } = require("generathor");

class DBSource extends Source {
  constructor() {
    super();
  }

  async load() {
    //Code here
  }

  items() {
    return this.$items;
  }

}

Templates

In order to create one file or one group of files you need to specify one template, and you can set more than one template to process. You need to associate the template with some source, and create the template file using handlebars.

Using Generathor

  1. Installation

    $ npm i -D generathor
    
  2. Create generathor.config.js in root path

    const path = require('path');
    const { ArraySource, TemplateForItem, TemplateForItemGroup } = require('generathor');
    
    module.exports = {
      sources: {
        db: new ArraySource([
          {
            table: 'table_1',
            columns: ['id', 'name'],
          },
          {
            table: 'table_2',
            columns: ['id', 'status'],
          }
        ])
      },
      templates: {
        models: new TemplateForItemGroup({
          template: './templates/export-models.handlebars',
          source: 'db',
          file: './result/index.js',
        }),
        'export-models': new TemplateForItem({
          template: path.resolve('./templates/model.handlebars'),
          source: 'db',
          directory: path.resolve('./result'),
          fileName(item) {
            return item.table + '.js';
          },
        }),
      },
    };
    
  3. Run the script

    $ generathor
    

    To check more options run:

    $ generathor --help
    

Ecosystem

TBD

FAQs

Package last updated on 19 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc