diff --git a/CHANGELOG.md b/CHANGELOG.md index fcad30ca..f90bb3ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/build/utils/helpers.js b/build/utils/helpers.js index 95fa5674..77f3fed8 100644 --- a/build/utils/helpers.js +++ b/build/utils/helpers.js @@ -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'); diff --git a/lib/utils/helpers.coffee b/lib/utils/helpers.coffee index 2752e305..55e32d02 100644 --- a/lib/utils/helpers.coffee +++ b/lib/utils/helpers.coffee @@ -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` diff --git a/package.json b/package.json index ef293a0f..22be1cc6 100644 --- a/package.json +++ b/package.json @@ -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",