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

@bookshop/builder

Package Overview
Dependencies
Maintainers
1
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bookshop/builder - npm Package Compare versions

Comparing version 2.0.0-beta.8 to 2.0.0-beta.9

.nyc_output/5cd809ac-fdc2-4720-b28c-e73f5a3a5974.json

2

.nyc_output/processinfo/index.json

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

{"processes":{"25007719-1955-49b4-9682-6203197e9ba3":{"parent":"50476b95-9cf0-4da0-985f-bfc21238e646","children":[]},"3606ba3b-0738-42a1-9454-fc3d1da95ce9":{"parent":"50476b95-9cf0-4da0-985f-bfc21238e646","children":[]},"50476b95-9cf0-4da0-985f-bfc21238e646":{"parent":null,"children":["25007719-1955-49b4-9682-6203197e9ba3","3606ba3b-0738-42a1-9454-fc3d1da95ce9","91e89f5c-bb15-4f0e-8eb3-c064772c67e5","92aef002-0f44-4bbd-8654-bbc64ae45776","b3ddba60-4dc3-4644-a738-481787fffba1"]},"91e89f5c-bb15-4f0e-8eb3-c064772c67e5":{"parent":"50476b95-9cf0-4da0-985f-bfc21238e646","children":[]},"92aef002-0f44-4bbd-8654-bbc64ae45776":{"parent":"50476b95-9cf0-4da0-985f-bfc21238e646","children":[]},"b3ddba60-4dc3-4644-a738-481787fffba1":{"parent":"50476b95-9cf0-4da0-985f-bfc21238e646","children":[]}},"files":{},"externalIds":{}}
{"processes":{"5cd809ac-fdc2-4720-b28c-e73f5a3a5974":{"parent":null,"children":["68593790-a715-47d5-9dca-6f8a7c5c6f1c","7836f42f-a459-41b1-b054-9563ca66f5ff","b342811a-495e-4d09-8487-ff70e1455232","c4d7da4a-e6e4-4672-83a0-cc60669ba101","fd884617-e72a-45ee-aa05-4044459740f9"]},"68593790-a715-47d5-9dca-6f8a7c5c6f1c":{"parent":"5cd809ac-fdc2-4720-b28c-e73f5a3a5974","children":[]},"7836f42f-a459-41b1-b054-9563ca66f5ff":{"parent":"5cd809ac-fdc2-4720-b28c-e73f5a3a5974","children":[]},"b342811a-495e-4d09-8487-ff70e1455232":{"parent":"5cd809ac-fdc2-4720-b28c-e73f5a3a5974","children":[]},"c4d7da4a-e6e4-4672-83a0-cc60669ba101":{"parent":"5cd809ac-fdc2-4720-b28c-e73f5a3a5974","children":[]},"fd884617-e72a-45ee-aa05-4044459740f9":{"parent":"5cd809ac-fdc2-4720-b28c-e73f5a3a5974","children":[]}},"files":{},"externalIds":{}}

@@ -7,10 +7,5 @@ import path from 'path';

build.onResolve({ filter: /^__bookshop_components__/ }, async (args) => {
const primaryBookshopDir = options?.bookshopDirs?.[0];
if (!primaryBookshopDir) return;
return {
path: args.path,
namespace: 'bookshop-import-components',
pluginData: {
resolveDir: path.join(primaryBookshopDir)
},
};

@@ -20,5 +15,5 @@ });

