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

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhamp committed Sep 7, 2024
1 parent 3e51313 commit 24289d9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
8 changes: 8 additions & 0 deletions dist/server/php.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ function retrieveNativePHPConfig() {
}
exports.retrieveNativePHPConfig = retrieveNativePHPConfig;
function callPhp(args, options, phpIniSettings = {}) {
if (args[0] === 'artisan' && runningSecureBuild()) {
args.unshift((0, path_1.join)(appPath, 'build', '__nativephp_app_bundle'));
}
let defaultIniSettings = {
'memory_limit': '512M',
'curl.cainfo': state_1.default.caCert,
Expand Down Expand Up @@ -150,6 +153,7 @@ function getDefaultEnvironmentVariables(secret, apiPort) {
return {
APP_ENV: process.env.NODE_ENV === 'development' ? 'local' : 'production',
APP_DEBUG: process.env.NODE_ENV === 'development' ? 'true' : 'false',
LARAVEL_STORAGE_PATH: storagePath,
NATIVEPHP_STORAGE_PATH: storagePath,
NATIVEPHP_DATABASE_PATH: databaseFile,
NATIVEPHP_API_URL: `http://localhost:${apiPort}/api/`,
Expand All @@ -168,6 +172,7 @@ function getDefaultEnvironmentVariables(secret, apiPort) {
};
}
function runningSecureBuild() {
return (0, fs_1.existsSync)((0, path_1.join)(appPath, 'build', '__nativephp_app_bundle'));
}
function serveApp(secret, apiPort, phpIniSettings) {
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
Expand All @@ -181,6 +186,9 @@ function serveApp(secret, apiPort, phpIniSettings) {
env
};
const store = new electron_store_1.default();
if (!runningSecureBuild()) {
callPhp(['artisan', 'storage:link', '--force'], phpOptions, phpIniSettings);
}
if (store.get('migrated_version') !== electron_1.app.getVersion() && process.env.NODE_ENV !== 'development') {
console.log('Migrating database...');
callPhp(['artisan', 'migrate', '--force'], phpOptions, phpIniSettings);
Expand Down
14 changes: 9 additions & 5 deletions src/server/php.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ async function retrieveNativePHPConfig() {
}

function callPhp(args, options, phpIniSettings = {}) {
if (args[0] === 'artisan' && runningSecureBuild()) {
args.unshift(join(appPath, 'build', '__nativephp_app_bundle'));
}

let defaultIniSettings = {
'memory_limit': '512M',
'curl.cainfo': state.caCert,
Expand Down Expand Up @@ -186,7 +190,7 @@ function getDefaultEnvironmentVariables(secret, apiPort) {
}

function runningSecureBuild() {

return existsSync(join(appPath, 'build', '__nativephp_app_bundle'))
}

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

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

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

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

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

0 comments on commit 24289d9

Please sign in to comment.