Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit 24289d9

Browse files
committed
wip
1 parent 3e51313 commit 24289d9

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

Diff for: dist/server/php.js

+8
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ function retrieveNativePHPConfig() {
6666
}
6767
exports.retrieveNativePHPConfig = retrieveNativePHPConfig;
6868
function callPhp(args, options, phpIniSettings = {}) {
69+
if (args[0] === 'artisan' && runningSecureBuild()) {
70+
args.unshift((0, path_1.join)(appPath, 'build', '__nativephp_app_bundle'));
71+
}
6972
let defaultIniSettings = {
7073
'memory_limit': '512M',
7174
'curl.cainfo': state_1.default.caCert,
@@ -150,6 +153,7 @@ function getDefaultEnvironmentVariables(secret, apiPort) {
150153
return {
151154
APP_ENV: process.env.NODE_ENV === 'development' ? 'local' : 'production',
152155
APP_DEBUG: process.env.NODE_ENV === 'development' ? 'true' : 'false',
156+
LARAVEL_STORAGE_PATH: storagePath,
153157
NATIVEPHP_STORAGE_PATH: storagePath,
154158
NATIVEPHP_DATABASE_PATH: databaseFile,
155159
NATIVEPHP_API_URL: `http://localhost:${apiPort}/api/`,
@@ -168,6 +172,7 @@ function getDefaultEnvironmentVariables(secret, apiPort) {
168172
};
169173
}
170174
function runningSecureBuild() {
175+
return (0, fs_1.existsSync)((0, path_1.join)(appPath, 'build', '__nativephp_app_bundle'));
171176
}
172177
function serveApp(secret, apiPort, phpIniSettings) {
173178
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
@@ -181,6 +186,9 @@ function serveApp(secret, apiPort, phpIniSettings) {
181186
env
182187
};
183188
const store = new electron_store_1.default();
189+
if (!runningSecureBuild()) {
190+
callPhp(['artisan', 'storage:link', '--force'], phpOptions, phpIniSettings);
191+
}
184192
if (store.get('migrated_version') !== electron_1.app.getVersion() && process.env.NODE_ENV !== 'development') {
185193
console.log('Migrating database...');
186194
callPhp(['artisan', 'migrate', '--force'], phpOptions, phpIniSettings);

Diff for: src/server/php.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ async function retrieveNativePHPConfig() {
5353
}
5454

5555
function callPhp(args, options, phpIniSettings = {}) {
56+
if (args[0] === 'artisan' && runningSecureBuild()) {
57+
args.unshift(join(appPath, 'build', '__nativephp_app_bundle'));
58+
}
59+
5660
let defaultIniSettings = {
5761
'memory_limit': '512M',
5862
'curl.cainfo': state.caCert,
@@ -186,7 +190,7 @@ function getDefaultEnvironmentVariables(secret, apiPort) {
186190
}
187191

188192
function runningSecureBuild() {
189-
193+
return existsSync(join(appPath, 'build', '__nativephp_app_bundle'))
190194
}
191195

192196
function serveApp(secret, apiPort, phpIniSettings): Promise<ProcessResult> {
@@ -210,9 +214,9 @@ function serveApp(secret, apiPort, phpIniSettings): Promise<ProcessResult> {
210214

211215
// Make sure the storage path is linked - as people can move the app around, we
212216
// need to run this every time the app starts
213-
// if (! runningSecureBuild()) {
214-
// callPhp(['artisan', 'storage:link', '--force'], phpOptions, phpIniSettings)
215-
// }
217+
if (! runningSecureBuild()) {
218+
callPhp(['artisan', 'storage:link', '--force'], phpOptions, phpIniSettings)
219+
}
216220

217221
// Migrate the database
218222
if (store.get('migrated_version') !== app.getVersion() && process.env.NODE_ENV !== 'development') {
@@ -230,7 +234,7 @@ function serveApp(secret, apiPort, phpIniSettings): Promise<ProcessResult> {
230234

231235
let serverPath = join(appPath, 'build', '__nativephp_app_bundle');
232236

233-
// if (process.env.NODE_ENV !== 'production' || ! existsSync(serverPath)) {
237+
// if (process.env.NODE_ENV !== 'production' || ! runningSecureBuild()) {
234238
// console.log('* * * Running from source * * *');
235239
// serverPath = join(appPath, 'vendor', 'laravel', 'framework', 'src', 'Illuminate', 'Foundation', 'resources', 'server.php');
236240
// }

0 commit comments

Comments
 (0)