Automattic / vip-cli

The VIP CLI
https://docs.wpvip.com/vip-cli/
MIT License
58 stars 16 forks source link

Gracefully fail when directory is not detected #1947

Closed ariskataoka closed 1 month ago

ariskataoka commented 1 month ago

Description

When a user attempts to validate a non-valid folder using the vip import validate-files command, vip-cli fails ungracefully. This PR includes an error message for that scenario and also adds some unit tests for the vip import validate-files command.

Issue pointed here.

Before:

➜  vip-cli git:(trunk) ✗ node ./dist/bin/vip-import-validate-files.js ~/Downloads/wp-content.zip
✕  Error: Cannot read nested directory: /Users/ariskataoka/Downloads/wp-content.zip. Reason: ENOTDIR: not a directory, scandir '/Users/ariskataoka/Downloads/wp-content.zip'
✕ Please contact VIP Support with the following information:
TypeError: Cannot destructure property 'files' of 'nestedFiles' as it is undefined.
    at /Users/ariskataoka/Projects/vip-cli/dist/bin/vip-import-validate-files.js:43:5
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async _args.default.argv (/Users/ariskataoka/Projects/vip-cli/dist/lib/cli/command.js:444:11)
Error:  Unexpected error
Debug:  VIP-CLI v3.7.1-dev.0, Node v18.20.2, darwin 23.5.0 arm64

After:

➜  vip-cli git:(fix/import-validate-files-not-directory-error) ✗ node ./dist/bin/vip-import-validate-files.js ~/Downloads/wp-content.zip 
✕ Error: The given path is not a directory, please provide a valid directory path.

Pull request checklist

New release checklist

Steps to Test

Outline the steps to test and verify the PR here.

Example:

  1. Check out PR.
  2. Run npm run build
  3. Run node ./dist/bin/vip-import-validate-files.js any.zip
  4. Verify error message.
github-actions[bot] commented 1 month ago

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud