Skip to content

Config

@simple-release/config loads the config file and turns addon queries into instances. It is how the GitHub Action reads the project setup, and it works the same in your own scripts.

release.js
import { Releaser } from '@simple-release/core'
import { load } from '@simple-release/config'
const {
project,
hosting,
releaser,
...options
} = await load({
config: true,
project: true
})
await new Releaser({
project,
hosting,
...releaser
})
.setOptions(options)
.bump()
.commit()
.tag()
.push()
.publish()
.release()
.run()

load(requirements, loader) searches up from the current directory for the first config file — .simple-release.js, .simple-release.mjs, .simple-release.cjs, or .simple-release.json — imports it, validates it against the requirements, and instantiates the project and hosting queries.

ParameterDescription
requirementsWhich keys must be present: { config: true } — the config file itself must exist; any config key set to true — that key must be set, e.g. { project: true }.
loaderHow to import a queried package: (path, version, config) => Promise<module>. Defaults to a plain import().

The returned object is the parsed config with project and hosting already instantiated: the releaser key holds the releaser options, and the rest are step options for setOptions.

The loader is the extension point for environments where addons are not preinstalled — the GitHub Action passes a loader that installs the queried package with the pinned version into a cache directory before importing it.

The query parser is exported for custom loaders:

import { parseImportQuery } from '@simple-release/config'
parseImportQuery('@simple-release/pnpm@3.2.1#PnpmWorkspacesProject')
// { path: '@simple-release/pnpm', version: '3.2.1', symbol: 'PnpmWorkspacesProject' }

symbol defaults to the module’s default export when omitted.