react-typescript-cli
Advanced tools
Comparing version 0.0.3 to 0.1.0
const path = require('path'); | ||
const fs = require('fs-extra'); | ||
const componentTemplate = require("../templates/component"); | ||
const containerTemplate = require("../templates/container"); | ||
const indexTemplate = require("../templates/index"); | ||
const interfacesTemplate = require("../templates/interfaces"); | ||
const stylesTemplate = require("../templates/styles"); | ||
const utils = require('./utils'); | ||
const Handlebars = require('handlebars'); | ||
require('./handlebars-helpers'); | ||
createComponent = (name, options) => { | ||
@@ -52,6 +49,10 @@ const root = path.resolve(utils.capitalize(name)); | ||
const root = path.resolve(utils.capitalize(componentName)); | ||
const filepath = path.join(path.join(__dirname, '..', 'templates'), 'component.hbs'); | ||
const template = fs.readFileSync(filepath, 'utf8'); | ||
fs.writeFileSync( | ||
path.join(root, `${utils.capitalize(componentName)}.tsx`), | ||
componentTemplate.getComponentTemplate(componentName) | ||
Handlebars.compile(template)({ | ||
name: componentName | ||
}) | ||
) | ||
@@ -62,6 +63,17 @@ } | ||
const root = path.resolve(utils.capitalize(componentName)); | ||
const filepath = path.join(path.join(__dirname, '..', 'templates'), 'container.hbs'); | ||
const template = fs.readFileSync(filepath, 'utf8'); | ||
fs.writeFileSync( | ||
path.join(root, `${utils.capitalize(componentName)}.container.ts`), | ||
containerTemplate.getContainerTemplate(componentName, withStyles, withConnect) | ||
Handlebars.compile(template)({ | ||
name: componentName, | ||
withConnect, | ||
withStyles, | ||
withStylesOrConnect: withStyles || withConnect, | ||
withStylesAndConnect: withStyles && withConnect, | ||
withOnlyStyles: withStyles && !withConnect, | ||
withOnlyConnect: !withStyles && withConnect, | ||
withoutConnectAndStyles: !withStyles && !withConnect | ||
}) | ||
) | ||
@@ -72,6 +84,11 @@ } | ||
const root = path.resolve(utils.capitalize(componentName)); | ||
const filepath = path.join(path.join(__dirname, '..', 'templates'), 'index.hbs'); | ||
const template = fs.readFileSync(filepath, 'utf8'); | ||
fs.writeFileSync( | ||
path.join(root, `index.ts`), | ||
indexTemplate.getIndexTemplate(componentName, withContainer) | ||
Handlebars.compile(template)({ | ||
name: componentName, | ||
withContainer | ||
}) | ||
) | ||
@@ -82,6 +99,12 @@ } | ||
const root = path.resolve(utils.capitalize(componentName)); | ||
const filepath = path.join(path.join(__dirname, '..', 'templates'), 'interfaces.hbs'); | ||
const template = fs.readFileSync(filepath, 'utf8'); | ||
fs.writeFileSync( | ||
path.join(root, `${utils.capitalize(componentName)}.interfaces.ts`), | ||
interfacesTemplate.getInterfacesTemplate(componentName, withStyles, withConnect) | ||
Handlebars.compile(template)({ | ||
name: componentName, | ||
withStyles, | ||
withConnect | ||
}) | ||
) | ||
@@ -92,6 +115,10 @@ } | ||
const root = path.resolve(utils.capitalize(componentName)); | ||
const filepath = path.join(path.join(__dirname, '..', 'templates'), 'styles.hbs'); | ||
const template = fs.readFileSync(filepath, 'utf8'); | ||
fs.writeFileSync( | ||
path.join(root, `${utils.capitalize(componentName)}.styles.ts`), | ||
stylesTemplate.getStylesTemplate() | ||
Handlebars.compile(template)({ | ||
name: componentName | ||
}) | ||
) | ||
@@ -98,0 +125,0 @@ } |
{ | ||
"name": "react-typescript-cli", | ||
"version": "0.0.3", | ||
"version": "0.1.0", | ||
"description": "CLI tool for React with Typescript", | ||
@@ -14,5 +14,15 @@ "files": "index.js", | ||
"commander": "^2.9.0", | ||
"fs-extra": "^2.0.0" | ||
"fs-extra": "^2.0.0", | ||
"handlebars": "^4.0.11" | ||
}, | ||
"keywords": ["react", "typescript", "cli", "components", "generate", "styles", "material"] | ||
"keywords": [ | ||
"react", | ||
"typescript", | ||
"cli", | ||
"components", | ||
"generate", | ||
"styles", | ||
"material" | ||
], | ||
"devDependencies": {} | ||
} |
@@ -36,2 +36,1 @@ # react-typescript-cli | ||
- Support for functional components | ||
- Creating components from src directory |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11
8922
3
126
36
+ Addedhandlebars@^4.0.11
+ Addedhandlebars@4.7.8(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedneo-async@2.6.2(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addeduglify-js@3.19.3(transitive)
+ Addedwordwrap@1.0.0(transitive)