Initial Skeleton
This commit is contained in:
parent
e5491413a8
commit
8966727672
|
@ -0,0 +1,136 @@
|
||||||
|
.github/*
|
||||||
|
index.ts
|
||||||
|
combined.ts
|
||||||
|
tooling/*
|
||||||
|
tsconfig.json
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
.pnpm-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
bower_components
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# Snowpack dependency directory (https://snowpack.dev/)
|
||||||
|
web_modules/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Optional stylelint cache
|
||||||
|
.stylelintcache
|
||||||
|
|
||||||
|
# Microbundle cache
|
||||||
|
.rpt2_cache/
|
||||||
|
.rts2_cache_cjs/
|
||||||
|
.rts2_cache_es/
|
||||||
|
.rts2_cache_umd/
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variable files
|
||||||
|
.env
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
.env.local
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
.parcel-cache
|
||||||
|
|
||||||
|
# Next.js build output
|
||||||
|
.next
|
||||||
|
out
|
||||||
|
|
||||||
|
# Nuxt.js build / generate output
|
||||||
|
.nuxt
|
||||||
|
dist
|
||||||
|
|
||||||
|
# Gatsby files
|
||||||
|
.cache/
|
||||||
|
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||||
|
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||||
|
# public
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# vuepress v2.x temp and cache directory
|
||||||
|
.temp
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# Docusaurus cache and generated files
|
||||||
|
.docusaurus
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# TernJS port file
|
||||||
|
.tern-port
|
||||||
|
|
||||||
|
# Stores VSCode versions used for testing VSCode extensions
|
||||||
|
.vscode-test
|
||||||
|
|
||||||
|
# yarn v2
|
||||||
|
.yarn/cache
|
||||||
|
.yarn/unplugged
|
||||||
|
.yarn/build-state.yml
|
||||||
|
.yarn/install-state.gz
|
||||||
|
.pnp.*
|
|
@ -0,0 +1,34 @@
|
||||||
|
// Copyright (c) Holly Stubbs (tgpholly) - Licensed under MIT
|
||||||
|
// Check LICENSE in repository root for more information.
|
||||||
|
|
||||||
|
import { createServer, Server } from "http";
|
||||||
|
import IConfig from "./interfaces/IConfig";
|
||||||
|
|
||||||
|
export default abstract class SimpleProm {
|
||||||
|
static instance?:SimpleProm;
|
||||||
|
|
||||||
|
public config:IConfig;
|
||||||
|
public selfHostServer?:Server;
|
||||||
|
|
||||||
|
private constructor(config:IConfig) {
|
||||||
|
SimpleProm.instance?.end();
|
||||||
|
SimpleProm.instance = this;
|
||||||
|
|
||||||
|
this.config = config;
|
||||||
|
|
||||||
|
this.selfHostServer = createServer((req, res) => {
|
||||||
|
res.end("SimpleProm exporter");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static init(config:IConfig) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public end() {
|
||||||
|
if (this.selfHostServer) {
|
||||||
|
this.selfHostServer.close();
|
||||||
|
this.selfHostServer.closeAllConnections();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
export default interface IConfig {
|
||||||
|
selfHost: boolean,
|
||||||
|
selfHostPort?: number
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
"name": "simple-prom",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "A simple and easy to use module for Prometheus metric exporting.",
|
||||||
|
"main": "./lib/index.js",
|
||||||
|
"types": "./lib/index.d.js",
|
||||||
|
"scripts": {
|
||||||
|
"updateCheck": "check-outdated",
|
||||||
|
"_clean": "tsc --build --clean",
|
||||||
|
|
||||||
|
"build": "npm-run-all build:*",
|
||||||
|
"build:smash": "ts-node ./tooling/fileSmasher.ts",
|
||||||
|
"build:build": "tsc --build",
|
||||||
|
"build:cleanup": "ts-node ./tooling/cleanup.ts"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.eusv.net/Catgirl.Enterprises/simple-prom.git"
|
||||||
|
},
|
||||||
|
"keywords": ["prometheus","prom","expoter","typescript","types"],
|
||||||
|
"author": "Catgirl.Enterprises",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"check-outdated": "^2.12.0",
|
||||||
|
"npm-run-all": "^4.1.5",
|
||||||
|
"ts-node": "^10.9.2",
|
||||||
|
"typescript": "^5.5.3"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
// Copyright (c) Holly Stubbs (tgpholly) - Licensed under MIT
|
||||||
|
// Check LICENSE in repository root for more information.
|
||||||
|
|
||||||
|
import { readdirSync, rmSync, renameSync } from "fs";
|
||||||
|
|
||||||
|
const libFiles = readdirSync("./lib");
|
||||||
|
|
||||||
|
for (const file of libFiles) {
|
||||||
|
if (!file.startsWith("combined")) {
|
||||||
|
rmSync(`./lib/${file}`, { recursive: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
renameSync("./lib/combined.js", "./lib/index.js");
|
||||||
|
renameSync("./lib/combined.d.ts", "./lib/index.d.ts");
|
|
@ -0,0 +1,69 @@
|
||||||
|
// Copyright (c) Holly Stubbs (tgpholly) - Licensed under MIT
|
||||||
|
// Check LICENSE in repository root for more information.
|
||||||
|
|
||||||
|
// fileSmasher ~.~
|
||||||
|
// for when you're just too lazy to
|
||||||
|
// do it properly.
|
||||||
|
|
||||||
|
import { readdirSync, lstatSync, readFileSync, writeFileSync } from "fs";
|
||||||
|
|
||||||
|
const tsFileData:Array<string> = new Array<string>();
|
||||||
|
|
||||||
|
// Github Actions forced my hand
|
||||||
|
const toolinglessFolderPath = __dirname.replace("/tooling", "/");
|
||||||
|
|
||||||
|
function readDir(nam:string) {
|
||||||
|
const files = readdirSync(nam);
|
||||||
|
for (const file of files) {
|
||||||
|
if (nam == toolinglessFolderPath && (file.startsWith(".") || file == "tooling" || file == "lib" || file == "node_modules" || file == "combined.ts")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lstatSync(`${nam}/${file}`).isDirectory()) {
|
||||||
|
readDir(`${nam}/${file}`);
|
||||||
|
} else if (file.endsWith(".ts")) {
|
||||||
|
tsFileData.push(readFileSync((`${nam}/${file}`).replace("//", "/")).toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
readDir(toolinglessFolderPath);
|
||||||
|
|
||||||
|
const combinedFiles = tsFileData.join("\n");
|
||||||
|
|
||||||
|
const splitLines = combinedFiles.split("\n");
|
||||||
|
const resultLines:Array<string> = new Array<string>();
|
||||||
|
|
||||||
|
const unExport = [
|
||||||
|
"class:ReaderBase",
|
||||||
|
"class:ReaderLE",
|
||||||
|
"class:ReaderBE",
|
||||||
|
"class:WriterBase",
|
||||||
|
"class:WriterLE",
|
||||||
|
"class:WriterBE",
|
||||||
|
];
|
||||||
|
|
||||||
|
function checkForMatchAndReplace(s:string) {
|
||||||
|
for (const tUExp of unExport) {
|
||||||
|
const spl = tUExp.split(":");
|
||||||
|
const type = spl[0];
|
||||||
|
if (s.startsWith(`export ${type} ${spl[1]}`)) {
|
||||||
|
return s.replace(`export ${type} ${spl[1]}`, `${type} ${spl[1]}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Let's process the file to make it usable
|
||||||
|
for (const line of splitLines) {
|
||||||
|
// Throw away imports as they aren't needed
|
||||||
|
// TODO: Add allow list for npm module imports
|
||||||
|
if (line.startsWith("import")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Fix up classes, interfaces and such.
|
||||||
|
resultLines.push(checkForMatchAndReplace(line));
|
||||||
|
}
|
||||||
|
|
||||||
|
writeFileSync("./combined.ts", resultLines.join("\n"));
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "CommonJS",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"target": "ES2020",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"rootDir": "./",
|
||||||
|
"outDir": "./lib/",
|
||||||
|
"strict": true,
|
||||||
|
"declaration": true
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue