Skip to content

feat(content): make the da.live backend and IMS provider configurable via env vars - #2796

Open
bpauli wants to merge 3 commits into
adobe:mainfrom
bpauli:content-env
Open

bpauli wants to merge 3 commits into
adobe:mainfrom
bpauli:content-env

Conversation

@bpauli

@bpauli bpauli commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Closes #2795.

What

The aem content commands were pinned to admin.da.live and a single hardcoded IMS provider. This resolves the da.live admin host and the IMS origin/client/scope from environment variables, defaulting to today's production values. With nothing set, behavior is unchanged.

Changes

  • src/content/da-api.js - resolve the DA admin host from AEM_DA_ADMIN (default https://admin.da.live); all /source and /list URLs use it.
  • src/content/da-auth.js - resolve the IMS origin, client id, and scope from AEM_DA_IMS_ORIGIN / AEM_DA_IMS_CLIENT_ID / AEM_DA_IMS_SCOPE (prod defaults). Cache the token per backend by keying the token file on the resolved host; admin.da.live keeps its existing .hlx/.da-token.json, so nothing migrates.
  • src/cli.js - load a local .env via dotenv before yargs parses, so its existing .env('AEM_') picks the vars up. A real shell variable overrides the file. .env is gitignored.
  • src/content/clone.cmd.js / push.cmd.js - clone records the source backend host; a push to a different backend than the clone source skips the source-baseline conflict check and requires --force, copying all files. Same-backend push is unchanged.

Tests

New coverage for the env-resolved host and IMS config, the per-env token file, and the cross-backend copy path under test/content/. Content tests and lint pass; the existing server suite is unaffected.

These are advanced options and stay out of --help; production remains the default everywhere.

Load the project .env in src/cli.js so that AEM_* variables reach the
commands, and resolve the da.live admin host from AEM_DA_ADMIN with
https://admin.da.live as the default. Variables already present in the
real environment keep precedence over the .env file, and .env is now
git ignored.
Replace the hardcoded IMS origin, client id and scope in da-auth.js with
values resolved from AEM_DA_IMS_ORIGIN, AEM_DA_IMS_CLIENT_ID and
AEM_DA_IMS_SCOPE, each defaulting to today's prod value when unset, and
key the cached token file by an environment label derived from the
resolved DA admin host. The default host keeps the unchanged
.hlx/.da-token.json name, so no token migrates; every other host gets its
own .hlx/.da-token-<label>.json, and the git ignore entry is now the glob
.hlx/.da-token*.json.
clone records the admin host it cloned from in .da-config.json. push
compares that host with the resolved target host: a push to another
backend is a copy, not a sync, so the source baseline no longer applies.

On a backend mismatch push skips the conflict check, uploads every file
at HEAD (no deletes), leaves the sync baseline with the backend it
belongs to, and requires --force. Without --force it stops with
"pushing to a different backend than cloned from; use --force to copy".

A push to the backend that was cloned from, or from a config that has no
recorded host, keeps the existing baseline and conflict behavior.
Comment thread test/cli.test.js
const cliPath = path.resolve(__rootdir, 'src', 'cli.js').split(path.sep).join('/');
const script = `import('file://${cliPath}').then(() => {`
+ ' process.stdout.write(String(process.env.AEM_DA_ADMIN)); });';
return shell.exec(`node -e ${JSON.stringify(script)}`, {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aem content: make the da.live backend and IMS provider configurable via env vars

2 participants