4 Commits

Author SHA1 Message Date
37e941ac56 0.1.8 2023-12-11 13:44:53 +01:00
984517cf90 adjust templates 2023-12-11 13:29:55 +01:00
6a9b39cb4e 0.1.7 2023-12-11 13:18:52 +01:00
a7b681a8f2 add currentDir to pnpm execution 2023-12-11 13:18:48 +01:00
3 changed files with 11 additions and 13 deletions

18
main.go
View File

@@ -52,19 +52,16 @@ func createComponent(name, currentDir string) error {
} }
// Component content // Component content
componentContent := fmt.Sprintf(`import React from 'react' componentContent := fmt.Sprintf(`import s from './%s.module.scss'
import s from './%s.module.scss'
export type %sProps = {} export type %sProps = {}
export const %s: React.FC<%sProps> = ({}) => { export const %s = ({}: %sProps) => {
return <div className={s.container}>%s</div> return <div>%s</div>
} }
`, name, capitalizedName, capitalizedName, capitalizedName, capitalizedName) `, name, capitalizedName, capitalizedName, capitalizedName, capitalizedName)
// SASS content // SASS content
sassContent := `.container { sassContent := ``
// styles go here
}`
// Index content // Index content
indexContent := fmt.Sprintf(`export * from './%s'`, name) indexContent := fmt.Sprintf(`export * from './%s'`, name)
@@ -106,8 +103,8 @@ export const Default: Story = {
} }
// Execute formatting and linting commands // Execute formatting and linting commands
runCommand("pnpm", "run", "format:file", dirPath) runCommand(currentDir, "npm", "run", "format:file", dirPath)
runCommand("pnpm", "run", "lint:file", dirPath+"/**") runCommand(currentDir, "npm", "run", "lint:file", dirPath+"/**")
return nil return nil
} }
@@ -149,8 +146,9 @@ func updateMainIndex(name, currentDir string) error {
return nil return nil
} }
func runCommand(command string, args ...string) { func runCommand(currentDir, command string, args ...string) {
cmd := exec.Command(command, args...) cmd := exec.Command(command, args...)
cmd.Dir = currentDir // Set the working directory
output, err := cmd.CombinedOutput() output, err := cmd.CombinedOutput()
if err != nil { if err != nil {
fmt.Println("Error executing command:", err) fmt.Println("Error executing command:", err)

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "@ershisan99/create-react-component", "name": "@ershisan99/create-react-component",
"version": "0.1.6", "version": "0.1.8",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@ershisan99/create-react-component", "name": "@ershisan99/create-react-component",
"version": "0.1.6", "version": "0.1.8",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"@ershisan99/go-npm": "^0.1.14" "@ershisan99/go-npm": "^0.1.14"

View File

@@ -1,6 +1,6 @@
{ {
"name": "@ershisan99/create-react-component", "name": "@ershisan99/create-react-component",
"version": "0.1.6", "version": "0.1.8",
"private": false, "private": false,
"repository": "https://github.com/ershisan99/create-react-component", "repository": "https://github.com/ershisan99/create-react-component",
"description": "A simple CLI tool to create react component", "description": "A simple CLI tool to create react component",