{"name":"@semantic-release/core","version":"1.0.0-beta.2","keywords":["javascript","node"],"author":{"url":"http://babblebey.dev","name":"Olabode Lawal-Shittabey"},"license":"MIT","_id":"@semantic-release/core@1.0.0-beta.2","maintainers":[{"name":"semantic-release-bot","email":"semantic-release@martynus.net"},{"name":"gr2m","email":"gregor@martynus.net"},{"name":"travi","email":"npm@travi.org"}],"homepage":"https://github.com/semantic-release/core#readme","bugs":{"url":"https://github.com/semantic-release/core/issues"},"ava":{"files":["test/**/*.test.js"],"timeout":"2m","nodeArguments":["--no-warnings"]},"dist":{"shasum":"2d13162c40d8e7f45afbb8f4ba752664d5a5d8a2","tarball":"http://registry-npm.ywwl.com/@semantic-release/core/download/@semantic-release/core-1.0.0-beta.2.tgz","fileCount":29,"integrity":"sha512-Xcv6+Ykt6r2mO77v5VN/zPHJUZcFy0HOM2xVSH9L7WU/2jUMTnnDNcf0aZt8LxPGeizo7VTOkf+cDfuiBNQuMg==","signatures":[{"sig":"MEQCIDPyiLJncd4/Li+saTA2dovPQwL6DK1mVDfdoBok3ehpAiB8F6VVrnUfdZX4etpRW3Ic2/e7Fm4KiQEGlh9/8MdWOA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@semantic-release%2fcore@1.0.0-beta.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":124794,"size":32181,"noattachment":false,"key":"/@semantic-release/core/-/@semantic-release/core-1.0.0-beta.2.tgz"},"main":"./index.js","type":"module","types":"./index.d.ts","engines":{"node":"^22.14.0 || >= 24.10.0"},"exports":{".":{"types":"./index.d.ts","default":"./index.js"}},"gitHead":"70bde3f085b9b0de249e0797fbbd689ca4446083","scripts":{"test":"npm-run-all --print-label --parallel lint:* --serial test:*","format":"npm run lint:prettier:fix","test:unit":"ava --verbose","lint:engines":"ls-engines","lint:lockfile":"lockfile-lint","lint:prettier":"prettier --check \"*.{js,json,md}\" \".github/**/*.{md,yml}\" \"{lib,test}/**/*.js\"","test:integration":"ava --verbose test/integration.test.js","lint:prettier:fix":"prettier --write \"*.{js,json,md}\" \".github/**/*.{md,yml}\" \"{lib,test}/**/*.js\""},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:920b46e4-a808-48ca-b4f5-e158980abd85"}},"prettier":{"printWidth":120,"trailingComma":"es5"},"repository":{"url":"git+https://github.com/semantic-release/core.git","type":"git"},"_npmVersion":"11.17.0","description":"Core orchestration engine for semantic-release","directories":{},"_nodeVersion":"24.17.0","dependencies":{"debug":"^4.0.0","execa":"^9.0.0","env-ci":"^11.0.0","semver":"^7.3.2","figures":"^6.0.0","signale":"^1.2.1","hook-std":"^4.0.0","p-reduce":"^3.0.0","lodash-es":"^4.17.21","get-stream":"^6.0.0","micromatch":"^4.0.2","cosmiconfig":"^9.0.0","resolve-from":"^5.0.0","p-each-series":"^3.0.0","git-log-parser":"^1.2.0","aggregate-error":"^5.0.0","hosted-git-info":"^9.0.0","import-from-esm":"^2.0.0","read-package-up":"^12.0.0","@semantic-release/error":"^4.0.0","@semantic-release/commit-analyzer":"^13.0.1"},"lockfile-lint":{"path":"package-lock.json","type":"npm","allowed-hosts":["npm"],"validate-https":true},"publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"ava":"8.0.1","sinon":"^22.0.0","tempy":"^3.2.0","fs-extra":"^11.3.5","prettier":"3.8.3","ls-engines":"0.10.0","testdouble":"^3.20.2","npm-run-all2":"^9.0.1","lockfile-lint":"5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/core_1.0.0-beta.2_1782525330349_0.7703447573384927","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":1782525330541,"_cnpm_publish_time":1782525330541,"dist-tags":{"beta":"1.0.0-beta.17","latest":"1.0.0"}}