@gjsify/cli 0.5.0 → 0.5.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/dist/cli.gjs.mjs +18 -18
- package/lib/commands/publish.js +19 -22
- package/lib/utils/publish-headers.d.ts +45 -0
- package/lib/utils/publish-headers.js +99 -0
- package/package.json +17 -17
package/dist/cli.gjs.mjs
CHANGED
|
@@ -738,7 +738,7 @@ var S=Object.getOwnPropertySymbols,C=Object.prototype.hasOwnProperty,N=Object.pr
|
|
|
738
738
|
`),I=new Set;return{input:N,plugin:{name:`gjsify-virtual-entry`,async resolveId(n,a){return n.startsWith(C)?n:I.has(n)?{id:n,moduleSideEffects:`no-treeshake`}:null},async load(n){if(!n.startsWith(C))return null;let a=S.get(n);if(!a)return null;let N=(await this.resolve(a,void 0,{skipSelf:!0}))?.id??a;return I.add(N),{code:`${F}\nimport ${JSON.stringify(N)};\nexport * from ${JSON.stringify(N)};\n`,moduleSideEffects:`no-treeshake`}}}}}function flattenAliases$4(n){let a={};for(let[S,C]of Object.entries(n))C&&(a[S]=C);return a}function createGjsExternalsPredicate(n=[]){let a=[`cairo`,`gettext`,`system`,...n];return n=>isRegisterSubpath(n)?!1:!!(n.startsWith(`gi://`)||a.includes(n))}function isRegisterSubpath(n){return!!(/\/register(?:\/[^?]*)?$/.test(n)||/[/\\]register(?:[/\\][^/\\]+)?\.(?:[mc]?js|ts)$/.test(n))}var aA,setupForGjs,oA=__esmMin(()=>{fn(),ls(),Ub(),Wb(),YS(),Ck(),a_(),kv(),kk(),Nk(),eA(),iA(),aA=ts(fileURLToPath(import.meta.url)),setupForGjs=async n=>{let a=n.userExternal??[],S=[`cairo`,`gettext`,`system`,...a.filter(n=>!isRegisterSubpath(n))],C=createGjsExternalsPredicate(a),N=n.pluginOptions.format??`esm`,F=n.pluginOptions.exclude??[],I=await globToEntryPoints(n.input,F),H=resolveShim(`unicorn-magic`),W={...getAliasesForGjs({external:C}),"unicorn-magic":H,...n.pluginOptions.aliases,...n.userAliases},K=n.pluginOptions.consoleShim===!1?null:resolveShim(`console-gjs`),q=[];n.pluginOptions.autoGlobalsInject&&q.push(n.pluginOptions.autoGlobalsInject);let Y=wrapInputWithSideEffects(I,q),X={input:Y.input,platform:`neutral`,external:S,resolve:{mainFields:N===`esm`?[`browser`,`module`,`main`]:[`browser`,`main`,`module`],conditionNames:N===`esm`?[`browser`,`import`]:[`browser`,`require`,`import`]},transform:{target:`firefox140`,define:{global:`globalThis`,window:`globalThis`,"process.env.READABLE_STREAM":`"disable"`},...K?{inject:{console:[K,`console`]}}:{}},output:{...n.output,format:N,sourcemap:!1,codeSplitting:!1},treeshake:!0},te=getBundleDirFromOutput(n.output);return{options:X,plugins:[...Y.plugin?[Y.plugin]:[],inputShebangStripPlugin(),aliasPlugin({entries:{"random-access-file":`random-access-file/index.js`,...flattenAliases$4(W)}}),externalsPlugin(C,{name:`gjsify-gjs-externalize`}),blueprintPlugin(),deepkitPlugin({reflection:n.pluginOptions.reflection}),cssAsStringPlugin({targets:{firefox:60<<16}}),nodeModulesPathRewritePlugin({bundleDir:te,runtimeResolve:N===`esm`}),processStubPlugin({userBanner:n.userBanner,captureBundleUrl:N===`esm`}),(()=>{let a=resolveShebangLine(n.shebang);return shebangPlugin({enabled:a!==null,line:a??void 0})})()]}},__name$1(flattenAliases$4,`flattenAliases`)});function gjsImportsEmptyPlugin(){return{name:`gjsify-gjs-imports-empty`,resolveId:{order:`pre`,filter:{id:/^(@girs\/|gi:\/\/)/},handler(n){return/^(@girs\/|gi:\/\/)/.test(n)?{id:sA}:null}},load(n){return n===sA?{code:`export {}; export default {};`,moduleSideEffects:!1}:null}}}var sA,cA=__esmMin(()=>{sA=`\0gjsify-empty-gjs-import`});function flattenAliases$3(n){let a={};for(let[S,C]of Object.entries(n))C&&(a[S]=C);return a}var setupForNode,lA=__esmMin(()=>{Ub(),YS(),i_(),a_(),kv(),kk(),eA(),cA(),setupForNode=async n=>{let a=n.userExternal??[],S=[...Jg,`node-datachannel`,...a],external=n=>!!S.includes(n),C=n.pluginOptions.format??`esm`,N=n.pluginOptions.exclude??[],F=await globToEntryPoints(n.input,N),I={...getAliasesForNode({external}),...n.pluginOptions.aliases,...n.userAliases},H=getBundleDirFromOutput(n.output);return{options:{input:F,platform:`node`,external:S,resolve:{mainFields:C===`esm`?[`module`,`main`,`browser`]:[`main`,`module`,`browser`],conditionNames:C===`esm`?[`require`,`node`,`module`]:[`require`]},transform:{target:`node24`,define:{global:`globalThis`,window:`globalThis`}},output:{...n.output,format:C,sourcemap:!1,banner:void 0,codeSplitting:!1},treeshake:!0},plugins:[gjsImportsEmptyPlugin(),aliasPlugin({entries:flattenAliases$3(I)}),deepkitPlugin({reflection:n.pluginOptions.reflection}),cssAsStringPlugin(),nodeModulesPathRewritePlugin({bundleDir:H})]}},__name$1(flattenAliases$3,`flattenAliases`)});function flattenAliases$2(n){let a={};for(let[S,C]of Object.entries(n))C&&(a[S]=C);return a}var setupForBrowser,uA=__esmMin(()=>{Ub(),YS(),Ck(),i_(),kv(),cA(),eA(),setupForBrowser=async n=>{let a=[...n.userExternal??[]],S=n.pluginOptions.exclude??[],C=await globToEntryPoints(n.input,S),N={};for(let[n,a]of Object.entries(Qg))N[n]=a,N[`node:${n}`]=a;let F={},I={...getDerivedAliasesSync(`browser`),...N,...F,...n.pluginOptions.aliases,...n.userAliases};return{options:{input:C,platform:`browser`,external:a,resolve:{mainFields:[`browser`,`module`,`main`],conditionNames:[`import`,`browser`]},transform:{target:`esnext`,define:{global:`globalThis`,window:`globalThis`}},output:{...n.output,format:`esm`,sourcemap:!1,codeSplitting:!1},treeshake:!0},plugins:[gjsImportsEmptyPlugin(),aliasPlugin({entries:flattenAliases$2(I)}),blueprintPlugin(),deepkitPlugin({reflection:n.pluginOptions.reflection}),cssAsStringPlugin()]}},__name$1(flattenAliases$2,`flattenAliases`)});function isPlatform(n){return dA.includes(n)}function platformResolvePlugin(n={}){let a=n.platform,S=a?[a,`native`]:[`native`];return{name:`gjsify-nativescript-platform-resolve`,resolveId:{order:`pre`,async handler(n,a,C){if(!a||!n.startsWith(`./`)&&!n.startsWith(`../`))return null;let N=fA.exec(n),F=N?N[0]:``,I=F?n.slice(0,-F.length):n;for(let N of S){let S=F&&`${I}.${N}`!=`${I}.${N}${F}`?[`${I}.${N}`,`${I}.${N}${F}`]:[`${I}.${N}`];for(let N of S){if(N===n)continue;let S=await this.resolve(N,a,{skipSelf:!0,...C?.kind?{kind:C.kind}:{}});if(S&&!S.external)return S}}return null}}}}function detectNativescriptPlatform(n=process.env){let a=n.NATIVESCRIPT_PLATFORM??n.NS_PLATFORM;if(a&&isPlatform(a))return a;let S=n.NATIVESCRIPT_BUNDLER_ENV??n.NATIVESCRIPT_WEBPACK_ENV;if(S)try{let n=JSON.parse(S);if(n.android===!0)return`android`;if(n.ios===!0)return`ios`;if(n.visionos===!0)return`visionos`;if(typeof n.platform==`string`&&isPlatform(n.platform))return n.platform}catch{}}function nativescriptPlatformDefines(n,a={}){let S=n===`android`,C=n===`ios`,N=n===`visionos`;return{__ANDROID__:String(S),__IOS__:String(C),__VISIONOS__:String(N),__APPLE__:String(C||N),__DEV__:String(a.dev??!1)}}var dA,fA,pA=__esmMin(()=>{dA=[`android`,`ios`,`visionos`],fA=/\.(tsx?|jsx?|mts|cts|mjs|cjs)$/});function flattenAliases$1(n){let a={};for(let[S,C]of Object.entries(n))C&&(a[S]=C);return a}var setupForNativescript,mA=__esmMin(()=>{Ub(),YS(),i_(),kv(),cA(),pA(),setupForNativescript=async n=>{let a=[...n.userExternal??[]],S=n.pluginOptions.exclude??[],C=await globToEntryPoints(n.input,S),N=detectNativescriptPlatform(),F={};for(let[n,a]of Object.entries($g))F[n]=a,F[`node:${n}`]=a;let I={},H={...getDerivedAliasesSync(`nativescript`),...F,...I,...n.pluginOptions.aliases,...n.userAliases};return{options:{input:C,platform:`browser`,external:a,resolve:{mainFields:[`nativescript`,`module`,`main`],conditionNames:[`import`,`nativescript`]},transform:{target:`esnext`,define:{global:`globalThis`,...nativescriptPlatformDefines(N,{dev:!1})}},output:{...n.output,format:`esm`,sourcemap:!1,codeSplitting:!1},treeshake:!0},plugins:[gjsImportsEmptyPlugin(),platformResolvePlugin({platform:N}),aliasPlugin({entries:flattenAliases$1(H)}),deepkitPlugin({reflection:n.pluginOptions.reflection})]}},__name$1(flattenAliases$1,`flattenAliases`)}),hA=__esmMin(()=>{oA(),lA(),uA(),mA()});function isExternalSpecifier(n){return!(n.startsWith(`./`)||n.startsWith(`../`)||n.startsWith(`/`)||n.startsWith(`\0`)||n.startsWith(`data:`))}function computeCommonRoot(n){let a=n===void 0?[]:typeof n==`string`?[n]:Array.isArray(n)?n:Object.values(n);if(a.length===0)return`src`;let S=a.map(n=>n.split(`/`).filter(Boolean)),C=S[0],N=0;for(;N<C.length;N++){let n=C[N];if(!S.every(a=>a[N]===n))break}if(N===0)return`src`;let F=C.slice(0,N);return S.some(n=>n.length>N)?F.join(`/`):F.slice(0,-1).join(`/`)||`src`}function flattenAliases(n){let a={};for(let[S,C]of Object.entries(n))C&&(a[S]=C);return a}var setupLib,gA=__esmMin(()=>{Ub(),eA(),Wb(),kv(),setupLib=async n=>{let a=n.pluginOptions.format??n.pluginOptions.library??`esm`,S=n.pluginOptions.exclude??[],C=await globToEntryPoints(n.input,S),N=computeCommonRoot(C),F={...n.pluginOptions.aliases,...n.userAliases};return{options:{input:C,platform:`neutral`,resolve:{mainFields:a===`esm`?[`module`,`main`]:[`main`],conditionNames:a===`esm`?[`module`,`import`]:[`require`]},transform:{target:`esnext`},output:{...n.output,format:a,preserveModules:!0,preserveModulesRoot:N,sourcemap:!1},treeshake:!1},plugins:[aliasPlugin({entries:flattenAliases(F)}),externalsPlugin(isExternalSpecifier,{name:`gjsify-lib-externalize`}),cssAsStringPlugin()]}}}),_A=__esmMin(()=>{gA()});function mimeForExtension(n){return vA[n.toLowerCase()]??`application/octet-stream`}function textLoaderPlugin(n={}){let a=n.loaders??{},S=Object.entries(a),C=S.filter(([,n])=>n===`text`).map(([n])=>n),N=S.filter(([,n])=>n===`dataurl`).map(([n])=>n),F=[...C,...N];if(F.length===0)return null;let I=F.map(n=>n.replace(/^\./,``).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)),H=RegExp(`\\.(?:${I.join(`|`)})$`),W=new Map(S.map(([n,a])=>[n.toLowerCase(),a]));return{name:`gjsify-asset-loader`,async load(n){if(!H.test(n))return null;let a=n.lastIndexOf(`.`),S=a>=0?n.slice(a).toLowerCase():``;if((W.get(S)??`text`)===`dataurl`){let a=await readFile$1(n),C=mimeForExtension(S),N=a.toString(`base64`);return{code:`export default ${JSON.stringify(`data:${C};base64,${N}`)};`,moduleType:`js`}}let C=await readFile$1(n,`utf8`);return{code:`export default ${JSON.stringify(C)};`,moduleType:`js`}}}}var vA,yA=__esmMin(()=>{Tc(),vA={".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".gif":`image/gif`,".webp":`image/webp`,".svg":`image/svg+xml`,".ico":`image/x-icon`,".avif":`image/avif`,".bmp":`image/bmp`,".tiff":`image/tiff`,".tif":`image/tiff`,".wasm":`application/wasm`}}),gjsifyPlugin,bA=__esmMin(()=>{hA(),_A(),gjsifyPlugin=async(n,a={})=>{if(a.library)switch(a.library){case`esm`:case`cjs`:return await setupLib({input:n.input,output:n.output,userAliases:n.userAliases,pluginOptions:a});default:throw TypeError(`Unknown library type: `+a.library)}let S=a.app??`gjs`;switch(S){case`gjs`:return await setupForGjs({input:n.input,output:n.output,userExternal:n.userExternal,userBanner:n.userBanner,userAliases:n.userAliases,shebang:n.shebang,pluginOptions:a});case`node`:return await setupForNode({input:n.input,output:n.output,userExternal:n.userExternal,userAliases:n.userAliases,pluginOptions:a});case`browser`:return await setupForBrowser({input:n.input,output:n.output,userExternal:n.userExternal,userAliases:n.userAliases,pluginOptions:a});case`nativescript`:return await setupForNativescript({input:n.input,output:n.output,userExternal:n.userExternal,userAliases:n.userAliases,pluginOptions:a});default:throw TypeError(`Unknown app platform: `+S)}}}),xA=__esmMin(()=>{Hg(),Hb(),hA(),_A(),kk(),Nk(),eA(),yA(),iA(),cA(),Wb(),pA(),bA(),bA(),i_()});function isPluginByName(n){return typeof n==`object`&&!!n&&typeof n.name==`string`&&!(`apply`in n)&&!(`resolveId`in n)&&!(`load`in n)&&!(`transform`in n)&&!(`renderChunk`in n)&&!(`generateBundle`in n)}async function resolveUserPlugins(n,a){let S=createRequire(Qo(a,`package.json`)),C=[];for(let N of n){if(!isPluginByName(N)){C.push(N);continue}let n;try{n=S.resolve(N.name)}catch(n){throw Error(`gjsify config: failed to resolve plugin "${N.name}" from ${a}. Add it to your project's dependencies, or pass a Plugin object directly. (${n.message})`)}let F=await import(pathToFileURL(n).href),I=N.export??`default`,H=F[I];if(typeof H!=`function`){let n=Object.keys(F).filter(n=>typeof F[n]==`function`);throw Error(`gjsify config: plugin "${N.name}" has no function export "${I}". Available function exports: ${n.length?n.join(`, `):`(none)`}.`)}let W=await H(N.options);if(W==null)throw Error(`gjsify config: plugin "${N.name}" factory returned ${W}. Check the plugin's signature — it should return a Rolldown/Vite plugin object.`);C.push(W)}return C}var SA=__esmMin(()=>{zo(),ls(),fn()}),CA,wA=__esmMin(()=>{CA={"@gjsify/buffer/register":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/dom-elements/register/canvas":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`HTMLCanvasElement`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`document`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/dom-elements/register/document":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`HTMLCanvasElement`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`document`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/dom-elements/register/font-face":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/dom-elements/register/image":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`HTMLCanvasElement`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`document`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/dom-elements/register/location":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/dom-elements/register/match-media":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/dom-elements/register/navigator":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`navigator`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/dom-elements/register/observers":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/domparser/register":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/gamepad/register":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/node-globals/register/buffer":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/node-globals/register/encoding":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/node-globals/register/microtask":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/node-globals/register/process":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/node-globals/register/structured-clone":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/node-globals/register/timers":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/node-globals/register/url":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`URL`,`URLSearchParams`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/web-globals/register/formdata":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`FormData`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/web-globals/register/performance":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/webaudio/register":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/webrtc/register/data-channel":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`Event`,`EventTarget`,`File`,`MessageEvent`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/webrtc/register/error":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`Event`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/webrtc/register/media":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`Event`,`EventTarget`,`File`,`MediaStream`,`MediaStreamTrack`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/webrtc/register/media-devices":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`Event`,`EventTarget`,`File`,`MediaStream`,`MediaStreamTrack`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/webrtc/register/peer-connection":`AbortController.AbortSignal.Blob.Buffer.ByteLengthQueuingStrategy.CountQueuingStrategy.DOMException.Event.EventTarget.File.MediaStream.MediaStreamTrack.MessageEvent.RTCSessionDescription.ReadableStream.TextDecoderStream.TextEncoderStream.TransformStream.WritableStream.atob.btoa.clearTimeout.performance.process.queueMicrotask.setTimeout.structuredClone`.split(`.`),"abort-controller/register":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"compression-streams/register":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CompressionStream`,`CountQueuingStrategy`,`DOMException`,`DecompressionStream`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"dom-events/register/custom-events":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"dom-events/register/event-target":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"dom-events/register/ui-events":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"dom-exception/register":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"eventsource/register":`AbortController.AbortSignal.Blob.Buffer.ByteLengthQueuingStrategy.CompressionStream.CountQueuingStrategy.DOMException.DecompressionStream.Event.EventSource.EventTarget.File.Headers.MessageEvent.ReadableStream.Request.Response.TextDecoderStream.TextEncoderStream.TransformStream.URL.URLSearchParams.WritableStream.atob.btoa.clearTimeout.fetch.performance.process.queueMicrotask.setTimeout.structuredClone`.split(`.`),"fetch/register/fetch":`AbortController.AbortSignal.Blob.Buffer.ByteLengthQueuingStrategy.CompressionStream.CountQueuingStrategy.DOMException.DecompressionStream.File.Headers.ReadableStream.Request.Response.TextDecoderStream.TextEncoderStream.TransformStream.URL.URLSearchParams.WritableStream.atob.btoa.clearTimeout.fetch.performance.process.queueMicrotask.setTimeout.structuredClone`.split(`.`),"fetch/register/xhr":`AbortController.AbortSignal.Blob.Buffer.ByteLengthQueuingStrategy.CompressionStream.CountQueuingStrategy.DOMException.DecompressionStream.Event.EventTarget.File.Headers.ProgressEvent.ReadableStream.Request.Response.TextDecoderStream.TextEncoderStream.TransformStream.URL.URLSearchParams.WritableStream.XMLHttpRequest.XMLHttpRequestUpload.atob.btoa.clearTimeout.fetch.performance.process.queueMicrotask.setTimeout.structuredClone`.split(`.`),"message-channel/register":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`MessageChannel`,`MessagePort`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"web-streams/register/queuing":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"web-streams/register/readable":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"web-streams/register/text-streams":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"web-streams/register/transform":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"web-streams/register/writable":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"webassembly/register/promise":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WebAssembly`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"webcrypto/register":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`crypto`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"websocket/register":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`]}});function expandWithClosure(n,a){let S=new Set(n),C=[...n];for(;C.length>0;){let n=TA[C.pop()];if(!n)continue;let N=EA[n];if(N)for(let n of N)a.has(n)||TA[n]&&(S.has(n)||(S.add(n),C.push(n)))}return S}function isSubset(n,a){for(let S of n)if(!a.has(S))return!1;return!0}async function applyExcludeGlobals(n,a,S,C,N){if(!C?.length)return{detected:n,injectPath:a};for(let a of C)n.delete(a);let F=detectedToRegisterPaths(n);for(let n of S)F.add(n);return N&&(F=filterResolvableRegisterPaths(F,N)),{detected:n,injectPath:F.size>0?await writeRegisterInjectFile(F,N)??void 0:void 0}}function detectedToRegisterPaths(n){let a=new Set;for(let S of n){let n=TA[S];n&&a.add(n)}return a}function isFullConfig(n){return typeof n==`object`&&!!n&&!Array.isArray(n)&&`plugins`in n&&`options`in n}async function detectAutoGlobals(n,a,S,C,N={},F=defaultBundler){let I=N.extraGlobalsList?resolveGlobalsList(N.extraGlobalsList):new Set,H=new Set(N.excludeGlobals??[]),W=N.cwd,K=new Set,q;I.size>0&&(q=await writeRegisterInjectFile(W?filterResolvableRegisterPaths(I,W):I,W)??void 0);let Y=(n.plugins??[]).filter(n=>{let a=n&&typeof n==`object`&&`name`in n?n.name:void 0;return a!==`gjsify`&&a!==`gjsify-orchestrator`});for(let X=1;X<=DA;X++){let te=await S({...a,autoGlobalsInject:q}),ne,re;isFullConfig(te)?(re=te.options,ne=te.plugins):ne=te;let ie=q?appendInjectAsEntry(n.input,q):n.input,ae=n.resolve??re?.resolve,oe=n.external??re?.external,Z=n.transform??re?.transform,se=re?.treeshake,ce=Array.isArray(ne)?ne:[ne],le=await F({rolldownInput:{input:ie,external:oe,resolve:ae,transform:Z,plugins:[...Y,...ce],logLevel:`silent`,...se===void 0?{}:{treeshake:se}},format:n.format??`esm`});if(le.length===0)return{detected:new Set,injectPath:q};let ue=new Set;for(let n=0;n<le.length;n++){let a=le[n]??``;try{for(let n of detectFreeGlobals(a))ue.add(n)}catch(S){if(globalThis.process?.env?.GJSIFY_DEBUG_AUTO_GLOBALS){let S=`/tmp/gjsify-auto-globals-failed-chunk-${n}.mjs`;try{(await Promise.resolve().then(()=>(Jc(),Gc))).writeFileSync(S,a),ke.error(`[gjsify-auto-globals] parse failed on chunk #${n} — wrote ${S} for inspection`)}catch{}}throw S}}if(H.size>0)for(let n of H)ue.delete(n);if(isSubset(ue,K)){if(C){let n=[...K].sort(),a=I.size>0?` (+ ${I.size} extra register module(s))`:``;ke.debug(`[gjsify] --globals auto: converged after ${X-1} iteration(s), ${K.size} global(s)${n.length?`: `+n.join(`, `):``}${a}`)}return applyExcludeGlobals(K,q,I,N.excludeGlobals,W)}let de=N.disableClosureExpansion?ue:expandWithClosure(ue,H);C&&de.size>ue.size&&ke.debug(`[gjsify] --globals auto: closure map expanded ${ue.size} → ${de.size} global(s)`),X>1&&C&&ke.debug("[gjsify] --globals auto: detection grew past the closure-map expansion — the committed register-globals-closure map looks stale. Regenerate via `node packages/infra/cli/scripts/generate-register-closure.mjs`."),K=new Set([...K,...de]);let fe=detectedToRegisterPaths(K);for(let n of I)fe.add(n);if(W&&(fe=filterResolvableRegisterPaths(fe,W)),fe.size===0)return{detected:K,injectPath:void 0};if(q=await writeRegisterInjectFile(fe,W)??void 0,C){let n=[...K].sort();ke.debug(`[gjsify] --globals auto: iteration ${X}, ${K.size} global(s)${n.length?`: `+n.join(`, `):``}`)}}return C&&ke.debug(`[gjsify] --globals auto: hit max iterations (${DA}), using last detected set`),applyExcludeGlobals(K,q,I,N.excludeGlobals,W)}function appendInjectAsEntry(n,a){return n===void 0?[a]:typeof n==`string`?[n,a]:Array.isArray(n)?[...n,a]:{...n,__gjsify_inject:a}}var defaultBundler,TA,EA,DA,OA=__esmMin(()=>{Ae(),Fb(),zb(),Ab(),wA(),defaultBundler=async({rolldownInput:n,format:a})=>{let S=await(await import(`rolldown`)).rolldown(n);try{let n=await S.generate({format:a,minify:!1,sourcemap:!1}),C=[];for(let a of n.output)a.type===`chunk`&&C.push(a.code);return C}finally{await S.close()}},TA=kb,EA=CA,DA=5}),kA=__esmMin(()=>{zb(),Fb(),OA()});function findPnpRoot(n){let a=n;for(;;){if(existsSync(Qo(a,`.pnp.cjs`)))return a;let n=ts(a);if(n===a)return null;a=n}}async function loadPnpApi(){try{let n=await import(`pnpapi`);return n.default??n}catch{return null}}async function pnpPlugin(n={}){let a=n.issuerUrl??import.meta.url;if(!findPnpRoot(process.cwd()))return null;let S=await loadPnpApi();if(S===null)return null;let C=fileURLToPath(a),N=createRequire(C),F=n.relayPackages??[`@gjsify/node-polyfills`,`@gjsify/web-polyfills`],I=[];for(let n of F)try{I.push(N.resolve(`${n}/package.json`))}catch{}return{name:`gjsify-pnp`,resolveId:{order:`pre`,async handler(n,a){if(n.startsWith(`.`)||n.startsWith(`/`))return null;if(n.startsWith(`gi://`))return{id:n,external:!0};if(n.startsWith(`node:`))return await this.resolve(n,a,{skipSelf:!0});if(!a)return null;let N=a.startsWith(`file://`)?fileURLToPath(a):a;try{let a=S.resolveRequest(n,N);return a===null?null:{id:a}}catch(a){if(!isUndeclaredDependency(a))throw a;try{let a=S.resolveRequest(n,C);if(a!==null)return{id:a}}catch(n){if(!isUndeclaredDependency(n))throw n}for(let a of I)try{let C=S.resolveRequest(n,a);if(C!==null)return{id:C}}catch(n){if(!isUndeclaredDependency(n))throw n}return null}}},async load(n){if(!n.includes(`/.yarn/`)&&!n.includes(`.zip/`))return null;try{return{code:await readFile$1(n,`utf8`)}}catch(a){let S=a instanceof Error?a.message:String(a);this.error(`gjsify-pnp: failed to read ${n}: ${S}`)}}}}function isUndeclaredDependency(n){return typeof n==`object`&&!!n&&`pnpCode`in n&&n.pnpCode===`UNDECLARED_DEPENDENCY`}var AA=__esmMin(()=>{zo(),fn(),ls(),Jc(),Tc()});function normalizeBundlerOptions(n){let a=n.bundler??{},S=a;if(typeof a.define==`object`&&a.define!==null){MA||(MA=!0,ke.warn(`[gjsify] WARNING: 'bundler.define' is not a valid Rolldown option and would be silently ignored — it has been auto-mapped to 'bundler.transform.define'. Move 'define' under 'bundler.transform.define' in your config to suppress this warning and avoid a ReferenceError at GJS load time.`));let{define:n,...C}=a;S={...C,transform:{...C.transform,define:{...n,...C.transform?.define}}}}if(!n.esbuild)return S;jA||(jA=!0,ke.warn(`[gjsify] DEPRECATION: the 'esbuild' config key is deprecated and will be removed in 0.5.0. Rename it to 'bundler' (typed as RolldownOptions). See the migration notes in the gjsify CHANGELOG.`));let C=legacyEsbuildToRolldown(n.esbuild),N={...C,...S};return(C.output||S.output)&&(N.output={...C.output,...S.output}),(C.transform||S.transform)&&(N.transform={...C.transform,...S.transform},(C.transform?.define||S.transform?.define)&&(N.transform.define={...C.transform?.define,...S.transform?.define})),(C.resolve||S.resolve)&&(N.resolve={...C.resolve,...S.resolve}),N}function legacyEsbuildToRolldown(n){let a={},S={},C={},N={};return n.outfile!==void 0&&(S.file=n.outfile),n.outdir!==void 0&&(S.dir=n.outdir),n.format!==void 0&&(S.format=n.format),n.minify!==void 0&&(S.minify=n.minify),n.sourcemap!==void 0&&(S.sourcemap=n.sourcemap===`inline`?`inline`:!!n.sourcemap),n.banner?.js!==void 0&&(S.banner=n.banner.js),n.target!==void 0&&(C.target=Array.isArray(n.target)?n.target.join(`,`):n.target),n.define!==void 0&&(C.define=n.define),n.mainFields!==void 0&&(N.mainFields=n.mainFields),n.conditions!==void 0&&(N.conditionNames=n.conditions),n.external!==void 0&&(a.external=n.external),n.platform!==void 0&&(a.platform=n.platform),Object.keys(S).length>0&&(a.output=S),Object.keys(C).length>0&&(a.transform=C),Object.keys(N).length>0&&(a.resolve=N),a}function mergeBundlerOptions(n,a){let{input:S,external:C,...N}=a,F={...n,...N};return(n.output||a.output)&&(F.output={...n.output,...a.output}),(n.transform||a.transform)&&(F.transform={...n.transform,...a.transform},(n.transform?.define||a.transform?.define)&&(F.transform.define={...n.transform?.define,...a.transform?.define})),(n.resolve||a.resolve)&&(F.resolve={...n.resolve,...a.resolve}),F}var jA,MA,NA=__esmMin(()=>{Ae(),jA=!1,MA=!1});function isUnsafeDefaultOutput(n){if(/\.[cm]?tsx?$/i.test(n))return!0;let a=n.replace(/\\/g,`/`);return!!/(?:^|\/)src\//.test(a)}async function buildPnpPlugin(){return pnpPlugin({issuerUrl:import.meta.url})}async function runOneLibraryBuild(n){let a=await gjsifyPlugin({input:n.userBundler.input,output:n.output,userAliases:n.userAliases},n.pluginOpts);return await runBundle({...mergeBundlerOptions(a.options,n.userBundler),plugins:[...n.pnpPlugins,...a.plugins]})}var PA,BuildAction,FA=__esmMin(()=>{Ae(),Rg(),xA(),SA(),kA(),AA(),ls(),Tc(),NA(),PA=`#!/usr/bin/env -S gjs -m`,BuildAction=class{configData;constructor(n={}){this.configData=n}async buildLibrary(){let{verbose:n,library:a,typescript:S,exclude:C,aliases:N}=this.configData,F=a??{},I=normalizeBundlerOptions(this.configData),H=F.module?ts(F.module):void 0,W=F.main?ts(F.main):void 0,K=F.module?rs(F.module):`.js`,q=F.main?rs(F.main):`.js`,Y=H&&W&&H!==W,X=await buildPnpPlugin(),te=X?[X]:[],ne=[];if(Y){let a=H.includes(`/cjs`)||K===`.cjs`?`cjs`:`esm`;ne.push(await runOneLibraryBuild({pluginOpts:{debug:n,library:a,exclude:C,reflection:S?.reflection,jsExtension:K},userBundler:I,output:{dir:H},userAliases:N,pnpPlugins:te}));let F=W.includes(`/cjs`)||q===`.cjs`?`cjs`:`esm`;ne.push(await runOneLibraryBuild({pluginOpts:{debug:n,library:F,exclude:C,reflection:S?.reflection,jsExtension:q},userBundler:I,output:{dir:W},userAliases:N,pnpPlugins:te}))}else{let a=I.output?.file??F.module??F.main,H=a?rs(a):`.js`,W=I.output?.dir??(a?ts(a):void 0),K=I.output?.format??(W?.includes(`/cjs`)||H===`.cjs`?`cjs`:`esm`);ne.push(await runOneLibraryBuild({pluginOpts:{debug:n,library:K,exclude:C,reflection:S?.reflection,jsExtension:H},userBundler:I,output:{dir:W},userAliases:N,pnpPlugins:te}))}return ne}parseGlobalsValue(n){if(n===void 0)return{autoMode:!0,extras:``};if(n===`none`||n===``)return{autoMode:!1,extras:``};let a=n.split(`,`).map(n=>n.trim()).filter(Boolean);return{autoMode:a.includes(`auto`),extras:a.filter(n=>n!==`auto`).join(`,`)}}async resolveGlobalsInject(n,a,S){if(n!==`gjs`||!a)return;let C=resolveGlobalsList(a);if(C.size===0)return;let N=await writeRegisterInjectFile(C,process.cwd());return S&&N&&ke.debug(`[gjsify] globals: injected ${C.size} register module(s) from --globals ${a}`),N??void 0}async applyShebang(n,a,S){if(!a){S&&ke.warn(`[gjsify] --shebang skipped: no single outfile (use --outfile for executables)`);return}let C=n===`node`?nA:PA,N=resolveShebangLine(this.configData.shebang,C)??C,F=await readFile$1(a,`utf-8`);F.startsWith(`#!`)?S&&ke.debug(`[gjsify] --shebang skipped: ${a} already starts with a shebang`):await writeFile$1(a,N+`
|
|
739
739
|
`+F),await chmod$1(a,493),S&&ke.debug(`[gjsify] --shebang: wrote ${N} + chmod 0o755 to ${a}`)}async buildApp(n=`gjs`,a={}){let{verbose:S,typescript:C,exclude:N,library:F,aliases:I,excludeGlobals:H}=this.configData,W=normalizeBundlerOptions(this.configData),K=W.output?.format??(W.output?.file?.endsWith(`.cjs`)?`cjs`:`esm`),q=K===`iife`?`esm`:K,Y=W.output?.file,X=W.output?.dir;if(!Y&&!X&&(F?.main||F?.module)){let n=q===`cjs`?F.main??F.module:F.module??F.main;if(n&&isUnsafeDefaultOutput(n))throw Error(`gjsify build: refusing to default --outfile to ${n} (would overwrite a TypeScript source file). Pass --outfile/--outdir explicitly, or set "gjsify.bundler.output.file" in package.json.`);Y=n}let{consoleShim:te,globals:ne}=this.configData,re=Array.isArray(W.external)?W.external:void 0,ie=typeof W.output?.banner==`string`?W.output.banner:void 0,ae={debug:S,app:n,format:q,exclude:N,reflection:C?.reflection,consoleShim:te,...I?{aliases:I}:{}},{autoMode:oe,extras:Z}=this.parseGlobalsValue(ne),se=await buildPnpPlugin(),ce=se?[se]:[],le=textLoaderPlugin({loaders:this.configData.loaders}),ue=le?[le]:[];if(W.plugins?.length){let n=await resolveUserPlugins(W.plugins,process.cwd());ue.push(...n)}if(n===`gjs`&&oe){let gjsifyPluginFactory=async n=>{let a=await gjsifyPlugin({input:W.input,output:{file:Y,dir:X},userExternal:re,userBanner:ie,userAliases:I,shebang:this.configData.shebang},n);return{options:a.options,plugins:a.plugins}},{injectPath:n}=await detectAutoGlobals({input:W.input,plugins:[...ce,...ue],external:W.external,transform:W.transform,format:q},ae,gjsifyPluginFactory,S,{extraGlobalsList:Z,excludeGlobals:H,cwd:process.cwd()},bundleToChunks);ae.autoGlobalsInject=n}else Z&&(ae.autoGlobalsInject=await this.resolveGlobalsInject(n,Z,S));let de=await gjsifyPlugin({input:W.input,output:{file:Y,dir:X},userExternal:re,userBanner:ie,userAliases:I,shebang:this.configData.shebang},ae),fe={...mergeBundlerOptions(de.options,W),plugins:[...ce,...ue,...de.plugins]};if(a.watch)return await this.runWatchLoop(fe,n,Y,S),[];let pe=await runBundle(fe);return(n===`gjs`||n===`node`)&&this.configData.shebang&&await this.applyShebang(n,Y,S),[pe]}async runWatchLoop(n,a,S,C){let N=await runWatch(n),F=new Promise(n=>{N.on(`close`,()=>n())}),I=!1,shutdown=async()=>{if(!I){I=!0,ke.log(`
|
|
740
740
|
[gjsify build --watch] stopping watcher…`);try{await N.close()}catch(n){ke.error(`[gjsify build --watch] watcher close error:`,n)}}};process.on(`SIGINT`,shutdown),process.on(`SIGTERM`,shutdown),N.on(`event`,async n=>{switch(n.code){case`START`:C&&ke.log(`[gjsify build --watch] rebuild start`);break;case`BUNDLE_START`:ke.log(`[gjsify build --watch] building…`);break;case`BUNDLE_END`:ke.log(`[gjsify build --watch] built in ${n.duration}ms`);try{(a===`gjs`||a===`node`)&&this.configData.shebang&&await this.applyShebang(a,S,C)}finally{await n.result.close()}break;case`END`:ke.log(`[gjsify build --watch] waiting for changes…`);break;case`ERROR`:ke.error(`[gjsify build --watch] build failed:`,n.error?.message??n.error),C&&n.error?.stack&&ke.error(n.error.stack);try{await n.result.close()}catch{}break}}),C&&N.on(`change`,(n,a)=>{ke.log(`[gjsify build --watch] ${a.event}: ${n}`)}),await F}async start(n={app:`gjs`}){if(n.library){if(n.watch)throw Error(`gjsify build: --watch is not supported with --library (library mode would emit watcher rebuilds for every produced format; use --app gjs|node|browser instead).`);return await this.buildLibrary()}return await this.buildApp(n.app,{watch:n.watch})}}}),IA,LA=__esmMin(()=>{Mg(),FA(),IA={command:`build [entryPoints..]`,description:`Build and bundle your Gjs project`,builder:n=>n.option(`entry-points`,{description:`The entry points you want to bundle. Defaults to bundler.input from package.json#gjsify or .gjsifyrc.js, falling back to src/index.ts when neither is set.`,array:!0,type:`string`,normalize:!0,defaultDescription:`src/index.ts (fallback)`,coerce:n=>[...new Set(n)]}).option(`exclude`,{description:`An array of glob patterns to exclude entry-points and aliases`,array:!0,type:`string`,normalize:!0,default:[]}).option(`verbose`,{description:`Switch on the verbose mode`,type:`boolean`,normalize:!0,default:!1}).option(`app`,{description:`Use this if you want to build an application, the platform node is usually only used for tests`,type:`string`,choices:[`gjs`,`node`,`browser`,`nativescript`],normalize:!0,default:`gjs`}).option(`format`,{description:`Override the default output format`,type:`string`,choices:[`iife`,`esm`,`cjs`],normalize:!0}).option(`minify`,{description:`Minify the bundled output. Defaults to true; use --no-minify to emit pretty-printed code (e.g. for debugging or readable bundle review).`,type:`boolean`,normalize:!0,defaultDescription:`true`}).option(`library`,{description:`Use this if you want to build a library for Gjsify`,type:`boolean`,normalize:!0,default:!1}).option(`outfile`,{alias:`o`,description:`Sets the output file name for the build operation. If no outfile is specified, the outfile will be parsed from the package.json. Only used if application mode is active`,type:`string`,normalize:!0}).option(`outdir`,{alias:`d`,description:`Sets the output directory for the build operation. If no outdir is specified, the outdir will be parsed from the package.json. Only used if library mode is active`,type:`string`,normalize:!0}).option(`reflection`,{alias:`r`,description:`Enables TypeScript types on runtime using Deepkit's type compiler`,type:`boolean`,normalize:!0,default:!1}).option(`log-level`,{description:`The log level can be changed to prevent esbuild from printing warning and/or error messages to the terminal`,type:`string`,choices:[`silent`,`error`,`warning`,`info`,`debug`,`verbose`],normalize:!0,default:`warning`}).option(`console-shim`,{description:`Inject a console shim into GJS builds for clean output without the GLib prefix and with working ANSI colors. Use --no-console-shim to disable. Only applies to GJS app builds.`,type:`boolean`,normalize:!0,default:!0}).option(`globals`,{description:"Comma-separated list of global identifiers, 'auto' (default) to detect automatically from the bundled output, or 'none' to disable. The 'auto' token may be combined with explicit identifiers/groups (e.g. 'auto,dom') for cases where the detector cannot statically see a global because it's accessed via indirection. Each identifier is mapped to the corresponding `@gjsify/<pkg>/register` module and injected into the bundle. See the CLI Reference docs for the full list of known identifiers. Only applies to GJS app builds.",type:`string`,normalize:!0,default:`auto`}).option(`shebang`,{description:"Prepend a target-appropriate shebang to the output and mark it executable (chmod 755): `#!/usr/bin/env -S gjs -m` for --app gjs, `#!/usr/bin/env node` for --app node. Applies to GJS and Node app builds with a single --outfile. Default: false (use --shebang to enable, or set `shebang: true` in `.gjsifyrc.js`).",type:`boolean`,normalize:!0}).option(`external`,{description:"Module names that should NOT be bundled — EXACT package names only, matched literally on both bundler engines (no globs). Repeat the flag or pass a comma-separated list (e.g. --external typedoc,prettier). Appended to the per-app built-in externals; register subpaths (`<pkg>/register[/…]`) are always force-inlined for --app gjs regardless of this flag.",array:!0,type:`string`,default:[],coerce:n=>n.flatMap(n=>n.split(`,`).map(n=>n.trim()).filter(Boolean))}).option(`define`,{description:`Substitute compile-time constants. Each entry is KEY=VALUE where VALUE is a JS expression (string literals must be quoted: --define VERSION='"1.2.3"'). Repeat the flag or pass comma-separated. See https://esbuild.github.io/api/#define`,array:!0,type:`string`,default:[]}).option(`alias`,{description:`Map module specifiers at bundle time. Each entry is FROM=TO (e.g. --alias typedoc=@gjsify/empty). Layered on top of the built-in alias map. Useful for stubbing heavy deps the test scenario never executes.`,array:!0,type:`string`,default:[],coerce:n=>n.flatMap(n=>n.split(`,`).map(n=>n.trim()).filter(Boolean))}).option(`exclude-globals`,{description:`Comma-separated global identifiers to remove from auto-detection results. Use for false positives from dead browser-compat code whose polyfills require unavailable native libraries (e.g. --exclude-globals fetch,XMLHttpRequest).`,type:`string`,normalize:!0}).option(`watch`,{alias:`w`,description:"Watch source files and rebuild on change. Logs each rebuild with duration; clean SIGINT shutdown. Only valid with --app gjs|node|browser (rejected with --library). Requires the npm `rolldown` engine — run under Node, not the GJS-bundled CLI.",type:`boolean`,normalize:!0,default:!1}),handler:async n=>{await new BuildAction(await new Config().forBuild(n)).start({library:n.library,app:n.app,watch:n.watch})}}});function nodeArchToLinuxArch(n){return{x64:`x86_64`,arm64:`aarch64`,arm:`armv7`,ia32:`i686`}[n]??n}function readPackageJson$3(n){try{return JSON.parse(readFileSync(n,`utf-8`))}catch{return null}}function scanNodeModules(n,a){let S=[];if(!existsSync(n))return S;let C;try{C=readdirSync(n)}catch{return S}for(let N of C)if(!N.startsWith(`.`))if(N.startsWith(`@`)){let C=Qo(n,N),F;try{F=readdirSync(C)}catch{continue}for(let n of F){let F=checkPackage(Qo(C,n),`${N}/${n}`,a);F&&S.push(F)}}else{let C=checkPackage(Qo(n,N),N,a);C&&S.push(C)}return S}function checkPackage(n,a,S){let C=readPackageJson$3(Qo(n,`package.json`));if(!C)return null;let N=C.gjsify;if(!N||typeof N!=`object`)return null;let F=N.prebuilds;if(typeof F!=`string`)return null;let I=Qo(n,F,`linux-${S}`);return existsSync(I)?{name:a,prebuildsDir:I}:null}function detectNativePackages(n){let a=nodeArchToLinuxArch(process.arch),S=[],C=new Set,N=Yo(n);for(;;){let n=Qo(N,`node_modules`);if(existsSync(n))for(let N of scanNodeModules(n,a))C.has(N.name)||(C.add(N.name),S.push(N));let F=Yo(N,`..`);if(F===N)break;N=F}return S}function buildNativeEnv(n){let a=n.map(n=>n.prebuildsDir),S=process.env.LD_LIBRARY_PATH??``,C=process.env.GI_TYPELIB_PATH??``;return{LD_LIBRARY_PATH:[...a,...S?[S]:[]].join(`:`),GI_TYPELIB_PATH:[...a,...C?[C]:[]].join(`:`)}}var RA=__esmMin(()=>{Jc(),ls(),__name$1(readPackageJson$3,`readPackageJson`)});function computeNativeEnvForBundle(n,a=process.cwd()){let S=Yo(n),C=detectNativePackages(a),N=detectNativePackages(ts(S)),F=new Set(C.map(n=>n.name)),I=buildNativeEnv([...C,...N.filter(n=>!F.has(n.name))]);return{env:I,envPrefix:Object.entries(I).filter(([,n])=>n!==void 0&&n!==``).map(([n,a])=>`${n}=${a}`).join(` `)}}async function runGjsBundle(n,a=[],S={}){let{env:C,envPrefix:N}=computeNativeEnvForBundle(n),F={...process.env,...C},I=[`-m`,n,...a],H=[`gjs`,...I.map(n=>n.includes(` `)?`"${n}"`:n)].join(` `);ke.error(`$ ${N?`${N} `:``}${H}`);let W=spawn(`gjs`,I,{env:F,stdio:`inherit`});await new Promise((n,a)=>{W.on(`close`,S=>{S===0?n():a(Error(`gjs exited with code ${S}`))}),W.on(`error`,a)}).catch(n=>{ke.error(n.message),process.exit(1)}),S.exitOnSuccess&&process.exit(0)}var zA=__esmMin(()=>{Ae(),nC(),ls(),RA()});async function buildTestBundle(n,a,S,C){let N=await new Config().forBuild({entryPoints:[n],outfile:a,app:S,verbose:C??!1,logLevel:`warning`,exclude:[]});N.library={...N.library},N.bundler={...N.bundler,input:[n],output:{...N.bundler?.output,file:a}},await new BuildAction(N).start({app:S,library:!1})}async function runTestBundle(n,a){if(a===`gjs`){await runGjsBundle(n);return}await new Promise((a,S)=>{let C=spawn(`node`,[n],{stdio:`inherit`});C.on(`error`,S),C.on(`exit`,n=>{n===0?a():S(Error(`node exited with code ${n}`))})})}function isFresh(n,a){if(!existsSync(n))return!1;let S=statSync(n).mtimeMs,C=ts(a);try{return S>=newestMtimeUnder(existsSync(C)?C:a)}catch{return!1}}function newestMtimeUnder(n){let a=statSync(n);if(a.isFile())return a.mtimeMs;let S=a.mtimeMs;for(let a of readdirSync(n,{withFileTypes:!0})){if(a.name===`node_modules`||a.name===`dist`||a.name===`lib`||a.name.startsWith(`.`))continue;let C=newestMtimeUnder(Qo(n,a.name));C>S&&(S=C)}return S}var BA,VA=__esmMin(()=>{Ae(),Jc(),ls(),nC(),Mg(),FA(),zA(),BA={command:`test`,description:"Build + run the package’s `src/test.mts` suite on GJS and Node and aggregate the results. Replaces the per-package `build:test:{gjs,node}` + `test:{gjs,node}` script boilerplate.",builder:n=>n.option(`runtime`,{description:`Target runtime. Default: both.`,type:`string`,choices:[`gjs`,`node`,`all`],default:`all`}).option(`entry`,{description:"Path to the test entry. Default: `src/test.mts` (or `gjsify.test.entry`).",type:`string`,normalize:!0}).option(`outdir`,{description:"Output directory for the built test bundles. Default: `dist/`.",type:`string`,normalize:!0}).option(`rebuild`,{description:`Always rebuild the test bundles, even when they look up-to-date.`,type:`boolean`,default:!1}).option(`build`,{description:`Build before running. Default: true (use --no-build to skip when bundles already exist).`,type:`boolean`,default:!0}).option(`verbose`,{description:`Print resolved entry/outdir + per-step timing.`,type:`boolean`,default:!1}),handler:async n=>{let a=process.cwd(),S=(await new Config().forBuild({}).catch(()=>({}))).test??{},C=Yo(a,n.entry??S.entry??`src/test.mts`),N=Yo(a,n.outdir??S.outdir??`dist`);existsSync(C)||(ke.error(`[gjsify test] no test entry at ${$o(a,C)} — add an \`src/test.mts\` that aggregates your \`@gjsify/unit\` suites, or set \`gjsify.test.entry\` in package.json.`),process.exit(1));let F=n.runtime===`gjs`?[`gjs`]:n.runtime===`node`?[`node`]:S.runtimes&&S.runtimes.length>0?S.runtimes:[`gjs`,`node`],I=[];for(let S of F){let F=Qo(N,`test.${S}.mjs`);if(n.build!==!1)if(n.rebuild||!isFresh(F,C)){let N=Date.now();n.verbose&&ke.log(`[gjsify test] building → ${$o(a,F)} (—app ${S})`);try{await buildTestBundle(C,F,S,n.verbose),n.verbose&&ke.log(`[gjsify test] built ${S} in ${Date.now()-N}ms`)}catch(n){ke.error(`[gjsify test] build failed for ${S}:`,n.message),I.push({runtime:S,ok:!1,durationMs:0,error:`build failed`});continue}}else n.verbose&&ke.log(`[gjsify test] ${S}: bundle is up-to-date — skipping build (use --rebuild to force)`);else if(!existsSync(F)){ke.error(`[gjsify test] --no-build but ${$o(a,F)} doesn't exist. Build first or drop --no-build.`),I.push({runtime:S,ok:!1,durationMs:0,error:`no bundle`});continue}let H=Date.now();try{await runTestBundle(F,S),I.push({runtime:S,ok:!0,durationMs:Date.now()-H})}catch(n){I.push({runtime:S,ok:!1,durationMs:Date.now()-H,error:n.message})}}let H=I.map(n=>`${n.ok?`✅`:`❌`} ${n.runtime} (${n.durationMs}ms)${n.error?` — ${n.error}`:``}`).join(` `);ke.log(`[gjsify test] ${H}`),I.some(n=>!n.ok)&&process.exit(1),process.exit(0)}}});function readPackageJson$2(n){if(!existsSync(n))return null;let a=readFileSync(n,`utf-8`);try{return JSON.parse(a)}catch(a){throw Error(`gjsify install: ${n} is not valid JSON: ${a.message}`)}}function writePackageJson(n,a){let S=sortKnownDepFields(a);writeFileSync(n,JSON.stringify(S,null,2)+`
|
|
741
|
-
`,`utf-8`)}function parseSpec$2(n){if(n.startsWith(`@`)){let a=n.indexOf(`/`);if(a===-1)return{name:n};let S=n.indexOf(`@`,a+1);return S===-1?{name:n}:{name:n.slice(0,S),range:n.slice(S+1)}}let a=n.indexOf(`@`);return a===-1?{name:n}:{name:n.slice(0,a),range:n.slice(a+1)}}function projectSpecsFromPackageJson(n){let a=[];for(let S of[`dependencies`,`devDependencies`,`optionalDependencies`]){let C=n[S];if(C)for(let[n,S]of Object.entries(C))typeof S==`string`&&(/^(workspace|link|file|portal|git\+|https?):/.test(S)||a.push(`${n}@${S}`))}return a}function addDependencyEntry(n,a,S,C){n[C]===void 0&&(n[C]={}),n[C][a]=S}function defaultRangeFromVersion(n){return`^${n}`}function sortKnownDepFields(n){let a={...n};for(let n of[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`]){let S=a[n];S&&(a[n]=Object.fromEntries(Object.entries(S).sort(([n],[a])=>n<a?-1:+(n>a))))}return a}var HA=__esmMin(()=>{Jc(),__name$1(readPackageJson$2,`readPackageJson`),__name$1(parseSpec$2,`parseSpec`)});function looksLikeFile(n){if(n.startsWith(`./`)||n.startsWith(`../`)||n.startsWith(`/`)||n.includes(`/`)||n.includes(`\\`)||/\.(c?js|mjs|cjs|gjs)$/.test(n))return!0;try{return statSync(n).isFile()}catch{return!1}}async function runScript(n,a){let S=process.cwd(),C=Qo(S,`package.json`),N=readPackageJson$2(C);N||(ke.error(`gjsify run: no package.json in ${S}`),process.exit(1));let F=N.scripts??{},I=F[n];if(typeof I!=`string`){let a=Object.keys(F).join(`, `)||`<none>`;ke.error(`gjsify run: no script "${n}" in ${C} (available: ${a})`),process.exit(1)}let H=findWorkspaceRoot(S),W=[Qo(S,`node_modules`,`.bin`)];H&&H!==S&&W.push(Qo(H,`node_modules`,`.bin`));let K=process.env.FORCE_COLOR!==void 0||process.env.NO_COLOR!==void 0?{}:{FORCE_COLOR:`1`},q={...process.env,...K,PATH:[...W,process.env.PATH??``].filter(Boolean).join(ss),npm_lifecycle_event:n,npm_package_name:N.name??``,npm_package_version:N.version??``},Y=runningUnderGjs()?gjsifyInProcessArgv(I,a):null;if(Y){process.env.PATH=q.PATH,process.env.npm_lifecycle_event=q.npm_lifecycle_event,process.env.npm_package_name=q.npm_package_name,process.env.npm_package_version=q.npm_package_version,q.FORCE_COLOR!==void 0&&(process.env.FORCE_COLOR=q.FORCE_COLOR);try{let{runCli:n}=await Promise.resolve().then(()=>(
|
|
741
|
+
`,`utf-8`)}function parseSpec$2(n){if(n.startsWith(`@`)){let a=n.indexOf(`/`);if(a===-1)return{name:n};let S=n.indexOf(`@`,a+1);return S===-1?{name:n}:{name:n.slice(0,S),range:n.slice(S+1)}}let a=n.indexOf(`@`);return a===-1?{name:n}:{name:n.slice(0,a),range:n.slice(a+1)}}function projectSpecsFromPackageJson(n){let a=[];for(let S of[`dependencies`,`devDependencies`,`optionalDependencies`]){let C=n[S];if(C)for(let[n,S]of Object.entries(C))typeof S==`string`&&(/^(workspace|link|file|portal|git\+|https?):/.test(S)||a.push(`${n}@${S}`))}return a}function addDependencyEntry(n,a,S,C){n[C]===void 0&&(n[C]={}),n[C][a]=S}function defaultRangeFromVersion(n){return`^${n}`}function sortKnownDepFields(n){let a={...n};for(let n of[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`]){let S=a[n];S&&(a[n]=Object.fromEntries(Object.entries(S).sort(([n],[a])=>n<a?-1:+(n>a))))}return a}var HA=__esmMin(()=>{Jc(),__name$1(readPackageJson$2,`readPackageJson`),__name$1(parseSpec$2,`parseSpec`)});function looksLikeFile(n){if(n.startsWith(`./`)||n.startsWith(`../`)||n.startsWith(`/`)||n.includes(`/`)||n.includes(`\\`)||/\.(c?js|mjs|cjs|gjs)$/.test(n))return!0;try{return statSync(n).isFile()}catch{return!1}}async function runScript(n,a){let S=process.cwd(),C=Qo(S,`package.json`),N=readPackageJson$2(C);N||(ke.error(`gjsify run: no package.json in ${S}`),process.exit(1));let F=N.scripts??{},I=F[n];if(typeof I!=`string`){let a=Object.keys(F).join(`, `)||`<none>`;ke.error(`gjsify run: no script "${n}" in ${C} (available: ${a})`),process.exit(1)}let H=findWorkspaceRoot(S),W=[Qo(S,`node_modules`,`.bin`)];H&&H!==S&&W.push(Qo(H,`node_modules`,`.bin`));let K=process.env.FORCE_COLOR!==void 0||process.env.NO_COLOR!==void 0?{}:{FORCE_COLOR:`1`},q={...process.env,...K,PATH:[...W,process.env.PATH??``].filter(Boolean).join(ss),npm_lifecycle_event:n,npm_package_name:N.name??``,npm_package_version:N.version??``},Y=runningUnderGjs()?gjsifyInProcessArgv(I,a):null;if(Y){process.env.PATH=q.PATH,process.env.npm_lifecycle_event=q.npm_lifecycle_event,process.env.npm_package_name=q.npm_package_name,process.env.npm_package_version=q.npm_package_version,q.FORCE_COLOR!==void 0&&(process.env.FORCE_COLOR=q.FORCE_COLOR);try{let{runCli:n}=await Promise.resolve().then(()=>(KN(),GN));await n(Y)}catch(n){ke.error(n.message),process.exit(1)}process.exit(process.exitCode==null?0:Number(process.exitCode))}let X=a.length>0?`${I} ${a.map(shellEscape).join(` `)}`:I;await new Promise((a,C)=>{let N=spawn(X,[],{cwd:S,env:q,stdio:`inherit`,shell:!0});N.on(`close`,S=>{S===0?a():C(Error(`script "${n}" exited with code ${S}`))}),N.on(`error`,C)}).catch(n=>{ke.error(n.message),process.exit(1)}),process.exit(0)}function shellEscape(n){return/^[a-zA-Z0-9_\-./=:@,]+$/.test(n)?n:`'${n.replace(/'/g,`'\\''`)}'`}function runningUnderGjs(){return globalThis.imports?.gi!==void 0}function gjsifyInProcessArgv(n,a){let S=tokenizeSimpleCommand(n);return!S||S.length<2||S[0]!==`gjsify`?null:[...S.slice(1),...a]}function tokenizeSimpleCommand(n){let a=[],S=``,C=!1,N=null;for(let F=0;F<n.length;F++){let I=n[F];if(N===`'`){I===`'`?N=null:S+=I;continue}if(N===`"`){if(I===`"`)N=null;else if(I===`\\`&&(n[F+1]===`"`||n[F+1]===`\\`))S+=n[++F];else if(I===`$`||I==="`")return null;else S+=I;continue}if(I===`'`||I===`"`){N=I,C=!0;continue}if(I===` `||I===` `){C&&=(a.push(S),S=``,!1);continue}if(`|&;<>\`$()\\
|
|
742
742
|
\r*?{}[]~#!`.includes(I))return null;S+=I,C=!0}return N?null:(C&&a.push(S),a)}var UA,WA=__esmMin(()=>{Ae(),Jc(),ls(),nC(),zA(),HA(),Pg(),UA={command:`run <target> [args..]`,description:"Run a script from package.json (yarn-run-style) or a GJS bundle file. If <target> resolves to a file on disk (or has a path-like prefix), it is launched via gjs with LD_LIBRARY_PATH + GI_TYPELIB_PATH set for native packages. Otherwise it is looked up in the current package.json `scripts`.",builder:n=>n.positional(`target`,{description:"Either a script name (looked up in package.json `scripts`) or a path to a GJS bundle (e.g. dist/gjs.js).",type:`string`,demandOption:!0}).positional(`args`,{description:`Extra arguments passed through to the script / gjs.`,type:`string`,array:!0,default:[]}).parserConfiguration({"populate--":!0}),handler:async n=>{let a=n.target,S=n.args??[],C=(n[`--`]??[]).filter(n=>typeof n==`string`),N=[...S,...C],F=readPackageJson$2(Qo(process.cwd(),`package.json`));if(!(F?.scripts&&typeof F.scripts[a]==`string`)&&looksLikeFile(a)){await runGjsBundle(Yo(a),N,{exitOnSuccess:!0});return}await runScript(a,N)}}}),GA,KA=__esmMin(()=>{Ae(),ls(),RA(),GA={command:`info [file]`,description:`Show native gjsify packages detected in node_modules and the env vars needed to run a GJS bundle directly with gjs.`,builder:n=>n.positional(`file`,{description:`Optional: the GJS bundle path to include in the example command (e.g. dist/gjs.js)`,type:`string`,normalize:!0}).option(`export`,{description:`Output only shell export statements suitable for eval (eval $(gjsify info --export))`,type:`boolean`,default:!1}),handler:async n=>{let a=process.cwd(),S=n.file?Yo(n.file):null,C=detectNativePackages(a),{LD_LIBRARY_PATH:N,GI_TYPELIB_PATH:F}=buildNativeEnv(C);if(n.export){ke.log(`export LD_LIBRARY_PATH="${N}"`),ke.log(`export GI_TYPELIB_PATH="${F}"`);return}if(C.length===0){ke.log(`No native gjsify packages detected in node_modules.`),ke.log(`Native packages declare "gjsify": { "prebuilds": "<dir>" } in their package.json.`);return}ke.log(`Native packages detected:`);for(let n of C)ke.log(` ${n.name} → ${n.prebuildsDir}`);ke.log(``),ke.log(`To run your app directly with gjs, set:`),ke.log(` export LD_LIBRARY_PATH="${N}"`),ke.log(` export GI_TYPELIB_PATH="${F}"`),S?ke.log(` gjs -m ${S}`):ke.log(` gjs -m <your-bundle.js>`),ke.log(``),ke.log(`Or use gjsify run to handle this automatically:`),S?ke.log(` gjsify run ${n.file}`):ke.log(` gjsify run <your-bundle.js>`)}}});function tryExecFile(n,a){try{return execFileSync(n,a,{encoding:`utf-8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()}catch{return null}}function checkBinary(n,a,S,C,N,F,I){let H=tryExecFile(S,C);return H===null?{id:n,name:a,found:!1,severity:N,requiredBy:I}:{id:n,name:a,found:!0,version:F?F(H):H.split(`
|
|
743
743
|
`)[0]??H,severity:N,requiredBy:I}}function checkPkgConfig(n,a,S,C,N){let F=tryExecFile(`pkg-config`,[`--modversion`,S]);return F===null?{id:n,name:a,found:!1,severity:C,requiredBy:N}:{id:n,name:a,found:!0,version:F.split(`
|
|
744
744
|
`)[0],severity:C,requiredBy:N}}function checkNpmPackage(n,a,S,C,N,F){try{return createRequire(pathToFileURL(Qo(C,`_check_.js`)).href).resolve(S),{id:n,name:a,found:!0,severity:N,requiredBy:F}}catch{}try{return createRequire(import.meta.url).resolve(S),{id:n,name:a,found:!0,severity:N,requiredBy:F}}catch{return{id:n,name:a,found:!1,severity:N,requiredBy:F}}}function detectPackageManager$2(){for(let n of[`apt`,`dnf`,`pacman`,`zypper`,`apk`])if(tryExecFile(`which`,[n])!==null)return n;return`unknown`}function findProjectRoot(n){let a=Yo(n);for(;;){if(existsSync(Qo(a,`package.json`)))return a;let n=Yo(a,`..`);if(n===a)return null;a=n}}function discoverGjsifyPackages(n){let a=findProjectRoot(n);if(!a)return null;let S=Qo(a,`node_modules`,`@gjsify`);if(!existsSync(S))return new Set;let C=Qo(a,`package.json`),N={};try{N=JSON.parse(readFileSync(C,`utf-8`))}catch{}let F={...N.dependencies,...N.devDependencies},I=new Set;try{for(let n of readdirSync(S,{withFileTypes:!0}))(n.isDirectory()||n.isSymbolicLink())&&I.add(`@gjsify/${n.name}`)}catch{}for(let n of Object.keys(F))n.startsWith(`@gjsify/`)&&I.add(n);return I}function computeNeededOptionalDeps(n){let a=discoverGjsifyPackages(n);if(a===null)return null;let S=new Set;for(let n of a){let a=JA[n];if(a)for(let n of a)S.add(n)}return S}function runAllChecks(n){let a=computeNeededOptionalDeps(n);return[...runMinimalChecks(),...runRequiredChecks(n),...runOptionalChecks(a,n)]}function runMinimalChecks(){let n=[];return n.push({id:`nodejs`,name:`Node.js`,found:!0,version:process.version,severity:`required`}),n.push(checkBinary(`gjs`,`GJS`,`gjs`,[`--version`],`required`,n=>n.replace(/^GJS\s+/i,``).split(`
|
|
@@ -798,12 +798,12 @@ jobs:
|
|
|
798
798
|
--- gjsify post-install checks ---`);let n=runMinimalChecks().filter(n=>!n.found&&n.severity===`required`);if(n.length>0){ke.warn(`Missing required system dependencies:
|
|
799
799
|
`);for(let a of n)ke.warn(` ✗ ${a.name}`);let a=buildInstallCommand(detectPackageManager$2(),n);a&&ke.warn(`\nInstall with:\n ${a}`)}else ke.log(`System dependencies OK.`);let a=detectNativePackages(process.cwd());if(a.length>0){ke.log(`\nDetected ${a.length} @gjsify/* package(s) with native prebuilds:`);for(let n of a)ke.log(` • ${n.name}`);ke.log("\nUse `gjsify run <bundle>` to launch with LD_LIBRARY_PATH/GI_TYPELIB_PATH set.")}maybeInstallGitHooks()}function maybeInstallGitHooks(){let n=process.cwd(),a=Qo(n,`scripts`,`install-git-hooks.mjs`);if(existsSync(a)&&existsSync(Qo(n,`.git`)))try{let S=spawnSync(process.execPath,[a,`--quiet`],{cwd:n,stdio:`inherit`,env:process.env});S.status!==0&&ke.warn(`[gjsify install] scripts/install-git-hooks.mjs exited ${S.status} — git hooks may not be active.`)}catch(n){ke.warn(`[gjsify install] git hook installation skipped: ${n instanceof Error?n.message:String(n)}`)}}var FM,IM,LM=__esmMin(()=>{Ae(),Jc(),ls(),nC(),Ng(),ZA(),RA(),jM(),PM(),HA(),FM=18e5,IM={command:`install [packages..]`,description:`Install npm dependencies in the current project (or globally with -g), then run gjsify-aware post-checks.`,builder:n=>n.positional(`packages`,{description:`Optional package specs. With none, runs a full project install.`,type:`string`,array:!0}).option(`global`,{description:`Install into the user-global XDG location and symlink bins into ~/.local/bin.`,type:`boolean`,alias:`g`,default:!1}).option(`save-dev`,{type:`boolean`,alias:`D`}).option(`save-peer`,{type:`boolean`}).option(`save-optional`,{type:`boolean`,alias:`O`}).option(`immutable`,{description:`CI mode: install strictly from gjsify-lock.json, fail if the lockfile is missing or stale. Equivalent to yarn --immutable / npm ci --frozen-lockfile.`,type:`boolean`,default:!1}).option(`verbose`,{description:`Verbose install logging.`,type:`boolean`,default:!1}).option(`quiet`,{description:`Silence the progress bar.`,type:`boolean`,default:!1}).option(`progress`,{description:`Show a TTY-aware progress bar for resolve / download / extract phases. Auto-enabled when stderr is a TTY (override with --no-progress). Implicitly off under --verbose (per-package log lines replace the bar) or --quiet.`,type:`boolean`,default:!0}).option(`backend`,{description:"Install backend. `native` (default) routes through `@gjsify/{semver,npm-registry,tar}` — no Node/npm at runtime. `npm` shells out to `npm install` as an escape hatch for cases the native backend does not yet model (Yarn PnP repos, lifecycle scripts). Overrides `GJSIFY_INSTALL_BACKEND` if both are set.",type:`string`,choices:[`native`,`npm`]}).option(`timeout`,{description:`Overall install wall-clock timeout in ms (default 1800000 = 30 min). On timeout, all in-flight registry fetches are aborted and the install exits non-zero with a clear "install timed out — likely a registry slowdown" message. Per-request timeouts in @gjsify/npm-registry (default 30s) still apply within this budget. Set to 0 to disable the overall budget.`,type:`number`,default:FM}),handler:async n=>{if(n.immutable&&(n.packages&&n.packages.length>0&&(ke.error(`gjsify install --immutable does not accept package arguments. Remove the package names or drop --immutable.`),process.exit(1)),n.global&&(ke.error(`gjsify install --immutable is incompatible with --global.`),process.exit(1))),n.global){(!n.packages||n.packages.length===0)&&(ke.error(`gjsify install --global requires at least one <pkg> argument.`),process.exit(1));for(let a of[`save-dev`,`save-peer`,`save-optional`])n[a]&&ke.warn(`gjsify install --global ignores --${a}: global installs do not modify a project package.json.`);await installGlobalAndLink(n.packages,{verbose:n.verbose});return}if((n.backend??process.env.GJSIFY_INSTALL_BACKEND??`native`)===`npm`){await projectInstallViaNpm(n),await runPostInstallChecks();return}let a=n.timeout>0?n.timeout:0,S=a>0?new AbortController:null,C=S===null?null:setTimeout(()=>S.abort(Error(`install-overall-timeout`)),a);try{await projectInstallNative(n,S?.signal),await runPostInstallChecks()}catch(n){if(S!==null&&S.signal.aborted&&isAbortedFromOverallTimeout(n)){let n=Math.round(a/100)/10;ke.error(`gjsify install: timed out after ${n}s — likely a registry slowdown.\nRe-run, or override with --timeout <ms> (set --timeout 0 to disable the overall budget).`),process.exit(1)}throw n}finally{C!==null&&clearTimeout(C)}}}});function readDirectChildren(n){let a;try{a=readdirSync(`/proc/${n}/task`)}catch{return null}let S=[],C=!1;for(let N of a)try{let a=readFileSync(`/proc/${n}/task/${N}/children`,`utf-8`);C=!0;for(let n of a.trim().split(/\s+/)){let a=Number(n);Number.isInteger(a)&&a>0&&S.push(a)}}catch{}return C?S:null}function buildPpidMap(){let n=new Map,a=[];try{a=readdirSync(`/proc`)}catch{return n}for(let S of a){let a=Number(S);if(!(!Number.isInteger(a)||a<=0))try{let S=readFileSync(`/proc/${a}/stat`,`utf-8`),C=S.slice(S.lastIndexOf(`)`)+2).split(` `),N=Number(C[1]);if(!Number.isInteger(N)||N<=0)continue;let F=n.get(N);F?F.push(a):n.set(N,[a])}catch{}}return n}function collectDescendants(n){let a=[],S=new Set([n]),C=[n],N=null;for(;C.length>0;){let n=C.shift(),F=readDirectChildren(n);F===null&&(N??=buildPpidMap(),F=N.get(n)??[]);for(let n of F)S.has(n)||(S.add(n),a.push(n),C.push(n))}return a}function signalTree(n,a,S){for(let n=a.length-1;n>=0;n--)try{process.kill(a[n],S)}catch{}try{n.kill(S)}catch{}}function killActiveChildren(){let n=new Map;for(let a of RM){let S=a.pid?collectDescendants(a.pid):[];n.set(a,S),signalTree(a,S,`SIGTERM`)}setTimeout(()=>{for(let a of RM){let S=new Set(a.pid?collectDescendants(a.pid):[]);for(let C of n.get(a)??[])S.add(C);signalTree(a,[...S],`SIGKILL`)}},zM).unref?.()}async function runSequential(n,a,S,C,N){for(let F of n)await runOne$1(F,a,S,!1,C,N)}async function runParallel(n,a,S,C,N,F){let I=0,H=[];for(let W=0;W<C;W++)H.push((async()=>{for(;I<n.length;)await runOne$1(n[I++],a,S,!0,N,F)})());await Promise.all(H)}async function runTopologicalParallel(n,a,S,C,N,F,I){let H=new Set(n.map(n=>n.name)),W=new Map;for(let a of n){let n=new Set,S=a.manifest;for(let a of[S.dependencies,F?S.devDependencies:void 0,S.optionalDependencies])if(a)for(let[S,C]of Object.entries(a))typeof C==`string`&&C.startsWith(`workspace:`)&&H.has(S)&&n.add(S);W.set(a.name,n)}let K=new Map(n.map(n=>[n.name,n])),q=n.length,Y=new Set,X=0,te=!process.stdout.isTTY||N,ne=new Map,re=Number(process.env.GJSIFY_FOREACH_STALL_MINUTES??`20`),ie=(Number.isFinite(re)&&re>0?re:20)*6e4;return new Promise((n,F)=>{let H=null,re=Date.now(),describeInflight=()=>[...ne.entries()].map(([n,a])=>`${n} (${Math.round((Date.now()-a)/1e3)}s)`).join(`, `),failFast=n=>{H||(H=n,killActiveChildren(),setTimeout(()=>settle(),BM).unref?.())},ae=setInterval(()=>{let n=Date.now()-re;n<3e5||ne.size===0||(ke.error(`[gjsify foreach] WARNING: no workspace completed for ${Math.round(n/6e4)}min — in-flight: ${describeInflight()}`),n>=ie&&failFast(Error(`gjsify foreach: stalled — no workspace completed for ${Math.round(n/6e4)}min (override via GJSIFY_FOREACH_STALL_MINUTES); killed in-flight: ${describeInflight()}`)))},6e4);ae.unref?.();let settle=()=>{clearInterval(ae),H?F(H):n()},pump=()=>{if(!H){for(;X<C;){let n=[...W.entries()].filter(([,n])=>[...n].every(n=>Y.has(n))).map(([n])=>n);if(n.length===0)break;let C=n.sort()[0];W.delete(C),X++,ne.set(C,Date.now()),te&&ke.error(`[gjsify foreach] start ${C} (${Y.size}/${q} done, ${X} in flight)`),runOne$1(K.get(C),a,S,!0,N,I).then(()=>{Y.add(C)}).catch(n=>{failFast(n instanceof Error?n:Error(String(n)))}).finally(()=>{X--,ne.delete(C),re=Date.now(),H?X===0&&settle():W.size===0&&X===0?settle():pump()})}W.size>0&&X===0&&!H&&(clearInterval(ae),F(Error(`gjsify foreach --topological: stuck — workspaces ${[...W.keys()].join(`, `)} have unsatisfied deps in the selected set`)))}};pump()})}async function runOne$1(n,a,S,C,N,F){if(F){N&&ke.error(`[${n.name}] $ ${a} ${S.join(` `)}`),await spawnPrefixed(a,S,n.location,C?`[${n.name}] `:null);return}let I=detectPackageManager$1(),H=I===`gjsify`?[`run`,a,...S]:[`run`,a,...S.length>0?[`--`,...S]:[]];N&&ke.error(`[${n.name}] $ ${I} ${H.join(` `)}`),await spawnPrefixed(I,H,n.location,C?`[${n.name}] `:null)}function detectPackageManager$1(){let n=process.env.npm_config_user_agent??``;return n.startsWith(`yarn/`)?`yarn`:n.startsWith(`gjsify/`)?`gjsify`:`npm`}function spawnPrefixed(n,a,S,C){let N=process.env.FORCE_COLOR!==void 0||process.env.NO_COLOR!==void 0?{}:{FORCE_COLOR:`1`};return new Promise((F,I)=>{let H=spawn(n,a,{cwd:S,stdio:C?[`ignore`,`pipe`,`pipe`]:`inherit`,env:{...process.env,...N}});RM.add(H);let W=!process.stdout.isTTY,K=[];C&&H.stdout&&H.stderr&&(K.push(prefixLines(H.stdout,process.stdout,C,W)),K.push(prefixLines(H.stderr,process.stderr,C,W))),H.on(`close`,S=>{RM.delete(H);for(let n of K)n();S===0?F():I(Error(`${n} ${a.join(` `)} exited with code ${S}`))}),H.on(`error`,n=>{RM.delete(H),I(n)})})}var RM,zM,BM,VM,HM=__esmMin(()=>{Ae(),nC(),Jc(),Vp(),Ng(),Pg(),ej(),RM=new Set,zM=5e3,BM=15e3,VM={command:`foreach [script] [args..]`,description:"Run a workspace script across all (or filtered) workspaces. Drop-in for `yarn workspaces foreach`: -A/--all, -p/--parallel, -t/--topological, --include, --exclude, --no-private. Pass --exec to run an arbitrary command instead of a script.",builder:n=>n.positional(`script`,{description:"Script name to run in each workspace (`run <name>`-equivalent). With --exec, the command to run instead.",type:`string`}).positional(`args`,{description:`Extra arguments forwarded to each child invocation.`,type:`string`,array:!0}).option(`all`,{description:"Include workspaces declared as `private: true`.",type:`boolean`,alias:`A`,default:!1}).option(`parallel`,{description:`Run workspaces in parallel (capped by --jobs).`,type:`boolean`,alias:`p`,default:!1}).option(`topological`,{description:`Wait for each workspace's deps to finish before starting it (production deps only).`,type:`boolean`,alias:`t`,default:!1}).option(`topological-dev`,{description:`Like --topological but also respects devDependencies (often cyclic — use sparingly).`,type:`boolean`,default:!1}).option(`include`,{description:`Glob pattern to include workspaces by name (repeatable).`,type:`string`,array:!0}).option(`exclude`,{description:`Glob pattern to exclude workspaces by name (repeatable).`,type:`string`,array:!0}).option(`private`,{description:`Include private workspaces (default true). Pass --no-private to skip them.`,type:`boolean`,default:!0}).option(`verbose`,{description:`Echo every spawned command before running it.`,type:`boolean`,alias:`v`,default:!1}).option(`jobs`,{description:`Maximum concurrent workspaces in --parallel mode (default: cpu count).`,type:`number`,alias:`j`}).option(`exec`,{description:"Treat <script> [args..] as an arbitrary command (yarn `workspaces foreach exec`-equivalent) instead of a package.json script lookup. Workspace filtering by script presence is skipped. Use `-- <cmd> <args...>` to pass flags to the command without yargs intercepting them.",type:`boolean`,default:!1}).parserConfiguration({"populate--":!0}),handler:async n=>{let a=discoverWorkspaces(findWorkspaceRoot(process.cwd())??process.cwd()),S=n.exec===!0,C=n.script,N=n.args??[];if(!S){let a=(n[`--`]??[]).filter(n=>typeof n==`string`);a.length>0&&(N=[...N,...a])}if(S){let a=(n[`--`]??[]).filter(n=>typeof n==`string`);a.length>0&&(C?N=[...N,...a]:(C=a[0],N=[...N,...a.slice(1)])),C||(ke.error("gjsify foreach --exec: missing command. Pass it after `--`, e.g. `gjsify foreach --exec -- npm publish --tag latest`."),process.exit(1))}let F=filterWorkspaces(a,{include:n.include,exclude:n.exclude,noPrivate:n.private===!1});if(!S){C||(ke.error(`gjsify foreach: missing <script> positional. Pass --exec to run an arbitrary command instead.`),process.exit(1));let n=C;F=F.filter(a=>typeof(a.manifest.scripts??{})[n]==`string`)}if(F.length===0){ke.log(`gjsify foreach: no workspaces match (${S?`exec`:`script`}="${C}", include=${JSON.stringify(n.include??[])}, exclude=${JSON.stringify(n.exclude??[])})`);return}(n.topological||n[`topological-dev`])&&(F=topologicalSort(buildDependencyGraph(F,{includeDev:n[`topological-dev`]===!0})));let I=n.verbose===!0,H=C;try{if(n.parallel&&!n.topological&&!n[`topological-dev`]){let a=n.jobs&&n.jobs>0?n.jobs:cpus().length;await runParallel(F,H,N,a,I,S)}else if(n.parallel){let a=n.jobs&&n.jobs>0?n.jobs:cpus().length;await runTopologicalParallel(F,H,N,a,I,n[`topological-dev`]===!0,S)}else await runSequential(F,H,N,I,S)}catch(n){killActiveChildren(),ke.error(n.message),process.exit(1)}process.exit(0)}},__name$1(runOne$1,`runOne`),__name$1(detectPackageManager$1,`detectPackageManager`)});function collectTransitiveClosure(n,a,S){let C=new Map;for(let n of a)C.set(n.name,n);let N=new Set,F=[],I=[n];for(;I.length>0;){let n=I.pop();if(N.has(n.name))continue;N.add(n.name),F.push(n);let a=n.manifest,H=[a.dependencies,S?a.devDependencies:void 0,a.optionalDependencies];for(let n of H)if(n)for(let[a,S]of Object.entries(n)){if(typeof S!=`string`||!S.startsWith(`workspace:`))continue;let n=C.get(a);n&&(N.has(n.name)||I.push(n))}}return F}async function runOne(n,a,S,C,N){let F=C===`gjsify`?[`run`,a,...S]:[`run`,a,...S.length>0?[`--`,...S]:[]];N&&ke.error(`[${n.name}] $ ${C} ${F.join(` `)}`);let I=process.env.FORCE_COLOR!==void 0||process.env.NO_COLOR!==void 0?{}:{FORCE_COLOR:`1`};await new Promise((a,S)=>{let N=spawn(C,F,{cwd:n.location,stdio:`inherit`,env:{...process.env,...I}});N.on(`close`,n=>{n===0?a():S(Error(`${C} ${F.join(` `)} exited with code ${n}`))}),N.on(`error`,S)})}function detectPackageManager(){let n=process.env.npm_config_user_agent??``;return n.startsWith(`yarn/`)?`yarn`:n.startsWith(`gjsify/`)?`gjsify`:`npm`}var UM,WM=__esmMin(()=>{Ae(),nC(),Ng(),Pg(),UM={command:`workspace <name> <script> [args..]`,description:"Run a workspace script (`yarn workspace <name> run <script>` equivalent).",builder:n=>n.positional(`name`,{description:"Workspace name (matches package.json `name` field).",type:`string`,demandOption:!0}).positional(`script`,{description:`Script name to run inside that workspace.`,type:`string`,demandOption:!0}).positional(`args`,{description:`Extra arguments forwarded to the script.`,type:`string`,array:!0}).option(`with-dependencies`,{description:"Pre-build the target workspace's transitive workspace dependencies in topological order before running the script in the target. Deps that don't declare the script are skipped (--if-present behaviour). Replaces manual `gjsify workspace A build && gjsify workspace B build && …` chains.",type:`boolean`,alias:[`d`,`t`,`topological`],default:!1}).option(`include-dev`,{description:"When --with-dependencies is set, also walk devDependencies (production deps only by default — matches `gjsify foreach -t`).",type:`boolean`,default:!1}).option(`continue-on-error`,{description:`When --with-dependencies is set, keep running remaining deps after one fails (default: stop on first failure).`,type:`boolean`,default:!1}).option(`verbose`,{description:`Echo every spawned command before running it.`,type:`boolean`,alias:`v`,default:!1}),handler:async n=>{let a=discoverWorkspaces(findWorkspaceRoot(process.cwd())??process.cwd()),S=a.find(a=>a.name===n.name);S||(ke.error(`gjsify workspace: no workspace named "${n.name}" — discovered ${a.length} workspace(s)`),process.exit(1));let C=detectPackageManager(),N=n.verbose===!0,F=n[`with-dependencies`]===!0,I=n[`continue-on-error`]===!0;typeof(S.manifest.scripts??{})[n.script]!=`string`&&(ke.error(`gjsify workspace: workspace "${n.name}" has no script "${n.script}"`),process.exit(1));let H;H=F?topologicalSort(buildDependencyGraph(collectTransitiveClosure(S,a,n[`include-dev`]===!0),{includeDev:n[`include-dev`]===!0})):[S];let W=[];for(let a of H){if(typeof(a.manifest.scripts??{})[n.script]!=`string`){N&&ke.error(`[${a.name}] (no "${n.script}" script — skipping)`);continue}try{await runOne(a,n.script,n.args??[],C,N)}catch(n){let S=n instanceof Error?n:Error(String(n));ke.error(`[${a.name}] ${S.message}`),I||process.exit(1),W.push({workspace:a.name,error:S})}}W.length>0&&(ke.error(`gjsify workspace: ${W.length} workspace(s) failed: ${W.map(n=>n.workspace).join(`, `)}`),process.exit(1)),process.exit(0)}}});async function runLifecycleScript(n,a,S,C={}){let N=(a.scripts??{})[S];if(typeof N!=`string`){if(C.optional!==!1)return!1;throw Error(`gjsify lifecycle-script: no "${S}" in ${n}/package.json`)}let F=findWorkspaceRoot(n),I=[Qo(n,`node_modules`,`.bin`)];F&&F!==n&&I.push(Qo(F,`node_modules`,`.bin`));let H=process.env.FORCE_COLOR!==void 0||process.env.NO_COLOR!==void 0?{}:{FORCE_COLOR:`1`},W={...process.env,...H,PATH:[...I,process.env.PATH??``].filter(Boolean).join(ss),npm_lifecycle_event:S,npm_package_name:a.name??``,npm_package_version:a.version??``,...C.env},K=C.stdio===`inherit-stderr`?[`inherit`,2,2]:C.stdio??`inherit`;return await new Promise((a,C)=>{let F=spawn(N,[],{cwd:n,env:W,stdio:K,shell:!0});F.on(`close`,N=>{N===0?a():C(Error(`gjsify lifecycle-script: "${S}" in ${n} exited with code ${N}`))}),F.on(`error`,C)}),!0}var GM=__esmMin(()=>{nC(),ls(),Pg()});async function packWorkspace(n,a={}){let S=Qo(n,`package.json`);if(!existsSync(S))throw Error(`gjsify pack: no package.json at ${n}`);let C=readFileSync(S,`utf-8`),N=JSON.parse(C),F=typeof N.name==`string`?N.name:``,I=typeof N.version==`string`?N.version:`0.0.0`;if(!F)throw Error(`gjsify pack: package.json at ${n} has no "name"`);let H=a.lifecycleScripts??[`prepack`];for(let S of H)await runLifecycleScript(n,N,S,{optional:!0,stdio:a.lifecycleStdio});let W=readFileSync(S,`utf-8`),K=W===C?N:JSON.parse(W),q=a.skipWorkspaceRewrite?K:rewriteWorkspaceDeps(K,n),Y=JSON.stringify(q,null,indentOf(W))+`
|
|
800
800
|
`,X=collectFiles(n,K),te=[{name:`package/`,directory:!0,mode:493}],ne=[],re=0;for(let a of X){let S;S=a===`package.json`?new TextEncoder().encode(Y):new Uint8Array(readFileSync(Qo(n,a)));let C=statSync(Qo(n,a)).mode&511;te.push({name:`package/${a}`,body:S,mode:C,mtime:0}),ne.push({path:a,size:S.byteLength,mode:C}),re+=S.byteLength}let ie=await gzip(createTarball(te)),ae=`${F.startsWith(`@`)?F.slice(1).replace(`/`,`-`):F}-${I}.tgz`,oe=createHash(`sha1`).update(ie).digest(`hex`),Z=`sha512-${createHash(`sha512`).update(ie).digest(`base64`)}`,se=a.destination?Yo(a.destination):n,ce=Qo(se,ae);return a.dryRun||(mkdirSync(se,{recursive:!0}),writeFileSync(ce,ie)),{filename:ae,name:F,version:I,size:ie.byteLength,unpackedSize:re,shasum:oe,integrity:Z,entryCount:ne.length,files:ne,absolutePath:a.dryRun?null:ce}}function collectFiles(n,a){let S=forceIncluded(a),C=Array.isArray(a.files)?a.files.filter(n=>typeof n==`string`):null,N;N=C?expandFilesPatterns(n,C):walkAll(n);let F=loadIgnore(n),I=new Set;for(let n of N)F(n)||I.add(n);for(let a of S)existsSync(Qo(n,a))&&I.add(a);return[...I].sort()}function forceIncluded(n){let a=new Set;a.add(`package.json`);for(let n of[`README`,`README.md`,`LICENSE`,`LICENSE.md`,`NOTICE`,`NOTICE.md`])a.add(n);let S=typeof n.main==`string`?n.main:null;S&&a.add(S.replace(/^\.\//,``));let C=n.bin;if(typeof C==`string`)a.add(C.replace(/^\.\//,``));else if(C&&typeof C==`object`)for(let n of Object.values(C))typeof n==`string`&&a.add(n.replace(/^\.\//,``));return[...a]}function walkAll(n,a=``){let S=[],C=a?Qo(n,a):n,N;try{N=readdirSync(C,{withFileTypes:!0})}catch{return S}for(let C of N){if(qM.has(C.name)||C.name.startsWith(`.tsbuildinfo`))continue;let N=a?`${a}/${C.name}`:C.name;C.isDirectory()?S.push(...walkAll(n,N)):C.isFile()&&S.push(N)}return S}function expandFilesPatterns(n,a){let S=new Set,C=null;for(let N of a){let a=N.replace(/^\.\//,``).replace(/\/$/,``);if(!a)continue;if(!/[*?[\]]/.test(a)){let C=Qo(n,a);if(!existsSync(C))continue;let N=statSync(C);if(N.isDirectory())for(let C of walkAll(n,a))S.add(C);else N.isFile()&&S.add(a);continue}C??=walkAll(n);let F=filesGlobToRegExp(a),I=filesGlobToRegExp(`${a}/**`);for(let n of C)(F.test(n)||I.test(n))&&S.add(n)}return[...S]}function filesGlobToRegExp(n){let a=`^`;for(let S=0;S<n.length;S++){let C=n[S];if(C===`*`)n[S+1]===`*`?(a+=`.*`,S++,n[S+1]===`/`&&S++):a+=`[^/]*`;else if(C===`?`)a+=`[^/]`;else if(C===`[`){let C=S+1,N=`[`;for(n[C]===`!`&&(N+=`^`,C++);C<n.length&&n[C]!==`]`;C++)N+=n[C];C<n.length?(a+=`${N}]`,S=C):a+=`\\[`}else ".+^${}()|\\]".includes(C)?a+=`\\${C}`:a+=C}return RegExp(`${a}$`)}function loadIgnore(n){let a=Qo(n,`.npmignore`),S=Qo(n,`.gitignore`),C=[],N=existsSync(a)?a:existsSync(S)?S:null;if(N){let n=readFileSync(N,`utf-8`).split(`
|
|
801
|
-
`);for(let a of n){let n=a.trim();!n||n.startsWith(`#`)||n.startsWith(`!`)||C.push(globToRegex(n))}}return n=>{for(let a of C)if(a.test(n))return!0;return!1}}function globToRegex(n){let a=n.replace(/^\//,``);return a=a.replace(/[.+^${}()|[\]\\]/g,`\\$&`),a=a.replace(/\*\*/g,`__DOUBLESTAR__`).replace(/\*/g,`[^/]*`).replace(/__DOUBLESTAR__/g,`.*`),a=a.replace(/\?/g,`[^/]`),RegExp(`^${a}($|/)`)}function rewriteWorkspaceDeps(n,a){let S=findWorkspaceRoot(a);if(!S)return n;let C=new Map;for(let n of discoverWorkspaces(S))n.name&&n.version&&C.set(n.name,n.version);let N=JSON.parse(JSON.stringify(n));for(let n of[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`]){let a=N[n];if(a)for(let[n,F]of Object.entries(a)){if(typeof F!=`string`||!F.startsWith(`workspace:`))continue;let I=C.get(n);if(!I)throw Error(`gjsify pack: ${N.name} declares workspace:^ on ${n} but no sibling workspace with that name exists in the monorepo at ${S}`);let H=F.slice(10);H===`*`||H===``?a[n]=I:H===`^`||H===`~`?a[n]=`${H}${I}`:a[n]=H}}return N}function indentOf(n){let a=n.match(/\n([ \t]+)"/);return a?a[1]:` `}var KM,qM,JM=__esmMin(()=>{Jc(),to(),ls(),yM(),Ng(),Pg(),GM(),KM={command:`pack [path]`,description:`Produce an npm-compatible .tgz tarball for the workspace at <path> (default: cwd). Rewrites workspace:^/~/* deps to resolved versions.`,builder:n=>n.positional(`path`,{description:`Workspace path (default: cwd).`,type:`string`}).option(`pack-destination`,{description:`Directory to write the tarball into. Default: workspace cwd.`,type:`string`}).option(`json`,{description:"Emit pack metadata as JSON on stdout (mirrors `npm pack --json`).",type:`boolean`,default:!1}).option(`dry-run`,{description:`Compute everything but do not write the .tgz.`,type:`boolean`,default:!1}).option(`ignore-scripts`,{description:"Skip the `prepack` lifecycle script before packing. Mirrors `npm pack --ignore-scripts`. Use when scripts are already run by the outer workflow.",type:`boolean`,default:!1}),handler:async n=>{let a=await packWorkspace(Yo(n.path??process.cwd()),{destination:n[`pack-destination`],dryRun:n[`dry-run`]===!0,lifecycleScripts:n[`ignore-scripts`]?[]:[`prepack`],lifecycleStdio:n.json?`inherit-stderr`:`inherit`});n.json?process.stdout.write(`${JSON.stringify([a],null,2)}\n`):process.stdout.write(`${a.filename}\n`)}},qM=new Set([`.git`,`.svn`,`.hg`,`.gitignore`,`.gitattributes`,`.npmrc`,`CVS`,`.DS_Store`,`node_modules`,`.npmignore`,`package-lock.json`,`gjsify-lock.json`,`yarn.lock`,`yarn-error.log`,`.yarn`,`.pnp.cjs`,`.pnp.loader.mjs`,`tsconfig.tsbuildinfo`])});function decodeJwtPayload(n){let a=n.split(`.`);if(a.length!==3)return null;try{let n=a[1].replace(/-/g,`+`).replace(/_/g,`/`),S=typeof atob==`function`?atob(n):Buffer.from(n,`base64`).toString(`binary`);return JSON.parse(S)}catch{return null}}function hasGithubOidcEnv(){return!!(process.env.ACTIONS_ID_TOKEN_REQUEST_URL&&process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN)}async function fetchGithubOidcToken(n,a){let S=process.env.ACTIONS_ID_TOKEN_REQUEST_URL,C=process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN;if(!S||!C)throw new OidcUnavailableError("GitHub Actions OIDC env vars (ACTIONS_ID_TOKEN_REQUEST_{URL,TOKEN}) not set. The calling workflow needs `permissions: id-token: write`.",`no-env`);let N=`${S}${S.includes(`?`)?`&`:`?`}audience=${encodeURIComponent(n)}`;a?.(`gjsify oidc: GET ${N.replace(C,`<bearer>`)}`);let F=await fetch(N,{method:`GET`,headers:{Accept:`application/json`,Authorization:`Bearer ${C}`}});if(!F.ok){let n=await F.text().catch(()=>`<no body>`);throw new OidcUnavailableError(`Failed to fetch GitHub OIDC id_token: ${F.status} ${F.statusText} — ${n.slice(0,200)}`,`fetch-id-token`)}let I=await F.json().catch(()=>({}));if(!I.value)throw new OidcUnavailableError("GitHub OIDC response missing `value` field",`no-id-token`);return I.value}async function exchangeOidcForNpmToken(n){let{packageName:a,registry:S,idToken:C,log:N}=n,F=`${S.endsWith(`/`)?S.slice(0,-1):S}/-/npm/v1/oidc/token/exchange/package/${a.startsWith(`@`)?(()=>{let n=a.indexOf(`/`),S=a.slice(1,n),C=a.slice(n+1);return`@${encodeURIComponent(S)}%2f${encodeURIComponent(C)}`})():encodeURIComponent(a)}`;N?.(`gjsify oidc: POST ${F}`);let I=await fetch(F,{method:`POST`,headers:{Authorization:`Bearer ${C}`,"Content-Type":`application/json`,Accept:`application/json`},body:`{}`}),H=await I.text().catch(()=>``);if(!I.ok)throw new OidcExchangeError(`npm OIDC token exchange failed for ${a}: ${I.status} ${I.statusText} — ${H.slice(0,300)}`,I.status,H,a,decodeJwtPayload(C)??void 0);let W;try{W=JSON.parse(H)}catch{throw new OidcExchangeError(`npm OIDC token exchange returned non-JSON body for ${a}: ${H.slice(0,200)}`,I.status,H,a)}if(!W.token)throw new OidcExchangeError(`npm OIDC token exchange returned no \`token\` field for ${a}`,I.status,H,a);return W.token}async function getNpmTrustedToken(n){let a=`npm:${new URL(n.registry).hostname}`,S=await fetchGithubOidcToken(a,n.log);return{token:await exchangeOidcForNpmToken({...n,idToken:S}),audience:a}}var OidcUnavailableError,OidcExchangeError,
|
|
801
|
+
`);for(let a of n){let n=a.trim();!n||n.startsWith(`#`)||n.startsWith(`!`)||C.push(globToRegex(n))}}return n=>{for(let a of C)if(a.test(n))return!0;return!1}}function globToRegex(n){let a=n.replace(/^\//,``);return a=a.replace(/[.+^${}()|[\]\\]/g,`\\$&`),a=a.replace(/\*\*/g,`__DOUBLESTAR__`).replace(/\*/g,`[^/]*`).replace(/__DOUBLESTAR__/g,`.*`),a=a.replace(/\?/g,`[^/]`),RegExp(`^${a}($|/)`)}function rewriteWorkspaceDeps(n,a){let S=findWorkspaceRoot(a);if(!S)return n;let C=new Map;for(let n of discoverWorkspaces(S))n.name&&n.version&&C.set(n.name,n.version);let N=JSON.parse(JSON.stringify(n));for(let n of[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`]){let a=N[n];if(a)for(let[n,F]of Object.entries(a)){if(typeof F!=`string`||!F.startsWith(`workspace:`))continue;let I=C.get(n);if(!I)throw Error(`gjsify pack: ${N.name} declares workspace:^ on ${n} but no sibling workspace with that name exists in the monorepo at ${S}`);let H=F.slice(10);H===`*`||H===``?a[n]=I:H===`^`||H===`~`?a[n]=`${H}${I}`:a[n]=H}}return N}function indentOf(n){let a=n.match(/\n([ \t]+)"/);return a?a[1]:` `}var KM,qM,JM=__esmMin(()=>{Jc(),to(),ls(),yM(),Ng(),Pg(),GM(),KM={command:`pack [path]`,description:`Produce an npm-compatible .tgz tarball for the workspace at <path> (default: cwd). Rewrites workspace:^/~/* deps to resolved versions.`,builder:n=>n.positional(`path`,{description:`Workspace path (default: cwd).`,type:`string`}).option(`pack-destination`,{description:`Directory to write the tarball into. Default: workspace cwd.`,type:`string`}).option(`json`,{description:"Emit pack metadata as JSON on stdout (mirrors `npm pack --json`).",type:`boolean`,default:!1}).option(`dry-run`,{description:`Compute everything but do not write the .tgz.`,type:`boolean`,default:!1}).option(`ignore-scripts`,{description:"Skip the `prepack` lifecycle script before packing. Mirrors `npm pack --ignore-scripts`. Use when scripts are already run by the outer workflow.",type:`boolean`,default:!1}),handler:async n=>{let a=await packWorkspace(Yo(n.path??process.cwd()),{destination:n[`pack-destination`],dryRun:n[`dry-run`]===!0,lifecycleScripts:n[`ignore-scripts`]?[]:[`prepack`],lifecycleStdio:n.json?`inherit-stderr`:`inherit`});n.json?process.stdout.write(`${JSON.stringify([a],null,2)}\n`):process.stdout.write(`${a.filename}\n`)}},qM=new Set([`.git`,`.svn`,`.hg`,`.gitignore`,`.gitattributes`,`.npmrc`,`CVS`,`.DS_Store`,`node_modules`,`.npmignore`,`package-lock.json`,`gjsify-lock.json`,`yarn.lock`,`yarn-error.log`,`.yarn`,`.pnp.cjs`,`.pnp.loader.mjs`,`tsconfig.tsbuildinfo`])});function escapePackageName(n){return n.replace(`/`,`%2f`)}function buildPublishHeaders(n,a){let S=buildHeaders(n,{npmrc:a.npmrc});return S[`content-type`]=`application/json`,S[`npm-command`]=`publish`,S[`npm-auth-type`]=a.otp?`legacy`:`web`,S[`user-agent`]=a.userAgent??defaultUserAgent(),a.otp&&(S[`npm-otp`]=a.otp),a.authorization&&(S.authorization=a.authorization),S}function defaultUserAgent(){let n=globalThis.process,a=n?.arch??`x64`;return`gjsify-publish/0.5.0 (${n?.platform??`linux`} ${a})`}var YM=__esmMin(()=>{mM()});function decodeJwtPayload(n){let a=n.split(`.`);if(a.length!==3)return null;try{let n=a[1].replace(/-/g,`+`).replace(/_/g,`/`),S=typeof atob==`function`?atob(n):Buffer.from(n,`base64`).toString(`binary`);return JSON.parse(S)}catch{return null}}function hasGithubOidcEnv(){return!!(process.env.ACTIONS_ID_TOKEN_REQUEST_URL&&process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN)}async function fetchGithubOidcToken(n,a){let S=process.env.ACTIONS_ID_TOKEN_REQUEST_URL,C=process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN;if(!S||!C)throw new OidcUnavailableError("GitHub Actions OIDC env vars (ACTIONS_ID_TOKEN_REQUEST_{URL,TOKEN}) not set. The calling workflow needs `permissions: id-token: write`.",`no-env`);let N=`${S}${S.includes(`?`)?`&`:`?`}audience=${encodeURIComponent(n)}`;a?.(`gjsify oidc: GET ${N.replace(C,`<bearer>`)}`);let F=await fetch(N,{method:`GET`,headers:{Accept:`application/json`,Authorization:`Bearer ${C}`}});if(!F.ok){let n=await F.text().catch(()=>`<no body>`);throw new OidcUnavailableError(`Failed to fetch GitHub OIDC id_token: ${F.status} ${F.statusText} — ${n.slice(0,200)}`,`fetch-id-token`)}let I=await F.json().catch(()=>({}));if(!I.value)throw new OidcUnavailableError("GitHub OIDC response missing `value` field",`no-id-token`);return I.value}async function exchangeOidcForNpmToken(n){let{packageName:a,registry:S,idToken:C,log:N}=n,F=`${S.endsWith(`/`)?S.slice(0,-1):S}/-/npm/v1/oidc/token/exchange/package/${a.startsWith(`@`)?(()=>{let n=a.indexOf(`/`),S=a.slice(1,n),C=a.slice(n+1);return`@${encodeURIComponent(S)}%2f${encodeURIComponent(C)}`})():encodeURIComponent(a)}`;N?.(`gjsify oidc: POST ${F}`);let I=await fetch(F,{method:`POST`,headers:{Authorization:`Bearer ${C}`,"Content-Type":`application/json`,Accept:`application/json`},body:`{}`}),H=await I.text().catch(()=>``);if(!I.ok)throw new OidcExchangeError(`npm OIDC token exchange failed for ${a}: ${I.status} ${I.statusText} — ${H.slice(0,300)}`,I.status,H,a,decodeJwtPayload(C)??void 0);let W;try{W=JSON.parse(H)}catch{throw new OidcExchangeError(`npm OIDC token exchange returned non-JSON body for ${a}: ${H.slice(0,200)}`,I.status,H,a)}if(!W.token)throw new OidcExchangeError(`npm OIDC token exchange returned no \`token\` field for ${a}`,I.status,H,a);return W.token}async function getNpmTrustedToken(n){let a=`npm:${new URL(n.registry).hostname}`,S=await fetchGithubOidcToken(a,n.log);return{token:await exchangeOidcForNpmToken({...n,idToken:S}),audience:a}}var OidcUnavailableError,OidcExchangeError,XM=__esmMin(()=>{OidcUnavailableError=class extends Error{reason;constructor(n,a){super(n),this.reason=a,this.name=`OidcUnavailableError`}},OidcExchangeError=class extends Error{status;body;packageName;claims;constructor(n,a,S,C,N){super(n),this.status=a,this.body=S,this.packageName=C,this.claims=N,this.name=`OidcExchangeError`}}});async function diagnose404(n){let{packageName:a,version:S,registry:C,npmrc:N}=n,F={};try{F=await whoami(C,N)}catch{return{reason:`unknown`,message:formatUnknown(a,S)}}return F.username&&F.username.length>0?{reason:`live-token-404`,username:F.username,message:formatLiveToken404(a,S,F.username)}:{reason:`dead-token`,message:formatDeadToken(a,S)}}function formatDeadToken(n,a){return[`gjsify publish: ${n}@${a} — 404 Not Found`,``,`The npm token in ~/.npmrc appears to be revoked or expired (the /-/whoami probe`,`returned {} instead of {"username": "..."}). The 404 is npm's response to a PUT`,`authenticated with an invalid bearer token.`,``,`To refresh:`,` npm login`,` # or, future: gjsify login (tracked as project_gjsify_login_goal)`,``,`Then verify before publishing:`,` curl -s -H "Authorization: Bearer $(grep registry.npmjs.org ~/.npmrc | sed 's|.*=||')" \\`,` https://registry.npmjs.org/-/whoami`,` # Healthy: {"username":"<you>"}`,` # Dead: {}`].join(`
|
|
802
802
|
`)}function formatLiveToken404(n,a,S){return[`gjsify publish: ${n}@${a} — 404 Not Found`,``,`Authenticated as: ${S}`,``,`Your token authenticates, so this is NOT a dead-token problem. The package`,`${n} is not (yet) on npmjs.com. Two cases:`,``,` 1. First publish of a brand-new scoped package — do the one-time bootstrap`,` (see AGENTS.md > "New @gjsify/* package: first-publish + Trusted`,` Publisher bootstrap"). The npm registry can also 404 *transiently*`,` while provisioning a brand-new package: simply re-run, or do the very`," first publish with `npm publish` (then configure the Trusted Publisher)."," 2. You lack publish access to the scope — verify with `npm access ls-packages`."].join(`
|
|
803
|
-
`)}function formatUnknown(n,a){return`gjsify publish: ${n}@${a} — 404 Not Found`}function is404DiagnosticCandidate(n){let a=n.trim();return!!(a.length===0||/^not found$/i.test(a)||/"error"\s*:\s*"Not Found"/i.test(a))}var
|
|
804
|
-
`).replace(/\$\{([A-Z_][A-Z0-9_]*)\}/gi,(n,a)=>process.env[a]??``))}function hasAnyAuthToken(n){return Object.keys(n.authTokens).length>0}function hasAnyCredential(n){return hasAnyAuthToken(n)||Object.keys(n.basicAuth).length>0}var
|
|
805
|
-
`);C>=0&&(cleanup(),n(a.slice(0,C).trim()))},onEnd=()=>{cleanup(),n(a.trim())},onError=()=>{cleanup(),n(``)},cleanup=()=>{process.stdin.removeListener(`data`,onData),process.stdin.removeListener(`end`,onEnd),process.stdin.removeListener(`error`,onError),typeof process.stdin.unref==`function`&&process.stdin.unref?.()};process.stdin.setEncoding(`utf-8`),process.stdin.isPaused()&&process.stdin.resume(),process.stdin.once(`data`,onData),process.stdin.once(`end`,onEnd),process.stdin.once(`error`,onError)})}function handleOidcFailure(n,a,S){if(n instanceof OidcUnavailableError){let C=`gjsify publish: OIDC not available — ${n.message}`;S?process.stdout.write(`${JSON.stringify({ok:!1,name:a,error:`oidc-unavailable`,reason:n.reason,message:n.message})}\n`):process.stderr.write(`${C}\n`);return}if(n instanceof OidcExchangeError){let C=n.status===401||n.status===403?`npm rejected the OIDC exchange (${n.status}) — check that ${a} has a Trusted Publisher configured at https://www.npmjs.com/package/${encodeURIComponent(a)}/access pointing at this workflow.`:n.message;if(S)process.stdout.write(`${JSON.stringify({ok:!1,name:a,error:`oidc-exchange`,status:n.status,body:n.body,claims:n.claims,message:n.message})}\n`);else if(process.stderr.write(`✗ ${a}: ${C}\n`),n.body&&process.stderr.write(` ↳ npm said: ${n.body.slice(0,300)}\n`),n.claims){let a=n.claims,S=[`aud`,`iss`,`repository`,`repository_owner`,`workflow_ref`,`job_workflow_ref`,`ref`,`environment`,`sub`].filter(n=>a[n]!==void 0).map(n=>`${n}=${JSON.stringify(a[n])}`).join(`, `);S&&process.stderr.write(` ↳ JWT claims npm received: ${S}\n`)}return}let C=n instanceof Error?n.message:String(n);S?process.stdout.write(`${JSON.stringify({ok:!1,name:a,error:`unknown`,message:C})}\n`):process.stderr.write(`✗ ${a}: ${C}\n`)}var
|
|
806
|
-
Enter OTP: `);let n=await readLineFromStdin();n?pe=await doPut({...le,"npm-otp":n}):(ke.error("gjsify publish: no OTP entered — re-run with `--otp <code>`"),process.exit(1))}else ke.error("gjsify publish: npm requires a 2FA one-time code — re-run with `--otp <code>`"),process.exit(1)}if(pe.ok){let a={ok:!0,name:X.name,version:X.version,filename:X.filename,size:X.size,integrity:X.integrity,tag:S,registry:oe};n.json?process.stdout.write(`${JSON.stringify(a,null,2)}\n`):process.stdout.write(`+ ${X.name}@${X.version}\n`);return}let me=await pe.text().catch(()=>`<no body>`);if((pe.status===409||pe.status===403&&/previously published/i.test(me))&&F){let a={ok:!0,action:`republish-tolerated`,name:X.name,version:X.version,status:pe.status};n.json?process.stdout.write(`${JSON.stringify(a,null,2)}\n`):process.stdout.write(`= ${X.name}@${X.version} (already published, tolerated)\n`);return}if(pe.status===404&&de===`token`&&is404DiagnosticCandidate(me)){let a=await diagnose404({packageName:X.name,version:X.version,registry:oe,npmrc:ie});a.reason!==`unknown`&&(n.json?process.stdout.write(`${JSON.stringify({ok:!1,name:X.name,version:X.version,status:404,diagnostic:a.reason,username:a.username},null,2)}\n`):process.stderr.write(`${a.message}\n`),process.exit(1))}ke.error(`gjsify publish: ${X.name}@${X.version} — ${pe.status} ${pe.statusText}`),ke.error(me),process.exit(1)}}}),
|
|
803
|
+
`)}function formatUnknown(n,a){return`gjsify publish: ${n}@${a} — 404 Not Found`}function is404DiagnosticCandidate(n){let a=n.trim();return!!(a.length===0||/^not found$/i.test(a)||/"error"\s*:\s*"Not Found"/i.test(a))}var ZM=__esmMin(()=>{mM()});async function loadNpmrc(n){let a=[],S=Qo(n,`.npmrc`);existsSync(S)&&a.push(readFileSync(S,`utf-8`));let C=process.env.NPM_CONFIG_USERCONFIG;if(C&&existsSync(C))a.push(readFileSync(C,`utf-8`));else{let n=Qo(homedir(),`.npmrc`);existsSync(n)&&a.push(readFileSync(n,`utf-8`))}return parseNpmrc(a.join(`
|
|
804
|
+
`).replace(/\$\{([A-Z_][A-Z0-9_]*)\}/gi,(n,a)=>process.env[a]??``))}function hasAnyAuthToken(n){return Object.keys(n.authTokens).length>0}function hasAnyCredential(n){return hasAnyAuthToken(n)||Object.keys(n.basicAuth).length>0}var QM=__esmMin(()=>{Jc(),Vp(),ls(),mM()});async function packWorkspaceToBytes(n){let a=`/tmp/gjsify-publish-${process.pid}-${Date.now()}`,S=await packWorkspace(n,{destination:a,dryRun:!1,lifecycleScripts:[]});if(!S.absolutePath)throw Error(`gjsify publish: pack did not produce a file`);let C=new Uint8Array(readFileSync(S.absolutePath));try{(await Promise.resolve().then(()=>(Jc(),Gc))).rmSync(S.absolutePath)}catch{}try{(await Promise.resolve().then(()=>(Jc(),Gc))).rmdirSync(a)}catch{}return C}async function loadRewrittenManifest(n,a){let S=`/tmp/gjsify-publish-manifest-${process.pid}-${Date.now()}.tgz`,C=await packWorkspace(n,{destination:S.substring(0,S.lastIndexOf(`/`)),dryRun:!1}),{rmSync:N}=await Promise.resolve().then(()=>(Jc(),Gc));if(!C.absolutePath)throw Error(`gjsify publish: pack did not produce a file`);let{gunzip:F,parseTar:I}=await Promise.resolve().then(()=>(yM(),vM)),H=new Uint8Array(readFileSync(C.absolutePath));N(C.absolutePath);let W=await F(H);for(let n of I(W))if(n.name===`package/package.json`&&n.body)return JSON.parse(new TextDecoder().decode(n.body));return a}function buildPublishPayload(n){let{pkg:a,tag:S,access:C,tarballBytes:N,tarballUrl:F,packed:I,provenance:H}=n,W={...a,_id:`${I.name}@${I.version}`,dist:{integrity:I.integrity,shasum:I.shasum,tarball:F}};H&&(W._hasShrinkwrap=!1);let K={_id:I.name,name:I.name,description:typeof a.description==`string`?a.description:``,"dist-tags":{[S]:I.version},versions:{[I.version]:W},readme:``,_attachments:{[I.wireFilename]:{content_type:`application/octet-stream`,data:base64Encode(N),length:N.byteLength}}};return C&&(K.access=C),K}function base64Encode(n){let a=``,S=32768;for(let C=0;C<n.length;C+=S)a+=String.fromCharCode(...n.subarray(C,C+S));return btoa(a)}async function readLineFromStdin(){return new Promise(n=>{let a=``,onData=S=>{a+=typeof S==`string`?S:S.toString(`utf-8`);let C=a.indexOf(`
|
|
805
|
+
`);C>=0&&(cleanup(),n(a.slice(0,C).trim()))},onEnd=()=>{cleanup(),n(a.trim())},onError=()=>{cleanup(),n(``)},cleanup=()=>{process.stdin.removeListener(`data`,onData),process.stdin.removeListener(`end`,onEnd),process.stdin.removeListener(`error`,onError),typeof process.stdin.unref==`function`&&process.stdin.unref?.()};process.stdin.setEncoding(`utf-8`),process.stdin.isPaused()&&process.stdin.resume(),process.stdin.once(`data`,onData),process.stdin.once(`end`,onEnd),process.stdin.once(`error`,onError)})}function handleOidcFailure(n,a,S){if(n instanceof OidcUnavailableError){let C=`gjsify publish: OIDC not available — ${n.message}`;S?process.stdout.write(`${JSON.stringify({ok:!1,name:a,error:`oidc-unavailable`,reason:n.reason,message:n.message})}\n`):process.stderr.write(`${C}\n`);return}if(n instanceof OidcExchangeError){let C=n.status===401||n.status===403?`npm rejected the OIDC exchange (${n.status}) — check that ${a} has a Trusted Publisher configured at https://www.npmjs.com/package/${encodeURIComponent(a)}/access pointing at this workflow.`:n.message;if(S)process.stdout.write(`${JSON.stringify({ok:!1,name:a,error:`oidc-exchange`,status:n.status,body:n.body,claims:n.claims,message:n.message})}\n`);else if(process.stderr.write(`✗ ${a}: ${C}\n`),n.body&&process.stderr.write(` ↳ npm said: ${n.body.slice(0,300)}\n`),n.claims){let a=n.claims,S=[`aud`,`iss`,`repository`,`repository_owner`,`workflow_ref`,`job_workflow_ref`,`ref`,`environment`,`sub`].filter(n=>a[n]!==void 0).map(n=>`${n}=${JSON.stringify(a[n])}`).join(`, `);S&&process.stderr.write(` ↳ JWT claims npm received: ${S}\n`)}return}let C=n instanceof Error?n.message:String(n);S?process.stdout.write(`${JSON.stringify({ok:!1,name:a,error:`unknown`,message:C})}\n`):process.stderr.write(`✗ ${a}: ${C}\n`)}var $M,eN=__esmMin(()=>{Ae(),Jc(),ls(),mM(),YM(),JM(),XM(),ZM(),QM(),$M={command:`publish [path]`,description:"Pack + upload the workspace at <path> (default: cwd) to its npm registry. Drop-in for `npm publish` with workspace:^ rewrite handled automatically.",builder:n=>n.positional(`path`,{description:`Workspace path (default: cwd).`,type:`string`}).option(`tag`,{description:`Dist-tag to publish under. Default: latest.`,type:`string`,default:`latest`}).option(`access`,{description:"Package access — `public` or `restricted` (required for first publish of scoped packages on the public registry).",type:`string`}).option(`otp`,{description:"npm 2FA one-time code; sent as the `npm-otp` header. Required for manual publishes from a 2FA-enabled account.",type:`string`}).option(`tolerate-republish`,{description:'Treat "version already published" as success — covers both classic 409 Conflict and the npm OIDC-path 403 Forbidden + `"previously published"` body shape. Matches yarn `--tolerate-republish`.',type:`boolean`,default:!1}).option(`tolerate-untrusted-new`,{description:'Skip (exit 0) when OIDC token exchange returns `package not found` AND no fallback token is configured — i.e. a never-before-published `@scope/<name>` whose Trusted Publisher entry hasn\'t been set up on npmjs.com yet. Without this flag, one un-bootstrapped new package breaks the entire serialized `gjsify foreach publish` loop. Pair with `--tolerate-republish` in CI release workflows so a fresh-merged package gracefully skips its first CI publish, leaving the manual-bootstrap step to a maintainer (see AGENTS.md "New @gjsify/* package: first-publish + Trusted Publisher bootstrap").',type:`boolean`,default:!1}).option(`provenance`,{description:`Pass-through flag — recorded in the payload but no signing happens (gjsify doesn't ship a sigstore signer yet).`,type:`boolean`,default:!1}).option(`dry-run`,{description:`Pack only, do not PUT.`,type:`boolean`,default:!1}).option(`json`,{description:`Emit publish metadata as JSON on stdout.`,type:`boolean`,default:!1}).option(`trusted`,{description:"Authenticate via npm Trusted Publishing (OIDC): exchange the GitHub Actions id-token for a short-lived npm token. Pass `--trusted` to force this mode (errors if env vars missing). Omit to auto-detect: OIDC is used iff `ACTIONS_ID_TOKEN_REQUEST_URL`+`_TOKEN` are set AND no `_authToken` is present in the resolved npmrc; otherwise the long-lived token path is used. Requires the calling workflow to declare `permissions: id-token: write` AND the target package to have a Trusted Publisher configured on npmjs.com.",type:`boolean`,default:void 0}).option(`check-trusted`,{description:"Diagnostic mode: perform the OIDC id-token request + npm token exchange, report success/failure, then exit WITHOUT publishing. Useful as a bulk-verifier (e.g. via `gjsify foreach publish --check-trusted`) to confirm Trusted Publisher config across many packages.",type:`boolean`,default:!1}),handler:async n=>{let a=Yo(n.path??process.cwd()),S=n.tag??`latest`,C=n.access,N=n.otp,F=n[`tolerate-republish`]===!0,I=n[`tolerate-untrusted-new`]===!0,H=n.provenance===!0,W=n[`dry-run`]===!0,K=n[`check-trusted`]===!0,q=n.trusted,Y=!!process.env.GJSIFY_PUBLISH_DEBUG;if(H&&ke.warn(`gjsify publish: --provenance recorded but not signed (no sigstore integration yet).`),K){let S=Qo(a,`package.json`),C=JSON.parse(readFileSync(S,`utf-8`));if(typeof C.name!=`string`&&(process.stderr.write(`gjsify publish --check-trusted: ${S} has no \`name\` field\n`),process.exit(2)),C.private===!0){let a={ok:!0,action:`check-trusted`,name:C.name,skipped:`private`};n.json?process.stdout.write(`${JSON.stringify(a)}\n`):process.stdout.write(`- ${C.name}: skipped (private package)\n`);return}let N=await loadNpmrc(a),F=process.env.npm_config_registry??registryFor(C.name,N)??pM;try{await getNpmTrustedToken({packageName:C.name,registry:F,log:Y?n=>ke.error(n):void 0});let a={ok:!0,action:`check-trusted`,name:C.name,registry:F};n.json?process.stdout.write(`${JSON.stringify(a)}\n`):process.stdout.write(`✓ ${C.name}: trusted publisher OK\n`);return}catch(a){handleOidcFailure(a,C.name,n.json===!0);return}}let X=await packWorkspace(a,{dryRun:!0,lifecycleScripts:[`prepublishOnly`,`prepack`],lifecycleStdio:n.json?`inherit-stderr`:`inherit`}),te=await packWorkspaceToBytes(a),ne=readFileSync(Qo(a,`package.json`),`utf-8`),re=await loadRewrittenManifest(a,JSON.parse(ne));if(W){let a={ok:!0,action:`dry-run`,name:X.name,version:X.version,filename:X.filename,size:X.size,shasum:X.shasum,integrity:X.integrity};n.json?process.stdout.write(`${JSON.stringify(a,null,2)}\n`):process.stdout.write(`+ ${X.name}@${X.version} (dry-run, ${X.size} bytes, ${X.entryCount} files)\n`);return}let ie=await loadNpmrc(a),ae=process.env.npm_config_registry??registryFor(X.name,ie)??pM,oe=ae.endsWith(`/`)?ae.slice(0,-1):ae,Z=`${oe}/${escapePackageName(X.name)}`,se=`${X.name.includes(`/`)?X.name.slice(X.name.indexOf(`/`)+1):X.name}-${X.version}.tgz`,ce=buildPublishPayload({pkg:re,tag:S,access:C,tarballBytes:te,tarballUrl:`${oe}/${X.name}/-/${se}`,packed:{...X,wireFilename:se},provenance:H}),le=buildPublishHeaders(Z,{npmrc:ie,otp:N}),ue=q===!0||q===void 0&&hasGithubOidcEnv()&&!process.env.NODE_AUTH_TOKEN,de=`token`;if(ue)try{let{token:n,audience:a}=await getNpmTrustedToken({packageName:X.name,registry:ae,log:Y?n=>ke.error(n):void 0});le.authorization=`Bearer ${n}`,de=`oidc`,Y&&ke.error(`gjsify publish: OIDC token obtained (audience=${a})`)}catch(a){if(a instanceof OidcExchangeError&&a.status===404&&/package not found/i.test(a.body)&&I){let a=`${X.name}@${X.version} (skipped — no Trusted Publisher on npm, see AGENTS.md "New @gjsify/* package: first-publish + Trusted Publisher bootstrap")`;n.json?process.stdout.write(`${JSON.stringify({ok:!0,action:`skipped-untrusted-new`,name:X.name,version:X.version,reason:`no-trusted-publisher`},null,2)}\n`):process.stdout.write(`~ ${a}\n`);return}if(q===!0&&(handleOidcFailure(a,X.name,n.json===!0),process.exit(1)),Y){let n=a instanceof Error?a.message:String(a);ke.error(`gjsify publish: OIDC auto-detect failed (${n}) — falling back to token auth`)}}Y&&(ke.error(`gjsify publish: PUT ${Z} (${X.name}@${X.version})`),ke.error(` auth-mode: ${de}`),ke.error(` authorization: ${le.authorization?`(set)`:`(none)`}`),ke.error(` otp: ${le[`npm-otp`]?`(set)`:`(none)`}`),ke.error(` payload size: ${JSON.stringify(ce).length} bytes`));let fe=JSON.stringify(ce);async function doPut(n){return fetch(Z,{method:`PUT`,headers:n,body:fe})}let pe=await doPut(le);if(!N&&pe.status===401){let n=pe.headers.get(`www-authenticate`)??``,a=await pe.text().catch(()=>``);if(n.toLowerCase().split(/,\s*/).includes(`otp`)||/one-time pass/i.test(a))if(process.stdin.isTTY&&process.stdout.isTTY){process.stdout.write(`This operation requires a one-time password.
|
|
806
|
+
Enter OTP: `);let n=await readLineFromStdin();n?pe=await doPut({...le,"npm-otp":n}):(ke.error("gjsify publish: no OTP entered — re-run with `--otp <code>`"),process.exit(1))}else ke.error("gjsify publish: npm requires a 2FA one-time code — re-run with `--otp <code>`"),process.exit(1)}if(pe.ok){let a={ok:!0,name:X.name,version:X.version,filename:X.filename,size:X.size,integrity:X.integrity,tag:S,registry:oe};n.json?process.stdout.write(`${JSON.stringify(a,null,2)}\n`):process.stdout.write(`+ ${X.name}@${X.version}\n`);return}let me=await pe.text().catch(()=>`<no body>`);if((pe.status===409||pe.status===403&&/previously published/i.test(me))&&F){let a={ok:!0,action:`republish-tolerated`,name:X.name,version:X.version,status:pe.status};n.json?process.stdout.write(`${JSON.stringify(a,null,2)}\n`):process.stdout.write(`= ${X.name}@${X.version} (already published, tolerated)\n`);return}if(pe.status===404&&de===`token`&&is404DiagnosticCandidate(me)){let a=await diagnose404({packageName:X.name,version:X.version,registry:oe,npmrc:ie});a.reason!==`unknown`&&(n.json?process.stdout.write(`${JSON.stringify({ok:!1,name:X.name,version:X.version,status:404,diagnostic:a.reason,username:a.username},null,2)}\n`):process.stderr.write(`${a.message}\n`),process.exit(1))}ke.error(`gjsify publish: ${X.name}@${X.version} — ${pe.status} ${pe.statusText}`),ke.error(me),process.exit(1)}}}),tN,nN=__esmMin(()=>{mM(),QM(),tN={command:`whoami`,description:`Print the npm-registry username for the current ~/.npmrc token. Clear failure message when the token is dead, missing, or the registry is unreachable.`,builder:n=>n.option(`registry`,{description:`Registry URL to probe. Default: scope-aware lookup from .npmrc (falls back to ${pM}).`,type:`string`}).option(`json`,{description:"Emit `{username, registry}` (or `{error, registry}`) as a single-line JSON object.",type:`boolean`,default:!1}),handler:async n=>{let a=await loadNpmrc(process.cwd()),S=n.registry??process.env.npm_config_registry??a.registry??pM,C=S.endsWith(`/`)?S.slice(0,-1):S,N=n.json===!0;hasAnyCredential(a)||(N?process.stdout.write(`${JSON.stringify({error:`no-token-configured`,registry:C})}\n`):process.stderr.write([`gjsify whoami: no npm token configured.`,``,`No \`_authToken\` found in ~/.npmrc / $NPM_CONFIG_USERCONFIG / .npmrc for ${C}.`,``,`Add one via: npm login`,`Then verify: gjsify whoami`].join(`
|
|
807
807
|
`)+`
|
|
808
808
|
`),process.exit(1));let F;try{F=await whoami(S,a)}catch(n){let a=n instanceof Error?n.message:String(n);N?process.stdout.write(`${JSON.stringify({error:a,registry:C})}\n`):(process.stderr.write(`gjsify whoami: ${a}\n`),process.stderr.write(`Registry: ${C}\n`)),process.exit(1);return}if(F.username&&F.username.length>0){N?process.stdout.write(`${JSON.stringify({username:F.username,registry:C})}\n`):(process.stdout.write(`Logged in as: ${F.username}\n`),process.stdout.write(`Registry: ${C}\n`));return}N?process.stdout.write(`${JSON.stringify({error:`dead-token`,registry:C})}\n`):process.stderr.write([`gjsify whoami: token appears dead or revoked (registry returned an empty whoami response).`,``,`Refresh via: npm login`,`Then verify: gjsify whoami`,``,`For the @gjsify scope, see AGENTS.md > "New @gjsify/* package: first-publish + Trusted Publisher bootstrap".`].join(`
|
|
809
809
|
`)+`
|
|
@@ -812,21 +812,21 @@ Enter OTP: `);let n=await readLineFromStdin();n?pe=await doPut({...le,"npm-otp":
|
|
|
812
812
|
`)+`
|
|
813
813
|
`),S}function removeAuthToken(n){let a=userconfigNpmrcPath(),S=authTokenKey(n),C=readUserconfig(a);if(!C)return{path:a,removed:!1};let N=C.split(`
|
|
814
814
|
`),F=N.filter(n=>!n.replace(/\s+/g,``).startsWith(`${S}=`)),I=F.length!==N.length;return I&&writeUserconfig(a,F.join(`
|
|
815
|
-
`)),{path:a,removed:I}}var
|
|
815
|
+
`)),{path:a,removed:I}}var rN=__esmMin(()=>{Jc(),Vp(),ls()});async function promptLine(n){return process.stdout.write(n),readLine()}async function promptHidden(n){process.stdout.write(n);let a=process.stdin;return!a.isTTY||typeof a.setRawMode!=`function`?readLine():new Promise(n=>{let S=``;a.setRawMode(!0),a.resume(),a.setEncoding(`utf-8`);let onData=a=>{for(let C of a)if(C===`\r`||C===`
|
|
816
816
|
`){cleanup(),process.stdout.write(`
|
|
817
|
-
`),n(S);return}else C===
|
|
818
|
-
`),process.exit(130)):C===
|
|
819
|
-
`);C>=0&&(cleanup(),n(a.slice(0,C).replace(/\r$/,``)))},onEnd=()=>{cleanup(),n(a.replace(/\r$/,``).trim())},cleanup=()=>{process.stdin.removeListener(`data`,onData),process.stdin.removeListener(`end`,onEnd)};process.stdin.setEncoding(`utf-8`),typeof process.stdin.isPaused==`function`&&process.stdin.isPaused()&&process.stdin.resume(),process.stdin.on(`data`,onData),process.stdin.once(`end`,onEnd)})}var
|
|
820
|
-
Enter OTP: `),K||(ke.error(`gjsify login: no OTP entered.`),process.exit(1)),q=await putUser(``,K))}if(q.status===409){let n=await fetch(`${H}?write=true`,{headers:authHeaders(K)});if(n.ok){let a=await n.json().catch(()=>({}));for(let n of Object.keys(a))(!W[n]||n===`roles`)&&(W[n]=a[n]);W._rev&&(q=await putUser(`/-rev/${W._rev}`,K))}}if(q.status===400&&(ke.error(`gjsify login: there is no user with the username "${N}" on ${C}.`),process.exit(1)),!q.ok){let n=await q.text().catch(()=>`<no body>`);ke.error(`gjsify login: ${q.status} ${q.statusText} from ${C}\n${n.slice(0,400)}`),process.exit(1)}let Y=await q.json().catch(()=>({}));Y.token||(ke.error("gjsify login: the registry accepted the login but returned no token (unexpected response shape). Your registry may require the web-OAuth flow — use `npm login`."),process.exit(1));let X=writeAuthToken(C,Y.token),te=(await whoami(C,await loadNpmrc(process.cwd()))).username??N;n.json?process.stdout.write(`${JSON.stringify({username:te,registry:C})}\n`):process.stdout.write(`Logged in as ${te} on ${C}\n(token written to ${X})\n`)}}}),
|
|
821
|
-
`).find(n=>/^exec (?:gjs -m )?'/.test(n));if(!S)continue;let F=S.match(/'([^']+)'/);if(!F)continue;let I=F[1];(I.startsWith(a+`/`)||I===a)&&C.push(N)}catch(n){S&&ke.warn(` ? could not inspect ${N}: ${n.message}`)}}return C}var
|
|
822
|
-
No packages removed.`),process.exit(1))}}});function handleInit({cwd:n,force:a}){let writeOne=(S,C)=>{let N=Yo(n,S);if(existsSync(N)&&!a){ke.log(`[gjsify format] ${S} exists at ${N} — pass --force to overwrite.`);return}writeFileSync(N,C,`utf-8`),ke.log(`[gjsify format] wrote ${N}`)};writeOne(`.oxlintrc.json`,loadOxlintTemplate()),writeOne(`.oxfmtrc.json`,loadOxfmtTemplate()),ke.log("[gjsify format] Run `gjsify format --write .` to apply the formatter to the project.")}var
|
|
823
|
-
[gjsify upgrade --align] --dry-run: no files changed.`);return}let N=applyToFiles(C);ke.log(`\n✏️ updated ${C.length} dep(s) across ${N} package.json file(s).`)}async function resolveCandidateGroups(n,a,S,C){let N=[],F=0;async function worker(){for(;;){let I=F++;if(I>=n.length)return;let H=n[I];try{let n=(await fetchPackument(H.name,{npmrc:a}))[`dist-tags`]?.latest;if(!n){S&&ke.warn(` ${H.name}: no dist-tags.latest, skipping`);continue}let F=H.highestVersion;if(!F){S&&ke.warn(` ${H.name}: unable to parse any current range`);continue}let I=classifyDiff(F,n);if(I===`none`||C===`minor`&&I===`major`||C===`patch`&&(I===`major`||I===`minor`))continue;N.push({...H,latestVersion:n,diff:I})}catch(n){S&&ke.warn(` ${H.name}: fetch failed (${n.message})`)}}}return await Promise.all(Array.from({length:8},()=>worker())),N.sort((n,a)=>n.name.localeCompare(a.name)),N}function classifyDiff(n,a){let S=parse(n),C=parse(a);return!S||!C?`none`:S.major===C.major?S.minor===C.minor?S.patch===C.patch?(S.prerelease??[]).join(`.`)===(C.prerelease??[]).join(`.`)?`none`:`prerelease`:C.patch>S.patch?`patch`:`none`:C.minor>S.minor?`minor`:`none`:C.major>S.major?`major`:`none`}function colorForDiff(n){switch(n){case`major`:return
|
|
824
|
-
Select upgrades: comma- or space-separated indices, `+
|
|
817
|
+
`),n(S);return}else C===iN?(cleanup(),process.stdout.write(`
|
|
818
|
+
`),process.exit(130)):C===aN||C===oN?S.length>0&&(S=S.slice(0,-1),process.stdout.write(`\b \b`)):C>=` `&&(S+=C,process.stdout.write(`*`))},cleanup=()=>{a.setRawMode(!1),a.removeListener(`data`,onData),a.pause()};a.on(`data`,onData)})}function readLine(){return new Promise(n=>{let a=``,onData=S=>{a+=typeof S==`string`?S:S.toString(`utf-8`);let C=a.indexOf(`
|
|
819
|
+
`);C>=0&&(cleanup(),n(a.slice(0,C).replace(/\r$/,``)))},onEnd=()=>{cleanup(),n(a.replace(/\r$/,``).trim())},cleanup=()=>{process.stdin.removeListener(`data`,onData),process.stdin.removeListener(`end`,onEnd)};process.stdin.setEncoding(`utf-8`),typeof process.stdin.isPaused==`function`&&process.stdin.isPaused()&&process.stdin.resume(),process.stdin.on(`data`,onData),process.stdin.once(`end`,onEnd)})}var iN,aN,oN,sN=__esmMin(()=>{iN=``,aN=``,oN=`\b`}),cN,lN=__esmMin(()=>{Ae(),mM(),QM(),rN(),sN(),cN={command:`login`,description:"Log in to an npm registry (Node-free `npm login`). Prompts for username + password (hidden) and writes the token to ~/.npmrc. Use --otp for 2FA. Web-OAuth flow is not supported — this is npm's legacy credentials flow.",builder:n=>n.option(`registry`,{description:`Registry URL to log in to. Default: ${pM} (or a --scope's registry).`,type:`string`}).option(`scope`,{description:`Associate the login with a scope (e.g. @gjsify) — resolves that scope's registry from .npmrc.`,type:`string`}).option(`username`,{description:`Username (prompted if omitted).`,type:`string`}).option(`otp`,{description:`npm 2FA one-time code (prompted on demand if omitted).`,type:`string`}).option(`json`,{description:"Emit `{username, registry}` JSON on success.",type:`boolean`}),handler:async n=>{let a=await loadNpmrc(process.cwd()),S=n.registry??process.env.npm_config_registry??(n.scope?registryFor(n.scope.startsWith(`@`)?`${n.scope}/_`:`@${n.scope}/_`,a):void 0)??pM,C=S.endsWith(`/`)?S:`${S}/`,N=n.username??await promptLine(`Username: `);N||(ke.error(`gjsify login: a username is required.`),process.exit(1));let F=await promptHidden(`Password: `);F||(ke.error(`gjsify login: a password is required.`),process.exit(1));let I=`Basic ${btoa(`${N}:${F}`)}`,H=`${C}-/user/org.couchdb.user:${encodeURIComponent(N)}`,W={_id:`org.couchdb.user:${N}`,name:N,password:F,type:`user`,roles:[],date:void 0};function authHeaders(n){let a={authorization:I,"content-type":`application/json`,accept:`*/*`};return n&&(a[`npm-otp`]=n),a}async function putUser(n,a){return fetch(`${H}${n}`,{method:`PUT`,headers:authHeaders(a),body:JSON.stringify(W)})}let K=n.otp,q=await putUser(``,K);if(q.status===401&&!K){let n=(q.headers.get(`www-authenticate`)??``).toLowerCase(),a=await q.clone().text().catch(()=>``);(n.includes(`otp`)||/one-time pass/i.test(a))&&(K=await promptLine(`This operation requires a one-time password.
|
|
820
|
+
Enter OTP: `),K||(ke.error(`gjsify login: no OTP entered.`),process.exit(1)),q=await putUser(``,K))}if(q.status===409){let n=await fetch(`${H}?write=true`,{headers:authHeaders(K)});if(n.ok){let a=await n.json().catch(()=>({}));for(let n of Object.keys(a))(!W[n]||n===`roles`)&&(W[n]=a[n]);W._rev&&(q=await putUser(`/-rev/${W._rev}`,K))}}if(q.status===400&&(ke.error(`gjsify login: there is no user with the username "${N}" on ${C}.`),process.exit(1)),!q.ok){let n=await q.text().catch(()=>`<no body>`);ke.error(`gjsify login: ${q.status} ${q.statusText} from ${C}\n${n.slice(0,400)}`),process.exit(1)}let Y=await q.json().catch(()=>({}));Y.token||(ke.error("gjsify login: the registry accepted the login but returned no token (unexpected response shape). Your registry may require the web-OAuth flow — use `npm login`."),process.exit(1));let X=writeAuthToken(C,Y.token),te=(await whoami(C,await loadNpmrc(process.cwd()))).username??N;n.json?process.stdout.write(`${JSON.stringify({username:te,registry:C})}\n`):process.stdout.write(`Logged in as ${te} on ${C}\n(token written to ${X})\n`)}}}),uN,dN=__esmMin(()=>{mM(),QM(),rN(),uN={command:`logout`,description:"Log out of an npm registry (Node-free `npm logout`). Revokes the token on the registry (best-effort) and removes it from ~/.npmrc.",builder:n=>n.option(`registry`,{description:`Registry URL to log out of. Default: ${pM} (or a --scope's registry).`,type:`string`}).option(`scope`,{description:`Log out of a scope's registry (e.g. @gjsify) — resolved from .npmrc.`,type:`string`}).option(`json`,{description:"Emit `{registry, revoked, removed}` JSON.",type:`boolean`}),handler:async n=>{let a=await loadNpmrc(process.cwd()),S=n.registry??process.env.npm_config_registry??(n.scope?registryFor(n.scope.startsWith(`@`)?`${n.scope}/_`:`@${n.scope}/_`,a):void 0)??pM,C=S.endsWith(`/`)?S:`${S}/`,N=resolveAuthForUrl(`${C}-/whoami`,a),F=!1;if(N?.startsWith(`Bearer `)){let n=N.slice(7);try{F=(await fetch(`${C}-/user/token/${encodeURIComponent(n)}`,{method:`DELETE`,headers:{authorization:N,accept:`*/*`}})).ok}catch{}}let{path:I,removed:H}=removeAuthToken(C);n.json?process.stdout.write(`${JSON.stringify({registry:C,revoked:F,removed:H})}\n`):H?process.stdout.write(`Logged out of ${C}${F?` (token revoked)`:``}\n(removed from ${I})\n`):process.stdout.write(`No token for ${C} found in ${I} — nothing to remove.\n`)}}});function readCurrentVersion(){try{let n=process.env.GJSIFY_CLI_PACKAGE_JSON;if(n){let a=JSON.parse(readFileSync(n,`utf-8`));return a.name===fN&&typeof a.version==`string`?a.version:null}let a=ts(Yo(fileURLToPath(import.meta.url)));for(let n=0;n<8&&a!==ts(a);n++){let n=Qo(a,`package.json`);if(existsSync(n)){let a=JSON.parse(readFileSync(n,`utf-8`));if(a.name===fN&&typeof a.version==`string`)return a.version}a=ts(a)}}catch{}return null}function resolveTag(n,a){let S=n[`dist-tags`]??{};return S[a]?S[a]:n.versions&&typeof n.versions==`object`&&n.versions[a]?a:null}var fN,pN,mN=__esmMin(()=>{Ae(),Jc(),ls(),fn(),mM(),jM(),PM(),fN=`@gjsify/cli`,pN={command:`self-update`,description:`Update the installed ${fN} to the latest release (or pinned --tag).`,builder:n=>n.option(`check`,{description:`Only check whether a newer version is available; do not install.`,type:`boolean`,default:!1}).option(`force`,{description:`Reinstall even when the current version already matches the target tag.`,type:`boolean`,default:!1}).option(`tag`,{description:"npm dist-tag or pinned version to install (e.g. `latest`, `next`, `0.5.0`).",type:`string`,default:`latest`}).option(`skip-deps`,{description:`Update only the @gjsify/cli bundle itself; do not pull its runtime dependencies (rolldown, lightningcss, @gjsify/tsc, the native gi:// bridges, …). Faster, but can leave the on-disk runtime deps stale relative to the new bundle.`,type:`boolean`,default:!1}),handler:async n=>{let a=defaultGlobalLayout(),S=Qo(Qo(a.prefix,`node_modules`,fN),`package.json`),C=readCurrentVersion(),N=existsSync(S);ke.log(`Current ${fN}: v${C??`(unknown)`}`),N||ke.warn(`\nWarning: no @gjsify/cli install found under ${a.prefix}.\nself-update only manages installs created by install.mjs or \`gjsify install -g\`.\nIf you installed via \`npm install -g\`, remove that and use:\n curl -fsSL https://github.com/gjsify/gjsify/releases/latest/download/install.mjs -o /tmp/g.mjs && gjs -m /tmp/g.mjs && rm /tmp/g.mjs`),ke.log(`Fetching dist-tags for ${fN}@${n.tag} ...`);let F;try{F=await fetchPackument(fN)}catch(n){let a=n instanceof Error?n.message:String(n);ke.error(`Failed to fetch packument: ${a}`),process.exit(1);return}let I=resolveTag(F,n.tag);if(!I){ke.error(`Unknown dist-tag '${n.tag}' on ${fN}. Known tags: ${Object.keys(F[`dist-tags`]??{}).join(`, `)||`(none)`}`),process.exit(1);return}if(ke.log(`Latest matching --tag ${n.tag}: v${I}`),C===I&&!n.force){ke.log(`Already up to date (v${I}).`),n.check||ke.log(`Run with --force to reinstall anyway.`);return}if(n.check){ke.log(C?`Update available: v${C} → v${I}`:`Install required: → v${I}`),process.exit(1);return}let H=!n.skipDeps,W=H?` + runtime dependencies`:` (bundle only)`;ke.log(`Installing ${fN}@${I}${W} ...`);try{await installPackages({prefix:a.prefix,specs:[`${fN}@${I}`],verbose:!1,skipDeps:!H})}catch(n){let a=n instanceof Error?n.message:String(n);ke.error(`self-update: install failed — ${a}`),ke.error("Re-run `gjsify self-update` to retry."),process.exit(1);return}let K=linkGlobalBins([fN],a);if(K.length===0)ke.warn("self-update: install completed but no bins were linked — package.json may be missing a `bin` field.");else for(let n of K)ke.log(` • ${n.link} → ${n.target}`);ke.log(`\nUpdated ${fN} to v${I}.`),H?ke.log(`Runtime dependencies were resolved alongside the bundle.`):ke.log(`Bundle-only update (--skip-deps): on-disk runtime dependencies were left unchanged.`)}}});function loadInstallerTemplate(){return readFileSync(new URL(`../templates/install.mjs.tmpl`,import.meta.url),`utf-8`)}function pickDefaultBinName(n,a){let S=n?.gjsify?.bin;if(S&&typeof S==`object`){let n=Object.keys(S)[0];if(n)return n}let C=n?.bin;if(C&&typeof C==`object`){let n=Object.keys(C)[0];if(n)return n}return a.startsWith(`@`)?a.slice(a.indexOf(`/`)+1):a}var hN,gN,_N=__esmMin(()=>{Ae(),Jc(),ls(),hN=`https://github.com/gjsify/gjsify/releases/latest/download/cli.gjs.mjs`,gN={command:`generate-installer [target]`,description:`Scaffold an install.mjs in the current directory for a GJS-runnable npm package.`,builder:n=>n.positional(`target`,{description:`Npm package name to install (default: current package.json name).`,type:`string`}).option(`bin-name`,{description:"Bin name produced by the installer (default: first key of `gjsify.bin` or `bin`).",type:`string`}).option(`bootstrap-url`,{description:`Override the cli.gjs.mjs bootstrap bundle URL (default: gjsify GitHub releases/latest).`,type:`string`}).option(`output`,{description:`Where to write the generated installer.`,type:`string`,default:`install.mjs`}).option(`force`,{description:`Overwrite an existing output file.`,type:`boolean`,default:!1}),handler:n=>{let a=Yo(process.cwd(),n.output);if(existsSync(a)&&!n.force){ke.error(`${n.output} already exists. Re-run with --force to overwrite.`),process.exit(1);return}let S=Yo(process.cwd(),`package.json`),C=null;if(existsSync(S))try{C=JSON.parse(readFileSync(S,`utf-8`))}catch{}let N=n.target??C?.name;if(!N){ke.error("No target package: pass `gjsify generate-installer <pkg>` or run inside a directory with a package.json."),process.exit(1);return}let F=n[`bin-name`]??pickDefaultBinName(C,N),I=n[`bootstrap-url`]??hN;writeFileSync(a,loadInstallerTemplate().replace(/const DEFAULT_TARGET = '[^']+';/,`const DEFAULT_TARGET = ${JSON.stringify(N)};`).replace(/const DEFAULT_BIN_NAME = '[^']+';/,`const DEFAULT_BIN_NAME = ${JSON.stringify(F)};`).replace(/const DEFAULT_BOOTSTRAP_URL =\s*'[^']+';/,`const DEFAULT_BOOTSTRAP_URL = ${JSON.stringify(I)};`),{mode:493}),ke.log(`Wrote ${n.output} (target=${N}, bin=${F}).`),ke.log(``),ke.log(`Install one-liner for your README:`),ke.log(` curl -fsSL https://github.com/<you>/<repo>/raw/main/${n.output} -o /tmp/i.mjs \\`),ke.log(` && gjs -m /tmp/i.mjs && rm /tmp/i.mjs`)}}});function findBinShimsForPackage(n,a,S){if(!existsSync(n))return[];let C=[],N;try{N=readdirSync(n)}catch{return[]}for(let F of N){let N=Qo(n,F);try{if(!statSync(N).isFile())continue;let n=readFileSync(N,`utf-8`);if(!n.startsWith(`#!/bin/sh`))continue;let S=n.split(`
|
|
821
|
+
`).find(n=>/^exec (?:gjs -m )?'/.test(n));if(!S)continue;let F=S.match(/'([^']+)'/);if(!F)continue;let I=F[1];(I.startsWith(a+`/`)||I===a)&&C.push(N)}catch(n){S&&ke.warn(` ? could not inspect ${N}: ${n.message}`)}}return C}var vN,yN=__esmMin(()=>{Ae(),Jc(),ls(),PM(),vN={command:`uninstall <packages..>`,description:"Uninstall a previously installed package. Currently only `--global` mode is supported.",builder:n=>n.positional(`packages`,{description:`Package(s) to uninstall (npm names, optionally with version).`,type:`string`,array:!0,demandOption:!0}).option(`global`,{description:`Uninstall from the user-global XDG location (the install -g target).`,type:`boolean`,alias:`g`,default:!1}).option(`dry-run`,{description:`Show what would be removed without touching the filesystem.`,type:`boolean`,default:!1}).option(`verbose`,{description:`Verbose logging.`,type:`boolean`,default:!1}),handler:n=>{if(!n.global){ke.error("gjsify uninstall currently only supports --global. For project-local removal, edit package.json + re-run `gjsify install`."),process.exit(1);return}let a=defaultGlobalLayout(),S=n[`dry-run`]??!1,C=n.verbose??!1,N=`gjsify uninstall${S?` (dry-run)`:``} --global`;ke.log(`${N} ← ${a.prefix}`),ke.log(`${` `.repeat(N.length)} bins ← ${a.binDir}`);let F=!1;for(let N of n.packages){let n=specToPackageName(N),I=Qo(a.prefix,`node_modules`,n);if(!existsSync(I)){ke.warn(` ✗ ${n} — not installed at ${I}`);continue}let H=findBinShimsForPackage(a.binDir,I,C);if(S){ke.log(` • would remove ${I}`);for(let n of H)ke.log(` • would remove ${n}`)}else{rmSync(I,{recursive:!0,force:!0}),ke.log(` • removed ${I}`);for(let n of H)unlinkSync(n),ke.log(` • removed ${n}`)}F=!0}F||(ke.error(`
|
|
822
|
+
No packages removed.`),process.exit(1))}}});function handleInit({cwd:n,force:a}){let writeOne=(S,C)=>{let N=Yo(n,S);if(existsSync(N)&&!a){ke.log(`[gjsify format] ${S} exists at ${N} — pass --force to overwrite.`);return}writeFileSync(N,C,`utf-8`),ke.log(`[gjsify format] wrote ${N}`)};writeOne(`.oxlintrc.json`,loadOxlintTemplate()),writeOne(`.oxfmtrc.json`,loadOxfmtTemplate()),ke.log("[gjsify format] Run `gjsify format --write .` to apply the formatter to the project.")}var bN,xN=__esmMin(()=>{Ae(),Jc(),ls(),kj(),bN={command:`format [paths..]`,description:`Format JS/TS source files via oxfmt (CSS/JSON formatting is not supported).`,builder:n=>n.positional(`paths`,{description:"Files or directories to format. Default: `.`",type:`string`,array:!0}).option(`write`,{description:`Modify files in place (default: report drift without writing).`,type:`boolean`,default:!1}).option(`check`,{description:`Report formatting drift without modifying files; exit non-zero if any file is unformatted. Useful for CI.`,type:`boolean`,default:!1}).option(`config-path`,{description:`Path to an .oxfmtrc.json. Default: walks up from cwd to find one.`,type:`string`,normalize:!0}).option(`init`,{description:`Write recommended .oxlintrc.json + .oxfmtrc.json into cwd (skips existing files unless --force).`,type:`boolean`,default:!1}).option(`force`,{description:`Overwrite existing .oxlintrc.json / .oxfmtrc.json with --init.`,type:`boolean`,default:!1}).option(`verbose`,{description:`Echo the resolved oxfmt launcher + args before spawning.`,type:`boolean`,default:!1}),handler:async n=>{let a=process.cwd();if(n.init){handleInit({cwd:a,force:n.force??!1});return}let S=n.paths?.length?n.paths:[`.`],C=[];n.check?C.push(`--check`):n.write?C.push(`--write`):C.push(`--list-different`);let N=n.configPath??findOxfmtConfig(a)??void 0;N&&C.push(`--config`,Yo(N)),C.push(...S);try{setOxcExitCode(await runOxfmt(C,{cwd:a,verbose:n.verbose}))}catch(n){if(n instanceof OxcNotFoundError){printOxcNotFound(n),setOxcExitCode(1);return}throw n}}}}),SN,CN=__esmMin(()=>{ls(),kj(),SN={command:`lint [paths..]`,description:`Run oxlint diagnostics (spawned via its Node launcher to support JS plugins).`,builder:n=>n.positional(`paths`,{description:"Files or directories to lint. Default: `.`",type:`string`,array:!0}).option(`fix`,{description:`Apply safe lint fixes in place.`,type:`boolean`,default:!1}).option(`config-path`,{description:`Path to an .oxlintrc.json. Default: walks up from cwd to find one.`,type:`string`,normalize:!0}).option(`verbose`,{description:`Echo the resolved oxlint launcher + args before spawning.`,type:`boolean`,default:!1}),handler:async n=>{let a=process.cwd(),S=n.paths?.length?n.paths:[`.`],C=[];n.fix&&C.push(`--fix`);let N=n.configPath??findOxlintConfig(a)??void 0;N&&C.push(`--config`,Yo(N)),C.push(...S);try{setOxcExitCode(await runOxlint(C,{cwd:a,verbose:n.verbose}))}catch(n){if(n instanceof OxcNotFoundError){printOxcNotFound(n),setOxcExitCode(1);return}throw n}}}}),wN,TN=__esmMin(()=>{ls(),kj(),wN={command:`fix [paths..]`,description:`Run oxfmt --write then oxlint --fix — format + safe lint fixes in one pass.`,builder:n=>n.positional(`paths`,{description:"Files or directories to fix. Default: `.`",type:`string`,array:!0}).option(`write`,{description:`Apply fixes in place (default: true). Pass --no-write to report only.`,type:`boolean`,default:!0}).option(`config-path`,{description:`Path to an .oxlintrc.json. Default: walks up from cwd to find one.`,type:`string`,normalize:!0}).option(`verbose`,{description:`Echo the resolved oxc launchers + args before spawning.`,type:`boolean`,default:!1}),handler:async n=>{let a=process.cwd(),S=n.paths?.length?n.paths:[`.`],C=n.verbose??!1,N=n.write!==!1;try{let F=[N?`--write`:`--list-different`],I=n.configPath??findOxfmtConfig(a)??void 0;I&&F.push(`--config`,Yo(I)),F.push(...S);let H=await runOxfmt(F,{cwd:a,verbose:C}),W=[];N&&W.push(`--fix`);let K=n.configPath??findOxlintConfig(a)??void 0;K&&W.push(`--config`,Yo(K)),W.push(...S);let q=await runOxlint(W,{cwd:a,verbose:C});setOxcExitCode(H||q)}catch(n){if(n instanceof OxcNotFoundError){printOxcNotFound(n),setOxcExitCode(1);return}throw n}}}});function createInterface(n,a){return typeof n==`object`&&n&&!(`read`in n&&typeof n.read==`function`)?new Interface(n):new Interface({input:n,output:a})}var Interface,EN=__esmMin(()=>{Ic(),Interface=class extends Interface$1{question(n,a){return new Promise(a=>{super.question(n,a)})}}});function semverGt(n,a){try{return compare(n,a)===1}catch{return!1}}function groupByDependency(n){let a=new Map;for(let S of n){let n=a.get(S.name);n||(n={name:S.name,occurrences:[],declaredRanges:new Set,dominantRange:S.currentRange,highestVersion:S.currentVersion},a.set(S.name,n)),n.occurrences.push(S),n.declaredRanges.add(S.currentRange),S.currentVersion&&(!n.highestVersion||semverGt(S.currentVersion,n.highestVersion))&&(n.highestVersion=S.currentVersion)}for(let n of a.values()){let a=new Map;for(let S of n.occurrences)a.set(S.currentRange,(a.get(S.currentRange)??0)+1);let S=n.occurrences[0].currentRange,C=-1,N=null;for(let[n,F]of a.entries()){let a=parse(n.replace(/^[\^~>=<]+/,``))?.version??null;(F>C||F===C&&a&&N&&semverGt(a,N)||F===C&&n<S)&&(S=n,C=F,N=a)}n.dominantRange=S}return[...a.values()].sort((n,a)=>n.name.localeCompare(a.name))}function isInconsistent(n){return n.declaredRanges.size>1}function findInconsistencies(n){return n.filter(isInconsistent)}var DN=__esmMin(()=>{fM()});function discoverContext(n){let a=findWorkspaceRoot(n);if(a)return{root:a,workspaces:discoverWorkspaces(a,{includeRoot:!0}),isMonorepo:!0};let S=Qo(n,`package.json`);if(!existsSync(S))throw Error(`[gjsify upgrade] no package.json at ${S}`);let C=JSON.parse(readFileSync(S,`utf-8`));return{root:n,workspaces:[{name:C.name??`<root>`,location:n,relativeLocation:`.`,version:C.version??`0.0.0`,manifest:C,private:C.private===!0}],isMonorepo:!1}}function applyWorkspaceFilter(n,a,S){let C=a?.split(`,`).map(n=>n.trim()).filter(Boolean),N=S?.split(`,`).map(n=>n.trim()).filter(Boolean);return(!C||C.length===0)&&(!N||N.length===0)?n:filterWorkspaces(n,{include:C,exclude:N})}function parseFilterList(n){return n?n.split(`,`).map(n=>n.trim().toLowerCase()).filter(Boolean):[]}function collectAllDeclarations(n,a){let S=[];for(let C of n)for(let n of collectFromWorkspace(C,a))S.push(n);return S}function collectFromWorkspace(n,a){let S=[],C=n.manifest;for(let N of kN){let F=C[N];if(!(!F||typeof F!=`object`))for(let[C,I]of Object.entries(F)){if(typeof I!=`string`||a.length&&!a.some(n=>C.toLowerCase().includes(n))||I.startsWith(`workspace:`)||I.startsWith(`file:`)||I.startsWith(`link:`)||I.startsWith(`git+`)||I.startsWith(`git:`)||I.startsWith(`http:`)||I.startsWith(`https:`)||I.startsWith(`npm:`)||I.startsWith(`portal:`))continue;let{prefix:F,version:H}=splitRange(I);S.push({workspace:n.name,workspaceLocation:n.location,name:C,field:N,currentRange:I,currentVersion:H,prefix:F})}}return S}function splitRange(n){let a=n.match(/^(\^|~|>=|<=|>|<|=)?\s*([0-9].*)$/);if(!a)return{prefix:``,version:null};let S=a[1]??``,C=a[2]?.split(/\s|[|&,]/)[0]??null;return{prefix:S,version:(C?parse(C):null)?.version??null}}function runCheckMode(n){let a=findInconsistencies(n);if(a.length===0){ke.log(`gjsify upgrade --check: OK. ${n.length} dep(s) consistently declared across workspaces.`);return}ke.error(`gjsify upgrade --check: FAIL. ${a.length} dep(s) declared at inconsistent ranges:\n`);for(let n of a){let a=new Map;for(let S of n.occurrences){let n=a.get(S.currentRange)??[];n.push(S.workspace),a.set(S.currentRange,n)}ke.error(` ${AN.bold}${n.name}${AN.reset}`);for(let[n,S]of a.entries())ke.error(` ${n.padEnd(16)} — ${S.join(`, `)}`)}ke.error("\nFix: run `gjsify upgrade --align` (offline; aligns each dep to its highest declared range)."),process.exit(1)}function runAlignMode(n,a){let S=findInconsistencies(n);if(S.length===0){ke.log(`gjsify upgrade --align: nothing to do. ${n.length} dep(s) already consistent.`);return}let C=[];for(let n of S){if(!n.highestVersion)continue;let a=n.occurrences.find(a=>a.currentRange===n.dominantRange)?.prefix||`^`;C.push({...n,latestVersion:n.highestVersion,diff:`none`,occurrences:n.occurrences.map(n=>({...n,prefix:a}))})}if(C.length===0){ke.log(`gjsify upgrade --align: inconsistencies present but no parseable target version. No-op.`);return}ke.log(`gjsify upgrade --align: aligning ${C.length} inconsistent dep(s) to their highest declared version:\n`);for(let n of C){let a=n.occurrences[0]?.prefix??`^`;ke.log(` ${n.name.padEnd(28)} ranges: ${[...n.declaredRanges].join(`, `)} → ${a}${n.latestVersion}`)}if(a.dryRun){ke.log(`
|
|
823
|
+
[gjsify upgrade --align] --dry-run: no files changed.`);return}let N=applyToFiles(C);ke.log(`\n✏️ updated ${C.length} dep(s) across ${N} package.json file(s).`)}async function resolveCandidateGroups(n,a,S,C){let N=[],F=0;async function worker(){for(;;){let I=F++;if(I>=n.length)return;let H=n[I];try{let n=(await fetchPackument(H.name,{npmrc:a}))[`dist-tags`]?.latest;if(!n){S&&ke.warn(` ${H.name}: no dist-tags.latest, skipping`);continue}let F=H.highestVersion;if(!F){S&&ke.warn(` ${H.name}: unable to parse any current range`);continue}let I=classifyDiff(F,n);if(I===`none`||C===`minor`&&I===`major`||C===`patch`&&(I===`major`||I===`minor`))continue;N.push({...H,latestVersion:n,diff:I})}catch(n){S&&ke.warn(` ${H.name}: fetch failed (${n.message})`)}}}return await Promise.all(Array.from({length:8},()=>worker())),N.sort((n,a)=>n.name.localeCompare(a.name)),N}function classifyDiff(n,a){let S=parse(n),C=parse(a);return!S||!C?`none`:S.major===C.major?S.minor===C.minor?S.patch===C.patch?(S.prerelease??[]).join(`.`)===(C.prerelease??[]).join(`.`)?`none`:`prerelease`:C.patch>S.patch?`patch`:`none`:C.minor>S.minor?`minor`:`none`:C.major>S.major?`major`:`none`}function colorForDiff(n){switch(n){case`major`:return AN.red;case`minor`:return AN.yellow;case`patch`:return AN.green;case`prerelease`:return AN.cyan;default:return``}}function printTable(n){let a=Math.max(...n.map(n=>n.name.length),4),S=Math.max(...n.map(n=>`${n.occurrences.length}`.length+2),3),C=Math.max(...n.map(n=>declaredCellWidth(n)),7),N=Math.max(...n.map(n=>n.latestVersion.length),6),F=String(n.length).length+2,I=` `.repeat(F+2)+AN.bold+`name`.padEnd(a)+` `+`fan`.padEnd(S)+` `+`declared`.padEnd(C)+` `+`latest`.padEnd(N)+` kind`+AN.reset;ke.log(I),ke.log(` `.repeat(F+2)+AN.dim+`─`.repeat(a+S+C+N+16)+AN.reset);for(let I=0;I<n.length;I++){let H=n[I],W=`${I+1}.`.padEnd(F),K=H.declaredRanges.size>1?`${AN.magenta}⚠ ${AN.reset}`:` `,q=colorForDiff(H.diff);ke.log(W+K+H.name.padEnd(a)+` `+AN.dim+`${H.occurrences.length}`.padEnd(S)+AN.reset+` `+AN.dim+renderDeclaredCell(H).padEnd(C)+AN.reset+` `+q+H.latestVersion.padEnd(N)+AN.reset+` `+q+H.diff+AN.reset)}let H=n.filter(n=>n.declaredRanges.size>1).length;H>0&&ke.log(`\n${AN.magenta}⚠${AN.reset} ${H} dep(s) declared at inconsistent ranges across workspaces.`)}function declaredCellWidth(n){return renderDeclaredCell(n).length}function renderDeclaredCell(n){if(n.declaredRanges.size===1)return[...n.declaredRanges][0];let a=[...n.declaredRanges].sort().join(`, `);return a.length<=32?a:a.slice(0,29)+`…`}function printChangePlan(n){for(let a of n)for(let n of a.occurrences)ke.log(` ${n.workspace.padEnd(38)} ${a.name.padEnd(28)} ${n.currentRange.padEnd(12)} → ${n.prefix}${a.latestVersion}`)}async function promptSelection(n){if(!process.stdin.isTTY)return ke.log(`[gjsify upgrade] non-TTY stdin: pass --latest / --minor / --patch (or --yes for interactive-all) to upgrade non-interactively.`),[];let a=createInterface({input:process.stdin,output:process.stdout});try{ke.log(`
|
|
824
|
+
Select upgrades: comma- or space-separated indices, `+AN.bold+`a`+AN.reset+` for all, ranges like `+AN.bold+`1-3`+AN.reset+`, or `+AN.bold+`ENTER`+AN.reset+` to skip:`);let S=(await a.question(`> `)).trim();if(!S)return[];if(S.toLowerCase()===`a`||S.toLowerCase()===`all`)return[...n];let C=new Set;for(let n of S.split(/[\s,]+/).filter(Boolean)){let a=n.match(/^(\d+)-(\d+)$/);if(a){let n=Number(a[1]),S=Number(a[2]);for(let a=Math.min(n,S);a<=Math.max(n,S);a++)C.add(a-1)}else /^\d+$/.test(n)&&C.add(Number(n)-1)}return[...C].filter(a=>a>=0&&a<n.length).map(a=>n[a])}finally{a.close()}}function applyToFiles(n){let a=new Map;for(let S of n)for(let n of S.occurrences){let C=a.get(n.workspaceLocation)??[];C.push({...S,occurrences:[n]}),a.set(n.workspaceLocation,C)}let S=0;for(let[n,C]of a.entries()){let a=Qo(n,`package.json`),N=readFileSync(a,`utf-8`),F=JSON.parse(N),I=!1;for(let n of C){let a=n.occurrences[0],S=F[a.field];if(!S)continue;let C=`${a.prefix}${n.latestVersion}`;S[n.name]!==C&&(S[n.name]=C,I=!0)}if(I){let n=detectIndent(N);writeFileSync(a,JSON.stringify(F,null,n)+(N.endsWith(`
|
|
825
825
|
`)?`
|
|
826
|
-
`:``),`utf-8`),S++}}return S}function uniqueLocations(n){let a=new Set;for(let S of n)for(let n of S.occurrences)a.add(n.workspaceLocation);return[...a]}function detectIndent(n){let a=n.match(/^\{\n( +)/);return a?a[1].length:2}async function loadNpmrcLight(n){let a={registry:pM,scopes:{},authTokens:{},basicAuth:{}};for(let S of[Qo(homedir(),`.npmrc`),Qo(n,`.npmrc`)])if(existsSync(S))try{let n=parseNpmrc(readFileSync(S,`utf-8`));a={...a,...n,scopes:{...a.scopes,...n.scopes}}}catch{}return process.env.npm_config_registry&&(a.registry=process.env.npm_config_registry),a}var
|
|
826
|
+
`:``),`utf-8`),S++}}return S}function uniqueLocations(n){let a=new Set;for(let S of n)for(let n of S.occurrences)a.add(n.workspaceLocation);return[...a]}function detectIndent(n){let a=n.match(/^\{\n( +)/);return a?a[1].length:2}async function loadNpmrcLight(n){let a={registry:pM,scopes:{},authTokens:{},basicAuth:{}};for(let S of[Qo(homedir(),`.npmrc`),Qo(n,`.npmrc`)])if(existsSync(S))try{let n=parseNpmrc(readFileSync(S,`utf-8`));a={...a,...n,scopes:{...a.scopes,...n.scopes}}}catch{}return process.env.npm_config_registry&&(a.registry=process.env.npm_config_registry),a}var ON,kN,AN,jN=__esmMin(()=>{Ae(),Jc(),ls(),Vp(),EN(),fM(),mM(),Ng(),Pg(),DN(),ON={command:`upgrade`,description:"Workspace-aware dependency upgrades. Walks every package.json in the monorepo, groups by dep, flags inconsistencies. `--latest` / `--minor` / `--patch` for bulk-mode, `--align` for offline consistency-only mode, `--check` for CI drift detection.",builder:n=>n.option(`latest`,{description:`Non-interactive: bump every dependency to its latest version (allows major).`,type:`boolean`,default:!1}).option(`minor`,{description:`Non-interactive: bump every dependency to the latest within the same major (semver-minor + semver-patch).`,type:`boolean`,default:!1}).option(`patch`,{description:`Non-interactive: bump every dependency to the latest within the same minor (semver-patch only).`,type:`boolean`,default:!1}).option(`filter`,{description:`Only consider deps whose name matches this substring (case-insensitive). Repeatable; comma-separated values are split.`,type:`string`}).option(`workspace`,{alias:`p`,description:`Restrict to a subset of workspaces. Patterns are matched against the workspace package name AND its directory path (substring + glob). Repeatable; comma-separated values are split.`,type:`string`}).option(`exclude-workspace`,{description:`Skip workspaces matching this pattern (glob-shaped; matched against workspace package name AND directory path). Repeatable; comma-separated values are split. Use for workspaces with intentional dependency drift — e.g. integration tests pinned to specific upstream versions.`,type:`string`}).option(`align`,{description:`Offline consistency mode: find deps declared at multiple ranges across the workspace and align them to the highest. No registry calls.`,type:`boolean`,default:!1}).option(`check`,{description:"CI gate: exit non-zero when any dep is declared inconsistently across workspaces. Implies offline (no registry calls). Pairs with `--align` as the fix.",type:`boolean`,default:!1}).option(`dry-run`,{description:`Print the upgrade plan without writing package.json files.`,type:`boolean`,default:!1}).option(`cwd`,{description:`Project directory. Default: process.cwd(). When inside a workspace, walks up to the monorepo root.`,type:`string`}).option(`yes`,{alias:`y`,description:`Interactive mode: select all without prompting.`,type:`boolean`,default:!1}).option(`verbose`,{description:`Print extra resolution details.`,type:`boolean`,default:!1}),handler:async n=>{let a=discoverContext(Yo(n.cwd??process.cwd())),S=applyWorkspaceFilter(a.workspaces,n.workspace,n.excludeWorkspace);if(S.length===0){ke.log(`[gjsify upgrade] no matching workspaces.`);return}let C=collectAllDeclarations(S,parseFilterList(n.filter));if(C.length===0){ke.log(`[gjsify upgrade] no external npm dependencies to check.`);return}let N=groupByDependency(C);if(n.check)return runCheckMode(N);if(n.align)return runAlignMode(N,n);let F=await loadNpmrcLight(a.root),I=n.latest?`latest`:n.minor?`minor`:n.patch?`patch`:`interactive`;ke.log(`[gjsify upgrade] checking ${N.length} unique deps across ${S.length} workspace(s) against ${F.registry}…`);let H=await resolveCandidateGroups(N,F,n.verbose??!1,I);if(H.length===0){ke.log(`✅ all dependencies are up to date`);let n=findInconsistencies(N);n.length>0&&ke.log(`\n⚠ ${n.length} dep(s) declared at inconsistent ranges across workspaces. Run \`gjsify upgrade --align\` to fix.`);return}printTable(H);let W;if(I===`interactive`&&!n.yes?W=await promptSelection(H):(n.yes&&I===`interactive`&&ke.log(`[gjsify upgrade] -y / --yes: selecting all`),W=H),W.length===0){ke.log(`[gjsify upgrade] nothing selected; no files changed.`);return}if(n.dryRun){let n=uniqueLocations(W).length;ke.log(`[gjsify upgrade] --dry-run: would update ${W.length} deps across ${n} package.json file(s).`),printChangePlan(W);return}let K=applyToFiles(W);ke.log(`✏️ updated ${W.length} dep(s) across ${K} package.json file(s). Run \`gjsify install\` to apply.`)}},kN=[`dependencies`,`devDependencies`,`optionalDependencies`,`peerDependencies`],AN={reset:`\x1B[0m`,bold:`\x1B[1m`,dim:`\x1B[2m`,red:`\x1B[31m`,yellow:`\x1B[33m`,green:`\x1B[32m`,cyan:`\x1B[36m`,magenta:`\x1B[35m`}});async function generateBarrels(n){let a=n.singleQuotes?`'`:`"`,S=n.noSemicolon?``:`;`,C=n.extension===`none`?``:`.${n.extension}`,N=0;for(let F of n.paths){let I=Yo(n.baseDir,F),H=ns(I)===`types`,W;try{W=(await readdir$1(I,{withFileTypes:!0})).filter(n=>n.isFile()).filter(n=>NN.test(n.name)).filter(n=>n.name!==`index.ts`).filter(a=>!n.exclude.some(n=>n.test(a.name))).sort((n,a)=>n.name.localeCompare(a.name))}catch(a){n.verbose&&ke.error(`[gjsify barrels] skip ${I}: ${a.message}`);continue}let K=W.map(n=>{let N=ns(n.name,rs(n.name));return`${H?`export type *`:`export *`} from ${a}./${N}${C}${a}${S}`}),q=K.length?`${K.join(`
|
|
827
827
|
`)}\n`:`export {};
|
|
828
|
-
`,Y=`${n.header}\n\n${q}`,X=Qo(I,`index.ts`);if(await readFile$1(X,`utf-8`).catch(()=>``)===Y){n.verbose&&ke.log(`[gjsify barrels] up-to-date: ${X}`);continue}n.check?(ke.error(`[gjsify barrels] drift: ${X}`),N++):(await writeFile$1(X,Y,`utf-8`),n.verbose&&ke.log(`[gjsify barrels] wrote: ${X}`))}return N}var
|
|
828
|
+
`,Y=`${n.header}\n\n${q}`,X=Qo(I,`index.ts`);if(await readFile$1(X,`utf-8`).catch(()=>``)===Y){n.verbose&&ke.log(`[gjsify barrels] up-to-date: ${X}`);continue}n.check?(ke.error(`[gjsify barrels] drift: ${X}`),N++):(await writeFile$1(X,Y,`utf-8`),n.verbose&&ke.log(`[gjsify barrels] wrote: ${X}`))}return N}var MN,NN,PN=__esmMin(()=>{Ae(),Tc(),ls(),MN=[`\\.test\\.`,`\\.spec\\.`,`\\.test-data\\.`],NN=/\.(ts|tsx|mts|cts)$/}),FN,IN=__esmMin(()=>{Ae(),PN(),FN={command:`barrels [paths..]`,description:"Regenerate `index.ts` barrel files for the given directories. Drop-in replacement for `barrelsby`.",builder:n=>n.positional(`paths`,{description:"Directories whose `index.ts` to (re)generate. May also be passed via `--paths`.",type:`string`,array:!0}).option(`paths`,{alias:`p`,description:`Alternative to positional — repeatable list of directories.`,type:`string`,array:!0}).option(`ext`,{description:"Import-specifier extension. Default: `none` (bundler-mode resolution).",type:`string`,choices:[`js`,`ts`,`none`],default:`none`}).option(`base-dir`,{alias:`b`,description:"Resolve `paths` against this directory. Default: cwd.",type:`string`}).option(`exclude`,{description:"Regex(es) of file names to skip. Repeatable. Defaults: `\\.test\\.`, `\\.spec\\.`, `\\.test-data\\.`.",type:`string`,array:!0}).option(`header`,{description:`Header comment prepended to every generated file.`,type:`string`}).option(`semicolon`,{description:"Emit trailing `;` on each export line. Negate with `--no-semicolon`. Default: omitted.",type:`boolean`,default:!1}).option(`single-quotes`,{description:"Use `'` for import specifiers. Default: true. Pass `--no-single-quotes` for `\"`.",type:`boolean`,default:!0}).option(`check`,{description:`Report drift without modifying files; exit non-zero if any barrel is stale.`,type:`boolean`,default:!1}).option(`verbose`,{description:`Log each file scanned + written.`,type:`boolean`,default:!1}),handler:async n=>{let a=Array.from(new Set((n.paths??[]).filter(Boolean)));if(a.length===0){ke.error(`[gjsify barrels] no paths provided. Pass directories as positional arguments or via --paths.`),process.exitCode=1;return}let S=n.exclude?.length?n.exclude:[...MN],C=await generateBarrels({paths:a,extension:n.ext??`none`,baseDir:n.baseDir??process.cwd(),exclude:S.map(n=>new RegExp(n)),header:n.header??"// Auto-generated by `gjsify barrels` — do not edit by hand.",noSemicolon:n.semicolon===!1||n.semicolon===void 0,singleQuotes:n.singleQuotes!==!1,check:n.check??!1,verbose:n.verbose??!1});n.check&&C>0&&(ke.error(`[gjsify barrels] ${C} barrel file(s) drifted. Run without --check to fix.`),process.exitCode=1)}}}),LN,RN=__esmMin(()=>{Ae(),nC(),zo(),ls(),fn(),RA(),Pg(),LN={command:`tsc [tscArgs..]`,description:"Run TypeScript compiler (tsc) under GJS via the @gjsify/tsc bundle. All arguments are passed through to tsc. Equivalent to `gjsify-tsc <args>` from the @gjsify/tsc bin.",builder:n=>n.parserConfiguration({"unknown-options-as-args":!0}).version(!1).help(!1).positional(`tscArgs`,{description:"Arguments forwarded verbatim to tsc (e.g. `--version`, `-p tsconfig.json`).",type:`string`,array:!0,default:[]}),handler:async n=>{let a=(n._??[]).slice(1).map(String),S=n.tscArgs??[],C=a.length>0?a:S,N=process.cwd(),F=[pathToFileURL(`${findWorkspaceRoot(N)??N}/__gjsify_tsc__.js`).href,import.meta.url],I;for(let n of F)try{I=createRequire(n).resolve(`@gjsify/tsc/bundle`);break}catch{}let H;for(let n of F)try{H=Qo(ts(createRequire(n).resolve(`typescript/package.json`)),`lib`,`tsc.js`);break}catch{}!I&&!H&&(ke.error("gjsify tsc: neither @gjsify/tsc (GJS bundle) nor npm `typescript` (Node) is installed."),ke.error(" Install with: gjsify install --save-dev @gjsify/tsc (or add `typescript`)."),process.exit(1));let W=buildNativeEnv(detectNativePackages(N)),K={...process.env,...W},runNodeTsc=()=>{let n=spawn(process.execPath,[H,...C],{env:K,stdio:`inherit`});n.on(`close`,n=>process.exit(n??1)),n.on(`error`,n=>{ke.error(`gjsify tsc (node typescript): ${n.message}`),process.exit(1)})};if(I){let n=spawn(`gjs`,[`-m`,I,...C],{env:K,stdio:`inherit`});await new Promise(a=>{n.on(`close`,n=>{process.exit(n??1)}),n.on(`error`,n=>{n.code===`ENOENT`&&H?runNodeTsc():n.code===`ENOENT`?(ke.error("gjsify tsc: `gjs` not found on PATH and no npm `typescript` fallback."),ke.error(" Install GJS (e.g. `dnf install gjs`), or add `typescript` to the project."),process.exit(1)):(ke.error(`gjsify tsc: ${n.message}`),process.exit(1))})})}else runNodeTsc()}}});function classifyAndExpand(n,a,S){let C=S.map(n=>n.replace(/\\/g,`/`)).filter(n=>n.length>0);if(C.length===0)return{global:!1,reason:`empty-diff`,workspaces:[],runE2E:!1,runIntegration:!1,skipAll:!0};let N=[];for(let n of C)VN.some(a=>a.test(n))||N.push(n);if(N.length===0)return{global:!1,reason:`ignored-only`,workspaces:[],runE2E:!1,runIntegration:!1,skipAll:!0};for(let a of N)for(let S of BN)if(S.test(a))return{global:!0,reason:`global-trigger ${S.source} matched ${a}`,workspaces:n.map(n=>n.name),runE2E:!0,runIntegration:!0,skipAll:!1};let{matched:F,unmatched:I}=workspacesForChangedFiles(n,a,N);if(I.length>0)return{global:!0,reason:`unmatched files (${I.length}): ${I.slice(0,3).join(`, `)}${I.length>3?`…`:``}`,workspaces:n.map(n=>n.name),runE2E:!0,runIntegration:!0,skipAll:!1};if(N.every(n=>HN.some(a=>a.test(n)))&&F.size===1){let n=[...F][0],a=N.some(n=>n.startsWith(`tests/e2e/`)),S=N.some(n=>n.startsWith(`tests/integration/`));return{global:!1,reason:`test-only (${N.length} file(s) in ${n})`,workspaces:[n],runE2E:a,runIntegration:S||isIntegrationWorkspace(n),skipAll:!1}}let H=affectedClosure(buildReverseDependencyGraph(n,{includeDev:!0}),[...F]),W=buildDependencyGraph(n,{includeDev:!0}),K=!1;for(let[n,a]of W.edges)if(isIntegrationWorkspace(n)){for(let S of a)if(H.has(S)){H.add(n),K=!0;break}}let q=N.some(n=>n.startsWith(`tests/e2e/`));return{global:!1,reason:`closure (${H.size} ws from ${F.size} seed(s))`,workspaces:[...H].sort(),runE2E:q,runIntegration:K,skipAll:!1}}function isIntegrationWorkspace(n){return n.startsWith(`@gjsify/integration-`)}function runGitDiff(n,a,S){let C=spawnSync(`git`,[`diff`,`--name-only`,`${a}...${S}`],{cwd:n,encoding:`utf8`});return C.status!==0&&(process.stderr.write(`gjsify affected: git diff failed (${C.status}): ${C.stderr.trim()}\n`),process.exit(2)),C.stdout.split(`
|
|
829
829
|
`).filter(Boolean)}function readStdinLines(){return readFileSync(0,`utf8`).split(`
|
|
830
830
|
`).map(n=>n.trim()).filter(Boolean)}function emit(n,a){if(n===`json`){process.stdout.write(JSON.stringify(a)+`
|
|
831
831
|
`);return}if(n===`globs`){for(let n of a.workspaces)process.stdout.write(`${n}\n`);return}if(n===`github-actions`){let n=a.global?``:a.workspaces.map(n=>`--include '${escSingleQuote(n)}'`).join(` `),S=process.env.GITHUB_OUTPUT,C=[`skip-all=${a.skipAll}`,`global=${a.global}`,`include-args=${n}`,`run-integration=${a.runIntegration}`,`run-e2e=${a.runE2E}`,`reason=${a.reason}`];if(S){let{appendFileSync:n}=(Jc(),__toCommonJS(Gc));for(let a of C)n(S,`${a}\n`)}else for(let n of C)process.stdout.write(`${n}\n`);return}process.stdout.write(`affected:
|
|
832
|
-
`),process.stdout.write(` reason: ${a.reason}\n`),process.stdout.write(` global: ${a.global}\n`),process.stdout.write(` skip-all: ${a.skipAll}\n`),process.stdout.write(` run-integration: ${a.runIntegration}\n`),process.stdout.write(` run-e2e: ${a.runE2E}\n`),process.stdout.write(` workspaces (${a.workspaces.length}):\n`);for(let n of a.workspaces)process.stdout.write(` - ${n}\n`)}function escSingleQuote(n){return n.replace(/'/g,`'\\''`)}var
|
|
832
|
+
`),process.stdout.write(` reason: ${a.reason}\n`),process.stdout.write(` global: ${a.global}\n`),process.stdout.write(` skip-all: ${a.skipAll}\n`),process.stdout.write(` run-integration: ${a.runIntegration}\n`),process.stdout.write(` run-e2e: ${a.runE2E}\n`),process.stdout.write(` workspaces (${a.workspaces.length}):\n`);for(let n of a.workspaces)process.stdout.write(` - ${n}\n`)}function escSingleQuote(n){return n.replace(/'/g,`'\\''`)}var zN,BN,VN,HN,UN=__esmMin(()=>{nC(),Jc(),Ng(),Pg(),zN={command:`affected`,description:"Classify changed files against the workspace tree and print the set of workspaces affected (seeds + transitive dependents). Designed for CI to gate `gjsify foreach test --include …` so unrelated workspaces are not re-tested on every PR.",builder:n=>n.option(`base`,{description:"Diff base. Default: `origin/main`. Resolved via `git rev-parse`. On a PR set this to `${{ github.event.pull_request.base.sha }}`.",type:`string`}).option(`head`,{description:"Diff head. Default: `HEAD`.",type:`string`,default:`HEAD`}).option(`format`,{description:`Output shape.`,choices:[`text`,`json`,`globs`,`github-actions`],default:`text`}).option(`changed-from-stdin`,{description:"Skip `git diff`. Read a newline-separated list of repo-relative paths from stdin instead. Lets callers — tests, ad-hoc scripts — control the input exactly.",type:`boolean`,default:!1}).option(`cwd`,{description:"Workspace root. Default: discovered from `process.cwd()`.",type:`string`}),handler:async n=>{let a=n.cwd??findWorkspaceRoot(process.cwd())??process.cwd(),S=classifyAndExpand(discoverWorkspaces(a,{includeRoot:!0}),a,n[`changed-from-stdin`]?readStdinLines():runGitDiff(a,n.base??`origin/main`,n.head??`HEAD`));emit(n.format,S)}},BN=[/^packages\/infra\/workspace\//,/^packages\/infra\/cli\//,/^packages\/infra\/rolldown-plugin-gjsify\//,/^packages\/infra\/resolve-npm\//,/^gjsify-lock\.json$/,/^package\.json$/,/^tsconfig[^/]*\.json$/,/^\.github\/workflows\/main\.yml$/,/^scripts\/audit-runtimes\.mjs$/],VN=[/\.md$/i,/^refs\//,/^website\//,/^docs\//,/^\.github\/workflows\/(deploy-docs|commitlint|release|audit-runtimes|prebuilds)\.yml$/,/^\.githooks\//,/^flatpak\//,/^LICENSE/,/^\.gitignore$/,/^\.gjsify-[^/]*\.md$/,/^STATUS\.md$/,/^CHANGELOG\.md$/,/^AGENTS\.md$/,/^CLAUDE\.md$/,/^README\.md$/],HN=[/\.spec\.[mc]?[tj]sx?$/,/^tests\/(e2e|integration)\//]}),WN=__esmMin(()=>{LA(),VA(),WA(),KA(),$A(),nj(),aj(),mj(),_j(),bj(),Cj(),$j(),NM(),LM(),HM(),WM(),JM(),eN(),nN(),lN(),dN(),mN(),_N(),yN(),xN(),CN(),TN(),jN(),IN(),RN(),UN()}),GN=__exportAll$3({runCli:()=>runCli});function runtimeLabel(){try{let n=globalThis.imports?.system;if(n?.version!==void 0){let a=Number(n.version);return`GJS ${Math.floor(a/1e4)}.${Math.floor(a%1e4/100)}.${a%100} (SpiderMonkey)`}}catch{}return typeof process<`u`&&typeof process.versions?.node==`string`?`Node.js ${process.version}`:`unknown runtime`}function readBundleVersion(){try{let n=ts(fileURLToPath(import.meta.url)),a=JSON.parse(readFileSync(Qo(n,`..`,`package.json`),`utf8`));return typeof a.version==`string`?a.version:`unknown`}catch{return`unknown`}}async function runCli(n){let a=Jd(n);await a.scriptName(Xd).version(readBundleVersion()).strict().wrap(a.terminalWidth()).command(pj.command,pj.description,pj.builder,pj.handler).command(IM.command,IM.description,IM.builder,IM.handler).command(IA.command,IA.description,IA.builder,IA.handler).command(BA.command,BA.description,BA.builder,BA.handler).command(UA.command,UA.description,UA.builder,UA.handler).command(MM.command,MM.description,MM.builder,MM.handler).command(GA.command,GA.description,GA.builder,GA.handler).command(QA.command,QA.description,QA.builder,QA.handler).command(tj.command,tj.description,tj.builder,tj.handler).command(ij.command,ij.description,ij.builder,ij.handler).command(gj.command,gj.description,gj.builder,gj.handler).command(yj.command,yj.description,yj.builder,yj.handler).command(Sj.command,Sj.description,Sj.builder,Sj.handler).command(Qj.command,Qj.description,Qj.builder,Qj.handler).command(VM.command,VM.description,VM.builder,VM.handler).command(UM.command,UM.description,UM.builder,UM.handler).command(KM.command,KM.description,KM.builder,KM.handler).command($M.command,$M.description,$M.builder,$M.handler).command(tN.command,tN.description,tN.builder,tN.handler).command(cN.command,cN.description,cN.builder,cN.handler).command(uN.command,uN.description,uN.builder,uN.handler).command(pN.command,pN.description,pN.builder,pN.handler).command(gN.command,gN.description,gN.builder,gN.handler).command(vN.command,vN.description,vN.builder,vN.handler).command(ON.command,ON.description,ON.builder,ON.handler).command(bN.command,bN.description,bN.builder,bN.handler).command(SN.command,SN.description,SN.builder,SN.handler).command(wN.command,wN.description,wN.builder,wN.handler).command(FN.command,FN.description,FN.builder,FN.handler).command(LN.command,LN.description,LN.builder,LN.handler).command(zN.command,zN.description,zN.builder,zN.handler).demandCommand(1).epilogue(`Running on ${runtimeLabel()}`).help().parseAsync()}var KN=__esmMin(()=>{Jc(),ls(),fn(),Yd(),WN(),Zd()});KN(),await runCli(hideBin(process.argv));
|
package/lib/commands/publish.js
CHANGED
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
// in-the-wild publish payloads.
|
|
36
36
|
import { readFileSync } from 'node:fs';
|
|
37
37
|
import { join, resolve } from 'node:path';
|
|
38
|
-
import { DEFAULT_REGISTRY, registryFor
|
|
38
|
+
import { DEFAULT_REGISTRY, registryFor } from '@gjsify/npm-registry';
|
|
39
|
+
import { buildPublishHeaders, escapePackageName } from '../utils/publish-headers.js';
|
|
39
40
|
import { packWorkspace } from './pack.js';
|
|
40
41
|
import { getNpmTrustedToken, hasGithubOidcEnv, OidcExchangeError, OidcUnavailableError } from '../utils/npm-oidc.js';
|
|
41
42
|
import { diagnose404, is404DiagnosticCandidate } from '../utils/publish-diagnose.js';
|
|
@@ -208,18 +209,12 @@ export const publishCommand = {
|
|
|
208
209
|
const npmrc = await loadNpmrc(wsDir);
|
|
209
210
|
const registry = process.env.npm_config_registry ?? registryFor(packed.name, npmrc) ?? DEFAULT_REGISTRY;
|
|
210
211
|
const registryClean = registry.endsWith('/') ? registry.slice(0, -1) : registry;
|
|
211
|
-
// npm-package-arg's escapedName convention
|
|
212
|
-
//
|
|
213
|
-
//
|
|
214
|
-
//
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const slash = packed.name.indexOf('/');
|
|
218
|
-
const scope = packed.name.slice(1, slash);
|
|
219
|
-
const base = packed.name.slice(slash + 1);
|
|
220
|
-
return `@${encodeURIComponent(scope)}%2f${encodeURIComponent(base)}`;
|
|
221
|
-
})()
|
|
222
|
-
: encodeURIComponent(packed.name);
|
|
212
|
+
// npm-package-arg's escapedName convention (npa.js:188):
|
|
213
|
+
// `name.replace('/', '%2f')` — scoped `@scope/name` → `@scope%2fname`
|
|
214
|
+
// (literal @, lowercase %2f, segments NOT otherwise re-encoded);
|
|
215
|
+
// unscoped names pass through. Match it exactly — the npm registry is
|
|
216
|
+
// picky about the publish PUT URL shape.
|
|
217
|
+
const escapedName = escapePackageName(packed.name);
|
|
223
218
|
const url = `${registryClean}/${escapedName}`;
|
|
224
219
|
// npm publish convention: the dist.tarball URL + _attachments key both
|
|
225
220
|
// use the UNSCOPED basename — `cli-0.4.5.tgz`, not
|
|
@@ -241,14 +236,15 @@ export const publishCommand = {
|
|
|
241
236
|
packed: { ...packed, wireFilename },
|
|
242
237
|
provenance,
|
|
243
238
|
});
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
//
|
|
248
|
-
//
|
|
249
|
-
//
|
|
250
|
-
|
|
251
|
-
|
|
239
|
+
// Build the publish-PUT headers to match what `npm publish` sends via
|
|
240
|
+
// npm-registry-fetch's `getHeaders` — critically `npm-command: publish`
|
|
241
|
+
// (the routing header npm's create-package frontdoor keys on; without it
|
|
242
|
+
// a first-publish of a brand-new scoped package returns a bare 404
|
|
243
|
+
// `Not Found`), plus `npm-auth-type` (legacy when --otp, else web), a
|
|
244
|
+
// real `user-agent`, and `npm-otp` when an OTP is supplied. See
|
|
245
|
+
// `utils/publish-headers.ts` for the field-by-field refs/npm-cli
|
|
246
|
+
// evidence.
|
|
247
|
+
const headers = buildPublishHeaders(url, { npmrc, otp });
|
|
252
248
|
// Trusted Publishing path. `--trusted` forces OIDC (errors if env
|
|
253
249
|
// vars are missing); the default `undefined` triggers auto-detect:
|
|
254
250
|
// OIDC is used iff GitHub OIDC env vars are present AND no
|
|
@@ -301,7 +297,8 @@ export const publishCommand = {
|
|
|
301
297
|
handleOidcFailure(err, packed.name, args.json === true);
|
|
302
298
|
process.exit(1);
|
|
303
299
|
}
|
|
304
|
-
// Auto-detect: fall back to
|
|
300
|
+
// Auto-detect: fall back to the npmrc token auth that
|
|
301
|
+
// buildPublishHeaders already resolved into `headers`.
|
|
305
302
|
if (verbose) {
|
|
306
303
|
const msg = err instanceof Error ? err.message : String(err);
|
|
307
304
|
console.error(`gjsify publish: OIDC auto-detect failed (${msg}) — falling back to token auth`);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type NpmrcConfig } from '@gjsify/npm-registry';
|
|
2
|
+
/**
|
|
3
|
+
* Percent-encode a package name for the publish PUT path, matching
|
|
4
|
+
* npm-package-arg's `escapedName` convention (npa.js:188):
|
|
5
|
+
* `this.escapedName = name.replace('/', '%2f')`.
|
|
6
|
+
*
|
|
7
|
+
* Scoped: `@scope/name` → `@scope%2fname` (literal `@`, lowercase `%2f`, the
|
|
8
|
+
* scope/name segments NOT otherwise re-encoded — npm only replaces the slash).
|
|
9
|
+
* Unscoped: returned unchanged (npa stores the bare name; the only characters
|
|
10
|
+
* npm forbids are those `encodeURIComponent` would touch, which npa rejects up
|
|
11
|
+
* front). The npm registry is picky about this exact shape on the publish PUT
|
|
12
|
+
* URL — `%2F` (uppercase) or a re-encoded `@` would miss the create route.
|
|
13
|
+
*/
|
|
14
|
+
export declare function escapePackageName(name: string): string;
|
|
15
|
+
export interface PublishHeaderOptions {
|
|
16
|
+
/** Parsed ~/.npmrc — supplies the `authorization` (Bearer/Basic) header. */
|
|
17
|
+
npmrc?: NpmrcConfig;
|
|
18
|
+
/** 2FA one-time code. When present, sent as `npm-otp` AND flips auth-type. */
|
|
19
|
+
otp?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Override the `authorization` header (e.g. an OIDC Bearer token resolved
|
|
22
|
+
* after `buildHeaders` ran). When set it replaces whatever the npmrc auth
|
|
23
|
+
* resolution produced.
|
|
24
|
+
*/
|
|
25
|
+
authorization?: string;
|
|
26
|
+
/**
|
|
27
|
+
* npm user-agent. Defaults to an npm-CLI-shaped string. The registry does
|
|
28
|
+
* not validate the exact value, but a real UA is what npm sends; the dead
|
|
29
|
+
* `gjsify-install/0.3.7` placeholder is not used here.
|
|
30
|
+
*/
|
|
31
|
+
userAgent?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Build the full set of headers for the publish PUT, mirroring
|
|
35
|
+
* `npm-registry-fetch`'s `getHeaders` for `npm publish`.
|
|
36
|
+
*
|
|
37
|
+
* The set: `authorization`, `content-type: application/json`,
|
|
38
|
+
* `npm-command: publish`, `npm-auth-type` (`web`, or `legacy` when `--otp`),
|
|
39
|
+
* `user-agent`, and `npm-otp` when an OTP is supplied.
|
|
40
|
+
*
|
|
41
|
+
* Notably it does NOT set an `accept: *` wildcard — `npm-registry-fetch` sends
|
|
42
|
+
* no `accept` header on the publish PUT; the stray wildcard gjsify used to send
|
|
43
|
+
* is dropped to match.
|
|
44
|
+
*/
|
|
45
|
+
export declare function buildPublishHeaders(url: string, opts: PublishHeaderOptions): Record<string, string>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// Publish-request header builder — matches what npm's CLI sends on a publish
|
|
2
|
+
// PUT so the npm registry's create-package frontdoor routes a *new* scoped
|
|
3
|
+
// package correctly.
|
|
4
|
+
//
|
|
5
|
+
// Root cause this fixes: a first-publish of a never-before-published
|
|
6
|
+
// `@scope/<name>` via token auth was returning a bare `404 Not Found` (body
|
|
7
|
+
// `Not Found`, NOT a JSON npm error). That is a routing miss, not a
|
|
8
|
+
// payload-validation failure — npm's write frontdoor keys the create path on
|
|
9
|
+
// the `npm-command` header, which gjsify was not sending. `npm publish` with
|
|
10
|
+
// the same ~/.npmrc token succeeds because libnpmpublish goes through
|
|
11
|
+
// `npm-registry-fetch`'s `getHeaders`, which always sets `npm-command`
|
|
12
|
+
// (+ `npm-auth-type`, + a real `user-agent`).
|
|
13
|
+
//
|
|
14
|
+
// Evidence (refs/npm-cli):
|
|
15
|
+
// - `lib/npm.js:404` `flat.npmCommand = this.command` → set for EVERY npm
|
|
16
|
+
// command; equals `"publish"` for `npm publish`.
|
|
17
|
+
// - `node_modules/npm-registry-fetch/lib/index.js:231-233`
|
|
18
|
+
// `if (opts.npmCommand) headers['npm-command'] = opts.npmCommand`
|
|
19
|
+
// and `:219-221` `if (opts.authType) headers['npm-auth-type'] = …`
|
|
20
|
+
// and `:215-217` `'user-agent': opts.userAgent`.
|
|
21
|
+
// - `workspaces/config/lib/definitions/definitions.js:282-290` — `auth-type`
|
|
22
|
+
// default `'web'`, flattened to `flatOptions.authType`.
|
|
23
|
+
// - `:1581-1587` — when `--otp` is set, npm forces `auth-type` to `'legacy'`
|
|
24
|
+
// before flattening, so an OTP publish sends `npm-auth-type: legacy`.
|
|
25
|
+
// - `node_modules/npm-package-arg/lib/npa.js:188`
|
|
26
|
+
// `this.escapedName = name.replace('/', '%2f')` — lowercase `%2f`,
|
|
27
|
+
// literal `@`. (gjsify's URL encoding already matches this — it was never
|
|
28
|
+
// the bug.)
|
|
29
|
+
//
|
|
30
|
+
// This module is pure (no I/O, no `gi://`) so it is unit-testable on both Node
|
|
31
|
+
// and GJS without dragging in the runtime fetch/Soup stack.
|
|
32
|
+
import { buildHeaders } from '@gjsify/npm-registry';
|
|
33
|
+
/**
|
|
34
|
+
* Percent-encode a package name for the publish PUT path, matching
|
|
35
|
+
* npm-package-arg's `escapedName` convention (npa.js:188):
|
|
36
|
+
* `this.escapedName = name.replace('/', '%2f')`.
|
|
37
|
+
*
|
|
38
|
+
* Scoped: `@scope/name` → `@scope%2fname` (literal `@`, lowercase `%2f`, the
|
|
39
|
+
* scope/name segments NOT otherwise re-encoded — npm only replaces the slash).
|
|
40
|
+
* Unscoped: returned unchanged (npa stores the bare name; the only characters
|
|
41
|
+
* npm forbids are those `encodeURIComponent` would touch, which npa rejects up
|
|
42
|
+
* front). The npm registry is picky about this exact shape on the publish PUT
|
|
43
|
+
* URL — `%2F` (uppercase) or a re-encoded `@` would miss the create route.
|
|
44
|
+
*/
|
|
45
|
+
export function escapePackageName(name) {
|
|
46
|
+
return name.replace('/', '%2f');
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Build the full set of headers for the publish PUT, mirroring
|
|
50
|
+
* `npm-registry-fetch`'s `getHeaders` for `npm publish`.
|
|
51
|
+
*
|
|
52
|
+
* The set: `authorization`, `content-type: application/json`,
|
|
53
|
+
* `npm-command: publish`, `npm-auth-type` (`web`, or `legacy` when `--otp`),
|
|
54
|
+
* `user-agent`, and `npm-otp` when an OTP is supplied.
|
|
55
|
+
*
|
|
56
|
+
* Notably it does NOT set an `accept: *` wildcard — `npm-registry-fetch` sends
|
|
57
|
+
* no `accept` header on the publish PUT; the stray wildcard gjsify used to send
|
|
58
|
+
* is dropped to match.
|
|
59
|
+
*/
|
|
60
|
+
export function buildPublishHeaders(url, opts) {
|
|
61
|
+
const headers = buildHeaders(url, { npmrc: opts.npmrc });
|
|
62
|
+
// npm-registry-fetch never sets `accept` on the publish PUT — drop the
|
|
63
|
+
// placeholder `accept-encoding` we don't want to influence the create route
|
|
64
|
+
// either. (buildHeaders defaults accept-encoding to `identity`; a publish
|
|
65
|
+
// PUT body is JSON we generated, so the encoding header is irrelevant — but
|
|
66
|
+
// we keep it harmless and explicit by leaving it as buildHeaders set it.)
|
|
67
|
+
// content-type: application/json — npm-registry-fetch sets this for any
|
|
68
|
+
// non-string/non-stream/non-buffer body (index.js:63-67); our body is a
|
|
69
|
+
// JSON string, so we set it explicitly.
|
|
70
|
+
headers['content-type'] = 'application/json';
|
|
71
|
+
// npm-command: publish — THE routing header. npm sets it for every command
|
|
72
|
+
// (npm.js:404); the registry's write frontdoor uses it to route the
|
|
73
|
+
// create-package PUT. Missing it = bare `404 Not Found` on a new package.
|
|
74
|
+
headers['npm-command'] = 'publish';
|
|
75
|
+
// npm-auth-type — `web` by default, `legacy` when an OTP is supplied
|
|
76
|
+
// (definitions.js:1583-1586). Sent by getHeaders (index.js:219-221).
|
|
77
|
+
headers['npm-auth-type'] = opts.otp ? 'legacy' : 'web';
|
|
78
|
+
// user-agent — a real npm-shaped UA (getHeaders index.js:215-217).
|
|
79
|
+
headers['user-agent'] = opts.userAgent ?? defaultUserAgent();
|
|
80
|
+
// npm-otp — only when an OTP is supplied (index.js:243-245).
|
|
81
|
+
if (opts.otp)
|
|
82
|
+
headers['npm-otp'] = opts.otp;
|
|
83
|
+
// authorization override (OIDC token resolved after npmrc auth).
|
|
84
|
+
if (opts.authorization)
|
|
85
|
+
headers['authorization'] = opts.authorization;
|
|
86
|
+
return headers;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* npm-CLI-shaped user-agent. Format mirrors npm-registry-fetch's
|
|
90
|
+
* `default-opts.js` (`npm@<v>/node@<v>+<arch> (<platform>)`); we substitute the
|
|
91
|
+
* gjsify CLI identity. The registry does not validate the exact value — it just
|
|
92
|
+
* must be a non-placeholder UA, which some WAF / CDN frontdoors require.
|
|
93
|
+
*/
|
|
94
|
+
function defaultUserAgent() {
|
|
95
|
+
const proc = globalThis.process;
|
|
96
|
+
const arch = proc?.arch ?? 'x64';
|
|
97
|
+
const platform = proc?.platform ?? 'linux';
|
|
98
|
+
return `gjsify-publish/0.5.0 (${platform} ${arch})`;
|
|
99
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "CLI for Gjsify",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -120,19 +120,19 @@
|
|
|
120
120
|
"cli"
|
|
121
121
|
],
|
|
122
122
|
"dependencies": {
|
|
123
|
-
"@gjsify/buffer": "^0.5.
|
|
124
|
-
"@gjsify/create-app": "^0.5.
|
|
125
|
-
"@gjsify/node-globals": "^0.5.
|
|
126
|
-
"@gjsify/node-polyfills": "^0.5.
|
|
127
|
-
"@gjsify/npm-registry": "^0.5.
|
|
128
|
-
"@gjsify/resolve-npm": "^0.5.
|
|
129
|
-
"@gjsify/rolldown-plugin-gjsify": "^0.5.
|
|
130
|
-
"@gjsify/rolldown-plugin-pnp": "^0.5.
|
|
131
|
-
"@gjsify/semver": "^0.5.
|
|
132
|
-
"@gjsify/tar": "^0.5.
|
|
133
|
-
"@gjsify/tsc": "^0.5.
|
|
134
|
-
"@gjsify/web-polyfills": "^0.5.
|
|
135
|
-
"@gjsify/workspace": "^0.5.
|
|
123
|
+
"@gjsify/buffer": "^0.5.1",
|
|
124
|
+
"@gjsify/create-app": "^0.5.1",
|
|
125
|
+
"@gjsify/node-globals": "^0.5.1",
|
|
126
|
+
"@gjsify/node-polyfills": "^0.5.1",
|
|
127
|
+
"@gjsify/npm-registry": "^0.5.1",
|
|
128
|
+
"@gjsify/resolve-npm": "^0.5.1",
|
|
129
|
+
"@gjsify/rolldown-plugin-gjsify": "^0.5.1",
|
|
130
|
+
"@gjsify/rolldown-plugin-pnp": "^0.5.1",
|
|
131
|
+
"@gjsify/semver": "^0.5.1",
|
|
132
|
+
"@gjsify/tar": "^0.5.1",
|
|
133
|
+
"@gjsify/tsc": "^0.5.1",
|
|
134
|
+
"@gjsify/web-polyfills": "^0.5.1",
|
|
135
|
+
"@gjsify/workspace": "^0.5.1",
|
|
136
136
|
"cosmiconfig": "^9.0.2",
|
|
137
137
|
"get-tsconfig": "^4.14.0",
|
|
138
138
|
"pkg-types": "^2.3.1",
|
|
@@ -140,13 +140,13 @@
|
|
|
140
140
|
"yargs": "^18.0.0"
|
|
141
141
|
},
|
|
142
142
|
"devDependencies": {
|
|
143
|
-
"@gjsify/unit": "^0.5.
|
|
143
|
+
"@gjsify/unit": "^0.5.1",
|
|
144
144
|
"@types/yargs": "^17.0.35",
|
|
145
145
|
"typescript": "^6.0.3"
|
|
146
146
|
},
|
|
147
147
|
"peerDependencies": {
|
|
148
|
-
"@gjsify/oxfmt-native": "^0.5.
|
|
149
|
-
"@gjsify/rolldown-native": "^0.5.
|
|
148
|
+
"@gjsify/oxfmt-native": "^0.5.1",
|
|
149
|
+
"@gjsify/rolldown-native": "^0.5.1"
|
|
150
150
|
},
|
|
151
151
|
"peerDependenciesMeta": {
|
|
152
152
|
"@gjsify/oxfmt-native": {
|