@springtree/eva-contentful-cli
v1.2.1
Published
NPM scripts for EVA project that use Contentful
Keywords
Readme
eva-contentful-cli
:evergreen_tree: Purpose
A command-line tool that copies STEP values from EVA into the field validations of Contentful content types. STEP values are product attributes that EVA gets from the STEP product information system.
The tool reads all content types in the master environment of a Contentful
space. If a content type has one of the fields below, the tool adds the values
to the in validation of that field:
| Field | Values added |
| ------------------ | ------------------------------------------------------------------- |
| stepMainCategory | The STEP main categories from EVA |
| stepSubCategory | The STEP sub categories from EVA |
| ancientRitual | The rituals from EVA, plus the concept collections in the code |
| locale | The fixed list of locales in the code |
| Field | Value | | ---------------- | --------------------- | | Customer | Rituals | | Project | Not recorded yet | | Production owner | Not recorded yet |
The package is public on npm as
@springtree/eva-contentful-cli.
:seedling: Getting started
You need these four values:
- An EVA token with permission to read STEP data.
- A Contentful management token with write access to the space.
- The Contentful space ID.
- The EVA domain, without
https://.
The package requires Node.js 24 or later. Run it with npx:
npx @springtree/eva-contentful-cli -c {CONTENTFUL_TOKEN} -e {EVA_EMPLOYEE_TOKEN} -s {CONTENTFUL_SPACE_ID} -d {EVA_DOMAIN}NOTE: The tool updates and publishes the content types in the
masterenvironment at once. There is no dry run.
The tool only adds values. It merges the new values with the existing list, removes duplicates and sorts the result. It never removes a value.
Upgrading from 1.2.0
The arguments are unchanged. What is different:
- Node.js 24 or later is required.
- contentful-management is upgraded from 7 to 12 and uses the plain client.
- The tool waits for every content type to finish. An unexpected error now reaches the command line error handler instead of being lost.
- A failed update is logged and that content type is not published. A failed publish is logged too.
- The "field not found" message shows the content type ID. It showed
undefinedbefore.
Command line arguments
| Argument | Required | Description |
| -------------------- | -------- | ------------------------------------------------- |
| -e, --eva | Yes | EVA token with permission to read STEP data |
| -c, --contentful | Yes | Contentful management token |
| -s, --space | Yes | Contentful space ID to update |
| -d, --domain | Yes | EVA domain, without the https:// prefix |
| -h, --help | No | Show the help message and stop |
Example result
After a run, the locale field of a content type looks like this:
{
"id": "locale",
"name": "Locale",
"type": "Symbol",
"localized": false,
"required": true,
"validations": [
{
"in": [
"bg_BG",
"da-DK",
"de-AT",
"de-CH",
"de-DE",
"el_GR",
"en-AT",
"en-BE",
...
]
}
],
"disabled": false,
"omitted": false
}:hammer: Development
# Use the Node.js version in .nvmrc (24)
fnm use # or: nvm use
# Install the dependencies from the lockfile
npm ci
# Run the CLI from the working copy
node lib/cli.js -c {CONTENTFUL_TOKEN} -e {EVA_EMPLOYEE_TOKEN} -s {CONTENTFUL_SPACE_ID} -d {EVA_DOMAIN}The locale list and the concept collections are in lib/contentful-fn.js. To
add a locale or a collection, edit that file.
NOTE: The repository has no tests and no linter. A run from the working copy changes the real Contentful space, the same as a run with npx.
:cool: Technology stack
- Node.js 24 with CommonJS modules. The version is in
.nvmrc. - yargs for the command line arguments.
- node-fetch for the EVA
SearchProductscall. - contentful-management, with the plain client.
- lodash.
- release-please for releases.
:twisted_rightwards_arrows: Branch strategy and protection
The default branch is master. It is the only long-lived branch. Every push
to it updates the release pull request (see Deploying).
The organization ruleset protects master:
- No direct pushes. All changes go through a pull request, merged by squash or rebase. History stays linear, and nobody can force-push or delete the branch.
- The four supply-chain checks (
supply-chain / secrets,supply-chain / licences,supply-chain / codeandsupply-chain / quarantine) run on every pull request. They block merging when an admin turns on enforcement for this repository. - Changes to the policy files (
.github/CODEOWNERS,.github/workflows/compliance.ymlandlicence-exemptions.json) need a review from@springtreesolutions/springtree-admins(see.github/CODEOWNERS).
:pencil: Commit messages
Commits follow Conventional Commits. release-please reads them to choose the next version and to write the changelog:
| Commit | Release |
| ------------------------------- | ------- |
| fix: or perf: | Patch |
| feat: | Minor |
| A BREAKING CHANGE: footer | Major |
| Other types, such as docs: | None |
Nothing checks the format. A commit with a wrong message does not cause a release.
:lock: Compliance
This repository is gated by SpringTree's shared supply-chain workflow
(.github/workflows/compliance.yml), which runs four checks on every pull
request and a full-history scan weekly:
| Gate | Refuses |
| ------------ | ------------------------------------------------------- |
| secrets | a credential committed anywhere in the scanned range |
| licences | a dependency whose licence is not on the allow-list |
| code | a code pattern the ruleset classes as a security defect |
| quarantine | missing or incorrect package-cooldown configuration |
A red gate is fixed here, in this repository. The
springtree-ci-workflows
README documents each gate and its inputs.
Packages younger than seven days are refused (min-release-age in .npmrc).
That window is a management decision recorded in the secure development
standard, not a local preference. Raise it there first.
:mag: Before you push
git config core.hooksPath .githooks # once per clone
brew install gitleaks # once per machineThe hook scans the commits you are about to push for secrets. If gitleaks is
not installed, the hook refuses the push. It is feedback, not enforcement: --no-verify skips
it and CI does not. Skipping is break-glass.
:up: Deploying
The package is published to npm as
@springtree/eva-contentful-cli
by GitHub Actions using release-please
(.github/workflows/release.yml). Nothing is published by hand.
- Every merge to
masterupdates a single release pull request with the version bump and changelog since the last release (release-please-config.json, current version in.release-please-manifest.json) - Merging the release pull request creates the tag and GitHub release
- The same workflow then publishes the package under the
latestdist-tag
Pull requests to master are checked by .github/workflows/build.yml, which
installs the dependencies with npm ci and does not publish.
Publishing uses npm trusted publishing
(OIDC), so there is no npm token. The package has a trusted publisher on
npmjs.com for this repository, workflow release.yml and environment
npm-publish. That GitHub environment only allows deployments from master,
so no other branch can publish.
