Skip to content

Commit

Permalink
#279: Ability to skip steps (tools and repositories) during update (#387
Browse files Browse the repository at this point in the history
)
  • Loading branch information
salimbouch authored Jun 17, 2024
1 parent e5e0a4d commit 99a3d9b
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.devonfw.tools.ide.context.GitContext;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.property.FlagProperty;
import com.devonfw.tools.ide.property.StringProperty;
import com.devonfw.tools.ide.repo.CustomTool;
import com.devonfw.tools.ide.step.Step;
Expand All @@ -23,6 +24,9 @@ public abstract class AbstractUpdateCommandlet extends Commandlet {
/** {@link StringProperty} for the settings repository URL. */
protected final StringProperty settingsRepo;

/** {@link FlagProperty} for skipping installation/updating of tools */
protected final FlagProperty skipTools;

/**
* The constructor.
*
Expand All @@ -31,15 +35,27 @@ public abstract class AbstractUpdateCommandlet extends Commandlet {
public AbstractUpdateCommandlet(IdeContext context) {

super(context);
addKeyword(getName());
this.skipTools = add(new FlagProperty("--skip-tools", false, null));
this.settingsRepo = new StringProperty("", false, "settingsRepository");
}

@Override
public void run() {

updateSettings();
Path templatesFolder = this.context.getSettingsPath().resolve(IdeContext.FOLDER_TEMPLATES);
updateConf();

if (skipTools.isTrue()) {
this.context.info("Skipping installation/update of tools as specified by the user.");
} else {
updateSoftware();
}
}

private void updateConf() {

Path templatesFolder = this.context.getSettingsPath().resolve(IdeContext.FOLDER_TEMPLATES);
if (!Files.exists(templatesFolder)) {
Path legacyTemplatesFolder = this.context.getSettingsPath().resolve(IdeContext.FOLDER_LEGACY_TEMPLATES);
if (Files.exists(legacyTemplatesFolder)) {
Expand All @@ -57,7 +73,6 @@ public void run() {
} finally {
step.end();
}
updateSoftware();
}

private void setupConf(Path template, Path conf) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.io.FileAccess;
import com.devonfw.tools.ide.property.FlagProperty;
import com.devonfw.tools.ide.property.StringProperty;

import java.nio.file.Path;
Expand All @@ -11,8 +12,12 @@
*/
public class CreateCommandlet extends AbstractUpdateCommandlet {

/** {@link StringProperty} for the name of the new project */
public final StringProperty newProject;

/** {@link FlagProperty} for skipping the setup of git repositories */
public final FlagProperty skipRepositories;

/**
* The constructor.
*
Expand All @@ -21,8 +26,8 @@ public class CreateCommandlet extends AbstractUpdateCommandlet {
public CreateCommandlet(IdeContext context) {

super(context);
addKeyword(getName());
newProject = add(new StringProperty("", true, "project"));
this.skipRepositories = add(new FlagProperty("--skip-repositories", false, null));
add(this.settingsRepo);
}

Expand Down Expand Up @@ -54,7 +59,11 @@ public void run() {
initializeProject(newProjectPath);
this.context.setIdeHome(newProjectPath);
super.run();
updateRepositories();
if (this.skipRepositories.isTrue()) {
this.context.info("Skipping the cloning of project repositories as specified by the user.");
} else {
updateRepositories();
}
this.context.success("Successfully created new project '{}'.", newProjectName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public class UpdateCommandlet extends AbstractUpdateCommandlet {
public UpdateCommandlet(IdeContext context) {

super(context);
addKeyword(getName());
}

@Override
Expand Down
2 changes: 2 additions & 0 deletions cli/src/main/resources/nls/Help.properties
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ opt.--force=enable force mode.
opt.--locale=the locale (e.g. '--locale=de' for German language).
opt.--offline=enable offline mode (skip updates or git pull, fail downloads or git clone).
opt.--quiet=disable info logging (only log success, warning or error).
opt.--skip-repositories=skip the setup of repositories.
opt.--skip-tools=skip the installation/update of tools.
opt.--trace=enable trace logging.
opt.--version=Print the IDE version and exit.
options=Options:
Expand Down
2 changes: 2 additions & 0 deletions cli/src/main/resources/nls/Help_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ opt.--force=Aktiviert den Force-Modus (Erzwingen).
opt.--locale=Die Spracheinstellungen (z.B. 'en' für Englisch).
opt.--offline=Aktiviert den Offline-Modus (Überspringt Aktualisierungen oder git pull, schlägt fehl bei Downloads or git clone).
opt.--quiet=Deaktiviert Info Logging ( nur success, warning und error).
opt.--skip-repositories=überspringt die Einrichtung der Repositories.
opt.--skip-tools=überspringt die Installation/Aktualisierung der Tools.
opt.--trace=Aktiviert Trace-Ausgaben (detaillierte Fehleranalyse).
opt.--version=Zeigt die IDE Version an und beendet das Programm.
options=Optionen:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public void testCreateCommandletRun() {
CreateCommandlet cc = context.getCommandletManager().getCommandlet(CreateCommandlet.class);
cc.newProject.setValueAsString(NEW_PROJECT_NAME, context);
cc.settingsRepo.setValue(IdeContext.DEFAULT_SETTINGS_REPO_URL);
cc.skipTools.setValue(true);
// act
cc.run();
// assert
Expand Down

0 comments on commit 99a3d9b

Please sign in to comment.