Skip to content
This repository has been archived by the owner on Jul 7, 2020. It is now read-only.

Commit

Permalink
first beta version
Browse files Browse the repository at this point in the history
  • Loading branch information
qazbnm456 committed Dec 31, 2017
1 parent f6b5b64 commit 0a919db
Show file tree
Hide file tree
Showing 521 changed files with 116,129 additions and 3 deletions.
34 changes: 34 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"comments": false,
"env": {
"test": {
"presets": [
["env", {
"targets": { "node": "8.2.1" }
}],
"stage-0"
],
"plugins": ["istanbul"]
},
"main": {
"presets": [
["env", {
"targets": { "node": "8.2.1" }
}],
"stage-0"
]
},
"renderer": {
"presets": [
["env", {
"modules": false
}],
"stage-0"
]
}
},
"plugins": [
"closure-elimination",
"transform-runtime"
]
}
149 changes: 149 additions & 0 deletions .electron-vue/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
'use strict'

process.env.NODE_ENV = 'production'

const { say } = require('cfonts')
const chalk = require('chalk')
const del = require('del')
const fs = require('fs')
const packager = require('electron-packager')
const webpack = require('webpack')
const Multispinner = require('multispinner')

const buildConfig = require('./config').building
const mainConfig = require('./webpack.main.config')
const rendererConfig = require('./webpack.renderer.config')

const doneLog = chalk.bgGreen.white(' DONE ') + ' '
const errorLog = chalk.bgRed.white(' ERROR ') + ' '
const okayLog = chalk.bgBlue.white(' OKAY ') + ' '
const isCI = process.env.CI || false

if (process.env.BUILD_TARGET === 'clean') clean()
else rev()

function clean () {
del.sync(['builds/*', '!.gitkeep'])
console.log(`\n${doneLog}\n`)
process.exit()
}

/**
* Write rev info in production
*/
function rev() {
console.log('\x1b[34mWriting rev into app(s)...\n\x1b[0m')
const appConfig = require('path').resolve(__dirname ,'../src/main/js/constants/config.ts')
fs.readFile(appConfig, 'utf8', (err, data) => {
if (err) {
console.error(err)
} else {
const result = data.replace(/lulumiRev: ['a-z0-9]*,/, `lulumiRev: '${require('git-rev-sync').long('.')}',`)
fs.writeFile(appConfig, result, 'utf8', (err) => {
if (err) {
console.error(err)
} else build()
});
}
})
}

function build () {
greeting()

del.sync(['dist/*', '!.gitkeep'])

const tasks = ['main', 'renderer']
const m = new Multispinner(tasks, {
preText: 'building',
postText: 'process'
})

let results = ''

m.on('success', () => {
process.stdout.write('\x1B[2J\x1B[0f')
console.log(`\n\n${results}`)
console.log(`${okayLog}take it away ${chalk.yellow('electron-packager')}\n`)
bundleApp()
})

pack(mainConfig).then(result => {
results += result + '\n\n'
m.success('main')
}).catch(err => {
m.error('main')
console.log(`\n ${errorLog}failed to build main process`)
console.error(`\n${err}\n`)
process.exit(1)
})

pack(rendererConfig).then(result => {
results += result + '\n\n'
m.success('renderer')
}).catch(err => {
m.error('renderer')
console.log(`\n ${errorLog}failed to build renderer process`)
console.error(`\n${err}\n`)
process.exit(1)
})
}

function pack (config) {
return new Promise((resolve, reject) => {
webpack(config, (err, stats) => {
if (err) reject(err.stack || err)
else if (stats.hasErrors()) {
let err = ''

stats.toString({
chunks: false,
colors: true
})
.split(/\r?\n/)
.forEach(line => {
err += ` ${line}\n`
})

reject(err)
} else {
resolve(stats.toString({
chunks: false,
colors: true
}))
}
})
})
}

function bundleApp () {
packager(buildConfig)
.then((appPaths) => {
console.log(`\n${doneLog}\n`)
console.log(appPaths)

console.log('\n\x1b[34mDONE\n\x1b[0m')
})
.catch((err) => {
console.log(`\n${errorLog}${chalk.yellow('`electron-packager`')} says...\n`)
console.log(err + '\n')
});
}

function greeting () {
const cols = process.stdout.columns
let text = ''

if (cols > 85) text = 'lets-build'
else if (cols > 60) text = 'lets-|build'
else text = false

if (text && !isCI) {
say(text, {
colors: ['yellow'],
font: 'simple3d',
space: false
})
} else console.log(chalk.yellow.bold('\n lets-build'))
console.log()
}
34 changes: 34 additions & 0 deletions .electron-vue/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const path = require('path');

const config = {
// Name of electron app
// Will be used in production builds
name: 'lulumi-predator',

// Use ESLint (extends `airbnb`)
// Further changes can be made in `.eslintrc.js`
eslint: true,

// webpack-dev-server port
port: 9080,

// electron-packager options
// https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-electron-packager.html
building: {
arch: 'x64',
asar: {
unpackDir: 'static',
},
dir: path.join(__dirname, '../'),
icon: path.join(__dirname, '../build/icons/icon'),
ignore: /(^\/(src|test|build|extensions|userData|tslint|\.\w+|README|yarn))|\.gitkeep/,
out: path.join(__dirname, '../builds'),
overwrite: true,
packageManager: false,
platform: process.env.BUILD_TARGET || 'all',
},
};

config.building.name = config.name;

module.exports = config;
40 changes: 40 additions & 0 deletions .electron-vue/dev-client-about.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const hotClient = require('webpack-hot-middleware/client?name=about&noInfo=true&reload=true')

hotClient.subscribe((event) => {
/**
* Reload browser when HTMLWebpackPlugin emits a new index.html
*
* Currently disabled until jantimon/html-webpack-plugin#680 is resolved.
* https://github.com/SimulatedGREG/electron-vue/issues/437
* https://github.com/jantimon/html-webpack-plugin/issues/680
*/
// if (event.action === 'reload') {
// window.location.reload()
// }

/**
* Notify `mainWindow` when `main` process is compiling,
* giving notice for an expected reload of the `electron` process
*/
if (event.action === 'compiling') {
document.body.innerHTML += `
<style>
#dev-client {
background: #4fc08d;
border-radius: 4px;
bottom: 20px;
box-shadow: 0 4px 5px 0 rgba(0, 0, 0, 0.14), 0 1px 10px 0 rgba(0, 0, 0, 0.12), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
color: #fff;
font-family: 'Source Sans Pro', sans-serif;
left: 20px;
padding: 8px 12px;
position: absolute;
}
</style>
<div id="dev-client">
Compiling Main Process...
</div>
`
}
})
41 changes: 41 additions & 0 deletions .electron-vue/dev-client-renderer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const hotClient = require('webpack-hot-middleware/client?name=renderer&noInfo=true&reload=true')
const { remote } = require('electron')

hotClient.subscribe((event) => {
/**
* Reload browser when HTMLWebpackPlugin emits a new index.html
*
* Currently disabled until jantimon/html-webpack-plugin#680 is resolved.
* https://github.com/SimulatedGREG/electron-vue/issues/437
* https://github.com/jantimon/html-webpack-plugin/issues/680
*/
// if (event.action === 'reload') {
// remote.BrowserWindow.getAllWindows().forEach(window => window.webContents.reloadIgnoringCache())
// }

/**
* Notify `mainWindow` when `main` process is compiling,
* giving notice for an expected reload of the `electron` process
*/
if (event.action === 'compiling') {
document.body.innerHTML += `
<style>
#dev-client {
background: #4fc08d;
border-radius: 4px;
bottom: 20px;
box-shadow: 0 4px 5px 0 rgba(0, 0, 0, 0.14), 0 1px 10px 0 rgba(0, 0, 0, 0.12), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
color: #fff;
font-family: 'Source Sans Pro', sans-serif;
left: 20px;
padding: 8px 12px;
position: absolute;
}
</style>
<div id="dev-client">
Compiling Main Process...
</div>
`
}
})
Loading

0 comments on commit 0a919db

Please sign in to comment.