-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3381 from ever-co/main
Release
- Loading branch information
Showing
210 changed files
with
10,825 additions
and
6,662 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]" | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.