Giter Club home page Giter Club logo

generate-template-files's People

Contributors

ccheney avatar codebelt avatar dependabot[bot] avatar jimschofield avatar ryokkkke avatar tikitdo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

generate-template-files's Issues

[Question] Is there a way to silence console messages?

Im using generateTemplateFilesBatch so I have my own process around generate-template-files, so i was wondering if there's an option to silence the Files saved to '<path>' console log messages that it generates so that I can add my own without the noise?

[Question] Is there a way to run a generate without the interactive cli?

I want to use this to just automatically create a bunch of templated files without needing any user input. I have a node script that i'm writing and i'd just like to run a function to generate the files without being asked about "which option would you like to template"? kind of thing? Is this possible?

Having a default replacement string

It would be great if we could set a default string for replacement, are there any plans to add this?

Something like

      { question: "Which directory?", slot: "__dir__", defaultString: "components" },

Output path options

Suggest separating the casing out as an option:

output: {
     path: 'path',
     case: 'camelCase'
}

Non-interactive / Batch Mode

Hello!

I'd like to be able to pass an array of configs to the generateTemplateFiles function and have it run them sequentially with no need for user interaction.

Thanks! Really great tool.

Description of the string replacers

Should be possibile add as feature the possibility to add on stringReplacers a description/label of the placeholder we have to replace and have something like this:

stringReplacers: [{description: "Model class name", value: "__model__"}]

and then have on console something like:

Insert model class name:

This is just an idea but should be possibile?

Emitter-mixin deprecation warning

Using the package with node 16.x.x shows a DeprecationWarning from the emitter-mixin dependency. It is used by the recursive-copy dependency and it has been fixed on version 2.0.12 (lib is already on 2.0.13 version). Is it possible to upgrade this dependency version so the warning is eliminated?

Warning message
[DEP0128] DeprecationWarning: Invalid 'main' field in 'xxx\node_modules\emitter-mixin\package.json' of 'y'. Please either fix that or report it to the module author

How Can I add branch and PR?

Should I receive a certain permission to add branch?

I want to contribute some code that replacing string. It's only supporting for English.

I compare to Lodash and it's good to be supporting for all languages.

Are you maintaining it?

Add `caseConverter__` values to `CaseConverterEnum`

The thing that really caught my eye with this lib is how it lets you write perfectly valid, type-safe files in typescript if you only restrict the use of case conversion to strings and comments. Unfortunately if you want to use case converters there are things you simply can't do.

For example, there is no way to make this snippet valid TS code.

// Given `__resourceName__ `is PascalCalse
export const __resourceName__(constantCase) _KEY = "__resourceName__(snakeCase)_exported_type";
const get__resourceName__ = (): Promise<ResultFor<__resourceName__(snakeCase)_exported_type>> => {
  get(__resourceName__(constantCase) _KEY)
}

This could be alleviated by allowing the case conversion tags to be underscored. In that case the above would look as follows:

// Given `__resourceName__ `is PascalCalse
export const __resourceName__constantCase___KEY = "__resourceName__snakeCase___exported_type";
export const get__resourceName__ = (): Promise<ResultFor<__resourceName__snakeCase___exported_type>> => {
  get(__resourceName__constantCase___KEY)
}

This ends up being totally valid TS, and at worst maybe need a few lint rules disabled. There's also no reason why the two couldn't coexist, so there shouldn't be any risk to existing users.

I've already tested that it works here. If you'd like I can merge this code into my other PR.

The result file generated by the binary template file is damaged

There is a binary file in my template dir, when I run generateTemplateFiles(), the output binary file is not the same as origin file.

the origin template dir files:
image

generated result files:
image

image

md5 of the binary file "echo_demo" is different, and result "echo_demo" file cannot be executed, looks like it's damaged.

Is it possible to use CaseConverter per stringReplacers?

I want to do something like that:

    stringReplacers: [
      {question: 'Extension name', slot: '${extname}', case:'(pascalCase)'},
      {question: 'Content element name', slot: '${cename}', case:'(lowerCase)'},
      {question: 'Content element title', slot: '${cetitle}'},
      {question: 'Content element description', slot: '${cedescription}'},
    ],

Would that be possbile?

When using slotValue I get TypeError: prop.split is not a function

// Angular

    {
        option: "Angular Ngrx Store",
        defaultCase: '(pascalCase)',
        entry: {
            folderPath: './tools/templates/angular/ngrx-store/',
        },
        stringReplacers: [{slot:'__name__', slotValue: 'asdasdada'}, '__model__'],
        output: {
            path: './src/app/stores/__name__(lowerCase)',
            pathAndFileNameDefaultCase: '(kebabCase)',
        },
    },

√ What do you want to generate? · Angular Ngrx Store
(node:19132) UnhandledPromiseRejectionWarning: TypeError: prop.split is not a function

stringReplacers is not optional

If i want to use just dynamicReplacers it's not possible as stringReplacers is mandatory

UnhandledPromiseRejectionWarning: Error: "stringReplacers" needs at least one item.

Code editor barking at improper syntax

In a few cases, we have to add the case suffix e.g. (pascalCase) after certain slots in our files, because it is an improper syntax, the code editor (I am using VS Code) is barking at the improper syntax:

// templates/.../__name__(pascalCase).js
class __name__(pascalCase) { ... } // <-- code editor does not like this, obviously

I certainly could update the settings of the editor to ignore those files, but we have a lot of contributors and would prefer not to have everyone have to do that. Do you know of a workaround? In the interim we decided to add a .template suffix to each filename (__name__(pascalCase).js.template) so the editor does not lint it. We then remove that extension in the onComplete callback. This works fine, but I'd prefer to retain the original extension so that I can take advantage of the project linting, formatting, etc.

I thought of a very simple, potential solution; If the dynamicReplacers were just replaced before the stringReplacers they could be used to dynamically add the non-editor-friendly syntax. For example:

stringReplacers: [
    { 
        question: 'Insert component name',
        slot: '__name__',
    }
],
dynamicReplacers: [
    { 
        slot: 'ComponentName', // <-- this slot gets replaced first...
        slotValue: '__name__(pascalCase)', // <-- ...with this syntax for the stringReplacers
    },
]
// templates/.../__name__(pascalCase).js
class ComponentName { ... } // <-- code editor does not mind this :)

Just an idea, not sure if it would work, or if that is a feature you want to enable. However, it does seem simple enough. I haven't looked at the source code yet, but would image a simple change to the order of operations could accomplish this.

Also, are you open to contributions? I am interested in taking a stab at this update and submitting a PR.

Any ideas/chances to run it with Arrays/Objects properly?

Hi! I'm loving so far this package.
However, I'm still not sure if it is possible to generate the file I need from terminal 100% automated, because parts of it might include JSON objects and array, like this (example only):

response: { 200: { type: "object", properties: { status: { type: "string" }, statusCode: { type: "integer" }, data: { type: "array", items: { type: "object", properties: { // name: { type: "string" } // prompt in terminal for this json object // could be an array here as well... } } } } },

Are there any recommendations to automate this?
Thanks in advance, best regards!

Prompt confirmation before files are written

Just an idea, but one potential feature that could be really handy is a confirmation step that optionally occurs before the files are written; similar to how npm init does it:

Screen Shot 2020-12-12 at 9 18 03 AM

This would give consumers the ability to see what files are going to be generated, and the ability to bail out if they entered something incorrectly OR might accidentally overwrite something they don't intend to. It will add a little transparency to each option and what it does, which can be very reassuring.

This could easily be an opt-in or opt-out feature by adding it to the API:

{
    option: 'Create Redux Store',
    defaultCase: '(pascalCase)',
    confirmFiles: true, // <-- opt-in
},

Are you open to contributions? I am interested in taking a stab at adding this feature, if you agree it is a feature worth pursuing. Thanks!

More control on dynamic output path

Could we give more control to a dynamic output path, something along the lines of webpack?

i.e.

outputPath: './assets/src/~blockname~(lowerCase)/~blockname~(lowerCase)',

ConfigItem.output.path as string or function

Hi, I'm clone this repo and I make an implementation for write output.path not only as string but also as function that return a string.

Reason:

  1. I want to create a Vue File and I'm using Atomic Design Pattern
  2. I want to create an atom, molecole, organism, template or page file.

So path, instead of be a simple string, will be a function that check input data and generate different output paths.

This is my working configuration:

const items = [
    {
        option: 'Vue File',
        defaultCase: '(pascalCase)',
        entry: {
            folderPath: './tools/templates/vue/__file__.vue',
        },
        stringReplacers: ['__type__', '__file__'],
        output: {
            path: (replacers, configItem) => {
                function search(key, replacers){
                    let i = 0
                    let l = replacers.length
                    for (i; i < l; i++) {
                        if (replacers[i].slot === key) {
                            return replacers[i];
                        }
                    }
                }

                const type = search('__type__(kebabCase)', replacers)

                if (type.slotValue === 'page') {
                    return `./src/pages/__file__.vue`
                } else if (['atom', 'component', 'organism'].includes(type.slotValue)) {
                    return `./src/components/__type__(kebabCase)s/__file__.vue`
                }

                throw new Error('Type specified is not valid.')
            },
            pathAndFileNameDefaultCase: '(pascalCase)',
        },
    },
]

If possibile, I want to create a pull request for this new feature.

[Question] Is there a way I can call multiple options at once

generateTemplateFiles([
 { option: "Create controller", output: "src/controllers"... },
 { option: "Create model", output: "src/models"...},
 { option: "Create route", output:"src/routes" ... },
])

Is there any way I can call these multiple options at once ?
For example i wanna create a user controller, route, and model at once (by just giving a name parameter as 'user').

Expose string utility functions as a parameter of the onComplete callback

I need to format the the slotValue using the string utility in this package inside the onComplete callback.

Maybe expose the utility functions so I can do it manually in the callback, or add the formatted string to the slots:

[
    {
        slot: '__test__',
        slotValue: 'string thing',
        formattedSlotValue: 'string-thing',
    }
    ...
]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.