@reelout/context 0.4.4 → 0.5.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/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/createContext.ts +2 -0
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/createContext.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport {\n findReleaseRule,\n getCurrentGitBranch,\n getCurrentGitCommit,\n GIT_TRAILER_RELEASE_AGENT,\n resolveGitRepository,\n resolveReleaseChannel,\n resolveVersionQualifier,\n type GitCommit,\n type GitRef,\n type ReleaseContext,\n type ReleaseTypeHint,\n type ResolvedReleaseConfig,\n} from '@reelout/core'\nimport { createConsola, LogLevels } from 'consola/basic'\nimport type { ConsolaInstance } from 'consola/core'\n\nexport interface CreateContextOptions extends Omit<\n ResolvedReleaseConfig,\n 'plugins'\n> {\n cwd: string\n env: Readonly<NodeJS.ProcessEnv>\n signal?: AbortSignal | undefined\n stdout: NodeJS.WritableStream\n stderr: NodeJS.WritableStream\n logger?: ConsolaInstance | undefined\n type?: ReleaseTypeHint | undefined\n qualifier?: boolean | string | undefined\n channel?: boolean | string | undefined\n allowEmpty?: boolean | undefined\n dryRun?: boolean | undefined\n debug?: boolean | undefined\n}\n\n/**\n * Initialize a release context for the current execution run.\n *\n * Resolves the Git repository, current commit, and branch information, then\n * computes target release parameters using the provided configuration rules\n * and runtime options.\n *\n * @param options Combined release configuration and runtime options\n * @returns A promise that resolves to the fully initialized release context\n * @throws If the Git repository has no commits or no branch is checked out\n */\nexport async function createContext(\n options: CreateContextOptions\n): Promise<ReleaseContext> {\n const { cwd, stdout, stderr } = options\n let { logger } = options\n\n logger ??= createConsola({\n level: options.debug ? LogLevels.verbose : LogLevels.info,\n stdout: stdout as NodeJS.WriteStream,\n stderr: stderr as NodeJS.WriteStream,\n })\n\n const repository = await resolveGitRepository(cwd)\n let commit: GitCommit\n let branch: string\n\n try {\n commit = await getCurrentGitCommit(cwd, [GIT_TRAILER_RELEASE_AGENT])\n } catch (err) {\n throw new Error(\n 'Initialize a Git repository with at least one commit before running this command.',\n { cause: err }\n )\n }\n\n try {\n branch = await getCurrentGitBranch(cwd)\n } catch (err) {\n throw new Error(\n 'Check out a Git branch in your repository before proceeding.',\n { cause: err }\n )\n }\n\n const ref: GitRef = { type: 'branch', name: branch }\n const rule = findReleaseRule(ref, options.rules)\n\n const now = new Date()\n const date = now.toISOString().slice(0, 10) // YYYY-MM-DD\n const time = now.toISOString().slice(11, 19) // HH:mm:ss\n const templateParams = {\n date: date.replaceAll('-', ''),\n time: time.replaceAll(':', ''),\n }\n\n const versionQualifier = resolveVersionQualifier({\n rule,\n templateParams,\n qualifier: options.qualifier,\n })\n\n const releaseChannel = resolveReleaseChannel({\n ref,\n rule,\n templateParams,\n channel: options.channel,\n })\n\n return {\n cwd,\n env: options.env,\n today: date,\n signal: options.signal,\n stdout,\n stderr,\n logger,\n repository,\n ref,\n commit,\n author: options.author,\n classifier: options.classifier,\n rules: options.rules,\n type: options.type ?? 'auto',\n versionQualifier,\n releaseChannel,\n allowEmpty: !!options.allowEmpty,\n dryRun: !!options.dryRun,\n packages: [],\n plans: [],\n status: null,\n phase: null,\n error: null,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/createContext.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport {\n findReleaseRule,\n getCurrentGitBranch,\n getCurrentGitCommit,\n GIT_TRAILER_RELEASE_AGENT,\n resolveGitRepository,\n resolveReleaseChannel,\n resolveVersionQualifier,\n type GitCommit,\n type GitRef,\n type ReleaseContext,\n type ReleaseTypeHint,\n type ResolvedReleaseConfig,\n} from '@reelout/core'\nimport { createConsola, LogLevels } from 'consola/basic'\nimport type { ConsolaInstance } from 'consola/core'\n\nexport interface CreateContextOptions extends Omit<\n ResolvedReleaseConfig,\n 'plugins'\n> {\n cwd: string\n env: Readonly<NodeJS.ProcessEnv>\n signal?: AbortSignal | undefined\n stdout: NodeJS.WritableStream\n stderr: NodeJS.WritableStream\n logger?: ConsolaInstance | undefined\n filter?: string[] | undefined\n type?: ReleaseTypeHint | undefined\n qualifier?: boolean | string | undefined\n channel?: boolean | string | undefined\n allowEmpty?: boolean | undefined\n dryRun?: boolean | undefined\n debug?: boolean | undefined\n}\n\n/**\n * Initialize a release context for the current execution run.\n *\n * Resolves the Git repository, current commit, and branch information, then\n * computes target release parameters using the provided configuration rules\n * and runtime options.\n *\n * @param options Combined release configuration and runtime options\n * @returns A promise that resolves to the fully initialized release context\n * @throws If the Git repository has no commits or no branch is checked out\n */\nexport async function createContext(\n options: CreateContextOptions\n): Promise<ReleaseContext> {\n const { cwd, stdout, stderr } = options\n let { logger } = options\n\n logger ??= createConsola({\n level: options.debug ? LogLevels.verbose : LogLevels.info,\n stdout: stdout as NodeJS.WriteStream,\n stderr: stderr as NodeJS.WriteStream,\n })\n\n const repository = await resolveGitRepository(cwd)\n let commit: GitCommit\n let branch: string\n\n try {\n commit = await getCurrentGitCommit(cwd, [GIT_TRAILER_RELEASE_AGENT])\n } catch (err) {\n throw new Error(\n 'Initialize a Git repository with at least one commit before running this command.',\n { cause: err }\n )\n }\n\n try {\n branch = await getCurrentGitBranch(cwd)\n } catch (err) {\n throw new Error(\n 'Check out a Git branch in your repository before proceeding.',\n { cause: err }\n )\n }\n\n const ref: GitRef = { type: 'branch', name: branch }\n const rule = findReleaseRule(ref, options.rules)\n\n const now = new Date()\n const date = now.toISOString().slice(0, 10) // YYYY-MM-DD\n const time = now.toISOString().slice(11, 19) // HH:mm:ss\n const templateParams = {\n date: date.replaceAll('-', ''),\n time: time.replaceAll(':', ''),\n }\n\n const versionQualifier = resolveVersionQualifier({\n rule,\n templateParams,\n qualifier: options.qualifier,\n })\n\n const releaseChannel = resolveReleaseChannel({\n ref,\n rule,\n templateParams,\n channel: options.channel,\n })\n\n return {\n cwd,\n env: options.env,\n today: date,\n signal: options.signal,\n stdout,\n stderr,\n logger,\n repository,\n ref,\n commit,\n author: options.author,\n classifier: options.classifier,\n rules: options.rules,\n filter: options.filter ?? [],\n type: options.type ?? 'auto',\n versionQualifier,\n releaseChannel,\n allowEmpty: !!options.allowEmpty,\n dryRun: !!options.dryRun,\n packages: [],\n plans: [],\n status: null,\n phase: null,\n error: null,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAkDA,eAAsB,cACpB,SACyB;CACzB,MAAM,EAAE,KAAK,QAAQ,WAAW;CAChC,IAAI,EAAE,WAAW;CAEjB,WAAW,cAAc;EACvB,OAAO,QAAQ,QAAQ,UAAU,UAAU,UAAU;EAC7C;EACA;CACV,CAAC;CAED,MAAM,aAAa,MAAM,qBAAqB,GAAG;CACjD,IAAI;CACJ,IAAI;CAEJ,IAAI;EACF,SAAS,MAAM,oBAAoB,KAAK,CAAC,yBAAyB,CAAC;CACrE,SAAS,KAAK;EACZ,MAAM,IAAI,MACR,qFACA,EAAE,OAAO,IAAI,CACf;CACF;CAEA,IAAI;EACF,SAAS,MAAM,oBAAoB,GAAG;CACxC,SAAS,KAAK;EACZ,MAAM,IAAI,MACR,gEACA,EAAE,OAAO,IAAI,CACf;CACF;CAEA,MAAM,MAAc;EAAE,MAAM;EAAU,MAAM;CAAO;CACnD,MAAM,OAAO,gBAAgB,KAAK,QAAQ,KAAK;CAE/C,MAAM,sBAAM,IAAI,KAAK;CACrB,MAAM,OAAO,IAAI,YAAY,CAAC,CAAC,MAAM,GAAG,EAAE;CAC1C,MAAM,OAAO,IAAI,YAAY,CAAC,CAAC,MAAM,IAAI,EAAE;CAC3C,MAAM,iBAAiB;EACrB,MAAM,KAAK,WAAW,KAAK,EAAE;EAC7B,MAAM,KAAK,WAAW,KAAK,EAAE;CAC/B;CAEA,MAAM,mBAAmB,wBAAwB;EAC/C;EACA;EACA,WAAW,QAAQ;CACrB,CAAC;CAED,MAAM,iBAAiB,sBAAsB;EAC3C;EACA;EACA;EACA,SAAS,QAAQ;CACnB,CAAC;CAED,OAAO;EACL;EACA,KAAK,QAAQ;EACb,OAAO;EACP,QAAQ,QAAQ;EAChB;EACA;EACA;EACA;EACA;EACA;EACA,QAAQ,QAAQ;EAChB,YAAY,QAAQ;EACpB,OAAO,QAAQ;EACf,QAAQ,QAAQ,UAAU,CAAC;EAC3B,MAAM,QAAQ,QAAQ;EACtB;EACA;EACA,YAAY,CAAC,CAAC,QAAQ;EACtB,QAAQ,CAAC,CAAC,QAAQ;EAClB,UAAU,CAAC;EACX,OAAO,CAAC;EACR,QAAQ;EACR,OAAO;EACP,OAAO;CACT;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reelout/context",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Creates the release execution context from Git state, resolved configuration, and runtime options.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"./src"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@reelout/config": "^0.4.
|
|
36
|
-
"@reelout/core": "^0.
|
|
35
|
+
"@reelout/config": "^0.4.6",
|
|
36
|
+
"@reelout/core": "^0.6.0",
|
|
37
37
|
"consola": "^3.4.2"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
package/src/createContext.ts
CHANGED
|
@@ -28,6 +28,7 @@ export interface CreateContextOptions extends Omit<
|
|
|
28
28
|
stdout: NodeJS.WritableStream
|
|
29
29
|
stderr: NodeJS.WritableStream
|
|
30
30
|
logger?: ConsolaInstance | undefined
|
|
31
|
+
filter?: string[] | undefined
|
|
31
32
|
type?: ReleaseTypeHint | undefined
|
|
32
33
|
qualifier?: boolean | string | undefined
|
|
33
34
|
channel?: boolean | string | undefined
|
|
@@ -119,6 +120,7 @@ export async function createContext(
|
|
|
119
120
|
author: options.author,
|
|
120
121
|
classifier: options.classifier,
|
|
121
122
|
rules: options.rules,
|
|
123
|
+
filter: options.filter ?? [],
|
|
122
124
|
type: options.type ?? 'auto',
|
|
123
125
|
versionQualifier,
|
|
124
126
|
releaseChannel,
|