Draft
Conversation
Reads a local .env file, diffs against remote MRT env vars, shows a summary, prompts for confirmation (skippable with --yes), and pushes changed variables one at a time with per-variable success/failure reporting. New files: - src/commands/mrt/env/var/push.ts — oclif command extending MrtCommand - src/utils/mrt/env-var-diff.ts — pure diff utilities (filterByPrefix, computeEnvVarDiff, formatEnvVarDiffSummary) - test/commands/mrt/env/var/push.test.ts — 8 mocha tests - test/utils/mrt/env-var-diff.test.ts — 19 mocha tests Adds dotenv dependency for .env file parsing.
Collaborator
|
We're using nodes native dotenv support and it comes with some programmatic APIs. @vmarta can you explore if https://nodejs.org/api/util.html#utilparseenvcontent is sufficient. It's available in node 21+ which is good for us and sfnext |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Storefront Next developers need to sync their local
.envfile to a Managed Runtime environment before or after a deployment. Today this is a manual process: look up each variable, compare it against what's in MRT, and callb2c mrt env var setone by one.This command automates that workflow. It belongs in
b2c-cli(rather than the storefront-next CLI) because pushing env vars to MRT is useful to any project deployed on MRT, not just storefront-next storefronts.TODOs:
dotenvdependencyWhat's changed
Adds
b2c mrt env var push— a new command alongside the existinglist,set, anddeletecommands.Behaviour:
.envfile (default:.env, configurable with--file)MRT_, configurable with--exclude-prefix)mrt env var list--yesis passed{ pushed, failed, skipped }in--jsonmodeNew files:
src/commands/mrt/env/var/push.ts— oclif commandsrc/utils/mrt/env-var-diff.ts— pure diff utilities (filterByPrefix,computeEnvVarDiff,formatEnvVarDiffSummary)test/commands/mrt/env/var/push.test.ts— 8 unit teststest/utils/mrt/env-var-diff.test.ts— 19 unit testsHow to test
Prerequisites: a Managed Runtime project you can write to, and a valid
~/.mobifycredentials file (b2c loginif needed).