UNPKG

bruce-cli

Version:

A JS/React App automation build scaffolding with zero-configuration and out-of-the-box

1 lines 1.77 kB
var x=this&&this.__awaiter||function(e,s,t,o){return new(t||(t=Promise))((function(p,n){function d(e){try{a(o.next(e))}catch(e){n(e)}}function r(e){try{a(o.throw(e))}catch(e){n(e)}}function a(e){var s;e.done?p(e.value):(s=e.value,s instanceof t?s:new t((function(e){e(s)}))).then(d,r)}a((o=o.apply(e,s||[])).next())}))};import{execSync as We}from"node:child_process";import{exit as s}from"node:process";import no from"ora";import{AppRender as is}from"../generators/index.js";import{CreateAnswer as ge}from"../helpers/index.js";import{CREATE_TEXT as h}from"../langs/index.js";import{DEPENDENCE as Re,GetDepsVer as Xe,ShowTitle as io}from"../utils/index.js";export default function u(e){return x(this,void 0,void 0,(function*(){io("init");const{frame:t,install:o,name:p,style:n,typescript:d}=e,r=t||o||p||n||d?{appName:""===p?"unknow":p,deps:[],devdeps:[],ext:d?"ts":"js",frame:""===t?"js":t,style:""===n?"scss":n,useInstaller:o,useTs:d}:yield ge(),a=no(h.doing1).start();if(r.deps=Re[r.frame].reduce(((e,s)=>(s.disabled&&e.push(s.value),e)),r.deps).sort(),r.useTs&&(r.devdeps=["@types/node"],"react"===r.frame&&(r.deps=r.deps.filter((e=>"prop-types"!==e)),r.devdeps=[...r.devdeps,r.deps.includes("react-dom")?"@types/react-dom":""]),"ts"===r.ext&&(r.devdeps=[...r.devdeps,"@yangzw/bruce-type"]),r.devdeps=r.devdeps.filter(Boolean).sort()),is({deps:yield Xe(r.deps),devdeps:yield Xe(r.devdeps),ext:r.ext,frame:r.frame,name:r.appName,style:r.style,useTs:r.useTs}),a.stop(),r.useInstaller){const e=no(h.doing2).start();try{We(`cd ${r.appName} && yarn`),e.stop(),console.log(h.done1(r.appName))}catch(s){try{We(`cd ${r.appName} && npm i`),e.stop(),console.log(h.done1(r.appName))}catch(s){e.stop(),console.log(h.done2(r.appName))}}}else console.log(h.done2(r.appName));s(1)}))}