@exadev/build-identity 2.1.0 → 2.2.0
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/README.md +17 -0
- package/dist/cli.js +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -118,6 +118,23 @@ const predictedVersion = await predictNextVersion(process.cwd(), releaseRules, a
|
|
|
118
118
|
const identity = resolvePredictedIdentity(build, predictedVersion);
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
+
## `readPackageVersion(repoRoot)`
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
function readPackageVersion(repoRoot: string): string;
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The plain `"version"` field from `package.json` at `repoRoot`, read unconditionally and with no git access at all. This is deliberately not the same thing as `resolveBuildIdentity(...).version`, which is a build *identity* -- the released version only when a tag genuinely points at HEAD, and a short commit hash otherwise. Reach for this one when you want the last released semantic version regardless of whether this checkout happens to be sitting on its tag: an OpenAPI document's `info.version`, a user agent string, anything wanting a stable semver rather than an honest answer about what is deployed.
|
|
128
|
+
|
|
129
|
+
Throws rather than defaulting when `package.json` is missing or its `"version"` is absent, non-string, or empty -- the same stance every other export in this package takes. `defaultTagName` (`v${version}`) is the shared convention `resolveBuildIdentity` and `predictNextVersion` both apply to this value.
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
import { readPackageVersion, resolveBuildIdentity } from '@exadev/build-identity';
|
|
133
|
+
|
|
134
|
+
const appVersion = readPackageVersion(process.cwd()); // "1.4.0", tagged or not
|
|
135
|
+
const build = resolveBuildIdentity(process.cwd(), 'exadev/example'); // "1.4.0" or "a1b2c3d"
|
|
136
|
+
```
|
|
137
|
+
|
|
121
138
|
## `build-identity` (CLI)
|
|
122
139
|
|
|
123
140
|
The same three functions, wired together, as a command. It exists for build and deploy steps that are a shell invocation rather than a JavaScript config file, so nothing in them can `import` this package at all -- `wrangler deploy --var RELEASE_VERSION:...` being the case it was built for. A step that *is* a JavaScript config file (`next.config.ts`, `vite.config.ts`) should import the functions directly instead; see [Framework-agnosticism](#framework-agnosticism) below.
|
package/dist/cli.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Command, InvalidArgumentError, Option } from "commander";
|
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { execFileSync } from "node:child_process";
|
|
7
7
|
//#region package.json
|
|
8
|
-
var version = "2.
|
|
8
|
+
var version = "2.2.0";
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region src/format-identity.ts
|
|
11
11
|
const OUTPUT_FORMATS = ["json", "env"];
|
package/dist/index.cjs
CHANGED
|
@@ -204,5 +204,6 @@ async function loadCommitAnalyzer() {
|
|
|
204
204
|
//#endregion
|
|
205
205
|
exports.loadCommitAnalyzer = loadCommitAnalyzer;
|
|
206
206
|
exports.predictNextVersion = predictNextVersion;
|
|
207
|
+
exports.readPackageVersion = readPackageVersion;
|
|
207
208
|
exports.resolveBuildIdentity = resolveBuildIdentity;
|
|
208
209
|
exports.resolvePredictedIdentity = resolvePredictedIdentity;
|
package/dist/index.d.cts
CHANGED
|
@@ -105,4 +105,8 @@ declare function predictNextVersion(repoRoot: string, releaseRules: readonly Rel
|
|
|
105
105
|
*/
|
|
106
106
|
declare function loadCommitAnalyzer(): Promise<AnalyzeCommits>;
|
|
107
107
|
//#endregion
|
|
108
|
-
|
|
108
|
+
//#region src/package-version.d.ts
|
|
109
|
+
/** The single semantic-release-managed version, read from `package.json` at `repoRoot`'s root -- shared by `resolveBuildIdentity` (what this build's version is, if released) and `predictNextVersion` (the version to diff commits since). Throws rather than defaulting, matching this package's own "no sensible placeholder identity" stance. */
|
|
110
|
+
declare function readPackageVersion(repoRoot: string): string;
|
|
111
|
+
//#endregion
|
|
112
|
+
export { type AnalyzeCommits, type BuildIdentity, type DisplayIdentity, type PredictNextVersionOptions, type ReleaseLevel, type ReleaseRule, type ResolveBuildIdentityOptions, loadCommitAnalyzer, predictNextVersion, readPackageVersion, resolveBuildIdentity, resolvePredictedIdentity };
|
package/dist/index.d.ts
CHANGED
|
@@ -105,4 +105,8 @@ declare function predictNextVersion(repoRoot: string, releaseRules: readonly Rel
|
|
|
105
105
|
*/
|
|
106
106
|
declare function loadCommitAnalyzer(): Promise<AnalyzeCommits>;
|
|
107
107
|
//#endregion
|
|
108
|
-
|
|
108
|
+
//#region src/package-version.d.ts
|
|
109
|
+
/** The single semantic-release-managed version, read from `package.json` at `repoRoot`'s root -- shared by `resolveBuildIdentity` (what this build's version is, if released) and `predictNextVersion` (the version to diff commits since). Throws rather than defaulting, matching this package's own "no sensible placeholder identity" stance. */
|
|
110
|
+
declare function readPackageVersion(repoRoot: string): string;
|
|
111
|
+
//#endregion
|
|
112
|
+
export { type AnalyzeCommits, type BuildIdentity, type DisplayIdentity, type PredictNextVersionOptions, type ReleaseLevel, type ReleaseRule, type ResolveBuildIdentityOptions, loadCommitAnalyzer, predictNextVersion, readPackageVersion, resolveBuildIdentity, resolvePredictedIdentity };
|
package/dist/index.js
CHANGED
|
@@ -201,4 +201,4 @@ async function loadCommitAnalyzer() {
|
|
|
201
201
|
return commitAnalyzerModule.analyzeCommits;
|
|
202
202
|
}
|
|
203
203
|
//#endregion
|
|
204
|
-
export { loadCommitAnalyzer, predictNextVersion, resolveBuildIdentity, resolvePredictedIdentity };
|
|
204
|
+
export { loadCommitAnalyzer, predictNextVersion, readPackageVersion, resolveBuildIdentity, resolvePredictedIdentity };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exadev/build-identity",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Resolve a build's true identity (a real release tag, or the commit it was built from) from git state, with an optional predicted-version display layer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|