Commit bb825989 authored by 神楽坂玲奈's avatar 神楽坂玲奈

Merge branch 'v3' of github.com:mycard/mycard into v3

parents 14834cc8 35158c17
......@@ -13,7 +13,7 @@ const Aria2 = require('aria2');
@Injectable()
export class DownloadService {
aria2 = new Aria2();
baseURL = 'http://thief.mycard.moe/metalinks/'
baseURL = 'https://thief.mycard.moe/metalinks/';
appGidMap = new Map<App,string>();
gidAppMap = new Map<string,App>();
eventEmitter = new EventEmitter();
......@@ -107,6 +107,9 @@ export class DownloadService {
return app;
} else {
let meta4link = `${this.baseURL}${id}.meta4`;
if (id === "ygopro") {
meta4link = `${this.baseURL}${id}-${process.platform}.meta4`
}
let response = await this.http.get(meta4link).toPromise();
let meta4 = btoa(response.text());
let gid = (await this.aria2.addMetalink(meta4, {dir: path}))[0];
......
......@@ -24,41 +24,41 @@ export class InstallService {
installingQueue: Set<App> = new Set();
checksumUri = "http://thief.mycard.moe/checksums/";
checksumUri = "https://thief.mycard.moe/checksums/";
constructor(private http: Http, private appsService: AppsService) {
if (process.platform === "win32") {
this.tarPath = path.join(process.resourcesPath, 'bin/tar.exe');
this.tarPath = path.join(process.resourcesPath, 'bin', 'bsdtar.exe');
} else {
this.tarPath = "tar"
this.tarPath = "bsdtar"
}
}
createDirectory(dir: string) {
return new Promise((resolve, reject) => {
return new Promise((resolve, reject)=> {
mkdirp(dir, resolve);
})
}
getComplete(app: App): Promise<App> {
return new Promise((resolve, reject) => {
this.eventEmitter.once(app.id, (complete) => {
return new Promise((resolve, reject)=> {
this.eventEmitter.once(app.id, (complete)=> {
resolve();
});
});
}
extract(file: string, destPath: string) {
return new Promise((resolve, reject) => {
return new Promise((resolve, reject)=> {
let tarProcess = child_process.spawn(this.tarPath, ['xvf', file, '-C', destPath]);
let rl = readline.createInterface({
input: <ReadableStream>tarProcess.stderr,
});
rl.on('line', (input) => {
rl.on('line', (input)=> {
console.log(input);
});
tarProcess.on('exit', (code) => {
tarProcess.on('exit', (code)=> {
if (code === 0) {
resolve();
} else {
......@@ -72,26 +72,26 @@ export class InstallService {
let action = app.actions.get('install');
if (action) {
let env = Object.assign({}, action.env);
let command: string[] = [];
let command:string[] = [];
command.push(path.join(appPath, action.execute));
command.push(...action.args);
let open = action.open;
if (open) {
let openAction: any = open.actions.get("main");
let openAction:any = open.actions.get("main");
env = Object.assign(env, openAction.env);
command.unshift(...openAction.args);
command.unshift(path.join((<AppLocal>open.local).path, openAction.execute));
}
return new Promise((resolve, reject) => {
return new Promise((resolve, reject)=> {
let child = child_process.spawn(<string>command.shift(), command, {
env: env,
stdio: 'inherit',
shell: true,
});
child.on('error', (error) => {
child.on('error', (error)=> {
console.log(error);
});
child.on('exit', (code) => {
child.on('exit', (code)=> {
if (code === 0) {
resolve();
} else {
......@@ -112,7 +112,7 @@ export class InstallService {
let backupPath = path.join((<AppLocal>app.local).path, "backup");
await this.createDirectory(backupPath);
for (let file of files) {
await new Promise((resolve, reject) => {
await new Promise((resolve, reject)=> {
let oldPath = path.join((<AppLocal>app.local).path, file);
let newPath = path.join(backupPath, file);
fs.rename(oldPath, newPath, resolve);
......@@ -121,8 +121,12 @@ export class InstallService {
}
async getChecksumFile(app: App): Promise<Map<string,string> > {
let checksumMap: Map<string,string> = await this.http.get(this.checksumUri + app.id)
.map((response) => {
let checksumUrl = this.checksumUri + app.id;
if (app.id === "ygopro") {
checksumUrl = this.checksumUri + app.id + "-" + process.platform;
}
let checksumMap: Map<string,string> = await this.http.get(checksumUrl)
.map((response)=> {
let map = new Map<string,string>();
for (let line of response.text().split('\n')) {
if (line !== "") {
......@@ -138,12 +142,15 @@ export class InstallService {
async doInstall() {
for (let app of this.installQueue.keys()) {
let depInstalled = app.findDependencies()
.every((dependency) => dependency.isInstalled());
.every((dependency)=>dependency.isInstalled());
if (depInstalled && !this.installingQueue.has(app)) {
this.installingQueue.add(app);
let options = <InstallConfig>this.installQueue.get(app);
let checksumMap = await this.getChecksumFile(app);
let packagePath = path.join(options.installLibrary, 'downloading', `${app.id}.tar.xz`);
if (app.id === "ygopro") {
packagePath = path.join(options.installLibrary, 'downloading', `${app.id}-${process.platform}.tar.xz`);
}
let destPath: string;
if (app.parent) {
let differenceSet = new Set<string>();
......@@ -187,15 +194,15 @@ export class InstallService {
}
deleteFile(file: string): Promise<string> {
return new Promise((resolve, reject) => {
fs.lstat(file, (err, stats) => {
return new Promise((resolve, reject)=> {
fs.lstat(file, (err, stats)=> {
if (err) return resolve(path);
if (stats.isDirectory()) {
fs.rmdir(file, (err) => {
fs.rmdir(file, (err)=> {
resolve(file);
});
} else {
fs.unlink(file, (err) => {
fs.unlink(file, (err)=> {
resolve(file);
});
}
......@@ -222,7 +229,7 @@ export class InstallService {
await this.deleteFile(oldFile);
if (app.parent) {
let backFile = path.join((<AppLocal>app.local).path, "backup", file);
await new Promise((resolve, reject) => {
await new Promise((resolve, reject)=> {
fs.rename(backFile, oldFile, resolve);
});
}
......
......@@ -39,8 +39,8 @@ export class LobbyComponent implements OnInit {
}
async updateApp() {
let updateServer = "http://thief.mycard.moe/update/metalinks/";
let checksumServer = "http://thief.mycard.moe/checksums/";
let updateServer = "https://thief.mycard.moe/update/metalinks/";
let checksumServer = "https://thief.mycard.moe/checksums/";
for (let app of this.apps.values()) {
if (app.isInstalled() && app.version != (<AppLocal>app.local).version) {
let checksumMap = await this.installService.getChecksumFile(app);
......
......@@ -46,7 +46,7 @@ interface SystemConf {
}
interface Server {
id: string
id?: string
url: string
address: string
port: number
......@@ -76,8 +76,7 @@ export class YGOProComponent implements OnInit {
app: App;
decks: string[] = [];
current_deck: string;
system_conf = path.join((<AppLocal>this.app.local).path, 'system.conf');
system_conf;
numfont = {'darwin': ['/System/Library/Fonts/PingFang.ttc']};
textfont = {'darwin': ['/System/Library/Fonts/PingFang.ttc']};
......@@ -109,10 +108,12 @@ export class YGOProComponent implements OnInit {
connections: WebSocket[] = [];
constructor(private http: Http, private appsService: AppsService, private loginService: LoginService, private ref: ChangeDetectorRef) {
this.refresh();
}
ngOnInit() {
this.system_conf = path.join((<AppLocal>this.app.local).path, 'system.conf');
this.refresh();
let modal = $('#game-list-modal');
modal.on('show.bs.modal', (event) => {
......
......@@ -42,7 +42,7 @@
},
"darwin": {
"main": {
"execute": "th07.exe",
"execute": "東方紅魔郷.exe",
"args": [],
"open": "wine",
"env": {
......@@ -57,7 +57,7 @@
"servers": [
{
"id": "wudizhanche",
"url": "ws://wudizhanche.mycard.moe:10800"
"url": "wss://wudizhanche.mycard.moe:10800"
}
]
},
......@@ -217,9 +217,12 @@
"language"
],
"dependencies": {
"win32": [],
"win32": [
"th07"
],
"darwin": [
"wine"
"wine",
"th07"
]
},
"references": {
......@@ -295,7 +298,7 @@
"actions": {
"win32": {
"main": {
"execute": "th07.exe",
"execute": "th075.exe",
"args": [],
"env": {
"LC_ALL": "ja_JP"
......@@ -304,7 +307,7 @@
},
"darwin": {
"main": {
"execute": "th07.exe",
"execute": "th075.exe",
"args": [],
"open": "wine",
"env": {
......@@ -336,9 +339,12 @@
"language"
],
"dependencies": {
"win32": [],
"win32": [
"th075"
],
"darwin": [
"wine"
"wine",
"th075"
]
},
"references": {
......@@ -353,7 +359,7 @@
"actions": {
"win32": {
"main": {
"execute": "th07.exe",
"execute": "th075c.exe",
"args": [],
"env": {
"LC_ALL": "ja_JP"
......@@ -362,7 +368,7 @@
},
"darwin": {
"main": {
"execute": "th07.exe",
"execute": "th075c.exe",
"args": [],
"open": "wine",
"env": {
......@@ -414,7 +420,7 @@
"actions": {
"win32": {
"main": {
"execute": "th07.exe",
"execute": "th08.exe",
"args": [],
"env": {
"LC_ALL": "ja_JP"
......@@ -423,7 +429,7 @@
},
"darwin": {
"main": {
"execute": "th07.exe",
"execute": "th08.exe",
"args": [],
"open": "wine",
"env": {
......@@ -455,9 +461,12 @@
"language"
],
"dependencies": {
"win32": [],
"win32": [
"th08"
],
"darwin": [
"wine"
"wine",
"th08"
]
},
"references": {
......@@ -472,7 +481,7 @@
"actions": {
"win32": {
"main": {
"execute": "th07.exe",
"execute": "th08.exe",
"args": [],
"env": {
"LC_ALL": "ja_JP"
......@@ -481,7 +490,7 @@
},
"darwin": {
"main": {
"execute": "th07.exe",
"execute": "th08.exe",
"args": [],
"open": "wine",
"env": {
......@@ -533,7 +542,7 @@
"actions": {
"win32": {
"main": {
"execute": "th07.exe",
"execute": "th09.exe",
"args": [],
"env": {
"LC_ALL": "ja_JP"
......@@ -542,7 +551,7 @@
},
"darwin": {
"main": {
"execute": "th07.exe",
"execute": "th09.exe",
"args": [],
"open": "wine",
"env": {
......@@ -574,9 +583,12 @@
"language"
],
"dependencies": {
"win32": [],
"win32": [
"th09"
],
"darwin": [
"wine"
"wine",
"th09"
]
},
"references": {
......@@ -591,7 +603,7 @@
"actions": {
"win32": {
"main": {
"execute": "th07.exe",
"execute": "th09c.exe",
"args": [],
"env": {
"LC_ALL": "ja_JP"
......@@ -600,7 +612,7 @@
},
"darwin": {
"main": {
"execute": "th07.exe",
"execute": "th09c.exe",
"args": [],
"open": "wine",
"env": {
......@@ -652,7 +664,7 @@
"actions": {
"win32": {
"main": {
"execute": "th07.exe",
"execute": "th095.exe",
"args": [],
"env": {
"LC_ALL": "ja_JP"
......@@ -661,7 +673,7 @@
},
"darwin": {
"main": {
"execute": "th07.exe",
"execute": "th095.exe",
"args": [],
"open": "wine",
"env": {
......@@ -693,9 +705,12 @@
"language"
],
"dependencies": {
"win32": [],
"win32": [
"th095"
],
"darwin": [
"wine"
"wine",
"th095"
]
},
"references": {
......@@ -710,7 +725,7 @@
"actions": {
"win32": {
"main": {
"execute": "th07.exe",
"execute": "th095c.exe",
"args": [],
"env": {
"LC_ALL": "ja_JP"
......@@ -719,7 +734,7 @@
},
"darwin": {
"main": {
"execute": "th07.exe",
"execute": "th095c.exe",
"args": [],
"open": "wine",
"env": {
......@@ -812,9 +827,12 @@
"language"
],
"dependencies": {
"win32": [],
"win32": [
"th1"
],
"darwin": [
"wine"
"wine",
"th1"
]
},
"references": {
......@@ -890,7 +908,7 @@
"actions": {
"win32": {
"main": {
"execute": "th07.exe",
"execute": "th10.exe",
"args": [],
"env": {
"LC_ALL": "ja_JP"
......@@ -899,7 +917,7 @@
},
"darwin": {
"main": {
"execute": "th07.exe",
"execute": "th10.exe",
"args": [],
"open": "wine",
"env": {
......@@ -931,9 +949,12 @@
"language"
],
"dependencies": {
"win32": [],
"win32": [
"th10"
],
"darwin": [
"wine"
"wine",
"th10"
]
},
"references": {
......@@ -948,7 +969,7 @@
"actions": {
"win32": {
"main": {
"execute": "th07.exe",
"execute": "th10chs.exe",
"args": [],
"env": {
"LC_ALL": "ja_JP"
......@@ -957,7 +978,7 @@
},
"darwin": {
"main": {
"execute": "th07.exe",
"execute": "th10chs.exe",
"args": [],
"open": "wine",
"env": {
......@@ -1009,7 +1030,7 @@
"actions": {
"win32": {
"main": {
"execute": "th07.exe",
"execute": "th105.exe",
"args": [],
"env": {
"LC_ALL": "ja_JP"
......@@ -1018,7 +1039,7 @@
},
"darwin": {
"main": {
"execute": "th07.exe",
"execute": "th105.exe",
"args": [],
"open": "wine",
"env": {
......@@ -1050,9 +1071,12 @@
"language"
],
"dependencies": {
"win32": [],
"win32": [
"th105"
],
"darwin": [
"wine"
"wine",
"th105"
]
},
"references": {
......@@ -1067,7 +1091,7 @@
"actions": {
"win32": {
"main": {
"execute": "th07.exe",
"execute": "th105.exe",
"args": [],
"env": {
"LC_ALL": "ja_JP"
......@@ -1076,7 +1100,7 @@
},
"darwin": {
"main": {
"execute": "th07.exe",
"execute": "th105.exe",
"args": [],
"open": "wine",
"env": {
......@@ -1128,7 +1152,7 @@
"actions": {
"win32": {
"main": {
"execute": "th07.exe",
"execute": "th11.exe",
"args": [],
"env": {
"LC_ALL": "ja_JP"
......@@ -1137,7 +1161,7 @@
},
"darwin": {
"main": {
"execute": "th07.exe",
"execute": "th11.exe",
"args": [],
"open": "wine",
"env": {
......@@ -1169,9 +1193,12 @@
"language"
],
"dependencies": {
"win32": [],
"win32": [
"th11"
],
"darwin": [
"wine"
"wine",
"th11"
]
},
"references": {
......@@ -1186,7 +1213,7 @@
"actions": {
"win32": {
"main": {
"execute": "th07.exe",
"execute": "th11c.exe",
"args": [],
"env": {
"LC_ALL": "ja_JP"
......@@ -1195,7 +1222,7 @@
},
"darwin": {
"main": {
"execute": "th07.exe",
"execute": "th11c.exe",
"args": [],
"open": "wine",
"env": {
......@@ -1247,7 +1274,7 @@
"actions": {
"win32": {
"main": {
"execute": "th07.exe",
"execute": "th12.exe",
"args": [],
"env": {
"LC_ALL": "ja_JP"
......@@ -1256,7 +1283,7 @@
},
"darwin": {
"main": {
"execute": "th07.exe",
"execute": "th12.exe",
"args": [],
"open": "wine",
"env": {
......@@ -1288,9 +1315,12 @@
"language"
],
"dependencies": {
"win32": [],
"win32": [
"th12"
],
"darwin": [
"wine"
"wine",
"th12"
]
},
"references": {
......@@ -1305,7 +1335,7 @@
"actions": {
"win32": {
"main": {
"execute": "th07.exe",
"execute": "th12c.exe",
"args": [],
"env": {
"LC_ALL": "ja_JP"
......@@ -1314,7 +1344,7 @@
},
"darwin": {
"main": {
"execute": "th07.exe",
"execute": "th12c.exe",
"args": [],
"open": "wine",
"env": {
......@@ -1369,7 +1399,7 @@
"actions": {
"win32": {
"main": {
"execute": "th07.exe",
"execute": "th123.exe",
"args": [],
"env": {
"LC_ALL": "ja_JP"
......@@ -1378,7 +1408,7 @@
},
"darwin": {
"main": {
"execute": "th07.exe",
"execute": "th123.exe",
"args": [],
"open": "wine",
"env": {
......@@ -1402,7 +1432,7 @@
"servers": [
{
"id": "tiramisu",
"url": "ws://wudizhanche.mycard.moe:10800/"
"url": "wss://wudizhanche.mycard.moe:10800/"
}
]
}
......@@ -1421,9 +1451,12 @@
"language"
],
"dependencies": {
"win32": [],
"win32": [
"th123"
],
"darwin": [
"wine"
"wine",
"th123"
]
},
"references": {
......@@ -1438,7 +1471,7 @@
"actions": {
"win32": {
"main": {
"execute": "th07.exe",
"execute": "th123_beta.exe",
"args": [],
"env": {
"LC_ALL": "ja_JP"
......@@ -1447,7 +1480,7 @@
},
"darwin": {
"main": {
"execute": "th07.exe",
"execute": "th123_beta.exe",
"args": [],
"open": "wine",
"env": {
......@@ -1540,9 +1573,12 @@
"language"
],
"dependencies": {
"win32": [],
"win32": [
"th2"
],
"darwin": [
"wine"
"wine",
"th2"
]
},
"references": {
......@@ -1659,9 +1695,12 @@
"language"
],
"dependencies": {
"win32": [],
"win32": [
"th3"
],
"darwin": [
"wine"
"wine",
"th3"
]
},
"references": {
......@@ -1778,9 +1817,12 @@
"language"
],
"dependencies": {
"win32": [],
"win32": [
"th4"
],
"darwin": [
"wine"
"wine",
"th4"
]
},
"references": {
......@@ -1897,9 +1939,12 @@
"language"
],
"dependencies": {
"win32": [],
"win32": [
"th5"
],
"darwin": [
"wine"
"wine",
"th5"
]
},
"references": {
......@@ -1971,7 +2016,7 @@
"actions": {
"win32": {
"main": {
"execute": "ygopro_vs.exe",
"execute": "ygopro.exe",
"args": [],
"env": {}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment