FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
NodeODM/scripts/winbundle.js at master · omerkalkan/NodeODM · GitHub
omerkalkan
/
NodeODM
Public
forked from
OpenDroneMap/NodeODM
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
NodeODM
/
scripts
/
winbundle.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
134 lines (118 loc) · 3.98 KB
Breadcrumbs
NodeODM
/
scripts
/
winbundle.js
Copy path
File metadata and controls
134 lines (118 loc) · 3.98 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
const
fs
=
require
(
'fs'
)
;
const
spawnSync
=
require
(
'child_process'
)
.
spawnSync
;
const
path
=
require
(
'path'
)
;
const
request
=
require
(
'request'
)
;
const
async
=
require
(
'async'
)
;
const
nodeUnzip
=
require
(
'node-unzip-2'
)
;
const
archiver
=
require
(
'archiver'
)
;
const
bundleName
=
"nodeodm-windows-x64.zip"
;
const
download
=
function
(
uri
,
filename
,
callback
)
{
console
.
log
(
`Downloading
${
uri
}
`
)
;
request
.
head
(
uri
,
function
(
err
,
res
,
body
)
{
if
(
err
)
callback
(
err
)
;
else
{
request
(
uri
)
.
pipe
(
fs
.
createWriteStream
(
filename
)
)
.
on
(
'close'
,
callback
)
;
}
}
)
;
}
;
function
downloadApp
(
destFolder
,
appUrl
,
cb
)
{
if
(
!
fs
.
existsSync
(
destFolder
)
)
fs
.
mkdirSync
(
destFolder
,
{
recursive
:
true
}
)
;
else
{
cb
(
)
;
return
;
}
let
zipPath
=
path
.
join
(
destFolder
,
"download.zip"
)
;
let
_called
=
false
;
const
done
=
(
err
)
=>
{
if
(
!
_called
)
{
// Bug in nodeUnzip, makes this get called twice
if
(
fs
.
existsSync
(
zipPath
)
)
fs
.
unlinkSync
(
zipPath
)
;
_called
=
true
;
cb
(
err
)
;
}
}
;
download
(
appUrl
,
zipPath
,
err
=>
{
if
(
err
)
done
(
err
)
;
else
{
// Unzip
console
.
log
(
`Extracting
${
zipPath
}
`
)
;
fs
.
createReadStream
(
zipPath
)
.
pipe
(
nodeUnzip
.
Extract
(
{
path
:
destFolder
}
)
)
.
on
(
'close'
,
done
)
.
on
(
'error'
,
done
)
;
}
}
)
;
}
async
.
series
(
[
cb
=>
{
// Cleanup directories
console
.
log
(
"Cleaning up folders"
)
;
for
(
let
dir
of
[
"data"
,
"tmp"
]
)
{
for
(
let
entry
of
fs
.
readdirSync
(
dir
)
)
{
if
(
entry
!==
".gitignore"
)
{
console
.
log
(
`Removing
${
dir
}
/
${
entry
}
`
)
;
fs
.
rmdirSync
(
path
.
join
(
dir
,
entry
)
,
{
recursive
:
true
}
)
;
}
}
}
cb
(
)
;
}
,
cb
=>
{
downloadApp
(
path
.
join
(
"apps"
,
"7z"
)
,
"https://github.com/OpenDroneMap/NodeODM/releases/download/v2.1.0/7z19.zip"
,
cb
)
;
}
,
cb
=>
{
downloadApp
(
path
.
join
(
"apps"
,
"unzip"
)
,
"https://github.com/OpenDroneMap/NodeODM/releases/download/v2.1.0/unzip600.zip"
,
cb
)
;
}
,
cb
=>
{
console
.
log
(
"Building executable"
)
;
const
code
=
spawnSync
(
'nexe.cmd'
,
[
'index.js'
,
'-t'
,
'windows-x64-12.16.3'
,
'-o'
,
'nodeodm.exe'
]
,
{
stdio
:
"pipe"
}
)
.
status
;
if
(
code
===
0
)
cb
(
)
;
else
cb
(
new
Error
(
`nexe returned non-zero error code:
${
code
}
`
)
)
;
}
,
cb
=>
{
// Zip
const
outFile
=
path
.
join
(
"dist"
,
bundleName
)
;
if
(
!
fs
.
existsSync
(
"dist"
)
)
fs
.
mkdirSync
(
"dist"
)
;
if
(
fs
.
existsSync
(
outFile
)
)
fs
.
unlinkSync
(
outFile
)
;
let
output
=
fs
.
createWriteStream
(
outFile
)
;
let
archive
=
archiver
.
create
(
'zip'
,
{
zlib
:
{
level
:
5
}
// Sets the compression level (1 = best speed since most assets are already compressed)
}
)
;
archive
.
on
(
'finish'
,
(
)
=>
{
console
.
log
(
"Done!"
)
;
cb
(
)
;
}
)
;
archive
.
on
(
'error'
,
err
=>
{
console
.
error
(
`Could not archive .zip file:
${
err
.
message
}
`
)
;
cb
(
err
)
;
}
)
;
const
files
=
[
"apps"
,
"data"
,
"helpers"
,
"public"
,
"scripts"
,
"tests"
,
"tmp"
,
"config-default.json"
,
"LICENSE"
,
"SOURCE"
,
"package.json"
,
"nodeodm.exe"
]
;
archive
.
pipe
(
output
)
;
files
.
forEach
(
file
=>
{
console
.
log
(
`Adding
${
file
}
`
)
;
let
stat
=
fs
.
lstatSync
(
file
)
;
if
(
stat
.
isFile
(
)
)
{
archive
.
file
(
file
,
{
name
:
path
.
basename
(
file
)
}
)
;
}
else
if
(
stat
.
isDirectory
(
)
)
{
archive
.
directory
(
file
,
path
.
basename
(
file
)
)
;
}
else
{
logger
.
error
(
`Could not add
${
file
}
`
)
;
}
}
)
;
archive
.
finalize
(
)
;
}
]
,
(
err
)
=>
{
if
(
err
)
console
.
log
(
`Bundle failed:
${
err
}
`
)
;
else
console
.
log
(
`Bundle ==> dist/
${
bundleName
}
`
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL