mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-09 23:48:36 +01:00
new selfhosted version
This commit is contained in:
4
scripts/.gitignore
vendored
4
scripts/.gitignore
vendored
@@ -1,2 +1,4 @@
|
||||
node_modules
|
||||
.config.ts
|
||||
.config.ts
|
||||
|
||||
aggregation
|
||||
@@ -4,7 +4,8 @@ import path from 'path';
|
||||
import child from 'child_process';
|
||||
import { createZip } from '../helpers/zip-helper';
|
||||
import { DeployHelper } from '../helpers/deploy-helper';
|
||||
import { DATABASE_CONNECTION_STRING_PRODUCTION, DATABASE_CONNECTION_STRING_TESTMODE, REMOTE_HOST_TESTMODE } from '../.config';
|
||||
import { CONSUMER, getEcosystemContent } from '../.config';
|
||||
import prettier from 'prettier';
|
||||
|
||||
const TMP_PATH = path.join(__dirname, '../../tmp');
|
||||
const LOCAL_PATH = path.join(__dirname, '../../consumer');
|
||||
@@ -26,25 +27,27 @@ async function main() {
|
||||
|
||||
if (!SKIP_BUILD) {
|
||||
console.log('Building');
|
||||
child.execSync(`cd ${LOCAL_PATH} && pnpm run build`);
|
||||
try {
|
||||
child.execSync(`cd ${LOCAL_PATH} && pnpm run build`);
|
||||
} catch (ex) {
|
||||
console.error(ex.stdout.toString());
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
console.log('Creting zip file');
|
||||
console.log('Creating zip file');
|
||||
const archive = createZip(TMP_PATH + '/' + ZIP_NAME);
|
||||
archive.directory(LOCAL_PATH + '/dist', '/dist');
|
||||
|
||||
if (MODE === 'testmode') {
|
||||
const ecosystemContent = fs.readFileSync(LOCAL_PATH + '/ecosystem.config.js', 'utf8');
|
||||
const REDIS_URL = ecosystemContent.match(/REDIS_URL: ["'](.*?)["']/)[1];
|
||||
const devContent = ecosystemContent
|
||||
.replace(REDIS_URL, `redis://${REMOTE_HOST_TESTMODE}`)
|
||||
.replace(DATABASE_CONNECTION_STRING_PRODUCTION, `redis://${DATABASE_CONNECTION_STRING_TESTMODE}`);
|
||||
archive.append(Buffer.from(devContent), { name: '/ecosystem.config.js' });
|
||||
} else {
|
||||
archive.file(LOCAL_PATH + '/ecosystem.config.js', { name: '/ecosystem.config.js' })
|
||||
}
|
||||
const envObject =
|
||||
MODE === 'testmode' ? CONSUMER.getEnv_TESTMODE() :
|
||||
MODE === 'testlive' ? CONSUMER.getEnv_TESTLIVE() :
|
||||
CONSUMER.getEnv_PRODUCTION();
|
||||
|
||||
const ecosystemContentRaw = getEcosystemContent('consumer', 3031, 'cluster', 2, './dist/consumer/src/index.js', envObject);
|
||||
const ecosystemContent = await prettier.format(ecosystemContentRaw, { parser: 'babel' });
|
||||
archive.append(Buffer.from(ecosystemContent), { name: '/ecosystem.config.js' });
|
||||
|
||||
archive.file(LOCAL_PATH + '/package.json', { name: '/package.json' });
|
||||
archive.file(LOCAL_PATH + '/pnpm-lock.yaml', { name: '/pnpm-lock.yaml' });
|
||||
|
||||
30
scripts/consumer/run_local.ts
Normal file
30
scripts/consumer/run_local.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import child from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
import { CONSUMER } from '../.config';
|
||||
|
||||
export function main() {
|
||||
|
||||
const mode = process.argv[2];
|
||||
|
||||
const consumerFolder = path.join(__dirname, '../../consumer');
|
||||
|
||||
const getEnv = {
|
||||
'--production': CONSUMER.getEnv_PRODUCTION(),
|
||||
'--testmode': CONSUMER.getEnv_TESTMODE()
|
||||
}
|
||||
|
||||
const env = getEnv[mode];
|
||||
|
||||
if (!env) {
|
||||
console.error('use --production or --testmode')
|
||||
return;
|
||||
}
|
||||
|
||||
const p = child.exec(`ts-node ${consumerFolder}/src/index.ts`, { env });
|
||||
|
||||
p.stdout.on('data', (e) => { console.log(e.toString()); });
|
||||
p.stderr.on('data', (e) => { console.log(e.toString()); })
|
||||
|
||||
}
|
||||
|
||||
main();
|
||||
@@ -12,17 +12,17 @@ helper.copy('utils/requireEnv.ts');
|
||||
helper.create('services');
|
||||
helper.copy('services/RedisStreamService.ts');
|
||||
helper.copy('services/DatabaseService.ts');
|
||||
helper.copy('services/EmailService.ts');
|
||||
|
||||
helper.create('schema');
|
||||
helper.copy('schema/UserSchema.ts');
|
||||
helper.copy('schema/UserLimitSchema.ts');
|
||||
helper.copy('schema/PremiumSchema.ts');
|
||||
|
||||
helper.create('schema/broker');
|
||||
helper.copy('schema/broker/LimitNotifySchema.ts');
|
||||
|
||||
helper.create('schema/project');
|
||||
helper.copy('schema/project/ProjectSchema.ts');
|
||||
helper.copy('schema/project/ProjectsLimits.ts');
|
||||
helper.copy('schema/project/ProjectsCounts.ts');
|
||||
|
||||
helper.create('schema/metrics');
|
||||
|
||||
@@ -4,6 +4,8 @@ import path from 'path';
|
||||
import child from 'child_process';
|
||||
import { createZip } from '../helpers/zip-helper';
|
||||
import { DeployHelper } from '../helpers/deploy-helper';
|
||||
import { getEcosystemContent } from '../.config';
|
||||
import prettier from 'prettier';
|
||||
|
||||
const TMP_PATH = path.join(__dirname, '../../tmp');
|
||||
const LOCAL_PATH = path.join(__dirname, '../../dashboard');
|
||||
@@ -25,13 +27,17 @@ async function main() {
|
||||
|
||||
|
||||
if (!SKIP_BUILD) {
|
||||
console.log('Building');
|
||||
console.log(`[${new Date().toLocaleTimeString('it-IT')}] Building`);
|
||||
child.execSync(`cd ${LOCAL_PATH} && pnpm run build`);
|
||||
|
||||
if (MODE === 'testmode') {
|
||||
child.execSync(`cd ${LOCAL_PATH} && pnpm run build`);
|
||||
child.execSync(`cd ${LOCAL_PATH} && pnpm run build:test`);
|
||||
} else if (MODE === 'testlive') {
|
||||
child.execSync(`cd ${LOCAL_PATH} && pnpm run build:testlive`);
|
||||
} else if (MODE === 'production') {
|
||||
child.execSync(`cd ${LOCAL_PATH} && pnpm run build:prod`);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fs.rmSync(path.join(LOCAL_PATH, '.env'), { force: true });
|
||||
@@ -40,7 +46,9 @@ async function main() {
|
||||
const archive = createZip(TMP_PATH + '/' + ZIP_NAME);
|
||||
archive.directory(LOCAL_PATH + '/.output', '/.output');
|
||||
|
||||
archive.file(LOCAL_PATH + '/ecosystem.config.js', { name: '/ecosystem.config.js' })
|
||||
const ecosystemContentRaw = getEcosystemContent('dashboard', 3010, 'cluster', 1, './.output/server/index.mjs', {});
|
||||
const ecosystemContent = await prettier.format(ecosystemContentRaw, { parser: 'babel' });
|
||||
archive.append(Buffer.from(ecosystemContent), { name: '/ecosystem.config.js' });
|
||||
|
||||
await archive.finalize();
|
||||
|
||||
|
||||
@@ -7,11 +7,9 @@ helper.clear();
|
||||
|
||||
helper.create('services');
|
||||
helper.copy('services/DateService.ts');
|
||||
helper.copy('services/EmailService.ts');
|
||||
|
||||
|
||||
helper.create('data');
|
||||
helper.copy('data/PREMIUM.ts');
|
||||
helper.copy('data/PLANS.ts');
|
||||
helper.copy('data/ADMINS.ts');
|
||||
|
||||
helper.create('data/broker');
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
import child from 'child_process';
|
||||
import prettier from 'prettier';
|
||||
import { createZip } from '../helpers/zip-helper';
|
||||
import { DeployHelper } from '../helpers/deploy-helper';
|
||||
import { EMAILS_SERVICE, getEcosystemContent } from '../.config';
|
||||
|
||||
const TMP_PATH = path.join(__dirname, '../../tmp');
|
||||
const LOCAL_PATH = path.join(__dirname, '../../email');
|
||||
const REMOTE_PATH = '/home/litlyx/email';
|
||||
const ZIP_NAME = 'email.zip';
|
||||
const LOCAL_PATH = path.join(__dirname, '../../emails');
|
||||
const REMOTE_PATH = '/home/litlyx/emails';
|
||||
const ZIP_NAME = 'emails.zip';
|
||||
|
||||
const MODE = DeployHelper.getMode();
|
||||
const SKIP_BUILD = DeployHelper.getArgAt(0) == '--no-build';
|
||||
|
||||
console.log('Deploying mail-service in mode:', MODE);
|
||||
|
||||
setTimeout(() => { main(); }, 3000);
|
||||
@@ -19,10 +24,32 @@ async function main() {
|
||||
if (fs.existsSync(TMP_PATH)) fs.rmSync(TMP_PATH, { force: true, recursive: true });
|
||||
fs.ensureDirSync(TMP_PATH);
|
||||
|
||||
if (!SKIP_BUILD) {
|
||||
console.log('Building');
|
||||
try {
|
||||
child.execSync(`cd ${LOCAL_PATH} && pnpm run build`);
|
||||
} catch (ex) {
|
||||
console.log(ex.output.map(e => {
|
||||
return e?.toString();
|
||||
}))
|
||||
console.error('Error during build process');
|
||||
process.exit();
|
||||
}
|
||||
}
|
||||
|
||||
console.log('Creating zip file');
|
||||
const archive = createZip(TMP_PATH + '/' + ZIP_NAME);
|
||||
archive.directory(LOCAL_PATH + '/dist', '/dist');
|
||||
archive.file(LOCAL_PATH + '/ecosystem.config.js', { name: '/ecosystem.config.js' })
|
||||
|
||||
const envObject =
|
||||
MODE === 'testmode' ? EMAILS_SERVICE.getEnv_TESTMODE() :
|
||||
MODE === 'testlive' ? EMAILS_SERVICE.getEnv_TESTLIVE() :
|
||||
EMAILS_SERVICE.getEnv_PRODUCTION();
|
||||
|
||||
const ecosystemContentRaw = getEcosystemContent('email-service', 3020, 'cluster', 1, './dist/src/index.js', envObject);
|
||||
const ecosystemContent = await prettier.format(ecosystemContentRaw, { parser: 'babel' });
|
||||
archive.append(Buffer.from(ecosystemContent), { name: '/ecosystem.config.js' });
|
||||
|
||||
archive.file(LOCAL_PATH + '/package.json', { name: '/package.json' });
|
||||
archive.file(LOCAL_PATH + '/pnpm-lock.yaml', { name: '/pnpm-lock.yaml' });
|
||||
await archive.finalize();
|
||||
30
scripts/emails/run_local.ts
Normal file
30
scripts/emails/run_local.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import child from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
import { EMAILS_SERVICE } from '../.config';
|
||||
|
||||
export function main() {
|
||||
|
||||
const mode = process.argv[2];
|
||||
|
||||
const paymentsFolder = path.join(__dirname, '../../emails');
|
||||
|
||||
const getEnv = {
|
||||
'--production': EMAILS_SERVICE.getEnv_PRODUCTION(),
|
||||
'--testmode': EMAILS_SERVICE.getEnv_TESTMODE()
|
||||
}
|
||||
|
||||
const env = getEnv[mode];
|
||||
|
||||
if (!env) {
|
||||
console.error('use --production or --testmode')
|
||||
return;
|
||||
}
|
||||
|
||||
const p = child.exec(`ts-node ${paymentsFolder}/src/index.ts`, { env });
|
||||
|
||||
p.stdout.on('data', (e) => { console.log(e.toString()); });
|
||||
p.stderr.on('data', (e) => { console.log(e.toString()); })
|
||||
|
||||
}
|
||||
|
||||
main();
|
||||
@@ -4,26 +4,34 @@ import { NodeSSH } from 'node-ssh'
|
||||
import fs from 'fs-extra';
|
||||
import { REMOTE_HOST_PRODUCTION, REMOTE_HOST_TESTMODE, IDENTITY_FILE } from '../.config'
|
||||
|
||||
|
||||
export const MODES_ARRAY = ['production', 'testmode', 'testlive'] as const;
|
||||
|
||||
export type MODE = typeof MODES_ARRAY[number];
|
||||
|
||||
export class DeployHelper {
|
||||
|
||||
private static scpClient: ScpClient;
|
||||
private static sshClient: NodeSSH;
|
||||
|
||||
static getMode() {
|
||||
const argvMode = process.argv[2]
|
||||
if (argvMode != '--production' && argvMode != '--testmode') {
|
||||
console.error('use --production or --testmode');
|
||||
static getMode(): MODE {
|
||||
const argvMode = process.argv[2];
|
||||
if (!argvMode) {
|
||||
console.error('use', MODES_ARRAY.map(e => `--${e}`).join(' or '));
|
||||
process.exit(0);
|
||||
}
|
||||
const MODE = argvMode === '--production' ? 'production' : 'testmode';
|
||||
return MODE;
|
||||
const mode = argvMode.replace('--', '');
|
||||
if (!MODES_ARRAY.includes(mode as any)) {
|
||||
console.error('use', MODES_ARRAY.map(e => `--${e}`).join(' or '));
|
||||
process.exit(0);
|
||||
}
|
||||
return mode as MODE;
|
||||
}
|
||||
|
||||
static getArgAt(index: number) {
|
||||
return process.argv[3 + index];
|
||||
}
|
||||
|
||||
|
||||
static async connect() {
|
||||
this.scpClient = await Client({
|
||||
host: this.getMode() === 'production' ? REMOTE_HOST_PRODUCTION : REMOTE_HOST_TESTMODE,
|
||||
|
||||
@@ -8,5 +8,8 @@
|
||||
"glob": "^11.0.0",
|
||||
"node-scp": "^0.0.23",
|
||||
"node-ssh": "^13.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"prettier": "^3.5.3"
|
||||
}
|
||||
}
|
||||
93
scripts/payments/deploy.ts
Normal file
93
scripts/payments/deploy.ts
Normal file
@@ -0,0 +1,93 @@
|
||||
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
import child from 'child_process';
|
||||
import prettier from 'prettier';
|
||||
import { createZip } from '../helpers/zip-helper';
|
||||
import { DeployHelper } from '../helpers/deploy-helper';
|
||||
import { getEcosystemContent, PAYMENTS_SERVICE } from '../.config';
|
||||
|
||||
const TMP_PATH = path.join(__dirname, '../../tmp');
|
||||
const LOCAL_PATH = path.join(__dirname, '../../payments');
|
||||
const REMOTE_PATH = '/home/litlyx/payments';
|
||||
const ZIP_NAME = 'payments.zip';
|
||||
|
||||
const MODE = DeployHelper.getMode();
|
||||
const SKIP_BUILD = DeployHelper.getArgAt(0) == '--no-build';
|
||||
|
||||
console.log('Deploying payments in mode:', MODE);
|
||||
|
||||
setTimeout(() => { main(); }, 3000);
|
||||
|
||||
async function main() {
|
||||
|
||||
if (fs.existsSync(TMP_PATH)) fs.rmSync(TMP_PATH, { force: true, recursive: true });
|
||||
fs.ensureDirSync(TMP_PATH);
|
||||
|
||||
|
||||
if (!SKIP_BUILD) {
|
||||
console.log('Building');
|
||||
try {
|
||||
child.execSync(`cd ${LOCAL_PATH} && pnpm run build`);
|
||||
} catch (ex) {
|
||||
console.log(ex.output.map(e => {
|
||||
return e?.toString();
|
||||
}))
|
||||
console.error('Error during build process');
|
||||
process.exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
console.log('Creating zip file');
|
||||
const archive = createZip(TMP_PATH + '/' + ZIP_NAME);
|
||||
archive.directory(LOCAL_PATH + '/dist', '/dist');
|
||||
|
||||
const envObject =
|
||||
MODE === 'testmode' ? PAYMENTS_SERVICE.getEnv_TESTMODE() :
|
||||
MODE === 'testlive' ? PAYMENTS_SERVICE.getEnv_TESTLIVE() :
|
||||
PAYMENTS_SERVICE.getEnv_PRODUCTION();
|
||||
|
||||
const ecosystemContentRaw = getEcosystemContent('payments', 3060, 'cluster', 1, './dist/payments/src/index.js', envObject);
|
||||
const ecosystemContent = await prettier.format(ecosystemContentRaw, { parser: 'babel' });
|
||||
archive.append(Buffer.from(ecosystemContent), { name: '/ecosystem.config.js' });
|
||||
|
||||
archive.file(LOCAL_PATH + '/package.json', { name: '/package.json' });
|
||||
archive.file(LOCAL_PATH + '/pnpm-lock.yaml', { name: '/pnpm-lock.yaml' });
|
||||
await archive.finalize();
|
||||
|
||||
await DeployHelper.connect();
|
||||
|
||||
const { scp, ssh } = DeployHelper.instances();
|
||||
|
||||
console.log('Creating remote structure');
|
||||
console.log('Check existing');
|
||||
const remoteExist = await scp.exists(REMOTE_PATH);
|
||||
console.log('Exist', remoteExist);
|
||||
if (remoteExist) {
|
||||
console.log('Deleting');
|
||||
await DeployHelper.execute(`rm -r ${REMOTE_PATH}`);
|
||||
}
|
||||
|
||||
console.log('Creating folder');
|
||||
await scp.mkdir(REMOTE_PATH);
|
||||
|
||||
console.log('Uploading zip file');
|
||||
await scp.uploadFile(TMP_PATH + '/' + ZIP_NAME, REMOTE_PATH + '/' + ZIP_NAME);
|
||||
scp.close();
|
||||
|
||||
console.log('Cleaning local');
|
||||
fs.rmSync(TMP_PATH + '/' + ZIP_NAME, { force: true, recursive: true });
|
||||
|
||||
console.log('Extracting remote');
|
||||
await DeployHelper.execute(`cd ${REMOTE_PATH} && unzip ${ZIP_NAME} && rm -r ${ZIP_NAME}`);
|
||||
|
||||
console.log('Installing remote');
|
||||
await DeployHelper.execute(`cd ${REMOTE_PATH} && /root/.nvm/versions/node/v21.2.0/bin/pnpm i`);
|
||||
|
||||
console.log('Executing remote');
|
||||
await DeployHelper.execute(`cd ${REMOTE_PATH} && /root/.nvm/versions/node/v21.2.0/bin/pm2 start ecosystem.config.js`);
|
||||
|
||||
ssh.dispose();
|
||||
|
||||
}
|
||||
30
scripts/payments/run_local.ts
Normal file
30
scripts/payments/run_local.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import child from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
import { PAYMENTS_SERVICE } from '../.config';
|
||||
|
||||
export function main() {
|
||||
|
||||
const mode = process.argv[2];
|
||||
|
||||
const paymentsFolder = path.join(__dirname, '../../payments');
|
||||
|
||||
const getEnv = {
|
||||
'--production': PAYMENTS_SERVICE.getEnv_PRODUCTION(),
|
||||
'--testmode': PAYMENTS_SERVICE.getEnv_TESTMODE()
|
||||
}
|
||||
|
||||
const env = getEnv[mode];
|
||||
|
||||
if (!env) {
|
||||
console.error('use --production or --testmode')
|
||||
return;
|
||||
}
|
||||
|
||||
const p = child.exec(`ts-node ${paymentsFolder}/src/index.ts`, { env });
|
||||
|
||||
p.stdout.on('data', (e) => { console.log(e.toString()); });
|
||||
p.stderr.on('data', (e) => { console.log(e.toString()); })
|
||||
|
||||
}
|
||||
|
||||
main();
|
||||
23
scripts/payments/shared.ts
Normal file
23
scripts/payments/shared.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
import { SharedHelper } from "../helpers/shared-helper";
|
||||
import path from "node:path";
|
||||
|
||||
const helper = new SharedHelper(path.join(__dirname, '../../payments/src/shared'))
|
||||
|
||||
helper.clear();
|
||||
|
||||
helper.create('utils');
|
||||
helper.copy('utils/requireEnv.ts');
|
||||
|
||||
helper.create('services');
|
||||
helper.copy('services/DatabaseService.ts');
|
||||
|
||||
helper.create('schema');
|
||||
helper.copy('schema/UserSchema.ts');
|
||||
helper.copy('schema/PremiumSchema.ts');
|
||||
helper.copy('schema/UserLimitSchema.ts');
|
||||
helper.create('schema/emails');
|
||||
helper.copy('schema/emails/EmailNotifySchema.ts');
|
||||
|
||||
helper.create('data');
|
||||
helper.copy('data/PLANS.ts');
|
||||
11
scripts/pnpm-lock.yaml
generated
11
scripts/pnpm-lock.yaml
generated
@@ -7,6 +7,10 @@ settings:
|
||||
importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
prettier:
|
||||
specifier: ^3.5.3
|
||||
version: 3.5.3
|
||||
devDependencies:
|
||||
'@types/archiver':
|
||||
specifier: ^6.0.3
|
||||
@@ -285,6 +289,11 @@ packages:
|
||||
resolution: {integrity: sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==}
|
||||
engines: {node: 20 || >=22}
|
||||
|
||||
prettier@3.5.3:
|
||||
resolution: {integrity: sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==}
|
||||
engines: {node: '>=14'}
|
||||
hasBin: true
|
||||
|
||||
process-nextick-args@2.0.1:
|
||||
resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==}
|
||||
|
||||
@@ -676,6 +685,8 @@ snapshots:
|
||||
lru-cache: 11.0.1
|
||||
minipass: 7.1.2
|
||||
|
||||
prettier@3.5.3: {}
|
||||
|
||||
process-nextick-args@2.0.1: {}
|
||||
|
||||
process@0.11.10: {}
|
||||
|
||||
@@ -4,7 +4,8 @@ import path from 'path';
|
||||
import child from 'child_process';
|
||||
import { createZip } from '../helpers/zip-helper';
|
||||
import { DeployHelper } from '../helpers/deploy-helper';
|
||||
import { REMOTE_HOST_TESTMODE } from '../.config';
|
||||
import prettier from 'prettier';
|
||||
import { getEcosystemContent, PRODUCER } from '../.config';
|
||||
|
||||
const TMP_PATH = path.join(__dirname, '../../tmp');
|
||||
const LOCAL_PATH = path.join(__dirname, '../../producer');
|
||||
@@ -30,18 +31,19 @@ async function main() {
|
||||
}
|
||||
|
||||
|
||||
console.log('Creting zip file');
|
||||
console.log('Creating zip file');
|
||||
const archive = createZip(TMP_PATH + '/' + ZIP_NAME);
|
||||
archive.directory(LOCAL_PATH + '/dist', '/dist');
|
||||
|
||||
if (MODE === 'testmode') {
|
||||
const ecosystemContent = fs.readFileSync(LOCAL_PATH + '/ecosystem.config.js', 'utf8');
|
||||
const REDIS_URL = ecosystemContent.match(/REDIS_URL: ["'](.*?)["']/)[1];
|
||||
const devContent = ecosystemContent.replace(REDIS_URL, `redis://${REMOTE_HOST_TESTMODE}`);
|
||||
archive.append(Buffer.from(devContent), { name: '/ecosystem.config.js' });
|
||||
} else {
|
||||
archive.file(LOCAL_PATH + '/ecosystem.config.js', { name: '/ecosystem.config.js' })
|
||||
}
|
||||
|
||||
const envObject =
|
||||
MODE === 'testmode' ? PRODUCER.getEnv_TESTMODE() :
|
||||
MODE === 'testlive' ? PRODUCER.getEnv_TESTLIVE() :
|
||||
PRODUCER.getEnv_PRODUCTION();
|
||||
|
||||
const ecosystemContentRaw = getEcosystemContent('producer', 3000, 'cluster', 1, './dist/index.js', envObject);
|
||||
const ecosystemContent = await prettier.format(ecosystemContentRaw, { parser: 'babel' });
|
||||
archive.append(Buffer.from(ecosystemContent), { name: '/ecosystem.config.js' });
|
||||
|
||||
|
||||
archive.file(LOCAL_PATH + '/package.json', { name: '/package.json' });
|
||||
|
||||
@@ -11,3 +11,11 @@ helper.copy('utils/requireEnv.ts');
|
||||
|
||||
helper.create('services');
|
||||
helper.copy('services/RedisStreamService.ts');
|
||||
helper.copy('services/DatabaseService.ts');
|
||||
|
||||
helper.create('schema');
|
||||
helper.create('schema/shields');
|
||||
helper.copy('schema/shields/AddressBlacklistSchema.ts');
|
||||
helper.copy('schema/shields/BotTrafficOptionSchema.ts');
|
||||
helper.copy('schema/shields/CountryBlacklistSchema.ts');
|
||||
helper.copy('schema/shields/DomainWhitelistSchema.ts');
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "NodeNext",
|
||||
"target": "ESNext"
|
||||
"target": "ESNext",
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": [
|
||||
"./**/*.ts"
|
||||
|
||||
Reference in New Issue
Block a user