diff --git a/cli/ballerina-cli/src/main/resources/new_cmd_defaults/gitignore b/cli/ballerina-cli/src/main/resources/new_cmd_defaults/gitignore index 7512ebe2325f..d5fc29aba3c3 100644 --- a/cli/ballerina-cli/src/main/resources/new_cmd_defaults/gitignore +++ b/cli/ballerina-cli/src/main/resources/new_cmd_defaults/gitignore @@ -1,3 +1,11 @@ -target -generated +# Ballerina generates this directory during the compilation of a package. +# It contains compiler-generated artifacts and the final executable if this is an application package. +target/ + +# Ballerina maintains the compiler-generated source code here. +# Remove this if you want to commit generated sources. +generated/ + +# Contains configuration values used during development time. +# See https://ballerina.io/learn/provide-values-to-configurable-variables/ for more details. Config.toml diff --git a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/NewCommandTest.java b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/NewCommandTest.java index dd7d70bc99a3..4d27b4ef5806 100644 --- a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/NewCommandTest.java +++ b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/NewCommandTest.java @@ -115,7 +115,16 @@ public void testNewCommand() throws IOException { Assert.assertTrue(Files.exists(packageDir.resolve(ProjectConstants.GITIGNORE_FILE_NAME))); String gitignoreContent = Files.readString( packageDir.resolve(ProjectConstants.GITIGNORE_FILE_NAME), StandardCharsets.UTF_8); - String expectedGitignoreContent = "target\ngenerated\n" + + String expectedGitignoreContent = "# Ballerina generates this directory during the compilation of a package. " + + "\n# It contains compiler-generated artifacts and the final executable if this is an application " + + "package.\ntarget/\n" + + "\n" + + "# Ballerina maintains the compiler-generated source code here.\n" + + "# Remove this if you want to commit generated sources.\n" + + "generated/\n" + + "\n" + + "# Contains configuration values used during development time.\n" + + "# See https://ballerina.io/learn/provide-values-to-configurable-variables/ for more details.\n" + "Config.toml\n"; Assert.assertEquals(gitignoreContent.trim(), expectedGitignoreContent.trim()); Assert.assertTrue(readOutput().contains("Created new package")); @@ -158,7 +167,16 @@ public void testNewCommandInExistingDirectory() throws IOException { Assert.assertTrue(Files.exists(packageDir.resolve(ProjectConstants.GITIGNORE_FILE_NAME))); String gitignoreContent = Files.readString( packageDir.resolve(ProjectConstants.GITIGNORE_FILE_NAME), StandardCharsets.UTF_8); - String expectedGitignoreContent = "target\ngenerated\n" + + String expectedGitignoreContent = "# Ballerina generates this directory during the compilation of a package. " + + "\n# It contains compiler-generated artifacts and the final executable if this is an application " + + "package.\ntarget/\n" + + "\n" + + "# Ballerina maintains the compiler-generated source code here.\n" + + "# Remove this if you want to commit generated sources.\n" + + "generated/\n" + + "\n" + + "# Contains configuration values used during development time.\n" + + "# See https://ballerina.io/learn/provide-values-to-configurable-variables/ for more details.\n" + "Config.toml\n"; Assert.assertEquals(gitignoreContent.trim(), expectedGitignoreContent.trim()); Assert.assertTrue(readOutput().contains("Created new package")); @@ -201,7 +219,16 @@ public void testNewCommandInExistingDirectoryWithExistingBalFilesForDefaultTempl Assert.assertTrue(Files.exists(packageDir.resolve(ProjectConstants.GITIGNORE_FILE_NAME))); String gitignoreContent = Files.readString( packageDir.resolve(ProjectConstants.GITIGNORE_FILE_NAME), StandardCharsets.UTF_8); - String expectedGitignoreContent = "target\ngenerated\n" + + String expectedGitignoreContent = "# Ballerina generates this directory during the compilation of a package. " + + "\n# It contains compiler-generated artifacts and the final executable if this is an application " + + "package.\ntarget/\n" + + "\n" + + "# Ballerina maintains the compiler-generated source code here.\n" + + "# Remove this if you want to commit generated sources.\n" + + "generated/\n" + + "\n" + + "# Contains configuration values used during development time.\n" + + "# See https://ballerina.io/learn/provide-values-to-configurable-variables/ for more details.\n" + "Config.toml\n"; Assert.assertEquals(gitignoreContent.trim(), expectedGitignoreContent.trim()); Assert.assertTrue(readOutput().contains("Created new package")); @@ -332,7 +359,16 @@ public void testNewCommandInExistingDirectoryWithInvalidName() throws IOExceptio Assert.assertTrue(Files.exists(packageDir.resolve(ProjectConstants.GITIGNORE_FILE_NAME))); String gitignoreContent = Files.readString( packageDir.resolve(ProjectConstants.GITIGNORE_FILE_NAME), StandardCharsets.UTF_8); - String expectedGitignoreContent = "target\ngenerated\n" + + String expectedGitignoreContent = "# Ballerina generates this directory during the compilation of a package. " + + "\n# It contains compiler-generated artifacts and the final executable if this is an application " + + "package.\ntarget/\n" + + "\n" + + "# Ballerina maintains the compiler-generated source code here.\n" + + "# Remove this if you want to commit generated sources.\n" + + "generated/\n" + + "\n" + + "# Contains configuration values used during development time.\n" + + "# See https://ballerina.io/learn/provide-values-to-configurable-variables/ for more details.\n" + "Config.toml\n"; Assert.assertEquals(gitignoreContent.trim(), expectedGitignoreContent.trim()); Assert.assertTrue(readOutput().contains("Created new package")); @@ -382,7 +418,16 @@ public void testNewCommandWithRelativePath() throws IOException { Assert.assertTrue(Files.exists(relativeToCurrentDir.resolve(ProjectConstants.GITIGNORE_FILE_NAME))); String gitignoreContent = Files.readString( relativeToCurrentDir.resolve(ProjectConstants.GITIGNORE_FILE_NAME), StandardCharsets.UTF_8); - String expectedGitignoreContent = "target\ngenerated\n" + + String expectedGitignoreContent = "# Ballerina generates this directory during the compilation of a package. " + + "\n# It contains compiler-generated artifacts and the final executable if this is an application " + + "package.\ntarget/\n" + + "\n" + + "# Ballerina maintains the compiler-generated source code here.\n" + + "# Remove this if you want to commit generated sources.\n" + + "generated/\n" + + "\n" + + "# Contains configuration values used during development time.\n" + + "# See https://ballerina.io/learn/provide-values-to-configurable-variables/ for more details.\n" + "Config.toml\n"; Assert.assertEquals(gitignoreContent.trim(), expectedGitignoreContent.trim()); Assert.assertTrue(readOutput().contains("Created new package"));