mirror of
https://github.com/ershisan99/create-react-component.git
synced 2025-12-18 05:09:25 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 37e941ac56 | |||
| 984517cf90 | |||
| 6a9b39cb4e | |||
| a7b681a8f2 | |||
| b1b46ce60d | |||
| 293e2f47c7 | |||
| 192371f218 | |||
| 277d347c96 | |||
| 250e512d40 | |||
| c017767263 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,4 +1,4 @@
|
|||||||
.idea
|
.idea
|
||||||
dist/
|
dist/
|
||||||
|
|
||||||
.node_modules
|
node_modules
|
||||||
@@ -13,9 +13,11 @@ before:
|
|||||||
- go mod tidy
|
- go mod tidy
|
||||||
|
|
||||||
builds:
|
builds:
|
||||||
- env:
|
- binary: create-react-component
|
||||||
- CGO_ENABLED=0
|
|
||||||
goos:
|
goos:
|
||||||
- linux
|
|
||||||
- windows
|
- windows
|
||||||
- darwin
|
- darwin
|
||||||
|
- linux
|
||||||
|
goarch:
|
||||||
|
- amd64
|
||||||
|
- arm64
|
||||||
18
main.go
18
main.go
@@ -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)
|
||||||
|
|||||||
24
package-lock.json
generated
Normal file
24
package-lock.json
generated
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"name": "@ershisan99/create-react-component",
|
||||||
|
"version": "0.1.8",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "@ershisan99/create-react-component",
|
||||||
|
"version": "0.1.8",
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@ershisan99/go-npm": "^0.1.14"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@ershisan99/go-npm": {
|
||||||
|
"version": "0.1.14",
|
||||||
|
"resolved": "https://registry.npmjs.org/@ershisan99/go-npm/-/go-npm-0.1.14.tgz",
|
||||||
|
"integrity": "sha512-1xLTMhRQ4qJ35yzA9p6LoT1XI9b5e4CfMwntxP8lWhQPZRscxwepQpE+xR02yP9IDS4VfdUJmWnog58HvI3EOA==",
|
||||||
|
"bin": {
|
||||||
|
"go-npm": "bin/index.js"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "@ershisan99/create-react-component",
|
"name": "@ershisan99/create-react-component",
|
||||||
"version": "0.1.3",
|
"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",
|
||||||
|
"files": [
|
||||||
|
"dist",
|
||||||
|
"postinstall.js"
|
||||||
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"go-npm": "^0.1.9"
|
"@ershisan99/go-npm": "^0.1.14"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"postinstall": "go-npm install",
|
"postinstall": "go-npm install",
|
||||||
|
|||||||
Reference in New Issue
Block a user