-
Notifications
You must be signed in to change notification settings - Fork 47
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 #3026 from ever-co/develop
Stage
- Loading branch information
Showing
160 changed files
with
2,696 additions
and
997 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
13 changes: 13 additions & 0 deletions
13
...s/electron-desktop-environment/concrete-environment-content/common-environment-content.ts
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,13 @@ | ||
import { IContentGenerator } from '../intefaces/i-content-generator'; | ||
import { Env } from '../../env'; | ||
|
||
|
||
export class CommonEnvironmentContent implements IContentGenerator { | ||
public generate(variable: Partial<Env>): string { | ||
return ` | ||
I18N_FILES_URL: '${variable.I18N_FILES_URL}', | ||
COMPANY_SITE_LINK: '${variable.COMPANY_SITE_LINK}', | ||
COMPANY_GITHUB_LINK: '${variable.COMPANY_GITHUB_LINK}', | ||
` | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...esktop-environment/concrete-environment-content/desktop-server-web-environment-content.ts
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,18 @@ | ||
import { IContentGenerator } from '../intefaces/i-content-generator'; | ||
import { IDesktopEnvironment } from '../intefaces/i-desktop-environment'; | ||
|
||
export class DesktopServerWebEnvironmentContent implements IContentGenerator { | ||
public generate(variable: Partial<IDesktopEnvironment>): string { | ||
return ` | ||
NAME: '${variable.DESKTOP_SERVER_WEB_APP_NAME || variable.NAME}', | ||
DESCRIPTION: '${variable.DESKTOP_SERVER_WEB_APP_DESCRIPTION || variable.DESCRIPTION}', | ||
APP_ID: '${variable.DESKTOP_SERVER_WEB_APP_ID || variable.APP_ID}', | ||
REPO_NAME: '${variable.DESKTOP_SERVER_WEB_APP_REPO_NAME || variable.REPO_NAME}', | ||
REPO_OWNER: '${variable.DESKTOP_SERVER_WEB_APP_REPO_OWNER || variable.REPO_OWNER}', | ||
WELCOME_TITLE: '${variable.DESKTOP_SERVER_WEB_APP_WELCOME_TITLE || variable.WELCOME_TITLE}', | ||
WELCOME_CONTENT: '${variable.DESKTOP_SERVER_WEB_APP_WELCOME_CONTENT || variable.WELCOME_CONTENT}', | ||
PLATFORM_LOGO: '${variable.PLATFORM_LOGO}', | ||
DESKTOP_SERVER_WEB_APP_DESKTOP_APP_LOGO_512X512: '${variable.DESKTOP_SERVER_WEB_APP_DESKTOP_APP_LOGO_512X512}', | ||
`; | ||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
.scripts/electron-desktop-environment/desktop-environment-manager.ts
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,108 @@ | ||
import { DesktopEnvirontmentContentFactory } from './desktop-environtment-content-factory'; | ||
import yargs from 'yargs'; | ||
import { hideBin } from 'yargs/helpers'; | ||
import * as path from 'path'; | ||
import * as fs from 'fs'; | ||
import { env } from '../env'; | ||
import { IDesktopEnvironment } from './intefaces/i-desktop-environment'; | ||
|
||
const argv: any = yargs(hideBin(process.argv)).argv; | ||
|
||
|
||
export class DesktopEnvironmentManager { | ||
private static _instance: DesktopEnvironmentManager; | ||
private readonly desktop: string; | ||
private readonly fileDir: string; | ||
private readonly fileName: string; | ||
private readonly isProd: boolean; | ||
|
||
private constructor() { | ||
console.log(argv); | ||
this.desktop = String(argv.desktop); | ||
this.isProd = argv.environment === 'prod'; | ||
this.fileName = 'config'; | ||
this.fileDir = path.join('apps', this.desktop, 'src', 'configs'); | ||
} | ||
|
||
|
||
private static get instance(): DesktopEnvironmentManager { | ||
if (!this._instance) { | ||
this._instance = new DesktopEnvironmentManager(); | ||
} | ||
return this._instance; | ||
} | ||
|
||
public static get environment(): any { | ||
if ( | ||
fs.existsSync( | ||
path.join( | ||
this.instance.fileDir, | ||
this.instance.fileName.concat(`.ts`) | ||
) | ||
) | ||
) { | ||
return require(path.join( | ||
'..', | ||
'..', | ||
this.instance.fileDir, | ||
this.instance.fileName | ||
)).config; | ||
} | ||
return null; | ||
} | ||
|
||
public static update(): void { | ||
const environment: IDesktopEnvironment = Object.assign( | ||
{}, | ||
this.environment | ||
); | ||
const filePath = path.join( | ||
this.instance.fileDir, | ||
this.instance.fileName.concat('.ts') | ||
); | ||
|
||
if (fs.existsSync(filePath)) { | ||
fs.unlinkSync(filePath); | ||
fs.writeFileSync( | ||
filePath, | ||
this.instance.content(environment, this.instance.isProd) | ||
); | ||
return; | ||
} | ||
console.log(`WARNING: File ${filePath} does not exist`); | ||
} | ||
|
||
public static generate(): void { | ||
const files = ['config.ts']; | ||
const environment: Partial<IDesktopEnvironment> = Object.assign({}, env); | ||
|
||
for (const file of files) { | ||
const isProd = file === 'config.ts'; | ||
const filePath = path.join(this.instance.fileDir, file); | ||
if (fs.existsSync(filePath)) { | ||
fs.unlinkSync(filePath); | ||
} | ||
fs.writeFileSync( | ||
filePath, | ||
this.instance.content(environment, isProd) | ||
); | ||
|
||
console.log(`✔ Generated desktop ${isProd} environment file: ${filePath}`) | ||
} | ||
} | ||
|
||
|
||
private content(variable: Partial<IDesktopEnvironment>, isProd: boolean): string { | ||
return ` | ||
export const config = { | ||
production: ${isProd}, | ||
${DesktopEnvirontmentContentFactory.generate( | ||
this.desktop, | ||
variable | ||
)} | ||
}; | ||
`; | ||
} | ||
} | ||
|
||
DesktopEnvironmentManager.update(); |
25 changes: 25 additions & 0 deletions
25
.scripts/electron-desktop-environment/desktop-environtment-content-factory.ts
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,25 @@ | ||
|
||
import { IDesktopEnvironment } from './intefaces/i-desktop-environment'; | ||
import { CommonEnvironmentContent } from './concrete-environment-content/common-environment-content'; | ||
import { DesktopServerWebEnvironmentContent } from './concrete-environment-content/desktop-server-web-environment-content'; | ||
|
||
export class DesktopEnvirontmentContentFactory { | ||
public static generate( | ||
desktop: string, | ||
environtment: Partial<IDesktopEnvironment> | ||
) { | ||
const common = new CommonEnvironmentContent(); | ||
switch (desktop) { | ||
case 'server-web': | ||
const desktopServerWeb = new DesktopServerWebEnvironmentContent(); | ||
return ` | ||
${common.generate(environtment)} | ||
${desktopServerWeb.generate(environtment)} | ||
`; | ||
default: | ||
return ` | ||
${common.generate(environtment)} | ||
`; | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
.scripts/electron-desktop-environment/intefaces/i-content-generator.ts
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,5 @@ | ||
import { IDesktopEnvironment } from './i-desktop-environment' | ||
|
||
export interface IContentGenerator { | ||
generate(variable: Partial<IDesktopEnvironment>): string; | ||
} |
13 changes: 13 additions & 0 deletions
13
.scripts/electron-desktop-environment/intefaces/i-desktop-environment.ts
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,13 @@ | ||
import { Env } from '../../env'; | ||
|
||
export interface IDesktopEnvironment extends Env { | ||
NAME: string; | ||
DESCRIPTION: string; | ||
APP_ID: string; | ||
REPO_NAME: string; | ||
REPO_OWNER: string; | ||
WELCOME_TITLE: string; | ||
WELCOME_CONTENT: string; | ||
PLATFORM_LOGO: string; | ||
DESKTOP_SERVER_WEB_APP_DESKTOP_APP_LOGO_512X512: string; | ||
} |
25 changes: 25 additions & 0 deletions
25
.scripts/electron-package-utils/concrete-packager/desktop-packager.ts
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,25 @@ | ||
import { IPackage } from '../interfaces/i-package'; | ||
import { IPackager } from '../interfaces/i-packager'; | ||
import { IPackageBuild } from '../interfaces/i-package-build'; | ||
import { env } from '../../env'; | ||
|
||
export class DesktopPackager implements IPackager { | ||
public prepare(pkg: IPackage): IPackage { | ||
pkg.name = env.DESKTOP_SERVER_WEB_APP_NAME || pkg.name; | ||
pkg.productName = env.DESKTOP_SERVER_WEB_APP_DESCRIPTION || pkg.productName; | ||
pkg.description = env.DESKTOP_SERVER_WEB_APP_DESCRIPTION || pkg.description; | ||
pkg.homepage = env.COMPANY_SITE_LINK || pkg.homepage; | ||
pkg.build.appId = env.DESKTOP_SERVER_WEB_APP_ID || pkg.build.appId; | ||
pkg.build.productName = | ||
env.DESKTOP_SERVER_WEB_APP_DESCRIPTION || pkg.build.productName; | ||
pkg.build.linux.executableName = | ||
env.DESKTOP_SERVER_WEB_APP_NAME || pkg.build.linux.executableName; | ||
return pkg; | ||
} | ||
|
||
public prepareBuild(pkg: IPackageBuild): IPackageBuild { | ||
pkg.description = env.DESKTOP_SERVER_WEB_APP_DESCRIPTION || pkg.description; | ||
pkg.name = env.DESKTOP_SERVER_WEB_APP_NAME || pkg.name; | ||
return pkg; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
.scripts/electron-package-utils/interfaces/i-package-build.ts
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,10 @@ | ||
export interface IPackageBuild { | ||
name: string; | ||
version: string; | ||
description: string; | ||
author: { | ||
name: string; | ||
email: string; | ||
url: string; | ||
} | ||
} |
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,68 @@ | ||
export interface IPackage { | ||
name: string; | ||
productName: string; | ||
version: string; | ||
description: string; | ||
license: string; | ||
homepage: string; | ||
repository: { type: string; url: string }; | ||
bugs: { url: string }; | ||
private: boolean; | ||
author: { name: string; email: string; url: string }; | ||
main: string; | ||
workspaces: { packages: string[] }; | ||
build: { | ||
appId: string; | ||
artifactName: string; | ||
productName: string; | ||
copyright: string; | ||
afterSign: string; | ||
dmg: { sign: boolean }; | ||
asar: boolean; | ||
npmRebuild: boolean; | ||
asarUnpack: string[]; | ||
directories: { buildResources: string; output: string }; | ||
publish: {}[]; | ||
mac: { | ||
category: string; | ||
icon: string; | ||
target: any[]; | ||
asarUnpack: string; | ||
artifactName: string; | ||
hardenedRuntime: boolean; | ||
gatekeeperAssess: boolean; | ||
entitlements: string; | ||
entitlementsInherit: string; | ||
extendInfo: {}; | ||
}; | ||
win: { | ||
publisherName: string; | ||
target: any[]; | ||
icon: string; | ||
verifyUpdateCodeSignature: boolean; | ||
}; | ||
linux: { | ||
icon: string; | ||
target: any[]; | ||
executableName: string; | ||
artifactName: string; | ||
synopsis: string; | ||
category: string; | ||
}; | ||
nsis: { | ||
oneClick: boolean; | ||
perMachine: boolean; | ||
createDesktopShortcut: boolean; | ||
createStartMenuShortcut: boolean; | ||
allowToChangeInstallationDirectory: boolean; | ||
allowElevation: boolean; | ||
installerIcon: string; | ||
artifactName: string; | ||
deleteAppDataOnUninstall: boolean; | ||
menuCategory: boolean; | ||
}; | ||
extraResources: (string | object[])[]; | ||
extraFiles: string[]; | ||
}; | ||
dependencies: { [key: string]: string }; | ||
} |
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,6 @@ | ||
import { IPackage } from './i-package'; | ||
import { IPackageBuild } from './i-package-build'; | ||
export interface IPackager { | ||
prepare(pkg: IPackage): IPackage; | ||
prepareBuild(pkg: IPackageBuild): IPackageBuild; | ||
} |
Oops, something went wrong.