0.2.7 • Published 1 month ago

@armit/generate-template-files v0.2.7

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

@armit/generate-template-files

A simple generator that is independent of any language. Create custom boilerplate, scaffolding, skeleton, and templating code files that you need to create over and over again. All you need is NodeJS installed to get started.

Install globally

  • npm install @armit/generate-template-files
  • yarn add @armit/generate-template-files

Module/Programmatic Usage

  1. Create a file called generate.mjs( Note that this file name is flexible).
  2. In that file, add in the example code below.
  3. Run node generate.js within Terminal (Mac) or Powershell (Win) once you've added your template files.
import { generateTemplateFiles } from '@armit/generate-template-files';

const config = require('../package.json');

generateTemplateFiles([
  {
    option: 'Create Redux Store',
    defaultCase: '(pascalCase)',
    entry: {
      folderPath: './tools/templates/react/redux-store/',
    },
    stringReplacers: [
      '__store__',
      { question: 'Insert model name', slot: '__model__' },
    ],
    output: {
      path: './src/stores/__store__(lowerCase)',
      pathAndFileNameDefaultCase: '(kebabCase)',
      overwrite: true,
    },
  },
  {
    option: 'Create Reduce Action',
    defaultCase: '(pascalCase)',
    entry: {
      folderPath: './tools/templates/react/redux-store/__store__Action.ts',
    },
    stringReplacers: ['__store__', '__model__'],
    dynamicReplacers: [
      { slot: '__version__', slotValue: config.version },
      { slot: '__description__', slotValue: config.description },
    ],
    output: {
      path: './src/stores/__store__/__store__(lowerCase)/__store__(pascalCase)Action.ts',
      pathAndFileNameDefaultCase: '(kebabCase)',
    },
    onComplete: (results) => {
      console.log(`results`, results);
    },
  },
]);

As outlined in the examples folder, I prefer to create a tools folder and place generate.js w/ templates files in there. Additionally, I'll add a script task ("generate": "node ./tools/generate.ts") to my package.json file for convienent running of the generator using npm run generate or yarn generate.

┣━ package.json
┣━ src
┗━ tools/
   ┣━ generate.ts
   ┗━ templates/
      ┣━ SomeFile.ts
      ┗━ __name__(pascalCase)Action.ts

Contributing

Contributions are happily accepted. I respond to all PR's and can offer guidance on where to make changes. For contributing tips see CONTRIBUTING.md

0.2.7

1 month ago

0.2.6

3 months ago

0.2.1

5 months ago

0.2.0

5 months ago

0.2.3

5 months ago

0.2.2

5 months ago

0.2.5

4 months ago

0.2.4

4 months ago

0.1.5

6 months ago

0.1.4

8 months ago

0.1.3

10 months ago

0.1.2

10 months ago

0.1.1

12 months ago

0.1.0

12 months ago

0.0.40

1 year ago

0.0.41

1 year ago

0.0.37

1 year ago

0.0.38

1 year ago

0.0.39

1 year ago

0.0.35

1 year ago

0.0.36

1 year ago

0.0.30

1 year ago

0.0.31

1 year ago

0.0.32

1 year ago

0.0.33

1 year ago

0.0.34

1 year ago

0.0.26

1 year ago

0.0.27

1 year ago

0.0.28

1 year ago

0.0.29

1 year ago

0.0.20

2 years ago

0.0.21

2 years ago

0.0.22

2 years ago

0.0.23

2 years ago

0.0.24

2 years ago

0.0.25

2 years ago

0.0.16

2 years ago

0.0.17

2 years ago

0.0.18

2 years ago

0.0.15

2 years ago

0.0.12

2 years ago

0.0.13

2 years ago

0.0.14

2 years ago

0.0.11

2 years ago