Skip to content

Commit 998eaef

Browse files
committed
Update: command
1 parent 47c25e7 commit 998eaef

File tree

4 files changed

+25
-15
lines changed

4 files changed

+25
-15
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ next-env.d.ts
4141

4242
# husky
4343
/.husky/
44+
45+
#bin
46+
/bin/*

bin/cli.js

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,34 @@ const repoName = process.argv[2]
66
const gitCheckoutCommand = `git clone --depth 1 git@github.com:rahadkc/nextjs-typescript-redux-jest-cypress-starter.git ${repoName}`
77
const installDepsCommand = `cd ${repoName} && npm install`
88

9-
console.log(`Cloning the repository ... ${repoName}`)
10-
const checkedOut = runCommand(gitCheckoutCommand)
11-
if (!checkedOut) exitProcess(-1)
12-
13-
console.log(`Installing dependencies for ${repoName}`)
14-
const installDeps = runCommand(installDepsCommand)
15-
if (!installDeps) exitProcess(-1)
9+
function colorizeText(text, colorCode) {
10+
return `\x1b[${colorCode}m${text}\x1b[0m`
11+
}
1612

17-
console.log('Congratulations! you are ready. Follow the following command to start')
18-
console.log(`cd ${repoName} && npm run dev`)
13+
function runCommandWithLoading(command, loadingMessage, colorCode) {
14+
process.stdout.write(`${colorizeText(loadingMessage, colorCode)} ...`)
1915

20-
function runCommand(command) {
2116
try {
22-
execSync(`${command}`, { studio: 'inherit' })
17+
execSync(`${command}`, { stdio: 'inherit' })
18+
process.stdout.write(colorizeText(' Done\n', '32')) // Green color for success
2319
} catch (error) {
24-
console.log(`Failed to execute command - ${command}`, error)
25-
return false
20+
process.stdout.write(colorizeText(' Failed\n', '31')) // Red color for failure
21+
console.error(`Failed to execute command - ${command}`, error)
22+
exitProcess(-1)
2623
}
27-
return true
2824
}
2925

26+
console.log(colorizeText(`Cloning the repository ... ${repoName}`, '34')) // Blue color for cloning
27+
runCommandWithLoading(gitCheckoutCommand, 'Cloning the repository', '34')
28+
29+
console.log(colorizeText(`Installing dependencies for ${repoName}`, '36')) // Cyan color for installing
30+
runCommandWithLoading(installDepsCommand, 'Installing dependencies', '36')
31+
32+
console.log(colorizeText('Congratulations! You are ready to go.', '32')) // Green color for success
33+
console.log('To start the project, run the following commands:')
34+
console.log(`cd ${repoName} && npm run dev`)
35+
console.log(colorizeText('Your project will be available at http://localhost:3050', '33')) // Yellow color for info
36+
3037
function exitProcess(code) {
3138
process.exit(code)
3239
}

bin/hok.js

Whitespace-only changes.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nextjs-typescript-redux-starter",
3-
"version": "1.0.3",
3+
"version": "1.0.5",
44
"bin": "./bin/cli.js",
55
"scripts": {
66
"dev": "next dev -p 3050",

0 commit comments

Comments
 (0)