1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

fix build env

This commit is contained in:
Rokt33r
2015-10-19 11:46:58 +09:00
parent 55db0bebbb
commit 7459e937b5
15 changed files with 126 additions and 29 deletions

1
.gitignore vendored
View File

@@ -3,3 +3,4 @@ node_modules/*
!node_modules/boost !node_modules/boost
Boost-darwin-x64/ Boost-darwin-x64/
backup/ backup/
compiled

View File

@@ -10,7 +10,7 @@ import { findWhere, findIndex, pick } from 'lodash'
import keygen from 'boost/keygen' import keygen from 'boost/keygen'
import api from 'boost/api' import api from 'boost/api'
import auth from 'boost/auth' import auth from 'boost/auth'
import 'boost/socket' import io from 'boost/socket'
class HomePage extends React.Component { class HomePage extends React.Component {
componentDidMount () { componentDidMount () {
@@ -19,7 +19,8 @@ class HomePage extends React.Component {
dispatch(switchUser(this.props.params.userId)) dispatch(switchUser(this.props.params.userId))
let currentUser = auth.user() let currentUser = auth.user()
let users = [currentUser].concat(currentUser.Teams)
let users = currentUser.Teams != null ? [currentUser].concat(currentUser.Teams) : [currentUser]
users.forEach(user => { users.forEach(user => {
api.fetchArticles(user.id) api.fetchArticles(user.id)
.then(res => { .then(res => {
@@ -30,6 +31,11 @@ class HomePage extends React.Component {
console.error(err) console.error(err)
}) })
}) })
let token = auth.token()
if (token != null) {
io.emit('JOIN', {token})
}
} }
componentWillReceiveProps (nextProps) { componentWillReceiveProps (nextProps) {

View File

@@ -167,6 +167,7 @@ export default class ArticleDetail extends React.Component {
api.createArticle(article) api.createArticle(article)
.then(res => { .then(res => {
console.log('saved as new')
console.log(res.body) console.log(res.body)
}) })
.catch(err => { .catch(err => {
@@ -196,6 +197,7 @@ export default class ArticleDetail extends React.Component {
api.saveArticle(article) api.saveArticle(article)
.then(res => { .then(res => {
console.log('saved')
console.log(res.body) console.log(res.body)
}) })
.catch(err => { .catch(err => {

View File

@@ -15,6 +15,7 @@ export default class ArticleList extends React.Component {
render () { render () {
let { articles, activeArticle } = this.props let { articles, activeArticle } = this.props
console.log(articles)
let articlesEl = articles.map(article => { let articlesEl = articles.map(article => {
let tags = Array.isArray(article.Tags) && article.Tags.length > 0 let tags = Array.isArray(article.Tags) && article.Tags.length > 0

View File

@@ -8,9 +8,9 @@ import Preferences from 'boost/components/modal/Preferences'
import CreateNewFolder from 'boost/components/modal/CreateNewFolder' import CreateNewFolder from 'boost/components/modal/CreateNewFolder'
export default class ArticleNavigator extends React.Component { export default class ArticleNavigator extends React.Component {
componentDidMount () { // componentDidMount () {
this.handlePreferencesButtonClick() // this.handlePreferencesButtonClick()
} // }
handlePreferencesButtonClick (e) { handlePreferencesButtonClick (e) {
openModal(Preferences) openModal(Preferences)

View File

@@ -15,6 +15,8 @@ export default class UserNavigator extends Component {
} }
renderUserList () { renderUserList () {
if (this.props.users == null) return null
var users = this.props.users.map((user, index) => ( var users = this.props.users.map((user, index) => (
<li key={'user-' + user.id}> <li key={'user-' + user.id}>
<Link to={'/users/' + user.id} activeClassName='active'> <Link to={'/users/' + user.id} activeClassName='active'>

View File

@@ -3,6 +3,7 @@ import { Link } from 'react-router'
import linkState from 'boost/linkState' import linkState from 'boost/linkState'
import openExternal from 'boost/openExternal' import openExternal from 'boost/openExternal'
import { signup } from 'boost/api' import { signup } from 'boost/api'
import auth from 'boost/auth'
export default class SignupContainer extends React.Component { export default class SignupContainer extends React.Component {
constructor (props) { constructor (props) {
@@ -27,8 +28,8 @@ export default class SignupContainer extends React.Component {
}, function () { }, function () {
signup(this.state.user) signup(this.state.user)
.then(res => { .then(res => {
localStorage.setItem('token', res.body.token) let { user, token } = res.body
localStorage.setItem('currentUser', JSON.stringify(res.body.user)) auth.user(user, token)
this.props.history.pushState('home') this.props.history.pushState('home')
}) })
@@ -42,8 +43,7 @@ export default class SignupContainer extends React.Component {
}, },
isSending: false isSending: false
}) })
} } else if (err.status != null) {
else if (err.status != null) {
return this.setState({ return this.setState({
error: { error: {
name: err.response.body.name, name: err.response.body.name,

View File

@@ -56,14 +56,15 @@
<script type="text/javascript"> <script type="text/javascript">
var version = require('remote').require('app').getVersion() var version = require('remote').require('app').getVersion()
document.title = 'Boost' + ((version == null || version.length === 0) ? ' DEV' : '') document.title = 'Boost' + ((version == null || version.length === 0) ? ' DEV' : '')
// require("babel-core/register")
// require('./index')
document.addEventListener('mousewheel', function(e) { document.addEventListener('mousewheel', function(e) {
if(e.deltaY % 1 !== 0) { if(e.deltaY % 1 !== 0) {
e.preventDefault() e.preventDefault()
} }
}) })
</script> </script>
<script type="text/javascript" src='../../compiled/main.js'></script>
<!--
<script src="http://localhost:8080/assets/main.js"></script> <script src="http://localhost:8080/assets/main.js"></script>
-->
</body> </body>
</html> </html>

View File

@@ -1,2 +1,3 @@
export const API_URL = 'http://localhost:8000/' // export const API_URL = 'http://localhost:8000/'
export const API_URL = 'http://boost-api4.elasticbeanstalk.com/'
// export API_URL 'https://api2.b00st.io/' // export API_URL 'https://api2.b00st.io/'

View File

@@ -1,6 +1,10 @@
var fs = require('fs') var fs = require('fs')
var path = require('path') var path = require('path')
var url = path.resolve(process.cwd(), './submodules/ace/src-min')
var rootUrl = process.cwd()
if (rootUrl === '/') rootUrl = require('remote').require('app').getAppPath()
var url = path.resolve(rootUrl, './submodules/ace/src-min')
console.log(url)
module.exports = fs.readdirSync(url) module.exports = fs.readdirSync(url)
.filter(function (file) { .filter(function (file) {

View File

@@ -81,8 +81,12 @@ function articles (state, action) {
let articles = JSON.parse(localStorage.getItem(teamKey)) let articles = JSON.parse(localStorage.getItem(teamKey))
let targetIndex = findIndex(articles, _article => article.key === _article.key) let targetIndex = findIndex(articles, _article => article.key === _article.key)
console.log('before')
console.log(articles)
if (targetIndex < 0) articles.unshift(article) if (targetIndex < 0) articles.unshift(article)
else articles.splice(targetIndex, 1, article) else articles.splice(targetIndex, 1, article)
console.log('after')
console.log(articles)
localStorage.setItem(teamKey, JSON.stringify(articles)) localStorage.setItem(teamKey, JSON.stringify(articles))
state[teamKey] = articles state[teamKey] = articles

View File

@@ -1,20 +1,26 @@
import React from 'react'
import reducer from './reducer' import reducer from './reducer'
import { createStore } from 'redux' import { createStore } from 'redux'
// Devtools // import React from 'react'
import { compose } from 'redux' // import { compose } from 'redux'
import { devTools, persistState } from 'redux-devtools' // import { devTools, persistState } from 'redux-devtools'
import { DevTools, DebugPanel, LogMonitor } from 'redux-devtools/lib/react' // import { DevTools, DebugPanel, LogMonitor } from 'redux-devtools/lib/react'
let finalCreateStore = compose(devTools(), persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/)))(createStore) console.log(process.env)
let store = finalCreateStore(reducer)
export let devToolElement = ( var store, devToolEl
<DebugPanel top right bottom> // if (process.env.NODE_ENV !== 'production') {
<DevTools store={store} monitor={LogMonitor} visibleOnLoad={false}/> // let finalCreateStore = compose(devTools(), persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/)))(createStore)
</DebugPanel> // let store = finalCreateStore(reducer)
)
// let store = createStore(reducer) // devToolEl = (
// <DebugPanel top right bottom>
// <DevTools store={store} monitor={LogMonitor} visibleOnLoad={false}/>
// </DebugPanel>
// )
// } else {
// }
devToolEl = null
store = createStore(reducer)
export let devToolElement = devToolEl
export default store export default store

View File

@@ -6,7 +6,9 @@
"scripts": { "scripts": {
"start": "electron ./main.js", "start": "electron ./main.js",
"webpack": "webpack-dev-server --inline", "webpack": "webpack-dev-server --inline",
"build": "electron-packager ./ Boost $npm_package_config_platform $npm_package_config_version $npm_package_config_ignore --overwrite" "compile": "NODE_ENV=production webpack --config webpack.config.production.js",
"build": "electron-packager ./ Boost $npm_package_config_platform $npm_package_config_version $npm_package_config_ignore --overwrite",
"codesign": "codesign --verbose --deep --force --sign \"MAISIN solutions Inc.\" Boost-darwin-x64/Boost.app"
}, },
"config": { "config": {
"version": "--version=0.33.0 --app-version=$npm_package_version --app-bundle-id=com.maisin.boost", "version": "--version=0.33.0 --app-version=$npm_package_version --app-bundle-id=com.maisin.boost",

View File

@@ -25,8 +25,8 @@ module.exports = {
] ]
}, },
plugins: [ plugins: [
new webpack.HotModuleReplacementPlugin() new webpack.HotModuleReplacementPlugin(),
// new webpack.NoErrorsPlugin() new webpack.NoErrorsPlugin()
], ],
externals: [ externals: [
'socket.io-client', 'socket.io-client',

View File

@@ -0,0 +1,67 @@
var webpack = require('webpack')
module.exports = {
devtool: 'source-map',
entry: {
main: './browser/main/index.js'
},
output: {
path: 'compiled',
filename: '[name].js',
sourceMapFilename: '[name].map',
publicPath: 'http://localhost:8090/assets',
libraryTarget: 'commonjs2'
},
module: {
loaders: [
{
test: /(\.js|\.jsx)?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel'
},
{
test: /\.styl?$/,
exclude: /(node_modules|bower_components)/,
loader: 'style-loader!css-loader!stylus-loader'
}
]
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production'),
'BABEL_ENV': JSON.stringify('production')
}
})
// new webpack.optimize.UglifyJsPlugin({
// compressor: {
// warnings: false
// }
// })
],
externals: [
'socket.io-client',
'md5',
'superagent',
'superagent-promise',
// 'react',
// 'redux',
// 'react-redux',
// 'react-router',
'lodash',
// 'redbox-react',
// 'react-transform-hmr',
// 'react-transform-catch-errors',
// 'redux-devtools',
// 'redux-devtools/lib/react',
// 'react-select',
'markdown-it',
'moment',
'fs',
'path'
],
resolve: {
extensions: ['', '.js', '.jsx', 'styl']
},
target: 'atom'
}