Skip to content

Commit

Permalink
chore: Better dependencies (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
LastDragon-ru authored Jan 18, 2024
2 parents f4a00ee + 6f77895 commit 0d1d914
Show file tree
Hide file tree
Showing 28 changed files with 1,748 additions and 509 deletions.
2 changes: 1 addition & 1 deletion .github/actions/php/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ runs:
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
echo "value=$(jq '[."require", ."require-dev", ."suggest"] | add | to_entries | map(select(.key | match("ext-";"i"))) | map(.key | sub("ext-"; "")) | sort' -r -c composer.json)" >> $GITHUB_OUTPUT
echo "value=$(jq '( (."require" // [] | keys) + (."require-dev" // [] | keys) + (.["extra"]["lara-asp"]["ci"]["required-extensions"] // [] | flatten) ) | map(select(.|startswith("ext-"))) | map(. | sub("ext-"; "")) | unique | sort ' -r -c composer.json)" >> $GITHUB_OUTPUT
- name: Install PHP
uses: shivammathur/setup-php@v2
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ jobs:
- name: Check package versions
run: |
composer run-script monorepo-builder
- name: Check packages
run: |
composer run-script composer-require-checker
- name: Check unused packages
run: |
composer run-script composer-unused
Expand Down Expand Up @@ -63,6 +66,9 @@ jobs:
uses: ramsey/composer-install@v2
with:
working-directory: ${{ needs.settings.outputs.packages-directory }}/${{ matrix.package }}
- name: Check packages
run: |
composer run-script composer-require-checker -- "${{ needs.settings.outputs.packages-directory }}/${{ matrix.package }}/composer.json"
- name: Check unused packages
run: |
composer run-script composer-unused -- "${{ needs.settings.outputs.packages-directory }}/${{ matrix.package }}/composer.json"
Expand Down
15 changes: 0 additions & 15 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,6 @@ jobs:
dependencies: ${{ fromJson(needs.settings.outputs.dependencies) }}
os: ${{ fromJson(inputs.runs-on) }}
exclude:
# `continue-on-error: true` will add a red mark in commit/pr, this is
# definitely not what I want :( So we exclude some items instead.
#
# https://github.com/actions/toolkit/issues/399
- php: ${{ fromJson(needs.settings.outputs.php-versions)[1] }}
dependencies: 'lowest'
- php: ${{ fromJson(needs.settings.outputs.php-versions)[2] }}
dependencies: 'lowest'
- php: ${{ fromJson(needs.settings.outputs.php-versions)[3] }}
dependencies: 'lowest'
- php: ${{ fromJson(needs.settings.outputs.php-versions)[4] }}
dependencies: 'lowest'
- php: ${{ fromJson(needs.settings.outputs.php-versions)[5] }}
dependencies: 'lowest'

# Laravel v10 doesn't support PHP 8.0
- php: 8.0
laravel: ^10.0.0
Expand Down
64 changes: 52 additions & 12 deletions .release-it/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ const breakingMark = {

module.exports = {
npm: false,
hooks: {
"after:bump": "composer run rebuild:docs",
hooks: {
'after:bump': 'composer run rebuild:docs',
},
git: {
tagArgs: '-s',
Expand Down Expand Up @@ -182,15 +182,11 @@ module.exports = {
// Comment may have multiple scopes (separated by `,`),
// each scope may have component (after `/`).
const pkgs = [];
const scopes = (commit.scope || '')
.split(',')
.map(scope => scope.trim())
.filter((v, i, a) => a.indexOf(v) === i);
const scopes = getScopes(commit.scope);

for (let scope of scopes) {
const parts = scope.split('/');
const package = parts[0].trim() || all;
const component = parts.slice(1).join('/').trim() || null;
const package = scope.package || all;
const component = scope.component;
const byPackage = packages[package] = packages[package] || {
name: package,
types: {},
Expand Down Expand Up @@ -292,22 +288,44 @@ module.exports = {
return null;
}

// Cleanup scopes
const scopes = getScopes(commit.scope);

for (let scope of scopes) {
if ((scope.component || '').startsWith('@')) {
scope.component = `\`${scope.component}\``;
}
}

if (scopes.length) {
commit.scope = scopes
.map(s => [s.package, s.component].filter(v => !!v).join('/'))
.join(',');
}

// Cleanup subject (github adds #issue on the end of PR message, we are no need it)
commit.subject = commit.subject.trim().replace(/\.+$/, '').trim();

for (let reference of commit.references) {
let patterns = [
for (let i = 0; i < commit.references.length; i++) {
const reference = commit.references[i];
const patterns = [
`(${reference.prefix}${reference.issue})`,
`(${reference.prefix}${reference.issue},`,
`(${reference.prefix}${reference.issue}`,
`${reference.prefix}${reference.issue})`,
`${reference.prefix}${reference.issue}`,
];

for (let pattern of patterns) {
if (commit.subject.endsWith(pattern)) {
commit.subject = commit.subject.slice(0, -pattern.length).trim();
i = -1;
}
}
}

commit.subject = commit.subject.trim().replace(/\.+$/, '').trim();

// Custom
commit.mentions = []; // see https://github.com/conventional-changelog/conventional-changelog/issues/601
commit.section = type.section;
Expand All @@ -327,17 +345,39 @@ module.exports = {
};

// Helpers
const compareStrings = (a, b, trim = /^[*`_~]+/g) => {
const compareStrings = (a, b, trim = /^[*`_~]+/g) => {
// The strings may contain the markdown, so we are
// removing "invisible" chars before comparing.
a = (a || '').trimStart().replace(trim, '');
b = (b || '').trimStart().replace(trim, '');

return a.localeCompare(b);
};

const comparePriority = (a, b, d) => {
a = a && Number.isInteger(a.priority) ? a.priority : d;
b = b && Number.isInteger(b.priority) ? b.priority : d;

return a - b;
};

const getScopes = (string) => {
let parsed = [];
const scopes = (string || '')
.split(',')
.map(scope => scope.trim())
.filter((v, i, a) => a.indexOf(v) === i);

for (let scope of scopes) {
const parts = scope.split('/');
const package = parts[0].trim() || null;
const component = parts.slice(1).join('/').trim() || null;

parsed.push({
package: package,
component: component,
})
}

return parsed;
};
6 changes: 3 additions & 3 deletions .release-it/templates/template.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## {{#if release.name}}{{release.name}}{{else}}Release v{{version}} ({{date}}){{/if}}
# {{#if release.name}}{{release.name}}{{else}}Release v{{version}} ({{date}}){{/if}}

{{#if summary}}
| Mark | Type | Count | Packages |
Expand All @@ -13,10 +13,10 @@

{{/if}}
{{#each packages}}
### {{#if name}}Package `{{name}}`{{else}}All packages{{/if}}
## {{#if name}}Package `{{name}}`{{else}}All packages{{/if}}

{{#each types}}
#### {{name}}{{#if mark}} {{mark}}{{/if}}
### {{name}}{{#if mark}} {{mark}}{{/if}}

{{#each commits}}
{{> commit root=@root}}
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ The set provides best practices to make development more fun and classes/service

# Installation

```shell
# Everything
composer require lastdragon-ru/lara-asp
Installation of the root `lastdragon-ru/lara-asp` package is not recommended because it will install all packages, but some of them are intended to use while dev only (and may want dependencies like `phpunit`/`phpstan`/etc). So select the desired package and install it. You can find requirements and installation instructions (if any) inside package documentation.

# Specific package (where "core" the package name)
composer require lastdragon-ru/lara-asp-core
```shell
# General case (where "<package>" the package name).
composer require lastdragon-ru/lara-asp-<package>
```

# Packages

| 🐝 | Package intended to use in dev. |
|:--:|---------------------------------|

[include:package-list]: ./packages
[//]: # (start: df3ee6374fabefbdeb79b26164b3f2ef88f6ed94646bb5d44751ea6da758de19)
[//]: # (warning: Generated automatically. Do not edit.)
Expand Down Expand Up @@ -93,7 +95,7 @@ This package provides a customizable wrapper around the [Symfony Serializer Comp

[Read more](<packages/serializer/README.md>).

## Testing Helpers
## Testing Helpers 🐝

This package provides various useful asserts for [PHPUnit](https://phpunit.de/) and alternative solution for HTTP tests - testing HTTP response has never been so easy! And this not only about `TestResponse` but any PSR response 😎

Expand Down
51 changes: 51 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Upgrade Guide

[include:file]: ./docs/Shared/Upgrade.md
[//]: # (start: 39d35167e0d4cea1b3b411d449b79f0b6df5fcbf65c5d8b9775671fe5603b7c9)
[//]: # (warning: Generated automatically. Do not edit.)

## Instructions

1. Determine the current version (`composer info ...`)
2. Choose the wanted version
3. Follow the instructions
4. ??????
5. PROFIT

For example, if the current version is `2.x` and you want to migrate to `5.x`, you need to perform all steps in the following order:

* "Upgrade from v2"
* "Upgrade from v3"
* "Upgrade from v4"

Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases) to find all changes.

## Legend

| 🤝 | Backward-compatible change. Please note that despite you can ignore it now, but it will be mandatory in the future. |
|:--:|---------------------------------------------------------------------------------------------------------------------|

[//]: # (end: 39d35167e0d4cea1b3b411d449b79f0b6df5fcbf65c5d8b9775671fe5603b7c9)

# Packages

[include:package-list]: ./packages ({"template": "upgradable"})
[//]: # (start: 39292ac87c6fc1ec1884b9449c69f39245874999bd085380a87c7473ffae043b)
[//]: # (warning: Generated automatically. Do not edit.)

* [Core](<packages/core/UPGRADE.md>)
* [Documentator](<packages/documentator/UPGRADE.md>)
* [Eloquent Helpers](<packages/eloquent/UPGRADE.md>)
* [Formatter](<packages/formatter/UPGRADE.md>)
* [GraphQL Extensions for Lighthouse](<packages/graphql/UPGRADE.md>)
* [GraphQL Printer](<packages/graphql-printer/UPGRADE.md>)
* [Migrator](<packages/migrator/UPGRADE.md>)
* [SPA Helpers](<packages/spa/UPGRADE.md>)
* [Serializer](<packages/serializer/UPGRADE.md>)
* [Testing Helpers 🐝](<packages/testing/UPGRADE.md>)

[//]: # (end: 39292ac87c6fc1ec1884b9449c69f39245874999bd085380a87c7473ffae043b)

# Upgrade from v5

* [ ] Installation of the root `lastdragon-ru/lara-asp` package is not recommended anymore 🤝
6 changes: 6 additions & 0 deletions composer-require-checker.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"symbol-whitelist": [
"Composer\\InstalledVersions",
"Laravel\\Scout\\Builder"
]
}
Loading

0 comments on commit 0d1d914

Please sign in to comment.