Socket
Socket
Sign inDemoInstall

code-gen-library

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

code-gen-library - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

templates/components/test.hbs

1

default.config.js

@@ -5,2 +5,3 @@ module.exports = {

withTypescript: true,
withTests: true,
withModels: true,

@@ -7,0 +8,0 @@ withStyles: true,

2

package.json

@@ -12,3 +12,3 @@ {

},
"version": "1.0.4",
"version": "1.0.5",
"license": "MIT",

@@ -15,0 +15,0 @@ "scripts": {

@@ -30,11 +30,13 @@ #!/usr/bin/env node

componentsPath,
withTypescript,
jsx,
utilsPath,
withModels,
withStyles,
withModels,
utilsPath,
withTests,
withTypescript,
} = config
const extension = withTypescript ? 'ts' : 'js'
const reactExtension = `${extension}${jsx ? 'x' : ''}`
const type = 'add'
printLogo()

@@ -64,12 +66,15 @@ plop.setGenerator('Component', {

actions: function ({ withStyles, withModels }) {
const pathToFolder = `${projectPath}/${componentsPath}/{{ pascalCase name }}`
const pathToTemplate = `${rootPath}/templates/components`
const actions = [
{
type: 'add',
path: `${projectPath}/${componentsPath}/{{ pascalCase name }}/{{ pascalCase name }}.${reactExtension}`,
templateFile: `${rootPath}/templates/components/component.hbs`,
type,
path: `${pathToFolder}/{{ pascalCase name }}.${reactExtension}`,
templateFile: `${pathToTemplate}/component.hbs`,
},
{
type: 'add',
path: `${projectPath}/${componentsPath}/{{ pascalCase name }}/index.${extension}`,
templateFile: `${rootPath}/templates/components/index.hbs`,
type,
path: `${pathToFolder}/index.${extension}`,
templateFile: `${pathToTemplate}/index.hbs`,
},

@@ -79,5 +84,5 @@ ]

actions.push({
type: 'add',
path: `${projectPath}/${componentsPath}/{{ pascalCase name }}/{{ pascalCase name }}.styles.${extension}`,
templateFile: `${rootPath}/templates/components/styles.hbs`,
type,
path: `${pathToFolder}/{{ pascalCase name }}.styles.${extension}`,
templateFile: `${pathToTemplate}/styles.hbs`,
})

@@ -87,7 +92,14 @@ }

actions.push({
type: 'add',
path: `${projectPath}/${componentsPath}/{{ pascalCase name }}/{{ pascalCase name }}.models.ts`,
templateFile: `${rootPath}/templates/components/models.hbs`,
type,
path: `${pathToFolder}/{{ pascalCase name }}.models.ts`,
templateFile: `${pathToTemplate}/models.hbs`,
})
}
if (withTests) {
actions.push({
type,
path: `${pathToFolder}/{{ pascalCase name }}.test.ts`,
templateFile: `${pathToTemplate}/test.hbs`,
})
}

@@ -114,16 +126,27 @@ return actions

actions: function ({ path }) {
const pathToFolder = `${rootPath}/${path}/{{ camelCase name }}`
const pathToTemplate = `${rootPath}/templates/utils`
const actions = [
{
type: 'add',
path: `${rootPath}/${path}/{{ camelCase name }}/{{ camelCase name }}.${extension}`,
templateFile: `${rootPath}/templates/utils/util.hbs`,
type,
path: `${pathToFolder}/{{ camelCase name }}.${extension}`,
templateFile: `${pathToTemplate}/util.hbs`,
data: { withTypescript },
},
{
type: 'add',
path: `${rootPath}/${path}/{{ camelCase name }}/index.${extension}`,
templateFile: `${rootPath}/templates/utils/index.hbs`,
type,
path: `${pathToFolder}/index.${extension}`,
templateFile: `${pathToTemplate}/index.hbs`,
},
]
if (withTests) {
actions.push({
type,
path: `${pathToFolder}/{{ camelCase name }}.test.${extension}`,
templateFile: `${pathToTemplate}/test.hbs`,
})
}
return actions

@@ -130,0 +153,0 @@ },

@@ -7,7 +7,7 @@ # Code Gen Library

<p align="center">
<img src="https://harrisgeo.xyz/images/cgl-cli.gif" />
<img src="https://user-images.githubusercontent.com/630705/99194052-0a284400-2775-11eb-8435-886f3e5336a8.gif" />
</p>
<p align="center">
<img src="https://harrisgeo.xyz/images/cgl-code.gif" />
<img src="https://user-images.githubusercontent.com/630705/99193989-748cb480-2774-11eb-8c59-0ea0f76de8c3.gif" />
</p>

@@ -30,3 +30,3 @@

or if installed globabally
or if installed globally

@@ -105,7 +105,8 @@ ```

jsx | If the main component will be `.jsx` / `.tsx` or `.js` / `.ts` | true
withTypescript | All files will be generated with TypeScript `.ts` / `.tsx` format | true
utilsPath | The default path for the utils | src/utils/
withModels | Models to be separated from the main component. Models files will suffix with `.models.*` | true
withStyles | Styles to be separated from the main component. Styles files will suffix with `.styles.*` | true
utilsPath | The default path for the utils | src/utils/
withTests | File for tests to also be included in the same directory. WIll suffix with `.test.*` format | true
withTypescript | All files will be generated with TypeScript `.ts` / `.tsx` format | true
### More to come soon

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc