Skip to content

Commit

Permalink
issue/147 Return targets from install/uninstall and update
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverfoster committed Feb 28, 2022
1 parent 6a05af2 commit acce06a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
12 changes: 6 additions & 6 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ class API {
* @param {Object} options
* @param {[string]} [options.plugins=null] An array with name@version or name@path strings
* @param {string} [options.cwd=process.cwd()] Root path of the framework installation
* @return {Promise}
* @return {Promise<[Target]>}
*/
async installPlugins ({
plugins = null,
cwd = process.cwd()
} = {}) {
await install({
return await install({
plugins,
isInteractive: false,
cwd
Expand All @@ -124,13 +124,13 @@ class API {
* @param {Object} options
* @param {[string]} [options.plugins=null] An array with name@version or name@path strings
* @param {string} [options.cwd=process.cwd()] Root path of the framework installation
* @return {Promise}
* @return {Promise<[Target]>}
*/
async uninstallPlugins ({
plugins = null,
cwd = process.cwd()
} = {}) {
await uninstall({
return await uninstall({
plugins,
isInteractive: false,
cwd
Expand All @@ -143,13 +143,13 @@ class API {
* @param {Object} options
* @param {[string]} [options.plugins=null] An array with name@version or name@path strings
* @param {string} [options.cwd=process.cwd()] Root path of the framework installation
* @return {Promise}
* @return {Promise<[Target]>}
*/
async updatePlugins ({
plugins = null,
cwd = process.cwd()
} = {}) {
await update({
return await update({
plugins,
isInteractive: false,
cwd
Expand Down
5 changes: 3 additions & 2 deletions lib/integration/PluginManagement/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ export default async function install ({
logger?.log(chalk.cyan(`${dev ? 'cloning' : 'installing'} adapt dependencies...`))

const targets = await getInstallTargets({ logger, project, plugins, isCompatibleEnabled })
if (!targets?.length) return
if (!targets?.length) return targets

await loadPluginData({ logger, project, targets })
await conflictResolution({ logger, targets, isInteractive, dev })
if (isDryRun) {
await summariseDryRun({ logger, targets })
return
return targets
}
const installTargetsToBeInstalled = targets.filter(target => target.isToBeInstalled)
if (installTargetsToBeInstalled.length) {
Expand All @@ -47,6 +47,7 @@ export default async function install ({
await updateManifest({ logger, project, targets, manifestDependencies, isInteractive })
}
await summariseInstallation({ logger, targets, dev })
return targets
}

/**
Expand Down
5 changes: 3 additions & 2 deletions lib/integration/PluginManagement/uninstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default async function uninstall ({
logger?.log(chalk.cyan('uninstalling adapt dependencies...'))

const targets = await getUninstallTargets({ logger, project, plugins, isInteractive })
if (!targets?.length) return
if (!targets?.length) return targets

await loadPluginData({ logger, targets })
await eachOfLimitProgress(
Expand All @@ -32,7 +32,8 @@ export default async function uninstall ({
logger?.log(`${chalk.bold.cyan('<info>')} Uninstalling plugins 100% complete`)
const installedDependencies = await project.getInstalledDependencies()
await updateManifest({ project, targets, installedDependencies, isInteractive })
return summariseUninstallation({ logger, targets })
await summariseUninstallation({ logger, targets })
return targets
}

/**
Expand Down
5 changes: 3 additions & 2 deletions lib/integration/PluginManagement/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ export default async function update ({
logger?.log(chalk.cyan('update adapt dependencies...'))

const targets = await getUpdateTargets({ logger, project, plugins, isDryRun, isInteractive })
if (!targets?.length) return
if (!targets?.length) return targets

await loadPluginData({ logger, project, targets })
await conflictResolution({ logger, targets, isInteractive })
if (isDryRun) {
await summariseDryRun({ logger, targets })
return
return targets
}
const updateTargetsToBeUpdated = targets.filter(target => target.isToBeInstalled)
if (updateTargetsToBeUpdated.length) {
Expand All @@ -40,6 +40,7 @@ export default async function update ({
logger?.log(`${chalk.bold.cyan('<info>')} Updating plugins 100% complete`)
}
await summariseUpdates({ logger, targets })
return targets
}

/**
Expand Down

0 comments on commit acce06a

Please sign in to comment.