openqa icon indicating copy to clipboard operation
openqa copied to clipboard

feat: integrate varlock for environment variable schema + validation

Open gurvinder-dhillon opened this issue 6 months ago • 0 comments

Overview

Replace bare dotenv with varlock in all scaffolded .openqa projects to add:

  • .env.schema — committed to git; documents every variable (name, description, type, default). AI agents can read the schema without seeing actual secret values.
  • Validation on load — clear errors if a required variable is missing or has the wrong type
  • Secret scanning / log leak detection at runtime
  • Multiple environment precedence (.env, .env.local, .env.[env])

Changes

  • Add varlock to all framework deps in init.js — auto-installed with zero manual steps
  • Add .env.schema template to each framework (playwright-bdd, cucumber, playwright-yaml)
  • Wrap npm scripts with varlock run -- so vars are pre-injected before Playwright/Cucumber starts
  • Remove import 'dotenv/config' from playwright.config files (varlock run makes it redundant)
  • Update template package.json files with engines: { node: ">=22" } (varlock requirement)

Approach

Use varlock run -- <command> in npm scripts rather than import 'varlock/auto-load' — this avoids a Node.js v22 constraint on the openqa core library itself while still providing full varlock features in the scaffolded project.

No change to src/index.js — openqa core keeps dotenv for its own env loading.

gurvinder-dhillon avatar May 06 '26 22:05 gurvinder-dhillon