Skip to content

Commit 07cb665

Browse files
authored
Merge branch 'main' into update-deps
2 parents cd97aaa + 1c62340 commit 07cb665

File tree

10 files changed

+416
-12
lines changed

10 files changed

+416
-12
lines changed

config/nativephp.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
/**
103103
* The updater provider to use.
104104
* Supported: "github", "s3", "spaces"
105+
* Note: The "s3" provider is compatible with S3-compatible services like Cloudflare R2.
105106
*/
106107
'default' => env('NATIVEPHP_UPDATER_PROVIDER', 'spaces'),
107108

@@ -113,6 +114,7 @@
113114
'token' => env('GITHUB_TOKEN'),
114115
'vPrefixedTagName' => env('GITHUB_V_PREFIXED_TAG_NAME', true),
115116
'private' => env('GITHUB_PRIVATE', false),
117+
'autoupdate_token' => env('GITHUB_AUTOUPDATE_TOKEN'), // Read-only token used by the updater for private repos
116118
'channel' => env('GITHUB_CHANNEL', 'latest'),
117119
'releaseType' => env('GITHUB_RELEASE_TYPE', 'draft'),
118120
],
@@ -125,6 +127,13 @@
125127
'bucket' => env('AWS_BUCKET'),
126128
'endpoint' => env('AWS_ENDPOINT'),
127129
'path' => env('NATIVEPHP_UPDATER_PATH', null),
130+
/**
131+
* Optional public URL for serving updates (e.g., CDN or custom domain).
132+
* When set, updates will be downloaded from this URL instead of the S3 endpoint.
133+
* Useful for S3 with CloudFront or Cloudflare R2 with public access
134+
* Example: 'https://updates.yourdomain.com'
135+
*/
136+
'public_url' => env('AWS_PUBLIC_URL'),
128137
],
129138

130139
'spaces' => [

package-lock.json

Lines changed: 277 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": {
3+
"fix-path": "^5.0.0"
4+
}
5+
}

resources/electron/electron-plugin/dist/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,16 @@ class NativePHP {
158158
}
159159
}
160160
startAutoUpdater(config) {
161-
var _a;
161+
var _a, _b, _c, _d, _e;
162162
if (((_a = config === null || config === void 0 ? void 0 : config.updater) === null || _a === void 0 ? void 0 : _a.enabled) === true) {
163+
const defaultProvider = (_b = config === null || config === void 0 ? void 0 : config.updater) === null || _b === void 0 ? void 0 : _b.default;
164+
const publicUrl = (_e = (_d = (_c = config === null || config === void 0 ? void 0 : config.updater) === null || _c === void 0 ? void 0 : _c.providers) === null || _d === void 0 ? void 0 : _d[defaultProvider]) === null || _e === void 0 ? void 0 : _e.public_url;
165+
if (publicUrl) {
166+
autoUpdater.setFeedURL({
167+
provider: 'generic',
168+
url: publicUrl
169+
});
170+
}
163171
autoUpdater.checkForUpdatesAndNotify();
164172
}
165173
}

resources/electron/electron-plugin/src/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class NativePHP {
3434
cert: string,
3535
appPath: string
3636
) {
37-
3837
initialize();
3938

4039
state.icon = icon;
@@ -216,6 +215,17 @@ class NativePHP {
216215

217216
private startAutoUpdater(config) {
218217
if (config?.updater?.enabled === true) {
218+
// If a public URL is configured for the current provider, use it for updates
219+
const defaultProvider = config?.updater?.default;
220+
const publicUrl = config?.updater?.providers?.[defaultProvider]?.public_url;
221+
222+
if (publicUrl) {
223+
autoUpdater.setFeedURL({
224+
provider: 'generic',
225+
url: publicUrl
226+
});
227+
}
228+
219229
autoUpdater.checkForUpdatesAndNotify();
220230
}
221231
}

resources/electron/src/main/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import {app} from 'electron'
22
import NativePHP from '#plugin'
33
import path from 'path'
44

5+
// Inherit User's PATH in Process & ChildProcess
6+
import fixPath from 'fix-path';
7+
fixPath();
8+
59
const buildPath = path.resolve(import.meta.dirname, import.meta.env.MAIN_VITE_NATIVEPHP_BUILD_PATH);
610
const defaultIcon = path.join(buildPath, 'icon.png')
711
const certificate = path.join(buildPath, 'cacert.pem')

src/Contracts/WindowManager.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@ public function current(): Window;
2020
public function all(): array;
2121

2222
public function get(string $id): Window;
23+
24+
public function reload($id = null): void;
2325
}

src/Drivers/Electron/Updater/GitHubProvider.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,20 @@ public function environmentVariables(): array
1717

1818
public function builderOptions(): array
1919
{
20-
return [
20+
$options = [
2121
'provider' => 'github',
2222
'repo' => $this->config['repo'],
2323
'owner' => $this->config['owner'],
2424
'vPrefixedTagName' => $this->config['vPrefixedTagName'],
2525
'private' => $this->config['private'],
2626
'channel' => $this->config['channel'],
2727
'releaseType' => $this->config['releaseType'],
28-
'token' => $this->config['token'],
2928
];
29+
30+
if ($this->config['private'] === true && ! empty($this->config['autoupdate_token'])) {
31+
$options['token'] = $this->config['autoupdate_token'];
32+
}
33+
34+
return $options;
3035
}
3136
}

0 commit comments

Comments
 (0)