chromatic
Version:
Automate visual testing across browsers. Gather UI feedback. Versioned documentation.
19 lines (16 loc) • 3.8 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]="1bd8f04b-a2ba-54dd-bba1-a217f265b92f")}catch(e){}}();
const e=require(`./chunk-gGpyby2o.cjs`),t=require(`./meow-Cmqsflq2.cjs`),n=require(`./build-BYxCbKPn.cjs`);let r=require(`fs`),i=require(`path`);i=e.a(i);let a=require(`os`);a=e.a(a);var o=e.a(t.u()),s=e.a(t.t());const c=[`android`,`ios`],l={android:`Android`,ios:`iOS`};function u(e,t){console.log(`› `+o.default.bold(e)+(t?`
`+o.default.dim(`→ `+t):``))}function d(e,t){console.log(o.default.bold.blue(`i`)+` `+o.default.bold(e)+(t?`
`+o.default.dim(`→ `+t):``))}function f(e,t){console.warn(o.default.bold.yellow(`⚠ `)+o.default.bold(e)+(t?`
`+o.default.dim(`→ `+t):``))}function p(e,t){console.error(o.default.bold.red(`✖ `)+o.default.bold(t||`Error`)+`
→ `+e)}function m(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 h(e){let{flags:t}=(0,s.default)(`
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.
`,{argv:e,description:`Build React Native Storybook for Chromatic`,flags:{platform:{type:`string`,isMultiple:!0},outputDir:{type:`string`}}});return{requestedPlatforms:t.platform&&t.platform.length>0?t.platform:void 0,outputDir:t.outputDir}}async function g(){return(await n.s().catch(()=>({}))).reactNative??{}}function _(e,t){if(t){let e=t.filter(e=>!c.includes(e));e.length>0&&(p(`Invalid platform ${e.map(e=>`"${e}"`).join(`, `)}.
Supported platforms: ${c.join(`, `)}`),process.exit(1))}let n=(e.platforms||[]).filter(e=>c.includes(e));n.length===0&&(p(`No supported platforms found in Expo config. Expected "android" and/or "ios" in the platforms array.`),process.exit(1));let r=t?n.filter(e=>t.includes(e)):n;return r.length===0&&(p(`Requested platform ${(t||[]).map(e=>`"${e}"`).join(`, `)} not found in Expo config.
Available platforms: ${n.join(`, `)}`),process.exit(1)),r}async function v(e,t,r,a,o){let s=[];for(let c of e)if(u(`Building for ${l[c]}`),c===`android`){let e=i.default.join(r,`storybook.apk`),t=await n.t(e,a,o);s.push({platform:`Android`,path:e,duration:t})}else if(c===`ios`){let e=i.default.join(r,`storybook.app`),o=await n.n(t,e,a);s.push({platform:`iOS`,path:e,duration:o})}return s}async function y(e){let{requestedPlatforms:t,outputDir:s}=h(e),{androidBuildArchitectures:c}=await g();f(`Chromatic React Native Build is in alpha. Use with caution.`,`Please report any issues you encounter on the Chromatic CLI GitHub repository.`);let l;try{u(`Reading configuration from Expo`,`npx expo config --json`),l=await n.i()}catch(e){p(e.message),process.exit(1)}let y=_(l,t),b=!s,x=s??(0,r.mkdtempSync)(i.default.join(a.default.tmpdir(),`chromatic-rn-build-`));s&&(0,r.mkdirSync)(s,{recursive:!0});let S=i.default.join(x,`chromatic-react-native-build-${Date.now()}.log`),C=await n.o(S),w;try{w=await v(y,l.name,x,C,c),await new Promise(e=>C.end(e))}catch(e){await new Promise(e=>C.end(e)),p(e.message),b?(0,r.rmSync)(x,{recursive:!0,force:!0}):u(`Build failed, see log for details`,S),process.exit(1)}console.log(o.default.bold.green(`✔ `)+o.default.bold(`Build Complete`)),d(`Log File`,S);for(let e of w)d(`${e.platform} (${m(e.duration)})`,e.path)}exports.main=y;
//# sourceMappingURL=reactNativeBuild-BZStPtgU.cjs.map
//# debugId=1bd8f04b-a2ba-54dd-bba1-a217f265b92f