Skip to content

Copying the "archived/" directory from recipes-checker #1037

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

Merged
merged 3 commits into from
Dec 17, 2021
Merged

Copying the "archived/" directory from recipes-checker #1037

merged 3 commits into from
Dec 17, 2021

Conversation

weaverryan
Copy link
Member

Q A
License MIT
Doc issue/PR TODO (mentioned on the main PR)

See symfony/flex#845

Once symfony-tools/recipes-checker#2 is merged, this can be merged.

@@ -47,5 +47,8 @@ jobs:
git rm -q *.json
mv .github/flex-endpoint/*.json .
git add *.json
# merge in new archived files
for file in ../flex_endpoint/archived/*/*.json; do mv "$file" "archived/$(basename $(dirname "$file"))/$(basename "$file")"; done
Copy link
Member

Choose a reason for hiding this comment

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

where does flex_endpoint come from?
shouldn't this be mkdir -p archived; mv .github/flex-endpoint/archived/*.json archived/ instead?

Copy link
Member Author

@weaverryan weaverryan Dec 17, 2021

Choose a reason for hiding this comment

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

Ha! Yes, sorry - you're right - this was a local testing path.

So I've added the mkdir -p archived (that was missing)Ha! Yes, sorry - you're right - this was a local testing path.

I've added the mkdir -p archived (that was missing). I've also fixed the path.

However, I don't think (EDIT: I confirmed it doesn't work) that the mv you suggested works because the .json files are in subdirectories - e.g. they are archived/symfony.twig-bundle.3.3/e13a79427495e670ef7a19f0e25fd13fbdd909d4.json. It IS very possible that my mv statement can be simplified, let me know if you have an idea :)

@@ -47,5 +47,9 @@ jobs:
git rm -q *.json
mv .github/flex-endpoint/*.json .
git add *.json
Copy link
Member

Choose a reason for hiding this comment

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

just after:

cp -a .github/flex-endpoint/archived .
git add archived/

and remove the rest?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, you nailed it - that worked. Thank you for pointing that out :)

@nicolas-grekas nicolas-grekas merged commit 2120e69 into symfony:main Dec 17, 2021
fabpot added a commit to symfony/flex that referenced this pull request Jan 19, 2022
This PR was squashed before being merged into the 1.x branch.

Discussion
----------

Merge-powered recipe update system

Hi!

tl;dr; Updating recipes was a pain. Now its easy: the new `recipes:update` command performs a smart "patch" to your project of what actually changed in the recipe.

[![asciicast](https://asciinema.org/a/456707.svg)](https://asciinema.org/a/456707)

If you run simply `composer recipes:update`, then it will ask you what to update, from a list of only the out-dated recipes (thanks to @shadowc for the idea!):

<img width="696" alt="Screen Shot 2021-12-17 at 11 18 09 AM" src="https://user-images.githubusercontent.com/121003/146575617-8ca7c6c8-1897-4fb4-be33-cdd5bf6894c0.png">

As you can see, if there are conflicts, you fix them like normal git conflicts. In addition to the unit tests, I've tried this on a fairly out-dated project and it worked *brilliantly*. This was NOT possible until @nicolas-grekas open sourced the Flex server - so a HUGE thanks 🎆

### How It Works

A) Whenever `symfony/recipes` (or contrib) has a new commit, a GitHub action *already* stores each recipe as JSON, which becomes the "recipe API": https://github.com/symfony/recipes/tree/flex/main. A change to that action (symfony/recipes#1037) and the recipes-checker (symfony-tools/recipes-checker#2) will add an "archived/" directory that contains EVERY version of every recipe. You can see an example in my fork: https://github.com/weaverryan/recipes/tree/flex/main/archived

B) When you run `recipes:update <package/name>`, we fetch the "original" recipe and "new" recipe and then pass both to each "configurator". Its job is to say what files would exist and what they would look if the "original" recipe were installed now and if the "new" recipe were installed now.

C) We use these "original files" and "new files" to generate a patch file.

D) We apply that patch file to the user's actual project. There are a few tricks here, like temporarily inserting the git "blob" for what the "original" version of the file would look like. That allows for a 3-way merge.

So, while it was a bit of work, it's a fairly straightforward process. It makes keeping your recipes up to date both easy and rewarding.

## TODOS

* [x] Merge recipes-checker PR symfony-tools/recipes-checker#2
* [x] Merge symfony/recipes PR symfony/recipes#1037
* [x] Update `Downloader` in this PR to remove 2x TODOs that the above PR's will enable
* [x] Make sure the `archived/` directory is populated for both `recipes` and `recipes-contrib` - see symfony-tools/recipes-checker#3 and symfony/recipes#1038
* [x] Document that this now exists symfony/symfony-docs#16301

Cheers!

Commits
-------

3ee7719 Merge-powered recipe update system
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