Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy #1244

Merged
merged 57 commits into from
Aug 22, 2017
Merged

Deploy #1244

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
6aae758
save blockquote on section layout
eessex Aug 11, 2017
dca93e1
Merge pull request #1220 from eessex/set-blockquote
kanaabe Aug 11, 2017
2988e00
use reaction text component
eessex Aug 11, 2017
2a65f6f
dont import by function
eessex Aug 11, 2017
44efde9
begin paragraph refactor
eessex Aug 11, 2017
1efbb1b
paragraph can save, has pop-up menu, makes links
eessex Aug 12, 2017
bd4327e
replace lead paragraph
eessex Aug 12, 2017
56eef0d
Add coffeelint
damassi Aug 14, 2017
96a1c34
Initial Babel dep additions
damassi Aug 14, 2017
8938066
Merge pull request #1223 from damassi/add-coffeelint
kanaabe Aug 14, 2017
fc5827e
Finish babel deps; fix ESLint
damassi Aug 14, 2017
4ab5be0
Merge pull request #1224 from damassi/add-babel-pipeline
kanaabe Aug 14, 2017
33b94dc
Add babel on the client
damassi Aug 15, 2017
95fe2b5
Merge pull request #1226 from damassi/add-babel-clientside
yuki24 Aug 15, 2017
315e09a
First draft of reloadable
damassi Aug 14, 2017
dd2e092
[WIP] Better API
damassi Aug 15, 2017
db3f3b6
Always use yarn 0.27.x, stable version as of today
yuki24 Aug 15, 2017
f045a9c
Merge pull request #1227 from yuki24/specify-yarn-version
kanaabe Aug 15, 2017
d7e040e
Finish hot-reload work
damassi Aug 15, 2017
7a5c498
Merge pull request #1225 from damassi/add-reloadable
kanaabe Aug 15, 2017
618086d
Remove unused error check
damassi Aug 15, 2017
a4faf5c
Merge pull request #1228 from damassi/quickfix-error
damassi Aug 15, 2017
6558c94
Remove unused test folder
damassi Aug 15, 2017
8dc7af7
Merge pull request #1229 from damassi/remove-folder
damassi Aug 15, 2017
1fff33e
Finish styled-components setup
damassi Aug 15, 2017
3c4c72c
Merge pull request #1232 from damassi/add-styled-components-grid
yuki24 Aug 15, 2017
aab8528
Fix Makefile
damassi Aug 15, 2017
49af645
Prefix test file extensions with .test.coffee
damassi Aug 15, 2017
762e0b0
Update Makefile
damassi Aug 15, 2017
89afe86
FIXME: Uncomment tests
damassi Aug 15, 2017
7522cba
Merge pull request #1233 from damassi/fix-forever
damassi Aug 15, 2017
6466c93
Initial working setup
damassi Aug 12, 2017
9e7f685
Update ENV vars
damassi Aug 15, 2017
7621ef8
Merge pull request #1221 from damassi/dockerize-dev-environment
yuki24 Aug 16, 2017
0505cd0
Update README.md
damassi Aug 16, 2017
66efa8a
Merge pull request #1235 from damassi/update-docs-docker
damassi Aug 16, 2017
f9c0746
Address feedback
damassi Aug 16, 2017
1202682
Merge pull request #1236 from damassi/docker-updates
damassi Aug 16, 2017
2287ff4
Update comment for clarity
damassi Aug 16, 2017
6a1ac4c
Update Dockerfile
damassi Aug 16, 2017
47de20c
testing
eessex Aug 12, 2017
331ba7a
merge conflicts
eessex Aug 16, 2017
97710c1
Do not fail when .env is missing in production/staging
yuki24 Aug 16, 2017
f8d4cef
Merge pull request #1237 from yuki24/fix-start-script
yuki24 Aug 16, 2017
0f5167e
Make undefined check safe
damassi Aug 16, 2017
5c53254
Merge pull request #1238 from damassi/fix-js-type
yuki24 Aug 16, 2017
beaf305
Refer to @artsy/express-reloadable
damassi Aug 16, 2017
7c6e811
better linebreak handling, more tests
eessex Aug 17, 2017
cbd42b2
kill handleBackspace error
eessex Aug 17, 2017
6555d9d
Merge pull request #1239 from damassi/update-package-ref
damassi Aug 17, 2017
e100c63
merge conflicts
eessex Aug 18, 2017
3a2cb28
merge conflicts, bump reaction version
eessex Aug 18, 2017
f7232d2
Merge pull request #1222 from eessex/more-text
eessex Aug 18, 2017
5a4d717
Update README.md
damassi Aug 18, 2017
54662af
Update README.md
damassi Aug 18, 2017
772fcba
Rename dangerfile.js to dangerfile.ts
orta Aug 21, 2017
8ff4131
Merge pull request #1241 from artsy/orta-dangerfile-ts-1
kanaabe Aug 21, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
{}
{
"presets": [
"es2015",
"react",
"stage-3"
],
"plugins": [
"babel-plugin-rewire",
"inline-react-svg",
"transform-runtime",
["module-resolver", {
"root": ["./"]
}],
"transform-class-properties"
],
"env": {
"development": {
"plugins": [
["styled-components", {
"ssr": true
}]
]
}
}
}
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
9 changes: 7 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ API_URL=http://localhost:3005/api
FORCE_URL=https://staging.artsy.net
ARTSY_URL=https://stagingapi.artsy.net
SESSION_SECRET=p0s1tr0n
MONGOHQ_URL=mongodb://localhost:27017/positron
ELASTICSEARCH_PORT=9200

