Run composer (fix #71)
This commit is contained in:
@@ -61,6 +61,7 @@ Just run `topgrade`. It will run the following steps:
|
|||||||
* Node
|
* Node
|
||||||
* Run `yarn global update` if yarn is installed.
|
* Run `yarn global update` if yarn is installed.
|
||||||
* Run `npm update -g` if NPM is installed and `npm root -g` is a path inside your home directory.
|
* Run `npm update -g` if NPM is installed and `npm root -g` is a path inside your home directory.
|
||||||
|
* Run `composer global update` if Composer's home directory is inside the home directory of the user.
|
||||||
* Upgrade Atom packages
|
* Upgrade Atom packages
|
||||||
* Run `gem upgrade --user-install` if `~/.gem` exists
|
* Run `gem upgrade --user-install` if `~/.gem` exists
|
||||||
* *Linux*: Update Flatpak packages
|
* *Linux*: Update Flatpak packages
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ use super::terminal::Terminal;
|
|||||||
use super::utils::{self, Check, PathExt};
|
use super::utils::{self, Check, PathExt};
|
||||||
use directories::BaseDirs;
|
use directories::BaseDirs;
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
const EMACS_UPGRADE: &str = include_str!("emacs.el");
|
const EMACS_UPGRADE: &str = include_str!("emacs.el");
|
||||||
|
|
||||||
@@ -145,3 +147,39 @@ pub fn run_custom_command(name: &str, command: &str, terminal: &mut Terminal, dr
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
pub fn run_composer_update(
|
||||||
|
base_dirs: &BaseDirs,
|
||||||
|
terminal: &mut Terminal,
|
||||||
|
dry_run: bool,
|
||||||
|
) -> Option<(&'static str, bool)> {
|
||||||
|
if let Some(composer) = utils::which("composer") {
|
||||||
|
let composer_home = || -> Result<PathBuf, Error> {
|
||||||
|
let output = Command::new(&composer)
|
||||||
|
.args(&["global", "config", "--absolute", "home"])
|
||||||
|
.output()?;
|
||||||
|
output.status.check()?;
|
||||||
|
Ok(PathBuf::from(&String::from_utf8(output.stdout)?))
|
||||||
|
}();
|
||||||
|
|
||||||
|
if let Ok(composer_home) = composer_home {
|
||||||
|
if composer_home.is_descendant_of(base_dirs.home_dir()) {
|
||||||
|
terminal.print_separator("Composer");
|
||||||
|
|
||||||
|
let success = || -> Result<(), Error> {
|
||||||
|
Executor::new(&composer, dry_run)
|
||||||
|
.args(&["global", "update"])
|
||||||
|
.spawn()?
|
||||||
|
.wait()?
|
||||||
|
.check()?;
|
||||||
|
Ok(())
|
||||||
|
}().is_ok();
|
||||||
|
|
||||||
|
return Some(("Composer", success));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|||||||
@@ -230,6 +230,10 @@ fn run() -> Result<(), Error> {
|
|||||||
|terminal| node::run_npm_upgrade(&base_dirs, terminal, opt.dry_run),
|
|terminal| node::run_npm_upgrade(&base_dirs, terminal, opt.dry_run),
|
||||||
&mut terminal,
|
&mut terminal,
|
||||||
));
|
));
|
||||||
|
report.push_result(execute(
|
||||||
|
|terminal| generic::run_composer_update(&base_dirs, terminal, opt.dry_run),
|
||||||
|
&mut terminal,
|
||||||
|
));
|
||||||
report.push_result(execute(
|
report.push_result(execute(
|
||||||
|terminal| node::yarn_global_update(terminal, opt.dry_run),
|
|terminal| node::yarn_global_update(terminal, opt.dry_run),
|
||||||
&mut terminal,
|
&mut terminal,
|
||||||
|
|||||||
Reference in New Issue
Block a user