chromatic
Version:
Automate visual testing across browsers. Gather UI feedback. Versioned documentation.
20 lines (17 loc) • 4.2 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]="9c72421e-3eb7-5145-af4b-c7f543a0d0e3")}catch(e){}}();
const e=require(`./chunk-gGpyby2o.cjs`),t=require(`./meow-CSiqYQZC.cjs`),n=require(`./build-lRyJHy8j.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.
--overwrite Overwrite existing output directory if it exists.
`,{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.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,a,o,s,c){let d=[];for(let f of e)if(u(`Building for ${l[f]}`),f===`android`){let e=i.default.join(a,`storybook.apk`);if(!o&&(0,r.existsSync)(e))throw Error(`Output file ${e} already exists. Use --overwrite to overwrite existing files.`);let t=await n.t(e,s,c);d.push({platform:`Android`,path:e,duration:t})}else if(f===`ios`){let e=i.default.join(a,`storybook.app`);if(!o&&(0,r.existsSync)(e))throw Error(`Output file ${e} already exists. Use --overwrite to overwrite existing files.`);let c=await n.n(t,e,s);d.push({platform:`iOS`,path:e,duration:c})}return d}async function y(e){let{requestedPlatforms:t,outputDir:s,overwrite:c}=h(e),{androidBuildArchitectures:l}=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 y;try{u(`Reading configuration from Expo`,`npx expo config --json`),y=await n.i()}catch(e){p(e.message),process.exit(1)}let b=_(y,t),x=!s,S=s??(0,r.mkdtempSync)(i.default.join(a.default.tmpdir(),`chromatic-rn-build-`));s&&(0,r.mkdirSync)(s,{recursive:!0});let C=i.default.join(S,`chromatic-react-native-build-${Date.now()}.log`),w=await n.o(C),T;try{T=await v(b,y.name,S,c,w,l),await new Promise(e=>w.end(e))}catch(e){await new Promise(e=>w.end(e)),p(e.message),x?(0,r.rmSync)(S,{recursive:!0,force:!0}):u(`Build failed, see log for details`,C),process.exit(1)}console.log(o.default.bold.green(`✔ `)+o.default.bold(`Build Complete`)),d(`Log File`,C);for(let e of T)d(`${e.platform} (${m(e.duration)})`,e.path)}exports.main=y;
//# sourceMappingURL=reactNativeBuild-CfCP94wU.cjs.map
//# debugId=9c72421e-3eb7-5145-af4b-c7f543a0d0e3