Skip to content

Commit

Permalink
fix: env issue in prod
Browse files Browse the repository at this point in the history
  • Loading branch information
timeowilliams committed Jul 9, 2024
1 parent f9828d8 commit 1ae9d1d
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 38 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# deepwork

###

![DeepWork](resources/gaudmire-ig.png)
![DeepFocus](resources/gaudmire-ig.png)

// TODO: VS Code extension to preview Markdown

Expand Down Expand Up @@ -35,7 +33,7 @@ This product was built primarily for Software Engineers/Product/Designers in min
Also, there's 10,000 hours to become an expert.

Coding is the same thing. We want to face imposter syndrome & create systems > not focusing as much on TC & the end goal, but also reflecting on the journey and remind yourself that you ARE putting the work in. And if you're not,
hopefully deepWork helps get you to do it.
hopefully deepFocus helps get you to do it.

Some ideas:
https://www.electronjs.org/docs/latest/tutorial/progress-bar (Progress Bar showing how much deep work done)
Expand Down
41 changes: 21 additions & 20 deletions electron-builder.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
appId: com.electron.app
productName: deepwork
productName: deepfocus
directories:
output: dist
buildResources: build
files:
- '!**/.vscode/*'
- '!src/*'
- '!electron.vite.config.{js,ts,mjs,cjs}'
- '!{.eslintignore,.eslintrc.cjs,.prettierignore,.prettierrc.yaml,dev-app-update.yml,CHANGELOG.md,README.md}'
- '!{.env,.env.*,.npmrc,pnpm-lock.yaml}'
- '!{tsconfig.json,tsconfig.node.json,tsconfig.web.json}'
- "out/**/*"
- "package.json"
extraResources:
- from: ".env"
to: ".env"
asar: true
asarUnpack:
- resources/**
- "resources/**"
mac:
entitlementsInherit: build/entitlements.mac.plist
extendInfo:
NSCameraUsageDescription: Application requests access to the device's camera.
NSMicrophoneUsageDescription: Application requests access to the device's microphone.
NSDocumentsFolderUsageDescription: Application requests access to the user's Documents folder.
NSDownloadsFolderUsageDescription: Application requests access to the user's Downloads folder.
notarize: true
dmg:
artifactName: ${name}-${version}.${ext}
win:
executableName: deepwork
executableName: deepfocus
nsis:
artifactName: ${name}-${version}-setup.${ext}
shortcutName: ${productName}
uninstallDisplayName: ${productName}
createDesktopShortcut: always
mac:
entitlementsInherit: build/entitlements.mac.plist
extendInfo:
- NSCameraUsageDescription: Application requests access to the device's camera.
- NSMicrophoneUsageDescription: Application requests access to the device's microphone.
- NSDocumentsFolderUsageDescription: Application requests access to the user's Documents folder.
- NSDownloadsFolderUsageDescription: Application requests access to the user's Downloads folder.
notarize: false
dmg:
artifactName: ${name}-${version}.${ext}
linux:
target:
- AppImage
Expand All @@ -40,4 +41,4 @@ appImage:
npmRebuild: false
publish:
provider: generic
url: https://example.com/auto-updates
url: https://example.com/auto-updates
28 changes: 21 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "deepwork",
"name": "deepfocus",
"version": "1.0.0",
"description": "An Electron application with Solid and TypeScript",
"main": "./out/main/index.js",
Expand All @@ -14,17 +14,18 @@
"typecheck": "npm run typecheck:node && npm run typecheck:web",
"start": "electron-vite preview",
"dev": "electron-vite dev",
"build": "npm run typecheck && electron-vite build",
"build": "NODE_ENV=production npm run typecheck && electron-vite build",
"postinstall": "electron-builder install-app-deps",
"build:unpack": "npm run build && electron-builder --dir",
"build:win": "npm run build && electron-builder --win",
"build:mac": "electron-vite build && electron-builder --mac",
"build:mac": "NODE_ENV=production electron-vite build && electron-builder --mac",
"build:linux": "electron-vite build && electron-builder --linux"
},
"dependencies": {
"@electron-toolkit/preload": "^3.0.1",
"@electron-toolkit/utils": "^3.0.0",
"axios": "^1.7.2",
"dotenv": "^16.4.5",
"electron-store": "^10.0.0",
"electron-updater": "^6.1.7",
"get-windows": "^9.1.1",
Expand Down
29 changes: 27 additions & 2 deletions src/main/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { app, shell, BrowserWindow, ipcMain } from 'electron'
import { join } from 'path'
import path, { join } from 'path'
import fs from 'fs'
import dotenv from 'dotenv'
// import icon from '../../resources/icon.png?asset'
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
const { activeWindow } = await import('get-windows')
Expand All @@ -10,7 +12,30 @@ import { getUrlFromResult, formatTime, updateSiteTimeTracker } from './productiv

const store = new Store<StoreSchema>() as TypedStore

console.log('resend API key', process.env.RESEND_API_KEY)
console.log('Current NODE_ENV:', process.env.NODE_ENV)
console.log('Is Production?', process.env.NODE_ENV === 'production')
console.log('Is Development?', process.env.NODE_ENV === 'development')

console.log('Is app packaged?', app.isPackaged)

if (app.isPackaged) {
// Production logic here
const envPath = path.join(process.resourcesPath, '.env')
console.log('Env file path:', envPath)
console.log('Env file exists:', fs.existsSync(envPath))
if (fs.existsSync(envPath)) {
console.log('Env file contents:', fs.readFileSync(envPath, 'utf8'))
dotenv.config({ path: envPath })
} else {
console.error('Env file not found in production build')
}
} else {
// Development logic here
dotenv.config()
}

console.log('RESEND_API_KEY after loading:', process.env.RESEND_API_KEY)

const emailService = new EmailService(process.env.EMAIL || '', store)

export let currentSiteTimeTrackers: SiteTimeTracker[] = []
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const App: Component = () => {
</div>
<div class="action">
<a
href="https://github.com/timeowilliams/deepWork/releases/download/v1.0.0/deepwork-1.0.0.dmg"
download="deepwork-1.0.0.dmg"
href="https://github.com/timeowilliams/deepWork/releases/download/v1.1.0/deepwork-1.1.0.dmg"
download="deepwork-1.1.0.dmg"
>
Download deepFocus (MacOS only)
</a>
Expand Down

0 comments on commit 1ae9d1d

Please sign in to comment.