Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 3 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,13 @@ aliases:
cd ./mobile && yarn && yarn setup && cd ..
cd ./desktop && yarn && cd ..

- &install-rethinkdb
name: Install RethinkDB 2.3.5
command:
|
echo "deb http://download.rethinkdb.com/apt jessie main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list
wget -qO- http://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install rethinkdb=2.3.5~0jessie

- &start-rethinkdb
name: Start RethinkDB
command: rethinkdb --bind all
background: true

- &setup-and-build-web
name: Setup and build web
command:
|
cp now-secrets.example.json now-secrets.json
yarn run build:web
yarn run build:hyperion

- &build-api
name: Build API
Expand All @@ -54,7 +41,7 @@ aliases:

- &start-web
name: Start web client in the background
command: yarn run dev:web
command: yarn run start:test
background: true

defaults: &defaults
Expand Down Expand Up @@ -107,7 +94,7 @@ jobs:
- run: *start-api
- run: *start-web
# Wait for the API and webserver to start
- run: ./node_modules/.bin/wait-on http://localhost:3000 http://localhost:3001
- run: ./node_modules/.bin/wait-on http://localhost:3006 http://localhost:3001
- run:
name: Run Unit Tests
command: yarn run test:ci
Expand Down
6 changes: 1 addition & 5 deletions api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ app.use(
);

app.use('/', (req: express$Request, res: express$Response) => {
res.redirect(
process.env.NODE_ENV === 'production' && !process.env.FORCE_DEV
? 'https://spectrum.chat'
: 'http://localhost:3000'
);
res.send('API active.');
});

