Skip to content

Commit

Permalink
Merge pull request #3381 from ever-co/main
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
evereq authored Nov 28, 2024
2 parents b6a1dc4 + 568a795 commit 06bd8e2
Show file tree
Hide file tree
Showing 210 changed files with 10,825 additions and 6,662 deletions.
9 changes: 7 additions & 2 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"words": [
" X",
" X ",
"hookform",
"accepte",
"Accordian",
"adipiscing",
Expand All @@ -24,6 +25,7 @@
"apidemodt",
"apidemodts",
"apidev",
"apikey",
"apisauce",
"apistage",
"apistagecivo",
Expand Down Expand Up @@ -92,6 +94,7 @@
"creatoe",
"dailyplan",
"Darkmode",
"DATACENTER",
"datas",
"dataToDisplay",
"daygrid",
Expand Down Expand Up @@ -240,6 +243,7 @@
"longpress",
"Lorem",
"lucide",
"mailchimp",
"mainconfig",
"mappagination",
"mathieudutour",
Expand Down Expand Up @@ -355,7 +359,6 @@
"tailess",
"Tailess",
"tailwindcss",
"timesheet-viewMode",
"tanstack",
"taskid",
"taskstatus",
Expand All @@ -367,12 +370,13 @@
"testid",
"timegrid",
"Timesheet",
"timesheet-viewMode",
"Timesheets",
"Timeslot",
"tinvitations",
"tnode",
"Togger",
"tomorow",
"tomorrow",
"Tongatapu",
"tota",
"TRANSFERT",
Expand Down Expand Up @@ -400,6 +404,7 @@
"VERSONS",
"vertificalline",
"vhidden",
"Waitlist",
"WARNING️",
"wasabisys",
"webm",
Expand Down
77 changes: 77 additions & 0 deletions .scripts/configure.electron.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import * as fs from 'fs';
import * as path from 'path';
import { hideBin } from 'yargs/helpers';
import yargs from 'yargs';

interface Arguments {
type: 'server' | 'constant'
}
const argv = yargs(hideBin(process.argv))
.options({
type: {
type: 'string',
choices: ['server', 'constant'],
demandOption: true,
description: 'Type of configuration to modify'
}
})
.parseSync() as Arguments;

function modifiedNextServer() {
const filePath = path.resolve(__dirname, '../apps/server-web/release/app/dist/standalone/apps/web/server.js');
try {
let fileContent = fs.readFileSync(filePath, 'utf8');
const searchString = 'process.env.__NEXT_PRIVATE_STANDALONE_CONFIG';
const codeToInsert = `
nextConfig.serverRuntimeConfig = {
"GAUZY_API_SERVER_URL": process.env.GAUZY_API_SERVER_URL,
"NEXT_PUBLIC_GAUZY_API_SERVER_URL": process.env.NEXT_PUBLIC_GAUZY_API_SERVER_URL
}
`;

let lines = fileContent.split('\n');
const index = lines.findIndex((line) => line.includes(searchString));

if (index !== -1) {
lines.splice(index - 1, 0, codeToInsert);

fileContent = lines.join('\n');
fs.writeFileSync(filePath, fileContent, 'utf8');
console.log('Line of code successfully inserted.');
} else {
console.log(`The string "${searchString}" was not found in the file.`);
}
} catch (error) {
console.error('Failed to change static server configuration');
}
}

function updateWebConstant(setDesktopApp) {
const filePath = path.resolve(__dirname, '../apps/web/app/constants.ts');
try {
let fileContent = fs.readFileSync(filePath, 'utf8');
const envCheck = `export const IS_DESKTOP_APP = process.env.IS_DESKTOP_APP === 'true';`;
const hardcoded = `export const IS_DESKTOP_APP = true;`;

const [from, to] = setDesktopApp ? [envCheck, hardcoded] : [hardcoded, envCheck];

if (!fileContent.includes(from)) {
throw new Error(`Expected content not found in ${filePath}`);
}

fileContent = fileContent.replace(from, to);
fs.writeFileSync(filePath, fileContent, 'utf8');
console.log(`Successfully ${setDesktopApp ? 'set' : 'reverted'} IS_DESKTOP_APP`);
} catch (error) {
console.error('Failed to update constants:', error);
process.exit(1);
}
}


if (argv.type === 'server') {
modifiedNextServer();
updateWebConstant(false);
} else if (argv.type === 'constant') {
updateWebConstant(true);
}
34 changes: 34 additions & 0 deletions .scripts/copy-web-build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { copy } from 'fs-extra';
import { join } from 'path';

async function copyWebBuild() {
const webDir = join(process.cwd(), 'apps/web');
const distDir = join(process.cwd(), 'apps/server-web/release/app/dist');

try {
// Copy standalone build
await copy(
join(webDir, '.next/standalone'),
join(distDir, 'standalone')
);

// Copy static files
await copy(
join(webDir, '.next/static'),
join(distDir, 'standalone/apps/web/.next/static')
);

// Copy public files
await copy(
join(webDir, 'public'),
join(distDir, 'standalone/apps/web/public')
);

console.log('Build files copied successfully');
} catch (error) {
console.error('Failed to copy build files:', error);
process.exit(1);
}
}

copyWebBuild();
7 changes: 2 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@
"source.fixAll": "explicit",
"source.organizeImports": "never",
"source.sortMembers": "never",
"organizeImports": "never",
// "source.removeUnusedImports": "always"
"organizeImports": "never"
},
"vsicons.presets.angular": true,
"deepscan.enable": true,
"cSpell.words": [
"Timepicker"
],
"cSpell.words": ["Timepicker"],
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
Expand Down
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ ARG NEXT_PUBLIC_JITSU_BROWSER_URL
ARG NEXT_PUBLIC_JITSU_BROWSER_WRITE_KEY
ARG NEXT_PUBLIC_GITHUB_APP_NAME=ever-github
ARG NEXT_PUBLIC_CHATWOOT_API_KEY
ARG NEXT_IGNORE_ESLINT_ERROR_ON_BUILD=true

