ek9_add_dependency
Answers with the edit that appends one runtime or dev dependency to the deps/devDeps Dict of a 'defines package' block - source only, nothing is fetched.
When to use it
'Add a dependency on ekopen.net.handy.tools 3.2.1-0' is one call with file:'package.ek9', bucket:'deps', module:'ekopen.net.handy.tools', version:'3.2.1-0'. Use bucket:'devDeps' for a test-only dependency.
When not to use it
- Removing a dependency - use
ek9_remove_dependency. - Blocking a TRANSITIVE dependency that a parent pulls in - use
ek9_exclude_transitive_dependency. - Declaring a security capability (a permission, not a library) - use
ek9_add_capability. - Fetching the declared dependencies afterwards -
ek9_resolve_dependencies(this tool edits the source only). - The 'defines package' block does not exist yet -
ek9_new_constructwith mode:'package' first.
Details
bucket selects deps or devDeps and the Dict is created when absent; only the multi-line Dict form is edited (a single-line bucket is error 'single-line-bucket-unsupported'). conflicts[].kind: 'dependency-already-pinned' (same module, same version - a no-op) or 'version-conflict' (same module, different version - ask the human). A file with no 'defines package' block is error 'package-block-not-found'; a version that is not major.minor.patch-build adds an advisories[] 'non-standard-version-format' but is written.
Arguments
| Argument | Type | Required | What it is |
|---|---|---|---|
bucket | string: deps | devDeps | yes | Which Dict to extend: 'deps' (runtime, deployed) or 'devDeps' (dev/test only, not deployed). |
file | string | yes | The .ek9 file holding the 'defines package' block, workspace-relative (typically 'package.ek9'); an absolute path inside the workspace is accepted. |
module | string | yes | The dependency's module name, e.g. 'ekopen.network.support.utils' - the Dict key. |
version | string | yes | The version to pin, e.g. '1.6.1-9' (major.minor.patch-build; a feature-tagged major.minor.patch-feature-build is also accepted) - the Dict value. |
It also takes the arguments every tool takes.
Recorded calls
Real calls, recorded against small projects and checked on every build - a changed answer fails it. 3 of the 4 recorded are shown.
Add dependency missing version
Request
{
"bucket" : "deps",
"file" : "package.ek9",
"module" : "ekopen.new.shiny.lib"
}
Response
{
"error" : {
"kind" : "missing-argument",
"message" : "Missing required parameter: version"
},
"meta" : {
"serverMs" : "<timing>"
},
"nextStep" : "re-call with version:'1.6.1-9'",
"status" : "error",
"summary" : "Missing required parameter: version"
}
Add dependency apply
Request
{
"bucket" : "deps",
"file" : "package.ek9",
"module" : "ekopen.new.shiny.lib",
"version" : "2.0.0-0"
}
Response
{
"conflicts" : [ ],
"edits" : [ {
"after" : " \"ekopen.new.shiny.lib\" : \"2.0.0-0\",",
"endLine" : 10,
"file" : "package.ek9",
"startLine" : 10,
"type" : "insert"
} ],
"meta" : {
"serverMs" : "<timing>"
},
"risk" : {
"crossesModuleBoundary" : false,
"estimatedSeverity" : "trivial",
"fileCount" : 1,
"lineCount" : 1,
"touchesPublicApi" : false,
"touchesTests" : false
},
"status" : "applied",
"summary" : "Added ekopen.new.shiny.lib=2.0.0-0 to deps",
"workspaceHash" : "<workspace-hash>",
"wouldBeDiagnostics" : [ ],
...
Cut short here: 2 more lines. The whole recorded call.
Add dependency already pinned
Request
{
"bucket" : "deps",
"file" : "package.ek9",
"module" : "ekopen.net.handy.tools",
"version" : "3.2.1-0"
}
Response
{
"conflicts" : [ {
"description" : "ekopen.net.handy.tools is already pinned at 3.2.1-0 in deps",
"file" : "package.ek9",
"kind" : "dependency-already-pinned"
} ],
"edits" : [ ],
"meta" : {
"serverMs" : "<timing>"
},
"risk" : {
"crossesModuleBoundary" : false,
"estimatedSeverity" : "trivial",
"fileCount" : 0,
"lineCount" : 0,
"touchesPublicApi" : false,
"touchesTests" : false
},
"status" : "conflicts",
"summary" : "ekopen.net.handy.tools is already pinned at 3.2.1-0 in deps",
"workspaceHash" : "<workspace-hash>",
"wouldBeDiagnostics" : [ ],
"written" : false
}
See also
- Part of the feature_branch_start workflow: Set feature-branch version + add new dependencies + resolve + verify.