mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 08:33:11 +00:00
feat: migrate to esm
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/*
|
||||
* Copyright (C) 2022 StApps
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -18,9 +16,9 @@
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {execSync} from 'child_process';
|
||||
import * as Dockerode from 'dockerode';
|
||||
import {render} from 'mustache';
|
||||
import {asyncReadFile, asyncWriteFile} from './common';
|
||||
import {getContainers, getTemplateView} from './main';
|
||||
import mustache from 'mustache';
|
||||
import {asyncReadFile, asyncWriteFile} from './common.js';
|
||||
import {getContainers, getTemplateView} from './main.js';
|
||||
|
||||
/* eslint-disable unicorn/prefer-module */
|
||||
|
||||
@@ -58,7 +56,7 @@ async function updateNginxConfig() {
|
||||
await delay(10_000);
|
||||
|
||||
// render nginx config file
|
||||
const nginxConfig = render(
|
||||
const nginxConfig = mustache.render(
|
||||
await asyncReadFile('nginx.conf.template', 'utf8'),
|
||||
await getTemplateView(containers),
|
||||
);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {SMTP} from '@openstapps/logger/lib/smtp';
|
||||
import {SMTP} from '@openstapps/logger/lib/smtp.js';
|
||||
import config from 'config';
|
||||
import {existsSync, readFile, writeFile} from 'fs';
|
||||
import {promisify} from 'util';
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import Dockerode from 'dockerode';
|
||||
import isCidr from 'is-cidr';
|
||||
import {render} from 'mustache';
|
||||
import mustache from 'mustache';
|
||||
import path from 'path';
|
||||
import * as semver from 'semver';
|
||||
import {
|
||||
@@ -28,14 +28,13 @@ import {
|
||||
sslHardeningParameters,
|
||||
SupportedLogFormats,
|
||||
TemplateView,
|
||||
} from './common';
|
||||
} from './common.js';
|
||||
// @ts-expect-error missing type defs
|
||||
import nodePortScanner from 'node-port-scanner';
|
||||
|
||||
/* eslint-disable unicorn/prefer-module */
|
||||
/* eslint-disable unicorn/no-await-expression-member */
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const nodePortScanner = require('node-port-scanner');
|
||||
|
||||
/**
|
||||
* Checks if a ContainerInfo matches a name and version regex
|
||||
*
|
||||
@@ -263,7 +262,7 @@ export async function generateMetricsServer(logFormat: string, enableMetrics?: b
|
||||
async function renderTemplate(path: string, view: unknown): Promise<string> {
|
||||
const content = await asyncReadFile(path, 'utf8');
|
||||
|
||||
return render(content, view);
|
||||
return mustache.render(content, view);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user