Skip to content

Commit

Permalink
日本語manifestの提供方法を変更
Browse files Browse the repository at this point in the history
  • Loading branch information
maktak1995 committed Jun 11, 2018
1 parent aee3a1f commit 9c03adc
Show file tree
Hide file tree
Showing 16 changed files with 906 additions and 686 deletions.
28 changes: 0 additions & 28 deletions ja/1001.json

This file was deleted.

35 changes: 0 additions & 35 deletions ja/1003.json

This file was deleted.

21 changes: 0 additions & 21 deletions ja/1005.json

This file was deleted.

49 changes: 0 additions & 49 deletions ja/1006.json

This file was deleted.

49 changes: 0 additions & 49 deletions ja/1007.json

This file was deleted.

9 changes: 0 additions & 9 deletions ja/manifestList.json

This file was deleted.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tucratch",
"version": "0.1.0",
"version": "0.1.1",
"description": "The TURIP-Scratch connection helper",
"main": "./src/index.js",
"scripts": {
Expand All @@ -18,7 +18,7 @@
"license": "MIT",
"dependencies": {
"co": "^4.6.0",
"electron": "^1.8.6",
"electron": "1.7.9",
"electron-json-storage-sync": "^1.1.0",
"electron-packager": "^11.1.0",
"fs": "0.0.1-security",
Expand All @@ -29,6 +29,7 @@
"node-localstorage": "^1.3.1",
"serialport": "^6.2.0",
"siimple": "^3.0.0",
"underscore": "^1.9.1",
"vue": "^2.5.16",
"webpack": "^4.8.1"
},
Expand Down
4 changes: 2 additions & 2 deletions src/domain/entity/Pod.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict'
'use strict';

module.exports = class Pod {
constructor(name, type, port, id, method){
Expand All @@ -8,4 +8,4 @@ module.exports = class Pod {
this.id = id;
this.method = method;
}
}
};
14 changes: 7 additions & 7 deletions src/domain/factory/JsonFactory.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict'
'use strict';

const path = require('path');
const {app} = require('electron');
const fs = require('fs');
const i18n = require('i18next');
const PodRepository = require('../repository/PodRepository');

const appPath = app.getPath('home');
module.exports = class JsonFactory {
static makeJson(JSONPATH) {
static makeJson() {
//Check tucratch.json not existing
if(this.isExistFile(JSONPATH + '/tucratch.json')) fs.unlinkSync(JSONPATH + '/tucratch.json');
if(this.isExistFile(appPath + '/Documents/tucratch/tucratch.json')) fs.unlinkSync(appPath + '/Documents/tucratch/tucratch.json');

let json = { "extensionName": "tucratch",
"extensionPort": 5000,
Expand All @@ -30,7 +30,7 @@ module.exports = class JsonFactory {
}else{
return false;
}
fs.writeFile(JSONPATH + '/tucratch.json', JSON.stringify(json, null, ' '));
fs.writeFile(appPath + '/Documents/tucratch/tucratch.json', JSON.stringify(json, null, ' '));
return true;
}

Expand All @@ -42,4 +42,4 @@ module.exports = class JsonFactory {
if(err.code === 'ENOENT') return false
}
}
}
};
14 changes: 7 additions & 7 deletions src/domain/repository/PodRepository.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
'use strict'
'use strict';

const PodFactory = require('../factory/PodFactory');
const JaManifest = require('../service/JaManifest');
const fetch = require('node-fetch');
const storage = require('electron-json-storage-sync');
const path = require('path');
const fs = require('fs');
const i18n = require('i18next');
const _ = require('underscore');
const manifest_ja = JSON.parse(fs.readFileSync(path.resolve('ja', 'manifestList.json'), 'utf8'));

const manifest_ja = new JaManifest();

module.exports = class PodRepository {
static async setPod(id){
const manifest_id = id.split('-')[0];
const URL = 'https://manifest.turip.org/';
let json;

if( i18n.language == 'ja' && _.find(manifest_ja["list"], (num) => { return manifest_id == num; })) {
json = JSON.parse(fs.readFileSync(path.resolve('ja', manifest_id+'.json'), 'utf8'));
if( i18n.language == 'ja' && _.find(manifest_ja.getManifestList(), (num) => { return manifest_id == num; })) {
json = manifest_ja.getManifests(manifest_id);
} else {
json = await fetch(URL + manifest_id).then((response) => {
return response.json();
Expand Down Expand Up @@ -101,4 +101,4 @@ module.exports = class PodRepository {
console.log(err);
}

}
};
4 changes: 3 additions & 1 deletion src/domain/service/ComWithPod.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

const serialPort = require('serialport');
const Readline = serialPort.parsers.Readline;
const SerialResponseParser = require('./SerialResponseParser');
Expand Down Expand Up @@ -48,4 +50,4 @@ module.exports = class ComWithPod {
SerialResponseParser.responseParser(event, res, sended.message);
});
}
}
};
4 changes: 3 additions & 1 deletion src/domain/service/ComWithScratch.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

const ComWithPod = require('./ComWithPod');
const PodRepository = require('../repository/PodRepository');

Expand All @@ -23,4 +25,4 @@ module.exports = class ComWithScratch {
const message = "post " + "/" + getPod.id + "/" + getPod.port + " " + data + "\n";
return ComWithPod.communicate(message, sp);
}
}
};
Loading

0 comments on commit 9c03adc

Please sign in to comment.