chromatic
Version:
Automate visual testing across browsers. Gather UI feedback. Versioned documentation.
18 lines (15 loc) • 3.86 kB
JavaScript
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5ad2b0a6-607f-57e2-b242-312744b860fb")}catch(e){}}();
const e=require("./rolldown-runtime-DMt3xDJx.cjs"),t=require("./icons-Cd4LHEK-.cjs"),n=require("./meowImportMeta-ATHx7qtc.cjs"),r=require("./getConfiguration-CWNd4Fym.cjs"),i=require("./build-DVAiPD5p.cjs");let a=require("fs"),o=require("path");o=e.a(o);let s=require("os");s=e.a(s);var c=/* @__PURE__ */ e.a(t.o());const l=[`android`,`ios`],u={android:`Android`,ios:`iOS`};function d(e,t){console.log(`› `+c.default.bold(e)+(t?`
`+c.default.dim(`→ `+t):``))}function f(e,t){console.log(c.default.bold.blue(`i`)+` `+c.default.bold(e)+(t?`
`+c.default.dim(`→ `+t):``))}function p(e){let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=Math.round(e%60),i=[];return t>0&&i.push(`${t}h`),n>0&&i.push(`${n}m`),i.push(`${r}s`),i.join(` `)}function m(e){let{flags:t}=n.n(`
Usage
$ chromatic react-native-build [options]
Options
--platform Platform to build (android, ios). Can be specified multiple times. Defaults to all platforms in Expo config.
--output-dir Directory to write build artifacts and log file to.
--overwrite Overwrite existing output directory if it exists.
`,{importMeta:n.t,argv:e,description:`Build React Native Storybook for Chromatic`,flags:{platform:{type:`string`,isMultiple:!0},outputDir:{type:`string`},overwrite:{type:`boolean`,default:!1}}});return{requestedPlatforms:t.platform&&t.platform.length>0?t.platform:void 0,outputDir:t.outputDir,overwrite:t.overwrite}}async function h(){return(await r.t().catch(()=>({}))).reactNative??{}}function g(e,t){if(t){let e=t.filter(e=>!l.includes(e));if(e.length>0)throw Error(`Invalid platform ${e.map(e=>`"${e}"`).join(`, `)}.
Supported platforms: ${l.join(`, `)}`)}let n=(e.platforms||[]).filter(e=>l.includes(e));if(n.length===0)throw Error(`No supported platforms found in Expo config. Expected "android" and/or "ios" in the platforms array.`);let r=t?n.filter(e=>t.includes(e)):n;if(r.length===0)throw Error(`Requested platform ${(t||[]).map(e=>`"${e}"`).join(`, `)} not found in Expo config.
Available platforms: ${n.join(`, `)}`);return r}async function _(e,t,n,r,s,c){let l=[];for(let f of e)if(d(`Building for ${u[f]}`),f===`android`){let e=o.default.join(n,`storybook.apk`);if(!r&&(0,a.existsSync)(e))throw Error(`Output file ${e} already exists. Use --overwrite to overwrite existing files.`);let t=await i.t(e,s,c);l.push({platform:`Android`,path:e,duration:t})}else if(f===`ios`){let e=o.default.join(n,`storybook.app`);if(!r&&(0,a.existsSync)(e))throw Error(`Output file ${e} already exists. Use --overwrite to overwrite existing files.`);let c=await i.n(t,e,s);l.push({platform:`iOS`,path:e,duration:c})}return l}async function v(e){let{requestedPlatforms:t,outputDir:n,overwrite:r}=m(e),{androidBuildArchitectures:l}=await h();d(`Reading configuration from Expo`,`npx expo config --json`);let u=await i.i(),v=g(u,t),y=!n,b=n??(0,a.mkdtempSync)(o.default.join(s.default.tmpdir(),`chromatic-rn-build-`));n&&(0,a.mkdirSync)(n,{recursive:!0});let x=o.default.join(b,`chromatic-react-native-build-${Date.now()}.log`),S=await i.s(x),C;try{C=await _(v,u.name,b,r,S,l),await new Promise(e=>S.end(e))}catch(e){throw await new Promise(e=>S.end(e)),y?(0,a.rmSync)(b,{recursive:!0,force:!0}):d(`Build failed, see log for details`,x),e}console.log(c.default.bold.green(`✔ `)+c.default.bold(`Build Complete`)),f(`Log File`,x);for(let e of C)f(`${e.platform} (${p(e.duration)})`,e.path)}exports.main=v;
//# sourceMappingURL=reactNativeBuild-C0yYZzaW.cjs.map
//# debugId=5ad2b0a6-607f-57e2-b242-312744b860fb