- Copyright © 2011-2016
+ Copyright © 2011-2017
Center for Open Science |
Terms of Use |
Privacy Policy
From ea06b739a3245333a5aa4628607bcb6f7a37b7e4 Mon Sep 17 00:00:00 2001
From: Henrique Moco
Date: Mon, 23 Jan 2017 14:16:20 -0500
Subject: [PATCH 121/147] remove --prefer-offline
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 09e9427d4..68241ec4b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -16,7 +16,7 @@ cache:
install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH
-- yarn --prefer-offline --pure-lockfile
+- yarn --pure-lockfile
- ./node_modules/bower/bin/bower install --config.interactive=false
script:
From 6bf7f50360953a8cb7360d39ad7b65acc58d6024 Mon Sep 17 00:00:00 2001
From: Sherif
Date: Mon, 23 Jan 2017 16:00:26 -0500
Subject: [PATCH 122/147] Change 2016 to the current year in the osf-copyright
Use ember property to get the current year instead of making the code change
manually. Ticket ID: EOSF-466
---
addon/components/osf-copyright/component.js | 5 ++++-
addon/components/osf-copyright/template.hbs | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/addon/components/osf-copyright/component.js b/addon/components/osf-copyright/component.js
index 068945264..1383665e8 100644
--- a/addon/components/osf-copyright/component.js
+++ b/addon/components/osf-copyright/component.js
@@ -11,5 +11,8 @@ import layout from './template';
* @class osf-copyright
*/
export default Ember.Component.extend({
- layout
+ layout,
+ currentYear: function() {
+ return new Date().getFullYear();
+ }.property()
});
diff --git a/addon/components/osf-copyright/template.hbs b/addon/components/osf-copyright/template.hbs
index 9bda57739..2f22165a2 100644
--- a/addon/components/osf-copyright/template.hbs
+++ b/addon/components/osf-copyright/template.hbs
@@ -2,7 +2,7 @@
- Copyright © 2011-2017
+ Copyright © 2011-{{currentYear}}
Center for Open Science |
Terms of Use |
Privacy Policy
From 005a2767be79eadd97e098267eb044729a7cb1d0 Mon Sep 17 00:00:00 2001
From: Andy Boughton
Date: Tue, 24 Jan 2017 15:44:19 -0500
Subject: [PATCH 123/147] Packaging changes: 1. Don't generate git flow or
commits automatically. Version command simply modifies files for review. 2.
Separate make-release command is now responsible for git-flow, only. This is
a convenience wrapper to fetch the version number automatically from
package.json.
[ci skip]
[#EOSF-446]
---
package.json | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/package.json b/package.json
index 8d10961ae..5e0dd204a 100644
--- a/package.json
+++ b/package.json
@@ -12,9 +12,10 @@
"start": "ember server",
"check-style": "./node_modules/jscs/bin/jscs .",
"test": "yarn run check-style && ember test",
- "make-release": "npm --no-git-tag-version version ",
+ "bump-version": "npm --no-git-tag-version version ",
"preversion": "git-branch-is develop && yarn test",
- "postversion": "yarn run docs && git add package.json ./docs && git commit -m 'Update documentation for release' && git flow release start $npm_package_version && git flow release finish $npm_package_version"
+ "postversion": "yarn run docs",
+ "make-release": "git-branch-is develop && git flow release start $npm_package_version && git flow release finish $npm_package_version"
},
"repository": {
"type": "git",
From fdf6a8430766bf4ecbcdd372bf783af3dd8a634a Mon Sep 17 00:00:00 2001
From: Andy Boughton
Date: Wed, 25 Jan 2017 17:29:42 -0500
Subject: [PATCH 124/147] Specify a default `authorizationType`, and document
use of this secret parameter
[#EOSF-105]
---
README.md | 16 ++++++++++++++++
index.js | 7 ++++++-
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 8b6e6552f..a0264362b 100644
--- a/README.md
+++ b/README.md
@@ -78,6 +78,22 @@ If for some reason you don't have a config/local.yml you can generate one. To do
ember generate ember-osf
```
+#### Advanced usage: Selecting an authorization type
+We expect that most projects based on `ember-osf` will authenticate via OAuth 2.0 ("Token Login"); the addon is
+configured to use this out of the box, so long as you provide your own login page based on the appropriate mixins.
+
+If you are developing an application that will be hosted under the `osf.io` domain, you may wish to use cookie-based
+authentication instead. In that rare case, add the following lines to your `config/environment.js` file:
+
+```javascript
+ ENV.authorizationType = 'cookie';
+
+ ENV['ember-simple-auth'] = {
+ authorizer: `authorizer:osf-${defaultAuthorizationType}`,
+ authenticator: `authenticator:osf-${defaultAuthorizationType}`
+ };
+```
+
## Usage
#### Ember Data: Using the OSF models
diff --git a/index.js b/index.js
index 4695b22dd..674b1a3e3 100644
--- a/index.js
+++ b/index.js
@@ -96,8 +96,13 @@ module.exports = {
ENV.OSF.helpUrl = 'http://help.osf.io';
}
+
+ const defaultAuthorizationType = 'token';
+ ENV.authorizationType = defaultAuthorizationType;
+
ENV['ember-simple-auth'] = {
- authorizer: 'authorizer:osf-token'
+ authorizer: `authorizer:osf-${defaultAuthorizationType}`,
+ authenticator: `authenticator:osf-${defaultAuthorizationType}`
};
},
afterInstall: function(options) {
From 1770a1c0e632fbc56f489ede8b205fdd07d6ad40 Mon Sep 17 00:00:00 2001
From: Andy Boughton
Date: Thu, 26 Jan 2017 09:48:30 -0500
Subject: [PATCH 125/147] Fix doc typo
[ci skip]
[#EOSF-105]
---
README.md | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index a0264362b..fc460a1f2 100644
--- a/README.md
+++ b/README.md
@@ -86,11 +86,12 @@ If you are developing an application that will be hosted under the `osf.io` doma
authentication instead. In that rare case, add the following lines to your `config/environment.js` file:
```javascript
- ENV.authorizationType = 'cookie';
+ var authorizationType = 'cookie';
+ ENV.authorizationType = authorizationType;
ENV['ember-simple-auth'] = {
- authorizer: `authorizer:osf-${defaultAuthorizationType}`,
- authenticator: `authenticator:osf-${defaultAuthorizationType}`
+ authorizer: `authorizer:osf-${authorizationType}`,
+ authenticator: `authenticator:osf-${authorizationType}`
};
```
From 8118a055f888f5347015ea899c6ad905f2882415 Mon Sep 17 00:00:00 2001
From: Andy Boughton
Date: Fri, 27 Jan 2017 11:43:30 -0500
Subject: [PATCH 126/147] Reorg settings into separate dictionaries
[#EOSF-449]
---
.gitignore | 1 +
index.js | 133 +++++++++++++++++++++++++++++------------------------
2 files changed, 75 insertions(+), 59 deletions(-)
diff --git a/.gitignore b/.gitignore
index f3e1637c8..4bbdbaaa4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,4 +16,5 @@
npm-debug.log
testem.log
+# Never commit configuration or private settings
config/*.yml
diff --git a/index.js b/index.js
index 4695b22dd..499fe2d31 100644
--- a/index.js
+++ b/index.js
@@ -33,68 +33,83 @@ module.exports = {
redirectUri: SETTINGS.REDIRECT_URI
};
- if (BACKEND === 'local') {
- ENV.OSF.url = 'http://localhost:5000/';
- ENV.OSF.apiUrl = 'http://localhost:8000';
+ switch (BACKEND) {
+ case 'local':
+ ENV.OSF = {
+ url: 'http://localhost:5000/',
+ apiUrl: 'http://localhost:8000',
- // Where to direct the user for cookie-based authentication
- ENV.OSF.cookieLoginUrl = 'http://localhost:8080/login';
- // Where to direct the user for oauth2-based authentication
- ENV.OSF.oauthUrl = 'http://localhost:8080/oauth2/profile';
- ENV.OSF.renderUrl = 'http://localhost:7778/render';
- ENV.OSF.waterbutlerUrl = 'http://localhost:7777/';
- ENV.OSF.helpUrl = 'http://localhost:4200/help';
+ // Where to direct the user for cookie-based authentication
+ cookieLoginUrl: 'http://localhost:8080/login',
+ // Where to direct the user for oauth2-based authentication
+ oauthUrl: 'http://localhost:8080/oauth2/profile',
+ renderUrl: 'http://localhost:7778/render',
+ waterbutlerUrl : 'http://localhost:7777/',
+ helpUrl: 'http://localhost:4200/help',
- ENV.OSF.accessToken = SETTINGS.PERSONAL_ACCESS_TOKEN;
- ENV.OSF.isLocal = true;
- }
- if (BACKEND === 'stage') {
- ENV.OSF.url = 'https://staging.osf.io/';
- ENV.OSF.apiUrl = 'https://staging-api.osf.io';
- ENV.OSF.cookieLoginUrl = 'https://staging-accounts.osf.io/login';
- ENV.OSF.oauthUrl = 'https://staging-accounts.osf.io/oauth2/authorize';
- ENV.OSF.renderUrl = 'https://staging-mfr.osf.io/render';
- ENV.OSF.waterbutlerUrl = 'http://staging-files.osf.io/';
- ENV.OSF.helpUrl = 'http://help.osf.io';
- }
- if (BACKEND === 'stage2') {
- ENV.OSF.url = 'https://staging2.osf.io/';
- ENV.OSF.apiUrl = 'https://staging2-api.osf.io';
- ENV.OSF.cookieLoginUrl = 'https://staging2-accounts.osf.io/login';
- ENV.OSF.oauthUrl = 'https://staging2-accounts.osf.io/oauth2/authorize';
- ENV.OSF.renderUrl = 'https://staging2-mfr.osf.io/render';
- ENV.OSF.waterbutlerUrl = 'http://staging2-files.osf.io/';
- ENV.OSF.helpUrl = 'http://help.osf.io';
- }
- // TODO: backend needs to go away, env's need to be from environment vars on build.
- if (BACKEND === 'stage3') {
- ENV.OSF.url = 'https://staging3.osf.io/';
- ENV.OSF.apiUrl = 'https://staging3-api.osf.io';
- ENV.OSF.cookieLoginUrl = 'https://staging3-accounts.osf.io/login';
- ENV.OSF.oauthUrl = 'https://staging3-accounts.osf.io/oauth2/authorize';
- ENV.OSF.renderUrl = 'https://staging3-mfr.osf.io/render';
- ENV.OSF.waterbutlerUrl = 'http://staging3-files.osf.io/';
- ENV.OSF.helpUrl = 'http://help.osf.io';
- }
- if (BACKEND === 'test') {
- ENV.OSF.url = 'https://test.osf.io/';
- ENV.OSF.apiUrl = 'https://test-api.osf.io';
- ENV.OSF.cookieLoginUrl = 'https://test-accounts.osf.io/login';
- ENV.OSF.oauthUrl = 'https://test-accounts.osf.io/oauth2/authorize';
- ENV.OSF.renderUrl = 'https://test-mfr.osf.io/render';
- ENV.OSF.waterbutlerUrl = 'http://test-files.osf.io/';
- ENV.OSF.helpUrl = 'http://help.osf.io';
- }
- if (BACKEND === 'prod') {
- console.log(`WARNING: you\'ve specified production as a backend. Please do not use production for testing or development purposes`);
- ENV.OSF.url = 'https://osf.io/';
- ENV.OSF.apiUrl = 'https://api.osf.io';
- ENV.OSF.cookieLoginUrl = 'https://accounts.osf.io/login';
- ENV.OSF.oauthUrl = 'https://accounts.osf.io/oauth2/authorize';
- ENV.OSF.renderUrl = 'https://mfr.osf.io/render';
- ENV.OSF.waterbutlerUrl = 'http://files.osf.io/';
- ENV.OSF.helpUrl = 'http://help.osf.io';
+ accessToken: SETTINGS.PERSONAL_ACCESS_TOKEN,
+ isLocal: true
+ };
+ break;
+ case 'stage':
+ ENV.OSF = {
+ url: 'https://staging.osf.io/',
+ apiUrl: 'https://staging-api.osf.io',
+ cookieLoginUrl: 'https://staging-accounts.osf.io/login',
+ oauthUrl: 'https://staging-accounts.osf.io/oauth2/authorize',
+ renderUrl: 'https://staging-mfr.osf.io/render',
+ waterbutlerUrl: 'http://staging-files.osf.io/',
+ helpUrl: 'http://help.osf.io'
+ };
+ break;
+ case 'stage2':
+ ENV.OSF = {
+ url: 'https://staging2.osf.io/',
+ apiUrl: 'https://staging2-api.osf.io',
+ cookieLoginUrl: 'https://staging2-accounts.osf.io/login',
+ oauthUrl: 'https://staging2-accounts.osf.io/oauth2/authorize',
+ renderUrl: 'https://staging2-mfr.osf.io/render',
+ waterbutlerUrl: 'http://staging2-files.osf.io/',
+ helpUrl: 'http://help.osf.io'
+ };
+ break;
+ case 'stage3':
+ ENV.OSF = {
+ url: 'https://staging3.osf.io/',
+ apiUrl: 'https://staging3-api.osf.io',
+ cookieLoginUrl: 'https://staging3-accounts.osf.io/login',
+ oauthUrl: 'https://staging3-accounts.osf.io/oauth2/authorize',
+ renderUrl: 'https://staging3-mfr.osf.io/render',
+ waterbutlerUrl: 'http://staging3-files.osf.io/',
+ helpUrl: 'http://help.osf.io'
+ };
+ break;
+ case 'test':
+ ENV.OSF = {
+ url: 'https://test.osf.io/',
+ apiUrl: 'https://test-api.osf.io',
+ cookieLoginUrl: 'https://test-accounts.osf.io/login',
+ oauthUrl: 'https://test-accounts.osf.io/oauth2/authorize',
+ renderUrl: 'https://test-mfr.osf.io/render',
+ waterbutlerUrl: 'http://test-files.osf.io/',
+ helpUrl: 'http://help.osf.io'
+ };
+ break;
+ case 'prod':
+ console.log(`WARNING: you\'ve specified production as a backend. Please do not use production for testing or development purposes`);
+ ENV.OSF = {
+ url: 'https://osf.io/',
+ apiUrl: 'https://api.osf.io',
+ cookieLoginUrl: 'https://accounts.osf.io/login',
+ oauthUrl: 'https://accounts.osf.io/oauth2/authorize',
+ renderUrl: 'https://mfr.osf.io/render',
+ waterbutlerUrl: 'http://files.osf.io/',
+ helpUrl: 'http://help.osf.io'
+ };
+ break;
+ default:
+ break;
}
ENV['ember-simple-auth'] = {
authorizer: 'authorizer:osf-token'
From 77324d1793751a242545272d070107604a2f336a Mon Sep 17 00:00:00 2001
From: Andy Boughton
Date: Fri, 27 Jan 2017 13:11:56 -0500
Subject: [PATCH 127/147] Flatten config files in a backwards-compatible way.
Also move predefined backends into a separate file
[#EOSF-452]
---
blueprints/ember-osf/files/config/_local.yml | 44 ++++----
config/backends.json | 47 ++++++++
config/custom-environment-variables.json | 15 +++
index.js | 106 ++++---------------
4 files changed, 106 insertions(+), 106 deletions(-)
create mode 100644 config/backends.json
create mode 100644 config/custom-environment-variables.json
diff --git a/blueprints/ember-osf/files/config/_local.yml b/blueprints/ember-osf/files/config/_local.yml
index 36ad1543e..45528129c 100644
--- a/blueprints/ember-osf/files/config/_local.yml
+++ b/blueprints/ember-osf/files/config/_local.yml
@@ -1,26 +1,26 @@
-
######## ember-osf settings ########
-# local:
-# CLIENT_ID: null
-# PERSONAL_ACCESS_TOKEN: null
-# OAUTH_SCOPES: osf.full_read osf.full_write
-# REDIRECT_URI: http://localhost:4200/login/
+## This file is solely for developer convenience. Any of these settings may alternately be passed in as
+# environment variables in your deployment environment
+
+### Login settings
+OAUTH_SCOPES: osf.full_write
+REDIRECT_URI: http://localhost:4200/login/
+# The developer app client ID (not client secret!). Allows your app to let users log in via the OSF.
+CLIENT_ID: null
+# Credentials for only a single user. This setting will be ignored except for local development; NEVER commit to github
+PERSONAL_ACCESS_TOKEN: null
+
+### In general, you can leave the items below commented out; ember-osf already knows how to talk to many common OSF
+## backends. Only use the below if running against a new or custom OSF instance where you need to control the URLs.
+#OSF_URL: 'http://localhost:5000/'
+#OSF_API_URL: 'http://localhost:8000'
+#RENDER_URL: 'http://localhost:7778/render'
+#FILE_URL: 'http://localhost:7777/'
+#HELP_URL: 'http://localhost:4200/help'
-# stage:
-# CLIENT_ID: null
-# PERSONAL_ACCESS_TOKEN: null
-# OAUTH_SCOPES: osf.full_read osf.full_write
-# REDIRECT_URI: http://localhost:4200/login/
-# stage2:
-# CLIENT_ID: null
-# PERSONAL_ACCESS_TOKEN: null
-# OAUTH_SCOPES: osf.full_read osf.full_write
-# REDIRECT_URI: http://localhost:4200/login/
+## Where to direct the user for cookie based authentication
+#COOKIE_LOGIN_URL: 'http://localhost:8080/login'
-test:
- CLIENT_ID: null
- PERSONAL_ACCESS_TOKEN: null
- OAUTH_SCOPES: osf.full_read osf.full_write
- REDIRECT_URI: http://localhost:4200/login/
-######### end ember-osf ##########
+## Where to direct the user for oauth-based authentication
+#OAUTH_URL: 'http://localhost:8080/oauth2/profile'
diff --git a/config/backends.json b/config/backends.json
new file mode 100644
index 000000000..7a363ba5b
--- /dev/null
+++ b/config/backends.json
@@ -0,0 +1,47 @@
+{
+ "local": {
+ "url": "http://localhost:5000/",
+ "apiUrl": "http://localhost:8000",
+ "renderUrl": "http://localhost:7778/render",
+ "waterbutlerUrl": "http://localhost:7777/",
+ "helpUrl": "http://localhost:4200/help",
+ "cookieLoginUrl": "http://localhost:8080/login",
+ "oauthUrl": "http://localhost:8080/oauth2/profile"
+ },
+ "stage": {
+ "url": "https://staging.osf.io/",
+ "apiUrl": "https://staging-api.osf.io",
+ "renderUrl": "https://staging-mfr.osf.io/render",
+ "waterbutlerUrl": "http://staging-files.osf.io/",
+ "helpUrl": "http://help.osf.io",
+ "cookieLoginUrl": "https://staging-accounts.osf.io/login",
+ "oauthUrl": "https://staging-accounts.osf.io/oauth2/authorize"
+ },
+ "stage2": {
+ "url": "https://staging2.osf.io/",
+ "apiUrl": "https://staging2-api.osf.io",
+ "renderUrl": "https://staging2-mfr.osf.io/render",
+ "waterbutlerUrl": "http://staging2-files.osf.io/",
+ "helpUrl": "http://help.osf.io",
+ "cookieLoginUrl": "https://staging2-accounts.osf.io/login",
+ "oauthUrl": "https://staging2-accounts.osf.io/oauth2/authorize"
+ },
+ "stage3": {
+ "url": "https://staging3.osf.io/",
+ "apiUrl": "https://staging3-api.osf.io",
+ "renderUrl": "https://staging3-mfr.osf.io/render",
+ "waterbutlerUrl": "http://staging3-files.osf.io/",
+ "helpUrl": "http://help.osf.io",
+ "cookieLoginUrl": "https://staging3-accounts.osf.io/login",
+ "oauthUrl": "https://staging3-accounts.osf.io/oauth2/authorize"
+ },
+ "test": {
+ "url": "https://test.osf.io/",
+ "apiUrl": "https://test-api.osf.io",
+ "renderUrl": "https://test-mfr.osf.io/render",
+ "waterbutlerUrl": "http://test-files.osf.io/",
+ "helpUrl": "http://help.osf.io",
+ "cookieLoginUrl": "https://test-accounts.osf.io/login",
+ "oauthUrl": "https://test-accounts.osf.io/oauth2/authorize"
+ }
+}
diff --git a/config/custom-environment-variables.json b/config/custom-environment-variables.json
new file mode 100644
index 000000000..884b7ed98
--- /dev/null
+++ b/config/custom-environment-variables.json
@@ -0,0 +1,15 @@
+{
+ "OAUTH_SCOPES": "OAUTH_SCOPES",
+ "REDIRECT_URI": "REDIRECT_URI",
+ "CLIENT_ID": "CLIENT_ID",
+ "PERSONAL_ACCESS_TOKEN": "PERSONAL_ACCESS_TOKEN",
+
+ "OSF_URL": "OSF_URL",
+ "OSF_API_URL": "OSF_API_URL",
+ "RENDER_URL": "RENDER_URL",
+ "FILE_URL": "FILE_URL",
+ "HELP_URL": "HELP_URL",
+
+ "COOKIE_LOGIN_URL": "COOKIE_LOGIN_URL",
+ "OAUTH_URL": "OAUTH_URL"
+}
diff --git a/index.js b/index.js
index 499fe2d31..b35ef565b 100644
--- a/index.js
+++ b/index.js
@@ -6,6 +6,9 @@ var Funnel = require('broccoli-funnel');
var mergeTrees = require('broccoli-merge-trees');
var compileSass = require('broccoli-sass-source-maps');
+// Fetch a list of known backends. The user can always choose to override any of these URLs via ENV vars
+var knownBackends = require('./config/backends');
+
module.exports = {
name: 'ember-osf',
blueprintsPath: function() {
@@ -13,12 +16,12 @@ module.exports = {
},
config: function(environment, ENV) {
let BACKEND = process.env.BACKEND || 'local';
- let SETTINGS = {};
- try {
- SETTINGS = config.get(BACKEND);
- } catch (e) {
- console.log(`WARNING: you\'ve specified a backend '${BACKEND}' that you have not configured in your config/local.yml`);
- }
+ // Settings required to configure the developer application, primarily for OAuth2
+ let OAUTH_SETTINGS = {};
+ // Backwards compatibility: old config.yml files were nested, with keys like "local", "test", etc.
+ // New ones are flat- you specify the values you want once. If there is no key, assume
+ // this is a flat config file and access keys accordingly.
+ OAUTH_SETTINGS = config['BACKEND'] || config;
// For i18n
ENV.i18n = {
@@ -26,91 +29,26 @@ module.exports = {
};
ENV.OSF = {
- clientId: SETTINGS.CLIENT_ID,
- scope: SETTINGS.OAUTH_SCOPES,
+ clientId: OAUTH_SETTINGS.CLIENT_ID,
+ scope: OAUTH_SETTINGS.OAUTH_SCOPES,
apiNamespace: 'v2', // URL suffix (after host)
backend: BACKEND,
- redirectUri: SETTINGS.REDIRECT_URI
+ redirectUri: OAUTH_SETTINGS.REDIRECT_URI
};
- switch (BACKEND) {
- case 'local':
- ENV.OSF = {
- url: 'http://localhost:5000/',
- apiUrl: 'http://localhost:8000',
+ // Fetch configuration information for the application
+ var backendConfig = knownBackends[BACKEND] || {};
- // Where to direct the user for cookie-based authentication
- cookieLoginUrl: 'http://localhost:8080/login',
- // Where to direct the user for oauth2-based authentication
- oauthUrl: 'http://localhost:8080/oauth2/profile',
- renderUrl: 'http://localhost:7778/render',
- waterbutlerUrl : 'http://localhost:7777/',
- helpUrl: 'http://localhost:4200/help',
+ if (BACKEND === 'local') {
+ backendConfig.accessToken = OAUTH_SETTINGS.PERSONAL_ACCESS_TOKEN;
+ backendConfig.isLocal = true;
+ } else if (BACKEND === 'prod') {
+ console.log("WARNING: you've specified production as a backend. Please do not use production for testing or development purposes");
+ }
- accessToken: SETTINGS.PERSONAL_ACCESS_TOKEN,
- isLocal: true
- };
- break;
- case 'stage':
- ENV.OSF = {
- url: 'https://staging.osf.io/',
- apiUrl: 'https://staging-api.osf.io',
- cookieLoginUrl: 'https://staging-accounts.osf.io/login',
- oauthUrl: 'https://staging-accounts.osf.io/oauth2/authorize',
- renderUrl: 'https://staging-mfr.osf.io/render',
- waterbutlerUrl: 'http://staging-files.osf.io/',
- helpUrl: 'http://help.osf.io'
- };
- break;
- case 'stage2':
- ENV.OSF = {
- url: 'https://staging2.osf.io/',
- apiUrl: 'https://staging2-api.osf.io',
- cookieLoginUrl: 'https://staging2-accounts.osf.io/login',
- oauthUrl: 'https://staging2-accounts.osf.io/oauth2/authorize',
- renderUrl: 'https://staging2-mfr.osf.io/render',
- waterbutlerUrl: 'http://staging2-files.osf.io/',
- helpUrl: 'http://help.osf.io'
- };
- break;
- case 'stage3':
- ENV.OSF = {
- url: 'https://staging3.osf.io/',
- apiUrl: 'https://staging3-api.osf.io',
- cookieLoginUrl: 'https://staging3-accounts.osf.io/login',
- oauthUrl: 'https://staging3-accounts.osf.io/oauth2/authorize',
- renderUrl: 'https://staging3-mfr.osf.io/render',
- waterbutlerUrl: 'http://staging3-files.osf.io/',
- helpUrl: 'http://help.osf.io'
- };
- break;
- case 'test':
- ENV.OSF = {
- url: 'https://test.osf.io/',
- apiUrl: 'https://test-api.osf.io',
- cookieLoginUrl: 'https://test-accounts.osf.io/login',
- oauthUrl: 'https://test-accounts.osf.io/oauth2/authorize',
- renderUrl: 'https://test-mfr.osf.io/render',
- waterbutlerUrl: 'http://test-files.osf.io/',
- helpUrl: 'http://help.osf.io'
- };
- break;
- case 'prod':
- console.log(`WARNING: you\'ve specified production as a backend. Please do not use production for testing or development purposes`);
- ENV.OSF = {
- url: 'https://osf.io/',
- apiUrl: 'https://api.osf.io',
- cookieLoginUrl: 'https://accounts.osf.io/login',
- oauthUrl: 'https://accounts.osf.io/oauth2/authorize',
- renderUrl: 'https://mfr.osf.io/render',
- waterbutlerUrl: 'http://files.osf.io/',
- helpUrl: 'http://help.osf.io'
+ // TODO: Deal with incomplete or unrecognized config? (since config comes from env variables, backends, or both, need to check at end)
+ ENV.OSF = backendConfig;
- };
- break;
- default:
- break;
- }
ENV['ember-simple-auth'] = {
authorizer: 'authorizer:osf-token'
};
From cbcb546a0a2edf5e900b1d55dc96cbc8eb3869a9 Mon Sep 17 00:00:00 2001
From: Andy Boughton
Date: Fri, 27 Jan 2017 13:43:26 -0500
Subject: [PATCH 128/147] Provide a means to fetch URL config from environment
variables (all-or-nothing)
[ci skip]
[#EOSF-452]
---
blueprints/ember-osf/files/config/_local.yml | 10 +++++-----
config/backends.json | 9 +++++++++
config/custom-environment-variables.json | 10 +++++-----
index.js | 19 ++++++++++++++++---
4 files changed, 35 insertions(+), 13 deletions(-)
diff --git a/blueprints/ember-osf/files/config/_local.yml b/blueprints/ember-osf/files/config/_local.yml
index 45528129c..d6019f2a1 100644
--- a/blueprints/ember-osf/files/config/_local.yml
+++ b/blueprints/ember-osf/files/config/_local.yml
@@ -14,13 +14,13 @@ PERSONAL_ACCESS_TOKEN: null
## backends. Only use the below if running against a new or custom OSF instance where you need to control the URLs.
#OSF_URL: 'http://localhost:5000/'
#OSF_API_URL: 'http://localhost:8000'
-#RENDER_URL: 'http://localhost:7778/render'
-#FILE_URL: 'http://localhost:7777/'
-#HELP_URL: 'http://localhost:4200/help'
+#OSF_RENDER_URL: 'http://localhost:7778/render'
+#OSF_FILE_URL: 'http://localhost:7777/'
+#OSF_HELP_URL: 'http://localhost:4200/help'
## Where to direct the user for cookie based authentication
-#COOKIE_LOGIN_URL: 'http://localhost:8080/login'
+#OSF_COOKIE_LOGIN_URL: 'http://localhost:8080/login'
## Where to direct the user for oauth-based authentication
-#OAUTH_URL: 'http://localhost:8080/oauth2/profile'
+#OSF_OAUTH_URL: 'http://localhost:8080/oauth2/profile'
diff --git a/config/backends.json b/config/backends.json
index 7a363ba5b..1eecfed8d 100644
--- a/config/backends.json
+++ b/config/backends.json
@@ -43,5 +43,14 @@
"helpUrl": "http://help.osf.io",
"cookieLoginUrl": "https://test-accounts.osf.io/login",
"oauthUrl": "https://test-accounts.osf.io/oauth2/authorize"
+ },
+ "env": {
+ "url": "OSF_URL",
+ "apiUrl": "OSF_API_URL",
+ "renderUrl": "OSF_RENDER_URL",
+ "waterbutlerUrl": "OSF_FILE_URL",
+ "helpUrl": "OSF_HELP_URL",
+ "cookieLoginUrl": "OSF_COOKIE_LOGIN_URL",
+ "oauthUrl": "OSF_OAUTH_URL"
}
}
diff --git a/config/custom-environment-variables.json b/config/custom-environment-variables.json
index 884b7ed98..c730bdb3d 100644
--- a/config/custom-environment-variables.json
+++ b/config/custom-environment-variables.json
@@ -6,10 +6,10 @@
"OSF_URL": "OSF_URL",
"OSF_API_URL": "OSF_API_URL",
- "RENDER_URL": "RENDER_URL",
- "FILE_URL": "FILE_URL",
- "HELP_URL": "HELP_URL",
+ "OSF_RENDER_URL": "OSF_RENDER_URL",
+ "OSF_FILE_URL": "OSF_FILE_URL",
+ "OSF_HELP_URL": "OSF_HELP_URL",
- "COOKIE_LOGIN_URL": "COOKIE_LOGIN_URL",
- "OAUTH_URL": "OAUTH_URL"
+ "OSF_COOKIE_LOGIN_URL": "OSF_COOKIE_LOGIN_URL",
+ "OSF_OAUTH_URL": "OSF_OAUTH_URL"
}
diff --git a/index.js b/index.js
index b35ef565b..dd357f00c 100644
--- a/index.js
+++ b/index.js
@@ -21,7 +21,7 @@ module.exports = {
// Backwards compatibility: old config.yml files were nested, with keys like "local", "test", etc.
// New ones are flat- you specify the values you want once. If there is no key, assume
// this is a flat config file and access keys accordingly.
- OAUTH_SETTINGS = config['BACKEND'] || config;
+ OAUTH_SETTINGS = config[BACKEND] || config;
// For i18n
ENV.i18n = {
@@ -43,10 +43,23 @@ module.exports = {
backendConfig.accessToken = OAUTH_SETTINGS.PERSONAL_ACCESS_TOKEN;
backendConfig.isLocal = true;
} else if (BACKEND === 'prod') {
- console.log("WARNING: you've specified production as a backend. Please do not use production for testing or development purposes");
+ console.warn("WARNING: you've specified production as a backend. Please do not use production for testing or development purposes");
+ } else if (BACKEND === 'env') {
+ // Optionally draw backend settings entirely from environment variables.
+ // This is an all-or-nothing operation; we currently do not support overriding one URL at a time.
+ let newConfig = {};
+ // Map the internal, old-style key names to the corresponding environment variables. All must be present.
+ Object.keys(backendConfig).forEach(key => {
+ const envEntryName = backendConfig[key];
+ newConfig[key] = config[envEntryName];
+ });
+ backendConfig = newConfig;
}
- // TODO: Deal with incomplete or unrecognized config? (since config comes from env variables, backends, or both, need to check at end)
+ // Warn the user if some config entries not present
+ Object.keys(backendConfig).forEach(key => {
+ if (!backendConfig[key]) console.error(`This backend must define a value for: ${key}`);
+ });
ENV.OSF = backendConfig;
ENV['ember-simple-auth'] = {
From a1d09f9930643f409983fc841afe29cc690ad463 Mon Sep 17 00:00:00 2001
From: Sherif
Date: Fri, 27 Jan 2017 14:17:45 -0500
Subject: [PATCH 129/147] Adjust styling
---
addon/components/osf-copyright/component.js | 2 +-
.../components/osf-copyright/component-test.js | 14 +-------------
2 files changed, 2 insertions(+), 14 deletions(-)
diff --git a/addon/components/osf-copyright/component.js b/addon/components/osf-copyright/component.js
index 1383665e8..4cf6ed0c3 100644
--- a/addon/components/osf-copyright/component.js
+++ b/addon/components/osf-copyright/component.js
@@ -13,6 +13,6 @@ import layout from './template';
export default Ember.Component.extend({
layout,
currentYear: function() {
- return new Date().getFullYear();
+ return new Date().getFullYear();
}.property()
});
diff --git a/tests/integration/components/osf-copyright/component-test.js b/tests/integration/components/osf-copyright/component-test.js
index 2ea0dafa0..08a8379de 100644
--- a/tests/integration/components/osf-copyright/component-test.js
+++ b/tests/integration/components/osf-copyright/component-test.js
@@ -2,25 +2,13 @@ import {
moduleForComponent,
test
} from 'ember-qunit';
-import hbs from 'htmlbars-inline-precompile';
+
moduleForComponent('osf-copyright', 'Integration | Component | osf copyright', {
integration: true
});
test('it renders', function(assert) {
- // Set any properties with this.set('myProperty', 'value');
- // Handle any actions with this.on('myAction', function(val) { ... });
-
- this.render(hbs `{{osf-copyright}}`);
-
-
- // Template block usage:
- this.render(hbs `
- {{#osf-copyright}}
- template block text
- {{/osf-copyright}}
- `);
assert.ok(true);
});
From 131cca23180dc1cd1a07b3439cc3c659073653ba Mon Sep 17 00:00:00 2001
From: Sherif
Date: Fri, 27 Jan 2017 15:42:20 -0500
Subject: [PATCH 130/147] Use getUTCFullYear
---
addon/components/osf-copyright/component.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/addon/components/osf-copyright/component.js b/addon/components/osf-copyright/component.js
index 4cf6ed0c3..ff15131a8 100644
--- a/addon/components/osf-copyright/component.js
+++ b/addon/components/osf-copyright/component.js
@@ -13,6 +13,7 @@ import layout from './template';
export default Ember.Component.extend({
layout,
currentYear: function() {
- return new Date().getFullYear();
+ let date = new Date();
+ return date.getUTCFullYear().toString();
}.property()
});
From bd10f904097059f66355212f6e0eff77ee81c9ac Mon Sep 17 00:00:00 2001
From: Andy Boughton
Date: Fri, 27 Jan 2017 20:51:35 -0500
Subject: [PATCH 131/147] Fix typo
[ci skip]
[#EOSF-452]
---
index.js | 6 +++---
yarn.lock | 4 ++++
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/index.js b/index.js
index dd357f00c..a9ba55416 100644
--- a/index.js
+++ b/index.js
@@ -18,9 +18,9 @@ module.exports = {
let BACKEND = process.env.BACKEND || 'local';
// Settings required to configure the developer application, primarily for OAuth2
let OAUTH_SETTINGS = {};
- // Backwards compatibility: old config.yml files were nested, with keys like "local", "test", etc.
- // New ones are flat- you specify the values you want once. If there is no key, assume
- // this is a flat config file and access keys accordingly.
+ // Backwards compatibility: old config/*.yml files were nested, with keys like "stage", "test", etc.
+ // New files are flat- you specify the values you want once. If there is no key, assume
+ // this is a flat config file and assume the settings we want are at the top level.
OAUTH_SETTINGS = config[BACKEND] || config;
// For i18n
diff --git a/yarn.lock b/yarn.lock
index 81e8dc1de..de4f1aa51 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1497,6 +1497,10 @@ dot-prop@^3.0.0:
dependencies:
is-obj "^1.0.0"
+dotenv@^4.0.0:
+ version "4.0.0"
+ resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-4.0.0.tgz#864ef1379aced55ce6f95debecdce179f7a0cd1d"
+
ecc-jsbn@~0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505"
From 66033de1db70f41a45256b2e8ac9edab532b0737 Mon Sep 17 00:00:00 2001
From: Sherif
Date: Mon, 30 Jan 2017 10:47:39 -0500
Subject: [PATCH 132/147] Remove unused test
---
.../components/osf-footer/component-test.js | 22 -------------------
1 file changed, 22 deletions(-)
delete mode 100644 tests/integration/components/osf-footer/component-test.js
diff --git a/tests/integration/components/osf-footer/component-test.js b/tests/integration/components/osf-footer/component-test.js
deleted file mode 100644
index 4c0e99102..000000000
--- a/tests/integration/components/osf-footer/component-test.js
+++ /dev/null
@@ -1,22 +0,0 @@
-import { moduleForComponent, test } from 'ember-qunit';
-import hbs from 'htmlbars-inline-precompile';
-
-moduleForComponent('osf-footer', 'Integration | Component | osf footer', {
- integration: true
-});
-
-test('it renders', function(assert) {
- // Set any properties with this.set('myProperty', 'value');
- // Handle any actions with this.on('myAction', function(val) { ... });
-
- this.render(hbs`{{osf-footer}}`);
-
- // Template block usage:
- this.render(hbs`
- {{#osf-footer}}
- template block text
- {{/osf-footer}}
- `);
-
- assert.ok(true);
-});
From 0ff0e050acdfc2c1176750d6b18df61ea636aebd Mon Sep 17 00:00:00 2001
From: Sherif
Date: Mon, 30 Jan 2017 10:54:29 -0500
Subject: [PATCH 133/147] Remove unused test
---
.../components/osf-copyright/component-test.js | 14 --------------
1 file changed, 14 deletions(-)
delete mode 100644 tests/integration/components/osf-copyright/component-test.js
diff --git a/tests/integration/components/osf-copyright/component-test.js b/tests/integration/components/osf-copyright/component-test.js
deleted file mode 100644
index 08a8379de..000000000
--- a/tests/integration/components/osf-copyright/component-test.js
+++ /dev/null
@@ -1,14 +0,0 @@
-import {
- moduleForComponent,
- test
-} from 'ember-qunit';
-
-
-moduleForComponent('osf-copyright', 'Integration | Component | osf copyright', {
- integration: true
-});
-
-test('it renders', function(assert) {
-
- assert.ok(true);
-});
From 2690c03f62765e27257a3cef38800c5aa753d813 Mon Sep 17 00:00:00 2001
From: Andy Boughton
Date: Mon, 30 Jan 2017 14:51:49 -0500
Subject: [PATCH 134/147] Doc improvements, https for file servers, and add
back prod backend accidentally omitted
[ci skip]
[#EOSF-452]
---
README.md | 111 ++++++++++++-------
blueprints/ember-osf/files/config/_local.yml | 6 +-
config/backends.json | 17 ++-
index.js | 10 +-
4 files changed, 100 insertions(+), 44 deletions(-)
diff --git a/README.md b/README.md
index 8b6e6552f..d81c88cf7 100644
--- a/README.md
+++ b/README.md
@@ -4,21 +4,31 @@
`develop` Build Status: [![Build Status](https://travis-ci.org/CenterForOpenScience/ember-osf.svg?branch=develop)](https://travis-ci.org/CenterForOpenScience/ember-osf)
-This repo contains code for interacting with the OSF APIv2 inside of an Ember app.
+This repo contains code for interacting with the [OSF APIv2](https://api.osf.io/v2/) inside of an Ember app. See
+[addon API Docs](http://centerforopenscience.github.io/ember-osf/) for a list of what this addon provides.
-## Contributing?
+## Contributing
Please read the [CONTRIBUTING.md](https://github.com/CenterForOpenScience/ember-osf/blob/develop/.github/CONTRIBUTING.md)
-## Installation (for Development)
-See the [yarn docs](https://yarnpkg.com/) for installing and using yarn.
+## Installing tools to develop and modify this addon
+See the [yarn docs](https://yarnpkg.com/) for installing and using yarn. These instructions will prepare your
+environment if you plan to modify and test this addon in isolation.
* `git clone` this repository
* `yarn install --pure-lockfile`
* `bower install`
-## Using this code in an Ember app
+## Using this addon in another Ember app
+### For production use
+Other applications that wish to consume this addon should add the following line manually to the consuming Ember app's
+`package.json` file, then run `yarn install` and `bower install` inside that app.
+ `"ember-osf": "git+https://github.com/CenterForOpenScience/ember-osf.git#NewestCommitHashGoesHere",`
+
+In the future, we will provide an installable `npm` package to simplify this process.
+
+### For local development
1. Clone the repository: `git clone https://github.com/CenterForOpenScience/ember-osf.git`
2. From the consuming Ember app:
- install the addon and it's dependencies: `ember install ../ember-osf`
@@ -32,19 +42,26 @@ See the [yarn docs](https://yarnpkg.com/) for installing and using yarn.
export default Ember.Route.extend(OsfLoginRouteMixin);
```
-> **Note**: Running ember install will automatically install all bower and npm dependencies for ember-osf.
+> **Note**: Running ember install will automatically install many bower and npm dependencies for ember-osf.
## Configuration
+### Specifying configuration information
+
#### local.yml settings
-This file is structured like:
+If for some reason you don't have a config/local.yml you can generate one. To do this:
+```bash
+ember generate ember-osf
+```
+
+Ember-osf needs certain configuration variables to run. This is usually done via a config file structured as follows:
```yaml
-:
+ OAUTH_SCOPES: osf.full_write
+ REDIRECT_URI: http://localhost:4200/login
+
CLIENT_ID: null
PERSONAL_ACCESS_TOKEN: null
- OAUTH_SCOPES: osf.full_read osf.full_write
- REDIRECT_URI: http://localhost:4200/login
```
You will need to fill out options for each backend you want to use (see 'Running' below).
@@ -54,65 +71,85 @@ uri is correct. If it needs a trailing slash, be sure to include a trailing sla
Edit the new file (installed in the config directory) and set:
- `CLIENT_ID` to the client id of your developer application
-- `PERSONAL_ACCESS_TOKEN` to the newly generated token (Only required or recognized for the LOCAL backend; do not set this value for staging, production, or test backends)
-- REDIRECT_URI: Must exactly match the redirect URI used to register the OAuth developer application.
+- `PERSONAL_ACCESS_TOKEN` to the newly generated token (Only required or recognized for the LOCAL backend; do not set
+this value for staging, production, or test backends)
+- `REDIRECT_URI`: Must exactly match the redirect URI used to register the OAuth developer application.
Default value is appropriate for local development using `ember server`, with a login page at `/login`
-Because of the potential for this file to include sensitive information, we strongly recommend adding this file to
-`.gitignore` for your project.
+Because of the potential for this file to include sensitive information, **we strongly recommend adding this file to
+`.gitignore`** for your project.
-#### Using the Test API
+#### Alternate option: Environment variables
+If you do not wish to use file-based configuration, any of the settings above can be overridden individually as
+environment variables with the same name as appears in the config file. Eg
-To do this, you will need to [create a developer application](https://test.osf.io/settings/applications/) on the relevant version of the OSF.
+`BACKEND=test CLIENT_ID=gibberish ember serve`
-#### Running the OSF Locally (optional)
+If you provide a setting in both the config file and an environment variable, the environment variables take precedence.
-For local development, you will need to be running the [OSF APIv2](https://github.com/CenterForOpenScience/osf.io#running-the-api-server).
-To connect to the APIv2 while using [fakecas](https://github.com/CenterForOpenScience/osf.io#running-the-osf), you will need to generate a
-personal access token on your local OSF instance [here](http://localhost:5000/settings/tokens/)--go ahead and grant access to all scopes.
+### Using the API
+Most apps that use this addon will authorize requests via OAuth2. As may be apparent from the `CLIENT_ID` and
+`REDIRECT_URI` settings above, you will need to [create a developer application](https://test.osf.io/settings/applications/)
+on the relevant version of the OSF, and provide the appropriate settings for your app.
-#### Create a local settings file
+### Running the OSF Locally (optional)
-If for some reason you don't have a config/local.yml you can generate one. To do this:
-```bash
-ember generate ember-osf
-```
+For local development, you will need to be running the [OSF APIv2](https://github.com/CenterForOpenScience/osf.io#running-the-api-server).
+To connect to the APIv2 while using [fakecas](https://github.com/CenterForOpenScience/osf.io#running-the-osf), you
+will need to generate a personal access token on your local OSF instance [here](http://localhost:5000/settings/tokens/)-
+go ahead and grant full privilege access to all scopes (the `osf.full_write` option).
-## Usage
+## Using this addon
-#### Ember Data: Using the OSF models
+### Ember Data: Using the OSF models
The models, serializers, adapters bundled in this addon with be available to you automatically.
For example, simply do:
```javascript
this.store.findAll('node')
```
-to fetch all nodes.
+to fetch all nodes (or at least the first page of results). If you need to fetch many results, see the API docs for
+information about how to handle pagination. Ember-osf also provides support for
+[paginated relationship requests](https://github.com/mdehoog/ember-data-has-many-query) via a third-party addon.
+
+### Advanced: using components and styles
+Some of the ember-osf components require additional configuration to take advantage of premade widgets or styles.
+
+Some of these settings, as well as recommended best practices, are gathered together in a
+[demonstration app](https://github.com/abought/demo-ember-osf/) that consumes this addon.
## Running
-We recommend developers target out test server:
+### Using the addon with a specific server
+We recommend developers target our test server:
- test (`test`): matches production features, very stable
-Other options include:
+Ember-osf also ships with builtin support for several other servers:
- local (`local`): for developers running the OSF stack locally
- staging (`stage`): contains bleeding edge features, but less stable
-- staging2 (`stage2`): another version of staging using running a specific feature branch
+- staging2 (`stage2`) or `staging3` (`stage3`): Staging servers that run specific feature branches, usually for
+ functionality that is being tested for longer or not targeted for immediate release
+- production (`prod`): The main osf.io site. This is a good choice for apps you deploy, but please be a good citizen
+ and avoid using the production server for your test data.
Then (using test as an example) run:
`BACKEND=test ember server`
and visit your app at http://localhost:4200.
-**Note:** This runs the dummy app contained in /tests/dummy
+**Note:** When run from within the `ember-osf` repository, this command runs the dummy app contained in /tests/dummy
-## Running Tests
+### Using a custom OSF backend
+In certain circumstances, you may wish to use a custom set of servers not known to the `ember-osf` addon.
+ You can elect to specify your server URLs individually, by specifying `BACKEND=env` and passing additional environment
+ variables/config file entries. For example:
+
+`BACKEND=env OSF_URL=https://e.io/ OSF_API_URL=https://api.e.io OSF_RENDER_URL=https://mfr.e.io/render OSF_FILE_URL=https://files.e.io OSF_HELP_URL=https://help.e.io OSF_COOKIE_LOGIN_URL=https://accounts.e.io/login OSF_OAUTH_URL=https://accounts.e.io/oauth2/authorize ember serve`
-* `yarn test`
-* `ember test --server`
+## Running Tests
-## Building
+* `yarn test` will run all tests used by Travis
+* `ember test --server` will run just ember tests, and reload any time that code is changed
-* `yarn run build`
For more information on using ember-cli, visit [http://www.ember-cli.com/](http://www.ember-cli.com/).
diff --git a/blueprints/ember-osf/files/config/_local.yml b/blueprints/ember-osf/files/config/_local.yml
index d6019f2a1..9c8151532 100644
--- a/blueprints/ember-osf/files/config/_local.yml
+++ b/blueprints/ember-osf/files/config/_local.yml
@@ -3,15 +3,19 @@
# environment variables in your deployment environment
### Login settings
+# Default is ability to read and write all data associated with a user's account. Some apps may not need full account
+# privileges. If your app only reads data, best practice is to limit permission requests to only what you need.
OAUTH_SCOPES: osf.full_write
+# Where to send the user on the site after they authenticated. Usually this is a page enabled to handle the oauth flow.
REDIRECT_URI: http://localhost:4200/login/
-# The developer app client ID (not client secret!). Allows your app to let users log in via the OSF.
+# The developer app client ID (not client secret!). This is needed for your app to let users log in via the OSF.
CLIENT_ID: null
# Credentials for only a single user. This setting will be ignored except for local development; NEVER commit to github
PERSONAL_ACCESS_TOKEN: null
### In general, you can leave the items below commented out; ember-osf already knows how to talk to many common OSF
## backends. Only use the below if running against a new or custom OSF instance where you need to control the URLs.
+## These values will be ignored unless running with `BACKEND=env`.
#OSF_URL: 'http://localhost:5000/'
#OSF_API_URL: 'http://localhost:8000'
#OSF_RENDER_URL: 'http://localhost:7778/render'
diff --git a/config/backends.json b/config/backends.json
index 1eecfed8d..e1733a9ad 100644
--- a/config/backends.json
+++ b/config/backends.json
@@ -12,7 +12,7 @@
"url": "https://staging.osf.io/",
"apiUrl": "https://staging-api.osf.io",
"renderUrl": "https://staging-mfr.osf.io/render",
- "waterbutlerUrl": "http://staging-files.osf.io/",
+ "waterbutlerUrl": "https://staging-files.osf.io/",
"helpUrl": "http://help.osf.io",
"cookieLoginUrl": "https://staging-accounts.osf.io/login",
"oauthUrl": "https://staging-accounts.osf.io/oauth2/authorize"
@@ -21,7 +21,7 @@
"url": "https://staging2.osf.io/",
"apiUrl": "https://staging2-api.osf.io",
"renderUrl": "https://staging2-mfr.osf.io/render",
- "waterbutlerUrl": "http://staging2-files.osf.io/",
+ "waterbutlerUrl": "https://staging2-files.osf.io/",
"helpUrl": "http://help.osf.io",
"cookieLoginUrl": "https://staging2-accounts.osf.io/login",
"oauthUrl": "https://staging2-accounts.osf.io/oauth2/authorize"
@@ -30,16 +30,25 @@
"url": "https://staging3.osf.io/",
"apiUrl": "https://staging3-api.osf.io",
"renderUrl": "https://staging3-mfr.osf.io/render",
- "waterbutlerUrl": "http://staging3-files.osf.io/",
+ "waterbutlerUrl": "https://staging3-files.osf.io/",
"helpUrl": "http://help.osf.io",
"cookieLoginUrl": "https://staging3-accounts.osf.io/login",
"oauthUrl": "https://staging3-accounts.osf.io/oauth2/authorize"
},
+ "prod": {
+ "url": "https://osf.io/",
+ "apiUrl": "https://api.osf.io",
+ "renderUrl": "https://mfr.osf.io/render",
+ "waterbutlerUrl": "https://files.osf.io/",
+ "helpUrl": "http://help.osf.io",
+ "cookieLoginUrl": "https://accounts.osf.io/login",
+ "oauthUrl": "https://accounts.osf.io/oauth2/authorize"
+ },
"test": {
"url": "https://test.osf.io/",
"apiUrl": "https://test-api.osf.io",
"renderUrl": "https://test-mfr.osf.io/render",
- "waterbutlerUrl": "http://test-files.osf.io/",
+ "waterbutlerUrl": "https://test-files.osf.io/",
"helpUrl": "http://help.osf.io",
"cookieLoginUrl": "https://test-accounts.osf.io/login",
"oauthUrl": "https://test-accounts.osf.io/oauth2/authorize"
diff --git a/index.js b/index.js
index a9ba55416..a874d8b99 100644
--- a/index.js
+++ b/index.js
@@ -39,6 +39,10 @@ module.exports = {
// Fetch configuration information for the application
var backendConfig = knownBackends[BACKEND] || {};
+ if (!Object.keys(knownBackends).includes(BACKEND)) {
+ console.warn('WARNING: You have specified an unknown backend environment. If you need to customize URL settings, specify BACKEND=env');
+ }
+
if (BACKEND === 'local') {
backendConfig.accessToken = OAUTH_SETTINGS.PERSONAL_ACCESS_TOKEN;
backendConfig.isLocal = true;
@@ -56,11 +60,13 @@ module.exports = {
backendConfig = newConfig;
}
- // Warn the user if some config entries not present
+ // Warn the user if some URL entries not present
Object.keys(backendConfig).forEach(key => {
if (!backendConfig[key]) console.error(`This backend must define a value for: ${key}`);
});
- ENV.OSF = backendConfig;
+
+ // Combine URLs + auth settings into final auth config
+ Object.assign(ENV.OSF, backendConfig);
ENV['ember-simple-auth'] = {
authorizer: 'authorizer:osf-token'
From a85194fb8eb9e1b5e000c9bd449e24ed272c59b9 Mon Sep 17 00:00:00 2001
From: Sherif
Date: Tue, 31 Jan 2017 13:48:16 -0500
Subject: [PATCH 135/147] Update osf-copyright component testing to use sinon
---
addon/components/osf-copyright/template.hbs | 2 +-
.../components/osf-copyright/component-test.js | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
create mode 100644 tests/integration/components/osf-copyright/component-test.js
diff --git a/addon/components/osf-copyright/template.hbs b/addon/components/osf-copyright/template.hbs
index 2f22165a2..665c20332 100644
--- a/addon/components/osf-copyright/template.hbs
+++ b/addon/components/osf-copyright/template.hbs
@@ -2,7 +2,7 @@
- Copyright © 2011-{{currentYear}}
+ Copyright © 2011-{{currentYear}}
Center for Open Science |
Terms of Use |
Privacy Policy
diff --git a/tests/integration/components/osf-copyright/component-test.js b/tests/integration/components/osf-copyright/component-test.js
new file mode 100644
index 000000000..9219ca7ce
--- /dev/null
+++ b/tests/integration/components/osf-copyright/component-test.js
@@ -0,0 +1,16 @@
+import { moduleForComponent, test } from 'ember-qunit';
+import hbs from 'htmlbars-inline-precompile';
+import sinon from 'sinon';
+
+moduleForComponent('osf-copyright', 'Integration | Component | osf copyright', {
+ integration: true
+});
+
+test('it renders', function(assert) {
+
+ const year = sinon.useFakeTimers(new Date(1648,1,1).getTime());
+ this.render(hbs`{{osf-copyright}}`);
+ const currentYear= this.$('div.container span.copyright').text().trim().split('-');
+ assert.equal(currentYear[1], '1648');
+ year.restore();
+});
From 9674055b1b7ef3c70f9ef3f183139699dfe5af25 Mon Sep 17 00:00:00 2001
From: Sherif
Date: Tue, 31 Jan 2017 13:49:18 -0500
Subject: [PATCH 136/147] Re-write the currentYear property
---
addon/components/osf-copyright/component.js | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/addon/components/osf-copyright/component.js b/addon/components/osf-copyright/component.js
index ff15131a8..55a464406 100644
--- a/addon/components/osf-copyright/component.js
+++ b/addon/components/osf-copyright/component.js
@@ -12,8 +12,5 @@ import layout from './template';
*/
export default Ember.Component.extend({
layout,
- currentYear: function() {
- let date = new Date();
- return date.getUTCFullYear().toString();
- }.property()
+ currentYear: (new Date()).getUTCFullYear().toString()
});
From a998d06ef4498a3472f322e193b82b2ff62b281b Mon Sep 17 00:00:00 2001
From: Andy Boughton
Date: Tue, 31 Jan 2017 16:57:11 -0500
Subject: [PATCH 137/147] Make all settings possible to override via env vars,
and deprecate node-config approach
(which breaks in consuming apps without fragile tree manipulation)
[ci skip]
[#EOSF-452]
---
blueprints/ember-osf/files/config/_local.yml | 2 +-
config/custom-environment-variables.json | 15 -----
index.js | 65 ++++++++++++++------
3 files changed, 47 insertions(+), 35 deletions(-)
delete mode 100644 config/custom-environment-variables.json
diff --git a/blueprints/ember-osf/files/config/_local.yml b/blueprints/ember-osf/files/config/_local.yml
index 9c8151532..6999f5b18 100644
--- a/blueprints/ember-osf/files/config/_local.yml
+++ b/blueprints/ember-osf/files/config/_local.yml
@@ -7,7 +7,7 @@
# privileges. If your app only reads data, best practice is to limit permission requests to only what you need.
OAUTH_SCOPES: osf.full_write
# Where to send the user on the site after they authenticated. Usually this is a page enabled to handle the oauth flow.
-REDIRECT_URI: http://localhost:4200/login/
+REDIRECT_URI: http://localhost:4200/login
# The developer app client ID (not client secret!). This is needed for your app to let users log in via the OSF.
CLIENT_ID: null
# Credentials for only a single user. This setting will be ignored except for local development; NEVER commit to github
diff --git a/config/custom-environment-variables.json b/config/custom-environment-variables.json
deleted file mode 100644
index c730bdb3d..000000000
--- a/config/custom-environment-variables.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "OAUTH_SCOPES": "OAUTH_SCOPES",
- "REDIRECT_URI": "REDIRECT_URI",
- "CLIENT_ID": "CLIENT_ID",
- "PERSONAL_ACCESS_TOKEN": "PERSONAL_ACCESS_TOKEN",
-
- "OSF_URL": "OSF_URL",
- "OSF_API_URL": "OSF_API_URL",
- "OSF_RENDER_URL": "OSF_RENDER_URL",
- "OSF_FILE_URL": "OSF_FILE_URL",
- "OSF_HELP_URL": "OSF_HELP_URL",
-
- "OSF_COOKIE_LOGIN_URL": "OSF_COOKIE_LOGIN_URL",
- "OSF_OAUTH_URL": "OSF_OAUTH_URL"
-}
diff --git a/index.js b/index.js
index a874d8b99..40d67aaa6 100644
--- a/index.js
+++ b/index.js
@@ -9,6 +9,32 @@ var compileSass = require('broccoli-sass-source-maps');
// Fetch a list of known backends. The user can always choose to override any of these URLs via ENV vars
var knownBackends = require('./config/backends');
+
+// The following environment variables can always override any other settings. These key names should match local.yml options.
+const authEnvVars = ['OAUTH_SCOPES', 'REDIRECT_URI', 'CLIENT_ID', 'PERSONAL_ACCESS_TOKEN'];
+const backendUrlEnvVars = [
+ "OSF_URL", "OSF_API_URL", "OSF_RENDER_URL", "OSF_FILE_URL", "OSF_HELP_URL",
+ "OSF_COOKIE_LOGIN_URL", "OSF_OAUTH_URL"
+];
+const knownEnvVars = authEnvVars.concat(backendUrlEnvVars);
+
+/**
+ * @method getEnvConfig Fetch values of the selected environment variables
+ * @param env A dictionary representing environment variable configuration
+ * @param desiredKeys
+ */
+function getEnvConfig(env, desiredKeys) {
+ desiredKeys = desiredKeys || knownEnvVars;
+ var res = {};
+ desiredKeys.forEach(function(key) {
+ const val = env[key];
+ if (val) {
+ res[key] = val;
+ }
+ });
+ return res;
+}
+
module.exports = {
name: 'ember-osf',
blueprintsPath: function() {
@@ -17,56 +43,57 @@ module.exports = {
config: function(environment, ENV) {
let BACKEND = process.env.BACKEND || 'local';
// Settings required to configure the developer application, primarily for OAuth2
- let OAUTH_SETTINGS = {};
+ let oauthYmlSettings = {};
// Backwards compatibility: old config/*.yml files were nested, with keys like "stage", "test", etc.
// New files are flat- you specify the values you want once. If there is no key, assume
// this is a flat config file and assume the settings we want are at the top level.
- OAUTH_SETTINGS = config[BACKEND] || config;
+ oauthYmlSettings = config[BACKEND] || config;
// For i18n
ENV.i18n = {
defaultLocale: 'en-US'
};
+ const envConfig = getEnvConfig(process.env);
ENV.OSF = {
- clientId: OAUTH_SETTINGS.CLIENT_ID,
- scope: OAUTH_SETTINGS.OAUTH_SCOPES,
+ // TODO: make this respect envConfig!!
+ clientId: envConfig.CLIENT_ID || oauthYmlSettings.CLIENT_ID,
+ scope: envConfig.OAUTH_SCOPES || oauthYmlSettings.OAUTH_SCOPES,
apiNamespace: 'v2', // URL suffix (after host)
backend: BACKEND,
- redirectUri: OAUTH_SETTINGS.REDIRECT_URI
+ redirectUri: envConfig.REDIRECT_URI || oauthYmlSettings.REDIRECT_URI
};
// Fetch configuration information for the application
- var backendConfig = knownBackends[BACKEND] || {};
+ var backendUrlConfig = knownBackends[BACKEND] || {};
if (!Object.keys(knownBackends).includes(BACKEND)) {
console.warn('WARNING: You have specified an unknown backend environment. If you need to customize URL settings, specify BACKEND=env');
}
if (BACKEND === 'local') {
- backendConfig.accessToken = OAUTH_SETTINGS.PERSONAL_ACCESS_TOKEN;
- backendConfig.isLocal = true;
+ backendUrlConfig.accessToken = envConfig.PERSONAL_ACCESS_TOKEN || oauthYmlSettings.PERSONAL_ACCESS_TOKEN;
+ backendUrlConfig.isLocal = true;
} else if (BACKEND === 'prod') {
console.warn("WARNING: you've specified production as a backend. Please do not use production for testing or development purposes");
} else if (BACKEND === 'env') {
- // Optionally draw backend settings entirely from environment variables.
+ // Optionally draw backend URL settings entirely from environment variables.
// This is an all-or-nothing operation; we currently do not support overriding one URL at a time.
let newConfig = {};
- // Map the internal, old-style key names to the corresponding environment variables. All must be present.
- Object.keys(backendConfig).forEach(key => {
- const envEntryName = backendConfig[key];
- newConfig[key] = config[envEntryName];
+ // Map environment var names to internal config keys, eg {url: OSF_URL}. All keys must be present.
+ Object.keys(backendUrlConfig).forEach(key => {
+ const envEntryName = backendUrlConfig[key];
+ newConfig[key] = envConfig[envEntryName] || config[envEntryName];
});
- backendConfig = newConfig;
+ backendUrlConfig = newConfig;
}
-
// Warn the user if some URL entries not present
- Object.keys(backendConfig).forEach(key => {
- if (!backendConfig[key]) console.error(`This backend must define a value for: ${key}`);
+ Object.keys(backendUrlConfig).forEach(key => {
+ if (!backendUrlConfig[key]) console.error(`This backend must define a value for: ${key}`);
});
- // Combine URLs + auth settings into final auth config
- Object.assign(ENV.OSF, backendConfig);
+ // Combine URLs + auth settings into final auth config. Anything in an env var takes precedence
+ Object.assign(ENV.OSF, backendUrlConfig, envConfig);
ENV['ember-simple-auth'] = {
authorizer: 'authorizer:osf-token'
From 6bd5c7409ec2613a5a75df8d913d9366263d5487 Mon Sep 17 00:00:00 2001
From: Andy Boughton
Date: Tue, 31 Jan 2017 17:18:01 -0500
Subject: [PATCH 138/147] Simplify to use closure
[ci skip]
[#EOSF-452]
---
blueprints/ember-osf/files/config/_local.yml | 2 +-
index.js | 55 +++++++-------------
2 files changed, 19 insertions(+), 38 deletions(-)
diff --git a/blueprints/ember-osf/files/config/_local.yml b/blueprints/ember-osf/files/config/_local.yml
index 6999f5b18..a27a10cdc 100644
--- a/blueprints/ember-osf/files/config/_local.yml
+++ b/blueprints/ember-osf/files/config/_local.yml
@@ -15,7 +15,7 @@ PERSONAL_ACCESS_TOKEN: null
### In general, you can leave the items below commented out; ember-osf already knows how to talk to many common OSF
## backends. Only use the below if running against a new or custom OSF instance where you need to control the URLs.
-## These values will be ignored unless running with `BACKEND=env`.
+## These values WILL be ignored unless you explicitly specify `BACKEND=env`.
#OSF_URL: 'http://localhost:5000/'
#OSF_API_URL: 'http://localhost:8000'
#OSF_RENDER_URL: 'http://localhost:7778/render'
diff --git a/index.js b/index.js
index 40d67aaa6..15fa6181f 100644
--- a/index.js
+++ b/index.js
@@ -9,30 +9,12 @@ var compileSass = require('broccoli-sass-source-maps');
// Fetch a list of known backends. The user can always choose to override any of these URLs via ENV vars
var knownBackends = require('./config/backends');
-
-// The following environment variables can always override any other settings. These key names should match local.yml options.
-const authEnvVars = ['OAUTH_SCOPES', 'REDIRECT_URI', 'CLIENT_ID', 'PERSONAL_ACCESS_TOKEN'];
-const backendUrlEnvVars = [
- "OSF_URL", "OSF_API_URL", "OSF_RENDER_URL", "OSF_FILE_URL", "OSF_HELP_URL",
- "OSF_COOKIE_LOGIN_URL", "OSF_OAUTH_URL"
-];
-const knownEnvVars = authEnvVars.concat(backendUrlEnvVars);
-
-/**
- * @method getEnvConfig Fetch values of the selected environment variables
- * @param env A dictionary representing environment variable configuration
- * @param desiredKeys
- */
-function getEnvConfig(env, desiredKeys) {
- desiredKeys = desiredKeys || knownEnvVars;
- var res = {};
- desiredKeys.forEach(function(key) {
- const val = env[key];
- if (val) {
- res[key] = val;
- }
- });
- return res;
+// Shorthand closure to fetch a key from one of two places (environment vars or a specified object)
+function envOrSource(env, source) {
+ function getKey(keyName) {
+ return env[keyName] || source[keyName];
+ }
+ return getKey;
}
module.exports = {
@@ -43,25 +25,24 @@ module.exports = {
config: function(environment, ENV) {
let BACKEND = process.env.BACKEND || 'local';
// Settings required to configure the developer application, primarily for OAuth2
- let oauthYmlSettings = {};
+ let configFileSettings = {};
// Backwards compatibility: old config/*.yml files were nested, with keys like "stage", "test", etc.
// New files are flat- you specify the values you want once. If there is no key, assume
// this is a flat config file and assume the settings we want are at the top level.
- oauthYmlSettings = config[BACKEND] || config;
+ configFileSettings = config[BACKEND] || config;
// For i18n
ENV.i18n = {
defaultLocale: 'en-US'
};
- const envConfig = getEnvConfig(process.env);
+ const eitherConfig = envOrSource(process.env, configFileSettings);
ENV.OSF = {
- // TODO: make this respect envConfig!!
- clientId: envConfig.CLIENT_ID || oauthYmlSettings.CLIENT_ID,
- scope: envConfig.OAUTH_SCOPES || oauthYmlSettings.OAUTH_SCOPES,
+ clientId: eitherConfig('CLIENT_ID'),
+ scope: eitherConfig('OAUTH_SCOPES'),
apiNamespace: 'v2', // URL suffix (after host)
backend: BACKEND,
- redirectUri: envConfig.REDIRECT_URI || oauthYmlSettings.REDIRECT_URI
+ redirectUri: eitherConfig('REDIRECT_URI')
};
// Fetch configuration information for the application
@@ -72,7 +53,7 @@ module.exports = {
}
if (BACKEND === 'local') {
- backendUrlConfig.accessToken = envConfig.PERSONAL_ACCESS_TOKEN || oauthYmlSettings.PERSONAL_ACCESS_TOKEN;
+ backendUrlConfig.accessToken = eitherConfig('PERSONAL_ACCESS_TOKEN');
backendUrlConfig.isLocal = true;
} else if (BACKEND === 'prod') {
console.warn("WARNING: you've specified production as a backend. Please do not use production for testing or development purposes");
@@ -80,10 +61,10 @@ module.exports = {
// Optionally draw backend URL settings entirely from environment variables.
// This is an all-or-nothing operation; we currently do not support overriding one URL at a time.
let newConfig = {};
- // Map environment var names to internal config keys, eg {url: OSF_URL}. All keys must be present.
- Object.keys(backendUrlConfig).forEach(key => {
- const envEntryName = backendUrlConfig[key];
- newConfig[key] = envConfig[envEntryName] || config[envEntryName];
+ // Map internal config names to the corresponding env var names, eg {url: OSF_URL}. All keys must be present.
+ Object.keys(backendUrlConfig).forEach(internalName => {
+ const envVarName = backendUrlConfig[internalName];
+ newConfig[internalName] = eitherConfig(envVarName);
});
backendUrlConfig = newConfig;
}
@@ -93,7 +74,7 @@ module.exports = {
});
// Combine URLs + auth settings into final auth config. Anything in an env var takes precedence
- Object.assign(ENV.OSF, backendUrlConfig, envConfig);
+ Object.assign(ENV.OSF, backendUrlConfig);
ENV['ember-simple-auth'] = {
authorizer: 'authorizer:osf-token'
From b0c73c291a85efdb7ceb010646e82ed6241716f4 Mon Sep 17 00:00:00 2001
From: Andy Boughton
Date: Tue, 31 Jan 2017 17:39:15 -0500
Subject: [PATCH 139/147] Revert accidental change to yarn.lock
[ci skip]
[#EOSF-449]
---
yarn.lock | 4 ----
1 file changed, 4 deletions(-)
diff --git a/yarn.lock b/yarn.lock
index de4f1aa51..81e8dc1de 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1497,10 +1497,6 @@ dot-prop@^3.0.0:
dependencies:
is-obj "^1.0.0"
-dotenv@^4.0.0:
- version "4.0.0"
- resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-4.0.0.tgz#864ef1379aced55ce6f95debecdce179f7a0cd1d"
-
ecc-jsbn@~0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505"
From 027df5f924f204e4dd87d7a14bdf9cca935f7e28 Mon Sep 17 00:00:00 2001
From: Andy Boughton
Date: Wed, 1 Feb 2017 10:59:26 -0500
Subject: [PATCH 140/147] Improve README and comments
[#EOSF-449]
---
README.md | 3 +++
index.js | 8 ++++----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index d81c88cf7..713b05d84 100644
--- a/README.md
+++ b/README.md
@@ -87,6 +87,9 @@ environment variables with the same name as appears in the config file. Eg
If you provide a setting in both the config file and an environment variable, the environment variables take precedence.
+You can always override auth-related settings, but attempts to override server URLs will be ignored unless you
+explicitly specify `BACKEND=env` (see "Running" for example).
+
### Using the API
Most apps that use this addon will authorize requests via OAuth2. As may be apparent from the `CLIENT_ID` and
`REDIRECT_URI` settings above, you will need to [create a developer application](https://test.osf.io/settings/applications/)
diff --git a/index.js b/index.js
index 15fa6181f..31d53ac42 100644
--- a/index.js
+++ b/index.js
@@ -9,7 +9,7 @@ var compileSass = require('broccoli-sass-source-maps');
// Fetch a list of known backends. The user can always choose to override any of these URLs via ENV vars
var knownBackends = require('./config/backends');
-// Shorthand closure to fetch a key from one of two places (environment vars or a specified object)
+// Closure to fetch a key from one of two places (environment vars or a specified object). Env vars take precedence.
function envOrSource(env, source) {
function getKey(keyName) {
return env[keyName] || source[keyName];
@@ -59,9 +59,9 @@ module.exports = {
console.warn("WARNING: you've specified production as a backend. Please do not use production for testing or development purposes");
} else if (BACKEND === 'env') {
// Optionally draw backend URL settings entirely from environment variables.
- // This is an all-or-nothing operation; we currently do not support overriding one URL at a time.
+ // This is all or nothing: If you want to specify a custom backend, you must provide ALL URLs.
let newConfig = {};
- // Map internal config names to the corresponding env var names, eg {url: OSF_URL}. All keys must be present.
+ // Map internal config names to the corresponding env var names, eg {url: OSF_URL}. All keys must be present
Object.keys(backendUrlConfig).forEach(internalName => {
const envVarName = backendUrlConfig[internalName];
newConfig[internalName] = eitherConfig(envVarName);
@@ -73,7 +73,7 @@ module.exports = {
if (!backendUrlConfig[key]) console.error(`This backend must define a value for: ${key}`);
});
- // Combine URLs + auth settings into final auth config. Anything in an env var takes precedence
+ // Combine URLs + auth settings into final auth config
Object.assign(ENV.OSF, backendUrlConfig);
ENV['ember-simple-auth'] = {
From 89e8c030bce114ea27c79e7d23f2f335a5844bd4 Mon Sep 17 00:00:00 2001
From: Andy Boughton
Date: Thu, 2 Feb 2017 10:23:53 -0500
Subject: [PATCH 141/147] Add code coverage reporting
- Once conceptually approved, this will require a coordinated change to turn this repo on in coveralls.io ( @abought can flip the switch)
Presently this does not exclude the dummy app for addon tests, which may be a known issue. See
https://github.com/kategengler/ember-cli-code-coverage/issues/41
---
.travis.yml | 19 ++--
README.md | 3 +-
config/coverage.js | 8 ++
package.json | 5 +-
yarn.lock | 249 +++++++++++++++++++++++++++++++++++++++++----
5 files changed, 257 insertions(+), 27 deletions(-)
create mode 100644 config/coverage.js
diff --git a/.travis.yml b/.travis.yml
index 09e9427d4..eec2bf131 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,14 +10,17 @@ env:
cache:
yarn: true
directories:
- - node_modules
- - $HOME/.cache # includes bowers cache
+ - node_modules
+ - $HOME/.cache # includes bowers cache
install:
-- curl -o- -L https://yarnpkg.com/install.sh | bash
-- export PATH=$HOME/.yarn/bin:$PATH
-- yarn --prefer-offline --pure-lockfile
-- ./node_modules/bower/bin/bower install --config.interactive=false
+ - curl -o- -L https://yarnpkg.com/install.sh | bash
+ - export PATH=$HOME/.yarn/bin:$PATH
+ - yarn --prefer-offline --pure-lockfile
+ - ./node_modules/bower/bin/bower install --config.interactive=false
-script:
-- yarn test
+ script:
+ - yarn test:cover
+
+after_success:
+ - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
diff --git a/README.md b/README.md
index 8b6e6552f..4f24b16dd 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,8 @@
`master` Build Status: [![Build Status](https://travis-ci.org/CenterForOpenScience/ember-osf.svg?branch=master)](https://travis-ci.org/CenterForOpenScience/ember-osf)
-`develop` Build Status: [![Build Status](https://travis-ci.org/CenterForOpenScience/ember-osf.svg?branch=develop)](https://travis-ci.org/CenterForOpenScience/ember-osf)
+`develop` Build Status: [![Build Status](https://travis-ci.org/CenterForOpenScience/ember-osf.svg?branch=develop)](https://travis-ci.org/CenterForOpenScience/ember-osf)
+[![Coverage Status](https://coveralls.io/repos/github/CenterForOpenScience/ember-osf/badge.svg?branch=develop)](https://coveralls.io/github/CenterForOpenScience/ember-osf?branch=develop)
This repo contains code for interacting with the OSF APIv2 inside of an Ember app.
diff --git a/config/coverage.js b/config/coverage.js
new file mode 100644
index 000000000..0d2dde81b
--- /dev/null
+++ b/config/coverage.js
@@ -0,0 +1,8 @@
+'use strict';
+
+//See https://github.com/kategengler/ember-cli-code-coverage/issues/41
+module.exports = {
+ excludes: [
+ 'tests/dummy/**/*',
+ ]
+};
diff --git a/package.json b/package.json
index b507f5982..c76a86378 100644
--- a/package.json
+++ b/package.json
@@ -11,7 +11,8 @@
"docs": "yuidoc",
"start": "ember server",
"check-style": "./node_modules/jscs/bin/jscs .",
- "test": "yarn run check-style && ember test"
+ "test": "yarn run check-style && ember test",
+ "test:cover": "COVERAGE=true yarn test"
},
"repository": {
"type": "git",
@@ -26,6 +27,7 @@
"devDependencies": {
"broccoli-asset-rev": "^2.2.0",
"chalk": "^1.1.3",
+ "coveralls": "^2.11.15",
"ember-a11y": "0.1.8",
"ember-a11y-testing": "0.0.5",
"ember-ajax": "0.7.1",
@@ -33,6 +35,7 @@
"ember-cli": "^2.4.3",
"ember-cli-app-version": "^1.0.0",
"ember-cli-bootstrap-sassy": "0.5.3",
+ "ember-cli-code-coverage": "0.3.11",
"ember-cli-dependency-checker": "^1.2.0",
"ember-cli-inject-live-reload": "^1.3.1",
"ember-cli-mirage": "0.1.13",
diff --git a/yarn.lock b/yarn.lock
index 81e8dc1de..8b5c3cb81 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -6,7 +6,7 @@
version "4.0.2"
resolved "https://registry.yarnpkg.com/JSV/-/JSV-4.0.2.tgz#d077f6825571f82132f9dffaed587b4029feff57"
-abbrev@1, abbrev@~1.0.9:
+abbrev@1, abbrev@1.0.x, abbrev@~1.0.9:
version "1.0.9"
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.0.9.tgz#91b4792588a7738c25f35dd6f63752a2f8776135"
@@ -216,7 +216,7 @@ async@0.2.x, async@~0.2.6, async@~0.2.9:
version "0.2.10"
resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1"
-async@^1.4.0, async@^1.5.2:
+async@1.x, async@^1.4.0, async@^1.5.2:
version "1.5.2"
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"
@@ -238,7 +238,7 @@ aws4@^1.2.1:
version "1.5.0"
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.5.0.tgz#0a29ffb79c31c9e712eeb087e8e7a64b4a56d755"
-babel-core@^5.0.0:
+babel-core@^5.0.0, babel-core@^5.8.38:
version "5.8.38"
resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-5.8.38.tgz#1fcaee79d7e61b750b00b8e54f6dfc9d0af86558"
dependencies:
@@ -463,6 +463,21 @@ bluebird@^3.1.1, bluebird@^3.4.6:
version "3.4.7"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.4.7.tgz#f72d760be09b7f76d08ed8fae98b289a8d05fab3"
+body-parser@^1.15.0:
+ version "1.16.0"
+ resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.16.0.tgz#924a5e472c6229fb9d69b85a20d5f2532dec788b"
+ dependencies:
+ bytes "2.4.0"
+ content-type "~1.0.2"
+ debug "2.6.0"
+ depd "~1.1.0"
+ http-errors "~1.5.1"
+ iconv-lite "0.4.15"
+ on-finished "~2.3.0"
+ qs "6.2.1"
+ raw-body "~2.2.0"
+ type-is "~1.6.14"
+
body@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/body/-/body-5.1.0.tgz#e4ba0ce410a46936323367609ecb4e6553125069"
@@ -898,6 +913,10 @@ bytes@2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/bytes/-/bytes-2.3.0.tgz#d5b680a165b6201739acb611542aabc2d8ceb070"
+bytes@2.4.0:
+ version "2.4.0"
+ resolved "https://registry.yarnpkg.com/bytes/-/bytes-2.4.0.tgz#7d97196f9d5baf7f6935e25985549edd2a6c2339"
+
callsite@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/callsite/-/callsite-1.0.0.tgz#280398e5d664bd74038b6f0905153e6e8af1bc20"
@@ -1300,6 +1319,16 @@ core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
+coveralls@^2.11.15:
+ version "2.11.15"
+ resolved "https://registry.yarnpkg.com/coveralls/-/coveralls-2.11.15.tgz#37d3474369d66c14f33fa73a9d25cee6e099fca0"
+ dependencies:
+ js-yaml "3.6.1"
+ lcov-parse "0.0.10"
+ log-driver "1.2.5"
+ minimist "1.2.0"
+ request "2.75.0"
+
cross-spawn@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-3.0.1.tgz#1256037ecb9f0c5f79e3d6ef135e30770184b982"
@@ -1372,7 +1401,7 @@ debug@2.3.3:
dependencies:
ms "0.7.2"
-debug@^2.1.0, debug@^2.1.1, debug@^2.1.3, debug@^2.2.0:
+debug@2.6.0, debug@^2.1.0, debug@^2.1.1, debug@^2.1.3, debug@^2.2.0:
version "2.6.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.0.tgz#bc596bcabe7617f11d9fa15361eded5608b8499b"
dependencies:
@@ -1390,6 +1419,10 @@ deep-equal@*:
version "1.0.1"
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5"
+deep-is@~0.1.3:
+ version "0.1.3"
+ resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34"
+
defaults@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d"
@@ -1586,6 +1619,27 @@ ember-cli-broccoli-sane-watcher@^2.0.3:
rsvp "^3.0.18"
sane "^1.1.1"
+ember-cli-code-coverage@0.3.11:
+ version "0.3.11"
+ resolved "https://registry.yarnpkg.com/ember-cli-code-coverage/-/ember-cli-code-coverage-0.3.11.tgz#9012e14ec5d6ef27d7c6b89d4c8c22b5a49709be"
+ dependencies:
+ babel-core "^5.8.38"
+ body-parser "^1.15.0"
+ broccoli-filter "^1.2.3"
+ broccoli-funnel "^1.0.1"
+ broccoli-merge-trees "^1.1.1"
+ ember-cli-babel "^5.1.6"
+ escodegen "^1.8.0"
+ esprima "^2.7.2"
+ exists-sync "0.0.3"
+ extend "^3.0.0"
+ fs-extra "^0.26.7"
+ istanbul "^0.4.3"
+ node-dir "^0.1.16"
+ rsvp "^3.2.1"
+ source-map "0.5.6"
+ string.prototype.startswith "^0.2.0"
+
ember-cli-dependency-checker@^1.2.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/ember-cli-dependency-checker/-/ember-cli-dependency-checker-1.3.0.tgz#f0e8cb7f0f43c1e560494eaa9372804e7a088a2a"
@@ -2296,6 +2350,17 @@ escape-string-regexp@^1.0.0, escape-string-regexp@^1.0.2, escape-string-regexp@^
version "1.0.5"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
+escodegen@1.8.x, escodegen@^1.8.0:
+ version "1.8.1"
+ resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.8.1.tgz#5a5b53af4693110bebb0867aa3430dd3b70a1018"
+ dependencies:
+ esprima "^2.7.1"
+ estraverse "^1.9.1"
+ esutils "^2.0.2"
+ optionator "^0.8.1"
+ optionalDependencies:
+ source-map "~0.2.0"
+
esprima-fb@~12001.1.0-dev-harmony-fb:
version "12001.1.0-dev-harmony-fb"
resolved "https://registry.yarnpkg.com/esprima-fb/-/esprima-fb-12001.1.0-dev-harmony-fb.tgz#d84400384ba95ce2678c617ad24a7f40808da915"
@@ -2304,7 +2369,7 @@ esprima-fb@~15001.1001.0-dev-harmony-fb:
version "15001.1001.0-dev-harmony-fb"
resolved "https://registry.yarnpkg.com/esprima-fb/-/esprima-fb-15001.1001.0-dev-harmony-fb.tgz#43beb57ec26e8cf237d3dd8b33e42533577f2659"
-esprima@^2.6.0:
+esprima@2.7.x, esprima@^2.6.0, esprima@^2.7.1, esprima@^2.7.2:
version "2.7.3"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581"
@@ -2316,6 +2381,10 @@ esprima@~3.1.0:
version "3.1.3"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633"
+estraverse@^1.9.1:
+ version "1.9.3"
+ resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-1.9.3.tgz#af67f2dc922582415950926091a4005d29c9bb44"
+
estraverse@^4.1.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13"
@@ -2442,6 +2511,10 @@ eyes@0.1.x:
version "0.1.8"
resolved "https://registry.yarnpkg.com/eyes/-/eyes-0.1.8.tgz#62cf120234c683785d902348a800ef3e0cc20bc0"
+fast-levenshtein@~2.0.4:
+ version "2.0.6"
+ resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
+
fast-ordered-set@^1.0.0, fast-ordered-set@^1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/fast-ordered-set/-/fast-ordered-set-1.0.3.tgz#3fbb36634f7be79e4f7edbdb4a357dee25d184eb"
@@ -2574,6 +2647,14 @@ form-data@~1.0.0-rc4:
combined-stream "^1.0.5"
mime-types "^2.1.11"
+form-data@~2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.0.0.tgz#6f0aebadcc5da16c13e1ecc11137d85f9b883b25"
+ dependencies:
+ asynckit "^0.4.0"
+ combined-stream "^1.0.5"
+ mime-types "^2.1.11"
+
form-data@~2.1.1:
version "2.1.2"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.2.tgz#89c3534008b97eada4cbb157d58f6f5df025eae4"
@@ -2619,7 +2700,7 @@ fs-extra@^0.24.0:
path-is-absolute "^1.0.0"
rimraf "^2.2.8"
-fs-extra@^0.26.0:
+fs-extra@^0.26.0, fs-extra@^0.26.7:
version "0.26.7"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.26.7.tgz#9ae1fdd94897798edab76d0918cf42d0c3184fa9"
dependencies:
@@ -2871,7 +2952,7 @@ growly@^1.2.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081"
-handlebars@^4.0.4:
+handlebars@^4.0.1, handlebars@^4.0.4:
version "4.0.6"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.6.tgz#2ce4484850537f9c97a8026d5399b935c4ed4ed7"
dependencies:
@@ -2922,6 +3003,10 @@ has-cors@1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/has-cors/-/has-cors-1.1.0.tgz#5e474793f7ea9843d1bb99c23eef49ff126fff39"
+has-flag@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa"
+
has-unicode@^2.0.0, has-unicode@~2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9"
@@ -3005,7 +3090,7 @@ htmlparser2@3.8.3, htmlparser2@3.8.x:
entities "1.0"
readable-stream "1.1"
-http-errors@~1.5.0:
+http-errors@~1.5.0, http-errors@~1.5.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.5.1.tgz#788c0d2c1de2c81b9e6e8c01843b6b97eb920750"
dependencies:
@@ -3032,7 +3117,7 @@ i@0.3.x:
version "0.3.5"
resolved "https://registry.yarnpkg.com/i/-/i-0.3.5.tgz#1d2b854158ec8169113c6cb7f6b6801e99e211d5"
-iconv-lite@^0.4.5, iconv-lite@~0.4.13:
+iconv-lite@0.4.15, iconv-lite@^0.4.5, iconv-lite@~0.4.13:
version "0.4.15"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.15.tgz#fe265a218ac6a57cfe854927e9d04c19825eddeb"
@@ -3282,6 +3367,25 @@ isstream@0.1.x, isstream@~0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
+istanbul@^0.4.3:
+ version "0.4.5"
+ resolved "https://registry.yarnpkg.com/istanbul/-/istanbul-0.4.5.tgz#65c7d73d4c4da84d4f3ac310b918fb0b8033733b"
+ dependencies:
+ abbrev "1.0.x"
+ async "1.x"
+ escodegen "1.8.x"
+ esprima "2.7.x"
+ glob "^5.0.15"
+ handlebars "^4.0.1"
+ js-yaml "3.x"
+ mkdirp "0.5.x"
+ nopt "3.x"
+ once "1.x"
+ resolve "1.1.x"
+ supports-color "^3.1.0"
+ which "^1.1.1"
+ wordwrap "^1.0.0"
+
istextorbinary@2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/istextorbinary/-/istextorbinary-2.1.0.tgz#dbed2a6f51be2f7475b68f89465811141b758874"
@@ -3308,7 +3412,14 @@ js-tokens@1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-1.0.1.tgz#cc435a5c8b94ad15acb7983140fc80182c89aeae"
-js-yaml@^3.2.5, js-yaml@^3.2.7, js-yaml@^3.6.0, js-yaml@^3.6.1:
+js-yaml@3.6.1:
+ version "3.6.1"
+ resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.6.1.tgz#6e5fe67d8b205ce4d22fad05b7781e8dadcc4b30"
+ dependencies:
+ argparse "^1.0.7"
+ esprima "^2.6.0"
+
+js-yaml@3.x, js-yaml@^3.2.5, js-yaml@^3.2.7, js-yaml@^3.6.0, js-yaml@^3.6.1:
version "3.7.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.7.0.tgz#5c967ddd837a9bfdca5f2de84253abe8a1c03b80"
dependencies:
@@ -3483,6 +3594,10 @@ lcid@^1.0.0:
dependencies:
invert-kv "^1.0.0"
+lcov-parse@0.0.10:
+ version "0.0.10"
+ resolved "https://registry.yarnpkg.com/lcov-parse/-/lcov-parse-0.0.10.tgz#1b0b8ff9ac9c7889250582b70b71315d9da6d9a3"
+
leek@0.0.23:
version "0.0.23"
resolved "https://registry.yarnpkg.com/leek/-/leek-0.0.23.tgz#d44b9f55b27e22902a6603eaeec193f0c301d25f"
@@ -3495,6 +3610,13 @@ leven@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/leven/-/leven-1.0.2.tgz#9144b6eebca5f1d0680169f1a6770dcea60b75c3"
+levn@~0.3.0:
+ version "0.3.0"
+ resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee"
+ dependencies:
+ prelude-ls "~1.1.2"
+ type-check "~0.3.2"
+
linkify-it@^2.0.0:
version "2.0.3"
resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-2.0.3.tgz#d94a4648f9b1c179d64fa97291268bdb6ce9434f"
@@ -3779,6 +3901,10 @@ lodash@~4.16.4:
version "4.16.6"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.16.6.tgz#d22c9ac660288f3843e16ba7d2b5d06cca27d777"
+log-driver@1.2.5:
+ version "1.2.5"
+ resolved "https://registry.yarnpkg.com/log-driver/-/log-driver-1.2.5.tgz#7ae4ec257302fd790d557cb10c97100d857b0056"
+
lolex@1.3.2:
version "1.3.2"
resolved "https://registry.yarnpkg.com/lolex/-/lolex-1.3.2.tgz#7c3da62ffcb30f0f5a80a2566ca24e45d8a01f31"
@@ -3964,7 +4090,7 @@ minimist@0.0.8, minimist@~0.0.1:
version "0.0.8"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
-minimist@^1.1.0, minimist@^1.1.1, minimist@^1.1.3:
+minimist@1.2.0, minimist@^1.1.0, minimist@^1.1.1, minimist@^1.1.3:
version "1.2.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
@@ -4056,6 +4182,12 @@ negotiator@0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9"
+node-dir@^0.1.16:
+ version "0.1.16"
+ resolved "https://registry.yarnpkg.com/node-dir/-/node-dir-0.1.16.tgz#d2ef583aa50b90d93db8cdd26fcea58353957fe4"
+ dependencies:
+ minimatch "^3.0.2"
+
node-emoji@^1.4.1:
version "1.5.0"
resolved "https://registry.yarnpkg.com/node-emoji/-/node-emoji-1.5.0.tgz#9a0d9fe03fd43afa357d6d8e439aa31e599959b7"
@@ -4158,7 +4290,7 @@ node-uuid@^1.4.3, node-uuid@~1.4.7:
chalk "~0.4.0"
underscore "~1.6.0"
-"nopt@2 || 3", nopt@^3.0.1, nopt@^3.0.3, nopt@~3.0.6:
+"nopt@2 || 3", nopt@3.x, nopt@^3.0.1, nopt@^3.0.3, nopt@~3.0.6:
version "3.0.6"
resolved "https://registry.yarnpkg.com/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9"
dependencies:
@@ -4353,7 +4485,7 @@ on-headers@~1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/on-headers/-/on-headers-1.0.1.tgz#928f5d0f470d49342651ea6794b0857c100693f7"
-once@^1.3.0, once@^1.3.3, once@~1.4.0:
+once@1.x, once@^1.3.0, once@^1.3.3, once@~1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
dependencies:
@@ -4374,6 +4506,17 @@ optimist@^0.6.1:
minimist "~0.0.1"
wordwrap "~0.0.2"
+optionator@^0.8.1:
+ version "0.8.2"
+ resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64"
+ dependencies:
+ deep-is "~0.1.3"
+ fast-levenshtein "~2.0.4"
+ levn "~0.3.0"
+ prelude-ls "~1.1.2"
+ type-check "~0.3.2"
+ wordwrap "~1.0.0"
+
options@>=0.0.5:
version "0.0.6"
resolved "https://registry.yarnpkg.com/options/-/options-0.0.6.tgz#ec22d312806bb53e731773e7cdaefcf1c643128f"
@@ -4553,6 +4696,10 @@ portfinder@^1.0.7:
debug "^2.2.0"
mkdirp "0.5.x"
+prelude-ls@~1.1.2:
+ version "1.1.2"
+ resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
+
preserve@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
@@ -4628,6 +4775,10 @@ qs@6.2.0, qs@^6.2.0, qs@~6.2.0:
version "6.2.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.2.0.tgz#3b7848c03c2dece69a9522b0fae8c4126d745f3b"
+qs@6.2.1:
+ version "6.2.1"
+ resolved "https://registry.yarnpkg.com/qs/-/qs-6.2.1.tgz#ce03c5ff0935bc1d9d69a9f14cbd18e568d67625"
+
qs@~6.3.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.3.0.tgz#f403b264f23bc01228c74131b407f18d5ea5d442"
@@ -4662,6 +4813,14 @@ raw-body@~1.1.0:
bytes "1"
string_decoder "0.10"
+raw-body@~2.2.0:
+ version "2.2.0"
+ resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.2.0.tgz#994976cf6a5096a41162840492f0bdc5d6e7fb96"
+ dependencies:
+ bytes "2.4.0"
+ iconv-lite "0.4.15"
+ unpipe "1.0.0"
+
read-cmd-shim@~1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/read-cmd-shim/-/read-cmd-shim-1.0.1.tgz#2d5d157786a37c055d22077c32c53f8329e91c7b"
@@ -4925,6 +5084,32 @@ request@2, request@^2.61.0, request@^2.74.0, request@~2.79.0:
tunnel-agent "~0.4.1"
uuid "^3.0.0"
+request@2.75.0:
+ version "2.75.0"
+ resolved "https://registry.yarnpkg.com/request/-/request-2.75.0.tgz#d2b8268a286da13eaa5d01adf5d18cc90f657d93"
+ dependencies:
+ aws-sign2 "~0.6.0"
+ aws4 "^1.2.1"
+ bl "~1.1.2"
+ caseless "~0.11.0"
+ combined-stream "~1.0.5"
+ extend "~3.0.0"
+ forever-agent "~0.6.1"
+ form-data "~2.0.0"
+ har-validator "~2.0.6"
+ hawk "~3.1.3"
+ http-signature "~1.1.0"
+ is-typedarray "~1.0.0"
+ isstream "~0.1.2"
+ json-stringify-safe "~5.0.1"
+ mime-types "~2.1.7"
+ node-uuid "~1.4.7"
+ oauth-sign "~0.8.1"
+ qs "~6.2.0"
+ stringstream "~0.0.4"
+ tough-cookie "~2.3.0"
+ tunnel-agent "~0.4.1"
+
request@~2.74.0:
version "2.74.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.74.0.tgz#7693ca768bbb0ea5c8ce08c084a45efa05b892ab"
@@ -4974,6 +5159,10 @@ resolve-dir@^0.1.0:
expand-tilde "^1.2.2"
global-modules "^0.2.3"
+resolve@1.1.x:
+ version "1.1.7"
+ resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
+
resolve@^1.1.2, resolve@^1.1.6, resolve@^1.1.7:
version "1.2.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.2.0.tgz#9589c3f2f6149d1417a40becc1663db6ec6bc26c"
@@ -5254,10 +5443,16 @@ source-map@0.4.x, source-map@^0.4.2, source-map@^0.4.4:
dependencies:
amdefine ">=0.0.4"
-source-map@^0.5.0, source-map@^0.5.3, source-map@~0.5.0, source-map@~0.5.1:
+source-map@0.5.6, source-map@^0.5.0, source-map@^0.5.3, source-map@~0.5.0, source-map@~0.5.1:
version "0.5.6"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412"
+source-map@~0.2.0:
+ version "0.2.0"
+ resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.2.0.tgz#dab73fbcfc2ba819b4de03bd6f6eaa48164b3f9d"
+ dependencies:
+ amdefine ">=0.0.4"
+
spawn-args@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/spawn-args/-/spawn-args-0.2.0.tgz#fb7d0bd1d70fd4316bd9e3dec389e65f9d6361bb"
@@ -5338,6 +5533,10 @@ string.prototype.codepointat@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/string.prototype.codepointat/-/string.prototype.codepointat-0.2.0.tgz#6b26e9bd3afcaa7be3b4269b526de1b82000ac78"
+string.prototype.startswith@^0.2.0:
+ version "0.2.0"
+ resolved "https://registry.yarnpkg.com/string.prototype.startswith/-/string.prototype.startswith-0.2.0.tgz#da68982e353a4e9ac4a43b450a2045d1c445ae7b"
+
string_decoder@0.10, string_decoder@~0.10.x:
version "0.10.31"
resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94"
@@ -5404,6 +5603,12 @@ supports-color@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
+supports-color@^3.1.0:
+ version "3.2.3"
+ resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6"
+ dependencies:
+ has-flag "^1.0.0"
+
symlink-or-copy@^1.0.0, symlink-or-copy@^1.0.1, symlink-or-copy@^1.1.8:
version "1.1.8"
resolved "https://registry.yarnpkg.com/symlink-or-copy/-/symlink-or-copy-1.1.8.tgz#cabe61e0010c1c023c173b25ee5108b37f4b4aa3"
@@ -5565,7 +5770,13 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0:
version "0.14.5"
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"
-type-is@~1.6.13:
+type-check@~0.3.2:
+ version "0.3.2"
+ resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72"
+ dependencies:
+ prelude-ls "~1.1.2"
+
+type-is@~1.6.13, type-is@~1.6.14:
version "1.6.14"
resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.14.tgz#e219639c17ded1ca0789092dd54a03826b817cb2"
dependencies:
@@ -5629,7 +5840,7 @@ unique-slug@^2.0.0:
dependencies:
imurmurhash "^0.1.4"
-unpipe@~1.0.0:
+unpipe@1.0.0, unpipe@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"
@@ -5770,7 +5981,7 @@ which-module@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/which-module/-/which-module-1.0.0.tgz#bba63ca861948994ff307736089e3b96026c2a4f"
-which@1, which@^1.0.5, which@^1.2.12, which@^1.2.9, which@~1.2.10, which@~1.2.11:
+which@1, which@^1.0.5, which@^1.1.1, which@^1.2.12, which@^1.2.9, which@~1.2.10, which@~1.2.11:
version "1.2.12"
resolved "https://registry.yarnpkg.com/which/-/which-1.2.12.tgz#de67b5e450269f194909ef23ece4ebe416fa1192"
dependencies:
@@ -5810,6 +6021,10 @@ wordwrap@0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f"
+wordwrap@^1.0.0, wordwrap@~1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
+
wordwrap@~0.0.2:
version "0.0.3"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107"
From ff7e9d8d701908e4b6939dc00abb9a15028305ba Mon Sep 17 00:00:00 2001
From: Andy Boughton
Date: Thu, 2 Feb 2017 10:35:03 -0500
Subject: [PATCH 142/147] Fix YML syntax error.
---
.travis.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index eec2bf131..e0a8f8016 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,7 +5,7 @@ dist: trusty
env:
global:
- - SUPPRESS_NO_CONFIG_WARNING=true
+ - SUPPRESS_NO_CONFIG_WARNING=true
cache:
yarn: true
@@ -19,7 +19,7 @@ install:
- yarn --prefer-offline --pure-lockfile
- ./node_modules/bower/bin/bower install --config.interactive=false
- script:
+script:
- yarn test:cover
after_success:
From 85c4780c048da1e382153fe2291f7b223f815771 Mon Sep 17 00:00:00 2001
From: Andy Boughton
Date: Thu, 2 Feb 2017 11:31:05 -0500
Subject: [PATCH 143/147] Update license metadata and release docs
---
.npmignore | 2 ++
README.md | 15 +++++++++++++++
package.json | 4 ++--
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/.npmignore b/.npmignore
index 8aa239e0e..d0baa52e0 100644
--- a/.npmignore
+++ b/.npmignore
@@ -1,6 +1,8 @@
/bower_components
+/config/coverage.js
/config/ember-try.js
/config/*.yml
+/coverage
/dist
/docs
/.github
diff --git a/README.md b/README.md
index 8b6e6552f..d30f501de 100644
--- a/README.md
+++ b/README.md
@@ -116,3 +116,18 @@ and visit your app at http://localhost:4200.
* `yarn run build`
For more information on using ember-cli, visit [http://www.ember-cli.com/](http://www.ember-cli.com/).
+
+## Distribution / releases
+The information below applies only to package maintainers, and most users will not need this.
+
+The following commands can be used to publish a new release of `ember-osf`:
+
+- `yarn run bump-version [ | major | minor | patch]`: Verify that the code is in a releasable state,
+increment the version number without generating a new git commit, and update documentation.
+See [docs](https://docs.npmjs.com/cli/version) for recognized options.
+- `yarn run make-release`: Uses [git flow](https://github.com/nvie/gitflow) to prepare a new release.
+You must be on the develop branch, commit all changes, and have run `git init` in this folder at least one time (ever).
+- `yarn publish`: [Publish](https://docs.npmjs.com/getting-started/publishing-npm-packages) a new version of the
+package to the NPM registry. It is highly recommended that you do this from a fresh checkout of the repo, and
+[validate](https://docs.npmjs.com/misc/developers#before-publishing-make-sure-your-package-installs-and-works)
+the package contents before uploading. You must be a recognized NPM collaborator or this command will fail.
diff --git a/package.json b/package.json
index 5e0dd204a..eaa53b86b 100644
--- a/package.json
+++ b/package.json
@@ -3,7 +3,7 @@
"version": "0.2.0",
"description": "Reusable ember models and components for interacting with the Open Science Framework",
"directories": {
- "doc": "doc",
+ "doc": "docs",
"test": "tests"
},
"scripts": {
@@ -26,7 +26,7 @@
"node": ">=6"
},
"author": "Center for Open Science",
- "license": "MIT",
+ "license": "Apache-2.0",
"devDependencies": {
"broccoli-asset-rev": "^2.2.0",
"chalk": "^1.1.3",
From cacc8ffb2d045efd0f9451dc4c15f22f1cfe7803 Mon Sep 17 00:00:00 2001
From: Andy Boughton
Date: Thu, 2 Feb 2017 12:00:01 -0500
Subject: [PATCH 144/147] Update yarn.lock with added dependency
---
yarn.lock | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/yarn.lock b/yarn.lock
index 81e8dc1de..bb467b71c 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2760,6 +2760,12 @@ getpass@^0.1.1:
dependencies:
assert-plus "^1.0.0"
+git-branch-is@^0.1.0:
+ version "0.1.0"
+ resolved "https://registry.yarnpkg.com/git-branch-is/-/git-branch-is-0.1.0.tgz#bef5a6113a30f4007e7c002f9ba4cf37925c171f"
+ dependencies:
+ commander "^2.9.0"
+
git-repo-info@^1.0.4, git-repo-info@^1.1.2:
version "1.4.0"
resolved "https://registry.yarnpkg.com/git-repo-info/-/git-repo-info-1.4.0.tgz#ed210221defd3fdefce8b16ac61985cabe242e4a"
From 6627dbefd88fbefdc176a3ae300c45347b2cfd5c Mon Sep 17 00:00:00 2001
From: Andy Boughton
Date: Fri, 3 Feb 2017 14:28:27 -0500
Subject: [PATCH 145/147] Add fixString helper that makes bad server data look
human readable [EOSF-452] (#167)
* Add fix-special-char util to ember-osf
Ticket ID:EOSF-202
* Fix the test
* fix the test
* Add fixString helper that makes bad server data look human readable
Similar to temp_ampersand_fixer in mako, and centralizes what would otherwise be one-off fixes in every ember template
Deliberately exempt filePath and URL fields from use of this helper. If we regret this choice, we can apply the filter to those fields later.
[#EOSF-452]
* Update documentation to include new fixstring helper, and address data.json `warnings` items
[#EOSF-452]
* Fix two failing tests that needed transform.
[#EOSF-452]
* Add fixSpecialCharHelper.
Add tests for the new helper.
Update current tests for util function fixSpecialChar
* Adjust indentation
* Update path
* Fix field definition
Many current usages (eg preprints) already defaulted to assuming it was a list, or used methods (indexOf, includes) that are on both strongs and lists.
[ci skip]
[#EOSF-452]
* Rename helper to shorter form. Confirmed it does not collide with utility function.
[ci skip]
[#EOSF-452]
* Use util & inherit from DS.StringTransform to DRY edge case logic
[ci skip]
[#EOSF-452]
* Add docstrings for new helpers
[ci skip]
[#EOSF-452]
* Revert "Update documentation to include new fixstring helper, and address data.json `warnings` items"
Will update docs in a separate commit; as scope increased this PR got very noisy.
This reverts commit d6996b8f232a113990eee04a7d4ae5afbf2821d2.
* Resolve YUIDoc data.json errors and ensure docs build
[#EOSF-452]
* DRY unit tests by centralizing fixtures
[#EOSF-452]
---
LICENSE | 2 +-
addon/adapters/osf-adapter.js | 2 ++
addon/const/permissions.js | 13 +++++++--
addon/helpers/fix-special-char.js | 19 +++++++++++++
addon/models/collection.js | 2 +-
addon/models/comment-report.js | 2 +-
addon/models/comment.js | 8 +++---
addon/models/contributor.js | 8 +++---
addon/models/draft-registration.js | 2 +-
addon/models/file-provider.js | 6 ++---
addon/models/file-version.js | 2 +-
addon/models/file.js | 10 +++----
addon/models/institution.js | 4 +--
addon/models/license.js | 4 +--
addon/models/log.js | 2 +-
addon/models/metaschema.js | 2 +-
addon/models/node.js | 13 ++++-----
addon/models/preprint-provider.js | 18 ++++++-------
addon/models/preprint.js | 4 +--
addon/models/registration.js | 8 +++---
addon/models/taxonomy.js | 2 +-
addon/models/user.js | 8 +++---
addon/transforms/fixstring.js | 30 +++++++++++++++++++++
addon/utils/fix-special-char.js | 23 ++++++++++++++++
app/helpers/fix-special-char.js | 1 +
app/transforms/fixstring.js | 1 +
app/utils/fix-special-char.js | 1 +
tests/fixtures/specialChars.js | 10 +++++++
tests/unit/adapters/osf-adapter-test.js | 2 +-
tests/unit/helpers/fix-special-char-test.js | 16 +++++++++++
tests/unit/services/file-manager-test.js | 2 +-
tests/unit/transforms/fixstring-test.js | 30 +++++++++++++++++++++
tests/unit/utils/fix-special-char-test.js | 16 +++++++++++
33 files changed, 216 insertions(+), 57 deletions(-)
create mode 100644 addon/helpers/fix-special-char.js
create mode 100644 addon/transforms/fixstring.js
create mode 100644 addon/utils/fix-special-char.js
create mode 100644 app/helpers/fix-special-char.js
create mode 100644 app/transforms/fixstring.js
create mode 100644 app/utils/fix-special-char.js
create mode 100644 tests/fixtures/specialChars.js
create mode 100644 tests/unit/helpers/fix-special-char-test.js
create mode 100644 tests/unit/transforms/fixstring-test.js
create mode 100644 tests/unit/utils/fix-special-char-test.js
diff --git a/LICENSE b/LICENSE
index 186e2e98a..9a8147fd9 100644
--- a/LICENSE
+++ b/LICENSE
@@ -187,7 +187,7 @@ APPENDIX: How to apply the Apache License to your work.
same "printed page" as the copyright notice for easier
identification within third-party archives.
-Copyright 2013-2016 Center for Open Science
+Copyright 2013-2017 Center for Open Science
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/addon/adapters/osf-adapter.js b/addon/adapters/osf-adapter.js
index d52ca61f8..0c05a8d78 100644
--- a/addon/adapters/osf-adapter.js
+++ b/addon/adapters/osf-adapter.js
@@ -34,6 +34,8 @@ export default DS.JSONAPIAdapter.extend(HasManyQuery.RESTAdapterMixin, GenericDa
* OSF APIv2 does not have "include" functionality, instead we use 'embed'.
* Usage: findRecord(type, id, {include: 'resource'}) or findRecord(type, id, {include: ['resource1', resource2]})
* Swaps included resources with embedded resources
+ *
+ * @method buildQuery
*/
buildQuery() {
let query = this._super(...arguments);
diff --git a/addon/const/permissions.js b/addon/const/permissions.js
index d2b0be78e..d14cbf4dc 100644
--- a/addon/const/permissions.js
+++ b/addon/const/permissions.js
@@ -2,14 +2,23 @@ var ADMIN = 'admin';
var READ = 'read';
var WRITE = 'write';
+/**
+ * @module ember-osf
+ * @submodule const
+ */
+
+/**
+ * @class permissions
+ */
+
/**
* Provide human-readable labels for permissions fields. Useful in dropdown UI.
* @property permissionSelector
* @final
- * @type {*[]}
+ * @type {Object[]}
*/
// TODO: Document constants in YUIDoc format
-let permissionSelector = [
+const permissionSelector = [
{ value: READ, text: 'Read' },
{ value: WRITE, text: 'Read + Write' },
{ value: ADMIN, text: 'Administrator' }
diff --git a/addon/helpers/fix-special-char.js b/addon/helpers/fix-special-char.js
new file mode 100644
index 000000000..a96f50e21
--- /dev/null
+++ b/addon/helpers/fix-special-char.js
@@ -0,0 +1,19 @@
+import Ember from 'ember';
+import fixSpecialChar from '../utils/fix-special-char';
+
+/**
+ Apply the `fix-special-char` utility function to clean up malformed text sent from the server.
+
+ Usage example:
+ ```handlebars
+ This is text we want to fix: {{fix-special-char 'Now & then'}}
+ ```
+
+ @class fix-special-char-helper
+ @uses fix-special-char
+ */
+export function fixSpecialCharHelper(params/*, hash*/) {
+ return params ? fixSpecialChar(params[0]) : params;
+}
+
+export default Ember.Helper.helper(fixSpecialCharHelper);
diff --git a/addon/models/collection.js b/addon/models/collection.js
index 3b775ff5c..c74dadebc 100644
--- a/addon/models/collection.js
+++ b/addon/models/collection.js
@@ -15,7 +15,7 @@ import OsfModel from './osf-model';
* @class Collection
*/
export default OsfModel.extend({
- title: DS.attr('string'),
+ title: DS.attr('fixstring'),
dateCreated: DS.attr('date'),
dateModified: DS.attr('date'),
bookmarks: DS.attr('boolean'),
diff --git a/addon/models/comment-report.js b/addon/models/comment-report.js
index dea5a5466..f20cc2a14 100644
--- a/addon/models/comment-report.js
+++ b/addon/models/comment-report.js
@@ -15,6 +15,6 @@ import OsfModel from './osf-model';
* @class CommentReport
*/
export default OsfModel.extend({
- category: DS.attr('string'),
+ category: DS.attr('fixstring'),
text: DS.belongsTo('comment')
});
diff --git a/addon/models/comment.js b/addon/models/comment.js
index 790a7baf3..ed3619bf0 100644
--- a/addon/models/comment.js
+++ b/addon/models/comment.js
@@ -19,13 +19,13 @@ import OsfModel from './osf-model';
*/
export default OsfModel.extend({
// TODO validation: maxLength
- content: DS.attr('string'),
- page: DS.attr('string'),
+ content: DS.attr('fixstring'),
+ page: DS.attr('fixstring'),
// Placeholder for comment creation: allow specifying attributes that are sent to the server, but not as attributes
// Both type and ID will be serialized into relationships field
- targetID: DS.attr('string'),
- targetType: DS.attr('string'),
+ targetID: DS.attr('fixstring'),
+ targetType: DS.attr('fixstring'),
// TODO dynamic belongsTo
user: DS.belongsTo('user'),
diff --git a/addon/models/contributor.js b/addon/models/contributor.js
index 6f3327bc1..d836c28bd 100644
--- a/addon/models/contributor.js
+++ b/addon/models/contributor.js
@@ -16,7 +16,7 @@ import OsfModel from './osf-model';
*/
export default OsfModel.extend({
bibliographic: DS.attr('boolean'),
- permission: DS.attr('string'),
+ permission: DS.attr('fixstring'),
_userId: null,
userId: Ember.computed('_userId', {
@@ -46,10 +46,10 @@ export default OsfModel.extend({
}).volatile(),
users: DS.belongsTo('user'),
- unregisteredContributor: DS.attr('string'),
+ unregisteredContributor: DS.attr('fixstring'),
index: DS.attr('number'),
- fullName: DS.attr('string'),
- email: DS.attr('string'),
+ fullName: DS.attr('fixstring'),
+ email: DS.attr('fixstring'),
sendEmail: DS.attr('boolean'),
node: DS.belongsTo('node', {
diff --git a/addon/models/draft-registration.js b/addon/models/draft-registration.js
index 67c2eb408..715b66d73 100644
--- a/addon/models/draft-registration.js
+++ b/addon/models/draft-registration.js
@@ -15,7 +15,7 @@ import OsfModel from './osf-model';
* @class DraftRegistration
*/
export default OsfModel.extend({
- registrationSupplement: DS.attr('string'),
+ registrationSupplement: DS.attr('fixstring'),
registrationMetadata: DS.attr(),
datetimeInitiated: DS.attr('date'),
datetimeUpdated: DS.attr('date'),
diff --git a/addon/models/file-provider.js b/addon/models/file-provider.js
index 35cd92b13..69f73d2e5 100644
--- a/addon/models/file-provider.js
+++ b/addon/models/file-provider.js
@@ -20,10 +20,10 @@ import FileItemMixin from 'ember-osf/mixins/file-item';
export default OsfModel.extend(FileItemMixin, {
isProvider: true,
- name: DS.attr('string'),
- kind: DS.attr('string'),
+ name: DS.attr('fixstring'),
+ kind: DS.attr('fixstring'),
path: DS.attr('string'),
- provider: DS.attr('string'),
+ provider: DS.attr('fixstring'),
files: DS.hasMany('file'),
node: DS.belongsTo('node')
});
diff --git a/addon/models/file-version.js b/addon/models/file-version.js
index 050599413..b483b7ce2 100644
--- a/addon/models/file-version.js
+++ b/addon/models/file-version.js
@@ -17,5 +17,5 @@ import OsfModel from './osf-model';
*/
export default OsfModel.extend({
size: DS.attr('number'),
- contentType: DS.attr('string')
+ contentType: DS.attr('fixstring')
});
diff --git a/addon/models/file.js b/addon/models/file.js
index 8fa990d6d..b71fb964f 100644
--- a/addon/models/file.js
+++ b/addon/models/file.js
@@ -23,13 +23,13 @@ import FileItemMixin from 'ember-osf/mixins/file-item';
export default OsfModel.extend(FileItemMixin, {
_isFileModel: true,
- name: DS.attr('string'),
- kind: DS.attr('string'),
- guid: DS.attr('string'),
+ name: DS.attr('fixstring'),
+ kind: DS.attr('fixstring'),
+ guid: DS.attr('fixstring'),
path: DS.attr('string'),
size: DS.attr('number'),
currentVersion: DS.attr('number'),
- provider: DS.attr('string'),
+ provider: DS.attr('fixstring'),
materializedPath: DS.attr('string'),
lastTouched: DS.attr('date'),
dateModified: DS.attr('date'),
@@ -46,5 +46,5 @@ export default OsfModel.extend(FileItemMixin, {
versions: DS.hasMany('file-version'),
comments: DS.hasMany('comment'),
node: DS.belongsTo('node'), // TODO: In the future apiv2 may also need to support this pointing at nodes OR registrations
- checkout: DS.attr('string')
+ checkout: DS.attr('fixstring')
});
diff --git a/addon/models/institution.js b/addon/models/institution.js
index 744cf95a9..fce1fea42 100644
--- a/addon/models/institution.js
+++ b/addon/models/institution.js
@@ -19,8 +19,8 @@ import OsfModel from './osf-model';
* @class Institution
*/
export default OsfModel.extend({
- name: DS.attr('string'),
- description: DS.attr('string'),
+ name: DS.attr('fixstring'),
+ description: DS.attr('fixstring'),
logoPath: DS.attr('string'),
authUrl: DS.attr('string'),
diff --git a/addon/models/license.js b/addon/models/license.js
index 703139b29..89edbac72 100644
--- a/addon/models/license.js
+++ b/addon/models/license.js
@@ -3,7 +3,7 @@ import DS from 'ember-data';
import OsfModel from './osf-model';
export default OsfModel.extend({
- name: DS.attr('string'),
- text: DS.attr('string'),
+ name: DS.attr('fixstring'),
+ text: DS.attr('fixstring'),
requiredFields: DS.attr()
});
diff --git a/addon/models/log.js b/addon/models/log.js
index 51dbf6046..55176ccf8 100644
--- a/addon/models/log.js
+++ b/addon/models/log.js
@@ -18,7 +18,7 @@ import OsfModel from './osf-model';
*/
export default OsfModel.extend({
date: DS.attr('date'),
- action: DS.attr('string'),
+ action: DS.attr('fixstring'),
params: DS.attr(),
node: DS.belongsTo('node', {
inverse: null
diff --git a/addon/models/metaschema.js b/addon/models/metaschema.js
index 161ed39ae..9e9e20e20 100644
--- a/addon/models/metaschema.js
+++ b/addon/models/metaschema.js
@@ -17,7 +17,7 @@ import OsfModel from './osf-model';
*/
export default OsfModel.extend({
- name: DS.attr('string'),
+ name: DS.attr('fixstring'),
schemaVersion: DS.attr('number'),
schema: DS.attr()
});
diff --git a/addon/models/node.js b/addon/models/node.js
index c9dd5ee0d..ccdb6a802 100644
--- a/addon/models/node.js
+++ b/addon/models/node.js
@@ -24,11 +24,12 @@ import FileItemMixin from 'ember-osf/mixins/file-item';
export default OsfModel.extend(FileItemMixin, {
isNode: true,
- title: DS.attr('string'),
- description: DS.attr('string'),
- category: DS.attr('string'),
+ title: DS.attr('fixstring'),
+ description: DS.attr('fixstring'),
+ category: DS.attr('fixstring'),
- currentUserPermissions: DS.attr('string'),
+ // List of strings
+ currentUserPermissions: DS.attr(),
fork: DS.attr('boolean'),
collection: DS.attr('boolean'),
@@ -41,7 +42,7 @@ export default OsfModel.extend(FileItemMixin, {
nodeLicense: DS.attr(),
tags: DS.attr(),
- templateFrom: DS.attr('string'),
+ templateFrom: DS.attr('fixstring'),
parent: DS.belongsTo('node', {
inverse: 'children'
@@ -111,7 +112,7 @@ export default OsfModel.extend(FileItemMixin, {
* Determine whether the specified user ID is a contributor on this node
* @method isContributor
* @param {String} userId
- * @returns {boolean} Whether the specified user is a contributor on this node
+ * @return {boolean} Whether the specified user is a contributor on this node
*/
isContributor(userId) {
// Return true if there is at least one matching contributor for this user ID
diff --git a/addon/models/preprint-provider.js b/addon/models/preprint-provider.js
index 89067f2cc..ed722d45d 100644
--- a/addon/models/preprint-provider.js
+++ b/addon/models/preprint-provider.js
@@ -2,18 +2,18 @@ import DS from 'ember-data';
import OsfModel from 'ember-osf/models/osf-model';
export default OsfModel.extend({
- name: DS.attr('string'),
+ name: DS.attr('fixstring'),
logoPath: DS.attr('string'),
bannerPath: DS.attr('string'),
- description: DS.attr('string'),
- example: DS.attr('string'),
+ description: DS.attr('fixstring'),
+ example: DS.attr('fixstring'),
advisoryBoard: DS.attr('string'),
- emailContact: DS.attr('string'),
- emailSupport: DS.attr('string'),
- socialTwitter: DS.attr('string'),
- socialFacebook: DS.attr('string'),
- socialInstagram: DS.attr('string'),
- headerText: DS.attr('string'),
+ emailContact: DS.attr('fixstring'),
+ emailSupport: DS.attr('fixstring'),
+ socialTwitter: DS.attr('fixstring'),
+ socialFacebook: DS.attr('fixstring'),
+ socialInstagram: DS.attr('fixstring'),
+ headerText: DS.attr('fixstring'),
subjectsAcceptable: DS.attr(),
// Relationships
taxonomies: DS.hasMany('taxonomy'),
diff --git a/addon/models/preprint.js b/addon/models/preprint.js
index 639385688..fe44fd0fe 100644
--- a/addon/models/preprint.js
+++ b/addon/models/preprint.js
@@ -16,13 +16,13 @@ import OsfModel from './osf-model';
* @class Preprint
*/
export default OsfModel.extend({
- title: DS.attr('string'),
+ title: DS.attr('fixstring'),
// TODO: May be a relationship in the future pending APIv2 changes
subjects: DS.attr(),
dateCreated: DS.attr('date'),
datePublished: DS.attr('date'),
dateModified: DS.attr('date'),
- doi: DS.attr('string'),
+ doi: DS.attr('fixstring'),
isPublished: DS.attr('boolean'),
isPreprintOrphan: DS.attr('boolean'),
licenseRecord: DS.attr(),
diff --git a/addon/models/registration.js b/addon/models/registration.js
index 468f43210..753bba2b7 100644
--- a/addon/models/registration.js
+++ b/addon/models/registration.js
@@ -24,10 +24,10 @@ export default Node.extend({
embargoEndDate: DS.attr('date'),
pendingEmbargoApproval: DS.attr('boolean'),
withdrawn: DS.attr('boolean'),
- withdrawalJustification: DS.attr('string'),
+ withdrawalJustification: DS.attr('fixstring'),
pendingWithdrawal: DS.attr('boolean'),
- registrationSupplement: DS.attr('string'),
+ registrationSupplement: DS.attr('fixstring'),
registeredMeta: DS.attr(),
registeredFrom: DS.belongsTo('node', {
@@ -38,8 +38,8 @@ export default Node.extend({
}),
contributors: DS.hasMany('contributors'),
comments: DS.hasMany('comments'),
- draftRegistration: DS.attr('string'),
- registrationChoice: DS.attr('string'),
+ draftRegistration: DS.attr('fixstring'),
+ registrationChoice: DS.attr('fixstring'),
liftEmbargo: DS.attr()
//more relationship
});
diff --git a/addon/models/taxonomy.js b/addon/models/taxonomy.js
index 0d759f47f..9ceca97a3 100644
--- a/addon/models/taxonomy.js
+++ b/addon/models/taxonomy.js
@@ -13,7 +13,7 @@ import OsfModel from './osf-model';
* @class Taxonomy
*/
export default OsfModel.extend({
- text: DS.attr('string'),
+ text: DS.attr('fixstring'),
// TODO: Api implements this as a list field for now. This should be a relationship field in the future, when API supports it
child_count: DS.attr(),
parents: DS.attr()
diff --git a/addon/models/user.js b/addon/models/user.js
index 6eec3201b..ad4c3aec0 100644
--- a/addon/models/user.js
+++ b/addon/models/user.js
@@ -18,14 +18,14 @@ import OsfModel from './osf-model';
* @class User
*/
export default OsfModel.extend({
- fullName: DS.attr('string'),
- givenName: DS.attr('string'),
+ fullName: DS.attr('fixstring'),
+ givenName: DS.attr('fixstring'),
middleNames: DS.attr(),
- familyName: DS.attr('string'),
+ familyName: DS.attr('fixstring'),
dateRegistered: DS.attr('date'),
// email
- username: DS.attr('string'),
+ username: DS.attr('fixstring'),
nodes: DS.hasMany('nodes'),
registrations: DS.hasMany('registrations'),
diff --git a/addon/transforms/fixstring.js b/addon/transforms/fixstring.js
new file mode 100644
index 000000000..e99ef1038
--- /dev/null
+++ b/addon/transforms/fixstring.js
@@ -0,0 +1,30 @@
+import DS from 'ember-data';
+
+import fixSpecialChars from '../utils/fix-special-char';
+
+/**
+ * @module ember-osf
+ * @submodule transforms
+ */
+
+/**
+ Custom string field transform that uses the `fix-special-char` utility function to clean up malformed text sent
+ from the server. This allows string fields to be correctly and transparently used in templates without manually fixing
+ these characters for display on each use.
+
+ This transform is used when `fixstring` is passed as the type parameter to the DS.attr function.
+ ```app/models/score.js
+ import DS from 'ember-data';
+ export default DS.Model.extend({
+ astring: DS.attr('fixstring'),
+ });
+ ```
+ @class fixstring
+ @extends DS.StringTransform
+ @uses fix-special-char
+ */
+export default DS.StringTransform.extend({
+ deserialize(serialized) {
+ return fixSpecialChars(this._super(serialized));
+ }
+});
diff --git a/addon/utils/fix-special-char.js b/addon/utils/fix-special-char.js
new file mode 100644
index 000000000..80e6a42ef
--- /dev/null
+++ b/addon/utils/fix-special-char.js
@@ -0,0 +1,23 @@
+/**
+ * @module ember-osf
+ * @submodule utils
+ */
+
+/**
+ * @class fix-special-char
+ */
+
+/**
+ * This function is useful for fixing a bad API behavior. In certain cases the server will insert HTML escape
+ * sequences into text, and this will replace `&` sequences with `&`. Template helper and ember-data field versions
+ * of this function are available.
+ *
+ * @method fixSpecialChar
+ * @param {String} inputString A string value to be transformed
+ * @return {String|null}
+ */
+export default function fixSpecialChar(inputString) {
+ return inputString ? inputString.replace(/&/g, '&') : inputString;
+}
+
+export { fixSpecialChar };
diff --git a/app/helpers/fix-special-char.js b/app/helpers/fix-special-char.js
new file mode 100644
index 000000000..c6e4d5427
--- /dev/null
+++ b/app/helpers/fix-special-char.js
@@ -0,0 +1 @@
+export { default, fixSpecialCharHelper } from 'ember-osf/helpers/fix-special-char';
diff --git a/app/transforms/fixstring.js b/app/transforms/fixstring.js
new file mode 100644
index 000000000..e18f6b241
--- /dev/null
+++ b/app/transforms/fixstring.js
@@ -0,0 +1 @@
+export { default } from 'ember-osf/transforms/fixstring';
diff --git a/app/utils/fix-special-char.js b/app/utils/fix-special-char.js
new file mode 100644
index 000000000..de822bcf5
--- /dev/null
+++ b/app/utils/fix-special-char.js
@@ -0,0 +1 @@
+export { default } from 'ember-osf/utils/fix-special-char';
diff --git a/tests/fixtures/specialChars.js b/tests/fixtures/specialChars.js
new file mode 100644
index 000000000..ecf2fc9fa
--- /dev/null
+++ b/tests/fixtures/specialChars.js
@@ -0,0 +1,10 @@
+// Test cases shared by the family of "special character" fixer functions.
+const fixStringTestCases = [
+ ['a regular string', 'a regular string'],
+ ['multiple & sequences all become &', 'multiple & sequences all become &'],
+ ['', ''],
+ ['for now, intentionally limit which characters are fixed & < >', 'for now, intentionally limit which characters are fixed & < >'],
+ [null, null]
+];
+
+export { fixStringTestCases };
diff --git a/tests/unit/adapters/osf-adapter-test.js b/tests/unit/adapters/osf-adapter-test.js
index 4e57adc03..e79c553a0 100644
--- a/tests/unit/adapters/osf-adapter-test.js
+++ b/tests/unit/adapters/osf-adapter-test.js
@@ -16,7 +16,7 @@ moduleFor('adapter:osf-adapter', 'Unit | Adapter | osf adapter', {
'adapter:osf-adapter', 'adapter:node', 'adapter:user',
'serializer:node',
'service:session',
- 'transform:links', 'transform:embed'
+ 'transform:links', 'transform:embed', 'transform:fixstring'
],
beforeEach() {
manualSetup(this.container);
diff --git a/tests/unit/helpers/fix-special-char-test.js b/tests/unit/helpers/fix-special-char-test.js
new file mode 100644
index 000000000..1e09f6e22
--- /dev/null
+++ b/tests/unit/helpers/fix-special-char-test.js
@@ -0,0 +1,16 @@
+import { fixSpecialCharHelper } from 'dummy/helpers/fix-special-char';
+import { module, test } from 'qunit';
+
+import { fixStringTestCases } from '../../fixtures/specialChars';
+
+module('Unit | Helper | fix special char helper');
+
+
+test('#fixSpecialCharHelper uses fixSpecialChar', function(assert) {
+ assert.expect(fixStringTestCases.length);
+
+ for (let [input, output] of fixStringTestCases) {
+ let res = fixSpecialCharHelper([input]);
+ assert.strictEqual(res, output);
+ }
+});
diff --git a/tests/unit/services/file-manager-test.js b/tests/unit/services/file-manager-test.js
index e83ac881a..4e72bcd6c 100644
--- a/tests/unit/services/file-manager-test.js
+++ b/tests/unit/services/file-manager-test.js
@@ -88,7 +88,7 @@ moduleFor('service:file-manager', 'Unit | Service | file manager', {
unit: true,
needs: [
'model:file', 'model:file-version', 'model:comment', 'model:node',
- 'transform:links', 'transform:embed'
+ 'transform:links', 'transform:embed', 'transform:fixstring'
],
beforeEach() {
this.register('service:session', sessionStub);
diff --git a/tests/unit/transforms/fixstring-test.js b/tests/unit/transforms/fixstring-test.js
new file mode 100644
index 000000000..9b2548a6a
--- /dev/null
+++ b/tests/unit/transforms/fixstring-test.js
@@ -0,0 +1,30 @@
+import { moduleFor, test } from 'ember-qunit';
+
+import { fixStringTestCases } from '../../fixtures/specialChars';
+
+moduleFor('transform:fixstring', 'Unit | Transform | fixstring', {
+ // Specify the other units that are required for this test.
+ // needs: ['serializer:foo']
+});
+
+test('#serialize does not alter values sent from the server', function(assert) {
+ let transform = this.subject();
+
+ assert.expect(fixStringTestCases.length);
+
+ for (let [raw,] of fixStringTestCases) {
+ let res = transform.serialize(raw);
+ assert.equal(res, raw, 'Serialized string did not match raw value');
+ }
+});
+
+test('#deserialize converts values sent from the server into something display friendly', function(assert) {
+ let transform = this.subject();
+
+ assert.expect(fixStringTestCases.length);
+
+ for (let [input, output] of fixStringTestCases) {
+ let res = transform.deserialize(input);
+ assert.strictEqual(res, output, 'Incorrect string deserialization');
+ }
+});
diff --git a/tests/unit/utils/fix-special-char-test.js b/tests/unit/utils/fix-special-char-test.js
new file mode 100644
index 000000000..0958b4586
--- /dev/null
+++ b/tests/unit/utils/fix-special-char-test.js
@@ -0,0 +1,16 @@
+import fixSpecialChar from 'dummy/utils/fix-special-char';
+import { module, test } from 'qunit';
+
+import { fixStringTestCases } from '../../fixtures/specialChars';
+
+module('Unit | Utility | fix special char');
+
+
+test('#fixSpecialChar converts values sent from the server into something display friendly', function(assert) {
+ assert.expect(fixStringTestCases.length);
+
+ for (let [input, output] of fixStringTestCases) {
+ let res = fixSpecialChar(input);
+ assert.strictEqual(res, output);
+ }
+});
From 131e563c47e97c6ff77d77353b0ad685c2771aef Mon Sep 17 00:00:00 2001
From: Andy Boughton
Date: Fri, 3 Feb 2017 17:22:21 -0500
Subject: [PATCH 146/147] Exclude coverage directory from JSCS + packaging
---
.npmignore | 1 +
package.json | 1 +
2 files changed, 2 insertions(+)
diff --git a/.npmignore b/.npmignore
index fa8b147ae..9d254b04d 100644
--- a/.npmignore
+++ b/.npmignore
@@ -1,5 +1,6 @@
/bower_components
/config/ember-try.js
+/coverage
/dist
/tests
/tmp
diff --git a/package.json b/package.json
index c76a86378..8b5e1f864 100644
--- a/package.json
+++ b/package.json
@@ -98,6 +98,7 @@
"excludeFiles": [
"package.json",
"bower_components",
+ "coverage",
"dist",
"docs",
"tmp",
From ce6fc30bf9964bbe8474ad979e21be0f6e410472 Mon Sep 17 00:00:00 2001
From: Andy Boughton
Date: Mon, 6 Feb 2017 10:34:44 -0500
Subject: [PATCH 147/147] Use "official" commands rather than undocumented
shorthand when possible
[ci skip]
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 0304828a4..a192cc5b5 100644
--- a/README.md
+++ b/README.md
@@ -83,7 +83,7 @@ Because of the potential for this file to include sensitive information, **we st
If you do not wish to use file-based configuration, any of the settings above can be overridden individually as
environment variables with the same name as appears in the config file. Eg
-`BACKEND=test CLIENT_ID=gibberish ember serve`
+`BACKEND=test CLIENT_ID=gibberish ember server`
If you provide a setting in both the config file and an environment variable, the environment variables take precedence.
@@ -165,7 +165,7 @@ In certain circumstances, you may wish to use a custom set of servers not known
You can elect to specify your server URLs individually, by specifying `BACKEND=env` and passing additional environment
variables/config file entries. For example:
-`BACKEND=env OSF_URL=https://e.io/ OSF_API_URL=https://api.e.io OSF_RENDER_URL=https://mfr.e.io/render OSF_FILE_URL=https://files.e.io OSF_HELP_URL=https://help.e.io OSF_COOKIE_LOGIN_URL=https://accounts.e.io/login OSF_OAUTH_URL=https://accounts.e.io/oauth2/authorize ember serve`
+`BACKEND=env OSF_URL=https://e.io/ OSF_API_URL=https://api.e.io OSF_RENDER_URL=https://mfr.e.io/render OSF_FILE_URL=https://files.e.io OSF_HELP_URL=https://help.e.io OSF_COOKIE_LOGIN_URL=https://accounts.e.io/login OSF_OAUTH_URL=https://accounts.e.io/oauth2/authorize ember server`
## Running Tests