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

motem

v1.0.4

Published

Simple modular templates generator

Downloads

14

Readme

MOTEM

Simple modular templates generator

Usage

  1. npm i motem -D or yarn add motem -D.
  2. Create a directory for your templates in the root directory e.g.: root/templates.
  3. Create at least one json template, use the following code as a starter:
{
  "name": "Component",
  "description": "Generate a component",
  "add": [
    {
      "dirPath": "src/components/[ModuleName]",
      "files": [
        {
          "fileName": "[ModuleName].tsx",
          "template": [
            "import React from 'react';",
            "import type { [ModuleName]Props } from './[ModuleName].props';",
            "",
            "const [ModuleName] = ({ label }: [ModuleName]Props) => {",
            "  const className = '[module-name]';",
            "  return <div className={className}>{label}</div>",
            "}",
            "",
            "export default [ModuleName];",
            ""
          ]
        },
        {
          "fileName": "[ModuleName].props.ts",
          "template": [
            "export interface [ModuleName]Props {",
            "  label: string;",
            "}",
            ""
          ]
        },
        {
          "fileName": "index.ts",
          "template": [
            "export { default } from './[ModuleName]';",
            ""
          ]
        }
      ]
    }
  ],
  "modify": [
    {
      "filePath": "src/module.ts",
      "lines": [
        {
          "hook": "// IMPORT_MODULE",
          "appendLines": [
            "import [ModuleName] from './components/[ModuleName]';"
          ]
        },
        {
          "hook": "/* ADD_UNION_TYPE */",
          "appendLine": "| '[module-name]'"
        }
      ]
    }
  ]
}
  1. run motem templates.

!Important

  • The magic keyword is [ModuleName], [moduleName], [module-name], [module_name], [MODULE_NAME]. The case will transform the module name that you will pass to it.

Parameters

| Parameter | Type | Required | Description | | ------------------------------ | -------------- | -------- | ------------------------------------------------------------ | | name | String | Yes | The name will be displayed in the cli | | description | String | No | The description will be displayed next to name in the cli | | add | Array | No | Array of files and templates and the directory in which that you want to create | | add[0].dirPath | String | Yes | Relative path(from where motem command will be launched) to directory where the files will be added | | add[0].checkAdditionalDirs | Array | No | Will check if such module exists in other directories than dirPath | | add[0].files | Array | Yes | Array of files and templates that you want to create | | add[0].files.fileName | String | Yes | Enter the file name that will be added use [ModuleName] syntax that will be replaced with user input. | | add[0].files.template | Array | Yes | Write your template for the file here, each new line, should be a new array item. [ModuleName] syntax also works here. | | modify | Array | No | List of files you want to modify | | modify[0].filePath | String | Yes | Relative path(from where motem command will be launched) to the file you want to modify | | modify[0].lines | Array | Yes | Array of a specific object, where you describe the lines you want to add. | | modify[0].lines[0].hook | String | Yes | A string (usually a comment), that will be used to add new lines. NOTE, the hook will be automatically added at the end of your added lines. | | modify[0].lines[0].appendLines | Array | No | Append multiple (or a single) lines. Hook will be added as a new line after your lines. | | modify[0].lines[0].appendLine | String | No | Append an inline string. Hook will be added after a space of your string. |