# Local development only for the below; refers to the key in docker-compose.yml
ELASTICSEARCH_URL=http://elasticsearch:9200
MONGOHQ_URL=mongodb://mongodb:27017/positron

TECH_SUPPORT=craig@artsymail.com
DEBUG=api,client,app
SALT=$2a$10$PJrPMBadu1NPdmnshBgFbe
Expand Down Expand Up @@ -34,4 +39,4 @@ INSTANT_ARTICLE_ACCESS_TOKEN=REPLACE
FB_PAGE_ID=REPLACE
DEFAULT_PARTNER_ID=REPLACE
SENTRY_PUBLIC_DSN=REPLACE
SENTRY_PRIVATE_DSN=REPLACE
SENTRY_PRIVATE_DSN=REPLACE
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ARTSY_URL=http://localhost:5000/__gravity
SESSION_SECRET=p0s1tr0n
MONGOHQ_URL=mongodb://localhost:27017/positron-test
ELASTICSEARCH_URL=http://localhost:9200
ELASTICSEARCH_PORT=9200
SALT=$2a$10$PJrPMBadu1NPdmnshBgFbe
API_MAX=100
API_PAGE_SIZE=10
Expand Down
21 changes: 21 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"parser": "babel-eslint",
"extends": [
"standard",
"standard-react"
],
"globals": {
__dirname: true
},
"env": {
"browser": true,
"mocha": true,
"node": true
},
"rules": {
"camelcase": 0,
"no-mixed-operators": 0,
"no-new": 0,
"react/jsx-indent": 0
}
}
7 changes: 0 additions & 7 deletions .eslintrc.js

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ dump.rdb
.env.ignore
node_modules
.vscode
data
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM node:7
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json .
RUN yarn install
COPY . .
13 changes: 4 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,16 @@ BIN = node_modules/.bin

# Start the server
s:
$(BIN)/coffee index.coffee
DEBUG=app,client,api node ./index.js

# Start the server using forever
sf:
$(BIN)/forever $(BIN)/coffee --nodejs --max-old-space-size=512 index.coffee
$(BIN)/forever ./index.js --max-old-space-size=512

# Run all of the project-level tests, followed by app-level tests
test: assets
$(BIN)/mocha $(shell find api/test -name '*.coffee' -not -path 'test/helpers/*')
$(BIN)/mocha $(shell find api/apps/*/test -name '*.coffee' -not -path 'test/helpers/*')
$(BIN)/mocha $(shell find client/test -name '*.coffee' -not -path 'test/helpers/*')
$(BIN)/mocha $(shell find client/apps/*/test -name '*.coffee' -not -path 'test/helpers/*')
$(BIN)/mocha $(shell find client/apps/*/**/*/test -name '*.coffee' -not -path 'test/helpers/*')
$(BIN)/mocha $(shell find client/apps/*/**/*/**/test -name '*.coffee' -not -path 'test/helpers/*')
$(BIN)/mocha $(shell find client/apps/*/**/*/**/*/test -name '*.coffee' -not -path 'test/helpers/*')
$(BIN)/mocha $(shell find api -name '*.test.coffee')
$(BIN)/mocha $(shell find client -name '*.test.coffee')

# Run app in test mode
test-s:
Expand Down
23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@ Meta
Set-Up
---

