ts-pantry 0.11.128 → 0.11.130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +100 -0
- package/dist/bin/cli.js +45 -45
- package/dist/chunk-0q9ma0fx.js +1 -0
- package/dist/{chunk-61fx83zk.js → chunk-49a6jmw9.js} +128 -128
- package/dist/chunk-5qaednd9.js +1 -0
- package/dist/chunk-832n69tb.js +14 -0
- package/dist/chunk-8h6c7pf2.js +1 -0
- package/dist/chunk-az1ps614.js +53 -0
- package/dist/chunk-b57pqv4k.js +133 -0
- package/dist/chunk-gjv8yyy4.js +1 -0
- package/dist/chunk-j5y05nsc.js +1 -0
- package/dist/chunk-kdydq4xh.js +1 -0
- package/dist/chunk-p0tr0ryj.js +1 -0
- package/dist/chunk-v0wf1yyp.js +1 -0
- package/dist/chunk-y7anxtyk.js +336 -0
- package/dist/chunk-ya1t19xm.js +1 -0
- package/dist/src/index.js +1 -1
- package/dist/src/native/android.d.ts +3 -0
- package/dist/src/native/apple-signing.d.ts +52 -0
- package/dist/src/native/apple.d.ts +7 -0
- package/dist/src/native/build.d.ts +24 -0
- package/dist/src/native/command.d.ts +6 -0
- package/dist/src/native/config.d.ts +21 -0
- package/dist/src/native/environment.d.ts +4 -0
- package/dist/src/native/google-play.d.ts +26 -0
- package/dist/src/native/index.d.ts +14 -0
- package/dist/src/native/index.js +50 -0
- package/dist/src/native/keychain-export.d.ts +3 -0
- package/dist/src/native/pipeline.d.ts +14 -0
- package/dist/src/native/release-app-store.d.ts +43 -0
- package/dist/src/native/release.d.ts +4 -0
- package/dist/src/native/release.js +1 -0
- package/dist/src/native/runtime.d.ts +7 -0
- package/dist/src/testing/index.js +1 -1
- package/package.json +13 -1
- package/dist/chunk-1n0pmyxb.js +0 -1
- package/dist/chunk-3xced748.js +0 -1
- package/dist/chunk-80sjcjk8.js +0 -1
- package/dist/chunk-eq8d7w4f.js +0 -1
- package/dist/chunk-ft6cxhxx.js +0 -1
- package/dist/chunk-gf497z2g.js +0 -1
- package/dist/chunk-metrsv35.js +0 -1
- package/dist/chunk-q1fhgg4q.js +0 -1
package/README.md
CHANGED
|
@@ -134,3 +134,103 @@ when the prepared version should enter App Review. `submitAppStore` prepares an
|
|
|
134
134
|
already-uploaded version by bundle ID and version, and preserves active review
|
|
135
135
|
submissions when a release command is retried. These APIs work for macOS and iOS
|
|
136
136
|
apps, independently of the application framework or an extension container.
|
|
137
|
+
|
|
138
|
+
## Native application releases
|
|
139
|
+
|
|
140
|
+
Pantry owns native runtime provisioning, temporary signing credentials,
|
|
141
|
+
notarization, App Store packaging and delivery, Google Play delivery, and
|
|
142
|
+
verified GitHub release assets. Buddy owns compilation. App repositories keep
|
|
143
|
+
application metadata in `craft.config.ts` and declare release policy in
|
|
144
|
+
`pantry.json`; they do not need platform scripts or entitlement XML.
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"native": {
|
|
149
|
+
"environment": "production",
|
|
150
|
+
"runtime": {
|
|
151
|
+
"revision": "d675077c317c486d8b5743f3432c40ddf1cd693a",
|
|
152
|
+
"version": "0.0.295"
|
|
153
|
+
},
|
|
154
|
+
"checks": {
|
|
155
|
+
"before": [["bun", "run", "lint"], ["bun", "run", "test:unit"]],
|
|
156
|
+
"after": [["bun", "run", "test:native"]]
|
|
157
|
+
},
|
|
158
|
+
"macos": {
|
|
159
|
+
"notarize": true,
|
|
160
|
+
"entitlements": { "direct": { "com.apple.security.cs.allow-jit": true } }
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Use the versioned `pantry-pm/pantry/.github/workflows/native-app.yml` reusable
|
|
167
|
+
workflow with `release: true` on version tags, and the versioned
|
|
168
|
+
`native-check.yml` workflow for read-only CI.
|
|
169
|
+
Pass `secrets: inherit` for releases. Create `.env.production` with
|
|
170
|
+
`buddy env:set KEY --stdin --file .env.production`, commit its authenticated
|
|
171
|
+
ciphertext, and keep `.env.keys` ignored. The release workflow receives only
|
|
172
|
+
`DOTENV_PRIVATE_KEY_PRODUCTION`; the other provider credentials below belong
|
|
173
|
+
in the encrypted file. Pantry uses the same whole-file reader and scoped key
|
|
174
|
+
resolver as Buddy, masks decrypted values before running commands, and never
|
|
175
|
+
writes plaintext credentials back to the repository. CI audits ciphertext
|
|
176
|
+
without receiving the decryption key. Missing, wrong or partial decryption
|
|
177
|
+
fails before signing or publication.
|
|
178
|
+
|
|
179
|
+
The workflow installs dependencies from the
|
|
180
|
+
lockfile, runs all declared checks, provisions the immutable Craft source with
|
|
181
|
+
its locked Zig compiler and first-party pins, builds through Buddy, and checks
|
|
182
|
+
the actual bundle's identity, size, Mach-O executable and native launch. Native
|
|
183
|
+
checks remain app-owned and run against the real artifact. Release tags must
|
|
184
|
+
match `package.json`. Releases reject the local `CRAFT_BIN` development override.
|
|
185
|
+
|
|
186
|
+
Direct macOS releases require `APPLE_APPLICATION_CERTIFICATE` (base64 P12),
|
|
187
|
+
`APPLE_CERTIFICATE_PASSWORD`, and, for restricted capabilities,
|
|
188
|
+
`APPLE_PROVISIONING_PROFILE_BASE64` in the encrypted environment. Notarization accepts App Store Connect
|
|
189
|
+
`APP_STORE_CONNECT_API_KEY_ID`, `APP_STORE_CONNECT_ISSUER_ID` and
|
|
190
|
+
`APP_STORE_CONNECT_PRIVATE_KEY`, or the `APPLE_ID`,
|
|
191
|
+
`APPLE_APP_SPECIFIC_PASSWORD`, `APPLE_TEAM_ID` alternative. Local runs can use
|
|
192
|
+
`APPLE_NOTARY_KEYCHAIN_PROFILE` or `APP_STORE_CONNECT_API_KEY_PATH` instead.
|
|
193
|
+
Only Apple's Accepted status allows stapling; the stapled file is hashed for the
|
|
194
|
+
release receipt. A configured target with missing credentials fails before the
|
|
195
|
+
build. Check runs receive no publishing secrets.
|
|
196
|
+
|
|
197
|
+
Enable `native.macos.appStore: true` to build a separate sandboxed distribution
|
|
198
|
+
and signed PKG. Declare `entitlements.appStore` including a true
|
|
199
|
+
`com.apple.security.app-sandbox`; provide
|
|
200
|
+
`APPLE_APP_STORE_APPLICATION_CERTIFICATE`, `APPLE_APP_STORE_INSTALLER_CERTIFICATE`,
|
|
201
|
+
and `APPLE_APP_STORE_PROVISIONING_PROFILE_BASE64` in addition to the Connect API
|
|
202
|
+
credentials. The API upload is validated and a receipt is attached. This is
|
|
203
|
+
App Store Connect delivery, not an assertion that Apple approved a review.
|
|
204
|
+
Apple enrollment, account agreements and initial account credentials remain
|
|
205
|
+
account-owner setup; Pantry's existing provisioning APIs handle certificates,
|
|
206
|
+
bundle IDs, profiles and Connect resources.
|
|
207
|
+
|
|
208
|
+
Android apps declare `native.android` with `bundle` (an AAB path), `packageName`,
|
|
209
|
+
`track`, and explicit `status` (`draft`, `completed`, or `inProgress` with a
|
|
210
|
+
`userFraction` between zero and one). Their `native.build` is an argument array
|
|
211
|
+
for the project's native compiler. Pantry signs with `ANDROID_KEYSTORE_BASE64`,
|
|
212
|
+
`ANDROID_KEYSTORE_PASSWORD`, `ANDROID_KEY_ALIAS` and `ANDROID_KEY_PASSWORD`, or
|
|
213
|
+
verifies the compiler's already-signed AAB. `GOOGLE_PLAY_SERVICE_ACCOUNT_JSON`
|
|
214
|
+
provides the publisher account. Pantry checks the upload SHA-256 and version
|
|
215
|
+
code, updates the configured track in an edit, validates it, and commits only
|
|
216
|
+
after those steps pass. Failed or validation-only edits are deleted. A commit
|
|
217
|
+
never implicitly cancels another in-progress store review. Play app enrollment
|
|
218
|
+
and granting the service account access are initial account-owner setup.
|
|
219
|
+
|
|
220
|
+
For local validation use `ts-pantry native:check`; for signed release artifact
|
|
221
|
+
preparation use `ts-pantry native:prepare-release`. The public
|
|
222
|
+
`ts-pantry/native` entry exports the same runtime, build, signing, notarization,
|
|
223
|
+
App Store and Google Play operations used by Buddy and the GitHub Action.
|
|
224
|
+
|
|
225
|
+
`exportAppleKeychainIdentity` exports exactly one existing macOS identity by
|
|
226
|
+
certificate fingerprint through Security.framework. Its P12 password is supplied
|
|
227
|
+
through the child environment, and unrelated identities are never exported.
|
|
228
|
+
It supports migrating a local signing identity into Buddy-encrypted CI settings.
|
|
229
|
+
|
|
230
|
+
`buddy release --bump patch|minor|major` delegates native app qualification and
|
|
231
|
+
versioning to `releaseNativeApp`. It requires clean source on `main`, runs the
|
|
232
|
+
configured artifact and native checks first, then uses the shared bumpx
|
|
233
|
+
publisher to commit, tag and push normally. The tag invokes the Pantry delivery
|
|
234
|
+
workflow. `ts-pantry native:release --bump patch` exposes the same operation;
|
|
235
|
+
`--dry-run` previews the version change after qualification without committing,
|
|
236
|
+
tagging or pushing.
|
package/dist/bin/cli.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
2
|
+
import{e,x,n,d,h,P,Y,re,f,z,j,E,L,ie,ce,s,M,U,m,V,D,S,_,T,c,G,ue,de,he,Qe,et,tt}from"../chunk-49a6jmw9.js";import"../chunk-5qaednd9.js";import C from"node:fs";import O from"node:path";import v from"node:process";import{existsSync as Ge}from"node:fs";import be from"node:fs/promises";import Te from"node:os";import we from"node:path";import oe from"node:process";import{EventEmitter as qe}from"node:events";import se from"node:process";import Ae from"node:process";import Se from"node:process";import ye from"node:process";import pe from"node:process";import De from"node:tty";import Mt,{stdin as ps,stdout as fs}from"node:process";class Ne{configPath;config=null;events=[];retryCount=0;maxRetries=3;retryDelayMs=1000;constructor(){let t=Te.homedir(),i=we.join(t,".config","clapp");this.configPath=we.join(i,"telemetry.json")}async isEnabled(){if(oe.env.DO_NOT_TRACK==="1"||oe.env.DO_NOT_TRACK==="true")return!1;if(oe.env.NO_TELEMETRY==="1"||oe.env.NO_TELEMETRY==="true")return!1;return(await this.loadConfig()).enabled}async enable(){let t=await this.loadConfig();if(t.enabled=!0,!t.userId)t.userId=this.generateUserId();await this.saveConfig(t)}async disable(){let t=await this.loadConfig();t.enabled=!1,await this.saveConfig(t)}async track(t,i){if(!await this.isEnabled())return;let o={event:t,...i,timestamp:Date.now(),platform:Te.platform(),nodeVersion:oe.version};if(this.events.push(o),this.events.length>=10)await this.send()}async trackCommand(t,i){await this.track("command",{command:t,duration:i})}async trackError(t,i){await this.track("error",{error:t,command:i})}async send(){if(!await this.isEnabled()||this.events.length===0)return!0;try{this.events=[],this.retryCount=0;let i=await this.loadConfig();return i.lastSent=Date.now(),await this.saveConfig(i),!0}catch{if(this.retryCount<this.maxRetries){this.retryCount++;let i=this.retryDelayMs*2**(this.retryCount-1);return await this.sleep(i),this.send()}return this.events=[],this.retryCount=0,!1}}async flush(){if(this.events.length===0)return!0;return this.send()}sleep(t){return new Promise((i)=>setTimeout(i,t))}async status(){let t=await this.loadConfig();return{enabled:t.enabled,doNotTrack:oe.env.DO_NOT_TRACK==="1"||oe.env.DO_NOT_TRACK==="true",eventsQueued:this.events.length,lastSent:t.lastSent}}async loadConfig(){if(this.config)return this.config;try{if(Ge(this.configPath)){let t=await be.readFile(this.configPath,"utf-8");return this.config=JSON.parse(t),this.config}}catch{}return this.config={enabled:!1},this.config}async saveConfig(t){this.config=t;try{let i=we.dirname(this.configPath);await be.mkdir(i,{recursive:!0}),await be.writeFile(this.configPath,JSON.stringify(t,null,2),"utf-8")}catch{}}generateUserId(){let t=Math.random().toString(36).substring(2,15),i=Date.now().toString(36);return`${t}-${i}`}}var es=new Ne;function xe(t){return t.replace(/[<[].+/,"").trim()}function He(t){let i=/<([^>]+)>/g,r=/\[([^\]]+)\]/g,o=[],a=(b)=>{let u=!1,p=b[1];if(p.startsWith("..."))p=p.slice(3),u=!0;return{required:b[0].startsWith("<"),value:p,variadic:u}},l;while(l=i.exec(t))o.push(a(l));let g;while(g=r.exec(t))o.push(a(g));return o}function Ke(t){let i={alias:{},boolean:[]};for(let[r,o]of t.entries()){if(o.names.length>1)i.alias[o.names[0]]=o.names.slice(1);if(o.isBoolean)if(o.negated){if(!t.some((l,g)=>g!==r&&l.names.some((b)=>o.names.includes(b))&&typeof l.required==="boolean"))i.boolean.push(o.names[0])}else i.boolean.push(o.names[0])}return i}function _e(t){return t.reduce((i,r)=>i.length>=r.length?i:r,"")}function ve(t,i){return t.length>=i?t:`${t}${" ".repeat(i-t.length)}`}function ge(t){return t.replace(/([a-z])-([a-z])/g,(i,r,o)=>r+o.toUpperCase())}function Je(t,i,r){let o=0,a=i.length,l=t,g;for(;o<a;++o)g=l[i[o]],l=l[i[o]]=o===a-1?r:g!=null?g:!!~i[o+1].indexOf(".")||!(+i[o+1]>-1)?{}:[]}function Ye(t,i){for(let r of Object.keys(i)){let o=i[r];if(o.shouldTransform){if(t[r]=Array.prototype.concat.call([],t[r]),typeof o.transformFunction==="function")t[r]=t[r].map(o.transformFunction)}}}function Ze(t){let i=/([^\\/]+)$/.exec(t);return i?i[1]:""}function fe(t){return t.split(".").map((i,r)=>r===0?ge(i):i).join(".")}class me extends Error{exitCode=2;isUsageError=!0;usage;constructor(t,i){super(t);if(this.name=this.constructor.name,i!==void 0)this.usage=i;if(typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,this.constructor);else this.stack=Error(t).stack}format(t=!1){if(t&&this.stack)return`${this.message}
|
|
3
3
|
|
|
4
4
|
Stack trace:
|
|
5
|
-
${this.stack}`;return this.message}}function
|
|
6
|
-
`);let
|
|
5
|
+
${this.stack}`;return this.message}}function Xe(t){if(t instanceof me)return!0;return!!t&&typeof t==="object"&&t.name==="ClappError"&&typeof t.message==="string"}function st(){let{env:t}=Ae,{TERM:i,TERM_PROGRAM:r}=t;if(Ae.platform!=="win32")return i!=="linux";return Boolean(t.WT_SESSION)||Boolean(t.TERMINUS_SUBLIME)||t.ConEmuTask==="{cmd::Cmder}"||r==="Terminus-Sublime"||r==="vscode"||i==="xterm-256color"||i==="alacritty"||i==="rxvt-unicode"||i==="rxvt-unicode-256color"||t.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var $e="\x1B",Z=`${$e}[`;var je={to(t,i){if(!i)return`${Z}${t+1}G`;return`${Z}${i+1};${t+1}H`},move(t,i){let r="";if(t<0)r+=`${Z}${-t}D`;else if(t>0)r+=`${Z}${t}C`;if(i<0)r+=`${Z}${-i}A`;else if(i>0)r+=`${Z}${i}B`;return r},up:(t=1)=>`${Z}${t}A`,down:(t=1)=>`${Z}${t}B`,forward:(t=1)=>`${Z}${t}C`,backward:(t=1)=>`${Z}${t}D`,nextLine:(t=1)=>`${Z}E`.repeat(t),prevLine:(t=1)=>`${Z}F`.repeat(t),left:`${Z}G`,hide:`${Z}?25l`,show:`${Z}?25h`,save:`${$e}7`,restore:`${$e}8`};var is={screen:`${Z}2J`,up:(t=1)=>`${Z}1J`.repeat(t),down:(t=1)=>`${Z}J`.repeat(t),line:`${Z}2K`,lineEnd:`${Z}K`,lineStart:`${Z}1K`,lines(t){let i="";for(let r=0;r<t;r++)i+=this.line+(r<t-1?je.up():"");if(t)i+=je.left;return i}},rs={screen:`${$e}c`};function nt(t,i){let r=[];for(let o=0;o<=i.length;o++)r[o]=[o];for(let o=0;o<=t.length;o++)r[0][o]=o;for(let o=1;o<=i.length;o++)for(let a=1;a<=t.length;a++)if(i.charAt(o-1)===t.charAt(a-1))r[o][a]=r[o-1][a-1];else r[o][a]=Math.min(r[o-1][a-1]+1,r[o][a-1]+1,r[o-1][a]+1);return r[i.length][t.length]}function Be(t,i,r=2,o=3){return i.map((a)=>({cmd:a,distance:nt(t,a)})).filter(({distance:a})=>a<=r).sort((a,l)=>a.distance-l.distance).slice(0,o).map(({cmd:a})=>a)}function it(t,i={}){let r={_:[]},o=i.alias||{},a=new Set(i.boolean||[]),l={};for(let u of Object.keys(o))for(let p of o[u])l[p]=u;for(let u of a)if(o[u])for(let p of o[u])a.add(p);function g(u,p){if(u===void 0)return p;if(typeof p==="boolean")return p;return Array.isArray(u)?[...u,p]:[u,p]}function b(u,p){let k=l[u]||u,I=g(r[k],p);if(r[k]=I,o[k])for(let y of o[k])r[y]=I;if(l[u]&&o[l[u]])for(let y of o[l[u]])r[y]=I;r[u]=I}for(let u=0;u<t.length;u++){let p=t[u];if(p==="--"){r._.push(...t.slice(u+1));break}if(p.startsWith("--")){let k=p.indexOf("=");if(k!==-1){let I=ge(p.slice(2,k)),y=p.slice(k+1);b(I,y)}else{let I=p.slice(2);if(I.startsWith("no-")){let w=ge(I.slice(3));b(w,!1);continue}let y=ge(I),A=l[y]||y;if(a.has(A)||a.has(y))b(y,!0);else{let w=t[u+1];if(w!==void 0&&!w.startsWith("-"))b(y,w),u++;else b(y,!0)}}}else if(p.startsWith("-")&&p.length>1){let k=p.slice(1);for(let I=0;I<k.length;I++){let y=k[I],A=l[y]||y;if(I===k.length-1&&!a.has(A)&&!a.has(y)){let w=t[u+1];if(w!==void 0&&!w.startsWith("-"))b(y,w),u++;else b(y,!0)}else b(y,!0)}}else r._.push(p)}return r}class Me{rawName;description;name;names;isBoolean;required;config;negated;constructor(t,i,r){if(this.rawName=t,this.description=i,this.config=Object.assign({},r),t=t.replace(/\.\*/g,""),this.negated=!1,this.names=xe(t).split(",").map((o)=>{let a=o.trim().replace(/^-{1,2}/,"");if(a.startsWith("no-"))this.negated=!0,a=a.replace(/^no-/,"");return fe(a)}).sort((o,a)=>o.length>a.length?1:-1),this.name=this.names[this.names.length-1],this.negated&&this.config.default==null)this.config.default=!0;if(t.includes("<"))this.required=!0;else if(t.includes("["))this.required=!1;else this.isBoolean=!0}}var as=Se.argv,rt=`${Se.platform}-${Se.arch} bun-v${typeof Bun<"u"?Bun.version:"unknown"}`,Pe=ye.argv,ot=`${ye.platform}-${ye.arch} node-${ye.version}`;class ke{rawName;description;config;cli;options;aliasNames;name;namespace;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;beforeHooks;afterHooks;middleware;constructor(t,i,r,o){this.rawName=t,this.description=i,this.config=r,this.cli=o,this.options=[],this.aliasNames=[],this.name=xe(t);let a=xe(t),l=a.indexOf(":");if(l>0)this.namespace=a.substring(0,l),this.name=a.substring(l+1);if(this.args=He(t),this.examples=[],this.beforeHooks=[],this.afterHooks=[],this.middleware=[],!r)this.config={}}usage(t){return this.usageText=t,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(t,i="-v, --version"){return this.versionNumber=t,this.option(i,"Display version number"),this}example(t){return this.examples.push(t),this}option(t,i,r){let o=new Me(t,i,r);return this.options.push(o),this}alias(t){return this.aliasNames.push(t),this}action(t){return this.commandAction=t,this}before(t){return this.beforeHooks.push(t),this}after(t){return this.afterHooks.push(t),this}use(t){return this.middleware.push(t),this}isMatched(t){if(this.aliasNames.includes(t))return!0;if(this.namespace)return`${this.namespace}:${this.name}`===t;return this.name===t}get isDefaultCommand(){return this.name===""||this.aliasNames.includes("!")}get isGlobalCommand(){return this instanceof Ce}get displayName(){return this.namespace?`${this.namespace}:${this.name}`:this.name}hasOption(t){let i=fe(t.split(".")[0]);return!!this.options.find((r)=>r.names.some((o)=>fe(o)===i))}outputHelp(){let{name:t,commands:i}=this.cli,{versionNumber:r,options:o,helpCallback:a}=this.cli.globalCommand,l=[{body:`${t}${r?`/${r}`:""}`}];if(l.push({title:"Usage",body:` $ ${t} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&i.length>0){let p=_e(i.map((w)=>w.rawName)),k=new Map,I=[];for(let w of i)if(w.namespace){if(!k.has(w.namespace))k.set(w.namespace,[]);k.get(w.namespace).push(w)}else I.push(w);let y="";if(I.sort((w,W)=>w.rawName<W.rawName?-1:w.rawName>W.rawName?1:0),I.length>0)y+=I.map((w)=>` ${ve(w.rawName,p.length)} ${w.description}`).join(`
|
|
6
|
+
`);let A=Array.from(k.keys()).sort();for(let w of A){let W=k.get(w);if(y.length>0)y+=`
|
|
7
7
|
|
|
8
|
-
`;
|
|
9
|
-
`,
|
|
10
|
-
`)}
|
|
11
|
-
`)})}if(this.examples.length>0)
|
|
12
|
-
`)});if(
|
|
8
|
+
`;y+=` ${w}:
|
|
9
|
+
`,y+=W.map((q)=>` ${ve(q.rawName,p.length-2)} ${q.description}`).join(`
|
|
10
|
+
`)}l.push({title:"Commands",body:y}),l.push({body:`Run \`${t} <command> --help\` for command details.`})}let b=new Set(this.options.flatMap((p)=>p.names)),u=this.isGlobalCommand?o:[...this.options,...(o||[]).filter((p)=>!p.names.some((k)=>b.has(k)))];if(!this.isGlobalCommand&&!this.isDefaultCommand)u=u.filter((p)=>p.name!=="version");if(u.length>0){let p=_e(u.map((k)=>k.rawName));l.push({title:"Options",body:u.map((k)=>` ${ve(k.rawName,p.length)} ${k.description} ${k.config.default===void 0?"":`(default: ${k.config.default})`}`).join(`
|
|
11
|
+
`)})}if(this.examples.length>0)l.push({title:"Examples",body:this.examples.map((p)=>{if(typeof p==="function")return p(t);return p}).join(`
|
|
12
|
+
`)});if(a)l=a(l)||l;console.log(l.map((p)=>p.title?`${p.title}:
|
|
13
13
|
${p.body}`:p.body).join(`
|
|
14
14
|
|
|
15
|
-
`))}outputVersion(){let{name:t}=this.cli,{versionNumber:
|
|
15
|
+
`))}outputVersion(){let{name:t}=this.cli,{versionNumber:i}=this.cli.globalCommand;if(i)console.log(`${t}/${i} ${typeof Bun<"u"?rt:ot}`)}get usageLine(){return`$ ${this.cli.name} ${this.usageText||this.rawName}`}checkRequiredArgs(){let t=this.args.filter((i)=>i.required).length;if(this.cli.args.length<t){let r=this.args.filter((a)=>a.required).slice(this.cli.args.length),o=r.map((a)=>`<${a.value}>`).join(" ");throw new me(`Missing required argument${r.length>1?"s":""}: ${o}
|
|
16
16
|
|
|
17
|
-
Run \`${this.cli.name} ${this.rawName} --help\` for usage information.`,this.usageLine)}}checkUnknownOptions(){let{options:t,globalCommand:
|
|
17
|
+
Run \`${this.cli.name} ${this.rawName} --help\` for usage information.`,this.usageLine)}}checkUnknownOptions(){let{options:t,globalCommand:i}=this.cli;if(!this.config.allowUnknownOptions){for(let r of Object.keys(t))if(r!=="--"&&!this.hasOption(r)&&!i.hasOption(r)){let a=[...i.options,...this.options].flatMap((p)=>p.names),l=fe(r.split(".")[0]),g=r.length>1?`--${r}`:`-${r}`,b=Be(l,a),u=`Unknown option \`${g}\``;if(b.length>0)u+=`
|
|
18
18
|
|
|
19
|
-
Did you mean one of these?`,
|
|
20
|
-
• ${
|
|
19
|
+
Did you mean one of these?`,b.forEach((p)=>{let k=p.length>1?`--${p}`:`-${p}`;u+=`
|
|
20
|
+
• ${k}`});throw u+=`
|
|
21
21
|
|
|
22
|
-
Run \`${this.cli.name} ${this.rawName} --help\` to see available options.`,new
|
|
22
|
+
Run \`${this.cli.name} ${this.rawName} --help\` to see available options.`,new me(u,this.usageLine)}}}checkOptionValue(){let{options:t,globalCommand:i}=this.cli,r=[...i.options,...this.options];for(let o of r){let a=t[o.name.split(".")[0]];if(o.required){let l=r.some((g)=>g.negated&&g.names.includes(o.name));if(a===!0||a===!1&&!l)throw new me(`Option \`${o.rawName}\` requires a value.
|
|
23
23
|
|
|
24
|
-
Example: ${this.cli.name} ${this.rawName} ${
|
|
24
|
+
Example: ${this.cli.name} ${this.rawName} ${o.rawName} <value>`,this.usageLine)}}}}class Ce extends ke{constructor(t){super("@@global@@","",{},t)}}var at=ke,ne={red:["\x1B[31m","\x1B[39m"],green:["\x1B[32m","\x1B[39m"],blue:["\x1B[34m","\x1B[39m"],yellow:["\x1B[33m","\x1B[39m"],cyan:["\x1B[36m","\x1B[39m"],magenta:["\x1B[35m","\x1B[39m"],white:["\x1B[37m","\x1B[39m"],gray:["\x1B[90m","\x1B[39m"],bgRed:["\x1B[41m","\x1B[49m"],bgGreen:["\x1B[42m","\x1B[49m"],bgBlue:["\x1B[44m","\x1B[49m"],bgYellow:["\x1B[43m","\x1B[49m"],bgCyan:["\x1B[46m","\x1B[49m"],bgMagenta:["\x1B[45m","\x1B[49m"],bold:["\x1B[1m","\x1B[22m"],italic:["\x1B[3m","\x1B[23m"],underline:["\x1B[4m","\x1B[24m"],dim:["\x1B[2m","\x1B[22m"],inverse:["\x1B[7m","\x1B[27m"],hidden:["\x1B[8m","\x1B[28m"],strikethrough:["\x1B[9m","\x1B[29m"]};var ae={primary:"blue",secondary:"cyan",success:"green",warning:"yellow",error:"red",info:"magenta",muted:"gray"};function ct(){return!0}function lt(){let t={};t.supportsColor=ct();function i(o,a=[]){let l=o===""?[]:[...a,o],g=function(u){if(!t.supportsColor)return u;let p="",k="";for(let I of l)if(I in ae&&ae[I]in ne){let y=ae[I];p+=ne[y][0],k=ne[y][1]+k}else if(I in ne)p+=ne[I][0],k=ne[I][1]+k;return p+u+k},b=[...Object.keys(ne),...Object.keys(ae)];for(let u of b)if(!(u in g))Object.defineProperty(g,u,{get(){return i(u,l)}});return g}let r=[...Object.keys(ne),...Object.keys(ae)];for(let o of r)if(!(o in t))Object.defineProperty(t,o,{get(){return i(o)}});return t}var le=lt();class Ie extends qe{name;commands;globalCommand;matchedCommand;matchedCommandName;rawArgs;args;options;showHelpOnExit;showVersionOnExit;enableDidYouMean=!0;signalHandlersSet=!1;isVerbose=!1;isQuiet=!1;isDebug=!1;isNoInteraction=!1;environment;isDryRun=!1;isForce=!1;useEmoji=!0;theme;isNoCache=!1;constructor(t=""){super();this.name=t,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new Ce(this),this.globalCommand.usage("<command> [options]")}handleSignals(t){if(this.signalHandlersSet)return this;let i=async(r)=>{if(console.log(`
|
|
25
25
|
|
|
26
|
-
Received ${r}, cleaning up...`),t)try{await t()}catch(
|
|
26
|
+
Received ${r}, cleaning up...`),t)try{await t()}catch(o){console.error("Error during cleanup:",o)}se.exit(0)};return se.on("SIGINT",()=>i("SIGINT")),se.on("SIGTERM",()=>i("SIGTERM")),this.signalHandlersSet=!0,this}didYouMean(t=!0){return this.enableDidYouMean=t,this}verbose(){return this.globalCommand.option("-v, --verbose","Enable verbose output"),this}quiet(){return this.globalCommand.option("-q, --quiet","Suppress non-essential output"),this}debug(){return this.globalCommand.option("--debug","Enable debug mode with detailed error information"),this}noInteraction(){return this.globalCommand.option("-n, --no-interaction","Do not ask any interactive questions (for CI/CD)"),this}env(){return this.globalCommand.option("--env <environment>","Target environment (e.g., production, staging, local)"),this}dryRun(){return this.globalCommand.option("--dry-run","Preview actions without executing them"),this}force(){return this.globalCommand.option("-f, --force","Skip confirmation prompts"),this}emoji(){return this.globalCommand.option("--no-emoji","Disable emoji in output"),this}themes(){return this.globalCommand.option("--theme <theme>","Color theme (default, dracula, nord, solarized, monokai)"),this}cache(){return this.globalCommand.option("--no-cache","Disable caching"),this}usage(t){return this.globalCommand.usage(t),this}command(t,i,r){if(!r)r={};let o=new at(t,i||"",r,this);return o.globalCommand=this.globalCommand,this.commands.push(o),o}option(t,i,r){return this.globalCommand.option(t,i,r),this}help(t){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=t,this.showHelpOnExit=!0,this}version(t,i="-v, --version"){return this.globalCommand.version(t,i),this.showVersionOnExit=!0,this}example(t){return this.globalCommand.example(t),this}outputHelp(){if(this.matchedCommand)this.matchedCommand.outputHelp();else this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:t,options:i},r,o){if(this.args=t,this.options=i,r)this.matchedCommand=r;if(o)this.matchedCommandName=o;return this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}showCommandNotFound(t){if(console.log(le.red(`
|
|
27
27
|
✗ Command "${t}" not found.
|
|
28
|
-
`)),this.enableDidYouMean){let
|
|
28
|
+
`)),this.enableDidYouMean){let i=[];for(let o of this.commands){if(o.displayName)i.push(o.displayName);if(o.aliasNames)i.push(...o.aliasNames)}let r=Be(t,i);if(r.length>0)console.log(le.yellow("Did you mean one of these?")),r.forEach((o)=>console.log(` ${le.dim("•")} ${this.name} ${o}`)),console.log("")}console.log(le.dim("Run"),`${this.name} --help`,le.dim("to see all available commands")),se.exit(1)}async parse(t=Pe,i={}){let{run:r=!0,exitOnError:o=!1}=i;if(o)try{return await this.parse(t,{run:r})}catch(u){throw this.handleUsageError(u),u}if(this.rawArgs=t,!this.name)this.name=t[1]?Ze(t[1]):"cli";let a=!0,l=t.slice(2),g=l[0];if(g&&!g.startsWith("-")){for(let u of this.commands)if(u.isMatched(g)){let p=this.mri(l,u);a=!1;let k={...p,args:p.args.slice(1)};this.setParsedInfo(k,u,g),this.emit(`command:${g}`,u);break}if(a){let u=l[1];if(u&&!u.startsWith("-")){let p=`${g}:${u}`;for(let k of this.commands)if(k.isMatched(p)){let I=this.mri(l,k);a=!1;let y={...I,args:I.args.slice(2)};this.setParsedInfo(y,k,p),this.emit(`command:${p}`,k);break}}}}if(a){for(let u of this.commands)if(u.name===""){a=!1;let p=this.mri(l,u);this.setParsedInfo(p,u),this.emit("command:!",u);break}}if(a){let u=this.mri(t.slice(2));this.setParsedInfo(u)}if(this.options.verbose)this.isVerbose=!0;if(this.options.quiet)this.isQuiet=!0;if(this.options.debug)this.isDebug=!0;if(this.options.noInteraction||this.options.interaction===!1)this.isNoInteraction=!0;if(this.options.env)this.environment=String(this.options.env);if(this.options.dryRun)this.isDryRun=!0;if(this.options.force)this.isForce=!0;if(this.options.noEmoji||this.options.emoji===!1)this.useEmoji=!1;if(this.options.theme)this.theme=String(this.options.theme);if(this.options.noCache||this.options.cache===!1)this.isNoCache=!0;if(this.options.help&&this.showHelpOnExit)this.outputHelp(),r=!1,this.unsetMatchedCommand();if(this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null)this.outputVersion(),r=!1,this.unsetMatchedCommand();let b={args:this.args,options:this.options};if(r)await this.runMatchedCommand();if(!this.matchedCommand&&this.args[0]){if(this.emit("command:*"),!(this.listenerCount("command:*")>0))this.showCommandNotFound(this.args[0])}return b}mri(t,i){let r=[...this.globalCommand.options,...i?i.options:[]],o=Ke(r),a=[],l=t.indexOf("--");if(l>-1)a=t.slice(l+1),t=t.slice(0,l);let g=it(t,o),b={_:g._};for(let y of Object.keys(g))if(y!=="_")b[fe(y)]=g[y];let u=b._,p={"--":a},k=i&&i.config.ignoreOptionDefaultValue?i.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,I=Object.create(null);for(let y of r){if(!k&&y.config.default!==void 0)for(let A of y.names)p[A]=y.config.default;if(Array.isArray(y.config.type)){if(I[y.name]===void 0)I[y.name]={shouldTransform:!0,transformFunction:y.config.type[0]}}}for(let y of Object.keys(b))if(y!=="_"){let A=y.split(".");Je(p,A,b[y]),Ye(p,I)}return{args:u,options:p}}async run(t=Pe){return this.parse(t,{run:!0,exitOnError:!0})}handleUsageError(t){if(!Xe(t)||t.isUsageError===!1)return;let i=t.message||"command-line error",r=this.name?`${this.name}: `:"",o=/--help/.test(i)?"":t.usage?`
|
|
29
29
|
Usage: ${t.usage}`:`
|
|
30
|
-
Run \`${this.name??"cli"} --help\` for usage.`;se.stderr.write(`${r}${
|
|
31
|
-
`),se.exit(t.exitCode??2)}async runMatchedCommand(){let{args:t,options:
|
|
30
|
+
Run \`${this.name??"cli"} --help\` for usage.`;se.stderr.write(`${r}${i}${o}
|
|
31
|
+
`),se.exit(t.exitCode??2)}async runMatchedCommand(){let{args:t,options:i,matchedCommand:r}=this;if(!r||!r.commandAction)return;r.checkUnknownOptions(),r.checkOptionValue(),r.checkRequiredArgs();let o=[];r.args.forEach((b,u)=>{if(b.variadic)o.push(t.slice(u));else o.push(t[u])}),o.push(i);let a={command:r,args:o,options:i};for(let b of r.beforeHooks)await b(a);let l,g=async()=>{let b=r.commandAction.apply(this,o);if(b instanceof Promise)l=await b;else l=b;return l};if(r.middleware.length>0){let b=0,u=async()=>{if(b<r.middleware.length){let p=r.middleware[b++];await p({...a,next:u})}else await g()};await u()}else await g();for(let b of r.afterHooks)await b(a);return l}removeSignalHandlers(){if(!this.signalHandlersSet)return this;return se.removeAllListeners("SIGINT"),se.removeAllListeners("SIGTERM"),this.signalHandlersSet=!1,this}destroy(){this.removeSignalHandlers(),this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.matchedCommand=void 0,this.matchedCommandName=void 0,this.removeAllListeners()}}class Re{cache;enabled;cleanupInterval=null;hits=0;misses=0;constructor(){this.cache=new Map,this.enabled=!0,this.startCleanupInterval()}startCleanupInterval(){if(this.cleanupInterval)return;this.cleanupInterval=setInterval(()=>{this.cleanup()},30000),this.cleanupInterval.unref()}stopCleanup(){if(this.cleanupInterval)clearInterval(this.cleanupInterval),this.cleanupInterval=null}isEnabled(){return this.enabled}get(t){if(!this.enabled){this.misses++;return}let i=this.cache.get(t);if(!i){this.misses++;return}if(Date.now()-i.timestamp>i.ttl){this.cache.delete(t),this.misses++;return}return this.hits++,i.value}set(t,i,r=5000){if(!this.enabled)return;this.cache.set(t,{value:i,timestamp:Date.now(),ttl:r})}has(t){if(!this.enabled)return!1;let i=this.cache.get(t);if(!i)return!1;if(Date.now()-i.timestamp>i.ttl)return this.cache.delete(t),!1;return!0}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}disable(){this.enabled=!1,this.clear()}enable(){this.enabled=!0}stats(){return{size:this.cache.size,enabled:this.enabled,hits:this.hits,misses:this.misses}}resetStats(){this.hits=0,this.misses=0}keys(){return Array.from(this.cache.keys())}cleanup(){let t=Date.now();for(let[i,r]of this.cache.entries())if(t-r.timestamp>r.ttl)this.cache.delete(i)}destroy(){this.stopCleanup(),this.clear(),this.resetStats()}}var ls=new Re;function ut(){if("FORCE_COLOR"in pe.env)return pe.env.FORCE_COLOR!=="0";if("NO_COLOR"in pe.env||pe.env.TERM==="dumb")return!1;if(pe.platform==="win32")return!0;return De.isatty(1)&&De.isatty(2)}var Le=ut();function J(t,i){if(!Le)return(r)=>r;return(r)=>t+r+i}var dt=J("\x1B[0m","\x1B[0m"),ht=J("\x1B[31m","\x1B[39m"),pt=J("\x1B[32m","\x1B[39m"),ft=J("\x1B[33m","\x1B[39m"),mt=J("\x1B[34m","\x1B[39m"),gt=J("\x1B[35m","\x1B[39m"),yt=J("\x1B[36m","\x1B[39m"),$t=J("\x1B[37m","\x1B[39m"),bt=J("\x1B[90m","\x1B[39m"),wt=J("\x1B[1m","\x1B[22m"),vt=J("\x1B[3m","\x1B[23m"),xt=J("\x1B[4m","\x1B[24m"),St=J("\x1B[2m","\x1B[22m"),kt=J("\x1B[7m","\x1B[27m"),Ct=J("\x1B[8m","\x1B[28m"),It=J("\x1B[9m","\x1B[29m"),Ot=J("\x1B[41m","\x1B[49m"),Et=J("\x1B[42m","\x1B[49m"),Tt=J("\x1B[43m","\x1B[49m"),At=J("\x1B[44m","\x1B[49m"),_t=J("\x1B[45m","\x1B[49m"),jt=J("\x1B[46m","\x1B[49m"),Pt=J("\x1B[47m","\x1B[49m"),Dt=Le,Nt={reset:dt,red:ht,green:pt,yellow:ft,blue:mt,magenta:gt,cyan:yt,white:$t,gray:bt,bold:wt,italic:vt,underline:xt,dim:St,inverse:kt,hidden:Ct,strikethrough:It,bgRed:Ot,bgGreen:Et,bgYellow:Tt,bgBlue:At,bgMagenta:_t,bgCyan:jt,bgWhite:Pt,isColorSupported:Dt},Bt=Nt,Rt=["up","down","left","right","space","enter","cancel"],ms={actions:new Set(Rt),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"}};var gs=Mt.platform.startsWith("win"),ys=Symbol("clapp:cancel");var Lt=st();var K=(t,i)=>Lt?t:i,$s=K("◆","*"),bs=K("■","x"),ws=K("▲","x"),vs=K("◇","o"),xs=K("┌","T"),Vt=K("│","|"),Ss=K("└","—"),ks=K("●",">"),Cs=K("○"," "),Is=K("◻","[•]"),Os=K("◼","[+]"),Es=K("◻","[ ]"),Ts=K("▪","•"),As=K("─","-"),_s=K("╮","+"),js=K("├","+"),Ps=K("╯","+"),Ds=K("●","•"),Ns=K("◆","*"),Bs=K("▲","!"),Ms=K("■","x");var Rs={light:K("─","-"),heavy:K("━","="),block:K("█","#")};function Ft(){return`${Bt.gray(Vt)} `}var Ls=Ft();var Ve="0.11.130";x();async function Wt(t="src/pantry"){if(!C.existsSync(t))throw Error(`Pantry directory not found: ${t}. Please run 'bun ./bin/cli.ts update-pantry' first.`);let i=[];function r(o,a=""){let l=C.readdirSync(o,{withFileTypes:!0}),g=O.join(o,"package.yml");if(a&&C.existsSync(g))i.push(a);for(let b of l)if(b.isDirectory()&&!b.name.startsWith(".")){let u=a?`${a}/${b.name}`:b.name,p=O.join(o,b.name);r(p,u)}}return r(t),console.log(`\uD83D\uDCE6 Found ${i.length} packages in local pantry`),i.sort()}async function Ut(t=!1){async function i(g){let b=new URL("https://s3.amazonaws.com/dist.tea.xyz/");if(b.searchParams.set("list-type","2"),b.searchParams.set("prefix",""),b.searchParams.set("max-keys","1000"),g)b.searchParams.set("continuation-token",g);let u=await fetch(b.toString());if(!u.ok)throw Error(`Failed to fetch S3 listing: ${u.status}`);let p=await u.text(),k=[],I=p.match(/<Key>([^<]+)<\/Key>/g);if(I)for(let W of I){let q=W.replace(/<Key>([^<]+)<\/Key>/,"$1");k.push({Key:q})}let y=p.includes("<IsTruncated>true</IsTruncated>"),A=p.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/),w=A?A[1]:void 0;return{IsTruncated:y,NextContinuationToken:w,Contents:k}}console.log("Scraping packages from S3 registry...");let r=new Set,o;do{let g=await i(o);for(let b of g.Contents){let u=b.Key,p=u.split("/");if(p.length===0)continue;if(p[0].startsWith(".")||p[0].includes(" ")||u.match(/\.(md|txt|yml|yaml|json)$/i))continue;let k=["darwin","linux","windows"],I=-1;for(let y=1;y<p.length;y++)if(k.includes(p[y])){I=y;break}if(I>0){let y=p.slice(0,I).join("/");if(y.includes("."))r.add(y)}else if(p.length>=2&&p[0].includes(".")&&!p[1].startsWith("v")&&!p[1].match(/^\d/)){let y=`${p[0]}/${p[1]}`;r.add(y)}else if(p.length>=1&&p[0].includes("."))r.add(p[0])}o=g.NextContinuationToken,console.log(`Found ${r.size} packages so far...`)}while(o);let a=Array.from(r).sort(),l=[];for(let g of a){if(!g.includes(".")||g.match(/^[a-z0-9.-]+\.[a-z]{2,}(\/[\w.-]+){0,20}$/i)===null)continue;if(g.endsWith("/README.rst")||g.endsWith("/README")||g.includes("/docs/"))continue;if(g.endsWith("/.pkgroot"))continue;if(["amazon.com/aws","charm.sh","code.videolan.org","crates.io"].includes(g))continue;l.push(g)}return console.log(`\uD83D\uDCE6 Found ${l.length} valid packages in registry`),l}async function Gt(t,i){let o=`/**
|
|
32
32
|
* Constants used throughout the ts-pantry package
|
|
33
|
-
* This file is auto-generated from ${
|
|
33
|
+
* This file is auto-generated from ${i}. Do not edit manually.
|
|
34
34
|
* Generated on ${new Date().toISOString()}
|
|
35
35
|
*/
|
|
36
36
|
|
|
@@ -77,33 +77,33 @@ export const PACKAGE_ALIASES: Record<string, string> = {
|
|
|
77
77
|
* List of all known packages (${t.length} total)
|
|
78
78
|
*/
|
|
79
79
|
export const ALL_KNOWN_PACKAGES: readonly string[] = [
|
|
80
|
-
${t.map((
|
|
80
|
+
${t.map((a)=>` '${a}',`).join(`
|
|
81
81
|
`)}
|
|
82
82
|
] as const
|
|
83
|
-
`;
|
|
84
|
-
Received ${t} signal. Cleaning up resources...`),clearTimeout(
|
|
85
|
-
Downloading props files from pkgx/pantry GitHub repo...`);let
|
|
86
|
-
Total packages: ${
|
|
83
|
+
`;C.writeFileSync("src/consts.ts",o,"utf-8")}function qt(t){if(!t)return;let r=t.toLowerCase().replace(/_/g,"-").match(/^(darwin|macos|linux|windows|win32)-(x86-64|x64|amd64|aarch64|arm64)$/),o=r?.[1],a=r?.[2],l=o==="macos"||o==="darwin"?"darwin":o==="linux"?"linux":o==="windows"||o==="win32"?"windows":void 0,g=a==="x64"||a==="x86-64"||a==="amd64"?"x86_64":a==="arm64"||a==="aarch64"?"aarch64":void 0;if(!l||!g)throw Error(`Invalid platform "${t}". Use linux-x86_64, linux-aarch64, macos-x86_64, macos-aarch64, or windows-x86_64.`);return{os:l,arch:g}}var F=new Ie("ts-pantry"),Ht=1500000,Oe=setTimeout(()=>{console.error("Force exiting after timeout - process may have hung"),v.exit(1)},Ht);v.on("exit",()=>{clearTimeout(Oe)});async function We(t){console.log(`
|
|
84
|
+
Received ${t} signal. Cleaning up resources...`),clearTimeout(Oe);try{await m(),console.log("Resources cleaned up. Exiting.")}catch(i){console.error("Error during cleanup:",i)}setTimeout(()=>{console.log("Forcing process exit..."),v.exit(0)},1000)}v.on("SIGINT",()=>We("SIGINT"));v.on("SIGTERM",()=>We("SIGTERM"));function Fe(t){let i={};for(let[r,o]of Object.entries(e))if(typeof o==="string")i[o]=r;return i[t]||t}function ze(t){let i=t.map(Fe),r=t.map((o)=>{let a=Fe(o);return a===o?o:a});return{friendlyNames:i,mixedNames:r}}F.command("fetch [packageName]","Fetch package information from pkgx.dev").option("-a, --all","Fetch all packages").option("-p, --pkg <packageNames>","Comma-separated list of package names to fetch").option("-o, --output-dir <dir>","Directory to save package data",{default:"src/packages"}).option("-c, --cache-dir <dir>","Directory to cache package data",{default:n}).option("-n, --no-cache","Disable caching").option("-e, --cache-expiration <minutes>","Cache expiration time in minutes",{default:d}).option("-l, --limit <count>","Limit the number of packages to fetch (use with --all)").option("-t, --timeout <ms>","Timeout for network requests in milliseconds",{default:h}).option("-r, --max-retries <count>","Maximum number of retry attempts for failed requests",{default:3}).option("-j, --json","Save as JSON instead of TypeScript").option("-d, --debug","Enable debug mode (save screenshots)").option("-v, --verbose","Enable verbose output").option("-y, --concurrency <count>","Number of packages to fetch concurrently (default: 8)",{default:8}).option("--output-json","Output results as JSON (for CI integration)").action(async(t,i)=>{let{all:r,outputDir:o="src/packages",cacheDir:a=n,cache:l=!0,cacheExpiration:g=d,limit:b,timeout:u=h,json:p=!1,debug:k=!1,verbose:I=!1,concurrency:y=8,pkg:A,outputJson:w=!1}=i,W=O.resolve(v.cwd(),o);if(!C.existsSync(W))C.mkdirSync(W,{recursive:!0});let q=O.resolve(v.cwd(),a);if(l){if(!C.existsSync(q))C.mkdirSync(q,{recursive:!0})}try{let N=[],H=[];if(r){if(!w)console.log("Fetching all packages...");let B={outputDir:o,cacheDir:a,cache:l,cacheExpirationMinutes:g,timeout:Number.parseInt(String(u),10),debug:k,limit:b?Number.parseInt(String(b),10):void 0,concurrency:Math.min(Number.parseInt(String(y),10),12),outputJson:w};N=await V(B),H=[...N]}else if(A){let B=A.split(",").map((R)=>R.trim());if(!w)console.log(`Fetching ${B.length} packages: ${B.join(", ")}`);for(let R of B)try{let X=O.join(a,`${R.replace(/\//g,"-")}.json`),Q=!1;if(l&&C.existsSync(X)){let ee=C.statSync(X),te=(Date.now()-ee.mtime.getTime())/60000;if(te<g){if(!w)console.log(`Using cached data for ${R} (age: ${Math.round(te)} minutes)`);try{let Ee=JSON.parse(C.readFileSync(X,"utf-8"));delete Ee.fetchedAt;let Ue=s(o,R,Ee);if(I&&!w)console.log(`Using cached data for ${R} (saved to ${Ue})`);N.push(R),Q=!0;continue}catch{console.warn(`Cache file corrupted for ${R}, will refetch`)}}}if(!Q){let ee=await D(R,{timeout:Number.parseInt(String(u),10),debug:k,outputJson:w,cacheDir:a,cache:l,cacheExpirationMinutes:g});if(ee){let{outputPath:te}=U(R,ee.packageInfo,{cacheDir:a,outputDir:o,cache:l});if(N.push(R),H.push(R),I&&!w)console.log(`Successfully saved ${R} to ${te}`)}}}catch(X){console.error(`Error processing ${R}:`,X)}}else if(t){if(!w)console.log(`Fetching package: ${t}`);try{let B=O.join(q,`${t.replace(/\//g,"-")}.json`),R=!1;if(l&&C.existsSync(B)){let X=C.statSync(B),Q=(Date.now()-X.mtime.getTime())/60000;if(Q<g){if(!w)console.log(`Using cached data for ${t} (age: ${Math.round(Q)} minutes)`);try{let ee=JSON.parse(C.readFileSync(B,"utf-8"));delete ee.fetchedAt;let te=s(W,t,ee);if(I&&!w)console.log(`Using cached data for ${t} (saved to ${te})`);N.push(t),R=!0}catch{console.warn(`Cache file corrupted for ${t}, will refetch`)}}}if(!R){let X=await D(t,{timeout:Number.parseInt(String(u),10),debug:k,outputJson:w,cacheDir:a,cache:l,cacheExpirationMinutes:g});if(X){let{outputPath:Q}=U(t,X.packageInfo,{cacheDir:a,outputDir:o,cache:l});if(N.push(t),H.push(t),I&&!w)console.log(`Successfully saved ${t} to ${Q}`)}}}catch(B){console.error(`Error processing ${t}:`,B)}}else{if(!w)console.error("Error: Please specify a package name, use --pkg, or use --all");v.exit(1)}if(!p&&N.length>0){let B=await S();if(!w)console.log(`Successfully generated ${B}`)}if(r&&N.length>0){let B=M(W,N);if(B.length>0&&!w)console.log(`Cleaned up ${B.length} stale generated file(s)`)}if(w){let{friendlyNames:B,mixedNames:R}=ze(H),{friendlyNames:X,mixedNames:Q}=ze(N),ee={success:!0,updatedPackages:H,updatedPackagesFriendly:B,updatedPackagesMixed:R,allProcessedPackages:N,allProcessedFriendly:X,allProcessedMixed:Q,totalUpdated:H.length,totalProcessed:N.length,timestamp:new Date().toISOString()};console.log(JSON.stringify(ee))}else console.log(`Processed ${N.length} packages.`);clearTimeout(Oe),await m(),setTimeout(()=>v.exit(0),1000)}catch(N){if(w){let H={success:!1,error:String(N),timestamp:new Date().toISOString()};console.log(JSON.stringify(H))}else console.error("Error:",N);await m(),setTimeout(()=>v.exit(1),1000)}});F.command("generate-index","Generate TypeScript index file for packages").option("-o, --output-dir <dir>","Directory containing package files",{default:"src/packages"}).action(async(t)=>{let{outputDir:i="src/packages"}=t,r=O.resolve(v.cwd(),i);if(!C.existsSync(r))console.error(`Error: Directory ${r} does not exist`),v.exit(1);try{let o=await S();console.log(`Successfully generated ${o}`),setTimeout(()=>v.exit(0),500)}catch(o){console.error("Error generating index:",o),v.exit(1)}});F.command("generate-ts","Generate TypeScript files from cached JSON files").option("--cache-dir <dir>","Directory with cached JSON files",{default:n}).option("--output-dir <dir>","Output directory for TypeScript files",{default:"packages"}).action(async(t)=>{try{console.log("Generating TypeScript files from cached JSON...");let{cacheDir:i,outputDir:r}=t;if(!C.existsSync(i))console.error(`Cache directory ${i} does not exist!`),v.exit(1);if(!C.existsSync(r))C.mkdirSync(r,{recursive:!0});let o=C.readdirSync(i).filter((l)=>l.endsWith(".json"));console.log(`Found ${o.length} JSON files in cache directory`);let a=0;for(let l of o)try{let g=C.readFileSync(O.join(i,l),"utf-8"),b=JSON.parse(g);delete b.fetchedAt;let u=l.replace(/\.json$/,""),p=s(r,b.fullPath||b.domain||u,b);console.log(`Generated ${p}`),a++}catch(g){console.error(`Error processing ${l}:`,g)}console.log(`Successfully generated ${a} TypeScript files from JSON cache`)}catch(i){console.error("Error generating TypeScript files:",i),v.exit(1)}});F.command("generate-aliases","Generate TypeScript aliases file for packages").action(async()=>{try{let t=await _();console.log(`Successfully generated ${t}`),setTimeout(()=>v.exit(0),500)}catch(t){console.error("Error generating aliases:",t),v.exit(1)}});F.command("generate-docs","Generate comprehensive BunPress documentation for all packages").option("-o, --output-dir <dir>","Output directory for documentation",{default:"docs"}).action(async(t)=>{try{let{outputDir:i="docs"}=t;await T(i),setTimeout(()=>v.exit(0),500)}catch(i){console.error("Error generating documentation:",i),v.exit(1)}});F.command("update-pantry","Download and extract the latest pantry.tgz file").option("-d, --pantry-dir <dir>","Directory to extract pantry files",{default:"src/pantry"}).action(async(t)=>{try{let{pantryDir:i="src/pantry"}=t,r=O.resolve(v.cwd(),i);console.log("Downloading pantry.tgz...");let o=await fetch("https://s3.amazonaws.com/dist.tea.xyz/pantry.tgz");if(!o.ok)throw Error(`Failed to download pantry.tgz: ${o.statusText}`);let a=await o.arrayBuffer(),l=O.join(v.cwd(),"pantry.tgz");C.writeFileSync(l,new Uint8Array(a)),console.log(`Downloaded ${a.byteLength} bytes`),C.mkdirSync(r,{recursive:!0});let g=O.join(v.cwd(),"temp-pantry"),{spawn:b}=await import("node:child_process");if(C.existsSync(g))C.rmSync(g,{recursive:!0,force:!0});C.mkdirSync(g,{recursive:!0});let u=b("tar",["-xzf",l,"-C",g,"--strip-components=1"],{stdio:"inherit"});await new Promise((y,A)=>{u.on("close",(w)=>{if(w===0)y(w);else A(Error(`tar extraction failed with code ${w}`))}),u.on("error",A)});let p=O.join(g,"projects");if(C.existsSync(p)){let y=C.readdirSync(p),A=0,w=0,W=(q,N)=>{if(!C.existsSync(N))C.mkdirSync(N,{recursive:!0});for(let H of C.readdirSync(q,{withFileTypes:!0})){let B=O.join(q,H.name),R=O.join(N,H.name);if(H.isDirectory())W(B,R);else if(H.name==="package.yml")if(C.existsSync(R))w++;else C.renameSync(B,R),A++;else if(!C.existsSync(R))C.renameSync(B,R)}};console.log(`Merging ${y.length} projects from upstream...`);for(let q of y){let N=O.join(p,q),H=O.join(r,q);if(C.statSync(N).isDirectory())W(N,H)}console.log(`Merged upstream pantry: ${A} new packages added, ${w} existing preserved`)}else console.log("Warning: No projects directory found in extracted pantry");if(C.unlinkSync(l),C.existsSync(g))C.rmSync(g,{recursive:!0,force:!0});console.log(`
|
|
85
|
+
Downloading props files from pkgx/pantry GitHub repo...`);let I=await fetch("https://github.com/pkgxdev/pantry/archive/refs/heads/main.tar.gz");if(I.ok){let y=await I.arrayBuffer(),A=O.join(v.cwd(),"pantry-gh.tar.gz"),w=O.join(v.cwd(),"temp-pantry-gh");if(C.writeFileSync(A,new Uint8Array(y)),console.log(`Downloaded GitHub archive: ${(y.byteLength/1024/1024).toFixed(1)} MB`),C.existsSync(w))C.rmSync(w,{recursive:!0,force:!0});C.mkdirSync(w,{recursive:!0});let W=b("tar",["-xzf",A,"-C",w,"--strip-components=1"],{stdio:"inherit"});await new Promise((N,H)=>{W.on("close",(B)=>B===0?N(B):H(Error(`tar failed: ${B}`))),W.on("error",H)});let q=O.join(w,"projects");if(C.existsSync(q)){let N=0,H=0,B=(R,X)=>{if(!C.existsSync(R))return;for(let Q of C.readdirSync(R,{withFileTypes:!0})){let ee=O.join(R,Q.name),te=O.join(X,Q.name);if(Q.isDirectory())B(ee,te);else if(Q.name!=="package.yml")if(C.mkdirSync(X,{recursive:!0}),C.copyFileSync(ee,te),C.existsSync(te))H++;else N++}};B(q,r),console.log(`Props files: ${N+H} synced (${N} new, ${H} updated)`)}if(C.unlinkSync(A),C.existsSync(w))C.rmSync(w,{recursive:!0,force:!0})}else console.log(`Warning: Could not download GitHub archive (${I.status}), props files will be missing`);if(console.log("Cleaned up temporary files"),C.existsSync(r)){let y=C.readdirSync(r).filter((A)=>{let w=O.join(r,A);return C.statSync(w).isDirectory()&&!A.startsWith(".")});console.log(`Final result: ${y.length} projects in ${r}`)}v.exit(0)}catch(i){console.error("Error updating pantry:",i),v.exit(1)}});F.command("generate-consts","Generate or update the consts.ts file with all known packages").option("-s, --source <source>",'Source for packages: "pantry" (default) or "registry"',{default:"pantry"}).option("--pantry-dir <dir>","Directory containing pantry files",{default:"src/pantry"}).option("--validate","Validate a sample of packages (slower but more accurate)").action(async(t)=>{try{let{source:i="pantry",pantryDir:r="src/pantry",validate:o=!1}=t;console.log(`\uD83D\uDE80 Generating consts.ts file using ${i} as source...`);let a=[];if(i==="pantry")a=await Wt(r);else if(i==="registry")a=await Ut(o);else console.error('Invalid source. Use "pantry" or "registry"'),v.exit(1);await Gt(a,i),console.log("✅ Successfully updated consts.ts"),console.log(`\uD83D\uDCCA Total packages: ${a.length}`);let l=new Date().toISOString(),g=`Generated from ${i} at ${l}
|
|
86
|
+
Total packages: ${a.length}
|
|
87
87
|
|
|
88
|
-
${
|
|
89
|
-
`)}`;
|
|
90
|
-
✅ Dependency resolution complete!`),console.log(`\uD83D\uDCE6 Total unique packages: ${
|
|
91
|
-
Conflicts found:`),
|
|
92
|
-
\uD83D\uDCCB All unique packages to install:`),
|
|
93
|
-
\uD83D\uDE80 Install command:`),console.log(`pantry install ${
|
|
94
|
-
\uD83D\uDDA5️ OS-specific dependencies:`),Object.entries(
|
|
95
|
-
${
|
|
96
|
-
`)}`);break;case"csv":console.log(
|
|
97
|
-
\uD83D\uDE80 Generating Zig package aliases...`),await r(
|
|
98
|
-
✅ Zig code generation complete!`),
|
|
88
|
+
${a.join(`
|
|
89
|
+
`)}`;C.writeFileSync(`${i}-packages-summary.txt`,g),console.log(`\uD83D\uDCC4 Created ${i}-packages-summary.txt for reference`),v.exit(0)}catch(i){console.error("Error generating consts file:",i),v.exit(1)}});F.command("resolve-deps [file]","Resolve all dependencies (including transitive) from a dependency file").option("-f, --file <path>","Path to dependency file (deps.yaml, dependencies.yaml, pkgx.yaml, etc.)").option("-d, --dir <directory>","Directory to search for dependency files",{default:"."}).option("--pantry-dir <dir>","Directory containing pantry files",{default:"src/pantry"}).option("--packages-dir <dir>","Directory containing generated package files",{default:"src/packages"}).option("--target-os <os>","Target OS for OS-specific dependencies (linux, darwin, windows)").option("--include-os-deps","Include OS-specific dependencies in resolution").option("--max-depth <depth>","Maximum recursion depth for dependency resolution",{default:10}).option("-v, --verbose","Enable verbose output").option("-j, --json","Output results as JSON").option("--install-command","Show install commands for resolved packages").action(async(t,i)=>{try{let{dir:r=".",packagesDir:o="src/packages",targetOs:a,includeOsDeps:l=!1,maxDepth:g=10,verbose:b=!1,json:u=!1,installCommand:p=!1}=i,k=t||i.file;if(!k){let A=re(r);if(A.length===0)console.error(`No dependency files found in ${r}`),console.error("Supported filenames: deps.yaml, dependencies.yaml, pkgx.yaml (and .yml variants)"),v.exit(1);else if(A.length>1)console.error(`Multiple dependency files found in ${r}:`),A.forEach((w)=>console.error(` ${w}`)),console.error("Please specify which file to use with --file or [file] argument"),v.exit(1);else if(k=A[0],!u)console.log(`Found dependency file: ${k}`)}if(!C.existsSync(k))console.error(`Dependency file not found: ${k}`),v.exit(1);let I={packagesDir:o,includeOsSpecific:l,targetOs:a,maxDepth:Number.parseInt(String(g),10),verbose:b&&!u};if(!u)console.log("\uD83D\uDD0D Resolving dependencies...");let y=await Y(k,I);if(u){let A={success:!0,file:k,summary:{totalUnique:y.uniquePackages.length,conflicts:y.conflicts.length,osSpecific:{linux:y.osSpecificDeps.linux.length,darwin:y.osSpecificDeps.darwin.length,windows:y.osSpecificDeps.windows.length}},packages:y.uniquePackages,dependencies:y.allDependencies,conflicts:y.conflicts,osSpecificDeps:y.osSpecificDeps,timestamp:new Date().toISOString()};console.log(JSON.stringify(A,null,2))}else{if(console.log(`
|
|
90
|
+
✅ Dependency resolution complete!`),console.log(`\uD83D\uDCE6 Total unique packages: ${y.uniquePackages.length}`),y.conflicts.length>0)console.log(`⚠️ Version conflicts: ${y.conflicts.length}`),console.log(`
|
|
91
|
+
Conflicts found:`),y.conflicts.forEach((w)=>{console.log(` ${w.package}: ${w.versions.join(", ")}`)});if(console.log(`
|
|
92
|
+
\uD83D\uDCCB All unique packages to install:`),y.uniquePackages.forEach((w,W)=>{let q=y.allDependencies.find((H)=>H.name===w),N=q&&q.version&&q.version!=="latest"?` (${q.version})`:"";console.log(` ${W+1}. ${w}${N}`)}),p)console.log(`
|
|
93
|
+
\uD83D\uDE80 Install command:`),console.log(`pantry install ${y.uniquePackages.join(" ")}`);if(Object.values(y.osSpecificDeps).reduce((w,W)=>w+W.length,0)>0)console.log(`
|
|
94
|
+
\uD83D\uDDA5️ OS-specific dependencies:`),Object.entries(y.osSpecificDeps).forEach(([w,W])=>{if(W.length>0)console.log(` ${w}: ${W.map((q)=>q.name).join(", ")}`)})}v.exit(0)}catch(r){if(i.json){let o={success:!1,error:String(r),timestamp:new Date().toISOString()};console.log(JSON.stringify(o))}else console.error("Error resolving dependencies:",r);v.exit(1)}});F.command("get-php-versions","Get PHP versions suitable for CI/CD workflows").option("--format <type>","Output format: json (default), yaml, or csv",{default:"json"}).option("--branches <branches>","Comma-separated list of PHP branches to include (e.g., 8.4,8.3,8.2)").option("--fallback <versions>","Comma-separated list of fallback versions if detection fails").action(async(t)=>{try{let{getPhpVersionsForWorkflow:i}=await import("../chunk-kdydq4xh.js"),r={};if(t.branches)r.supportedBranches=t.branches.split(",").map((a)=>a.trim());if(t.fallback)r.fallbackVersions=t.fallback.split(",").map((a)=>a.trim());let o=i(r);switch(t.format.toLowerCase()){case"yaml":console.log(`php_versions:
|
|
95
|
+
${o.map((a)=>` - "${a}"`).join(`
|
|
96
|
+
`)}`);break;case"csv":console.log(o.join(","));break;case"json":default:console.log(JSON.stringify(o));break}v.exit(0)}catch(i){console.error("Error getting PHP versions:",i),v.exit(1)}});F.command("generate-zig","Generate Zig package definitions from TypeScript packages").option("--packages-dir <dir>","Directory containing TypeScript package files",{default:"src/packages"}).option("--output <file>","Output Zig file path",{default:"packages.zig"}).option("--aliases","Also generate aliases file").option("--aliases-output <file>","Output file for Zig aliases",{default:"aliases.zig"}).action(async(t)=>{try{let{generateZigDefinitions:i,generateZigAliases:r}=await import("../chunk-ya1t19xm.js"),{packagesDir:o="src/packages",output:a="packages.zig",aliases:l=!1,aliasesOutput:g="aliases.zig"}=t;if(console.log("\uD83D\uDE80 Generating Zig package definitions..."),await i(o,a),l)console.log(`
|
|
97
|
+
\uD83D\uDE80 Generating Zig package aliases...`),await r(o,g);console.log(`
|
|
98
|
+
✅ Zig code generation complete!`),v.exit(0)}catch(i){console.error("Error generating Zig definitions:",i),v.exit(1)}});F.command("release [type]","Release a Zig package (changelog, bump, commit, tag, push, publish)").option("-y, --yes","Non-interactive mode (skip confirmation prompts)").option("--dry-run","Preview the release without changing anything").option("--no-changelog","Skip changelog generation").option("--no-push","Skip pushing the commit and tag").option("--no-publish","Skip publishing to the pantry registry").action(async(t,i)=>{let r=(t??"patch").toLowerCase();if(!["patch","minor","major"].includes(r))console.error(`error: invalid release type "${r}" (expected: patch | minor | major)`),v.exit(1);let{runRelease:o}=await import("../chunk-cwa30yjr.js"),a=await o({type:r,yes:i.yes,dryRun:i.dryRun,noChangelog:i.changelog===!1,noPush:i.push===!1,noPublish:i.publish===!1});v.exit(a.exitCode)});F.command("apps","List installed desktop applications with version info").option("-j, --json","Output as JSON").action(async(t)=>{try{let{scanInstalledApps:i}=await import("../chunk-8h6c7pf2.js"),r=i();if(t.json)console.log(JSON.stringify({success:!0,apps:r,total:r.length}));else{console.log(`
|
|
99
99
|
Installed Desktop Apps (${r.length}):
|
|
100
|
-
`),console.log("Application".padEnd(40)+"Version"),console.log("-".repeat(60));for(let
|
|
101
|
-
Outdated Apps (${
|
|
102
|
-
`),console.log("Application".padEnd(30)+"Current".padEnd(16)+"Latest".padEnd(16)+"Source"),console.log("-".repeat(75));for(let
|
|
103
|
-
All desktop apps are up to date!`);let
|
|
104
|
-
${
|
|
105
|
-
✓ ${
|
|
106
|
-
⚠ ${
|
|
107
|
-
✓ Built ${
|
|
108
|
-
Pushing ${
|
|
109
|
-
`,{mode:384}),console.log(JSON.stringify({reportPath:
|
|
100
|
+
`),console.log("Application".padEnd(40)+"Version"),console.log("-".repeat(60));for(let o of r)console.log(`${o.name.padEnd(40)}${o.version}`)}v.exit(0)}catch(i){console.error("Error listing apps:",i),v.exit(1)}});F.command("apps-outdated","Check for outdated desktop applications").option("-j, --json","Output as JSON").action(async(t)=>{try{let{checkAppUpdates:i}=await import("../chunk-8h6c7pf2.js");if(!t.json)console.log("Checking desktop apps for updates...");let r=await i(),o=r.filter((a)=>a.updateAvailable);if(t.json)console.log(JSON.stringify({success:!0,apps:r,outdated:o.length,total:r.length,timestamp:new Date().toISOString()}));else{if(o.length>0){console.log(`
|
|
101
|
+
Outdated Apps (${o.length}):
|
|
102
|
+
`),console.log("Application".padEnd(30)+"Current".padEnd(16)+"Latest".padEnd(16)+"Source"),console.log("-".repeat(75));for(let l of o)console.log(`${l.name.padEnd(30)}${l.currentVersion.padEnd(16)}${(l.latestVersion||"?").padEnd(16)}${l.source}`)}else console.log(`
|
|
103
|
+
All desktop apps are up to date!`);let a=r.filter((l)=>!l.updateAvailable&&l.source!=="system"&&l.source!=="unknown");if(a.length>0)console.log(`
|
|
104
|
+
${a.length} app(s) up to date, ${r.filter((l)=>l.source==="unknown").length} unchecked`)}v.exit(0)}catch(i){console.error("Error checking app updates:",i),v.exit(1)}});F.command("apps-update <name>","Update a desktop application from the pantry registry").action(async(t)=>{try{let{updateApp:i}=await import("../chunk-8h6c7pf2.js");console.log(`Updating ${t} from the pantry registry...`);let r=await i(t);if(r.success)console.log(`Successfully updated ${t} to ${r.version}`);else console.error(`Failed to update ${t}: ${r.error}`),v.exit(1);v.exit(0)}catch(i){console.error("Error updating app:",i),v.exit(1)}});F.command("install <pkg>","Install a system package (e.g. ziglang.org@0.17.0-dev)").option("--global","Link binaries into the user-level global bin so they appear on PATH").option("--install-dir <dir>","Where to download into (default: ./pantry)").option("--platform <target>","Install for a target platform (e.g. linux-x86_64)").option("--no-bin-links","Skip creating local .bin/ symlinks").option("--quiet","Suppress progress output").action(async(t,i)=>{let r=t.lastIndexOf("@"),o=r>0,a=o?t.slice(0,r):t,l=o?t.slice(r+1):"latest";try{let g=await z(a,l,{installDir:i.installDir,platform:qt(i.platform),createBinLinks:i.binLinks!==!1,quiet:i.quiet,globalBin:i.global?!0:void 0});if(!i.quiet){if(console.log(`
|
|
105
|
+
✓ ${g.name}@${g.version}`),console.log(` installed to: ${g.installPath}`),g.globalLinks&&g.globalLinks.length>0){if(console.log(` linked into: ${O.dirname(g.globalLinks[0])}`),!v.env.PATH?.split(O.delimiter).includes(O.dirname(g.globalLinks[0])))console.log(`
|
|
106
|
+
⚠ ${O.dirname(g.globalLinks[0])} is not on your PATH yet.`),console.log(" Run `ts-pantry shell-init --install` once to fix that.")}}v.exit(0)}catch(g){console.error(`Error installing ${t}:`,g instanceof Error?g.message:g),v.exit(1)}});function Kt(t){let i=re(t);if(i.length===0)return[];try{return P(i[0]).map((r)=>r.version&&r.version!=="latest"?`${r.name}@${String(r.version).replace(/^[\^~>=<]+/,"")}`:r.name)}catch{return[]}}F.command("env","Print the environment pantry-installed packages need, for a program to consume").option("--json","Print JSON instead of shell assignments").option("--dir <path>","A project directory, whose dependency file is included (default: cwd)").option("--install","Install anything the dependency file names that is missing").action(async(t)=>{let i=O.resolve(t.dir??v.cwd()),r=Kt(i);if(t.install&&r.length>0)for(let l of r){let g=l.lastIndexOf("@"),b=g>0;await z(b?l.slice(0,g):l,b?l.slice(g+1):"latest",{globalBin:!0,quiet:!0}).catch((u)=>{console.error(`# could not install ${l}: ${u instanceof Error?u.message:u}`)})}let o=f(),a=[O.join(i,".bin"),o].filter((l)=>C.existsSync(l));if(t.json)console.log(JSON.stringify({path:a,PATH:[...a,v.env.PATH??""].filter(Boolean).join(O.delimiter),dependencies:r,globalBin:o},null,2)),v.exit(0);console.log(`export PATH="${[...a,"$PATH"].join(O.delimiter)}"`),v.exit(0)});F.command("shell-init","Print the shell snippet that puts pantry-installed packages on PATH").option("--install","Append the snippet to your shell rc file (idempotent)").option("--uninstall","Remove a previously installed snippet").option("--shell <shell>","Force a shell (zsh|bash|fish) instead of autodetect").action(async(t)=>{let i=t.shell??j();try{if(t.uninstall){let o=ce({shell:i});console.log(o.changed?`✓ Removed pantry shell-init from ${o.rcFile}`:`Nothing to remove (no pantry shell-init block in ${o.rcFile})`),v.exit(0)}if(t.install){let o=ie({shell:i});if(o.changed)console.log(`✓ Added pantry shell-init to ${o.rcFile}`),console.log(` Restart your shell or run: source ${o.rcFile}`);else console.log(`✓ Already integrated in ${o.rcFile}`);v.exit(0)}let r=E(i);if(v.stdout.isTTY){if(console.log(`# Detected shell: ${i}`),console.log(`# Global bin dir: ${f()}`),r)console.log(`# Append this to: ${r}`);console.log("# Or run: ts-pantry shell-init --install"),console.log()}v.stdout.write(L({shell:i})),v.exit(0)}catch(r){console.error("Error:",r instanceof Error?r.message:r),v.exit(1)}});F.command("build [context]","Build a Dockerfile into an OCI image (no Docker daemon required)").option("-f, --file <path>","Path to the Dockerfile (default: <context>/Dockerfile)").option("-t, --tag <tag>","Image tag, e.g. myapp:latest (repeatable)").option("--target <stage>","Target stage for a multi-stage build").option("--build-arg <kv>","Set a build arg KEY=VALUE (repeatable)").option("--platform <os/arch>","Target platform (default: linux/<host-arch>)").option("--output <dir>","Where to write the image archive + OCI layout (default: <context>/.pantry/images)").option("--run-mode <mode>","How to run RUN steps: auto|chroot|host|skip (default: auto)").option("--push","Push the built image to the pantry registry after building").option("--quiet","Suppress step output").action(async(t,i)=>{try{let r=[].concat(i.tag??[]),o={};for(let l of[].concat(i.buildArg??[])){let g=l.indexOf("=");if(g!==-1)o[l.slice(0,g)]=l.slice(g+1)}let a=await de({context:t??".",dockerfile:i.file,tags:r,target:i.target,buildArgs:o,platform:i.platform,outputDir:i.output,runMode:i.runMode,quiet:i.quiet});if(!i.quiet){if(console.log(`
|
|
107
|
+
✓ Built ${a.imageId}`),r.length)console.log(` tags: ${r.join(", ")}`);console.log(` archive: ${a.archivePath}`),console.log(` oci layout: ${a.ociLayoutPath}`)}if(i.push){let l=G(r[0]||"app:latest");if(!i.quiet)console.log(`
|
|
108
|
+
Pushing ${l.repository}:${l.tag} → ${c} ...`);let g=await ue({repository:l.repository,tag:l.tag,registry:l.implicitRegistry?void 0:`https://${l.registry}`,configBytes:Buffer.from(a.configBytes),configDigest:a.configDigest,layers:a.layers.map((b)=>({digest:b.digest,path:b.path,size:b.size})),manifestBytes:Buffer.from(a.manifestBytes),manifestMediaType:a.manifestMediaType,quiet:i.quiet});console.log(`✓ Pushed ${g.ref} (${g.digest})`)}v.exit(0)}catch(r){console.error("Build failed:",r instanceof Error?r.message:r),v.exit(1)}});F.command("container:generate [outDir]","Generate a Dockerfile + .freezer (default outDir: storage/framework)").alias("freeze").option("--base <image>","Base image (default: oven/bun:1.3.10)").option("--workdir <dir>","Working directory in the image (default: /app)").option("--install <cmd>","Install command (default: bun install --frozen-lockfile)").option("--build <cmd>","Optional build command run after install").option("--start <cmd>","Start command (default: bun start)").option("--port <port>","Exposed port (default: 3000)").option("--force","Overwrite existing files").action(async(t,i)=>{try{let r=he({outDir:t??"storage/framework",baseImage:i.base,workdir:i.workdir,installCommand:i.install,buildCommand:i.build,startCommand:i.start?i.start.split(/\s+/):void 0,port:i.port?Number(i.port):void 0,force:i.force});console.log(`${r.wroteDockerfile?"✓ wrote":"• kept"} ${r.dockerfilePath}`),console.log(`${r.wroteFreezer?"✓ wrote":"• kept"} ${r.freezerPath}`),v.exit(0)}catch(r){console.error("Generate failed:",r instanceof Error?r.message:r),v.exit(1)}});F.command("native:release","Qualify, version, commit and push a native app release through Pantry").option("--bump <bump>","patch, minor or major (default: patch)").option("--dry-run","Validate and preview without changing the version or publishing").action(async(t)=>{let{releaseNativeApp:i}=await import("../src/native/release.js");await i(v.cwd(),{bump:t.bump||"patch",dryRun:t.dryRun})});F.command("native:check","Build and verify the native app declared in pantry.json").action(async()=>{let{prepareNativeRelease:t}=await import("../src/native/index.js");console.log(JSON.stringify(await t(v.cwd(),"check"),null,2))});F.command("native:prepare-release","Sign, verify, notarize and package configured native release targets").action(async()=>{let{prepareNativeRelease:t}=await import("../src/native/index.js");console.log(JSON.stringify(await t(v.cwd(),"release"),null,2))});F.command("app-store:csr","Generate private keys and CSRs for Mac App Store certificates").option("--name <name>","App name used in certificate request common names").option("--output <dir>","Output directory (default: .pantry/apple)").action((t)=>{try{if(!t.name)throw Error("--name is required");let i=et({outputDirectory:t.output??".pantry/apple",commonName:t.name});console.log(JSON.stringify({requests:i},null,2)),v.exit(0)}catch(i){console.error("Apple CSR generation failed:",i instanceof Error?i.message:i),v.exit(1)}});F.command("app-store:provision","Plan or reconcile macOS App Store Connect resources").option("--bundle-id <id>","Reverse-DNS bundle identifier").option("--name <name>","Mac App Store display name").option("--api-key-id <id>","App Store Connect API key ID").option("--api-issuer-id <id>","App Store Connect API issuer ID").option("--api-key-path <path>","App Store Connect AuthKey .p8 file").option("--capabilities <types>","Comma-separated Apple capability types").option("--app-certificate-csr <path>","CSR for a missing Mac App Distribution certificate").option("--installer-certificate-csr <path>","CSR for a missing Mac Installer Distribution certificate").option("--profile-name <name>","Provisioning profile name").option("--output <dir>","Output directory (default: .pantry/apple)").option("--p12-password <password>","Export newly issued certificates as password-protected P12 files").option("--apply","Apply the plan; the default only reports missing resources").action(async(t)=>{try{if(!t.bundleId||!t.name)throw Error("--bundle-id and --name are required");let i=(u)=>{if(!u)return;return C.readFileSync(O.resolve(u),"utf8")},r=O.resolve(t.output??".pantry/apple");C.mkdirSync(r,{recursive:!0});let o=await Qe({identifier:t.bundleId,name:t.name,capabilities:t.capabilities?.split(",").map((u)=>u.trim()).filter(Boolean),appCertificateCsr:i(t.appCertificateCsr),installerCertificateCsr:i(t.installerCertificateCsr),profileName:t.profileName,keyId:t.apiKeyId,issuerId:t.apiIssuerId,keyPath:t.apiKeyPath,checkOnly:!t.apply});for(let u of o.certificates){if(!u.certificateContent)continue;let p=u.type==="MAC_APP_DISTRIBUTION"?"mac-app-distribution":"mac-installer-distribution",k=O.join(r,`${p}.cer`);C.writeFileSync(k,Buffer.from(u.certificateContent,"base64"),{mode:384});let I=u.type==="MAC_APP_DISTRIBUTION"?t.appCertificateCsr:t.installerCertificateCsr;if(t.p12Password&&I)tt({certificatePath:k,privateKeyPath:O.resolve(I.replace(/\.csr$/i,".key")),outputPath:O.join(r,`${p}.p12`),password:t.p12Password,name:`${t.name} ${u.type==="MAC_APP_DISTRIBUTION"?"Mac App Distribution":"Mac Installer Distribution"}`})}if(o.profile.profileContent)C.writeFileSync(O.join(r,"mac-app-store.provisionprofile"),Buffer.from(o.profile.profileContent,"base64"),{mode:384});let a=o.certificates.map((u)=>{let p={...u};return delete p.certificateContent,p}),l={...o.profile};delete l.profileContent;let g={...o,certificates:a,profile:l},b=O.join(r,"provisioning-plan.json");C.writeFileSync(b,`${JSON.stringify(g,null,2)}
|
|
109
|
+
`,{mode:384}),console.log(JSON.stringify({reportPath:b,...g},null,2)),v.exit(0)}catch(i){console.error("App Store provisioning failed:",i instanceof Error?i.message:i),v.exit(1)}});F.help();F.version(Ve);var tn=F.parse();if(v.argv.length<=2||v.argv.includes("--help")||v.argv.includes("-h"))v.exit(0);
|