@fugood/bricks-cli 2.25.0-beta.62 → 2.25.0-beta.63
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/10.js +1 -1
- package/lib/117.js +1 -1
- package/lib/274.js +42 -3
- package/lib/486.js +1 -1
- package/lib/708.js +7 -7
- package/lib/818.js +1 -1
- package/lib/915.js +4 -4
- package/lib/index.js +2 -2
- package/lib/simulator-host-bridge.cjs +1 -0
- package/lib/simulator-main.mjs +3 -3
- package/package.json +5 -5
package/lib/index.js
CHANGED
|
@@ -93,10 +93,10 @@ ${y.default.bold("Usage")}`),console.log(`Used In: ${n.use_count.total_coun
|
|
|
93
93
|
${y.default.bold("Exposed Properties")} (${n.expose_properties.length})`),n.expose_properties.forEach(e=>{console.log(` - ${y.default.cyan(e)}`)})),console.log("─".repeat(60))}catch(e){r.fail(`Failed to get module: ${e.message}`),process.exit(1)}}),function(e,t){return a.apply(this,arguments)})),x.command("resolve <query>").description("Resolve a module name or ID to stable IDs").option("-l, --limit <limit>","Limit search results",e=>Number.parseInt(e,10),10).option("-j, --json","Output as JSON").action((s=m(function*(e,t){var o=(0,$.requireAuth)(),r=t.json?null:(0,v.default)("Resolving module...").start();try{var n=yield(0,E.Y)(()=>o.module({id:e})),i=n?[n]:yield o.modules({keyword:e,paginate:{limit:t.limit}}),a=(0,E.K)({resource:"module",query:e,items:i||[],fields:["_id","name"],selectedBy:n?"id":null});if(r&&r.stop(),t.json)return void(0,C.GF)(a);if(a.resolved){var s=a.resolved;console.log(y.default.bold("\nResolved Module")),console.log("─".repeat(60)),console.log(`Name: ${y.default.cyan(s.name||"Unnamed")}`),console.log(`ID: ${y.default.gray(s._id)}`),console.log(`Selected By: ${a.selectedBy}`),console.log("─".repeat(60));return}if(0===a.matches.length)return void console.log(y.default.yellow(`No modules matched "${e}"`));console.log(y.default.bold(`
|
|
94
94
|
Matching Modules (${a.matches.length})`)),console.log("─".repeat(80)),a.matches.forEach(e=>{console.log(`${y.default.cyan(e.name||"Unnamed")} ${y.default.gray(e._id)}`)}),console.log("─".repeat(80))}catch(t){r?r.fail(`Failed to resolve module: ${t.message}`):(0,C.OW)(t.message,{resource:"module",query:e}),process.exit(1)}}),function(e,t){return s.apply(this,arguments)})),x.command("update <id>").description("Update module name, description, and/or configuration").option("-n, --name <name>","Module name").option("-d, --description <description>","Module description").option("-c, --config <json>","Module config as JSON string").option("-f, --file <path>","Module config from file").option("--validate","Validate configuration (default: true when config is set)",!0).option("--no-validate","Skip server-side config validation").option("--last-commit-id <id>","Reject if server config.bricks_project_last_commit_id does not match this value").option("-j, --json","Output as JSON").action((l=m(function*(e,t){var o=(0,$.requireAuth)(),r=t.json?null:(0,v.default)("Updating module...").start();try{var n=yield o.updateModule((0,k.jB)(e,t));t.json?(0,k.yd)({action:"module.update",target:S(n,e),result:{lastCommitId:t.lastCommitId||null},json:!0}):(r.succeed(`Module updated: ${y.default.green(n.name)}`),n.has_unreleased_changes&&console.log(y.default.yellow("Note: Module has unreleased changes")))}catch(o){t.json?(0,C.OW)(o.message,{action:"module.update",target:{id:e}}):r.fail(`Failed to update module: ${o.message}`),process.exit(1)}}),function(e,t){return l.apply(this,arguments)})),x.command("short-edit <id>").description("Short edit module properties").requiredOption("-l, --list <json>","Short edit list as JSON array").action((u=m(function*(e,t){var o=(0,$.requireAuth)(),r=(0,v.default)("Applying short edit...").start();try{var n=JSON.parse(t.list);Array.isArray(n)||(r.fail("List must be a JSON array"),process.exit(1));var i=yield o.shortEditModule({id:e,list:n});r.succeed(`Short edit applied to: ${y.default.green(i.name)}`)}catch(e){r.fail(`Failed to apply short edit: ${e.message}`),process.exit(1)}}),function(e,t){return u.apply(this,arguments)})),x.command("short-refs <id>").description("List short edit references for a module").option("-k, --keyword <keyword>","Filter by shortId or title").option("-t, --types <types>","Comma-separated shortId prefixes to include (e.g. B,C,S)").option("-j, --json","Output as JSON").action((c=m(function*(e,t){var o=(0,$.requireAuth)(),r=(0,v.default)("Fetching short edit references...").start();try{var n=yield o.module({id:e});if(r.stop(),!n?.short_edit?.enabled)return void console.log(y.default.yellow("Short Edit is not enabled for this module"));var i=t.types?t.types.split(",").map(e=>e.trim()).filter(Boolean):[],a=(0,_.V)(n.short_edit.ref_map,{keyword:t.keyword,types:i});if(t.json)return void console.log(JSON.stringify(a,null,2));if(0===a.length)return void console.log(y.default.yellow("No short edit references found"));console.log(y.default.bold(`
|
|
95
95
|
Short Edit References: ${n.name}`)),a.forEach(e=>{console.log(y.default.cyan(`
|
|
96
|
-
${e.label} (${e.prefix}_)`)),e.refs.forEach(({shortId:e,ref:t})=>{var o=t?.title?y.default.gray(`- ${t.title}`):"";console.log(` ${y.default.green(e)} ${o}`)})}),console.log()}catch(e){r.fail(`Failed to fetch short edit references: ${e.message}`),process.exit(1)}}),function(e,t){return c.apply(this,arguments)})),x.command("remove <id>").description("Remove a module").option("--dry-run","Validate the target and show the removal plan without deleting it").option("-j, --json","Output as JSON").action((d=m(function*(e,t){var o=(0,$.requireAuth)(),r=t.json?null:(0,v.default)("Removing module...").start();try{var n=yield o.module({id:e});if(!n)throw Error("Module not found");var i=S(n,e);if(t.dryRun){r&&r.stop(),(0,k.S5)({action:"module.remove",target:i,request:{id:e},checks:[(0,k.Iy)("module exists",!0,`${i.name} (${i.id})`)],json:t.json});return}var a=yield o.removeModule({id:e});t.json?(0,k.yd)({action:"module.remove",target:i,result:{removed:!!a},json:!0}):r.succeed(`Module removed: ${y.default.green(i.name)}`)}catch(o){t.json?(0,C.OW)(o.message,{action:"module.remove",target:{id:e}}):r.fail(`Failed to remove module: ${o.message}`),process.exit(1)}}),function(e,t){return d.apply(this,arguments)})),x.command("release <id>").description("Release module to BRICKS platform").requiredOption("-c, --config <path|json>","Module config file path or JSON string").option("-n, --name <name>","Update module name as part of the release").option("--version <version>","Version name").option("--changelogs <text>","Release changelogs").option("--dry-run","Validate inputs and show the release plan without publishing").option("-j, --json","Output as JSON").action((p=m(function*(e,t){var o=(0,$.requireAuth)(),r=t.json?null:(0,v.default)("Releasing module...").start();try{var n=(0,w.Ku)(t.config),i=n.config,a=n.source,s=n.sizeBytes,l=yield o.module({id:e});if(!l)throw Error("Module not found");if(l.is_public)throw Error("Public module deployment is temporarily not recommended");var u=t.version||t.name||l.name||"Untitled",c=(0,w.w9)(t.changelogs);if(t.dryRun){r&&r.stop(),(0,k.S5)({action:"module.release",target:S(l,e),request:{name:t.name||null,version:u,changelogs:t.changelogs||null,configSource:a,configSizeBytes:s},checks:[(0,k.Iy)("module exists",!0,`${l.name} (${l._id})`),(0,k.Iy)("module is private",!l.is_public),(0,k.Iy)("release config loaded",!0,`${s} bytes`)],json:t.json});return}var d=yield o.releaseModule({id:e,config:i,...t.name?{name:t.name}:{},releaseCurrentVersion:u,releaseCurrentVersionNote:c});t.json?(0,k.yd)({action:"module.release",target:S(d||l,e),result:{name:t.name||null,version:u,configSource:a,configSizeBytes:s},json:!0}):r.succeed(`Module released: ${y.default.green(d?.name||l.name)}`)}catch(o){t.json?(0,C.OW)(o.message,{action:"module.release",target:{id:e}}):r.fail(`Failed to release module: ${o.message}`),process.exit(1)}}),function(e,t){return p.apply(this,arguments)})),x.command("project-pull <id>").description("Pull module source files from BRICKS platform").option("-j, --json","Output as JSON (for programmatic use)").action((f=m(function*(e,t){var o=(0,$.requireAuth)(),r=t.json?null:(0,v.default)("Pulling module project...").start();try{var n=yield o.moduleProject({id:e,buildApplicationOnly:!0});n||(r?r.fail("Module project not found"):console.error(JSON.stringify({error:"Module project not found"})),process.exit(1)),t.json?console.log(JSON.stringify(n)):(r.succeed(`Module project fetched: ${y.default.green(n.files?.length||0)} files`),console.log(JSON.stringify(n,null,2)))}catch(e){t.json?console.error(JSON.stringify({error:e.message})):r.fail(`Failed to pull module project: ${e.message}`),process.exit(1)}}),function(e,t){return f.apply(this,arguments)})),x.command("doctor <idOrPath>").description("Diagnose a module config: schema validation plus semantic lint rules (data races, layout mistakes, dead config)").option("-j, --json","Output as JSON").option("--strict","Exit with code 1 when warnings are found").option("--only <codes>","Run only these rule codes (comma-separated)").option("--ignore <codes>","Skip these rule codes (comma-separated)").option("--validate-automation","Also validate automation_map and test_map references").action((g=m(function*(e,t){var r=t.json?null:(0,v.default)("Running config doctor...").start();try{var n=yield Promise.all([o.e(866),o.e(645),o.e(430),o.e(10),o.e(511),o.e(563)]).then(o.bind(o,63322)),i=n.runConfigDoctor,a=n.renderConfigDoctorReport,s=yield i("module",e,t),l=s.report,u=s.exitCode;r?.stop(),t.json?(0,C.GF)({...l,exitCode:u}):console.log(a(l)),0!==u&&process.exit(u)}catch(e){r?r.fail(`Config doctor failed: ${e.message}`):(0,C.OW)(e.message),process.exit(1)}}),function(e,t){return g.apply(this,arguments)})),x.command("ctor-init <id>").alias("project-init").description("Initialize a BRICKS Project from a module (deprecated: use `bricks ctor init --type module`)").option("-o, --output <dir>","Output directory (default: current directory)").option("--github-actions","Include GitHub Actions workflow (default: true)").option("--no-github-actions","Skip GitHub Actions workflow setup").option("--agents","Include AGENTS.md (default: true)").option("--no-agents","Skip AGENTS.md setup").option("--claude","Include CLAUDE.md (default: true)").option("--no-claude","Skip CLAUDE.md setup").option("--gemini","Include GEMINI.md (default: false)").option("--no-gemini","Skip GEMINI.md setup").option("--install","Run bun install after generation (default: true)").option("--no-install","Skip bun install after generation").option("--git","Initialize git repository (default: true)").option("--no-git","Skip git initialization").option("-y, --yes","Skip prompts and use defaults/flags").option("-j, --json","Output as JSON (for programmatic use)").action((h=m(function*(e,t){t.json||console.error(y.default.yellow("Note: `bricks module ctor-init` is deprecated. Use `bricks ctor init <id> --type module` instead."));var r=(yield Promise.all([o.e(658),o.e(456)]).then(o.bind(o,58891))).initProject;yield r("module",e,t)}),function(e,t){return h.apply(this,arguments)}))},38311(e,t,o){o.d(t,{D:()=>d});var r,n,i,a=o(99436),s=o(35679),l=o(73284),u=(r=a(function*(){var e=(yield Promise.resolve().then(o.bind(o,30155))).default,t=yield o.e(818).then(o.bind(o,53241)),r=t.detectChannel,n=t.detectInstallMethod,i=yield o.e(405).then(o.bind(o,21068));return{ora:e,detectChannel:r,detectInstallMethod:n,fetchLatestVersionInfo:i.fetchLatestVersionInfo,runUpdateForMethod:i.runUpdateForMethod}}),function(){return r.apply(this,arguments)}),c=(n=a(function*({message:e,defaultValue:t,autoYes:r}){if(r)return!0;(0,(yield Promise.resolve().then(o.bind(o,8479))).isInteractiveTerminal)()||(console.error(l.default.red("Refusing to prompt in a non-interactive shell. Pass -y/--yes to confirm.")),process.exit(1));try{var n=(yield o.e(658).then(o.bind(o,27521))).confirm;return yield n({message:e,default:t})}catch{return!1}}),function(e){return n.apply(this,arguments)}),d=new s.uB("update-cli").description("Update the BRICKS CLI to the latest version").option("-y, --yes","Skip confirmation prompts").option("--channel <channel>","Override channel (release|beta)").option("--check-update","Only check whether a newer version is available and exit").action((i=a(function*(e){var t,o=yield u(),r=o.ora,n=o.detectChannel,i=o.detectInstallMethod,s=o.fetchLatestVersionInfo,d=o.runUpdateForMethod,p="2.25.0-beta.
|
|
96
|
+
${e.label} (${e.prefix}_)`)),e.refs.forEach(({shortId:e,ref:t})=>{var o=t?.title?y.default.gray(`- ${t.title}`):"";console.log(` ${y.default.green(e)} ${o}`)})}),console.log()}catch(e){r.fail(`Failed to fetch short edit references: ${e.message}`),process.exit(1)}}),function(e,t){return c.apply(this,arguments)})),x.command("remove <id>").description("Remove a module").option("--dry-run","Validate the target and show the removal plan without deleting it").option("-j, --json","Output as JSON").action((d=m(function*(e,t){var o=(0,$.requireAuth)(),r=t.json?null:(0,v.default)("Removing module...").start();try{var n=yield o.module({id:e});if(!n)throw Error("Module not found");var i=S(n,e);if(t.dryRun){r&&r.stop(),(0,k.S5)({action:"module.remove",target:i,request:{id:e},checks:[(0,k.Iy)("module exists",!0,`${i.name} (${i.id})`)],json:t.json});return}var a=yield o.removeModule({id:e});t.json?(0,k.yd)({action:"module.remove",target:i,result:{removed:!!a},json:!0}):r.succeed(`Module removed: ${y.default.green(i.name)}`)}catch(o){t.json?(0,C.OW)(o.message,{action:"module.remove",target:{id:e}}):r.fail(`Failed to remove module: ${o.message}`),process.exit(1)}}),function(e,t){return d.apply(this,arguments)})),x.command("release <id>").description("Release module to BRICKS platform").requiredOption("-c, --config <path|json>","Module config file path or JSON string").option("-n, --name <name>","Update module name as part of the release").option("--version <version>","Version name").option("--changelogs <text>","Release changelogs").option("--dry-run","Validate inputs and show the release plan without publishing").option("-j, --json","Output as JSON").action((p=m(function*(e,t){var o=(0,$.requireAuth)(),r=t.json?null:(0,v.default)("Releasing module...").start();try{var n=(0,w.Ku)(t.config),i=n.config,a=n.source,s=n.sizeBytes,l=yield o.module({id:e});if(!l)throw Error("Module not found");if(l.is_public)throw Error("Public module deployment is temporarily not recommended");var u=t.version||t.name||l.name||"Untitled",c=(0,w.w9)(t.changelogs);if(t.dryRun){r&&r.stop(),(0,k.S5)({action:"module.release",target:S(l,e),request:{name:t.name||null,version:u,changelogs:t.changelogs||null,configSource:a,configSizeBytes:s},checks:[(0,k.Iy)("module exists",!0,`${l.name} (${l._id})`),(0,k.Iy)("module is private",!l.is_public),(0,k.Iy)("release config loaded",!0,`${s} bytes`)],json:t.json});return}var d=yield o.releaseModule({id:e,config:i,...t.name?{name:t.name}:{},releaseCurrentVersion:u,releaseCurrentVersionNote:c});t.json?(0,k.yd)({action:"module.release",target:S(d||l,e),result:{name:t.name||null,version:u,configSource:a,configSizeBytes:s},json:!0}):r.succeed(`Module released: ${y.default.green(d?.name||l.name)}`)}catch(o){t.json?(0,C.OW)(o.message,{action:"module.release",target:{id:e}}):r.fail(`Failed to release module: ${o.message}`),process.exit(1)}}),function(e,t){return p.apply(this,arguments)})),x.command("project-pull <id>").description("Pull module source files from BRICKS platform").option("-j, --json","Output as JSON (for programmatic use)").action((f=m(function*(e,t){var o=(0,$.requireAuth)(),r=t.json?null:(0,v.default)("Pulling module project...").start();try{var n=yield o.moduleProject({id:e,buildApplicationOnly:!0});n||(r?r.fail("Module project not found"):console.error(JSON.stringify({error:"Module project not found"})),process.exit(1)),t.json?console.log(JSON.stringify(n)):(r.succeed(`Module project fetched: ${y.default.green(n.files?.length||0)} files`),console.log(JSON.stringify(n,null,2)))}catch(e){t.json?console.error(JSON.stringify({error:e.message})):r.fail(`Failed to pull module project: ${e.message}`),process.exit(1)}}),function(e,t){return f.apply(this,arguments)})),x.command("doctor <idOrPath>").description("Diagnose a module config: schema validation plus semantic lint rules (data races, layout mistakes, dead config)").option("-j, --json","Output as JSON").option("--strict","Exit with code 1 when warnings are found").option("--only <codes>","Run only these rule codes (comma-separated)").option("--ignore <codes>","Skip these rule codes (comma-separated)").option("--validate-automation","Also validate automation_map and test_map references").action((g=m(function*(e,t){var r=t.json?null:(0,v.default)("Running config doctor...").start();try{var n=yield Promise.all([o.e(866),o.e(645),o.e(430),o.e(10),o.e(511),o.e(563)]).then(o.bind(o,63322)),i=n.runConfigDoctor,a=n.renderConfigDoctorReport,s=yield i("module",e,t),l=s.report,u=s.exitCode;r?.stop(),t.json?(0,C.GF)({...l,exitCode:u}):console.log(a(l)),0!==u&&process.exit(u)}catch(e){r?r.fail(`Config doctor failed: ${e.message}`):(0,C.OW)(e.message),process.exit(1)}}),function(e,t){return g.apply(this,arguments)})),x.command("ctor-init <id>").alias("project-init").description("Initialize a BRICKS Project from a module (deprecated: use `bricks ctor init --type module`)").option("-o, --output <dir>","Output directory (default: current directory)").option("--github-actions","Include GitHub Actions workflow (default: true)").option("--no-github-actions","Skip GitHub Actions workflow setup").option("--agents","Include AGENTS.md (default: true)").option("--no-agents","Skip AGENTS.md setup").option("--claude","Include CLAUDE.md (default: true)").option("--no-claude","Skip CLAUDE.md setup").option("--gemini","Include GEMINI.md (default: false)").option("--no-gemini","Skip GEMINI.md setup").option("--install","Run bun install after generation (default: true)").option("--no-install","Skip bun install after generation").option("--git","Initialize git repository (default: true)").option("--no-git","Skip git initialization").option("-y, --yes","Skip prompts and use defaults/flags").option("-j, --json","Output as JSON (for programmatic use)").action((h=m(function*(e,t){t.json||console.error(y.default.yellow("Note: `bricks module ctor-init` is deprecated. Use `bricks ctor init <id> --type module` instead."));var r=(yield Promise.all([o.e(658),o.e(456)]).then(o.bind(o,58891))).initProject;yield r("module",e,t)}),function(e,t){return h.apply(this,arguments)}))},38311(e,t,o){o.d(t,{D:()=>d});var r,n,i,a=o(99436),s=o(35679),l=o(73284),u=(r=a(function*(){var e=(yield Promise.resolve().then(o.bind(o,30155))).default,t=yield o.e(818).then(o.bind(o,53241)),r=t.detectChannel,n=t.detectInstallMethod,i=yield o.e(405).then(o.bind(o,21068));return{ora:e,detectChannel:r,detectInstallMethod:n,fetchLatestVersionInfo:i.fetchLatestVersionInfo,runUpdateForMethod:i.runUpdateForMethod}}),function(){return r.apply(this,arguments)}),c=(n=a(function*({message:e,defaultValue:t,autoYes:r}){if(r)return!0;(0,(yield Promise.resolve().then(o.bind(o,8479))).isInteractiveTerminal)()||(console.error(l.default.red("Refusing to prompt in a non-interactive shell. Pass -y/--yes to confirm.")),process.exit(1));try{var n=(yield o.e(658).then(o.bind(o,27521))).confirm;return yield n({message:e,default:t})}catch{return!1}}),function(e){return n.apply(this,arguments)}),d=new s.uB("update-cli").description("Update the BRICKS CLI to the latest version").option("-y, --yes","Skip confirmation prompts").option("--channel <channel>","Override channel (release|beta)").option("--check-update","Only check whether a newer version is available and exit").action((i=a(function*(e){var t,o=yield u(),r=o.ora,n=o.detectChannel,i=o.detectInstallMethod,s=o.fetchLatestVersionInfo,d=o.runUpdateForMethod,p="2.25.0-beta.63",f=i(),g=e.channel||n({version:p,execPath:f.execPath});console.log(l.default.bold(e.checkUpdate?"BRICKS CLI Update Check":"BRICKS CLI Update")),console.log("─".repeat(60)),console.log(`Current version : ${l.default.cyan(p)}`),console.log(`Channel : ${l.default.cyan(g)}`),console.log(`Detected method : ${l.default.cyan(f.method)}`),f.execPath&&"binary"===f.method&&console.log(`Binary path : ${l.default.gray(f.execPath)}`),f.installRoot&&console.log(`Install root : ${l.default.gray(f.installRoot)}`);var h="npm"===f.method||"bun"===f.method?"npm":"cdn",m=r(`Fetching latest version info (${h})...`).start(),D=null,y=null;try{D=(yield s(g,f.method)).version,m.succeed(`Latest ${g} (${h}): ${l.default.green(D)}`)}catch(e){y=e,m.warn(`Could not fetch version info: ${e.message}`)}var v=D&&D===p;if(e.checkUpdate){if(y&&process.exit(2),v)return void console.log(l.default.green("\nUp to date."));D&&(console.log(l.default.yellow(`
|
|
97
97
|
Update available: ${p} → ${D}. Run 'bricks update-cli' to install.`)),process.exit(1)),console.log(l.default.yellow("\nCould not determine current version.")),process.exit(2)}if(v&&(console.log(l.default.green("\nAlready running the latest version.")),!(yield c({message:"Reinstall anyway?",defaultValue:!1,autoYes:e.yes}))))return void console.log(l.default.gray("Skipped."));var b=["npm","bun","binary"].includes(f.method);b||console.log(l.default.yellow(`Cannot auto-detect installer (method: ${f.method}); falling back to binary install.`));var F=b?f.method:"binary";if(!(yield c({message:`Update CLI using "${F}" method?`,defaultValue:!0,autoYes:e.yes})))return void console.log(l.default.yellow("Cancelled."));var _=(t=a(function*(e){console.log(l.default.cyan(`
|
|
98
98
|
→ Running ${e} update...`));try{return yield d(e,g,f),!0}catch(t){return console.error(l.default.yellow(`
|
|
99
|
-
${e} update failed: ${t.message}`)),!1}}),function(e){return t.apply(this,arguments)}),C=yield _(F);!C&&"binary"!==F&&(console.log(l.default.cyan("\nFalling back to binary install (same method used by the desktop app).")),(yield c({message:"Try the binary installer as a fallback?",defaultValue:!0,autoYes:e.yes}))&&(C=yield _("binary"))),C||(console.error(l.default.red("\nUpdate failed. See messages above.")),process.exit(1)),console.log(l.default.green("\nUpdate complete."))}),function(e){return i.apply(this,arguments)}))},1878(e,t,o){o.a(e,async function(e,r){try{o.d(t,{A:()=>S,e:()=>k});var n,i=o(99436),a=o(35679),s=o(73284),l=o(47988),u=o(8479),c=o(55614),d=o(1983),p=o(17422),f=o(32541),g=o(28634),h=o(12569),m=o(55609),D=o(71335),y=o(429),v=o(80274),b=o(42400),F=o(98247),_=o(70970),C=o(38311),$=o(59845),E=o(22175),w=e([b]);b=(w.then?(await w)():w)[0];var k=(n=i(function*(){var e,t=process.argv.findIndex(e=>"--auth-profile"===e||"-ap"===e);-1!==t&&process.argv[t+1]&&((0,l.setProfileOverride)(process.argv[t+1]),process.argv.splice(t,2)),a.DM.name("bricks").description("BRICKS CLI - Command-line interface for BRICKS Workspace API").version("2.25.0-beta.
|
|
99
|
+
${e} update failed: ${t.message}`)),!1}}),function(e){return t.apply(this,arguments)}),C=yield _(F);!C&&"binary"!==F&&(console.log(l.default.cyan("\nFalling back to binary install (same method used by the desktop app).")),(yield c({message:"Try the binary installer as a fallback?",defaultValue:!0,autoYes:e.yes}))&&(C=yield _("binary"))),C||(console.error(l.default.red("\nUpdate failed. See messages above.")),process.exit(1)),console.log(l.default.green("\nUpdate complete."))}),function(e){return i.apply(this,arguments)}))},1878(e,t,o){o.a(e,async function(e,r){try{o.d(t,{A:()=>S,e:()=>k});var n,i=o(99436),a=o(35679),s=o(73284),l=o(47988),u=o(8479),c=o(55614),d=o(1983),p=o(17422),f=o(32541),g=o(28634),h=o(12569),m=o(55609),D=o(71335),y=o(429),v=o(80274),b=o(42400),F=o(98247),_=o(70970),C=o(38311),$=o(59845),E=o(22175),w=e([b]);b=(w.then?(await w)():w)[0];var k=(n=i(function*(){var e,t=process.argv.findIndex(e=>"--auth-profile"===e||"-ap"===e);-1!==t&&process.argv[t+1]&&((0,l.setProfileOverride)(process.argv[t+1]),process.argv.splice(t,2)),a.DM.name("bricks").description("BRICKS CLI - Command-line interface for BRICKS Workspace API").version("2.25.0-beta.63","-v, --version","output the version number").enablePositionalOptions(),a.DM.addCommand(c.s),a.DM.addCommand(d._),a.DM.addCommand(p.B),a.DM.addCommand(f.A),a.DM.addCommand(g.p),a.DM.addCommand(h.u),a.DM.addCommand(m.E),a.DM.addCommand(D.oT),a.DM.addCommand(y.K),a.DM.addCommand(v.gf),a.DM.addCommand(b.D),a.DM.addCommand(F.v),a.DM.addCommand(_.l),a.DM.addCommand(C.D),a.DM.addCommand($.Q),a.DM.addCommand(E.g),a.DM.command("interactive").alias("i").description("Start interactive mode with Ink UI").action(i(function*(){try{var e=(yield Promise.all([o.e(370),o.e(785),o.e(332),o.e(209),o.e(690),o.e(907),o.e(940)]).then(o.bind(o,92319))).runInteractiveMode;yield e()}catch(e){console.error(s.default.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}})),a.DM.command("workspace").alias("ws").description("Show current workspace information").option("-j, --json","Output as JSON").action((e=i(function*(e){var t=yield Promise.resolve().then(o.bind(o,47988)),r=t.getToken,n=t.getBaseUrl,i=t.getCurrentProfile,a=(yield Promise.all([o.e(370),o.e(785),o.e(332),o.e(209),o.e(907)]).then(o.bind(o,85382))).createClient,l=(yield Promise.resolve().then(o.bind(o,30155))).default,u=i(),c=r(u);c||(console.error(s.default.red("Not logged in. Use `bricks auth login` first.")),process.exit(1));var d=l("Fetching workspace info...").start();try{var p=a(n(),c),f=yield p.workspace();if(d.stop(),e.json)return void console.log(JSON.stringify(f,null,2));console.log(s.default.bold("\nWorkspace Information")),console.log("─".repeat(60)),console.log(`Name: ${s.default.green(f.name)}`),console.log(`ID: ${s.default.gray(f._id)}`),console.log(`Description: ${f.description||s.default.gray("N/A")}`),console.log(`
|
|
100
100
|
${s.default.bold("Data")}`),console.log(`Remote Update: ${f.bank?.enable_remote_update?s.default.green("Enabled"):s.default.gray("Disabled")}`),console.log(`Spacename: ${f.bank?.spacename||s.default.gray("N/A")}`),console.log("─".repeat(60))}catch(e){d.fail(`Failed to get workspace: ${e.message}`),process.exit(1)}}),function(t){return e.apply(this,arguments)})),a.DM.on("--help",()=>{console.log(""),console.log(s.default.bold("Examples:")),console.log(""),console.log(s.default.gray(" # Login with a one-time passcode (recommended)")),console.log(" $ bricks auth login <passcode>"),console.log(""),console.log(s.default.gray(" # List all devices")),console.log(" $ bricks device list"),console.log(""),console.log(s.default.gray(" # Monitor devices in real-time")),console.log(" $ bricks device monitor"),console.log(""),console.log(s.default.gray(" # Control a device")),console.log(" $ bricks device refresh <device-id>"),console.log(" $ bricks device control <device-id> clear-cache"),console.log(""),console.log(s.default.gray(" # Bind a new device")),console.log(' $ bricks device bind <passcode> -n "My Device"'),console.log(""),console.log(s.default.gray(" # List applications")),console.log(" $ bricks app list"),console.log(""),console.log(s.default.gray(" # Start interactive mode")),console.log(" $ bricks interactive"),console.log(""),console.log(s.default.gray(" # Change API endpoint")),console.log(" $ bricks config endpoint beta"),console.log(""),console.log(s.default.gray("Get workspace token from BRICKS Controller:")),console.log(s.default.cyan(" https://control.bricks.tools")),console.log(s.default.gray(" Go to Workspace Settings > API Token"))});var r=process.argv.slice(2);if(0===r.length){if((0,u.shouldStartInteractiveMode)(r))try{var n=(yield Promise.all([o.e(370),o.e(785),o.e(332),o.e(209),o.e(690),o.e(907),o.e(940)]).then(o.bind(o,92319))).runInteractiveMode;yield n();return}catch(e){console.error(s.default.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}console.error(s.default.gray("No command provided. Interactive mode requires a TTY, so showing help instead.\n")),a.DM.outputHelp();return}yield a.DM.parseAsync(process.argv)}),function(){return n.apply(this,arguments)});let S=k;r()}catch(e){r(e)}})},31596(e,t,o){o.d(t,{GE:()=>n,YC:()=>r,jR:()=>i});var r=["InSubspace","Global"],n="Data Bank is not enabled for this workspace.",i=e=>{if(e&&!r.includes(e))throw Error(`Invalid meta "${e}" (expected ${r.join(" | ")})`)}},56493(e,t,o){o.r(t),o.d(t,{requireAuth:()=>l});var r=o(99436),n=o(73284),i=o(47988),a=o(29988),s=new Set(["$$typeof","asymmetricMatch","catch","constructor","finally","hasOwnProperty","inspect","nodeType","toJSON","toString","valueOf"]),l=()=>{var e,t,o,l,u=(0,i.getCurrentProfile)(),c=(0,i.getToken)(u);return c||(console.error(n.default.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),e=(0,i.getBaseUrl)(),t=null,o=r(function*(){return t||=Promise.resolve((0,a.i)()).then(({createClient:t})=>t(e,c))}),l=function(){return o.apply(this,arguments)},new Proxy({},{get:(e,t)=>t===Symbol.toStringTag?"BricksLazyClient":"string"!=typeof t||"then"===t||s.has(t)?void 0:r(function*(...e){var o=yield l(),r=o[t];return"function"==typeof r?r.apply(o,e):r})})}},7586(e,t,o){o.d(t,{$l:()=>i,GF:()=>r,OW:()=>n});var r=e=>{console.log(JSON.stringify(e,null,2))},n=(e,t={})=>{console.error(JSON.stringify({ok:!1,error:{message:e,...t}},null,2))},i=(e,t=4)=>e?e.length<=2*t?"*".repeat(e.length):`${e.slice(0,t)}…${e.slice(-t)}`:null},8479(e,t,o){o.r(t),o.d(t,{isInteractiveTerminal:()=>r,shouldStartInteractiveMode:()=>n});var r=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&"function"==typeof process.stdin.setRawMode),n=(e=[])=>0===e.length&&r()},47988(e,t,o){o.r(t),o.d(t,{CONFIG_DIR:()=>a,CONFIG_PATH:()=>s,clearBankCredentials:()=>$,clearConfig:()=>k,default:()=>S,getActivityLogBaseUrl:()=>E,getBankCredentials:()=>_,getBaseUrl:()=>u,getCurrentProfile:()=>y,getCurrentProfileSource:()=>v,getToken:()=>p,getTokenInfo:()=>f,getTokens:()=>d,listProfiles:()=>F,removeToken:()=>h,setActivityLogBaseUrl:()=>w,setBankCredentials:()=>C,setBaseUrl:()=>c,setCurrentProfile:()=>b,setProfileOverride:()=>D,setToken:()=>g});var r=o(83440),n=o(16928),i=o(70857),a=n.join(i.homedir(),".bricks-cli"),s=n.join(a,"config.json"),l=new r.default({projectName:"bricks-cli",cwd:a,schema:{tokens:{type:"object",default:{},additionalProperties:{type:"object",properties:{token:{type:"string"},name:{type:"string"},workspaceId:{type:"string"},workspaceName:{type:"string"},workspaceBilling:{type:"object"},createdAt:{type:"string"},baseUrl:{type:"string"},bank:{type:"object"}}}},currentProfile:{type:"string",default:"default"},baseUrl:{type:"string",default:"https://display.bricks.tools"},activityLogBaseUrl:{type:"string",default:"https://activity-log.bricks.tools"},devtoolsTokens:{type:"object",default:{},additionalProperties:{type:"object",additionalProperties:{type:"object",properties:{token:{type:"string"},expiresAt:{type:"string"},jti:{type:"string"},workspaceId:{type:"string"}}}}}}}),u=()=>{var e=y(),t=l.get("tokens");return t[e]?.baseUrl||l.get("baseUrl")},c=(e,t)=>{if(!t)return void l.set("baseUrl",e);var o=l.get("tokens");o[t]||(o[t]={}),o[t].baseUrl=e,l.set("tokens",o)},d=()=>l.get("tokens"),p=(e="default")=>{var t=l.get("tokens");return t[e]?.token},f=(e="default")=>l.get("tokens")[e],g=(e,t)=>{var o=l.get("tokens"),r=o[e];o[e]={...r?.baseUrl?{baseUrl:r.baseUrl}:{},...r?.activityLogBaseUrl?{activityLogBaseUrl:r.activityLogBaseUrl}:{},...t,createdAt:new Date().toISOString()},l.set("tokens",o)},h=e=>{var t=l.get("tokens");delete t[e],l.set("tokens",t)},m=null,D=e=>{m=e},y=()=>m||process.env.BRICKS_PROFILE||l.get("currentProfile"),v=()=>m?"override":process.env.BRICKS_PROFILE?"env":"config",b=e=>l.set("currentProfile",e),F=()=>{var e=l.get("tokens"),t=l.get("currentProfile");return Object.keys(e).map(o=>({...e[o],name:o,current:o===t}))},_=(e="default")=>{var t=l.get("tokens");return t[e]?.bank||null},C=(e,t)=>{var o=l.get("tokens");o[e]||(o[e]={}),o[e].bank=t,l.set("tokens",o)},$=e=>{var t=l.get("tokens");return!!t[e]?.bank&&(delete t[e].bank,l.set("tokens",t),!0)},E=()=>{var e=y(),t=l.get("tokens");return t[e]?.activityLogBaseUrl||l.get("activityLogBaseUrl")},w=(e,t)=>{if(!t)return void l.set("activityLogBaseUrl",e);var o=l.get("tokens");o[t]||(o[t]={}),o[t].activityLogBaseUrl=e,l.set("tokens",o)},k=()=>{l.clear()};let S=l},75646(e,t,o){o.r(t),o.d(t,{discoverDevToolsServers:()=>l,httpProbeSubnet:()=>u,verifyDevToolsServer:()=>c});var r,n,i=o(99436),a=o(19557),s="bricks-devtools",l=({timeout:e=3e3,idleTimeout:t=0}={})=>(0,a.YH)({port:19900,timeout:e,idleTimeout:t,buildQuery:()=>Buffer.from(JSON.stringify({t:"QUERY",v:"1.0",s:s,d:{id:`cli-${(0,a.BW)()}`}})),parseMessage:(e,t)=>{var o=JSON.parse(e.toString());if(o.s!==s||"ANNOUNCE"!==o.t&&"RESPONSE"!==o.t)return null;var r=o.d?.info;if(!r)return null;var n=t.address;return{key:`${n}:${r.port}`,value:{...r,address:n}}}}),u=(r=i(function*({port:e=19851,connectTimeout:t=500,concurrency:o=50,timeout:r=0}={}){var n=(0,a.r9)();if(0===n.length)return[];var s=[],l=r>0?Date.now()+r:0,u=[],d=new Set;for(var p of n){var f=p.address.split(".").slice(0,3).join(".");if(!d.has(f)){d.add(f);for(var g=1;g<255;g++)u.push(`${f}.${g}`)}}for(var h=0;h<u.length&&!(l&&Date.now()>=l);h+=o){var m=u.slice(h,h+o);yield Promise.allSettled(m.map(function(){var o=i(function*(o){var r=yield c(o,e,t);r&&s.push({...r,address:o,port:e})});return function(e){return o.apply(this,arguments)}}()))}return s}),function(){return r.apply(this,arguments)}),c=(n=i(function*(e,t,o=3e3){return(0,a.uE)(`http://${e}:${t}/devtools/info`,o)}),function(e,t){return n.apply(this,arguments)})},29988(e,t,o){o.d(t,{i:()=>r});var r=()=>"u">typeof module&&"function"==typeof module.require?module.require("../gql/client.js"):Promise.all([o.e(370),o.e(785),o.e(332),o.e(209),o.e(907)]).then(o.bind(o,85382))},19557(e,t,o){o.d(t,{BW:()=>s,YH:()=>u,r9:()=>l,uE:()=>c});var r,n=o(99436),i=o(41314),a=o(48161),s=()=>Math.random().toString(36).slice(2,9),l=()=>{var e=[];for(var t of Object.values(a.networkInterfaces()))for(var o of t)if(function(){if("IPv4"!==o.family||o.internal)return 1;var t=o.address.split(".").map(Number),r=o.netmask.split(".").map(Number),n=t.map((e,t)=>(e|255&~r[t]).toString()).join(".");e.push({address:o.address,broadcast:n})}())continue;return e},u=({port:e,timeout:t=3e3,idleTimeout:o=0,buildQuery:r,parseMessage:n})=>new Promise((a,s)=>{var u=new Map,c=i.createSocket("udp4"),d=null,p=null,f=!1,g=()=>{if(!f){f=!0,clearTimeout(d),clearTimeout(p);try{c.close()}catch{}a([...u.values()])}};c.on("error",e=>{if(!f){f=!0,clearTimeout(d),clearTimeout(p);try{c.close()}catch{}s(e)}}),c.on("message",(e,t)=>{try{var r=n(e,t);if(!r||u.has(r.key))return;u.set(r.key,r.value),o&&!f&&(clearTimeout(p),p=setTimeout(g,o))}catch{}}),c.bind(()=>{c.setBroadcast(!0);var o=r();for(var n of(()=>{var e=new Set(["255.255.255.255","127.0.0.1"]);for(var t of l())e.add(t.broadcast);return[...e]})())c.send(o,0,o.length,e,n);d=setTimeout(g,t)})}),c=(r=n(function*(e,t=3e3){var o;try{var r=new AbortController;o=setTimeout(()=>r.abort(),t);var n=yield fetch(e,{signal:r.signal});if(!n.ok)return null;return yield n.json()}catch{return null}finally{void 0!==o&&clearTimeout(o)}}),function(e){return r.apply(this,arguments)})},74049(e,t,o){o.d(t,{Ku:()=>s,w9:()=>a});var r=o(79896),n=o(16928),i=new Set(["CTOR","CTOR Desktop"]),a=e=>{var t,o=`Release by ${(t=process.env.BRICKS_RELEASE_SIGN)&&i.has(t)?t:"BRICKS CLI"}`;return e?`${e}
|
|
101
101
|
|
|
102
102
|
${o}`:o},s=e=>{if(e.endsWith(".json")||e.includes("/")){if(!r.existsSync(e))throw Error(`Config file not found: ${e}`);var t=r.readFileSync(e,"utf-8");return{config:t,source:{type:"file",path:n.resolve(e)},sizeBytes:Buffer.byteLength(t)}}return{config:e,source:{type:"inline"},sizeBytes:Buffer.byteLength(e)}}},68168(e,t,o){o.d(t,{K:()=>a,Y:()=>s});var r,n=o(99436),i=e=>String(e||"").trim().toLowerCase(),a=({resource:e,query:t,items:o,fields:r,selectedBy:n=null})=>{var a=i(t),s=o.filter(e=>r.some(t=>i(t.split(".").reduce((e,t)=>e?.[t],e)??null)===a)),l=null,u=n;return"id"===n?l=o[0]||null:1===s.length?(l=s[0],u="exact"):1===o.length&&(l=o[0],u="single"),{resource:e,query:t,exactMatchCount:s.length,matchCount:o.length,selectedBy:u,ambiguous:o.length>1&&!l,resolved:l,matches:o}},s=(r=n(function*(e){try{return yield e()}catch(e){if(/not found/i.test(e.message))return null;throw e}}),function(e){return r.apply(this,arguments)})},44618(e,t,o){o.d(t,{V:()=>i});var r={S:"Subspace",B:"Brick",C:"Canvas",A:"Animation",G:"Generator",D:"Data",F:"Data Calc",N:"Calc Node",T:"Test",TC:"Test Case",AT:"Automation Map"},n=e=>e?.split("_")?.[0]||"",i=(e,{keyword:t,types:o}={})=>{var i=t?.trim().toLowerCase()||"",a=o?.length>0?new Set(o.flatMap(e=>{var t=String(e).trim().toUpperCase();return t?[t]:[]})):null;return Object.entries(Object.entries(e||{}).filter(([,e])=>e&&!e.hide).filter(([e,t])=>{var o=n(e);if(a&&!a.has(o))return!1;if(!i)return!0;var r=t?.title?String(t.title).toLowerCase():"";return e.toLowerCase().includes(i)||r.includes(i)}).reduce((e,[t,o])=>{var r=n(t);return e[r]||(e[r]=[]),e[r].push({shortId:t,ref:o}),e},{})).map(([e,t])=>({prefix:e,label:r[e]||e,refs:t.sort((e,t)=>{var o=e.ref?.title||e.shortId,r=t.ref?.title||t.shortId;return String(o).localeCompare(String(r))})})).sort((e,t)=>e.label.localeCompare(t.label))}},94979(e,t,o){o.d(t,{p:()=>i});var r=/^(\d+)(s|m|h|d|w)$/,n={s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5};function i(e){var t=e.match(r);if(t){var o=parseInt(t[1],10),i=n[t[2]];return new Date(Date.now()-o*i).toISOString()}var a=new Date(e);if(isNaN(a.getTime()))throw Error(`Invalid time format: "${e}". Use ISO 8601 or relative (e.g. 1h, 30m, 2d)`);return a.toISOString()}},98593(e,t,o){o.d(t,{H_:()=>s,Iy:()=>a,S5:()=>c,jB:()=>l,yd:()=>d});var r=o(73284),n=o(79896),i=o(7586),a=(e,t,o)=>({label:e,ok:t,detail:o}),s=(e,t,{id:o,name:r,...n}={})=>({id:e?._id||t,name:r||e?.name||"Unnamed",...n}),l=(e,t)=>{var o={id:e};return t.name&&(o.name=t.name),t.description&&(o.description=t.description),t.config?o.config=t.config:t.file&&(o.config=n.readFileSync(t.file,"utf-8")),void 0!==o.config&&(o.validateConfig=!1!==t.validate),t.lastCommitId&&(o.lastCommitId=t.lastCommitId),o},u=e=>null==e?r.default.gray("N/A"):"object"==typeof e?r.default.gray(JSON.stringify(e,null,2)):String(e),c=({action:e,target:t,request:o,checks:n=[],json:a=!1})=>{a?(0,i.GF)({ok:!0,dryRun:!0,action:e,target:t||null,request:o||null,checks:n}):(console.log(r.default.bold(`
|
|
@@ -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};
|
package/lib/simulator-main.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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";for(let e of[process.stdout,process.stderr])e.on("error",e=>{if("EPIPE"!==e.code)throw e});let{values:
|
|
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:f}=h;for(let e of[process.stdout,process.stderr])e.on("error",e=>{if("EPIPE"!==e.code)throw e});let{values:g}=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"},"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}},I=async()=>{try{return v(JSON.parse(await n(`${y}/simulator.json`,"utf8")))}catch{return v()}},k=null;try{g["take-screenshot"]&&((k=JSON.parse(g["take-screenshot"])).path||(k.path=`${y}/screenshot.jpg`),k.width||(k.width=1280),k.height||(k.height=768),k.delay||(k.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 I(),T=g["test-id"]||null;if(!T&&g["test-title-like"]){let e=g["test-title-like"].toLowerCase();for(let t of Object.values(J.automation_map||{})){let o=Object.entries(t.map||{}).find(([,t])=>t.title?.toLowerCase().includes(e));if(o){[T]=o;break}}if(!T)throw Error(`No automation found matching title: ${g["test-title-like"]}`)}let j=g["no-keep-open"]??!1,N=process.env.BRICKS_STAGE||"production",L={production:"https://control.bricks.tools/applicationPreview.html",beta:"https://control-beta.bricks.tools/applicationPreview.html",development:"http://localhost:3006/dev-applicationPreview.html"}[N];if(!L)throw Error(`Invalid BRICKS_STAGE: ${N}`);O=v({...O,allowedInsecureHosts:[...O.allowedInsecureHosts,C(L)].filter(Boolean)});let R=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:L,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(`
|
|
2
2
|
if (!window.__cdpRelayInstalled) {
|
|
3
3
|
window.__cdpRelayInstalled = true
|
|
4
4
|
window.addEventListener('message', (evt) => {
|
|
@@ -9,7 +9,7 @@ import{app as e,BrowserWindow as t,ipcMain as o}from"electron";import{mkdir as s
|
|
|
9
9
|
} catch {}
|
|
10
10
|
})
|
|
11
11
|
}
|
|
12
|
-
`),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(
|
|
12
|
+
`),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),f(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,f(r))});let c=!0;k&&!k.noHeadless&&(c=!1);let d=new t({width:k?.width||1280,height:k?.height||768,frame:!k,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(L);let u=()=>{let t={type:"config",configFile:{_originTitle:"Test",...J,title:Math.random().toString()},workspace:{billing:{lock:{},plan:"free"}},showMenu:g["show-menu"]||!1,testId:T};if(d.webContents.executeJavaScript(`window.postMessage(JSON.stringify(${JSON.stringify(t)}))`),k){let{delay:t,width:o,height:s,path:r}=k;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{j&&(console.log("Closing app"),t?e.exit(1):e.quit())}},t)}};d.webContents.once("dom-ready",()=>{u(),T&&d.webContents.executeJavaScript(`
|
|
13
13
|
window.addEventListener('message', (evt) => {
|
|
14
14
|
try {
|
|
15
15
|
const data = JSON.parse(evt.data)
|
|
@@ -18,4 +18,4 @@ import{app as e,BrowserWindow as t,ipcMain as o}from"electron";import{mkdir as s
|
|
|
18
18
|
}
|
|
19
19
|
} catch (e) {}
|
|
20
20
|
})
|
|
21
|
-
`);let e=
|
|
21
|
+
`);let e=g["cdp-port"]?parseInt(g["cdp-port"],10):null;e&&R(d,e)}),T&&d.webContents.on("console-message",(t,...o)=>{let s="object"==typeof o[0]?o[0].message:o[1];if(s?.startsWith("[TEST_RESULT]")){let t=JSON.parse(s.replace("[TEST_RESULT]",""));console.log(`[TEST_RESULT_TOON]${w.encode(t.result)}`),!k&&j&&e.quit()}}),g["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 I();O=v({...e,allowedInsecureHosts:[...e.allowedInsecureHosts,C(L)].filter(Boolean)}),u()}),l(`${y}/simulator.json`,{bigint:!1,persistent:!0,interval:1e3},async()=>{console.log("Detected simulator settings changed");let e=await I();O=v({...e,allowedInsecureHosts:[...e.allowedInsecureHosts,C(L)].filter(Boolean)})})});
|
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.63",
|
|
4
4
|
"description": "BRICKS CLI - Command-line interface for BRICKS Workspace API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bricks",
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
"@babel/parser": "7.28.5",
|
|
57
57
|
"@babel/traverse": "7.28.5",
|
|
58
58
|
"@babel/types": "7.28.5",
|
|
59
|
-
"@fugood/bricks-config-core": "^2.25.0-beta.
|
|
60
|
-
"@fugood/bricks-core-generated": "^2.25.0-beta.
|
|
59
|
+
"@fugood/bricks-config-core": "^2.25.0-beta.63",
|
|
60
|
+
"@fugood/bricks-core-generated": "^2.25.0-beta.63",
|
|
61
61
|
"@fugood/bricks-system-properties-definition": "^2.24.0",
|
|
62
|
-
"@fugood/property-bank-calc-generated": "^2.25.0-beta.
|
|
62
|
+
"@fugood/property-bank-calc-generated": "^2.25.0-beta.63",
|
|
63
63
|
"@huggingface/gguf": "^0.3.2",
|
|
64
64
|
"@iarna/toml": "^3.0.0",
|
|
65
65
|
"@inquirer/prompts": "^7.0.0",
|
|
@@ -90,5 +90,5 @@
|
|
|
90
90
|
"engines": {
|
|
91
91
|
"node": ">=18.0.0"
|
|
92
92
|
},
|
|
93
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "c298a2ceeab7fb5f94db9a165bb31e4486b7f025"
|
|
94
94
|
}
|