From 05414ee2417b8c4027dd901cd24fae1a516bf2df Mon Sep 17 00:00:00 2001 From: laurens Date: Fri, 11 Jun 2021 16:52:26 +0200 Subject: [PATCH 1/3] use keyword "templateName" to replace TemplateName in camelCase --- src/utils/generateComponentUtils.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/utils/generateComponentUtils.js b/src/utils/generateComponentUtils.js index b230777..4ddd9b7 100644 --- a/src/utils/generateComponentUtils.js +++ b/src/utils/generateComponentUtils.js @@ -365,6 +365,14 @@ function generateComponent(componentName, cmd, cliConfigFile) { silent: true, }); + replace({ + regex: 'templateName', + replacement: camelCase(componentName), + paths: [componentPath], + recursive: false, + silent: true, + }); + console.log(chalk.green(`${filename} was successfully created at ${componentPath}`)); } catch (error) { console.error(chalk.red(`${filename} failed and was not created.`)); From a1f25ec4d0df8523b614329a4faa177a8287bbb6 Mon Sep 17 00:00:00 2001 From: laurens Date: Fri, 11 Jun 2021 16:53:52 +0200 Subject: [PATCH 2/3] change TypeScript template to not use React.FC anymore since it is not recommended anymore. --- src/templates/component/componentTsTemplate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/component/componentTsTemplate.js b/src/templates/component/componentTsTemplate.js index b2bce38..fcf3d08 100644 --- a/src/templates/component/componentTsTemplate.js +++ b/src/templates/component/componentTsTemplate.js @@ -1,7 +1,7 @@ module.exports = `import React from 'react'; import styles from './TemplateName.module.css'; -const TemplateName: React.FC = () => ( +const TemplateName = () => (
TemplateName Component
From e858259cc59225f0512ffc260dcb7c4c764577b0 Mon Sep 17 00:00:00 2001 From: laurens Date: Fri, 11 Jun 2021 17:02:22 +0200 Subject: [PATCH 3/3] update readme to reflect the change --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 814a28e..c39c780 100644 --- a/readme.md +++ b/readme.md @@ -221,7 +221,7 @@ There is an optional `customTemplates` object that you can pass to the `componen }, ``` -The keys represent the type of file, and the values are the paths that point to where your custom template lives in your project/system. Please note the `TemplateName` keyword in the template filename. GRC will use this keyword and replace it with your component name as the filename. +The keys represent the type of file, and the values are the paths that point to where your custom template lives in your project/system. Please note the `TemplateName` keyword in the template filename. GRC will use this keyword and replace it with your component name as the filename. You can also use the keyword `templateName`, which will be replaced with your component name in camelCase. #### Example of using the `customTemplates` object within your generate-react-cli.json config file: