Skip to content

feat: add configuration option#2

Open
TomChv wants to merge 1 commit into
mainfrom
feat/add-configuration-options
Open

feat: add configuration option#2
TomChv wants to merge 1 commit into
mainfrom
feat/add-configuration-options

Conversation

@TomChv
Copy link
Copy Markdown
Member

@TomChv TomChv commented Jun 4, 2026

Make TypeScript module customization first-class in the typescript-sdk module, instead of requiring users to hand-edit package.json / deno.json. Two settings are exposed: package manager and base image — both at creation time (via init flags) and afterward (via mod ... config commands). All settings persist to the module's config file.

Runtime selection stays on init as the existing Runtime enum (NODE / BUN / DENO); pinning a runtime version (e.g. node@20.15.0) is an advanced case and not exposed yet.

Configure at creation

dagger call typescript-sdk init --name my-module \
    --package-manager pnpm@8.15.4 \
    --base-image node:23.2.0-alpine

Both flags are optional. Defaults leave the template unconfigured (no packageManager field, no base image override). --package-manager is rejected with --runtime DENO since Deno does not use a Node package manager.

Configure an existing module

Read current configuration:

dagger call typescript-sdk mod --path my-module config package-manager
dagger call typescript-sdk mod --path my-module config base-image

Change configuration (each returns a Changeset, prompting before writing):

dagger call typescript-sdk mod --path my-module \
    config set-package-manager --value pnpm@8.15.4
dagger call typescript-sdk mod --path my-module \
    config set-base-image --image node:23.2.0-alpine
dagger call typescript-sdk mod --path my-module config unset-package-manager
dagger call typescript-sdk mod --path my-module config unset-base-image

Where it's stored

Setting Location
Package manager package.json#packageManager (Node-standard, corepack reads it)
Base image (Node / Bun) package.json#dagger.baseImage
Base image (Deno) deno.json#dagger.baseImage

baseImage is routed by runtime detection: for Deno modules (deno.json present at the module root) it writes to deno.json, otherwise to package.json. The engine accepts either, so per-module we keep one source of truth.

How it works

A small JSON-aware Go helper (helpers/module-config) reads/edits the target config file, preserving unrelated keys. Both the init flags and the mod.config command surface drive that single helper, so there is one source of truth for reading and writing config.

Empty dagger objects are pruned on unset-base-image so the file does not carry a stray empty table after a round trip.

Testing

  • Go unit tests for the helper (helpers/module-config).
  • e2e check configCheck covers readers, single-file-scope edits, sibling-key preservation on unset, and baseImage routing to deno.json for Deno modules.
  • e2e check initConfigCheck covers init flags writing to the correct file (package.json for Node, deno.json for Deno), default init leaving the config untouched, and Deno init not generating a stray package.json.

Signed-off-by: Vasek - Tom C <tom.chauveau@epitech.eu>
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.

1 participant