Skip to content

Commit 7fb49b5

Browse files
committed
Merge pull request #133 from 10gen/INT-420_auth_dialog_REMIX
INT-420 auth dialog remix
2 parents 8ee8f69 + b7f5329 commit 7fb49b5

20 files changed

+976
-260
lines changed

docs/tutorials/npm-link.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# How to `npm link`
2+
3+
Say `~/scout-ci` is your work projects folder.
4+
First, grab the money module as the first step in
5+
any debugging adventure is adding a `console.log`
6+
somewhere just to know you're env is setup.
7+
8+
```bash
9+
mkdir -p ~/scout-ci;
10+
cd ~/scout-ci;
11+
git clone [email protected]:mongodb-js/mongodb-connection-model.git;
12+
cd mongodb-connection-model;
13+
npm link;
14+
cd ../;
15+
git clone [email protected]:10gen/scout-server.git;
16+
cd scout-server;
17+
git checkout -t origin/auth;
18+
npm link;
19+
npm link mongodb-connection-model;
20+
cd ../;
21+
git clone [email protected]:10gen/scout-client.git;
22+
cd scout-client;
23+
git checkout -t origin/auth;
24+
npm link;
25+
npm link scout-server;
26+
npm link mongodb-connection-model;
27+
npm install [email protected];
28+
./node_modules/.bin/zuul --electron -- test/*.test.js;
29+
```
30+
31+
Yay. Not so bad. Yes, that did take a bit of time BUT
32+
next week we be removing aNd updating a tonnnnn of dependencies.
33+
Deep breaths :)
34+
35+
Soooooo now let's run some tests! Please open a new doc
36+
in google drive because I need to give you a list of
37+
all the places where your print out will need to be correcte...
38+
39+
Nah! Just run:
40+
41+
```bash
42+
npm start;
43+
```
44+
45+
So yeah you know... one command?! big whoop! What could that possibly do?
46+
47+
- Starts a mongodb deployment using the same tooling the nodejs
48+
driver does (ht @Judah)
49+
- Starts up `scout-server` if one not already running
50+
- [zuul](http://npm.im/zuul) watches your changes to this dir and
51+
your tests, deps, src and rebuilds your src maps, code coverage,
52+
starts up Chrome and loads your test harness... But, yeah, that
53+
was a ton of deps... :)
54+
55+
> @todo (imlucas): How to use Chrome Devtools to Debug Failing or Flakey
56+
> Tests like Dan Pasette [sneak peak](https://cldup.com/745nt7Jca_-1200x1200.png)
57+
58+
What's that you say? You think their might be something in server
59+
you want to be able to change and have it reloaded automatically?
60+
And when you're connecting to a cluster?
61+
And... on the latest unstable release of the kernel?
62+
63+
Press `ctrl+c`.
64+
65+
```bash
66+
cd ../scout-server;
67+
DEBUG=* MONGODB_VERSION=unstable MONGODB_TOPOLOGY=cluster npm start;
68+
```
69+
70+
Open another terminal window and start up the client tests... oh?
71+
But in electron? Using the same artifacts we use to build the app
72+
on our end? Well.... gee I dunno... Might take a littl.... BOOM!
73+
74+
```bash
75+
cd ~/scout-ci;
76+
cd ~/scout-client;
77+
npm install [email protected];
78+
./node_modules/.bin/zuul --electron -- test/*.test.js;
79+
```
80+
81+
> @todo (imlucas): How to use localtunnel to test real-world
82+
> latency between NYC and Sydney w/o filing a JIRA.

gulpfile.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ var shell = require('gulp-shell');
2424
var del = require('del');
2525
var sequence = require('run-sequence');
2626
var watch = require('gulp-watch');
27-
// var livereload = require('gulp-livereload');
2827
var notify = require('./tasks/notify');
2928
var pkg = require('./package.json');
3029

3130
// Platform specific tasks
3231
var platform = require(path.join(__dirname, 'tasks', process.platform));
3332

33+
// Where we'll put everything so it runs in Electron.
34+
// var DEST = path.join(platform.RESOURCES, 'app');
35+
3436
/**
3537
* # release
3638
*

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,12 @@
6565
"url": "git://github.com/10gen/scout.git"
6666
},
6767
"dependencies": {
68+
"ampersand-form-view": "^5.1.1",
69+
"ampersand-input-view": "^5.0.0",
6870
"debug": "^2.2.0",
69-
"scout-server": "http://bin.mongodb.org/js/scout-server/v0.1.0/scout-server-0.1.0.tar.gz",
70-
"electron-squirrel-startup": "^0.1.2"
71+
"electron-squirrel-startup": "^0.1.2",
72+
"mongodb-connection-model": "0.0.2",
73+
"scout-server": "http://bin.mongodb.org/js/scout-server/v0.2.1/scout-server-0.2.1.tar.gz"
7174
},
7275
"devDependencies": {
7376
"ampersand-app": "^1.0.4",
@@ -128,8 +131,9 @@
128131
"run-sequence": "^1.1.2",
129132
"run-series": "^1.1.2",
130133
"scout-brain": "http://bin.mongodb.org/js/scout-brain/v0.0.2/scout-brain-0.0.2.tar.gz",
131-
"scout-client": "http://bin.mongodb.org/js/scout-client/v0.0.5/scout-client-0.0.5.tar.gz",
134+
"scout-client": "http://bin.mongodb.org/js/scout-client/v0.1.2/scout-client-0.1.2.tar.gz",
132135
"stream-combiner2": "^1.0.2",
136+
"uuid": "^2.0.1",
133137
"vinyl-buffer": "^1.0.0",
134138
"vinyl-source-stream": "^1.1.0",
135139
"watchify": "^3.2.3"

scripts/ci.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env bash
2+
3+
# What version of the kernel to download
4+
# and use when running tests.
5+
# @see http://npm.im/mongodb-version-manager
6+
export MONGODB_VERSION='unstable';
7+
8+
# Topology of the kernel to test against.
9+
#
10+
# standalone|replicaset|cluster
11+
#
12+
# @see http://npm.im/mongodb-runner
13+
export MONGODB_TOPOLOGY='replicaset';
14+
15+
rm -rf ~/scout-ci;
16+
mkdir -p ~/scout-ci;
17+
cd ~/scout-ci;
18+
19+
# First test the connection-model which is the basis.
20+
# it provides a gaurantee to everything else that
21+
# it will talk to the driver correctly.
22+
# If we're talking to the driver correctly,
23+
# the driver has already been heavily tested
24+
# for all auth scenarios.
25+
git clone [email protected]:mongodb-js/mongodb-connection-model.git;
26+
cd mongodb-connection-model;
27+
npm link && npm test;
28+
cd ../;
29+
30+
# Is scout-server using connection-model correctly?
31+
git clone [email protected]:10gen/scout-server.git;
32+
cd scout-server;
33+
git checkout -t origin/auth;
34+
npm install;
35+
npm link mongodb-connection-model;
36+
npm test;
37+
npm link;
38+
cd ../;
39+
40+
# Is the client using the connection-model
41+
# correctly when talking to the server?
42+
git clone [email protected]:10gen/scout-client.git;
43+
cd scout-client;
44+
git checkout -t origin/auth;
45+
npm link;
46+
npm link scout-server;
47+
npm link mongodb-connection-model;
48+
npm test;
49+
50+
# @todo (imlucas): Is the connection dialog in Compass
51+
# and the app in general using scout-client correctly?
52+
# 1. Pulls the branch for compass
53+
# 2. build it
54+
# 3. npm link's the deps above
55+
# 4. fires up `chromedriver`
56+
# 5. fill in connect dialog with creds for each test deployment on Cloud Manager
57+
# 6. do we get a list of namespaces after connecting

scripts/repl.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
cd ./dist/MongoDB\ Compass-darwin-x64/MongoDB\ Compass.app/Contents/Resources/app;
3+
npm install --log-level error;
4+
5+
DEBUG='*' \
6+
ATOM_SHELL_INTERNAL_RUN_AS_NODE=1 \
7+
../../MacOS/Electron \
8+
-e "require('repl').start({terminal: true, prompt: 'compass> '});";

scripts/server.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
DEBUG=* \
2+
ATOM_SHELL_INTERNAL_RUN_AS_NODE=1 \
3+
./dist/MongoDB\ Compass-darwin-x64/MongoDB\ Compass.app/Contents/MacOS/Electron ./dist/MongoDB\ Compass-darwin-x64/MongoDB\ Compass.app/Contents/Resources/app/node_modules/scout-server/bin/scout-server-worker.js

src/app.js

Lines changed: 58 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
var pkg = require('../package.json');
22
var app = require('ampersand-app');
33
app.extend({
4+
// @todo (imlucas) Move to config
5+
// `scout-server` to point at.
6+
endpoint: 'http://localhost:29017',
47
meta: {
58
'App Version': pkg.version
69
}
@@ -145,9 +148,9 @@ var Application = View.extend({
145148
});
146149

147150
var params = qs.parse(window.location.search.replace('?', ''));
148-
var uri = params.uri || 'mongodb://localhost:27017';
151+
var connection_id = params.connection_id;
149152
var state = new Application({
150-
uri: uri
153+
connection_id: connection_id
151154
});
152155

153156
var QueryOptions = require('./models/query-options');
@@ -156,23 +159,41 @@ var MongoDBInstance = require('./models/mongodb-instance');
156159
var Router = require('./router');
157160
var Statusbar = require('./statusbar');
158161

162+
function start() {
163+
state.router = new Router();
164+
domReady(state._onDOMReady.bind(state));
165+
}
166+
159167
app.extend({
160168
client: null,
161169
init: function() {
162-
state.statusbar = new Statusbar();
163-
this.connection = new Connection();
164-
this.connection.use(uri);
165-
this.queryOptions = new QueryOptions();
166-
this.volatileQueryOptions = new QueryOptions();
167-
this.instance = new MongoDBInstance();
168-
169170
// feature flags
170171
this.features = {
171172
querybuilder: true
172173
};
174+
state.statusbar = new Statusbar();
173175

174-
state.router = new Router();
175-
176+
if (connection_id) {
177+
state.connection = new Connection({
178+
_id: connection_id
179+
});
180+
181+
182+
debug('looking up connection `%s`...', connection_id);
183+
state.connection.fetch({
184+
success: function() {
185+
debug('got connection `%j`...', state.connection.serialize());
186+
app.client = getOrCreateClient(app.endpoint, state.connection.serialize());
187+
188+
state.queryOptions = new QueryOptions();
189+
state.volatileQueryOptions = new QueryOptions();
190+
state.instance = new MongoDBInstance();
191+
start();
192+
}
193+
});
194+
} else {
195+
start();
196+
}
176197
// set up ipc
177198
ipc.on('message', state.onMessageReceived.bind(this));
178199
},
@@ -185,20 +206,37 @@ Object.defineProperty(app, 'statusbar', {
185206
}
186207
});
187208

188-
Object.defineProperty(app, 'client', {
209+
Object.defineProperty(app, 'instance', {
189210
get: function() {
190-
return getOrCreateClient({
191-
seed: app.connection.uri
192-
});
211+
return state.instance;
193212
}
194213
});
195-
app.init();
196214

197-
function render_app() {
198-
state._onDOMReady();
199-
}
215+
Object.defineProperty(app, 'queryOptions', {
216+
get: function() {
217+
return state.queryOptions;
218+
}
219+
});
200220

201-
domReady(render_app);
221+
Object.defineProperty(app, 'volatileQueryOptions', {
222+
get: function() {
223+
return state.volatileQueryOptions;
224+
}
225+
});
226+
227+
Object.defineProperty(app, 'connection', {
228+
get: function() {
229+
return state.connection;
230+
}
231+
});
232+
233+
Object.defineProperty(app, 'router', {
234+
get: function() {
235+
return state.router;
236+
}
237+
});
238+
239+
app.init();
202240

203241
// expose app globally for debugging purposes
204242
window.app = app;

0 commit comments

Comments
 (0)