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

devonfw / IDEasy / 16754549568

05 Aug 2025 03:29PM UTC coverage: 69.457% (+1.0%) from 68.446%
16754549568

Pull #1418

github

web-flow
Merge a1115a3da into d13807b57
Pull Request #1418: Use WindowsHelper to find bash instead of direct ProcessBuilder

3338 of 5242 branches covered (63.68%)

Branch coverage included in aggregate %.

8617 of 11970 relevant lines covered (71.99%)

3.17 hits per line

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

93.18
cli/src/main/java/com/devonfw/tools/ide/commandlet/CreateCommandlet.java
1
package com.devonfw.tools.ide.commandlet;
2

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

7
import com.devonfw.tools.ide.context.IdeContext;
8
import com.devonfw.tools.ide.io.FileAccess;
9
import com.devonfw.tools.ide.property.FlagProperty;
10
import com.devonfw.tools.ide.property.StringProperty;
11
import com.devonfw.tools.ide.version.IdeVersion;
12

13
/**
14
 * {@link Commandlet} to create a new IDEasy instance
15
 */
16
public class CreateCommandlet extends AbstractUpdateCommandlet {
17

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

21
  /** {@link FlagProperty} for creating a project with settings inside a code repository */
22
  public final FlagProperty codeRepositoryFlag;
23

24
  /**
25
   * The constructor.
26
   *
27
   * @param context the {@link IdeContext}.
28
   */
29
  public CreateCommandlet(IdeContext context) {
30

31
    super(context);
3✔
32
    this.newProject = add(new StringProperty("", true, "project"));
11✔
33
    this.codeRepositoryFlag = add(new FlagProperty("--code"));
9✔
34
    add(this.settingsRepo);
5✔
35
  }
1✔
36

37
  @Override
38
  public String getName() {
39

40
    return "create";
2✔
41
  }
42

43
  @Override
44
  public boolean isIdeHomeRequired() {
45

46
    return false;
2✔
47
  }
48

49
  @Override
50
  public void run() {
51

52
    String newProjectName = this.newProject.getValue();
5✔
53
    Path newProjectPath = this.context.getIdeRoot().resolve(newProjectName);
6✔
54

55
    this.context.info("Creating new IDEasy project in {}", newProjectPath);
10✔
56
    if (!this.context.getFileAccess().isEmptyDir(newProjectPath)) {
6!
57
      this.context.askToContinue("Directory " + newProjectPath + " already exists. Do you want to continue?");
×
58
    } else {
59
      this.context.getFileAccess().mkdirs(newProjectPath);
5✔
60
    }
61

62
    initializeProject(newProjectPath);
3✔
63
    this.context.setIdeHome(newProjectPath);
4✔
64
    this.context.verifyIdeMinVersion(true);
4✔
65
    super.run();
2✔
66
    this.context.verifyIdeMinVersion(true);
4✔
67
    this.context.getFileAccess().writeFileContent(IdeVersion.getVersionString(), newProjectPath.resolve(IdeContext.FILE_SOFTWARE_VERSION));
8✔
68
    this.context.success("Successfully created new project '{}'.", newProjectName);
10✔
69

70
    logWelcomeMessage();
2✔
71
  }
1✔
72

73
  private void initializeProject(Path newInstancePath) {
74

75
    FileAccess fileAccess = this.context.getFileAccess();
4✔
76
    fileAccess.mkdirs(newInstancePath.resolve(IdeContext.FOLDER_SOFTWARE));
5✔
77
    fileAccess.mkdirs(newInstancePath.resolve(IdeContext.FOLDER_PLUGINS));
5✔
78
    fileAccess.mkdirs(newInstancePath.resolve(IdeContext.FOLDER_WORKSPACES).resolve(IdeContext.WORKSPACE_MAIN));
7✔
79
  }
1✔
80

81
  @Override
82
  protected boolean isCodeRepository() {
83
    return this.codeRepositoryFlag.isTrue();
4✔
84
  }
85

86
  @Override
87
  protected String getStepMessage() {
88

89
    return "Create (clone) " + (isCodeRepository() ? "code" : "settings") + " repository";
8✔
90
  }
91

92
  private void logWelcomeMessage() {
93
    Path settingsFolder = this.context.getSettingsPath();
4✔
94
    if (Files.exists(settingsFolder)) {
5✔
95
      Predicate<Path> welcomePredicate = path -> String.valueOf(path.getFileName()).startsWith("welcome.");
8✔
96
      Path welcomeFilePath = this.context.getFileAccess().findFirst(settingsFolder, welcomePredicate, false);
8✔
97
      if (welcomeFilePath != null) {
2!
98
        this.context.info(this.context.getFileAccess().readFileContent(welcomeFilePath));
8✔
99
      }
100
    }
101
  }
1✔
102
}
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