@fugood/bricks-cli 2.25.0-beta.8 → 2.25.0-beta.81
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 +115 -28
- package/lib/1001.js +1 -0
- package/lib/1010.js +1 -0
- package/lib/1178.js +1 -0
- package/lib/1215.js +1 -0
- package/lib/1708.js +9 -0
- package/lib/1759.js +1 -0
- package/lib/1936.js +1 -0
- package/lib/1946.js +1 -0
- package/lib/2151.js +1 -0
- package/lib/2247.js +1 -0
- package/lib/2486.js +1 -0
- package/lib/2557.js +1 -0
- package/lib/3223.js +4 -0
- package/lib/3332.js +13 -0
- package/lib/3593.js +1 -0
- package/lib/3690.js +1 -0
- package/lib/3774.js +44 -0
- package/lib/3976.js +14 -0
- package/lib/4305.js +1 -0
- package/lib/4456.js +3 -0
- package/lib/4479.js +30 -0
- package/lib/4530.js +22 -0
- package/lib/4642.js +9 -0
- package/lib/4685.js +1202 -0
- package/lib/5212.js +1 -0
- package/lib/563.js +4 -0
- package/lib/5658.js +2 -0
- package/lib/6194.js +3 -0
- package/lib/6645.js +1 -0
- package/lib/6818.js +1 -0
- package/lib/7111.js +2 -0
- package/lib/7233.js +2546 -0
- package/lib/7294.js +19 -0
- package/lib/7456.js +1 -0
- package/lib/7494.js +18 -0
- package/lib/7511.js +1 -0
- package/lib/7574.js +1 -0
- package/lib/7648.js +1 -0
- package/lib/8166.js +1 -0
- package/lib/8295.js +109 -0
- package/lib/831.js +1 -0
- package/lib/853.js +1 -0
- package/lib/907.js +918 -0
- package/lib/9215.js +1 -0
- package/lib/9320.js +3 -0
- package/lib/9387.js +32 -0
- package/lib/9405.js +1 -0
- package/lib/9430.js +1 -0
- package/lib/9583.js +19 -0
- package/lib/9590.js +7 -0
- package/lib/9663.js +1 -0
- package/lib/9866.js +7 -0
- package/lib/index.js +165 -974
- package/lib/lib.js +1121 -0
- package/lib/simulator-host-bridge.cjs +1 -0
- package/lib/simulator-main.mjs +23 -0
- package/lib/simulator-preload.cjs +1 -0
- package/package.json +28 -8
- package/lib/10.js +0 -1
- package/lib/117.js +0 -2543
- package/lib/166.js +0 -1
- package/lib/178.js +0 -1
- package/lib/3.js +0 -1
- package/lib/456.js +0 -1
- package/lib/511.js +0 -1
- package/lib/587.js +0 -7
- package/lib/602.js +0 -3
- package/lib/647.js +0 -30
- package/lib/940.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const path=require("node:path"),AUTOMATION_SCREENSHOT_PROJECT_DIR=path.join(".bricks","automation_screenshots");function resolveAutomationScreenshotPath(t,e=""){let o=path.resolve(t,AUTOMATION_SCREENSHOT_PROJECT_DIR),r=String(e||AUTOMATION_SCREENSHOT_PROJECT_DIR),n=path.resolve(t,r),s=n===o||n.startsWith(`${o}${path.sep}`)?n:path.resolve(o,r);if(s!==o&&!s.startsWith(`${o}${path.sep}`))throw Error("Automation screenshot path must stay inside the project screenshot directory.");return s}function normalizeAutomationScreenshotEncoding(t){return"base64"===t?"base64":"utf8"}module.exports={AUTOMATION_SCREENSHOT_PROJECT_DIR,resolveAutomationScreenshotPath,normalizeAutomationScreenshotEncoding};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import{app as e,BrowserWindow as t,ipcMain as o}from"electron";import{mkdir as s,readdir as r,readFile as n,rm as a,writeFile as i}from"fs/promises";import{watchFile as l}from"fs";import{createServer as c}from"http";import p from"node:path";import{fileURLToPath as d}from"node:url";import{parseArgs as u}from"util";import*as w from"@toon-format/toon";import h from"./simulator-host-bridge.cjs";let{resolveAutomationScreenshotPath:m,normalizeAutomationScreenshotEncoding:g}=h;for(let e of[process.stdout,process.stderr])e.on("error",e=>{if("EPIPE"!==e.code)throw e});let{values:f}=u({args:process.argv,options:{"clear-cache":{type:"boolean"},"take-screenshot":{type:"string"},"show-menu":{type:"boolean"},"test-id":{type:"string"},"test-title-like":{type:"string"},"test-timeout":{type:"string"},"no-keep-open":{type:"boolean"},"cdp-port":{type:"string"}},strict:!0,allowPositionals:!0}),y=process.cwd(),S=p.dirname(d(import.meta.url)),b=Object.freeze({allowedInsecureHosts:[]}),v=(e={})=>{let t=e&&"object"==typeof e&&!Array.isArray(e)?e:{};return{allowedInsecureHosts:(Array.isArray(t.allowedInsecureHosts)?t.allowedInsecureHosts:b.allowedInsecureHosts).filter(e=>"string"==typeof e).map(e=>e.trim().toLowerCase()).filter(Boolean)}},C=e=>{try{let t=new URL(String(e||""));if("http:"!==t.protocol&&"ws:"!==t.protocol)return null;return t.host.toLowerCase()}catch{return null}},k=async()=>{try{return v(JSON.parse(await n(`${y}/simulator.json`,"utf8")))}catch{return v()}},I=null;try{f["take-screenshot"]&&((I=JSON.parse(f["take-screenshot"])).path||(I.path=`${y}/screenshot.jpg`),I.width||(I.width=1280),I.height||(I.height=768),I.delay||(I.delay=1e3))}catch(e){console.error("Invalid take-screenshot config",e),process.exit(1)}let J=JSON.parse(await n(`${y}/.bricks/build/application-config.json`)),O=await k(),T=e=>{console.error(e),process.exit(1)},$=Object.values(J.automation_map||{}).flatMap(e=>Object.entries(e.map||{})),j=e=>{let t=e.toLowerCase();return $.find(([,e])=>e.title?.toLowerCase().includes(t))?.[0]??null},N=()=>$.map(([e,t])=>`- ${e} (${t.title||"untitled"})`).join("\n")||"(none — the compiled automation map is empty)",L=f["test-id"]||null;if(L&&!$.some(([e])=>e===L)){let e=f["test-title-like"]?j(f["test-title-like"]):null;e||T(`No automation test with id: ${f["test-id"]}. Available tests:
|
|
2
|
+
${N()}`),L=e}!L&&f["test-title-like"]&&((L=j(f["test-title-like"]))||T(`No automation found matching title: ${f["test-title-like"]}. Available tests:
|
|
3
|
+
${N()}`));let R=f["no-keep-open"]??!1,H=parseInt(f["test-timeout"]||"",10)||9e4,P=process.env.BRICKS_STAGE||"production",E={production:"https://control.bricks.tools/applicationPreview.html",beta:"https://control-beta.bricks.tools/applicationPreview.html",development:"http://localhost:3006/dev-applicationPreview.html"}[P];E||T(`Invalid BRICKS_STAGE: ${P}`),O=v({...O,allowedInsecureHosts:[...O.allowedInsecureHosts,C(E)].filter(Boolean)});let B=async(e,t)=>{let{WebSocketServer:o}=await import("ws"),s=new Set;e.webContents.on("console-message",(e,...t)=>{let o="object"==typeof t[0]?t[0].message:t[1];if(o?.startsWith("[CDP]"))try{let e=JSON.parse(o.slice(5)),t="cdp-response"===e.type?{id:e.id,result:e.result,error:e.error}:{method:e.method,params:e.params};e.sessionId&&(t.sessionId=e.sessionId);let r=JSON.stringify(t);for(let e of s)1===e.readyState&&e.send(r)}catch{}});let r=e=>new Promise(o=>{let s=c();s.once("error",()=>{e<t+100?o(r(e+1)):o(null)}),s.listen(e,()=>s.close(()=>o(e)))}),n=await r(t);if(!n)return void console.warn(`CDP server: no available port in range ${t}-${t+99}`);let a=c((e,t)=>{if("/json/list"===e.url||"/json"===e.url){t.writeHead(200,{"Content-Type":"application/json"}),t.end(JSON.stringify([{description:"BRICKS Simulator",id:"bricks-simulator",title:"BRICKS Simulator",type:"page",url:E,webSocketDebuggerUrl:`ws://localhost:${n}/ws`}]));return}if("/json/version"===e.url){t.writeHead(200,{"Content-Type":"application/json"}),t.end(JSON.stringify({Browser:"BRICKS Simulator","Protocol-Version":"1.3"}));return}if("/devtools/info"===e.url){t.writeHead(200,{"Content-Type":"application/json"}),t.end(JSON.stringify({name:"BRICKS Simulator",port:n,protocols:["cdp"],hasPasscode:!1}));return}t.writeHead(404),t.end()});new o({server:a,path:"/ws"}).on("connection",t=>{s.add(t),e.webContents.executeJavaScript(`
|
|
4
|
+
if (!window.__cdpRelayInstalled) {
|
|
5
|
+
window.__cdpRelayInstalled = true
|
|
6
|
+
window.addEventListener('message', (evt) => {
|
|
7
|
+
try {
|
|
8
|
+
const d = typeof evt.data === 'string' ? JSON.parse(evt.data) : evt.data
|
|
9
|
+
if (d && (d.type === 'cdp-response' || d.type === 'cdp-event'))
|
|
10
|
+
console.log('[CDP]' + JSON.stringify(d))
|
|
11
|
+
} catch {}
|
|
12
|
+
})
|
|
13
|
+
}
|
|
14
|
+
`),t.on("message",t=>{try{let o=JSON.parse(t.toString()),s=JSON.stringify({type:"cdp-request",id:o.id,method:o.method,params:o.params||{},sessionId:o.sessionId});e.webContents.executeJavaScript(`window.postMessage(${JSON.stringify(s)})`)}catch{}}),t.on("close",()=>s.delete(t))}),a.listen(n,()=>{console.log(`CDP server: ws://localhost:${n}/ws`),console.log(`Inspect: devtools://devtools/bundled/inspector.html?ws=localhost:${n}/ws`)})};e.on("ready",()=>{o.handle("bricks-automation-screenshots:exists",async(e,t)=>{try{return await n(((e="")=>m(y,e))(t)),!0}catch{return!1}}),o.handle("bricks-automation-screenshots:readdir",async(e,t)=>{try{return await r(((e="")=>m(y,e))(t))}catch{return[]}}),o.handle("bricks-automation-screenshots:mkdir",async(e,t)=>{await s(((e="")=>m(y,e))(t),{recursive:!0})}),o.handle("bricks-automation-screenshots:unlink",async(e,t)=>{await a(((e="")=>m(y,e))(t),{recursive:!0,force:!0})}),o.handle("bricks-automation-screenshots:read-file",async(e,t,o)=>n(((e="")=>m(y,e))(t),g(o))),o.handle("bricks-automation-screenshots:write-file",async(e,t,o,r)=>{let n=((e="")=>m(y,e))(t);await s(p.dirname(n),{recursive:!0}),await i(n,o,g(r))});let c=!0;I&&!I.noHeadless&&(c=!1);let d=new t({width:I?.width||1280,height:I?.height||768,frame:!I,show:c,webPreferences:{preload:p.join(S,"simulator-preload.cjs"),contextIsolation:!0,nodeIntegration:!1}});d.setBackgroundColor("#333"),d.webContents.session.webRequest.onBeforeRequest({urls:["http://*/*","ws://*/*"]},(e,t)=>{t({cancel:((e,t={})=>{let o=v(t);try{let t=new URL(String(e||""));if("http:"!==t.protocol&&"ws:"!==t.protocol)return!1;let s=t.host.toLowerCase(),r=t.hostname.toLowerCase().replace(/^\[|\]$/g,"");return!o.allowedInsecureHosts.some(e=>{let o=(e=>{let t=String(e||"").trim().toLowerCase();if(!t)return null;if(!/^[a-z][a-z0-9+.-]*:\/\//i.test(t))return{host:t,protocol:null};try{let e=new URL(t);return{host:e.host.toLowerCase(),protocol:e.protocol}}catch{return null}})(e);return!!o&&(!o.protocol||o.protocol===t.protocol)&&(o.host===s||o.host===r)})}catch{return!1}})(e.url,O)})}),d.loadURL(E);let u=()=>{let t={type:"config",configFile:{_originTitle:"Test",...J,title:Math.random().toString()},workspace:{billing:{lock:{},plan:"free"}},showMenu:f["show-menu"]||!1,testId:L};if(d.webContents.executeJavaScript(`window.postMessage(JSON.stringify(${JSON.stringify(t)}))`),I){let{delay:t,width:o,height:s,path:r}=I;setTimeout(async()=>{let t=!1;console.log("Taking screenshot");try{let e=await d.webContents.capturePage();console.log("Writing screenshot to",r),await i(r,e.resize({width:o,height:s}).toJPEG(75))}catch(e){t=!0,console.error("Screenshot capture/write failed",e)}finally{R&&(console.log("Closing app"),t?e.exit(1):e.quit())}},t)}},h=null;d.webContents.once("dom-ready",()=>{u(),L&&(R||I)&&(h=setTimeout(()=>{console.error(`Automation test ${L} did not report a result within ${H}ms — check that its waits can resolve and the expected canvas/data changes actually happen.`),e.exit(1)},H)),L&&d.webContents.executeJavaScript(`
|
|
15
|
+
window.addEventListener('message', (evt) => {
|
|
16
|
+
try {
|
|
17
|
+
const data = JSON.parse(evt.data)
|
|
18
|
+
if (data.type === 'bricks-preview-test-result') {
|
|
19
|
+
console.log('[TEST_RESULT]' + JSON.stringify(data))
|
|
20
|
+
}
|
|
21
|
+
} catch (e) {}
|
|
22
|
+
})
|
|
23
|
+
`);let t=f["cdp-port"]?parseInt(f["cdp-port"],10):null;t&&B(d,t)}),L&&d.webContents.on("console-message",(t,...o)=>{let s="object"==typeof o[0]?o[0].message:o[1];if(s?.startsWith("[TEST_RESULT]")){h&&clearTimeout(h);let t=JSON.parse(s.replace("[TEST_RESULT]",""));console.log(`[TEST_RESULT_TOON]${w.encode(t.result)}`),!I&&R&&e.quit()}}),f["clear-cache"]&&(console.log("Clearing cache"),d.webContents.session.clearCache()),d.on("close",()=>e.quit()),l(`${y}/.bricks/build/application-config.json`,{bigint:!1,persistent:!0,interval:1e3},async()=>{console.log("Detected config changed"),J=JSON.parse(await n(`${y}/.bricks/build/application-config.json`));let e=await k();O=v({...e,allowedInsecureHosts:[...e.allowedInsecureHosts,C(E)].filter(Boolean)}),u()}),l(`${y}/simulator.json`,{bigint:!1,persistent:!0,interval:1e3},async()=>{console.log("Detected simulator settings changed");let e=await k();O=v({...e,allowedInsecureHosts:[...e.allowedInsecureHosts,C(E)].filter(Boolean)})})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const{contextBridge:i,ipcRenderer:s}=require("electron"),AUTOMATION_SCREENSHOT_ROOT=".bricks/automation_screenshots";i.exposeInMainWorld("BRICKS_AUTOMATION_SCREENSHOTS",{rootDir:".bricks/automation_screenshots",exists:i=>s.invoke("bricks-automation-screenshots:exists",i),readdir:i=>s.invoke("bricks-automation-screenshots:readdir",i),readDir:i=>s.invoke("bricks-automation-screenshots:readdir",i),mkdir:i=>s.invoke("bricks-automation-screenshots:mkdir",i),unlink:i=>s.invoke("bricks-automation-screenshots:unlink",i),readFile:(i,e)=>s.invoke("bricks-automation-screenshots:read-file",i,e),writeFile:(i,e,o)=>s.invoke("bricks-automation-screenshots:write-file",i,e,o)});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fugood/bricks-cli",
|
|
3
|
-
"version": "2.25.0-beta.
|
|
3
|
+
"version": "2.25.0-beta.81",
|
|
4
4
|
"description": "BRICKS CLI - Command-line interface for BRICKS Workspace API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bricks",
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
20
|
"lib",
|
|
21
|
-
"!lib/lib.js",
|
|
22
21
|
"bin"
|
|
23
22
|
],
|
|
24
23
|
"type": "module",
|
|
@@ -31,15 +30,18 @@
|
|
|
31
30
|
"scripts": {
|
|
32
31
|
"start": "bun bin/bricks.js",
|
|
33
32
|
"dev": "bun --watch bin/bricks.js",
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
33
|
+
"ctor:bundle-assets": "node src/ctor/scripts/bundle-lib-assets.mjs",
|
|
34
|
+
"ctor:codegen": "bun src/ctor/scripts/build.js && bun run ctor:bundle-assets",
|
|
35
|
+
"build": "bun run ctor:codegen && rspack build --config rspack.config.js",
|
|
36
|
+
"build:dist": "bun run ctor:codegen && $npm_execpath scripts/build-distribution.js",
|
|
37
|
+
"release": "bun run ctor:codegen && $npm_execpath scripts/build-distribution.js",
|
|
38
|
+
"release-beta": "bun run ctor:codegen && $npm_execpath scripts/build-distribution.js --beta",
|
|
38
39
|
"upload-release": "node scripts/upload-release.js",
|
|
39
40
|
"upload-beta": "node scripts/upload-release.js --beta",
|
|
40
41
|
"prepack": "bun run build"
|
|
41
42
|
},
|
|
42
43
|
"dependencies": {
|
|
44
|
+
"@toon-format/toon": "^2.1.0",
|
|
43
45
|
"conf": "^13.0.1",
|
|
44
46
|
"ink": "^6.0.0",
|
|
45
47
|
"ink-picture": "^1.3.3",
|
|
@@ -49,11 +51,25 @@
|
|
|
49
51
|
},
|
|
50
52
|
"devDependencies": {
|
|
51
53
|
"@apollo/client": "^3.13.8",
|
|
54
|
+
"@babel/generator": "7.28.5",
|
|
55
|
+
"@babel/parser": "7.28.5",
|
|
56
|
+
"@babel/traverse": "7.28.5",
|
|
57
|
+
"@babel/types": "7.28.5",
|
|
58
|
+
"@fugood/bricks-config-core": "^2.25.0-beta.81",
|
|
59
|
+
"@fugood/bricks-core-generated": "^2.25.0-beta.81",
|
|
60
|
+
"@fugood/bricks-system-properties-definition": "^2.24.0",
|
|
61
|
+
"@fugood/property-bank-calc-generated": "^2.25.0-beta.81",
|
|
62
|
+
"@huggingface/gguf": "^0.3.2",
|
|
63
|
+
"@iarna/toml": "^3.0.0",
|
|
52
64
|
"@inquirer/prompts": "^7.0.0",
|
|
65
|
+
"@modelcontextprotocol/sdk": "^1.15.0",
|
|
53
66
|
"@rspack/cli": "^2.0.1",
|
|
54
67
|
"@rspack/core": "^2.0.1",
|
|
68
|
+
"acorn": "^8.13.0",
|
|
55
69
|
"chalk": "^5.3.0",
|
|
56
70
|
"commander": "^12.1.0",
|
|
71
|
+
"escodegen": "2.1.0",
|
|
72
|
+
"fuse.js": "^7.0.0",
|
|
57
73
|
"graphql": "^16.3.0",
|
|
58
74
|
"graphql-tag": "^2.10.3",
|
|
59
75
|
"https-proxy-agent": "^5.0.0",
|
|
@@ -61,13 +77,17 @@
|
|
|
61
77
|
"ink-spinner": "^5.0.0",
|
|
62
78
|
"ink-testing-library": "^4.0.0",
|
|
63
79
|
"ink-text-input": "^6.0.0",
|
|
80
|
+
"json5": "^2.0.1",
|
|
64
81
|
"lodash": "^4.17.4",
|
|
65
82
|
"mime-types": "^2.1.31",
|
|
66
83
|
"node-fetch": "^2.6.9",
|
|
67
|
-
"
|
|
84
|
+
"node-machine-id": "^1.1.12",
|
|
85
|
+
"ora": "^8.1.1",
|
|
86
|
+
"uuid": "^8.3.1",
|
|
87
|
+
"zod": "^3.25.76"
|
|
68
88
|
},
|
|
69
89
|
"engines": {
|
|
70
90
|
"node": ">=18.0.0"
|
|
71
91
|
},
|
|
72
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "786f7d14d23954bd41cd09cd19aae34a9d7d1b26"
|
|
73
93
|
}
|