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. A dependency not installed in the library yet is the normal first step: the edit is applied (the compiler's E06263 on the line added is expected, and no other new error is) and advisories[] 'dependency-not-installed' names the next step - install the package by hand, then ek9_resolve_dependencies.
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 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
}
Add dependency apply
Request
{
"bucket" : "deps",
"file" : "package.ek9",
"module" : "ekopen.new.shiny.lib",
"version" : "2.0.0-0"
}
Response
{
"advisories" : [ {
"kind" : "dependency-not-installed",
"message" : "'ekopen.new.shiny.lib' version '2.0.0-0' is not installed in the library, so the compiler reports E06263 on the line just added until it is. That is expected, not a fault in the edit. Next: install the package into the library by hand ('ek9 -I' on the project that defines it, or put its zip in the library folder), then resolve with ek9_resolve_dependencies ('ek9 -Dp'; in the IDE, Resolve Dependencies)."
} ],
"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
},
...
Cut short here: 6 more lines. The whole recorded call.
See also
- Show me in the IDE: The package block
- Part of the feature_branch_start workflow: Set feature-branch version + add new dependencies + resolve + verify.