Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
SQL Syntax Highlighter and Logger. Unadorned and customizable.
$ npm install igniculus
const igniculus = require('igniculus')();
igniculus('SELECT [port] AS Printer, \'on fire\' AS Status ' +
'FROM [Printers] P ' +
'WHERE P."online" = 1 AND P."check" = 1');
A reference to the log function is returned on initialization but can be accessed anywhere through .log
// config.js
const igniculus = require('igniculus');
const options = { ... };
igniculus(options);
// any.js
const igniculus = require('igniculus');
let query = 'SELECT ...';
igniculus.log(query);
A default color scheme is provided. However, you can define the highlight style for each rule when instantiating:
const igniculus = require('igniculus');
/* White constants over red background using inverse mode.
* Gray keywords.
* Prefixed by white '(query)' message.
*/
const options = {
constants: { mode: 'inverse', fg: 'red', bg: 'white' },
standardKeywords: { mode: 'bold', fg: 'black' },
lesserKeywords: { mode: 'bold', fg: 'black' },
prefix: { mode: 'bold', fg: 'white', text: '(query) '}
};
const illumine = igniculus(options);
illumine('SELECT * FROM Student s ' +
'WHERE s.programme = \'IT\' AND EXISTS (' +
'SELECT * FROM Enrolled e ' +
'JOIN Class c ON c.code = e.code ' +
'JOIN Tutor t ON t.tid = c.tid ' +
'WHERE e.sid = s.sid AND t.name LIKE \'%Hoffman\')');
The options argument is optional and each property should be one of the following.
'static'
2.5
+
or >=
[Employee]
or "salary"
INTEGER
or VARCHAR
['SERIAL', 'TIMESTAMP']
'lowercase'
or 'uppercase'
. If not defined data types won't be capitalized.SELECT
or CONSTRAINT
['CLUSTER', 'NATURAL']
'lowercase'
or 'uppercase'
. If not defined standard keywords won't be capitalized.ANY
, AVG
or DESC
['VOLATILE', 'ASYMMETRIC']
'lowercase'
or 'uppercase'
. If not defined lesser keywords won't be capitalized.Executing (default|transaction_id):
This is removed by default by the option prefix: { replace: /.*?: / }
console.log
by default. E.g: process.stdout
, st => st
If defined, the options argument takes precedence over default options. If a rule or it´s style is missing it won't be applied. This allows to "enable" or "disable" certain syntax highlighting as you see fit. (Examples below)
A word on types and keywords
Most often, highlighting every reserved keyword can make syntax difficult to read, defeating the purpose altogether. Therefore, three distinct rules are provided: dataTypes, standardKeywords and lesserKeywords. Each of these rules can be customized individually and come with a predefined list of most widely used T-SQL and SQL-92 keywords and data types. Furthermore each of this lists can be customized as described above.
Starting from v1.1.0 types and keywords are no longer uppercased by default. Custom styles should use the
casing: 'uppercase'
option for this behaviour. Predefined style already provides this option so no changes should be required.
All of the previous rule styles can be defined like this:
/* options = {"rule": style, ... } where
* style = { mode: "modifier", fg: "color", bg: "color"}
*/
const options = {
constants: {
mode: 'inverse',
fg: 'red',
bg: 'white'
},
...
};
Each style having an optional:
'bold'
'red'
'black'
These can be one of the following.
reset
bold
dim
italic
underline
blink
inverse
hidden
strikethrough
black
red
green
yellow
blue
magenta
cyan
white
/* Predifined style */
const defaults = {
constants: { mode: 'dim', fg: 'red' },
delimitedIdentifiers: { mode: 'dim', fg: 'yellow', casing: 'uppercase' },
dataTypes: { mode: 'dim', fg: 'green', casing: 'uppercase' },
standardKeywords: { mode: 'dim', fg: 'cyan', casing: 'uppercase' },
lesserKeywords: { mode: 'bold', fg: 'black' },
prefix: { replace: /.*?: / }
};
const igniculus = require('igniculus')(
{
constants: { mode: 'bold', fg: 'yellow' },
numbers: { mode: 'bold', fg: 'magenta' },
delimitedIdentifiers: { mode: 'bold', fg: 'red' },
standardKeywords: { mode: 'bold', fg: 'blue' }
}
);
igniculus("INSERT INTO [Printers] ([port], [name], [ready], [online], [check]) " +
"VALUES ('lp0', 'Bob Marley', 0, 1, 1)");
const igniculus = require('igniculus');
const options = {
delimitedIdentifiers: {
fg: 'yellow'
},
dataTypes: {
fg: 'magenta',
types: ['VARBINARY']
},
standardKeywords: {
fg: 'red',
keywords: ['CREATE', 'PRIMARY', 'KEY']
},
lesserKeywords: {
mode: 'bold',
fg: 'black',
keywords: ['TABLE', 'NOT', 'NULL']
},
prefix: {
text: '\n'
}
};
igniculus(options);
igniculus.log('CREATE TABLE User (' +
'[username] VARCHAR(20) NOT NULL, ' +
'[password] BINARY(64) NOT NULL, ' +
'[avatar] VARBINARY(MAX), PRIMARY KEY ([username]))');
Igniculus' logger is a drop in replacement on any tool that passes the log function either a string
or Object
paramater. In the latest case the toString()
method will be called to obtain a string
primitive.
Using igniculus with sequelize is straightforward.
const Sequelize = require('sequelize');
const igniculus = require('igniculus')();
const sequelize = new Sequelize('database', 'username', 'password', {
logging: igniculus
});
/* Or add some customizations */
const Sequelize = require('sequelize');
const igniculus = require('igniculus')(
{
constants: { fg: 'red' },
delimitedIdentifiers: { fg: 'yellow' },
dataTypes: { fg: 'red' },
standardKeywords: { fg: 'magenta' },
lesserKeywords: { mode: 'bold', fg: 'black' },
prefix: {
mode: 'bold',
fg: 'white',
replace: /.*?:/,
text: '(Sequelize)'
},
postfix: { text:'\r\n' }
}
);
const sequelize = new Sequelize('database', 'username', 'password', {
logging: igniculus
});
...
sequelize.sync({ logging: igniculus});
For a full list of changes please refer to the changelog.
Planned support for variables and custom rules.
1.1.0 ~ 26 Feb 2018
FAQs
SQL Syntax Highlighter and Logger. Unadorned and customizable.
The npm package igniculus receives a total of 5,362 weekly downloads. As such, igniculus popularity was classified as popular.
We found that igniculus demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.