@fugood/bricks-cli 2.26.0-beta.2 → 2.26.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/9663.js CHANGED
@@ -1 +1 @@
1
- export const __rspack_esm_id=9663;export const __rspack_esm_ids=[9663];export const __webpack_modules__={70604(e){e.exports=function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports},90250(e,t,r){var i=r(3634),n=r(70604),o=r(78243),s=r(5523);e.exports=function(e){return i(e)||n(e)||o(e)||s()},e.exports.__esModule=!0,e.exports.default=e.exports},69995(e,t,r){r.d(t,{H:()=>i});function i(e,t){try{var r=JSON.parse(e).error,i=r?.message??r;if("string"==typeof i&&i)return i}catch{}return e||t}},42208(e,t,r){r.d(t,{RP:()=>u});var i=r(99436),n=r(75720),o="CTOR",s="ctor@bricks.tools",l=`Co-authored-by: ${o} <${s}>`;function a(){return(a=i(function*(e){return!!(yield(0,n.sh)`cd ${e} && git config user.email`.quiet().nothrow().text()).trim()})).apply(this,arguments)}function u(e,t){return c.apply(this,arguments)}function c(){return(c=i(function*(e,t,r=[]){var i=yield function(e){return a.apply(this,arguments)}(e),n=i?[]:["-c",`user.name=${o}`,"-c",`user.email=${s}`],u=[];for(var c of t)u.push("-m",c);return i&&u.push("-m",l),[...n,"commit",...r,...u]})).apply(this,arguments)}},13376(e,t,r){r.d(t,{a:()=>a,p:()=>s});var i=r(99436),n=r(51455),o=".bricks/.last-pushed-commit";function s(e){return l.apply(this,arguments)}function l(){return(l=i(function*(e){try{return(yield(0,n.readFile)(`${e}/${o}`,"utf8")).trim()||null}catch{return null}})).apply(this,arguments)}function a(e,t){return u.apply(this,arguments)}function u(){return(u=i(function*(e,t){t&&(yield(0,n.mkdir)(`${e}/.bricks`,{recursive:!0}),yield(0,n.writeFile)(`${e}/${o}`,t))})).apply(this,arguments)}},69070(e,t,r){r.d(t,{k:()=>s,q:()=>a});var i=r(99436),n=r(26848),o=r(1708);function s(e){return l.apply(this,arguments)}function l(){return(l=i(function*(e){if(!o.stdin.isTTY)return"";var t=(0,n.createInterface)({input:o.stdin,output:o.stdout});try{return(yield t.question(`${e} `)).trim()}finally{t.close()}})).apply(this,arguments)}function a(e){return u.apply(this,arguments)}function u(){return(u=i(function*(e){return(yield s(e))==="y"})).apply(this,arguments)}},75720(e,t,r){r.d(t,{p:()=>l,sh:()=>c});var i=r(90250),n=r(99436),o=r(31421),s=r(73024),l=()=>{var e=process.argv[1];return e&&!(e.includes("$bunfs")||e.includes("~BUN"))&&(0,s.existsSync)(e)?[process.execPath,e]:[process.execPath]};class a{_cwd=void 0;_mode="default";_throw=!0;_env=void 0;_promise=null;constructor(e){this.args=e}cwd(e){return this._cwd=e,this}quiet(){return this._mode="quiet",this}nothrow(){return this._throw=!1,this}env(e){return this._env={...this._env,...e},this}text(){var e=this;return n(function*(){return"default"===e._mode&&(e._mode="text"),(yield e.run()).stdout.toString("utf8")})()}then(e,t){return this.run().then(e,t)}run(){return this._promise||(this._promise=this.exec()),this._promise}exec(){var e=this;return n(function*(){var t=i(e.args),r=t[0],n=(function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);r<t;r++)i[r]=e[r];return i})(t).slice(1);if(!r)throw Error("sh: empty command");var s="default"===e._mode?["inherit","pipe","pipe"]:"quiet"===e._mode?["ignore","pipe","pipe"]:["inherit","pipe","pipe"],l=e._env?{...process.env,...e._env}:void 0,a=(0,o.spawn)(r,n,{cwd:e._cwd,stdio:s,env:l}),u=[],c=[];a.stdout?.on("data",t=>{u.push(t),"default"===e._mode&&process.stdout.write(t)}),a.stderr?.on("data",t=>{c.push(t),"default"===e._mode&&process.stderr.write(t)});var d=yield new Promise((e,t)=>{a.on("error",t),a.on("close",t=>e(t??0))}),p=Buffer.concat(u),h=Buffer.concat(c);if(0!==d&&e._throw){var f=Error(`sh: command failed with exit ${d}: ${e.args.join(" ")}`);throw f.exitCode=d,f.stdout=p,f.stderr=h,f}return{exitCode:d,stdout:p,stderr:h}})()}}var u=/\s/;function c(e,...t){var r,i,n,o,s,l=(r=[],i="",n=!1,o=()=>{n&&(r.push(i),i="",n=!1)},s=e=>{i+=e,n=!0},(e.forEach((e,r)=>{for(var i=0;i<e.length;i++){var n=e[i];u.test(n)?o():s(n)}r<t.length&&(e=>{if(null!=e){if(Array.isArray(e))return e.forEach((e,t)=>{t>0&&o(),s(String(e))});s(String(e))}})(t[r])}),o(),r.length>=3&&"cd"===r[0]&&"&&"===r[2])?{tokens:r.slice(3),initialCwd:r[1]}:{tokens:r}),d=l.tokens,p=l.initialCwd,h=new a(d);return p&&h.cwd(p),h}},47090(e,t,r){r.r(t),r.d(t,{pull:()=>y});var i=r(99436),n=r(51455),o=r(73024),s=r(76760),l=r(75720),a=r(69995),u=r(42208),c=r(13376),d=r(69070),p=["subspaces","automation-tests"];function h(e,t){return f.apply(this,arguments)}function f(){return(f=i(function*(e,t){if(!(0,o.existsSync)(e))return[];var r,l=[],a=yield(0,n.readdir)(e,{withFileTypes:!0});return yield Promise.all(a.map((r=i(function*(r){var i=(0,s.join)(e,r.name);r.isDirectory()?l.push(...yield h(i,t)):r.isFile()&&r.name.endsWith(".ts")&&l.push((0,s.relative)(t,i))}),function(e){return r.apply(this,arguments)}))),l})).apply(this,arguments)}function y(){return m.apply(this,arguments)}function m(){return(m=i(function*(e={}){var t,o,f=process.cwd(),y=!!e.force,m=0===(yield(0,l.sh)`cd ${f} && git status`.nothrow()).exitCode;if(m){if(yield(0,l.sh)`cd ${f} && git diff --name-only --diff-filter=ACMR`.text())if(y){console.log("Force mode: committing unstaged changes before pull..."),yield(0,l.sh)`cd ${f} && git add .`;var g=yield(0,u.RP)(f,["chore(force-pull): saved unstaged changes before pull"]);yield(0,l.sh)`cd ${f} && git ${g}`}else throw Error("Unstaged changes found, please commit or stash your changes before pulling")}else if(!(yield(0,d.q)("No git repository found, so it will not be safe to pull, continue? (y/n)")))throw Error("Pull cancelled");var $=JSON.parse((yield(0,n.readFile)(`${f}/application.json`,"utf8"))),v="module"===$.type,_=v?"module":"app";console.log(`Pulling ${_} project (${$.id})...`);var w=yield(0,l.sh)`bricks ${_} project-pull ${$.id} --json`.quiet().nothrow();if(0!==w.exitCode){var x=w.stderr.toString()||w.stdout.toString();throw Error((0,a.H)(x,"Pull failed"))}var b=JSON.parse(w.stdout.toString()),C=b.files,S=b.lastCommitId,k=(yield(0,c.p)(f))||S,P=v?"BRICKS_PROJECT_try-pull-module":"BRICKS_PROJECT_try-pull-application",j="";if(m&&!y){if(!(j=(yield(0,l.sh)`cd ${f} && git branch --show-current`.text()).trim()))throw Error("Cannot pull from a detached HEAD");console.log(`Checking commit ${k}...`);var E=(yield(0,l.sh)`cd ${f} && git rev-list -1 ${k}`.nothrow().text()).trim().match(/^[\da-f]{40}$/);if((yield(0,l.sh)`cd ${f} && git rev-parse HEAD`.text()).trim()===S)throw Error("Commit not changed");yield(0,l.sh)`cd ${f} && git branch -D ${P}`.nothrow(),E?yield(0,l.sh)`cd ${f} && git checkout -b ${P} ${k}`.nothrow():yield(0,l.sh)`cd ${f} && git checkout -b ${P}`}var R=yield(0,n.readFile)(`${f}/.oxfmtrc.json`,"utf8").then(JSON.parse).catch(()=>({trailingComma:"all",tabWidth:2,semi:!1,singleQuote:!0,printWidth:100})),A=new Set(C.map(e=>e.name)),q=[];yield Promise.all(p.map((t=i(function*(e){for(var t of yield h((0,s.join)(f,e),f)){var r=t.split(/[\\/]/).join("/");A.has(r)||q.push(r)}}),function(e){return t.apply(this,arguments)}))),yield Promise.all(q.map(e=>(0,n.unlink)(`${f}/${e}`)));var F=(yield r.e(7456).then(r.bind(r,79491))).format;if(yield Promise.all(C.map((o=i(function*(e){var t=e.input;e.formatable&&(t=(yield F(e.name,e.input,R)).code);var r=(0,s.join)(f,e.name);return yield(0,n.mkdir)((0,s.dirname)(r),{recursive:!0}),(0,n.writeFile)(r,t)}),function(e){return o.apply(this,arguments)}))),m){if(yield(0,l.sh)`cd ${f} && git add .`,(yield(0,l.sh)`cd ${f} && git diff --cached --name-only`.text()).trim()){var B=y?`chore(force-pull): apply force pull-${_}`:v?"chore(project): apply file changes from BRICKS module":"chore(project): apply file changes from BRICKS application",O=yield(0,u.RP)(f,[B]);yield(0,l.sh)`cd ${f} && git ${O}`}if(!y){if(yield(0,l.sh)`cd ${f} && git checkout ${j}`,0!==(yield(0,l.sh)`cd ${f} && git merge ${P} --no-edit`.nothrow()).exitCode){yield(0,l.sh)`cd ${f} && git add .`;var D=yield(0,u.RP)(f,[`chore(project): merge with conflicts (resolve in ${j})`],["--no-verify"]);yield(0,l.sh)`cd ${f} && git ${D}`}yield(0,l.sh)`cd ${f} && git branch -D ${P}`.nothrow()}var I=(yield(0,l.sh)`cd ${f} && git rev-parse HEAD`.nothrow().text()).trim();I&&(yield(0,c.a)(f,I))}console.log(`${v?"Module":"App"} project pulled: ${C.length} files${q.length?`, removed ${q.length} orphan .ts file${1===q.length?"":"s"}`:""}${y?" (force)":""}`)})).apply(this,arguments)}}};
1
+ export const __rspack_esm_id=9663;export const __rspack_esm_ids=[9663];export const __webpack_modules__={5018(t){t.exports=function(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")},t.exports.__esModule=!0,t.exports.default=t.exports},44668(t,e,r){var i=r(56347);function o(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,i(o.key),o)}}t.exports=function(t,e,r){return e&&o(t.prototype,e),r&&o(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t},t.exports.__esModule=!0,t.exports.default=t.exports},70604(t){t.exports=function(t){if("u">typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)},t.exports.__esModule=!0,t.exports.default=t.exports},90250(t,e,r){var i=r(3634),o=r(70604),n=r(78243),s=r(5523);t.exports=function(t){return i(t)||o(t)||n(t)||s()},t.exports.__esModule=!0,t.exports.default=t.exports},23878(t,e,r){var i=r(14319).default;t.exports=function(t,e){if("object"!=i(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||"default");if("object"!=i(o))return o;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports},56347(t,e,r){var i=r(14319).default,o=r(23878);t.exports=function(t){var e=o(t,"string");return"symbol"==i(e)?e:e+""},t.exports.__esModule=!0,t.exports.default=t.exports},14319(t){function e(r){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},69995(t,e,r){r.d(e,{H:()=>i});function i(t,e){try{var r=JSON.parse(t).error,i=r?.message??r;if("string"==typeof i&&i)return i}catch{}return t||e}},42208(t,e,r){r.d(e,{RP:()=>a});var i=r(99436),o=r(75720),n="CTOR",s="ctor@bricks.tools",l=`Co-authored-by: ${n} <${s}>`;function u(){return(u=i(function*(t){return!!(yield(0,o.sh)`cd ${t} && git config user.email`.quiet().nothrow().text()).trim()})).apply(this,arguments)}function a(t,e){return c.apply(this,arguments)}function c(){return(c=i(function*(t,e,r=[]){var i=yield function(t){return u.apply(this,arguments)}(t),o=i?[]:["-c",`user.name=${n}`,"-c",`user.email=${s}`],a=[];for(var c of e)a.push("-m",c);return i&&a.push("-m",l),[...o,"commit",...r,...a]})).apply(this,arguments)}},13376(t,e,r){r.d(e,{a:()=>u,p:()=>s});var i=r(99436),o=r(51455),n=".bricks/.last-pushed-commit";function s(t){return l.apply(this,arguments)}function l(){return(l=i(function*(t){try{return(yield(0,o.readFile)(`${t}/${n}`,"utf8")).trim()||null}catch{return null}})).apply(this,arguments)}function u(t,e){return a.apply(this,arguments)}function a(){return(a=i(function*(t,e){e&&(yield(0,o.mkdir)(`${t}/.bricks`,{recursive:!0}),yield(0,o.writeFile)(`${t}/${n}`,e))})).apply(this,arguments)}},69070(t,e,r){r.d(e,{k:()=>s,q:()=>u});var i=r(99436),o=r(26848),n=r(1708);function s(t){return l.apply(this,arguments)}function l(){return(l=i(function*(t){if(!n.stdin.isTTY)return"";var e=(0,o.createInterface)({input:n.stdin,output:n.stdout});try{return(yield e.question(`${t} `)).trim()}finally{e.close()}})).apply(this,arguments)}function u(t){return a.apply(this,arguments)}function a(){return(a=i(function*(t){return(yield s(t))==="y"})).apply(this,arguments)}},75720(t,e,r){r.d(e,{p:()=>d,sh:()=>f});var i,o,n=r(90250),s=r(99436),l=r(5018),u=r(44668),a=r(31421),c=r(73024),d=()=>{var t=process.argv[1];return t&&!(t.includes("$bunfs")||t.includes("~BUN"))&&(0,c.existsSync)(t)?[process.execPath,t]:[process.execPath]},p=u(function t(e){l(this,t),this._cwd=void 0,this._mode="default",this._throw=!0,this._env=void 0,this._promise=null,this.args=e},[{key:"cwd",value:function(t){return this._cwd=t,this}},{key:"quiet",value:function(){return this._mode="quiet",this}},{key:"nothrow",value:function(){return this._throw=!1,this}},{key:"env",value:function(t){return this._env={...this._env,...t},this}},{key:"text",value:(i=s(function*(){return"default"===this._mode&&(this._mode="text"),(yield this.run()).stdout.toString("utf8")}),function(){return i.apply(this,arguments)})},{key:"then",value:function(t,e){return this.run().then(t,e)}},{key:"run",value:function(){return this._promise||(this._promise=this.exec()),this._promise}},{key:"exec",value:(o=s(function*(){var t=n(this.args),e=t[0],r=(function(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i})(t).slice(1);if(!e)throw Error("sh: empty command");var i="default"===this._mode?["inherit","pipe","pipe"]:"quiet"===this._mode?["ignore","pipe","pipe"]:["inherit","pipe","pipe"],o=this._env?{...process.env,...this._env}:void 0,s=(0,a.spawn)(e,r,{cwd:this._cwd,stdio:i,env:o}),l=[],u=[];s.stdout?.on("data",t=>{l.push(t),"default"===this._mode&&process.stdout.write(t)}),s.stderr?.on("data",t=>{u.push(t),"default"===this._mode&&process.stderr.write(t)});var c=yield new Promise((t,e)=>{s.on("error",e),s.on("close",e=>t(e??0))}),d=Buffer.concat(l),p=Buffer.concat(u);if(0!==c&&this._throw){var h=Error(`sh: command failed with exit ${c}: ${this.args.join(" ")}`);throw h.exitCode=c,h.stdout=d,h.stderr=p,h}return{exitCode:c,stdout:d,stderr:p}}),function(){return o.apply(this,arguments)})}]),h=/\s/;function f(t,...e){var r,i,o,n,s,l=(r=[],i="",o=!1,n=()=>{o&&(r.push(i),i="",o=!1)},s=t=>{i+=t,o=!0},(t.forEach((t,r)=>{for(var i=0;i<t.length;i++){var o=t[i];h.test(o)?n():s(o)}r<e.length&&(t=>{if(null!=t){if(Array.isArray(t))return t.forEach((t,e)=>{e>0&&n(),s(String(t))});s(String(t))}})(e[r])}),n(),r.length>=3&&"cd"===r[0]&&"&&"===r[2])?{tokens:r.slice(3),initialCwd:r[1]}:{tokens:r}),u=l.tokens,a=l.initialCwd,c=new p(u);return a&&c.cwd(a),c}},47090(t,e,r){r.r(e),r.d(e,{pull:()=>y});var i=r(99436),o=r(51455),n=r(73024),s=r(76760),l=r(75720),u=r(69995),a=r(42208),c=r(13376),d=r(69070),p=["subspaces","automation-tests"];function h(t,e){return f.apply(this,arguments)}function f(){return(f=i(function*(t,e){if(!(0,n.existsSync)(t))return[];var r,l=[],u=yield(0,o.readdir)(t,{withFileTypes:!0});return yield Promise.all(u.map((r=i(function*(r){var i=(0,s.join)(t,r.name);r.isDirectory()?l.push(...yield h(i,e)):r.isFile()&&r.name.endsWith(".ts")&&l.push((0,s.relative)(e,i))}),function(t){return r.apply(this,arguments)}))),l})).apply(this,arguments)}function y(){return m.apply(this,arguments)}function m(){return(m=i(function*(t={}){var e,n,f=process.cwd(),y=!!t.force,m=0===(yield(0,l.sh)`cd ${f} && git status`.nothrow()).exitCode;if(m){if(yield(0,l.sh)`cd ${f} && git diff --name-only --diff-filter=ACMR`.text())if(y){console.log("Force mode: committing unstaged changes before pull..."),yield(0,l.sh)`cd ${f} && git add .`;var v=yield(0,a.RP)(f,["chore(force-pull): saved unstaged changes before pull"]);yield(0,l.sh)`cd ${f} && git ${v}`}else throw Error("Unstaged changes found, please commit or stash your changes before pulling")}else if(!(yield(0,d.q)("No git repository found, so it will not be safe to pull, continue? (y/n)")))throw Error("Pull cancelled");var g=JSON.parse((yield(0,o.readFile)(`${f}/application.json`,"utf8"))),$="module"===g.type,x=$?"module":"app";console.log(`Pulling ${x} project (${g.id})...`);var _=yield(0,l.sh)`bricks ${x} project-pull ${g.id} --json`.quiet().nothrow();if(0!==_.exitCode){var w=_.stderr.toString()||_.stdout.toString();throw Error((0,u.H)(w,"Pull failed"))}var b=JSON.parse(_.stdout.toString()),k=b.files,S=b.lastCommitId,C=(yield(0,c.p)(f))||S,P=$?"BRICKS_PROJECT_try-pull-module":"BRICKS_PROJECT_try-pull-application",j="";if(m&&!y){if(!(j=(yield(0,l.sh)`cd ${f} && git branch --show-current`.text()).trim()))throw Error("Cannot pull from a detached HEAD");console.log(`Checking commit ${C}...`);var E=(yield(0,l.sh)`cd ${f} && git rev-list -1 ${C}`.nothrow().text()).trim().match(/^[\da-f]{40}$/);if((yield(0,l.sh)`cd ${f} && git rev-parse HEAD`.text()).trim()===S)throw Error("Commit not changed");yield(0,l.sh)`cd ${f} && git branch -D ${P}`.nothrow(),E?yield(0,l.sh)`cd ${f} && git checkout -b ${P} ${C}`.nothrow():yield(0,l.sh)`cd ${f} && git checkout -b ${P}`}var R=yield(0,o.readFile)(`${f}/.oxfmtrc.json`,"utf8").then(JSON.parse).catch(()=>({trailingComma:"all",tabWidth:2,semi:!1,singleQuote:!0,printWidth:100})),M=new Set(k.map(t=>t.name)),A=[];yield Promise.all(p.map((e=i(function*(t){for(var e of yield h((0,s.join)(f,t),f)){var r=e.split(/[\\/]/).join("/");M.has(r)||A.push(r)}}),function(t){return e.apply(this,arguments)}))),yield Promise.all(A.map(t=>(0,o.unlink)(`${f}/${t}`)));var O=(yield r.e(7456).then(r.bind(r,79491))).format;if(yield Promise.all(k.map((n=i(function*(t){var e=t.input;t.formatable&&(e=(yield O(t.name,t.input,R)).code);var r=(0,s.join)(f,t.name);return yield(0,o.mkdir)((0,s.dirname)(r),{recursive:!0}),(0,o.writeFile)(r,e)}),function(t){return n.apply(this,arguments)}))),m){if(yield(0,l.sh)`cd ${f} && git add .`,(yield(0,l.sh)`cd ${f} && git diff --cached --name-only`.text()).trim()){var q=y?`chore(force-pull): apply force pull-${x}`:$?"chore(project): apply file changes from BRICKS module":"chore(project): apply file changes from BRICKS application",F=yield(0,a.RP)(f,[q]);yield(0,l.sh)`cd ${f} && git ${F}`}if(!y){if(yield(0,l.sh)`cd ${f} && git checkout ${j}`,0!==(yield(0,l.sh)`cd ${f} && git merge ${P} --no-edit`.nothrow()).exitCode){yield(0,l.sh)`cd ${f} && git add .`;var T=yield(0,a.RP)(f,[`chore(project): merge with conflicts (resolve in ${j})`],["--no-verify"]);yield(0,l.sh)`cd ${f} && git ${T}`}yield(0,l.sh)`cd ${f} && git branch -D ${P}`.nothrow()}var B=(yield(0,l.sh)`cd ${f} && git rev-parse HEAD`.nothrow().text()).trim();B&&(yield(0,c.a)(f,B))}console.log(`${$?"Module":"App"} project pulled: ${k.length} files${A.length?`, removed ${A.length} orphan .ts file${1===A.length?"":"s"}`:""}${y?" (force)":""}`)})).apply(this,arguments)}}};