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

devonfw / IDEasy / 16519104220

25 Jul 2025 09:50AM UTC coverage: 68.59% (+0.1%) from 68.477%
16519104220

push

github

web-flow
#1399: Fix welcome message not working on linux (#1425)

Co-authored-by: Jörg Hohwiller <hohwille@users.noreply.github.com>

3295 of 5206 branches covered (63.29%)

Branch coverage included in aggregate %.

8425 of 11881 relevant lines covered (70.91%)

3.13 hits per line

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

93.75
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 void processRepository() {
83
    RepositoryStrategy repositoryStrategy = new SettingsRepositoryStrategy();
4✔
84
    if (isCodeRepository()) {
3✔
85
      repositoryStrategy = new CodeRepositoryStrategy();
4✔
86
    }
87

88
    processRepositoryUsingStrategy(repositoryStrategy);
3✔
89
  }
1✔
90

91
  @Override
92
  protected boolean isCodeRepository() {
93
    return this.codeRepositoryFlag.isTrue();
4✔
94
  }
95

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