@stacksjs/buddy 0.75.96 → 0.75.97
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/release.js +2 -1
- package/dist/release-ios.d.ts +8 -0
- package/dist/release-ios.js +1 -0
- package/package.json +55 -55
package/dist/commands/release.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{execFileSync}from"node:child_process";import process from"node:process";import{runAction}from"@stacksjs/actions";import{intro,italic,log,onUnknownSubcommand,outro}from"@stacksjs/cli";import{Action}from"@stacksjs/enums";import{ExitCode}from"@stacksjs/types";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 | calendar | x.y.z",verbose:"Enable verbose output"};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("--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()))}`)});
|
|
1
|
+
import{execFileSync}from"node:child_process";import{existsSync,readFileSync,writeFileSync}from"node:fs";import{join}from"node:path";import process from"node:process";import{runAction}from"@stacksjs/actions";import{intro,italic,log,onUnknownSubcommand,outro}from"@stacksjs/cli";import{Action}from"@stacksjs/enums";import{ExitCode}from"@stacksjs/types";import{bumpedVersion,iosVersionIn,nextBuildTag,withIosVersion}from"../release-ios";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 | calendar | x.y.z",verbose:"Enable verbose output"};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("--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>","Raise the app version first: patch | minor | major | x.y.z (default: a new build of the current version)").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)}});onUnknownSubcommand(buddy,"release")}function git(...args){return execFileSync("git",args,{encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim()}async function releaseIos(options){const root=process.cwd(),configPath=join(root,"config/mobile.ts");if(!existsSync(configPath))throw Error("config/mobile.ts not found: run this in a Stacks app with a mobile config");const branch=git("rev-parse","--abbrev-ref","HEAD");if(branch!=="main")throw Error(`releases are cut from main; this is ${branch}`);if(git("status","--porcelain","--untracked-files=no"))throw Error("commit or stash your changes first, so the release is exactly what is on main");git("pull","--quiet","--rebase","origin","main");git("fetch","--quiet","--tags","origin");const source=readFileSync(configPath,"utf8"),current=iosVersionIn(source);if(!current)throw Error("config/mobile.ts declares no iOS `version`");const version=options.bump?bumpedVersion(current,options.bump):current,tag=nextBuildTag(version,git("tag","--list",`v${version}-build.*`).split(`
|
|
2
|
+
`).filter(Boolean));log.info(`Releasing ${tag}${version===current?"":` (version ${current} \u2192 ${version})`}`);if(options.dryRun)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")}}for(const key of["MOBILE_URL","IOS_APP_VERSION","IOS_BUILD_NUMBER"])delete process.env[key];const result=await runAction(Action.BuildIos,{});if(resultFailed(result))throw result.error??Error("the iOS build failed");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);return tag}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}}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** The iOS app version config/mobile.ts declares (the default, when it reads an env var first). */
|
|
2
|
+
export declare function iosVersionIn(source: string): string | null;
|
|
3
|
+
/** config/mobile.ts with the iOS app version replaced, everything else as written. */
|
|
4
|
+
export declare function withIosVersion(source: string, version: string): string;
|
|
5
|
+
/** The version a bump leads to, or the one given outright. */
|
|
6
|
+
export declare function bumpedVersion(current: string, bump: string): string;
|
|
7
|
+
/** The next build's tag for `version`, after the tags that already exist. */
|
|
8
|
+
export declare function nextBuildTag(version: string, tags: string[]): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const SEMVER=/^\d+\.\d+\.\d+$/;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){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){if(SEMVER.test(bump))return bump;const[major=0,minor=0,patch=0]=current.split(".").map(Number);if(bump==="major")return`${major+1}.0.0`;if(bump==="minor")return`${major}.${minor+1}.0`;if(bump==="patch")return`${major}.${minor}.${patch+1}`;throw Error(`"${bump}" is not patch, minor, major or a version like 1.2.0`)}export function nextBuildTag(version,tags){const prefix=`v${version}-build.`,builds=tags.filter((tag)=>tag.startsWith(prefix)).map((tag)=>Number(tag.slice(prefix.length))).filter((n)=>Number.isInteger(n)&&n>0);return`${prefix}${Math.max(0,...builds)+1}`}
|
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.97",
|
|
6
6
|
"description": "Meet Buddy. The Stacks runtime.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -95,68 +95,68 @@
|
|
|
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.
|
|
107
|
-
"@stacksjs/cache": "^0.75.
|
|
108
|
-
"@stacksjs/chat": "^0.75.
|
|
98
|
+
"@stacksjs/actions": "^0.75.97",
|
|
99
|
+
"@stacksjs/ai": "^0.75.97",
|
|
100
|
+
"@stacksjs/alias": "^0.75.97",
|
|
101
|
+
"@stacksjs/analytics": "^0.75.97",
|
|
102
|
+
"@stacksjs/api": "^0.75.97",
|
|
103
|
+
"@stacksjs/arrays": "^0.75.97",
|
|
104
|
+
"@stacksjs/auth": "^0.75.97",
|
|
105
|
+
"@stacksjs/browser-extension": "^0.75.97",
|
|
106
|
+
"@stacksjs/build": "^0.75.97",
|
|
107
|
+
"@stacksjs/cache": "^0.75.97",
|
|
108
|
+
"@stacksjs/chat": "^0.75.97",
|
|
109
109
|
"@stacksjs/clapp": "^0.2.16",
|
|
110
|
-
"@stacksjs/cli": "^0.75.
|
|
111
|
-
"@stacksjs/cloud": "^0.75.
|
|
112
|
-
"@stacksjs/cms": "^0.75.
|
|
113
|
-
"@stacksjs/collections": "^0.75.
|
|
114
|
-
"@stacksjs/commerce": "^0.75.
|
|
115
|
-
"@stacksjs/config": "^0.75.
|
|
116
|
-
"@stacksjs/database": "^0.75.
|
|
117
|
-
"@stacksjs/desktop-build": "^0.75.
|
|
118
|
-
"@stacksjs/dns": "^0.75.
|
|
110
|
+
"@stacksjs/cli": "^0.75.97",
|
|
111
|
+
"@stacksjs/cloud": "^0.75.97",
|
|
112
|
+
"@stacksjs/cms": "^0.75.97",
|
|
113
|
+
"@stacksjs/collections": "^0.75.97",
|
|
114
|
+
"@stacksjs/commerce": "^0.75.97",
|
|
115
|
+
"@stacksjs/config": "^0.75.97",
|
|
116
|
+
"@stacksjs/database": "^0.75.97",
|
|
117
|
+
"@stacksjs/desktop-build": "^0.75.97",
|
|
118
|
+
"@stacksjs/dns": "^0.75.97",
|
|
119
119
|
"@stacksjs/dnsx": "^0.2.3",
|
|
120
|
-
"@stacksjs/email": "^0.75.
|
|
121
|
-
"@stacksjs/enums": "^0.75.
|
|
122
|
-
"@stacksjs/env": "^0.75.
|
|
123
|
-
"@stacksjs/error-handling": "^0.75.
|
|
124
|
-
"@stacksjs/events": "^0.75.
|
|
125
|
-
"@stacksjs/features": "^0.75.
|
|
126
|
-
"@stacksjs/git": "^0.75.
|
|
120
|
+
"@stacksjs/email": "^0.75.97",
|
|
121
|
+
"@stacksjs/enums": "^0.75.97",
|
|
122
|
+
"@stacksjs/env": "^0.75.97",
|
|
123
|
+
"@stacksjs/error-handling": "^0.75.97",
|
|
124
|
+
"@stacksjs/events": "^0.75.97",
|
|
125
|
+
"@stacksjs/features": "^0.75.97",
|
|
126
|
+
"@stacksjs/git": "^0.75.97",
|
|
127
127
|
"@stacksjs/gitit": "^0.2.5",
|
|
128
|
-
"@stacksjs/health": "^0.75.
|
|
128
|
+
"@stacksjs/health": "^0.75.97",
|
|
129
129
|
"@stacksjs/httx": "^0.1.10",
|
|
130
|
-
"@stacksjs/image": "^0.75.
|
|
131
|
-
"@stacksjs/lint": "^0.75.
|
|
132
|
-
"@stacksjs/logging": "^0.75.
|
|
133
|
-
"@stacksjs/notifications": "^0.75.
|
|
134
|
-
"@stacksjs/objects": "^0.75.
|
|
135
|
-
"@stacksjs/orm": "^0.75.
|
|
136
|
-
"@stacksjs/path": "^0.75.
|
|
137
|
-
"@stacksjs/payments": "^0.75.
|
|
138
|
-
"@stacksjs/realtime": "^0.75.
|
|
139
|
-
"@stacksjs/router": "^0.75.
|
|
130
|
+
"@stacksjs/image": "^0.75.97",
|
|
131
|
+
"@stacksjs/lint": "^0.75.97",
|
|
132
|
+
"@stacksjs/logging": "^0.75.97",
|
|
133
|
+
"@stacksjs/notifications": "^0.75.97",
|
|
134
|
+
"@stacksjs/objects": "^0.75.97",
|
|
135
|
+
"@stacksjs/orm": "^0.75.97",
|
|
136
|
+
"@stacksjs/path": "^0.75.97",
|
|
137
|
+
"@stacksjs/payments": "^0.75.97",
|
|
138
|
+
"@stacksjs/realtime": "^0.75.97",
|
|
139
|
+
"@stacksjs/router": "^0.75.97",
|
|
140
140
|
"@stacksjs/rpx": "^0.11.54",
|
|
141
|
-
"@stacksjs/scheduler": "^0.75.
|
|
142
|
-
"@stacksjs/search-engine": "^0.75.
|
|
143
|
-
"@stacksjs/security": "^0.75.
|
|
144
|
-
"@stacksjs/server": "^0.75.
|
|
145
|
-
"@stacksjs/sites": "^0.75.
|
|
146
|
-
"@stacksjs/skills": "^0.75.
|
|
147
|
-
"@stacksjs/socials": "^0.75.
|
|
148
|
-
"@stacksjs/storage": "^0.75.
|
|
149
|
-
"@stacksjs/strings": "^0.75.
|
|
141
|
+
"@stacksjs/scheduler": "^0.75.97",
|
|
142
|
+
"@stacksjs/search-engine": "^0.75.97",
|
|
143
|
+
"@stacksjs/security": "^0.75.97",
|
|
144
|
+
"@stacksjs/server": "^0.75.97",
|
|
145
|
+
"@stacksjs/sites": "^0.75.97",
|
|
146
|
+
"@stacksjs/skills": "^0.75.97",
|
|
147
|
+
"@stacksjs/socials": "^0.75.97",
|
|
148
|
+
"@stacksjs/storage": "^0.75.97",
|
|
149
|
+
"@stacksjs/strings": "^0.75.97",
|
|
150
150
|
"@stacksjs/stx": "^0.2.406",
|
|
151
|
-
"@stacksjs/testing": "^0.75.
|
|
152
|
-
"@stacksjs/tinker": "^0.75.
|
|
151
|
+
"@stacksjs/testing": "^0.75.97",
|
|
152
|
+
"@stacksjs/tinker": "^0.75.97",
|
|
153
153
|
"@stacksjs/tlsx": "^0.13.19",
|
|
154
154
|
"@stacksjs/ts-cloud": "^0.16.47",
|
|
155
|
-
"@stacksjs/tunnel": "^0.75.
|
|
156
|
-
"@stacksjs/types": "^0.75.
|
|
157
|
-
"@stacksjs/ui": "^0.75.
|
|
158
|
-
"@stacksjs/utils": "^0.75.
|
|
159
|
-
"@stacksjs/validation": "^0.75.
|
|
155
|
+
"@stacksjs/tunnel": "^0.75.97",
|
|
156
|
+
"@stacksjs/types": "^0.75.97",
|
|
157
|
+
"@stacksjs/ui": "^0.75.97",
|
|
158
|
+
"@stacksjs/utils": "^0.75.97",
|
|
159
|
+
"@stacksjs/validation": "^0.75.97",
|
|
160
160
|
"ajv": "^8.20.0",
|
|
161
161
|
"ajv-formats": "^3.0.1",
|
|
162
162
|
"bun-plugin-stx": "^0.2.406",
|