Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement / address build command papercuts #153

Open
wants to merge 79 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
49b0bdc
copy app to build path before cleanup & composer install
gwleuverink Jan 7, 2025
aa11099
copied CleansEnvFile trait from upstream PR #106
gwleuverink Jan 7, 2025
29a7d55
copied updated app icon path from upstream PR #106
gwleuverink Jan 7, 2025
b097cce
copied app name fix from upstream PR #106
gwleuverink Jan 7, 2025
dc54e55
tidy
gwleuverink Jan 7, 2025
442c265
tidy
gwleuverink Jan 8, 2025
4db4dfb
added skip patterns from electron-builder & account for symlinks (for…
gwleuverink Jan 8, 2025
52202d6
add more default skip patterns
gwleuverink Jan 8, 2025
f2b3a1d
Merge branch 'NativePHP:main' into main
gwleuverink Jan 8, 2025
439c9b6
merge upstream
gwleuverink Jan 8, 2025
f1fe426
wip
gwleuverink Jan 8, 2025
d12628d
Build plugin
gwleuverink Jan 8, 2025
507be34
wip
gwleuverink Jan 8, 2025
2f6446f
remove redundant electron-builder app copy logic
gwleuverink Jan 8, 2025
587a9f5
move php building from separate step to beforePack hook
gwleuverink Jan 8, 2025
4c388eb
remove explicit php building from npm scripts
gwleuverink Jan 8, 2025
cc758fd
tidy
gwleuverink Jan 8, 2025
679ba0c
make sure database, logs, sessions & cached views are never included …
gwleuverink Jan 8, 2025
f9311c3
use 8.1 compatible syntax
gwleuverink Jan 8, 2025
0dba963
refactor to use symfony finder
gwleuverink Jan 13, 2025
d134a83
move vendor/bin & node_modules exclude to config file (see PR nativep…
gwleuverink Jan 13, 2025
680f041
fix ignore paths
gwleuverink Jan 13, 2025
08f6383
ignore vsc files
gwleuverink Jan 13, 2025
00da744
revert back to using RecursiveDirectoryIterator
gwleuverink Jan 13, 2025
e3cffc0
Fix styling
gwleuverink Jan 13, 2025
7670441
use npm ci for updating electron dependencies
gwleuverink Jan 13, 2025
a2633ac
Merge branch 'main' of github.com:gwleuverink/nativephp-electron
gwleuverink Jan 13, 2025
e1bd74d
update mac x86 comment
gwleuverink Jan 13, 2025
550922d
add PrunesVendorDirectory trait
gwleuverink Jan 14, 2025
7f6176b
move default exclude list to nativephp-internal config
gwleuverink Jan 14, 2025
b8eacfc
Fix styling
gwleuverink Jan 14, 2025
0225bc9
add comments for file relocation when more adapters are added later on
gwleuverink Jan 16, 2025
7d1f9aa
decouple terminal messages from the build traits
gwleuverink Jan 16, 2025
5b63f37
decouple source path from build traits (for testing)
gwleuverink Jan 16, 2025
99dc8ea
consolidate namespaces with identical purpose
gwleuverink Jan 16, 2025
08cbb7c
bring back default exclude list to electron repo
gwleuverink Jan 16, 2025
de68451
fix regression
gwleuverink Jan 16, 2025
fa53b11
wip - tests
gwleuverink Jan 16, 2025
0ad11cf
Merge branch 'main' of github.com:gwleuverink/nativephp-electron
gwleuverink Jan 16, 2025
0f7b711
Fix styling
gwleuverink Jan 16, 2025
b2c0baf
add more tests
gwleuverink Jan 16, 2025
017201b
Merge branch 'main' of github.com:gwleuverink/nativephp-electron
gwleuverink Jan 16, 2025
b310a74
Fix styling
gwleuverink Jan 16, 2025
0e5438a
more flexibility when working with paths
gwleuverink Jan 16, 2025
3229e7b
boyscouting
gwleuverink Jan 16, 2025
cf844ba
add filesystem stub directories to gitignore
gwleuverink Jan 16, 2025
6c09f38
add CleanEnvFile tests
gwleuverink Jan 16, 2025
5b94787
Merge branch 'main' of github.com:gwleuverink/nativephp-electron
gwleuverink Jan 16, 2025
1ae6d10
Fix styling
gwleuverink Jan 16, 2025
df31f36
add more tests
gwleuverink Jan 17, 2025
db5f919
Merge branch 'main' of github.com:gwleuverink/nativephp-electron
gwleuverink Jan 17, 2025
9a375e9
fix unclosed bracket
gwleuverink Jan 17, 2025
16ed54c
Fix styling
gwleuverink Jan 17, 2025
0a687c0
dependency compatibility for php 8.1
gwleuverink Jan 17, 2025
bf43fef
Merge branch 'main' of github.com:gwleuverink/nativephp-electron
gwleuverink Jan 17, 2025
296f980
use php 8.1 compatible syntax
gwleuverink Jan 17, 2025
42fb080
fix - native config not loaded in CI
gwleuverink Jan 17, 2025
7978451
wip - fix CI inconsistencies
gwleuverink Jan 17, 2025
2811d98
wip - typo
gwleuverink Jan 17, 2025
ca4ff79
fix typo
gwleuverink Jan 17, 2025
20a9077
Fix styling
gwleuverink Jan 17, 2025
eee682f
fix - yet another mistake
gwleuverink Jan 17, 2025
874cfbe
Merge branch 'main' of github.com:gwleuverink/nativephp-electron
gwleuverink Jan 17, 2025
1256e4a
use platform specific directory separators
gwleuverink Jan 17, 2025
63c8394
speed up tests & split by type
gwleuverink Jan 17, 2025
3924d34
Fix styling
gwleuverink Jan 17, 2025
73968c3
move app name step down
gwleuverink Jan 17, 2025
b0b9c34
remove mac x86 naming deviation
gwleuverink Jan 17, 2025
933cb92
Merge branch 'main' of github.com:gwleuverink/nativephp-electron
gwleuverink Jan 17, 2025
c2ae5af
add workflow_run trigger (for debugging)
gwleuverink Jan 21, 2025
330637d
Merge branch 'NativePHP:main' into main
gwleuverink Jan 21, 2025
fab50d9
workflow dispatch instead of run
gwleuverink Jan 21, 2025
9b1a310
cover unhappy path
gwleuverink Jan 22, 2025
141bccc
wip - fix test in CI
gwleuverink Jan 22, 2025
abe7dbd
wip - add dumps to debug CI errors
gwleuverink Jan 22, 2025
d5f16af
disable flaky test (due to tight repo coupling)
gwleuverink Jan 23, 2025
1d51cd8
Merge branch 'NativePHP:main' into main
gwleuverink Jan 23, 2025
d2180e1
wip - fix composer version conflict after upstream merge
gwleuverink Jan 23, 2025
956d2e3
Merge branch 'main' of github.com:gwleuverink/nativephp-electron
gwleuverink Jan 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: run-tests

on:
workflow_dispatch:
push:
branches: [main]
pull_request:
Expand All @@ -20,12 +21,12 @@ jobs:
- laravel: 10.*
testbench: ^8.18
carbon: ^2.67
laravel-package-tools: ^1.16
laravel-package-tools: ^1.16.4
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version in the Laravel repo wasn't compatible with the matrix we're running. Needed a bump to prevent composer errors in CI

collision: 7.*
- laravel: 11.*
testbench: 9.*
carbon: "^2.67|^3.0"
laravel-package-tools: ^1.16
laravel-package-tools: ^1.16.4
collision: ^8.1.1
exclude:
- laravel: 11.*
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"laravel/prompts": "^0.1.1|^0.2|^0.3",
"nativephp/laravel": "^1.0",
"nativephp/php-bin": "^0.5.1",
"spatie/laravel-package-tools": "^1.14.0"
"spatie/laravel-package-tools": "^1.14.0",
"symfony/filesystem": "^6.4|^7.2"
},
"require-dev": {
"laravel/pint": "^1.0",
Expand Down
102 changes: 20 additions & 82 deletions resources/js/electron-builder.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import os from 'os';
import { join } from 'path';
import { mkdtempSync } from 'fs';
import { exec } from 'child_process';

// Workaround for CommonJS module
import fs_extra from 'fs-extra';
const { copySync, removeSync, writeJsonSync } = fs_extra;

const isBuilding = process.env.NATIVEPHP_BUILDING;
const appUrl = process.env.APP_URL;
const appId = process.env.NATIVEPHP_APP_ID;
const appName = process.env.NATIVEPHP_APP_NAME;
const isBuilding = process.env.NATIVEPHP_BUILDING;
const appAuthor = process.env.NATIVEPHP_APP_AUTHOR;
const fileName = process.env.NATIVEPHP_APP_FILENAME;
const appVersion = process.env.NATIVEPHP_APP_VERSION;
const appUrl = process.env.APP_URL;
const appAuthor = process.env.NATIVEPHP_APP_AUTHOR;
const deepLinkProtocol = process.env.NATIVEPHP_DEEPLINK_SCHEME;

// Since we do not copy the php executable here, we only need these for building
Expand All @@ -25,20 +20,18 @@ let targetOs;
if (isWindows) {
targetOs = 'win';
}

if (isLinux) {
targetOs = 'linux';
}
// Use of isDarwin

if (isDarwin) {
targetOs = 'mac';
}


let updaterConfig = {};

// We wouldn't need these since its not representing the target platform
console.log("Arch: ", process.arch)
console.log("Platform: ", process.platform)
try {
updaterConfig = process.env.NATIVEPHP_UPDATER_CONFIG;
updaterConfig = JSON.parse(updaterConfig);
Expand All @@ -47,82 +40,13 @@ try {
}

if (isBuilding) {

console.log();
console.log('===================================================================');
console.log(' Building for ' + targetOs);
console.log('===================================================================');
console.log();
console.log('Updater config', updaterConfig);
console.log();

try {
const appPath = join(import.meta.dirname, 'resources', 'app');

removeSync(appPath);

// As we can't copy into a subdirectory of ourself we need to copy to a temp directory
let tmpDir = mkdtempSync(join(os.tmpdir(), 'nativephp'));

copySync(process.env.APP_PATH, tmpDir, {
overwrite: true,
dereference: true,
filter: (src, dest) => {
let skip = [
// Skip .git and Dev directories
join(process.env.APP_PATH, '.git'),
join(process.env.APP_PATH, 'docker'),
join(process.env.APP_PATH, 'packages'),

// Only needed for local testing
join(process.env.APP_PATH, 'vendor', 'nativephp', 'electron', 'vendor'),
join(process.env.APP_PATH, 'vendor', 'nativephp', 'laravel', 'vendor'),

join(process.env.APP_PATH, 'vendor', 'nativephp', 'php-bin'),
join(process.env.APP_PATH, 'vendor', 'nativephp', 'electron', 'bin'),
join(process.env.APP_PATH, 'vendor', 'nativephp', 'electron', 'resources'),
join(process.env.APP_PATH, 'node_modules'),
join(process.env.APP_PATH, 'dist'),
];

let shouldSkip = false;
skip.forEach((path) => {
if (src.indexOf(path) === 0) {
shouldSkip = true;
}
});

return !shouldSkip;
}
});

copySync(tmpDir, appPath);

// Electron build removes empty folders, so we have to create dummy files
// dotfiles unfortunately don't work.
writeJsonSync(join(appPath, 'storage', 'framework', 'cache', '_native.json'), {})
writeJsonSync(join(appPath, 'storage', 'framework', 'sessions', '_native.json'), {})
writeJsonSync(join(appPath, 'storage', 'framework', 'testing', '_native.json'), {})
writeJsonSync(join(appPath, 'storage', 'framework', 'views', '_native.json'), {})
writeJsonSync(join(appPath, 'storage', 'app', 'public', '_native.json'), {})
writeJsonSync(join(appPath, 'storage', 'logs', '_native.json'), {})

removeSync(tmpDir);

console.log();
console.log('Copied app to resources');
console.log(join(process.env.APP_PATH, 'dist'));
console.log();
console.log('===================================================================');
console.log(' Starting build...');
console.log();
} catch (e) {
console.error();
console.error('Error copying app into build environment');
console.error(e);
console.error();
}

}

export default {
Expand All @@ -142,6 +66,20 @@ export default {
asarUnpack: [
'resources/**',
],
beforePack: async (context) => {
let arch = {
1: 'x64',
3: 'arm64'
}[context.arch];

if(arch === undefined) {
console.error('Cannot build PHP for unsupported architecture');
process.exit(1);
}

console.log(` • building php binary - exec php.js --${targetOs} --${arch}`);
exec(`node php.js --${targetOs} --${arch}`);
},
afterSign: 'build/notarize.js',
win: {
executableName: fileName,
Expand Down
Loading
Loading