-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
573b7d3
commit 4956fed
Showing
14 changed files
with
2,399 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules/ | ||
coverage/ | ||
dist/ | ||
.nyc_output/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
module.exports = { | ||
env: { | ||
node: true, | ||
es2024: true, | ||
commonjs: true, | ||
}, | ||
parserOptions: { | ||
ecmaVersion: 2024, | ||
sourceType: 'commonjs', | ||
}, | ||
extends: [ | ||
'eslint:recommended', | ||
], | ||
rules: { | ||
'indent': ['error', 2], | ||
'linebreak-style': ['error', 'unix'], | ||
'quotes': ['error', 'single'], | ||
'semi': ['error', 'always'], | ||
'no-unused-vars': ['error', { 'argsIgnorePattern': '^_' }], | ||
'no-console': ['error', { allow: ['warn', 'error'] }], | ||
'no-constant-condition': ['error', { checkLoops: false }], | ||
'eqeqeq': ['error', 'always'], | ||
'curly': ['error', 'all'], | ||
'comma-dangle': ['error', { | ||
'arrays': 'always-multiline', | ||
'objects': 'always-multiline', | ||
'imports': 'always-multiline', | ||
'exports': 'always-multiline', | ||
'functions': 'never', | ||
}], | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['test/**/*.js'], | ||
env: { | ||
node: true, | ||
commonjs: true, | ||
es2024: true, | ||
}, | ||
rules: { | ||
'no-console': 'off', | ||
}, | ||
}, | ||
], | ||
globals: { | ||
'__dirname': 'readonly', | ||
'process': 'readonly', | ||
'require': 'readonly', | ||
'module': 'readonly', | ||
'exports': 'readonly', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
const esbuild = require('esbuild'); | ||
const { readFile } = require('fs/promises'); | ||
const path = require('path'); | ||
|
||
async function getBanner() { | ||
const pkg = JSON.parse( | ||
await readFile(path.join(__dirname, 'package.json'), 'utf8') | ||
); | ||
return `/** | ||
* @license | ||
* ${pkg.name} v${pkg.version} | ||
* Copyright (c) ${new Date().getFullYear()} ${pkg.author} | ||
* Licensed under the ${pkg.license} license | ||
*/`; | ||
} | ||
|
||
async function build() { | ||
const banner = await getBanner(); | ||
|
||
try { | ||
await esbuild.build({ | ||
entryPoints: ['./index.js'], | ||
bundle: true, | ||
minify: true, | ||
platform: 'node', | ||
target: 'node20', | ||
outfile: 'dist/log4js-pg-appender.min.js', | ||
banner: { | ||
js: banner, | ||
}, | ||
external: ['pg'], // Don't bundle external dependencies | ||
format: 'cjs', | ||
metafile: true, | ||
sourcemap: true, | ||
}); | ||
|
||
// Build metadata for analysis | ||
const metadata = await esbuild.build({ | ||
entryPoints: ['./index.js'], | ||
bundle: true, | ||
minify: true, | ||
platform: 'node', | ||
target: 'node20', | ||
external: ['pg'], | ||
format: 'cjs', | ||
metafile: true, | ||
write: false, | ||
}); | ||
|
||
// Output build analysis | ||
const text = await esbuild.analyzeMetafile(metadata.metafile); | ||
// eslint-disable-next-line no-console | ||
console.log('Build analysis:', text); | ||
|
||
} catch (error) { | ||
// eslint-disable-next-line no-console | ||
console.error('Build failed:', error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
build(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module.exports = (client, tableName = 'Logs') => { | ||
const query = { | ||
name: 'log4js-pg-appender-add-record', | ||
text: `INSERT INTO "${ tableName }" ("startTime", "categoryName", "data", "level", "context") VALUES($1, $2, $3, $4, $5)`, | ||
}; | ||
return (...values) => client.query({ ...query, values}); | ||
const query = { | ||
name: 'log4js-pg-appender-add-record', | ||
text: `INSERT INTO "${ tableName }" ("startTime", "categoryName", "data", "level", "context") VALUES($1, $2, $3, $4, $5)`, | ||
}; | ||
return (...values) => client.query({ ...query, values}); | ||
}; |
Oops, something went wrong.