Skip to content

Commit

Permalink
fix: Make splash screen visible for new windows
Browse files Browse the repository at this point in the history
  • Loading branch information
erdkse authored and kambydyne committed Oct 7, 2021
1 parent 70b941a commit a9cd31e
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 116 deletions.
14 changes: 9 additions & 5 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {createMenu, getDockMenu} from './menu';
import {K8sResource} from '@models/k8sresource';
import {isInPreviewModeSelector} from '@redux/selectors';
import {HelmChart, HelmValuesFile} from '@models/helm';
import {PROCESS_ENV} from '@utils/env';

import initKubeconfig from './src/initKubeconfig';
import terminal from '../cli/terminal';
Expand All @@ -40,7 +41,7 @@ autoUpdater.logger = console;

const {MONOKLE_RUN_AS_NODE} = process.env;

const isDev = process.env.NODE_ENV === 'development';
const isDev = PROCESS_ENV.NODE_ENV === 'development';

const userHomeDir = app.getPath('home');
const APP_DEPENDENCIES = ['kubectl', 'helm'];
Expand All @@ -58,8 +59,8 @@ ipcMain.on('run-kustomize', (event, folder: string) => {
let stdout = execSync('kubectl kustomize ./', {
cwd: folder,
env: {
NODE_ENV: process.env.NODE_ENV,
PUBLIC_URL: process.env.PUBLIC_URL,
NODE_ENV: PROCESS_ENV.NODE_ENV,
PUBLIC_URL: PROCESS_ENV.PUBLIC_URL,
},
});

Expand Down Expand Up @@ -105,8 +106,8 @@ ipcMain.on('run-helm', (event, args: any) => {
let stdout = execSync(args.helmCommand, {
cwd: args.cwd,
env: {
NODE_ENV: process.env.NODE_ENV,
PUBLIC_URL: process.env.PUBLIC_URL,
NODE_ENV: PROCESS_ENV.NODE_ENV,
PUBLIC_URL: PROCESS_ENV.PUBLIC_URL,
KUBECONFIG: args.kubeconfig,
},
});
Expand Down Expand Up @@ -308,6 +309,9 @@ terminal()
.catch(e => console.log(e));

export const setWindowTitle = (store: any, window: BrowserWindow) => {
if (!store || !window) {
return;
}
const state = store.getState();
const isInPreviewMode = isInPreviewModeSelector(state);
const previewType = state.main.previewType;
Expand Down
196 changes: 98 additions & 98 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/redux/services/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import fs from 'fs';
import path from 'path';
import {PROCESS_ENV} from '@utils/env';

/**
* Gets the absolute path to a statically bundled resource in the /resources folder
*/

export function getStaticResourcePath(resourcePath: string) {
return process.env.NODE_ENV === 'production'
? // @ts-ignore
path.join(process.resourcesPath, 'resources', resourcePath)
: path.join('resources', resourcePath);
return PROCESS_ENV.NODE_ENV === 'development'
? path.join('resources', resourcePath)
: path.join(process.resourcesPath, 'resources', resourcePath);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/redux/thunks/applyFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {getShellPath} from '@utils/shell';
import {setApplyingResource} from '@redux/reducers/main';
import fs from 'fs';
import {getAbsoluteFileEntryPath} from '@redux/services/fileEntry';
import {PROCESS_ENV} from '@utils/env';

/**
* Invokes kubectl for the content of the specified resource
Expand All @@ -16,8 +17,8 @@ import {getAbsoluteFileEntryPath} from '@redux/services/fileEntry';
function applyFileToCluster(filePath: string, kubeconfig: string) {
const child = spawn('kubectl', ['apply', '-f', '-'], {
env: {
NODE_ENV: process.env.NODE_ENV,
PUBLIC_URL: process.env.PUBLIC_URL,
NODE_ENV: PROCESS_ENV.NODE_ENV,
PUBLIC_URL: PROCESS_ENV.PUBLIC_URL,
PATH: getShellPath(),
KUBECONFIG: kubeconfig,
},
Expand Down
5 changes: 3 additions & 2 deletions src/redux/thunks/applyHelmChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {getAbsoluteHelmChartPath, getAbsoluteValuesFilePath} from '@redux/servic
import {setAlert} from '@redux/reducers/alert';
import {AlertEnum, AlertType} from '@models/alert';
import path from 'path';
import {PROCESS_ENV} from '@utils/env';

/**
* Invokes helm install for the specified helm chart and values file
Expand All @@ -27,8 +28,8 @@ function applyHelmChartToCluster(
['install', '-f', getAbsoluteValuesFilePath(valuesFile, fileMap), helmChart.name, chartPath],
{
env: {
NODE_ENV: process.env.NODE_ENV,
PUBLIC_URL: process.env.PUBLIC_URL,
NODE_ENV: PROCESS_ENV.NODE_ENV,
PUBLIC_URL: PROCESS_ENV.PUBLIC_URL,
PATH: getShellPath(),
KUBECONFIG: kubeconfig,
},
Expand Down
9 changes: 5 additions & 4 deletions src/redux/thunks/applyResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {isKustomizationResource} from '@redux/services/kustomize';
import {getShellPath} from '@utils/shell';
import {setApplyingResource, updateResource} from '@redux/reducers/main';
import {getResourceFromCluster} from '@redux/thunks/utils';
import {PROCESS_ENV} from '@utils/env';
import {performResourceDiff} from './diffResource';

/**
Expand All @@ -20,8 +21,8 @@ import {performResourceDiff} from './diffResource';
function applyK8sResource(resource: K8sResource, kubeconfig: string) {
const child = spawn('kubectl', ['apply', '-f', '-'], {
env: {
NODE_ENV: process.env.NODE_ENV,
PUBLIC_URL: process.env.PUBLIC_URL,
NODE_ENV: PROCESS_ENV.NODE_ENV,
PUBLIC_URL: PROCESS_ENV.PUBLIC_URL,
PATH: getShellPath(),
KUBECONFIG: kubeconfig,
},
Expand All @@ -39,8 +40,8 @@ function applyKustomization(resource: K8sResource, fileMap: FileMapType, kubecon
const folder = getAbsoluteResourceFolder(resource, fileMap);
const child = spawn('kubectl', ['apply', '-k', folder], {
env: {
NODE_ENV: process.env.NODE_ENV,
PUBLIC_URL: process.env.PUBLIC_URL,
NODE_ENV: PROCESS_ENV.NODE_ENV,
PUBLIC_URL: PROCESS_ENV.PUBLIC_URL,
PATH: getShellPath(),
KUBECONFIG: kubeconfig,
},
Expand Down
1 change: 0 additions & 1 deletion src/utils/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,4 @@ function shellEnvSync() {
}
}
}

export const PROCESS_ENV: any = shellEnvSync();

0 comments on commit a9cd31e

Please sign in to comment.