Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
console
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
MyCard
console
Commits
6ed6079d
Commit
6ed6079d
authored
Apr 28, 2017
by
nano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete local files
parent
045e05c1
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
290 additions
and
199 deletions
+290
-199
.idea/workspace.xml
.idea/workspace.xml
+147
-154
config.ts
config.ts
+4
-1
migrate.ts
migrate.ts
+92
-26
package/main.ts
package/main.ts
+3
-0
src/models/App.ts
src/models/App.ts
+34
-18
src/routes/upload.ts
src/routes/upload.ts
+6
-0
test.ts
test.ts
+4
-0
No files found.
.idea/workspace.xml
View file @
6ed6079d
This diff is collapsed.
Click to expand it.
config.ts
View file @
6ed6079d
import
*
as
path
from
'
path
'
;
import
*
as
path
from
'
path
'
;
let
baseUrl
=
'
http://127.0.01:8001
'
let
baseUrl
=
'
http://127.0.01:8001
'
let
testUrl
=
'
http://114.215.243.95:8001
'
export
default
{
export
default
{
upload_path
:
path
.
join
(
__dirname
,
'
./test/upload
'
),
upload_path
:
path
.
join
(
__dirname
,
'
./test/upload
'
),
download_path
:
path
.
join
(
__dirname
,
'
./test/release/downloads
'
),
download_path
:
path
.
join
(
__dirname
,
'
./test/release/downloads
'
),
new_apps_json
:
`
${
baseUrl
}
/v2/apps`
,
new_apps_json
:
`
${
baseUrl
}
/v2/apps`
,
upload_url
:
`
${
testUrl
}
/v1/upload/packageUrl`
,
old_apps_json
:
'
https://api.moecube.com/apps.json
'
,
old_apps_json
:
'
https://api.moecube.com/apps.json
'
,
new_package
:
`
${
baseUrl
}
/v1/package/`
,
new_app
:
(
appId
)
=>
`
${
baseUrl
}
/v1/app/
${
appId
}
`
,
new_app
:
(
appId
)
=>
`
${
baseUrl
}
/v1/app/
${
appId
}
`
,
old_metalinks
:
(
package_id
)
=>
`https://cdn01.moecube.com/release/metalinks/
${
package_id
}
.meta4
llf
`
,
old_metalinks
:
(
package_id
)
=>
`https://cdn01.moecube.com/release/metalinks/
${
package_id
}
.meta4`
,
new_metalinks
:
(
package_id
)
=>
`
${
baseUrl
}
/
${
package_id
}
/meta`
,
new_metalinks
:
(
package_id
)
=>
`
${
baseUrl
}
/
${
package_id
}
/meta`
,
old_checksums
:
(
package_id
)
=>
`https://cdn01.moecube.com/release/checksums/
${
package_id
}
`
,
old_checksums
:
(
package_id
)
=>
`https://cdn01.moecube.com/release/checksums/
${
package_id
}
`
,
new_checksums
:
(
package_id
)
=>
`
${
baseUrl
}
/
${
package_id
}
/checksum`
,
new_checksums
:
(
package_id
)
=>
`
${
baseUrl
}
/
${
package_id
}
/checksum`
,
...
...
migrate.ts
View file @
6ed6079d
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
import
config
from
'
./config
'
;
import
config
from
'
./config
'
;
import
*
as
uuid
from
'
uuid
'
;
import
*
as
_
from
'
lodash
'
;
import
{
XmlDocument
}
from
'
xmldoc
'
;
let
apps
=
{};
const
locales
=
[
'
zh-CN
'
,
'
zh-TW
'
,
'
en-US
'
,
'
ja-JP
'
];
const
languagePack
=
[
'
zh-CN
'
,
'
en-US
'
];
const
platforms
=
[
'
win32
'
,
'
darwin
'
];
const
lang
=
{
'
en-US
'
:
{
'
en-US
'
:
'
English
'
,
'
zh-CN
'
:
'
Simplified Chinese
'
,
'
zh-TW
'
:
'
Traditional Chinese
'
,
'
language_pack
'
:
'
Language Pack
'
},
'
zh-CN
'
:
{
'
en-US
'
:
'
英文
'
,
'
zh-CN
'
:
'
简体中文
'
,
'
zh-TW
'
:
'
繁体中文
'
,
'
language_pack
'
:
'
语言包
'
}
};
async
function
createPackage
(
app
)
{
return
await
axios
.
post
(
config
.
new_package
,
{
id
:
uuid
.
v1
(),
appId
:
app
.
id
,
locales
:
locales
,
platforms
:
platforms
,
version
:
'
0.0.1
'
,
});
}
async
function
updatePackage
(
app
,
pack
)
{
let
{
data
}
=
await
axios
.
get
(
config
.
old_metalinks
(
app
.
id
));
const
xml
=
new
XmlDocument
(
data
);
const
rawUrl
=
xml
.
valueWithPath
(
'
file.url
'
);
const
url
=
rawUrl
.
replace
(
'
https://r.my-card.in/dist/
'
,
'
https://r.my-card.in/release/dist/
'
);
if
(
app
.
name
==
'
th1
'
)
{
return
await
axios
.
post
(
config
.
upload_url
,
{
_id
:
pack
.
_id
,
url
});
}
}
async
function
createApp
(
app
)
{
async
function
createApp
(
app
)
{
return
await
axios
.
post
(
config
.
new_app
(
app
.
id
),
{
return
await
axios
.
post
(
config
.
new_app
(
app
.
id
),
{
...
@@ -11,30 +57,46 @@ async function createApp(app) {
...
@@ -11,30 +57,46 @@ async function createApp(app) {
});
});
}
}
function
handleName
(
app
)
{
return
Object
.
assign
({},
...
languagePack
.
map
(
language
=>
({
/* tslint:disable */
[
language
]:
`
${
apps
[
app
.
parent
][
'
name
'
][
language
]}
${
lang
[
language
][
'
language_pack
'
]}
(
${
app
.
locales
.
map
(
locale
=>
lang
[
language
][
locale
])}
)`
/* tslint:enable */
})));
}
async
function
updateApp
(
app
)
{
async
function
updateApp
(
app
)
{
const
{
id
,
name
,
description
,
developers
,
publishers
,
released_at
,
category
,
tags
,
dependencies
,
references
,
homepage
,
actions
,
version
,
conference
,
icon
,
cover
,
background
,
news
,
...
other
}
=
app
;
const
{
return
await
axios
.
patch
(
config
.
new_app
(
app
.
id
),
{
id
,
name
,
description
,
developers
,
publishers
,
released_at
,
category
,
tags
,
dependencies
,
references
,
id
,
homepage
,
actions
,
version
,
conference
,
icon
,
cover
,
background
,
locales
,
author
,
news
,
...
other
name
,
}
=
app
;
description
,
await
developers
,
axios
.
patch
(
config
.
new_app
(
app
.
id
),
{
publishers
,
id
,
released_at
,
name
:
name
||
handleName
(
app
),
category
,
description
,
tags
,
developers
,
dependencies
,
publishers
,
references
,
released_at
,
homepage
,
category
,
homepage
,
tags
,
actions
,
dependencies
,
version
,
references
,
conference
,
homepage
,
icon
,
actions
,
cover
,
version
,
background
,
conference
,
news
:
{}
icon
,
...
other
,
cover
,
});
background
,
locales
:
locales
||
[],
news
:
{},
...
other
,
});
let
{
data
}
=
await
createPackage
(
app
);
await
updatePackage
(
app
,
data
);
}
}
...
@@ -44,9 +106,13 @@ async function main() {
...
@@ -44,9 +106,13 @@ async function main() {
let
{
data
}
=
await
axios
.
get
(
config
.
old_apps_json
);
let
{
data
}
=
await
axios
.
get
(
config
.
old_apps_json
);
try
{
try
{
for
(
let
app
of
data
)
{
for
(
let
app
of
_
.
sampleSize
(
data
,
5
))
{
await
createApp
(
app
).
catch
(
error
=>
{});
if
(
!
[
'
ygopro
'
,
'
desmume
'
,
'
test
'
].
includes
(
app
.
id
))
{
await
updateApp
(
app
);
apps
[
app
.
id
]
=
app
;
await
createApp
(
app
).
catch
(
error
=>
{
});
await
updateApp
(
app
);
}
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
trace
(
e
);
console
.
trace
(
e
);
...
...
package/main.ts
View file @
6ed6079d
...
@@ -79,6 +79,9 @@ export async function bundle(...args) {
...
@@ -79,6 +79,9 @@ export async function bundle(...args) {
let
fullPath
=
path
.
join
(
path
.
dirname
(
filePath
),
`
${
fullHash
}
.tar.gz`
);
let
fullPath
=
path
.
join
(
path
.
dirname
(
filePath
),
`
${
fullHash
}
.tar.gz`
);
await
fs
.
renameAsync
(
filePath
,
fullPath
);
await
fs
.
renameAsync
(
filePath
,
fullPath
);
await
fs
.
removeAsync
(
uploadFile_path
)
await
fs
.
removeAsync
(
package_path
)
return
{
return
{
distPath
:
dist_path
,
distPath
:
dist_path
,
files
:
Array
.
from
(
files
.
values
()),
files
:
Array
.
from
(
files
.
values
()),
...
...
src/models/App.ts
View file @
6ed6079d
...
@@ -9,21 +9,32 @@ interface Platform<T> {
...
@@ -9,21 +9,32 @@ interface Platform<T> {
[
platform
:
string
]:
T
;
[
platform
:
string
]:
T
;
}
}
interface
Package
{
// interface Package {
id
:
string
;
// id: string;
name
:
string
;
// name: string;
platforms
:
Platform
<
string
[]
>
;
// platforms: Platform<string[]>;
locales
:
I18n
<
string
[]
>
;
// locales: I18n<string[]>;
files
:
File
[];
// files: File[];
}
// }
//
// interface File {
// path: string;
// size: number;
// hash: string;
// }
interface
File
{
interface
Trailer
{
path
:
string
;
type
:
string
;
size
:
number
;
url
:
string
;
hash
:
string
;
poster
:
string
;
}
}
interface
Achievement
{
name
:
string
;
description
:
string
;
image
:
string
;
progress_max
:
number
;
}
export
interface
App
{
export
interface
App
{
...
@@ -37,7 +48,7 @@ export interface App {
...
@@ -37,7 +48,7 @@ export interface App {
released_at
?:
string
;
released_at
?:
string
;
category
?:
string
;
category
?:
string
;
parent
?:
string
;
parent
?:
string
;
tag
?:
string
[];
tag
s
?:
string
[];
dependencies
?:
Platform
<
string
[]
>
;
dependencies
?:
Platform
<
string
[]
>
;
references
?:
Platform
<
string
[]
>
;
references
?:
Platform
<
string
[]
>
;
homepage
?:
string
;
homepage
?:
string
;
...
@@ -52,6 +63,8 @@ export interface App {
...
@@ -52,6 +63,8 @@ export interface App {
cover
?:
string
;
cover
?:
string
;
background
?:
string
;
background
?:
string
;
created_at
?:
Date
;
created_at
?:
Date
;
trailer
?:
Trailer
[];
achievements
?:
Achievement
[];
}
}
@
Collection
(
'
apps
'
)
@
Collection
(
'
apps
'
)
...
@@ -78,7 +91,7 @@ export class AppSchema extends Instance<App, AppSchema> implements App {
...
@@ -78,7 +91,7 @@ export class AppSchema extends Instance<App, AppSchema> implements App {
@
Property
(
String
,
false
)
@
Property
(
String
,
false
)
parent
?:
string
;
parent
?:
string
;
@
Property
(
Array
,
false
)
@
Property
(
Array
,
false
)
tag
?:
string
[];
tag
s
?:
string
[];
@
Property
(
Object
,
false
)
@
Property
(
Object
,
false
)
dependencies
?:
Platform
<
string
[]
>
;
dependencies
?:
Platform
<
string
[]
>
;
@
Property
(
Object
,
false
)
@
Property
(
Object
,
false
)
...
@@ -90,7 +103,7 @@ export class AppSchema extends Instance<App, AppSchema> implements App {
...
@@ -90,7 +103,7 @@ export class AppSchema extends Instance<App, AppSchema> implements App {
@
Property
(
Object
,
false
)
@
Property
(
Object
,
false
)
actions
?:
Platform
<
{
[
key
:
string
]:
{
execuate
:
string
,
args
:
string
[],
env
:
{
[
key
:
string
]:
string
}
}
}
>
;
actions
?:
Platform
<
{
[
key
:
string
]:
{
execuate
:
string
,
args
:
string
[],
env
:
{
[
key
:
string
]:
string
}
}
}
>
;
@
Property
(
Object
,
false
)
@
Property
(
Object
,
false
)
files
?:
{
[
key
:
string
]:
{
sync
:
boolean
,
ignore
:
boolean
}
};
files
?:
{
[
key
:
string
]:
{
sync
:
boolean
,
ignore
:
boolean
}
};
@
Property
(
Object
,
false
)
@
Property
(
Object
,
false
)
version
?:
Platform
<
string
>
;
version
?:
Platform
<
string
>
;
@
Property
(
Object
,
false
)
@
Property
(
Object
,
false
)
...
@@ -105,10 +118,13 @@ export class AppSchema extends Instance<App, AppSchema> implements App {
...
@@ -105,10 +118,13 @@ export class AppSchema extends Instance<App, AppSchema> implements App {
cover
?:
string
;
cover
?:
string
;
@
Property
(
String
,
false
)
@
Property
(
String
,
false
)
background
?:
string
;
background
?:
string
;
// @Property(Array, false)
// packages?: Package[];
@
Property
(
Date
,
false
)
@
Property
(
Date
,
false
)
created_at
:
Date
;
created_at
?:
Date
;
@
Property
(
Array
,
false
)
trailer
?:
Trailer
[];
@
Property
(
Array
,
false
)
achievements
?:
Achievement
[];
static
onCreating
(
app
:
App
)
{
static
onCreating
(
app
:
App
)
{
app
.
created_at
=
new
Date
();
app
.
created_at
=
new
Date
();
...
...
src/routes/upload.ts
View file @
6ed6079d
...
@@ -108,6 +108,9 @@ export const UploadPackage = async (ctx: Context) => {
...
@@ -108,6 +108,9 @@ export const UploadPackage = async (ctx: Context) => {
await
mongodb
.
Packages
.
update
({
id
:
pack
!
.
id
},
{
$set
:
{
status
:
'
deprecated
'
}},
{
multi
:
true
});
await
mongodb
.
Packages
.
update
({
id
:
pack
!
.
id
},
{
$set
:
{
status
:
'
deprecated
'
}},
{
multi
:
true
});
await
pack
!
.
save
();
await
pack
!
.
save
();
// 上传完,干掉本地目录
await
fs
.
removeAsync
(
bundled
.
distPath
)
}
catch
(
e
)
{
}
catch
(
e
)
{
pack
!
.
status
=
'
failed
'
;
pack
!
.
status
=
'
failed
'
;
...
@@ -170,6 +173,9 @@ const uploadPackageUrl = async (ctx: Context) => {
...
@@ -170,6 +173,9 @@ const uploadPackageUrl = async (ctx: Context) => {
await
mongodb
.
Packages
.
update
({
id
:
pack
!
.
id
},
{
$set
:
{
status
:
'
deprecated
'
}},
{
multi
:
true
});
await
mongodb
.
Packages
.
update
({
id
:
pack
!
.
id
},
{
$set
:
{
status
:
'
deprecated
'
}},
{
multi
:
true
});
await
pack
!
.
save
();
await
pack
!
.
save
();
// 上传完,干掉本地目录
await
fs
.
removeAsync
(
bundled
.
distPath
)
}
catch
(
e
)
{
}
catch
(
e
)
{
pack
!
.
status
=
'
failed
'
;
pack
!
.
status
=
'
failed
'
;
await
pack
!
.
save
();
await
pack
!
.
save
();
...
...
test.ts
View file @
6ed6079d
...
@@ -28,9 +28,13 @@ async function test_download() {
...
@@ -28,9 +28,13 @@ async function test_download() {
const
app
:
any
=
_
.
sample
(
apps
);
const
app
:
any
=
_
.
sample
(
apps
);
console
.
log
(
`正在测试
${
app
.
id
}
的 下载`
);
console
.
log
(
`正在测试
${
app
.
id
}
的 下载`
);
const
metalink
=
await
(
await
fetch
(
config
.
new_metalinks
(
app
.
id
))).
text
();
const
metalink
=
await
(
await
fetch
(
config
.
new_metalinks
(
app
.
id
))).
text
();
const
xml
=
new
XmlDocument
(
metalink
);
const
xml
=
new
XmlDocument
(
metalink
);
const
url
=
xml
.
valueWithPath
(
'
file.url
'
);
const
url
=
xml
.
valueWithPath
(
'
file.url
'
);
const
response
=
await
fetch
(
url
,
{
method
:
'
HEAD
'
});
const
response
=
await
fetch
(
url
,
{
method
:
'
HEAD
'
});
if
(
!
response
.
ok
)
{
if
(
!
response
.
ok
)
{
throw
`
${
app
.
id
}
的 下载地址
${
url
}
返回
${
response
.
statusText
}
`
;
throw
`
${
app
.
id
}
的 下载地址
${
url
}
返回
${
response
.
statusText
}
`
;
...
...
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