Skip to content

feat(cli): default to envilder.json and .env when flags are omitted - #314

Open
macalbert with Copilot wants to merge 35 commits into
mainfrom
copilot/featcli-default-to-envilder-json
Open

feat(cli): default to envilder.json and .env when flags are omitted#314
macalbert with Copilot wants to merge 35 commits into
mainfrom
copilot/featcli-default-to-envilder-json

Conversation

Copilot AI commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds zero-config CLI defaults: when --map is omitted, the CLI resolves
envilder.json from the current directory; when --envfile is omitted, it
defaults to .env. Running envilder with no flags now works when an
envilder.json is present in the working directory.

Note: this PR was originally opened as a docs-only line-wrap fix. The branch
actually delivers a CLI behavior change, so the title and description have been
updated to match. Semver impact: minor.

Changes

  • src/envilder/apps/cli/Cli.ts: default --mapenvilder.json and
    --envfile.env when omitted; reject empty --map values.
  • Push-single honors $config: single-variable push
    (--key/--value/--secret-path) now resolves the default envilder.json when
    present and reads its $config section (provider, vaultUrl, profile),
    so it targets the same provider as the rest of the project instead of
    silently defaulting to AWS. Missing envilder.json is not an error for
    push-single. The resolved provider is logged before the push for
    transparency. CLI flags still override $config.
  • Single source of truth for operation mode: the CLI now derives the mode
    from DispatchActionCommand.determineOperationMode, removing the duplicated
    push-single detection that previously lived in Cli.ts.
  • Tests: unit coverage in tests/envilder/apps/cli/Cli.test.ts (zero-config
    defaults, empty-map rejection, push-single without a map file, push-single
    reading envilder.json $config) and e2e coverage in e2e/cli.test.ts
    (zero-config pull, missing-map error message). E2E temp dirs are cleaned up
    via Vitest's onTestFinished so cleanup runs even when an assertion fails.
  • Docs / website / i18n: README, docs/pull-command.md,
    docs/push-command.md, and website copy updated to document the zero-config
    defaults and the push-single $config behavior.

Type of change

  • Feature
  • Bugfix
  • Refactor
  • Documentation
  • Other

Checklist

  • Tests added/updated
  • Docs updated
  • Lint/format pass

Notes for reviewer

Addresses all review feedback:

  • Push-single no longer requires a map file, and now honors $config from
    envilder.json when present (no silent AWS fallback for Azure projects).
  • The --map default is consistently applied wherever a map file is consulted.
  • E2E temp-directory cleanup is reliable on assertion failure via
    onTestFinished.
  • PR title/description updated to reflect the behavioral change.

Copilot AI linked an issue Jun 7, 2026 that may be closed by this pull request
10 tasks
Copilot AI changed the title [WIP] Add default behavior for envilder CLI without --map feat(cli): zero-config defaults — --map → envilder.json, --envfile → .env Jun 7, 2026
Copilot AI requested a review from macalbert June 7, 2026 21:09
Copilot AI changed the title feat(cli): zero-config defaults — --map → envilder.json, --envfile → .env fix(docs): wrap long line in README.md to pass MD013 markdownlint check Jun 7, 2026
@macalbert
macalbert marked this pull request as ready for review June 7, 2026 21:15
Copilot AI review requested due to automatic review settings June 7, 2026 21:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a “zero-config” CLI path resolution (defaulting to envilder.json and .env when flags are omitted), and updates docs/website copy and tests to reflect the new UX.

Changes:

  • Add CLI defaults for --map/--envfile (with new error when no map is discoverable).
  • Update docs + website quickstart snippets to show envilder / envilder --push without explicit paths.
  • Add/adjust unit + E2E test coverage for the new defaulting behavior.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/envilder/apps/cli/Cli.ts Adds default map/envfile resolution and updates banner/help messaging.
tests/envilder/apps/cli/Cli.test.ts Adds unit tests + mocks for existsSync to cover default-map/default-envfile cases.
e2e/cli.test.ts Adds E2E coverage for zero-arg behavior and updates expected error messaging; adds cwd support in runner.
README.md Updates quickstart to show zero-config invocation and wraps the previously-long line.
docs/pull-command.md Updates pull docs/examples/options to describe defaults.
docs/push-command.md Updates push docs/examples/options to describe defaults.
src/website/src/components/HowItWorks.astro Updates terminal snippets to use the shorter commands.
src/website/src/components/GetStarted.astro Updates terminal snippet for pull to envilder only.
src/website/src/i18n/en.ts Updates quickstart step text to “Run envilder”.
src/website/src/i18n/es.ts Updates quickstart step text to “Ejecuta envilder”.
src/website/src/i18n/ca.ts Updates quickstart step text to “Executa envilder”.

