feat: add configuration option#2
Open
TomChv wants to merge 1 commit into
Open
Conversation
Signed-off-by: Vasek - Tom C <tom.chauveau@epitech.eu>
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.
Make TypeScript module customization first-class in the
typescript-sdkmodule, instead of requiring users to hand-editpackage.json/deno.json. Two settings are exposed: package manager and base image — both at creation time (viainitflags) and afterward (viamod ... configcommands). All settings persist to the module's config file.Runtime selection stays on
initas the existingRuntimeenum (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-alpineBoth flags are optional. Defaults leave the template unconfigured (no
packageManagerfield, no base image override).--package-manageris rejected with--runtime DENOsince Deno does not use a Node package manager.Configure an existing module
Read current configuration:
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-imageWhere it's stored
package.json#packageManager(Node-standard, corepack reads it)package.json#dagger.baseImagedeno.json#dagger.baseImagebaseImageis routed by runtime detection: for Deno modules (deno.jsonpresent at the module root) it writes todeno.json, otherwise topackage.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 theinitflags and themod.configcommand surface drive that single helper, so there is one source of truth for reading and writing config.Empty
daggerobjects are pruned onunset-base-imageso the file does not carry a stray empty table after a round trip.Testing
helpers/module-config).configCheckcovers readers, single-file-scope edits, sibling-key preservation on unset, andbaseImagerouting todeno.jsonfor Deno modules.initConfigCheckcovers init flags writing to the correct file (package.jsonfor Node,deno.jsonfor Deno), default init leaving the config untouched, and Deno init not generating a straypackage.json.