Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
mycard
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
syntax_j
mycard
Commits
2fe2094d
Commit
2fe2094d
authored
Aug 10, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rework app open
parent
5a2e9e54
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
114 additions
and
90 deletions
+114
-90
app/app.ts
app/app.ts
+113
-2
app/apps.service.ts
app/apps.service.ts
+1
-88
No files found.
app/app.ts
View file @
2fe2094d
import
{
AppLocal
}
from
'
./app-local
'
;
import
*
as
path
from
'
path
'
;
import
*
as
ini
from
'
ini
'
;
import
*
as
fs
from
'
fs
'
;
import
*
as
child_process
from
'
child_process
'
;
export
enum
Category
{
game
,
...
...
@@ -21,13 +25,21 @@ export enum Category {
// uninstalling,
// waiting,
// }
export
interface
Action
{
interpreter
?:
string
;
export
interface
BaseAction
{
execute
:
string
;
args
:
string
[];
env
:
{};
}
export
interface
Action
extends
BaseAction
{
interpreter
?:
string
;
open
?:
App
;
}
export
interface
SpawnAction
extends
BaseAction
{
cwd
?:
string
;
}
export
class
FileOptions
{
sync
:
boolean
;
ignore
:
boolean
;
...
...
@@ -214,4 +226,103 @@ export class App {
return
dependencies
.
every
((
dependency
)
=>
dependency
.
isReady
());
}
async
getSpawnAction
(
children
:
App
[],
action_name
=
'
main
'
,
referencedApp
?:
App
,
referencedAction
?:
Action
,
cwd
?:
string
):
Promise
<
SpawnAction
>
{
const
appCwd
=
(
<
AppLocal
>
this
.
local
).
path
;
if
(
!
cwd
)
{
cwd
=
appCwd
;
}
if
(
this
.
id
===
'
np2fmgen
'
)
{
const
config_file
=
path
.
join
(
this
.
local
!
.
path
,
'
np21nt.ini
'
);
let
config
=
await
new
Promise
((
resolve
,
reject
)
=>
{
fs
.
readFile
(
config_file
,
{
encoding
:
'
utf-8
'
},
(
error
,
data
)
=>
{
if
(
error
)
{
return
reject
(
error
);
}
resolve
(
ini
.
parse
(
data
));
});
});
const
default_config
=
{
clk_mult
:
'
48
'
,
DIPswtch
:
'
3e f3 7b
'
,
SampleHz
:
'
44100
'
,
Latencys
:
'
100
'
,
MIX_TYPE
:
'
true
'
,
windtype
:
'
0
'
};
config
[
'
NekoProject21
'
]
=
Object
.
assign
({},
default_config
,
config
[
'
NekoProject21
'
]);
config
[
'
NekoProject21
'
][
'
HDD1FILE
'
]
=
path
.
win32
.
join
(
process
.
platform
===
'
win32
'
?
''
:
'
Z:
'
,
referencedApp
.
local
!
.
path
,
referencedAction
.
execute
);
config
[
'
NekoProject21
'
][
'
fontfile
'
]
=
path
.
win32
.
join
(
process
.
platform
===
'
win32
'
?
''
:
'
Z:
'
,
referencedApp
.
local
!
.
path
,
'
font.bmp
'
);
await
new
Promise
((
resolve
,
reject
)
=>
{
fs
.
writeFile
(
config_file
,
ini
.
stringify
(
config
),
(
error
)
=>
{
if
(
error
)
{
reject
(
error
);
}
else
{
resolve
(
null
);
}
});
});
cwd
=
appCwd
;
}
let
action
:
Action
=
<
Action
>
this
.
actions
.
get
(
action_name
);
let
args
:
string
[]
=
[];
let
env
=
Object
.
assign
({},
process
.
env
);
for
(
let
child
of
children
)
{
if
(
child
.
isInstalled
())
{
let
_action
=
child
.
actions
.
get
(
action_name
);
if
(
_action
)
{
action
=
_action
;
}
}
}
let
execute
:
string
;
const
appExecute
=
path
.
join
(
cwd
,
action
.
execute
);
if
(
action
.
interpreter
)
{
execute
=
action
.
interpreter
;
args
.
push
(
appExecute
);
}
else
{
execute
=
appExecute
;
}
if
(
action
.
open
)
{
const
np2
=
action
.
open
;
const
openAction
=
await
np2
.
getSpawnAction
([],
'
main
'
,
this
,
action
,
cwd
);
args
=
args
.
concat
(
openAction
.
args
);
args
.
push
(
action
.
execute
);
execute
=
openAction
.
execute
;
cwd
=
openAction
.
cwd
;
}
args
=
args
.
concat
(
action
.
args
);
env
=
Object
.
assign
(
env
,
action
.
env
);
return
{
execute
,
args
,
env
,
cwd
}
}
async
spawnApp
(
children
:
App
[],
action_name
=
'
main
'
)
{
if
(
this
.
id
===
'
th123
'
)
{
let
th105
=
<
App
>
this
.
references
.
get
(
'
th105
'
);
if
(
th105
.
isInstalled
())
{
console
.
log
(
`Reference of th123:
${
th105
}
`
);
const
config_file
=
path
.
join
((
<
AppLocal
>
this
.
local
).
path
,
'
configex123.ini
'
);
let
config
=
ini
.
parse
(
await
fs
.
promises
.
readFile
(
config_file
,
{
encoding
:
'
utf-8
'
}));
const
th105LocalApp
=
(
<
AppLocal
>
th105
.
local
);
const
targetTh105Path
=
th105LocalApp
?
th105LocalApp
.
path
:
(
<
AppLocal
>
this
.
local
).
path
.
replace
(
/th123/g
,
'
th105
'
);
config
[
'
th105path
'
]
=
{
path
:
targetTh105Path
};
await
fs
.
promises
.
writeFile
(
config_file
,
ini
.
stringify
(
config
));
}
}
const
appCwd
=
(
<
AppLocal
>
this
.
local
).
path
;
const
{
execute
,
args
,
env
,
cwd
}
=
await
this
.
getSpawnAction
(
children
,
action_name
);
console
.
log
(
execute
,
args
,
env
,
cwd
,
appCwd
);
return
child_process
.
spawn
(
execute
,
args
,
{
env
:
env
,
cwd
:
cwd
||
appCwd
});
}
}
app/apps.service.ts
View file @
2fe2094d
...
...
@@ -763,95 +763,8 @@ export class AppsService {
async
runApp
(
app
:
App
,
action_name
=
'
main
'
)
{
let
children
=
this
.
findChildren
(
app
);
let
cwd
=
(
<
AppLocal
>
app
.
local
).
path
;
let
action
:
Action
=
<
Action
>
app
.
actions
.
get
(
action_name
);
let
args
:
string
[]
=
[];
let
env
=
Object
.
assign
({},
process
.
env
);
for
(
let
child
of
children
)
{
if
(
child
.
isInstalled
())
{
let
_action
=
child
.
actions
.
get
(
action_name
);
if
(
_action
)
{
action
=
_action
;
}
}
}
let
execute
:
string
;
const
appExecute
=
path
.
join
(
cwd
,
action
.
execute
);
if
(
action
.
interpreter
)
{
execute
=
action
.
interpreter
;
args
.
push
(
appExecute
)
}
else
{
execute
=
appExecute
;
}
if
(
app
.
id
===
'
th123
'
)
{
let
th105
=
<
App
>
app
.
references
.
get
(
'
th105
'
);
if
(
th105
.
isInstalled
())
{
console
.
log
(
`Reference of th123:
${
th105
}
`
);
const
config_file
=
path
.
join
((
<
AppLocal
>
app
.
local
).
path
,
'
configex123.ini
'
);
let
config
=
ini
.
parse
(
await
fs
.
promises
.
readFile
(
config_file
,
{
encoding
:
'
utf-8
'
}));
const
th105LocalApp
=
(
<
AppLocal
>
th105
.
local
);
const
targetTh105Path
=
th105LocalApp
?
th105LocalApp
.
path
:
(
<
AppLocal
>
app
.
local
).
path
.
replace
(
/th123/g
,
'
th105
'
);
config
[
'
th105path
'
]
=
{
path
:
targetTh105Path
};
await
fs
.
promises
.
writeFile
(
config_file
,
ini
.
stringify
(
config
));
}
}
if
(
action
.
open
)
{
let
np2
=
action
.
open
;
let
openAction
:
Action
;
openAction
=
np2
.
actions
.
get
(
'
main
'
)
!
;
let
openPath
=
np2
.
local
!
.
path
;
if
(
action
.
open
.
id
===
'
np2fmgen
'
)
{
const
config_file
=
path
.
join
(
action
.
open
!
.
local
!
.
path
,
'
np21nt.ini
'
);
let
config
=
await
new
Promise
((
resolve
,
reject
)
=>
{
fs
.
readFile
(
config_file
,
{
encoding
:
'
utf-8
'
},
(
error
,
data
)
=>
{
if
(
error
)
{
return
reject
(
error
);
}
resolve
(
ini
.
parse
(
data
));
});
});
const
default_config
=
{
clk_mult
:
'
48
'
,
DIPswtch
:
'
3e f3 7b
'
,
SampleHz
:
'
44100
'
,
Latencys
:
'
100
'
,
MIX_TYPE
:
'
true
'
,
windtype
:
'
0
'
};
config
[
'
NekoProject21
'
]
=
Object
.
assign
({},
default_config
,
config
[
'
NekoProject21
'
]);
config
[
'
NekoProject21
'
][
'
HDD1FILE
'
]
=
path
.
win32
.
join
(
process
.
platform
===
'
win32
'
?
''
:
'
Z:
'
,
app
.
local
!
.
path
,
action
.
execute
);
config
[
'
NekoProject21
'
][
'
fontfile
'
]
=
path
.
win32
.
join
(
process
.
platform
===
'
win32
'
?
''
:
'
Z:
'
,
app
.
local
!
.
path
,
'
font.bmp
'
);
await
new
Promise
((
resolve
,
reject
)
=>
{
fs
.
writeFile
(
config_file
,
ini
.
stringify
(
config
),
(
error
)
=>
{
if
(
error
)
{
reject
(
error
);
}
else
{
resolve
(
null
);
}
});
});
if
(
process
.
platform
!==
'
win32
'
)
{
args
.
push
(
openAction
.
execute
);
args
=
args
.
concat
(
openAction
.
args
);
let
wine
=
openAction
.
open
!
;
openPath
=
wine
.
local
!
.
path
;
openAction
=
openAction
!
.
open
!
.
actions
.
get
(
'
main
'
)
!
;
}
cwd
=
np2
.
local
!
.
path
;
}
args
=
args
.
concat
(
openAction
.
args
);
args
.
push
(
action
.
execute
);
execute
=
path
.
join
(
openPath
,
openAction
.
execute
);
env
=
Object
.
assign
(
env
,
openAction
.
env
);
}
args
=
args
.
concat
(
action
.
args
);
env
=
Object
.
assign
(
env
,
action
.
env
);
console
.
log
(
execute
,
args
,
env
,
cwd
);
let
handle
=
child_process
.
spawn
(
execute
,
args
,
{
env
:
env
,
cwd
:
cwd
});
const
handle
=
await
app
.
spawnApp
(
children
,
action_name
);
handle
.
stdout
.
on
(
'
data
'
,
(
data
)
=>
{
console
.
log
(
`stdout:
${
data
}
`
);
...
...
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