diff --git a/app/package.json b/app/package.json index 09b21bb..2dd4dce 100644 --- a/app/package.json +++ b/app/package.json @@ -6,7 +6,7 @@ "scripts": { "build": "yarn rebuild && webpack --mode production", "dev": "node_modules/.bin/webpack-dev-server --mode development --progress", - "rebuild": "cd node_modules/heapdump && node-gyp rebuild --target=5.0.0 --arch=x64 --dist-url=https://atom.io/download/electron; cd -" + "rebuild": "cd node_modules/heapdump && node-gyp rebuild --target=5.0.0 --arch=x64 --dist-url=https://atom.io/download/electron || echo Could not build heapdump; cd -" }, "author": "", "license": "CC-BY-ND-4.0", diff --git a/app/src/components/App.tsx b/app/src/components/App.tsx index 9ee6f42..0cde894 100644 --- a/app/src/components/App.tsx +++ b/app/src/components/App.tsx @@ -89,6 +89,12 @@ class App extends React.PureComponent { const styles = (theme: Theme) => { const drawerWidth = 300 + const contentBaseStyle = { + width: '100vw', + overflow: 'hidden' as 'hidden', + backgroundColor: theme.palette.background.default, + } + return { heightProperty: { height: 'calc(100vh - 64px) !important', @@ -106,9 +112,7 @@ const styles = (theme: Theme) => { overflow: 'hidden' as 'hidden', }, content: { - width: '100vw', - overflowX: 'hidden' as 'hidden', - backgroundColor: theme.palette.background.default, + ...contentBaseStyle, transition: theme.transitions.create('transform', { easing: theme.transitions.easing.sharp, duration: theme.transitions.duration.leavingScreen, @@ -116,9 +120,7 @@ const styles = (theme: Theme) => { transform: 'translateX(0px)', }, contentShift: { - overflowX: 'hidden' as 'hidden', - width: '100vw', - padding: 0, + ...contentBaseStyle, backgroundColor: theme.palette.background.default, transition: theme.transitions.create('transform', { easing: theme.transitions.easing.easeOut, diff --git a/backend/src/ConfigStorage.ts b/backend/src/ConfigStorage.ts index 5ea262f..1e48cad 100644 --- a/backend/src/ConfigStorage.ts +++ b/backend/src/ConfigStorage.ts @@ -1,13 +1,15 @@ import * as FileAsync from 'lowdb/adapters/FileAsync' +import * as fs from 'fs-extra' import * as lowdb from 'lowdb' +import * as path from 'path' import { backendEvents } from '../../events' import { + makeStorageAcknowledgementEvent, makeStorageResponseEvent, storageClearEvent, storageLoadEvent, - storageStoreEvent, - makeStorageAcknowledgementEvent -} from '../../events/StorageEvents' + storageStoreEvent + } from '../../events/StorageEvents' export default class ConfigStorage { private file: string @@ -17,6 +19,10 @@ export default class ConfigStorage { } private async getDb() { + const pathInfo = path.parse(this.file) + + // Ensure that Settings dir exists + await fs.mkdirp(pathInfo.dir) const adapter = new FileAsync(this.file) if (!this.database) { this.database = await lowdb(adapter) diff --git a/package.json b/package.json index f615749..ed5246e 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "publish": [ "github" ], - "provisioningProfile": "res/MQTT_Explorer_Store_Distribution_Profile.provisionprofile", "entitlements": "res/entitlements.mas.plist" }, "linux": { @@ -91,6 +90,7 @@ }, "dependencies": { "about-window": "^1.12.1", + "dot-prop": "^5.0.0", "electron-log": "^2.2.17", "electron-telemetry": "git+https://github.com/thomasnordquist/electron-telemetry.git#dist", "electron-updater": "^4.0.6", diff --git a/package.ts b/package.ts index 982bc23..daa43a1 100644 --- a/package.ts +++ b/package.ts @@ -1,6 +1,7 @@ import * as builder from 'electron-builder' import * as fs from 'fs' import * as path from 'path' +import * as dotProp from 'dot-prop' const linuxAppImage: builder.CliOptions = { x64: true, @@ -88,20 +89,36 @@ type Packages = 'portable' | 'nsis' | 'appx' | 'AppImage' | 'snap' | 'dmg' | 'zi async function buildWithOptions(options: builder.CliOptions, buildInfo: BuildInfo) { fs.writeFileSync(path.join(options.projectDir!, 'buildOptions.json'), JSON.stringify(buildInfo)) - ensureAppNameForPackage(options, buildInfo.package) - await builder.build({ - ...options, - [buildInfo.platform]: [buildInfo.package], - }) -} - -// AppX must hav a different name since the store name is already taken (but not used) -function ensureAppNameForPackage(options: builder.CliOptions, packageOption: Packages) { const jsonLocation = path.join((options.projectDir as string), 'package.json') + const packageJsonStr = fs.readFileSync(jsonLocation).toString() + const packageJson = JSON.parse(fs.readFileSync(jsonLocation).toString()) - packageJson.build.productName = packageOption === 'appx' ? 'MQTT-Explorer' : 'MQTT Explorer' - fs.writeFileSync(jsonLocation, JSON.stringify(packageJson, undefined, ' ')) + + // AppX must have a different name since the store name is already taken (but not used) + if (buildInfo.package === 'appx') { + dotProp.set(packageJson, 'build.productName', 'MQTT-Explorer') + } + + if (buildInfo.platform === 'mac') { + console.log(buildInfo.package) + const provisioningProfile = (buildInfo.package === 'mas') ? 'res/MQTT_Explorer_Store_Distribution_Profile.provisionprofile' : 'res/MQTTExplorerdmg.provisionprofile' + dotProp.set(packageJson, 'build.mac.provisioningProfile', provisioningProfile) + } + + try { + // Write modified package.json + fs.writeFileSync(jsonLocation, JSON.stringify(packageJson)) + await builder.build({ + ...options, + [buildInfo.platform]: [buildInfo.package], + }) + } catch (error) { + throw error + } finally { + // Roll back changes to package.json + fs.writeFileSync(jsonLocation, packageJsonStr) + } } function build() { diff --git a/res/MQTTExplorerdmg.provisionprofile b/res/MQTTExplorerdmg.provisionprofile new file mode 100644 index 0000000..0221c36 Binary files /dev/null and b/res/MQTTExplorerdmg.provisionprofile differ diff --git a/src/electron.ts b/src/electron.ts index bac0b4b..e8ee291 100644 --- a/src/electron.ts +++ b/src/electron.ts @@ -14,6 +14,8 @@ if (!isDev() && !runningUiTestOnCi()) { const electronTelemetry = electronTelemetryFactory('9b0c8ca04a361eb8160d98c5', buildOptions) } +app.commandLine.appendSwitch('--no-sandbox') + autoUpdater.logger = log log.info('App starting...') @@ -33,7 +35,7 @@ async function createWindow() { loadDevTools() } - const iconPath = path.join(__dirname, 'icon.png') + const iconPath = path.join(__dirname, '..', '..', 'icon.png') // Create the browser window. mainWindow = new BrowserWindow({ width: 1024, @@ -42,13 +44,14 @@ async function createWindow() { webPreferences: { nodeIntegration: true, devTools: true, + sandbox: false, }, icon: iconPath, }) mainWindow.once('ready-to-show', () => { if (mainWindow) { - runningUiTestOnCi && mainWindow.setFullScreen(true) + runningUiTestOnCi() && mainWindow.setFullScreen(true) mainWindow.show() } }) diff --git a/yarn.lock b/yarn.lock index 48c3892..1ddd166 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1131,6 +1131,13 @@ dot-prop@^4.1.0: dependencies: is-obj "^1.0.0" +dot-prop@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-5.0.0.tgz#64b7968af349c3a9f966aa12658dbd5829f6b953" + integrity sha512-RTmaF2jx3nOBO2GvtFqjnDLycjFUMqt+2pwRx7JVYa81lDauoj9aNkyrJI2ikR58FbBIchiIlRiGG+muLJ4oHQ== + dependencies: + is-obj "^1.0.0" + dotenv-expand@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-4.2.0.tgz#def1f1ca5d6059d24a766e587942c21106ce1275"