Skip to content

Instantly share code, notes, and snippets.

@H4ad
Last active February 28, 2023 23:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save H4ad/bc6e6f2af449942b8cd1b8220aa4adb9 to your computer and use it in GitHub Desktop.
Save H4ad/bc6e6f2af449942b8cd1b8220aa4adb9 to your computer and use it in GitHub Desktop.
TP Template
# the description that will be shown during "tp list"
description: "My simple template"
# Where we can get this template
# installUrl:
# commands that will be read by tp
generate:
# name of your resource
# this will be exposed like: tp generate setup <name>
setup:
description: "Initialize the API with some files"
structure:
# inside your resource, you can specificy which files will be created
# it will be relative to the CLI, and you can specificy sub-folders by just putting folder/file
src/$PARAM_SINGULAR_NAME$.api.js:
content: |-
const express = require('express');
const router = express.Router();
router.get('/$NAME$', (req, res) => res.json(JSON.parse({ hello: 'World' })));
module.exports = router;
src/index.js:
content: |-
const $CAMEL_SINGULAR_NAME$ = require('$PARAM_SINGULAR_NAME$.api');
const express = require('express');
const app = express();
app.use('/$NAME$', $CAMEL_SINGULAR_NAME$);
app.listen(3000);
README.md:
content: |-
# Simple API
This is an example of how this could work.
## Docs
To customize the file content during generation, you can use the above variables:
- `NAME`: $NAME$
- `PASCAL_SINGULAR_NAME`: $PASCAL_SINGULAR_NAME$
- `PARAM_SINGULAR_NAME`: $PARAM_SINGULAR_NAME$
- `CAMEL_SINGULAR_NAME`: $CAMEL_SINGULAR_NAME$
- `PASCAL_PLURAL_NAME`: $PASCAL_PLURAL_NAME$
- `CAMEL_PLURAL_NAME`: $CAMEL_PLURAL_NAME$
- `PARAM_PLURAL_NAME`: $PARAM_PLURAL_NAME$
- `PASCAL_NAME`: $PASCAL_NAME$
- `PARAM_NAME`: $PARAM_NAME$
- `CAMEL_NAME`: $CAMEL_NAME$
To work, you should put the name wrapped by `$`, like: `$TEST$`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment