diff --git a/.changeset/js-version-facades.md b/.changeset/js-version-facades.md
new file mode 100644
index 0000000..4984d57
--- /dev/null
+++ b/.changeset/js-version-facades.md
@@ -0,0 +1,5 @@
+---
+'@haetae/javascript': patch
+---
+
+Add new functions `majorVersion`, `untilMinorVersion`, `untilPatchVersion`, and `fullVersion`.
diff --git a/packages/docs/pages/apis/javascript.mdx b/packages/docs/pages/apis/javascript.mdx
index 00664a0..f98235e 100644
--- a/packages/docs/pages/apis/javascript.mdx
+++ b/packages/docs/pages/apis/javascript.mdx
@@ -177,6 +177,78 @@ export default configure({
```
+### `majorVersion`
+
+A [Facade pattern](https://en.wikipedia.org/wiki/Facade_pattern) for the major version from [`version()`](#version).
+
+**Implementation**
+
+
+```ts
+async function majorVersion(
+ packageName: string,
+ options: VersionOptions = {},
+): Promise {
+ const { major } = await version(packageName, options)
+ return major
+}
+```
+
+
+### `untilMinorVersion`
+
+A [Facade pattern](https://en.wikipedia.org/wiki/Facade_pattern) for the until-minor(`x.y`) version of [`version()`](#version).
+
+**Implementation**
+
+
+```ts
+async function untilMinorVersion(
+ packageName: string,
+ options: VersionOptions = {},
+): Promise {
+ const { untilMinor } = await version(packageName, options)
+ return untilMinor
+}
+```
+
+
+### `untilPatchVersion`
+
+A [Facade pattern](https://en.wikipedia.org/wiki/Facade_pattern) for the until-patch(`x.y.z`) version from [`version()`](#version).
+
+**Implementation**
+
+
+```ts
+async function untilPatchVersion(
+ packageName: string,
+ options: VersionOptions = {},
+): Promise {
+ const { untilPatch } = await version(packageName, options)
+ return untilPatch
+}
+```
+
+
+### `fullVersion`
+
+A [Facade pattern](https://en.wikipedia.org/wiki/Facade_pattern) for the full version from [`version()`](#version).
+
+**Implementation**
+
+
+```ts
+async function fullVersion(
+ packageName: string,
+ options: VersionOptions = {},
+): Promise {
+ const { value } = await version(packageName, options)
+ return value
+}
+```
+
+
### `GraphOptions`
An argument interface for [`graph`](#graph).
diff --git a/packages/docs/pages/getting-started.mdx b/packages/docs/pages/getting-started.mdx
index d24232e..93d67a7 100644
--- a/packages/docs/pages/getting-started.mdx
+++ b/packages/docs/pages/getting-started.mdx
@@ -529,7 +529,7 @@ For instance, let's change the config to this.
'configure': './apis/haetae#configure',
'pkg': './apis/haetae#pkg',
'.hash': './apis/utils#hash',
- '.version': './apis/javascript#version',
+ '.majorVersion': './apis/javascript#majorversion',
'.branch': './apis/git#branch',
}}>
```js filename="haetae.config.js" showLineNumbers
@@ -545,7 +545,7 @@ export default configure({
return {
NODE_ENV: process.env.NODE_ENV,
jestConfig: await utils.hash(['jest.config.js']),
- jest: (await js.version('jest')).major,
+ jest: await js.majorVersion('jest'),
branch: await git.branch(),
os: process.platform,
node: semver.major(process.version),
@@ -1516,7 +1516,7 @@ haetaeConfig: await utils.hash(
```
-Evaluated `env` is passed from each command's `env` to upper levels.
+Evaluated `env` object is propagated to upper levels.
{
- // Evaluated `env` from each command
+ // Env from each command
assert(env.hello === 'world')
return {
...env,
@@ -1535,7 +1535,7 @@ export default configure({
}
},
recordData: async (data, { env }) => {
- // Evaluated `env` from root env
+ // Eenv from RootEnv
assert(env.hi === 'there')
assert(env.hello === 'world')
// ...
@@ -1544,7 +1544,7 @@ export default configure({
myCommand: {
env: { hello: 'world' },,
run: async ({ env }) => {
- // Evaluated `env` of "myCommand"
+ // Env from "myCommand"
assert(env.hello === 'world')
// ...
}
diff --git a/packages/js/src/version.ts b/packages/js/src/version.ts
index 34af9b1..2cc3ee7 100644
--- a/packages/js/src/version.ts
+++ b/packages/js/src/version.ts
@@ -98,3 +98,35 @@ export async function version(
return parseVersion(await versionFromYarnBerry(packageName, { rootDir }))
}
}
+
+export async function majorVersion(
+ packageName: string,
+ options: VersionOptions = {},
+): Promise {
+ const { major } = await version(packageName, options)
+ return major
+}
+
+export async function untilMinorVersion(
+ packageName: string,
+ options: VersionOptions = {},
+): Promise {
+ const { untilMinor } = await version(packageName, options)
+ return untilMinor
+}
+
+export async function untilPatchVersion(
+ packageName: string,
+ options: VersionOptions = {},
+): Promise {
+ const { untilPatch } = await version(packageName, options)
+ return untilPatch
+}
+
+export async function fullVersion(
+ packageName: string,
+ options: VersionOptions = {},
+): Promise {
+ const { value } = await version(packageName, options)
+ return value
+}