add MAC variant for build

This commit is contained in:
Son NK
2022-11-08 18:18:30 +01:00
parent c820e64306
commit ea3f00b808
7 changed files with 54 additions and 29 deletions
+9 -1
View File
@@ -78,7 +78,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
variant: ['full', 'lite']
variant: ['full', 'lite', 'mac']
steps:
- name: Build info
@@ -136,6 +136,14 @@ jobs:
npm run build
npm run build-zip
- name: Build Mac version
if: matrix.variant == 'mac'
shell: bash
run: |
npm install
npm run build:mac
npm run build-zip
- name: Package extension
run: |
ZIP_NAME=$(find dist-zip -type f -name '*.zip' | head -n 1)
+6
View File
@@ -74,6 +74,12 @@ In order to build the extension yourself, please follow these steps:
- (Optional, only useful for beta build) Build beta version: change `betaRev` in `package.json`, then generate zip file using
## How to build a version for Mac
For the development, you can run `npm run start:mac` for the Mac app.
For the production release, `npm run build:mac`
```bash
npm run build:beta && npm run build-zip
```
+3 -1
View File
@@ -13,11 +13,13 @@
"build:lite": "cross-env NODE_ENV=production LITE=1 webpack",
"build:beta": "cross-env NODE_ENV=production BETA=1 webpack",
"build:dev": "cross-env NODE_ENV=development BETA=1 webpack",
"build:mac": "cross-env NODE_ENV=production MAC=1 webpack",
"build-zip": "node scripts/build-zip.js",
"generate:buildconfig": "node scripts/generateBuildConfig.js",
"watch": "npm run build -- --watch",
"watch:dev": "cross-env HMR=true npm run build:dev -- --watch",
"start": "cross-env HMR=true npm run build:dev -- --watch"
"start": "cross-env HMR=true npm run build:dev -- --watch",
"start:mac": "cross-env HMR=true MAC=1 npm run build:dev -- --watch"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.36",
-1
View File
@@ -15,7 +15,6 @@
"activeTab",
"storage",
"contextMenus",
"nativeMessaging",
"https://*.simplelogin.io/*",
"http://*/*",
"https://*/*"
+5 -7
View File
@@ -186,16 +186,14 @@ export default {
EventManager.broadcast(EventManager.EVENT.SETTINGS_CHANGED);
Navigation.clearHistoryAndNavigateTo(Navigation.PATH.LOGIN);
try {
if (process.env.MAC) {
console.log("send log out event to host app");
let r = await browser.runtime.sendNativeMessage(
await browser.runtime.sendNativeMessage(
"application.id",
JSON.stringify({
logged_out: {},
})
);
} catch (error) {
console.info("can't send data to native app", error);
}
},
@@ -208,15 +206,15 @@ export default {
this.reportURISLButton = `mailto:extension@simplelogin.io?subject=${subject}&body=${body}`;
},
async upgrade() {
try {
if (process.env.MAC) {
console.log("send upgrade event to host app");
let r = await browser.runtime.sendNativeMessage(
await browser.runtime.sendNativeMessage(
"application.id",
JSON.stringify({
upgrade: {},
})
);
} catch (error) {
} else {
console.info("can't send data to native app", error);
let apiUrl = await SLStorage.get(SLStorage.SETTINGS.API_URL);
let upgradeURL = apiUrl + "/dashboard/pricing";
+15 -19
View File
@@ -262,23 +262,19 @@ export default {
this.apiUrl = await SLStorage.get(SLStorage.SETTINGS.API_URL);
this.apiKey = await SLStorage.get(SLStorage.SETTINGS.API_KEY);
if (this.apiKey) {
try {
console.log("send api key to host app");
let r = await browser.runtime.sendNativeMessage(
"application.id",
JSON.stringify({
logged_in: {
data: {
api_key: this.apiKey,
api_url: this.apiUrl,
},
if (this.apiKey && process.env.MAC) {
console.log("send api key to host app");
await browser.runtime.sendNativeMessage(
"application.id",
JSON.stringify({
logged_in: {
data: {
api_key: this.apiKey,
api_url: this.apiUrl,
},
})
);
} catch (error) {
console.info("can't send data to native app", error);
}
},
})
);
}
this.contentElem = document.querySelector(".app > .content");
@@ -528,15 +524,15 @@ export default {
},
async upgrade() {
try {
if (process.env.MAC) {
console.log("send upgrade event to host app");
let r = await browser.runtime.sendNativeMessage(
await browser.runtime.sendNativeMessage(
"application.id",
JSON.stringify({
upgrade: {},
})
);
} catch (error) {
} else {
console.info("can't send data to native app", error);
let upgradeURL = this.apiUrl + "/dashboard/pricing";
browser.tabs.create({ url: upgradeURL });
+16
View File
@@ -138,6 +138,14 @@ const config = {
jsonContent.short_name = "SimpleLogin Without SL icon";
}
if (process.env.MAC) {
jsonContent.permissions.push("nativeMessaging");
// Change metadata
jsonContent.name = "SimpleLogin Mac App";
jsonContent.short_name = "SimpleLogin Mac App";
}
return JSON.stringify(jsonContent, null, 2);
},
},
@@ -155,6 +163,14 @@ if (config.mode === 'development') {
]);
}
if (process.env.MAC){
config.plugins = (config.plugins || []).concat([
new webpack.DefinePlugin({
'process.env.MAC': JSON.stringify(!!process.env.MAC),
}),
]);
}
if (config.mode === 'production') {
config.plugins = (config.plugins || []).concat([
new webpack.DefinePlugin({