@cardstack/boxel-cli 0.0.1
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/LICENSE +21 -0
- package/README.md +111 -0
- package/api.ts +24 -0
- package/dist/index.js +75 -0
- package/package.json +78 -0
- package/src/commands/profile.ts +457 -0
- package/src/commands/realm/create.ts +245 -0
- package/src/commands/realm/index.ts +16 -0
- package/src/commands/realm/pull.ts +245 -0
- package/src/commands/realm/push.ts +379 -0
- package/src/commands/realm/sync.ts +587 -0
- package/src/commands/run-command.ts +186 -0
- package/src/index.ts +47 -0
- package/src/lib/auth.ts +169 -0
- package/src/lib/boxel-cli-client.ts +631 -0
- package/src/lib/checkpoint-manager.ts +609 -0
- package/src/lib/colors.ts +9 -0
- package/src/lib/profile-manager.ts +583 -0
- package/src/lib/realm-sync-base.ts +647 -0
- package/src/lib/sync-logic.ts +169 -0
- package/src/lib/sync-manifest.ts +81 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Cardstack
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Boxel CLI
|
|
2
|
+
|
|
3
|
+
CLI tools for Boxel workspace management.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### Global Installation (Recommended)
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @cardstack/boxel-cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Per-project Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @cardstack/boxel-cli
|
|
17
|
+
npx boxel --help
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Development Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
git clone https://github.com/cardstack/boxel.git
|
|
24
|
+
cd boxel/packages/boxel-cli
|
|
25
|
+
pnpm install
|
|
26
|
+
pnpm build
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
boxel --help
|
|
33
|
+
boxel --version
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Development
|
|
37
|
+
|
|
38
|
+
### Building
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Clean and build bundled executable
|
|
42
|
+
pnpm build
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Development Script
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Run from TypeScript source (no build step required)
|
|
49
|
+
pnpm start
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Code Quality
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Linting
|
|
56
|
+
pnpm lint
|
|
57
|
+
pnpm lint:fix
|
|
58
|
+
|
|
59
|
+
# Type checking
|
|
60
|
+
pnpm lint:types
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Testing
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Run tests
|
|
67
|
+
pnpm test
|
|
68
|
+
|
|
69
|
+
# Run tests in watch mode
|
|
70
|
+
pnpm test:watch
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Publishing
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Version bumping
|
|
77
|
+
pnpm version:patch # 0.0.1 -> 0.0.2
|
|
78
|
+
pnpm version:minor # 0.0.1 -> 0.1.0
|
|
79
|
+
pnpm version:major # 0.0.1 -> 1.0.0
|
|
80
|
+
|
|
81
|
+
# Publishing
|
|
82
|
+
pnpm publish:dry # Dry run to see what would be published
|
|
83
|
+
pnpm publish:npm # Publish to npm registry
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Testing Built Version
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# Build and test locally
|
|
90
|
+
pnpm build
|
|
91
|
+
node dist/index.js --help
|
|
92
|
+
|
|
93
|
+
# Test as installed package
|
|
94
|
+
npm pack
|
|
95
|
+
npm install -g ./cardstack-boxel-cli-0.0.1.tgz
|
|
96
|
+
boxel --help
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Architecture
|
|
100
|
+
|
|
101
|
+
The package uses esbuild to create a standalone executable that bundles all dependencies:
|
|
102
|
+
|
|
103
|
+
- **`boxel`** - Standalone executable for Boxel workspace management
|
|
104
|
+
|
|
105
|
+
## Requirements
|
|
106
|
+
|
|
107
|
+
- Node.js 18 or higher
|
|
108
|
+
|
|
109
|
+
## License
|
|
110
|
+
|
|
111
|
+
MIT
|
package/api.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export {
|
|
2
|
+
BoxelCLIClient,
|
|
3
|
+
type CreateRealmOptions,
|
|
4
|
+
type CreateRealmResult,
|
|
5
|
+
type PullOptions,
|
|
6
|
+
type PullResult,
|
|
7
|
+
type ReadResult,
|
|
8
|
+
type WriteResult,
|
|
9
|
+
type DeleteResult,
|
|
10
|
+
type SearchResult,
|
|
11
|
+
type ListFilesResult,
|
|
12
|
+
type RunCommandResult,
|
|
13
|
+
type LintMessage,
|
|
14
|
+
type LintResult,
|
|
15
|
+
type WaitForReadyResult,
|
|
16
|
+
type WaitForFileOptions,
|
|
17
|
+
type AtomicResult,
|
|
18
|
+
type CancelIndexingResult,
|
|
19
|
+
} from './src/lib/boxel-cli-client';
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
resetProfileManager,
|
|
23
|
+
setProfileManager,
|
|
24
|
+
} from './src/lib/profile-manager';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";var br=Object.create;var lt=Object.defineProperty;var _r=Object.getOwnPropertyDescriptor;var wr=Object.getOwnPropertyNames;var yr=Object.getPrototypeOf,xr=Object.prototype.hasOwnProperty;var M=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var vr=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of wr(e))!xr.call(n,i)&&i!==t&<(n,i,{get:()=>e[i],enumerable:!(r=_r(e,i))||r.enumerable});return n};var k=(n,e,t)=>(t=n!=null?br(yr(n)):{},vr(e||!n||!n.__esModule?lt(t,"default",{value:n,enumerable:!0}):t,n));var ct=M((Wi,Er)=>{Er.exports={name:"dotenv",version:"16.6.1",description:"Loads environment variables from .env file",main:"lib/main.js",types:"lib/main.d.ts",exports:{".":{types:"./lib/main.d.ts",require:"./lib/main.js",default:"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},scripts:{"dts-check":"tsc --project tests/types/tsconfig.json",lint:"standard",pretest:"npm run lint && npm run dts-check",test:"tap run --allow-empty-coverage --disable-coverage --timeout=60000","test:coverage":"tap run --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",prerelease:"npm test",release:"standard-version"},repository:{type:"git",url:"git://github.com/motdotla/dotenv.git"},homepage:"https://github.com/motdotla/dotenv#readme",funding:"https://dotenvx.com",keywords:["dotenv","env",".env","environment","variables","config","settings"],readmeFilename:"README.md",license:"BSD-2-Clause",devDependencies:{"@types/node":"^18.11.3",decache:"^4.6.2",sinon:"^14.0.1",standard:"^17.0.0","standard-version":"^9.5.0",tap:"^19.2.0",typescript:"^4.8.4"},engines:{node:">=12"},browser:{fs:!1}}});var ft=M((Bi,I)=>{var ye=require("fs"),ae=require("path"),$r=require("os"),Cr=require("crypto"),Or=ct(),xe=Or.version,Pr=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function Ar(n){let e={},t=n.toString();t=t.replace(/\r\n?/mg,`
|
|
3
|
+
`);let r;for(;(r=Pr.exec(t))!=null;){let i=r[1],s=r[2]||"";s=s.trim();let o=s[0];s=s.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),o==='"'&&(s=s.replace(/\\n/g,`
|
|
4
|
+
`),s=s.replace(/\\r/g,"\r")),e[i]=s}return e}function kr(n){n=n||{};let e=dt(n);n.path=e;let t=E.configDotenv(n);if(!t.parsed){let o=new Error(`MISSING_DATA: Cannot parse ${e} for an unknown reason`);throw o.code="MISSING_DATA",o}let r=pt(n).split(","),i=r.length,s;for(let o=0;o<i;o++)try{let a=r[o].trim(),l=Sr(t,a);s=E.decrypt(l.ciphertext,l.key);break}catch(a){if(o+1>=i)throw a}return E.parse(s)}function Rr(n){console.log(`[dotenv@${xe}][WARN] ${n}`)}function Z(n){console.log(`[dotenv@${xe}][DEBUG] ${n}`)}function ht(n){console.log(`[dotenv@${xe}] ${n}`)}function pt(n){return n&&n.DOTENV_KEY&&n.DOTENV_KEY.length>0?n.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function Sr(n,e){let t;try{t=new URL(e)}catch(a){if(a.code==="ERR_INVALID_URL"){let l=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw l.code="INVALID_DOTENV_KEY",l}throw a}let r=t.password;if(!r){let a=new Error("INVALID_DOTENV_KEY: Missing key part");throw a.code="INVALID_DOTENV_KEY",a}let i=t.searchParams.get("environment");if(!i){let a=new Error("INVALID_DOTENV_KEY: Missing environment part");throw a.code="INVALID_DOTENV_KEY",a}let s=`DOTENV_VAULT_${i.toUpperCase()}`,o=n.parsed[s];if(!o){let a=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${s} in your .env.vault file.`);throw a.code="NOT_FOUND_DOTENV_ENVIRONMENT",a}return{ciphertext:o,key:r}}function dt(n){let e=null;if(n&&n.path&&n.path.length>0)if(Array.isArray(n.path))for(let t of n.path)ye.existsSync(t)&&(e=t.endsWith(".vault")?t:`${t}.vault`);else e=n.path.endsWith(".vault")?n.path:`${n.path}.vault`;else e=ae.resolve(process.cwd(),".env.vault");return ye.existsSync(e)?e:null}function ut(n){return n[0]==="~"?ae.join($r.homedir(),n.slice(1)):n}function Tr(n){let e=!!(n&&n.debug),t=n&&"quiet"in n?n.quiet:!0;(e||!t)&&ht("Loading env from encrypted .env.vault");let r=E._parseVault(n),i=process.env;return n&&n.processEnv!=null&&(i=n.processEnv),E.populate(i,r,n),{parsed:r}}function Mr(n){let e=ae.resolve(process.cwd(),".env"),t="utf8",r=!!(n&&n.debug),i=n&&"quiet"in n?n.quiet:!0;n&&n.encoding?t=n.encoding:r&&Z("No encoding is specified. UTF-8 is used by default");let s=[e];if(n&&n.path)if(!Array.isArray(n.path))s=[ut(n.path)];else{s=[];for(let u of n.path)s.push(ut(u))}let o,a={};for(let u of s)try{let c=E.parse(ye.readFileSync(u,{encoding:t}));E.populate(a,c,n)}catch(c){r&&Z(`Failed to load ${u} ${c.message}`),o=c}let l=process.env;if(n&&n.processEnv!=null&&(l=n.processEnv),E.populate(l,a,n),r||!i){let u=Object.keys(a).length,c=[];for(let h of s)try{let p=ae.relative(process.cwd(),h);c.push(p)}catch(p){r&&Z(`Failed to load ${h} ${p.message}`),o=p}ht(`injecting env (${u}) from ${c.join(",")}`)}return o?{parsed:a,error:o}:{parsed:a}}function Nr(n){if(pt(n).length===0)return E.configDotenv(n);let e=dt(n);return e?E._configVault(n):(Rr(`You set DOTENV_KEY but you are missing a .env.vault file at ${e}. Did you forget to build it?`),E.configDotenv(n))}function Dr(n,e){let t=Buffer.from(e.slice(-64),"hex"),r=Buffer.from(n,"base64"),i=r.subarray(0,12),s=r.subarray(-16);r=r.subarray(12,-16);try{let o=Cr.createDecipheriv("aes-256-gcm",t,i);return o.setAuthTag(s),`${o.update(r)}${o.final()}`}catch(o){let a=o instanceof RangeError,l=o.message==="Invalid key length",u=o.message==="Unsupported state or unable to authenticate data";if(a||l){let c=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw c.code="INVALID_DOTENV_KEY",c}else if(u){let c=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw c.code="DECRYPTION_FAILED",c}else throw o}}function Fr(n,e,t={}){let r=!!(t&&t.debug),i=!!(t&&t.override);if(typeof e!="object"){let s=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw s.code="OBJECT_REQUIRED",s}for(let s of Object.keys(e))Object.prototype.hasOwnProperty.call(n,s)?(i===!0&&(n[s]=e[s]),r&&Z(i===!0?`"${s}" is already defined and WAS overwritten`:`"${s}" is already defined and was NOT overwritten`)):n[s]=e[s]}var E={configDotenv:Mr,_configVault:Tr,_parseVault:kr,config:Nr,decrypt:Dr,parse:Ar,populate:Fr};I.exports.configDotenv=E.configDotenv;I.exports._configVault=E._configVault;I.exports._parseVault=E._parseVault;I.exports.config=E.config;I.exports.decrypt=E.decrypt;I.exports.parse=E.parse;I.exports.populate=E.populate;I.exports=E});var gt=M((qi,mt)=>{var Y={};process.env.DOTENV_CONFIG_ENCODING!=null&&(Y.encoding=process.env.DOTENV_CONFIG_ENCODING);process.env.DOTENV_CONFIG_PATH!=null&&(Y.path=process.env.DOTENV_CONFIG_PATH);process.env.DOTENV_CONFIG_QUIET!=null&&(Y.quiet=process.env.DOTENV_CONFIG_QUIET);process.env.DOTENV_CONFIG_DEBUG!=null&&(Y.debug=process.env.DOTENV_CONFIG_DEBUG);process.env.DOTENV_CONFIG_OVERRIDE!=null&&(Y.override=process.env.DOTENV_CONFIG_OVERRIDE);process.env.DOTENV_CONFIG_DOTENV_KEY!=null&&(Y.DOTENV_KEY=process.env.DOTENV_CONFIG_DOTENV_KEY);mt.exports=Y});var _t=M((Yi,bt)=>{var Lr=/^dotenv_config_(encoding|path|quiet|debug|override|DOTENV_KEY)=(.+)$/;bt.exports=function(e){let t=e.reduce(function(r,i){let s=i.match(Lr);return s&&(r[s[1]]=s[2]),r},{});return"quiet"in t||(t.quiet="true"),t}});var ee=M(Ee=>{var le=class extends Error{constructor(e,t,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},ve=class extends le{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};Ee.CommanderError=le;Ee.InvalidArgumentError=ve});var ce=M(Ce=>{var{InvalidArgumentError:Ur}=ee(),$e=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new Ur(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Ir(n){let e=n.name()+(n.variadic===!0?"...":"");return n.required?"<"+e+">":"["+e+"]"}Ce.Argument=$e;Ce.humanReadableArgName=Ir});var Ae=M(Pe=>{var{humanReadableArgName:jr}=ce(),Oe=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(i=>!i._hidden),r=e._getHelpCommand();return r&&!r._hidden&&t.push(r),this.sortSubcommands&&t.sort((i,s)=>i.name().localeCompare(s.name())),t}compareOptions(e,t){let r=i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,"");return r(e).localeCompare(r(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),r=e._getHelpOption();if(r&&!r.hidden){let i=r.short&&e._findOption(r.short),s=r.long&&e._findOption(r.long);!i&&!s?t.push(r):r.long&&!s?t.push(e.createOption(r.long,r.description)):r.short&&!i&&t.push(e.createOption(r.short,r.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let r=e.parent;r;r=r.parent){let i=r.options.filter(s=>!s.hidden);t.push(...i)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(r=>jr(r)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(i)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(i)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let r="";for(let i=e.parent;i;i=i.parent)r=i.name()+" "+r;return r+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];return e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}formatHelp(e,t){let r=t.padWidth(e,t),i=t.helpWidth??80;function s(h,p){return t.formatItem(h,r,p,t)}let o=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],a=t.commandDescription(e);a.length>0&&(o=o.concat([t.boxWrap(t.styleCommandDescription(a),i),""]));let l=t.visibleArguments(e).map(h=>s(t.styleArgumentTerm(t.argumentTerm(h)),t.styleArgumentDescription(t.argumentDescription(h))));l.length>0&&(o=o.concat([t.styleTitle("Arguments:"),...l,""]));let u=t.visibleOptions(e).map(h=>s(t.styleOptionTerm(t.optionTerm(h)),t.styleOptionDescription(t.optionDescription(h))));if(u.length>0&&(o=o.concat([t.styleTitle("Options:"),...u,""])),t.showGlobalOptions){let h=t.visibleGlobalOptions(e).map(p=>s(t.styleOptionTerm(t.optionTerm(p)),t.styleOptionDescription(t.optionDescription(p))));h.length>0&&(o=o.concat([t.styleTitle("Global Options:"),...h,""]))}let c=t.visibleCommands(e).map(h=>s(t.styleSubcommandTerm(t.subcommandTerm(h)),t.styleSubcommandDescription(t.subcommandDescription(h))));return c.length>0&&(o=o.concat([t.styleTitle("Commands:"),...c,""])),o.join(`
|
|
5
|
+
`)}displayWidth(e){return wt(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t==="[command]"?this.styleSubcommandText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,r,i){let o=" ".repeat(2);if(!r)return o+e;let a=e.padEnd(t+e.length-i.displayWidth(e)),l=2,c=(this.helpWidth??80)-t-l-2,h;return c<this.minWidthToWrap||i.preformatted(r)?h=r:h=i.boxWrap(r,c).replace(/\n/g,`
|
|
6
|
+
`+" ".repeat(t+l)),o+a+" ".repeat(l)+h.replace(/\n/g,`
|
|
7
|
+
${o}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let r=e.split(/\r\n|\n/),i=/[\s]*[^\s]+/g,s=[];return r.forEach(o=>{let a=o.match(i);if(a===null){s.push("");return}let l=[a.shift()],u=this.displayWidth(l[0]);a.forEach(c=>{let h=this.displayWidth(c);if(u+h<=t){l.push(c),u+=h;return}s.push(l.join(""));let p=c.trimStart();l=[p],u=this.displayWidth(p)}),s.push(l.join(""))}),s.join(`
|
|
8
|
+
`)}};function wt(n){let e=/\x1b\[\d*(;\d*)*m/g;return n.replace(e,"")}Pe.Help=Oe;Pe.stripColor=wt});var Te=M(Se=>{var{InvalidArgumentError:Vr}=ee(),ke=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let r=Hr(e);this.short=r.shortFlag,this.long=r.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new Vr(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?yt(this.name().replace(/^no-/,"")):yt(this.name())}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Re=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,r)=>{this.positiveOptions.has(r)&&this.dualOptions.add(r)})}valueFromOption(e,t){let r=t.attributeName();if(!this.dualOptions.has(r))return!0;let i=this.negativeOptions.get(r).presetArg,s=i!==void 0?i:!1;return t.negate===(s===e)}};function yt(n){return n.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Hr(n){let e,t,r=/^-[^-]$/,i=/^--[^-]/,s=n.split(/[ |,]+/).concat("guard");if(r.test(s[0])&&(e=s.shift()),i.test(s[0])&&(t=s.shift()),!e&&r.test(s[0])&&(e=s.shift()),!e&&i.test(s[0])&&(e=t,t=s.shift()),s[0].startsWith("-")){let o=s[0],a=`option creation failed due to '${o}' in option flags '${n}'`;throw/^-[^-][^-]/.test(o)?new Error(`${a}
|
|
9
|
+
- a short flag is a single dash and a single character
|
|
10
|
+
- either use a single dash and a single character (for a short flag)
|
|
11
|
+
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):r.test(o)?new Error(`${a}
|
|
12
|
+
- too many short flags`):i.test(o)?new Error(`${a}
|
|
13
|
+
- too many long flags`):new Error(`${a}
|
|
14
|
+
- unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${n}'.`);return{shortFlag:e,longFlag:t}}Se.Option=ke;Se.DualOptions=Re});var vt=M(xt=>{function Gr(n,e){if(Math.abs(n.length-e.length)>3)return Math.max(n.length,e.length);let t=[];for(let r=0;r<=n.length;r++)t[r]=[r];for(let r=0;r<=e.length;r++)t[0][r]=r;for(let r=1;r<=e.length;r++)for(let i=1;i<=n.length;i++){let s=1;n[i-1]===e[r-1]?s=0:s=1,t[i][r]=Math.min(t[i-1][r]+1,t[i][r-1]+1,t[i-1][r-1]+s),i>1&&r>1&&n[i-1]===e[r-2]&&n[i-2]===e[r-1]&&(t[i][r]=Math.min(t[i][r],t[i-2][r-2]+1))}return t[n.length][e.length]}function Wr(n,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=n.startsWith("--");t&&(n=n.slice(2),e=e.map(o=>o.slice(2)));let r=[],i=3,s=.4;return e.forEach(o=>{if(o.length<=1)return;let a=Gr(n,o),l=Math.max(n.length,o.length);(l-a)/l>s&&(a<i?(i=a,r=[o]):a===i&&r.push(o))}),r.sort((o,a)=>o.localeCompare(a)),t&&(r=r.map(o=>`--${o}`)),r.length>1?`
|
|
15
|
+
(Did you mean one of ${r.join(", ")}?)`:r.length===1?`
|
|
16
|
+
(Did you mean ${r[0]}?)`:""}xt.suggestSimilar=Wr});var Ot=M(Le=>{var Br=require("node:events").EventEmitter,Me=require("node:child_process"),j=require("node:path"),ue=require("node:fs"),w=require("node:process"),{Argument:qr,humanReadableArgName:Yr}=ce(),{CommanderError:Ne}=ee(),{Help:zr,stripColor:Xr}=Ae(),{Option:Et,DualOptions:Kr}=Te(),{suggestSimilar:$t}=vt(),De=class n extends Br{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:t=>w.stdout.write(t),writeErr:t=>w.stderr.write(t),outputError:(t,r)=>r(t),getOutHelpWidth:()=>w.stdout.isTTY?w.stdout.columns:void 0,getErrHelpWidth:()=>w.stderr.isTTY?w.stderr.columns:void 0,getOutHasColors:()=>Fe()??(w.stdout.isTTY&&w.stdout.hasColors?.()),getErrHasColors:()=>Fe()??(w.stderr.isTTY&&w.stderr.hasColors?.()),stripColor:t=>Xr(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,r){let i=t,s=r;typeof i=="object"&&i!==null&&(s=i,i=null),s=s||{};let[,o,a]=e.match(/([^ ]+) *(.*)/),l=this.createCommand(o);return i&&(l.description(i),l._executableHandler=!0),s.isDefault&&(this._defaultCommandName=l._name),l._hidden=!!(s.noHelp||s.hidden),l._executableFile=s.executableFile||null,a&&l.arguments(a),this._registerCommand(l),l.parent=this,l.copyInheritedSettings(this),i?this:l}createCommand(e){return new n(e)}createHelp(){return Object.assign(new zr,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
|
|
17
|
+
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new qr(e,t)}argument(e,t,r,i){let s=this.createArgument(e,t);return typeof r=="function"?s.default(i).argParser(r):s.default(r),this.addArgument(s),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,this;e=e??"help [command]";let[,r,i]=e.match(/([^ ]+) *(.*)/),s=t??"display help for command",o=this.createCommand(r);return o.helpOption(!1),i&&o.arguments(i),s&&o.description(s),this._addImplicitHelpCommand=!0,this._helpCommand=o,this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let r=["preSubcommand","preAction","postAction"];if(!r.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
|
|
18
|
+
Expecting one of '${r.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,r){this._exitCallback&&this._exitCallback(new Ne(e,t,r)),w.exit(e)}action(e){let t=r=>{let i=this.registeredArguments.length,s=r.slice(0,i);return this._storeOptionsAsProperties?s[i]=this:s[i]=this.opts(),s.push(this),e.apply(this,s)};return this._actionHandler=t,this}createOption(e,t){return new Et(e,t)}_callParseArg(e,t,r,i){try{return e.parseArg(t,r)}catch(s){if(s.code==="commander.invalidArgument"){let o=`${i} ${s.message}`;this.error(o,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let r=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${r}'
|
|
19
|
+
- already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=i=>[i.name()].concat(i.aliases()),r=t(e).find(i=>this._findCommand(i));if(r){let i=t(this._findCommand(r)).join("|"),s=t(e).join("|");throw new Error(`cannot add command '${s}' as already have command '${i}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),r=e.attributeName();if(e.negate){let s=e.long.replace(/^--no-/,"--");this._findOption(s)||this.setOptionValueWithSource(r,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(r,e.defaultValue,"default");let i=(s,o,a)=>{s==null&&e.presetArg!==void 0&&(s=e.presetArg);let l=this.getOptionValue(r);s!==null&&e.parseArg?s=this._callParseArg(e,s,l,o):s!==null&&e.variadic&&(s=e._concatValue(s,l)),s==null&&(e.negate?s=!1:e.isBoolean()||e.optional?s=!0:s=""),this.setOptionValueWithSource(r,s,a)};return this.on("option:"+t,s=>{let o=`error: option '${e.flags}' argument '${s}' is invalid.`;i(s,o,"cli")}),e.envVar&&this.on("optionEnv:"+t,s=>{let o=`error: option '${e.flags}' value '${s}' from env '${e.envVar}' is invalid.`;i(s,o,"env")}),this}_optionEx(e,t,r,i,s){if(typeof t=="object"&&t instanceof Et)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(t,r);if(o.makeOptionMandatory(!!e.mandatory),typeof i=="function")o.default(s).argParser(i);else if(i instanceof RegExp){let a=i;i=(l,u)=>{let c=a.exec(l);return c?c[0]:u},o.default(s).argParser(i)}else o.default(i);return this.addOption(o)}option(e,t,r,i){return this._optionEx({},e,t,r,i)}requiredOption(e,t,r,i){return this._optionEx({mandatory:!0},e,t,r,i)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,r){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=r,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(r=>{r.getOptionValueSource(e)!==void 0&&(t=r.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){w.versions?.electron&&(t.from="electron");let i=w.execArgv??[];(i.includes("-e")||i.includes("--eval")||i.includes("-p")||i.includes("--print"))&&(t.from="eval")}e===void 0&&(e=w.argv),this.rawArgs=e.slice();let r;switch(t.from){case void 0:case"node":this._scriptPath=e[1],r=e.slice(2);break;case"electron":w.defaultApp?(this._scriptPath=e[1],r=e.slice(2)):r=e.slice(1);break;case"user":r=e.slice(0);break;case"eval":r=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",r}parse(e,t){this._prepareForParse();let r=this._prepareUserArgs(e,t);return this._parseCommand([],r),this}async parseAsync(e,t){this._prepareForParse();let r=this._prepareUserArgs(e,t);return await this._parseCommand([],r),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
20
|
+
- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,r){if(ue.existsSync(e))return;let i=t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",s=`'${e}' does not exist
|
|
21
|
+
- if '${r}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
22
|
+
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
23
|
+
- ${i}`;throw new Error(s)}_executeSubCommand(e,t){t=t.slice();let r=!1,i=[".js",".ts",".tsx",".mjs",".cjs"];function s(c,h){let p=j.resolve(c,h);if(ue.existsSync(p))return p;if(i.includes(j.extname(h)))return;let f=i.find(g=>ue.existsSync(`${p}${g}`));if(f)return`${p}${f}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=e._executableFile||`${this._name}-${e._name}`,a=this._executableDir||"";if(this._scriptPath){let c;try{c=ue.realpathSync(this._scriptPath)}catch{c=this._scriptPath}a=j.resolve(j.dirname(c),a)}if(a){let c=s(a,o);if(!c&&!e._executableFile&&this._scriptPath){let h=j.basename(this._scriptPath,j.extname(this._scriptPath));h!==this._name&&(c=s(a,`${h}-${e._name}`))}o=c||o}r=i.includes(j.extname(o));let l;w.platform!=="win32"?r?(t.unshift(o),t=Ct(w.execArgv).concat(t),l=Me.spawn(w.argv[0],t,{stdio:"inherit"})):l=Me.spawn(o,t,{stdio:"inherit"}):(this._checkForMissingExecutable(o,a,e._name),t.unshift(o),t=Ct(w.execArgv).concat(t),l=Me.spawn(w.execPath,t,{stdio:"inherit"})),l.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(h=>{w.on(h,()=>{l.killed===!1&&l.exitCode===null&&l.kill(h)})});let u=this._exitCallback;l.on("close",c=>{c=c??1,u?u(new Ne(c,"commander.executeSubCommandAsync","(close)")):w.exit(c)}),l.on("error",c=>{if(c.code==="ENOENT")this._checkForMissingExecutable(o,a,e._name);else if(c.code==="EACCES")throw new Error(`'${o}' not executable`);if(!u)w.exit(1);else{let h=new Ne(1,"commander.executeSubCommandAsync","(error)");h.nestedError=c,u(h)}}),this.runningCommand=l}_dispatchSubcommand(e,t,r){let i=this._findCommand(e);i||this.help({error:!0}),i._prepareForParse();let s;return s=this._chainOrCallSubCommandHook(s,i,"preSubcommand"),s=this._chainOrCall(s,()=>{if(i._executableHandler)this._executeSubCommand(i,t.concat(r));else return i._parseCommand(t,r)}),s}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(r,i,s)=>{let o=i;if(i!==null&&r.parseArg){let a=`error: command-argument value '${i}' is invalid for argument '${r.name()}'.`;o=this._callParseArg(r,i,s,a)}return o};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((r,i)=>{let s=r.defaultValue;r.variadic?i<this.args.length?(s=this.args.slice(i),r.parseArg&&(s=s.reduce((o,a)=>e(r,a,o),r.defaultValue))):s===void 0&&(s=[]):i<this.args.length&&(s=this.args[i],r.parseArg&&(s=e(r,s,r.defaultValue))),t[i]=s}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let r=e,i=[];return this._getCommandAndAncestors().reverse().filter(s=>s._lifeCycleHooks[t]!==void 0).forEach(s=>{s._lifeCycleHooks[t].forEach(o=>{i.push({hookedCommand:s,callback:o})})}),t==="postAction"&&i.reverse(),i.forEach(s=>{r=this._chainOrCall(r,()=>s.callback(s.hookedCommand,this))}),r}_chainOrCallSubCommandHook(e,t,r){let i=e;return this._lifeCycleHooks[r]!==void 0&&this._lifeCycleHooks[r].forEach(s=>{i=this._chainOrCall(i,()=>s(this,t))}),i}_parseCommand(e,t){let r=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(r.operands),t=r.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(r.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i=()=>{r.unknown.length>0&&this.unknownOption(r.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){i(),this._processArguments();let o;return o=this._chainOrCallHooks(o,"preAction"),o=this._chainOrCall(o,()=>this._actionHandler(this.processedArgs)),this.parent&&(o=this._chainOrCall(o,()=>{this.parent.emit(s,e,t)})),o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent&&this.parent.listenerCount(s))i(),this._processArguments(),this.parent.emit(s,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(i(),this._processArguments())}else this.commands.length?(i(),this.help({error:!0})):(i(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(r=>{let i=r.attributeName();return this.getOptionValue(i)===void 0?!1:this.getOptionValueSource(i)!=="default"});e.filter(r=>r.conflictsWith.length>0).forEach(r=>{let i=e.find(s=>r.conflictsWith.includes(s.attributeName()));i&&this._conflictingOption(r,i)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],r=[],i=t,s=e.slice();function o(l){return l.length>1&&l[0]==="-"}let a=null;for(;s.length;){let l=s.shift();if(l==="--"){i===r&&i.push(l),i.push(...s);break}if(a&&!o(l)){this.emit(`option:${a.name()}`,l);continue}if(a=null,o(l)){let u=this._findOption(l);if(u){if(u.required){let c=s.shift();c===void 0&&this.optionMissingArgument(u),this.emit(`option:${u.name()}`,c)}else if(u.optional){let c=null;s.length>0&&!o(s[0])&&(c=s.shift()),this.emit(`option:${u.name()}`,c)}else this.emit(`option:${u.name()}`);a=u.variadic?u:null;continue}}if(l.length>2&&l[0]==="-"&&l[1]!=="-"){let u=this._findOption(`-${l[1]}`);if(u){u.required||u.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${u.name()}`,l.slice(2)):(this.emit(`option:${u.name()}`),s.unshift(`-${l.slice(2)}`));continue}}if(/^--[^=]+=/.test(l)){let u=l.indexOf("="),c=this._findOption(l.slice(0,u));if(c&&(c.required||c.optional)){this.emit(`option:${c.name()}`,l.slice(u+1));continue}}if(o(l)&&(i=r),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&r.length===0){if(this._findCommand(l)){t.push(l),s.length>0&&r.push(...s);break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l),s.length>0&&t.push(...s);break}else if(this._defaultCommandName){r.push(l),s.length>0&&r.push(...s);break}}if(this._passThroughOptions){i.push(l),s.length>0&&i.push(...s);break}i.push(l)}return{operands:t,unknown:r}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let r=0;r<t;r++){let i=this.options[r].attributeName();e[i]=i===this._versionOptionName?this._version:this[i]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
|
|
24
|
+
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
25
|
+
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
26
|
+
`),this.outputHelp({error:!0}));let r=t||{},i=r.exitCode||1,s=r.code||"commander.error";this._exit(i,s,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in w.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,w.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Kr(this.options),t=r=>this.getOptionValue(r)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(r));this.options.filter(r=>r.implied!==void 0&&t(r.attributeName())&&e.valueFromOption(this.getOptionValue(r.attributeName()),r)).forEach(r=>{Object.keys(r.implied).filter(i=>!t(i)).forEach(i=>{this.setOptionValueWithSource(i,r.implied[i],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let r=o=>{let a=o.attributeName(),l=this.getOptionValue(a),u=this.options.find(h=>h.negate&&a===h.attributeName()),c=this.options.find(h=>!h.negate&&a===h.attributeName());return u&&(u.presetArg===void 0&&l===!1||u.presetArg!==void 0&&l===u.presetArg)?u:c||o},i=o=>{let a=r(o),l=a.attributeName();return this.getOptionValueSource(l)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},s=`error: ${i(e)} cannot be used with ${i(t)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[],s=this;do{let o=s.createHelp().visibleOptions(s).filter(a=>a.long).map(a=>a.long);i=i.concat(o),s=s.parent}while(s&&!s._enablePositionalOptions);t=$t(e,i)}let r=`error: unknown option '${e}'${t}`;this.error(r,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,r=t===1?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${r} but got ${e.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let i=[];this.createHelp().visibleCommands(this).forEach(s=>{i.push(s.name()),s.alias()&&i.push(s.alias())}),t=$t(e,i)}let r=`error: unknown command '${e}'${t}`;this.error(r,{code:"commander.unknownCommand"})}version(e,t,r){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",r=r||"output the version number";let i=this.createOption(t,r);return this._versionOptionName=i.attributeName(),this._registerOption(i),this.on("option:"+i.name(),()=>{this._outputConfiguration.writeOut(`${e}
|
|
27
|
+
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let r=this.parent?._findCommand(e);if(r){let i=[r.name()].concat(r.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${i}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(r=>Yr(r));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=j.basename(e,j.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),r=this._getOutputContext(e);t.prepareContext({error:r.error,helpWidth:r.helpWidth,outputHasColors:r.hasColors});let i=t.formatHelp(this,t);return r.hasColors?i:this._outputConfiguration.stripColor(i)}_getOutputContext(e){e=e||{};let t=!!e.error,r,i,s;return t?(r=a=>this._outputConfiguration.writeErr(a),i=this._outputConfiguration.getErrHasColors(),s=this._outputConfiguration.getErrHelpWidth()):(r=a=>this._outputConfiguration.writeOut(a),i=this._outputConfiguration.getOutHasColors(),s=this._outputConfiguration.getOutHelpWidth()),{error:t,write:a=>(i||(a=this._outputConfiguration.stripColor(a)),r(a)),hasColors:i,helpWidth:s}}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let r=this._getOutputContext(e),i={error:r.error,write:r.write,command:this};this._getCommandAndAncestors().reverse().forEach(o=>o.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let s=this.helpInformation({error:r.error});if(t&&(s=t(s),typeof s!="string"&&!Buffer.isBuffer(s)))throw new Error("outputHelp callback must return a string or a Buffer");r.write(s),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach(o=>o.emit("afterAllHelp",i))}helpOption(e,t){return typeof e=="boolean"?(e?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(e=e??"-h, --help",t=t??"display help for command",this._helpOption=this.createOption(e,t),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let t=Number(w.exitCode??0);t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let r=["beforeAll","before","after","afterAll"];if(!r.includes(e))throw new Error(`Unexpected value for position to addHelpText.
|
|
28
|
+
Expecting one of '${r.join("', '")}'`);let i=`${e}Help`;return this.on(i,s=>{let o;typeof t=="function"?o=t({error:s.error,command:s.command}):o=t,o&&s.write(`${o}
|
|
29
|
+
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(i=>t.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Ct(n){return n.map(e=>{if(!e.startsWith("--inspect"))return e;let t,r="127.0.0.1",i="9229",s;return(s=e.match(/^(--inspect(-brk)?)$/))!==null?t=s[1]:(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=s[1],/^\d+$/.test(s[3])?i=s[3]:r=s[3]):(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=s[1],r=s[3],i=s[4]),t&&i!=="0"?`${t}=${r}:${parseInt(i)+1}`:e})}function Fe(){if(w.env.NO_COLOR||w.env.FORCE_COLOR==="0"||w.env.FORCE_COLOR==="false")return!1;if(w.env.FORCE_COLOR||w.env.CLICOLOR_FORCE!==void 0)return!0}Le.Command=De;Le.useColor=Fe});var Rt=M(N=>{var{Argument:Pt}=ce(),{Command:Ue}=Ot(),{CommanderError:Jr,InvalidArgumentError:At}=ee(),{Help:Qr}=Ae(),{Option:kt}=Te();N.program=new Ue;N.createCommand=n=>new Ue(n);N.createOption=(n,e)=>new kt(n,e);N.createArgument=(n,e)=>new Pt(n,e);N.Command=Ue;N.Option=kt;N.Argument=Pt;N.Help=Qr;N.CommanderError=Jr;N.InvalidArgumentError=At;N.InvalidOptionArgumentError=At});var Jt=M((bs,Kt)=>{function Gt(n){return Array.isArray(n)?n:[n]}var Xe="",Wt=" ",Ye="\\",gi=/^\s+$/,bi=/(?:[^\\]|^)\\$/,_i=/^\\!/,wi=/^\\#/,yi=/\r?\n/g,xi=/^\.*\/|^\.+$/,ze="/",Yt="node-ignore";typeof Symbol<"u"&&(Yt=Symbol.for("node-ignore"));var Bt=Yt,vi=(n,e,t)=>Object.defineProperty(n,e,{value:t}),Ei=/([0-z])-([0-z])/g,zt=()=>!1,$i=n=>n.replace(Ei,(e,t,r)=>t.charCodeAt(0)<=r.charCodeAt(0)?e:Xe),Ci=n=>{let{length:e}=n;return n.slice(0,e-e%2)},Oi=[[/^\uFEFF/,()=>Xe],[/((?:\\\\)*?)(\\?\s+)$/,(n,e,t)=>e+(t.indexOf("\\")===0?Wt:Xe)],[/(\\+?)\s/g,(n,e)=>{let{length:t}=e;return e.slice(0,t-t%2)+Wt}],[/[\\$.|*+(){^]/g,n=>`\\${n}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(n,e,t)=>e+6<t.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(n,e,t)=>{let r=t.replace(/\\\*/g,"[^\\/]*");return e+r}],[/\\\\\\(?=[$.|*+(){^])/g,()=>Ye],[/\\\\/g,()=>Ye],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(n,e,t,r,i)=>e===Ye?`\\[${t}${Ci(r)}${i}`:i==="]"&&r.length%2===0?`[${$i(t)}${r}]`:"[]"],[/(?:[^*])$/,n=>/\/$/.test(n)?`${n}$`:`${n}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(n,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],qt=Object.create(null),Pi=(n,e)=>{let t=qt[n];return t||(t=Oi.reduce((r,[i,s])=>r.replace(i,s.bind(n)),n),qt[n]=t),e?new RegExp(t,"i"):new RegExp(t)},Qe=n=>typeof n=="string",Ai=n=>n&&Qe(n)&&!gi.test(n)&&!bi.test(n)&&n.indexOf("#")!==0,ki=n=>n.split(yi),Ke=class{constructor(e,t,r,i){this.origin=e,this.pattern=t,this.negative=r,this.regex=i}},Ri=(n,e)=>{let t=n,r=!1;n.indexOf("!")===0&&(r=!0,n=n.substr(1)),n=n.replace(_i,"!").replace(wi,"#");let i=Pi(n,e);return new Ke(t,n,r,i)},Si=(n,e)=>{throw new e(n)},V=(n,e,t)=>Qe(n)?n?V.isNotRelative(n)?t(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:t("path must not be empty",TypeError):t(`path must be a string, but got \`${e}\``,TypeError),Xt=n=>xi.test(n);V.isNotRelative=Xt;V.convert=n=>n;var Je=class{constructor({ignorecase:e=!0,ignoreCase:t=e,allowRelativePaths:r=!1}={}){vi(this,Bt,!0),this._rules=[],this._ignoreCase=t,this._allowRelativePaths=r,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}_addPattern(e){if(e&&e[Bt]){this._rules=this._rules.concat(e._rules),this._added=!0;return}if(Ai(e)){let t=Ri(e,this._ignoreCase);this._added=!0,this._rules.push(t)}}add(e){return this._added=!1,Gt(Qe(e)?ki(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this}addPattern(e){return this.add(e)}_testOne(e,t){let r=!1,i=!1;return this._rules.forEach(s=>{let{negative:o}=s;if(i===o&&r!==i||o&&!r&&!i&&!t)return;s.regex.test(e)&&(r=!o,i=o)}),{ignored:r,unignored:i}}_test(e,t,r,i){let s=e&&V.convert(e);return V(s,e,this._allowRelativePaths?zt:Si),this._t(s,t,r,i)}_t(e,t,r,i){if(e in t)return t[e];if(i||(i=e.split(ze)),i.pop(),!i.length)return t[e]=this._testOne(e,r);let s=this._t(i.join(ze)+ze,t,r,i);return t[e]=s.ignored?s:this._testOne(e,r)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return Gt(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}},pe=n=>new Je(n),Ti=n=>V(n&&V.convert(n),n,zt);pe.isPathValid=Ti;pe.default=pe;Kt.exports=pe;if(typeof process<"u"&&(process.env&&process.env.IGNORE_TEST_WIN32||process.platform==="win32")){let n=t=>/^\\\\\?\\/.test(t)||/["<>|\u0000-\u001F]+/u.test(t)?t:t.replace(/\\/g,"/");V.convert=n;let e=/^[a-z]:\//i;V.isNotRelative=t=>e.test(t)||Xt(t)}});(function(){ft().config(Object.assign({},gt(),_t()(process.argv)))})();var dr=k(Rt()),fr=require("fs"),mr=require("path");var Be=k(require("readline")),Ft=require("stream");var L=k(require("fs")),Ge=k(require("path")),Nt=k(require("os"));var R="\x1B[32m",D="\x1B[33m",C="\x1B[36m",te="\x1B[35m",v="\x1B[31m",y="\x1B[2m",W="\x1B[1m",d="\x1B[0m";var St="app.boxel.realms";var Zr={"anthropic/claude-3.5-sonnet":"Anthropic: Claude 3.5 Sonnet","anthropic/claude-3.7-sonnet":"Anthropic: Claude 3.7 Sonnet","anthropic/claude-3.7-sonnet:thinking":"Anthropic: Claude 3.7 Sonnet (thinking)","anthropic/claude-haiku-4.5":"Anthropic: Claude Haiku 4.5","anthropic/claude-sonnet-4":"Anthropic: Claude Sonnet 4","anthropic/claude-sonnet-4.5":"Anthropic: Claude Sonnet 4.5","anthropic/claude-sonnet-4.6":"Anthropic: Claude Sonnet 4.6","anthropic/claude-opus-4.1":"Anthropic: Claude Opus 4.1","deepseek/deepseek-chat-v3-0324":"DeepSeek: DeepSeek V3 0324","google/gemini-2.5-pro":"Google: Gemini 2.5 Pro","google/gemini-2.5-flash-lite":"Google: Gemini 2.5 Flash Lite","google/gemini-2.5-flash":"Google: Gemini 2.5 Flash","meta-llama/llama-3.2-3b-instruct":"Meta: Llama 3.2 3B Instruct","openai/gpt-4.1-nano":"OpenAI: GPT-4.1 Nano","openai/gpt-4.1-mini":"OpenAI: GPT-4.1 Mini","openai/gpt-4.1":"OpenAI: GPT-4.1","openai/gpt-4o":"OpenAI: GPT-4o","openai/gpt-4o-mini":"OpenAI: GPT-4o-mini","openai/gpt-5-nano":"OpenAI: GPT-5 Nano","openai/gpt-5-mini":"OpenAI: GPT-5 Mini","openai/gpt-5":"OpenAI: GPT-5","openai/gpt-oss-20b":"OpenAI: GPT OSS 20B"},rs=Object.keys(Zr);async function Tt(n,e,t){let r=await fetch(new URL("_matrix/client/v3/login",n).href,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identifier:{type:"m.id.user",user:e},password:t,type:"m.login.password"})}),i=await r.json();if(!r.ok)throw new Error(`Matrix login failed: ${r.status} ${JSON.stringify(i)}`);return{accessToken:i.access_token,deviceId:i.device_id,userId:i.user_id,matrixUrl:n}}async function ei(n){let e=await fetch(new URL(`_matrix/client/v3/user/${encodeURIComponent(n.userId)}/openid/request_token`,n.matrixUrl).href,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.accessToken}`},body:"{}"});if(!e.ok){let t=await e.text();throw new Error(`OpenID token request failed: ${e.status} ${t}`)}return await e.json()}async function Ie(n,e){let t=await ei(n),r=`${e.replace(/\/$/,"")}/_server-session`,i=await fetch(r,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)});if(!i.ok){let o=await i.text();throw new Error(`Realm server session failed: ${i.status} ${o}`)}let s=i.headers.get("Authorization");if(!s)throw new Error("Realm server session response did not include an Authorization header");return s}async function je(n,e){let t=`${n.replace(/\/$/,"")}/_realm-auth`,r=await fetch(t,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:e}});if(!r.ok){let i=await r.text();throw new Error(`Realm auth lookup failed: ${r.status} ${i}`)}return await r.json()}async function Mt(n,e){let t=new URL(`_matrix/client/v3/user/${encodeURIComponent(n.userId)}/account_data/${St}`,n.matrixUrl).href,r=[];try{let i=await fetch(t,{headers:{Authorization:`Bearer ${n.accessToken}`}});if(i.ok){let s=await i.json();r=Array.isArray(s.realms)?[...s.realms]:[]}}catch{}if(!r.includes(e)){r.push(e);let i=await fetch(t,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.accessToken}`},body:JSON.stringify({realms:r})});if(!i.ok){let s=await i.text();throw new Error(`Failed to update Matrix account data: ${i.status} ${s}`)}}}var ti=Ge.join(Nt.homedir(),".boxel-cli"),ri="profiles.json";function he(n){return n.endsWith(":stack.cards")?"staging":n.endsWith(":boxel.ai")?"production":n.endsWith(":localhost")?"local":"unknown"}function J(n){let e=n.match(/^@([^:]+):/);return e?e[1]:n}function ii(n){let e=n.match(/:([^:]+)$/);return e?e[1]:"unknown"}function We(n){switch(n){case"staging":return"stack.cards";case"production":return"boxel.ai";case"local":return"localhost";default:return"unknown"}}function U(n){let e=J(n),t=We(he(n));return`${y}[${d}${C}${e}${d} ${y}\xB7${d} ${te}${t}${d}${y}]${d}`}var He=class{config;configDir;profilesFile;constructor(e){this.configDir=e||ti,this.profilesFile=Ge.join(this.configDir,ri),this.config=this.loadConfig()}ensureConfigDir(){L.existsSync(this.configDir)||L.mkdirSync(this.configDir,{recursive:!0})}loadConfig(){let e={profiles:{},activeProfile:null};if(L.existsSync(this.profilesFile))try{let t=L.readFileSync(this.profilesFile,"utf-8"),r=JSON.parse(t);if(r&&typeof r=="object"&&!Array.isArray(r)){let i=r,s=i.profiles&&typeof i.profiles=="object"&&!Array.isArray(i.profiles)?i.profiles:null,o=i.activeProfile===null||typeof i.activeProfile=="string"?i.activeProfile:null;if(s)return{profiles:s,activeProfile:o}}}catch{}return e}saveConfig(){this.ensureConfigDir(),L.writeFileSync(this.profilesFile,JSON.stringify(this.config,null,2),{mode:384});try{L.chmodSync(this.profilesFile,384)}catch{}}listProfiles(){return Object.keys(this.config.profiles)}getProfile(e){return this.config.profiles[e]}getActiveProfileId(){return this.config.activeProfile}getActiveProfile(){let e=this.config.activeProfile;if(!e)return null;let t=this.config.profiles[e];return t?{id:e,profile:t}:null}async addProfile(e,t,r,i,s){let o=he(e),a=J(e);if(o==="unknown"&&(!i||!s))throw new Error(`Unknown domain in Matrix ID "${e}". You must provide explicit --matrix-url and --realm-server-url for non-standard domains.`);let l=o==="production"?"https://matrix.boxel.ai":"https://matrix-staging.stack.cards",u=o==="production"?"https://app.boxel.ai/":"https://realms-staging.stack.cards/",c=ii(e),h={displayName:r||`${a} \xB7 ${c}`,matrixUrl:i||l,realmServerUrl:s||u,password:t};this.config.profiles[e]=h,this.config.activeProfile||(this.config.activeProfile=e),this.saveConfig()}async removeProfile(e){if(!this.config.profiles[e])return!1;if(delete this.config.profiles[e],this.config.activeProfile===e){let t=Object.keys(this.config.profiles);this.config.activeProfile=t.length>0?t[0]:null}return this.saveConfig(),!0}switchProfile(e){return this.config.profiles[e]?(this.config.activeProfile=e,this.saveConfig(),!0):!1}async getActiveCredentials(){let e=this.getActiveProfile();if(e&&e.profile.password)return{matrixUrl:e.profile.matrixUrl,username:J(e.id),password:e.profile.password,realmServerUrl:e.profile.realmServerUrl,profileId:e.id};let t=process.env.MATRIX_URL,r=process.env.MATRIX_USERNAME,i=process.env.MATRIX_PASSWORD,s=process.env.REALM_SERVER_URL;return t&&r&&i&&s?{matrixUrl:t,username:r,password:i,realmServerUrl:s,profileId:null}:null}async getPassword(e){return this.config.profiles[e]?.password||null}async updatePassword(e,t){return this.config.profiles[e]?(this.config.profiles[e].password=t,this.saveConfig(),!0):!1}updateDisplayName(e,t){return this.config.profiles[e]?(this.config.profiles[e].displayName=t,this.saveConfig(),!0):!1}setRealmToken(e,t){let r=this.getActiveProfile();r&&(r.profile.realmTokens||(r.profile.realmTokens={}),r.profile.realmTokens[e]=t,this.saveConfig())}getRealmToken(e){return this.getActiveProfile()?.profile.realmTokens?.[e]}setRealmServerToken(e){let t=this.getActiveProfile();t&&(t.profile.realmServerToken=e,this.saveConfig())}getRealmServerToken(){return this.getActiveProfile()?.profile.realmServerToken}async loginToMatrix(){let e=this.getActiveProfile();if(!e)throw new Error("No active profile");let{id:t,profile:r}=e,i=J(t);return Tt(r.matrixUrl,i,r.password)}async getOrRefreshServerToken(){let e=this.getRealmServerToken();if(e)return e;let t=await this.loginToMatrix(),i=this.getActiveProfile().profile.realmServerUrl.replace(/\/$/,""),s=await Ie(t,i);return this.setRealmServerToken(s),s}async refreshServerToken(){let e=await this.loginToMatrix(),r=this.getActiveProfile().profile.realmServerUrl.replace(/\/$/,""),i=await Ie(e,r);return this.setRealmServerToken(i),i}findRealmTokenForUrl(e){let r=this.getActiveProfile()?.profile.realmTokens;if(r){for(let[i,s]of Object.entries(r))if(e.startsWith(i)&&s)return s}}async fetchAndStoreAllRealmTokens(){let e=await this.getOrRefreshServerToken(),r=this.getActiveProfile().profile.realmServerUrl.replace(/\/$/,""),i=await je(r,e);for(let[s,o]of Object.entries(i))this.setRealmToken(s,o)}async getRealmTokenForUrl(e){let t=this.findRealmTokenForUrl(e);if(t)return t;try{await this.fetchAndStoreAllRealmTokens()}catch{return}return this.findRealmTokenForUrl(e)}buildHeaders(e,t,r){let i=e instanceof Request?new Headers(e.headers):new Headers,s=new Headers(t?.headers);for(let[o,a]of s)i.set(o,a);return i.has("Authorization")||i.set("Authorization",r),i}async authedRealmFetch(e,t){let r=e instanceof Request?e.url:e instanceof URL?e.href:e,i=await this.getRealmTokenForUrl(r);if(i){let l=this.buildHeaders(e,t,i),u=await fetch(e,{...t,headers:l});if(u.status!==401)return u}let s=this.getActiveProfile();if(s&&(s.profile.realmTokens={},s.profile.realmServerToken=void 0,this.saveConfig()),await this.fetchAndStoreAllRealmTokens(),i=this.findRealmTokenForUrl(r),!i)throw new Error(`No realm token available for ${r}. The realm may not be accessible.`);let o=this.buildHeaders(e,t,i);return await fetch(e,{...t,headers:o})}async authedRealmServerFetch(e,t){let r=await this.getOrRefreshServerToken(),i=this.buildHeaders(e,t,r),s=await fetch(e,{...t,headers:i});return s.status===401&&(r=await this.refreshServerToken(),i=this.buildHeaders(e,t,r),s=await fetch(e,{...t,headers:i})),s}async fetchAndStoreRealmToken(e,t){let i=this.getActiveProfile().profile.realmServerUrl.replace(/\/$/,""),o=(await je(i,t))[e];return o&&this.setRealmToken(e,o),o}async addToUserRealms(e){let t=await this.loginToMatrix();await Mt(t,e)}async migrateFromEnv(){let e=process.env.MATRIX_URL,t=process.env.MATRIX_USERNAME,r=process.env.MATRIX_PASSWORD,i=process.env.REALM_SERVER_URL;if(!e||!t||!r||!i)return null;let o=e.includes("boxel.ai")?"boxel.ai":"stack.cards",a=`@${t}:${o}`;return this.config.profiles[a]?(this.config.profiles[a].password!==r&&(this.config.profiles[a].password=r,this.saveConfig()),{profileId:a,created:!1}):(await this.addProfile(a,r,void 0,e,i),{profileId:a,created:!0})}printStatus(){let e=this.getActiveProfile();e?(console.log(`
|
|
30
|
+
${W}Active Profile:${d} ${U(e.id)}`),console.log(` ${y}Display Name:${d} ${e.profile.displayName}`),console.log(` ${y}Matrix URL:${d} ${e.profile.matrixUrl}`),console.log(` ${y}Realm Server:${d} ${e.profile.realmServerUrl}`)):process.env.MATRIX_USERNAME?(console.log(`
|
|
31
|
+
${W}Using environment variables${d} (no profile active)`),console.log(` ${y}Username:${d} ${process.env.MATRIX_USERNAME}`)):(console.log(`
|
|
32
|
+
${D}No active profile and no environment variables set.${d}`),console.log(`Run ${C}boxel profile add${d} to create a profile.`))}},Ve=null;function F(){return Ve||(Ve=new He),Ve}function Q(n){let e=Be.createInterface({input:process.stdin,output:process.stdout});return new Promise(t=>{e.question(n,r=>{e.close(),t(r.trim())})})}function si(n){let e=new Ft.Writable({write:(r,i,s)=>s()}),t=Be.createInterface({input:process.stdin,output:e,terminal:!0});return new Promise((r,i)=>{let s=process.stdin,o=s.readableFlowing;s.isTTY&&s.setRawMode(!0);let a=()=>{s.removeListener("data",l),s.isTTY&&s.setRawMode(!1),t.close(),o||s.pause()},l=c=>{try{let h=c.toString();h===`
|
|
33
|
+
`||h==="\r"?(a(),process.stdout.write(`
|
|
34
|
+
`),r(u)):h===""?(a(),process.exit()):h==="\x7F"||h==="\b"?u.length>0&&(u=u.slice(0,-1),process.stdout.write("\b \b")):(u+=h,process.stdout.write("*"))}catch(h){a(),i(h)}},u="";try{process.stdout.write(n),s.on("data",l),s.resume()}catch(c){a(),i(c)}})}async function Lt(n,e,t){let r=F();switch(n){case"list":await Dt(r);break;case"add":{let i=t?.password||process.env.BOXEL_PASSWORD;t?.user&&i?await li(r,t.user,i,t.name):await ni(r);break}case"switch":e||(console.error(`${v}Error:${d} Please specify a profile to switch to.`),console.log("Usage: boxel profile switch <profile-id>"),console.log(`
|
|
35
|
+
Available profiles:`),await Dt(r),process.exit(1)),await oi(r,e);break;case"remove":e||(console.error(`${v}Error:${d} Please specify a profile to remove.`),process.exit(1)),await ai(r,e);break;case"migrate":await ci(r);break;default:r.printStatus(),console.log(`
|
|
36
|
+
${y}Commands:${d}`),console.log(` ${C}boxel profile list${d} List all profiles`),console.log(` ${C}boxel profile add${d} Add a new profile`),console.log(` ${C}boxel profile switch${d} Switch active profile`),console.log(` ${C}boxel profile remove${d} Remove a profile`),console.log(` ${C}boxel profile migrate${d} Import from .env file`)}}async function Dt(n){let e=n.listProfiles(),t=n.getActiveProfileId();if(e.length===0){console.log(`
|
|
37
|
+
${D}No profiles configured.${d}`),console.log(`Run ${C}boxel profile add${d} to create one.`);return}console.log(`
|
|
38
|
+
${W}Saved Profiles:${d}
|
|
39
|
+
`);for(let r of e){let i=n.getProfile(r),s=r===t,o=he(r),a=s?`${R}\u2605${d} `:" ",l=We(o),u=o==="production"?te:C;console.log(`${a}${W}${r}${d}`),console.log(` ${y}Name:${d} ${i.displayName}`),console.log(` ${y}Environment:${d} ${u}${l}${d}`),console.log(` ${y}Realm Server:${d} ${i.realmServerUrl}`),console.log("")}t&&console.log(`${y}\u2605 = active profile${d}`)}async function ni(n){console.log(`
|
|
40
|
+
${W}Add New Profile${d}
|
|
41
|
+
`),console.log("Which environment?"),console.log(` ${C}1${d}) Staging (realms-staging.stack.cards)`),console.log(` ${te}2${d}) Production (app.boxel.ai)`),console.log(` ${R}3${d}) Local (localhost:4201)`);let e=await Q(`
|
|
42
|
+
Choice [1/2/3]: `),t=e==="2",r=e==="3",i,s,o;r?(i="localhost",s="http://localhost:8008",o="http://localhost:4201/"):t?(i="boxel.ai",s="https://matrix.boxel.ai",o="https://app.boxel.ai/"):(i="stack.cards",s="https://matrix-staging.stack.cards",o="https://realms-staging.stack.cards/"),console.log(`
|
|
43
|
+
Enter your Boxel username (without @ or domain)`),console.log(`${y}Example: ctse, aallen90${d}`);let a=await Q("Username: ");a||(console.error(`${v}Error:${d} Username is required.`),process.exit(1));let l=`@${a}:${i}`;if(n.getProfile(l)&&(console.log(`
|
|
44
|
+
${D}Profile ${l} already exists.${d}`),(await Q("Overwrite? [y/N]: ")).toLowerCase()!=="y")){console.log("Cancelled.");return}let u=await si("Password: ");u||(console.error(`${v}Error:${d} Password is required.`),process.exit(1));let c=`${a} \xB7 ${i}`,p=await Q(`Display name [${c}]: `)||c;await n.addProfile(l,u,p,s,o),console.log(`
|
|
45
|
+
${R}\u2713${d} Profile created: ${U(l)}`),n.getActiveProfileId()===l?console.log(`${y}This profile is now active.${d}`):(await Q("Switch to this profile now? [Y/n]: ")).toLowerCase()!=="n"&&(n.switchProfile(l),console.log(`${R}\u2713${d} Switched to ${U(l)}`))}async function oi(n,e){let t=n.listProfiles(),r=e;if(!t.includes(e)){let i=t.filter(s=>{let o=J(s);return s.includes(e)||o===e});if(i.length===0){console.error(`${v}Error:${d} Profile not found: ${e}`),console.log(`
|
|
46
|
+
Available profiles:`);for(let s of t)console.log(` ${s}`);process.exit(1)}else if(i.length===1)r=i[0];else{console.error(`${v}Error:${d} Ambiguous profile: ${e}`),console.log(`
|
|
47
|
+
Matching profiles:`);for(let s of i)console.log(` ${s}`);process.exit(1)}}n.switchProfile(r)?console.log(`${R}\u2713${d} Switched to ${U(r)}`):(console.error(`${v}Error:${d} Failed to switch profile.`),process.exit(1))}async function ai(n,e){if(n.getProfile(e)||(console.error(`${v}Error:${d} Profile not found: ${e}`),process.exit(1)),(await Q(`Remove profile ${e}? [y/N]: `)).toLowerCase()!=="y"){console.log("Cancelled.");return}if(await n.removeProfile(e)){console.log(`${R}\u2713${d} Profile removed.`);let i=n.getActiveProfileId();i&&console.log(`Active profile is now: ${U(i)}`)}else console.error(`${v}Error:${d} Failed to remove profile.`),process.exit(1)}async function li(n,e,t,r){if((!e.startsWith("@")||!e.includes(":"))&&(console.error(`${v}Error:${d} Invalid Matrix ID format. Expected @user:domain`),process.exit(1)),n.getProfile(e)){console.log(`${D}Profile ${e} already exists. Updating password.${d}`),await n.updatePassword(e,t),r&&n.updateDisplayName(e,r),console.log(`${R}\u2713${d} Profile updated: ${U(e)}`);return}await n.addProfile(e,t,r),console.log(`${R}\u2713${d} Profile created: ${U(e)}`),n.getActiveProfileId()!==e&&console.log(`${y}Use 'boxel profile switch ${e}' to switch to this profile.${d}`)}async function ci(n){console.log(`
|
|
48
|
+
${W}Migrate from .env${d}
|
|
49
|
+
`);let e=process.env.MATRIX_URL,t=process.env.MATRIX_USERNAME,r=process.env.MATRIX_PASSWORD,i=process.env.REALM_SERVER_URL;if(!e||!t||!r||!i){console.log(`${D}No complete credentials found in environment variables.${d}`),console.log(`
|
|
50
|
+
Required variables: MATRIX_URL, MATRIX_USERNAME, MATRIX_PASSWORD, REALM_SERVER_URL`);return}let s=await n.migrateFromEnv();s?s.created?(console.log(`${R}\u2713${d} Created profile: ${U(s.profileId)}`),console.log(`
|
|
51
|
+
${y}You can now remove credentials from .env if desired.${d}`)):(console.log(`${D}Profile ${U(s.profileId)} already exists.${d} Password has been updated if it changed.`),console.log(`
|
|
52
|
+
${y}Use 'boxel profile add -u ${s.profileId} -p <password>' to update other fields.${d}`)):console.log(`${D}Migration failed.${d}`)}var ui=Object.freeze({a:"https://boxel-images.boxel.ai/icons/Letter-a.png",b:"https://boxel-images.boxel.ai/icons/Letter-b.png",c:"https://boxel-images.boxel.ai/icons/Letter-c.png",d:"https://boxel-images.boxel.ai/icons/Letter-d.png",e:"https://boxel-images.boxel.ai/icons/Letter-e.png",f:"https://boxel-images.boxel.ai/icons/Letter-f.png",g:"https://boxel-images.boxel.ai/icons/Letter-g.png",h:"https://boxel-images.boxel.ai/icons/Letter-h.png",i:"https://boxel-images.boxel.ai/icons/Letter-i.png",j:"https://boxel-images.boxel.ai/icons/Letter-j.png",k:"https://boxel-images.boxel.ai/icons/Letter-k.png",l:"https://boxel-images.boxel.ai/icons/Letter-l.png",m:"https://boxel-images.boxel.ai/icons/Letter-m.png",n:"https://boxel-images.boxel.ai/icons/Letter-n.png",o:"https://boxel-images.boxel.ai/icons/Letter-o.png",p:"https://boxel-images.boxel.ai/icons/Letter-p.png",q:"https://boxel-images.boxel.ai/icons/Letter-q.png",r:"https://boxel-images.boxel.ai/icons/Letter-r.png",s:"https://boxel-images.boxel.ai/icons/Letter-s.png",t:"https://boxel-images.boxel.ai/icons/Letter-t.png",u:"https://boxel-images.boxel.ai/icons/Letter-u.png",v:"https://boxel-images.boxel.ai/icons/Letter-v.png",w:"https://boxel-images.boxel.ai/icons/Letter-w.png",x:"https://boxel-images.boxel.ai/icons/Letter-x.png",y:"https://boxel-images.boxel.ai/icons/Letter-y.png",z:"https://boxel-images.boxel.ai/icons/letter-z.png"}),Ut=Object.freeze(["https://boxel-images.boxel.ai/background-images/4k-arabic-teal.jpg","https://boxel-images.boxel.ai/background-images/4k-arrow-weave.jpg","https://boxel-images.boxel.ai/background-images/4k-atmosphere-curvature.jpg","https://boxel-images.boxel.ai/background-images/4k-brushed-slabs.jpg","https://boxel-images.boxel.ai/background-images/4k-coral-reefs.jpg","https://boxel-images.boxel.ai/background-images/4k-crescent-lake.jpg","https://boxel-images.boxel.ai/background-images/4k-curvilinear-stairs.jpg","https://boxel-images.boxel.ai/background-images/4k-desert-dunes.jpg","https://boxel-images.boxel.ai/background-images/4k-doodle-board.jpg","https://boxel-images.boxel.ai/background-images/4k-fallen-leaves.jpg","https://boxel-images.boxel.ai/background-images/4k-flowing-mesh.jpg","https://boxel-images.boxel.ai/background-images/4k-glass-reflection.jpg","https://boxel-images.boxel.ai/background-images/4k-glow-cells.jpg","https://boxel-images.boxel.ai/background-images/4k-granite-peaks.jpg","https://boxel-images.boxel.ai/background-images/4k-green-wormhole.jpg","https://boxel-images.boxel.ai/background-images/4k-joshua-dawn.jpg","https://boxel-images.boxel.ai/background-images/4k-lava-river.jpg","https://boxel-images.boxel.ai/background-images/4k-leaves-moss.jpg","https://boxel-images.boxel.ai/background-images/4k-light-streaks.jpg","https://boxel-images.boxel.ai/background-images/4k-lowres-glitch.jpg","https://boxel-images.boxel.ai/background-images/4k-marble-shimmer.jpg","https://boxel-images.boxel.ai/background-images/4k-metallic-leather.jpg","https://boxel-images.boxel.ai/background-images/4k-microscopic-crystals.jpg","https://boxel-images.boxel.ai/background-images/4k-moon-face.jpg","https://boxel-images.boxel.ai/background-images/4k-mountain-runway.jpg","https://boxel-images.boxel.ai/background-images/4k-origami-flock.jpg","https://boxel-images.boxel.ai/background-images/4k-paint-swirl.jpg","https://boxel-images.boxel.ai/background-images/4k-pastel-triangles.jpg","https://boxel-images.boxel.ai/background-images/4k-perforated-sheet.jpg","https://boxel-images.boxel.ai/background-images/4k-plastic-ripples.jpg","https://boxel-images.boxel.ai/background-images/4k-powder-puff.jpg","https://boxel-images.boxel.ai/background-images/4k-radiant-crystal.jpg","https://boxel-images.boxel.ai/background-images/4k-redrock-canyon.jpg","https://boxel-images.boxel.ai/background-images/4k-rock-portal.jpg","https://boxel-images.boxel.ai/background-images/4k-rolling-hills.jpg","https://boxel-images.boxel.ai/background-images/4k-sand-stone.jpg","https://boxel-images.boxel.ai/background-images/4k-silver-fur.jpg","https://boxel-images.boxel.ai/background-images/4k-spa-pool.jpg","https://boxel-images.boxel.ai/background-images/4k-stained-glass.jpg","https://boxel-images.boxel.ai/background-images/4k-stone-veins.jpg","https://boxel-images.boxel.ai/background-images/4k-tangerine-plains.jpg","https://boxel-images.boxel.ai/background-images/4k-techno-floor.jpg","https://boxel-images.boxel.ai/background-images/4k-thick-frost.jpg","https://boxel-images.boxel.ai/background-images/4k-water-surface.jpg","https://boxel-images.boxel.ai/background-images/4k-watercolor-splashes.jpg","https://boxel-images.boxel.ai/background-images/4k-wildflower-field.jpg","https://boxel-images.boxel.ai/background-images/4k-wood-grain.jpg"]);function qe(n){if(!n)return;let e=n.toLowerCase().replace(/[^a-z0-9]/g,"").replace(/^[0-9]+/,"");return ui[e.charAt(0)]}function It(){let n=Math.floor(Math.random()*Ut.length);return Ut[n]}var hi=/^[a-z0-9-]+$/;function Vt(n){n.command("create").description("Create a new realm on the realm server").argument("<realm-name>","realm name (lowercase, numbers, hyphens only)").argument("<display-name>","display name for the realm").option("--background <url>","background image URL").option("--icon <url>","icon image URL").action(async(e,t,r)=>{await fi(e,t,r)})}async function pi(n,e,t={}){let r=t.profileManager??F(),i=r.getActiveProfile();if(!i)throw new Error("No active profile. Run `boxel profile add` to create one.");let s=i.profile.realmServerUrl.replace(/\/$/,""),o={endpoint:n,name:e,backgroundURL:t.background??It(),iconURL:t.icon??qe(e)??qe(n)},a=await r.authedRealmServerFetch(`${s}/_create-realm`,{method:"POST",headers:{"Content-Type":"application/vnd.api+json"},body:JSON.stringify({data:{type:"realm",attributes:o}})});if(!a.ok){let p;try{p=await a.text()}catch{p="server returned a non-serialized object body"}if(p.includes("[object Object]")&&(p="server returned a non-serialized object body"),p.includes("already exists")){let f=mi(p,s,n),g=await jt(r,f);try{await r.addToUserRealms(f)}catch{}return{realmUrl:f,created:!1,realmToken:g}}throw new Error(`Realm server returned ${a.status}: ${p}`)}let u=(await a.json())?.data?.id;if(typeof u!="string"||u.trim()==="")throw new Error(`Realm server response did not include a realm URL (data.id) for "${n}".`);let c=Ht(u),h=await jt(r,c);try{await r.addToUserRealms(c)}catch{}return t.waitForReady&&h&&await di(c,h),{realmUrl:c,created:!0,realmToken:h}}async function jt(n,e){try{let t=await n.getOrRefreshServerToken();return await n.fetchAndStoreRealmToken(e,t)}catch{return}}async function di(n,e){let t=new URL("_readiness-check",n).href,r=15e3,i=250,s=Date.now(),o;for(;Date.now()-s<r;){try{let a=await fetch(t,{headers:{Accept:"application/vnd.api+json",Authorization:e}});if(a.ok)return;o=`HTTP ${a.status}`}catch(a){o=a instanceof Error?a.message:String(a)}await new Promise(a=>setTimeout(a,i))}throw new Error(`Timed out waiting for realm ${n} to become ready${o?`: ${o}`:""}`)}async function fi(n,e,t){hi.test(n)||(console.error("Error: realm name must contain only lowercase letters, numbers, and hyphens"),process.exit(1));try{let r=await pi(n,e,t),i=r.created?"created":"already exists";console.log(`${R}Realm ${i}:${d} ${C}${r.realmUrl}${d}`)}catch(r){console.error(`Error: ${r instanceof Error?r.message:String(r)}`),process.exit(1)}}function mi(n,e,t){let r=n.match(/'(https?:\/\/[^']+)'/);if(r)return Ht(r[1]);throw new Error(`Could not determine realm URL from server error response for endpoint "${t}" on "${e}". The response did not include an explicit realm URL.`)}function Ht(n){return n.endsWith("/")?n:`${n}/`}var P=k(require("fs/promises")),O=k(require("path")),tt=k(Jt());var Ze=class{value;next;constructor(e){this.value=e}},re=class{#e;#t;#r;constructor(){this.clear()}enqueue(e){let t=new Ze(e);this.#e?(this.#t.next=t,this.#t=t):(this.#e=t,this.#t=t),this.#r++}dequeue(){let e=this.#e;if(e)return this.#e=this.#e.next,this.#r--,this.#e||(this.#t=void 0),e.value}peek(){if(this.#e)return this.#e.value}clear(){this.#e=void 0,this.#t=void 0,this.#r=0}get size(){return this.#r}*[Symbol.iterator](){let e=this.#e;for(;e;)yield e.value,e=e.next}*drain(){for(;this.#e;)yield this.dequeue()}};function et(n){let e=!1;if(typeof n=="object"&&({concurrency:n,rejectOnClear:e=!1}=n),Qt(n),typeof e!="boolean")throw new TypeError("Expected `rejectOnClear` to be a boolean");let t=new re,r=0,i=()=>{r<n&&t.size>0&&(r++,t.dequeue().run())},s=()=>{r--,i()},o=async(u,c,h)=>{let p=(async()=>u(...h))();c(p);try{await p}catch{}s()},a=(u,c,h,p)=>{let f={reject:h};new Promise(g=>{f.run=g,t.enqueue(f)}).then(o.bind(void 0,u,c,p)),r<n&&i()},l=(u,...c)=>new Promise((h,p)=>{a(u,h,p,c)});return Object.defineProperties(l,{activeCount:{get:()=>r},pendingCount:{get:()=>t.size},clearQueue:{value(){if(!e){t.clear();return}let u=AbortSignal.abort().reason;for(;t.size>0;)t.dequeue().reject(u)}},concurrency:{get:()=>n,set(u){Qt(u),n=u,queueMicrotask(()=>{for(;r<n&&t.size>0;)i()})}},map:{async value(u,c){let h=Array.from(u,(p,f)=>this(c,p,f));return Promise.all(h)}}}),l}function Qt(n){if(!((Number.isInteger(n)||n===Number.POSITIVE_INFINITY)&&n>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up")}var Mi=tt.default.default||tt.default,Ni=new Set([".realm.json"]);function T(n){let e=n.replace(/\\/g,"/").replace(/^\/+/,"");return Ni.has(e)}async function Zt(n){try{return await P.access(n),!0}catch{return!1}}var de={CardSource:"application/vnd.card+source",DirectoryListing:"application/vnd.api+json",Mtimes:"application/vnd.api+json"},Di=10,er=new Set(["node_modules"]),B=class{constructor(e,t){this.options=e;this.profileManager=t;this.normalizedRealmUrl=this.normalizeRealmUrl(e.realmUrl)}normalizedRealmUrl;ignoreCache=new Map;remoteLimit=et(Di);normalizeRealmUrl(e){try{let t=new URL(e),r=t.pathname;return(r.split("/").filter(Boolean).pop()||"").includes(".")?console.warn(`Warning: "${e}" looks like a file URL, not a realm URL.
|
|
53
|
+
Realm URLs should point to a directory (e.g., ${t.origin}${r.replace(/\/[^/]*\.[^/]*$/,"/")})`):e.endsWith("/")||console.warn(`Warning: Realm URL should end with a trailing slash.
|
|
54
|
+
Did you mean "${e}/"?`),t.href.replace(/\/+$/,"")+"/"}catch{throw new Error(`Invalid workspace URL: ${e}`)}}buildDirectoryUrl(e=""){if(!e)return this.normalizedRealmUrl;let t=e.replace(/^\/+|\/+$/g,"");return`${this.normalizedRealmUrl}${t}/`}buildFileUrl(e){let t=e.replace(/^\/+/,"");return`${this.normalizedRealmUrl}${t}`}async getRemoteFileList(e=""){let t=new Map;try{let r=this.buildDirectoryUrl(e),i=await this.profileManager.authedRealmFetch(r,{headers:{Accept:"application/vnd.api+json"}});if(!i.ok){if(i.status===404)return t;throw i.status===401||i.status===403?new Error(`Authentication failed (${i.status}): Cannot access workspace. Check your Matrix credentials and workspace permissions.`):new Error(`Failed to get directory listing: ${i.status} ${i.statusText}`)}let s=await i.json();if(s.data&&s.data.relationships){let o=Object.entries(s.data.relationships),a=await Promise.all(o.map(([l,u])=>{let h=u.meta.kind==="file",p=e?O.posix.join(e,l):l;return h?this.shouldIgnoreRemoteFile(p)?[]:[[p,!0]]:this.remoteLimit(async()=>{let f=await this.getRemoteFileList(p);return Array.from(f.entries())})}));for(let l of a)for(let[u,c]of l)t.set(u,c)}}catch(r){throw r instanceof Error&&(r.message.includes("Authentication failed")||r.message.includes("Cannot access workspace")||r.message.includes("401")||r.message.includes("403"))||console.error(`Error reading remote directory ${e}:`,r),r}return t}async getRemoteMtimes(){let e=new Map;try{let t=`${this.normalizedRealmUrl}_mtimes`,r=await this.profileManager.authedRealmFetch(t,{headers:{Accept:de.Mtimes}});if(!r.ok){if(r.status===404)return console.log("Note: _mtimes endpoint not available, will upload all files"),e;throw new Error(`Failed to get mtimes: ${r.status} ${r.statusText}`)}let i=await r.json();if(i.data?.attributes?.mtimes){let s=Object.entries(i.data.attributes.mtimes);process.env.DEBUG&&(console.log(`Remote mtimes received: ${s.length} entries`),s.length>0&&console.log(`Sample: ${s[0][0]} = ${s[0][1]}`));for(let[o,a]of s){let l=o.replace(this.normalizedRealmUrl,"");this.shouldIgnoreRemoteFile(l)||e.set(l,a)}}else process.env.DEBUG&&console.log("No mtimes in response:",JSON.stringify(i).slice(0,200))}catch(t){console.warn("Could not fetch remote mtimes, will upload all files:",t)}return e}async getLocalFileListWithMtimes(e=""){let t=new Map,r=O.join(this.options.localDir,e),i;try{i=await P.readdir(r,{withFileTypes:!0})}catch(o){if(o.code==="ENOENT")return t;throw o}let s=await Promise.all(i.map(async o=>{let a=O.join(r,o.name),l=e?O.posix.join(e,o.name):o.name;if(o.isDirectory()&&er.has(o.name))return[];if(await this.shouldIgnoreFile(l,a))return[];if(o.isFile()){let u=await P.stat(a);return[[l,{path:a,mtime:u.mtimeMs}]]}else if(o.isDirectory()){let u=await this.getLocalFileListWithMtimes(l);return Array.from(u.entries())}return[]}));for(let o of s)for(let[a,l]of o)t.set(a,l);return t}async getLocalFileList(e=""){let t=new Map,r=O.join(this.options.localDir,e),i;try{i=await P.readdir(r,{withFileTypes:!0})}catch(o){if(o.code==="ENOENT")return t;throw o}let s=await Promise.all(i.map(async o=>{let a=O.join(r,o.name),l=e?O.posix.join(e,o.name):o.name;if(o.isDirectory()&&er.has(o.name))return[];if(await this.shouldIgnoreFile(l,a))return[];if(o.isFile())return[[l,a]];if(o.isDirectory()){let u=await this.getLocalFileList(l);return Array.from(u.entries())}return[]}));for(let o of s)for(let[a,l]of o)t.set(a,l);return t}async uploadFile(e,t){if(T(e)){console.log(` Skipped (protected): ${e}`);return}if(console.log(`Uploading: ${e}`),this.options.dryRun){console.log(`[DRY RUN] Would upload ${e}`);return}let r=await P.readFile(t,"utf8"),i=this.buildFileUrl(e),s=await this.profileManager.authedRealmFetch(i,{method:"POST",headers:{"Content-Type":"text/plain;charset=UTF-8",Accept:de.CardSource},body:r});if(!s.ok)throw new Error(`Failed to upload: ${s.status} ${s.statusText}`);console.log(` Uploaded: ${e}`)}async uploadFilesAtomic(e,t){let r=Array.from(e.entries()).filter(([u])=>!T(u));if(r.length===0)return{succeeded:[]};if(this.options.dryRun){for(let[u]of r)console.log(`[DRY RUN] Would upload ${u}`);return{succeeded:[]}}let i=await Promise.all(r.map(async([u,c])=>{let h=await P.readFile(c,"utf8");return{op:t.has(u)?"add":"update",href:this.buildFileUrl(u),data:{type:"source",attributes:{content:h},meta:{}}}})),s=`${this.normalizedRealmUrl}_atomic`,o=await this.profileManager.authedRealmFetch(s,{method:"POST",headers:{"Content-Type":"application/vnd.api+json",Accept:"application/vnd.api+json"},body:JSON.stringify({"atomic:operations":i})});if(o.status===201){let u=await o.json(),c=new Map(r.map(([p])=>[this.buildFileUrl(p),p])),h=(u["atomic:results"]??[]).map(p=>p.data?.id).filter(p=>typeof p=="string").map(p=>c.get(p)??p);for(let p of h)console.log(` Uploaded: ${p}`);return{succeeded:h}}let a={};try{a=await o.json()}catch{}let l=(a.errors??[]).map(u=>{let h=(u.detail??"").match(/Resource (\S+) /),p=h?h[1]:"";return{path:new Map(r.map(([g])=>[this.buildFileUrl(g),g])).get(p)??p,status:u.status??o.status,title:u.title??"Error"}});return{succeeded:[],error:{status:o.status,perFile:l,message:`Atomic upload failed: ${o.status} ${o.statusText}`}}}async downloadFile(e,t){if(console.log(`Downloading: ${e}`),this.options.dryRun){console.log(`[DRY RUN] Would download ${e}`);return}let r=this.buildFileUrl(e),i=await this.profileManager.authedRealmFetch(r,{headers:{Accept:de.CardSource}});if(!i.ok)throw new Error(`Failed to download: ${i.status} ${i.statusText}`);let s=await i.text(),o=O.dirname(t);await P.mkdir(o,{recursive:!0}),await P.writeFile(t,s,"utf8"),console.log(` Downloaded: ${e}`)}async deleteFile(e){if(T(e)){console.log(` Skipped (protected): ${e}`);return}if(console.log(`Deleting remote: ${e}`),this.options.dryRun){console.log(`[DRY RUN] Would delete ${e}`);return}let t=this.buildFileUrl(e),r=await this.profileManager.authedRealmFetch(t,{method:"DELETE",headers:{Accept:de.CardSource}});if(!r.ok&&r.status!==404)throw new Error(`Failed to delete: ${r.status} ${r.statusText}`);console.log(` Deleted: ${e}`)}async deleteLocalFile(e){if(console.log(`Deleting local: ${e}`),this.options.dryRun){console.log(`[DRY RUN] Would delete local file ${e}`);return}try{await P.unlink(e),console.log(` Deleted: ${e}`)}catch(t){if(t.code!=="ENOENT")throw t}}getIgnoreInstance(e){let t=this.ignoreCache.get(e);if(t)return t;let r=(async()=>{let i=Mi(),s=e,o=this.options.localDir;for(;s.startsWith(o);){let a=O.join(s,".gitignore");if(await Zt(a))try{let c=await P.readFile(a,"utf8");i.add(c)}catch(c){console.warn(`Warning: Could not read .gitignore file at ${a}:`,c)}let l=O.join(s,".boxelignore");if(await Zt(l))try{let c=await P.readFile(l,"utf8");i.add(c)}catch(c){console.warn(`Warning: Could not read .boxelignore file at ${l}:`,c)}let u=O.dirname(s);if(u===s)break;s=u}return i})();return this.ignoreCache.set(e,r),r}async shouldIgnoreFile(e,t){let r=O.basename(e);if(r===".boxel-sync.json"||r.startsWith("."))return!0;let i=O.dirname(t),s=await this.getIgnoreInstance(i),o=e.replace(/\\/g,"/");return s.ignores(o)}shouldIgnoreRemoteFile(e){return!!O.basename(e).startsWith(".")}};var tr=require("child_process"),S=k(require("fs/promises")),A=k(require("path"));async function rt(n){try{return await S.access(n),!0}catch{return!1}}var q=class{workspaceDir;gitDir;constructor(e){this.workspaceDir=A.resolve(e),this.gitDir=A.join(this.workspaceDir,".boxel-history")}async init(){await rt(this.gitDir)||await S.mkdir(this.gitDir,{recursive:!0});let e=A.join(this.gitDir,".git");await rt(e)||(await this.git("init"),await this.git("config","user.email","boxel-cli@local"),await this.git("config","user.name","Boxel CLI"),await this.git("commit","--allow-empty","-m","[init] Initialize checkpoint history"))}async isInitialized(){return rt(A.join(this.gitDir,".git"))}async syncFilesToHistory(){let e=await this.getWorkspaceFiles(),t=new Set(e),r=await this.getHistoryFiles();await Promise.all(r.map(async i=>{if(!t.has(i)){let s=A.join(this.gitDir,i);try{await S.unlink(s)}catch(o){if(o.code!=="ENOENT")throw o}}})),await Promise.all(e.map(async i=>{let s=A.join(this.workspaceDir,i),o=A.join(this.gitDir,i),a=A.dirname(o);await S.mkdir(a,{recursive:!0}),await S.copyFile(s,o)}))}async getWorkspaceFiles(){let e=[],t=async(r,i="")=>{let s;try{s=await S.readdir(r,{withFileTypes:!0})}catch(o){if(o.code==="ENOENT")return;throw o}await Promise.all(s.map(async o=>{if(o.name===".boxel-history"||o.name===".boxel-sync.json"||o.name==="node_modules"||o.name.startsWith("."))return;let a=i?`${i}/${o.name}`:o.name;o.isDirectory()?await t(A.join(r,o.name),a):e.push(a)}))};return await t(this.workspaceDir),e}async getHistoryFiles(){let e=[],t=async(r,i="")=>{let s;try{s=await S.readdir(r,{withFileTypes:!0})}catch(o){if(o.code==="ENOENT")return;throw o}await Promise.all(s.map(async o=>{if(o.name===".git")return;let a=i?`${i}/${o.name}`:o.name;o.isDirectory()?await t(A.join(r,o.name),a):e.push(a)}))};return await t(this.gitDir),e}async detectCurrentChanges(){if(!await this.isInitialized())return(await this.getWorkspaceFiles()).map(i=>({file:i,status:"added"}));await this.syncFilesToHistory();let e=(await this.git("status","--porcelain")).replace(/\n+$/,"");if(!e)return[];let t=[];for(let r of e.split(`
|
|
55
|
+
`)){if(!r)continue;let i=r.substring(0,2),s=r.substring(3);if(i.includes("R")){let o=s.indexOf(" -> ");if(o!==-1){let a=s.substring(0,o),l=s.substring(o+4);t.push({file:a,status:"deleted"}),t.push({file:l,status:"added"});continue}}i.includes("D")?t.push({file:s,status:"deleted"}):i.includes("A")||i.includes("C")||i==="??"?t.push({file:s,status:"added"}):(i.includes("M")||i.includes("U")||i.includes("T"))&&t.push({file:s,status:"modified"})}return t}async createCheckpoint(e,t,r){if(await this.isInitialized()||await this.init(),await this.syncFilesToHistory(),await this.git("add","-A"),!(await this.git("status","--porcelain")).trim())return null;let s=this.classifyChanges(t),{message:o,description:a}=r?{message:r,description:""}:this.generateCommitMessage(e,t,s),l=s?"[MAJOR]":"[minor]",u=`[${e}]`,c=`${l} ${u} ${o}${a?`
|
|
56
|
+
|
|
57
|
+
`+a:""}`;await this.git("commit","-m",c);let h=(await this.git("rev-parse","HEAD")).trim(),p=h.substring(0,7);return{hash:h,shortHash:p,message:o,description:a,date:new Date,isMajor:s,filesChanged:t.length,insertions:0,deletions:0,source:e,isMilestone:!1}}classifyChanges(e){if(e.length>3)return!0;for(let t of e)if(t.status==="added"||t.status==="deleted"||t.file.endsWith(".gts"))return!0;return!1}generateCommitMessage(e,t,r){let i=e==="local"?"Push":e==="remote"?"Pull":"Manual";if(t.length===0)return{message:`${i}: No changes detected`,description:""};if(t.length===1){let h=t[0],p=h.status==="added"?"Add":h.status==="deleted"?"Delete":"Update";return{message:`${i}: ${p} ${h.file}`,description:""}}let s=t.filter(h=>h.status==="added"),o=t.filter(h=>h.status==="modified"),a=t.filter(h=>h.status==="deleted"),l=[];s.length>0&&l.push(`+${s.length}`),o.length>0&&l.push(`~${o.length}`),a.length>0&&l.push(`-${a.length}`);let u=`${i}: ${t.length} files (${l.join(", ")})`,c=[];return s.length>0&&(c.push("Added:"),s.forEach(h=>c.push(` + ${h.file}`))),o.length>0&&(c.push("Modified:"),o.forEach(h=>c.push(` ~ ${h.file}`))),a.length>0&&(c.push("Deleted:"),a.forEach(h=>c.push(` - ${h.file}`))),{message:u,description:c.join(`
|
|
58
|
+
`)}}async getCheckpoints(e=50){if(!await this.isInitialized())return[];let r=await this.git("log","--format=%H|%h|%s|%aI|%an",`-${e}`);if(!r.trim())return[];let i=await this.getAllMilestones(),s=r.trim().split(`
|
|
59
|
+
`).filter(o=>!(o.split("|")[2]??"").startsWith("[init]"));return Promise.all(s.map(async o=>{let[a,l,u,c]=o.split("|"),h=u.includes("[MAJOR]"),p=u.includes("[local]")?"local":u.includes("[remote]")?"remote":"manual",f=u.replace(/\[(MAJOR|minor)\]\s*/i,"").replace(/\[(local|remote|manual)\]\s*/i,""),g=await this.getCommitStats(a),$=i.get(a),H=!!$;return{hash:a,shortHash:l,message:f,description:"",date:new Date(c),isMajor:h,source:p,isMilestone:H,milestoneName:$,...g}}))}async getCommitStats(e){try{let r=(await this.git("show","--stat","--format=",e)).trim().split(`
|
|
60
|
+
`),i=r[r.length-1]||"",s=i.match(/(\d+) files? changed/),o=i.match(/(\d+) insertions?/),a=i.match(/(\d+) deletions?/);return{filesChanged:s?parseInt(s[1]):0,insertions:o?parseInt(o[1]):0,deletions:a?parseInt(a[1]):0}}catch{return{filesChanged:0,insertions:0,deletions:0}}}async getChangedFiles(e){return(await this.git("show","--name-only","--format=",e)).trim().split(`
|
|
61
|
+
`).filter(Boolean)}async getDiff(e){return this.git("show","--format=",e)}async restore(e){let t=await this.getHistoryFiles();await Promise.all(t.map(async o=>{let a=A.join(this.gitDir,o);try{await S.unlink(a)}catch(l){if(l.code!=="ENOENT")throw l}})),await this.git("checkout",e,"--",".");let r=await this.getHistoryFiles(),i=new Set(r),s=await this.getWorkspaceFiles();await Promise.all(s.map(async o=>{if(!T(o)&&!i.has(o)){let a=A.join(this.workspaceDir,o);try{await S.unlink(a)}catch(l){if(l.code!=="ENOENT")throw l}}})),await Promise.all(r.map(async o=>{if(T(o))return;let a=A.join(this.gitDir,o),l=A.join(this.workspaceDir,o),u=A.dirname(l);await S.mkdir(u,{recursive:!0}),await S.copyFile(a,l)})),await this.git("checkout","HEAD","--",".")}async markMilestone(e,t){if(!await this.isInitialized())return null;let r;if(typeof e=="number"){let s=await this.getCheckpoints(e+1);if(e<1||e>s.length)return null;r=s[e-1].hash}else r=e;let i=`milestone/${t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9\-_.]/g,"")}`;try{return await this.git("tag","-a",i,r,"-m",`Milestone: ${t}`),{hash:r,name:t}}catch{return null}}async unmarkMilestone(e){if(!await this.isInitialized())return!1;let t;if(typeof e=="number"){let i=await this.getCheckpoints(e+1);if(e<1||e>i.length)return!1;t=i[e-1].hash}else t=e;let r=await this.getMilestoneTags(t);if(r.length===0)return!1;for(let i of r)try{await this.git("tag","-d",i)}catch{}return!0}async getMilestoneTags(e){try{return(await this.git("tag","--points-at",e)).trim().split(`
|
|
62
|
+
`).filter(r=>r.startsWith("milestone/")).filter(Boolean)}catch{return[]}}async getAllMilestones(){let e=new Map;try{let t=await this.git("tag","-l","milestone/*");for(let r of t.trim().split(`
|
|
63
|
+
`).filter(Boolean))try{let i=(await this.git("rev-list","-1",r)).trim(),s=r.replace("milestone/","").replace(/-/g," ");e.set(i,s)}catch{}}catch{}return e}async getMilestones(){return(await this.getCheckpoints(100)).filter(t=>t.isMilestone)}git(...e){return new Promise((t,r)=>{let i=(0,tr.spawn)("git",e,{cwd:this.gitDir}),s="",o="";i.stdout.on("data",a=>{s+=a.toString("utf-8")}),i.stderr.on("data",a=>{o+=a.toString("utf-8")}),i.on("error",a=>r(a)),i.on("close",a=>{if(a!==0&&!e.includes("status")){r(new Error(`git ${e.join(" ")} failed: ${o}`));return}t(s)})})}};var fe=k(require("fs/promises")),rr=k(require("path")),it=class extends B{constructor(t,r){super(t,r);this.pullOptions=t}hasError=!1;downloadedFiles=[];async sync(){console.log(`Starting pull from ${this.options.realmUrl} to ${this.options.localDir}`),console.log("Testing realm access...");try{await this.getRemoteFileList("")}catch(l){throw console.error("Failed to access realm:",l),new Error("Cannot proceed with pull: Authentication or access failed. Please check your Matrix credentials and realm permissions.")}console.log("Realm access verified");let[t,r]=await Promise.all([this.getRemoteFileList(),this.getLocalFileList()]);if(console.log(`Found ${t.size} files in remote realm`),console.log(`Found ${r.size} files in local directory`),this.options.dryRun)try{await fe.access(this.options.localDir)}catch{console.log(`[DRY RUN] Would create directory: ${this.options.localDir}`)}else await fe.mkdir(this.options.localDir,{recursive:!0});let i=new Set;if(this.pullOptions.deleteLocal)for(let l of r.keys())t.has(l)||i.add(l);let s=new q(this.options.localDir);if(i.size>0&&!this.options.dryRun){let l=Array.from(i).map(c=>({file:c,status:"deleted"})),u=await s.createCheckpoint("remote",l,`Pre-delete checkpoint: ${i.size} files not on server`);u&&console.log(`
|
|
64
|
+
Checkpoint created before deletion: ${u.shortHash}`)}let o=await Promise.all(Array.from(t.keys()).map(l=>this.remoteLimit(async()=>{try{let u=rr.join(this.options.localDir,l);return await this.downloadFile(l,u),l}catch(u){return this.hasError=!0,console.error(`Error downloading ${l}:`,u),null}})));this.downloadedFiles=o.filter(l=>l!==null);let a=[];if(i.size>0&&(console.log(`
|
|
65
|
+
Deleting ${i.size} local files that don't exist in realm...`),a=(await Promise.all(Array.from(i).map(async u=>{try{let c=r.get(u);return c?(await this.deleteLocalFile(c),console.log(` Deleted: ${u}`),u):null}catch(c){return this.hasError=!0,console.error(`Error deleting local file ${u}:`,c),null}}))).filter(u=>u!==null)),!this.options.dryRun&&this.downloadedFiles.length+a.length>0){let l=[...this.downloadedFiles.map(c=>({file:c,status:"modified"})),...a.map(c=>({file:c,status:"deleted"}))],u=await s.createCheckpoint("remote",l);if(u){let c=u.isMajor?"[MAJOR]":"[minor]";console.log(`
|
|
66
|
+
Checkpoint created: ${u.shortHash} ${c} ${u.message}`)}}console.log("Pull completed")}};function ir(n){n.command("pull").description("Pull files from a Boxel realm to a local directory").argument("<realm-url>","The URL of the source realm (e.g., https://app.boxel.ai/demo/)").argument("<local-dir>","The local directory to sync files to").option("--delete","Delete local files that do not exist in the realm").option("--dry-run","Show what would be done without making changes").action(async(e,t,r)=>{let i=await Fi(e,t,r);i.error&&(console.error(`Error: ${i.error}`),process.exit(i.files.length>0?2:1)),console.log("Pull completed successfully")})}async function Fi(n,e,t){let r=t.profileManager??F();if(!r.getActiveProfile())return{files:[],error:"No active profile. Run `boxel profile add` to create one."};try{let s=new it({realmUrl:n,localDir:e,deleteLocal:t.delete,dryRun:t.dryRun},r);return await s.sync(),s.hasError?{files:s.downloadedFiles.sort(),error:"Pull completed with errors. Some files may not have been downloaded."}:{files:s.downloadedFiles.sort()}}catch(s){return{files:[],error:`Pull failed: ${s instanceof Error?s.message:String(s)}`}}}var z=k(require("fs/promises")),st=k(require("path")),sr=k(require("crypto"));function Li(n){if(typeof n!="object"||n===null)return!1;let e=n;if(typeof e.realmUrl!="string"||typeof e.files!="object"||e.files===null)return!1;for(let t of Object.values(e.files))if(typeof t!="string")return!1;if(e.remoteMtimes!==void 0){if(typeof e.remoteMtimes!="object"||e.remoteMtimes===null)return!1;for(let t of Object.values(e.remoteMtimes))if(typeof t!="number")return!1}return!0}async function me(n){try{return await z.access(n),!0}catch{return!1}}async function X(n){let e=await z.readFile(n);return sr.createHash("md5").update(e).digest("hex")}async function ge(n){let e=st.join(n,".boxel-sync.json"),t;try{t=await z.readFile(e,"utf8")}catch(i){if(i.code==="ENOENT")return null;throw i}let r;try{r=JSON.parse(t)}catch{return null}return Li(r)?r:(console.warn("Warning: .boxel-sync.json is malformed or has an unexpected shape; falling back to a full upload."),null)}async function be(n,e){let t=st.join(n,".boxel-sync.json");await z.writeFile(t,JSON.stringify(e,null,2))}var nt=class extends B{constructor(t,r){super(t,r);this.pushOptions=t}hasError=!1;async sync(){console.log(`Starting push from ${this.options.localDir} to ${this.options.realmUrl}`),console.log("Testing realm access...");let t;try{t=await this.getRemoteFileList("")}catch(c){throw console.error("Failed to access realm:",c),new Error("Cannot proceed with push: Authentication or access failed. Please check your credentials and realm permissions.")}console.log("Realm access verified");let r=await this.getLocalFileList();console.log(`Found ${r.size} files in local directory`);let i=await ge(this.options.localDir),s={realmUrl:this.normalizedRealmUrl,files:{},remoteMtimes:{}},o=new Map,a=new Set;if(!this.pushOptions.force&&i!==null&&i.realmUrl===this.normalizedRealmUrl){console.log("Checking for changed files...");let c=0,[h,p]=await Promise.all([this.getRemoteMtimes(),Promise.all(Array.from(r.entries()).map(async([f,g])=>{if(T(f))return{relativePath:f,localPath:g,currentHash:"",protected:!0};let $=await X(g);return{relativePath:f,localPath:g,currentHash:$,protected:!1}}))]);for(let f of p){if(f.protected){c++;continue}let g=i.files[f.relativePath],$=i.remoteMtimes?.[f.relativePath],H=h.get(f.relativePath),G=g!==f.currentHash,_e=g!==void 0&&!t.has(f.relativePath),K=$!==void 0&&H!==void 0&&H!==$;G||_e||K?(o.set(f.relativePath,f.localPath),!G&&(_e||K)&&a.add(f.relativePath)):(c++,s.files[f.relativePath]=f.currentHash,$!==void 0&&(s.remoteMtimes[f.relativePath]=$))}if(c>0&&console.log(`Skipping ${c} unchanged files`),a.size>0){let f=Array.from(a),g=f.slice(0,5).join(", "),$=f.length>5?", ...":"";console.warn(`Warning: ${a.size} file(s) changed on the realm since your last push; your local versions will overwrite them: ${g}${$}`)}}else{this.pushOptions.force?console.log("Force mode: uploading all files"):console.log(i?"Realm URL changed, will upload all files":"No sync manifest found, will upload all files");for(let[c,h]of r)T(c)||o.set(c,h)}let u=!1;if(o.size===0)console.log("No files to upload - everything is up to date");else{console.log(`Uploading ${o.size} file(s) via /_atomic...`);let c=new Set,h=this.pushOptions.force||!i;for(let f of o.keys())if(h)t.has(f)||c.add(f);else{let g=i.files[f]!==void 0,$=g&&!t.has(f);(!g||$)&&c.add(f)}let p=await this.uploadFilesAtomic(o,c);if(p.error){u=!0,this.hasError=!0,console.error(p.error.message);for(let f of p.error.perFile){let g;f.status===409?g=`${f.path} was created on the realm concurrently \u2014 run with --force to overwrite.`:f.status===404?g=`${f.path} was removed from the realm concurrently \u2014 run with --force to re-create it from your local copy.`:g=`${f.path}: ${f.title}`,console.error(` ${g}`)}}else if(p.succeeded.length>0){let f=await Promise.all(p.succeeded.map(async g=>({rel:g,hash:await X(o.get(g))})));for(let{rel:g,hash:$}of f)s.files[g]=$}}if(this.pushOptions.deleteRemote){let c=new Set(t.keys());for(let h of c)T(h)&&c.delete(h);for(let h of r.keys())c.delete(h);c.size>0&&(console.log(`Deleting ${c.size} remote files that don't exist locally`),await Promise.all(Array.from(c).map(async h=>{try{await this.deleteFile(h)}catch(p){this.hasError=!0,console.error(`Error deleting ${h}:`,p)}})))}if(!this.options.dryRun&&!u&&o.size>0)try{let c=await this.getRemoteMtimes();for(let h of Object.keys(s.files)){let p=c.get(h);p!==void 0&&(s.remoteMtimes[h]=p)}}catch(c){console.warn("Could not refresh remote mtimes after upload:",c)}if(s.remoteMtimes&&Object.keys(s.remoteMtimes).length===0&&delete s.remoteMtimes,!this.options.dryRun&&!u&&await be(this.options.localDir,s),!this.options.dryRun&&o.size>0&&!u){let c=new q(this.options.localDir),h=Array.from(o.keys()).map(f=>({file:f,status:"modified"})),p=await c.createCheckpoint("local",h);if(p){let f=p.isMajor?"[MAJOR]":"[minor]";console.log(`
|
|
67
|
+
Checkpoint created: ${p.shortHash} ${f} ${p.message}`)}}console.log("Push completed")}};function nr(n){n.command("push").description("Push local files to a Boxel realm").argument("<local-dir>","The local directory containing files to sync").argument("<realm-url>","The URL of the target realm (e.g., https://app.boxel.ai/demo/)").option("--delete","Delete remote files that do not exist locally").option("--dry-run","Show what would be done without making changes").option("--force","Upload all files, even if unchanged").action(async(e,t,r)=>{await Ui(e,t,r)})}async function Ui(n,e,t){let r=t.profileManager??F();r.getActiveProfile()||(console.error("Error: no active profile. Run `boxel profile add` to create one."),process.exit(1)),await me(n)||(console.error(`Local directory does not exist: ${n}`),process.exit(1));try{let s=new nt({realmUrl:e,localDir:n,deleteRemote:t.delete,dryRun:t.dryRun,force:t.force},r);await s.sync(),s.hasError?(console.log("Push did not complete successfully. View logs for details"),process.exit(2)):console.log("Push completed successfully")}catch(s){console.error("Push failed:",s),process.exit(1)}}var ot=k(require("path"));function or(n,e,t){let r=e.has(n),i=t?.files[n]!==void 0;return r&&i?e.get(n)===t.files[n]?"unchanged":"changed":r&&!i?"added":!r&&i?"deleted":"unchanged"}function ar(n,e,t){let r=e.has(n),i=t?.remoteMtimes?.[n]!==void 0,s=t?.files[n]!==void 0,o=i||s;return r&&i?e.get(n)===t.remoteMtimes[n]?"unchanged":"changed":r&&s?"changed":r&&!o?"added":!r&&o?"deleted":"unchanged"}function lr(n,e,t){return n==="unchanged"&&e==="unchanged"?"noop":n==="changed"&&e==="unchanged"?"push":n==="unchanged"&&e==="changed"?"pull":n==="added"&&e==="unchanged"?"push":n==="unchanged"&&e==="added"?"pull":n==="changed"&&e==="changed"||n==="added"&&e==="added"||n==="changed"&&e==="added"||n==="added"&&e==="changed"?"conflict":n==="deleted"&&e==="unchanged"?t.deleteSync||t.preferLocal?"push-delete":"noop":n==="unchanged"&&e==="deleted"?t.deleteSync||t.preferRemote?"pull-delete":"noop":n==="deleted"&&e==="changed"||n==="changed"&&e==="deleted"?"conflict":n==="deleted"&&e==="deleted"?"noop":n==="added"&&e==="deleted"?"push":n==="deleted"&&e==="added"?"pull":"noop"}function cr(n,e,t,r){let{localStatus:i,remoteStatus:s,relativePath:o}=n;if(!r)return null;switch(r){case"prefer-local":return i==="deleted"?"push-delete":"push";case"prefer-remote":return s==="deleted"?"pull-delete":"pull";case"prefer-newest":{if(i==="deleted"&&s==="changed")return"pull";if(i==="changed"&&s==="deleted")return"push";let a=e.get(o),l=t.get(o);return a&&l!==void 0?a.mtime>l*1e3?"push":"pull":"push"}}}var at=class extends B{constructor(t,r){super(t,r);this.syncOptions=t}hasError=!1;get conflictStrategy(){return this.syncOptions.preferLocal?"prefer-local":this.syncOptions.preferRemote?"prefer-remote":this.syncOptions.preferNewest?"prefer-newest":null}async sync(){console.log(`Starting sync between ${this.options.localDir} and ${this.options.realmUrl}`),console.log("Testing realm access...");let t;try{t=await this.getRemoteFileList("")}catch(m){throw console.error("Failed to access realm:",m),new Error("Cannot proceed with sync: Authentication or access failed. Please check your Matrix credentials and realm permissions.")}console.log("Realm access verified");let[r,i,s]=await Promise.all([this.getLocalFileListWithMtimes(),this.getRemoteMtimes(),ge(this.options.localDir)]),o=new Map;for(let[m,b]of r)o.set(m,b.path);if(i.size===0&&t&&t.size>0){console.log("Remote mtimes unavailable, falling back to file listing for remote detection");for(let[m]of t)i.set(m,0)}console.log(`Found ${o.size} local files`),console.log(`Found ${i.size} remote files`),s&&s.realmUrl!==this.normalizedRealmUrl&&console.warn(`${D}Warning:${d} Manifest realm URL (${s.realmUrl}) differs from target (${this.normalizedRealmUrl}). Treating as first sync.`);let a=s&&s.realmUrl===this.normalizedRealmUrl?s:null,l=new Map;await Promise.all(Array.from(o.entries()).map(async([m,b])=>{T(m)||l.set(m,await X(b))}));let u=new Set;for(let m of o.keys())u.add(m);for(let m of i.keys())u.add(m);if(a){for(let m of Object.keys(a.files))u.add(m);if(a.remoteMtimes)for(let m of Object.keys(a.remoteMtimes))u.add(m)}let c=[];for(let m of u){if(T(m))continue;let b=or(m,l,a),_=ar(m,i,a),x=lr(b,_,this.syncOptions);c.push({relativePath:m,localStatus:b,remoteStatus:_,action:x})}let h=[],p=[],f=[],g=[],$=[],H=0;for(let m of c)switch(m.action){case"push":h.push(m.relativePath);break;case"pull":p.push(m.relativePath);break;case"push-delete":f.push(m.relativePath);break;case"pull-delete":g.push(m.relativePath);break;case"conflict":$.push(m);break;case"noop":H++;break}let G=[];for(let m of $)switch(cr(m,r,i,this.conflictStrategy)){case"push":h.push(m.relativePath);break;case"pull":p.push(m.relativePath);break;case"push-delete":f.push(m.relativePath);break;case"pull-delete":g.push(m.relativePath);break;case"noop":break;default:G.push(m.relativePath);break}if(console.log(`
|
|
68
|
+
${y}Sync plan:${d}`),h.length>0&&console.log(` ${R}\u2191 Push:${d} ${h.length} file(s)`),p.length>0&&console.log(` ${C}\u2193 Pull:${d} ${p.length} file(s)`),f.length>0&&console.log(` ${v}\u2191 Delete remote:${d} ${f.length} file(s)`),g.length>0&&console.log(` ${v}\u2193 Delete local:${d} ${g.length} file(s)`),G.length>0){console.log(` ${D}\u26A0 Conflicts skipped:${d} ${G.length} file(s)`);for(let m of G)console.log(` ${m}`);console.log(` ${y}Use --prefer-local, --prefer-remote, or --prefer-newest to resolve.${d}`)}if(H>0&&console.log(` ${y}Unchanged: ${H} file(s)${d}`),h.length+p.length+f.length+g.length===0){console.log(`
|
|
69
|
+
Everything is up to date`),!this.options.dryRun&&!a&&G.length===0&&await this.writeManifest(l,i);return}let K=[],se=[],ne=[],we=[];if(p.length>0){console.log(`
|
|
70
|
+
Pulling ${p.length} file(s)...`);let m=await Promise.all(p.map(b=>this.remoteLimit(async()=>{try{let _=ot.join(this.options.localDir,b);return await this.downloadFile(b,_),b}catch(_){return this.hasError=!0,console.error(`Error downloading ${b}:`,_),null}})));K.push(...m.filter(b=>b!==null))}if(h.length>0){console.log(`
|
|
71
|
+
Pushing ${h.length} file(s)...`);let m=new Map;for(let x of h){let oe=o.get(x);oe&&m.set(x,oe)}let b=new Set;for(let x of m.keys()){let oe=a?.files[x]!==void 0,gr=i.has(x);!oe&&!gr&&b.add(x)}let _=await this.uploadFilesAtomic(m,b);if(_.error){this.hasError=!0,console.error(_.error.message);for(let x of _.error.perFile)console.error(` ${x.path}: ${x.title}`)}else se.push(..._.succeeded)}if(f.length>0){console.log(`
|
|
72
|
+
Deleting ${f.length} remote file(s)...`);let m=await Promise.all(f.map(b=>this.remoteLimit(async()=>{try{return await this.deleteFile(b),b}catch(_){return this.hasError=!0,console.error(`Error deleting remote ${b}:`,_),null}})));ne.push(...m.filter(b=>b!==null))}if(g.length>0){console.log(`
|
|
73
|
+
Deleting ${g.length} local file(s)...`);let m=await Promise.all(g.map(async b=>{try{let _=o.get(b);return _?(await this.deleteLocalFile(_),b):null}catch(_){return this.hasError=!0,console.error(`Error deleting local ${b}:`,_),null}}));we.push(...m.filter(b=>b!==null))}if(!this.options.dryRun&&!this.hasError){let m=new Map;if(a)for(let[_,x]of Object.entries(a.files))m.set(_,x);for(let[_,x]of l)m.set(_,x);for(let _ of se){let x=o.get(_);x&&m.set(_,await X(x))}for(let _ of K){let x=ot.join(this.options.localDir,_);m.set(_,await X(x))}for(let _ of ne)m.delete(_);for(let _ of we)m.delete(_);let b=i;if(se.length>0||ne.length>0)try{b=await this.getRemoteMtimes()}catch{console.warn("Could not refresh remote mtimes after sync")}await this.writeManifest(m,b)}if(!this.options.dryRun){let m=[...se.map(b=>({file:b,status:"modified"})),...K.map(b=>({file:b,status:"modified"})),...ne.map(b=>({file:b,status:"deleted"})),...we.map(b=>({file:b,status:"deleted"}))];if(m.length>0){let _=await new q(this.options.localDir).createCheckpoint("local",m);if(_){let x=_.isMajor?"[MAJOR]":"[minor]";console.log(`
|
|
74
|
+
Checkpoint created: ${_.shortHash} ${x} ${_.message}`)}}}console.log(`
|
|
75
|
+
Sync completed`)}async writeManifest(t,r){let i={realmUrl:this.normalizedRealmUrl,files:{},remoteMtimes:{}};for(let[s,o]of t){i.files[s]=o;let a=r.get(s);a!==void 0&&a!==0&&(i.remoteMtimes[s]=a)}i.remoteMtimes&&Object.keys(i.remoteMtimes).length===0&&delete i.remoteMtimes,await be(this.options.localDir,i)}};function ur(n){n.command("sync").description("Bidirectional sync between a local directory and a Boxel realm").argument("<local-dir>","The local directory to sync").argument("<realm-url>","The URL of the target realm (e.g., https://app.boxel.ai/demo/)").option("--prefer-local","Resolve conflicts by keeping local version").option("--prefer-remote","Resolve conflicts by keeping remote version").option("--prefer-newest","Resolve conflicts by keeping newest version").option("--delete","Sync deletions both ways").option("--dry-run","Preview without making changes").action(async(e,t,r)=>{await Ii(e,t,r)})}async function Ii(n,e,t){let r=t.profileManager??F();r.getActiveProfile()||(console.error("Error: no active profile. Run `boxel profile add` to create one."),process.exit(1)),[t.preferLocal,t.preferRemote,t.preferNewest].filter(Boolean).length>1&&(console.error("Error: only one conflict strategy can be specified (--prefer-local, --prefer-remote, or --prefer-newest)"),process.exit(1)),await me(n)||(console.error(`Local directory does not exist: ${n}`),process.exit(1));try{let o=new at({realmUrl:e,localDir:n,preferLocal:t.preferLocal,preferRemote:t.preferRemote,preferNewest:t.preferNewest,deleteSync:t.delete,dryRun:t.dryRun},r);await o.sync(),o.hasError?(console.log("Sync did not complete successfully. View logs for details"),process.exit(2)):console.log("Sync completed successfully")}catch(o){console.error("Sync failed:",o),process.exit(1)}}function hr(n){let e=n.command("realm").description("Manage realms on the realm server");Vt(e),ir(e),nr(e),ur(e)}async function ji(n,e,t){let r=t?.profileManager??F(),i=r.getActiveProfile();if(!i)throw new Error("No active profile. Run `boxel profile add` to create one.");let o=`${i.profile.realmServerUrl.replace(/\/$/,"")}/_run-command`,a={data:{type:"run-command",attributes:{realmURL:e,command:n,commandInput:t?.input??null}}},l;try{l=await r.authedRealmServerFetch(o,{method:"POST",headers:{"Content-Type":"application/vnd.api+json",Accept:"application/vnd.api+json"},body:JSON.stringify(a)})}catch(h){return{status:"error",error:`run-command fetch failed: ${h instanceof Error?h.message:String(h)}`}}if(!l.ok){let h=await l.text().catch(()=>"(no body)");return{status:"error",error:`run-command HTTP ${l.status}: ${h}`}}let u;try{u=await l.json()}catch{return{status:"error",error:`run-command response was not valid JSON (HTTP ${l.status})`}}let c=u.data?.attributes;return{status:c?.status??"error",result:c?.cardResultString??null,error:c?.error??null}}function pr(n){n.command("run-command").description("Execute a host command on the realm server via the prerenderer").argument("<command-specifier>","Command module path (e.g. @cardstack/boxel-host/commands/get-card-type-schema/default)").requiredOption("--realm <realm-url>","The realm URL context for the command").option("--input <json>","JSON string of command input").option("--json","Output raw JSON response").action(async(e,t)=>{let r;if(t.input)try{let s=JSON.parse(t.input);(typeof s!="object"||s===null||Array.isArray(s))&&(console.error(`${v}Error:${d} --input must be a JSON object, got ${Array.isArray(s)?"array":typeof s}`),process.exit(1)),r=s}catch{console.error(`${v}Error:${d} --input is not valid JSON: ${t.input}`),process.exit(1)}let i;try{i=await ji(e,t.realm,{input:r})}catch(s){console.error(`${v}Error:${d} ${s instanceof Error?s.message:String(s)}`),process.exit(1)}if(t.json)console.log(JSON.stringify(i,null,2));else{if(console.log(`${y}Status:${d} ${Vi(i.status)}${i.status}${d}`),i.result){console.log(`${y}Result:${d}`);try{console.log(JSON.stringify(JSON.parse(i.result),null,2))}catch{console.log(i.result)}}i.error&&console.error(`${v}Error:${d} ${i.error}`)}(i.status==="error"||i.status==="unusable")&&process.exit(1)})}function Vi(n){switch(n){case"ready":return R;case"error":return v;default:return C}}var Hi=JSON.parse((0,fr.readFileSync)((0,mr.resolve)(__dirname,"../package.json"),"utf-8")),ie=new dr.Command;ie.name("boxel").description("CLI tools for Boxel workspace management").version(Hi.version);ie.command("profile").description("Manage saved profiles for different users/environments").argument("[subcommand]","list | add | switch | remove | migrate").argument("[arg]","Profile ID (for switch/remove)").option("-u, --user <matrixId>","Matrix user ID (e.g., @user:boxel.ai)").option("-p, --password <password>","Password (for add command)").option("-n, --name <displayName>","Display name (for add command)").action(async(n,e,t)=>{t?.password&&console.warn('Warning: Supplying a password via -p/--password may expose it in shell history and process listings. For non-interactive usage, prefer the BOXEL_PASSWORD environment variable or use "boxel profile add" interactively.'),await Lt(n,e,t)});hr(ie);pr(ie);ie.parse();
|
package/package.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cardstack/boxel-cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "CLI tools for Boxel workspace management",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"boxel": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/**/*",
|
|
12
|
+
"src/**/*.ts",
|
|
13
|
+
"api.ts",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">= 18"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"boxel",
|
|
21
|
+
"cli",
|
|
22
|
+
"cardstack"
|
|
23
|
+
],
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/cardstack/boxel.git",
|
|
27
|
+
"directory": "packages/boxel-cli"
|
|
28
|
+
},
|
|
29
|
+
"author": "Cardstack",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@aws-crypto/sha256-js": "^5.2.0",
|
|
32
|
+
"commander": "^13.1.0",
|
|
33
|
+
"dotenv": "^16.4.7",
|
|
34
|
+
"ignore": "^5.2.0",
|
|
35
|
+
"p-limit": "^7.3.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^24.3.0",
|
|
39
|
+
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
40
|
+
"@typescript-eslint/parser": "^7.18.0",
|
|
41
|
+
"concurrently": "^8.2.2",
|
|
42
|
+
"esbuild": "^0.19.0",
|
|
43
|
+
"eslint": "^8.57.1",
|
|
44
|
+
"eslint-plugin-n": "^17.17.0",
|
|
45
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
46
|
+
"prettier": "^3.6.2",
|
|
47
|
+
"ts-node": "^10.9.1",
|
|
48
|
+
"tsx": "^4.0.0",
|
|
49
|
+
"typescript": "~5.9.3",
|
|
50
|
+
"vite": "^6.3.2",
|
|
51
|
+
"vitest": "^2.1.9",
|
|
52
|
+
"@cardstack/local-types": "0.0.0",
|
|
53
|
+
"@cardstack/runtime-common": "1.0.0",
|
|
54
|
+
"@cardstack/postgres": "0.0.0"
|
|
55
|
+
},
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"access": "public"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "pnpm clean && tsx scripts/build.ts",
|
|
61
|
+
"clean": "rm -rf dist/*",
|
|
62
|
+
"start": "NODE_NO_WARNINGS=1 ts-node --transpileOnly src/index.ts",
|
|
63
|
+
"lint": "concurrently \"pnpm:lint:*(!fix)\" --names \"lint:\"",
|
|
64
|
+
"lint:fix": "concurrently \"pnpm:lint:*:fix\" --names \"fix:\"",
|
|
65
|
+
"lint:js": "eslint . --report-unused-disable-directives --cache",
|
|
66
|
+
"lint:js:fix": "eslint . --report-unused-disable-directives --fix",
|
|
67
|
+
"lint:types": "tsc --noEmit",
|
|
68
|
+
"test": "vitest run",
|
|
69
|
+
"test:unit": "vitest run --exclude 'tests/integration/**'",
|
|
70
|
+
"test:integration": "./tests/scripts/run-integration-with-test-pg.sh",
|
|
71
|
+
"test:watch": "vitest",
|
|
72
|
+
"version:patch": "npm version patch",
|
|
73
|
+
"version:minor": "npm version minor",
|
|
74
|
+
"version:major": "npm version major",
|
|
75
|
+
"publish:npm": "npm publish",
|
|
76
|
+
"publish:dry": "npm publish --dry-run"
|
|
77
|
+
}
|
|
78
|
+
}
|