Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More โ†’
Socket
Sign inDemoInstall
Socket

@storybook/bench

Package Overview
Dependencies
Maintainers
29
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@storybook/bench - npm Package Compare versions

Comparing version 1.0.0--canary.12.3afe824.0 to 1.0.0--canary.12.7cccdee.0

16

dist/bench.cjs.development.js

@@ -41,2 +41,3 @@ 'use strict';

const server = new Hapi.Server({
host: 'localhost',
port: STATS_PORT

@@ -73,2 +74,3 @@ });

const server = new Hapi.Server({
host: 'localhost',
port: STATIC_STORYBOOK_PORT

@@ -171,4 +173,6 @@ });

let resolve;
const promise = new Promise(res => {
resolve = res;
const promise = new Promise((res, rej) => {
resolve = res; // if the preview doesn't load in 40s, something is wrong
setTimeout(rej, 40000);
});

@@ -192,3 +196,3 @@ const stats = resetStats();

const page = await browser.newPage();
await page.goto(`http://127.0.0.1:${STATIC_STORYBOOK_PORT}/index.html`);
await page.goto(`http://localhost:${STATIC_STORYBOOK_PORT}/index.html`);
await promise;

@@ -225,3 +229,3 @@ const build = {

const installAddonBench = async () => {
let commandArgs = ['add', '@storybook/addon-bench', '--dev'];
let commandArgs = ['add', '@storybook/addon-bench@0.0.3-canary.4.cc1f164.0', '--dev'];

@@ -309,3 +313,5 @@ if (isUsingYarn1()) {

const child = crossSpawn.spawn('yarn', ['storybook', '-p', DEV_PORT.toString(), '--ci', ...extraFlags], {
stdio: 'pipe'
// For some reason, storybook dev server hangs on my dev machine (and Norbert's) if we capture
// stderr, so just let it go through & only capture stdout for usage below
stdio: ['inherit', 'pipe', 'inherit']
});

@@ -312,0 +318,0 @@ let managerWebpack = -1;

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

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("jsonexport")),a=e(require("commander")),r=e(require("fs")),o=require("exectimer"),i=require("cross-spawn"),s=e(require("du")),n=e(require("fs-extra")),l=e(require("path")),c=e(require("rimraf")),m=require("playwright"),d=e(require("@hapi/hapi")),w=e(require("@hapi/inert")),u=require("@google-cloud/bigquery"),p=e(require("lodash/mapValues"));require("pretty-bytes");const g=["managerRender","previewRender"],b=["--no-sandbox","--disable-setuid-sandbox"],y=()=>(new Date).getTime(),h=e=>{const t=e||{init:y(),time:{}};return t.init=y(),g.forEach(e=>t.time[e]=null),t},v=async(e,t)=>{const a=new d.Server({port:9898});return g.forEach(r=>{var o;a.route({method:"GET",path:"/"+(o=r),handler:async(a,r)=>(console.log("HANDLER: "+o,e),e.time[o]||(e.time[o]=1e6*(y()-e.init)),"previewRender"===o&&t(),r.response("ok").code(200))})}),await a.start(),a},f=/<script.*?src="(.[^"]*\.js)">/g,k=console,S=e=>Array.from(e.matchAll(f)).map(e=>e[1]),j=async(e,t,a,r)=>{let o=a.find(e=>e.startsWith(t)),i=r.find(e=>e.startsWith(t));if("vendors"===t&&(i=i||r.find(e=>!e.startsWith("main")&&!e.startsWith("runtime")),o=o||a.find(e=>!e.startsWith("main")&&!e.startsWith("runtime"))),o||"main"!==t||(o=a.find(e=>e.startsWith("/assets/iframe"))),await n.pathExists(l.join(e,"sb-manager"))&&(i="sb-manager"),!i)throw new Error(`Missing manager files for '${t}')}`);return{manager:await s(l.join(e,i)),preview:o?await s(l.join(e,o)):0}},z=async e=>{try{return await s(e)}catch{return 0}},_=/(addons.*\:.*\[)/g,x=/^.\s+(\d*\.?\d*) s for manager and (\d*\.?\d*) s for preview/gm,D=/^.\s+(\d*\.?\d*) s for preview/gm,R=console,q=JSON.parse(process.env.GCP_CREDENTIALS||"{}"),E="true"===process.env.SB_BENCH_UPLOAD,{CIRCLE_BRANCH:P,CIRCLE_SHA1:C}=process.env,F=e=>{const t=i.sync("git",e,{stdio:"pipe"});if(t.error)throw t.error;return t.output.join("\n").trim()},W=(e,t)=>"object"==typeof e?p(e,e=>W(e,t)):t(e),T=e=>Math.round(e/1e6),A=e=>Math.round(e/1024);exports.main=async()=>{a.arguments("[installCommand]"),a.option("-l, --label <label>","Save as <label>.csv/json and upload with <label> if SB_BENCH_UPLOAD is true","bench"),a.option("-e, --extra-flags <flags>",'Run storybook with extra flags (e.g. "--no-dll")',""),a.option("--no-install","Do not measure storybook install time"),a.option("--no-start","Do not measure storybook start time"),a.option("--no-browse","Do not measure storybook browse time"),a.parse(process.argv),a.install&&!a.args.length&&a.help();const{label:e,extraFlags:g,install:y,start:f,browse:M}=a,B=a.args[0],N=g.length>0?g.split(" "):[],H=await(async({installCommand:e,label:a,extraFlags:u,benchmarks:g})=>{await(async()=>{c.sync("storybook-static")})();const y=(f={install:g.install?await(async e=>{if(console.log("measuring install"),!e)return console.warn("No install command provided"),{size:{total:0},time:{total:0}};const t=await s("node_modules");o.Tick.wrap((function(t){const[a,...r]=e.split(" ");i.sync(a,r,{stdio:"inherit"}),t()}));const a=await s("node_modules");return await(async()=>{let e=["add","@storybook/addon-bench","--dev"];(()=>{const e=i.sync("yarn",["--version"]);if(0!==e.status)throw new Error("๐Ÿงถ Yarn must be installed to run '@storybook/bench'");const t=e.output.toString().replace(/,/g,"").replace(/"/g,"");return/^1\.+/.test(t)})()&&e.push("-W"),i.sync("yarn",e,{stdio:"inherit"});const t=r.readFileSync(".storybook/main.js").toString();if(!t.includes("@storybook/addon-bench")){const e=(e=>e.split("\n").map(e=>e.replace(_,'$1 "@storybook/addon-bench",')).join("\n"))(t);r.writeFileSync(".storybook/main.js",e)}})(),{size:{total:a-t},time:{total:o.timers.install.duration()}}})(e):{},start:g.start?await(async e=>{let t;console.log("measuring start-storybook");const a=new Promise(e=>{t=e});let r;const o=new Promise(e=>{r=e}),s=h(),n=i.spawn("yarn",["storybook","-p",9999..toString(),"--ci",...e],{stdio:"pipe"});let l,c=-1,d=-1;n.stdout.on("data",e=>{const a=e.toString();let r=x.exec(a);r&&(console.log({match:r}),c=1e9*parseFloat(r[1]),d=1e9*parseFloat(r[2]),t()),r=D.exec(a),r&&(console.log({match:r}),c=0,d=1e9*parseFloat(r[1]),t())}),n.on("exit",()=>{R.log("closing start-storybook"),r()});const w=await m.chromium.launch({args:b});l=await v(s,async()=>{R.log("killing start-storybook"),n.kill(),R.log("stopping stats server"),await l.stop(),R.log("closing browser"),await w.close()}),await a;const u=await w.newPage();return await u.goto("http://localhost:9999/"),await o,{time:{managerWebpack:c,previewWebpack:d,...s.time},size:{}}})(u):{},...g.browse?await(async e=>{let t;console.log("measuring build-storybook"),o.Tick.wrap((function(t){i.sync("yarn",["build-storybook",...e],{stdio:"inherit"}),t()}));const a=new Promise(e=>{t=e}),r=h(),c=await m.chromium.launch({args:b}),u=await(async()=>{const e=new d.Server({port:9899});return await e.register(w),e.route({method:"GET",path:"/{param*}",handler:async(e,t)=>{const a=l.join(process.cwd(),"storybook-static",e.path);return t.file(a,{confine:!1})}}),await e.start(),console.log("Static server:",e.info.uri),e})();let p;p=await v(r,async()=>{k.log("resolving browse"),t(),k.log("stopping stats server"),await p.stop(),k.log("stopping static server"),await u.stop(),k.log("closing browser"),await c.close()});const g=await c.newPage();await g.goto("http://127.0.0.1:9899/index.html"),await a;const y={time:{build:o.timers.build.duration()},size:{}},f=await(async e=>{const t=S((await n.readFile(l.join(e,"iframe.html"))).toString()),a=S((await n.readFile(l.join(e,"index.html"))).toString()),[r,o,i,s,c]=await Promise.all([j(e,"main",t,a),j(e,"runtime",t,a),j(e,"vendors",t,a),z(l.join(e,"sb_dll","storybook_docs_dll.js")),z(l.join(e,"sb_dll","storybook_ui_dll.js"))]);return{manager:{total:r.manager+o.manager+i.manager,main:r.manager,runtime:o.manager,vendors:i.manager,uiDll:c},preview:{total:r.preview+o.preview+i.preview,main:r.preview,runtime:o.preview,vendors:i.preview,docsDll:s}}})("storybook-static");return{build:y,browse:{size:{total:await s("storybook-static"),...f},time:r.time}}})(u):{build:{},browse:{}}},p(f,e=>({time:W(e.time,T),size:W(e.size,A)})));var f;return await(async(e,a)=>{const o=await t(e);r.writeFileSync(a+".csv",o),r.writeFileSync(a+".json",JSON.stringify(e))})(y,a),y})({installCommand:B,label:e,extraFlags:N,benchmarks:{install:y,start:f,browse:M}});E&&await(async({install:e,start:t,build:a,browse:r},o)=>{console.log("uploading to label",o);const i={branch:P||F(["rev-parse","--abbrev-ref","HEAD"]),commit:C||F(["rev-parse","HEAD"]),timestamp:(new Date).toISOString(),label:o,installTime:e.time.total,installSize:e.size.total,startManagerBuild:t.time.managerWebpack,startPreviewBuild:t.time.previewWebpack,startManagerRender:t.time.managerRender,startPreviewRender:t.time.previewRender,buildTime:a.time.build,browseManagerRender:r.time.managerRender,browsePreviewRender:r.time.previewRender,browseSizeTotal:r.size.total,browseSizeManagerTotal:r.size.manager.total,browseSizeManagerVendors:r.size.manager.vendors,browseSizeManagerUiDll:r.size.manager.uiDll,browseSizePreviewTotal:r.size.preview.total,browseSizePreviewVendors:r.size.preview.vendors,browseSizePreviewDocsDll:r.size.preview.docsDll},s=new u.BigQuery({projectId:q.project_id,credentials:q}).dataset("benchmark_results").table("bench");await s.insert([i])})(H,e)};
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("jsonexport")),a=e(require("commander")),r=e(require("fs")),o=require("exectimer"),i=require("cross-spawn"),s=e(require("du")),n=e(require("fs-extra")),l=e(require("path")),c=e(require("rimraf")),m=require("playwright"),d=e(require("@hapi/hapi")),w=e(require("@hapi/inert")),u=require("@google-cloud/bigquery"),p=e(require("lodash/mapValues"));require("pretty-bytes");const g=["managerRender","previewRender"],b=["--no-sandbox","--disable-setuid-sandbox"],h=()=>(new Date).getTime(),y=e=>{const t=e||{init:h(),time:{}};return t.init=h(),g.forEach(e=>t.time[e]=null),t},v=async(e,t)=>{const a=new d.Server({host:"localhost",port:9898});return g.forEach(r=>{var o;a.route({method:"GET",path:"/"+(o=r),handler:async(a,r)=>(console.log("HANDLER: "+o,e),e.time[o]||(e.time[o]=1e6*(h()-e.init)),"previewRender"===o&&t(),r.response("ok").code(200))})}),await a.start(),a},f=/<script.*?src="(.[^"]*\.js)">/g,k=console,S=e=>Array.from(e.matchAll(f)).map(e=>e[1]),j=async(e,t,a,r)=>{let o=a.find(e=>e.startsWith(t)),i=r.find(e=>e.startsWith(t));if("vendors"===t&&(i=i||r.find(e=>!e.startsWith("main")&&!e.startsWith("runtime")),o=o||a.find(e=>!e.startsWith("main")&&!e.startsWith("runtime"))),o||"main"!==t||(o=a.find(e=>e.startsWith("/assets/iframe"))),await n.pathExists(l.join(e,"sb-manager"))&&(i="sb-manager"),!i)throw new Error(`Missing manager files for '${t}')}`);return{manager:await s(l.join(e,i)),preview:o?await s(l.join(e,o)):0}},z=async e=>{try{return await s(e)}catch{return 0}},_=/(addons.*\:.*\[)/g,x=/^.\s+(\d*\.?\d*) s for manager and (\d*\.?\d*) s for preview/gm,D=/^.\s+(\d*\.?\d*) s for preview/gm,R=console,q=JSON.parse(process.env.GCP_CREDENTIALS||"{}"),E="true"===process.env.SB_BENCH_UPLOAD,{CIRCLE_BRANCH:P,CIRCLE_SHA1:C}=process.env,F=e=>{const t=i.sync("git",e,{stdio:"pipe"});if(t.error)throw t.error;return t.output.join("\n").trim()},T=(e,t)=>"object"==typeof e?p(e,e=>T(e,t)):t(e),W=e=>Math.round(e/1e6),A=e=>Math.round(e/1024);exports.main=async()=>{a.arguments("[installCommand]"),a.option("-l, --label <label>","Save as <label>.csv/json and upload with <label> if SB_BENCH_UPLOAD is true","bench"),a.option("-e, --extra-flags <flags>",'Run storybook with extra flags (e.g. "--no-dll")',""),a.option("--no-install","Do not measure storybook install time"),a.option("--no-start","Do not measure storybook start time"),a.option("--no-browse","Do not measure storybook browse time"),a.parse(process.argv),a.install&&!a.args.length&&a.help();const{label:e,extraFlags:g,install:h,start:f,browse:M}=a,B=a.args[0],N=g.length>0?g.split(" "):[],H=await(async({installCommand:e,label:a,extraFlags:u,benchmarks:g})=>{await(async()=>{c.sync("storybook-static")})();const h=(f={install:g.install?await(async e=>{if(console.log("measuring install"),!e)return console.warn("No install command provided"),{size:{total:0},time:{total:0}};const t=await s("node_modules");o.Tick.wrap((function(t){const[a,...r]=e.split(" ");i.sync(a,r,{stdio:"inherit"}),t()}));const a=await s("node_modules");return await(async()=>{let e=["add","@storybook/addon-bench@0.0.3-canary.4.cc1f164.0","--dev"];(()=>{const e=i.sync("yarn",["--version"]);if(0!==e.status)throw new Error("๐Ÿงถ Yarn must be installed to run '@storybook/bench'");const t=e.output.toString().replace(/,/g,"").replace(/"/g,"");return/^1\.+/.test(t)})()&&e.push("-W"),i.sync("yarn",e,{stdio:"inherit"});const t=r.readFileSync(".storybook/main.js").toString();if(!t.includes("@storybook/addon-bench")){const e=(e=>e.split("\n").map(e=>e.replace(_,'$1 "@storybook/addon-bench",')).join("\n"))(t);r.writeFileSync(".storybook/main.js",e)}})(),{size:{total:a-t},time:{total:o.timers.install.duration()}}})(e):{},start:g.start?await(async e=>{let t;console.log("measuring start-storybook");const a=new Promise(e=>{t=e});let r;const o=new Promise(e=>{r=e}),s=y(),n=i.spawn("yarn",["storybook","-p",9999..toString(),"--ci",...e],{stdio:["inherit","pipe","inherit"]});let l,c=-1,d=-1;n.stdout.on("data",e=>{const a=e.toString();let r=x.exec(a);r&&(console.log({match:r}),c=1e9*parseFloat(r[1]),d=1e9*parseFloat(r[2]),t()),r=D.exec(a),r&&(console.log({match:r}),c=0,d=1e9*parseFloat(r[1]),t())}),n.on("exit",()=>{R.log("closing start-storybook"),r()});const w=await m.chromium.launch({args:b});l=await v(s,async()=>{R.log("killing start-storybook"),n.kill(),R.log("stopping stats server"),await l.stop(),R.log("closing browser"),await w.close()}),await a;const u=await w.newPage();return await u.goto("http://localhost:9999/"),await o,{time:{managerWebpack:c,previewWebpack:d,...s.time},size:{}}})(u):{},...g.browse?await(async e=>{let t;console.log("measuring build-storybook"),o.Tick.wrap((function(t){i.sync("yarn",["build-storybook",...e],{stdio:"inherit"}),t()}));const a=new Promise((e,a)=>{t=e,setTimeout(a,4e4)}),r=y(),c=await m.chromium.launch({args:b}),u=await(async()=>{const e=new d.Server({host:"localhost",port:9899});return await e.register(w),e.route({method:"GET",path:"/{param*}",handler:async(e,t)=>{const a=l.join(process.cwd(),"storybook-static",e.path);return t.file(a,{confine:!1})}}),await e.start(),console.log("Static server:",e.info.uri),e})();let p;p=await v(r,async()=>{k.log("resolving browse"),t(),k.log("stopping stats server"),await p.stop(),k.log("stopping static server"),await u.stop(),k.log("closing browser"),await c.close()});const g=await c.newPage();await g.goto("http://localhost:9899/index.html"),await a;const h={time:{build:o.timers.build.duration()},size:{}},f=await(async e=>{const t=S((await n.readFile(l.join(e,"iframe.html"))).toString()),a=S((await n.readFile(l.join(e,"index.html"))).toString()),[r,o,i,s,c]=await Promise.all([j(e,"main",t,a),j(e,"runtime",t,a),j(e,"vendors",t,a),z(l.join(e,"sb_dll","storybook_docs_dll.js")),z(l.join(e,"sb_dll","storybook_ui_dll.js"))]);return{manager:{total:r.manager+o.manager+i.manager,main:r.manager,runtime:o.manager,vendors:i.manager,uiDll:c},preview:{total:r.preview+o.preview+i.preview,main:r.preview,runtime:o.preview,vendors:i.preview,docsDll:s}}})("storybook-static");return{build:h,browse:{size:{total:await s("storybook-static"),...f},time:r.time}}})(u):{build:{},browse:{}}},p(f,e=>({time:T(e.time,W),size:T(e.size,A)})));var f;return await(async(e,a)=>{const o=await t(e);r.writeFileSync(a+".csv",o),r.writeFileSync(a+".json",JSON.stringify(e))})(h,a),h})({installCommand:B,label:e,extraFlags:N,benchmarks:{install:h,start:f,browse:M}});E&&await(async({install:e,start:t,build:a,browse:r},o)=>{console.log("uploading to label",o);const i={branch:P||F(["rev-parse","--abbrev-ref","HEAD"]),commit:C||F(["rev-parse","HEAD"]),timestamp:(new Date).toISOString(),label:o,installTime:e.time.total,installSize:e.size.total,startManagerBuild:t.time.managerWebpack,startPreviewBuild:t.time.previewWebpack,startManagerRender:t.time.managerRender,startPreviewRender:t.time.previewRender,buildTime:a.time.build,browseManagerRender:r.time.managerRender,browsePreviewRender:r.time.previewRender,browseSizeTotal:r.size.total,browseSizeManagerTotal:r.size.manager.total,browseSizeManagerVendors:r.size.manager.vendors,browseSizeManagerUiDll:r.size.manager.uiDll,browseSizePreviewTotal:r.size.preview.total,browseSizePreviewVendors:r.size.preview.vendors,browseSizePreviewDocsDll:r.size.preview.docsDll},s=new u.BigQuery({projectId:q.project_id,credentials:q}).dataset("benchmark_results").table("bench");await s.insert([i])})(H,e)};
//# sourceMappingURL=bench.cjs.production.min.js.map
{
"name": "@storybook/bench",
"version": "1.0.0--canary.12.3afe824.0",
"version": "1.0.0--canary.12.7cccdee.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "author": "Michael Shilman",

Sorry, the diff of this file is not supported yet

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