Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New: add update API (fixes #185) #195

Merged
merged 3 commits into from
Aug 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down