• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 19833758920

01 Dec 2025 06:47PM UTC coverage: 69.787% (-0.07%) from 69.854%
19833758920

push

github

web-flow
#1521: Use wiremock for npm repository. (#1529)

Co-authored-by: jan-vcapgemini <59438728+jan-vcapgemini@users.noreply.github.com>
Co-authored-by: jan-vcapgemini <jan-vincent.hoelzle@capgemini.com>
Co-authored-by: Jörg Hohwiller <hohwille@users.noreply.github.com>
Co-authored-by: Malte Brunnlieb <maybeec@users.noreply.github.com>

3822 of 6009 branches covered (63.6%)

Branch coverage included in aggregate %.

9790 of 13496 relevant lines covered (72.54%)

3.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.33
cli/src/main/java/com/devonfw/tools/ide/tool/ide/IdeToolCommandlet.java
1
package com.devonfw.tools.ide.tool.ide;
2

3
import java.nio.file.Files;
4
import java.nio.file.Path;
5
import java.util.Set;
6

7
import com.devonfw.tools.ide.common.Tag;
8
import com.devonfw.tools.ide.context.IdeContext;
9
import com.devonfw.tools.ide.io.FileAccess;
10
import com.devonfw.tools.ide.process.ProcessMode;
11
import com.devonfw.tools.ide.process.ProcessResult;
12
import com.devonfw.tools.ide.step.Step;
13
import com.devonfw.tools.ide.tool.ToolCommandlet;
14
import com.devonfw.tools.ide.tool.ToolInstallRequest;
15
import com.devonfw.tools.ide.tool.ToolInstallation;
16
import com.devonfw.tools.ide.tool.eclipse.Eclipse;
17
import com.devonfw.tools.ide.tool.intellij.Intellij;
18
import com.devonfw.tools.ide.tool.plugin.PluginBasedCommandlet;
19
import com.devonfw.tools.ide.tool.vscode.Vscode;
20

21
/**
22
 * {@link ToolCommandlet} for an IDE (integrated development environment) such as {@link Eclipse}, {@link Vscode}, or {@link Intellij}.
23
 */
24
public abstract class IdeToolCommandlet extends PluginBasedCommandlet {
1✔
25

26
  /**
27
   * The constructor.
28
   *
29
   * @param context the {@link IdeContext}.
30
   * @param tool the {@link #getName() tool name}.
31
   * @param tags the {@link #getTags() tags} classifying the tool. Should be created via {@link Set#of(Object) Set.of} method.
32
   */
33
  public IdeToolCommandlet(IdeContext context, String tool, Set<Tag> tags) {
34

35
    super(context, tool, tags);
5✔
36
    assert (hasIde(tags));
5!
37
  }
1✔
38

39
  private boolean hasIde(Set<Tag> tags) {
40

41
    for (Tag tag : tags) {
10!
42
      if (tag.isAncestorOf(Tag.IDE) || (tag == Tag.IDE)) {
7!
43
        return true;
2✔
44
      }
45
    }
×
46
    throw new IllegalStateException("Tags of IdeTool has to be connected with tag IDE: " + tags);
×
47
  }
48

49
  @Override
50
  public final void run() {
51
    super.run();
2✔
52
  }
1✔
53

54
  @Override
55
  public ProcessResult runTool(String... args) {
56

57
    return runTool(ProcessMode.BACKGROUND, null, args);
6✔
58
  }
59

60
  @Override
61
  public ToolInstallation install(ToolInstallRequest request) {
62

63
    configureWorkspace();
2✔
64
    return super.install(request);
4✔
65
  }
66

67
  /**
68
   * Configure (initialize or update) the workspace for this IDE using the templates from the settings.
69
   */
70
  protected void configureWorkspace() {
71

72
    FileAccess fileAccess = this.context.getFileAccess();
4✔
73
    Path workspaceFolder = this.context.getWorkspacePath();
4✔
74
    if (!fileAccess.isExpectedFolder(workspaceFolder)) {
4!
75
      this.context.warning("Current workspace does not exist: {}", workspaceFolder);
×
76
      return; // should actually never happen...
×
77
    }
78
    Step step = this.context.newStep("Configuring workspace " + workspaceFolder.getFileName() + " for IDE " + this.tool);
10✔
79
    step.run(() -> doMergeWorkspaceStep(step, workspaceFolder));
12✔
80
  }
1✔
81

82
  private void doMergeWorkspaceStep(Step step, Path workspaceFolder) {
83

84
    int errors = 0;
2✔
85
    errors = mergeWorkspace(this.context.getUserHomeIde(), workspaceFolder, errors);
8✔
86
    errors = mergeWorkspace(this.context.getSettingsPath(), workspaceFolder, errors);
8✔
87
    errors = mergeWorkspace(this.context.getConfPath(), workspaceFolder, errors);
8✔
88
    if (errors == 0) {
2!
89
      step.success();
3✔
90
    } else {
91
      step.error("Your workspace configuration failed with {} error(s) - see log above.\n"
×
92
          + "This is either a configuration error in your settings git repository or a bug in IDEasy.\n"
93
          + "Please analyze the above errors with your team or IDE-admin and try to fix the problem.", errors);
×
94
      this.context.askToContinue(
×
95
          "In order to prevent you from being blocked, you can start your IDE anyhow but some configuration may not be in sync.");
96
    }
97
  }
1✔
98

99
  private int mergeWorkspace(Path configFolder, Path workspaceFolder, int errors) {
100

101
    int result = errors;
2✔
102
    result = mergeWorkspaceSingle(configFolder.resolve(IdeContext.FOLDER_WORKSPACE), workspaceFolder, result);
8✔
103
    result = mergeWorkspaceSingle(configFolder.resolve(this.tool).resolve(IdeContext.FOLDER_WORKSPACE), workspaceFolder, result);
11✔
104
    return result;
2✔
105
  }
106

107
  private int mergeWorkspaceSingle(Path templatesFolder, Path workspaceFolder, int errors) {
108

109
    Path setupFolder = templatesFolder.resolve(IdeContext.FOLDER_SETUP);
4✔
110
    Path updateFolder = templatesFolder.resolve(IdeContext.FOLDER_UPDATE);
4✔
111
    if (!Files.isDirectory(setupFolder) && !Files.isDirectory(updateFolder)) {
10✔
112
      this.context.trace("Skipping empty or non-existing workspace template folder {}.", templatesFolder);
10✔
113
      return errors;
2✔
114
    }
115
    this.context.debug("Merging workspace templates from {}...", templatesFolder);
10✔
116
    return errors + this.context.getWorkspaceMerger().merge(setupFolder, updateFolder, this.context.getVariables(), workspaceFolder);
13✔
117
  }
118

119
  /**
120
   * Imports the repository specified by the given {@link Path} into the IDE managed by this {@link IdeToolCommandlet}.
121
   *
122
   * @param repositoryPath the {@link Path} to the repository directory to import.
123
   */
124
  public void importRepository(Path repositoryPath) {
125

126
    throw new UnsupportedOperationException("Repository import is not yet implemented for IDE " + this.tool);
×
127
  }
128
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc