Automattic / vip-cli

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

Update: media import validation #1919

Closed ariskataoka closed 1 month ago

ariskataoka commented 2 months ago

Description

While maintaining previous validations, such as folder structure, this PR updates the media file validation implementation. The configuration for these validations will originate from the public API.

Pull request checklist

New release checklist

Test

Data

The uploads folder should contain files with invalid types/extensions, large files (more than 2GB), and files with long names (more than 255 chars).

Steps

  1. Check out PR.

  2. Run npm run build

  3. Login with a valid token node ./dist/bin/vip login

  4. Run node ./dist/bin/vip-import-validate-files.js <MY_FOLDER_NAME> to trigger the validation for the content within a specific folder

  5. Verify the validation result

github-actions[bot] commented 2 months ago

Dependency Review

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

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

saroshaga commented 2 months ago

When I accidently applied this command to an archive file, it failed ungracefully

→ node ./dist/bin/vip-import-validate-files.js @2786.production ~/Downloads/wp-content.tar.gz 
✕  Error: Cannot read nested directory: /Users/saroshaga/Downloads/wp-content.tar.gz. Reason: ENOTDIR: not a directory, scandir '/Users/saroshaga/Downloads/wp-content.tar.gz'
✕ Please contact VIP Support with the following information:
TypeError: Cannot destructure property 'files' of 'nestedFiles' as it is undefined.
    at /Users/saroshaga/Projects/Automattic/vip/dist/bin/vip-import-validate-files.js:67:5
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async _args.default.argv (/Users/saroshaga/Projects/Automattic/vip/dist/lib/cli/command.js:444:11)
Error:  Unexpected error
Debug:  VIP-CLI v3.5.1-dev.0, Node v18.20.2, darwin 23.5.0 x64

Maybe we should fail gracefully if a directory is not detected at the start. Can do this in a separate PR too!

ariskataoka commented 1 month ago

When I accidently applied this command to an archive file, it failed ungracefully ... Maybe we should fail gracefully if a directory is not detected at the start. Can do this in a separate PR too!

Good finding! Gonna raise a different PR for that one.

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