New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

attr-transform.macro

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

attr-transform.macro - npm Package Compare versions

Comparing version 0.0.10 to 0.0.11

102

attr-transform.macro.js

@@ -9,2 +9,11 @@ var babelPluginMacros = require('babel-plugin-macros');

function getSourceFromNode(path) {
const {
default: generator
} = require("@babel/generator");
const print = generator;
const code = print(path.node).code;
return code;
}
function stringify(obj, options) {

@@ -117,2 +126,3 @@ const opt = Object.assign({

this.lineWith = 80;
this.enabled = false;
}

@@ -128,39 +138,64 @@ stringify(obj, maxDepth = this.maxDepth) {

object(obj, color = "white", maxDepth) {
let json = this.stringify(obj, maxDepth);
this.msg(json, color);
if (this.enabled) {
let json = this.stringify(obj, maxDepth);
this.msg(json, color);
}
}
node(nodePath, color = "white") {
if (this.enabled) {
const code = getSourceFromNode(nodePath);
this.msg(code, color);
}
}
msg(message, color = "white") {
this.logLines.push({
msg: message,
color
});
if (this.enabled) {
this.logLines.push({
msg: message,
color
});
}
}
contentLine(line, color = "white") {
let message = `${line}: ` + this.content.split("\n")[line - 1];
this.logLines.push({
msg: message,
color
});
if (this.enabled) {
let message = `${line}: ` + this.content.split("\n")[line - 1];
this.logLines.push({
msg: message,
color
});
}
}
note(message, color = "blackBright") {
this.line(message, "---- # ", false, color);
if (this.enabled) {
this.line(message, "## -- ", false, color);
}
}
header(message, color = "cyan") {
this.line(message, "---- ", true, color);
if (this.enabled) {
this.line(message, "## ", true, color);
}
}
subheader(message, color = "cyan") {
if (this.enabled) {
this.line(message, ">> ", false, color);
}
}
end(color = "blackBright") {
this.line("", "---- - - - - -", true, color);
if (this.enabled) {
this.line("", "---- - - - - -", true, color);
}
}
line(message, prefix = "", header, color = "white") {
let msg = `${prefix}${message} `;
let len = msg.length;
if (len < this.lineWith) {
let space = this.lineWith - len;
let char = header ? "-" : " ";
msg += char.repeat(space);
if (this.enabled) {
let msg = `${prefix}${message} `;
let len = msg.length;
if (len < this.lineWith) {
let space = this.lineWith - len;
let char = header ? "-" : " ";
msg += char.repeat(space);
}
this.logLines.push({
msg,
color
});
}
this.logLines.push({
msg,
color
});
}

@@ -420,2 +455,4 @@ getColorLog() {

}
log.subheader(`Transformed Attribute`);
log.node(foundProp.nodePath);
}

@@ -502,9 +539,11 @@

for (const foundProp of foundAttributes) {
log.header(`Attr: ${foundProp.nodePath.node.name.name}`, "cyan");
log.note(`Value from attr: ${foundProp.value}`, "blackBright");
log.subheader(`Attr: ${foundProp.nodePath.node.name.name} - Source:`, "cyan");
log.node(foundProp.nodePath);
log.subheader(`Value from attr config: ${foundProp.value}`, "blackBright");
if (foundProp.attrConfig.replaceName || foundProp.attrConfig.replaceValue) {
replaceNameAndOrValue(foundProp, t, log);
}
log.note(`End attribute parsing`);
}
log.note(`Run elm actions conditions`, "blackBright");
log.subheader(`Run elm actions conditions`, "blackBright");
const matchedActions = postMatchActions.map(action => {

@@ -540,3 +579,3 @@ var _action$name;

var _action$name2;
log.header(`Action: ${(_action$name2 = action.name) != null ? _action$name2 : " (no name)"}`, "cyan");
log.subheader(`Action: ${(_action$name2 = action.name) != null ? _action$name2 : " (no name)"}`, "cyan");
let value = action.value;

@@ -589,2 +628,3 @@ if (action.postMatchAction.createAttribute) {

const program = params.state.file.path;
log.enabled = true;
log.header(`attr-transform.macro`);

@@ -596,2 +636,5 @@ log.note(`file: ${params.state.filename}`);

const attrTransformConfig = loadConfig(params, log);
if (!attrTransformConfig.devMode) {
log.enabled = false;
}
log.header(`Using Config`);

@@ -614,4 +657,3 @@ log.object(attrTransformConfig);

const devMode = attrTransformConfig.devMode;
const print = require("@babel/generator").default;
const code = print(program.node).code;
const code = getSourceFromNode(program);
log.msg(`\n\n`);

@@ -618,0 +660,0 @@ log.header(`Transformed Code`);

{
"name": "attr-transform.macro",
"version": "0.0.10",
"version": "0.0.11",
"description": "jsx attribute pre-processor",

@@ -5,0 +5,0 @@ "main": "attr-transform.macro.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc