Skip to content

Commit

Permalink
chore: release v1.8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed Aug 4, 2024
1 parent abef306 commit 9e2b881
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 24 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "johannschopplich/kirby-copilot",
"description": "AI-powered content generation for Kirby CMS",
"type": "kirby-plugin",
"version": "1.8.1",
"version": "1.8.2",
"keywords": [
"ai",
"content",
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "kirby-copilot",
"type": "module",
"version": "1.8.1",
"version": "1.8.2",
"private": true,
"packageManager": "pnpm@9.5.0",
"scripts": {
Expand Down
14 changes: 7 additions & 7 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,23 @@
},
{
"name": "johannschopplich/kirby-tools-licensing",
"version": "0.4.3",
"version_normalized": "0.4.3.0",
"version": "0.5.0",
"version_normalized": "0.5.0.0",
"source": {
"type": "git",
"url": "https://github.com/kirby-tools/licensing-backend.git",
"reference": "afd11dc6f0b3153218ec61953d574963255ee4fc"
"reference": "a8ac9a672c554e0d6694a5c11d631c40cb24c6ef"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/kirby-tools/licensing-backend/zipball/afd11dc6f0b3153218ec61953d574963255ee4fc",
"reference": "afd11dc6f0b3153218ec61953d574963255ee4fc",
"url": "https://api.github.com/repos/kirby-tools/licensing-backend/zipball/a8ac9a672c554e0d6694a5c11d631c40cb24c6ef",
"reference": "a8ac9a672c554e0d6694a5c11d631c40cb24c6ef",
"shasum": ""
},
"require-dev": {
"getkirby/cms": "^4"
},
"time": "2024-07-15T14:05:29+00:00",
"time": "2024-08-04T07:19:39+00:00",
"type": "library",
"extra": {
"kirby-cms-path": false
Expand All @@ -94,7 +94,7 @@
"homepage": "https://github.com/kirby-tools/licensing-backend#readme",
"support": {
"issues": "https://github.com/kirby-tools/licensing-backend/issues",
"source": "https://github.com/kirby-tools/licensing-backend/tree/v0.4.3"
"source": "https://github.com/kirby-tools/licensing-backend/tree/v0.5.0"
},
"install-path": "../johannschopplich/kirby-tools-licensing"
}
Expand Down
14 changes: 7 additions & 7 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php return array(
'root' => array(
'name' => 'johannschopplich/kirby-copilot',
'pretty_version' => '1.8.1',
'version' => '1.8.1.0',
'pretty_version' => '1.8.2',
'version' => '1.8.2.0',
'reference' => null,
'type' => 'kirby-plugin',
'install_path' => __DIR__ . '/../../',
Expand All @@ -20,18 +20,18 @@
'dev_requirement' => false,
),
'johannschopplich/kirby-copilot' => array(
'pretty_version' => '1.8.1',
'version' => '1.8.1.0',
'pretty_version' => '1.8.2',
'version' => '1.8.2.0',
'reference' => null,
'type' => 'kirby-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev_requirement' => false,
),
'johannschopplich/kirby-tools-licensing' => array(
'pretty_version' => '0.4.3',
'version' => '0.4.3.0',
'reference' => 'afd11dc6f0b3153218ec61953d574963255ee4fc',
'pretty_version' => '0.5.0',
'version' => '0.5.0.0',
'reference' => 'a8ac9a672c554e0d6694a5c11d631c40cb24c6ef',
'type' => 'library',
'install_path' => __DIR__ . '/../johannschopplich/kirby-tools-licensing',
'aliases' => array(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "johannschopplich/kirby-tools-licensing",
"description": "Shared tooling for licensing server-side",
"type": "library",
"version": "0.4.3",
"version": "0.5.0",
"license": "AGPL-3.0-or-later",
"homepage": "https://github.com/kirby-tools/licensing-backend#readme",
"authors": [
Expand Down
28 changes: 22 additions & 6 deletions vendor/johannschopplich/kirby-tools-licensing/src/Licenses.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@ public static function read(string $packageName, array $options = []): static
}

$instance = new static($licenses, $packageName);

if ($options['migrate'] ?? true) {
$instance->migration();
}
$instance->migration();
$instance->refresh();

return $instance;
}
Expand Down Expand Up @@ -106,6 +104,12 @@ public function getLicenseCompatibility(): string|null
return $this->licenses[$this->packageName]['licenseCompatibility'] ?? null;
}

public function getPluginVersion(): string|null
{
$kirbyPackageName = str_replace('/kirby-', '/', $this->packageName);
return App::instance()->plugin($kirbyPackageName)?->version();
}

public function isRegistered(): bool
{
return $this->isValid($this->getLicenseKey()) && $this->isCompatible($this->getLicenseCompatibility());
Expand All @@ -118,8 +122,7 @@ public function isValid(string|null $licenseKey): bool

public function isCompatible(string|null $versionConstraint): bool
{
$kirbyPackageName = str_replace('/kirby-', '/', $this->packageName);
$version = App::instance()->plugin($kirbyPackageName)?->version();
$version = $this->getPluginVersion();

if ($version !== null && str_starts_with($version, 'dev-')) {
throw new LogicException('Development versions are not supported');
Expand Down Expand Up @@ -180,6 +183,7 @@ public function update(string $packageName, array $data): void
$this->licenses[$packageName] = [
'licenseKey' => $data['licenseKey'],
'licenseCompatibility' => $data['licenseCompatibility'],
'pluginVersion' => $this->getPluginVersion(),
'createdAt' => $data['order']['createdAt']
];

Expand Down Expand Up @@ -234,6 +238,18 @@ private function migration(): void
}
}

private function refresh(): void
{
// If the plugin version has changed, update the license data
if (
$this->isValid($this->getLicenseKey()) &&
$this->getPluginVersion() !== $this->licenses[$this->packageName]['pluginVersion'] ?? null
) {
$response = $this->request('licenses/' . $this->getLicenseKey() . '/package');
$this->update($this->packageName, $response);
}
}

private function request(string $path, array $options = []): array
{
$response = new Remote(static::API_URL . '/' . $path, array_merge($options, [
Expand Down

0 comments on commit 9e2b881

Please sign in to comment.