acquia / cli

Acquia CLI
GNU General Public License v2.0
42 stars 47 forks source link

Make `acli app:new:from:drupal7` default to the latest AMA recommendations on d.o #1588

Closed wimleers closed 1 year ago

wimleers commented 1 year ago

Motivation

1543 added acli app:new:from:drupal7. πŸ‘ Next steps in open sourcing: https://git.drupalcode.org/project/acquia_migrate/-/tree/recommendations is live.

So now let's get it all working together. Unfortunately, this made me hit an edge case in GitLab and/or PHP. I opened #1587 for that.

Ideally, we'd get the command to automatically download the latest, to allow you to omit --recommendations.

That'd be a much better UX than having to specify a long URL manually.

Proposed changes

Defaulting to automatically downloading the latest is a one-line change:

-    $recommendations_location = __DIR__ . '/../../../config/from_d7_recommendations.json';
+    $recommendations_location = "https://git.drupalcode.org/project/acquia_migrate/-/raw/recommendations/recommendations.json";

(plus the bugfix in #1587)

+    // PHP defaults to no user agent. (Drupal.org's) GitLab requires it.
+    // @see https://www.php.net/manual/en/filesystem.configuration.php#ini.user-agent
+    ini_set('user_agent', 'ACLI');
     $recommendations_resource = fopen($recommendations_location, 'r');

☝️ That's literally the whole PR! πŸ˜„

Alternatives considered

1587 is the absolute minimum.

Testing steps Before:

$ ./bin/acli app:new:from:drupal7 --directory=/tmp/foo  --stored-analysis tests/fixtures/drupal7/training.acquia.com/extensions.json 
πŸ€– Scanning Drupal 7 site.
πŸ‘ Found Drupal 7 site (7.70 to be precise) at <location unknown>, with 96 modules enabled!
πŸ€– Computing recommendations for this Drupal 7 site…
πŸ₯³ Great news: found 9 recommendations that apply to this Drupal 7 site, resulting in a composer.json with:
    - 11 packages
    - 1 patches
    - 4 modules to be installed!
πŸš€ Generated composer.json and committed to a new git repo.
…

After:

$ ./bin/acli app:new:from:drupal7 --directory=/tmp/foo  --stored-analysis tests/fixtures/drupal7/training.acquia.com/extensions.json 
πŸ€– Scanning Drupal 7 site.
πŸ‘ Found Drupal 7 site (7.70 to be precise) at <location unknown>, with 96 modules enabled!
πŸ€– Computing recommendations for this Drupal 7 site…
πŸ₯³ Great news: found 105 recommendations that apply to this Drupal 7 site, resulting in a composer.json with:
    - 46 packages
    - 1 patches
    - 64 modules to be installed!
πŸš€ Generated composer.json and committed to a new git repo.
…

Note: 11 β†’ 46 packages, 4 β†’ 64 modules!

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (4affeb3) 91.76% compared to head (0307191) 91.76%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1588 +/- ## ========================================= Coverage 91.76% 91.76% Complexity 1809 1809 ========================================= Files 124 124 Lines 6470 6471 +1 ========================================= + Hits 5937 5938 +1 Misses 533 533 ``` | [Files Changed](https://app.codecov.io/gh/acquia/cli/pull/1588?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=acquia) | Coverage Ξ” | | |---|---|---| | [src/Command/App/NewFromDrupal7Command.php](https://app.codecov.io/gh/acquia/cli/pull/1588?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=acquia#diff-c3JjL0NvbW1hbmQvQXBwL05ld0Zyb21EcnVwYWw3Q29tbWFuZC5waHA=) | `77.39% <100.00%> (+0.15%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

wimleers commented 1 year ago

If this gets merged, #1587 can be closed.