Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/main/scripts/bin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env node

const fs = require('fs')
const { execSync } = require('child_process')

const runCommand = (command) => {
Expand All @@ -12,6 +13,7 @@ const runCommand = (command) => {
return true
}

const authorName = process.argv[3]
const repoName = process.argv[2]

const gitCheckoutCommand = `git clone --depth 1 https://github.com/rubemfsv/clean-react-app ${repoName}`
Expand All @@ -32,3 +34,26 @@ console.log(
)

console.log(`cd ${repoName} && npm run dev`)



// Dynamically update package.json
const packageJsonPath = `${repoName}/package.json`

try {
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))

// Update package.json fields
packageJson.name = repoName
packageJson.author = authorName
packageJson.version = '0.0.1'

// Write the updated package.json back to the file
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))

console.log('Updated package.json with dynamic values.')
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not necessary, because it is not an instruction

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line is missing! After remove it, run "npm run format:fix" to run prettier here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rubemfsv you are talking about whicj line ?

} catch (error) {
console.error('Failed to update package.json: ', error)
}