feat: modernize workflows and standardize configuration files (#85)

This commit is contained in:
2025-12-02 12:50:42 +02:00
committed by GitHub
parent 6027501f24
commit 6dd157f35b
23 changed files with 4365 additions and 6000 deletions

View File

@@ -1,10 +1,10 @@
/* eslint no-console: "off", n/no-process-exit: "off" -- CLI app that gives users feedback */
const fs = require('node:fs')
const path = require('node:path')
const fs = require("node:fs");
const path = require("node:path");
// noinspection NpmUsedModulesInstalled
const process = require('node:process')
const configurationPaths = require('./configuration-paths')
const process = require("node:process");
const configurationPaths = require("./configuration-paths");
/**
* Checks for the existence of a configuration file.
@@ -12,21 +12,21 @@ const configurationPaths = require('./configuration-paths')
* @param {string} pathPrefix The prefix to add to the path.
* @returns {string[]} - The paths to the configuration files.
*/
const configChecker = (moduleName, pathPrefix = '') => {
let searchPath = process.env.INIT_CWD
const configChecker = (moduleName, pathPrefix = "") => {
let searchPath = process.env.INIT_CWD;
if (pathPrefix.length > 0) {
searchPath = pathPrefix
searchPath = pathPrefix;
}
const allFiles = configurationPaths(moduleName)
const allFiles = configurationPaths(moduleName);
if (process.env.DEBUG) {
const filesWithPath = allFiles.map(file => path.join(searchPath, file))
console.log(filesWithPath)
const filesWithPath = allFiles.map((file) => path.join(searchPath, file));
console.log(filesWithPath);
}
// Look for config files in defined search path, and return found.
return allFiles.filter(file => fs.existsSync(path.join(searchPath, file)))
}
return allFiles.filter((file) => fs.existsSync(path.join(searchPath, file)));
};
module.exports = configChecker
module.exports = configChecker;

View File

@@ -1,11 +1,11 @@
const path = require('node:path')
const path = require("node:path");
/**
* Returns an array of configuration paths.
* @param {string} moduleName The name of the module to check for.
* @returns {string[]} - The paths to the configuration files.
*/
const configurationPaths = moduleName => {
const configurationPaths = (moduleName) => {
const filesPlain = [
moduleName,
`${moduleName}rc`,
@@ -22,14 +22,14 @@ const configurationPaths = moduleName => {
`${moduleName}.config.js`,
`${moduleName}.config.ts`,
`${moduleName}.config.mjs`,
`${moduleName}.config.cjs`
]
`${moduleName}.config.cjs`,
];
const filesDot = filesPlain.map(file => `.${file}`)
const bothFiles = filesPlain.concat(filesDot)
const filesInConfig = bothFiles.map(file => path.join('.config', file))
const filesDot = filesPlain.map((file) => `.${file}`);
const bothFiles = filesPlain.concat(filesDot);
const filesInConfig = bothFiles.map((file) => path.join(".config", file));
return bothFiles.concat(filesInConfig)
}
return bothFiles.concat(filesInConfig);
};
module.exports = configurationPaths
module.exports = configurationPaths;