mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 07:48:37 +01:00
update scripts to typescript
This commit is contained in:
@@ -4,8 +4,8 @@
|
|||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dashboard:clear-logs": "node scripts/dashboard/clear-logs.js",
|
"dashboard:clear-logs": "ts-node scripts/dashboard/clear-logs.ts",
|
||||||
"dashboard:shared": "node scripts/dashboard/shared.js",
|
"dashboard:shared": "ts-node scripts/dashboard/shared.ts",
|
||||||
"producer:shared": "node scripts/producer/shared.js",
|
"producer:shared": "node scripts/producer/shared.js",
|
||||||
"email:deploy": "ts-node scripts/email/deploy.ts"
|
"email:deploy": "ts-node scripts/email/deploy.ts"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
const path = require('path');
|
import fs from 'fs';
|
||||||
const fs = require('fs');
|
import path from 'path';
|
||||||
|
|
||||||
const dashboardPath = path.join(__dirname, '../../dashboard');
|
const dashboardPath = path.join(__dirname, '../../dashboard');
|
||||||
|
|
||||||
@@ -13,5 +13,5 @@ const logNames = [
|
|||||||
|
|
||||||
for (const logName of logNames) {
|
for (const logName of logNames) {
|
||||||
const logFullPath = path.join(dashboardPath, logName);
|
const logFullPath = path.join(dashboardPath, logName);
|
||||||
fs.rmSync(logFullPath);
|
if (fs.existsSync(logFullPath)) fs.rmSync(logFullPath);
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
const path = require('path');
|
import { SharedHelper } from "../helpers/shared-helper";
|
||||||
const fs = require('fs');
|
import path from "path";
|
||||||
const { SharedHelper } = require('../shared-helper.js');
|
|
||||||
|
|
||||||
|
|
||||||
const helper = new SharedHelper(path.join(__dirname, '../../dashboard/shared'))
|
const helper = new SharedHelper(path.join(__dirname, '../../dashboard/shared'))
|
||||||
|
|
||||||
@@ -4,19 +4,11 @@ import path from 'path';
|
|||||||
import { createZip } from '../helpers/zip-helper';
|
import { createZip } from '../helpers/zip-helper';
|
||||||
import { DeployHelper } from '../helpers/deploy-helper';
|
import { DeployHelper } from '../helpers/deploy-helper';
|
||||||
|
|
||||||
const MODE = process.env.MODE;
|
|
||||||
const isProduction = MODE === 'prod';
|
|
||||||
|
|
||||||
if (MODE === 'prod') {
|
|
||||||
console.error('production mode not implemented yet')
|
|
||||||
process.exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
const TMP_PATH = path.join(__dirname, '../../tmp');
|
const TMP_PATH = path.join(__dirname, '../../tmp');
|
||||||
|
|
||||||
const LOCAL_PATH = path.join(__dirname, '../../email');
|
const LOCAL_PATH = path.join(__dirname, '../../email');
|
||||||
|
|
||||||
const REMOTE_PATH = '/home/testmode/litlyx/email';
|
const REMOTE_PATH = '/home/production/litlyx/email';
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
|
||||||
@@ -26,9 +18,7 @@ async function main() {
|
|||||||
const archive = createZip(TMP_PATH + '/email.zip');
|
const archive = createZip(TMP_PATH + '/email.zip');
|
||||||
archive.directory(LOCAL_PATH + '/dist', '/dist');
|
archive.directory(LOCAL_PATH + '/dist', '/dist');
|
||||||
|
|
||||||
const ecosystemContent = fs.readFileSync(LOCAL_PATH + '/ecosystem.config.js', 'utf8');
|
archive.file(LOCAL_PATH + '/ecosystem.config.js', { name: '/ecosystem.config.js' })
|
||||||
const devContent = ecosystemContent.replace(/name: '(.*?)'/, "name: 'test-$1'");
|
|
||||||
archive.append(Buffer.from(devContent), { name: '/ecosystem.config.js' })
|
|
||||||
|
|
||||||
archive.file(LOCAL_PATH + '/package.json', { name: '/package.json' });
|
archive.file(LOCAL_PATH + '/package.json', { name: '/package.json' });
|
||||||
archive.file(LOCAL_PATH + '/pnpm-lock.yaml', { name: '/pnpm-lock.yaml' });
|
archive.file(LOCAL_PATH + '/pnpm-lock.yaml', { name: '/pnpm-lock.yaml' });
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
|
|
||||||
const path = require('path');
|
import path from 'path';
|
||||||
const fs = require('fs');
|
import fs from 'fs';
|
||||||
|
|
||||||
|
|
||||||
class SharedHelper {
|
export class SharedHelper {
|
||||||
|
|
||||||
static getSharedPath() {
|
constructor(private localSharedPath: string) { }
|
||||||
return path.join(__dirname, '../shared_global');
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(localSharedPath) {
|
static getSharedPath() { return path.join(__dirname, '../../shared_global'); }
|
||||||
this.localSharedPath = localSharedPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
if (fs.existsSync(this.localSharedPath)) {
|
if (fs.existsSync(this.localSharedPath)) {
|
||||||
@@ -20,28 +16,21 @@ class SharedHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
create(name) {
|
create(name: string) {
|
||||||
const localFolder = path.join(this.localSharedPath, name);
|
const localFolder = path.join(this.localSharedPath, name);
|
||||||
fs.mkdirSync(localFolder);
|
fs.mkdirSync(localFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
copy(name) {
|
copy(name: string) {
|
||||||
const localSharedFile = path.join(this.localSharedPath, name);
|
const localSharedFile = path.join(this.localSharedPath, name);
|
||||||
const sharedFile = path.join(SharedHelper.getSharedPath(), name);
|
const sharedFile = path.join(SharedHelper.getSharedPath(), name);
|
||||||
fs.cpSync(sharedFile, localSharedFile);
|
fs.cpSync(sharedFile, localSharedFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
copyFolder(name) {
|
copyFolder(name: string) {
|
||||||
const localFolder = path.join(this.localSharedPath, name);
|
const localFolder = path.join(this.localSharedPath, name);
|
||||||
const sharedFolder = path.join(SharedHelper.getSharedPath(), name);
|
const sharedFolder = path.join(SharedHelper.getSharedPath(), name);
|
||||||
fs.cpSync(sharedFolder, localFolder, { force: true, recursive: true });
|
fs.cpSync(sharedFolder, localFolder, { force: true, recursive: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
SharedHelper
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
const { getSharedPath } = require("../shared-helper");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
console.log('SHAREDPATH')
|
|
||||||
console.log(getSharedPath());
|
|
||||||
1
scripts/producer/shared.ts
Normal file
1
scripts/producer/shared.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
Reference in New Issue
Block a user