diff --git a/lib/api.js b/lib/api.js index 2842ee8..345fcf0 100644 --- a/lib/api.js +++ b/lib/api.js @@ -64,6 +64,40 @@ class API { }) } + /** + * Updates an existing installation of the framework + * @param {Object} options + * @param {string} [options.version=null] Specific version of the framework to install + * @param {string} [options.repository] URL to github repo + * @param {string} [options.cwd=process.cwd()] Directory to install into + * @return {Promise} + */ + async updateFramework ({ + version = null, + repository = ADAPT_FRAMEWORK, + cwd = process.cwd(), + logger + } = {}) { + // cache state of plugins, as these will be wiped + const plugins = (await new Project({ cwd }).getInstallTargets()) + .map(p => p.isLocalSource ? p.sourcePath : `${p.name}@${p.requestedVersion}`) + + await this.installFramework({ version, repository, cwd, logger }) + // restore plugins + await this.installPlugins({ plugins, cwd, logger }) + } + + /** + * @param {Object} options + * @param {string} [options.cwd=process.cwd()] Directory to install into + * @returns {string} + */ + getCurrentFrameworkVersion ({ + cwd = process.cwd(), + } = {}) { + return new Project({ cwd }).version + } + /** * @param {Object} options * @param {Object} [options.repository=ADAPT_FRAMEWORK] The github repository url