metamigo-common: build, fmt, lint

This commit is contained in:
Abel Luck 2023-03-13 11:46:12 +00:00
parent 2a1ced5383
commit 75fb3f84c4
21 changed files with 95 additions and 156 deletions

View file

@ -11,14 +11,14 @@ export const AppMetaConfig: ConvictSchema<IAppMetaConfig> = {
doc: "The current application version",
format: String,
env: "npm_package_version",
default: null,
default: undefined,
skipGenerate: true,
},
name: {
doc: "Application name",
format: String,
env: "npm_package_name",
default: null,
default: undefined,
skipGenerate: true,
},
figletFont: {

View file

@ -1,7 +1,9 @@
import * as Joi from "joi";
import type { Format } from "convict";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const coerceString = (v: any): string => v.toString();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const validator = (s: any) => (v: any) => Joi.assert(v, s);
const url = Joi.string().uri({

View file

@ -1,5 +1,6 @@
import convict from "convict";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const visitLeaf = (acc: any, key: any, leaf: any) => {
if (leaf.skipGenerate) {
return;
@ -12,9 +13,11 @@ const visitLeaf = (acc: any, key: any, leaf: any) => {
}
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const visitNode = (acc: any, node: any, key = "") => {
if (node._cvtProperties) {
const keys = Object.keys(node._cvtProperties);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let subacc: any;
if (key === "") {
subacc = acc;

View file

@ -1,4 +1,4 @@
import process from "process";
import process from "node:process";
import convict, { SchemaObj } from "convict";
import { IServerConfig, ServerConfig } from "./server";
import { IMetricsConfig, MetricsConfig } from "./metrics-server";
@ -42,19 +42,14 @@ interface IMetamigoConfig {
isProd?: boolean;
isTest?: boolean;
isDev?: boolean;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
frontend: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
nextAuth: any;
}
export type IMetamigoConvict = ExtendedConvict<IMetamigoConfig>;
export type {
IServerConfig,
IMetricsConfig,
IAppMetaConfig,
ICorsConfig,
ILoggingConfig,
IMetamigoConfig,
};
export type { IMetamigoConfig };
export * from "./formats";
export * from "./generate";
@ -103,6 +98,7 @@ ${error}
try {
config.validate({ allowed: "strict" });
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
const msg = `
@ -140,3 +136,9 @@ export const loadConfiguration = async <T extends IMetamigoConfig>(
const c = await loadConfigurationRaw(schema, override);
return c.getProperties();
};
export { type IServerConfig } from "./server";
export { type IMetricsConfig } from "./metrics-server";
export { type IAppMetaConfig } from "./app-meta";
export { type ICorsConfig } from "./cors";
export { type ILoggingConfig } from "./logging";

View file

@ -1,6 +1,7 @@
import chalk from "chalk";
import convict from "convict";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const visitLeaf = (path: any, key: any, leaf: any) => {
if (leaf.skipGenerate) {
return;
@ -20,6 +21,7 @@ const visitLeaf = (path: any, key: any, leaf: any) => {
console.log(`\tenv: ${leaf.env}`);
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const visitNode = (path: any, node: any, key = "") => {
if (node._cvtProperties) {
const keys = Object.keys(node._cvtProperties);