Skip to content

Commit 5a40cda

Browse files
committed
[Feature] Update packages
1 parent aa59ad2 commit 5a40cda

File tree

6 files changed

+3309
-327
lines changed

6 files changed

+3309
-327
lines changed

bin/init.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,22 @@ async function isWantStyle() {
7878
])
7979
}
8080

81-
function createApp(gitURL: string, nameOfApp: string, defaultNodePackageName: string) {
81+
function createApp(selectApp: number, nameOfApp: string, defaultNodePackageName: string, style: string) {
8282
const gitDownSpinner = ora("Creating app: " + nameOfApp + "...\n")
8383
gitDownSpinner.start()
84+
const gitURL = getGitURL(selectApp, style)
8485
shell.exec(`git clone ${gitURL} ${nameOfApp}`, (code: number, stdout: string, stderr: string) => {
8586
gitDownSpinner.stop()
8687
if (code !== 0) {
8788
shell.echo(chalk.cyanBright(`code: ${code}`))
8889
shell.echo(chalk.cyanBright(`Program output: ${stdout}`))
8990
shell.echo(chalk.cyanBright(`Program stderr: ${stderr}`))
9091
}
91-
flowUp(nameOfApp, defaultNodePackageName)
92+
flowUp(selectApp, nameOfApp, defaultNodePackageName, style)
9293
})
9394
}
9495

95-
function flowUp(nameOfApp: string, defaultNodePackageName: string) {
96+
function flowUp(selectApp:number, nameOfApp: string, defaultNodePackageName: string, style: string) {
9697
const projectCleanupSpinner = ora("Project Cleanup...\n")
9798
projectCleanupSpinner.start()
9899

@@ -105,17 +106,22 @@ function flowUp(nameOfApp: string, defaultNodePackageName: string) {
105106
)
106107
shell.rm("-rf", `${nameOfApp}/.git`)
107108
projectCleanupSpinner.stop()
108-
109-
const npmInstallSpinner = ora("npm install...just a moment, please.\n").start()
110109
shell.cd(nameOfApp)
111-
shell.exec("npm install")
112-
npmInstallSpinner.stop()
113-
110+
shell.exec("flow update")
111+
reinstallAutotprefixcer(selectApp, style)
114112
shell.echo(chalk.greenBright(nameOfApp + " created."))
115113
process.exit(0)
116114
}, 2000)
117115
}
118116

117+
function reinstallAutotprefixcer(selectApp:number, style: string) {
118+
if (style == TYPE_OF_STYLE.TAILWIND && selectApp == TYPE_OF_APP.REACT) {
119+
const tailwindSpinner = ora("autotprefixcer setting for tailwindcss...\n").start()
120+
shell.exec("npm install autoprefixer@^9.8.6")
121+
tailwindSpinner.succeed()
122+
}
123+
}
124+
119125
function invalidProgramInput() {
120126
shell.echo(chalk.redBright("There is no app for current choice. Please try again."))
121127
process.exit(0)
@@ -163,9 +169,9 @@ function selectTheNameOfTheApp() {
163169
if (!isValidateComponentNaming(nameOfApp)) {
164170
return process.exit(0)
165171
}
166-
const gitURL = getGitURL(options[0].value, style)
172+
const selectApp = options[0].value
167173
const defaultNodePackageName = getDefaultNodePackageName(options[0].value)
168-
createApp(gitURL, nameOfApp, defaultNodePackageName)
174+
createApp(selectApp, nameOfApp, defaultNodePackageName, style)
169175
})
170176
}
171177

bin/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import chalk from "chalk"
77
import pkg from "../package.json"
88
import page from "./page"
99
import updateNotifier from "update-notifier"
10+
import update from "./update"
1011

1112
const printWelcomeMessage = () => {
1213
const welcome = `
@@ -28,6 +29,7 @@ const checkPkgUpdate = () => {
2829
printWelcomeMessage()
2930
checkPkgUpdate()
3031
init()
32+
update()
3133
page()
3234

3335
program.parse(process.argv)

bin/update.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import program from "commander"
2+
import shell from "shelljs"
3+
import ora from "ora"
4+
5+
const update = () => {
6+
program
7+
.command("update")
8+
.description("Generate page(screen) component.")
9+
.action(() => {
10+
const updateCheckSpinner = ora("Check package updates...\n").start()
11+
shell.exec("npx npm-check-updates --packageFile package.json -u")
12+
updateCheckSpinner.succeed()
13+
const npmInstallSpinner = ora("npm install...just a moment, please.\n").start()
14+
shell.exec("npm install")
15+
npmInstallSpinner.succeed()
16+
process.exit(0)
17+
})
18+
}
19+
20+
export default update

0 commit comments

Comments
 (0)