Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced eslint with Standard for formatting #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 0 additions & 122 deletions .eslintrc.js

This file was deleted.

38 changes: 19 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
#! /usr/bin/env node

const _ = require('lodash');
const Yargs = require('yargs');
const _ = require('lodash')
const Yargs = require('yargs')

const Pkg = require('./package.json');
const Data = require('./src/data');
const Pkg = require('./package.json')
const Data = require('./src/data')

// https://gist.github.com/zambon/8b2d207bd21cf4fcd47b96cd6d7f99c2
_.mixin({
deeply: map =>
(obj, fn) =>
map(_.mapValues(obj, (v) => {
if (_.isPlainObject(v)) {
return _.deeply(map)(v, fn);
return _.deeply(map)(v, fn)
} else if (_.isArray(v)) {
return _.map(v, item => _.deeply(map)(item, fn));
return _.map(v, item => _.deeply(map)(item, fn))
}
return v;
}), fn),
});
return v
}), fn)
})

module.exports = Yargs
.command({
command: 'data <key> [value]',
desc: 'Set a config variable',
builder: (yargs) => yargs.default('value', 'false'),
handler: (argv) => {
switch(argv.key) {
switch (argv.key) {
case 'all':
Data.run();
break;
Data.run()
break
case 'community':
case 'comm':
Data.run('community');
break;
Data.run('community')
break
case 'community-oauth-profile':
case 'comm-oauth-prof':
Data.run('community-oauth-profile');
break;
Data.run('community-oauth-profile')
break
case 'game-data':
Data.run('game-data');
break;
Data.run('game-data')
break
default:
console.log('Command not found...')
}
Expand All @@ -51,4 +51,4 @@ module.exports = Yargs
.help('help')
.alias('help', 'h')
.demandCommand()
.argv;
.argv
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@
"description": "Command Line Interface for TargetDummy",
"main": "index.js",
"scripts": {
"lint": "./node_modules/.bin/eslint -c .eslintrc.js .",
"format": "standard --fix",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Ben Weier <[email protected]>",
"contributors": [{
"name": "Devin Leaman (Alcha)",
"email": "[email protected]",
"url": "https://paranoiddevs.com"
}, {
"name": "Josh Weiss",
"url": "https://github.com/coder4life"
}],
"license": "MIT",
"repository": {
"type": "git",
Expand All @@ -31,6 +39,6 @@
"targetdummy-test-data": "index.js"
},
"devDependencies": {
"eslint": "^4.7.2"
"standard": "10.0.3"
}
}
74 changes: 35 additions & 39 deletions src/data.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,65 @@
const FS = require('fs');
const Glob = require('glob');
const Path = require('path');
const YamlJS = require('js-yaml');
const FS = require('fs')
const Glob = require('glob')
const Path = require('path')
const YamlJS = require('js-yaml')

class Data {

constructor(options) {

this.type = this.constructor.name;
constructor (options) {
this.type = this.constructor.name
}

get response() {
return this._response;
get response () {
return this._response
}

set response(response) {
this._response = response;
set response (response) {
this._response = response
}

static instances() {
const data = [];
static instances () {
const data = []
// Load All Data Classes
Glob.sync('./src/data/**/*.js').forEach(file => {
data.push(require(Path.resolve(file)));
});
return data;
data.push(require(Path.resolve(file)))
})
return data
}

static scoped(name = null) {
const data = [];
static scoped (name = null) {
const data = []
this.instances().forEach(item => {
if(item.scope === name) {
data.push(item);
if (item.scope === name) {
data.push(item)
} else {
data.push(item);
data.push(item)
}
});
return data;
})
return data
}

static run(scoped = null) {
static run (scoped = null) {
this.scoped(scoped).forEach(data => {
return data.request()
.then(result => {
data.store(result);
});
});
data.store(result)
})
})
}

static getStorage(filePath, extension) {
static getStorage (filePath, extension) {
if (FS.existsSync(filePath + extension)) {
if(extension === 'js') {
return JSON.parse(FS.readFileSync(filePath + '.' + extension, 'utf8'));
} else if(extension === 'yaml') {
return YamlJS.safeLoad(FS.readFileSync(filePath + '.' + extension, 'utf8'));
if (extension === 'js') {
return JSON.parse(FS.readFileSync(filePath + '.' + extension, 'utf8'))
} else if (extension === 'yaml') {
return YamlJS.safeLoad(FS.readFileSync(filePath + '.' + extension, 'utf8'))
} else {
return false;
return false
}
} else {
FS.openSync(filePath + extension, 'a');
return false;
FS.openSync(filePath + extension, 'a')
return false
}
}


}

module.exports = Data;
module.exports = Data
55 changes: 27 additions & 28 deletions src/data/community/wow/data/character/achievement.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
const _ =require('lodash');
const AppRoot = require('app-root-path');
const BlizzardJS = require('blizzard.js').initialize({apikey: 'api_key_goes_here_for_now'});
const Sequelize = require('sequelize');
const _ = require('lodash')
const AppRoot = require('app-root-path')
const BlizzardJS = require('blizzard.js').initialize({apikey: 'api_key_goes_here_for_now'})
const Sequelize = require('sequelize')

const Data = require(AppRoot + '/src/data');
const Data = require(AppRoot + '/src/data')

class AchievementCharacterDataWowCommunityData extends Data {
constructor(options) {
super();
this.name = 'Achievement Character Data World of Warcraft Community Data';
this.description = 'The achievement data from the World of Warcraft community data endpoints.';
this.scope = 'community';
this.dataPath = 'data/community/wow/data/';
this.dataFilename = 'character-achievements';
constructor (options) {
super()
this.name = 'Achievement Character Data World of Warcraft Community Data'
this.description = 'The achievement data from the World of Warcraft community data endpoints.'
this.scope = 'community'
this.dataPath = 'data/community/wow/data/'
this.dataFilename = 'character-achievements'
}

request() {
return BlizzardJS.wow.data('character-achievements', { origin: 'us' })
request () {
return BlizzardJS.wow.data('character-achievements', { origin: 'us' })
.then(response => {
return response;
});
return response
})
}

store(source) {
let filePath = AppRoot + '/' + this.dataPath + this.dataFilename;
let yamlData = Data.getStorage(filePath);
if(source) {
//console.log(source.data);
let requestData = _.flatMapDeep(source.data, ['id']);
console.log(requestData);
/*requestData.forEach(item => {
store (source) {
let filePath = AppRoot + '/' + this.dataPath + this.dataFilename
let yamlData = Data.getStorage(filePath)
if (source) {
// console.log(source.data);
let requestData = _.flatMapDeep(source.data, ['id'])
console.log(requestData)
/* requestData.forEach(item => {
console.log(item);
});*/
return true;
}); */
return true
}
}

}

module.exports = new AchievementCharacterDataWowCommunityData();
module.exports = new AchievementCharacterDataWowCommunityData()