Skip to content
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

preview implementation of the Laminas ecosystem RFC #226

Open
wants to merge 8 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/validate-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Validate ecosystem packages JSON file

on:
pull_request:
push:
branches:
tags:

jobs:
validate-packages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
packages=$(cat ./data/ecosystem/ecosystem-packages.json);
if [ ! -z "$packages" ] && [ $(echo $packages | jq empty > /dev/null 2>&1; echo $?) -eq 0 ]; then
for key in packagistUrl keywords homepage category usage; do
if ! $(echo $packages | jq ".[]" | jq "has(\"$key\")" | jq 'select(. == false)'); then
echo "Invalid JSON. Missing key \"$key\"."
exit 1;
fi
done
echo "Valid JSON."
exit 0;
else
echo "Invalid JSON."
exit 1;
fi
19 changes: 19 additions & 0 deletions .platform.app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ mounts:
'public/share':
source: local
source_path: public/share
'data/ecosystem/database':
source: local
source_path: data/ecosystem/database

hooks:
build: |
Expand Down Expand Up @@ -54,6 +57,7 @@ hooks:
rm -f data/cache/config-cache.php
if [ ! -e data/cache/releases.rss ];then cp templates/releases.rss data/cache/ ;fi
./vendor/bin/laminas repository:generate-data "$PLATFORM_VARIABLES" | base64 --decode | jq '."REPO_TOKEN"'
./vendor/bin/laminas ecosystem:create-db

crons:
snapshot:
Expand All @@ -79,6 +83,21 @@ crons:
./vendor/bin/laminas repository:generate-data "$PLATFORM_VARIABLES" | base64 --decode | jq '."REPO_TOKEN"'
fi
shutdown_timeout: 20
generateecosystem:
# Refresh repository data every 6 hours (UTC).
spec: '0 */6 * * *'
commands:
start: |
if [ "$PLATFORM_BRANCH" = master ]; then
./vendor/bin/laminas ecosystem:seed-db
fi
shutdown_timeout: 20

operations:
rebuildEcosystemDatabase:
role: admin
commands:
start: ./vendor/bin/laminas ecosystem:create-db --force-rebuild

web:
locations:
Expand Down
55 changes: 55 additions & 0 deletions ADD_ECOSYSTEM_PACKAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Adding your entry to the Laminas Ecosystem

You can add packages **available via composer** to the `data/ecosystem/ecosystem-packages.json` file by following the steps below:

- Entries must use the [template](#new-entry-template) as a guide.
- Submit a PR.

> Use the following command to make sure your submission will be correctly built:

```bash
composer build
```

> The following command can be run individually for testing:

```bash
./vendor/bin/laminas ecosystem:create-db
```

*Used for creating the database.*

```bash
./vendor/bin/laminas ecosystem:seed-db
```

*Used for updating the package data every X hours.*

## New entry template

```json
{
"packagistUrl": "",
"githubUrl": "",
"keywords": [],
"homepage": "",
"category": ""
}
```

### New entry fields description

- `packagistUrl` **required**
**string** - the packagist URL of the entry, with no query parameters

- `githubUrl`
**string** - optional link to be displayed on the package card

- `keywords`
**array of strings** - user defined keywords used for filtering results

- `homepage`
**string** - optional URL to package homepage, will overwrite "homepage" field from Packagist Api data

- `category`
**string** - package category must be one of "skeleton", "integration", "tool"
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,7 @@ Everyone is welcome to post a blog entry. Once submitted, it will be reviewed by
If it's rejected, the reason for the rejection will be included, so you can update it and resubmit the post if applicable.

The submission process is described in the [ADD_BLOG_ENTRY](ADD_BLOG_ENTRY.md) file.

## Adding packages to the Laminas Ecosystem

The [ADD ECOSYSTEM PACKAGE](ADD_ECOSYSTEM_PACKAGE.md) file describes the process of adding packages to the [Laminas Ecosystem](https://getlaminas.org/ecosystem)
3 changes: 2 additions & 1 deletion bootstrap/gulpfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ function js() {
'node_modules/@popperjs/core/dist/umd/popper.min.js',
'node_modules/bootstrap/dist/js/bootstrap.min.js',
'node_modules/anchor-js/anchor.min.js',
'js/base.js'
'js/base.js',
'js/_ecosystem.js'
]))
.pipe(concat({path: 'laminas.js'}))
.pipe(terser({mangle: false}).on('error', function (e) {
Expand Down
114 changes: 114 additions & 0 deletions bootstrap/js/_ecosystem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
'use strict';

$(document).ready(function () {
Copy link
Member

@froschdesign froschdesign Dec 10, 2024

Choose a reason for hiding this comment

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

Vanilla JavaScript is good in 2024 and it should be dropped when we move to Bootstrap 5.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair enough, I saw jquery was already added as a dependency and went with it, but I'll go ahead and refactor

$('.package-button').click(function (e) {
e.preventDefault();

const url = new URL(window.location.href);
const params = new URLSearchParams(url.search);
const entry = $(this).data('value');

if ($(this).hasClass('keyword')) {
if (! params.has("keywords[]", entry)) {
params.append("keywords[]", entry);
url.search = params.toString();

window.location.replace(url.toString());
}
}

if ($(this).hasClass('type')) {
if (! params.has("type", entry)) {
url.searchParams.set('type', entry);

window.location.replace(url.toString());
} else if (params.get("type") === entry) {
url.searchParams.delete("type");

window.location.replace(url.toString());
}
}

if ($(this).hasClass('category')) {
if (! params.has("category", entry)) {
url.searchParams.set('category', entry);

window.location.replace(url.toString());
} else if (params.get("category") === entry) {
url.searchParams.delete("category");

window.location.replace(url.toString());
}
}

if ($(this).hasClass('usage')) {
if (! params.has("usage", entry)) {
url.searchParams.set('usage', entry);

window.location.replace(url.toString());
} else if (params.get("usage") === entry) {
url.searchParams.delete("usage");

window.location.replace(url.toString());
}
}
});

$('.ecosystem-filter').click(function (e) {
e.preventDefault();

const url = new URL(window.location.href);
const params = new URLSearchParams(url.search);
const entry = $(this).data('value');

if ($(this).hasClass('keyword')) {
if (params.has("keywords[]", entry)) {
params.delete("keywords[]", entry);
url.search = params.toString();

window.location.replace(url.toString());
}
}
});

[...$('#ecosystem-pagination a')].forEach(a => {
const url = new URL(a.href)
for (let [k,v] of new URLSearchParams(window.location.search).entries()) {
if (k === 'keywords[]' || k === 'q' || k === 'type' || k === 'category' || k === 'usage') {
url.searchParams.set(k,v)
}
}
a.href = url.toString();
})

$('#ecosystem-search').keypress(function (e) {
const search = $(this).val();
if (e.which === 13) {
setSearchQuery(search);
}
});

$('#ecosystem-search-btn').click(function (e) {
const search = $('#ecosystem-search').val();
setSearchQuery(search);
});

function setSearchQuery(search) {
const url = new URL(window.location.href);

url.searchParams.set('q', search);
window.location.replace(url.toString());
}

$('#clear-filters-button').click(function (e) {
const url = new URL(window.location.href);

for (let [k,v] of new URLSearchParams(window.location.search).entries()) {
if (k === 'type' || k === 'category' || k === 'usage') {
url.searchParams.delete(k)
}
}

window.location.replace(url.toString());
});
});
Loading
Loading