Commit 09d307b6 authored by Jure's avatar Jure

Merge branch 'config' into 'master'

node_config -> CONFIG -> config.js -> config

See merge request !3
parents aa05f98b 53f136c8
Pipeline #2348 failed with stage
in 25 minutes and 27 seconds
......@@ -89,3 +89,4 @@ _build
coverage/
yarn-error.log
package-lock.json
config/local*.*
image: node:7
before_script:
- npm install -g yarn
- yarn
test:
......
......@@ -4,11 +4,10 @@ import ReactDOM from 'react-dom'
import { configureStore, Root } from 'pubsweet-client'
import { AppContainer } from 'react-hot-loader'
import { browserHistory } from 'react-router'
import { syncHistoryWithStore } from 'react-router-redux'
import createHistory from 'history/createBrowserHistory'
let store = configureStore(browserHistory, {})
let history = syncHistoryWithStore(browserHistory, store)
const history = createHistory()
const store = configureStore(history, {})
const rootEl = document.getElementById('root')
......
import React from 'react'
import config from 'config'
import AuthenticatedComponent from 'pubsweet-client/src/components/AuthenticatedComponent'
import Manage from 'pubsweet-component-manage/Manage'
import Navigation from '../Navigation/Navigation'
export default ({children, ...props}) => (
<AuthenticatedComponent
authsome={config.authsome}
operation='create'
selector={(state) => state.collections[0]}
{...props}
>
<Manage nav={<Navigation />}>
{children}
</Manage>
</AuthenticatedComponent>
)
import React from 'react'
import PropTypes from 'prop-types'
import { LinkContainer } from 'react-router-bootstrap'
import { Navbar, Nav, NavItem, NavbarBrand } from 'react-bootstrap'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import Authorize from 'pubsweet-client/src/helpers/Authorize'
import NavbarUser from 'pubsweet-component-navigation/NavbarUser'
import actions from 'pubsweet-client/src/actions'
export default class Navigation extends React.Component {
export class Navigation extends React.Component {
render () {
const { actions, currentUser } = this.props
let logoutButtonIfAuthenticated
......@@ -45,6 +48,20 @@ export default class Navigation extends React.Component {
}
Navigation.propTypes = {
actions: React.PropTypes.object.isRequired,
currentUser: React.PropTypes.object
actions: PropTypes.object.isRequired,
currentUser: PropTypes.object
}
function mapState (state) {
return {
currentUser: state.currentUser
}
}
function mapDispatch (dispatch) {
return {
actions: bindActionCreators(actions, dispatch)
}
}
export default connect(mapState, mapDispatch)(Navigation)
import React from 'react'
import { Route } from 'react-router'
import { requireAuthentication } from 'pubsweet-client/src/components/AuthenticatedComponent'
import { Route, Switch } from 'react-router-dom'
// Manage
import Manage from 'pubsweet-component-manage/Manage'
import PostsManager from 'pubsweet-component-posts-manager/PostsManager'
import UsersManager from 'pubsweet-component-users-manager/UsersManager'
import TeamsManager from 'pubsweet-component-teams-manager/TeamsManager'
import AuthenticatedManage from './components/AuthenticatedManage/AuthenticatedManage'
import PostsManager from 'pubsweet-component-posts-manager/PostsManagerContainer'
import UsersManager from 'pubsweet-component-users-manager/UsersManagerContainer'
import TeamsManager from 'pubsweet-component-teams-manager/TeamsManagerContainer'
// Editor
import MediumDraft from 'pubsweet-component-medium-draft/MediumDraft'
import MediumDraft from 'pubsweet-component-medium-draft/MediumDraftContainer'
// Public
import Blog from 'pubsweet-component-blog/Blog'
import HTML from 'pubsweet-component-html/HTML'
import Blog from 'pubsweet-component-blog/BlogContainer'
import HTML from 'pubsweet-component-html/HTMLContainer'
// Authentication
import Login from 'pubsweet-component-login/Login'
import Signup from 'pubsweet-component-signup/Signup'
const AuthenticatedManage = requireAuthentication(
Manage, 'create', (state) => state.collections[0]
)
import Login from 'pubsweet-component-login/LoginContainer'
import Signup from 'pubsweet-component-signup/SignupContainer'
class Managed extends React.Component {
render () {
return <AuthenticatedManage>
<Switch>
<Route path='/manage/posts' component={PostsManager} />
<Route path='/manage/users' component={UsersManager} />
<Route path='/manage/teams' component={TeamsManager} />
<Route path='/manage/sciencewriter/:id' component={MediumDraft} />
</Switch>
</AuthenticatedManage>
}
}
export default (
<Route>
<Route path='/' component={Blog} />
<Route path='/manage' component={AuthenticatedManage}>
<Route path='posts' component={PostsManager} />
<Route path='users' component={UsersManager} />
<Route path='teams' component={TeamsManager} />
<Route path='sciencewriter/:id' component={MediumDraft} />
</Route>
<Switch>
<Route exact path='/' component={Blog} />
<Route path='/manage' component={Managed} />
<Route path='/login' component={Login} />
<Route path='/signup' component={Signup} />
<Route path='/:id' component={HTML} />
</Route>
</Switch>
)
const blogmode = require('authsome/src/modes/blog')
const Joi = require('joi')
module.exports = {
'pubsweet-client': {
API_ENDPOINT: '/api',
theme: 'PepperTheme',
'login-redirect': '/manage/posts',
'redux-log': true
},
authsome: {
mode: blogmode,
teams: {
teamContributors: {
name: 'Contributors',
permissions: 'create'
},
teamCoauthors: {
name: 'Coauthors',
permissions: 'update'
}
},
'fail-redirect': '/login'
},
pubsweet: {
components: require('./components.json')
},
validations: {
fragment: {
kind: Joi.string(),
published: Joi.bool(),
published_at: Joi.string(),
source: Joi.any(),
presentation: Joi.string()
}
}
}
const config = require('./client-default.js')
module.exports = config
const config = require('./client-default.js')
module.exports = config
const config = require('./client-default.js')
module.exports = config
......@@ -5,13 +5,8 @@ const Joi = require('joi')
module.exports = {
'pubsweet-server': {
dbPath: process.env.PUBSWEET_DB || path.join(__dirname, '..', 'api', 'db'),
API_ENDPOINT: '/api',
sse: process.env.PUBSWEET_SSE
},
'pubsweet-client': {
theme: 'PepperTheme',
'login-redirect': '/manage/posts'
},
authsome: {
mode: blogmode,
teams: {
......
const config = require('./shared.js')
const config = require('./default.js')
module.exports = config
const config = require('./shared.js')
const config = require('./default.js')
module.exports = config
const config = require('./shared.js')
const config = require('./default.js')
module.exports = config
......@@ -11,20 +11,22 @@
"dependencies": {
"@pubsweet/logger": "^0.0.1",
"jest": "^21.1.0",
"pubsweet": "git+https://gitlab.coko.foundation/yld/pubsweet-cli.git#refactor/db-manager",
"pubsweet-client": "1.0.0-alpha.3",
"pubsweet-component-blog": "^0.2.0",
"pubsweet-component-html": "^0.0.1",
"pubsweet-component-login": "^0.3.0",
"pubsweet-component-manage": "^0.1.8",
"pubsweet-component-medium-draft": "^0.0.3",
"pubsweet": "git+https://git@gitlab.coko.foundation/yld/pubsweet-cli.git#refactor/db-manager",
"pubsweet-client": "^1.0.0-beta.3",
"pubsweet-component-blog": "^0.3.1",
"pubsweet-component-html": "^0.2.0",
"pubsweet-component-login": "^0.5.1",
"pubsweet-component-manage": "^0.1.11",
"pubsweet-component-medium-draft": "^0.2.0",
"pubsweet-component-navigation": "^0.2.7",
"pubsweet-component-pepper-theme": "^0.0.3",
"pubsweet-component-posts-manager": "^0.3.0",
"pubsweet-component-signup": "^0.2.0",
"pubsweet-component-teams-manager": "^0.1.7",
"pubsweet-component-users-manager": "^0.1.6",
"pubsweet-component-posts-manager": "^0.4.2",
"pubsweet-component-signup": "^0.4.0",
"pubsweet-component-teams-manager": "^0.2.1",
"pubsweet-component-users-manager": "^0.2.1",
"pubsweet-server": "1.0.0-alpha.2",
"pubsweet-theme-plugin": "^0.0.1"
"pubsweet-theme-plugin": "^0.0.1",
"react-router-redux": "next"
},
"devDependencies": {
"app-module-path": "^2.2.0",
......@@ -44,6 +46,13 @@
"compression-webpack-plugin": "^0.3.1",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.28.1",
"eslint": "^4.7.1",
"eslint-config-standard": "^10.2.1",
"eslint-config-standard-react": "^5.0.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.2.0",
"eslint-plugin-react": "^7.4.0",
"eslint-plugin-standard": "^3.0.1",
"extract-text-webpack-plugin": "^2.0.0-beta.4",
"file-loader": "^0.11.1",
"html-webpack-plugin": "^2.24.0",
......@@ -65,8 +74,9 @@
"webpack-hot-middleware": "^2.18.0"
},
"scripts": {
"start": "pubsweet run",
"setupdb": "pubsweet setupdb .",
"lint": "eslint app test webpack",
"start": "node src/scripts/start.js",
"setupdb": "pubsweet setupdb",
"pubsweet": "pubsweet",
"test": "jest"
},
......@@ -74,11 +84,6 @@
"testMatch": [
"**/test/*.js"
],
"collectCoverage": true,
"collectCoverageFrom": [
"**/src/scripts/*.js",
"**/app/**/*.js"
],
"modulePaths": [
"<rootDir>/node_modules"
],
......
require('app-module-path').addPath(process.cwd())
const path = require('path')
if (!process.env.NODE_ENV) {
process.env.NODE_ENV = 'development'
}
const dotenvPath = path.join(process.cwd(), `.env.${process.env.NODE_ENV}`)
require('dotenv').config({ path: dotenvPath })
......@@ -24,10 +28,6 @@ const webpackconfig = require(path.join(
process.cwd(), 'webpack', `webpack.${process.env.NODE_ENV}.config.js`
))
if (process.env.NODE_ENV === 'test') {
webpackconfig.target = 'electron-main'
}
const registerDevtools = (app, compiler, cb) => {
app.use(require(
path.join(process.cwd(), 'node_modules', 'webpack-dev-middleware')
......@@ -137,7 +137,7 @@ const runapp = (err, stats, cb) => {
logger.info(`PubSweet is listening on port ${port}`)
serverListening = true
if (cb) cb(server) // used to enable testing
if (process.env.NODE_ENV === 'dev' && !watcher) startWatcher()
if (process.env.NODE_ENV === 'development' && !watcher) startWatcher()
}
server.on('error', onError)
......@@ -146,7 +146,7 @@ const runapp = (err, stats, cb) => {
server.listen(port)
}
if (process.env.NODE_ENV === 'dev') {
if (process.env.NODE_ENV === 'development') {
registerDevtools(rawapp, compiler, postcompile)
} else {
compiler.run(postcompile)
......
{
"env": {
"node": true,
"es6": true,
"browser": true,
"jest": true,
"jasmine": true
}
}
......@@ -128,8 +128,8 @@ module.exports = {
)
.click(
team.fragment
? newteamform.fragmentchoice(1)
: newteamform.collectionchoice(1)
? newteamform.fragmentchoice(1)
: newteamform.collectionchoice(1)
)
.wait(200)
.click(newteamform.submit),
......
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1200000
const path = require('path')
// require('app-module-path').addPath(path.join(__dirname, '..', '..'))
const logger = require('@pubsweet/logger')
const fixtures = require('./fixtures')
......@@ -57,4 +53,4 @@ describe('start', () => {
await expect(promise).resolves.toBe(dbconfig.collection)
})
})
\ No newline at end of file
})
const path = require('path')
const config = require(`../config/${process.env.NODE_ENV}.js`)
const config = require('config')
const babelIncludes = require('./babel-includes')
const resolve = (type, entry) => {
......
const path = require('path')
const webpack = require('webpack')
const ThemePlugin = require('pubsweet-theme-plugin')
const config = require('../config/dev')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const CompressionPlugin = require('compression-webpack-plugin')
const config = require('../config/client-development')
module.exports = [
{
......@@ -35,7 +35,8 @@ module.exports = [
'node_modules'
],
alias: {
joi: 'joi-browser'
joi: 'joi-browser',
config: path.resolve(__dirname, '..', 'config', 'client-development')
},
plugins: [new ThemePlugin(config['pubsweet-client'].theme)],
extensions: ['.js', '.jsx', '.json', '.scss'],
......@@ -50,9 +51,6 @@ module.exports = [
'REDUXLOG_OFF': process.env.REDUXLOG_OFF
}
}),
new webpack.ProvidePlugin({
'CONFIG': path.resolve(__dirname, '..', 'config', 'dev.js')
}),
new CopyWebpackPlugin([
{ from: '../static' }
]),
......
......@@ -5,7 +5,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin')
const ThemePlugin = require('pubsweet-theme-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const CompressionPlugin = require('compression-webpack-plugin')
const config = require('../config/production')
const config = require('../config/client-production')
module.exports = [
{
......@@ -32,7 +32,8 @@ module.exports = [
'node_modules'
],
alias: {
joi: 'joi-browser'
joi: 'joi-browser',
config: path.resolve(__dirname, '..', 'config', 'client-production')
},
extensions: ['.js', '.jsx', '.json', '.scss'],
plugins: [new ThemePlugin(config['pubsweet-client'].theme)]
......@@ -46,9 +47,6 @@ module.exports = [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new webpack.ProvidePlugin({
'CONFIG': path.resolve(__dirname, '..', 'config', 'production.js')
}),
new ExtractTextPlugin('styles/main.css'),
new CopyWebpackPlugin([
{ from: '../static' }
......
const path = require('path')
const webpack = require('webpack')
const ThemePlugin = require('pubsweet-theme-plugin')
const config = require('../config/test')
const CompressionPlugin = require('compression-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const CompressionPlugin = require('compression-webpack-plugin')
const config = require('../config/client-test')
module.exports = [
{
// The configuration for the client
name: 'app',
target: 'electron-main',
target: 'web',
context: path.join(__dirname, '..', 'app'),
entry: {
app: [
......@@ -34,7 +34,8 @@ module.exports = [
'node_modules'
],
alias: {
joi: 'joi-browser'
joi: 'joi-browser',
config: path.resolve(__dirname, '..', 'config', 'client-test')
},
plugins: [new ThemePlugin(config['pubsweet-client'].theme)],
extensions: ['.js', '.jsx', '.json', '.scss'],
......@@ -49,9 +50,6 @@ module.exports = [
'REDUXLOG_OFF': process.env.REDUXLOG_OFF
}
}),
new webpack.ProvidePlugin({
'CONFIG': path.resolve(__dirname, '..', 'config', 'test.js')
}),
new CopyWebpackPlugin([
{ from: '../static' }
]),
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment