{"name":"@semantic-release/core","version":"0.0.0","_id":"@semantic-release/core@0.0.0","maintainers":[{"name":"pvdlg","email":"pierre.denis.vanduynslager@gmail.com"},{"name":"semantic-release-bot","email":"semantic-release@martynus.net"},{"name":"gr2m","email":"gregor@martynus.net"},{"name":"travi","email":"npm@travi.org"}],"dist":{"shasum":"ca904514b96d47686eb3a1bccae0b706473dec66","tarball":"http://registry-npm.ywwl.com/@semantic-release/core/download/@semantic-release/core-0.0.0.tgz","fileCount":1,"integrity":"sha512-Pu5PAndnSGizUO9OYHr9I/BUS3jJVMFTUpyiKQUSNuNmRnThQFt0x01YZXY96tnngK/5qyVhl8NNBVj4j2NOgg==","signatures":[{"sig":"MEUCIFh5TYNw3fEVsSo4VD4zYfgccx/jf+8emmp03/wFSuRaAiEApUnjG2UQSds1/xvnP2Jw9KAQGMt1RK44E/9Pic4x5Ak=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":109,"size":184,"noattachment":false,"key":"/@semantic-release/core/-/@semantic-release/core-0.0.0.tgz"},"_npmUser":{"name":"gr2m","email":"gregor@martynus.net"},"_npmVersion":"11.12.1","directories":{},"_nodeVersion":"24.15.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/core_0.0.0_1780678496346_0.07434456093680875","host":"s3://npm-registry-packages-npm-production"},"readme":"# @semantic-release/core\n\n`@semantic-release/core` is the composable release engine behind [semantic-release](https://github.com/semantic-release/semantic-release). It owns orchestration, config resolution, branch validation, plugin execution, and git interactions, while leaving CLI parsing and wrapper defaults to higher-level packages.\n\nUse this package when you want to build a custom release workflow, compose your own CLI, or run semantic-release with an explicit plugin stack.\n\n## Installation\n\n```bash\nnpm install @semantic-release/core\n```\n\n## Public API\n\nThe package exports four public entry points:\n\n- [`default`](#default): run a release with an explicit execution `context`, `plugins` input, optional `onInit` callback, and optional terminal `formatOutput` formatter.\n- [`resolveConfig(context, runtimeOptions?, configOptions?)`](#resolveconfigcontext-runtimeoptions-configoptions): resolve configuration and, when requested, build the plugin pipeline.\n- [`getLogger({ stdout, stderr })`](#getlogger-stdout-stderr-): create the logger used by semantic-release.\n- [`resolveEnvCi({ env?, cwd? })`](#resolveenvci-env-cwd-): resolve CI metadata for the current environment.\n\n### `default`\n\nExecute one full release run: verify context, normalize plugins, analyze commits, prepare, tag, publish, and call success/fail hooks.\n\nSignature:\n\n```ts\ndefault(input: {\n  context: Context;\n  plugins: PluginsInput;\n  onInit?: (context: Context) => Promise<void> | void;\n  formatOutput?: (text: string) => string | Promise<string>;\n}): Promise<false | { lastRelease; commits; nextRelease; releases }>\n```\n\nInputs:\n\n- `context` (required): execution context. Must include `context.options`.\n- `plugins` (required): explicit plugin source for the run.\n- `onInit` (optional): hook called before plugin normalization.\n- `formatOutput` (optional): formatter used before writing markdown release notes or semantic-release error details to terminal streams.\n\nBehavior notes:\n\n- Throws a `TypeError` when `context.options` or `plugins` is missing.\n- Returns `false` when no release should be performed.\n- Returns a result object when a release is added or published.\n- Calls `plugins.fail` with extracted semantic-release errors when possible.\n- Does not implement wrapper-level CI policy guards such as pull-request skip or auto dry-run.\n\nResult shape:\n\n- `lastRelease`: last matching release on the active branch.\n- `commits`: commits used for analysis.\n- `nextRelease`: computed next release metadata (when applicable).\n- `releases`: publish/addChannel outputs from plugins.\n\n### `resolveConfig(context, runtimeOptions?, configOptions?)`\n\nResolve semantic-release config into normalized `options`, and optionally build a normalized plugin pipeline.\n\nSignature:\n\n```ts\nresolveConfig(\n  context: Context,\n  runtimeOptions?: Options,\n  configOptions?: {\n    buildPlugins?: boolean;\n    baseConfig?: string | object;\n  }\n): Promise<{ options } | { options; plugins }>\n```\n\nInputs:\n\n- `context` (required): runtime context used during resolution (typically includes `cwd`, `env`, `envCi`, `stdout`, `stderr`, and `logger`).\n- `runtimeOptions` (optional): caller-provided semantic-release options that override values from config files and shareable configs.\n- `configOptions` (optional): controls how config resolution is performed. `configOptions` fields:\n  - `buildPlugins` (optional, default `false`):\n    - `true`: resolve config and build/normalize plugin pipeline.\n    - `false`: resolve config only; plugin loading is deferred to the caller.\n  - `baseConfig` (optional): seed config source (for example a shareable-config name or object) used as a base during resolution.\n\nReturn value:\n\n- Always returns normalized `options`.\n- Returns `plugins` only when `configOptions.buildPlugins` is `true`.\n\nTypical usage:\n\n- Use `configOptions.buildPlugins: true` to return both `options` and `plugins` for [config-driven composition](#1-config-driven-composition).\n- Use `configOptions.buildPlugins: false` to resolve `options` only and provide `plugins` explicitly to the default export for [direct composition](#2-direct-composition).\n- Use `configOptions.buildPlugins: false` when wrapper code needs to read `options.plugins`, enforce required plugins, and then pass the final plugin list explicitly to the default export for [direct composition](#2-direct-composition).\n\n### `getLogger({ stdout, stderr })`\n\nCreate a logger instance compatible with core/plugin execution.\n\nInputs:\n\n- `stdout` and `stderr` writable streams (required).\n\nBehavior notes:\n\n- `getLogger` does not inject fallback process streams. Passing missing streams (for example `getLogger({})`) produces an unusable logger.\n- Use this output to populate `context.logger` before calling `resolveConfig` or `default`.\n- The logger supports semantic-release style levels (`log`, `success`, `warn`, `error`, `start`, `skip`, `complete`).\n\n### `resolveEnvCi({ env?, cwd? })`\n\nDetect CI runtime metadata (for example branch/pr context) using the current process environment and working directory.\n\nInputs:\n\n- `env` (optional): environment variable object. Defaults to `process.env`.\n- `cwd` (optional): working directory. Defaults to `process.cwd()`.\n\nBehavior notes:\n\n- Use this output to populate `context.envCi` before calling `resolveConfig` or `default`.\n- Wrapper packages can apply additional policy on top of the detected CI state.\n\n## Supported composition paths\n\nThere are two supported ways to compose core.\n\n### 1. Config-driven composition\n\nUse `resolveConfig(..., { buildPlugins: true })` when you want core to resolve configuration and build the plugin pipeline for you.\n\n```js\nimport semanticRelease, { getLogger, resolveConfig, resolveEnvCi } from \"@semantic-release/core\";\n\nconst cwd = process.cwd();\nconst env = process.env;\nconst envCi = resolveEnvCi({ cwd, env });\nconst logger = getLogger({ stdout: process.stdout, stderr: process.stderr });\n\nconst context = {\n  cwd,\n  env,\n  envCi,\n  logger,\n  stdout: process.stdout,\n  stderr: process.stderr,\n};\nconst runtimeOptions = { dryRun: true };\n\nconst { options, plugins } = await resolveConfig(context, runtimeOptions, {\n  buildPlugins: true,\n  baseConfig: \"@my-org/release-config\",\n});\n\nconst result = await semanticRelease({\n  context: { ...context, options },\n  plugins,\n});\n```\n\n### 2. Direct composition\n\nPass an explicit plugin list or plugin pipeline directly to core when you want the plugin source to be authoritative in your code.\n\nIf you only want configuration resolution, use `resolveConfig(..., { buildPlugins: false })` and provide plugins separately.\n\n```js\nimport semanticRelease, { getLogger, resolveConfig, resolveEnvCi } from \"@semantic-release/core\";\n\nconst cwd = process.cwd();\nconst env = process.env;\nconst envCi = resolveEnvCi({ cwd, env });\nconst logger = getLogger({ stdout: process.stdout, stderr: process.stderr });\n\nconst context = {\n  cwd,\n  env,\n  envCi,\n  logger,\n  stdout: process.stdout,\n  stderr: process.stderr,\n};\nconst runtimeOptions = {\n  ci: true,\n  dryRun: true,\n};\n\nconst { options } = await resolveConfig(context, runtimeOptions, {\n  buildPlugins: false,\n});\n\nconst result = await semanticRelease({\n  context: { ...context, options },\n  plugins: [\"@semantic-release/commit-analyzer\"],\n});\n```\n\nWrappers can also use `resolveConfig(..., { buildPlugins: false })` to read configured plugin specs, apply wrapper policy, and then pass the final plugin list explicitly to core. This remains direct composition because the explicit `plugins` argument is still authoritative.\n\n```js\nimport semanticRelease, { getLogger, resolveConfig, resolveEnvCi } from \"@semantic-release/core\";\n\nconst BASE_CONFIG = {\n  plugins: [\"@semantic-release/commit-analyzer\", \"@semantic-release/release-notes-generator\"],\n};\n\nfunction ensureRequiredPlugins(configuredPlugins) {\n  return configuredPlugins.includes(\"@semantic-release/git\")\n    ? configuredPlugins\n    : [...configuredPlugins, \"@semantic-release/git\"];\n}\n\nconst cwd = process.cwd();\nconst env = process.env;\nconst envCi = resolveEnvCi({ cwd, env });\nconst logger = getLogger({ stdout: process.stdout, stderr: process.stderr });\n\nconst context = {\n  cwd,\n  env,\n  envCi,\n  logger,\n  stdout: process.stdout,\n  stderr: process.stderr,\n};\n\nconst { options } = await resolveConfig(\n  context,\n  {},\n  {\n    buildPlugins: false,\n    baseConfig: BASE_CONFIG,\n  }\n);\n\nconst configuredPlugins = Array.isArray(options.plugins) ? options.plugins : [];\nconst plugins = ensureRequiredPlugins(configuredPlugins);\n\nawait semanticRelease({\n  context: { ...context, options },\n  plugins,\n});\n```\n\nIn the direct-composition path, any plugin list passed to core is the plugin source, whether it comes directly from caller code or from wrapper code that first reads `options.plugins`. `options.plugins` from config or shareable-config `extends` is not used as a fallback source for plugin loading once the caller passes `plugins` explicitly.\n\n## Core contract\n\nThe default export expects an object with:\n\n- `context`: a release context that must include `context.options`.\n- `plugins`: the explicit plugin input for the run.\n- `onInit?`: an optional hook that runs before plugin normalization.\n- `formatOutput?`: optional formatter for markdown output written to `stdout`/`stderr`.\n\n`context.options` is required. `plugins` is required.\n\nThe release context should include the standard semantic-release runtime fields such as `cwd`, `env`, `envCi`, `stdout`, `stderr`, and `logger`.\n\n## `analyzeCommits` fallback injection\n\nCore injects `@semantic-release/commit-analyzer` as a fallback for `analyzeCommits` only when all of the following are true:\n\n- No plugin in the plugin list already provides `analyzeCommits`.\n- `options.analyzeCommits` is not already an explicit plugin spec.\n\nAn explicit plugin spec means one of these forms:\n\n- a string\n- a function\n- an array plugin spec\n- a plain object with a `path`\n\nWhen `options.analyzeCommits` is a plain object without `path`, core treats it as step configuration and merges it into the injected fallback plugin. If you want the highest-release-type-wins behavior from multiple analyzers, include `@semantic-release/commit-analyzer` explicitly in your plugin list.\n\nExamples:\n\n- Plugin list covers `analyzeCommits` -> no fallback injection.\n- `options.analyzeCommits` is a plugin spec -> no fallback injection.\n- `options.analyzeCommits` is an options-only plain object or is absent -> commit-analyzer is injected and the options are merged into it.\n\n## Git process environment defaults\n\nThe Git process environment is what core and git use to make automated releases non-interactive and to attribute commits and tags correctly in CI.\n\nSet these values before building the release `context` so `context.env` already includes them.\n\nThe example below shows the Git process environment values a caller or wrapper can set for CI.\n\nTypical caller-provided CI setup:\n\n```js\nObject.assign(env, {\n  GIT_AUTHOR_NAME: \"semantic-release-bot\",\n  GIT_AUTHOR_EMAIL: \"semantic-release-bot@semantic-release.org\",\n  GIT_COMMITTER_NAME: \"semantic-release-bot\",\n  GIT_COMMITTER_EMAIL: \"semantic-release-bot@semantic-release.org\",\n  ...env,\n  GIT_ASKPASS: \"echo\",\n  GIT_TERMINAL_PROMPT: 0,\n});\n```\n\nFor each of these value that you do not set, core applies its own defaults.\n\n## Dependency and ownership model\n\n`@semantic-release/core` does not own CLI parsing or wrapper defaults.\n\n- Core owns the release engine and config-resolution API.\n- Core expects callers to provide plugins explicitly.\n- Wrapper packages can layer default plugins, CLI flags, or output formatting on top of core.\n- Wrapper/caller code owns CI policy decisions (for example PR skip and auto dry-run behavior).\n- Core applies default git process environment hardening when values are missing; see [Git process environment defaults](#git-process-environment-defaults).\n- Wrapper/caller code can override any of those defaults by providing explicit values on `context.env`.\n\n## Plugin loading security model\n\nPlugin resolution is a trusted-code execution boundary. Plugin specs and shareable configuration sources can load code dynamically, so only use sources you trust.\n\nRecommended hardening practices:\n\n- protect release branches\n- use least-privilege CI tokens\n- enforce lockfile integrity with `npm ci`\n- prefer trusted shareable-config sources\n- make plugin-load failures visible in CI logs\n\n## TypeScript\n\nThe package ships TypeScript declarations. A minimal typed setup looks like this:\n\n```ts\nimport semanticRelease, { getLogger, resolveConfig, resolveEnvCi } from \"@semantic-release/core\";\n\nconst cwd = process.cwd();\nconst env = process.env;\nconst envCi = resolveEnvCi({ cwd, env });\nconst logger = getLogger({ stdout: process.stdout, stderr: process.stderr });\n\n// Optional: override defaults applied by core.\nObject.assign(env, {\n  GIT_AUTHOR_NAME: \"semantic-release-bot\",\n  GIT_AUTHOR_EMAIL: \"semantic-release-bot@example.com\",\n  GIT_COMMITTER_NAME: \"semantic-release-bot\",\n  GIT_COMMITTER_EMAIL: \"semantic-release-bot@example.com\",\n  ...env,\n  GIT_ASKPASS: \"echo\",\n  GIT_TERMINAL_PROMPT: 0,\n});\n\nconst context = {\n  cwd,\n  env,\n  envCi,\n  logger,\n  stdout: process.stdout,\n  stderr: process.stderr,\n};\nconst runtimeOptions = { dryRun: true };\n\nconst { options, plugins } = await resolveConfig(context, runtimeOptions, {\n  buildPlugins: true,\n  baseConfig: { branches: [\"main\"] },\n});\n\nawait semanticRelease({\n  context: { ...context, options },\n  plugins,\n});\n```\n","publish_time":1780678496541,"_cnpm_publish_time":1780678496541,"dist-tags":{"beta":"1.0.0-beta.17","latest":"1.0.0"}}