@fugood/bricks-cli 2.26.0-beta.2 → 2.26.0-beta.21
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/README.md +61 -4
- package/lib/1010.js +1 -1
- package/lib/1178.js +1 -1
- package/lib/1215.js +1 -1
- package/lib/1374.js +4 -0
- package/lib/1708.js +8 -8
- package/lib/2486.js +1 -1
- package/lib/2557.js +1 -1
- package/lib/2700.js +1 -0
- package/lib/3332.js +13 -0
- package/lib/3690.js +1 -1
- package/lib/3774.js +2 -2
- package/lib/3976.js +3 -3
- package/lib/4456.js +2 -2
- package/lib/4485.js +1 -0
- package/lib/4530.js +10 -10
- package/lib/{5188.js → 4642.js} +2 -2
- package/lib/5698.js +1 -0
- package/lib/6194.js +2 -2
- package/lib/6632.js +7 -0
- package/lib/6818.js +1 -1
- package/lib/{9206.js → 6842.js} +1 -1
- package/lib/6954.js +3 -3
- package/lib/7294.js +3 -3
- package/lib/7494.js +12 -3
- package/lib/7511.js +1 -1
- package/lib/907.js +350 -81
- package/lib/9320.js +23 -2
- package/lib/9387.js +5 -5
- package/lib/9439.js +2594 -0
- package/lib/9663.js +1 -1
- package/lib/devtools.js +1 -0
- package/lib/index.js +114 -101
- package/lib/lib.js +370 -92
- package/package.json +7 -6
- package/lib/1143.js +0 -1
- package/lib/563.js +0 -4
- package/lib/6645.js +0 -1
- package/lib/7109.js +0 -1
- package/lib/7233.js +0 -2546
- package/lib/7574.js +0 -1
- package/lib/7648.js +0 -1
- package/lib/7896.js +0 -13
- package/lib/9590.js +0 -7
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,r)=>t({code:e,signal:r}))}),d=c.code,p=c.signal,h=d??1,f=Buffer.concat(l),y=Buffer.concat(u);if(0!==h&&this._throw){var m=p?`signal ${p}`:`exit ${h}`,v=Error(`sh: command failed with ${m}: ${this.args.join(" ")}`);throw v.exitCode=h,v.stdout=f,v.stderr=y,v}return{exitCode:h,stdout:f,stderr:y}}),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)}}};
|
package/lib/devtools.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as e}from"node:module";let r=e(import.meta.url);var t,o,n,s,a,i,l,c={84361(e){e.exports=import("ws").then(function(e){return e})},41314(e){e.exports=r("node:dgram")},51455(e){e.exports=r("node:fs/promises")},48161(e){e.exports=r("node:os")},76760(e){e.exports=r("node:path")},66442(e){e.exports=function(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,o=Array(r);t<r;t++)o[t]=e[t];return o},e.exports.__esModule=!0,e.exports.default=e.exports},3634(e){e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},99436(e){function r(e,r,t,o,n,s,a){try{var i=e[s](a),l=i.value}catch(e){return void t(e)}i.done?r(l):Promise.resolve(l).then(o,n)}e.exports=function(e){return function(){var t=this,o=arguments;return new Promise(function(n,s){var a=e.apply(t,o);function i(e){r(a,n,s,i,l,"next",e)}function l(e){r(a,n,s,i,l,"throw",e)}i(void 0)})}},e.exports.__esModule=!0,e.exports.default=e.exports},96525(e){e.exports=function(e,r){var t=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var o,n,s,a,i=[],l=!0,c=!1;try{if(s=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;l=!1}else for(;!(l=(o=s.call(t)).done)&&(i.push(o.value),i.length!==r);l=!0);}catch(e){c=!0,n=e}finally{try{if(!l&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(c)throw n}}return i}},e.exports.__esModule=!0,e.exports.default=e.exports},5523(e){e.exports=function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},68832(e,r,t){var o=t(3634),n=t(96525),s=t(78243),a=t(5523);e.exports=function(e,r){return o(e)||n(e,r)||s(e,r)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},78243(e,r,t){var o=t(66442);e.exports=function(e,r){if(e){if("string"==typeof e)return o(e,r);var t=({}).toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?o(e,r):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},13346(e,r,t){t.a(e,async function(e,o){try{t.d(r,{TB:()=>a.verifyDevToolsServer,fl:()=>s.createCdpClient,le:()=>n.le});var n=t(38372),s=t(28193),a=t(75646),i=e([s]);s=(i.then?(await i)():i)[0],o()}catch(e){o(e)}})},28193(e,r,t){t.a(e,async function(e,o){try{t.d(r,{createCdpClient:()=>v});var n,s=t(99436),a=t(73610),i=t(84361),l=e([i]);i=(l.then?(await l)():l)[0];var c=15e3,u={[a.AB.takenOver]:"Another DevTools client took this device.",[a.AB.targetGone]:"The device stopped its DevTools server (the app restarted or went to the background). Retry the command."},d=({address:e,port:r,method:t,phase:o="request",closeCode:n,closeReason:s,local:a=!1})=>{var i=s?Buffer.isBuffer(s)?s.toString("utf8"):String(s):"",l="connect"===o?"before the CDP session opened":t?`while waiting for ${t}`:"during the CDP session",c=`${e}:${r}`,d=[];null!=n&&d.push(`code ${n}`),i&&d.push(`reason: ${i}`);var p=[a?`CDP client closed the connection to ${c} ${l}.`:`CDP connection to ${c} closed ${l}.`,d.length>0?`WebSocket close ${d.join(", ")}.`:null,a?null:u[n]??"The DevTools server currently accepts one CDP client at a time. Another DevTools window or CLI command may have replaced this session. Retry the command, close the other inspector, or avoid running DevTools commands in parallel."].filter(Boolean).join("\n"),v=Error(p);return v.code="CDP_CONNECTION_CLOSED",v.method=t,v.phase=o,v.closeCode=n,v.closeReason=i,v},p=(n=s(function*(e,r,t){var o,n=t?"string"==typeof t?{passcode:t}:t:{},s=n.passcode,a=n.accessToken;if(a)return`ws://${e}:${r}/ws?access_token=${encodeURIComponent(a)}`;if(!s)try{var i=new AbortController;o=setTimeout(()=>i.abort(),3e3);var l=yield fetch(`http://${e}:${r}/json/list`,{signal:i.signal});if(l.ok){var c=yield l.json(),u=c?.[0]?.webSocketDebuggerUrl;if(u){var d=u.match(/\/ws(?:\/.*)?$/);if(d)return`ws://${e}:${r}${d[0]}`}}}catch{}finally{void 0!==o&&clearTimeout(o)}return s?`ws://${e}:${r}/ws/${encodeURIComponent(s)}`:`ws://${e}:${r}/ws`}),function(e,r,t){return n.apply(this,arguments)}),v=(e,r,t)=>{var o,n,a=0,l=new Map,u=new Map,v=null,f=0,h=e=>{for(var r of l.values()){var t=r.reject,o=r.timer,n=r.method;clearTimeout(o),t(e(n))}l.clear()};return{connect:(o=s(function*(){var o=++f,s=yield p(e,r,t);if(o!==f)throw d({address:e,port:r,phase:"connect",local:!0});return new Promise((t,o)=>{n=new i.WebSocket(s,{handshakeTimeout:c});var a=!1;n.once("open",()=>{a=!0,v=null,t()}),n.once("error",t=>{a||o(Error(t.message||`Cannot connect to ${e}:${r}`))}),n.on("message",e=>{try{var r=JSON.parse(e.toString());if(null!=r.id&&l.has(r.id)){var t=l.get(r.id),o=t.resolve,n=t.reject,s=t.timer;clearTimeout(s),l.delete(r.id),r.error?n(Error(r.error.message)):o(r.result);return}if(r.method){var a=u.get(r.method);if(a)for(var i of a)i(r.params)}}catch{}}),n.on("close",(t,n)=>{v={closeCode:t,closeReason:n},a||o(d({address:e,port:r,phase:"connect",closeCode:t,closeReason:n})),h(o=>d({address:e,port:r,method:o,closeCode:t,closeReason:n}))})})}),function(){return o.apply(this,arguments)}),send:(t,o={},s=c)=>new Promise((i,c)=>{if(!n||n.readyState!==n.OPEN)return v?void c(d({address:e,port:r,method:t,closeCode:v.closeCode,closeReason:v.closeReason})):void c(Error(`Not connected to CDP at ${e}:${r} while sending ${t}`));var u=++a,p=setTimeout(()=>{l.delete(u),c(Error(`Timeout: ${t}`))},s);l.set(u,{resolve:i,reject:c,timer:p,method:t}),n.send(JSON.stringify({id:u,method:t,params:o}))}),on:(e,r)=>{u.has(e)||u.set(e,[]),u.get(e).push(r)},off:(e,r)=>{var t=u.get(e);if(t){var o=t.indexOf(r);o>=0&&t.splice(o,1)}},close:()=>{f++,h(t=>d({address:e,port:r,method:t,local:!0})),n&&(n.terminate(),n=null)}}};o()}catch(e){o(e)}})},38372(e,r,t){t.d(r,{le:()=>f});var o,n,s,a=t(68832),i=t(99436),l=t(51455),c=t(76760),u=t(75646),d=t(19557),p=(o=i(function*(e,r,t=3e3){return(0,d.uE)(`http://${e}:${r}/json/list`,t)}),function(e,r){return o.apply(this,arguments)}),v=(n=i(function*(e,r=1e3){for(var t=[],o=e,n=0;n<10;n++){var s=c.join(o,".bricks","devtools.json");try{var a=yield l.readFile(s,"utf8"),i=JSON.parse(a),d=yield(0,u.verifyDevToolsServer)(i.address||"localhost",i.port,r);d&&t.push({name:i.name||"BRICKS Simulator",address:i.address||"localhost",port:i.port,protocols:["cdp"],hasPasscode:!1,source:"project",projectPath:o,...d})}catch{}var p=c.dirname(o);if(p===o)break;o=p}return t}),function(e){return n.apply(this,arguments)}),f=(s=i(function*({timeout:e=3e3,verify:r=!1,udpOnly:t=!1,project:o=!0,port:n=19851,cwd:s=process.cwd(),onStatus:l}={}){var c,d=(0,u.discoverDevToolsServers)({timeout:e,idleTimeout:800}),f=t?Promise.resolve([]):(l?.("Scanning via UDP + HTTP probe..."),(0,u.httpProbeSubnet)({port:n,timeout:e})),h=o?v(s,1e3):Promise.resolve([]),m=a((yield Promise.all([d,f,h])),3),y=(e=>{var r=new Map;for(var t of e){var o=t.deviceId||`${t.address}:${t.port}`,n=r.get(o);if(!n){r.set(o,{...t,addresses:[t.address],protocols:[...t.protocols||[]]});continue}for(var s of(n.addresses.includes(t.address)||n.addresses.push(t.address),"127.0.0.1"===n.address&&"127.0.0.1"!==t.address&&(n.address=t.address),t.protocols||[]))n.protocols.includes(s)||n.protocols.push(s);for(var i of Object.entries(t)){var l=a(i,2),c=l[0],u=l[1];null!=u&&"address"!==c&&"addresses"!==c&&"protocols"!==c&&(void 0===n[c]||null===n[c])&&(n[c]=u)}}return[...r.values()]})([...m[0],...m[1],...m[2]]);if(0===y.length)return[];if(r){l?.(`Verifying ${y.length} server(s)...`);var b,g=yield Promise.all(y.map((b=i(function*(e){var r=yield(0,u.verifyDevToolsServer)(e.address,e.port);return{...e,...r||{},address:e.address,port:e.port,verified:!!r,version:r?.version||e.version}}),function(e){return b.apply(this,arguments)})));y.splice(0,y.length,...g)}return l?.("Checking chrome://inspect support..."),yield Promise.all(y.map((c=i(function*(e){var r=yield p(e.address,e.port);if(r){e.chromeInspect=!0;var t=(e=>{if(!e)return null;var r=e.match(/\/ws\/(.+)$/);return r?decodeURIComponent(r[1]):null})(r[0]?.webSocketDebuggerUrl);t&&(e.passcode=t)}}),function(e){return c.apply(this,arguments)}))),y}),function(){return s.apply(this,arguments)})},75646(e,r,t){t.d(r,{discoverDevToolsServers:()=>l,httpProbeSubnet:()=>c,verifyDevToolsServer:()=>u});var o,n,s=t(99436),a=t(19557),i="bricks-devtools",l=({timeout:e=3e3,idleTimeout:r=0}={})=>(0,a.YH)({port:19900,timeout:e,idleTimeout:r,buildQuery:()=>Buffer.from(JSON.stringify({t:"QUERY",v:"1.0",s:i,d:{id:`cli-${(0,a.BW)()}`}})),parseMessage:(e,r)=>{var t=(0,a.nl)(e,e=>e?.s===i);if(!t)return null;var o=r.address;return{key:`${o}:${t.port}`,value:{...t,address:o}}}}),c=(o=s(function*({port:e=19851,connectTimeout:r=500,concurrency:t=50,timeout:o=0}={}){var n=(0,a.r9)();if(0===n.length)return[];var i=[],l=o>0?Date.now()+o:0,c=[],d=new Set;for(var p of n){var v=p.address.split(".").slice(0,3).join(".");if(!d.has(v)){d.add(v);for(var f=1;f<255;f++)c.push(`${v}.${f}`)}}for(var h=0;h<c.length&&!(l&&Date.now()>=l);h+=t){var m=c.slice(h,h+t);yield Promise.allSettled(m.map(function(){var t=s(function*(t){var o=yield u(t,e,r);o&&i.push({...o,address:t,port:e})});return function(e){return t.apply(this,arguments)}}()))}return i}),function(){return o.apply(this,arguments)}),u=(n=s(function*(e,r,t=3e3){return(0,a.uE)(`http://${e}:${r}/devtools/info`,t)}),function(e,r){return n.apply(this,arguments)})},19557(e,r,t){t.d(r,{BW:()=>i,YH:()=>d,nl:()=>c,r9:()=>u,uE:()=>p});var o,n=t(99436),s=t(41314),a=t(48161),i=()=>Math.random().toString(36).slice(2,9),l=new Set(["ANNOUNCE","RESPONSE"]),c=(e,r)=>{var t=JSON.parse(e.toString());return r(t)&&l.has(t.t)&&t.d?.info||null},u=()=>{var e=[];for(var r of Object.values(a.networkInterfaces()))for(var t of r)if(function(){if("IPv4"!==t.family||t.internal)return 1;var r=t.address.split(".").map(Number),o=t.netmask.split(".").map(Number),n=r.map((e,r)=>(e|255&~o[r]).toString()).join(".");e.push({address:t.address,broadcast:n})}())continue;return e},d=({port:e,timeout:r=3e3,idleTimeout:t=0,buildQuery:o,parseMessage:n})=>new Promise((a,i)=>{var l=new Map,c=s.createSocket("udp4"),d=null,p=null,v=!1,f=e=>{if(!v){v=!0,clearTimeout(d),clearTimeout(p);try{c.close()}catch{}e?i(e):a([...l.values()])}};c.on("error",f),c.on("message",(e,r)=>{if(!v)try{var o=n(e,r);if(!o||l.has(o.key))return;l.set(o.key,o.value),t&&!v&&(clearTimeout(p),p=setTimeout(f,t))}catch{}});try{c.bind(()=>{if(!v)try{c.setBroadcast(!0);var t=o();for(var n of(()=>{var e=new Set(["255.255.255.255","127.0.0.1"]);for(var r of u())e.add(r.broadcast);return[...e]})())c.send(t,0,t.length,e,n);d=setTimeout(f,r)}catch(e){f(e)}})}catch(e){f(e)}}),p=(o=n(function*(e,r=3e3){var t,o=new AbortController;try{t=setTimeout(()=>o.abort(),r);var n=yield fetch(e,{signal:o.signal});if(!n.ok)return null;return yield n.json()}catch{return null}finally{void 0!==t&&clearTimeout(t),o.abort()}}),function(e){return o.apply(this,arguments)})},73610(e,r,t){t.d(r,{AB:()=>o}),Object.freeze({ready:"bricks-devtools:ready",init:"bricks-devtools:init",hello:"bricks-devtools:hello",connect:"bricks-devtools:connect",disconnect:"bricks-devtools:disconnect",close:"bricks-devtools:close",openUrl:"bricks-devtools:open-url",save:"bricks-devtools:save",copy:"bricks-devtools:copy",shortcut:"bricks-devtools:shortcut",open:"bricks-devtools:open",closed:"bricks-devtools:closed",config:"bricks-devtools:config",target:"bricks-devtools:target"});let o=Object.freeze({takenOver:4e3,targetGone:4001,signedOut:4003,noTarget:1006})}},u={};function d(e){var r=u[e];if(void 0!==r)return r.exports;var t=u[e]={exports:{}};return c[e](t,t.exports,d),t.exports}o=(t="function"==typeof Symbol)?Symbol("rspack queues"):"__rspack_queues",n=d.aE=t?Symbol("rspack exports"):"__webpack_exports__",s=t?Symbol("rspack error"):"__rspack_error",a=t?Symbol("rspack done"):"__rspack_done",i=d.zS=t?Symbol("rspack defer"):"__rspack_defer",d.zT=e=>{if(e.some(e=>{var r=u[e];return!r||!1===r[a]}))return{then:(r,t)=>Promise.all(e.map(d)).then(r,t)}},l=e=>{e&&e.d<1&&(e.d=1,e.forEach(e=>e.r--),e.forEach(e=>e.r--?e.r++:e()))},d.a=(e,r,t)=>{t&&((c=[]).d=-1);var c,u,p,v,f=new Set,h=e.exports,m=new Promise((e,r)=>{v=r,p=e});m[n]=h,m[o]=e=>{c&&e(c),f.forEach(e),m.catch(()=>{})},e.exports=m,r(e=>{u=e.map(e=>{if(null!==e&&"object"==typeof e){if(!e[o]&&e[i]){var r=d.zT(e[i]);if(!r)return e;var t=e;e={then(e,o){r.then(()=>e(t),o)}}}if(e[o])return e;if(e.then){var a=[];a.d=0,e.then(e=>{c[n]=e,l(a)},e=>{c[s]=e,l(a)});var c={};return c[i]=!1,c[o]=e=>e(a),c}}var u={};return u[o]=()=>{},u[n]=e,u});var r,t=()=>u.map(e=>{if(e[i])return e;if(e[s])throw e[s];return e[n]}),a=new Promise(e=>{(r=()=>e(t)).r=0;var n=e=>e!==c&&!f.has(e)&&(f.add(e),e&&!e.d&&(r.r++,e.push(r)));u.map(e=>e[i]||e[o](n))});return r.r?a:t()},e=>(e?v(m[s]=e):p(h),l(c),m[a]=!0)),c&&c.d<0&&(c.d=0)},d.d=(e,r)=>{for(var t in r)d.o(r,t)&&!d.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},d.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r);var p=d(13346),v=(p=await p).fl,f=p.le,h=p.TB;export{v as createCdpClient,f as scanDevToolsCore,h as verifyDevToolsServer};
|