@stacksjs/buddy 0.75.592 → 0.75.593
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.
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{appendFile,mkdir,writeFile}from"node:fs/promises";import{dirname,resolve}from"node:path";async function output(values){console.log(JSON.stringify(values));if(process.env.GITHUB_OUTPUT){for(const[key,value]of Object.entries(values)){if(!/^[a-z_]+$/.test(key)||/[\r\n]/.test(String(value)))throw new Error("Invalid workflow output");await appendFile(process.env.GITHUB_OUTPUT,`${key}=${value}
|
|
2
|
+
`)}}}async function save(path,value){if(!path){console.log(JSON.stringify(value,null,2));return}await mkdir(dirname(resolve(path)),{recursive:true});await writeFile(resolve(path),`${JSON.stringify(value,null,2)}
|
|
3
|
+
`)}export function releaseLibrary(buddy){const command=(name,description)=>buddy.command(name,description).option("--directory <path>","Retained native library candidate directory");command("release:prepare","Build, check and retain the exact source library candidate for normal CI").option("--dry-run","Validate the real library plan without writing files",{default:false}).action(async(options)=>{const{prepareNativeLibraryRelease,LIBRARY_CANDIDATE_DIRECTORY}=await import("@stacksjs/actions/library/release-lifecycle");const result=await prepareNativeLibraryRelease({cwd:process.cwd(),directory:resolve(options.directory??LIBRARY_CANDIDATE_DIRECTORY),dryRun:options.dryRun,runId:Number(process.env.GITHUB_RUN_ID),runAttempt:Number(process.env.GITHUB_RUN_ATTEMPT),branch:process.env.GITHUB_HEAD_REF||process.env.GITHUB_REF_NAME});await output({prepared:result.prepared,source_eligible:result.prepared&&result.sourceEligible})});command("release:accept","Accept exact successful source CI and download its original library candidate").option("--tag <tag>","Actual release tag (defaults to GITHUB_REF_NAME)").option("--run-id <id>","Exact source CI run for a historical readback or retry").option("--historical","Read-only acquisition using current source policy, independent of current public package definitions",{default:false}).action(async(options)=>{const{acceptNativeLibraryRelease,LIBRARY_CANDIDATE_DIRECTORY}=await import("@stacksjs/actions/library/release-lifecycle");const receipt=await acceptNativeLibraryRelease({cwd:process.cwd(),directory:resolve(options.directory??LIBRARY_CANDIDATE_DIRECTORY),tag:options.tag??process.env.GITHUB_REF_NAME??"",token:process.env.GITHUB_TOKEN,historical:options.historical,runId:options.runId===undefined?undefined:Number(options.runId)});await output({accepted:!!receipt,...receipt?{source_sha:receipt.source.commit,artifact_id:String(receipt.artifact.id)}:{}})});command("release:publish","Publish only accepted original archives and verify actual registry bytes and tags").option("--dry-run","Validate retained publisher input without uploading",{default:false}).action(async(options)=>{const{publishNativeLibraryRelease,LIBRARY_CANDIDATE_DIRECTORY}=await import("@stacksjs/actions/library/release-lifecycle");await save(undefined,await publishNativeLibraryRelease({cwd:process.cwd(),directory:resolve(options.directory??LIBRARY_CANDIDATE_DIRECTORY),token:process.env.GITHUB_TOKEN,dryRun:options.dryRun}))});command("release:readback","Verify retained historical library bytes using only the current verifier").option("--output <path>","Save the read-only registry verification receipt").action(async(options)=>{const{readbackNativeLibraryRelease,LIBRARY_CANDIDATE_DIRECTORY}=await import("@stacksjs/actions/library/release-lifecycle");await save(options.output,await readbackNativeLibraryRelease({cwd:process.cwd(),directory:resolve(options.directory??LIBRARY_CANDIDATE_DIRECTORY),token:process.env.GITHUB_TOKEN}))})}
|
package/dist/commands/release.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{execFileSync}from"node:child_process";import{existsSync,readFileSync,renameSync,rmSync,writeFileSync}from"node:fs";import{join}from"node:path";import{pathToFileURL}from"node:url";import process from"node:process";import{resolveXcodegen}from"@stacksjs/actions/build/ios-toolchain";import{describeGitHubRelease,publishGitHubRelease,resolveGitHubToken}from"@stacksjs/actions/github-release";import{validateReleaseEvidencePlan,verifyReleaseEvidence}from"@stacksjs/actions/release-evidence";import{assertPublicationAllowed}from"@stacksjs/actions/publication-preflight";import{runAction}from"@stacksjs/actions/run-action";import{intro,italic,log,onUnknownSubcommand,outro}from"@stacksjs/cli";import{printAsync}from"@stacksjs/cli/output";import{Action}from"@stacksjs/enums";import{withholdEnv}from"@stacksjs/env";import{ExitCode}from"@stacksjs/types";import{AppStoreConnect,appStoreConnectCredentials,buildsToExpire,waitForBuild}from"../app-store-connect";import{bumpedVersion,iosReleaseSummary,iosVersionIn,nextBuildTag,pushIosReleaseTag,unreleasableSite,withIosVersion}from"../release-ios";import{appStoreLocales,commitsBetween,committedWhatToTest,fitNotes,NO_VISIBLE_CHANGES,PLAY_NOTES_LIMIT,previousMobileTag,resolveNotes,TESTFLIGHT_NOTES_LIMIT,testerNotes,writeWhatToTest,XCODE_CLOUD_NOTES_LIMIT}from"@stacksjs/actions/release-notes";import{resultFailed}from"../result";const descriptions={release:"Release a new version of your libraries/packages",project:"Target a specific project",dryRun:"Run the release without actually releasing",bump:"Non-interactive bump: patch | minor | major | prepatch | preminor | premajor | prerelease | pre | release | build | calendar | x.y.z",verbose:"Enable verbose output",skipGithubRelease:"Push the tag without creating its GitHub release"};const IOS_PROJECT_DIR="storage/framework/mobile/ios";const DEFAULT_WAIT_MINUTES=60;async function loadMobileConfig(configPath){return(await import(pathToFileURL(configPath).href)).default??{}}export function waitMinutes(value){if(value===undefined||value===false)return null;if(value===true||value==="")return DEFAULT_WAIT_MINUTES;const minutes=Number(value);if(!Number.isFinite(minutes)||minutes<0)throw new Error(`--wait takes minutes, not ${String(value)}`);return minutes}export function retainedBuildCount(value){if(value!==undefined&&typeof value!=="number"&&typeof value!=="string"||typeof value==="string"&&!/^(0|[1-9]\d*)$/.test(value.trim()))throw new Error("--keep-builds needs a nonnegative integer");const count=Number(value??1);if(!Number.isSafeInteger(count)||count<0)throw new Error("--keep-builds needs a nonnegative integer");return count}function buildNumberOf(tag){const match=/^v(\d+\.\d+\.\d+)-build\.(\d+)$/.exec(tag);if(!match)throw new Error(`${tag} is not an iOS build tag (v<version>-build.<n>)`);return{version:match[1],number:Number(match[2])}}function notesLocales(mobile){return mobile.release?.locales?.length?[...new Set(mobile.release.locales)]:appStoreLocales(mobile.ios?.nativeMessages?.languages)}async function applyWhatToTest(store,tag,notes,locales,minutes){try{const{version,number}=buildNumberOf(tag);if(minutes>0)log.info(`Waiting up to ${minutes} min for TestFlight build ${number} to reach App Store Connect…`);const build=await waitForBuild(store.api,store.appId,version,number,{timeoutMs:minutes*60000,onWait:(elapsed)=>log.debug(`TestFlight build ${number} not there yet (${Math.round(elapsed/1000)}s)`)});if(!build){log.warn(`TestFlight build ${number} is not in App Store Connect yet; once it is, run \`buddy release:notes ${tag} --testflight\`.`);return false}const text=fitNotes(notes,TESTFLIGHT_NOTES_LIMIT);await store.api.setWhatToTest(build.id,Object.fromEntries(locales.map((locale)=>[locale,text])));log.info(`Set What to Test on TestFlight build ${number} (${locales.join(", ")})`);return true}catch(error){log.warn(`Could not set What to Test: ${error instanceof Error?error.message:String(error)}. Retry with \`buddy release:notes ${tag} --testflight\`.`);return false}}async function deliverTestFlight(store,tag,notes,locales,minutes,groups,keep){const{version,number}=buildNumberOf(tag);try{const build=await store.api.deliverBuild(store.appId,version,number,{timeoutMs:minutes*60000,groups,keepBuilds:keep,notes:notes===undefined?undefined:Object.fromEntries(locales.map((locale)=>[locale,fitNotes(notes,TESTFLIGHT_NOTES_LIMIT)])),onWait:(elapsed)=>log.debug(`TestFlight build ${number} is not ready for its testers (${Math.round(elapsed/1000)}s)`)});if(build){log.info(`TestFlight build ${number} is IN_BETA_TESTING${groups.length?` for ${groups.join(", ")}`:""}; older build retention is complete`);return true}log.warn(`TestFlight build ${number} is not available to its testers yet. Older builds remain available. Resume with \`buddy release:testflight ${tag} --wait\`.`)}catch(error){log.warn(`TestFlight delivery is incomplete: ${error instanceof Error?error.message:String(error)}. Resume with \`buddy release:testflight ${tag} --wait\`.`)}return false}function githubSummary(summary,notes){return`${summary.trim()}
|
|
1
|
+
import{releaseLibrary}from"./release-library";import{execFileSync}from"node:child_process";import{existsSync,readFileSync,renameSync,rmSync,writeFileSync}from"node:fs";import{join}from"node:path";import{pathToFileURL}from"node:url";import process from"node:process";import{resolveXcodegen}from"@stacksjs/actions/build/ios-toolchain";import{describeGitHubRelease,publishGitHubRelease,resolveGitHubToken}from"@stacksjs/actions/github-release";import{validateReleaseEvidencePlan,verifyReleaseEvidence}from"@stacksjs/actions/release-evidence";import{assertPublicationAllowed}from"@stacksjs/actions/publication-preflight";import{runAction}from"@stacksjs/actions/run-action";import{intro,italic,log,onUnknownSubcommand,outro}from"@stacksjs/cli";import{printAsync}from"@stacksjs/cli/output";import{Action}from"@stacksjs/enums";import{withholdEnv}from"@stacksjs/env";import{ExitCode}from"@stacksjs/types";import{AppStoreConnect,appStoreConnectCredentials,buildsToExpire,waitForBuild}from"../app-store-connect";import{bumpedVersion,iosReleaseSummary,iosVersionIn,nextBuildTag,pushIosReleaseTag,unreleasableSite,withIosVersion}from"../release-ios";import{appStoreLocales,commitsBetween,committedWhatToTest,fitNotes,NO_VISIBLE_CHANGES,PLAY_NOTES_LIMIT,previousMobileTag,resolveNotes,TESTFLIGHT_NOTES_LIMIT,testerNotes,writeWhatToTest,XCODE_CLOUD_NOTES_LIMIT}from"@stacksjs/actions/release-notes";import{resultFailed}from"../result";const descriptions={release:"Release a new version of your libraries/packages",project:"Target a specific project",dryRun:"Run the release without actually releasing",bump:"Non-interactive bump: patch | minor | major | prepatch | preminor | premajor | prerelease | pre | release | build | calendar | x.y.z",verbose:"Enable verbose output",skipGithubRelease:"Push the tag without creating its GitHub release"};const IOS_PROJECT_DIR="storage/framework/mobile/ios";const DEFAULT_WAIT_MINUTES=60;async function loadMobileConfig(configPath){return(await import(pathToFileURL(configPath).href)).default??{}}export function waitMinutes(value){if(value===undefined||value===false)return null;if(value===true||value==="")return DEFAULT_WAIT_MINUTES;const minutes=Number(value);if(!Number.isFinite(minutes)||minutes<0)throw new Error(`--wait takes minutes, not ${String(value)}`);return minutes}export function retainedBuildCount(value){if(value!==undefined&&typeof value!=="number"&&typeof value!=="string"||typeof value==="string"&&!/^(0|[1-9]\d*)$/.test(value.trim()))throw new Error("--keep-builds needs a nonnegative integer");const count=Number(value??1);if(!Number.isSafeInteger(count)||count<0)throw new Error("--keep-builds needs a nonnegative integer");return count}function buildNumberOf(tag){const match=/^v(\d+\.\d+\.\d+)-build\.(\d+)$/.exec(tag);if(!match)throw new Error(`${tag} is not an iOS build tag (v<version>-build.<n>)`);return{version:match[1],number:Number(match[2])}}function notesLocales(mobile){return mobile.release?.locales?.length?[...new Set(mobile.release.locales)]:appStoreLocales(mobile.ios?.nativeMessages?.languages)}async function applyWhatToTest(store,tag,notes,locales,minutes){try{const{version,number}=buildNumberOf(tag);if(minutes>0)log.info(`Waiting up to ${minutes} min for TestFlight build ${number} to reach App Store Connect…`);const build=await waitForBuild(store.api,store.appId,version,number,{timeoutMs:minutes*60000,onWait:(elapsed)=>log.debug(`TestFlight build ${number} not there yet (${Math.round(elapsed/1000)}s)`)});if(!build){log.warn(`TestFlight build ${number} is not in App Store Connect yet; once it is, run \`buddy release:notes ${tag} --testflight\`.`);return false}const text=fitNotes(notes,TESTFLIGHT_NOTES_LIMIT);await store.api.setWhatToTest(build.id,Object.fromEntries(locales.map((locale)=>[locale,text])));log.info(`Set What to Test on TestFlight build ${number} (${locales.join(", ")})`);return true}catch(error){log.warn(`Could not set What to Test: ${error instanceof Error?error.message:String(error)}. Retry with \`buddy release:notes ${tag} --testflight\`.`);return false}}async function deliverTestFlight(store,tag,notes,locales,minutes,groups,keep){const{version,number}=buildNumberOf(tag);try{const build=await store.api.deliverBuild(store.appId,version,number,{timeoutMs:minutes*60000,groups,keepBuilds:keep,notes:notes===undefined?undefined:Object.fromEntries(locales.map((locale)=>[locale,fitNotes(notes,TESTFLIGHT_NOTES_LIMIT)])),onWait:(elapsed)=>log.debug(`TestFlight build ${number} is not ready for its testers (${Math.round(elapsed/1000)}s)`)});if(build){log.info(`TestFlight build ${number} is IN_BETA_TESTING${groups.length?` for ${groups.join(", ")}`:""}; older build retention is complete`);return true}log.warn(`TestFlight build ${number} is not available to its testers yet. Older builds remain available. Resume with \`buddy release:testflight ${tag} --wait\`.`)}catch(error){log.warn(`TestFlight delivery is incomplete: ${error instanceof Error?error.message:String(error)}. Resume with \`buddy release:testflight ${tag} --wait\`.`)}return false}function githubSummary(summary,notes){return`${summary.trim()}
|
|
2
2
|
|
|
3
3
|
## What to Test
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ ${notes.trim()}`}function git(...args){return execFileSync("git",args,{encoding:
|
|
|
7
7
|
|
|
8
8
|
${fitNotes(notes.text,XCODE_CLOUD_NOTES_LIMIT)}`);if(store){const retiring=buildsToExpire(await store.api.builds(store.appId),keep);log.info(retiring.length?`After the new build is available to its testers, would expire TestFlight builds ${retiring.map((b)=>b.number).join(", ")}`:"No TestFlight builds to expire")}if(!options.skipGithubRelease){const preview=await publishGitHubRelease({cwd:root,tag,ref:"HEAD",name:summary.name,summary:githubSummary(summary.body,githubNotes),dryRun:true});log.info(preview.draft?`Would create the GitHub release ${tag} (${preview.draft.name}):
|
|
9
9
|
|
|
10
|
-
${preview.draft.body}`:describeGitHubRelease(tag,preview))}return tag}const paths=["config/mobile.ts","storage/framework/mobile/ios"];if(version!==current){writeFileSync(configPath,withIosVersion(source,version));const pkgPath=join(root,"package.json");if(existsSync(pkgPath)){const pkg=readFileSync(pkgPath,"utf8");writeFileSync(pkgPath,pkg.replace(/("version"\s*:\s*)"[^"]*"/,`$1"${version}"`));paths.push("package.json")}}const devOverrides=["MOBILE_URL","IOS_APP_VERSION","IOS_BUILD_NUMBER"];for(const key of devOverrides)delete process.env[key];const result=await runAction(Action.BuildIos,{env:{...withholdEnv(devOverrides),NODE_ENV:"production"}});if(resultFailed(result))throw result.error??new Error("the iOS build failed");const craftConfigPath=join(root,IOS_PROJECT_DIR,"craft.config.json");if(existsSync(craftConfigPath)){const problem=unreleasableSite(JSON.parse(readFileSync(craftConfigPath,"utf8")));if(problem)throw new Error(`${problem}. Set ios.url in config/mobile.ts to the production site. Nothing was committed, tagged or pushed; restore the build output and any version bump with \`git checkout -- ${paths.join(" ")}\`.`)}const written=writeWhatToTest(root,IOS_PROJECT_DIR,notes.text,locales);log.info(`What to Test from ${origin}: ${written.join(", ")}`);git("add","--",...paths);if(git("diff","--cached","--name-only"))git("commit","--quiet","-m",`chore(release): ${tag}`);pushIosReleaseTag(root,tag);if(!options.skipGithubRelease){const published=await publishGitHubRelease({cwd:root,tag,name:summary.name,summary:githubSummary(summary.body,githubNotes)});if(published.status==="failed")log.warn(describeGitHubRelease(tag,published));else log.info(describeGitHubRelease(tag,published))}if(store){if(wait!==null&&numberedByXcodeCloud){if(!await deliverTestFlight(store,tag,notes.text,locales,wait,groups,keep))process.exitCode=ExitCode.FatalError}else log.info(`Older TestFlight builds are retained. Complete tester delivery with \`buddy release:testflight ${tag} --wait\`.`)}return tag}function notesForTag(root,tag,mobile,options){const releaseConfig=mobile.release??{};const generateOptions={types:releaseConfig.noteTypes,excludeScopes:releaseConfig.excludeScopes};const from=options.from||previousMobileTag(root,`${tag}^`);const commits=commitsBetween(root,from,tag);const plainGenerated=testerNotes(commits,generateOptions)||NO_VISIBLE_CHANGES;const committed=options.from?null:committedWhatToTest(root,tag,IOS_PROJECT_DIR);const handWritten=committed&&committed.trim()!==fitNotes(plainGenerated,XCODE_CLOUD_NOTES_LIMIT)?committed.trim():null;const notes=resolveNotes({cwd:root,flags:options,config:releaseConfig,generate:()=>handWritten??plainGenerated});if(notes.source!=="generated"||handWritten)return{text:notes.text,plain:notes.text};return{text:options.markdown?testerNotes(commits,{...generateOptions,markdown:true})||NO_VISIBLE_CHANGES:plainGenerated,plain:plainGenerated}}async function releaseNotesCommand(tagArgument,options){const root=process.cwd();const configPath=join(root,"config/mobile.ts");const mobile=existsSync(configPath)?await loadMobileConfig(configPath):{};const tag=tagArgument||previousMobileTag(root,"HEAD");if(!tag||!git("tag","--list",tag))throw new Error(tagArgument?`there is no tag ${tagArgument}`:"there is no mobile release tag (v*-build.*) yet");const notes=notesForTag(root,tag,mobile,options);if(options.testflight){const credentials=appStoreConnectCredentials();if(!credentials)throw new Error("--testflight needs an App Store Connect API key (APP_STORE_CONNECT_KEY_ID, _ISSUER_ID, _PRIVATE_KEY_PATH)");const bundleId=mobile.ios?.bundleId;if(!bundleId)throw new Error("config/mobile.ts declares no ios.bundleId");const api=await AppStoreConnect.connect(credentials);const store={api,appId:await api.appId(bundleId)};if(!await applyWhatToTest(store,tag,notes.plain,notesLocales(mobile),waitMinutes(options.wait)??0))process.exitCode=ExitCode.FatalError;return}const limit=options.play?PLAY_NOTES_LIMIT:options.markdown?Number.POSITIVE_INFINITY:TESTFLIGHT_NOTES_LIMIT;await printAsync(Number.isFinite(limit)?fitNotes(notes.text,limit):notes.text)}async function releaseTestFlightCommand(tagArgument,options){const root=process.cwd();if(!options.dryRun)await assertPublicationAllowed({cwd:root,channel:"ios"});const mobile=await loadMobileConfig(join(root,"config/mobile.ts"));const tag=tagArgument||previousMobileTag(root,"HEAD");if(!tag||!git("tag","--list",tag))throw new Error("Select an existing mobile release tag");buildNumberOf(tag);const credentials=appStoreConnectCredentials();if(!credentials||!mobile.ios?.bundleId)throw new Error("TestFlight delivery needs an App Store Connect API key and ios.bundleId");const api=await AppStoreConnect.connect(credentials);const store={api,appId:await api.appId(mobile.ios.bundleId)};const groups=mobile.ios.testFlightGroups??[];await api.internalTestFlightGroups(store.appId,groups);const keep=retainedBuildCount(options.keepBuilds);if(options.dryRun){log.info(`Would deliver ${tag}${groups.length?` to ${groups.join(", ")}`:" using its existing internal tester access"}, confirm IN_BETA_TESTING, then retain ${keep} older builds. Nothing was distributed or expired.`);return}if(!await deliverTestFlight(store,tag,undefined,notesLocales(mobile),waitMinutes(options.wait)??DEFAULT_WAIT_MINUTES,groups,keep))process.exitCode=ExitCode.FatalError}export function release(buddy){buddy.command("release",descriptions.release).option("--dry-run",descriptions.dryRun,{default:false}).option("-p, --project [project]",descriptions.project,{default:false}).option("--bump <type>",descriptions.bump).option("--preid <identifier>","Prerelease channel, for example beta or rc").option("--skip-github-release",descriptions.skipGithubRelease,{default:false}).option("--verbose",descriptions.verbose,{default:false}).action(async(options)=>{log.debug("Running `buddy release` ...",options);if(options.dryRun)log.warn("Dry run enabled. No changes will be made or committed.");const startTime=await intro("buddy release");const result=await runAction(Action.Release,options);if(resultFailed(result)){await log.error("Failed to release",result.error);process.exit(ExitCode.FatalError)}await outro(options.dryRun?"Dry run complete. Nothing was committed, tagged or pushed.":"Triggered CI/CD Release via GitHub Actions",{startTime,useSeconds:true});if(!options.dryRun)log.info(`Follow along: ${italic(resolveGitHubActionsUrl(readOriginRemote()))}`)});buddy.command("release:ios","Ship the iOS app: regenerate its project for production, commit, tag and push").option("--bump <type>","build | patch | minor | major | x.y.z (default: a new build of the current marketing version)").option("--keep-builds <n>","Older TestFlight builds to retain after the replacement is available to testers (needs an App Store Connect API key)",{default:1}).option("--skip-github-release",descriptions.skipGithubRelease,{default:false}).option("--notes <text>","What to Test for this build, instead of the notes generated from the commits since the previous build").option("--notes-file <path>","Read What to Test from a file (also RELEASE_NOTES / RELEASE_NOTES_FILE, or release.notes in config/mobile.ts)").option("--wait [minutes]","Wait for processing, notes and configured internal TestFlight group delivery (default 60 minutes; needs an App Store Connect API key)").option("--dry-run",descriptions.dryRun,{default:false}).action(async(options)=>{const startTime=await intro("buddy release:ios");try{const tag=await releaseIos(options);await outro(options.dryRun?`Dry run complete: would release ${tag}`:process.exitCode?`Published ${tag}; TestFlight delivery is incomplete`:`Released ${tag}`,{startTime,useSeconds:true});if(!options.dryRun)log.info('A CI that builds tags (Xcode Cloud: Tag Changes, prefix "v") turns it into a TestFlight build now.')}catch(error){await log.error("Failed to release the iOS app",error);process.exit(ExitCode.FatalError)}});buddy.command("release:testflight [tag]","Complete internal tester delivery for an existing iOS release tag").option("--wait [minutes]","Wait for processing and tester availability (default 60 minutes)").option("--keep-builds <n>","Older builds to retain after tester delivery succeeds",{default:1}).option("--dry-run",descriptions.dryRun,{default:false}).action(async(tag,options)=>{try{await releaseTestFlightCommand(tag,options)}catch(error){await log.error("Failed to deliver the TestFlight build",error);process.exit(ExitCode.FatalError)}});buddy.command("release:notes [tag]","Print the tester notes of a mobile release tag (default: the newest v*-build.* tag), or set them as its TestFlight What to Test").option("--from <ref>","Generate from the commits since this ref instead of the previous build tag").option("--play","Fit the notes to Google Play's 500-character What's new",{default:false}).option("--markdown","Markdown, as the GitHub release shows the notes",{default:false}).option("--testflight","Set the notes as the TestFlight build's What to Test through App Store Connect",{default:false}).option("--wait [minutes]","With --testflight: wait this long for the build to appear (default 60)").option("--notes <text>","Use this text instead").option("--notes-file <path>","Read the text from a file instead").action(async(tag,options)=>{try{await releaseNotesCommand(tag,options)}catch(error){await log.error("Failed to produce the release notes",error);process.exit(ExitCode.FatalError)}});buddy.command("release:github [tag]","Create the GitHub release for a pushed tag (default: the newest), with the changes since the tag before it").option("--dry-run","Print the release instead of creating it",{default:false}).action(async(tag,options)=>{const startTime=await intro("buddy release:github");try{if(!options.dryRun)await assertPublicationAllowed({cwd:process.cwd(),channel:"github-release"});const target=tag||git("describe","--tags","--abbrev=0");if(!git("tag","--list",target))throw new Error(`there is no tag ${target}`);const ios=/^v\d+\.\d+\.\d+-build\.\d+$/.test(target)?iosReleaseSummary(target,{numberedByXcodeCloud:appStoreConnectCredentials()!==null}):null;let summary=ios?.body;if(ios){const configPath=join(process.cwd(),"config/mobile.ts");const mobile=existsSync(configPath)?await loadMobileConfig(configPath):{};summary=githubSummary(ios.body,notesForTag(process.cwd(),target,mobile,{markdown:true}).text)}const result=await publishGitHubRelease({cwd:process.cwd(),tag:target,name:ios?.name,summary,dryRun:options.dryRun});if(result.status==="failed")throw new Error(describeGitHubRelease(target,result));log.info(options.dryRun&&result.draft?`Would create the GitHub release ${target} (${result.draft.name}):
|
|
10
|
+
${preview.draft.body}`:describeGitHubRelease(tag,preview))}return tag}const paths=["config/mobile.ts","storage/framework/mobile/ios"];if(version!==current){writeFileSync(configPath,withIosVersion(source,version));const pkgPath=join(root,"package.json");if(existsSync(pkgPath)){const pkg=readFileSync(pkgPath,"utf8");writeFileSync(pkgPath,pkg.replace(/("version"\s*:\s*)"[^"]*"/,`$1"${version}"`));paths.push("package.json")}}const devOverrides=["MOBILE_URL","IOS_APP_VERSION","IOS_BUILD_NUMBER"];for(const key of devOverrides)delete process.env[key];const result=await runAction(Action.BuildIos,{env:{...withholdEnv(devOverrides),NODE_ENV:"production"}});if(resultFailed(result))throw result.error??new Error("the iOS build failed");const craftConfigPath=join(root,IOS_PROJECT_DIR,"craft.config.json");if(existsSync(craftConfigPath)){const problem=unreleasableSite(JSON.parse(readFileSync(craftConfigPath,"utf8")));if(problem)throw new Error(`${problem}. Set ios.url in config/mobile.ts to the production site. Nothing was committed, tagged or pushed; restore the build output and any version bump with \`git checkout -- ${paths.join(" ")}\`.`)}const written=writeWhatToTest(root,IOS_PROJECT_DIR,notes.text,locales);log.info(`What to Test from ${origin}: ${written.join(", ")}`);git("add","--",...paths);if(git("diff","--cached","--name-only"))git("commit","--quiet","-m",`chore(release): ${tag}`);pushIosReleaseTag(root,tag);if(!options.skipGithubRelease){const published=await publishGitHubRelease({cwd:root,tag,name:summary.name,summary:githubSummary(summary.body,githubNotes)});if(published.status==="failed")log.warn(describeGitHubRelease(tag,published));else log.info(describeGitHubRelease(tag,published))}if(store){if(wait!==null&&numberedByXcodeCloud){if(!await deliverTestFlight(store,tag,notes.text,locales,wait,groups,keep))process.exitCode=ExitCode.FatalError}else log.info(`Older TestFlight builds are retained. Complete tester delivery with \`buddy release:testflight ${tag} --wait\`.`)}return tag}function notesForTag(root,tag,mobile,options){const releaseConfig=mobile.release??{};const generateOptions={types:releaseConfig.noteTypes,excludeScopes:releaseConfig.excludeScopes};const from=options.from||previousMobileTag(root,`${tag}^`);const commits=commitsBetween(root,from,tag);const plainGenerated=testerNotes(commits,generateOptions)||NO_VISIBLE_CHANGES;const committed=options.from?null:committedWhatToTest(root,tag,IOS_PROJECT_DIR);const handWritten=committed&&committed.trim()!==fitNotes(plainGenerated,XCODE_CLOUD_NOTES_LIMIT)?committed.trim():null;const notes=resolveNotes({cwd:root,flags:options,config:releaseConfig,generate:()=>handWritten??plainGenerated});if(notes.source!=="generated"||handWritten)return{text:notes.text,plain:notes.text};return{text:options.markdown?testerNotes(commits,{...generateOptions,markdown:true})||NO_VISIBLE_CHANGES:plainGenerated,plain:plainGenerated}}async function releaseNotesCommand(tagArgument,options){const root=process.cwd();const configPath=join(root,"config/mobile.ts");const mobile=existsSync(configPath)?await loadMobileConfig(configPath):{};const tag=tagArgument||previousMobileTag(root,"HEAD");if(!tag||!git("tag","--list",tag))throw new Error(tagArgument?`there is no tag ${tagArgument}`:"there is no mobile release tag (v*-build.*) yet");const notes=notesForTag(root,tag,mobile,options);if(options.testflight){const credentials=appStoreConnectCredentials();if(!credentials)throw new Error("--testflight needs an App Store Connect API key (APP_STORE_CONNECT_KEY_ID, _ISSUER_ID, _PRIVATE_KEY_PATH)");const bundleId=mobile.ios?.bundleId;if(!bundleId)throw new Error("config/mobile.ts declares no ios.bundleId");const api=await AppStoreConnect.connect(credentials);const store={api,appId:await api.appId(bundleId)};if(!await applyWhatToTest(store,tag,notes.plain,notesLocales(mobile),waitMinutes(options.wait)??0))process.exitCode=ExitCode.FatalError;return}const limit=options.play?PLAY_NOTES_LIMIT:options.markdown?Number.POSITIVE_INFINITY:TESTFLIGHT_NOTES_LIMIT;await printAsync(Number.isFinite(limit)?fitNotes(notes.text,limit):notes.text)}async function releaseTestFlightCommand(tagArgument,options){const root=process.cwd();if(!options.dryRun)await assertPublicationAllowed({cwd:root,channel:"ios"});const mobile=await loadMobileConfig(join(root,"config/mobile.ts"));const tag=tagArgument||previousMobileTag(root,"HEAD");if(!tag||!git("tag","--list",tag))throw new Error("Select an existing mobile release tag");buildNumberOf(tag);const credentials=appStoreConnectCredentials();if(!credentials||!mobile.ios?.bundleId)throw new Error("TestFlight delivery needs an App Store Connect API key and ios.bundleId");const api=await AppStoreConnect.connect(credentials);const store={api,appId:await api.appId(mobile.ios.bundleId)};const groups=mobile.ios.testFlightGroups??[];await api.internalTestFlightGroups(store.appId,groups);const keep=retainedBuildCount(options.keepBuilds);if(options.dryRun){log.info(`Would deliver ${tag}${groups.length?` to ${groups.join(", ")}`:" using its existing internal tester access"}, confirm IN_BETA_TESTING, then retain ${keep} older builds. Nothing was distributed or expired.`);return}if(!await deliverTestFlight(store,tag,undefined,notesLocales(mobile),waitMinutes(options.wait)??DEFAULT_WAIT_MINUTES,groups,keep))process.exitCode=ExitCode.FatalError}export function release(buddy){releaseLibrary(buddy);buddy.command("release",descriptions.release).option("--dry-run",descriptions.dryRun,{default:false}).option("-p, --project [project]",descriptions.project,{default:false}).option("--bump <type>",descriptions.bump).option("--preid <identifier>","Prerelease version identifier, for example beta or rc (registry channel is library.release.distTag)").option("--skip-github-release",descriptions.skipGithubRelease,{default:false}).option("--verbose",descriptions.verbose,{default:false}).action(async(options)=>{log.debug("Running `buddy release` ...",options);if(options.dryRun)log.warn("Dry run enabled. No changes will be made or committed.");const startTime=await intro("buddy release");const result=await runAction(Action.Release,options);if(resultFailed(result)){await log.error("Failed to release",result.error);process.exit(ExitCode.FatalError)}await outro(options.dryRun?"Dry run complete. Nothing was committed, tagged or pushed.":"Triggered CI/CD Release via GitHub Actions",{startTime,useSeconds:true});if(!options.dryRun)log.info(`Follow along: ${italic(resolveGitHubActionsUrl(readOriginRemote()))}`)});buddy.command("release:ios","Ship the iOS app: regenerate its project for production, commit, tag and push").option("--bump <type>","build | patch | minor | major | x.y.z (default: a new build of the current marketing version)").option("--keep-builds <n>","Older TestFlight builds to retain after the replacement is available to testers (needs an App Store Connect API key)",{default:1}).option("--skip-github-release",descriptions.skipGithubRelease,{default:false}).option("--notes <text>","What to Test for this build, instead of the notes generated from the commits since the previous build").option("--notes-file <path>","Read What to Test from a file (also RELEASE_NOTES / RELEASE_NOTES_FILE, or release.notes in config/mobile.ts)").option("--wait [minutes]","Wait for processing, notes and configured internal TestFlight group delivery (default 60 minutes; needs an App Store Connect API key)").option("--dry-run",descriptions.dryRun,{default:false}).action(async(options)=>{const startTime=await intro("buddy release:ios");try{const tag=await releaseIos(options);await outro(options.dryRun?`Dry run complete: would release ${tag}`:process.exitCode?`Published ${tag}; TestFlight delivery is incomplete`:`Released ${tag}`,{startTime,useSeconds:true});if(!options.dryRun)log.info('A CI that builds tags (Xcode Cloud: Tag Changes, prefix "v") turns it into a TestFlight build now.')}catch(error){await log.error("Failed to release the iOS app",error);process.exit(ExitCode.FatalError)}});buddy.command("release:testflight [tag]","Complete internal tester delivery for an existing iOS release tag").option("--wait [minutes]","Wait for processing and tester availability (default 60 minutes)").option("--keep-builds <n>","Older builds to retain after tester delivery succeeds",{default:1}).option("--dry-run",descriptions.dryRun,{default:false}).action(async(tag,options)=>{try{await releaseTestFlightCommand(tag,options)}catch(error){await log.error("Failed to deliver the TestFlight build",error);process.exit(ExitCode.FatalError)}});buddy.command("release:notes [tag]","Print the tester notes of a mobile release tag (default: the newest v*-build.* tag), or set them as its TestFlight What to Test").option("--from <ref>","Generate from the commits since this ref instead of the previous build tag").option("--play","Fit the notes to Google Play's 500-character What's new",{default:false}).option("--markdown","Markdown, as the GitHub release shows the notes",{default:false}).option("--testflight","Set the notes as the TestFlight build's What to Test through App Store Connect",{default:false}).option("--wait [minutes]","With --testflight: wait this long for the build to appear (default 60)").option("--notes <text>","Use this text instead").option("--notes-file <path>","Read the text from a file instead").action(async(tag,options)=>{try{await releaseNotesCommand(tag,options)}catch(error){await log.error("Failed to produce the release notes",error);process.exit(ExitCode.FatalError)}});buddy.command("release:github [tag]","Create the GitHub release for a pushed tag (default: the newest), with the changes since the tag before it").option("--assets <paths>","Attach comma-separated immutable native JSON receipts to the release").option("--dry-run","Print the release instead of creating it",{default:false}).action(async(tag,options)=>{const startTime=await intro("buddy release:github");try{if(!options.dryRun)await assertPublicationAllowed({cwd:process.cwd(),channel:"github-release"});const target=tag||git("describe","--tags","--abbrev=0");if(!git("tag","--list",target))throw new Error(`there is no tag ${target}`);const ios=/^v\d+\.\d+\.\d+-build\.\d+$/.test(target)?iosReleaseSummary(target,{numberedByXcodeCloud:appStoreConnectCredentials()!==null}):null;let summary=ios?.body;if(ios){const configPath=join(process.cwd(),"config/mobile.ts");const mobile=existsSync(configPath)?await loadMobileConfig(configPath):{};summary=githubSummary(ios.body,notesForTag(process.cwd(),target,mobile,{markdown:true}).text)}const result=await publishGitHubRelease({cwd:process.cwd(),tag:target,name:ios?.name,summary,dryRun:options.dryRun});if(result.status==="failed")throw new Error(describeGitHubRelease(target,result));if(options.assets&&!options.dryRun){const{attachGitHubReleaseAssets}=await import("@stacksjs/actions/github-release-assets");for(const link of await attachGitHubReleaseAssets({cwd:process.cwd(),tag:target,files:options.assets.split(",")}))log.info(link)}log.info(options.dryRun&&result.draft?`Would create the GitHub release ${target} (${result.draft.name}):
|
|
11
11
|
|
|
12
12
|
${result.draft.body}`:describeGitHubRelease(target,result));await outro(options.dryRun?"Dry run complete. Nothing was created.":`GitHub release for ${target}`,{startTime,useSeconds:true})}catch(error){await log.error("Failed to create the GitHub release",error);process.exit(ExitCode.FatalError)}});buddy.command("release:verify <plan>","Verify exact source gates, published archives and installed consumer checks").option("--output <path>","Save the successful verification receipt as JSON").action(async(planPath,options)=>{let temporary;try{const plan=JSON.parse(readFileSync(planPath,"utf8"));validateReleaseEvidencePlan(plan);const receipt=await verifyReleaseEvidence(plan,{cwd:process.cwd(),token:resolveGitHubToken()??undefined});const json=`${JSON.stringify(receipt,null,2)}
|
|
13
13
|
`;if(options.output){temporary=`${options.output}.${crypto.randomUUID()}.tmp`;writeFileSync(temporary,json,{flag:"wx",mode:384});renameSync(temporary,options.output);temporary=undefined;await printAsync(`Verified release evidence saved to ${options.output}`)}else{await printAsync(json.trimEnd())}}catch(error){if(temporary)rmSync(temporary,{force:true});await log.error("Release verification failed",error);process.exitCode=ExitCode.FatalError}});onUnknownSubcommand(buddy,"release")}export function resolveGitHubActionsUrl(remoteUrl,repository=process.env.GITHUB_REPOSITORY,serverUrl=process.env.GITHUB_SERVER_URL??"https://github.com"){const repo=repository?.trim()||remoteUrl?.trim().match(/github\.com[/:]([^/\s]+\/[^/\s]+?)(?:\.git)?$/)?.[1];return repo?`${serverUrl.replace(/\/$/,"")}/${repo}/actions`:"https://github.com/stacksjs/stacks/actions"}function readOriginRemote(){try{return execFileSync("git",["config","--get","remote.origin.url"],{encoding:"utf8"}).trim()}catch{return}}
|
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.593",
|
|
6
6
|
"description": "Meet Buddy. The Stacks runtime.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -95,74 +95,74 @@
|
|
|
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.593",
|
|
99
|
+
"@stacksjs/docs": "0.75.593",
|
|
100
|
+
"@stacksjs/ai": "0.75.593",
|
|
101
|
+
"@stacksjs/alias": "0.75.593",
|
|
102
|
+
"@stacksjs/analytics": "0.75.593",
|
|
103
|
+
"@stacksjs/api": "0.75.593",
|
|
104
|
+
"@stacksjs/arrays": "0.75.593",
|
|
105
|
+
"@stacksjs/auth": "0.75.593",
|
|
106
|
+
"@stacksjs/browser-extension": "0.75.593",
|
|
107
|
+
"@stacksjs/build": "0.75.593",
|
|
108
108
|
"@stacksjs/bumpx": "^0.2.26",
|
|
109
|
-
"@stacksjs/cache": "0.75.
|
|
110
|
-
"@stacksjs/chat": "0.75.
|
|
109
|
+
"@stacksjs/cache": "0.75.593",
|
|
110
|
+
"@stacksjs/chat": "0.75.593",
|
|
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.593",
|
|
113
|
+
"@stacksjs/cloud": "0.75.593",
|
|
114
|
+
"@stacksjs/cms": "0.75.593",
|
|
115
|
+
"@stacksjs/collections": "0.75.593",
|
|
116
|
+
"@stacksjs/commerce": "0.75.593",
|
|
117
|
+
"@stacksjs/config": "0.75.593",
|
|
118
|
+
"@stacksjs/database": "0.75.593",
|
|
119
|
+
"@stacksjs/desktop-build": "0.75.593",
|
|
120
|
+
"@stacksjs/dns": "0.75.593",
|
|
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.593",
|
|
123
|
+
"@stacksjs/enums": "0.75.593",
|
|
124
|
+
"@stacksjs/env": "0.75.593",
|
|
125
|
+
"@stacksjs/error-handling": "0.75.593",
|
|
126
|
+
"@stacksjs/events": "0.75.593",
|
|
127
|
+
"@stacksjs/features": "0.75.593",
|
|
128
|
+
"@stacksjs/git": "0.75.593",
|
|
129
129
|
"@stacksjs/gitit": "^0.2.5",
|
|
130
|
-
"@stacksjs/health": "0.75.
|
|
131
|
-
"@stacksjs/hq": "0.75.
|
|
130
|
+
"@stacksjs/health": "0.75.593",
|
|
131
|
+
"@stacksjs/hq": "0.75.593",
|
|
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.593",
|
|
134
|
+
"@stacksjs/lint": "0.75.593",
|
|
135
|
+
"@stacksjs/logging": "0.75.593",
|
|
136
|
+
"@stacksjs/notifications": "0.75.593",
|
|
137
|
+
"@stacksjs/objects": "0.75.593",
|
|
138
|
+
"@stacksjs/orm": "0.75.593",
|
|
139
|
+
"@stacksjs/path": "0.75.593",
|
|
140
|
+
"@stacksjs/payments": "0.75.593",
|
|
141
|
+
"@stacksjs/realtime": "0.75.593",
|
|
142
|
+
"@stacksjs/router": "0.75.593",
|
|
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.
|
|
153
|
-
"@stacksjs/stx": "^0.2.
|
|
154
|
-
"@stacksjs/testing": "0.75.
|
|
155
|
-
"@stacksjs/tinker": "0.75.
|
|
144
|
+
"@stacksjs/scheduler": "0.75.593",
|
|
145
|
+
"@stacksjs/search-engine": "0.75.593",
|
|
146
|
+
"@stacksjs/security": "0.75.593",
|
|
147
|
+
"@stacksjs/server": "0.75.593",
|
|
148
|
+
"@stacksjs/sites": "0.75.593",
|
|
149
|
+
"@stacksjs/skills": "0.75.593",
|
|
150
|
+
"@stacksjs/socials": "0.75.593",
|
|
151
|
+
"@stacksjs/storage": "0.75.593",
|
|
152
|
+
"@stacksjs/strings": "0.75.593",
|
|
153
|
+
"@stacksjs/stx": "^0.2.885",
|
|
154
|
+
"@stacksjs/testing": "0.75.593",
|
|
155
|
+
"@stacksjs/tinker": "0.75.593",
|
|
156
156
|
"@stacksjs/tlsx": "^0.13.19",
|
|
157
157
|
"@stacksjs/ts-cloud": "^0.16.129",
|
|
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.593",
|
|
159
|
+
"@stacksjs/types": "0.75.593",
|
|
160
|
+
"@stacksjs/ui": "0.75.593",
|
|
161
|
+
"@stacksjs/utils": "0.75.593",
|
|
162
|
+
"@stacksjs/validation": "0.75.593",
|
|
163
163
|
"ajv": "^8.20.0",
|
|
164
164
|
"ajv-formats": "^3.0.1",
|
|
165
|
-
"bun-plugin-stx": "^0.2.
|
|
165
|
+
"bun-plugin-stx": "^0.2.885",
|
|
166
166
|
"ts-pantry": "^0.11.205"
|
|
167
167
|
},
|
|
168
168
|
"devDependencies": {
|