🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

generate-react-cli

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

generate-react-cli - npm Package Compare versions

Comparing version

to
1.7.4

{
"name": "generate-react-cli",
"version": "1.7.3",
"version": "1.7.4",
"description": "A simple React CLI to generate components instantly and more.",

@@ -26,3 +26,3 @@ "main": "src/index.js",

"chalk": "^2.4.2",
"commander": "^4.0.0",
"commander": "^4.0.1",
"deep-keys": "^0.5.0",

@@ -29,0 +29,0 @@ "esm": "^3.2.25",

import chalk from 'chalk';
import { camelCase } from 'lodash-es';
import { generateComponentTemplates } from '../services/templateService';
import { generateComponentTemplates, getTestingLibraryTemplate } from '../services/templateService';
import componentJsTemplate from '../templates/components/componentJsTemplate';
import componentLazyTemplate from '../templates/components/componentLazyTemplate';
import componentCssTemplate from '../templates/components/componentCssTemplate';
import componentTestDefaultTemplate from '../templates/components/componentTestDefaultTemplate';
import componentTestEnzymeTemplate from '../templates/components/componentTestEnzymeTemplate';
import componentTestTestingLibraryTemplate from '../templates/components/componentTestTestingLibraryTemplate';
import componentStoryTemplate from '../templates/components/componentStoryTemplate';

@@ -17,2 +13,13 @@

// Make sure component name is valid.
if (!componentName.match(/^[$A-Z_][0-9A-Z_$]*$/i)) {
console.error(
chalk.red.bold(
'ERROR: Component name is invalid. Please use a valid naming convention for the component you are trying to create.'
)
);
return;
}
// if test library is not Testing Library. Remove data-testid from jsTemplate

@@ -52,13 +59,2 @@ if (componentConfig.test.library !== 'Testing Library') {

// Make sure component name is valid.
if (!componentName.match(/^[$A-Z_][0-9A-Z_$]*$/i)) {
console.error(
chalk.red.bold(
'ERROR: Component name is invalid. Please use a valid naming convention for the component you are trying to create.'
)
);
return;
}
// converting boolean to string intentionally.

@@ -96,12 +92,1 @@ if (cmd.withTest.toString() === 'true') {

}
function getTestingLibraryTemplate(componentName, componentConfig) {
switch (componentConfig.test.library) {
case 'Enzyme':
return componentTestEnzymeTemplate;
case 'Testing Library':
return componentTestTestingLibraryTemplate.replace(/#|templateName/g, camelCase(componentName))
default:
return componentTestDefaultTemplate;
}
}

@@ -10,3 +10,3 @@ import program from 'commander';

export async function cli(args) {
const cliConfigFile = (await getCLIConfigFile()) || {};
const cliConfigFile = await getCLIConfigFile();
const { component } = cliConfigFile;

@@ -13,0 +13,0 @@

import { existsSync, outputFileSync } from 'fs-extra';
import chalk from 'chalk';
import replace from 'replace';
import { camelCase } from 'lodash-es';
import componentTestEnzymeTemplate from '../templates/components/componentTestEnzymeTemplate';
import componentTestDefaultTemplate from '../templates/components/componentTestDefaultTemplate';
import componentTestTestingLibraryTemplate from '../templates/components/componentTestTestingLibraryTemplate';

@@ -34,1 +38,12 @@ export function generateComponentTemplates(componentTemplates) {

}
export function getTestingLibraryTemplate(componentName, componentConfig) {
switch (componentConfig.test.library) {
case 'Enzyme':
return componentTestEnzymeTemplate;
case 'Testing Library':
return componentTestTestingLibraryTemplate.replace(/#|templateName/g, camelCase(componentName));
default:
return componentTestDefaultTemplate;
}
}