@stacksjs/buddy 0.75.336 → 0.75.339
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/commands/migrate.js +3 -3
- package/dist/commands/release.js +2 -2
- package/dist/commands/upgrade.js +1 -1
- package/dist/release-ios.d.ts +7 -0
- package/dist/release-ios.js +1 -1
- package/package.json +55 -55
package/dist/commands/migrate.js
CHANGED
|
@@ -49,7 +49,7 @@ These were written under the old \`foreign_keys = OFF\` default (#1951). Review
|
|
|
49
49
|
2. (Optional) Export data from the current ${current} database.
|
|
50
50
|
3. ${switchBlocked?`Regenerate the migration files for ${target} FIRST - \`./buddy migrate\` will refuse until then.`:"Run `./buddy migrate` (or `migrate:fresh` to start clean)."}
|
|
51
51
|
4. The post-migrate FK audit will report any constraints that didn't replay.
|
|
52
|
-
`);await outro("Plan rendered. Re-run after updating .env to actually switch.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)});buddy.command("migrate:regenerate [dialect]","Rebuild database/migrations from your models for a given dialect").option("--dry-run","Show what would change without writing anything",{default:!1}).option("-f, --force","Regenerate even though the database already has migrations recorded",{default:!1}).option("--replace-unmarked","Also delete migrations carrying no @generated marker (pre-marker corpora only)",{default:!1}).option("--only-existing-tables","Rebuild exactly the tables already in the corpus, for changing dialect without adopting the framework schema",{default:!1}).action(async(dialect,options)=>{const perf=await intro("buddy migrate:regenerate"),target=(dialect||process.env.DB_CONNECTION||"sqlite").toLowerCase();if(!new Set(["sqlite","mysql","vitess","postgres","singlestore"]).has(target)){log.syncError(`Unknown dialect "${target}". Allowed: sqlite, mysql, vitess, postgres, singlestore.`);process.exit(ExitCode.FatalError)}const{countAppliedMigrations,regenerateMigrationCorpus}=await import("@stacksjs/database");let applied=0;try{applied=await countAppliedMigrations()}catch{applied=0}if(applied>0&&!options.force&&!options.dryRun){log.syncError(`This database already has ${applied} migration(s) recorded.`);log.syncError("Regenerating renumbers every file, and the migrations table keys on the filename,");log.syncError("so already-applied migrations would look pending and run a second time.");log.syncError(" Point at an empty database, or re-run with --force if you know it is safe.");process.exit(ExitCode.FatalError)}const plan=await regenerateMigrationCorpus({dialect:target,dryRun:!0,replaceUnmarked:options.replaceUnmarked,onlyExistingTables:options.onlyExistingTables});if(resultFailed(plan)){log.syncError(plan.error.message);process.exit(ExitCode.FatalError)}const{files,removed,removedObsolete,removedDataOnly,preserved,preservedOutOfScope,preservedData,relocated,models,modelRoots,unrebuildable}=plan.value,dataKept=new Set(preservedData),outOfScope=new Set(preservedOutOfScope),protectedHistory=preserved.filter((f)=>!outOfScope.has(f)&&!dataKept.has(f)),outOfScopeKept=preservedOutOfScope.filter((f)=>!dataKept.has(f)),movedTo=new Map(relocated.map((r)=>[r.from,r.to])),protectedHistoryBlock=protectedHistory.length===0?"":`
|
|
52
|
+
`);await outro("Plan rendered. Re-run after updating .env to actually switch.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)});buddy.command("migrate:regenerate [dialect]","Rebuild database/migrations from your models for a given dialect").option("--dry-run","Show what would change without writing anything",{default:!1}).option("-f, --force","Regenerate even though the database already has migrations recorded",{default:!1}).option("--replace-unmarked","Also delete migrations carrying no @generated marker (pre-marker corpora only)",{default:!1}).option("--only-existing-tables","Rebuild exactly the tables already in the corpus, for changing dialect without adopting the framework schema",{default:!1}).action(async(dialect,options)=>{const perf=await intro("buddy migrate:regenerate"),target=(dialect||process.env.DB_CONNECTION||"sqlite").toLowerCase();if(!new Set(["sqlite","mysql","vitess","postgres","singlestore"]).has(target)){log.syncError(`Unknown dialect "${target}". Allowed: sqlite, mysql, vitess, postgres, singlestore.`);process.exit(ExitCode.FatalError)}const{countAppliedMigrations,regenerateMigrationCorpus}=await import("@stacksjs/database");let applied=0;try{applied=await countAppliedMigrations()}catch{applied=0}if(applied>0&&!options.force&&!options.dryRun){log.syncError(`This database already has ${applied} migration(s) recorded.`);log.syncError("Regenerating renumbers every file, and the migrations table keys on the filename,");log.syncError("so already-applied migrations would look pending and run a second time.");log.syncError(" Point at an empty database, or re-run with --force if you know it is safe.");process.exit(ExitCode.FatalError)}const plan=await regenerateMigrationCorpus({dialect:target,dryRun:!0,replaceUnmarked:options.replaceUnmarked,onlyExistingTables:options.onlyExistingTables});if(resultFailed(plan)){log.syncError(plan.error.message);process.exit(ExitCode.FatalError)}const{files,removed,removedObsolete,removedDataOnly,preserved,preservedOutOfScope,preservedData,relocated,models,modelRoots,unrebuildable}=plan.value,corpusDir=relativeMigrationDirectory(plan.value.dir),dataKept=new Set(preservedData),outOfScope=new Set(preservedOutOfScope),protectedHistory=preserved.filter((f)=>!outOfScope.has(f)&&!dataKept.has(f)),outOfScopeKept=preservedOutOfScope.filter((f)=>!dataKept.has(f)),movedTo=new Map(relocated.map((r)=>[r.from,r.to])),protectedHistoryBlock=protectedHistory.length===0?"":`
|
|
53
53
|
\u2022 ${protectedHistory.length} protected history file(s) will be KEPT:
|
|
54
54
|
${protectedHistory.map((f)=>` ${f}`).join(`
|
|
55
55
|
`)}
|
|
@@ -91,11 +91,11 @@ ${unrebuildable.map((t)=>` ${t}`).join(`
|
|
|
91
91
|
Regenerate plan: ${target}
|
|
92
92
|
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
93
93
|
\u2022 ${models} model(s) read from ${rootList}
|
|
94
|
-
\u2022 ${files.length} migration file(s) will be written
|
|
94
|
+
\u2022 ${files.length} migration file(s) will be written to ${corpusDir}
|
|
95
95
|
\u2022 ${removed.length} existing file(s) will be removed${obsoleteBlock}${dataOnlyBlock}${dataBlock}${protectedHistoryBlock}${outOfScopeBlock}${unrebuildableBlock}
|
|
96
96
|
\u2022 These files are tracked in git, so review with \`git diff\` afterwards
|
|
97
97
|
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
98
|
-
`);if(options.dryRun){await outro("Dry run. Nothing was written.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)}if(!isCI&&hasTTY&&process.stdin.isTTY){await log.flush();if(!await confirm({message:`Replace ${removed.length} migration file(s) with ${files.length} generated for ${target}?`,initial:!1})){await outro("Cancelled. Nothing was written.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)}}const result=await regenerateMigrationCorpus({dialect:target,replaceUnmarked:options.replaceUnmarked,onlyExistingTables:options.onlyExistingTables});if(resultFailed(result)){log.syncError(result.error.message);process.exit(ExitCode.FatalError)}log.success(`Wrote ${result.value.files.length} ${target} migration file(s) to
|
|
98
|
+
`);if(options.dryRun){await outro("Dry run. Nothing was written.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)}if(!isCI&&hasTTY&&process.stdin.isTTY){await log.flush();if(!await confirm({message:`Replace ${removed.length} migration file(s) with ${files.length} generated for ${target}?`,initial:!1})){await outro("Cancelled. Nothing was written.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)}}const result=await regenerateMigrationCorpus({dialect:target,replaceUnmarked:options.replaceUnmarked,onlyExistingTables:options.onlyExistingTables});if(resultFailed(result)){log.syncError(result.error.message);process.exit(ExitCode.FatalError)}log.success(`Wrote ${result.value.files.length} ${target} migration file(s) to ${relativeMigrationDirectory(result.value.dir)}.`);if((applied>0?applied:await countAppliedMigrations().catch(()=>0))>0){const{reconcileMigrationLedger}=await import("@stacksjs/database"),fixed=await reconcileMigrationLedger({regenerated:{removed:result.value.removed,written:result.value.files.map((file)=>file.name)}});if(fixed.remapped.length>0)log.info(`Repointed ${fixed.remapped.length} ledger row(s) at their renumbered file.`);if(fixed.recorded.length>0)log.info(`Recorded ${fixed.recorded.length} regenerated migration(s) whose every table, index and type the schema already has - they will not run.`);if(fixed.retired.length>0)log.info(`Retired ${fixed.retired.length} ledger row(s) for migrations the regenerated corpus replaced.`);if(fixed.pruned.length>0)log.info(`Pruned ${fixed.pruned.length} duplicate ledger row(s).`);if(fixed.skipped.length>0){log.warn(`${fixed.skipped.length} ledger entr(ies) need a look:`);for(const entry of fixed.skipped.slice(0,10))log.info(` ${entry.file} - ${entry.reason}`);if(fixed.skipped.length>10)log.info(` \u2026 +${fixed.skipped.length-10} more - run \`./buddy migrate:status\``)}log.info("This database has history. Before `./buddy migrate`, bring its schema in line with the models:");log.info(" ./buddy migrate:align # what differs, and what can be repaired safely");log.info(" ./buddy migrate:align --apply # rename legacy indexes, add missing indexes and foreign keys");log.info(" ./buddy migrate:status --reconcile # record the regenerated files the schema now satisfies")}log.info("Review the change with `git diff`, then run `./buddy migrate`.");await outro("Regenerated.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)});buddy.command("migrate:align","Repair a live database that drifted from the models, without writing migrations (PostgreSQL)").option("--apply","Run the safe repairs, in one transaction",{default:!1}).option("--widen-integers","Also widen integer columns the models declare as bigint (rewrites those tables)",{default:!1}).option("--relax-constraints","Also remove obsolete NOT NULL constraints, polymorphic foreign keys, and conflicting keys with an enforced model reference",{default:!1}).option("-f, --force","With --apply, skip the confirmation",{default:!1}).option("--json","Emit the plan as JSON",{default:!1}).action(async(options)=>{const perf=options.json?void 0:await intro("buddy migrate:align"),{alignSchema}=await import("@stacksjs/database");let planned;try{planned=await alignSchema({widenIntegers:options.widenIntegers,relaxConstraints:options.relaxConstraints})}catch(error){log.syncError(`Could not compare the database with the models: ${error instanceof Error?error.message:String(error)}`);process.exit(ExitCode.FatalError)}if(options.json){console.log(JSON.stringify(planned,null,2));process.exit(ExitCode.Success)}if(!planned.supported){await log.info(`migrate:align is not supported for "${planned.dialect}" yet - only PostgreSQL. Nothing was compared.`);await outro("Skipped.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)}const{actions,reports,refused}=planned.plan,report=["",` Align plan: ${planned.dialect}`," \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"];if(actions.length>0){report.push(` ${actions.length} safe repair(s)${options.apply?"":" - run with --apply to make them, in one transaction"}:`);for(const action of actions)report.push(` \u2022 ${action.detail}`,` ${action.sql};`);report.push("")}if(refused.length>0){report.push(` ${refused.length} repair(s) REFUSED - the data would violate them:`);for(const action of refused)report.push(` \u2022 ${action.detail}: ${action.reason}`);report.push("")}if(reports.length>0){report.push(` ${reports.length} difference(s) left for you to decide - destructive or ambiguous, never applied:`);for(const item of reports.slice(0,40))report.push(` \u2022 [${item.kind}] ${item.detail}`);if(reports.length>40)report.push(` \u2026 +${reports.length-40} more (--json lists all)`);report.push("")}if(actions.length===0&&refused.length===0&&reports.length===0)report.push(" The database matches the models.","");console.log(report.join(`
|
|
99
99
|
`));if(!options.apply||actions.length===0){await outro(options.apply?"Nothing to repair.":"Plan only. Nothing was changed.",{startTime:perf,useSeconds:!0});process.exit(refused.length>0?ExitCode.FatalError:ExitCode.Success)}if(!options.force&&!isCI&&hasTTY&&process.stdin.isTTY){await log.flush();if(!await confirm({message:`Apply ${actions.length} repair(s) to the ${process.env.APP_ENV||"local"} database "${currentDatabaseLabel()}"?`,initial:!1})){await outro("Cancelled. Nothing was changed.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)}}try{const applied=await alignSchema({apply:!0,widenIntegers:options.widenIntegers,relaxConstraints:options.relaxConstraints});await log.success(`Applied ${applied.applied.length} repair(s).`);for(const action of applied.plan.refused)await log.warn(`Refused: ${action.detail}: ${action.reason}`)}catch(error){log.syncError(`Nothing was changed - the repairs run as one transaction and it failed: ${error instanceof Error?error.message:String(error)}`);process.exit(ExitCode.FatalError)}await log.info("Migrations whose every table, index and type now exists can be recorded without running:");await log.info(" ./buddy migrate:status --reconcile");await outro("Aligned.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)});buddy.command("migrate:status","Compare database/migrations, the migrations ledger, and the live schema").option("--reconcile","Repair the ledger where the schema proves what happened",{default:!1}).option("--include-partial","With --reconcile, also record half-applied migrations",{default:!1}).option("--requeue-reverted","With --reconcile, un-record the migrations of a table that is missing so the next migrate rebuilds it",{default:!1}).option("--json","Emit the audit as JSON",{default:!1}).option("--strict","Also fail when a migration was written by hand rather than generated from the models",{default:!1}).action(async(options)=>{const perf=options.json?void 0:await intro("buddy migrate:status"),{auditMigrationLedger,handWrittenMigrations,reconcileMigrationLedger}=await import("@stacksjs/database"),audit=await auditMigrationLedger(),handWritten=(await handWrittenMigrations()).files,strict=strictMode(options),handWrittenFails=strict&&handWritten.length>0;if(options.json){console.log(JSON.stringify({...audit,handWritten},(_k,v)=>v instanceof Set?[...v]:v,2));process.exit(audit.drift||handWrittenFails?ExitCode.FatalError:ExitCode.Success)}if(!audit.supported){log.info(`Dialect "${audit.dialect}" is not audited. Nothing to compare.`);await outro("Skipped.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)}const{counts,entries,orphans}=audit,list=(status)=>entries.filter((e)=>e.status===status).map((e)=>e.file),report=[],section=(heading,files)=>{if(files.length===0)return;if(heading)report.push(` ${heading}`);for(const file of files.slice(0,8))report.push(` ${file}`);if(files.length>8)report.push(` \u2026 +${files.length-8} more`);report.push("")};report.push("");report.push(` Migration status: ${audit.dialect}`);report.push(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");report.push(` ${entries.length+audit.gated.length} file(s) on disk \xB7 ${audit.recordedCount} recorded in the ledger`);report.push("");if(counts.applied>0)report.push(` ${counts.applied} applied - recorded, and present in the schema.`,"");if(counts.unverifiable>0)report.push(` ${counts.unverifiable} unverifiable - data migrations with no schema trace to check.`,"");if(audit.gated.length>0)report.push(` ${audit.gated.length} skipped - owned by a disabled feature, so \`buddy migrate\` does not run them until it is enabled.`,"");section(`${counts.pending} pending - not applied yet, will run on the next \`buddy migrate\`:`,list("pending"));if(counts.stranded>0){report.push(` ${counts.stranded} STRANDED - already applied to the schema, but missing from the ledger.`);report.push(" These re-run on the next `buddy migrate`, which is unsafe for anything not idempotent.");section("",list("stranded"))}section(`${counts.partial} PARTIAL - some effects present, some missing. Needs a human:`,list("partial"));section(`${counts.reverted} REVERTED - recorded as applied, but the effects are gone from the schema:`,list("reverted"));if(orphans.length>0)section(`${orphans.length} orphaned ledger row(s) - recorded, but no such file on disk:`,orphans.map((o)=>{if(o.renamedTo)return`${o.migration} -> renumbered to ${o.renamedTo}`;if(audit.remapPlan.superseded.includes(o.migration))return`${o.migration} (duplicate; already recorded under its current name)`;return`${o.migration} (no counterpart; migration deleted?)`}));if(handWritten.length>0){section(`${handWritten.length} hand-written - no \`-- qb:generated\` marker, so no model describes ${handWritten.length===1?"it":"them"}${strict?" (fails --strict)":""}:`,handWritten);report.push(" Move each change into app/Models and regenerate, or allow the file in");report.push(" database.safety.allowHandWrittenMigrations (reference data no model can describe).","")}console.log(report.join(`
|
|
100
100
|
`));if(!audit.drift){if(handWrittenFails){await outro("--strict: hand-written migrations (see above).",{startTime:perf,useSeconds:!0,type:"error"});process.exit(ExitCode.FatalError)}await outro("Ledger matches the corpus and the schema.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)}if(!options.reconcile){console.log(`
|
|
101
101
|
Repair with: ./buddy migrate:status --reconcile
|
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{ExitCode}from"@stacksjs/types";import{AppStoreConnect,appStoreConnectCredentials,buildsToExpire,waitForBuild}from"../app-store-connect";import{bumpedVersion,iosReleaseSummary,iosVersionIn,nextBuildTag,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"},IOS_PROJECT_DIR="storage/framework/mobile/ios",DEFAULT_WAIT_MINUTES=60;async function loadMobileConfig(configPath){return(await import(pathToFileURL(configPath).href)).default??{}}export function waitMinutes(value){if(value===void 0||value===!1)return null;if(value===!0||value==="")return DEFAULT_WAIT_MINUTES;const minutes=Number(value);if(!Number.isFinite(minutes)||minutes<0)throw Error(`--wait takes minutes, not ${String(value)}`);return minutes}function buildNumberOf(tag){const match=/^v(\d+\.\d+\.\d+)-build\.(\d+)$/.exec(tag);if(!match)throw 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\u2026`);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!1}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!0}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!1}}function githubSummary(summary,notes){return`${summary.trim()}
|
|
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,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"},IOS_PROJECT_DIR="storage/framework/mobile/ios",DEFAULT_WAIT_MINUTES=60;async function loadMobileConfig(configPath){return(await import(pathToFileURL(configPath).href)).default??{}}export function waitMinutes(value){if(value===void 0||value===!1)return null;if(value===!0||value==="")return DEFAULT_WAIT_MINUTES;const minutes=Number(value);if(!Number.isFinite(minutes)||minutes<0)throw Error(`--wait takes minutes, not ${String(value)}`);return minutes}function buildNumberOf(tag){const match=/^v(\d+\.\d+\.\d+)-build\.(\d+)$/.exec(tag);if(!match)throw 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\u2026`);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!1}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!0}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!1}}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?`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:!0});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")}}
|
|
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)});if(resultFailed(result))throw result.error??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 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}`);git("tag","-a",tag,"-m",tag);git("push","--quiet","--atomic","origin","main",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){try{const retiring=buildsToExpire(await store.api.builds(store.appId),keep);for(const build of retiring)await store.api.expire(build.id);if(retiring.length)log.info(`Expired TestFlight builds ${retiring.map((b)=>b.number).join(", ")}`)}catch(error){log.warn(`Could not expire older TestFlight builds: ${error instanceof Error?error.message:String(error)}`)}if(wait!==null&&numberedByXcodeCloud)await applyWhatToTest(store,tag,notes.text,locales,wait)}return tag}function notesForTag(root,tag,mobile,options){const releaseConfig=mobile.release??{},generateOptions={types:releaseConfig.noteTypes,excludeScopes:releaseConfig.excludeScopes},from=options.from||previousMobileTag(root,`${tag}^`),commits=commitsBetween(root,from,tag),plainGenerated=testerNotes(commits,generateOptions)||NO_VISIBLE_CHANGES,committed=options.from?null:committedWhatToTest(root,tag,IOS_PROJECT_DIR),handWritten=committed&&committed.trim()!==fitNotes(plainGenerated,XCODE_CLOUD_NOTES_LIMIT)?committed.trim():null,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:!0})||NO_VISIBLE_CHANGES:plainGenerated,plain:plainGenerated}}async function releaseNotesCommand(tagArgument,options){const root=process.cwd(),configPath=join(root,"config/mobile.ts"),mobile=existsSync(configPath)?await loadMobileConfig(configPath):{},tag=tagArgument||previousMobileTag(root,"HEAD");if(!tag||!git("tag","--list",tag))throw 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 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 Error("config/mobile.ts declares no ios.bundleId");const api=await AppStoreConnect.connect(credentials),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)}export function release(buddy){buddy.command("release",descriptions.release).option("--dry-run",descriptions.dryRun,{default:!1}).option("-p, --project [project]",descriptions.project,{default:!1}).option("--bump <type>",descriptions.bump).option("--preid <identifier>","Prerelease channel, for example beta or rc").option("--skip-github-release",descriptions.skipGithubRelease,{default:!1}).option("--verbose",descriptions.verbose,{default:!1}).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"),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:!0});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>","TestFlight builds to keep besides the new one; older ones are expired (needs an App Store Connect API key)",{default:1}).option("--skip-github-release",descriptions.skipGithubRelease,{default:!1}).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 the build to reach App Store Connect, then set its What to Test there too (default 60 minutes; needs an App Store Connect API key)").option("--dry-run",descriptions.dryRun,{default:!1}).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}`:`Released ${tag}`,{startTime,useSeconds:!0});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: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:!1}).option("--markdown","Markdown, as the GitHub release shows the notes",{default:!1}).option("--testflight","Set the notes as the TestFlight build's What to Test through App Store Connect",{default:!1}).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:!1}).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 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"),mobile=existsSync(configPath)?await loadMobileConfig(configPath):{};summary=githubSummary(ios.body,notesForTag(process.cwd(),target,mobile,{markdown:!0}).text)}const result=await publishGitHubRelease({cwd:process.cwd(),tag:target,name:ios?.name,summary,dryRun:options.dryRun});if(result.status==="failed")throw Error(describeGitHubRelease(target,result));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:!0})}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()??void 0}),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=void 0;await printAsync(`Verified release evidence saved to ${options.output}`)}else await printAsync(json.trimEnd())}catch(error){if(temporary)rmSync(temporary,{force:!0});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/dist/commands/upgrade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import process from"node:process";import{runAction}from"@stacksjs/actions";import{intro,log,onUnknownSubcommand,outro}from"@stacksjs/cli";import{Action}from"@stacksjs/enums";import{ExitCode}from"@stacksjs/types";import{resultFailed}from"../result";export function upgrade(buddy){const descriptions={upgrade:"Upgrade the Stacks framework to the latest version",version:"Install a specific version (e.g., 0.70.23)",canary:"Upgrade to the latest canary (bleeding-edge `main`) build",stable:"Switch to the latest vetted stable release",dryRun:"Preview the upgrade (which dependencies would change) without writing or installing",force:"Force re-download, bypassing cache and version checks",from:"Sync from a local stacks checkout (e.g. ~/Code/stacks). Skips GitHub.",noPostinstall:"Skip post-sync hooks (auto-imports, bun install, migrate)",verbose:"Enable verbose output",dependencies:"Upgrade your dependencies (pantry.yaml & package.json)",bun:"Upgrade Bun to the latest version",shell:"Upgrade the shell integration (currently only supports Oh My Zsh)",binary:"Upgrade the `stacks` binary to the latest version",project:"Target a specific project",all:"Upgrade framework, dependencies, Bun, and binary"};buddy.command("upgrade",descriptions.upgrade).option("-V, --version <version>",descriptions.version).option("--canary",descriptions.canary,{default:!1}).option("--stable",descriptions.stable,{default:!1}).option("--dry-run",descriptions.dryRun,{default:!1}).option("-f, --force",descriptions.force,{default:!1}).option("--from <path>",descriptions.from).option("--no-postinstall",descriptions.noPostinstall).option("--verbose",descriptions.verbose,{default:!1}).alias("update").example("buddy upgrade").example("buddy update").example("buddy upgrade --from ~/Code/stacks").example("buddy upgrade --version 0.70.23").example("buddy upgrade --dry-run").example("buddy upgrade --canary").example("buddy upgrade --stable").example("buddy upgrade --force").action(async(options)=>{log.debug("Running `buddy upgrade` ...",options);const opts={...options};if(opts.postinstall===!1){delete opts.postinstall;opts.noPostinstall=!0}const perf=await intro("buddy upgrade"),result=await runAction(Action.UpgradeFramework,opts);if(resultFailed(result)){await outro("While running buddy upgrade, there was an issue",{startTime:perf,useSeconds:!0},result.error);process.exit(ExitCode.FatalError)}await outro("Upgrade complete.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)});buddy.command("upgrade:all",descriptions.all).option("--canary",descriptions.canary,{default:!1}).option("-f, --force",descriptions.force,{default:!1}).option("-p, --project [project]",descriptions.project,{default:!1}).option("--verbose",descriptions.verbose,{default:!1}).example("buddy upgrade:all").action(async(options)=>{log.debug("Running `buddy upgrade:all` ...",options);const perf=await intro("buddy upgrade:all");options.all=!0;const result=await runAction(Action.Upgrade,options);if(resultFailed(result)){await outro("While running buddy upgrade:all, there was an issue",{startTime:perf,useSeconds:!0},result.error);process.exit(ExitCode.FatalError)}await outro("All upgrades complete.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)});buddy.command("upgrade:dependencies",descriptions.dependencies).option("-p, --project [project]",descriptions.project,{default:!1}).option("--verbose",descriptions.verbose,{default:!1}).alias("upgrade:deps").example("buddy upgrade:dependencies").action(async(options)=>{log.debug("Running `buddy upgrade:dependencies` ...",options);const perf=await intro("buddy upgrade:dependencies");options.dependencies=!0;const result=await runAction(Action.Upgrade,options);if(resultFailed(result)){await outro("While running buddy upgrade:dependencies, there was an issue",{startTime:perf,useSeconds:!0},result.error);process.exit(ExitCode.FatalError)}await outro("Dependencies upgraded.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)});buddy.command("upgrade:bun",descriptions.bun).option("--verbose",descriptions.verbose,{default:!1}).example("buddy upgrade:bun").action(async(options)=>{log.debug("Running `buddy upgrade:bun` ...",options);const perf=await intro("buddy upgrade:bun"),result=await runAction(Action.UpgradeBun,options);if(resultFailed(result)){await outro("While running buddy upgrade:bun, there was an issue",{startTime:perf,useSeconds:!0},result.error);process.exit(ExitCode.FatalError)}await outro("Bun upgraded.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)});buddy.command("upgrade:shell",descriptions.shell).option("--verbose",descriptions.verbose,{default:!1}).example("buddy upgrade:shell").action(async(options)=>{log.debug("Running `buddy upgrade:shell` ...",options);const perf=await intro("buddy upgrade:shell"),result=await runAction(Action.UpgradeShell,options);if(resultFailed(result)){await outro("While running buddy upgrade:shell, there was an issue",{startTime:perf,useSeconds:!0},result.error);process.exit(ExitCode.FatalError)}await outro("Shell integration upgraded.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)});buddy.command("upgrade:binary",descriptions.binary).option("--verbose",descriptions.verbose,{default:!1}).example("buddy upgrade:binary").action(async(options)=>{if(process.getuid&&process.getuid()!==0){log.warn("To upgrade the binary, you need to run this command with sudo, or as root.");await log.flush();process.exit(ExitCode.FatalError)}log.debug("Running `buddy upgrade:binary` ...",options);const perf=await intro("buddy upgrade:binary"),result=await runAction(Action.UpgradeBinary,options);if(resultFailed(result)){await outro("While running buddy upgrade:binary, there was an issue",{startTime:perf,useSeconds:!0},result.error);process.exit(ExitCode.FatalError)}await outro("Binary upgraded.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)});onUnknownSubcommand(buddy,"upgrade")}
|
|
1
|
+
import process from"node:process";import{runAction}from"@stacksjs/actions";import{intro,log,onUnknownSubcommand,outro}from"@stacksjs/cli";import{Action}from"@stacksjs/enums";import{ExitCode}from"@stacksjs/types";import{resultFailed}from"../result";export function upgrade(buddy){const descriptions={upgrade:"Upgrade the Stacks framework to the latest version",version:"Install a specific version (e.g., 0.70.23)",canary:"Upgrade to the latest canary (bleeding-edge `main`) build",stable:"Switch to the latest vetted stable release",dryRun:"Preview the upgrade (which dependencies would change) without writing or installing",allowDowngrade:"Accept a release that moves a dependency this app declares to an older version (refused by default)",force:"Force re-download, bypassing cache and version checks",from:"Sync from a local stacks checkout (e.g. ~/Code/stacks). Skips GitHub.",noPostinstall:"Skip post-sync hooks (auto-imports, bun install, migrate)",verbose:"Enable verbose output",dependencies:"Upgrade your dependencies (pantry.yaml & package.json)",bun:"Upgrade Bun to the latest version",shell:"Upgrade the shell integration (currently only supports Oh My Zsh)",binary:"Upgrade the `stacks` binary to the latest version",project:"Target a specific project",all:"Upgrade framework, dependencies, Bun, and binary"};buddy.command("upgrade",descriptions.upgrade).option("-V, --version <version>",descriptions.version).option("--canary",descriptions.canary,{default:!1}).option("--stable",descriptions.stable,{default:!1}).option("--dry-run",descriptions.dryRun,{default:!1}).option("--allow-downgrade",descriptions.allowDowngrade,{default:!1}).option("-f, --force",descriptions.force,{default:!1}).option("--from <path>",descriptions.from).option("--no-postinstall",descriptions.noPostinstall).option("--verbose",descriptions.verbose,{default:!1}).alias("update").example("buddy upgrade").example("buddy update").example("buddy upgrade --from ~/Code/stacks").example("buddy upgrade --version 0.70.23").example("buddy upgrade --dry-run").example("buddy upgrade --allow-downgrade").example("buddy upgrade --canary").example("buddy upgrade --stable").example("buddy upgrade --force").action(async(options)=>{log.debug("Running `buddy upgrade` ...",options);const opts={...options};if(opts.postinstall===!1){delete opts.postinstall;opts.noPostinstall=!0}const perf=await intro("buddy upgrade"),result=await runAction(Action.UpgradeFramework,opts);if(resultFailed(result)){await outro("While running buddy upgrade, there was an issue",{startTime:perf,useSeconds:!0},result.error);process.exit(ExitCode.FatalError)}await outro("Upgrade complete.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)});buddy.command("upgrade:all",descriptions.all).option("--canary",descriptions.canary,{default:!1}).option("-f, --force",descriptions.force,{default:!1}).option("-p, --project [project]",descriptions.project,{default:!1}).option("--verbose",descriptions.verbose,{default:!1}).example("buddy upgrade:all").action(async(options)=>{log.debug("Running `buddy upgrade:all` ...",options);const perf=await intro("buddy upgrade:all");options.all=!0;const result=await runAction(Action.Upgrade,options);if(resultFailed(result)){await outro("While running buddy upgrade:all, there was an issue",{startTime:perf,useSeconds:!0},result.error);process.exit(ExitCode.FatalError)}await outro("All upgrades complete.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)});buddy.command("upgrade:dependencies",descriptions.dependencies).option("-p, --project [project]",descriptions.project,{default:!1}).option("--verbose",descriptions.verbose,{default:!1}).alias("upgrade:deps").example("buddy upgrade:dependencies").action(async(options)=>{log.debug("Running `buddy upgrade:dependencies` ...",options);const perf=await intro("buddy upgrade:dependencies");options.dependencies=!0;const result=await runAction(Action.Upgrade,options);if(resultFailed(result)){await outro("While running buddy upgrade:dependencies, there was an issue",{startTime:perf,useSeconds:!0},result.error);process.exit(ExitCode.FatalError)}await outro("Dependencies upgraded.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)});buddy.command("upgrade:bun",descriptions.bun).option("--verbose",descriptions.verbose,{default:!1}).example("buddy upgrade:bun").action(async(options)=>{log.debug("Running `buddy upgrade:bun` ...",options);const perf=await intro("buddy upgrade:bun"),result=await runAction(Action.UpgradeBun,options);if(resultFailed(result)){await outro("While running buddy upgrade:bun, there was an issue",{startTime:perf,useSeconds:!0},result.error);process.exit(ExitCode.FatalError)}await outro("Bun upgraded.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)});buddy.command("upgrade:shell",descriptions.shell).option("--verbose",descriptions.verbose,{default:!1}).example("buddy upgrade:shell").action(async(options)=>{log.debug("Running `buddy upgrade:shell` ...",options);const perf=await intro("buddy upgrade:shell"),result=await runAction(Action.UpgradeShell,options);if(resultFailed(result)){await outro("While running buddy upgrade:shell, there was an issue",{startTime:perf,useSeconds:!0},result.error);process.exit(ExitCode.FatalError)}await outro("Shell integration upgraded.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)});buddy.command("upgrade:binary",descriptions.binary).option("--verbose",descriptions.verbose,{default:!1}).example("buddy upgrade:binary").action(async(options)=>{if(process.getuid&&process.getuid()!==0){log.warn("To upgrade the binary, you need to run this command with sudo, or as root.");await log.flush();process.exit(ExitCode.FatalError)}log.debug("Running `buddy upgrade:binary` ...",options);const perf=await intro("buddy upgrade:binary"),result=await runAction(Action.UpgradeBinary,options);if(resultFailed(result)){await outro("While running buddy upgrade:binary, there was an issue",{startTime:perf,useSeconds:!0},result.error);process.exit(ExitCode.FatalError)}await outro("Binary upgraded.",{startTime:perf,useSeconds:!0});process.exit(ExitCode.Success)});onUnknownSubcommand(buddy,"upgrade")}
|
package/dist/release-ios.d.ts
CHANGED
|
@@ -15,3 +15,10 @@ export declare function nextBuildTag(version: string, tags: string[], latestRun?
|
|
|
15
15
|
* key it is only a count of tags, and the release says so rather than claim it.
|
|
16
16
|
*/
|
|
17
17
|
export declare function iosReleaseSummary(tag: string, options: { numberedByXcodeCloud: boolean }): { name: string, body: string };
|
|
18
|
+
/**
|
|
19
|
+
* Why a built project cannot ship: its `devServerURL` (what the app talks to)
|
|
20
|
+
* is the developer's own machine or network, which no tester's phone reaches.
|
|
21
|
+
* Checked on the generated `craft.config.json`, so it catches the address
|
|
22
|
+
* whatever set it - a `.env` override, a shell, or the config itself (#3028).
|
|
23
|
+
*/
|
|
24
|
+
export declare function unreleasableSite(craftConfig: { devServerURL?: unknown }): string | null;
|
package/dist/release-ios.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{incrementVersion,nextBuildNumber,SemVer}from"@stacksjs/bumpx";function marketingVersion(version){const parsed=new SemVer(version);if(parsed.prerelease.length||parsed.build.length||parsed.toString()!==version)throw Error("An iOS marketing version must be a stable version such as 1.0.0");return parsed.toString()}function iosBlock(source){const start=source.search(/\bios\s*:\s*\{/);if(start===-1)return null;const after=source.slice(start+1).search(/\n\s*(?:android|desktop|watch|web)\s*:\s*\{/);return{start,end:after===-1?source.length:start+1+after}}const VERSION_ENTRY=/(\bversion\s*:\s*(?:[^,\n]*?\?\?\s*)?)(['"])(\d+\.\d+\.\d+)\2/;export function iosVersionIn(source){const block=iosBlock(source);if(!block)return null;return VERSION_ENTRY.exec(source.slice(block.start,block.end))?.[3]??null}export function withIosVersion(source,version){marketingVersion(version);const block=iosBlock(source);if(!block||!VERSION_ENTRY.test(source.slice(block.start,block.end)))throw Error("config/mobile.ts declares no iOS `version`");const ios=source.slice(block.start,block.end).replace(VERSION_ENTRY,(_,lead,quote)=>`${lead}${quote}${version}${quote}`);return source.slice(0,block.start)+ios+source.slice(block.end)}export function bumpedVersion(current,bump){marketingVersion(current);if(bump==="build")return current;if(["patch","minor","major"].includes(bump))return marketingVersion(incrementVersion(current,bump));return marketingVersion(bump)}export function nextBuildTag(version,tags,latestRun=0){marketingVersion(version);const prefix=`v${version}-build.`,builds=tags.filter((tag)=>tag.startsWith(prefix)).map((tag)=>tag.slice(prefix.length)).filter((number)=>/^[1-9]\d*$/.test(number)).map(Number).filter(Number.isSafeInteger);return`${prefix}${nextBuildNumber(latestRun,builds)}`}export function iosReleaseSummary(tag,options){const match=/^v(\d+\.\d+\.\d+)-build\.(\d+)$/.exec(tag);if(!match)throw Error(`${tag} is not an iOS build tag (v<version>-build.<n>)`);const[,version,build]=match;return{name:`${version} (build ${build})`,body:options.numberedByXcodeCloud?`Version ${version}, TestFlight build **${build}**: Xcode Cloud builds this tag, and its run number is the build number TestFlight shows.`:`Version ${version}, build tag ${build}. Xcode Cloud builds this tag; it was cut without an App Store Connect key, so the build number TestFlight shows may differ.`}}
|
|
1
|
+
import{incrementVersion,nextBuildNumber,SemVer}from"@stacksjs/bumpx";import{isLocalSite}from"@stacksjs/actions/build/mobile-target";function marketingVersion(version){const parsed=new SemVer(version);if(parsed.prerelease.length||parsed.build.length||parsed.toString()!==version)throw Error("An iOS marketing version must be a stable version such as 1.0.0");return parsed.toString()}function iosBlock(source){const start=source.search(/\bios\s*:\s*\{/);if(start===-1)return null;const after=source.slice(start+1).search(/\n\s*(?:android|desktop|watch|web)\s*:\s*\{/);return{start,end:after===-1?source.length:start+1+after}}const VERSION_ENTRY=/(\bversion\s*:\s*(?:[^,\n]*?\?\?\s*)?)(['"])(\d+\.\d+\.\d+)\2/;export function iosVersionIn(source){const block=iosBlock(source);if(!block)return null;return VERSION_ENTRY.exec(source.slice(block.start,block.end))?.[3]??null}export function withIosVersion(source,version){marketingVersion(version);const block=iosBlock(source);if(!block||!VERSION_ENTRY.test(source.slice(block.start,block.end)))throw Error("config/mobile.ts declares no iOS `version`");const ios=source.slice(block.start,block.end).replace(VERSION_ENTRY,(_,lead,quote)=>`${lead}${quote}${version}${quote}`);return source.slice(0,block.start)+ios+source.slice(block.end)}export function bumpedVersion(current,bump){marketingVersion(current);if(bump==="build")return current;if(["patch","minor","major"].includes(bump))return marketingVersion(incrementVersion(current,bump));return marketingVersion(bump)}export function nextBuildTag(version,tags,latestRun=0){marketingVersion(version);const prefix=`v${version}-build.`,builds=tags.filter((tag)=>tag.startsWith(prefix)).map((tag)=>tag.slice(prefix.length)).filter((number)=>/^[1-9]\d*$/.test(number)).map(Number).filter(Number.isSafeInteger);return`${prefix}${nextBuildNumber(latestRun,builds)}`}export function iosReleaseSummary(tag,options){const match=/^v(\d+\.\d+\.\d+)-build\.(\d+)$/.exec(tag);if(!match)throw Error(`${tag} is not an iOS build tag (v<version>-build.<n>)`);const[,version,build]=match;return{name:`${version} (build ${build})`,body:options.numberedByXcodeCloud?`Version ${version}, TestFlight build **${build}**: Xcode Cloud builds this tag, and its run number is the build number TestFlight shows.`:`Version ${version}, build tag ${build}. Xcode Cloud builds this tag; it was cut without an App Store Connect key, so the build number TestFlight shows may differ.`}}export function unreleasableSite(craftConfig){const site=craftConfig.devServerURL;if(typeof site!=="string"||!site)return null;let url;try{url=new URL(site)}catch{return`devServerURL ${JSON.stringify(site)} is not a URL`}return isLocalSite(url)?`devServerURL ${url.origin}${url.pathname} is a local address, which a tester's phone cannot reach`:null}
|
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.339",
|
|
6
6
|
"description": "Meet Buddy. The Stacks runtime.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -95,69 +95,69 @@
|
|
|
95
95
|
"prepublishOnly": "bun run build"
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
|
-
"@stacksjs/actions": "0.75.
|
|
99
|
-
"@stacksjs/ai": "0.75.
|
|
100
|
-
"@stacksjs/alias": "0.75.
|
|
101
|
-
"@stacksjs/analytics": "0.75.
|
|
102
|
-
"@stacksjs/api": "0.75.
|
|
103
|
-
"@stacksjs/arrays": "0.75.
|
|
104
|
-
"@stacksjs/auth": "0.75.
|
|
105
|
-
"@stacksjs/browser-extension": "0.75.
|
|
106
|
-
"@stacksjs/build": "0.75.
|
|
98
|
+
"@stacksjs/actions": "0.75.339",
|
|
99
|
+
"@stacksjs/ai": "0.75.339",
|
|
100
|
+
"@stacksjs/alias": "0.75.339",
|
|
101
|
+
"@stacksjs/analytics": "0.75.339",
|
|
102
|
+
"@stacksjs/api": "0.75.339",
|
|
103
|
+
"@stacksjs/arrays": "0.75.339",
|
|
104
|
+
"@stacksjs/auth": "0.75.339",
|
|
105
|
+
"@stacksjs/browser-extension": "0.75.339",
|
|
106
|
+
"@stacksjs/build": "0.75.339",
|
|
107
107
|
"@stacksjs/bumpx": "^0.2.26",
|
|
108
|
-
"@stacksjs/cache": "0.75.
|
|
109
|
-
"@stacksjs/chat": "0.75.
|
|
108
|
+
"@stacksjs/cache": "0.75.339",
|
|
109
|
+
"@stacksjs/chat": "0.75.339",
|
|
110
110
|
"@stacksjs/clapp": "^0.2.16",
|
|
111
|
-
"@stacksjs/cli": "0.75.
|
|
112
|
-
"@stacksjs/cloud": "0.75.
|
|
113
|
-
"@stacksjs/cms": "0.75.
|
|
114
|
-
"@stacksjs/collections": "0.75.
|
|
115
|
-
"@stacksjs/commerce": "0.75.
|
|
116
|
-
"@stacksjs/config": "0.75.
|
|
117
|
-
"@stacksjs/database": "0.75.
|
|
118
|
-
"@stacksjs/desktop-build": "0.75.
|
|
119
|
-
"@stacksjs/dns": "0.75.
|
|
111
|
+
"@stacksjs/cli": "0.75.339",
|
|
112
|
+
"@stacksjs/cloud": "0.75.339",
|
|
113
|
+
"@stacksjs/cms": "0.75.339",
|
|
114
|
+
"@stacksjs/collections": "0.75.339",
|
|
115
|
+
"@stacksjs/commerce": "0.75.339",
|
|
116
|
+
"@stacksjs/config": "0.75.339",
|
|
117
|
+
"@stacksjs/database": "0.75.339",
|
|
118
|
+
"@stacksjs/desktop-build": "0.75.339",
|
|
119
|
+
"@stacksjs/dns": "0.75.339",
|
|
120
120
|
"@stacksjs/dnsx": "^0.2.3",
|
|
121
|
-
"@stacksjs/email": "0.75.
|
|
122
|
-
"@stacksjs/enums": "0.75.
|
|
123
|
-
"@stacksjs/env": "0.75.
|
|
124
|
-
"@stacksjs/error-handling": "0.75.
|
|
125
|
-
"@stacksjs/events": "0.75.
|
|
126
|
-
"@stacksjs/features": "0.75.
|
|
127
|
-
"@stacksjs/git": "0.75.
|
|
121
|
+
"@stacksjs/email": "0.75.339",
|
|
122
|
+
"@stacksjs/enums": "0.75.339",
|
|
123
|
+
"@stacksjs/env": "0.75.339",
|
|
124
|
+
"@stacksjs/error-handling": "0.75.339",
|
|
125
|
+
"@stacksjs/events": "0.75.339",
|
|
126
|
+
"@stacksjs/features": "0.75.339",
|
|
127
|
+
"@stacksjs/git": "0.75.339",
|
|
128
128
|
"@stacksjs/gitit": "^0.2.5",
|
|
129
|
-
"@stacksjs/health": "0.75.
|
|
129
|
+
"@stacksjs/health": "0.75.339",
|
|
130
130
|
"@stacksjs/httx": "^0.1.10",
|
|
131
|
-
"@stacksjs/image": "0.75.
|
|
132
|
-
"@stacksjs/lint": "0.75.
|
|
133
|
-
"@stacksjs/logging": "0.75.
|
|
134
|
-
"@stacksjs/notifications": "0.75.
|
|
135
|
-
"@stacksjs/objects": "0.75.
|
|
136
|
-
"@stacksjs/orm": "0.75.
|
|
137
|
-
"@stacksjs/path": "0.75.
|
|
138
|
-
"@stacksjs/payments": "0.75.
|
|
139
|
-
"@stacksjs/realtime": "0.75.
|
|
140
|
-
"@stacksjs/router": "0.75.
|
|
141
|
-
"@stacksjs/security": "0.75.
|
|
131
|
+
"@stacksjs/image": "0.75.339",
|
|
132
|
+
"@stacksjs/lint": "0.75.339",
|
|
133
|
+
"@stacksjs/logging": "0.75.339",
|
|
134
|
+
"@stacksjs/notifications": "0.75.339",
|
|
135
|
+
"@stacksjs/objects": "0.75.339",
|
|
136
|
+
"@stacksjs/orm": "0.75.339",
|
|
137
|
+
"@stacksjs/path": "0.75.339",
|
|
138
|
+
"@stacksjs/payments": "0.75.339",
|
|
139
|
+
"@stacksjs/realtime": "0.75.339",
|
|
140
|
+
"@stacksjs/router": "0.75.339",
|
|
141
|
+
"@stacksjs/security": "0.75.339",
|
|
142
142
|
"@stacksjs/rpx": "^0.11.54",
|
|
143
|
-
"@stacksjs/scheduler": "0.75.
|
|
144
|
-
"@stacksjs/search-engine": "0.75.
|
|
145
|
-
"@stacksjs/server": "0.75.
|
|
146
|
-
"@stacksjs/sites": "0.75.
|
|
147
|
-
"@stacksjs/skills": "0.75.
|
|
148
|
-
"@stacksjs/socials": "0.75.
|
|
149
|
-
"@stacksjs/storage": "0.75.
|
|
150
|
-
"@stacksjs/strings": "0.75.
|
|
143
|
+
"@stacksjs/scheduler": "0.75.339",
|
|
144
|
+
"@stacksjs/search-engine": "0.75.339",
|
|
145
|
+
"@stacksjs/server": "0.75.339",
|
|
146
|
+
"@stacksjs/sites": "0.75.339",
|
|
147
|
+
"@stacksjs/skills": "0.75.339",
|
|
148
|
+
"@stacksjs/socials": "0.75.339",
|
|
149
|
+
"@stacksjs/storage": "0.75.339",
|
|
150
|
+
"@stacksjs/strings": "0.75.339",
|
|
151
151
|
"@stacksjs/stx": "0.2.736",
|
|
152
|
-
"@stacksjs/testing": "0.75.
|
|
153
|
-
"@stacksjs/tinker": "0.75.
|
|
152
|
+
"@stacksjs/testing": "0.75.339",
|
|
153
|
+
"@stacksjs/tinker": "0.75.339",
|
|
154
154
|
"@stacksjs/tlsx": "^0.13.19",
|
|
155
155
|
"@stacksjs/ts-cloud": "^0.16.69",
|
|
156
|
-
"@stacksjs/tunnel": "0.75.
|
|
157
|
-
"@stacksjs/types": "0.75.
|
|
158
|
-
"@stacksjs/ui": "0.75.
|
|
159
|
-
"@stacksjs/utils": "0.75.
|
|
160
|
-
"@stacksjs/validation": "0.75.
|
|
156
|
+
"@stacksjs/tunnel": "0.75.339",
|
|
157
|
+
"@stacksjs/types": "0.75.339",
|
|
158
|
+
"@stacksjs/ui": "0.75.339",
|
|
159
|
+
"@stacksjs/utils": "0.75.339",
|
|
160
|
+
"@stacksjs/validation": "0.75.339",
|
|
161
161
|
"ajv": "^8.20.0",
|
|
162
162
|
"ajv-formats": "^3.0.1",
|
|
163
163
|
"bun-plugin-stx": "0.2.736",
|