Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improvement]: Add directory content validation for bal clean --target-dir <path> option #42695

Open
Thushara-Piyasekara opened this issue May 6, 2024 · 0 comments
Labels
needTriage The issue has to be inspected and labeled manually Type/Improvement userCategory/Compilation

Comments

@Thushara-Piyasekara
Copy link
Contributor

Description

As of now it is possible to delete any directory and its contents using bal clean --target-dir <path> command. Following is the emitted output for bal clean --help command,

SYNOPSIS
       bal clean [OPTIONS]


DESCRIPTION
       Remove the 'target' directory created during the build. This will delete
       all files and directories in the target directory.

       The default target directory that will be cleaned is the
       '<package-root>/target'. You may also provide a custom target to be
       cleaned.


OPTIONS
       --target-dir <path>
           Target directory path.

EXAMPLES
       Clean the default target directory of the current package.
           $ bal clean

       Clean the provided target directory.
           $ bal clean <target-directory-path>

Describe your problem(s)

Since the help description says, Remove the 'target' directory created during the build, the bal clean command should be limited to ballerina related directories. Some users might mistakenly provide the project directory instead of the target directory for the bal clean --target-dir <path> and get the project directory deleted.

Describe your solution(s)

It is possible to do a content validation before deleting the provided directory. We can check whether a bin\ directory is present inside the given target directory. If such a directory is not present or if there are unrecognized subdirectories we can halt the deletion and ask for verification in the CLI.

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@ballerina-bot ballerina-bot added needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needTriage The issue has to be inspected and labeled manually Type/Improvement userCategory/Compilation
Projects
None yet
Development

No branches or pull requests

2 participants