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
cafd7f2a
Commit
cafd7f2a
authored
Aug 21, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v3-newpackager' into v3
parents
47f3b906
fa8af8ea
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
21 deletions
+55
-21
app/app.ts
app/app.ts
+22
-9
app/apps.service.ts
app/apps.service.ts
+32
-11
package.json
package.json
+1
-1
No files found.
app/app.ts
View file @
cafd7f2a
...
@@ -94,34 +94,47 @@ export class App {
...
@@ -94,34 +94,47 @@ export class App {
background
:
string
;
background
:
string
;
price
:
{
[
currency
:
string
]:
string
};
price
:
{
[
currency
:
string
]:
string
};
key
?:
string
;
key
?:
string
static
downloadUrl
(
app
:
App
,
platform
:
string
,
locale
:
string
):
string
{
static
getQuerySuffix
(
platform
:
string
,
locale
:
string
,
arch
:
string
)
{
const
params
=
new
URLSearchParams
();
params
.
set
(
'
platform
'
,
platform
);
params
.
set
(
'
locale
'
,
locale
);
params
.
set
(
'
arch
'
,
arch
);
return
params
.
toString
();
}
static
downloadUrl
(
app
:
App
,
platform
:
string
,
locale
:
string
,
arch
:
string
):
string
{
/*
if (app.id === 'ygopro') {
if (app.id === 'ygopro') {
return `https://sthief.moecube.com:444/metalinks/${app.id}-${process.platform}-${locale}/${app.version}`;
return `https://sthief.moecube.com:444/metalinks/${app.id}-${process.platform}-${locale}/${app.version}`;
} else if (app.id === 'desmume') {
} else if (app.id === 'desmume') {
return `https://sthief.moecube.com:444/metalinks/${app.id}-${process.platform}/${app.version}`;
return `https://sthief.moecube.com:444/metalinks/${app.id}-${process.platform}/${app.version}`;
}
}
return `https://sthief.moecube.com:444/metalinks/${app.id}/${app.version}`;
return `https://sthief.moecube.com:444/metalinks/${app.id}/${app.version}`;
*/
return
`https://sapi.moecube.com:444/release/update/metalinks/
${
app
.
id
}
/
${
app
.
version
}
?
${
this
.
getQuerySuffix
(
platform
,
locale
,
arch
)}
`
;
}
}
static
checksumUrl
(
app
:
App
,
platform
:
string
,
locale
:
string
):
string
{
static
checksumUrl
(
app
:
App
,
platform
:
string
,
locale
:
string
,
arch
:
string
):
string
{
if
(
app
.
id
===
'
ygopro
'
)
{
/*
if (app.id === 'ygopro') {
return `https://sthief.moecube.com:444/checksums/${app.id}-${platform}-${locale}/${app.version}`;
return `https://sthief.moecube.com:444/checksums/${app.id}-${platform}-${locale}/${app.version}`;
} else if (app.id === 'desmume') {
} else if (app.id === 'desmume') {
return `https://sthief.moecube.com:444/checksums/${app.id}-${platform}/${app.version}`;
return `https://sthief.moecube.com:444/checksums/${app.id}-${platform}/${app.version}`;
}
}
return
`https://sthief.moecube.com:444/checksums/
${
app
.
id
}
/
${
app
.
version
}
`
;
return `https://sthief.moecube.com:444/checksums/${app.id}/${app.version}`;*/
return
`https://sapi.moecube.com:444/release/update/checksums/
${
app
.
id
}
/
${
app
.
version
}
?
${
this
.
getQuerySuffix
(
platform
,
locale
,
arch
)}
`
;
}
}
static
updateUrl
(
app
:
App
,
platform
:
string
,
locale
:
string
):
string
{
static
updateUrl
(
app
:
App
,
platform
:
string
,
locale
:
string
,
arch
:
string
):
string
{
if
(
app
.
id
===
'
ygopro
'
)
{
/*
if (app.id === 'ygopro') {
return `https://sthief.moecube.com:444/update/${app.id}-${platform}-${locale}/${app.version}`;
return `https://sthief.moecube.com:444/update/${app.id}-${platform}-${locale}/${app.version}`;
} else if (app.id === 'desmume') {
} else if (app.id === 'desmume') {
return `https://sthief.moecube.com:444/update/${app.id}-${platform}/${app.version}`;
return `https://sthief.moecube.com:444/update/${app.id}-${platform}/${app.version}`;
}
}
*/
return
`https://s
thief.moecube.com:444/update/
${
app
.
id
}
/
${
app
.
version
}
`
;
return
`https://s
api.moecube.com:444/release/update/update/
${
app
.
id
}
/
${
app
.
version
}
?
${
this
.
getQuerySuffix
(
platform
,
locale
,
arch
)
}
`
;
}
}
isBought
():
Boolean
{
isBought
():
Boolean
{
...
...
app/apps.service.ts
View file @
cafd7f2a
...
@@ -21,6 +21,7 @@ import {ComparableSet} from './shared/ComparableSet';
...
@@ -21,6 +21,7 @@ import {ComparableSet} from './shared/ComparableSet';
import
{
AppsJson
}
from
'
./apps-json-type
'
;
import
{
AppsJson
}
from
'
./apps-json-type
'
;
import
Timer
=
NodeJS
.
Timer
;
import
Timer
=
NodeJS
.
Timer
;
import
ReadableStream
=
NodeJS
.
ReadableStream
;
import
ReadableStream
=
NodeJS
.
ReadableStream
;
import
*
as
os
from
'
os
'
;
const
Logger
=
{
const
Logger
=
{
info
:
(...
message
:
any
[])
=>
{
info
:
(...
message
:
any
[])
=>
{
...
@@ -57,9 +58,24 @@ export class AppsService {
...
@@ -57,9 +58,24 @@ export class AppsService {
map
:
Map
<
string
,
string
>
=
new
Map
();
map
:
Map
<
string
,
string
>
=
new
Map
();
connections
=
new
Map
<
App
,
Connection
>
();
connections
=
new
Map
<
App
,
Connection
>
();
maotama
:
Promise
<
ChildProcess
>
;
maotama
:
Promise
<
ChildProcess
>
;
readonly
tarPath
=
process
.
platform
===
'
win32
'
?
private
systemBinPath
(
executableName
:
string
)
{
path
.
join
(
process
.
env
[
'
NODE_ENV
'
]
===
'
production
'
?
process
.
resourcesPath
!
:
''
,
'
bin
'
,
'
bsdtar.exe
'
)
return
path
.
join
(
process
.
env
[
'
NODE_ENV
'
]
===
'
production
'
?
process
.
resourcesPath
!
:
''
,
'
bin
'
,
executableName
);
:
'
bsdtar
'
;
}
private
get
tarPath
()
{
if
(
process
.
platform
===
'
linux
'
)
{
return
'
tar
'
;
}
else
if
(
process
.
platform
===
'
win32
'
)
{
return
this
.
systemBinPath
(
'
bsdtar.exe
'
);
}
else
{
return
this
.
systemBinPath
(
'
gtar
'
);
}
}
private
getTarStream
(
p
:
child_process
.
ChildProcessWithoutNullStreams
)
{
return
process
.
platform
===
'
win32
'
?
p
.
stderr
:
p
.
stdout
;
}
private
apps
:
Map
<
string
,
App
>
;
private
apps
:
Map
<
string
,
App
>
;
constructor
(
private
http
:
Http
,
private
settingsService
:
SettingsService
,
private
ref
:
ApplicationRef
,
constructor
(
private
http
:
Http
,
private
settingsService
:
SettingsService
,
private
ref
:
ApplicationRef
,
...
@@ -81,7 +97,7 @@ export class AppsService {
...
@@ -81,7 +97,7 @@ export class AppsService {
}
}
async
loadApps
()
{
async
loadApps
()
{
let
appsURL
=
'
https://sapi.moecube.com:444/apps.json
'
;
let
appsURL
=
'
https://sapi.moecube.com:444/
release/update/
apps.json
'
;
let
keysURL
=
'
https://sapi.moecube.com:444/keys
'
;
let
keysURL
=
'
https://sapi.moecube.com:444/keys
'
;
try
{
try
{
let
data
=
await
this
.
http
.
get
(
appsURL
)
let
data
=
await
this
.
http
.
get
(
appsURL
)
...
@@ -640,7 +656,7 @@ export class AppsService {
...
@@ -640,7 +656,7 @@ export class AppsService {
if
(
!
[
'
zh-CN
'
,
'
en-US
'
,
'
ja-JP
'
].
includes
(
locale
))
{
if
(
!
[
'
zh-CN
'
,
'
en-US
'
,
'
ja-JP
'
].
includes
(
locale
))
{
locale
=
'
en-US
'
;
locale
=
'
en-US
'
;
}
}
let
updateUrl
=
App
.
updateUrl
(
app
,
process
.
platform
,
locale
);
let
updateUrl
=
App
.
updateUrl
(
app
,
process
.
platform
,
locale
,
os
.
arch
()
);
let
metalink
=
await
this
.
http
.
post
(
updateUrl
,
changedFiles
).
map
((
response
)
=>
response
.
text
()).
toPromise
();
let
metalink
=
await
this
.
http
.
post
(
updateUrl
,
changedFiles
).
map
((
response
)
=>
response
.
text
()).
toPromise
();
let
downloadDir
=
path
.
join
(
path
.
dirname
(
app
.
local
!
.
path
),
'
downloading
'
);
let
downloadDir
=
path
.
join
(
path
.
dirname
(
app
.
local
!
.
path
),
'
downloading
'
);
let
downloadId
=
await
this
.
downloadService
.
addMetalink
(
metalink
,
downloadDir
);
let
downloadId
=
await
this
.
downloadService
.
addMetalink
(
metalink
,
downloadDir
);
...
@@ -698,7 +714,7 @@ export class AppsService {
...
@@ -698,7 +714,7 @@ export class AppsService {
if
(
!
[
'
zh-CN
'
,
'
en-US
'
,
'
ja-JP
'
].
includes
(
locale
))
{
if
(
!
[
'
zh-CN
'
,
'
en-US
'
,
'
ja-JP
'
].
includes
(
locale
))
{
locale
=
'
en-US
'
;
locale
=
'
en-US
'
;
}
}
let
metalinkUrl
=
App
.
downloadUrl
(
_app
,
process
.
platform
,
locale
);
let
metalinkUrl
=
App
.
downloadUrl
(
_app
,
process
.
platform
,
locale
,
os
.
arch
()
);
_app
.
status
.
status
=
'
downloading
'
;
_app
.
status
.
status
=
'
downloading
'
;
let
metalink
=
await
this
.
http
.
get
(
metalinkUrl
).
map
((
response
)
=>
response
.
text
()).
toPromise
();
let
metalink
=
await
this
.
http
.
get
(
metalinkUrl
).
map
((
response
)
=>
response
.
text
()).
toPromise
();
let
downloadId
=
await
this
.
downloadService
.
addMetalink
(
metalink
,
dir
);
let
downloadId
=
await
this
.
downloadService
.
addMetalink
(
metalink
,
dir
);
...
@@ -990,13 +1006,18 @@ export class AppsService {
...
@@ -990,13 +1006,18 @@ export class AppsService {
extract
(
file
:
string
,
dir
:
string
):
Observable
<
string
>
{
extract
(
file
:
string
,
dir
:
string
):
Observable
<
string
>
{
return
Observable
.
create
((
observer
:
Observer
<
string
>
)
=>
{
return
Observable
.
create
((
observer
:
Observer
<
string
>
)
=>
{
Logger
.
info
(
'
Start to extract... Command Line:
'
+
this
.
tarPath
,
file
,
dir
);
const
tarArgs
=
[
'
-xvf
'
,
file
,
'
-C
'
,
dir
];
let
tarProcess
=
child_process
.
spawn
(
this
.
tarPath
,
[
'
xvf
'
,
file
,
'
-C
'
,
dir
]);
if
(
process
.
platform
===
'
darwin
'
)
{
tarArgs
.
unshift
(
`--use-compress-program=
${
this
.
systemBinPath
(
'
zstd
'
)}
`
)
}
Logger
.
info
(
'
Start to extract... Command Line:
'
+
this
.
tarPath
,
tarArgs
.
join
(
'
'
));
let
tarProcess
=
child_process
.
spawn
(
this
.
tarPath
,
tarArgs
);
let
rl
=
readline
.
createInterface
({
let
rl
=
readline
.
createInterface
({
input
:
<
ReadableStream
>
tarProcess
.
stderr
,
input
:
this
.
getTarStream
(
tarProcess
)
,
});
});
rl
.
on
(
'
line
'
,
(
input
:
string
)
=>
{
rl
.
on
(
'
line
'
,
(
input
:
string
)
=>
{
observer
.
next
(
input
.
split
(
'
'
,
2
)[
1
]);
const
line
=
input
.
split
(
'
'
,
2
).
pop
();
observer
.
next
(
line
);
});
});
tarProcess
.
on
(
'
exit
'
,
(
code
)
=>
{
tarProcess
.
on
(
'
exit
'
,
(
code
)
=>
{
if
(
code
===
0
)
{
if
(
code
===
0
)
{
...
@@ -1096,7 +1117,7 @@ export class AppsService {
...
@@ -1096,7 +1117,7 @@ export class AppsService {
locale
=
'
en-US
'
;
locale
=
'
en-US
'
;
}
}
let
checksumUrl
=
App
.
checksumUrl
(
app
,
process
.
platform
,
locale
);
let
checksumUrl
=
App
.
checksumUrl
(
app
,
process
.
platform
,
locale
,
os
.
arch
()
);
return
this
.
http
.
get
(
checksumUrl
)
return
this
.
http
.
get
(
checksumUrl
)
.
map
((
response
)
=>
{
.
map
((
response
)
=>
{
let
map
=
new
Map
<
string
,
string
>
();
let
map
=
new
Map
<
string
,
string
>
();
...
...
package.json
View file @
cafd7f2a
{
{
"name"
:
"mycard"
,
"name"
:
"mycard"
,
"version"
:
"3.0.5
0"
,
"version"
:
"3.0.5
1
,
"
description
": "
moecube
",
"
description
": "
moecube
",
"
keywords
": [],
"
keywords
": [],
"
author
": "
zh
99998
<zh
99998
@gmail.com>
",
"
author
": "
zh
99998
<zh
99998
@gmail.com>
",
...
...
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