import type { Loader } from './loaders/types';
Expand Down
16 changes: 4 additions & 12 deletions config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@ module.exports = function override(config, env) {
}
config = injectBabelPlugin('react-loadable/babel', config);
config = transpileShared(config);
config.plugins.push(
new webpack.optimize.CommonsChunkPlugin({
names: ['bootstrap'],
filename: 'static/js/[name].js',
minChunks: Infinity,
})
);
// Filter the default serviceworker plugin, add offline plugin instead
config.plugins = config.plugins.filter(
plugin => !isServiceWorkerPlugin(plugin)
Expand Down Expand Up @@ -141,12 +134,11 @@ module.exports = function override(config, env) {
})
);
}
config.plugins.push(
config.plugins.unshift(
new webpack.optimize.CommonsChunkPlugin({
minChunks: 3,
name: 'main',
async: 'commons',
children: true,
names: ['bootstrap'],
filename: 'static/js/[name].js',
minChunks: Infinity,
})
);
if (process.env.NODE_ENV === 'production') {
Expand Down
5 changes: 3 additions & 2 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"baseUrl": "http://localhost:3000",
"baseUrl": "http://localhost:3006",
"viewportWidth": 1300,
"defaultCommandTimeout": 20000,
"blacklistHosts": [
"*.google-analytics.com"
"*.google-analytics.com",
"*.amplitude.com"
],
"env": {
"DEBUG": "src*,testing*,build*"
Expand Down
9 changes: 9 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,17 @@

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
const setup = require('../../shared/testing/setup');
const teardown = require('../../shared/testing/teardown');

module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
on('task', {
resetdb() {
return teardown()
.then(setup)
.then(() => null);
},
});
};
9 changes: 0 additions & 9 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@ Cypress.Commands.add('auth', userId => {
);
});

Cypress.Commands.add('resetdb', () => {
cy.exec(
`node -e "const teardown = require('./shared/testing/teardown.js')().then(() => process.exit())"`
);
cy.exec(
`node -e "const setup = require('./shared/testing/setup.js')().then(() => process.exit())"`
);
});

Cypress.Commands.overwrite('type', (originalFn, $elem, text, options) => {
const textarea = $elem[0];
// If it's a DraftJS editor, simulate text events
Expand Down
4 changes: 2 additions & 2 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
import './commands';

before(() => {
cy.resetdb();
cy.task('resetdb');
cy.clearLocalStorage();
});

beforeEach(() => {
cy.resetdb();
cy.task('resetdb');
cy.clearLocalStorage();
});
88 changes: 52 additions & 36 deletions hyperion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,42 +39,6 @@ if (process.env.NODE_ENV === 'production' && !process.env.FORCE_DEV) {
import cors from 'shared/middlewares/cors';
app.use(cors);

// Redirect requests to /api and /auth to the production API
// This allows deploy previews to work, as this route would only be called
// if there's no path alias in Now for hyperionurl.com/api, which would only
// happen on deploy previews
app.use('/api', (req: express$Request, res: express$Response) => {
const redirectUrl = `${req.baseUrl}${req.path}`;
res.redirect(
req.method === 'POST' || req.xhr ? 307 : 301,
`https://spectrum.chat${redirectUrl}`
);
});

app.use('/auth', (req: express$Request, res: express$Response) => {
const redirectUrl = `${req.baseUrl}${req.path}`;
res.redirect(
req.method === 'POST' || req.xhr ? 307 : 301,
`https://spectrum.chat${redirectUrl}`
);
});

app.use('/websocket', (req: express$Request, res: express$Response) => {
const redirectUrl = `${req.baseUrl}${req.path}`;
res.redirect(
req.method === 'POST' || req.xhr ? 307 : 301,
`https://spectrum.chat${redirectUrl}`
);
});

// In development the Webpack HMR server requests /sockjs-node constantly,
// so let's patch that through to it!
if (process.env.NODE_ENV === 'development') {
app.use('/sockjs-node', (req: express$Request, res: express$Response) => {
res.redirect(301, `http://localhost:3000${req.path}`);
});
}

import cookieParser from 'cookie-parser';
app.use(cookieParser());

Expand Down Expand Up @@ -105,6 +69,53 @@ app.use(passport.session());
import threadParamRedirect from 'shared/middlewares/thread-param';
app.use(threadParamRedirect);

const BASE_URI =
process.env.NODE_ENV === 'testing' || process.env.TEST_DB
? 'http://localhost:3001'
: 'https://spectrum.chat';

// Redirect requests to /api and /auth to the production API
// This allows deploy previews to work, as this route would only be called
// if there's no path alias in Now for hyperionurl.com/api, which would only
// happen on deploy previews
app.use('/api', (req: express$Request, res: express$Response) => {
const redirectUrl = `${req.baseUrl}${req.path}`;
fetch(`${BASE_URI}${redirectUrl}`, {
method: req.method,
headers: {
cookie: req.headers.cookie,
'content-type': req.headers['content-type'],
},
body: JSON.stringify(req.body),
})
.then(res => res.json())
.then(json => res.send(json));
});

app.use('/auth', (req: express$Request, res: express$Response) => {
const redirectUrl = `${req.baseUrl}${req.path}`;
res.redirect(
req.method === 'POST' || req.xhr ? 307 : 301,
`${BASE_URI}${redirectUrl}`
);
});

app.use('/websocket', (req: express$Request, res: express$Response) => {
const redirectUrl = `${req.baseUrl}${req.path}`;
res.redirect(
req.method === 'POST' || req.xhr ? 307 : 301,
`${BASE_URI}${redirectUrl}`
);
});

// In development the Webpack HMR server requests /sockjs-node constantly,
// so let's patch that through to it!
if (process.env.NODE_ENV === 'development') {
app.use('/sockjs-node', (req: express$Request, res: express$Response) => {
res.redirect(301, `http://localhost:3000${req.path}`);
});
}

// Static files
// This route handles the case where our ServiceWorker requests main.asdf123.js, but
// we've deployed a new version of the app so the filename changed to main.dfyt975.js
Expand All @@ -131,6 +142,11 @@ app.use(
);
app.get('/static/js/:name', (req: express$Request, res, next) => {
if (!req.params.name) return next();
const existingFile = jsFiles.find(file => file.startsWith(req.params.name));
if (existingFile)
return res.sendFile(
path.resolve(__dirname, '..', 'build', 'static', 'js', req.params.name)
);
const match = req.params.name.match(/(\w+?)\.(\w+?\.)?js/i);
if (!match) return next();
const actualFilename = jsFiles.find(file => file.startsWith(match[1]));
Expand Down
9 changes: 9 additions & 0 deletions hyperion/renderer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,19 @@ const renderer = (req: express$Request, res: express$Response) => {
cache,
});
// Define the initial redux state
const { t } = req.query;

const initialReduxState = {
users: {
currentUser: req.user ? req.user : null,
},
dashboardFeed: {
activeThread: t ? t : '',
mountedWithActiveThread: t ? t : '',
search: {
isOpen: false,
},
},
};
// Create the Redux store
const store = initStore(initialReduxState);
Expand Down
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"uuid": "^3.0.1",
"wait-on": "^2.1.0",
"webpack-bundle-analyzer": "^2.9.1",
"write-file-webpack-plugin": "^4.1.0"
"write-file-webpack-plugin": "^4.3.2"
},
"dependencies": {
"abab": "^1.0.4",
Expand Down Expand Up @@ -70,7 +70,7 @@
"cors": "^2.8.3",
"cryptr": "^3.0.0",
"css.escape": "^1.5.1",
"cypress": "^2.1.0",
"cypress": "^3.0.1",
"dataloader": "^1.3.0",
"debounce": "^1.1.0",
"debug": "^2.6.8",
Expand Down Expand Up @@ -138,24 +138,24 @@
"query-string": "^5.0.0",
"raven": "^2.0.2",
"raven-js": "^3.18.1",
"react": "16.2.0",
"react": "^16.4.0",
"react-apollo": "2.x",
"react-app-rewire-styled-components": "^3.0.0",
"react-app-rewired": "^1.0.5",
"react-clipboard.js": "^1.1.3",
"react-dom": "16.2.0",
"react-flip-move": "^2.10.1",
"react-helmet-async": "^0.0.4",
"react-app-rewired": "^1.5.2",
"react-clipboard.js": "^2.0.0",
"react-dom": "^16.4.0",
"react-flip-move": "^3.0.2",
"react-helmet-async": "^0.1.0",
"react-infinite-scroller-with-scroll-element": "2.0.2",
"react-loadable": "5.3.1",
"react-loadable": "^5.4.0",
"react-modal": "3.x",
"react-popper": "^1.0.0-beta.5",
"react-redux": "^5.0.2",
"react-router": "^4.0.0-beta.7",
"react-router-dom": "^4.0.0-beta.7",
"react-router-dom": "^4.3.1",
"react-stripe-checkout": "^2.2.5",
"react-stripe-elements": "^1.4.1",
"react-textarea-autosize": "^4.0.5",
"react-textarea-autosize": "^6.1.0",
"react-transition-group": "^2.2.0",
"react-trend": "^1.2.4",
"recompose": "0.26.x",
Expand Down Expand Up @@ -255,6 +255,7 @@
"test:e2e": "cypress run",
"prestart:api:test": "node -e \"require('./shared/testing/setup.js')().then(() => process.exit())\"",
"start:api:test": "TEST_DB=true FORCE_DEV=true DEBUG=api*,shared* forever build-api/main.js",
"start:test": "DISABLE_CACHE=true TEST_DB=true FORCE_DEV=true DEBUG=hyperion*,shared* forever build-hyperion/main.js",
"cypress:open": "cypress open",
"lint": "eslint .",
"flow": "flow",
Expand Down
4 changes: 2 additions & 2 deletions src/components/buttons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { Spinner } from '../globals';
import Icon from '../icons';

type ButtonProps = {
type ButtonProps = {|
loading?: boolean,
disabled?: boolean,
large?: boolean,
Expand All @@ -21,7 +21,7 @@ type ButtonProps = {
icon?: string,
children?: any,
dataCy?: string,
};
|};

type IconProps = {
glyph: string,
Expand Down
1 change: 0 additions & 1 deletion src/components/infiniteScroll/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export default class InfiniteScroll extends React.Component<Props> {
useWindow: true,
isReverse: false,
scrollElement: null,
scrollComponent: null,
};

scrollListener: Function;
Expand Down
1 change: 0 additions & 1 deletion src/components/upsell/joinChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ class JoinChannel extends React.Component<Props, State> {
loading={isLoading}
onClick={this.toggleSubscription}
icon="plus"
label
dataCy="thread-join-channel-upsell-button"
>
Join
Expand Down
8 changes: 7 additions & 1 deletion src/helpers/analytics/raven.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// @flow
import Raven from 'raven-js';
if (process.env.NODE_ENV === 'production' && process.env.SENTRY_DSN_CLIENT) {

if (
process.env.NODE_ENV === 'production' &&
!process.env.FORCE_DEV &&
process.env.SENTRY_DSN_CLIENT &&
process.env.SENTRY_DSN_CLIENT !== 'undefined'
) {
Raven.config(process.env.SENTRY_DSN_CLIENT, {
whitelistUrls: [/spectrum\.chat/, /www\.spectrum\.chat/],
environment: process.env.NODE_ENV,
Expand Down
Loading