const fileContents = `import components from '__bookshop_glob__(.bookshop.toml)';export default components;`;
return { contents: fileContents, resolveDir: args.pluginData.resolveDir };
return { contents: fileContents };
});
},
});
import fs from 'fs/promises';
import path from 'path';
const loadFileFromBookshops = async (bookshops, file) => {
for (const dir of bookshops) {
const filePath = path.join(dir, file);
try {
const fileContents = await fs.readFile(filePath, 'utf8');
return {
fileContents: fileContents,
resolveDir: dir,
filePath: filePath
}
} catch (e) {}
}
return {
fileContents: "",
resolveDir: "",
filePath: ""
}
};
export default (options) => ({

@@ -8,4 +27,3 @@ name: 'bookshop-file',

build.onResolve({ filter: /^__bookshop_file__/ }, async (args) => {
const primaryBookshopDir = options?.bookshopDirs?.[0];
if (!primaryBookshopDir) return;
if (!options?.bookshopDirs?.length) return;
return {

@@ -15,3 +33,3 @@ path: args.path.replace(/^__bookshop_file__/, ''),

pluginData: {
resolveDir: path.join(primaryBookshopDir)
resolveDirs: options.bookshopDirs
},

@@ -21,8 +39,8 @@ };

build.onLoad({ filter: /.*/, namespace: 'bookshop-import-file' }, async (args) => {
const filePath = path.join(args.pluginData.resolveDir, args.path);
const fileContents = await fs.readFile(filePath, 'utf8');
const {fileContents, resolveDir, filePath} = await loadFileFromBookshops(args.pluginData.resolveDirs, args.path);
return {
contents: fileContents,
loader: 'text',
resolveDir: args.pluginData.resolveDir,
resolveDir: resolveDir,
watchFiles: [filePath]

@@ -29,0 +47,0 @@ };

@@ -20,3 +20,6 @@ import test from 'ava';

bookshopFilePlugin({
bookshopDirs: [path.join(process.cwd(), './.test/fixtures')]
bookshopDirs: [
path.join(process.cwd(), './.test/fixtures'),
path.join(process.cwd(), './.test/second-fixtures')
]
})

@@ -33,1 +36,102 @@ ],

});
test('import a component from a secondary bookshop', async t => {
let result = await esbuild.build({
stdin: {
contents: `import file from "__bookshop_file__components/dos/dos.jekyll.html";
console.log(file);`,
resolveDir: process.cwd(),
sourcefile: 'virtual.js'
},
plugins: [
bookshopFilePlugin({
bookshopDirs: [
path.join(process.cwd(), './.test/fixtures'),
path.join(process.cwd(), './.test/second-fixtures')
]
})
],
format: 'esm',
write: false,
bundle: true
});
t.is(result.errors.length, 0);
t.is(result.warnings.length, 0);
t.regex(result.outputFiles[0].text, /<p>dos<\/p>/);
});
test('import a clashing component from the primary bookshop', async t => {
let result = await esbuild.build({
stdin: {
contents: `import file from "__bookshop_file__components/clash/clash.jekyll.html";
console.log(file);`,
resolveDir: process.cwd(),
sourcefile: 'virtual.js'
},
plugins: [
bookshopFilePlugin({
bookshopDirs: [
path.join(process.cwd(), './.test/fixtures'),
path.join(process.cwd(), './.test/second-fixtures')
]
})
],
format: 'esm',
write: false,
bundle: true
});
t.is(result.errors.length, 0);
t.is(result.warnings.length, 0);
t.regex(result.outputFiles[0].text, /<p>bookshop-a<\/p>/);
});
test('respect order of bookshopDirs', async t => {
let result = await esbuild.build({
stdin: {
contents: `import file from "__bookshop_file__components/clash/clash.jekyll.html";
console.log(file);`,
resolveDir: process.cwd(),
sourcefile: 'virtual.js'
},
plugins: [
bookshopFilePlugin({
bookshopDirs: [
path.join(process.cwd(), './.test/second-fixtures'),
path.join(process.cwd(), './.test/fixtures')
]
})
],
format: 'esm',
write: false,
bundle: true
});
t.is(result.errors.length, 0);
t.is(result.warnings.length, 0);
t.regex(result.outputFiles[0].text, /<p>bookshop-b<\/p>/);
});
test('import a shared file', async t => {
let result = await esbuild.build({
stdin: {
contents: `import file from "__bookshop_file__shared/jekyll/title.jekyll.html";
console.log(file);`,
resolveDir: process.cwd(),
sourcefile: 'virtual.js'
},
plugins: [
bookshopFilePlugin({
bookshopDirs: [path.join(process.cwd(), './.test/fixtures')]
})
],
format: 'esm',
write: false,
bundle: true
});
t.is(result.errors.length, 0);
t.is(result.warnings.length, 0);
t.regex(result.outputFiles[0].text, /<h1>{{ include.title }}<\/h1>/);
});

@@ -14,4 +14,3 @@ import path from 'path';

build.onResolve({ filter: /^__bookshop_glob__/ }, async (args) => {
const primaryBookshopDir = options?.bookshopDirs?.[0];
if (!primaryBookshopDir) return;
if (!options?.bookshopDirs?.length) return;
return {

@@ -21,3 +20,3 @@ path: args.path.replace(/^__bookshop_glob__/, ''),

pluginData: {
resolveDir: path.join(primaryBookshopDir)
resolveDirs: options.bookshopDirs
},

@@ -27,8 +26,14 @@ };

build.onLoad({ filter: /.*/, namespace: 'bookshop-import-glob' }, async (args) => {
const files = (await fastGlob(`components/**/*@${args.path}`, {
cwd: args.pluginData.resolveDir,
})).sort();
const globs = args.pluginData.resolveDirs.map(dir => {
return fastGlob(`@(components|shared)/**/*@${args.path}`, {
cwd: dir,
});
});
const globResults = await Promise.all(globs);
const files = [].concat.apply([], globResults).sort();
const uniqueFiles = Array.from(new Set(files));
const output = `
const files = {};
${files.map(importFile).join('\n')}
${uniqueFiles.map(importFile).join('\n')}

@@ -35,0 +40,0 @@ export default files;

@@ -7,8 +7,5 @@ import test from 'ava';

test('bookshopGlobPlugin should be defined', t => {
t.truthy(bookshopGlobPlugin);
});
test('import components', async t => {
let result = await esbuild.build({
let esbuildOutput = "";
test.before(async t => {
esbuildOutput = await esbuild.build({
stdin: {

@@ -21,3 +18,6 @@ contents: `import files from "__bookshop_glob__(.jekyll.html)";`,

bookshopGlobPlugin({
bookshopDirs: [path.join(process.cwd(), './.test/fixtures')]
bookshopDirs: [
path.join(process.cwd(), './.test/fixtures'),
path.join(process.cwd(), './.test/second-fixtures')
]
}),

@@ -30,11 +30,42 @@ stubExternalPlugin("skip-bookshop-files", /^__bookshop_file__/)

});
});
test('bookshopGlobPlugin should be defined', t => {
t.truthy(bookshopGlobPlugin);
});
test('build without warnings or errors', async t => {
t.is(esbuildOutput.errors.length, 0);
t.is(esbuildOutput.warnings.length, 0);
});
test('import a component to the files object', async t => {
let m = /import file0 from "__bookshop_file__components\/card\/card\.jekyll\.html";/;
t.regex(esbuildOutput.outputFiles[0].text, m);
t.is(result.errors.length, 0);
t.is(result.warnings.length, 0);
m = /files\["components\/card\/card\.jekyll\.html"\] = file0;/;
t.regex(esbuildOutput.outputFiles[0].text, m);
});
test('import a component from a secondary bookshop', async t => {
let m = /import file\d from "__bookshop_file__components\/dos\/dos\.jekyll\.html";/;
t.regex(esbuildOutput.outputFiles[0].text, m);
let m = /import file0 from "__bookshop_file__components\/card\/card.jekyll.html";/;
t.regex(result.outputFiles[0].text, m);
m = /files\["components\/dos\/dos\.jekyll\.html"\] = file\d;/;
t.regex(esbuildOutput.outputFiles[0].text, m);
});
test('Reference clashed components only once', async t => {
let m = /__bookshop_file__components\/clash\/clash\.jekyll\.html/g;
t.deepEqual(esbuildOutput.outputFiles[0].text.match(m), [
"__bookshop_file__components/clash/clash.jekyll.html"
], "don't reference duplicate files twice");
});
test('import a file from the shared directory', async t => {
let m = /import file\d from "__bookshop_file__shared\/jekyll\/title\.jekyll\.html";/;
t.regex(esbuildOutput.outputFiles[0].text, m);
m = /files\["components\/card\/card.jekyll.html"\] = file0;/;
t.regex(result.outputFiles[0].text, m);
m = /files\["shared\/jekyll\/title\.jekyll\.html"\] = file\d;/;
t.regex(esbuildOutput.outputFiles[0].text, m);
});

@@ -41,3 +41,6 @@ import test from 'ava';

},
bookshopDirs: [path.join(process.cwd(), './.test/fixtures')]
bookshopDirs: [
path.join(process.cwd(), './.test/fixtures'),
path.join(process.cwd(), './.test/second-fixtures')
]
});

@@ -47,3 +50,3 @@ t.is(result.errors.length, 0);

t.is(result.outputFiles[0].text, `// bookshop-styles-import:_
var __default = "p {\\n color: palegoldenrod;\\n}";
var __default = "p {\\n color: palegoldenrod;\\n}\\n\\np {\\n color: coral;\\n}\\n\\np {\\n color: chocolate;\\n}\\n\\np {\\n color: darksalmon;\\n}";

@@ -50,0 +53,0 @@ // .test/fixtures/virtual.js

{
"name": "@bookshop/builder",
"version": "2.0.0-beta.8",
"version": "2.0.0-beta.9",
"description": "esbuild wrapper for bringing bookshop components and engines throught to a frontend",

@@ -16,3 +16,3 @@ "type": "module",

"devDependencies": {
"@bookshop/jekyll-engine": "2.0.0-beta.8",
"@bookshop/jekyll-engine": "2.0.0-beta.9",
"ava": "^3.15.0",

@@ -22,3 +22,3 @@ "nyc": "^15.1.0"

"dependencies": {
"@bookshop/styles": "2.0.0-beta.8",
"@bookshop/styles": "2.0.0-beta.9",
"esbuild": "^0.12.17"

@@ -25,0 +25,0 @@ },

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