Comment thread src/envilder/apps/cli/Cli.ts Outdated
Comment thread src/envilder/apps/cli/Cli.ts Outdated
Comment thread README.md
Comment thread e2e/cli.test.ts Outdated
Comment thread e2e/cli.test.ts
@macalbert macalbert changed the title fix(docs): wrap long line in README.md to pass MD013 markdownlint check feat(cli): default to envilder.json and .env when flags are omitted Jun 7, 2026
macalbert added 2 commits June 8, 2026 01:11
Push-single mode (--key/--value/--secret-path) does not need a map file, but

resolveMapFile() was called unconditionally and threw 'No map file found' when

envilder.json was absent in the cwd. Guard the default-map lookup so push-single

passes options.map through as-is. Pull and push-env modes are unchanged.
The zero-config and missing-map e2e tests deleted their temp directories

after the assertions. A failing assertion left the directory behind. Wrap

Act+Assert in try/finally so rm() always runs.
Copilot AI review requested due to automatic review settings June 8, 2026 06:36
@macalbert
macalbert force-pushed the copilot/featcli-default-to-envilder-json branch from 2168c0e to 93924f5 Compare June 8, 2026 06:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.

Comment thread src/envilder/apps/cli/entry/Cli.ts
macalbert added 2 commits June 8, 2026 18:28
Push-single skipped map-file resolution entirely, so the config section
(provider, vaultUrl, profile) from envilder.json was ignored — a user
with an Azure config silently pushed to AWS. Now push-single resolves
the default envilder.json when present (without throwing if absent) and
reads its config section. Operation mode is derived from a single
source (determineOperationMode), removing the duplicated push-single
check, and the resolved provider is logged for transparency.
Single-variable push now reads the config section from envilder.json when

present, targeting the same provider as the project. Clarify the behavior

and add the optional map row to the push-single options table.
Copilot AI review requested due to automatic review settings June 8, 2026 20:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.

Comment thread src/envilder/apps/cli/Cli.ts Outdated
Comment thread e2e/cli.test.ts
Comment thread tests/envilder/apps/cli/Cli.test.ts Outdated
Comment thread docs/push-command.md

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Comment on lines +210 to +213
const trimmed = envfileOption.trim();
if (trimmed.length === 0) {
throw new Error('Invalid --envfile value: path must not be empty.');
}
Copilot AI review requested due to automatic review settings July 26, 2026 21:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/envilder/apps/cli/entry/Cli.ts:213

  • resolveEnvfile() throws a generic Error for invalid --envfile values, while other CLI argument validation (e.g., --map) uses the domain InvalidArgumentError. Using the domain error keeps CLI argument failures consistent and aligns with the project's error-handling conventions.
  if (trimmed.length === 0) {
    throw new Error('Invalid --envfile value: path must not be empty.');
  }

Copilot AI review requested due to automatic review settings July 27, 2026 08:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/envilder/apps/cli/entry/Cli.ts:213

  • resolveEnvfile() throws a plain Error for an invalid --envfile value, while other CLI argument validation consistently uses InvalidArgumentError (e.g., resolveMapFile() and DispatchActionCommandHandler). Using the domain error keeps argument failures consistent for callers and error presentation.
  const trimmed = envfileOption.trim();
  if (trimmed.length === 0) {
    throw new Error('Invalid --envfile value: path must not be empty.');
  }

@macalbert

Copy link
Copy Markdown
Owner

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Addressed in 398217a (Merge branch 'main' into copilot/featcli-default-to-envilder-json). The worktree and index have no unresolved entries or conflict markers, and the merge preserves the CLI changes relative to main. CI run 30250837397 passed formatting, lint, build, and unit tests for this exact SHA.