- Copy `.env.example` to `.env` in the root of the project and edit all `REPLACE` values with sensitive configuration obtained from `positron-staging`. This should help.

```
heroku config --app=positron-staging | grep -E `cat .env.example | grep REPLACE | cut -f1 -d= | xargs | tr ' ' \|` | sed -e 's/:\ /=/g' | sed -e 's/ //g'
```

### Via Docker Compose
- Install [Docker for Mac](https://docs.docker.com/docker-for-mac/install/)
- `git clone git@github.com:<your username>/positron.git && cd positron`
- `docker-compose up`

This starts a new self-contained Docker instance that boots MongoDB, ElasticSearch and Node. Changes made to source-code located in `api` and `client` is [automatically reloaded](https://github.com/artsy/positron/blob/master/boot.js#L34) on browser-refresh; no need to restart the process.

To shut down the process, press `ctrl+c` or execute `docker-compose down`.

### Manually

- Install [NVM](https://github.com/creationix/nvm)
- Install Node 6

Expand All @@ -41,12 +58,6 @@ git clone git@github.com:craigspaeth/positron.git && cd positron
yarn install
```

- Copy `.env.example` to `.env` in the root of the project and edit all `REPLACE` values with sensitive configuration obtained from `positron-staging`. This should help.

```
heroku config --app=positron-staging | grep -E `cat .env.example | grep REPLACE | cut -f1 -d= | xargs | tr ' ' \|` | sed -e 's/:\ /=/g' | sed -e 's/ //g'
```

- Positron uses MongoDB as a database. To install MongoDB using homebrew do the following, if you would prefer to install manually check the documentation at [MongoDB](http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/)

```
Expand Down
1 change: 1 addition & 0 deletions api/apps/articles/model/schema.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ denormalizedArtwork = (->
@object().meta(name: 'Text').keys
type: @string().valid('text')
body: @string().allow('', null)
layout: @string().allow('blockquote', null)
@object().meta(name: 'Artworks').keys
type: @string().valid('artworks')
ids: @array().items(@string().objectid())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,22 @@ describe 'Save', ->
]
})

it 'can save layouts on text sections', (done) ->
Save.sanitizeAndSave( ->
Article.find '5086df098523e60002000011', (err, article) =>
article.sections[0].layout.should.eql 'blockquote'
done()
)(null, {
_id: ObjectId '5086df098523e60002000011'
sections: [
{
type: 'text'
body: '<blockquote>Viva Art</blockquote>'
layout: 'blockquote'
}
]
})

it 'indexes articles that are indexable', (done) ->
Save.sanitizeAndSave( =>
Article.find '5086df098523e60002000011', (err, article) =>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion api/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ app.use notFound
app.use errorHandler

# Start the test server if run directly
app.listen(5000, -> debug "Listening on 5000") if module is require.main
app.listen(5000, -> debug "Listening on 5000") if module is require.main
File renamed without changes.
File renamed without changes.
File renamed without changes.
70 changes: 70 additions & 0 deletions boot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* Main server that combines API & client
*/

import artsyXapp from 'artsy-xapp'
import express from 'express'
import newrelic from 'artsy-newrelic'
import path from 'path'
import { IpFilter } from 'express-ipfilter'
import { createReloadable, isDevelopment } from '@artsy/express-reloadable'

const debug = require('debug')('app')
const app = module.exports = express()

// Blacklist ips
app.use(
IpFilter([process.env.IP_BLACKLIST.split(',')], { log: false, mode: 'deny' })
)

// Get an xapp token
const xappConfig = {
url: process.env.ARTSY_URL,
id: process.env.ARTSY_ID,
secret: process.env.ARTSY_SECRET
}

artsyXapp.init(xappConfig, () => {
app.use(newrelic)

if (isDevelopment) {
const reloadAndMount = createReloadable(app, require)

// Enable server-side code hot-swapping on change
app.use('/api', reloadAndMount(path.resolve(__dirname, 'api'), {
mountPoint: '/api'
}))

invalidateUserMiddleware(app)
reloadAndMount(path.resolve(__dirname, 'client'))

// Staging, Prod
} else {
app.use('/api', require('./api'))
invalidateUserMiddleware(app)
app.use(require('./client'))
}

// Start the server and send a message to IPC for the integration test
// helper to hook into.
app.listen(process.env.PORT, () => {
debug(`Listening on port ${process.env.PORT}`)

if (typeof process.send === 'function') {
process.send('listening')
}
})
})

// Crash if we can't get/refresh an xapp token
artsyXapp.on('error', (error) => {
console.warn(error)
process.exit(1)
})

const invalidateUserMiddleware = (app) => {
app.use((req, rest, next) => {
req.user = null
next()
})
}
2 changes: 1 addition & 1 deletion client/apps/articles_list/routes.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ renderArticles = (res, req, result, published) ->
res.locals.sd.HAS_PUBLISHED = published
res.render 'index',
articles: result.articles || []
current_channel: req.user?.get('current_channel')
current_channel: req.user?.get('current_channel')
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ DragContainer = React.createFactory require '../../../../../../components/drag_d
{ div, section, ul, li } = React.DOM

components = require('@artsy/reaction-force/dist/components/publishing/index').default
ImageSetPreview = React.createFactory components.ImagesetPreviewClassic
ImageSetPreview = React.createFactory components.ImageSetPreviewClassic

module.exports = React.createClass
displayName: 'SectionImageCollection'
Expand Down
34 changes: 16 additions & 18 deletions client/apps/edit/components/content2/section_container/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@

React = require 'react'
_ = require 'underscore'
SectionText = React.createFactory require '../sections/text/index.coffee'
SectionVideo = React.createFactory require '../../content/sections/video/index.coffee'
SectionSlideshow = React.createFactory require '../../content/sections/slideshow/index.coffee'
SectionEmbed = React.createFactory require '../../content/sections/embed/index.coffee'
SectionFullscreen = React.createFactory require '../../content/sections/fullscreen/index.coffee'
SectionCallout = React.createFactory require '../../content/sections/callout/index.coffee'
SectionImageCollection = React.createFactory require '../sections/image_collection/index.coffee'
SectionImage = React.createFactory require '../../content/sections/image/index.coffee'
Text = React.createFactory require '../sections/text/index.coffee'
Video = React.createFactory require '../../content/sections/video/index.coffee'
Slideshow = React.createFactory require '../../content/sections/slideshow/index.coffee'
Embed = React.createFactory require '../../content/sections/embed/index.coffee'
Fullscreen = React.createFactory require '../../content/sections/fullscreen/index.coffee'
ImageCollection = React.createFactory require '../sections/image_collection/index.coffee'
Image = React.createFactory require '../../content/sections/image/index.coffee'
{ div, nav, button } = React.DOM
icons = -> require('../../icons.jade') arguments...

Expand Down Expand Up @@ -46,7 +45,7 @@ module.exports = React.createClass
className: 'edit-section__container'
'data-editing': @props.editing
'data-type': @props.section.get('type')
'data-layout': @props.section.getLayout(@props.article.get('layout'))
'data-layout': @props.section.get('layout') or 'column_width'
},
unless @props.section.get('type') is 'fullscreen'
div {
Expand All @@ -64,15 +63,14 @@ module.exports = React.createClass
dangerouslySetInnerHTML: __html: $(icons()).filter('.remove').html()
}
(switch @props.section.get('type')
when 'text' then SectionText
when 'video' then SectionVideo
when 'slideshow' then SectionSlideshow
when 'embed' then SectionEmbed
when 'fullscreen' then SectionFullscreen
when 'callout' then SectionCallout
when 'image_set' then SectionImageCollection
when 'image_collection' then SectionImageCollection
when 'image' then SectionImage
when 'text' then Text
when 'video' then Video
when 'slideshow' then Slideshow
when 'embed' then Embed
when 'fullscreen' then Fullscreen
when 'image_set' then ImageCollection
when 'image_collection' then ImageCollection
when 'image' then Image
)(
section: @props.section
sections: @props.sections
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
border-radius 50%

.classic
[data-layout='column_width']
[data-layout='column_width'], [data-layout='blockquote']
max-width classic-body-w-margin
margin 0 auto
[data-layout='overflow_fillwidth']
Expand All @@ -82,7 +82,7 @@
[data-layout='column_width']
max-width standard-body-w-margin
margin 0 auto
[data-layout='overflow_fillwidth']
[data-layout='overflow_fillwidth'], [data-layout='blockquote']
max-width standard-overflow-w-margin

.feature
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe 'SectionContainer', ->
dragOver: 4
article: new Article
}
@SectionContainer.__set__ 'SectionText', ->
@SectionContainer.__set__ 'Text', ->
@component = ReactDOM.render React.createElement(@SectionContainer, @props
), $("<div></div>")[0], => setTimeout =>
@component.setState = sinon.stub()
Expand Down
Loading