Skip to content

Commit fbd28ea

Browse files
WINBIGFOXsimonhamp
andauthored
style: apply Prettier configs and standardize formatting across electron plugin (#69)
* style: apply Prettier configurations and improve code consistency Applied Prettier rules across project files to enforce consistent code formatting. Added `.prettierrc` and `.prettierignore` files, updated dependencies with `prettier-plugin-organize-imports`, and refactored imports, string quotes, and object formatting for uniformity. * merge main into branch and resolve conflicts --------- Co-authored-by: Simon Hamp <simon.hamp@me.com>
1 parent a028946 commit fbd28ea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2287
-3066
lines changed

resources/electron/.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
out
2+
electron-plugin/dist
3+
package-lock.json
4+
eslint.config.js
5+
.prettierrc.json

resources/electron/.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"plugins": ["prettier-plugin-organize-imports"],
3+
"trailingComma": "all",
4+
"tabWidth": 4,
5+
"semi": true,
6+
"singleQuote": true,
7+
"printWidth": 120
8+
}

resources/electron/build/notarize.js

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,26 @@ export default async (context) => {
77
// And the current build target is macOS
88
if (context.packager.platform.name !== 'mac') return;
99

10-
console.log('aftersign hook triggered, start to notarize app.')
11-
12-
if (!('NATIVEPHP_APPLE_ID' in process.env && 'NATIVEPHP_APPLE_ID_PASS' in process.env && 'NATIVEPHP_APPLE_TEAM_ID' in process.env)) {
13-
console.warn('skipping notarizing, NATIVEPHP_APPLE_ID, NATIVEPHP_APPLE_ID_PASS and NATIVEPHP_APPLE_TEAM_ID env variables must be set.')
14-
return
10+
console.log('aftersign hook triggered, start to notarize app.');
11+
12+
if (
13+
!(
14+
'NATIVEPHP_APPLE_ID' in process.env &&
15+
'NATIVEPHP_APPLE_ID_PASS' in process.env &&
16+
'NATIVEPHP_APPLE_TEAM_ID' in process.env
17+
)
18+
) {
19+
console.warn(
20+
'skipping notarizing, NATIVEPHP_APPLE_ID, NATIVEPHP_APPLE_ID_PASS and NATIVEPHP_APPLE_TEAM_ID env variables must be set.',
21+
);
22+
return;
1523
}
1624

1725
const appId = process.env.NATIVEPHP_APP_ID;
1826

19-
const {appOutDir} = context
27+
const { appOutDir } = context;
2028

21-
const appName = context.packager.appInfo.productFilename
29+
const appName = context.packager.appInfo.productFilename;
2230

2331
try {
2432
await notarize({
@@ -28,10 +36,10 @@ export default async (context) => {
2836
appleIdPassword: process.env.NATIVEPHP_APPLE_ID_PASS,
2937
teamId: process.env.NATIVEPHP_APPLE_TEAM_ID,
3038
tool: 'notarytool',
31-
})
39+
});
3240
} catch (error) {
33-
console.error(error)
41+
console.error(error);
3442
}
3543

36-
console.log(`done notarizing ${appId}.`)
37-
}
44+
console.log(`done notarizing ${appId}.`);
45+
};

resources/electron/electron-builder.mjs

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ let updaterConfig = {};
4141
try {
4242
updaterConfig = process.env.NATIVEPHP_UPDATER_CONFIG;
4343
updaterConfig = JSON.parse(updaterConfig);
44-
} catch (e) {
44+
} catch {
4545
updaterConfig = {};
4646
}
4747

@@ -68,7 +68,7 @@ export default {
6868
beforePack: async (context) => {
6969
let arch = {
7070
1: 'x64',
71-
3: 'arm64'
71+
3: 'arm64',
7272
}[context.arch];
7373

7474
if (arch === undefined) {
@@ -82,13 +82,15 @@ export default {
8282
afterSign: 'build/notarize.js',
8383
win: {
8484
executableName: fileName,
85-
...(azureEndpoint && azureCertificateProfileName && azureCodeSigningAccountName ? {
86-
azureSignOptions: {
87-
endpoint: azureEndpoint,
88-
certificateProfileName: azureCertificateProfileName,
89-
codeSigningAccountName: azureCodeSigningAccountName
85+
...(azureEndpoint && azureCertificateProfileName && azureCodeSigningAccountName
86+
? {
87+
azureSignOptions: {
88+
endpoint: azureEndpoint,
89+
certificateProfileName: azureCertificateProfileName,
90+
codeSigningAccountName: azureCodeSigningAccountName
91+
},
9092
}
91-
} : {}),
93+
: {}),
9294
},
9395
nsis: {
9496
artifactName: appName + '-${version}-setup.${ext}',
@@ -104,14 +106,10 @@ export default {
104106
entitlementsInherit: 'build/entitlements.mac.plist',
105107
artifactName: appName + '-${version}-${arch}.${ext}',
106108
extendInfo: {
107-
NSCameraUsageDescription:
108-
"Application requests access to the device's camera.",
109-
NSMicrophoneUsageDescription:
110-
"Application requests access to the device's microphone.",
111-
NSDocumentsFolderUsageDescription:
112-
"Application requests access to the user's Documents folder.",
113-
NSDownloadsFolderUsageDescription:
114-
"Application requests access to the user's Downloads folder.",
109+
NSCameraUsageDescription: "Application requests access to the device's camera.",
110+
NSMicrophoneUsageDescription: "Application requests access to the device's microphone.",
111+
NSDocumentsFolderUsageDescription: "Application requests access to the user's Documents folder.",
112+
NSDownloadsFolderUsageDescription: "Application requests access to the user's Downloads folder.",
115113
},
116114
},
117115
dmg: {
@@ -136,22 +134,15 @@ export default {
136134
{
137135
from: process.env.NATIVEPHP_BUILD_PATH,
138136
to: 'build',
139-
filter: [
140-
'**/*',
141-
'!{.git}',
142-
]
143-
}
137+
filter: ['**/*', '!{.git}'],
138+
},
144139
],
145140
extraFiles: [
146141
{
147142
from: join(process.env.APP_PATH, 'extras'),
148143
to: 'extras',
149-
filter: [
150-
'**/*'
151-
]
152-
}
144+
filter: ['**/*'],
145+
},
153146
],
154-
...updaterEnabled
155-
? { publish: updaterConfig }
156-
: {}
147+
...(updaterEnabled ? { publish: updaterConfig } : {}),
157148
};
Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
{
2-
"extends": [
3-
"stylelint-config-recommended",
4-
"stylelint-config-sass-guidelines"
5-
],
6-
"overrides": [
7-
{
8-
"files": ["**/*.scss"],
9-
"customSyntax": "postcss-scss"
2+
"extends": ["stylelint-config-recommended", "stylelint-config-sass-guidelines"],
3+
"overrides": [
4+
{
5+
"files": ["**/*.scss"],
6+
"customSyntax": "postcss-scss"
7+
}
8+
],
9+
"rules": {
10+
"function-parentheses-space-inside": null,
11+
"no-descending-specificity": null,
12+
"max-nesting-depth": 2,
13+
"selector-max-id": 1
1014
}
11-
],
12-
"rules": {
13-
"function-parentheses-space-inside": null,
14-
"no-descending-specificity": null,
15-
"max-nesting-depth": 2,
16-
"selector-max-id": 1
17-
}
1815
}
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
export default {
2-
presets: [
3-
['@babel/preset-env', {targets: {node: 'current'}}],
4-
'@babel/preset-typescript',
5-
],
2+
presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'],
63
};

0 commit comments

Comments
 (0)