Setting up a remoteStorage.js development environment

@raucao I’m creating a build & test setup…

I have mysteryshack running (with the default config).

I have forked and built remoteStorage.js, and npm test runs with lots of passes and some errors. Do I need to create a test user on the server or otherwise tell it about mysteryshack for these tests to pass?

Here is the start of my output:

$ npm test

> remotestoragejs@0.12.1 test /home/mrh/src/remotestorage.js
> make test

node_modules/jaribu/bin/jaribu
jaribu is in: /home/mrh/src/remotestorage.js/node_modules/jaribu/bin/../
app is in: /home/mrh/src/remotestorage.js/node_modules/jaribu/bin/../../../
[ '/home/mrh/src/remotestorage.js/test/unit/access-suite.js',
  '/home/mrh/src/remotestorage.js/test/unit/authorize-suite.js',
  '/home/mrh/src/remotestorage.js/test/unit/baseclient-suite.js',
  '/home/mrh/src/remotestorage.js/test/unit/baseclient/types-suite.js',
  '/home/mrh/src/remotestorage.js/test/unit/caching-suite.js',
  '/home/mrh/src/remotestorage.js/test/unit/cachinglayer-suite.js',
  '/home/mrh/src/remotestorage.js/test/unit/discover-suite.js',
  '/home/mrh/src/remotestorage.js/test/unit/dropbox-suite.js',
  '/home/mrh/src/remotestorage.js/test/unit/googledrive-suite.js',
  '/home/mrh/src/remotestorage.js/test/unit/i18n-suite.js',
  '/home/mrh/src/remotestorage.js/test/unit/indexeddb-suite.js',
  '/home/mrh/src/remotestorage.js/test/unit/inmemorycaching-suite.js',
  '/home/mrh/src/remotestorage.js/test/unit/localstorage-suite.js',
  '/home/mrh/src/remotestorage.js/test/unit/modules-suite.js',
  '/home/mrh/src/remotestorage.js/test/unit/node-wireclient-suite.js',
  '/home/mrh/src/remotestorage.js/test/unit/remotestorage-suite.js',
  '/home/mrh/src/remotestorage.js/test/unit/sync-suite.js',
  '/home/mrh/src/remotestorage.js/test/unit/util-suite.js',
  '/home/mrh/src/remotestorage.js/test/unit/versioning-suite.js',
  '/home/mrh/src/remotestorage.js/test/unit/wireclient-suite.js' ]

running... 26 suites, 328 tests.


= access - access knows all about the scope we claimed and which paths that gives us access to
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 

= Authorize - OAuth dance
+ + + + + + + + + + + + 

= BaseClient - High-level client, scoped to a path
DEPRECATION WARNING: remoteStorage.util was moved to RemoteStorage.util
+ + + + + + 

= BaseClient folder handling
+ + !+ Unhandled rejection Error: Not a folder: bar
    at Object.ensureErrorObject (/home/mrh/src/remotestorage.js/node_modules/jaribu/node_modules/bluebird/js/main/util.js:261:20)
    at Promise._rejectCallback (/home/mrh/src/remotestorage.js/node_modules/jaribu/node_modules/bluebird/js/main/promise.js:469:22)
    at Function.Promise.reject.Promise.rejected (/home/mrh/src/remotestorage.js/node_modules/jaribu/node_modules/bluebird/js/main/promise.js:196:9)
    at Object.RS.BaseClient.getListing (/home/mrh/src/remotestorage.js/src/baseclient.js:222:17)
    at bound Scaffolding.suites.push.tests.run (/home/mrh/src/remotestorage.js/test/unit/baseclient-suite.js:189:29)
    at null._onTimeout (/home/mrh/src/remotestorage.js/node_modules/jaribu/lib/jaribu.js:479:25)
    at Timer.listOnTimeout (timers.js:89:15)
+ + + + + + + + + + + + + WARNING: caching strategy <false> is deprecated. Use <"FLUSH"> instead.
+ + + + + + + + + 

FYI: I moved your post to a new topic.

You don’t need a server running for the tests to pass in general. For actual development of both rs.js and apps based on it, it’s needed as soon as you want to connect a storage, of course (although even then you can use a hosted service as well, but it’s rather nice to have access to storage objects on the local filesystem while debugging).

Do you actually see tests failing in the stats at the end, or do you only see error messages in the run, but then all tests passed? I’m asking, because we do trigger some exceptions intentionally on the way, which can look like tests are failing, while they’re passing.

1 Like

Ahh, my apologies. Yes, I don’t see any fails in the individual tests - every test summary says: all tests passed. :blush:

Thanks for the quick response :smile:

Glad I could help. You’re certainly not the first person to run into this question!

Do you have an idea where we could add a notice/hint for new developers to make it clear?

I’d suggest a mod to readme.md:

Run all tests.
Note: deliberate exceptions may look like errors, but if it says “all tests passed” under the test output all is well for that test.

$ npm test

Could be my first PR :smile:

Definitely. Go for it!

I’m a git noob so be aware :stuck_out_tongue: this may contain idiocy…

I have a fork, and on it have created a branch “feature/clarify-readme.md” and am ready to PR the above change to github.com/remotestorage. Your CONTRIBUTING.md says I should not push to master but create a branch - but I can’t do this (or push my branch) on github.com/remotestorage/remotestorage.js because I don’t have access rights.

For this shall I just send the PR to master? I don’t need access at this point so we can set that up when and if I have anything more deserving to PR.

Sorry for the confusion; I guess we could clarify that section for PRs from new contributors.

The part about not pushing to master only concerns people with write access not pushing code directly to master. However, everyone can and should always send pull requests to the master branch, no matter if it’s from a branch in our shared repository, a branch in one’s own fork, or even master in one’s own fork.

So, long story short: yes, please send a PR to our common repo’s master branch.

1 Like

Now I have RS building, what would you recommend for a development environment for exercising my code and debugging? I’m unfamiliar with a lot of this stuff so something easy to set up and understand would be good. Or if there’s a simple guide to this let me know. I’m on Linux.

I have a local version of litewrite working and have installed and built mysteryshack. What I’d like next is to know how to exercise a particular backend but I’m not sure how to do this - the widget in litewrite suggests "user@provider.com" so how would I connect this up to a particular backend - say Dropbox? And if I duplicated the Dropbox code but renamed the Dropbox to Safenetwork, how would I use that to test that the Safenetwork backend is live (ie can connect to Dropbox)?

Thanks.

Aside:
I’ve had a brief look at the RS code and spec and think a basic backend can be supported, but there appear to be things lacking in the SAFE API in some areas so not sure how I’ll deal with those yet. But my first stage is just to be able to run a test app or something, and then prove I can add a new backend - just using one of the existing one’s. Then I can try talking to the SAFE API.

Good to hear!

In order to use Dropbox with your app, you need to configure a Dropbox app key, as documented here:

https://remotestorage.github.io/remotestorage.js/files/dropbox-js.html

We should add those instructions to the Beginner’s Guide I guess (feel free to do so). Google Drive also requires an app key, but it’s called client ID:

https://remotestorage.github.io/remotestorage.js/files/googledrive-js.html

In order to add a new button to the widget, you’d have to edit the widget view code, but I think it’s much easier to just emulate a button press by calling connect with your new backend name from the console. When you search the rs.js codebase for dropbox, you should find the code that calls connect with the dropbox backend configuration (so will call connect in the Dropbox class).

Thanks @raucao

Is there an existing app I can use that has this capability built in so I can just test it with a Dropbox account?

I’m assuming from what you said the litewrite doesn’t have this and would need it adding, or am I missing something?

All apps with a halfway modern remoteStorage.js version have this capability built in. It’s only a matter of configuring the Dropbox and/or Google Drive app ID/key before calling displayWidget. You need to register those yourself for apps that don’t offer it right now (and you also shouldn’t use other developer’s production app keys for your development).

The easiest app to run, with the least code, is probably My Favorite Drinks. It doesn’t use any frameworks or fancy build setups, so it’s super easy to run by just starting an HTTP server (e.g. using python2 -m SimpleHTTPServer in its root dir).

You could add the keys for your registered apps somewhere around this line:

https://github.com/remotestorage/myfavoritedrinks/blob/master/app.js#L19

1 Like

Is there a sample App which I can look at that has Dropbox or GoogleDrive already - for example, I found hits for both in starter-kit so might that be an alternative to myfavouritedrinks?

starter-kit Google hits and Dropbox hits

As it’s an experimental feature, there are currently no published apps using it that I know of. It’s really simple to set up, though. It’s only two steps (as I suggested probably easiest with sth like My Favorite Drinks):

  1. Register app at Dropbox or Google Drive
  2. Add one line of config to the app (e.g. in the line suggested above)

Then when you load the app, you should see the additional icon in the widget.

1 Like

I have created a new app (a copy of backend_experimental_ with my Dropbox API key) at http://test-dropbox-backend.safepress.org/. This loads ok in a browser but when I click on the Dropbox icon (top right) nothing happens and I’m getting a console error. Any idea what’s going on here? Thanks.

TypeError: this.rs[options.special] is undefined (remoteStorage.js:6122)

This happens here (see the <-):

setView: function (view) {
  this.view = view;
  this.view.on('connect', function (options) {
    if (typeof(options) === 'string') {
      // options is simply a useraddress
      this.rs.connect(options);
    } else if (options.special) {
      this.rs[options.special].connect(options); // <- ERROR occurs here
    }
}.bind(this));

That app seems to be outdated. I think @michielbdejong is not maintaining his starter kit anymore.

The remoteStorage.js there is not the latest version, and the config key for the app key has changed as well. Compare it with: https://remotestorage.github.io/remotestorage.js/files/dropbox-js.html

I would try to either update both rs.js and the config key, or just use My Favorite Drinks, which is an up-to-date example app, maintained by the rs.js team.

1 Like

Now working with myfavouritedrinks as suggested and looking at how to put SAFE API into rs backend…

I know so little about node etc that this is like wading through treacle! :slight_smile: I’m looking at using a node module that someone created a nice low level SAFE API wrapper - safenet.js. It is a fairly thin but useful - and working :slight_smile: - wrapper, but pulls in some things that may not be wanted in rs. Also, some essentials needed for SAFE API but probably not anything else.

So before I decide on my route I wonder if you have any policy or thoughts on this.

For example, should I code myself using only things that are already pulled in by rs (such as bluebird promises), and things needed by SAFE API (such as tweetnacl and base64-js), or is it ok to pull in new things (such as es6-promise and isomorphic-fetch) so I can use the safenet.js wrapper pretty much as is?

I think these decisions have a lot of impact either for rs or for the work needed to support SAFE storage, so I’m reluctant to just jump in.

I responded in a new topic. Unfortunately that’s not very obvious in this thread’s history, so I’m linking it in this reply, too: Adding new dependencies