diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index efe6892543c..69256cf724a 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -6,40 +6,54 @@ We are always after more contributors and suggestions. #### Does it relate to our API (backend)... ? - 1. Please check the [previously reported API issues](https://github.com/CPAN-API/cpan-api/issues) - 2. Please check the [Wishlist](https://github.com/CPAN-API/cpan-api/wiki/Wishlist). If you can't find it already there: - * If it's a wishlist idea, please edit the [wiki](https://github.com/CPAN-API/cpan-api/wiki/Wishlist) (add a 'wishlist_MYIDEA' page if you need more space!) - * If it's an actual bug [create a new issue](https://github.com/CPAN-API/cpan-api/issues/new) +1. Please check the + [previously reported API issues](https://github.com/CPAN-API/cpan-api/issues) +2. Please check the + [Wishlist](https://github.com/CPAN-API/cpan-api/wiki/Wishlist). If you can't + find it already there: + - If it's a wishlist idea, please edit the + [wiki](https://github.com/CPAN-API/cpan-api/wiki/Wishlist) (add a + 'wishlist_MYIDEA' page if you need more space!) + - If it's an actual bug + [create a new issue](https://github.com/CPAN-API/cpan-api/issues/new) #### If you are not sure, or it is related to https://metacpan.org/ front end: - 1. Please check the [previously reported Web issues](https://github.com/CPAN-API/metacpan-web/issues) - 2. Please check the [Wishlist](https://github.com/CPAN-API/cpan-api/wiki/Wishlist). If you can't find it already there: - * If it's a wishlist idea, please edit the [wiki](https://github.com/CPAN-API/cpan-api/wiki/Wishlist) (add a 'wishlist_MYIDEA' page if you need more space!) - * If it's an actual bug [create a new issue](https://github.com/CPAN-API/metacpan-web/issues/new) +1. Please check the + [previously reported Web issues](https://github.com/CPAN-API/metacpan-web/issues) +2. Please check the + [Wishlist](https://github.com/CPAN-API/cpan-api/wiki/Wishlist). If you can't + find it already there: + - If it's a wishlist idea, please edit the + [wiki](https://github.com/CPAN-API/cpan-api/wiki/Wishlist) (add a + 'wishlist_MYIDEA' page if you need more space!) + - If it's an actual bug + [create a new issue](https://github.com/CPAN-API/metacpan-web/issues/new) ## Contributing code Come talk to us on IRC (see below), or send a pull request and we'll respond -there. If you implement a new feature, please add a note about it to the -News.md file at the top level of metacpan-web so that it will appear in our -news feed. +there. If you implement a new feature, please add a note about it to the News.md +file at the top level of metacpan-web so that it will appear in our news feed. -If you aren't using the VM, remember to enable the pre-commit hook before you start working. +If you aren't using the VM, remember to enable the pre-commit hook before you +start working. sh git/setup.sh These links will get you going quickly: - * [Using our developer VM](https://github.com/CPAN-API/metacpan-developer) to get you going in minutes (depending on bandwidth) - * [Front end bug list](https://github.com/CPAN-API/metacpan-web/issues) - * [API (back end) bug list](https://github.com/CPAN-API/cpan-api/issues) - * [Wishlist](https://github.com/CPAN-API/cpan-api/wiki/Wishlist) - things that probably need doing +- [Using our developer VM](https://github.com/CPAN-API/metacpan-developer) to + get you going in minutes (depending on bandwidth) +- [Front end bug list](https://github.com/CPAN-API/metacpan-web/issues) +- [API (back end) bug list](https://github.com/CPAN-API/cpan-api/issues) +- [Wishlist](https://github.com/CPAN-API/cpan-api/wiki/Wishlist) - things that + probably need doing # Git workflow We try to keep a clean git history, so if it all possible, please rebase to get -the latest changes from master _before_ submitting a pull request. You'll only +the latest changes from master _before_ submitting a pull request. You'll only need to do the first command (git remote add) once in your local checkout. git remote add upstream https://github.com/CPAN-API/metacpan-web.git @@ -50,17 +64,18 @@ which are no longer relevant to your branch before submitting your work. git rebase -i master -If you are not comfortable with rebasing, but want to use it, check out the steps -from [here](https://help.github.com/articles/using-git-rebase/). +If you are not comfortable with rebasing, but want to use it, check out the +steps from [here](https://help.github.com/articles/using-git-rebase/). # Coding conventions -Please try to follow the conventions already been used in the code base. This -will generally be the right thing to do. Our standards are improving, so even -if you do follow what you see, we may ask you to make some changes, but that is -a good thing. We are trying to keep things tidy. +Please try to follow the conventions already been used in the code base. This +will generally be the right thing to do. Our standards are improving, so even if +you do follow what you see, we may ask you to make some changes, but that is a +good thing. We are trying to keep things tidy. -If you are using the [developer VM](https://github.com/CPAN-API/metacpan-developer) you can run: +If you are using the +[developer VM](https://github.com/CPAN-API/metacpan-developer) you can run: ```sh /home/vagrant/carton/metacpan-web/bin/tidyall @@ -69,24 +84,24 @@ If you are using the [developer VM](https://github.com/CPAN-API/metacpan-develop ## Perl Best Practices In general, the concepts discussed in "Perl Best Practices" are a good starting -point. Use autodie where possible and MetaCPAN::Web::Types when creating new -Moose attributes. Many of the other standards will be enforced by Perl::Critic. +point. Use autodie where possible and MetaCPAN::Web::Types when creating new +Moose attributes. Many of the other standards will be enforced by Perl::Critic. ## Clear > Concise Take pains to use variable names which are easy to understand and to write -readable code. We value readable code over concise code. Use singular nouns -for class names. Use verbs for method names. +readable code. We value readable code over concise code. Use singular nouns for +class names. Use verbs for method names. ## Try::Tiny > eval { ... } -You will see many eval statements in the code. We would like to standardize on +You will see many eval statements in the code. We would like to standardize on Try::Tiny, so feel free to swap out any eval with a Try::Tiny and use Try::Tiny in all new code. ## Prefer single quotes -Always use single quotes in cases where there is no variable interpolation. If +Always use single quotes in cases where there is no variable interpolation. If there is a single quote in the quoted item, use curly quotes. q{Isn't this a lovely day}; @@ -94,46 +109,50 @@ q{Isn't this a lovely day}; ## Include a test (or more!) Any time when a pull request includes a test, it makes it easier for us to -review and accept, so please do test your changes whenever possible. If your +review and accept, so please do test your changes whenever possible. If your pull request includes visual changes, please include a before and after screen shot, so that we can better understand the problem you're trying to solve. ## Dependencies Introducing new dependencies is fine, if they solve a specific problem which -current dependencies cannot address. If we prefer a different module to be used, +current dependencies cannot address. If we prefer a different module to be used, we'll let you know. ## It's OK to be controversial If a pull request contains any controversial changes, we'll likely wait for some -feedback from several developers before a merge. If you think your changes may +feedback from several developers before a merge. If you think your changes may be controversial, feel free to discuss them in a GitHub issue before starting to write any code. ## Travis is your friend -We use Travis to test all code changes. After submitting your pull request, +We use Travis to test all code changes. After submitting your pull request, remember to check back to see whether Travis has come back with any test -failures. We do get some false negatives. If your pull request failed for +failures. We do get some false negatives. If your pull request failed for reasons unrelated to your changes, we may still be able to merge your work. # Additional Resources - * [\#metacpan](http://widget01.mibbit.com/?autoConnect=true&server=irc.perl.org&channel=%23metacpan&nick=) IRC channel on irc.perl.org +- [\#metacpan](http://widget01.mibbit.com/?autoConnect=true&server=irc.perl.org&channel=%23metacpan&nick=) + IRC channel on irc.perl.org # Current Policies ### What is indexed? - * Perl distributions which contain Perl packages. +- Perl distributions which contain Perl packages. ### When are issues closed? We want to keep the issue list manageable, so we can focus on what actually -needs fixing. If you feel an issue needs opening again, please add a comment +needs fixing. If you feel an issue needs opening again, please add a comment explaining why it needs re-opening and we'll look at it again. - * Issues will be closed and moved to [Wishlist](https://github.com/CPAN-API/cpan-api/wiki/Wishlist) if they are not actual bugs - * Issues we think we have addressed will be closed - * Issues we are not going to take any further action on without more information will be closed +- Issues will be closed and moved to + [Wishlist](https://github.com/CPAN-API/cpan-api/wiki/Wishlist) if they are not + actual bugs +- Issues we think we have addressed will be closed +- Issues we are not going to take any further action on without more information + will be closed diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 81556677f70..03065edabbc 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,42 +1,43 @@ --- name: Bug report about: Create a report to help us improve -title: '' +title: "" labels: ["type:Bug"] -assignees: '' - +assignees: "" --- **PLEASE NOTE** -This issue tracker is for bugs in the https://metacpan.org web site. If you are are reporting a bug about anything else, this is most likely not the correct venue. Please use the left side menu for the module you are interested in and click the `Issues` link in order to find the bug tracker for your module. +This issue tracker is for bugs in the https://metacpan.org web site. If you are +are reporting a bug about anything else, this is most likely not the correct +venue. Please use the left side menu for the module you are interested in and +click the `Issues` link in order to find the bug tracker for your module. + +**Describe the bug** A clear and concise description of what the bug is. -**Describe the bug** -A clear and concise description of what the bug is. +**To Reproduce** Steps to reproduce the behavior: -**To Reproduce** -Steps to reproduce the behavior: 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' 4. See error -**Expected behavior** -A clear and concise description of what you expected to happen. +**Expected behavior** A clear and concise description of what you expected to +happen. -**Screenshots** -If applicable, add screenshots to help explain your problem. +**Screenshots** If applicable, add screenshots to help explain your problem. **Desktop (please complete the following information):** - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] + +- OS: [e.g. iOS] +- Browser [e.g. chrome, safari] +- Version [e.g. 22] **Smartphone (please complete the following information):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] -**Additional context** -Add any other context about the problem here. +- Device: [e.g. iPhone6] +- OS: [e.g. iOS8.1] +- Browser [e.g. stock browser, safari] +- Version [e.g. 22] + +**Additional context** Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 38317be1310..ade111c2a2c 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,21 +1,18 @@ --- name: Feature request about: Request a feature to be added -title: '' +title: "" labels: ["type:Feature"] -assignees: '' - +assignees: "" --- -**Describe the feature** -A clear and concise description of what the feature is. + +**Describe the feature** A clear and concise description of what the feature is. **Which problem does it solve?** -**Expected behavior** -A clear and concise description of what you expect to see. +**Expected behavior** A clear and concise description of what you expect to see. -**Volunteering** -Are you willing to implement (or help to implement) this feature? +**Volunteering** Are you willing to implement (or help to implement) this +feature? -**Additional context** -Add any other context about the request here. +**Additional context** Add any other context about the request here. diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 0d206a676e1..83871979551 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,4 +1,4 @@ -name: "Code scanning - action" +name: 'Code scanning - action' on: push: @@ -10,39 +10,38 @@ on: jobs: CodeQL-Build: - runs-on: ubuntu-22.04 steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. - fetch-depth: 2 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - # Override language selection by uncommenting this and choosing your languages - # with: - # languages: go, javascript, csharp, python, cpp, java - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v3 - - # ℹ️ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 + - name: Checkout repository + uses: actions/checkout@v4 + with: + # We must fetch at least the immediate parents so that if this is + # a pull request then we can checkout the head. + fetch-depth: 2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + # Override language selection by uncommenting this and choosing your languages + # with: + # languages: go, javascript, csharp, python, cpp, java + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v3 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fd916a44912..955cada7f18 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,10 +3,10 @@ name: test on: push: branches: - - "master" + - 'master' pull_request: branches: - - "*" + - '*' workflow_dispatch: jobs: @@ -28,19 +28,24 @@ jobs: fail-fast: false matrix: perl-version: - - "5.30" + - '5.30' resolver: - snapshot - metacpan container: image: perl:${{ matrix.perl-version }} env: - DEVEL_COVER_OPTIONS: "-ignore,^local/" + DEVEL_COVER_OPTIONS: '-ignore,^local/' steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 + if: matrix.resolver == 'snapshot' + - uses: actions/checkout@v4 + if: matrix.resolver != 'snapshot' - uses: actions/setup-node@v4 with: - node-version: "18" + node-version: '18' - run: npm install - run: apt-get update && apt-get -y install libcmark-dev - name: Install Carton @@ -51,7 +56,7 @@ jobs: - name: Install CPAN deps uses: perl-actions/install-with-cpm@v1 with: - cpanfile: "cpanfile" + cpanfile: 'cpanfile' sudo: false args: > --resolver ${{ matrix.resolver }} @@ -83,3 +88,17 @@ jobs: run: cover -report codecov env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + - name: Install precious + run: ./bin/install-precious /usr/local/bin + - name: Install perlimports + run: cpm install -g App::perlimports + if: matrix.resolver == 'snapshot' + - name: Fetch master + run: git fetch origin master:master + if: github.ref != 'refs/heads/master' && matrix.resolver == 'snapshot' + - name: Lint files in diff (branch) + run: precious lint -d master + if: github.ref != 'refs/heads/master' && matrix.resolver == 'snapshot' + - name: Lint all files (master) + run: precious lint --all + if: github.ref == 'refs/heads/master' && matrix.resolver == 'snapshot' diff --git a/.github/workflows/update-snapshot.yml b/.github/workflows/update-snapshot.yml index b5eafc1614b..ab3816670de 100644 --- a/.github/workflows/update-snapshot.yml +++ b/.github/workflows/update-snapshot.yml @@ -1,11 +1,11 @@ name: Update cpanfile.snapshot on: schedule: - - cron: "1 15 * * 0" + - cron: '1 15 * * 0' workflow_dispatch: jobs: update-dep: - runs-on: "ubuntu-20.04" + runs-on: 'ubuntu-20.04' steps: - name: Generate Auth Token id: auth-token diff --git a/.gitignore b/.gitignore index 54f143a6ffe..6ed7fd6ad15 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,3 @@ -!/root/assets/.gitignore -*.bak -*.sw* -.DS_Store /.carton /.includepath /.project @@ -18,7 +14,13 @@ /node_modules/ /perltidy.LOG /pm_to_blib -/root/assets -/root/static/sitemaps /tidyall.ERR /var +/bin/precious +/bin/ubi +/root/assets +/root/static/sitemaps +*.bak +*.sw* +.DS_Store +!/root/assets/.gitignore diff --git a/Dockerfile b/Dockerfile index 163d2008d76..ce48e1e77ad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -114,7 +114,7 @@ RUN \ cpm install --show-build-log-on-failure --resolver=snapshot --with-test EOT -COPY .perlcriticrc .perltidyrc perlimports.toml tidyall.ini ./ +COPY .perlcriticrc .perltidyrc perlimports.toml ./ COPY t t USER metacpan diff --git a/News.md b/News.md index 033b3e5ddaf..d57e32854ad 100644 --- a/News.md +++ b/News.md @@ -1,26 +1,28 @@ -Title: Source code permalinks are here ------------------------------- +## Title: Source code permalinks are here + Date: 2020-03-29T00:00:00 -Versioned permalinks from source code pages are [now available](https://twitter.com/metacpan/status/1244677954275336200) +Versioned permalinks from source code pages are +[now available](https://twitter.com/metacpan/status/1244677954275336200) + +## Title: Rendering .md files -Title: Rendering .md files ------------------------------- Date: 2019-10-18T01:54:00 We're now rendering .md files as HTML instead of as raw code. -Title: The traffic is coming ------------------------------- +## Title: The traffic is coming + Date: 2018-12-02T19:30:00 -As [announced](https://log.perl.org/2018/05/goodbye-search-dot-cpan-dot-org.html) +As +[announced](https://log.perl.org/2018/05/goodbye-search-dot-cpan-dot-org.html) in the Perl NOC, search.cpan.org is going to redirect all traffic to MetaCPAN -from 25th of June 2018. We are doing lots of work to prepare for this -trebling of traffic. +from 25th of June 2018. We are doing lots of work to prepare for this trebling +of traffic. + +## Title: MetaHack 2 -Title: MetaHack 2 ------------------------------- Date: 2017-11-02T19:30:00 http://www.olafalders.com/2017/10/12/announcing-metahack-v2/ @@ -29,144 +31,149 @@ https://metacpan.org/about/meta_hack http://blogs.perl.org/users/leo_lapworth/2017/11/metahack-2.html +## Title: SSL improvements - - -Title: SSL improvements ------------------------------- Date: 2014-12-02T19:30:00 -Our servers have had their SSL configuration upgraded, -so we now get an A rating on [SSL Labs](https://www.ssllabs.com/ssltest/analyze.html?d=fastapi.metacpan.org). +Our servers have had their SSL configuration upgraded, so we now get an A rating +on +[SSL Labs](https://www.ssllabs.com/ssltest/analyze.html?d=fastapi.metacpan.org). + +[Fastly](https://www.fastly.com) who serve all our content other than the +[api](https://fastapi.metacpan.org/) already had tight configs... and now so do +we. I'd like to thank then for providing both examples, support and an IRC +channel where Donald Stufft from the Python infrastructure team was able to help +out. -[Fastly](https://www.fastly.com) who serve all our content -other than the [api](https://fastapi.metacpan.org/) already had -tight configs... and now so do we. I'd like to thank then for providing -both examples, support and an IRC channel where Donald Stufft -from the Python infrastructure team was able to help out. +All our configs and systems are in our +[github repos](https://github.com/metacpan/) so feel free to review / improve or +'borrow' configs from. -All our configs and systems are in our [github repos](https://github.com/metacpan/) -so feel free to review / improve or 'borrow' configs from. +## Title: Liquid Web is Sponsoring MetaCPAN -Title: Liquid Web is Sponsoring MetaCPAN ------------------------------- Date: 2014-11-08T03:00:00 -We're immensely pleased to announce that [Liquid Web -Inc.](https://www.liquidweb.com/) is our newest hosting sponsor. This -sponsorship entails 3 powerful machines which are provided and co-located by -Liquid Web Inc. Having access to this hardware will allow us greater +We're immensely pleased to announce that +[Liquid Web Inc.](https://www.liquidweb.com/) is our newest hosting sponsor. +This sponsorship entails 3 powerful machines which are provided and co-located +by Liquid Web Inc. Having access to this hardware will allow us greater redundancy in addition to giving us powerful machines to use as a staging area -when developing new MetaCPAN features. This is a huge development for us and -we'd like to thank Liquid Web Inc. for this very kind donation. More details -to come! +when developing new MetaCPAN features. This is a huge development for us and +we'd like to thank Liquid Web Inc. for this very kind donation. More details to +come! + +## Title: Server move - phase 2 -Title: Server move - phase 2 ------------------------------- Date: 2014-10-21T19:00:00 -We have moved all sites over to [Fastly](https://www.fastly.com) -(where possible) and they are backed up by the new +We have moved all sites over to [Fastly](https://www.fastly.com) (where +possible) and they are backed up by the new [Bytemark](https://www.bytemark.co.uk/) servers. -We have further plans... but this will do for now, -many thanks to our sponsors for making this possible. +We have further plans... but this will do for now, many thanks to our sponsors +for making this possible. -[network-infrastructure](https://github.com/metacpan/network-infrastructure) -and [metacpan-puppet](https://github.com/metacpan/metacpan-puppet) have all -our configs if you want to see details of anything. +[network-infrastructure](https://github.com/metacpan/network-infrastructure) and +[metacpan-puppet](https://github.com/metacpan/metacpan-puppet) have all our +configs if you want to see details of anything. +## Title: Server move - phase 1 -Title: Server move - phase 1 ------------------------------- Date: 2014-09-19T19:00:00 -We are moving servers, [Bytemark](https://www.bytemark.co.uk/) have -asked for the old one back... and given us 2 new ones in replacement! +We are moving servers, [Bytemark](https://www.bytemark.co.uk/) have asked for +the old one back... and given us 2 new ones in replacement! -We are moving as much as possible to [Fastly](https://www.fastly.com) CDN -which makes switching origins very easy, and instant. +We are moving as much as possible to [Fastly](https://www.fastly.com) CDN which +makes switching origins very easy, and instant. So far we have moved... -* http(s)://cpan.metacpan.org/ -* http://explorer.metacpan.org/ -* http://search.mcpan.org/ -* http://mcpan.org/ +- http(s)://cpan.metacpan.org/ +- http://explorer.metacpan.org/ +- http://search.mcpan.org/ +- http://mcpan.org/ -We will be documenting this a bit more under [Network Infrastructure](https://github.com/metacpan/network-infrastructure) -but that's a work in progress. +We will be documenting this a bit more under +[Network Infrastructure](https://github.com/metacpan/network-infrastructure) but +that's a work in progress. +## Title: Let's move to Bootstrap 3 -Title: Let's move to Bootstrap 3 ------------------------------- Date: 2014-08-06T08:55:22 -MetaCPAN has moved to Bootstrap 3 as well as introducing cool icons from [Font Awesome](http://fortawesome.github.io/Font-Awesome/). Let's make MetaCPAN be more colorful! +MetaCPAN has moved to Bootstrap 3 as well as introducing cool icons from +[Font Awesome](http://fortawesome.github.io/Font-Awesome/). Let's make MetaCPAN +be more colorful! + +## Title: Link to Task::Kensho is now available on home page and no result page -Title: Link to Task::Kensho is now available on home page and no result page ------------------------------- Date: 2014-06-14T23:25:11 -If you’re absolute newbies who're not even sure what to search, it will be good idea to take a look at [Task::Kensho!](https://metacpan.org/pod/Task::Kensho) We provide a link to the module in both Home page and No result page with the idea to help CPAN beginners to get started. +If you’re absolute newbies who're not even sure what to search, it will be good +idea to take a look at [Task::Kensho!](https://metacpan.org/pod/Task::Kensho) We +provide a link to the module in both Home page and No result page with the idea +to help CPAN beginners to get started. + +## Title: Faster with Fastly -Title: Faster with Fastly ------------------------------- Date: 2014-06-14T18:44:15 -You may have noticed an increase in speed for https://metacpan.org/ -since the 22nd of May, this is because the site is now served -through [Fastly](https://www.fastly.com/). Fastly are providing this -service free of charge. We are not fully utilising is yet (we don't -let Fastly cache much), but it makes all sorts of things easier -for us and we will be able to do even more for you with it in the future. +You may have noticed an increase in speed for https://metacpan.org/ since the +22nd of May, this is because the site is now served through +[Fastly](https://www.fastly.com/). Fastly are providing this service free of +charge. We are not fully utilising is yet (we don't let Fastly cache much), but +it makes all sorts of things easier for us and we will be able to do even more +for you with it in the future. + +## Title: Suggestion on incorrect number of colons -Title: Suggestion on incorrect number of colons ------------------------------- Date: 2014-06-09T08:15:00 -Perl module name should contain only 2 colons, some common mistakes are we underuse or overuse it. Now, suggestion on no result page available when search with missing colon such as [Test:More](https://metacpan.org/search?q=Test%3AMore) or too much colons like [DBIx:::Class::::ResultSet](https://metacpan.org/search?q=DBIx%3A%3A%3AClass%3A%3A%3A%3AResultSet). +Perl module name should contain only 2 colons, some common mistakes are we +underuse or overuse it. Now, suggestion on no result page available when search +with missing colon such as +[Test:More](https://metacpan.org/search?q=Test%3AMore) or too much colons like +[DBIx:::Class::::ResultSet](https://metacpan.org/search?q=DBIx%3A%3A%3AClass%3A%3A%3A%3AResultSet). + +## Title: Table sorting is now persistent -Title: Table sorting is now persistent ------------------------------- Date: 2014-05-19T10:50:12 -When you change the sorting of a table it will be saved in your -browser's localStorage so that the next time you view that particular table -it will remember your last preference. This is saved on a per table basis -(for example, author releases, author favorites, and reverse dependency releases). -No need to set it every time when accessing that page in the same browser. +When you change the sorting of a table it will be saved in your browser's +localStorage so that the next time you view that particular table it will +remember your last preference. This is saved on a per table basis (for example, +author releases, author favorites, and reverse dependency releases). No need to +set it every time when accessing that page in the same browser. + +## Title: Details of (++)plussers displayed -Title: Details of (++)plussers displayed ------------------------------- Date: 2014-05-12T18:40:17 -To get a better insight of which Pause users have ++ed a particular distribution, a list of their gravatar images is displayed. -Also, the count of non-Pause plussers makes it easier to know how many users have liked the module. +To get a better insight of which Pause users have ++ed a particular +distribution, a list of their gravatar images is displayed. Also, the count of +non-Pause plussers makes it easier to know how many users have liked the module. Hence, it gives us a perception of the people who recommend the module. +## Title: Dependency Graphs are Here -Title: Dependency Graphs are Here ------------------------------- Date: 2014-05-13T20:50:10 Jeffrey Thalhammer took the time this week to contribute dependency graphs to -MetaCPAN. The graphs are hosted by [Stratopan](https://stratopan.com) and they +MetaCPAN. The graphs are hosted by [Stratopan](https://stratopan.com) and they can be found on module and release pages under the "Reverse Dependencies" link. Thanks very much to [THALJEF](https://metacpan.org/author/THALJEF) for implementing this new feature. +## Title: News feed of MetaCPAN created -Title: News feed of MetaCPAN created ------------------------------- Date: 2014-04-15T21:10:10 +In this news feed you can follow the development of the MetaCPAN site. There is +also an [Atom feed](/feed/news). -In this news feed you can follow the development of the MetaCPAN site. -There is also an [Atom feed](/feed/news). - -If you are interested in how the news feed itself was implemented, check out -the article [Adding a News Feed to -MetaCPAN](https://perlmaven.com/adding-news-feed-to-metacpan) +If you are interested in how the news feed itself was implemented, check out the +article +[Adding a News Feed to MetaCPAN](https://perlmaven.com/adding-news-feed-to-metacpan) diff --git a/README.md b/README.md index 2c1bf6e7798..44f93b540af 100644 --- a/README.md +++ b/README.md @@ -3,29 +3,32 @@ -* [Getting Started](#getting-started) - * [Installing Manually](#installing-manually) - * [Installing on macOS](#installing-on-macos) - * [Running Tests](#running-tests) - * [Running the App](#running-the-app) - * [Local Git and testing considerations](#local-git-and-testing-considerations) - * [Local Configuration Changes](#local-configuration-changes) - * [Compatibility Notes](#compatibility-notes) +- [Getting Started](#getting-started) + - [Installing Manually](#installing-manually) + - [Installing on macOS](#installing-on-macos) + - [Running Tests](#running-tests) + - [Running the App](#running-the-app) + - [Local Git and testing considerations](#local-git-and-testing-considerations) + - [Local Configuration Changes](#local-configuration-changes) + - [Compatibility Notes](#compatibility-notes) # Getting Started -We strongly recommend using [metacpan-docker](https://github.com/metacpan/metacpan-docker). -This will give you a virtual machine already configured and ready to start developing on. +We strongly recommend using +[metacpan-docker](https://github.com/metacpan/metacpan-docker). This will give +you a virtual machine already configured and ready to start developing on. If you prefer not to use Docker, the following commands will get you started: ## Installing Manually - carton install - npm install - export PATH="$(realpath ./node_modules/.bin):$PATH" +```bash +carton install +npm install +export PATH="$(realpath ./node_modules/.bin):$PATH" +``` ### Installing on macOS @@ -35,19 +38,23 @@ If you like, you can install `carton` via Homebrew: brew install carton ``` -If your `carton install` is having issues with SSL-related modules, you may need to use an `OPENSSL_PREFIX`. Something like: +If your `carton install` is having issues with SSL-related modules, you may need +to use an `OPENSSL_PREFIX`. Something like: ```bash OPENSSL_PREFIX="/usr/local/Cellar/openssl@1.1/1.1.1q" carton install ``` -You may need to check `/usr/local/Cellar/openssl@1.1` to find the latest installed path on your system. +You may need to check `/usr/local/Cellar/openssl@1.1` to find the latest +installed path on your system. ## Running Tests You can use the supplied wrapper around `prove` to run tests: - ./bin/prove t +```bash +./bin/prove t +``` To run the tests in parallel, add `-j8` (or however many CPUs you have) to the `prove` command. @@ -68,19 +75,23 @@ carton exec plackup -p 5001 -s Gazelle -r You will want to set up the supplied pre-commit Git hook like so: - ./git/setup.sh +```bash +./git/setup.sh +``` -which causes `tidyall` to be run before each commit. You can manually -run this with `tidyall path/to/file` +which causes `precious` to be run before each commit. You can manually run this +with `precious path/to/file` ## Local Configuration Changes The back end defaults to `fastapi.metacpan.org`. Running a local API server is -optional and not required to hack on the front end. The address to the API -being used can be changed in the `metacpan_web.conf` file. Ideally you would create a +optional and not required to hack on the front end. The address to the API being +used can be changed in the `metacpan_web.conf` file. Ideally you would create a new file called `metacpan_web_local.conf` that contains - api http://127.0.0.1:5000 +```bash +api http://127.0.0.1:5000 +``` which will be loaded on top of the existing config file. diff --git a/SECURITY.md b/SECURITY.md index 2e705059102..0322ce15f23 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,9 +2,9 @@ ## Supported Versions -| Version | Supported | -| ------- | ------------------ | -| `master` branch | :white_check_mark: | +| Version | Supported | +| --------------- | ------------------ | +| `master` branch | :white_check_mark: | ## Reporting a Vulnerability diff --git a/app.psgi b/app.psgi index 1a59bcd2811..37fb6216a46 100644 --- a/app.psgi +++ b/app.psgi @@ -12,7 +12,6 @@ use Config::ZOMG (); use Log::Log4perl (); use Log::Log4perl::MDC (); use File::Spec (); -use File::Path (); use Plack::Builder qw( builder enable ); use Digest::SHA (); @@ -46,7 +45,7 @@ BEGIN { } use lib "$root_dir/lib"; -use MetaCPAN::Web; +use MetaCPAN::Web (); STDERR->autoflush; diff --git a/bin/install-precious b/bin/install-precious new file mode 100755 index 00000000000..0d712a47070 --- /dev/null +++ b/bin/install-precious @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# This is for installing precious and other 3rd party libs needed for linting +# in CI + +set -euo pipefail + +if [ -z "${1:-}" ]; then + echo "usage: ./bin/install-precious /path/to/bin/dir" + exit 1 +fi + +TARGET=$1 +export TARGET + +TARGET=$1 +export TARGET + +curl --silent --location \ + https://raw.githubusercontent.com/houseabsolute/ubi/master/bootstrap/bootstrap-ubi.sh | + sh + +ubi --project houseabsolute/omegasort --in "$TARGET" +ubi --project houseabsolute/precious --in "$TARGET" diff --git a/cpanfile b/cpanfile index e3d87b0cf39..a0fe98d9565 100644 --- a/cpanfile +++ b/cpanfile @@ -93,8 +93,6 @@ requires 'XML::FeedPP'; # Test dependencies requires 'aliased', '0.34'; requires 'App::Prove'; -requires 'Code::TidyAll', '>= 0.74'; -requires 'Code::TidyAll::Plugin::Test::Vars', '0.04'; requires 'Perl::Critic', '1.136'; requires 'Perl::Tidy' => '20230909'; requires 'Test::Code::TidyAll'; diff --git a/docker-compose.yml b/docker-compose.yml index d07b100ef4e..3e946aea4b9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: volumes: - './root:/build/root/' - 'assets:/build/root/assets/' - command: [ './build-assets.mjs', '--watch' ] + command: ['./build-assets.mjs', '--watch'] server: build: context: . @@ -16,6 +16,6 @@ services: - 'assets:/metacpan-web/root/assets' - '/metacpan-web/local' ports: - - "8000:80" + - '8000:80' volumes: assets: diff --git a/git/hooks/pre-commit b/git/hooks/pre-commit index ba139e35917..e95d9b90288 100755 --- a/git/hooks/pre-commit +++ b/git/hooks/pre-commit @@ -1,13 +1,3 @@ -#!/usr/bin/env perl +#!/usr/bin/env bash -use strict; -use warnings; - -# Hack to use carton's local::lib. -use lib 'local/lib/perl5'; - -use Code::TidyAll::Git::Precommit (); -Code::TidyAll::Git::Precommit->check( - no_stash => 1, - tidyall_options => { verbose => $ENV{TIDYALL_VERBOSE} // 0 }, -); +precious lint -s diff --git a/lib/MetaCPAN/Web/Controller/About.pm b/lib/MetaCPAN/Web/Controller/About.pm index 520f45dac82..ec6714d40ba 100644 --- a/lib/MetaCPAN/Web/Controller/About.pm +++ b/lib/MetaCPAN/Web/Controller/About.pm @@ -2,7 +2,7 @@ package MetaCPAN::Web::Controller::About; use Moose; -use Cpanel::JSON::XS qw(encode_json); +use Cpanel::JSON::XS qw( encode_json ); BEGIN { extends 'MetaCPAN::Web::Controller' } diff --git a/lib/MetaCPAN/Web/Controller/Feed.pm b/lib/MetaCPAN/Web/Controller/Feed.pm index b5682358447..3b32f6b795b 100644 --- a/lib/MetaCPAN/Web/Controller/Feed.pm +++ b/lib/MetaCPAN/Web/Controller/Feed.pm @@ -5,14 +5,14 @@ use namespace::autoclean; BEGIN { extends 'MetaCPAN::Web::Controller' } -use DateTime (); -use HTML::Escape qw( escape_html ); -use MetaCPAN::Web::Types qw( ArrayRef Enum HashRef Str Undef Uri DateTime ); +use DateTime (); +use HTML::Escape qw( escape_html ); +use MetaCPAN::Web::RenderUtil qw( render_markdown ); +use MetaCPAN::Web::Types qw( ArrayRef DateTime Enum HashRef Str Undef Uri ); use Params::ValidationCompiler qw( validation_for ); use Path::Tiny qw( path ); -use MetaCPAN::Web::RenderUtil qw( render_markdown ); +use XML::FeedPP (); ## no perlimports use URI (); -use XML::FeedPP (); sub recent_rdf : Path('/recent.rdf') Args(0) { my ( $self, $c ) = @_; @@ -248,14 +248,12 @@ sub build_feed { my $self = shift; my %params = $feed_check->(@_); - my $format - = $params{format} eq 'rdf' ? 'RDF' - : $params{format} eq 'rss' ? 'RSS' - : $params{format} eq 'atom' ? 'Atom::Atom10' + my $feed_class + = $params{format} eq 'rdf' ? XML::FeedPP::RDF:: + : $params{format} eq 'rss' ? XML::FeedPP::RSS:: + : $params{format} eq 'atom' ? XML::FeedPP::Atom::Atom10:: : die 'invalid format'; - my $feed_class = "XML::FeedPP::$format"; - my $feed = $feed_class->new; $feed->title( $params{title} ); $feed->link("$params{link}"); diff --git a/lib/MetaCPAN/Web/Model/API/Pod.pm b/lib/MetaCPAN/Web/Model/API/Pod.pm index ba7c2849a13..a3646b06969 100644 --- a/lib/MetaCPAN/Web/Model/API/Pod.pm +++ b/lib/MetaCPAN/Web/Model/API/Pod.pm @@ -2,7 +2,7 @@ package MetaCPAN::Web::Model::API::Pod; use Moose; use namespace::autoclean; -use MetaCPAN::Web::RenderUtil qw( split_index filter_html ); +use MetaCPAN::Web::RenderUtil qw( filter_html split_index ); use Encode qw( encode ); use Future (); use HTML::TokeParser (); diff --git a/lib/MetaCPAN/Web/Model/GitHub.pm b/lib/MetaCPAN/Web/Model/GitHub.pm index cf4a312b957..1fce12f09bf 100644 --- a/lib/MetaCPAN/Web/Model/GitHub.pm +++ b/lib/MetaCPAN/Web/Model/GitHub.pm @@ -7,14 +7,12 @@ use namespace::autoclean; use Cpanel::JSON::XS qw( decode_json encode_json ); -use IO::Async::Loop (); -use IO::Async::SSL (); -use IO::Socket::SSL qw( SSL_VERIFY_PEER ); -use Net::Async::HTTP (); -use HTTP::Request::Common (); -use MIME::Base64 qw(encode_base64url); -use Crypt::OpenSSL::RSA (); -use Ref::Util qw(is_arrayref is_hashref); +use IO::Async::Loop (); +use IO::Socket::SSL qw( SSL_VERIFY_PEER ); +use Net::Async::HTTP (); +use MIME::Base64 qw( encode_base64url ); +use Crypt::OpenSSL::RSA (); +use Ref::Util qw( is_arrayref is_hashref ); my $loop; diff --git a/lib/MetaCPAN/Web/RenderUtil.pm b/lib/MetaCPAN/Web/RenderUtil.pm index f4bb4569602..c5ad0d6ce1f 100644 --- a/lib/MetaCPAN/Web/RenderUtil.pm +++ b/lib/MetaCPAN/Web/RenderUtil.pm @@ -8,7 +8,20 @@ use HTML::Escape qw( escape_html ); use HTML::Restrict (); use URI (); use Digest::MD5 (); -use CommonMark qw( :node :event ); +use CommonMark qw( + EVENT_ENTER + EVENT_EXIT + NODE_CODE + NODE_CODE_BLOCK + NODE_DOCUMENT + NODE_HEADER + NODE_HRULE + NODE_HTML + NODE_INLINE_HTML + NODE_LINEBREAK + NODE_SOFTBREAK + NODE_TEXT +); our @EXPORT_OK = qw( filter_html diff --git a/package.json b/package.json index 50b2e8c6672..3b3797e977b 100644 --- a/package.json +++ b/package.json @@ -17,13 +17,14 @@ }, "homepage": "https://github.com/metacpan/metacpanweb#readme", "devDependencies": { - "js-beautify": "^1.15.1" + "js-beautify": "^1.15.1", + "prettier": "3.2.5" }, "dependencies": { - "less": "^4.2.0", "esbuild": "^0.21.2", "esbuild-plugin-less": "^1.3.4", "jquery": "^3.7.1", + "less": "^4.2.0", "minimist": "^1.2.8" } } diff --git a/precious.toml b/precious.toml new file mode 100644 index 00000000000..7e98b357df2 --- /dev/null +++ b/precious.toml @@ -0,0 +1,72 @@ +excludes = [ + ".build/**", + "blib/**", +] + +[commands.perlimports] +type = "both" +include = [ "**/*.{pl,pm,t,psgi}" ] +cmd = [ "perlimports" ] +lint-flags = ["--lint" ] +tidy-flags = ["-i" ] +ok-exit-codes = 0 +expect-stderr = true + +[commands.perlcritic] +type = "lint" +include = [ "**/*.{pl,pm,t,psgi}" ] +cmd = [ "perlcritic", "--profile=$PRECIOUS_ROOT/.perlcriticrc" ] +ok-exit-codes = 0 +lint-failure-exit-codes = 2 + +[commands.perltidy] +type = "both" +include = [ "**/*.{pl,pm,t,psgi}" ] +cmd = [ "perltidy", "--profile=$PRECIOUS_ROOT/.perltidyrc" ] +lint-flags = [ "--assert-tidy", "--no-standard-output", "--outfile=/dev/null" ] +tidy-flags = [ "--backup-and-modify-in-place", "--backup-file-extension=/" ] +ok-exit-codes = 0 +lint-failure-exit-codes = 2 +ignore-stderr = "Begin Error Output Stream" + +[commands.omegasort-gitignore] +type = "both" +include = "**/.gitignore" +cmd = [ "omegasort", "--sort", "path", "--unique" ] +lint-flags = "--check" +tidy-flags = "--in-place" +ok-exit-codes = 0 +lint-failure-exit-codes = 1 +ignore-stderr = [ + "The .+ file is not sorted", + "The .+ file is not unique", +] + +[commands.prettier-markdown] +type = "both" +include = "**/*.md" +cmd = [ + "./node_modules/.bin/prettier", + "--no-config", + "--print-width", "80", + "--prose-wrap", "always", +] +lint-flags = "--check" +tidy-flags = "--write" +ok-exit-codes = 0 +lint-failure-exit-codes = 1 +ignore-stderr = [ "Code style issues" ] + +[commands.prettier-yaml] +type = "both" +include = "**/*.yml" +cmd = [ + "./node_modules/.bin/prettier", + "--no-config", + "--single-quote", +] +lint-flags = "--check" +tidy-flags = "--write" +ok-exit-codes = 0 +lint-failure-exit-codes = 1 +ignore-stderr = [ "Code style issues" ] diff --git a/static-app.psgi b/static-app.psgi index 9b4e0d0c78f..96794b8426f 100644 --- a/static-app.psgi +++ b/static-app.psgi @@ -1,11 +1,12 @@ use strict; use warnings; -use Plack::Builder; +use Plack::Builder qw( builder enable mount ); use Plack::App::Proxy; -use File::Basename; -use Config::ZOMG (); +use File::Basename (); +use Config::ZOMG (); -my $root_dir; BEGIN { $root_dir = File::Basename::dirname(__FILE__); } +my $root_dir; +BEGIN { $root_dir = File::Basename::dirname(__FILE__); } use lib "$root_dir/lib"; my $port = $ENV{METACPAN_WEB_PORT} || 5001; @@ -17,8 +18,8 @@ my $config = Config::ZOMG->open( builder { enable '+MetaCPAN::Middleware::Static' => ( - root => $root_dir, - config => $config, + root => $root_dir, + config => $config, dev_mode => 1, ); enable sub { @@ -31,10 +32,10 @@ builder { }; }; mount '/' => Plack::App::Proxy->new( - remote => "http://localhost:$port", + remote => "http://localhost:$port", preserve_host_header => 1, - backend => 'LWP', - options => { + backend => 'LWP', + options => { env_proxy => 0, }, )->to_app; diff --git a/t/lib/MetaCPAN/Web/Test.pm b/t/lib/MetaCPAN/Web/Test.pm index 9de19bc2d71..4cfc143a113 100644 --- a/t/lib/MetaCPAN/Web/Test.pm +++ b/t/lib/MetaCPAN/Web/Test.pm @@ -5,9 +5,9 @@ package MetaCPAN::Web::Test; use strict; use warnings; -use Plack::Test qw( test_psgi ); -use HTTP::Request::Common qw( GET POST ); -use HTTP::Message::PSGI (); +use HTTP::Request::Common qw( GET POST ); ## no perlimports +use HTTP::Message::PSGI (); ## no perlimports +use Plack::Test qw( test_psgi); ## no perlimports use Test::More import => [qw( is )]; use Test::XPath (); use Try::Tiny qw( catch try ); diff --git a/t/testrules.yml b/t/testrules.yml index 346e3d549c8..60ac37e1cec 100644 --- a/t/testrules.yml +++ b/t/testrules.yml @@ -1,5 +1,4 @@ --- seq: - - seq: t/tidyall.t - - par: - - t/**.t + - par: + - t/**.t diff --git a/t/tidyall.t b/t/tidyall.t deleted file mode 100755 index 172f0c71376..00000000000 --- a/t/tidyall.t +++ /dev/null @@ -1,28 +0,0 @@ -use strict; -use warnings; -use lib 't/lib'; - -# This test is _really_ slow with Devel::Cover running. Also, -# there's really no reason to run this when coverage tests are running, since -# it's not bringing anything to the table. -use Test::More $ENV{COVERAGE} - ? ( skip_all => 'skip under Devel::Cover' ) - : (); - -use File::Temp (); - -use Test::Code::TidyAll qw( tidyall_ok ); - -my %opts = ( verbose => $ENV{TEST_TIDYALL_VERBOSE}, ); - -if ( -e '.tidyall.d' ? !-w _ : !-w '.' ) { - $opts{data_dir} = File::Temp::tempdir( - TEMPLATE => 'tidyall-XXXXXX', - TMPDIR => 1, - CLEANUP => 1, - ); -} - -tidyall_ok(%opts); - -done_testing(); diff --git a/tidyall.ini b/tidyall.ini deleted file mode 100644 index 611737adf2c..00000000000 --- a/tidyall.ini +++ /dev/null @@ -1,21 +0,0 @@ -jobs = 5 - -[PerlTidy] -select = {bin,lib,t}/**/*.{pl,pm,t,psgi} -select = app.psgi -argv = --profile=$ROOT/.perltidyrc - -[SortLines] -select = .gitignore - -[GenericTransformer / JS-Beautify] -cmd = npx -s js-beautify -select = root/static/js/cpan.js -argv = --indent-size 4 --end_with_newline -ok_exit_codes = 0 - -[Test::Vars] -select = {lib,t}/**/*.pm - -[PerlCritic] -select = {bin,lib,t}/**/*.{pl,pm,t,psgi}