add version.js

This commit is contained in:
Andreas Knuth 2024-05-16 13:32:42 -05:00
parent cb73daf863
commit 327aef0f21
3 changed files with 55 additions and 1 deletions

1
.gitignore vendored
View File

@ -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

View File

@ -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',
},
};

30
bizmatch/version.js Normal file
View File

@ -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 ...');
})();