Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
d3709f85
Commit
d3709f85
authored
Jun 25, 2023
by
Jeffrey Morgan
Browse files
build server into desktop app
parent
369108e1
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
27 additions
and
51 deletions
+27
-51
.gitignore
.gitignore
+0
-4
client/forge.config.ts
client/forge.config.ts
+1
-0
client/permissions-plugin.ts
client/permissions-plugin.ts
+0
-24
client/src/app.tsx
client/src/app.tsx
+1
-1
client/src/index.ts
client/src/index.ts
+17
-9
client/webpack.plugins.ts
client/webpack.plugins.ts
+0
-9
models/.gitignore
models/.gitignore
+1
-0
server/.gitignore
server/.gitignore
+5
-0
server/build.py
server/build.py
+1
-3
server/server.py
server/server.py
+1
-1
No files found.
.gitignore
View file @
d3709f85
.DS_Store
.DS_Store
.vscode
.vscode
*.spec
*/build
*/dist
client/resources/server
\ No newline at end of file
client/forge.config.ts
View file @
d3709f85
...
@@ -13,6 +13,7 @@ const config: ForgeConfig = {
...
@@ -13,6 +13,7 @@ const config: ForgeConfig = {
packagerConfig
:
{
packagerConfig
:
{
asar
:
true
,
asar
:
true
,
icon
:
'
./images/icon
'
,
icon
:
'
./images/icon
'
,
extraResource
:
[
'
../server/dist/server
'
],
},
},
rebuildConfig
:
{},
rebuildConfig
:
{},
makers
:
[
new
MakerSquirrel
({}),
new
MakerZIP
({},
[
'
darwin
'
]),
new
MakerRpm
({}),
new
MakerDeb
({})],
makers
:
[
new
MakerSquirrel
({}),
new
MakerZIP
({},
[
'
darwin
'
]),
new
MakerRpm
({}),
new
MakerDeb
({})],
...
...
client/permissions-plugin.ts
deleted
100644 → 0
View file @
369108e1
import
chmodr
from
'
chmodr
'
import
*
as
path
from
'
path
'
interface
PluginOptions
{
resourcePath
:
string
}
class
PermissionsPlugin
{
options
:
PluginOptions
constructor
(
options
:
PluginOptions
)
{
this
.
options
=
options
}
apply
(
compiler
:
any
)
{
compiler
.
hooks
.
afterEmit
.
tap
(
'
PermissionsPlugin
'
,
()
=>
{
chmodr
(
path
.
join
(
this
.
options
.
resourcePath
),
0o755
,
err
=>
{
// this fails on the first call to suppress the error
})
})
}
}
export
default
PermissionsPlugin
client/src/app.tsx
View file @
d3709f85
import
{
useState
}
from
'
react
'
import
{
useState
}
from
'
react
'
const
API_URL
=
'
http://127.0.0.1:500
0
'
const
API_URL
=
'
http://127.0.0.1:500
1
'
type
Message
=
{
type
Message
=
{
sender
:
string
sender
:
string
...
...
client/src/index.ts
View file @
d3709f85
...
@@ -21,24 +21,32 @@ const createWindow = (): void => {
...
@@ -21,24 +21,32 @@ const createWindow = (): void => {
minWidth
:
400
,
minWidth
:
400
,
minHeight
:
300
,
minHeight
:
300
,
titleBarStyle
:
'
hiddenInset
'
,
titleBarStyle
:
'
hiddenInset
'
,
// trafficLightPosition: { x: 20, y: 18 },
// vibrancy: 'titlebar',
transparent
:
true
,
transparent
:
true
,
})
})
// and load the index.html of the app.
mainWindow
.
loadURL
(
MAIN_WINDOW_WEBPACK_ENTRY
)
}
// if the app is packaged then run the server
if
(
app
.
isPackaged
)
{
const
resources
=
process
.
resourcesPath
console
.
log
(
resources
)
// Start the executable
// Start the executable
let
pyExecutable
=
path
.
join
(
__dirname
,
'
../renderer/
resources
/
server
'
)
const
exec
=
path
.
join
(
resources
,
'
server
'
)
console
.
log
(
`Starting
${
pyExecutable
}
`
)
console
.
log
(
`Starting
${
exec
}
`
)
le
t
p
yP
roc
ess
=
spawn
(
pyExecutable
)
cons
t
proc
=
spawn
(
exec
)
p
yP
roc
ess
.
stdout
.
on
(
'
data
'
,
data
=>
{
proc
.
stdout
.
on
(
'
data
'
,
data
=>
{
console
.
log
(
`server:
${
data
}
`
)
console
.
log
(
`server:
${
data
}
`
)
})
})
p
yP
roc
ess
.
stderr
.
on
(
'
data
'
,
data
=>
{
proc
.
stderr
.
on
(
'
data
'
,
data
=>
{
console
.
error
(
`server:
${
data
}
`
)
console
.
error
(
`server:
${
data
}
`
)
})
})
// and load the index.html of the app.
process
.
on
(
'
exit
'
,
()
=>
{
mainWindow
.
loadURL
(
MAIN_WINDOW_WEBPACK_ENTRY
)
proc
.
kill
()
})
}
}
// This method will be called when Electron has finished
// This method will be called when Electron has finished
...
...
client/webpack.plugins.ts
View file @
d3709f85
import
type
IForkTsCheckerWebpackPlugin
from
'
fork-ts-checker-webpack-plugin
'
import
type
IForkTsCheckerWebpackPlugin
from
'
fork-ts-checker-webpack-plugin
'
import
*
as
path
from
'
path
'
import
PermissionsPlugin
from
'
./permissions-plugin
'
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-var-requires
const
ForkTsCheckerWebpackPlugin
:
typeof
IForkTsCheckerWebpackPlugin
=
require
(
'
fork-ts-checker-webpack-plugin
'
)
const
ForkTsCheckerWebpackPlugin
:
typeof
IForkTsCheckerWebpackPlugin
=
require
(
'
fork-ts-checker-webpack-plugin
'
)
const
CopyWebpackPlugin
=
require
(
'
copy-webpack-plugin
'
)
export
const
plugins
=
[
export
const
plugins
=
[
new
ForkTsCheckerWebpackPlugin
({
new
ForkTsCheckerWebpackPlugin
({
logger
:
'
webpack-infrastructure
'
,
logger
:
'
webpack-infrastructure
'
,
}),
}),
new
CopyWebpackPlugin
({
patterns
:
[{
from
:
'
resources
'
,
to
:
'
resources
'
}],
}),
new
PermissionsPlugin
({
resourcePath
:
'
.webpack/renderer/resources/server
'
,
}),
]
]
models/.gitignore
0 → 100644
View file @
d3709f85
*.bin
server/.gitignore
0 → 100644
View file @
d3709f85
.env
.venv
*.spec
build
dist
server/build.py
View file @
d3709f85
import
site
import
site
import
os
import
os
import
shutil
from
PyInstaller.__main__
import
run
as
pyi_run
from
PyInstaller.__main__
import
run
as
pyi_run
# the llama_cpp directory is not included if not explicitly added
# the llama_cpp directory is not included if not explicitly added
...
@@ -13,10 +12,9 @@ args = [
...
@@ -13,10 +12,9 @@ args = [
site_packages_dir
,
site_packages_dir
,
"--add-data"
,
"--add-data"
,
f
"
{
llama_cpp_dir
}{
os
.
pathsep
}
llama_cpp"
,
f
"
{
llama_cpp_dir
}{
os
.
pathsep
}
llama_cpp"
,
"--onefile"
,
"--onefile"
]
]
# generate the .spec file and run PyInstaller
# generate the .spec file and run PyInstaller
pyi_run
(
args
)
pyi_run
(
args
)
shutil
.
copy2
(
"dist/server"
,
"../client/resources/server"
)
server/server.py
View file @
d3709f85
...
@@ -76,4 +76,4 @@ def generate():
...
@@ -76,4 +76,4 @@ def generate():
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
app
.
run
(
debug
=
True
,
threaded
=
True
,
port
=
500
0
)
app
.
run
(
debug
=
True
,
threaded
=
True
,
port
=
500
1
)
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