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

@bookshop/eleventy-bookshop

Package Overview
Dependencies
Maintainers
1
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bookshop/eleventy-bookshop - npm Package Compare versions

Comparing version 2.0.10 to 2.1.0

.nyc_output/096f8481-d72b-4b98-82ea-383e84a0a25b.json

2

.nyc_output/processinfo/index.json

@@ -1,1 +0,1 @@

{"processes":{"7d7b6256-9674-4d8d-b5cb-d4eeb8c66652":{"parent":"fde4a2ce-ef11-4098-9626-d11fab28b360","children":[]},"fde4a2ce-ef11-4098-9626-d11fab28b360":{"parent":null,"children":["7d7b6256-9674-4d8d-b5cb-d4eeb8c66652"]}},"files":{},"externalIds":{}}
{"processes":{"096f8481-d72b-4b98-82ea-383e84a0a25b":{"parent":"b4d86a81-e9c1-4a80-baa3-a55f9829fd68","children":[]},"b4d86a81-e9c1-4a80-baa3-a55f9829fd68":{"parent":null,"children":["096f8481-d72b-4b98-82ea-383e84a0a25b"]}},"files":{},"externalIds":{}}
const path = require("path");
const fs = require("fs");
const getComponentKey = (name) => {
const base = name.split("/").reverse()[0];
return `components/${name}/${base}.eleventy.liquid`;
}
const getIncludeKey = (name) => {
return `shared/eleventy/${name}.eleventy.liquid`;
}
const bookshopTagHandler = (tagType, locations, baseLocation) => (liquidEngine) => {
return {
parse: function (tagToken, remainingTokens) {
const [, component, args] = tagToken.args.match(/^['"]?([^\s'"]+)['"]?\s(.*)$/);
this.component = component;
this.args = args;
},
render: async function (ctx, hash) {
let component = this.component;
let preComment = `<!--bookshop-live -->`, loop_context = '';
const postComment = `<!--bookshop-live end-->`;
// Handle a dynamic component syntax that matches Jekyll:
// {% bookshop {{component._name}} %}
if (/^{{.*}}$/.test(component)) {
component = component.replace(/^{{(.*)}}$/, "$1").trim();
component = ctx.get(component) || this.component;
}
const componentKey = tagType === 'include' ?
getIncludeKey(component) :
getComponentKey(component);
let convertedBookshopTag = null;
for (let location of locations) {
const bookshopPath = path.join(baseLocation, location);
const componentPath = path.join(bookshopPath, componentKey);
if (fs.existsSync(componentPath)) {
const includeRoot = liquidEngine?.options?.root?.filter(p => p.includes('_includes'))?.[0] || "_includes";
const includePath = path.join(baseLocation, includeRoot);
const relativeBookshopPath = path.relative(includePath, bookshopPath);
const relativeIncludePath = path.join(relativeBookshopPath, componentKey);
let loop_context = '';
const top_context = ctx.contexts[ctx.contexts.length - 1] || {};
if (top_context["forloop"]) {
const variable = Object.keys(top_context).filter(k => k !== 'forloop')[0];
// TODO: Find the actual source. This is a guess.
const index = top_context["forloop"].index0;
const guessedSource = contextHunt(ctx, top_context[variable], index);
loop_context = `${variable}: ${guessedSource}[${index}]`;
}
preComment = `<!--bookshop-live name(${component}) params(${this.args}) context(${loop_context}) -->`;
convertedBookshopTag = `{% include ${relativeIncludePath} ${this.args} %}`;
break;
}
};
if (!convertedBookshopTag) {
console.error(`Bookshop: Could not find component ${component} in any of [ ${locations.join(',')} ]`);
process.exit(1);
}
// Support the bookshop bind property
const componentScope = {...(hash.bind || {})};
ctx.push(componentScope);
const tpl = liquidEngine.parse(convertedBookshopTag);
const output = await tpl[0].render(ctx);
// TODO: This is for old liquidjs.
// We shouldn't need to pass the scope in any more.
ctx.pop(componentScope);
return `${preComment}${output}${postComment}`;
}
};
}
const contextHunt = (ctx, hash, index) => {
let h = JSON.stringify(hash);
for (let scope of ctx.contexts.reverse()) {
for (let [k,v] of Object.entries(scope)) {
if (!Array.isArray(v)) continue;
if (JSON.stringify(v[index]) === h) {
return k;
}
}
}
return "UNKNOWN";
}
const transformHostString = (host) => {

@@ -134,7 +44,12 @@ switch (host) {

return function (eleventyConfig) {
// TODO: Better way to check 11ty version
const isEleventyOne = !!eleventyConfig.ignores;
const bookshopTag = isEleventyOne
? require('./lib/eleventy-one-bookshop.js')
: require('./lib/eleventy-zero-bookshop.js');
eleventyConfig.bookshopOptions = { locations, baseLocation };
eleventyConfig.addLiquidTag("bookshop", bookshopTagHandler('component', locations, baseLocation));
eleventyConfig.addLiquidTag("bookshop_include", bookshopTagHandler('include', locations, baseLocation));
eleventyConfig.addLiquidTag("bookshop", bookshopTag('component', locations, baseLocation));
eleventyConfig.addLiquidTag("bookshop_include", bookshopTag('include', locations, baseLocation));
eleventyConfig.addLiquidTag("bookshop_browser", browserTagHandler);
};
}
{
"name": "@bookshop/eleventy-bookshop",
"packageManager": "yarn@3.0.0",
"version": "2.0.10",
"version": "2.1.0",
"description": "Eleventy plugin for consuming Bookshop components",

@@ -20,3 +20,4 @@ "main": "main.js",

"dependencies": {
"@bookshop/helpers": "2.0.10"
"@bookshop/helpers": "2.1.0",
"normalize-path": "^3.0.0"
},

@@ -23,0 +24,0 @@ "engines": {

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