UNPKG

41.3 kBJavaScriptView Raw
1module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="dist",r(r.s=42)}([function(t,e){t.exports=require("@babel/runtime/regenerator")},function(t,e){t.exports=require("@babel/runtime/helpers/asyncToGenerator")},function(t,e){t.exports=require("@babel/runtime/helpers/toConsumableArray")},function(t,e){t.exports=require("debug")},function(t,e){t.exports=require("@babel/runtime/helpers/classCallCheck")},function(t,e){t.exports=require("path")},function(t,e){t.exports=require("@babel/runtime/helpers/possibleConstructorReturn")},function(t,e){t.exports=require("@babel/runtime/helpers/getPrototypeOf")},function(t,e){t.exports=require("@babel/runtime/helpers/inherits")},function(t,e){t.exports=require("url")},function(t,e){t.exports=require("@babel/runtime/helpers/createClass")},function(t,e){t.exports=require("node-fetch")},function(t,e){t.exports=require("@babel/runtime/helpers/objectSpread")},function(t,e){t.exports=require("child_process")},function(t,e){t.exports=require("pino")},function(t,e){t.exports=require("denodeify")},function(t,e){t.exports=require("@babel/runtime/helpers/slicedToArray")},function(t,e){t.exports=require("jsonfile")},function(t){t.exports={a:"storybook-chromatic",b:"2.1.1"}},function(t,e){t.exports=require("fs")},function(t,e){t.exports=require("minimatch")},function(t,e){t.exports=require("semver")},function(t,e){t.exports=require("jsdom")},function(t,e){t.exports=require("@babel/runtime/helpers/taggedTemplateLiteral")},function(t,e){t.exports=require("fake-tag")},function(t,e){t.exports=require("node-ask")},function(t,e){t.exports=require("tree-kill")},function(t,e){t.exports=require("env-ci")},function(t,e){t.exports=require("uuid")},function(t,e){t.exports=require("tmp")},function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.d(__webpack_exports__,"a",function(){return getStorybookInfo});var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(16),_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0__),viewLayers=["react","angular","vue","polymer","mithril","marko","html","svelte","riot","ember"],require2=eval("require");function getStorybookInfo(){var t=process.env.CHROMATIC_STORYBOOK_VERSION;if(t){var e=t.split("@"),r=_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default()(e,2),n=r[0],o=r[1];if(!n||!o)throw new Error('CHROMATIC_STORYBOOK_VERSION misspecified -- use "viewLayer@version"');return{viewLayer:n,storybookVersion:o}}for(;viewLayers.length>0;){var a=viewLayers.shift();try{return{viewLayer:a,storybookVersion:require2("@storybook/".concat(a,"/package.json")).version}}catch(t){}}throw new Error("Couldn't discover storybook version. Try upgrading the storybook-chromatic package?")}},function(t,e){t.exports=require("https")},function(t,e){t.exports=require("@chromaui/localtunnel")},function(t,e){t.exports=require("async-retry")},function(t,e,r){const n=r(14),o=r(40).default;t.exports={__esModule:!0,default:{...n.stdSerializers,err:o}}},function(t,e){t.exports=require("node-loggly-bulk")},function(t,e){t.exports=require("util")},function(t,e){t.exports=require("strip-color")},function(t,e){t.exports=require("progress-stream")},function(t,e){t.exports=require("progress")},function(t,e,r){const n=r(14),o=r(41).default;t.exports={__esModule:!0,default:t=>{const{envPairs:e,...r}=n.stdSerializers.err(t);return{...r,...t.response&&{response:o(t.response)}}}}},function(t,e){t.exports={__esModule:!0,default:function({status:t,statusText:e,headers:r,url:n,_raw:o}){return{status:t,statusText:e,headers:r,url:n,_raw:o.toString()}}}},function(t,e,r){"use strict";r.r(e);var n=r(12),o=r.n(n),a=r(2),i=r.n(a),c=r(0),s=r.n(c),u=r(1),p=r.n(u),l=r(15),f=r.n(l),m=r(25),d=r(3),h=r.n(d),b=r(26),v=r.n(b),y=r(27),w=r.n(y),g=r(28),x=r(9),_=r(20),k=r.n(_),C=r(29),E=r(21),O=r(6),T=r.n(O),S=r(7),R=r.n(S),A=r(8),I=r.n(A),P=r(4),B=r.n(P),U=r(10),j=r.n(U),N=r(22);function L(t){Object.defineProperty(t.window,"matchMedia",{value:function(){return{matches:!0,addListener:function(){},removeListener:function(){}}},writable:!0});var e=function(){function t(){B()(this,t),this.store={}}return j()(t,[{key:"getItem",value:function(t){return this.store[t]}},{key:"removeItem",value:function(t){delete this.store[t]}},{key:"setItem",value:function(t,e){this.store[t]=e.toString()}},{key:"clear",value:function(){this.store={}}}]),t}();Object.defineProperty(t.window,"localStorage",{value:new e,writable:!0});var r=function(){function t(){B()(this,t)}return j()(t,[{key:"addEventListener",value:function(){}},{key:"removeEventLister",value:function(){}},{key:"postMessage",value:function(){}},{key:"terminate",value:function(){}}]),t}();function n(){}Object.defineProperty(t.window,"Worker",{value:r,writable:!0}),Object.defineProperty(t.window,"crypto",{value:{getRandomValues:function(){return 0}},writable:!0}),Object.defineProperty(t.window.navigator,"mimeTypes",{value:function(){return[]},writable:!0}),Object.defineProperty(t.window.URL,"createObjectURL",{value:function(){}}),Object.defineProperty(t.window.URL,"revokeObjectURL",{value:function(){}}),n.prototype={observe:function(){return[]},takeRecords:function(){return[]},disconnect:function(){}},Object.defineProperty(t.window,"MutationObserver",{value:n,writable:!0});var o=function(){function t(){B()(this,t)}return j()(t,[{key:"resolvedOptions",value:function(){return{}}}],[{key:"supportedLocalesOf",value:function(){return[]}}]),t}(),a=function(t){function e(){return B()(this,e),T()(this,R()(e).apply(this,arguments))}return I()(e,t),j()(e,[{key:"format",value:function(){return""}},{key:"formatToParts",value:function(){return[]}}]),e}(o),i=function(t){function e(){return B()(this,e),T()(this,R()(e).apply(this,arguments))}return I()(e,t),j()(e,[{key:"compare",value:function(){return 0}}]),e}(o),c=function(t){function e(){return B()(this,e),T()(this,R()(e).apply(this,arguments))}return I()(e,t),j()(e,[{key:"select",value:function(){return""}}]),e}(o),s=function(t){function e(){return B()(this,e),T()(this,R()(e).apply(this,arguments))}return I()(e,t),e}(a),u=function(t){function e(){return B()(this,e),T()(this,R()(e).apply(this,arguments))}return I()(e,t),e}(a),p=function(t){function e(){return B()(this,e),T()(this,R()(e).apply(this,arguments))}return I()(e,t),e}(a),l=function(t){function e(){return B()(this,e),T()(this,R()(e).apply(this,arguments))}return I()(e,t),e}(a);Object.defineProperty(t.window,"Intl",{value:{Collator:i,DateTimeFormat:s,ListFormat:u,NumberFormat:p,PluralRules:c,RelativeTimeFormat:l},writable:!0});var f,m={};Object.defineProperty(t.window,"customElements",{value:{define:function(t,e){m[t]=m[t]||{resolvers:[]},m[t].constructor=e,m[t].resolvers.forEach(function(t){return t()})},get:function(t){return m[t]&&m[t].constructor},upgrade:function(){},whenDefined:function(t){return new Promise(function(e){m[t]=m[t]||{resolvers:[]},m[t].constructor?e():m[t].resolvers.push(e)})}},writable:!1}),(f=t.window).HTMLCanvasElement.prototype.getContext=function(){return{fillRect:function(){return{}},clearRect:function(){return{}},getImageData:function(t,e,r,n){return{data:new Array(r*n*4)}},putImageData:function(){return{}},createImageData:function(){return[]},setTransform:function(){return{}},drawImage:function(){return{}},save:function(){return{}},fillText:function(){return{}},restore:function(){return{}},beginPath:function(){return{}},moveTo:function(){return{}},lineTo:function(){return{}},closePath:function(){return{}},stroke:function(){return{}},translate:function(){return{}},scale:function(){return{}},rotate:function(){return{}},arc:function(){return{}},fill:function(){return{}},measureText:function(){return{width:0}},transform:function(){return{}},rect:function(){return{}},clip:function(){return{}}}},f.HTMLCanvasElement.prototype.toDataURL=function(){return""}}function q(t){return D.apply(this,arguments)}function D(){return(D=p()(s.a.mark(function t(e){var r,n,o,a,i,c,u,p,l,f=arguments;return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=f.length>1&&void 0!==f[1]?f[1]:{},n=r.verbose,o=void 0!==n&&n,a=r.names,i=a.product,c=a.packageName,u=[],p=new N.VirtualConsole,Object.keys(console).forEach(function(t){p.on(t,function(e){return u.push({logType:t,log:e})})}),p.on("jsdomError",function(t){return u.push({logType:"error",log:t})}),o&&p.sendTo(console),t.next=8,N.JSDOM.fromURL(e,{userAgent:"Chromatic",runScripts:"dangerously",resources:"usable",virtualConsole:p,pretendToBeVisual:!0});case 8:return L(l=t.sent),t.abrupt("return",new Promise(function(t,r){return l.window.document.addEventListener("DOMContentLoaded",function(){try{var n="=========================";if(!l.window.__chromaticRuntimeSpecs__)throw console.error("Didn't find ".concat(i," addon in your storybook.\n \nDid you add it with `import '").concat(c,"'` in your `.storybook/config.js`?\n\nRead more: http://docs.chromaticqa.com")),!o&&u.length&&(console.error("Your app's output:\n".concat(n,"\n")),u.forEach(function(t){var e=t.logType,r=t.log;return console[e](r)}),console.error("\n".concat(n,"\n"))),new Error("Didn't find 'window.__chromaticRuntimeSpecs__' at ".concat(e,"."));u.find(function(t){return"error"===t.logType})&&(console.error("\nYour app logged the following to the error console:\n".concat(n)),u.filter(function(t){return"error"===t.logType}).forEach(function(t){var e=t.logType,r=t.log;return console[e](r)}),console.error("\n".concat(n,"\nThis may lead to some stories not working right or getting detected by Chromatic")+"\nWe suggest you fix the errors, but we will continue anyway..\n"));var a=l.window.__chromaticRuntimeSpecs__();l.window.close(),t(a)}catch(t){l.window.close(),r(t)}})}));case 11:case"end":return t.stop()}},t,this)}))).apply(this,arguments)}var M=r(30),V=r(13),H=r(31),W=r.n(H),G=r(11),$=r.n(G),Q=r(5),F=r.n(Q),Y=1e3,z=3e5,K=new W.a.Agent({rejectUnauthorized:!1});function J(t){return X.apply(this,arguments)}function X(){return(X=p()(s.a.mark(function t(e){return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,$()(e,{agent:e.startsWith("https:")?K:void 0});case 3:return t.abrupt("return",!0);case 6:return t.prev=6,t.t0=t.catch(0),t.abrupt("return",!1);case 9:case"end":return t.stop()}},t,this,[[0,6]])}))).apply(this,arguments)}function Z(t,e){return tt.apply(this,arguments)}function tt(){return(tt=p()(s.a.mark(function t(e,r){var n;return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=Date.now()+z,t.abrupt("return",new Promise(function(t,o){var a=!1;function i(){return c.apply(this,arguments)}function c(){return(c=p()(s.a.mark(function e(){return s.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(Date.now()>n)){e.next=4;break}return a=!0,o(new Error("No server responding at ".concat(r," within ").concat(z/1e3," seconds."))),e.abrupt("return");case 4:return e.next=6,J(r);case 6:if(!e.sent){e.next=10;break}return a=!0,t(),e.abrupt("return");case 10:setTimeout(i,Y);case 11:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}if(i(),e){var u="";e.stderr.on("data",function(t){u+=t.toString()}),e.stdout.on("data",function(t){u+=t.toString()}),e.on("close",function(){a||o(new Error("Script failed to start: ".concat(u,"\n")))})}}));case 2:case"end":return t.stop()}},t,this)}))).apply(this,arguments)}function et(t){return rt.apply(this,arguments)}function rt(){return(rt=p()(s.a.mark(function t(e){var r,n,a,c,u,p,l,f,m,d,h,b;return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.scriptName,n=e.commandName,a=e.args,c=void 0===a?[]:a,u=e.url,p=e.inheritStdio,l=void 0!==p&&p,f=o()({},process.env,{NODE_ENV:"development",BROWSER:"none"}),!r){t.next=13;break}return t.next=5,J(u);case 5:if(!t.sent){t.next=7;break}return t.abrupt("return",null);case 7:d=process.env.npm_execpath,h="string"==typeof d&&/\.m?js/.test(F.a.extname(d)),b=h?process.execPath:d||"npm",m=Object(V.spawn)(b,[].concat(i()(h?[d]:[]),["run",r],i()(c)),o()({env:f},l&&{stdio:"inherit"})),t.next=16;break;case 13:if(n){t.next=15;break}throw new Error("You must pass commandName or scriptName");case 15:m=Object(V.spawn)(n,{env:f,shell:!0});case 16:if(!u){t.next=19;break}return t.next=19,Z(m,u);case 19:return t.abrupt("return",m);case 20:case"end":return t.stop()}},t,this)}))).apply(this,arguments)}var nt=r(32),ot=r.n(nt),at=h()("storybook-chromatic:tester:tunnel");function it(t){return ct.apply(this,arguments)}function ct(){return(ct=p()(s.a.mark(function t(e){var r,n,o,a;return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.tunnelUrl,n=e.port,o=e.https,n){t.next=3;break}throw new Error("Need to pass a port into `openTunnel`");case 3:return t.next=5,f()(ot.a)(n,{local_host:"localhost",host:r,https:!!o,cert:o&&o.cert,key:o&&o.key,ca:o&&o.ca});case 5:return(a=t.sent).on("url",function(t){return at("Got tunnel url: %s",t)}),a.on("request",function(t){return at("Got request: %O",t)}),a.tunnel_cluster.on("error",function(t){return at("Got tunnel cluster error: %O",t)}),t.abrupt("return",a);case 10:case"end":return t.stop()}},t,this)}))).apply(this,arguments)}var st=r(17);function ut(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.command,r=t.appDir,n=void 0===r?process.cwd():r,o=Object(st.readFileSync)(F.a.resolve(n,"./package.json"));return Object.values(o.scripts||{}).find(function(t){return t.match(e)})}function pt(t,e){var r=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).appDir,n=void 0===r?process.cwd():r,o=F.a.resolve(n,"./package.json"),a=Object(st.readFileSync)(o);if(a[t])throw new Error("Script named '".concat(t,"' already exists in package.json"));a.scripts||(a.scripts={}),a.scripts[t]=e,Object(st.writeFileSync)(o,a,{spaces:2})}var lt=r(14),ft=r.n(lt),mt=r(33),dt=r.n(mt),ht=r(34),bt=r.n(ht);class vt extends Error{constructor(t,e,...r){super(...r),Error.captureStackTrace&&Error.captureStackTrace(this,vt),this.response=t,this.message=e||`HTTPClient Failed to fetch ${t.url}, got ${t.status}/${t.statusText}`}}class yt{constructor(t={}){const{log:e=ft()({name:"HTTPClient",serializers:bt.a}),retries:r=0,headers:n={}}=t;this.log=e,this.retries=r,this.headers=n}async fetch(t,e={},{retries:r,noLogErrorBody:n=!1}={}){return dt()(async()=>{const r=await $()(t,{...e,headers:{...this.headers,...e.headers}});if(!r.ok){const t=new vt(r);if(!n){const e=await r.text();this.log.warn({body:e},t.message)}throw t}return r},{retries:void 0!==r?r:this.retries,onRetry:e=>{this.log.warn({url:t,err:e},"Retrying fetch")}})}async fetchBuffer(t,e){return(await this.fetch(t,e)).buffer()}static async fetch(t,e={},r={}){return new yt(r).fetch(t,e)}static async fetchBuffer(t,e={},r={}){return new yt(r).fetchBuffer(t,e)}}class wt{constructor({uri:t,headers:e,retries:r}){if(!t)throw new Error("Option `uri` required.");this.uri=t,this.headers=e,this.retries=r,this.client=new yt}async runQuery(t,e){const r=await this.client.fetch(this.uri,{headers:{...this.headers,"Content-Type":"application/json"},method:"post",body:JSON.stringify({query:t,variables:e})},{retries:this.retries}),{data:n,errors:o}=await r.json();if(o)throw o;return n}static async runQuery(t,e,r){return new wt(t).runQuery(e,r)}}var gt=r(16),xt=r.n(gt),_t=r(23),kt=r.n(_t),Ct=r(24),Et=r.n(Ct);function Ot(){var t=kt()(["\n query TesterHasBuildsWithCommitsQuery($commits: [String!]!) {\n app {\n hasBuildsWithCommits(commits: $commits)\n }\n }\n"]);return Ot=function(){return t},t}function Tt(){var t=kt()(["\n query TesterFirstCommittedAtQuery($branch: String!) {\n app {\n firstBuild(sortByCommittedAt: true) {\n committedAt\n }\n lastBuild(branch: $branch, sortByCommittedAt: true) {\n commit\n committedAt\n }\n }\n }\n"]);return Tt=function(){return t},t}var St=h()("storybook-chromatic:tester:git");function Rt(t){return At.apply(this,arguments)}function At(){return(At=p()(s.a.mark(function t(e){var r,n;return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.abrupt("return",Object(V.execSync)("".concat(e," 2>&1")).toString().trim());case 4:if(t.prev=4,t.t0=t.catch(0),r=t.t0.message,!(n=void 0===r?"":r).match("Not a git repository")){t.next=9;break}throw new Error("Unable to execute git command '".concat(e,"'.\n\nChromatic only works in git projects.\nContact us at support@hichroma.com if you need to use Chromatic outside of one.\n"));case 9:if(!n.match("does not have any commits yet")){t.next=11;break}throw new Error("Unable to execute git command '".concat(e,"'.\n\nChromatic requires that you have created a commit before it can be run.\n"));case 11:throw t.t0;case 12:case"end":return t.stop()}},t,this,[[0,4]])}))).apply(this,arguments)}var It=20,Pt=Et()(Tt()),Bt=Et()(Ot());function Ut(){return jt.apply(this,arguments)}function jt(){return(jt=p()(s.a.mark(function t(){var e,r,n,o,a,i;return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Rt('git log -n 1 --format="%H,%ct,%ce,%cn"');case 2:return e=t.sent.split(","),r=xt()(e,4),n=r[0],o=r[1],a=r[2],i=r[3],t.abrupt("return",{commit:n,committedAt:1e3*o,committerEmail:a,committerName:i});case 9:case"end":return t.stop()}},t,this)}))).apply(this,arguments)}function Nt(){return Lt.apply(this,arguments)}function Lt(){return(Lt=p()(s.a.mark(function t(){return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",Rt("git rev-parse --abbrev-ref HEAD"));case 1:case"end":return t.stop()}},t,this)}))).apply(this,arguments)}function qt(t){return Dt.apply(this,arguments)}function Dt(){return(Dt=p()(s.a.mark(function t(e){return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,Rt('git cat-file -e "'.concat(e,'^{commit}"'));case 3:return t.abrupt("return",!0);case 6:return t.prev=6,t.t0=t.catch(0),t.abrupt("return",!1);case 9:case"end":return t.stop()}},t,this,[[0,6]])}))).apply(this,arguments)}function Mt(t){return t.map(function(t){return t.trim()}).join(" ")}function Vt(t,e){return Ht.apply(this,arguments)}function Ht(){return(Ht=p()(s.a.mark(function t(e,r){var n,o,a,i,c;return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.firstCommittedAtSeconds,o=r.commitsWithBuilds,a=r.commitsWithoutBuilds,i="git rev-list HEAD ".concat(n?"--since ".concat(n):""," -n ").concat(e+a.length," --not ").concat(Mt(o)),St("running ".concat(i)),t.next=5,Rt(i);case 5:return t.t0=function(t){return!!t},c=t.sent.split("\n").filter(t.t0),St("command output: ".concat(c)),t.abrupt("return",c.filter(function(t){return!o.includes(t)}).filter(function(t){return!a.includes(t)}).slice(0,e));case 9:case"end":return t.stop()}},t,this)}))).apply(this,arguments)}function Wt(t){return Gt.apply(this,arguments)}function Gt(){return(Gt=p()(s.a.mark(function t(e){var r,n,o;return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(0!==e.length){t.next=2;break}return t.abrupt("return",e);case 2:return r=e.map(function(t){return'"'.concat(t,'^@"')}),n="git rev-list ".concat(Mt(e)," --not ").concat(Mt(r)),St("running ".concat(n)),t.next=7,Rt(n);case 7:return t.t0=function(t){return!!t},o=t.sent.split("\n").filter(t.t0),St("command output: ".concat(o)),t.abrupt("return",o);case 11:case"end":return t.stop()}},t,this)}))).apply(this,arguments)}function $t(t,e,r){return Qt.apply(this,arguments)}function Qt(){return(Qt=p()(s.a.mark(function t(e,r,n){var o,a,c,u,p,l,f;return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return o=n.firstCommittedAtSeconds,a=n.commitsWithBuilds,c=n.commitsWithoutBuilds,St("step: checking ".concat(r," up to ").concat(o)),St("step: commitsWithBuilds: ".concat(a)),St("step: commitsWithoutBuilds: ".concat(c)),t.next=6,Vt(r,{firstCommittedAtSeconds:o,commitsWithBuilds:a,commitsWithoutBuilds:c});case 6:if(u=t.sent,St("step: candidateCommits: ".concat(u)),0!==u.length){t.next=11;break}return St("step: no candidateCommits; we are done"),t.abrupt("return",a);case 11:return t.next=13,e.runQuery(Bt,{commits:u});case 13:return p=t.sent,l=p.app.hasBuildsWithCommits,St("step: newCommitsWithBuilds: ".concat(l)),f=u.filter(function(t){return!l.find(function(e){return e===t})}),t.abrupt("return",$t(e,2*r,{firstCommittedAtSeconds:o,commitsWithBuilds:[].concat(i()(a),i()(l)),commitsWithoutBuilds:[].concat(i()(c),i()(f))}));case 18:case"end":return t.stop()}},t,this)}))).apply(this,arguments)}function Ft(t){return Yt.apply(this,arguments)}function Yt(){return(Yt=p()(s.a.mark(function t(e){var r,n,o,a,c,u,p,l,f,m,d,h,b,v=arguments;return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=v.length>1&&void 0!==v[1]?v[1]:{},n=r.branch,o=r.ignoreLastBuildOnBranch,a=void 0!==o&&o,t.next=3,Ut();case 3:return c=t.sent,u=c.committedAt,t.next=7,e.runQuery(Pt,{branch:n});case 7:if(p=t.sent,l=p.app,f=l.firstBuild,m=l.lastBuild,St("App firstBuild: ".concat(f,", lastBuild: ").concat(m)),f){t.next=15;break}return St("App has no builds, returning []"),t.abrupt("return",[]);case 15:if(d=[],h=[],!("HEAD"!==n&&!a&&m&&m.committedAt<=u)){t.next=26;break}return t.next=20,qt(m.commit);case 20:if(!t.sent){t.next=24;break}d.push(m.commit),t.next=26;break;case 24:St("Last build commit not in index, blindly appending to baselines"),h.push(m.commit);case 26:return t.next=28,$t(e,It,{firstCommittedAtSeconds:f.committedAt&&f.committedAt/1e3,commitsWithBuilds:d,commitsWithoutBuilds:[]});case 28:return b=t.sent,St("Final commitsWithBuilds: ".concat(b)),t.t0=[],t.t1=h,t.t2=i.a,t.next=35,Wt(b);case 35:return t.t3=t.sent,t.t4=(0,t.t2)(t.t3),t.abrupt("return",t.t0.concat.call(t.t0,t.t1,t.t4));case 38:case"end":return t.stop()}},t,this)}))).apply(this,arguments)}var zt=r(18),Kt=process.env,Jt=(Kt.CHROMATIC_SERVER_PORT,Kt.CHROMATIC_INDEX_URL),Xt=void 0===Jt?"https://index.chromaticqa.com":Jt,Zt=Kt.CHROMATIC_TUNNEL_URL,te=void 0===Zt?"https://tunnel.chromaticqa.com":Zt,ee=(Kt.CHROMATIC_CREATE_TUNNEL,Kt.CHROMATIC_APP_CODE,Kt.CHROMA_APP_CODE,Kt.LOGGLY_CUSTOMER_TOKEN),re=void 0===ee?"b5e26204-cdc5-4c78-a9cc-c69eb7fabad3":ee,ne=r(35),oe=r.n(ne),ae=r(36),ie=r(37),ce=r.n(ie);function se(t){var e=t.sessionId;if(!process.env.DISABLE_LOGGING){var r=oe.a.createClient({token:re,subdomain:"hichroma",tags:["storybook-chromatic"],json:!0}),n=!!process.env.DEBUG;h.a.enable("storybook-chromatic:*,localtunnel:*"),h.a.log=function(){var t=ae.format.apply(void 0,arguments);r.log({sessionId:e,msg:ce()(t)}),n&&process.stderr.write("".concat(t,"\n"))}}}var ue=r(19),pe=r(38),le=r.n(pe),fe=r(39),me=r.n(fe),de=h()("storybook-chromatic:tester:upload"),he="\n mutation TesterGetUploadUrlsMutation($paths: [String!]!) {\n getUploadUrls(paths: $paths) {\n domain\n urls {\n path\n url\n contentType\n }\n }\n }\n";function be(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".";return Object(ue.readdirSync)(Object(Q.join)(t,e)).map(function(t){return Object(Q.join)(e,t)}).map(function(e){var r=Object(ue.statSync)(Object(Q.join)(t,e));return r.isDirectory()?be(t,e):[{pathname:e,contentLength:r.size}]}).reduce(function(t,e){return[].concat(i()(t),i()(e))},[])}function ve(t){return ye.apply(this,arguments)}function ye(){return(ye=p()(s.a.mark(function t(e){var r,n,o,a,i,c,u,l,f,m;return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.client,n=e.dirname,de("uploading '".concat(n,"' to s3")),o=be(n),t.next=5,r.runQuery(he,{paths:o.map(function(t){return t.pathname})});case 5:return a=t.sent,i=a.getUploadUrls,c=i.domain,u=i.urls,l=o.map(function(t){return t.contentLength}).reduce(function(t,e){return t+e},0),f=new me.a("uploading [:bar] :rate/bps :percent :etas",{width:20,total:l}),m=[],u.forEach(function(t){var e=t.path,r=t.url,a=t.contentType,i=Object(Q.join)(n,e);de("uploading '".concat(i,"' to '").concat(r,"' with content type '").concat(a,"'"));var c=le()();c.on("progress",function(t){var e=t.delta;return f.tick(e)});var u=o.find(function(t){return t.pathname===e}).contentLength;m.push(p()(s.a.mark(function t(){var n;return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,$()(r,{method:"PUT",body:Object(ue.createReadStream)(i).pipe(c),headers:{"content-type":a,"content-length":u}});case 2:if((n=t.sent).ok){t.next=6;break}throw de("Uploading '".concat(e,"' failed: %O"),n),new Error("Failed to upload ".concat(e));case 6:case"end":return t.stop()}},t,this)}))())}),t.next=15,Promise.all(m);case 15:return t.abrupt("return",new x.URL("/iframe.html",c).toString());case 16:case"end":return t.stop()}},t,this)}))).apply(this,arguments)}r.d(e,"default",function(){return He});var we,ge,xe=1e3,_e=[/^GERRIT/,/^TRAVIS/],ke={"--ci":"4.0.0","--loglevel":"5.1.0"},Ce="storybook-chromatic"===zt.a?{product:"Chromatic",packageName:"storybook-chromatic",script:"chromatic",command:"chromatic test",envVar:"CHROMATIC_APP_CODE",url:"https://www.chromaticqa.com"}:{product:"Chroma",packageName:"storybook-chroma",script:"chroma",command:"chroma publish",envVar:"CHROMA_APP_CODE",url:"https://www.chromaui.com"},Ee=(we=Ce.product,function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.noPrefix,n=void 0!==r&&r,o=e.level,a=void 0===o?"log":o;"true"!==process.env.DISABLE_LOGGING&&(n?console[a](t):console[a]("".concat(we,": ").concat(t)))}),Oe="\n mutation TesterCreateAppTokenMutation($appCode: String!) {\n createAppToken(code: $appCode)\n }\n",Te="\n mutation TesterCreateBuildMutation($input: CreateBuildInput!, $isolatorUrl: String!) {\n createBuild(input: $input, isolatorUrl: $isolatorUrl) {\n id\n number\n specCount\n snapshotCount\n componentCount\n webUrl\n app {\n account {\n features { \n diffs\n }\n }\n }\n }\n }\n",Se="\n mutation TesterSkipBuildMutation($appId: ObjID, $commit: String!) {\n skipBuild(appId: $appId, commit: $commit)\n }\n",Re="\n query TesterBuildQuery($buildNumber: Int!) {\n app {\n build(number: $buildNumber) {\n id\n status\n autoAcceptChanges\n inProgressCount: snapshotCount(statuses: [SNAPSHOT_IN_PROGRESS])\n snapshotCount\n changeCount\n errorCount: snapshotCount(statuses: [SNAPSHOT_CAPTURE_ERROR])\n }\n }\n }\n",Ae=h()("storybook-chromatic:tester");function Ie(t,e,r){var n=1===t?e:"".concat(e,"s");return n.endsWith("ys")&&(n=n.replace(/ys$/,"ies")),r?n:"".concat(t," ").concat(n)}function Pe(t,e,r){return Be.apply(this,arguments)}function Be(){return(Be=p()(s.a.mark(function t(e,r,n){var o,a,i,c,u,p,l,f;return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return o=n.diffs,t.next=3,e.runQuery(Re,r);case 3:if(a=t.sent,i=a.app.build,Ae("build:".concat(JSON.stringify(i))),c=i.status,u=i.inProgressCount,p=i.snapshotCount,l=i.changeCount,f=i.errorCount,"BUILD_IN_PROGRESS"!==c){t.next=12;break}return u!==ge&&(ge=u,Ee(o?"".concat(u,"/").concat(Ie(p,"snapshot")," remain to test. ")+"(".concat(Ie(l,"change"),", ").concat(Ie(f,"error"),")"):"".concat(u,"/").concat(Ie(p,"story")," remain to publish. "))),t.next=11,new Promise(function(t){return setTimeout(t,xe)});case 11:return t.abrupt("return",Pe(e,r,{diffs:o}));case 12:return t.abrupt("return",i);case 13:case"end":return t.stop()}},t,this)}))).apply(this,arguments)}function Ue(t){return je.apply(this,arguments)}function je(){return(je=p()(s.a.mark(function t(e){var r,n,o,a,i,c,u,p,l,f,m,d,h,b,v,y;return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.inputFromCI,t.next=3,Ut();case 3:return n=t.sent,o=n.commit,a=n.committedAt,i=n.committerEmail,c=n.committerName,t.next=10,Nt();case 10:if(u=t.sent,p="pull_request"===process.env.TRAVIS_EVENT_TYPE,l=process.env,f=l.TRAVIS_EVENT_TYPE,m=l.TRAVIS_PULL_REQUEST_SLUG,d=l.TRAVIS_REPO_SLUG,h=l.TRAVIS_PULL_REQUEST_SHA,b=l.TRAVIS_PULL_REQUEST_BRANCH,"pull_request"===f&&m===d&&Ee("WARNING: Running Chromatic on a Travis PR build from an internal branch.\n\nIt is recommended to run Chromatic on the push builds from Travis where possible.\nWe advise turning on push builds and disabling Chromatic for internal PR builds.\nRead more: https://docs.chromaticqa.com/setup_ci#travis\n",{noPrefix:!0,level:"warn"}),!p){t.next=19;break}if(u=b,(o=h)&&u){t.next=19;break}throw new Error("`TRAVIS_EVENT_TYPE` environment variable set to 'pull_request', \nbut `TRAVIS_PULL_REQUEST_SHA` and `TRAVIS_PULL_REQUEST_BRANCH` are not both set.\n\nRead more here: https://docs.chromaticqa.com/setup_ci#travis");case 19:return"HEAD"!==u&&u||(v=w()(),"HEAD"!==(u=v.branch)&&u||(u=process.env.HEAD||process.env.GERRIT_BRANCH||process.env.CI_BRANCH||u||"HEAD")),y=r||!!process.env.CI||!!process.env.REPOSITORY_URL,Ae("git info: ".concat(JSON.stringify({commit:o,committedAt:a,committerEmail:i,committerName:c,branch:u,isTravisPrBuild:p,fromCI:y}))),t.abrupt("return",{commit:o,committedAt:a,committerEmail:i,committerName:c,branch:u,isTravisPrBuild:p,fromCI:y});case 23:case"end":return t.stop()}},t,this)}))).apply(this,arguments)}function Ne(t){return Le.apply(this,arguments)}function Le(){return(Le=p()(s.a.mark(function t(e){var r,n,a,c,u,l,m,d,h,b,y,w,g,_,k,O,T,S,R,A,I,P,B,U,j,N,L;return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.client,n=e.dirname,a=e.noStart,c=e.buildScriptName,u=e.scriptName,l=e.commandName,m=e.https,d=e.url,h=e.createTunnel,b=e.tunnelUrl,y=e.storybookVersion,!n&&!c){t.next=20;break}if(w=n,!c){t.next=13;break}return Ee("Building your storybook"),g=Object(C.dirSync)({unsafeCleanup:!0,prefix:"".concat(Ce.script,"-")}),w=g.name,Ae("Building storybook to ".concat(w)),t.next=10,et({scriptName:c,args:["--","-o",w].concat(i()(y&&Object(E.gte)(y,ke["--loglevel"])?["--loglevel","error"]:[])),inheritStdio:!0});case 10:return _=t.sent,t.next=13,new Promise(function(t,e){_.on("error",e),_.on("close",function(r){r>0&&e(new Error("".concat(c," script exited with code ").concat(r))),t()})});case 13:return Ee("Uploading your built storybook..."),t.next=16,ve({client:r,dirname:w});case 16:return k=t.sent,Ae("uploading to s3, got ".concat(k)),Ee("Uploaded your build, verifying"),t.abrupt("return",{isolatorUrl:k});case 20:if(a){t.next=29;break}return Ee("Starting storybook"),t.next=24,et({scriptName:u,commandName:l,url:d,args:u&&y&&Object(E.gte)(y,ke["--ci"])&&["--","--ci"]});case 24:T=t.sent,O=T&&p()(s.a.mark(function t(){return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",f()(v.a)(T.pid,"SIGHUP"));case 1:case"end":return t.stop()}},t,this)})),Ee("Started storybook at ".concat(d)),t.next=35;break;case 29:if(!d){t.next=35;break}return t.next=32,J(d);case 32:if(t.sent){t.next=34;break}throw new Error("No server responding at ".concat(d," -- make sure you've started it."));case 34:Ee("Detected storybook at ".concat(d));case 35:if(S=Object(x.parse)(d,!0),R=S.port,A=S.pathname,I=S.query,P=S.hash,h){t.next=38;break}return t.abrupt("return",{cleanup:O,isolatorUrl:d});case 38:return Ee("Opening tunnel to Chromatic capture servers"),t.prev=39,t.next=42,it({tunnelUrl:b,port:R,https:m});case 42:B=t.sent,U=function(){var t=p()(s.a.mark(function t(){return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!O){t.next=3;break}return t.next=3,O();case 3:return t.next=5,B.close();case 5:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}(),Ae("Opened tunnel to ".concat(B.url)),t.next=52;break;case 47:throw t.prev=47,t.t0=t.catch(39),Ae("Got error %O",t.t0),O&&O(),t.t0;case 52:if((j=Object(x.parse)(B.cachedUrl||B.url)).pathname=A,j.query=I,j.hash=P,N=j.format(),!B.cachedUrl){t.next=63;break}return(L=Object(x.parse)(B.url,!0)).query=o()({},L.query,{path:Object(x.format)({pathname:A,query:I})}),L.hash=P,L.search=null,t.abrupt("return",{cleanup:U,isolatorUrl:L.format(),cachedUrl:N});case 63:return t.abrupt("return",{cleanup:U,isolatorUrl:N});case 64:case"end":return t.stop()}},t,this,[[39,47]])}))).apply(this,arguments)}function qe(t){return De.apply(this,arguments)}function De(){return(De=p()(s.a.mark(function t(e){var r,n,o,a,i,c,u,p;return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.only,n=e.list,o=e.isolatorUrl,a=e.verbose,i=function(){return!0},!r){t.next=8;break}if(c=r.match(/(.*):([^:]*)/)){t.next=6;break}throw new Error('--only argument must provided in the form "componentName:storyName"');case 6:Ee("Running only story '".concat(c[2],"' of component '").concat(c[1],"'")),i=function(t){var e=t.name,r=t.component.name;return k()(e,c[2])&&k()(r,c[1])};case 8:return u=function(t){return t},n&&(Ee("Listing available stories:"),u=function(t){var e=t.name,r=t.component.name;return Ee("".concat(r,":").concat(e)),t}),t.next=12,q(o,{verbose:a,names:Ce});case 12:if(t.t0=u,t.t1=i,0!==(p=t.sent.map(t.t0).filter(t.t1)).length){t.next=17;break}throw new Error("Cannot run a build with no stories. Please add some stories!");case 17:return Ee("Found ".concat(Ie(p.length,"story"))),t.abrupt("return",p);case 19:case"end":return t.stop()}},t,this)}))).apply(this,arguments)}function Me(){return Ve.apply(this,arguments)}function Ve(){return(Ve=p()(s.a.mark(function t(){var e,r;return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e={},Object.keys(process.env).forEach(function(t){_e.find(function(e){return t.match(e)})&&(e[t]=process.env[t])}),r=JSON.stringify(e),Ae("Got environment %s",r),t.abrupt("return",r);case 5:case"end":return t.stop()}},t,this)}))).apply(this,arguments)}function He(t){return We.apply(this,arguments)}function We(){return(We=p()(s.a.mark(function t(e){var r,n,a,i,c,u,p,l,f,d,h,b,v,y,w,x,_,k,C,E,O,T,S,R,A,I,P,B,U,j,N,L,q,D,V,H,W,G,$,Q,F,Y,z,K,J,X,Z,tt,et,rt,nt,ot,at,it,ct,st,lt,ft,mt,dt,ht,bt,vt,yt,gt,xt,_t,kt,Ct,Et,Ot,Tt,St,Rt,At,It;return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.appCode,n=e.buildScriptName,a=e.scriptName,i=e.exec,c=e.noStart,u=void 0!==c&&c,p=e.https,l=e.url,f=e.storybookBuildDir,d=e.only,h=e.skip,b=e.list,v=e.fromCI,y=void 0!==v&&v,w=e.autoAcceptChanges,x=void 0!==w&&w,_=e.exitZeroOnChanges,k=void 0!==_&&_,C=e.ignoreLastBuildOnBranch,E=void 0!==C&&C,O=e.preserveMissingSpecs,T=void 0!==O&&O,S=e.verbose,R=void 0!==S&&S,A=e.interactive,I=void 0===A||A,P=e.indexUrl,B=void 0===P?Xt:P,U=e.tunnelUrl,j=void 0===U?te:U,N=e.createTunnel,L=void 0===N||N,q=e.originalArgv,D=void 0!==q&&q,V=e.sessionId,se({sessionId:H=void 0===V?Object(g.v4)():V}),Ae("Creating build with session id: ".concat(H)),Ae("Connecting to index:".concat(B," and ").concat(L?"using tunnel:".concat(j):"not creating a tunnel")),W=new wt({uri:"".concat(B,"/graphql"),headers:{"x-chromatic-session-id":H},retries:3}),r){t.next=7;break}throw new Error("You must provide an app code.\n\nIf you don't have a project yet login to ".concat(Ce.url," and create a new project.\nOr find your code on the manage page of an existing project.\n\nPass your app code with the `").concat(Ce.envVar,"` environment variable or the `--app-code` flag."));case 7:return t.prev=7,t.next=10,W.runQuery(Oe,{appCode:r});case 10:G=t.sent,$=G.createAppToken,W.headers=o()({},W.headers,{Authorization:"Bearer ".concat($)}),t.next=20;break;case 15:if(t.prev=15,t.t0=t.catch(7),!(t.t0[0]&&t.t0[0].message&&t.t0[0].message.match("No app with code"))){t.next=19;break}throw new Error("Incorrect app code '".concat(r,"'.\n \nIf you don't have a project yet login to ").concat(Ce.url," and create a new project.\nOr find your code on the manage page of an existing project."));case 19:throw t.t0;case 20:return t.next=22,Ue({inputFromCI:y});case 22:if(Q=t.sent,F=Q.commit,Y=Q.committedAt,z=Q.committerEmail,K=Q.committerName,J=Q.branch,X=Q.isTravisPrBuild,Z=Q.fromCI,!h){t.next=37;break}return t.next=33,W.runQuery(Se,{commit:F});case 33:if(!t.sent){t.next=36;break}return Ee("Build skipped for commit ".concat(F,".")),t.abrupt("return",0);case 36:throw new Error("Failed to skip build.");case 37:if(n||a||i||u){t.next=39;break}throw new Error("Either buildScriptName, scriptName, commandName or noStart is required");case 39:return tt="string"==typeof x?x===J:x,et="string"==typeof k?k===J:k,rt="string"==typeof E?E===J:E,t.next=44,Ft(W,{branch:J,ignoreLastBuildOnBranch:rt});case 44:return nt=t.sent,Ae("Found baselineCommits: ".concat(nt)),ot=Object(M.a)(),at=ot.storybookVersion,it=ot.viewLayer,Ae("Detected package version:".concat(zt.b,", storybook version:").concat(at,", view layer: ").concat(it)),ct=5,t.next=51,Ne({storybookVersion:at,client:W,dirname:f,noStart:u,buildScriptName:n,scriptName:a,commandName:i,https:p,url:l,createTunnel:L,tunnelUrl:j});case 51:return st=t.sent,lt=st.cleanup,ft=st.isolatorUrl,mt=st.cachedUrl,Ae("Connecting to ".concat(ft," (cachedUrl ").concat(mt,")")),Ee("Uploading and verifying build (this may take a few minutes depending on your connection)"),t.prev=57,t.next=60,qe({only:d,list:b,isolatorUrl:ft,verbose:R});case 60:return dt=t.sent,t.next=63,Me();case 63:return ht=t.sent,t.next=66,W.runQuery(Te,{input:{cachedUrl:mt,autoAcceptChanges:tt,preserveMissingSpecs:T,branch:J,commit:F,committedAt:Y,baselineCommits:nt,runtimeSpecs:dt,fromCI:Z,isTravisPrBuild:X,packageVersion:zt.b,storybookVersion:at,viewLayer:it,committerEmail:z,committerName:K,environment:ht},isolatorUrl:ft});case 66:return bt=t.sent,vt=bt.createBuild,yt=vt.number,gt=vt.snapshotCount,xt=vt.specCount,_t=vt.componentCount,kt=vt.webUrl,Ct=vt.app.account.features.diffs,Et="View it online at ".concat(kt),Ee("Started Build ".concat(yt," ")+"(".concat(Ie(_t,"component"),", ").concat(Ie(xt,"story"),", ").concat(Ie(gt,"snapshot"),").\n\n").concat(Et,".")),t.next=78,Pe(W,{buildNumber:yt},{diffs:Ct});case 78:Ot=t.sent,Tt=Ot.status,St=Ot.autoAcceptChanges,Rt=Ot.changeCount,At=Ot.errorCount,t.t1=Tt,t.next="BUILD_PASSED"===t.t1?86:"BUILD_ACCEPTED"===t.t1?89:"BUILD_PENDING"===t.t1?89:"BUILD_DENIED"===t.t1?89:"BUILD_FAILED"===t.t1?93:"BUILD_TIMED_OUT"===t.t1?96:"BUILD_ERROR"===t.t1?96:99;break;case 86:return Ee(Ct?"Build ".concat(yt," passed! ").concat(Et,"."):"Build ".concat(yt," published! ").concat(Et,".")),ct=0,t.abrupt("break",100);case 89:return Ee("Build ".concat(yt," has ").concat(Ie(Rt,"change"),". ").concat(Et,".")),0!==(ct=et||St?0:1)&&Ee("Pass --exit-zero-on-changes if you want this command to exit successfully in this case.\n Alternatively, pass --auto-accept-changes if you want changed builds to pass on this branch.\n Read more: https://docs.chromaticqa.com/test"),t.abrupt("break",100);case 93:return Ee(Ct?"Build ".concat(yt," has ").concat(Ie(At,"error"),". ").concat(Et,"."):"Build ".concat(yt," was published but we found errors. ").concat(Et,".")),ct=2,t.abrupt("break",100);case 96:return Ee("Build ".concat(yt," has failed to run. Our apologies. Please try again.")),ct=3,t.abrupt("break",100);case 99:throw new Error("Unexpected build status: ".concat(Tt));case 100:t.next=111;break;case 102:if(t.prev=102,t.t2=t.catch(57),!(t.t2.length&&t.t2[0]&&t.t2[0].message&&t.t2[0].message.match(/Cannot run a build with no specs./))){t.next=109;break}Ee(t.t2[0].message),ct=255,t.next=111;break;case 109:throw Ae("Got error %O",t.t2),t.t2;case 111:if(t.prev=111,!lt){t.next=115;break}return t.next=115,lt();case 115:return t.finish(111);case 116:if(ut({command:Ce.command})||!D||Z||!I){t.next=122;break}return It="".concat(Ce.envVar,"=").concat(r," ").concat(Ce.command," ").concat(D.slice(2).join(" ")).replace(/--app-code[= ]\S+/,"").trim(),t.next=120,Object(m.confirm)("\nYou have not added the `".concat(Ce.script,"` script to your `package.json`. Would you like me to do it for you?"));case 120:t.sent?(pt(Ce.script,It),Ee("\nAdded script `".concat(Ce.script,"`. You can now run it here or in CI with `npm run ").concat(Ce.script,"` (or `yarn ").concat(Ce.script,"`)\n\nNOTE: I wrote your app code to the `").concat(Ce.envVar,"` environment variable. The app code cannot be used to read story data, it can only be used to create new builds. If you would still prefer not to check it into source control, you can remove it from `package.json` and set it via an environment variable instead."),{noPrefix:!0})):Ee('\nNo problem. You can add it later with:\n{\n "scripts": {\n "'.concat(Ce.script,'": "').concat(It,'"\n }\n}'),{noPrefix:!0});case 122:return t.abrupt("return",ct);case 123:case"end":return t.stop()}},t,this,[[7,15],[57,102,111,116]])}))).apply(this,arguments)}}]);
2//# sourceMappingURL=tester.js.map
\No newline at end of file