From 327aef0f2167579d10c966984da4d1c6a8e03922 Mon Sep 17 00:00:00 2001 From: Andreas Knuth Date: Thu, 16 May 2024 13:32:42 -0500 Subject: [PATCH] add version.js --- .gitignore | 1 - bizmatch-server/.eslintrc.js | 25 +++++++++++++++++++++++++ bizmatch/version.js | 30 ++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 bizmatch-server/.eslintrc.js create mode 100644 bizmatch/version.js diff --git a/.gitignore b/.gitignore index a305eed..3f95515 100644 --- a/.gitignore +++ b/.gitignore @@ -62,7 +62,6 @@ pids # Diagnostic reports (https://nodejs.org/api/report.html) report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json -*.js *.map package-lock.json diff --git a/bizmatch-server/.eslintrc.js b/bizmatch-server/.eslintrc.js new file mode 100644 index 0000000..259de13 --- /dev/null +++ b/bizmatch-server/.eslintrc.js @@ -0,0 +1,25 @@ +module.exports = { + parser: '@typescript-eslint/parser', + parserOptions: { + project: 'tsconfig.json', + tsconfigRootDir: __dirname, + sourceType: 'module', + }, + plugins: ['@typescript-eslint/eslint-plugin'], + extends: [ + 'plugin:@typescript-eslint/recommended', + 'plugin:prettier/recommended', + ], + root: true, + env: { + node: true, + jest: true, + }, + ignorePatterns: ['.eslintrc.js'], + rules: { + '@typescript-eslint/interface-name-prefix': 'off', + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/no-explicit-any': 'off', + }, +}; diff --git a/bizmatch/version.js b/bizmatch/version.js new file mode 100644 index 0000000..e29f63a --- /dev/null +++ b/bizmatch/version.js @@ -0,0 +1,30 @@ +#! /usr/bin/env node +const fs = require('fs'); +const dayjs = require('dayjs'); +const timezone = require('dayjs/plugin/timezone'); +const utc = require('dayjs/plugin/utc'); + +dayjs.extend(utc); +dayjs.extend(timezone); + +const write = (content, path) => { + const writePath = path || `${process.cwd()}/src/build.ts`; + try { + fs.writeFileSync( + writePath, + '// Build information, automatically generated by `the_build_script` :zwinkern:\n' + 'const build = ' + JSON.stringify(content, null, 4).replace(/\"([^(\")"]+)\":/g, '$1:') + ';\n\nexport default build;', + ); + } catch (error) { + console.log(error); + } +}; +const package = require(`${process.cwd()}/package.json`); +(() => { + console.log('start build.js script ...'); + // Generate `build` object + const build = {}; + build.timestamp = dayjs(new Date()).utc().format('DD.MM.YYYY HH:mm') + ' UTC'; + // Write Build information to file + write(build); + console.log('build.js script finished ...'); +})();