Skip to content

feat(cli): harden env checks, add tests, non-interactive flags for new - #101

Merged
marioserrano09 merged 1 commit into
mainfrom
feat/cli-hardening
Sep 22, 2026
Merged

marioserrano09 merged 1 commit into
mainfrom
feat/cli-hardening

Conversation

@marioserrano09

Copy link
Copy Markdown
Contributor

Closes #95, #96, #97, #98, #99, #100.

Changes

  • checkJava() (env.ts): parses the major version out of the version "NN pattern instead of an includes('25') substring match — avoids false positives on e.g. a JDK reporting 17.0.25.
  • checkNode() (env.ts): now reads the minimum version from cli.properties via CliConfig instead of a hardcoded 22, matching package.json's engines.node >=24.
  • fetchSpringBootVersion() (new.ts): added a 4s AbortSignal timeout so a slow/dead start.spring.io degrades to the fallback instead of stalling the wizard.
  • Tests: added vitest (same setup as sdk/ui-core/vue/microfrontend-bridge) with 31 unit tests covering config.ts (properties parsing, token camelCasing, template loading), replace.ts (token replacement, Java package renaming/Application class rename, pom.xml rewriting), env.ts (mocked execa), and the new flag parser. package.json now has a real test script, so pnpm -r test in publish-npm.yml actually gates on this package instead of silently skipping it.
  • Non-interactive flags for dynamia new: --name, --scaffold, --backend-lang, --group-id, --artifact-id, --version, --description, --frontend, --pm, --yes, --git/--no-git. Any flag left unset still falls back to its interactive prompt. Verified end-to-end with a real clone of template-backend-java.
  • Removed the stray package-lock.json — this is a pnpm workspace and the package was already tracked in the root pnpm-lock.yaml.

Verification

  • pnpm run typecheck — clean
  • pnpm run build — clean
  • pnpm run test — 31/31 passing
  • Manual smoke test: dynamia new --name smoke-test --scaffold backend --backend-lang java --group-id com.acme --artifact-id smoke-test --version 1.0.0-SNAPSHOT --yes --no-git generated a correctly renamed project (SmokeTestApplication.java under com/acme/smoke/test).

Note: base branch also depends on #93 (disables the 4 template ids without an existing repo) — that PR is separate and unmerged, this one doesn't touch cli.properties.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UcARdenC1Sk5EVpkzboH9W

- checkJava(): parse the major version out of the "version \"NN" pattern
  instead of an includes('25') substring match (false-positive risk on
  e.g. a JDK reporting 17.0.25).
- checkNode(): read the minimum version from cli.properties/CliConfig
  instead of a hardcoded 22, matching engines.node (>=24).
- fetchSpringBootVersion: add a 4s AbortSignal timeout so a slow/dead
  start.spring.io doesn't stall the wizard before the first prompt.
- Add vitest (matching sdk/ui-core/vue/microfrontend-bridge convention)
  with unit tests for config.ts parsing, replace.ts (token replacement
  + Java package renaming), env.ts checks, and the new flag parser.
- dynamia new: add non-interactive flags (--name, --scaffold,
  --backend-lang, --group-id, --artifact-id, --version, --description,
  --frontend, --pm, --yes, --git/--no-git) so the wizard can run
  unattended for scripting/CI. Any flag left unset still prompts.
- Remove stray package-lock.json (npm) -- this is a pnpm workspace and
  the package was already tracked in the root pnpm-lock.yaml.

Fixes #95, #96, #97, #98, #99, #100

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UcARdenC1Sk5EVpkzboH9W
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.

cli: checkJava() version detection is a fragile substring match

1 participant