Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit 1f14d80

Browse files
authored
Merge pull request #2882 from withspectrum/2.2.6
2.2.6
2 parents 17b294f + bffba60 commit 1f14d80

File tree

207 files changed

+4947
-2756
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

207 files changed

+4947
-2756
lines changed

.circleci/config.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,12 @@ aliases:
3939
name: Setup and build
4040
command:
4141
|
42-
node -e "const setup = require('./shared/testing/setup.js')().then(() => process.exit())"
4342
yarn run build:web
4443
yarn run build:api
4544

4645
- &start-api
4746
name: Start the API in the background
48-
command: TEST_DB=true yarn run dev:api
47+
command: yarn run start:api:test
4948
background: true
5049

5150
- &start-web
@@ -90,28 +89,28 @@ jobs:
9089
- image: circleci/node:8-browsers
9190
- image: redis:3.2.7
9291
- image: cypress/base:6
92+
- image: rethinkdb:2.3.5
9393
environment:
9494
TERM: xterm
9595
steps:
9696
- attach_workspace:
9797
at: ~/spectrum
98-
- run: *install-rethinkdb
99-
- run: *start-rethinkdb
100-
- run: sleep 10
98+
- run: node -e "const setup = require('./shared/testing/setup.js')().then(() => process.exit())"
10199
- run: *setup-and-build-web
102100
- run: *start-api
103101
- run: *start-web
104-
- run: sleep 60
102+
# Wait for the API and webserver to start
103+
- run: ./node_modules/.bin/wait-on http://localhost:3000 http://localhost:3001
105104
- run:
106105
name: Run Unit Tests
107106
command: yarn run test:ci
108-
- run:
109-
name: Run E2E Tests
110-
command: yarn run test:e2e
111107
- run:
112108
name: Danger
113109
when: always
114-
command: yarn run danger ci
110+
command: test -z $DANGER_GITHUB_API_TOKEN && yarn run danger ci || echo "forks are not allowed to run danger"
111+
- run:
112+
name: Run E2E Tests
113+
command: yarn run test:e2e
115114

116115
# Run eslint, flow etc.
117116
test_static_js:
@@ -170,6 +169,7 @@ workflows:
170169
- test_mobile_js:
171170
requires:
172171
- checkout_environment
172+
173173
# Disabled as Expo is fixing their critical issue with Detox
174174
# - test_mobile_native:
175175
# requires:

.flowconfig

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
[ignore]
2-
.*/node_modules/.*
32
.*/build.*
43
.*/*.test.js
54
.*/.expo
5+
.*/node_modules/expo
6+
.*/node_modules/react-native
7+
.*/node_modules/cypress
8+
.*/node_modules/draft-js
9+
.*/node_modules/graphql
10+
.*/node_modules/protobufjs-no-cli
11+
.*/node_modules/react-navigation
12+
.*/node_modules/reqwest
13+
.*/node_modules/sentry-expo
14+
15+
.*/node_modules/react-apollo
16+
.*/node_modules/dataloader
17+
618

719
[include]
820

@@ -13,7 +25,7 @@ suppress_comment=.*\\$FlowFixMe
1325
suppress_comment=.*\\$FlowIssue
1426
esproposal.class_instance_fields=enable
1527
module.system.node.resolve_dirname=node_modules
16-
module.system.node.resolve_dirname=spectrum
28+
module.system.node.resolve_dirname=.
1729
module.file_ext=.ios.js
1830
module.file_ext=.android.js
1931
module.file_ext=.native.js

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,8 @@ YES
2020
**Release notes for users (delete if codebase-only change)**
2121
-
2222

