Automattic / vip-cli

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

Refactor `dev-env sync`, `dev-env import` and `export-sql` to TypeScript #1955

Closed abdullah-kasim closed 1 month ago

abdullah-kasim commented 1 month ago

Description

Just refactoring dev-env sync. dev-env import, and export-sql to TypeScript

Note that there's some logic changes that I'll note, but almost all of these changes are just adding types.

Pull request checklist

New release checklist

Steps to Test

  1. Check out PR.
  2. Run npm run build
  3. Run ./dist/bin/vip-export-sql.js @6462.production
  4. Get an output like this:
    ./dist/bin/vip-export-sql.js @6462.production
    ✓ Latest backup found with timestamp 2024-07-25T08:36:06.000Z
    Attaching to an existing export for the backup with timestamp 2024-07-25T08:36:06.000Z
    ✓ Preparing for backup download 
    ✓ Creating backup copy 
    ✓ Checking if there's enough storage 
    ✓ Requesting download link 
    ✓ Downloading file - 100.00% (142.86 KB/142.86 KB)
    File saved to /Users/uzer/Documents/Development/vip-cli/2024-07-25T0836UTC-6462.abdullaha8ctest.blog-0ffee71288d22474-db-backup.sql.gz

And for testing the vip dev-env sync flow:

  1. Ensure that you have a dev environment running i.e. run vip @6462.production dev-env create
  2. Run ./dist/bin/vip-dev-env-sync-sql.js @6462.production --slug=6462-production
  3. You should get an output like below:
    $ ./dist/bin/vip-dev-env-sync-sql.js @6462.production --slug=6462-production
    ✓ Latest backup found with timestamp 2024-07-25T08:36:06.000Z
    Attaching to an existing export for the backup with timestamp 2024-07-25T08:36:06.000Z
    ✓ Preparing for backup download 
    ✓ Creating backup copy 
    ✓ Checking if there's enough storage 
    ✓ Requesting download link 
    ✓ Downloading file - 100.00% (142.86 KB/142.86 KB)
    File saved to /var/folders/zv/h4914qz12lq5mbkl151xh8hh0000gn/T/vip-cli-E7qVN1/sql-export.sql.gz
    Extracting the exported file /var/folders/zv/h4914qz12lq5mbkl151xh8hh0000gn/T/vip-cli-E7qVN1/sql-export.sql.gz...
    ✓ Extracted to /var/folders/zv/h4914qz12lq5mbkl151xh8hh0000gn/T/vip-cli-E7qVN1/sql-export.sql
    Extracting site urls from the SQL file...
    Generating search-replace configuration...
    Running the following search-replace operations on the SQL file:
    abdullah-multi-vip-test.go-vip.net -> 6462-production.vipdev.lndo.site
    6462-2.abdullaha8ctest.blog -> 6462-2-abdullaha8ctest-blog-2.6462-production.vipdev.lndo.site
    6462.abdullaha8ctest.blog -> 6462-production.vipdev.lndo.site
    ✓ Search-replace operation is complete
    Importing the SQL file...
    mysql: [Warning] Using a password on the command line interface can be insecure.
    ✓ SQL file imported
  4. Then, go to 6462-production.vipdev.lndo.site and things should just work
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
7 New issues
2 Accepted issues

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

See analysis details on SonarCloud