FROM node:${NODE_VERSION}-slim as base
FROM node:${NODE_VERSION}-slim AS base

# Output the environment variable value
ARG NEXT_PUBLIC_GAUZY_API_SERVER_URL
RUN echo "NEXT_PUBLIC_GAUZY_API_SERVER_URL=${NEXT_PUBLIC_GAUZY_API_SERVER_URL}"

LABEL maintainer="[email protected]"
Expand All @@ -42,7 +44,7 @@ RUN mkdir /temp && cd /temp && \
RUN npm cache clean --force

# Throw-away build stage to reduce size of final image
FROM base as build
FROM base AS build

# We make env vars passed as build argument to be available in this build stage because we prebuild the NextJs app
ARG NEXT_PUBLIC_GAUZY_API_SERVER_URL
Expand Down Expand Up @@ -80,6 +82,7 @@ RUN cd apps/web && \
COPY . .

ENV NODE_ENV=production
ENV NEXT_IGNORE_ESLINT_ERROR_ON_BUILD=true

RUN echo $NEXT_PUBLIC_GAUZY_API_SERVER_URL

Expand All @@ -96,8 +99,6 @@ RUN yarn cache clean
# Final stage for app image
FROM base

ENV NODE_ENV=production

# Copy built application
COPY --from=build /app/apps/web/.next/standalone ./
COPY --from=build /app/apps/web/.next/static ./apps/web/.next/static
Expand Down
6 changes: 3 additions & 3 deletions apps/extensions/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2684,9 +2684,9 @@ cosmiconfig@^7.0.1:
yaml "^1.10.0"

cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
version "7.0.6"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.6.tgz#8a58fe78f00dcd70c370451759dfbfaf03e8ee9f"
integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==
dependencies:
path-key "^3.1.0"
shebang-command "^2.0.0"
Expand Down
15 changes: 15 additions & 0 deletions apps/server-web/src/locales/i18n/bg/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@
"OPEN_WEB": "Отворете уеб в браузъра",
"SERVER_WINDOW": "Прозорец на сървъра"
},
"MENU_APP": {
"APP_ABOUT": "Относно",
"APP_QUIT": "Изход",
"APP_WINDOW": "Прозорец",
"APP_SUBMENU": {
"APP_SETTING": "Настройки",
"APP_SERVER_WINDOW": "Сървърен прозорец",
"APP_LEARN_MORE": "Научете повече",
"APP_DOC": "Документация",
"APP_SETTING_DEV": "Настройки за разработчици",
"APP_SERVER_DEV": "Сървър за разработчици"
},
"APP_DEV": "Разработчик",
"APP_HELP": "Помощ"
},
"FORM": {
"FIELDS": {
"PORT": "ПРИСТАНИЩЕ",
Expand Down
15 changes: 15 additions & 0 deletions apps/server-web/src/locales/i18n/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@
"OPEN_WEB": "Open Web In Browser",
"SERVER_WINDOW": "Server Window"
},
"MENU_APP": {
"APP_ABOUT": "About",
"APP_QUIT": "Quit",
"APP_WINDOW": "Window",
"APP_SUBMENU": {
"APP_SETTING": "Setting",
"APP_SERVER_WINDOW": "Server Window",
"APP_LEARN_MORE": "Learn More",
"APP_DOC": "Documentation",
"APP_SETTING_DEV": "Setting Dev.",
"APP_SERVER_DEV": "Server Dev."
},
"APP_DEV": "Developer",
"APP_HELP": "Help"
},
"FORM": {
"FIELDS": {
"PORT": "PORT",
Expand Down
4 changes: 3 additions & 1 deletion apps/server-web/src/main/helpers/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export const EventLists = {
SERVER_WINDOW: 'SERVER_WINDOW',
RESTART_SERVER: 'RESTART_SERVER',
CHANGE_THEME: 'CHANGE_THEME',
SETUP_WINDOW: 'SETUP_WINDOW'
SETUP_WINDOW: 'SETUP_WINDOW',
SETTING_WINDOW_DEV: 'SETTING_WINDOW_DEV',
SERVER_WINDOW_DEV: 'SERVER_WINDOW_DEV'
}

export const SettingPageTypeMessage = {
Expand Down
2 changes: 1 addition & 1 deletion apps/server-web/src/main/helpers/interfaces/i-constant.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export type Channels = 'setting-page' | 'ipc-renderer' | 'language-set' | 'updater-page' | 'server-page' | 'theme-change' | 'current-theme';
export type Channels = 'setting-page' | 'ipc-renderer' | 'language-set' | 'updater-page' | 'server-page' | 'theme-change' | 'current-theme' | 'current-language';
15 changes: 15 additions & 0 deletions apps/server-web/src/main/helpers/interfaces/i-menu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { MenuItemConstructorOptions } from 'electron';
export interface AppMenu {
id?: string;
label: string; // Menu label
submenu?: (AppMenu | ElectronMenuItem)[]; // Nested menus or Electron menu items
role?: 'appMenu' | 'fileMenu' | 'editMenu' | 'viewMenu' | 'windowMenu' | 'help'; // Predefined menu roles
type?: 'normal' | 'separator' | 'submenu' | 'checkbox' | 'radio'; // Menu item type
click?: () => void; // Click handler for the menu item
accelerator?: string; // Keyboard shortcut
enabled?: boolean; // Whether the item is enabled
visible?: boolean; // Whether the item is visible
checked?: boolean; // For 'checkbox' or 'radio' type
}

export type ElectronMenuItem = MenuItemConstructorOptions;
6 changes: 3 additions & 3 deletions apps/server-web/src/main/helpers/interfaces/i-server.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
interface GeneralConfig {
export interface GeneralConfig {
lang?: string
autoUpdate?: boolean
updateCheckPeriode?: string
updateCheckPeriod?: string
theme?: string
setup?: boolean
[key: string]: any
}

interface ServerConfig {
export interface ServerConfig {
PORT: number;
NEXT_PUBLIC_GAUZY_API_SERVER_URL: string;
GAUZY_API_SERVER_URL: string;
Expand Down
1 change: 1 addition & 0 deletions apps/server-web/src/main/helpers/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './i-server';
export * from './i-desktop-dialog';
export * from './i-constant';
export * from './i-menu';
24 changes: 24 additions & 0 deletions apps/server-web/src/main/helpers/replace-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,27 @@ export const replaceConfig = async (folderPath: string, envOptions: EnvOptions)
console.log('error on replacing file', error);
}
}

export const clearDesktopConfig = async (folderPath: string): Promise<Boolean> => {
if (!folderPath || typeof folderPath !== 'string') {
throw new Error('Invalid folder path provided');
}
const DESKTOP_CONFIG_FILES = ['desktop-server.body', 'desktop-server.meta'] as const;
try {
// remove cached desktop server config
await Promise.all(
DESKTOP_CONFIG_FILES.map(async (file) => {
const filePath = path.join(folderPath, file);
try {
await fs.promises.unlink(filePath)
} catch (error: any) {
console.log('error unlink static web file', error.message)
}
})
)
return true;
} catch (error) {
console.log('Failed to clear static config');
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export class DesktopServerFactory {
if (!this.apiInstance && !!env) {
this.apiInstance = new WebService(path, env, win, signal, eventEmitter);
}
this.apiInstance.updateEnv(env)
return this.apiInstance;
}
}
Loading

0 comments on commit 06bd8e2

Please sign in to comment.