Last active
July 26, 2022 18:43
-
-
Save j-steinbach/e2f4c320af570c1fdbc9971772a2405a to your computer and use it in GitHub Desktop.
This fish script grabs the source code of all Solid apps from solidprojects.org and clones them into a sub-dir. No warranty/liabality/etc. Use on your own risk.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/fish | |
| # clone all the example solid projects | |
| # 1. curl https://solidproject.org/apps | |
| # 2. regex: https:\/\/github.com\/[a-zA-Z0-9-]+\/[a-zA-Z0-9-]+\" | |
| # 3. clean list, remove duplicates | |
| # 4. create subfolder (if not already existing) | |
| # 5. for each gitrepo: clone it! | |
| set url "https://solidproject.org/apps" | |
| set regex "https:\/\/github.com\/[a-zA-Z0-9-]+\/[a-zA-Z0-9-]+\"" | |
| set folder community-apps | |
| echo -e "Getting website source\n" | |
| set website_source (curl -s $url) | |
| echo -e "$website_source\n" | |
| echo -e "Searching for github projects\n" | |
| set urls (string match -a -r $regex $website_source ) | |
| echo -e "$urls\n" | |
| echo -e "Stripping trailing \"\n" | |
| set urls_stripped (string replace \" "" $urls) | |
| echo -e "$urls_stripped\n" | |
| echo -e "Removing duplicates\n" | |
| set urls_sorted (printf "%s\n" $urls_stripped | sort -u) | |
| echo $urls_sorted | |
| echo -e "Creating subdir\n" | |
| if test -d $folder | |
| else | |
| mkdir $folder | |
| end | |
| echo -e "Descending into subdir\n" | |
| cd $folder | |
| echo -e "Will clone $(count $urls_sorted) projects\n" | |
| echo -e "Cloning...\n" | |
| for u in $urls_sorted | |
| set dirname (string replace -r 'https:\/\/github.com\/([\w\_-]+)\/([\w_-]+)' '$1-$2' $u) | |
| echo -e "\n..$u into $dirname" | |
| git clone $u $dirname | |
| end | |
| echo -e "Done!" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Improvements to be made:
write to "username/repo" to make sure that no project gets overwrittenDONE