mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-09 23:48:36 +01:00
refactoring
This commit is contained in:
@@ -1,63 +1,68 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { SharedHelper } = require('../shared-helper.js');
|
||||
|
||||
const dashboardPath = path.join(__dirname, '../../dashboard');
|
||||
const sharedPath = path.join(__dirname, '../../shared_global');
|
||||
|
||||
const helper = new SharedHelper(path.join(__dirname, '../../dashboard'))
|
||||
|
||||
helper.clear();
|
||||
|
||||
// TODO: Email service as external repo
|
||||
|
||||
|
||||
|
||||
// ---------------- Services ----------------
|
||||
const dashServicesPath = path.join(dashboardPath, 'shared/services');
|
||||
const sharedServicesPath = path.join(sharedPath, 'services');
|
||||
|
||||
if (fs.existsSync(dashServicesPath)) {
|
||||
fs.rmSync(dashServicesPath, { force: true, recursive: true });
|
||||
fs.mkdirSync(dashServicesPath);
|
||||
}
|
||||
|
||||
// DateService
|
||||
const dashDateServicePath = path.join(dashServicesPath, 'DateService.ts');
|
||||
const sharedDateServicePath = path.join(sharedServicesPath, 'DateService.ts');
|
||||
fs.cpSync(sharedDateServicePath, dashDateServicePath);
|
||||
// helper.create('/shared/services');
|
||||
|
||||
|
||||
// ---------------- Data ----------------
|
||||
// // ---------------- Services ----------------
|
||||
// const dashServicesPath = path.join(dashboardPath, 'shared/services');
|
||||
// const sharedServicesPath = path.join(sharedPath, 'services');
|
||||
|
||||
const dashDataPath = path.join(dashboardPath, 'shared/data');
|
||||
const sharedDataPath = path.join(sharedPath, 'data');
|
||||
// if (fs.existsSync(dashServicesPath)) {
|
||||
// fs.rmSync(dashServicesPath, { force: true, recursive: true });
|
||||
// fs.mkdirSync(dashServicesPath);
|
||||
// }
|
||||
|
||||
if (fs.existsSync(dashDataPath)) {
|
||||
fs.rmSync(dashDataPath, { force: true, recursive: true });
|
||||
fs.mkdirSync(dashDataPath);
|
||||
}
|
||||
// // DateService
|
||||
// const dashDateServicePath = path.join(dashServicesPath, 'DateService.ts');
|
||||
// const sharedDateServicePath = path.join(sharedServicesPath, 'DateService.ts');
|
||||
// fs.cpSync(sharedDateServicePath, dashDateServicePath);
|
||||
|
||||
// Premium
|
||||
const dashPremiumDataPath = path.join(dashDataPath, 'PREMIUM.ts');
|
||||
const sharedPremiumDataPath = path.join(sharedDataPath, 'PREMIUM.ts');
|
||||
fs.cpSync(sharedPremiumDataPath, dashPremiumDataPath);
|
||||
|
||||
// Admins
|
||||
const dashAdminsDataPath = path.join(dashDataPath, 'ADMINS.ts');
|
||||
const sharedAdminsDataPath = path.join(sharedDataPath, 'ADMINS.ts');
|
||||
fs.cpSync(sharedAdminsDataPath, dashAdminsDataPath);
|
||||
// // ---------------- Data ----------------
|
||||
|
||||
// BrokerLimits
|
||||
const dashBrokerLimitsDataPath = path.join(dashDataPath, 'broker/Limits.ts');
|
||||
const sharedBrokerLimitsDataPath = path.join(sharedDataPath, 'broker/Limits.ts');
|
||||
fs.cpSync(sharedBrokerLimitsDataPath, dashBrokerLimitsDataPath);
|
||||
// const dashDataPath = path.join(dashboardPath, 'shared/data');
|
||||
// const sharedDataPath = path.join(sharedPath, 'data');
|
||||
|
||||
// if (fs.existsSync(dashDataPath)) {
|
||||
// fs.rmSync(dashDataPath, { force: true, recursive: true });
|
||||
// fs.mkdirSync(dashDataPath);
|
||||
// }
|
||||
|
||||
// // Premium
|
||||
// const dashPremiumDataPath = path.join(dashDataPath, 'PREMIUM.ts');
|
||||
// const sharedPremiumDataPath = path.join(sharedDataPath, 'PREMIUM.ts');
|
||||
// fs.cpSync(sharedPremiumDataPath, dashPremiumDataPath);
|
||||
|
||||
// // Admins
|
||||
// const dashAdminsDataPath = path.join(dashDataPath, 'ADMINS.ts');
|
||||
// const sharedAdminsDataPath = path.join(sharedDataPath, 'ADMINS.ts');
|
||||
// fs.cpSync(sharedAdminsDataPath, dashAdminsDataPath);
|
||||
|
||||
// // BrokerLimits
|
||||
// const dashBrokerLimitsDataPath = path.join(dashDataPath, 'broker/Limits.ts');
|
||||
// const sharedBrokerLimitsDataPath = path.join(sharedDataPath, 'broker/Limits.ts');
|
||||
// fs.cpSync(sharedBrokerLimitsDataPath, dashBrokerLimitsDataPath);
|
||||
|
||||
|
||||
|
||||
// ---------------- Schema ----------------
|
||||
// // ---------------- Schema ----------------
|
||||
|
||||
const dashSchemaPath = path.join(dashboardPath, 'shared/schema');
|
||||
const sharedSchemaPath = path.join(sharedPath, 'schema');
|
||||
// const dashSchemaPath = path.join(dashboardPath, 'shared/schema');
|
||||
// const sharedSchemaPath = path.join(sharedPath, 'schema');
|
||||
|
||||
if (fs.existsSync(dashSchemaPath)) {
|
||||
fs.rmSync(dashSchemaPath, { force: true, recursive: true });
|
||||
fs.mkdirSync(dashSchemaPath);
|
||||
}
|
||||
// if (fs.existsSync(dashSchemaPath)) {
|
||||
// fs.rmSync(dashSchemaPath, { force: true, recursive: true });
|
||||
// fs.mkdirSync(dashSchemaPath);
|
||||
// }
|
||||
|
||||
fs.cpSync(sharedSchemaPath, dashSchemaPath, { recursive: true });
|
||||
// fs.cpSync(sharedSchemaPath, dashSchemaPath, { recursive: true });
|
||||
6
scripts/producer/shared.js
Normal file
6
scripts/producer/shared.js
Normal file
@@ -0,0 +1,6 @@
|
||||
const { getSharedPath } = require("../shared-helper");
|
||||
|
||||
|
||||
|
||||
console.log('SHAREDPATH')
|
||||
console.log(getSharedPath());
|
||||
40
scripts/shared-helper.js
Normal file
40
scripts/shared-helper.js
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
|
||||
class SharedHelper {
|
||||
|
||||
static getSharedPath() {
|
||||
return path.join(__dirname, '../shared_global');
|
||||
}
|
||||
|
||||
constructor(localSharedPath) {
|
||||
this.localSharedPath = localSharedPath;
|
||||
}
|
||||
|
||||
clear() {
|
||||
if (fs.existsSync(this.localSharedPath)) {
|
||||
fs.rmSync(this.localSharedPath, { force: true, recursive: true });
|
||||
fs.mkdirSync(this.localSharedPath);
|
||||
}
|
||||
}
|
||||
|
||||
create(name) {
|
||||
const localFolder = path.join(this.localSharedPath, name);
|
||||
fs.mkdirSync(localFolder);
|
||||
}
|
||||
|
||||
copy(name) {
|
||||
const localSharedFile = path.join(this.localSharedPath, name);
|
||||
fs.cpSync(SharedHelper.getSharedPath(), localSharedFile);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
module.exports = {
|
||||
SharedHelper
|
||||
}
|
||||
Reference in New Issue
Block a user