Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
04c972c1
Commit
04c972c1
authored
Aug 18, 2018
by
Nicolas Giard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: installer syscheck + prompt (wip)
parent
96f4e890
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
106 additions
and
4 deletions
+106
-4
main.go
dev/installer/main.go
+52
-4
syscheck.go
dev/installer/syscheck.go
+54
-0
No files found.
dev/installer/main.go
View file @
04c972c1
...
...
@@ -19,29 +19,75 @@ var logo = `
|__/
`
var
finish
=
`
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
| |
| Open http://localhost:3000/ in your browser |
| to complete the installation! |
| |
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`
func
main
()
{
fmt
.
Println
(
chalk
.
Yellow
.
Color
(
logo
))
fmt
.
Println
(
chalk
.
Bold
.
TextStyle
(
"Installer for Wiki.js 2.x"
))
fmt
.
Printf
(
"for %s-%s
\n\n
"
,
runtime
.
GOOS
,
runtime
.
GOARCH
)
fmt
.
Printf
(
"%s-%s
\n\n
"
,
runtime
.
GOOS
,
runtime
.
GOARCH
)
// Check system requirements
fmt
.
Println
(
chalk
.
Bold
.
TextStyle
(
"Verifying system requirements..."
))
CheckNodeJs
()
CheckRAM
()
fmt
.
Println
(
chalk
.
Bold
.
TextStyle
(
"
\n
Setup"
))
// Prompt for build to install
prompt
:=
promptui
.
Select
{
prompt
Build
:=
promptui
.
Select
{
Label
:
"Select Build to install"
,
Items
:
[]
string
{
"Stable"
,
"Dev"
},
Templates
:
&
promptui
.
SelectTemplates
{
Help
:
" "
,
Selected
:
chalk
.
Green
.
Color
(
"✔"
)
+
" Build: {{ . }}"
,
},
}
_
,
result
,
err
:=
prompt
.
Run
()
_
,
_
,
err
:=
promptBuild
.
Run
()
if
err
!=
nil
{
fmt
.
Printf
(
"Prompt failed %v
\n
"
,
err
)
return
}
fmt
.
Printf
(
"You choose %q
\n
"
,
result
)
// Choose database driver
promptDB
:=
promptui
.
Select
{
Label
:
"Select database driver"
,
Items
:
[]
string
{
"MariaDB"
,
"MySQL"
,
"MS SQL Server"
,
"PostgreSQL"
,
"SQLite"
},
Templates
:
&
promptui
.
SelectTemplates
{
Help
:
" "
,
Selected
:
chalk
.
Green
.
Color
(
"✔"
)
+
" Database Driver: {{ . }}"
,
},
Size
:
10
,
}
_
,
_
,
err
=
promptDB
.
Run
()
// Port
promptPort
:=
promptui
.
Prompt
{
Label
:
"Port"
,
Default
:
"3000"
,
Templates
:
&
promptui
.
PromptTemplates
{
Success
:
chalk
.
Green
.
Color
(
"✔"
)
+
" Port: {{ . }}"
,
},
}
_
,
err
=
promptPort
.
Run
()
// Download archives...
fmt
.
Println
(
chalk
.
Bold
.
TextStyle
(
"
\n
Downloading packages..."
))
uiprogress
.
Start
()
bar
:=
uiprogress
.
AddBar
(
100
)
...
...
@@ -51,4 +97,6 @@ func main() {
for
bar
.
Incr
()
{
time
.
Sleep
(
time
.
Millisecond
*
20
)
}
fmt
.
Println
(
"
\n
"
+
chalk
.
Yellow
.
Color
(
finish
))
}
dev/installer/syscheck.go
0 → 100644
View file @
04c972c1
package
main
import
(
"fmt"
"log"
"os"
"os/exec"
"github.com/blang/semver"
"github.com/pbnjay/memory"
"github.com/ttacon/chalk"
)
const
nodejsSemverRange
=
">=8.11.3 <10.0.0"
const
ramMin
=
768
// CheckNodeJs checks if Node.js is installed and has minimal supported version
func
CheckNodeJs
()
bool
{
cmd
:=
exec
.
Command
(
"node"
,
"-v"
)
cmdOutput
,
err
:=
cmd
.
CombinedOutput
()
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
validRange
:=
semver
.
MustParseRange
(
nodejsSemverRange
)
nodeVersion
,
err
:=
semver
.
ParseTolerant
(
string
(
cmdOutput
[
:
]))
if
!
validRange
(
nodeVersion
)
{
fmt
.
Printf
(
chalk
.
Red
.
Color
(
"Error: Installed Node.js version is not supported! %s"
),
nodejsSemverRange
)
os
.
Exit
(
1
)
}
fmt
.
Printf
(
chalk
.
Green
.
Color
(
"✔"
)
+
" Node.js %s: OK
\n
"
,
nodeVersion
.
String
())
return
true
}
// CheckRAM checks if system total RAM meets requirements
func
CheckRAM
()
bool
{
var
totalRAM
=
memory
.
TotalMemory
()
/
1024
/
1024
if
totalRAM
<
ramMin
{
fmt
.
Printf
(
chalk
.
Red
.
Color
(
"Error: System does not meet RAM requirements. %s MB minimum."
),
ramMin
)
os
.
Exit
(
1
)
}
fmt
.
Printf
(
chalk
.
Green
.
Color
(
"✔"
)
+
" Total System RAM %d MB: OK
\n
"
,
totalRAM
)
return
true
}
// CheckNetworkAccess checks if download server can be reached
func
CheckNetworkAccess
()
bool
{
// TODO
return
true
}
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