Skip to content

Instantly share code, notes, and snippets.

@H4ad
Last active February 28, 2023 23:04
Show Gist options
  • Save H4ad/bc6e6f2af449942b8cd1b8220aa4adb9 to your computer and use it in GitHub Desktop.
Save H4ad/bc6e6f2af449942b8cd1b8220aa4adb9 to your computer and use it in GitHub Desktop.

Revisions

  1. H4ad renamed this gist Feb 28, 2023. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions .dobby.yml → tp.yml
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,13 @@
    # the description that will be shown during "dobby list"
    # 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 dobby
    # commands that will be read by tp
    generate:
    # name of your resource
    # this will be exposed like: dobby generate setup <name>
    # this will be exposed like: tp generate setup <name>
    setup:
    description: "Initialize the API with some files"
    structure:
  2. H4ad created this gist Feb 26, 2023.
    54 changes: 54 additions & 0 deletions .dobby.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,54 @@
    # the description that will be shown during "dobby list"
    description: "My simple template"

    # Where we can get this template
    # installUrl:

    # commands that will be read by dobby
    generate:
    # name of your resource
    # this will be exposed like: dobby 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$`