@stacksjs/buddy 0.75.650 → 0.75.652
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.
|
@@ -114,6 +114,7 @@ export declare function parseDistributionIdentities(output: string, teamId: stri
|
|
|
114
114
|
* needs no Apple variables beyond the App Store Connect key.
|
|
115
115
|
*/
|
|
116
116
|
export declare function withKeychainIdentities(config: AppleDesktopConfig, read?: (keychain?: string) => string): AppleDesktopConfig;
|
|
117
|
+
export declare function unsupportedMacosTarget(loadCommands: string, minimumMacos: string): string | undefined;
|
|
117
118
|
/**
|
|
118
119
|
* What a failure prints, as a value.
|
|
119
120
|
*
|
|
@@ -102,9 +102,9 @@ jobs:
|
|
|
102
102
|
secrets: inherit
|
|
103
103
|
`}function command(args,cwd=projectPath(),extraEnv={}){const result=Bun.spawnSync(args,{cwd,env:{...process.env,...extraEnv},stdin:"inherit",stdout:"inherit",stderr:"inherit"});if(result.exitCode!==0)throw new Error(`${args[0]} ${args.slice(1).join(" ")} exited with code ${result.exitCode}`)}export function signingPlan(input){const sign=(entitlements,target)=>["codesign","--force","--timestamp","--options","runtime","--entitlements",entitlements,...input.keychain?["--keychain",input.keychain]:[],"--sign",input.identity,target];return[sign(input.helperEntitlements,input.helperPath),sign(input.appEntitlements,input.appPath)]}export const captureCommand=(args)=>{const result=Bun.spawnSync(args,{cwd:projectPath(),stdin:"inherit",stdout:"pipe",stderr:"inherit"});if(result.exitCode!==0)throw new Error(`${args[0]} ${args.slice(1).join(" ")} exited with code ${result.exitCode}`);return result.stdout.toString()};export const MACH_O_ARCHITECTURE={arm64:"arm64",x64:"x86_64"};export function parseLipoArchs(output){return output.trim().split(/\s+/).filter(Boolean).sort()}export function mergeUniversalBinary(input,run=captureCommand){for(const architecture of["arm64","x64"]){const expected=MACH_O_ARCHITECTURE[architecture];const found=parseLipoArchs(run(["lipo","-archs",input[architecture]]));if(found.length!==1||found[0]!==expected){throw new Error(`${input.name}: the ${architecture} input ${input[architecture]} contains ${found.join(" + ")||"no architectures"}, expected only ${expected}`)}}run(["lipo","-create","-output",input.output,input.arm64,input.x64]);const merged=parseLipoArchs(run(["lipo","-archs",input.output]));const expected=Object.values(MACH_O_ARCHITECTURE).sort();if(merged.join(" ")!==expected.join(" "))throw new Error(`${input.name}: the universal binary ${input.output} contains ${merged.join(" + ")||"no architectures"}, expected ${expected.join(" + ")}`);return merged}export function buildUniversalPayload(input,run=captureCommand){const slice=(architecture)=>join(input.directory,architecture,"stacks-desktop");for(const architecture of["arm64","x64"]){mkdirSync(join(input.directory,architecture),{recursive:true});run(input.launcherCompileArgs(architecture,slice(architecture)))}const launcher=join(input.directory,"stacks-desktop");const runtime=join(input.directory,"craft-runtime");mergeUniversalBinary({name:"stacks-desktop",arm64:slice("arm64"),x64:slice("x64"),output:launcher},run);const architectures=mergeUniversalBinary({name:"craft-runtime",arm64:input.craft.arm64,x64:input.craft.x64,output:runtime},run);return{launcher,runtime,architectures}}export function launcherSliceCompileArgs(base,architecture){return["bun",...base,`--target=bun-darwin-${architecture}`]}export function parseDistributionIdentities(output,teamId){const named=(kinds)=>new RegExp(`"((?:${kinds}): [^"]+ \\(${teamId}\\))"`).exec(output)?.[1];return{app:named("Apple Distribution|3rd Party Mac Developer Application"),installer:named("3rd Party Mac Developer Installer|Mac Installer Distribution")}}export function withKeychainIdentities(config,read=readIdentities){if(config.appSigningIdentity&&config.installerSigningIdentity||!config.teamId)return config;const found=parseDistributionIdentities(read(config.keychain),config.teamId);return{...config,appSigningIdentity:config.appSigningIdentity||found.app||"",installerSigningIdentity:config.installerSigningIdentity||found.installer||""}}function readIdentities(keychain){const result=Bun.spawnSync(["security","find-identity","-v",...keychain?[keychain]:[]],{stdout:"pipe",stderr:"pipe"});return result.exitCode===0?result.stdout.toString():""}async function appStoreClient(config){if(!config.apiKeyId||!config.apiIssuerId||!config.apiKeyPath||!existsSync(config.apiKeyPath))throw new Error("App Store Connect API key ID, issuer ID, and .p8 key (APP_STORE_CONNECT_API_KEY or APP_STORE_CONNECT_API_KEY_PATH) are required");const{AppStoreConnectClient}=await import("ts-pantry");return new AppStoreConnectClient({keyId:config.apiKeyId,issuerId:config.apiIssuerId,keyPath:config.apiKeyPath})}async function appStoreAppId(client,bundleId){const app=await client.findApp(bundleId);if(!app)throw new Error(`App Store Connect has no app for ${bundleId}. Create it under Apps first.`);return app.id}async function withDownloadedProfile(config){if(config.provisioningProfile||!config.bundleId)return config;const client=await appStoreClient(config);const bundle=await client.findBundleId(config.bundleId);if(!bundle)throw new Error(`No Apple bundle id ${config.bundleId}. Run buddy desktop:apple:provision --apply first.`);const profile=(await client.listProfiles(bundle.id)).filter((item)=>item.attributes.profileState==="ACTIVE"&&item.attributes.profileContent).sort((a,b)=>String(b.attributes.expirationDate).localeCompare(String(a.attributes.expirationDate)))[0];if(!profile)throw new Error(`No active Mac App Store profile for ${config.bundleId}. Run buddy desktop:apple:provision --apply first.`);const directory=storagePath("framework/desktop-dist/apple");mkdirSync(directory,{recursive:true});const provisioningProfile=join(directory,`${config.bundleId}.provisionprofile`);writeFileSync(provisioningProfile,Buffer.from(String(profile.attributes.profileContent),"base64"),{mode:420});log.info(`Using the Mac App Store profile "${profile.attributes.name}" from App Store Connect`);return{...config,provisioningProfile}}async function withNextBuildNumber(config){if(config.buildNumber!=="next")return config;const client=await appStoreClient(config);const{nextBuildNumber}=await import("ts-pantry");const buildNumber=await nextBuildNumber(client,await appStoreAppId(client,config.bundleId));log.info(`Building ${config.version} (${buildNumber})`);return{...config,buildNumber}}async function releaseConfig(options,native){const config=withKeychainIdentities(withApiKeyFile(resolveAppleDesktopConfig(options,native)));return await withNextBuildNumber(await withDownloadedProfile(config))}async function distributeToTestFlight(config,groups,whatsNew){const client=await appStoreClient(config);const{distributeTestFlightBuild}=await import("ts-pantry");log.info(`Waiting for App Store Connect to process ${config.version} (${config.buildNumber})...`);const result=await distributeTestFlightBuild(client,{appId:await appStoreAppId(client,config.bundleId),version:config.version,buildNumber:config.buildNumber,groups,whatsNew});log.success(`${config.version} (${config.buildNumber}) is on TestFlight for ${result.groups.map((group)=>group.name).join(", ")}`)}function commitsSinceLastTag(){const run=(args)=>Bun.spawnSync(args,{cwd:projectPath(),stdout:"pipe",stderr:"pipe"});const tag=run(["git","describe","--tags","--abbrev=0"]);const range=tag.exitCode===0?[`${tag.stdout.toString().trim()}..HEAD`]:[];return run(["git","log","--no-merges","--format=- %s","-20",...range]).stdout.toString().trim().slice(0,4000)}function signingIdentityExists(identity,keychain){if(!identity)return false;const result=Bun.spawnSync(["security","find-identity","-v",...keychain?[keychain]:[]],{stdout:"pipe",stderr:"pipe"});return result.exitCode===0&&result.stdout.toString().includes(identity)}function provisioningProfileMatches(config){if(!config.provisioningProfile||!existsSync(config.provisioningProfile))return false;const result=Bun.spawnSync(["security","cms","-D","-i",config.provisioningProfile],{stdout:"pipe",stderr:"pipe"});if(result.exitCode!==0)return false;const profile=result.stdout.toString();return profile.includes(config.bundleId)&&profile.includes(config.teamId)}async function buildDesktop(){const{runAction}=await import("@stacksjs/actions");const{Action}=await import("@stacksjs/enums");const result=await runAction(Action.BuildDesktop);if(resultFailed(result))throw result.error}function sha256(path){return createHash("sha256").update(readFileSync(path)).digest("hex")}async function packageAppleDesktop(config,skipBuild=false,native=null){const errors=validateAppleDesktopConfig(config,false);if(config.keychain&&!existsSync(config.keychain))errors.push(`APPLE_KEYCHAIN does not exist: ${config.keychain}`);const where=config.keychain?` in ${config.keychain}`:"";if(!signingIdentityExists(config.appSigningIdentity,config.keychain))errors.push(`App signing identity is not installed${where}: ${config.appSigningIdentity}`);if(!signingIdentityExists(config.installerSigningIdentity,config.keychain))errors.push(`Installer signing identity is not installed${where}: ${config.installerSigningIdentity}`);if(!provisioningProfileMatches(config))errors.push(`Provisioning profile does not match ${config.teamId}.${config.bundleId}`);if(native&&config.universal)errors.push("--universal is not supported for a native macOS app yet: the AppKit host is built for this machine's architecture");if(errors.length)throw new Error(errors.join(`
|
|
104
104
|
`));if(native)return packageNativeApple(config,native);const{loadDesktopConfig}=await import("@stacksjs/desktop-build");const local=(await loadDesktopConfig(projectPath()))?.launcher?.appStore;if(local&&config.universal)throw new Error("The local App Store host supports one target architecture per build");if(!skipBuild)await buildDesktop();if(local)return packageLocalLauncher(config,local);const desktopDist=storagePath("framework/desktop-dist");let launcher=join(desktopDist,"stacks-desktop");let runtime=join(desktopDist,"craft-runtime");const manifest=join(desktopDist,"desktop.json");for(const path of[launcher,runtime,manifest]){if(!existsSync(path))throw new Error(`Desktop build artifact is missing: ${path}`)}let architectures=[process.arch==="x64"?"x86_64":process.arch];let craftSlices;if(config.universal){const universalDir=join(desktopDist,"universal");if(existsSync(universalDir))rmSync(universalDir,{recursive:true});const{desktopLauncherCompileArgs,resolveDesktopLauncher}=await import("@stacksjs/desktop-build");const entry=resolveDesktopLauncher(projectPath());const minify=process.env.DESKTOP_MINIFY!=="false";const payload=buildUniversalPayload({directory:universalDir,launcherCompileArgs:(architecture,outfile)=>launcherSliceCompileArgs(desktopLauncherCompileArgs({entry,outfile,minify}),architecture),craft:{arm64:config.craftArm64,x64:config.craftX64}});launcher=payload.launcher;runtime=payload.runtime;architectures=payload.architectures;craftSlices={arm64:config.craftArm64,x64:config.craftX64}}const appleDir=join(desktopDist,"apple");const appPath=join(appleDir,`${config.appName}.app`);const contents=join(appPath,"Contents");const macosDir=join(contents,"MacOS");const resourcesDir=join(contents,"Resources");if(existsSync(appleDir))rmSync(appleDir,{recursive:true});mkdirSync(macosDir,{recursive:true});mkdirSync(resourcesDir,{recursive:true});copyFileSync(launcher,join(macosDir,"stacks-desktop"));copyFileSync(runtime,join(macosDir,"craft-runtime"));if(config.universal){const parsed=JSON.parse(readFileSync(manifest,"utf8"));writeFileSync(join(resourcesDir,"desktop.json"),`${JSON.stringify({...parsed,architecture:"universal"},null,2)}
|
|
105
|
-
`)}else{copyFileSync(manifest,join(resourcesDir,"desktop.json"))}copyFileSync(config.provisioningProfile,join(contents,"embedded.provisionprofile"));chmodSync(join(contents,"embedded.provisionprofile"),420);chmodSync(join(macosDir,"stacks-desktop"),493);chmodSync(join(macosDir,"craft-runtime"),493);if(config.icon)copyFileSync(resolve(config.icon),join(resourcesDir,"AppIcon.icns"));const infoPlist=join(contents,"Info.plist");const appEntitlements=join(appleDir,"app.entitlements");const helperEntitlements=join(appleDir,"helper.entitlements");writeFileSync(infoPlist,renderInfoPlist(config));writeFileSync(appEntitlements,renderAppEntitlements(config));writeFileSync(helperEntitlements,renderHelperEntitlements());command(["plutil","-lint",infoPlist,appEntitlements,helperEntitlements]);for(const args of signingPlan({identity:config.appSigningIdentity,appPath,helperPath:join(macosDir,"craft-runtime"),appEntitlements,helperEntitlements,keychain:config.keychain}))command(args);command(["codesign","--verify","--deep","--strict","--verbose=2",appPath]);command(["codesign","-d","--entitlements","-","--xml",appPath]);await verifyStoreBundle(appPath,"stacks-desktop");return finishPackage(config,appPath,appleDir,{architectures,craft:{sha256:sha256(join(macosDir,"craft-runtime")),...craftSlices&&{slices:{arm64:sha256(craftSlices.arm64),x64:sha256(craftSlices.x64)}}}})}async function packageLocalLauncher(config,local,sandboxCheck=false){const{renderUserlandPlistEntries,resolveCraftExecutable}=await import("@stacksjs/desktop-build");const desktopDist=storagePath("framework/desktop-dist");const executable=config.appName;const backend="craft-backend";const runtime=local.runtime?projectPath(local.runtime):join(dirname(resolveCraftExecutable()),"craft-app-store");const probe=Bun.spawnSync([runtime,"--distribution"],{stdout:"pipe",stderr:"pipe"});if(probe.exitCode!==0||probe.stdout.toString().trim()!=="app-store")throw new Error(`Expected Craft's App Store runtime at ${runtime}`);const appleDir=join(desktopDist,"apple");const app=join(appleDir,`${config.appName}.app`);const contents=join(app,"Contents");const macOS=join(contents,"MacOS");const resources=join(contents,"Resources");rmSync(appleDir,{recursive:true,force:true});mkdirSync(macOS,{recursive:true});mkdirSync(resources,{recursive:true});const launcher=join(desktopDist,"stacks-desktop");for(const[source,name]of[[runtime,executable],[launcher,backend]]){const target=join(macOS,name);copyFileSync(source,target);chmodSync(target,493)}for(const source of[projectPath("app/Desktop/Resources"),join(desktopDist,"resources")]){if(existsSync(source))cpSync(source,resources,{recursive:true})}if(config.icon)copyFileSync(resolve(config.icon),join(resources,"AppIcon.icns"));writeFileSync(join(resources,"craft.json"),JSON.stringify({title:executable,appName:executable,width:1400,height:900,titlebarHidden:true,backend:{executable:backend}}));if(!sandboxCheck){const profile=join(contents,"embedded.provisionprofile");copyFileSync(config.provisioningProfile,profile);chmodSync(profile,420)}const declared=projectPath("app/Desktop/Info.plist.json");const declaredInfo=existsSync(declared)?JSON.parse(readFileSync(declared,"utf8")):{};for(const key of["CFBundlePackageType","CFBundleInfoDictionaryVersion","CFBundleIconFile","LSApplicationCategoryType","LSMinimumSystemVersion","NSHighResolutionCapable"])delete declaredInfo[key];const extra=renderUserlandPlistEntries(declaredInfo).xml;const plist=join(contents,"Info.plist");const appEntitlements=join(appleDir,"app.entitlements");const helperEntitlements=join(appleDir,"helper.entitlements");writeFileSync(plist,renderInfoPlist(config,executable,extra));writeFileSync(appEntitlements,renderAppEntitlements(config,local,sandboxCheck));writeFileSync(helperEntitlements,renderHelperEntitlements());command(["plutil","-lint",plist,appEntitlements,helperEntitlements]);for(const args of signingPlan({identity:sandboxCheck?"-":config.appSigningIdentity,appPath:app,helperPath:join(macOS,backend),appEntitlements,helperEntitlements,keychain:config.keychain}))command(args);command(["codesign","--verify","--deep","--strict",app]);if(sandboxCheck)return app;await verifyStoreBundle(app,executable);return finishPackage(config,app,appleDir,{architectures:[process.arch==="x64"?"x86_64":process.arch],craft:{kind:"app-store-host",sha256:sha256(runtime)}})}async function verifyStoreBundle(app,executable){const{bundleDirectoryFor}=await import("@stacksjs/desktop-build");const files=bundleFiles(app);const findings=storeRejectionFindings(files,executable);for(const file of files){const path=join(app,file);if(bundleDirectoryFor(path)!=="MacOS")continue;const deps=Bun.spawnSync(["/usr/bin/otool","-L",path],{stdout:"pipe",stderr:"pipe"});if(deps.exitCode!==0)throw new Error(`Could not inspect the Mach-O dependencies of ${file}`);if(/^\s+\/usr\/lib\/libicucore(?:\.[^\s]+)?\.dylib\s/m.test(deps.stdout.toString()))findings.push(`${file} links Apple's system ICU library, which App Review flagged. Build with a Bun runtime linked to upstream ICU.`)}if(findings.length)throw new Error(`The app bundle failed Store preflight:
|
|
105
|
+
`)}else{copyFileSync(manifest,join(resourcesDir,"desktop.json"))}copyFileSync(config.provisioningProfile,join(contents,"embedded.provisionprofile"));chmodSync(join(contents,"embedded.provisionprofile"),420);chmodSync(join(macosDir,"stacks-desktop"),493);chmodSync(join(macosDir,"craft-runtime"),493);if(config.icon)copyFileSync(resolve(config.icon),join(resourcesDir,"AppIcon.icns"));const infoPlist=join(contents,"Info.plist");const appEntitlements=join(appleDir,"app.entitlements");const helperEntitlements=join(appleDir,"helper.entitlements");writeFileSync(infoPlist,renderInfoPlist(config));writeFileSync(appEntitlements,renderAppEntitlements(config));writeFileSync(helperEntitlements,renderHelperEntitlements());command(["plutil","-lint",infoPlist,appEntitlements,helperEntitlements]);for(const args of signingPlan({identity:config.appSigningIdentity,appPath,helperPath:join(macosDir,"craft-runtime"),appEntitlements,helperEntitlements,keychain:config.keychain}))command(args);command(["codesign","--verify","--deep","--strict","--verbose=2",appPath]);command(["codesign","-d","--entitlements","-","--xml",appPath]);await verifyStoreBundle(appPath,"stacks-desktop",config.minimumMacos);return finishPackage(config,appPath,appleDir,{architectures,craft:{sha256:sha256(join(macosDir,"craft-runtime")),...craftSlices&&{slices:{arm64:sha256(craftSlices.arm64),x64:sha256(craftSlices.x64)}}}})}async function packageLocalLauncher(config,local,sandboxCheck=false){const{renderUserlandPlistEntries,resolveCraftExecutable}=await import("@stacksjs/desktop-build");const desktopDist=storagePath("framework/desktop-dist");const executable=config.appName;const backend="craft-backend";const runtime=local.runtime?projectPath(local.runtime):join(dirname(resolveCraftExecutable()),"craft-app-store");const probe=Bun.spawnSync([runtime,"--distribution"],{stdout:"pipe",stderr:"pipe"});if(probe.exitCode!==0||probe.stdout.toString().trim()!=="app-store")throw new Error(`Expected Craft's App Store runtime at ${runtime}`);const appleDir=join(desktopDist,"apple");const app=join(appleDir,`${config.appName}.app`);const contents=join(app,"Contents");const macOS=join(contents,"MacOS");const resources=join(contents,"Resources");rmSync(appleDir,{recursive:true,force:true});mkdirSync(macOS,{recursive:true});mkdirSync(resources,{recursive:true});const launcher=join(desktopDist,"stacks-desktop");for(const[source,name]of[[runtime,executable],[launcher,backend]]){const target=join(macOS,name);copyFileSync(source,target);chmodSync(target,493)}for(const source of[projectPath("app/Desktop/Resources"),join(desktopDist,"resources")]){if(existsSync(source))cpSync(source,resources,{recursive:true})}if(config.icon)copyFileSync(resolve(config.icon),join(resources,"AppIcon.icns"));writeFileSync(join(resources,"craft.json"),JSON.stringify({title:executable,appName:executable,width:1400,height:900,titlebarHidden:true,backend:{executable:backend}}));if(!sandboxCheck){const profile=join(contents,"embedded.provisionprofile");copyFileSync(config.provisioningProfile,profile);chmodSync(profile,420)}const declared=projectPath("app/Desktop/Info.plist.json");const declaredInfo=existsSync(declared)?JSON.parse(readFileSync(declared,"utf8")):{};for(const key of["CFBundlePackageType","CFBundleInfoDictionaryVersion","CFBundleIconFile","LSApplicationCategoryType","LSMinimumSystemVersion","NSHighResolutionCapable"])delete declaredInfo[key];const extra=renderUserlandPlistEntries(declaredInfo).xml;const plist=join(contents,"Info.plist");const appEntitlements=join(appleDir,"app.entitlements");const helperEntitlements=join(appleDir,"helper.entitlements");writeFileSync(plist,renderInfoPlist(config,executable,extra));writeFileSync(appEntitlements,renderAppEntitlements(config,local,sandboxCheck));writeFileSync(helperEntitlements,renderHelperEntitlements());command(["plutil","-lint",plist,appEntitlements,helperEntitlements]);for(const args of signingPlan({identity:sandboxCheck?"-":config.appSigningIdentity,appPath:app,helperPath:join(macOS,backend),appEntitlements,helperEntitlements,keychain:config.keychain}))command(args);command(["codesign","--verify","--deep","--strict",app]);if(sandboxCheck)return app;await verifyStoreBundle(app,executable,config.minimumMacos);return finishPackage(config,app,appleDir,{architectures:[process.arch==="x64"?"x86_64":process.arch],craft:{kind:"app-store-host",sha256:sha256(runtime)}})}export function unsupportedMacosTarget(loadCommands,minimumMacos){const declared=minimumMacos.split(".").map(Number);const targets=loadCommands.matchAll(/^\s*(?:minos\s+|cmd LC_VERSION_MIN_MACOSX\s*\n\s*cmdsize \d+\s*\n\s*version\s+)(\d+(?:\.\d+){0,2})\s*$/gm);for(const[,target]of targets){if(!target)continue;const components=target.split(".").map(Number);for(let i=0;i<Math.max(components.length,declared.length);i++){const difference=(components[i]??0)-(declared[i]??0);if(difference>0)return target;if(difference<0)break}}}async function verifyStoreBundle(app,executable,minimumMacos){const{bundleDirectoryFor}=await import("@stacksjs/desktop-build");const files=bundleFiles(app);const findings=storeRejectionFindings(files,executable);for(const file of files){const path=join(app,file);if(bundleDirectoryFor(path)!=="MacOS")continue;const deps=Bun.spawnSync(["/usr/bin/otool","-L",path],{stdout:"pipe",stderr:"pipe"});if(deps.exitCode!==0)throw new Error(`Could not inspect the Mach-O dependencies of ${file}`);if(/^\s+\/usr\/lib\/libicucore(?:\.[^\s]+)?\.dylib\s/m.test(deps.stdout.toString()))findings.push(`${file} links Apple's system ICU library, which App Review flagged. Build with a Bun runtime linked to upstream ICU.`);const commands=Bun.spawnSync(["/usr/bin/otool","-l",path],{stdout:"pipe",stderr:"pipe"});if(commands.exitCode!==0)throw new Error(`Could not inspect the Mach-O deployment target of ${file}`);const target=unsupportedMacosTarget(commands.stdout.toString(),minimumMacos);if(target)findings.push(`${file} requires macOS ${target}, later than the app's declared minimum macOS ${minimumMacos}.`)}if(findings.length)throw new Error(`The app bundle failed Store preflight:
|
|
106
106
|
${findings.map((finding)=>` - ${finding}`).join(`
|
|
107
|
-
`)}`)}async function packageNativeApple(config,native){const{prepareMacosAgent,prepareMacosNative}=await import("@stacksjs/actions");const{assembleMacosApp}=await import("@stacksjs/desktop-build");const store={...native,appName:config.appName,executable:config.appName,bundleId:config.bundleId,teamId:config.teamId,version:config.version,buildNumber:config.buildNumber,minimumSystemVersion:config.minimumMacos,category:config.category,...config.icon?{icon:config.icon}:{},sandbox:true};const prepared=await prepareMacosNative(store,{distribution:"app-store"});const agent=store.agent?await prepareMacosAgent(store,prepared,"app-store"):undefined;const appleDir=join(storagePath("framework/desktop/macos"),"apple");if(existsSync(appleDir))rmSync(appleDir,{recursive:true});mkdirSync(appleDir,{recursive:true});const assembled=assembleMacosApp({config:store,root:projectPath(),host:prepared.host,nativeBundle:prepared.nativeBundle,output:appleDir,distribution:"app-store",provisioningProfile:config.provisioningProfile,signingIdentity:config.appSigningIdentity,keychain:config.keychain,agent});for(const note of assembled.notes)await log.warn(note);command(["codesign","-d","--entitlements","-","--xml",assembled.appPath]);await verifyStoreBundle(assembled.appPath,store.executable);return finishPackage(config,assembled.appPath,appleDir,{architectures:[process.arch==="x64"?"x86_64":process.arch],craft:{kind:"native-appkit",hostKey:prepared.hostKey,sha256:sha256(prepared.host)}})}function finishPackage(config,appPath,appleDir,provenance){const packagePath=join(appleDir,`${config.appName}-${config.version}-${config.buildNumber}.pkg`);command(["productbuild","--component",appPath,"/Applications",...config.keychain?["--keychain",config.keychain]:[],"--sign",config.installerSigningIdentity,packagePath]);command(["pkgutil","--check-signature",packagePath]);const packageHash=sha256(packagePath);writeFileSync(join(appleDir,"checksums.sha256"),`${packageHash} ${basename(packagePath)}
|
|
107
|
+
`)}`)}async function packageNativeApple(config,native){const{prepareMacosAgent,prepareMacosNative}=await import("@stacksjs/actions");const{assembleMacosApp}=await import("@stacksjs/desktop-build");const store={...native,appName:config.appName,executable:config.appName,bundleId:config.bundleId,teamId:config.teamId,version:config.version,buildNumber:config.buildNumber,minimumSystemVersion:config.minimumMacos,category:config.category,...config.icon?{icon:config.icon}:{},sandbox:true};const prepared=await prepareMacosNative(store,{distribution:"app-store"});const agent=store.agent?await prepareMacosAgent(store,prepared,"app-store"):undefined;const appleDir=join(storagePath("framework/desktop/macos"),"apple");if(existsSync(appleDir))rmSync(appleDir,{recursive:true});mkdirSync(appleDir,{recursive:true});const assembled=assembleMacosApp({config:store,root:projectPath(),host:prepared.host,nativeBundle:prepared.nativeBundle,output:appleDir,distribution:"app-store",provisioningProfile:config.provisioningProfile,signingIdentity:config.appSigningIdentity,keychain:config.keychain,agent});for(const note of assembled.notes)await log.warn(note);command(["codesign","-d","--entitlements","-","--xml",assembled.appPath]);await verifyStoreBundle(assembled.appPath,store.executable,config.minimumMacos);return finishPackage(config,assembled.appPath,appleDir,{architectures:[process.arch==="x64"?"x86_64":process.arch],craft:{kind:"native-appkit",hostKey:prepared.hostKey,sha256:sha256(prepared.host)}})}function finishPackage(config,appPath,appleDir,provenance){const packagePath=join(appleDir,`${config.appName}-${config.version}-${config.buildNumber}.pkg`);command(["productbuild","--component",appPath,"/Applications",...config.keychain?["--keychain",config.keychain]:[],"--sign",config.installerSigningIdentity,packagePath]);command(["pkgutil","--check-signature",packagePath]);const packageHash=sha256(packagePath);writeFileSync(join(appleDir,"checksums.sha256"),`${packageHash} ${basename(packagePath)}
|
|
108
108
|
`);writeFileSync(join(appleDir,"apple-provenance.json"),`${JSON.stringify({schemaVersion:"1.0.0",appName:config.appName,bundleId:config.bundleId,teamId:config.teamId,version:config.version,buildNumber:config.buildNumber,minimumMacos:config.minimumMacos,architectures:provenance.architectures,package:{name:basename(packagePath),sha256:packageHash},sourceRevision:Bun.spawnSync(["git","rev-parse","HEAD"],{cwd:projectPath()}).stdout.toString().trim(),craft:provenance.craft},null,2)}
|
|
109
109
|
`);return packagePath}function validateOrUpload(packagePath,config,validateOnly){const errors=validateAppleDesktopConfig(config,true);if(errors.length)throw new Error(errors.join(`
|
|
110
110
|
`));const common=["--type","macos","--file",packagePath,"--apiKey",config.apiKeyId,"--apiIssuer",config.apiIssuerId];const keysDirectory=resolve(config.apiKeyPath,"..");const env={API_PRIVATE_KEYS_DIR:keysDirectory};command(["xcrun","altool","--validate-app",...common],projectPath(),env);if(!validateOnly)command(["xcrun","altool","--upload-app",...common],projectPath(),env)}export function renderFailure(error){return`${error instanceof Error?error.message:String(error)}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/buddy",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.75.
|
|
5
|
+
"version": "0.75.652",
|
|
6
6
|
"description": "Meet Buddy. The Stacks runtime.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -95,71 +95,71 @@
|
|
|
95
95
|
"prepublishOnly": "bun run build"
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
|
-
"@stacksjs/actions": "0.75.
|
|
99
|
-
"@stacksjs/docs": "0.75.
|
|
100
|
-
"@stacksjs/ai": "0.75.
|
|
101
|
-
"@stacksjs/alias": "0.75.
|
|
102
|
-
"@stacksjs/analytics": "0.75.
|
|
103
|
-
"@stacksjs/api": "0.75.
|
|
104
|
-
"@stacksjs/arrays": "0.75.
|
|
105
|
-
"@stacksjs/auth": "0.75.
|
|
106
|
-
"@stacksjs/browser-extension": "0.75.
|
|
107
|
-
"@stacksjs/build": "0.75.
|
|
98
|
+
"@stacksjs/actions": "0.75.652",
|
|
99
|
+
"@stacksjs/docs": "0.75.652",
|
|
100
|
+
"@stacksjs/ai": "0.75.652",
|
|
101
|
+
"@stacksjs/alias": "0.75.652",
|
|
102
|
+
"@stacksjs/analytics": "0.75.652",
|
|
103
|
+
"@stacksjs/api": "0.75.652",
|
|
104
|
+
"@stacksjs/arrays": "0.75.652",
|
|
105
|
+
"@stacksjs/auth": "0.75.652",
|
|
106
|
+
"@stacksjs/browser-extension": "0.75.652",
|
|
107
|
+
"@stacksjs/build": "0.75.652",
|
|
108
108
|
"@stacksjs/bumpx": "^0.2.32",
|
|
109
|
-
"@stacksjs/cache": "0.75.
|
|
110
|
-
"@stacksjs/chat": "0.75.
|
|
109
|
+
"@stacksjs/cache": "0.75.652",
|
|
110
|
+
"@stacksjs/chat": "0.75.652",
|
|
111
111
|
"@stacksjs/clapp": "^0.2.17",
|
|
112
|
-
"@stacksjs/cli": "0.75.
|
|
113
|
-
"@stacksjs/cloud": "0.75.
|
|
114
|
-
"@stacksjs/cms": "0.75.
|
|
115
|
-
"@stacksjs/collections": "0.75.
|
|
116
|
-
"@stacksjs/commerce": "0.75.
|
|
117
|
-
"@stacksjs/config": "0.75.
|
|
118
|
-
"@stacksjs/database": "0.75.
|
|
119
|
-
"@stacksjs/desktop-build": "0.75.
|
|
120
|
-
"@stacksjs/dns": "0.75.
|
|
112
|
+
"@stacksjs/cli": "0.75.652",
|
|
113
|
+
"@stacksjs/cloud": "0.75.652",
|
|
114
|
+
"@stacksjs/cms": "0.75.652",
|
|
115
|
+
"@stacksjs/collections": "0.75.652",
|
|
116
|
+
"@stacksjs/commerce": "0.75.652",
|
|
117
|
+
"@stacksjs/config": "0.75.652",
|
|
118
|
+
"@stacksjs/database": "0.75.652",
|
|
119
|
+
"@stacksjs/desktop-build": "0.75.652",
|
|
120
|
+
"@stacksjs/dns": "0.75.652",
|
|
121
121
|
"@stacksjs/dnsx": "^0.2.3",
|
|
122
|
-
"@stacksjs/email": "0.75.
|
|
123
|
-
"@stacksjs/enums": "0.75.
|
|
124
|
-
"@stacksjs/env": "0.75.
|
|
125
|
-
"@stacksjs/error-handling": "0.75.
|
|
126
|
-
"@stacksjs/events": "0.75.
|
|
127
|
-
"@stacksjs/features": "0.75.
|
|
128
|
-
"@stacksjs/git": "0.75.
|
|
122
|
+
"@stacksjs/email": "0.75.652",
|
|
123
|
+
"@stacksjs/enums": "0.75.652",
|
|
124
|
+
"@stacksjs/env": "0.75.652",
|
|
125
|
+
"@stacksjs/error-handling": "0.75.652",
|
|
126
|
+
"@stacksjs/events": "0.75.652",
|
|
127
|
+
"@stacksjs/features": "0.75.652",
|
|
128
|
+
"@stacksjs/git": "0.75.652",
|
|
129
129
|
"@stacksjs/gitit": "^0.2.5",
|
|
130
|
-
"@stacksjs/health": "0.75.
|
|
131
|
-
"@stacksjs/hq": "0.75.
|
|
130
|
+
"@stacksjs/health": "0.75.652",
|
|
131
|
+
"@stacksjs/hq": "0.75.652",
|
|
132
132
|
"@stacksjs/httx": "^0.1.10",
|
|
133
|
-
"@stacksjs/image": "0.75.
|
|
134
|
-
"@stacksjs/lint": "0.75.
|
|
135
|
-
"@stacksjs/logging": "0.75.
|
|
136
|
-
"@stacksjs/notifications": "0.75.
|
|
137
|
-
"@stacksjs/objects": "0.75.
|
|
138
|
-
"@stacksjs/orm": "0.75.
|
|
139
|
-
"@stacksjs/path": "0.75.
|
|
140
|
-
"@stacksjs/payments": "0.75.
|
|
141
|
-
"@stacksjs/realtime": "0.75.
|
|
142
|
-
"@stacksjs/router": "0.75.
|
|
133
|
+
"@stacksjs/image": "0.75.652",
|
|
134
|
+
"@stacksjs/lint": "0.75.652",
|
|
135
|
+
"@stacksjs/logging": "0.75.652",
|
|
136
|
+
"@stacksjs/notifications": "0.75.652",
|
|
137
|
+
"@stacksjs/objects": "0.75.652",
|
|
138
|
+
"@stacksjs/orm": "0.75.652",
|
|
139
|
+
"@stacksjs/path": "0.75.652",
|
|
140
|
+
"@stacksjs/payments": "0.75.652",
|
|
141
|
+
"@stacksjs/realtime": "0.75.652",
|
|
142
|
+
"@stacksjs/router": "0.75.652",
|
|
143
143
|
"@stacksjs/rpx": "^0.11.54",
|
|
144
|
-
"@stacksjs/scheduler": "0.75.
|
|
145
|
-
"@stacksjs/search-engine": "0.75.
|
|
146
|
-
"@stacksjs/security": "0.75.
|
|
147
|
-
"@stacksjs/server": "0.75.
|
|
148
|
-
"@stacksjs/sites": "0.75.
|
|
149
|
-
"@stacksjs/skills": "0.75.
|
|
150
|
-
"@stacksjs/socials": "0.75.
|
|
151
|
-
"@stacksjs/storage": "0.75.
|
|
152
|
-
"@stacksjs/strings": "0.75.
|
|
144
|
+
"@stacksjs/scheduler": "0.75.652",
|
|
145
|
+
"@stacksjs/search-engine": "0.75.652",
|
|
146
|
+
"@stacksjs/security": "0.75.652",
|
|
147
|
+
"@stacksjs/server": "0.75.652",
|
|
148
|
+
"@stacksjs/sites": "0.75.652",
|
|
149
|
+
"@stacksjs/skills": "0.75.652",
|
|
150
|
+
"@stacksjs/socials": "0.75.652",
|
|
151
|
+
"@stacksjs/storage": "0.75.652",
|
|
152
|
+
"@stacksjs/strings": "0.75.652",
|
|
153
153
|
"@stacksjs/stx": "^0.2.908",
|
|
154
|
-
"@stacksjs/testing": "0.75.
|
|
155
|
-
"@stacksjs/tinker": "0.75.
|
|
154
|
+
"@stacksjs/testing": "0.75.652",
|
|
155
|
+
"@stacksjs/tinker": "0.75.652",
|
|
156
156
|
"@stacksjs/tlsx": "^0.13.19",
|
|
157
157
|
"@stacksjs/ts-cloud": "^0.16.144",
|
|
158
|
-
"@stacksjs/tunnel": "0.75.
|
|
159
|
-
"@stacksjs/types": "0.75.
|
|
160
|
-
"@stacksjs/ui": "0.75.
|
|
161
|
-
"@stacksjs/utils": "0.75.
|
|
162
|
-
"@stacksjs/validation": "0.75.
|
|
158
|
+
"@stacksjs/tunnel": "0.75.652",
|
|
159
|
+
"@stacksjs/types": "0.75.652",
|
|
160
|
+
"@stacksjs/ui": "0.75.652",
|
|
161
|
+
"@stacksjs/utils": "0.75.652",
|
|
162
|
+
"@stacksjs/validation": "0.75.652",
|
|
163
163
|
"ajv": "^8.20.0",
|
|
164
164
|
"ajv-formats": "^3.0.1",
|
|
165
165
|
"bun-plugin-stx": "^0.2.908",
|