Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 5 additions & 0 deletions resources/electron/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
out
electron-plugin/dist
package-lock.json
eslint.config.js
.prettierrc.json
8 changes: 8 additions & 0 deletions resources/electron/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"plugins": ["prettier-plugin-organize-imports"],
"trailingComma": "all",
"tabWidth": 4,
"semi": true,
"singleQuote": true,
"printWidth": 120
}
30 changes: 19 additions & 11 deletions resources/electron/build/notarize.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,26 @@ export default async (context) => {
// And the current build target is macOS
if (context.packager.platform.name !== 'mac') return;

console.log('aftersign hook triggered, start to notarize app.')

if (!('NATIVEPHP_APPLE_ID' in process.env && 'NATIVEPHP_APPLE_ID_PASS' in process.env && 'NATIVEPHP_APPLE_TEAM_ID' in process.env)) {
console.warn('skipping notarizing, NATIVEPHP_APPLE_ID, NATIVEPHP_APPLE_ID_PASS and NATIVEPHP_APPLE_TEAM_ID env variables must be set.')
return
console.log('aftersign hook triggered, start to notarize app.');

if (
!(
'NATIVEPHP_APPLE_ID' in process.env &&
'NATIVEPHP_APPLE_ID_PASS' in process.env &&
'NATIVEPHP_APPLE_TEAM_ID' in process.env
)
) {
console.warn(
'skipping notarizing, NATIVEPHP_APPLE_ID, NATIVEPHP_APPLE_ID_PASS and NATIVEPHP_APPLE_TEAM_ID env variables must be set.',
);
return;
}

const appId = process.env.NATIVEPHP_APP_ID;

const {appOutDir} = context
const { appOutDir } = context;

const appName = context.packager.appInfo.productFilename
const appName = context.packager.appInfo.productFilename;

try {
await notarize({
Expand All @@ -28,10 +36,10 @@ export default async (context) => {
appleIdPassword: process.env.NATIVEPHP_APPLE_ID_PASS,
teamId: process.env.NATIVEPHP_APPLE_TEAM_ID,
tool: 'notarytool',
})
});
} catch (error) {
console.error(error)
console.error(error);
}

console.log(`done notarizing ${appId}.`)
}
console.log(`done notarizing ${appId}.`);
};
51 changes: 21 additions & 30 deletions resources/electron/electron-builder.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ let updaterConfig = {};
try {
updaterConfig = process.env.NATIVEPHP_UPDATER_CONFIG;
updaterConfig = JSON.parse(updaterConfig);
} catch (e) {
} catch {
updaterConfig = {};
}

Expand All @@ -69,7 +69,7 @@ export default {
beforePack: async (context) => {
let arch = {
1: 'x64',
3: 'arm64'
3: 'arm64',
}[context.arch];

if (arch === undefined) {
Expand All @@ -83,14 +83,16 @@ export default {
afterSign: 'build/notarize.js',
win: {
executableName: fileName,
...(azurePublisherName && azureEndpoint && azureCertificateProfileName && azureCodeSigningAccountName ? {
azureSignOptions: {
publisherName: azurePublisherName,
endpoint: azureEndpoint,
certificateProfileName: azureCertificateProfileName,
codeSigningAccountName: azureCodeSigningAccountName
}
} : {}),
...(azurePublisherName && azureEndpoint && azureCertificateProfileName && azureCodeSigningAccountName
? {
azureSignOptions: {
publisherName: azurePublisherName,
endpoint: azureEndpoint,
certificateProfileName: azureCertificateProfileName,
codeSigningAccountName: azureCodeSigningAccountName,
},
}
: {}),
},
nsis: {
artifactName: appName + '-${version}-setup.${ext}',
Expand All @@ -106,14 +108,10 @@ export default {
entitlementsInherit: 'build/entitlements.mac.plist',
artifactName: appName + '-${version}-${arch}.${ext}',
extendInfo: {
NSCameraUsageDescription:
"Application requests access to the device's camera.",
NSMicrophoneUsageDescription:
"Application requests access to the device's microphone.",
NSDocumentsFolderUsageDescription:
"Application requests access to the user's Documents folder.",
NSDownloadsFolderUsageDescription:
"Application requests access to the user's Downloads folder.",
NSCameraUsageDescription: "Application requests access to the device's camera.",
NSMicrophoneUsageDescription: "Application requests access to the device's microphone.",
NSDocumentsFolderUsageDescription: "Application requests access to the user's Documents folder.",
NSDownloadsFolderUsageDescription: "Application requests access to the user's Downloads folder.",
},
},
dmg: {
Expand All @@ -138,22 +136,15 @@ export default {
{
from: process.env.NATIVEPHP_BUILD_PATH,
to: 'build',
filter: [
'**/*',
'!{.git}',
]
}
filter: ['**/*', '!{.git}'],
},
],
extraFiles: [
{
from: join(process.env.APP_PATH, 'extras'),
to: 'extras',
filter: [
'**/*'
]
}
filter: ['**/*'],
},
],
...updaterEnabled
? { publish: updaterConfig }
: {}
...(updaterEnabled ? { publish: updaterConfig } : {}),
};
27 changes: 12 additions & 15 deletions resources/electron/electron-plugin/.stylelintrc
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
{
"extends": [
"stylelint-config-recommended",
"stylelint-config-sass-guidelines"
],
"overrides": [
{
"files": ["**/*.scss"],
"customSyntax": "postcss-scss"
"extends": ["stylelint-config-recommended", "stylelint-config-sass-guidelines"],
"overrides": [
{
"files": ["**/*.scss"],
"customSyntax": "postcss-scss"
}
],
"rules": {
"function-parentheses-space-inside": null,
"no-descending-specificity": null,
"max-nesting-depth": 2,
"selector-max-id": 1
}
],
"rules": {
"function-parentheses-space-inside": null,
"no-descending-specificity": null,
"max-nesting-depth": 2,
"selector-max-id": 1
}
}
5 changes: 1 addition & 4 deletions resources/electron/electron-plugin/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
export default {
presets: [
['@babel/preset-env', {targets: {node: 'current'}}],
'@babel/preset-typescript',
],
presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'],
};
Loading