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
Jason Zhou
wildcat
Commits
f32d9ab2
Commit
f32d9ab2
authored
Jul 30, 2018
by
Jason Zhou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add log display
parent
a7568fb3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
actions.js
packages/actions.js
+12
-3
No files found.
packages/actions.js
View file @
f32d9ab2
// const path = require('path')
// const path = require('path')
const
fs
=
require
(
'fs'
)
const
fs
=
require
(
'fs'
)
const
path
=
require
(
'path'
)
const
path
=
require
(
'path'
)
const
chalk
=
require
(
'chalk'
)
const
shell
=
require
(
'shelljs'
)
const
shell
=
require
(
'shelljs'
)
const
handlebars
=
require
(
'handlebars'
)
const
handlebars
=
require
(
'handlebars'
)
const
{
log
}
=
require
(
'./utils/log'
)
const
{
TEMPLATES
,
PACKAGES
,
LEGACY_CODES
,
BACKUP_FILES
}
=
require
(
'./configs'
)
const
{
TEMPLATES
,
PACKAGES
,
LEGACY_CODES
,
BACKUP_FILES
}
=
require
(
'./configs'
)
handlebars
.
registerHelper
(
'if_eq'
,
function
(
a
,
b
,
opts
)
{
handlebars
.
registerHelper
(
'if_eq'
,
function
(
a
,
b
,
opts
)
{
...
@@ -12,15 +15,16 @@ handlebars.registerHelper('if_eq', function(a, b, opts) {
...
@@ -12,15 +15,16 @@ handlebars.registerHelper('if_eq', function(a, b, opts) {
const
preserveOldFiles
=
()
=>
{
const
preserveOldFiles
=
()
=>
{
BACKUP_FILES
.
forEach
(
file
=>
{
BACKUP_FILES
.
forEach
(
file
=>
{
console
.
log
(
`Preserving
${
file
}
...`
)
log
.
item
(
`Preserving
${
file
}
...`
)
const
basename
=
path
.
basename
(
file
)
const
basename
=
path
.
basename
(
file
)
fs
.
copyFileSync
(
file
,
`
${
__dirname
}
/backups/
${
basename
}
`
)
fs
.
copyFileSync
(
file
,
`
${
__dirname
}
/backups/
${
basename
}
`
)
})
})
}
}
const
restoreOldFiles
=
()
=>
{
const
restoreOldFiles
=
()
=>
{
log
.
title
(
'📤 Restore previous configs'
)
BACKUP_FILES
.
forEach
(
file
=>
{
BACKUP_FILES
.
forEach
(
file
=>
{
console
.
log
(
`Restoring
${
file
}
...`
)
log
.
item
(
`Restoring
${
file
}
...`
)
const
basename
=
path
.
basename
(
file
)
const
basename
=
path
.
basename
(
file
)
fs
.
copyFileSync
(
`
${
__dirname
}
/backups/
${
basename
}
`
,
file
)
fs
.
copyFileSync
(
`
${
__dirname
}
/backups/
${
basename
}
`
,
file
)
})
})
...
@@ -28,6 +32,7 @@ const restoreOldFiles = () => {
...
@@ -28,6 +32,7 @@ const restoreOldFiles = () => {
const
updateConfigFiles
=
(
mode
=
'chill'
)
=>
{
const
updateConfigFiles
=
(
mode
=
'chill'
)
=>
{
TEMPLATES
.
forEach
(
filename
=>
{
TEMPLATES
.
forEach
(
filename
=>
{
log
.
item
(
`Updating
${
filename
}
...`
)
const
content
=
fs
.
readFileSync
(
const
content
=
fs
.
readFileSync
(
`
${
__dirname
}
/templates/
${
filename
}
.template`
,
`
${
__dirname
}
/templates/
${
filename
}
.template`
,
'utf8'
'utf8'
...
@@ -40,6 +45,7 @@ const updateConfigFiles = (mode = 'chill') => {
...
@@ -40,6 +45,7 @@ const updateConfigFiles = (mode = 'chill') => {
const
updateLegacyCodes
=
()
=>
{
const
updateLegacyCodes
=
()
=>
{
LEGACY_CODES
.
forEach
(({
name
,
update
})
=>
{
LEGACY_CODES
.
forEach
(({
name
,
update
})
=>
{
log
.
item
(
`Updating
${
name
}
...`
)
const
content
=
fs
.
readFileSync
(
name
,
'utf8'
)
const
content
=
fs
.
readFileSync
(
name
,
'utf8'
)
const
output
=
update
(
content
)
const
output
=
update
(
content
)
fs
.
writeFileSync
(
name
,
output
,
'utf8'
)
fs
.
writeFileSync
(
name
,
output
,
'utf8'
)
...
@@ -49,7 +55,10 @@ const updateLegacyCodes = () => {
...
@@ -49,7 +55,10 @@ const updateLegacyCodes = () => {
const
upgradePackages
=
()
=>
{
const
upgradePackages
=
()
=>
{
const
command
=
const
command
=
'yarn add -D '
+
'yarn add -D '
+
PACKAGES
.
map
(({
name
,
version
})
=>
`
${
name
}
@
${
version
}
`
).
join
(
' '
)
PACKAGES
.
map
(({
name
,
version
})
=>
{
log
.
item
(
`
${
name
}
:⛳️
${
chalk
.
bgGreen
.
black
(
version
)}
`
)
return
`
${
name
}
@
${
version
}
`
}).
join
(
' '
)
const
{
code
,
stderr
}
=
shell
.
exec
(
command
)
const
{
code
,
stderr
}
=
shell
.
exec
(
command
)
if
(
!
code
)
console
.
error
(
stderr
)
if
(
!
code
)
console
.
error
(
stderr
)
}
}
...
...
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