23+
<!--
24+
25+
If your pull request introduces changes to the user interface on Spectrum, please share before and after screenshots of the changes (gifs or videos are encouraged for interaction changes). Please include screenshots of desktop and mobile viewports to ensure that all responsive cases are reviewed.
26+
27+
-->

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ build
55
.DS_Store
66
src/config/FirebaseConfig.js
77
npm-debug.log
8+
yarn-error.log
89
rethinkdb_data
910
debug
1011
now-secrets.json

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ Spectrum has been under full-time development since March, 2017. See [the roadma
4040
- [Running the app locally](#running-the-app-locally)
4141
- [Roadmap](https://github.com/withspectrum/spectrum/projects/19)
4242
- [Technical](docs/)
43-
- [Testing](docs/testing.md)
43+
- [Testing](docs/testing/intro.md)
4444
- [Background Jobs](docs/backend/background-jobs.md)
45-
- [Deployment](docs/backend/deployment.md)
45+
- [Deployment](docs/deployments.md)
4646
- [API](docs/backend/api/)
4747
- [Fragments](docs/backend/api/fragments.md)
4848
- [Pagination](docs/backend/api/pagination.md)
@@ -151,6 +151,11 @@ The first step to running Spectrum locally is downloading the code by cloning th
151151

152152
```sh
153153
git clone [email protected]:withspectrum/spectrum.git
154+
```
155+
If you get `Permission denied` error using `ssh` refer [here](https://help.github.com/articles/error-permission-denied-publickey/)
156+
or use `https` link as a fallback.
157+
```sh
158+
git clone https://github.com/withspectrum/spectrum.git
154159
```
155160

156161
#### Installation

api/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
/**
33
* The entry point for the server, this is where everything starts
44
*/
5-
console.log('Server starting...');
65
const compression = require('compression');
76
const debug = require('debug')('api');
7+
debug('Server starting...');
88
debug('logging with debug enabled!');
99
import { createServer } from 'http';
1010
import express from 'express';
@@ -62,6 +62,14 @@ app.use(
6262
}
6363
);
6464

65+
app.use('/', (req: express$Request, res: express$Response) => {
66+
res.redirect(
67+
process.env.NODE_ENV === 'production' && !process.env.FORCE_DEV
68+
? 'https://spectrum.chat'
69+
: 'http://localhost:3000'
70+
);
71+
});
72+
6573
import type { Loader } from './loaders/types';
6674
export type GraphQLContext = {
6775
user: DBUser,
@@ -96,7 +104,7 @@ const subscriptionsServer = createSubscriptionsServer(server, '/websocket');
96104
// graphqlPaths: ['/api'],
97105
// });
98106
server.listen(PORT);
99-
console.log(`GraphQL server running at http://localhost:${PORT}/api`);
107+
debug(`GraphQL server running at http://localhost:${PORT}/api`);
100108

101109
process.on('unhandledRejection', async err => {
102110
console.error('Unhandled rejection', err);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
exports.up = async (r, conn) => {
2+
return Promise.all([
3+
r
4+
.table('users')
5+
.update({
6+
username: r.row('username').downcase(),
7+
email: r.row('email').downcase(),
8+
})
9+
.run(conn),
10+
r
11+
.table('communities')
12+
.update({
13+
slug: r.row('slug').downcase(),
14+
})
15+
.run(conn),
16+
r
17+
.table('channels')
18+
.update({
19+
slug: r.row('slug').downcase(),
20+
})
21+
.run(conn),
22+
]);
23+
};
24+
25+
exports.down = function(r, conn) {
26+
return Promise.resolve();
27+
};

api/migrations/seed/default/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const defaultDirectMessageThreads = require('./directMessageThreads');
99
const defaultUsersDirectMessageThreads = require('./usersDirectMessageThreads');
1010
const defaultUsersCommunities = require('./usersCommunities');
1111
const defaultUsersChannels = require('./usersChannels');
12+
const defaultUsersSettings = require('./usersSettings')();
1213
const defaultMessages = require('./messages');
1314

1415
module.exports = {
@@ -23,8 +24,8 @@ module.exports = {
2324
defaultUsersCommunities,
2425
defaultUsersChannels,
2526
defaultMessages,
27+
defaultUsersSettings,
2628
defaultNotifications: [],
2729
defaultCommunitySettings: [],
2830
defaultChannelSettings: [],
29-
defaultUsersSettings: [],
3031
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// @flow
2+
3+
module.exports = () => {
4+
let settings = [];
5+
for (let step = 0; step < 10; step++) {
6+
settings.push({
7+
userId: step.toString(),
8+
notifications: {
9+
types: {
10+
newMessageInThreads: {
11+
email: true,
12+
},
13+
newMention: {
14+
email: true,
15+
},
16+
newDirectMessage: {
17+
email: true,
18+
},
19+
newThreadCreated: {
20+
email: true,
21+
},
22+
dailyDigest: {
23+
email: true,
24+
},
25+
weeklyDigest: {
26+
email: true,
27+
},
28+
},
29+
},
30+
});
31+
}
32+
return settings;
33+
};

api/models/db.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ const config = IS_PROD
2929

3030
var r = require('rethinkdbdash')(config);
3131

32+
// Exit the process on unhealthy db in test env
33+
if (process.env.TEST_DB) {
34+
r.getPoolMaster().on('healthy', healthy => {
35+
if (!healthy) {
36+
process.exit(1);
37+
}
38+
});
39+
}
40+
3241
if (process.env.NODE_ENV === 'development') {
3342
const fs = require('fs');
3443
const inspect = require('rethinkdb-inspector');

0 commit comments

Comments
 (0)