Skip to content

Commit

Permalink
avoid using process.env
Browse files Browse the repository at this point in the history
  • Loading branch information
baruchiro committed Sep 2, 2024
1 parent da7ebe5 commit 4b2fed1
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 34 deletions.
11 changes: 0 additions & 11 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
const globals = require('./globals.cjs');
const readonlyGlobals = Object.keys(globals).reduce((acc, key) => {
acc[key] = 'readonly';
return acc;
}, {});

const _productionError = process.env.NODE_ENV === 'production' ? 'error' : 'warn';

module.exports = {
root: true,
env: {
Expand All @@ -28,9 +20,6 @@ module.exports = {
},
plugins: ['@typescript-eslint'],
ignorePatterns: ['node_modules/**', '**/dist/**'],
globals: {
...readonlyGlobals,
},
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
Expand Down
9 changes: 0 additions & 9 deletions globals.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "caspion",
"description": "Caspion is a personal finance management application",
"version": "2.0.0-test.1",
"version": "2.0.0-test.2",
"private": true,
"type": "module",
"author": "Jonathan Goldfarb <brafdlog@gmail.com>",
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/app-globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import electron from 'electron';

export const App: Electron.App = electron.app;

if (process.env.NODE_ENV !== 'production') {
if (import.meta.env.MODE !== 'production') {
const localUserData = path.resolve('userData');
mkdirSync(localUserData, { recursive: true });
App.setPath('userData', localUserData);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Auth } from 'googleapis';
import { homepage } from '../../../../../../../package.json';

export const clientId = import.meta.env.GOOGLE_CLIENT_ID;
export const clientSecret = import.meta.env.GOOGLE_CLIENT_SECRET;
export const clientId = import.meta.env.VITE_GOOGLE_CLIENT_ID;
export const clientSecret = import.meta.env.VITE_GOOGLE_CLIENT_SECRET;
export const redirectUri = homepage;
export const scopes = [
'https://www.googleapis.com/auth/drive.file',
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/handlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const functions: Record<string, Listener> = {
getLogsInfo: getLogsInfoHandler,
getAppInfo: async () => {
return {
sourceCommitShort: import.meta.env.SOURCE_COMMIT_SHORT,
sourceCommitShort: import.meta.env.VITE_SOURCE_COMMIT_SHORT,
repository,
discordChanel: discord,
currentVersion: App.getVersion(),
Expand Down
4 changes: 2 additions & 2 deletions packages/main/src/logging/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { machineId } from 'node-machine-id';
import { type BudgetTrackingEventEmitter} from '@/backend/eventEmitters/EventEmitter';
import { EventNames } from '@/backend/eventEmitters/EventEmitter';

const analytics = import.meta.env.SEGMENT_WRITE_KEY ? new Analytics(import.meta.env.SEGMENT_WRITE_KEY) : null;
const analytics = import.meta.env.VITE_SEGMENT_WRITE_KEY ? new Analytics(import.meta.env.VITE_SEGMENT_WRITE_KEY) : null;

type EventProperties = Record<string, string | number | boolean | undefined>;

Expand Down Expand Up @@ -54,7 +54,7 @@ async function buildEvent(properties?: EventProperties) {
return {
anonymousId: id,
properties: {
env: process.env.NODE_ENV,
env: import.meta.env.MODE,
...properties,
},
};
Expand Down
4 changes: 2 additions & 2 deletions packages/main/src/logging/sentry.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { init, captureMessage, type ElectronMainOptions } from '@sentry/electron/main';

const reporterConfiguration = {
dsn: import.meta.env.SENTRY_DSN,
dsn: import.meta.env.VITE_SENTRY_DSN,
defaultIntegrations: false,
environment: process.env.NODE_ENV,
environment: import.meta.env.MODE,
enableJavaScript: true,
enableNative: false,
enableUnresponsive: false,
Expand Down
10 changes: 5 additions & 5 deletions types/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ interface ImportMetaEnv {
readonly VITE_APP_VERSION: string;
readonly VITE_APP_NAME: string;

readonly SENTRY_DSN: string;
readonly VITE_SENTRY_DSN: string;

readonly GOOGLE_CLIENT_ID: string;
readonly GOOGLE_CLIENT_SECRET: string;
readonly VITE_GOOGLE_CLIENT_ID: string;
readonly VITE_GOOGLE_CLIENT_SECRET: string;

readonly SEGMENT_WRITE_KEY: string;
readonly VITE_SEGMENT_WRITE_KEY: string;

readonly SOURCE_COMMIT_SHORT: string;
readonly VITE_SOURCE_COMMIT_SHORT: string;
}

interface ImportMeta {
Expand Down

0 comments on commit 4b2fed1

Please sign in to comment.