chromatic
Version:
Automate visual testing across browsers. Gather UI feedback. Versioned documentation.
19 lines (16 loc) • 4.01 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]="809000db-2edc-583d-85df-56734644629a")}catch(e){}}();
const e=require(`./chunk-gGpyby2o.cjs`),t=require(`./icons-BshdA1Sq.cjs`),n=require(`./getConfiguration-BsibAQbp.cjs`),r=require(`./meowImportMeta-C1QmuJuk.cjs`),i=require(`./build-DGUvSGi3.cjs`);let a=require(`fs`),o=require(`path`);o=e.a(o);let s=require(`os`);s=e.a(s);var c=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,t){console.error(c.default.bold.red(`✖ `)+c.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}=r.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:r.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 g(){return(await n.t().catch(()=>({}))).reactNative??{}}function _(e,t){if(t){let e=t.filter(e=>!l.includes(e));e.length>0&&(p(`Invalid platform ${e.map(e=>`"${e}"`).join(`, `)}.
Supported platforms: ${l.join(`, `)}`),process.exit(1))}let n=(e.platforms||[]).filter(e=>l.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,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 y(e){let{requestedPlatforms:t,outputDir:n,overwrite:r}=h(e),{androidBuildArchitectures:l}=await g(),u;try{d(`Reading configuration from Expo`,`npx expo config --json`),u=await i.i()}catch(e){p(e.message),process.exit(1)}let y=_(u,t),b=!n,x=n??(0,a.mkdtempSync)(o.default.join(s.default.tmpdir(),`chromatic-rn-build-`));n&&(0,a.mkdirSync)(n,{recursive:!0});let S=o.default.join(x,`chromatic-react-native-build-${Date.now()}.log`),C=await i.o(S),w;try{w=await v(y,u.name,x,r,C,l),await new Promise(e=>C.end(e))}catch(e){await new Promise(e=>C.end(e)),p(e.message),b?(0,a.rmSync)(x,{recursive:!0,force:!0}):d(`Build failed, see log for details`,S),process.exit(1)}console.log(c.default.bold.green(`✔ `)+c.default.bold(`Build Complete`)),f(`Log File`,S);for(let e of w)f(`${e.platform} (${m(e.duration)})`,e.path)}exports.main=y;
//# sourceMappingURL=reactNativeBuild-Eko-q-V_.cjs.map
//# debugId=809000db-2edc-583d-85df-56734644629a