@stacksjs/actions 0.74.20 → 0.74.22
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/bump.js +3 -3
- package/package.json +38 -38
package/dist/bump.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{execSync,log,parseOptions}from"@stacksjs/cli";import{path as p}from"@stacksjs/path";import{versionBump}from"@stacksjs/bumpx";import{generateChangelog,loadLogsmithConfig}from"@stacksjs/logsmith";import{existsSync,readdirSync,readFileSync,unlinkSync,writeFileSync}from"node:fs";import{join,relative}from"node:path";const options=parseOptions(),allowedBumps=new Set(["patch","minor","major","prepatch","preminor","premajor","prerelease"]),rawBump=options?.bump?.toString(),bumpArg=rawBump?allowedBumps.has(rawBump)||/^\d+\.\d+\.\d+(?:-[\w.]+)?$/.test(rawBump)?rawBump:null:null;if(rawBump&&!bumpArg)log.warn(`Ignoring invalid --bump "${rawBump}"; expected one of patch|minor|major or x.y.z`);const isDryRun=options?.dryRun===!0,isVerbose=options?.verbose===!0;async function readPackage(file){if(!existsSync(file))return;return await Bun.file(file).json()}const rootManifest=p.projectPath("package.json"),rootPkg=await readPackage(rootManifest),isFrameworkRelease=rootPkg?.name==="stacks"&&existsSync(p.frameworkPath("core/package.json")),bumpCwd=isFrameworkRelease?p.frameworkPath("core"):p.projectPath(),primaryManifest=isFrameworkRelease?p.frameworkPath("core/package.json"):rootManifest;async function resolveBumpArg(bump){if(!bump||/^\d+\.\d+\.\d+(?:-[\w.]+)?$/.test(bump))return bump;if(!["patch","minor","major"].includes(bump))return bump;const match=(await readPackage(primaryManifest))?.version?.match(/^(\d+)\.(\d+)\.(\d+)$/);if(!match)return bump;const major=Number(match[1]),minor=Number(match[2]),patch=Number(match[3]);if(bump==="major")return`${major+1}.0.0`;if(bump==="minor")return`${major}.${minor+1}.0`;return`${major}.${minor}.${patch+1}`}const resolvedBumpArg=await resolveBumpArg(bumpArg);async function git(args,cwd=p.projectPath(),options={}){return await execSync(["git",...args],{cwd,stdin:"inherit",stderr:"pipe",throwOnError:options.throwOnError??!0})}async function readVersion(file){const pkg=await readPackage(file);if(!pkg?.version||!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(pkg.version))throw Error(`Invalid version in ${file}: ${pkg?.version??"<missing>"}`);return pkg.version}async function packageFilesFor(pattern,cwd){const glob=new Bun.Glob(pattern),files=[];for await(const file of glob.scan({cwd,absolute:!0,onlyFiles:!0})){if(file.includes("/node_modules/")||file.includes("/dist/")||file.includes("/pantry/"))continue;files.push(`./${relative(bumpCwd,file)}`)}return files}async function existingPackageFiles(files){const existing=[];for(const file of files){const absolutePath=join(bumpCwd,file);if(await Bun.file(absolutePath).exists())existing.push(file)}return existing}async function frameworkBumpFiles(){return Array.from(new Set([...await packageFilesFor("package.json",bumpCwd),...await packageFilesFor("*/package.json",bumpCwd),...await packageFilesFor("*/*/package.json",bumpCwd),...await existingPackageFiles(["../package.json","../defaults/ide/vscode/package.json","../api/package.json","../cloud/package.json","../docs/package.json","../orm/package.json","../server/package.json"]),...await packageFilesFor("../libs/**/package.json",bumpCwd)]))}const bumpFiles=isFrameworkRelease?await frameworkBumpFiles():["./package.json"];log.debug(`Release mode: ${isFrameworkRelease?"framework monorepo":"consumer app"} (${rootPkg?.name??"unknown"})`);log.debug(`Bumping ${bumpFiles.length} package manifest(s) in ${bumpCwd}`);await versionBump({release:resolvedBumpArg??void 0,files:bumpFiles,cwd:bumpCwd,recursive:!1,commit:!1,tag:!1,push:!1,changelog:!1,noGitCheck:!0,dryRun:isDryRun,yes:Boolean(resolvedBumpArg),verbose:isVerbose});const nextVersion=isDryRun&&resolvedBumpArg&&/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(resolvedBumpArg)?resolvedBumpArg:await readVersion(primaryManifest),latestTag=(await git(["describe","--abbrev=0","--tags"],p.projectPath(),{throwOnError:!1}).catch(()=>"")).trim();async function writeChangelog(){const config=await loadLogsmithConfig({dir:p.projectPath(),from:latestTag||void 0,to:"HEAD",output:isDryRun?!1:"CHANGELOG.md",theme:"github",verbose:isVerbose}),result=await generateChangelog(config);if(isDryRun){log.info(result.content);return}const changelogPath=p.projectPath("CHANGELOG.md");if(!existsSync(changelogPath))return;let content=readFileSync(changelogPath,"utf-8");const versionSeen=new RegExp(`\\bv?${nextVersion.replace(/\./g,"\\.")}\\b`);if(/\/compare\/[^)\s]+\.\.\.HEAD\)/.test(content))content=content.replace(/(\/compare\/[^)\s]+\.\.\.)HEAD(\))/,`$1v${nextVersion}$2`);else if(!versionSeen.test(content.split(`
|
|
1
|
+
import{execSync,log,parseOptions}from"@stacksjs/cli";import{path as p}from"@stacksjs/path";import{versionBump}from"@stacksjs/bumpx";import{generateChangelog,loadLogsmithConfig}from"@stacksjs/logsmith";import{existsSync,readdirSync,readFileSync,unlinkSync,writeFileSync}from"node:fs";import{join,relative}from"node:path";const options=parseOptions(),allowedBumps=new Set(["patch","minor","major","prepatch","preminor","premajor","prerelease"]),rawBump=options?.bump?.toString(),bumpArg=rawBump?allowedBumps.has(rawBump)||/^\d+\.\d+\.\d+(?:-[\w.]+)?$/.test(rawBump)?rawBump:null:null;if(rawBump&&!bumpArg)log.warn(`Ignoring invalid --bump "${rawBump}"; expected one of patch|minor|major or x.y.z`);const isDryRun=options?.dryRun===!0,isVerbose=options?.verbose===!0;async function readPackage(file){if(!existsSync(file))return;return await Bun.file(file).json()}const rootManifest=p.projectPath("package.json"),rootPkg=await readPackage(rootManifest),isFrameworkRelease=rootPkg?.name==="stacks"&&existsSync(p.frameworkPath("core/package.json")),bumpCwd=isFrameworkRelease?p.frameworkPath("core"):p.projectPath(),primaryManifest=isFrameworkRelease?p.frameworkPath("core/package.json"):rootManifest;async function resolveBumpArg(bump){if(!bump||/^\d+\.\d+\.\d+(?:-[\w.]+)?$/.test(bump))return bump;if(!["patch","minor","major"].includes(bump))return bump;const match=(await readPackage(primaryManifest))?.version?.match(/^(\d+)\.(\d+)\.(\d+)$/);if(!match)return bump;const major=Number(match[1]),minor=Number(match[2]),patch=Number(match[3]);if(bump==="major")return`${major+1}.0.0`;if(bump==="minor")return`${major}.${minor+1}.0`;return`${major}.${minor}.${patch+1}`}const resolvedBumpArg=await resolveBumpArg(bumpArg);async function git(args,cwd=p.projectPath(),options={}){return await execSync(["git",...args],{cwd,stdin:"inherit",stderr:"pipe",throwOnError:options.throwOnError??!0})}async function readVersion(file){const pkg=await readPackage(file);if(!pkg?.version||!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(pkg.version))throw Error(`Invalid version in ${file}: ${pkg?.version??"<missing>"}`);return pkg.version}function lockfileVersion(contents){const match=contents.match(/"lockfileVersion"\s*:\s*(\d+)/);return match?Number(match[1]):null}async function packageFilesFor(pattern,cwd){const glob=new Bun.Glob(pattern),files=[];for await(const file of glob.scan({cwd,absolute:!0,onlyFiles:!0})){if(file.includes("/node_modules/")||file.includes("/dist/")||file.includes("/pantry/"))continue;files.push(`./${relative(bumpCwd,file)}`)}return files}async function existingPackageFiles(files){const existing=[];for(const file of files){const absolutePath=join(bumpCwd,file);if(await Bun.file(absolutePath).exists())existing.push(file)}return existing}async function frameworkBumpFiles(){return Array.from(new Set([...await packageFilesFor("package.json",bumpCwd),...await packageFilesFor("*/package.json",bumpCwd),...await packageFilesFor("*/*/package.json",bumpCwd),...await existingPackageFiles(["../package.json","../defaults/ide/vscode/package.json","../api/package.json","../cloud/package.json","../docs/package.json","../orm/package.json","../server/package.json"]),...await packageFilesFor("../libs/**/package.json",bumpCwd)]))}const bumpFiles=isFrameworkRelease?await frameworkBumpFiles():["./package.json"];log.debug(`Release mode: ${isFrameworkRelease?"framework monorepo":"consumer app"} (${rootPkg?.name??"unknown"})`);log.debug(`Bumping ${bumpFiles.length} package manifest(s) in ${bumpCwd}`);await versionBump({release:resolvedBumpArg??void 0,files:bumpFiles,cwd:bumpCwd,recursive:!1,commit:!1,tag:!1,push:!1,changelog:!1,noGitCheck:!0,dryRun:isDryRun,yes:Boolean(resolvedBumpArg),verbose:isVerbose});const nextVersion=isDryRun&&resolvedBumpArg&&/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(resolvedBumpArg)?resolvedBumpArg:await readVersion(primaryManifest),latestTag=(await git(["describe","--abbrev=0","--tags"],p.projectPath(),{throwOnError:!1}).catch(()=>"")).trim();async function writeChangelog(){const config=await loadLogsmithConfig({dir:p.projectPath(),from:latestTag||void 0,to:"HEAD",output:isDryRun?!1:"CHANGELOG.md",theme:"github",verbose:isVerbose}),result=await generateChangelog(config);if(isDryRun){log.info(result.content);return}const changelogPath=p.projectPath("CHANGELOG.md");if(!existsSync(changelogPath))return;let content=readFileSync(changelogPath,"utf-8");const versionSeen=new RegExp(`\\bv?${nextVersion.replace(/\./g,"\\.")}\\b`);if(/\/compare\/[^)\s]+\.\.\.HEAD\)/.test(content))content=content.replace(/(\/compare\/[^)\s]+\.\.\.)HEAD(\))/,`$1v${nextVersion}$2`);else if(!versionSeen.test(content.split(`
|
|
2
2
|
`).slice(0,4).join(`
|
|
3
3
|
`)))content=content.replace(/^(#\s.*\n+)?/,(match)=>`${match??""}## v${nextVersion}
|
|
4
4
|
|
|
5
|
-
`);writeFileSync(changelogPath,content)}await writeChangelog();if(!isDryRun&&isFrameworkRelease)pinLockstepDeps(nextVersion);if(!isDryRun&&existsSync(p.projectPath("bun.lock"))){const lockPath=p.projectPath("bun.lock"),previousLock=readFileSync(lockPath);unlinkSync(lockPath);try{await execSync(["bun","install","--lockfile-only"],{cwd:p.projectPath(),stdin:"inherit"})}catch(error){writeFileSync(lockPath,previousLock);throw error}if(!existsSync(lockPath)){writeFileSync(lockPath,previousLock);throw Error("Release aborted: `bun install --lockfile-only` wrote no lockfile, so the previous one has been restored. This usually means a dependency range this bump just raised names a version that is not published yet - release that package first, then re-run.")}const expectedLockfileVersion=
|
|
6
|
-
`)}if(pinned>0)log.debug(`Pinned ${pinned} lockstep core dep(s) to ^${version}`)}async function stageReleaseArtifacts(){const pathspecs=isFrameworkRelease?[":(glob)storage/framework/**/package.json","package.json"]:["package.json"];for(const file of["CHANGELOG.md","bun.lock"])if(existsSync(p.projectPath(file)))pathspecs.push(file);await git(["add","--",...pathspecs]);const leftover=(await git(["status","--porcelain"])).split(`
|
|
5
|
+
`);writeFileSync(changelogPath,content)}await writeChangelog();if(!isDryRun&&isFrameworkRelease)pinLockstepDeps(nextVersion);async function refreshPantryLock(){const lockPath=p.projectPath("pantry.lock");if(!existsSync(lockPath))return;const previousLock=readFileSync(lockPath);try{await execSync(["pantry","install","--ignore-scripts","--quiet"],{cwd:p.projectPath(),stdin:"inherit"});if(!existsSync(lockPath))throw Error("Pantry completed without writing pantry.lock")}catch(error){writeFileSync(lockPath,previousLock);throw Error("Release aborted: Pantry could not refresh pantry.lock without lifecycle scripts. The previous lockfile was restored.",{cause:error})}}if(!isDryRun)await refreshPantryLock();if(!isDryRun&&existsSync(p.projectPath("bun.lock"))){const lockPath=p.projectPath("bun.lock"),previousLock=readFileSync(lockPath);unlinkSync(lockPath);try{await execSync(["bun","install","--lockfile-only"],{cwd:p.projectPath(),stdin:"inherit"})}catch(error){writeFileSync(lockPath,previousLock);throw error}if(!existsSync(lockPath)){writeFileSync(lockPath,previousLock);throw Error("Release aborted: `bun install --lockfile-only` wrote no lockfile, so the previous one has been restored. This usually means a dependency range this bump just raised names a version that is not published yet - release that package first, then re-run.")}const expectedLockfileVersion=lockfileVersion(previousLock.toString("utf8")),regeneratedLock=readFileSync(lockPath,"utf8"),producedVersion=lockfileVersion(regeneratedLock);if(expectedLockfileVersion==null||producedVersion!==expectedLockfileVersion){writeFileSync(lockPath,previousLock);throw Error(`Release aborted: regenerating bun.lock produced lockfileVersion ${producedVersion??"unknown"}, but the repository requires v${expectedLockfileVersion??"unknown"}. Re-run the release with the repository's declared Bun toolchain through \`pantry install\`, then regenerate and commit the canonical lockfile.`)}}function lockstepPackages(version){const names=new Set;for(const entry of readdirSync(p.frameworkPath("core"),{withFileTypes:!0})){if(!entry.isDirectory())continue;const manifest=p.frameworkPath(`core/${entry.name}/package.json`);if(!existsSync(manifest))continue;const pkg=JSON.parse(readFileSync(manifest,"utf-8"));if(pkg.name?.startsWith("@stacksjs/")&&pkg.version===version)names.add(pkg.name)}return names}function pinLockstepDeps(version){const lockstep=lockstepPackages(version),next=`^${version}`,manifests=[p.frameworkPath("core/package.json"),...readdirSync(p.frameworkPath("core"),{withFileTypes:!0}).filter((entry)=>entry.isDirectory()).map((entry)=>p.frameworkPath(`core/${entry.name}/package.json`)).filter((path)=>existsSync(path))];let pinned=0;for(const manifestPath of manifests){const manifest=JSON.parse(readFileSync(manifestPath,"utf-8"));let changed=!1;for(const field of["dependencies","devDependencies"]){const deps=manifest[field];if(!deps)continue;for(const name of Object.keys(deps)){if(!lockstep.has(name)||deps[name].startsWith("workspace:")||deps[name]===next)continue;deps[name]=next;changed=!0;pinned++}}if(changed)writeFileSync(manifestPath,`${JSON.stringify(manifest,null,2)}
|
|
6
|
+
`)}if(pinned>0)log.debug(`Pinned ${pinned} lockstep core dep(s) to ^${version}`)}async function stageReleaseArtifacts(){const pathspecs=isFrameworkRelease?[":(glob)storage/framework/**/package.json","package.json"]:["package.json"];for(const file of["CHANGELOG.md","bun.lock","pantry.lock"])if(existsSync(p.projectPath(file)))pathspecs.push(file);await git(["add","--",...pathspecs]);const leftover=(await git(["status","--porcelain"])).split(`
|
|
7
7
|
`).map((line)=>line.trimEnd()).filter((line)=>line&&!line.startsWith("A ")&&!line.startsWith("M "));if(leftover.length)log.warn(`Kept ${leftover.length} change(s) out of the release commit:
|
|
8
8
|
${leftover.slice(0,20).join(`
|
|
9
9
|
`)}${leftover.length>20?`
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/actions",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.74.
|
|
5
|
+
"version": "0.74.22",
|
|
6
6
|
"description": "The Stacks actions.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -60,51 +60,51 @@
|
|
|
60
60
|
"prepublishOnly": "bun run build"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@stacksjs/action-runner": "0.74.
|
|
64
|
-
"@stacksjs/ai": "0.74.
|
|
65
|
-
"@stacksjs/analytics": "0.74.
|
|
66
|
-
"@stacksjs/api": "0.74.
|
|
67
|
-
"@stacksjs/auth": "0.74.
|
|
68
|
-
"@stacksjs/build": "0.74.
|
|
63
|
+
"@stacksjs/action-runner": "0.74.22",
|
|
64
|
+
"@stacksjs/ai": "0.74.22",
|
|
65
|
+
"@stacksjs/analytics": "0.74.22",
|
|
66
|
+
"@stacksjs/api": "0.74.22",
|
|
67
|
+
"@stacksjs/auth": "0.74.22",
|
|
68
|
+
"@stacksjs/build": "0.74.22",
|
|
69
69
|
"@stacksjs/bumpx": "^0.2.6",
|
|
70
70
|
"@stacksjs/bunpress": "^0.2.8",
|
|
71
|
-
"@stacksjs/cli": "0.74.
|
|
72
|
-
"@stacksjs/cloud": "0.74.
|
|
73
|
-
"@stacksjs/cms": "0.74.
|
|
74
|
-
"@stacksjs/config": "0.74.
|
|
75
|
-
"@stacksjs/database": "0.74.
|
|
76
|
-
"@stacksjs/desktop-build": "0.74.
|
|
77
|
-
"@stacksjs/dns": "0.74.
|
|
78
|
-
"@stacksjs/enums": "0.74.
|
|
79
|
-
"@stacksjs/env": "0.74.
|
|
80
|
-
"@stacksjs/error-handling": "0.74.
|
|
71
|
+
"@stacksjs/cli": "0.74.22",
|
|
72
|
+
"@stacksjs/cloud": "0.74.22",
|
|
73
|
+
"@stacksjs/cms": "0.74.22",
|
|
74
|
+
"@stacksjs/config": "0.74.22",
|
|
75
|
+
"@stacksjs/database": "0.74.22",
|
|
76
|
+
"@stacksjs/desktop-build": "0.74.22",
|
|
77
|
+
"@stacksjs/dns": "0.74.22",
|
|
78
|
+
"@stacksjs/enums": "0.74.22",
|
|
79
|
+
"@stacksjs/env": "0.74.22",
|
|
80
|
+
"@stacksjs/error-handling": "0.74.22",
|
|
81
81
|
"@stacksjs/gitit": "^0.2.5",
|
|
82
|
-
"@stacksjs/i18n": "0.74.
|
|
83
|
-
"@stacksjs/image": "0.74.
|
|
84
|
-
"@stacksjs/logging": "0.74.
|
|
82
|
+
"@stacksjs/i18n": "0.74.22",
|
|
83
|
+
"@stacksjs/image": "0.74.22",
|
|
84
|
+
"@stacksjs/logging": "0.74.22",
|
|
85
85
|
"@stacksjs/logsmith": "^0.2.3",
|
|
86
|
-
"@stacksjs/orm": "0.74.
|
|
87
|
-
"@stacksjs/path": "0.74.
|
|
88
|
-
"@stacksjs/payments": "0.74.
|
|
89
|
-
"@stacksjs/queue": "0.74.
|
|
90
|
-
"@stacksjs/registry": "0.74.
|
|
91
|
-
"@stacksjs/router": "0.74.
|
|
86
|
+
"@stacksjs/orm": "0.74.22",
|
|
87
|
+
"@stacksjs/path": "0.74.22",
|
|
88
|
+
"@stacksjs/payments": "0.74.22",
|
|
89
|
+
"@stacksjs/queue": "0.74.22",
|
|
90
|
+
"@stacksjs/registry": "0.74.22",
|
|
91
|
+
"@stacksjs/router": "0.74.22",
|
|
92
92
|
"@stacksjs/rpx": "^0.11.42",
|
|
93
|
-
"@stacksjs/scheduler": "0.74.
|
|
94
|
-
"@stacksjs/search-engine": "0.74.
|
|
95
|
-
"@stacksjs/security": "0.74.
|
|
96
|
-
"@stacksjs/server": "0.74.
|
|
97
|
-
"@stacksjs/sites": "0.74.
|
|
98
|
-
"@stacksjs/storage": "0.74.
|
|
99
|
-
"@stacksjs/strings": "0.74.
|
|
93
|
+
"@stacksjs/scheduler": "0.74.22",
|
|
94
|
+
"@stacksjs/search-engine": "0.74.22",
|
|
95
|
+
"@stacksjs/security": "0.74.22",
|
|
96
|
+
"@stacksjs/server": "0.74.22",
|
|
97
|
+
"@stacksjs/sites": "0.74.22",
|
|
98
|
+
"@stacksjs/storage": "0.74.22",
|
|
99
|
+
"@stacksjs/strings": "0.74.22",
|
|
100
100
|
"@stacksjs/stx": "^0.2.274",
|
|
101
101
|
"@stacksjs/tlsx": "^0.13.19",
|
|
102
102
|
"@stacksjs/ts-cloud": "^0.12.10",
|
|
103
103
|
"@stacksjs/ts-md": "^0.1.1",
|
|
104
|
-
"@stacksjs/tunnel": "0.74.
|
|
105
|
-
"@stacksjs/types": "0.74.
|
|
106
|
-
"@stacksjs/utils": "0.74.
|
|
107
|
-
"@stacksjs/whois": "0.74.
|
|
104
|
+
"@stacksjs/tunnel": "0.74.22",
|
|
105
|
+
"@stacksjs/types": "0.74.22",
|
|
106
|
+
"@stacksjs/utils": "0.74.22",
|
|
107
|
+
"@stacksjs/whois": "0.74.22",
|
|
108
108
|
"bun-plugin-stx": "^0.2.274"
|
|
109
109
|
},
|
|
110
110
|
"peerDependencies": {
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
}
|
|
121
121
|
},
|
|
122
122
|
"devDependencies": {
|
|
123
|
-
"@stacksjs/validation": "0.74.
|
|
123
|
+
"@stacksjs/validation": "0.74.22",
|
|
124
124
|
"better-dx": "^0.2.24"
|
|
125
125
|
}
|
|
126
126
|
}
|