mirror of
https://github.com/block/goose.git
synced 2026-05-05 23:40:20 +00:00
use app.isPackaged instead of checking for node env development (#5465)
Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
parent
ae7e713d37
commit
ff49fa1617
5 changed files with 6 additions and 66 deletions
|
|
@ -768,7 +768,7 @@ const createTray = () => {
|
|||
// If tray already exists, destroy it first
|
||||
destroyTray();
|
||||
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
const isDev = !app.isPackaged;
|
||||
let iconPath: string;
|
||||
|
||||
if (isDev) {
|
||||
|
|
|
|||
|
|
@ -248,7 +248,6 @@ export function setupAutoUpdater(tray?: Tray) {
|
|||
log.info('Setting up auto-updater...');
|
||||
log.info(`Current app version: ${app.getVersion()}`);
|
||||
log.info(`Platform: ${process.platform}, Arch: ${process.arch}`);
|
||||
log.info(`NODE_ENV: ${process.env.NODE_ENV}`);
|
||||
log.info(`ENABLE_DEV_UPDATES: ${process.env.ENABLE_DEV_UPDATES}`);
|
||||
log.info(`App is packaged: ${app.isPackaged}`);
|
||||
log.info(`App path: ${app.getAppPath()}`);
|
||||
|
|
@ -470,7 +469,7 @@ function sendStatusToWindow(event: string, data?: unknown) {
|
|||
function updateTrayIcon(hasUpdate: boolean) {
|
||||
if (!trayRef) return;
|
||||
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
const isDev = !app.isPackaged;
|
||||
let iconPath: string;
|
||||
|
||||
if (hasUpdate) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
// Import the proper type from ConfigContext
|
||||
import { getApiUrl } from '../config';
|
||||
import { safeJsonParse } from './conversionUtils';
|
||||
|
||||
|
|
@ -206,49 +205,3 @@ export async function fetchAndCachePricing(
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh pricing data from backend
|
||||
*/
|
||||
export async function refreshPricing(): Promise<boolean> {
|
||||
try {
|
||||
// Clear session cache to force re-fetch
|
||||
sessionPricingCache.clear();
|
||||
|
||||
// The actual refresh happens on the backend when we call with configured_only: false
|
||||
const apiUrl = getApiUrl('/config/pricing');
|
||||
const secretKey = await window.electron.getSecretKey();
|
||||
|
||||
const headers: HeadersInit = { 'Content-Type': 'application/json' };
|
||||
if (secretKey) {
|
||||
headers['X-Secret-Key'] = secretKey;
|
||||
}
|
||||
|
||||
const response = await fetch(apiUrl, {
|
||||
method: 'POST',
|
||||
headers,
|
||||
body: JSON.stringify({ configured_only: false }),
|
||||
});
|
||||
|
||||
return response.ok;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Expose functions for testing in development mode
|
||||
declare global {
|
||||
interface Window {
|
||||
getCostForModel?: typeof getCostForModel;
|
||||
fetchAndCachePricing?: typeof fetchAndCachePricing;
|
||||
refreshPricing?: typeof refreshPricing;
|
||||
sessionPricingCache?: typeof sessionPricingCache;
|
||||
}
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV === 'development' || typeof window !== 'undefined') {
|
||||
window.getCostForModel = getCostForModel;
|
||||
window.fetchAndCachePricing = fetchAndCachePricing;
|
||||
window.refreshPricing = refreshPricing;
|
||||
window.sessionPricingCache = sessionPricingCache;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,21 +2,11 @@ import log from 'electron-log';
|
|||
import path from 'node:path';
|
||||
import { app } from 'electron';
|
||||
|
||||
// Configure electron-log
|
||||
// In development: ~/Library/Logs/goose/main.log
|
||||
// In production: ~/Library/Application Support/goose/logs/main.log
|
||||
log.transports.file.resolvePathFn = () => {
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
if (isDev) {
|
||||
return path.join(app.getPath('home'), 'Library/Logs/goose/main.log');
|
||||
}
|
||||
return path.join(app.getPath('userData'), 'logs/main.log');
|
||||
return path.join(app.getPath('userData'), 'logs', 'main.log');
|
||||
};
|
||||
|
||||
// Configure log level based on environment
|
||||
log.transports.file.level = process.env.NODE_ENV === 'development' ? 'debug' : 'info';
|
||||
|
||||
// Also log to console in development
|
||||
log.transports.console.level = process.env.NODE_ENV === 'development' ? 'debug' : false;
|
||||
log.transports.file.level = app.isPackaged ? 'info' : 'debug';
|
||||
log.transports.console.level = app.isPackaged ? false : 'debug';
|
||||
|
||||
export default log;
|
||||
|
|
|
|||
|
|
@ -71,9 +71,7 @@ const addPaths = (
|
|||
executableName: string,
|
||||
app: Electron.App
|
||||
): void => {
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
const isPackaged = app.isPackaged;
|
||||
if (isDev && !isPackaged) {
|
||||
if (!app.isPackaged) {
|
||||
possiblePaths.push(
|
||||
path.join(process.cwd(), 'src', 'bin', executableName),
|
||||
path.join(process.cwd(), 'bin', executableName),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue