@stacksjs/actions 0.74.41 → 0.74.42

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 CHANGED
@@ -1,4 +1,4 @@
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 isGitIgnored(file){return(await git(["check-ignore","--",file],p.projectPath(),{throwOnError:!1})).trim().length>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(`
1
+ import{execSync,log,parseOptions}from"@stacksjs/cli";import{path as p}from"@stacksjs/path";import{versionBump}from"@stacksjs/bumpx";import{isCalendarBump,nextCalendarVersion}from"./calendar-version";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)||isCalendarBump(rawBump)||/^\d+\.\d+\.\d+(?:-[\w.]+)?$/.test(rawBump)?rawBump:null:null;if(rawBump&&!bumpArg)log.warn(`Ignoring invalid --bump "${rawBump}"; expected patch|minor|major, calendar, 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(isCalendarBump(bump)){const pkg=await readPackage(primaryManifest);return nextCalendarVersion(pkg?.version)}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 isGitIgnored(file){return(await git(["check-ignore","--",file],p.projectPath(),{throwOnError:!1})).trim().length>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
 
@@ -0,0 +1,40 @@
1
+ /** Parse `YYYY.M.N`, or `null` if this is not one. */
2
+ export declare function parseCalendarVersion(version: string): CalendarVersionParts | null;
3
+ /**
4
+ * The next calendar version, given the current one and the current date.
5
+ *
6
+ * - Same month as the current version: the sequence increments.
7
+ * - A different month, or a version that is not calendar-shaped at all: the
8
+ * sequence restarts at 0.
9
+ *
10
+ * Never returns a version that does not sort ABOVE `current`. A clock that is
11
+ * behind - a runner in another timezone, a machine whose time drifted - would
12
+ * otherwise produce a version npm rejects, and the error at that point names
13
+ * the registry rather than the clock. Instead the sequence keeps climbing
14
+ * within the current version's own month, which is always publishable and
15
+ * visibly wrong to a human reading the tag.
16
+ */
17
+ export declare function nextCalendarVersion(current: string | undefined, now?: Date): string;
18
+ /** Whether this `--bump` argument asks for a calendar version. */
19
+ export declare function isCalendarBump(bump: string | null | undefined): boolean;
20
+ /** The `--bump` values that mean "compute a calendar version". */
21
+ export declare const CALENDAR_BUMPS: ReadonlySet<string>;
22
+ /**
23
+ * Calendar versioning (stacksjs/stacks#475).
24
+ *
25
+ * `YYYY.M.N` - the year, the month, and a counter that resets each month. It
26
+ * looks like CalVer and it IS valid semver, which is the constraint that
27
+ * decides the shape: npm, Bun and every range operator in a `package.json`
28
+ * parse `major.minor.patch` and nothing else. A scheme like `2026.09.10` fails
29
+ * on the leading zero, and `2026.9.10-1` is a prerelease rather than a release.
30
+ *
31
+ * The counter is not the day. A day is the wrong unit for a release counter:
32
+ * two releases on one day would collide, and a month with releases on the 3rd
33
+ * and the 20th would jump the version by 17 for no reason a reader could act
34
+ * on. `N` counts releases within the month.
35
+ */
36
+ export declare interface CalendarVersionParts {
37
+ year: number
38
+ month: number
39
+ sequence: number
40
+ }
@@ -0,0 +1 @@
1
+ export function parseCalendarVersion(version){const match=version.match(/^(\d{4})\.(0|[1-9]\d?)\.(0|[1-9]\d*)$/);if(!match)return null;const month=Number(match[2]);if(month<1||month>12)return null;return{year:Number(match[1]),month,sequence:Number(match[3])}}export function nextCalendarVersion(current,now=new Date){const year=now.getUTCFullYear(),month=now.getUTCMonth()+1,parsed=current?parseCalendarVersion(current):null;if(!parsed)return`${year}.${month}.0`;if(parsed.year>year||parsed.year===year&&parsed.month>month)return`${parsed.year}.${parsed.month}.${parsed.sequence+1}`;if(parsed.year===year&&parsed.month===month)return`${year}.${month}.${parsed.sequence+1}`;return`${year}.${month}.0`}export const CALENDAR_BUMPS=new Set(["calendar","calver","date"]);export function isCalendarBump(bump){return typeof bump==="string"&&CALENDAR_BUMPS.has(bump.toLowerCase())}
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.41",
5
+ "version": "0.74.42",
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.41",
64
- "@stacksjs/ai": "0.74.41",
65
- "@stacksjs/analytics": "0.74.41",
66
- "@stacksjs/api": "0.74.41",
67
- "@stacksjs/auth": "0.74.41",
68
- "@stacksjs/build": "0.74.41",
63
+ "@stacksjs/action-runner": "0.74.42",
64
+ "@stacksjs/ai": "0.74.42",
65
+ "@stacksjs/analytics": "0.74.42",
66
+ "@stacksjs/api": "0.74.42",
67
+ "@stacksjs/auth": "0.74.42",
68
+ "@stacksjs/build": "0.74.42",
69
69
  "@stacksjs/bumpx": "^0.2.6",
70
70
  "@stacksjs/bunpress": "^0.2.8",
71
- "@stacksjs/cli": "0.74.41",
72
- "@stacksjs/cloud": "0.74.41",
73
- "@stacksjs/cms": "0.74.41",
74
- "@stacksjs/config": "0.74.41",
75
- "@stacksjs/database": "0.74.41",
76
- "@stacksjs/desktop-build": "0.74.41",
77
- "@stacksjs/dns": "0.74.41",
78
- "@stacksjs/enums": "0.74.41",
79
- "@stacksjs/env": "0.74.41",
80
- "@stacksjs/error-handling": "0.74.41",
71
+ "@stacksjs/cli": "0.74.42",
72
+ "@stacksjs/cloud": "0.74.42",
73
+ "@stacksjs/cms": "0.74.42",
74
+ "@stacksjs/config": "0.74.42",
75
+ "@stacksjs/database": "0.74.42",
76
+ "@stacksjs/desktop-build": "0.74.42",
77
+ "@stacksjs/dns": "0.74.42",
78
+ "@stacksjs/enums": "0.74.42",
79
+ "@stacksjs/env": "0.74.42",
80
+ "@stacksjs/error-handling": "0.74.42",
81
81
  "@stacksjs/gitit": "^0.2.5",
82
- "@stacksjs/i18n": "0.74.41",
83
- "@stacksjs/image": "0.74.41",
84
- "@stacksjs/logging": "0.74.41",
82
+ "@stacksjs/i18n": "0.74.42",
83
+ "@stacksjs/image": "0.74.42",
84
+ "@stacksjs/logging": "0.74.42",
85
85
  "@stacksjs/logsmith": "^0.2.3",
86
- "@stacksjs/orm": "0.74.41",
87
- "@stacksjs/path": "0.74.41",
88
- "@stacksjs/payments": "0.74.41",
89
- "@stacksjs/queue": "0.74.41",
90
- "@stacksjs/registry": "0.74.41",
91
- "@stacksjs/router": "0.74.41",
86
+ "@stacksjs/orm": "0.74.42",
87
+ "@stacksjs/path": "0.74.42",
88
+ "@stacksjs/payments": "0.74.42",
89
+ "@stacksjs/queue": "0.74.42",
90
+ "@stacksjs/registry": "0.74.42",
91
+ "@stacksjs/router": "0.74.42",
92
92
  "@stacksjs/rpx": "^0.11.53",
93
- "@stacksjs/scheduler": "0.74.41",
94
- "@stacksjs/search-engine": "0.74.41",
95
- "@stacksjs/security": "0.74.41",
96
- "@stacksjs/server": "0.74.41",
97
- "@stacksjs/sites": "0.74.41",
98
- "@stacksjs/storage": "0.74.41",
99
- "@stacksjs/strings": "0.74.41",
93
+ "@stacksjs/scheduler": "0.74.42",
94
+ "@stacksjs/search-engine": "0.74.42",
95
+ "@stacksjs/security": "0.74.42",
96
+ "@stacksjs/server": "0.74.42",
97
+ "@stacksjs/sites": "0.74.42",
98
+ "@stacksjs/storage": "0.74.42",
99
+ "@stacksjs/strings": "0.74.42",
100
100
  "@stacksjs/stx": "^0.2.285",
101
101
  "@stacksjs/tlsx": "^0.13.19",
102
102
  "@stacksjs/ts-cloud": "^0.16.0",
103
103
  "@stacksjs/ts-md": "^0.1.1",
104
- "@stacksjs/tunnel": "0.74.41",
105
- "@stacksjs/types": "0.74.41",
106
- "@stacksjs/utils": "0.74.41",
107
- "@stacksjs/whois": "0.74.41",
104
+ "@stacksjs/tunnel": "0.74.42",
105
+ "@stacksjs/types": "0.74.42",
106
+ "@stacksjs/utils": "0.74.42",
107
+ "@stacksjs/whois": "0.74.42",
108
108
  "bun-plugin-stx": "^0.2.285"
109
109
  },
110
110
  "peerDependencies": {
@@ -120,7 +120,7 @@
120
120
  }
121
121
  },
122
122
  "devDependencies": {
123
- "@stacksjs/validation": "0.74.41",
123
+ "@stacksjs/validation": "0.74.42",
124
124
  "better-dx": "^0.2.24"
125
125
  }
126
126
  }