diff --git a/.eslintignore b/.eslintignore index f1c92da..a89ac8d 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,4 @@ build/*.js config/*.js dist/*.js -tmp/*.js +src/tmp/*.js diff --git a/.gitignore b/.gitignore index 23e3789..9f771ea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ .DS_Store -tmp/ +src/tmp/ node_modules/ dist/ src/statics/spells.json diff --git a/README.md b/README.md index febd38e..9cc8ec5 100644 --- a/README.md +++ b/README.md @@ -21,10 +21,16 @@ App contains content from the SRD and is restricted and covered by the OGL. You $ npm install # serve with hot reload at localhost:8080 -$ npm run dev +$ npm run dev_web # build for production with minification -$ npm run build +$ npm run build_web # or build_app + +# build cordova (android, iOS potentially in future) release +$ npm run build_app_cordova +# sign apk with android studio or jarsigner +# install on device +$ adp install cordova/platforms/android/build/apk/ # lint code $ npm run lint diff --git a/build/generate_index.js b/build/process_spells.js similarity index 54% rename from build/generate_index.js rename to build/process_spells.js index 97e0c27..49d55d0 100644 --- a/build/generate_index.js +++ b/build/process_spells.js @@ -1,5 +1,7 @@ 'use strict' +const args = require('yargs').argv + const fs = require('fs') const spells = require('../src/spells_original.json') @@ -14,6 +16,8 @@ const hashCode = function (str) { return hash } +console.log('Processing spells...', args.web ? 'for web!' : 'for apps!') + let spellsWithIDs = spells.map(spell => { spell.id = hashCode(spell.name).toString() return spell @@ -29,11 +33,21 @@ let indexedSpells = spellsWithIDs.map(spell => { } }) -let dirs = ['tmp'] +let dirs = ['dist', 'dist/statics', 'src/tmp'] dirs.forEach(dir => { if (!fs.existsSync(dir)) { fs.mkdirSync(dir) } }) -fs.writeFileSync('./src/statics/spells.json', JSON.stringify(spellsWithIDs)) -fs.writeFileSync('./tmp/spells_index.js', `export default ${JSON.stringify(indexedSpells)};`) + +fs.writeFileSync('./src/tmp/spells_index.js', `export default ${JSON.stringify(indexedSpells)};`) + +if (args.web) { + fs.writeFileSync('./dist/statics/spells.json', JSON.stringify(spellsWithIDs)); + fs.writeFileSync('./src/tmp/spells.js', `export default []; // Will fetch from web`) +} +else { + fs.writeFileSync('./src/tmp/spells.js', `export default ${JSON.stringify(spellsWithIDs)};`) +} + +console.log('Processed spells') diff --git a/build/script.build.js b/build/script.build.js index eb34956..dcc65b8 100644 --- a/build/script.build.js +++ b/build/script.build.js @@ -1,6 +1,5 @@ process.env.NODE_ENV = 'production' -require('./generate_index') require('colors') var diff --git a/build/script.clean.js b/build/script.clean.js index d45b1e9..38cd7c8 100644 --- a/build/script.clean.js +++ b/build/script.clean.js @@ -2,5 +2,5 @@ var shell = require('shelljs'), path = require('path') -shell.rm('-rf', path.resolve(__dirname, '../dist ../tmp')) +shell.rm('-rf', path.resolve(__dirname, '../dist ../src/tmp')) console.log(' Cleaned build artifacts.\n') diff --git a/build/script.dev.js b/build/script.dev.js index 69f0398..058288f 100644 --- a/build/script.dev.js +++ b/build/script.dev.js @@ -1,6 +1,5 @@ process.env.NODE_ENV = 'development' -require('./generate_index') require('colors') var diff --git a/cordova/.idea/compiler.xml b/cordova/.idea/compiler.xml new file mode 100644 index 0000000..96cc43e --- /dev/null +++ b/cordova/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cordova/.idea/copyright/profiles_settings.xml b/cordova/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/cordova/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/cordova/.idea/cordova.iml b/cordova/.idea/cordova.iml new file mode 100644 index 0000000..b57f217 --- /dev/null +++ b/cordova/.idea/cordova.iml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cordova/.idea/misc.xml b/cordova/.idea/misc.xml new file mode 100644 index 0000000..9d89a47 --- /dev/null +++ b/cordova/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cordova/.idea/modules.xml b/cordova/.idea/modules.xml new file mode 100644 index 0000000..1868afb --- /dev/null +++ b/cordova/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/cordova/.idea/workspace.xml b/cordova/.idea/workspace.xml new file mode 100644 index 0000000..7dded40 --- /dev/null +++ b/cordova/.idea/workspace.xml @@ -0,0 +1,291 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1502571896668 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Android + + + + + + + + + + + + + + + 1.8 + + + + + + + + Android|cordova + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cordova/.npmignore b/cordova/.npmignore new file mode 100644 index 0000000..fd29596 --- /dev/null +++ b/cordova/.npmignore @@ -0,0 +1,2 @@ +# OS X +.DS_Store diff --git a/cordova/config.xml b/cordova/config.xml new file mode 100644 index 0000000..b540b86 --- /dev/null +++ b/cordova/config.xml @@ -0,0 +1,31 @@ + + + My Spells DnD5e + + My Spells is an open source web-based application to elegantly view spells and save them to your local spellbook. + + + Joe Wroten + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cordova/hooks/README.md b/cordova/hooks/README.md new file mode 100644 index 0000000..574ad4c --- /dev/null +++ b/cordova/hooks/README.md @@ -0,0 +1,23 @@ + +# Cordova Hooks + +Cordova Hooks represent special scripts which could be added by application and plugin developers or even by your own build system to customize cordova commands. See Hooks Guide for more details: http://cordova.apache.org/docs/en/edge/guide_appdev_hooks_index.md.html#Hooks%20Guide. diff --git a/cordova/package.json b/cordova/package.json new file mode 100644 index 0000000..cfc0505 --- /dev/null +++ b/cordova/package.json @@ -0,0 +1,24 @@ +{ + "name": "my_spells_app", + "displayName": "My Spells - Cordova", + "version": "1.0.0", + "description": "My Spells is an open source web-based application to elegantly view spells and save them to your local spellbook.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Joe Wroten ", + "license": "ISC", + "dependencies": { + "cordova-android": "^6.2.3", + "cordova-plugin-whitelist": "^1.3.2" + }, + "cordova": { + "plugins": { + "cordova-plugin-whitelist": {} + }, + "platforms": [ + "android" + ] + } +} \ No newline at end of file diff --git a/cordova/res/README.md b/cordova/res/README.md new file mode 100644 index 0000000..bffb33b --- /dev/null +++ b/cordova/res/README.md @@ -0,0 +1,29 @@ + + +Note that these image resources are not copied into a project when a project +is created with the CLI. Although there are default image resources in a +newly-created project, those come from the platform-specific project template, +which can generally be found in the platform's `template` directory. Until +icon and splashscreen support is added to the CLI, these image resources +aren't used directly. + +See https://issues.apache.org/jira/browse/CB-5145 diff --git a/cordova/res/android/hdpi.png b/cordova/res/android/hdpi.png new file mode 100644 index 0000000..c4d858e Binary files /dev/null and b/cordova/res/android/hdpi.png differ diff --git a/cordova/res/android/ldpi.png b/cordova/res/android/ldpi.png new file mode 100644 index 0000000..8701d33 Binary files /dev/null and b/cordova/res/android/ldpi.png differ diff --git a/cordova/res/android/mdpi.png b/cordova/res/android/mdpi.png new file mode 100644 index 0000000..9e7d219 Binary files /dev/null and b/cordova/res/android/mdpi.png differ diff --git a/cordova/res/android/xhdpi.png b/cordova/res/android/xhdpi.png new file mode 100644 index 0000000..4ccd5fa Binary files /dev/null and b/cordova/res/android/xhdpi.png differ diff --git a/cordova/res/android/xxhdpi.png b/cordova/res/android/xxhdpi.png new file mode 100644 index 0000000..314433b Binary files /dev/null and b/cordova/res/android/xxhdpi.png differ diff --git a/cordova/res/android/xxxhdpi.png b/cordova/res/android/xxxhdpi.png new file mode 100644 index 0000000..b7118b2 Binary files /dev/null and b/cordova/res/android/xxxhdpi.png differ diff --git a/cordova/www b/cordova/www new file mode 120000 index 0000000..85d8c32 --- /dev/null +++ b/cordova/www @@ -0,0 +1 @@ +../dist \ No newline at end of file diff --git a/package.json b/package.json index 577d18a..24523f2 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,16 @@ { "name": "my_spells", - "version": "2.0.3", + "version": "2.0.4", "description": "My Spells is an open source web-based application to elegantly view spells and save them to your local spellbook.", "author": "Joe Wroten ", "license": "ISC", "scripts": { "clean": "node build/script.clean.js", - "dev": "node build/script.dev.js", - "build": "node build/script.build.js", + "dev_web": "node build/process_spells.js --web && node build/script.dev.js ", + "dev_app_cordova": "cd cordova && cordova run --device android", + "build_web": "node build/process_spells.js --web && node build/script.build.js", + "build_app": "node build/process_spells.js && node build/script.build.js", + "build_app_cordova": "cd cordova && cordova build --release", "lint": "eslint --ext .js,.vue src" }, "dependencies": { @@ -67,6 +70,7 @@ "webpack-dev-middleware": "^1.8.4", "webpack-hot-middleware": "^2.17.0", "webpack-merge": "^4.0.0", - "whatwg-fetch": "^2.0.3" + "whatwg-fetch": "^2.0.3", + "yargs": "^8.0.2" } } diff --git a/src/App.vue b/src/App.vue index d65ad8a..2e5224d 100644 --- a/src/App.vue +++ b/src/App.vue @@ -25,6 +25,7 @@ import 'whatwg-fetch' import { state, dispatch } from './store' import Header from './components/Header' import Footer from './components/Footer' +import bakedInSpells from './tmp/spells' Vue.component('nav-header', Header) Vue.component('nav-footer', Footer) @@ -50,11 +51,18 @@ function fetchFailure (reason) { } function fetchSpells () { - fetch('./statics/spells.json') - .then(response => response.json()) - .then(fetchSuccess) - .catch(fetchFailure) - .then(() => { Loading.hide() }) + console.log('WOW DATA', bakedInSpells) + if (bakedInSpells.length) { + fetchSuccess(bakedInSpells) + Loading.hide() + } + else { + fetch('./statics/spells.json') + .then(response => response.json()) + .then(fetchSuccess) + .catch(fetchFailure) + .then(() => { Loading.hide() }) + } } export default { diff --git a/src/store.js b/src/store.js index 54595b5..232e86d 100644 --- a/src/store.js +++ b/src/store.js @@ -1,5 +1,5 @@ import { LocalStorage } from 'quasar' -import indexedSpells from '../tmp/spells_index' +import indexedSpells from './tmp/spells_index' export let state = { indexedSpells,