Merge pull request #617 from resin-io/594-shared-app-lookup

Allow the looking up of applications with the owner username
This commit is contained in:
CameronDiver 2017-08-14 22:43:56 +01:00 committed by GitHub
commit 4dec846256
4 changed files with 27 additions and 4 deletions

View File

@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
### Changed
- Added support for looking up shared apps via [owner]/[appname] strings
### Added
- Use forked global-tunnel-ng that doesn't proxy connections to socket files

View File

@ -15,7 +15,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var Promise;
var Promise, getApplication;
Promise = require('bluebird');
@ -99,7 +99,7 @@ exports.getAppInfo = function(application) {
var _, resin;
resin = require('resin-sdk-preconfigured');
_ = require('lodash');
return Promise.join(resin.models.application.get(application), resin.models.config.getDeviceTypes(), function(app, config) {
return Promise.join(getApplication(application), resin.models.config.getDeviceTypes(), function(app, config) {
config = _.find(config, {
'slug': app.device_type
});
@ -111,6 +111,15 @@ exports.getAppInfo = function(application) {
});
};
getApplication = function(application) {
var match, resin;
resin = require('resin-sdk-preconfigured');
if ((match = /(\w+)\/(\w+)/.exec(application))) {
return resin.models.application.getAppWithOwner(match[2], match[1]);
}
return resin.models.application.get(application);
};
exports.getSubShellCommand = function(command) {
var os;
os = require('os');

View File

@ -96,7 +96,7 @@ exports.getAppInfo = (application) ->
resin = require('resin-sdk-preconfigured')
_ = require('lodash')
Promise.join(
resin.models.application.get(application),
getApplication(application),
resin.models.config.getDeviceTypes(),
(app, config) ->
config = _.find(config, 'slug': app.device_type)
@ -106,6 +106,16 @@ exports.getAppInfo = (application) ->
return app
)
getApplication = (application) ->
resin = require('resin-sdk-preconfigured')
# Check for an app of the form `user/application`, and send
# this off to a special handler (before importing any modules)
if (match = /(\w+)\/(\w+)/.exec(application))
return resin.models.application.getAppWithOwner(match[2], match[1])
return resin.models.application.get(application)
# A function to reliably execute a command
# in all supported operating systems, including
# different Windows environments like `cmd.exe`

View File

@ -83,7 +83,7 @@
"resin-image-fs": "^2.3.0",
"resin-image-manager": "^4.1.1",
"resin-preload": "^2.0.0",
"resin-sdk-preconfigured": "^6.4.1",
"resin-sdk-preconfigured": "^6.9.0",
"resin-settings-client": "^3.6.1",
"resin-stream-logger": "^0.0.4",
"resin-sync": "^9.1.0",