mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-09 23:48:36 +01:00
update scripts to typescript
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"dashboard:clear-logs": "node scripts/dashboard/clear-logs.js",
|
||||
"dashboard:shared": "node scripts/dashboard/shared.js",
|
||||
"dashboard:clear-logs": "ts-node scripts/dashboard/clear-logs.ts",
|
||||
"dashboard:shared": "ts-node scripts/dashboard/shared.ts",
|
||||
"producer:shared": "node scripts/producer/shared.js",
|
||||
"email:deploy": "ts-node scripts/email/deploy.ts"
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
const dashboardPath = path.join(__dirname, '../../dashboard');
|
||||
|
||||
@@ -13,5 +13,5 @@ const logNames = [
|
||||
|
||||
for (const logName of logNames) {
|
||||
const logFullPath = path.join(dashboardPath, logName);
|
||||
fs.rmSync(logFullPath);
|
||||
if (fs.existsSync(logFullPath)) fs.rmSync(logFullPath);
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { SharedHelper } = require('../shared-helper.js');
|
||||
|
||||
import { SharedHelper } from "../helpers/shared-helper";
|
||||
import path from "path";
|
||||
|
||||
const helper = new SharedHelper(path.join(__dirname, '../../dashboard/shared'))
|
||||
|
||||
@@ -4,19 +4,11 @@ import path from 'path';
|
||||
import { createZip } from '../helpers/zip-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 LOCAL_PATH = path.join(__dirname, '../../email');
|
||||
|
||||
const REMOTE_PATH = '/home/testmode/litlyx/email';
|
||||
const REMOTE_PATH = '/home/production/litlyx/email';
|
||||
|
||||
async function main() {
|
||||
|
||||
@@ -26,9 +18,7 @@ async function main() {
|
||||
const archive = createZip(TMP_PATH + '/email.zip');
|
||||
archive.directory(LOCAL_PATH + '/dist', '/dist');
|
||||
|
||||
const ecosystemContent = fs.readFileSync(LOCAL_PATH + '/ecosystem.config.js', 'utf8');
|
||||
const devContent = ecosystemContent.replace(/name: '(.*?)'/, "name: 'test-$1'");
|
||||
archive.append(Buffer.from(devContent), { name: '/ecosystem.config.js' })
|
||||
archive.file(LOCAL_PATH + '/ecosystem.config.js', { name: '/ecosystem.config.js' })
|
||||
|
||||
archive.file(LOCAL_PATH + '/package.json', { name: '/package.json' });
|
||||
archive.file(LOCAL_PATH + '/pnpm-lock.yaml', { name: '/pnpm-lock.yaml' });
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
|
||||
|
||||
class SharedHelper {
|
||||
export class SharedHelper {
|
||||
|
||||
static getSharedPath() {
|
||||
return path.join(__dirname, '../shared_global');
|
||||
}
|
||||
constructor(private localSharedPath: string) { }
|
||||
|
||||
constructor(localSharedPath) {
|
||||
this.localSharedPath = localSharedPath;
|
||||
}
|
||||
static getSharedPath() { return path.join(__dirname, '../../shared_global'); }
|
||||
|
||||
clear() {
|
||||
if (fs.existsSync(this.localSharedPath)) {
|
||||
@@ -20,28 +16,21 @@ class SharedHelper {
|
||||
}
|
||||
}
|
||||
|
||||
create(name) {
|
||||
create(name: string) {
|
||||
const localFolder = path.join(this.localSharedPath, name);
|
||||
fs.mkdirSync(localFolder);
|
||||
}
|
||||
|
||||
copy(name) {
|
||||
copy(name: string) {
|
||||
const localSharedFile = path.join(this.localSharedPath, name);
|
||||
const sharedFile = path.join(SharedHelper.getSharedPath(), name);
|
||||
fs.cpSync(sharedFile, localSharedFile);
|
||||
}
|
||||
|
||||
copyFolder(name) {
|
||||
copyFolder(name: string) {
|
||||
const localFolder = path.join(this.localSharedPath, name);
|
||||
const sharedFolder = path.join(SharedHelper.getSharedPath(), name);
|
||||
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