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

Validate project config srcDir within project root #951

Merged
merged 4 commits into from
Nov 7, 2023

Conversation

mendel-at-hubspot
Copy link
Contributor

@mendel-at-hubspot mendel-at-hubspot commented Nov 3, 2023

Description and Context

Adds validation within validateProjectConfig to ensure the srcDir of a project points to either the project root, or a subdirectory. This will help ensure a user doesn't attempt to upload a parent or root directory by mistake.

Adds a suite of jest tests to confirm our current validations, as well as the new validation logic.

To support the testing with mocks around process.exit, added return statements to all the spots in validateProjectConfig where the whole node process would be existing anyway. Open to reverting those changes and using exceptions in the mocking of process.exit if that'd be cleaner / clearer.

Screenshots

Screenshot 2023-11-06 at 12 24 53 PM

cc @camden11 @brandenrodgers

Adds validation within `validateProjectConfig` to ensure the srcDir of a project points to either the project root, or a subdirectory.
This will help ensure a user doesn't attempt to upload a parent or root directory by mistake.

Adds a suite of jest tests to confirm our current validations, as well as the new validation logic.

To support the testing with mocks around `process.exit`, added `return` statements to all the spots in `validateProjectConfig` where the whole node process would be existing anyway.
Open to reverting those changes and using exceptions in the mocking of `process.exit` if that'd be cleaner / clearer.
Also reworks the error message for srcOutsideProjectDir to be more informative and actionable
Drops including the "project root" filesystem path, and just has the message say project root.
@@ -87,6 +88,8 @@ exports.handler = async options => {
process.exit(EXIT_CODES.ERROR);
}

validateProjectConfig(projectConfig, projectDir);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Callout for the top level PR. This addition is intentional.
The dev command should be validating the project configuration for use later on.

@mendel-at-hubspot mendel-at-hubspot merged commit df3e4cb into master Nov 7, 2023
1 check passed
@mendel-at-hubspot mendel-at-hubspot deleted the validate-src-dir-within-project branch November 7, 2023 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants