Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wildcat
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bal Feng
wildcat
Commits
60a55828
Commit
60a55828
authored
Jul 30, 2018
by
Jason Zhou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:
- add commands - add log display - add backup function
parent
f32d9ab2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
11 deletions
+48
-11
index.js
bin/index.js
+48
-11
No files found.
bin/index.js
View file @
60a55828
#!/usr/bin/env node
#!/usr/bin/env node
const
inquirer
=
require
(
'inquirer'
)
const
inquirer
=
require
(
'inquirer'
)
const
program
=
require
(
'commander'
)
const
chalk
=
require
(
'chalk'
)
const
{
log
,
colors
}
=
require
(
'../packages/utils/log'
)
const
{
spawn
}
=
require
(
'child_process'
)
const
{
spawn
}
=
require
(
'child_process'
)
const
_
=
require
(
'lodash'
)
const
{
const
{
updateConfigFiles
,
updateConfigFiles
,
updateLegacyCodes
,
updateLegacyCodes
,
upgradePackages
,
upgradePackages
,
preserveOldFiles
preserveOldFiles
,
restoreOldFiles
}
=
require
(
'../packages/actions'
)
}
=
require
(
'../packages/actions'
)
const
BANNER
=
`
const
BANNER
=
`
...
@@ -27,7 +32,9 @@ const BANNER = `
...
@@ -27,7 +32,9 @@ const BANNER = `
| | | | | | | | | | | | | | |
| | | | | | | | | | | | | | |
`
`
const
main
=
async
()
=>
{
const
VERSION
=
'0.1.0'
const
run
=
async
()
=>
{
console
.
info
(
BANNER
)
console
.
info
(
BANNER
)
const
{
mode
}
=
await
inquirer
.
prompt
([
const
{
mode
}
=
await
inquirer
.
prompt
([
...
@@ -35,9 +42,11 @@ const main = async () => {
...
@@ -35,9 +42,11 @@ const main = async () => {
name
:
'mode'
,
name
:
'mode'
,
type
:
'list'
,
type
:
'list'
,
message
:
[
message
:
[
'Which mode would like to choose:'
,
colors
.
title
(
'Which mode would like to choose:'
),
' 🚝 chill - webpack 4, ES2018 output, cheap-eval-source-map'
,
colors
.
item
(
' 🚀 mad max - coming soon ...'
,
' 🚝 chill - webpack 4, ES2018 output, cheap-eval-source-map'
),
colors
.
item
(
' 🚀 mad max - coming soon ...
\
n'
),
// add extra \n for good looking
// ' 🚀 mad max - webpack 4, ES2018 output, no source map, no backend log',
// ' 🚀 mad max - webpack 4, ES2018 output, no source map, no backend log',
''
''
].
join
(
'
\
n'
),
].
join
(
'
\
n'
),
...
@@ -46,16 +55,18 @@ const main = async () => {
...
@@ -46,16 +55,18 @@ const main = async () => {
}
}
])
])
console
.
log
(
'Preserve current configs ...'
)
// add extra \n for good looking
console
.
log
(
'
\
n'
)
log
.
title
(
'📥 Preserve current configs'
)
preserveOldFiles
()
preserveOldFiles
()
console
.
log
(
'Update config files ...
'
)
log
.
title
(
'📝 Update config files
'
)
updateConfigFiles
(
mode
)
updateConfigFiles
(
mode
)
console
.
log
(
'Update legacy codes ...
'
)
log
.
title
(
'💯 Update legacy codes
'
)
updateLegacyCodes
()
updateLegacyCodes
()
console
.
log
(
'Upgrade pacakages ...
'
)
log
.
title
(
'🐣 Upgrade pacakages
'
)
upgradePackages
()
upgradePackages
()
console
.
log
(
'
yarn dev'
)
log
.
title
(
'🐥 Everything set! Run
yarn dev'
)
// since shelljs.exec doesn't work with inqurier.js
// since shelljs.exec doesn't work with inqurier.js
// use spawn instead
// use spawn instead
spawn
(
'yarn'
,
[
'dev'
],
{
spawn
(
'yarn'
,
[
'dev'
],
{
...
@@ -63,4 +74,30 @@ const main = async () => {
...
@@ -63,4 +74,30 @@ const main = async () => {
})
})
}
}
main
()
program
.
version
(
VERSION
)
program
.
command
(
'run'
)
.
description
(
'Run wildcat'
)
.
action
(
run
)
program
.
command
(
'restore'
)
.
description
(
'Restore the previous configs, make sure you have execed wildcat run command or it may go wrong.'
)
.
action
(
restoreOldFiles
)
program
.
parse
(
process
.
argv
)
// default command when no params attached
if
(
_
.
isEmpty
(
program
.
args
))
{
console
.
info
(
BANNER
)
console
.
info
(
chalk
.
cyanBright
(
`Version: v
${
VERSION
}
\n`
))
console
.
info
(
`🐾
${
chalk
.
cyanBright
(
'Wildcat is a cli tool for accelerating webpack dev server of Bobcat.'
)}
`
)
program
.
help
()
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment