Browse Source

- Code cleanup

tags/v1.4.4
Ivan Bravo Bravo 1 year ago
parent
commit
a766e6019e

+ 13
- 22
.github/workflows/ci.yml View File

@@ -34,43 +34,40 @@ jobs:
- windows-latest
- macOS-latest
device:
- gpu
- cpu
- any
- cpuonly

include:
- os: ubuntu-latest # Ubuntu
os-short: ubuntu
os-ext: deb
python: python3
artifact-file: DreamTime.deb
- os: ubuntu-latest # Ubuntu & GPU
device: gpu
device: any
torch-version: https://download.pytorch.org/whl/cu100/torch-1.1.0-cp37-cp37m-linux_x86_64.whl
- os: ubuntu-latest # Ubuntu & CPU
device: cpu
device: cpuonly
torch-version: https://download.pytorch.org/whl/cpu/torch-1.1.0-cp37-cp37m-linux_x86_64.whl
- os: windows-latest # Windows
os-short: windows
os-ext: exe
python: python
artifact-file: DreamTime_Setup.exe
pyinstaller-args: --add-binary "./third/msvcp/msvcp140.dll;."
- os: windows-latest # Windows & GPU
device: gpu
device: any
torch-version: https://download.pytorch.org/whl/cu100/torch-1.1.0-cp37-cp37m-win_amd64.whl
- os: windows-latest # Windows & CPU
device: cpu
device: cpuonly
torch-version: https://download.pytorch.org/whl/cpu/torch-1.1.0-cp37-cp37m-win_amd64.whl
- os: macOS-latest # macOS
os-short: macos
os-ext: dmg
python: python3
artifact-file: DreamTime.dmg
torch-version: torch

exclude:
- os: macOS-latest
device: gpu
device: any

steps:
- name: Dump GitHub context
@@ -130,22 +127,16 @@ jobs:
run: |
${{ matrix.python }} -m PyInstaller main.py -y --onedir --name "dreampower" --distpath "../../dist" ${{ matrix.pyinstaller-args }}

- name: Build DreamTime
- name: Build & Deploy DreamTime
working-directory: src
if: false
run: |
yarn build

- name: Deploy
working-directory: src
#if: startsWith(github.ref, 'refs/tags')
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
BUILD_DEVICE: ${{ matrix.device }}
run: |
yarn release --ci --github.assets="../dist/${{ matrix.artifact-file }}"
yarn release --ci --github.assets="../dist/DreamTime-${{ matrix.os-short }}-${{ matrix.device }}.${{ matrix.os-ext }}"

- name: Upload Artifact
- name: Upload Internal Artifact
uses: actions/upload-artifact@v1
with:
name: DreamTime-${{ github.sha }}-${{ matrix.os-short }}-${{ matrix.device }}
path: dist/${{ matrix.artifact-file }}
name: ${{ matrix.os-short }}-${{ matrix.device }}
path: dist/DreamTime-${{ matrix.os-short }}-${{ matrix.device }}.${{ matrix.os-ext }}

+ 82
- 0
src/.eslintrc.js View File

@@ -0,0 +1,82 @@
module.exports = {
root: true,
env: {
browser: true,
node: true,
'shared-node-browser': true,
},
parserOptions: {
parser: 'babel-eslint',
},
extends: [
'@nuxtjs',
'airbnb-base',
'plugin:lodash/recommended',
'plugin:vue/recommended',
'plugin:nuxt/recommended',
'prettier',
'prettier/vue',
],
plugins: ['lodash', 'vue', 'prettier'],
// add your custom rules here
rules: {
'class-methods-use-this': 'off',
'global-require': 'off',
'import/no-unresolved': 'off',
'padded-blocks': ['error', 'never'],
'no-await-in-loop': 'warn',
'no-console': 'off',
'no-alert': 'off',
'no-continue': 'off',
'no-param-reassign': 'off',
'no-restricted-syntax': 'off',
'no-useless-constructor': 'warn',
'no-underscore-dangle': 'off',
'no-shadow': 'off',
'no-unused-vars': 'warn',
'no-debugger': 'warn',
'no-restricted-globals': 'warn',
'no-unreachable': 'warn',
'no-lone-blocks': 'off',
'object-shorthand': ['error', 'always'],
'quote-props': ['error', 'as-needed'],
'spaced-comment': 'warn',
'import/no-webpack-loader-syntax': 'warn',
'vue/no-v-html': 'off',
'vue/html-indent': ['warn', 2],
'vue/html-self-closing': 'off',
'vue/singleline-html-element-content-newline': 'off',
'vue/html-closing-bracket-newline': [
'warn',
{
singleline: 'never',
multiline: 'never',
},
],
'lodash/import-scope': ['warn', 'full'],
'lodash/prefer-lodash-method': 'off',
'lodash/prefer-immutable-method': 'warn',
'lodash/prefer-noop': 'off',
'lodash/prefer-includes': 'warn',
'lodash/prefer-lodash-typecheck': 'warn',
'lodash/prefer-constant': 'off',
'import/order': 'warn',
'import/no-extraneous-dependencies': [
'off',
{
devDependencies: true,
optionalDependencies: false,
peerDependencies: false,
},
],
'nuxt/no-globals-in-created': 'off',
},
globals: {
$dream: false,
$settings: false,
$rollbar: false,
$nucleus: false,
$tools: false,
AppError: false,
},
}

+ 0
- 82
src/.eslintrc.json View File

@@ -1,82 +0,0 @@
{
"plugins": ["lodash", "vue", "prettier"],
"extends": [
"@nuxtjs",
"plugin:nuxt/recommended",
"plugin:lodash/recommended",
"plugin:vue/recommended",
"airbnb-base",
"prettier"
],
"env": {
"shared-node-browser": true,
"es6": true,
"browser": true,
"node": true
},
"parserOptions": {
"parser": "babel-eslint",
"ecmaVersion": 8,
"sourceType": "module"
},
"rules": {
"class-methods-use-this": "off",
"global-require": "off",
"import/no-unresolved": "off",
"padded-blocks": ["error", "never"],
"no-await-in-loop": "warn",
"no-console": "off",
"no-alert": "off",
"no-continue": "off",
"no-param-reassign": "off",
"no-restricted-syntax": "off",
"no-useless-constructor": "warn",
"no-underscore-dangle": "off",
"no-shadow": "off",
"no-unused-vars": "warn",
"no-debugger": "warn",
"no-restricted-globals": "warn",
"no-unreachable": "warn",
"no-lone-blocks": "off",
"object-shorthand": ["error", "always"],
"quote-props": ["error", "as-needed"],
"spaced-comment": "warn",
"import/no-webpack-loader-syntax": "warn",
"vue/no-v-html": "off",
"vue/html-indent": ["warn", 2],
"vue/html-self-closing": "off",
"vue/singleline-html-element-content-newline": "off",
"vue/html-closing-bracket-newline": [
"warn",
{
"singleline": "never",
"multiline": "never"
}
],
"lodash/import-scope": ["warn", "full"],
"lodash/prefer-lodash-method": "off",
"lodash/prefer-immutable-method": "warn",
"lodash/prefer-noop": "off",
"lodash/prefer-includes": "warn",
"lodash/prefer-lodash-typecheck": "warn",
"lodash/prefer-constant": "off",
"import/order": "warn",
"import/no-extraneous-dependencies": [
"off",
{
"devDependencies": true,
"optionalDependencies": false,
"peerDependencies": false
}
],
"nuxt/no-globals-in-created": "off"
},
"globals": {
"$dream": false,
"$settings": false,
"$rollbar": false,
"$nucleus": false,
"$tools": false,
"AppError": false
}
}

+ 1
- 0
src/.prettierrc View File

@@ -1,4 +1,5 @@
{
"arrowParens": "always",
"tabWidth": 2,
"useTabs": false,
"semi": false,

+ 6
- 4
src/.release-it.js View File

@@ -1,9 +1,10 @@
module.exports = {
hooks: {
'before:init': ['yarn lint', 'yarn build'],
'before:github:release': [
'before:init': [
'git config user.email "developers@dreamnet.tech"',
'git config user.name "DreamNet"'
'git config user.name "DreamNet"',
'yarn lint',
'yarn build'
]
},

@@ -24,6 +25,7 @@ module.exports = {
release: true,
releaseName: 'v${version}',
preRelease: true,
draft: true
draft: true,
tagName: 'v${version}'
}
}

+ 3
- 0
src/assets/css/tailwind.css View File

@@ -0,0 +1,3 @@
@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';

+ 0
- 4
src/components/Telemetry/index.js View File

@@ -1,4 +0,0 @@
import Vue from 'vue'
// import Firebase from './Firebase'

// Vue.component('telemetry-firebase', Firebase)

+ 0
- 1
src/components/index.js View File

@@ -3,4 +3,3 @@ import './Layout'
import './Nudity'
import './Settings'
import './Form'
import './Telemetry'

+ 0
- 41
src/electron/modules/bullet.js View File

@@ -1,41 +0,0 @@
const bullet = require('bullet-train-nodejs')
const _ = require('lodash')
const debug = require('debug').default('app:electron:modules:bullet')

const settings = require('./settings')

const instance = {
init() {
const config = {
environmentID: process.env.BULLET_TRAIN_KEY,
onChange: (old, params) => {}
}

if (!_.isNil(settings.user)) {
// Anonymous User.
// In the future this could help us to experiment new features only in a group of users.
// bullet.identify(settings.user)
}

bullet.init(config)

bullet.getValue()
debug('Bullet Train initialized!', config)
}
}

instance.init()

module.exports = new Proxy(instance, {
get(obj, prop) {
if (prop in obj) {
return obj[prop]
}

if (prop in bullet) {
return bullet[prop]
}

return undefined
}
})

+ 0
- 1
src/electron/modules/index.js View File

@@ -3,5 +3,4 @@ module.exports = {
settings: require('./settings'),
nucleus: require('./nucleus'),
rollbar: require('./rollbar')
// bullet: require('./bullet'),
}

+ 11
- 10
src/electron/tools/fs.js View File

@@ -1,3 +1,4 @@
const _ = require('lodash')
const fs = require('fs')
const mime = require('mime-types')
const path = require('path')
@@ -125,7 +126,7 @@ module.exports = {
bus.emit('end')
})

stream.on('data', entryStream => {
stream.on('data', (entryStream) => {
extracted += 1
const progress = extracted / 4 // TODO: Hardcoded for checkpoints

@@ -137,7 +138,7 @@ module.exports = {
bus.emit('progress', null, progress)
})

stream.on('error', err => {
stream.on('error', (err) => {
bus.emit('error', null, err)
})

@@ -193,7 +194,7 @@ module.exports = {
responseType: 'stream',
maxContentLength: -1
})
.then(response => {
.then((response) => {
const contentLength = response.data.headers['content-length'] || -1
const mbTotal = filesize(contentLength, {
exponent: 2,
@@ -203,7 +204,7 @@ module.exports = {
const output = fs.createWriteStream(filePath)
const stream = response.data

const cancel = err => {
const cancel = (err) => {
stream.destroy(err)
deleteFile()

@@ -222,11 +223,11 @@ module.exports = {
exists: fs.existsSync(filePath)
})

output.on('error', err => {
output.on('error', (err) => {
cancel(err)
})

stream.on('data', chunk => {
stream.on('data', (chunk) => {
output.write(Buffer.from(chunk))

if (contentLength > 0) {
@@ -266,7 +267,7 @@ module.exports = {
bus.emit('end', null, filePath)
})

stream.on('error', err => {
stream.on('error', (err) => {
cancel(err)
})

@@ -275,7 +276,7 @@ module.exports = {
cancel()
})
})
.catch(err => {
.catch((err) => {
bus.emit('error', null, err)
})

@@ -286,11 +287,11 @@ module.exports = {
return new Promise((resolve, reject) => {
const bus = this.download(url, options)

bus.on('end', filePath => {
bus.on('end', (filePath) => {
resolve(filePath)
})

bus.on('error', err => {
bus.on('error', (err) => {
reject(err)
})
})

+ 4
- 6
src/electron/tools/index.js View File

@@ -9,9 +9,7 @@ const debug = require('debug').default('app:electron:tools')
const { Image } = require('image-js')
// const { Caman } = require('caman')

const AppError = require('../modules/error')
const paths = require('./paths')
const config = require('../../nuxt.config')

/**
* deepTools.
@@ -149,22 +147,22 @@ module.exports = {
process = spawn(paths.getCli('dreampower'), cliArgs)
}

process.on('error', error => {
process.on('error', (error) => {
console.error(error)
bus.emit('error', null, error)
})

process.stdout.on('data', data => {
process.stdout.on('data', (data) => {
console.info(`stdout: ${data}`)
bus.emit('stdout', null, data)
})

process.stderr.on('data', data => {
process.stderr.on('data', (data) => {
console.warn(`stderr: ${data}`)
bus.emit('stderr', null, data)
})

process.on('close', code => {
process.on('close', (code) => {
console.log(`CLI process exited with code ${code}`)
bus.emit('ready', null, code)
})

+ 0
- 2
src/middleware/nudity.js View File

@@ -9,8 +9,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import _ from 'lodash'

/**
* Pages that include this middleware will only be accessible
* if the user has selected a photo to transform.

+ 1
- 0
src/mixins/index.js View File

@@ -1 +1,2 @@
/* eslint-disable-next-line */
export { default as VModel } from './VModel'

+ 1
- 2
src/modules/dream.js View File

@@ -1,5 +1,4 @@
import _ from 'lodash'

/* eslint-disable-next-line */
const debug = require('debug').default('app:modules:app')

export default {

+ 1
- 0
src/modules/file.js View File

@@ -1,6 +1,7 @@
import _ from 'lodash'
import path from 'path'

/* eslint-disable-next-line */
const debug = require('debug').default('app:modules:file')

export default class File {

+ 1
- 0
src/modules/helpers.js View File

@@ -13,4 +13,5 @@ const rand = (min, max) => {
return Math.random() * (max - min) + min
}

/* eslint-disable-next-line */
export { rand }

+ 0
- 2
src/modules/models/model.js View File

@@ -1,5 +1,3 @@
import _ from 'lodash'

export default class Model {
constructor(id) {
this.id = id

+ 4
- 3
src/modules/update/base.js View File

@@ -293,14 +293,14 @@ export default class {

this.downloadBus = $tools.fs.download(url)

this.downloadBus.on('progress', payload => {
this.downloadBus.on('progress', (payload) => {
this.updating.progress = payload.progress
this.updating.mbTotal = payload.mbTotal
this.updating.mbWritten = payload.mbWritten
// debug(`Progress: ${progress}`)
})

this.downloadBus.on('end', filePath => {
this.downloadBus.on('end', (filePath) => {
debug('Download finished!', {
filePath
})
@@ -309,7 +309,7 @@ export default class {
deferred.resolve(filePath)
})

this.downloadBus.on('error', err => {
this.downloadBus.on('error', (err) => {
this.downloadBus = undefined
deferred.reject(err)
})
@@ -332,6 +332,7 @@ export default class {
* Install the downloaded update
* @param {string} filePath
*/
/* eslint-disable-next-line */
async install(filePath) {
// Custom
}

+ 12
- 5
src/nuxt.config.js View File

@@ -1,5 +1,6 @@
require('dotenv').config()

// eslint-disable-next-line nuxt/no-cjs-in-config
module.exports = {
mode: 'spa',

@@ -62,14 +63,20 @@ module.exports = {
plugins: ['~/plugins/boot.client.js', '~/components'],

/*
** Nuxt.js modules
** Nuxt.js dev-modules
*/
modules: [
'@nuxtjs/pwa',
// '@nuxtjs/eslint-module',
'@nuxtjs/dotenv'
devModules: [
// Doc: https://github.com/nuxt-community/eslint-module
'@nuxtjs/eslint-module',
// Doc: https://github.com/nuxt-community/nuxt-tailwindcss
'@nuxtjs/tailwindcss'
],

/*
** Nuxt.js modules
*/
modules: ['@nuxtjs/pwa', '@nuxtjs/dotenv'],

/*
** Axios module configuration
** See https://axios.nuxtjs.org/options

+ 12
- 7
src/package.json View File

@@ -105,7 +105,7 @@
},
"nsis": {
"oneClick": false,
"artifactName": "${productName}_Setup.${ext}",
"artifactName": "${productName}-windows-${env.BUILD_DEVICE}.${ext}",
"menuCategory": true,
"perMachine": false,
"allowToChangeInstallationDirectory": true,
@@ -114,30 +114,33 @@
"license": "license.txt"
},
"deb": {
"artifactName": "${productName}.${ext}",
"artifactName": "${productName}-ubuntu-${env.BUILD_DEVICE}.${ext}",
"fpm": [
"--deb-no-default-config-files"
]
},
"dmg": {
"title": "${productName} v${version}",
"artifactName": "${productName}.${ext}"
"artifactName": "${productName}-macos-${env.BUILD_DEVICE}.${ext}"
}
},
"scripts": {
"lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
"precommit": "yarn lint",
"postinstall": "patch-package",
"pack": "electron-builder --dir",
"dev:gui": "cross-env NODE_ENV=development nuxt",
"dev:electron": "cross-env NODE_ENV=development DEBUG=app:* electron .",
"build:gui": "cross-env NODE_ENV=production nuxt build",
"build:electron": "cross-env NODE_ENV=production electron-builder --publish=never",
"test": "yarn build:gui && cross-env NODE_ENV=production DEBUG=app:* electron .",
"build": "yarn build:gui && yarn build:electron",
"rebuild": "electron-rebuild",
"pack": "electron-builder --dir",
"preview": "yarn build:gui && cross-env NODE_ENV=production DEBUG=app:* electron .",
"release": "release-it"
},
"husky": {
"hooks": {
"pre-commit": "yarn lint"
}
},
"dependencies": {
"@nuxtjs/dotenv": "^1.4.0",
"@nuxtjs/pwa": "^2.6.0",
@@ -178,6 +181,7 @@
"@babel/core": "^7.5.0",
"@nuxtjs/eslint-config": "^0.0.1",
"@nuxtjs/eslint-module": "^0.0.1",
"@nuxtjs/tailwindcss": "^1.1.2",
"babel-eslint": "^10.0.1",
"cross-env": "^5.2.0",
"electron": "^5.0.6",
@@ -197,6 +201,7 @@
"eslint-plugin-promise": ">=4.0.1",
"eslint-plugin-standard": ">=4.0.0",
"eslint-plugin-vue": "^5.2.3",
"husky": "^3.0.4",
"node-sass": "^4.12.0",
"nodemon": "^1.18.9",
"nuxtjs-electron": "^0.1.10",

+ 0
- 2
src/pages/index.vue View File

@@ -20,8 +20,6 @@
</template>

<script>
import path from 'path'

export default {
data: () => ({}),


+ 0
- 1
src/pages/nudity/crop.vue View File

@@ -67,7 +67,6 @@

<script>
import Cropper from 'cropperjs'
import _ from 'lodash'

export default {
middleware: 'nudity',

+ 0
- 60
src/pages/nudity/results.old.vue View File

@@ -1,60 +0,0 @@
<template>
<div class="nudity-results">
<app-title>
<h1 class="title">
📷 Transformation in {{ $nudity.transformation.duration }}s
</h1>

<h3 class="subtitle">
Remember to visit our server in <nuxt-link to="/about">Discord</nuxt-link> to share and discuss changes
</h3>
</app-title>

<div class="content-body">
<nudity-preview :width="412" :height="412" type="output" />

<div class="buttons">
<button type="button" class="button is-success" @click.prevent="save">Save</button>
<br /><br />
<button type="button" class="button is-primary" @click.prevent="openDirectory">Open folder</button>
<nuxt-link to="/" class="button is-danger">Another one</nuxt-link>
</div>
</div>
</div>
</template>

<script>
import _ from 'lodash'
// import download from 'downloadjs'
import moment from 'moment'

export default {
middleware: 'nudity',

data: () => ({}),

methods: {
async save() {
const outputDataURL = await this.$nudity.modelPhoto
.getOutputFile()
.readAsDataURL()

const filename = this.$nudity.modelPhoto.getOutputFileName()

download(outputDataURL, filename, 'image/png')
},

openDirectory() {
window.deepTools.shell.openItem(this.$nudity.modelPhoto.getFolderPath())
}
}
}
</script>

<style lang="scss">
.nudity-results {
.buttons {
@apply text-center;
}
}
</style>

+ 3
- 14
src/plugins/boot.client.js View File

@@ -1,7 +1,6 @@
import Vue from 'vue'
import moment from 'moment'
import tippy from 'tippy.js'
import swal from 'sweetalert'
import BaseMixin from '~/mixins/BaseMixin'
import { dream, platform, updater, nudify, WebError } from '~/modules'

@@ -28,16 +27,6 @@ tippy.setDefaults({
arrowType: 'round'
})

function live(selector, event, callback, context) {
;(context || document).addEventListener(event, function event(e) {
let found
let el = e.target || e.srcElement
// eslint-disable-next-line
while (el && !(found = el.id == selector)) el = el.parentElement
if (found) callback.call(el, e)
})
}

export default async ({ app }, inject) => {
// Environment Information
debug('Enviroment', {
@@ -66,7 +55,7 @@ export default async ({ app }, inject) => {

//---

window.addEventListener('error', (error, url, lineNumber) => {
window.addEventListener('error', (error) => {
debug('Error captured', {
error,
type: typeof error
@@ -76,7 +65,7 @@ export default async ({ app }, inject) => {
return true
})

window.addEventListener('unhandledrejection', rejection => {
window.addEventListener('unhandledrejection', (rejection) => {
debug('Unhandled Rejection captured', {
error: rejection.reason,
type: typeof rejection.reason
@@ -86,7 +75,7 @@ export default async ({ app }, inject) => {
return true
})

Vue.config.errorHandler = (err, vm, info) => {
Vue.config.errorHandler = (err) => {
WebError.handle(err)
throw err
}

Loading…
Cancel
Save