Copilot AI review requested due to automatic review settings July 31, 2026 09:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/envilder/apps/cli/entry/Cli.ts:213

  • resolveEnvfile() throws a plain Error for invalid --envfile values, while other CLI argument validation in this flow uses InvalidArgumentError (e.g., resolveMapFile() and DispatchActionCommandHandler validations). Using InvalidArgumentError here keeps argument failures typed consistently for the CLI error presenter and any downstream handling.
  const trimmed = envfileOption.trim();
  if (trimmed.length === 0) {
    throw new Error('Invalid --envfile value: path must not be empty.');
  }

Copilot AI review requested due to automatic review settings July 31, 2026 09:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Suppressed comments (2)

src/envilder/apps/cli/entry/Cli.ts:213

  • resolveEnvfile() throws a plain Error for invalid --envfile values, while other CLI argument validation uses InvalidArgumentError (including resolveMapFile()). Using the domain error type keeps argument errors consistent and easier to handle uniformly in the CLI presenter.
  const trimmed = envfileOption.trim();
  if (trimmed.length === 0) {
    throw new Error('Invalid --envfile value: path must not be empty.');
  }

tests/envilder/apps/cli/entry/Cli.test.ts:265

  • This test currently only asserts the error message. If resolveEnvfile() is meant to treat empty --envfile as an invalid CLI argument (like --map), it’s better to also assert the thrown error type (InvalidArgumentError) to prevent regressions where a generic error is thrown instead.
    // Assert
    await expect(action).rejects.toThrow(
      'Invalid --envfile value: path must not be empty.',
    );

Copilot AI review requested due to automatic review settings July 31, 2026 10:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

src/envilder/apps/cli/entry/Cli.ts:213

  • resolveEnvfile() throws a generic Error for invalid --envfile values, while other CLI argument validation throws InvalidArgumentError. Using the domain error consistently makes argument failures easier to handle/present uniformly (and aligns with resolveMapFile()).
  const trimmed = envfileOption.trim();
  if (trimmed.length === 0) {
    throw new Error('Invalid --envfile value: path must not be empty.');
  }

Comment on lines +75 to +85
<span class="line">
<span class="comment">{t.getStarted.commentPull}</span>
</span>
<span class="line">
<span class="prompt">$</span><span class="command"> envilder</span>
</span>
<span class="line">&nbsp;</span>
<span class="line">
<span class="highlight">✔</span>
<span class="output">{t.getStarted.doneMessage}</span>
</span>
Copilot AI review requested due to automatic review settings July 31, 2026 11:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Suppressed comments (4)

src/envilder/apps/cli/entry/Cli.ts:213

  • resolveEnvfile() throws a generic Error for invalid --envfile values, while other CLI argument validation uses InvalidArgumentError (e.g., resolveMapFile() and DispatchActionCommandHandler). Using the domain error keeps argument errors consistent and easier to classify/present.
  const trimmed = envfileOption.trim();
  if (trimmed.length === 0) {
    throw new Error('Invalid --envfile value: path must not be empty.');
  }

src/website/src/components/GetStarted.astro:103

  • t.getStarted.commentPull is referenced, but the website i18n types and locale dictionaries currently don’t define this key (it’s missing from GetStartedTranslations and en.ts), which will break type-checking/build.
          <span class="line">
            <span class="comment">{t.getStarted.commentPull}</span>
          </span>
          <span class="line">
            <span class="prompt">$</span><span class="command"> envilder</span>

src/website/src/components/GetStarted.astro:109

  • t.getStarted.doneMessage is referenced, but the website i18n types and locale dictionaries currently don’t define this key, which will break type-checking/build.
          <span class="line">
            <span class="highlight">✔</span>
            <span class="output">{t.getStarted.doneMessage}</span>
          </span>

tests/envilder/apps/cli/entry/Cli.test.ts:266

  • This test asserts only a generic thrown error for an empty --envfile. If resolveEnvfile() is updated to throw InvalidArgumentError (to match other CLI argument validation), this should assert the specific error type to keep the test aligned with the intended contract.
  it('Should_ThrowError_When_EnvfileOptionIsEmptyString', async () => {
    // Arrange
    process.argv = ['node', 'cli.js', '--map', 'map.json', '--envfile', '   '];

    // Act
    const action = () => main();

    // Assert
    await expect(action).rejects.toThrow(
      'Invalid --envfile value: path must not be empty.',
    );
  });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation e2e End-to-end tests (Playwright) enhancement New feature or request size/L Large change — 200-399 lines / 10-24 files; consider splitting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(cli): default to envilder.json when --map is omitted

3 participants