Comments (3)
Yes, there are two use cases for bringing definitions into a workspace that aren't in the current repository:
- When a context is split into multiple repositories and you don't want to duplicate the context's definitions in each repo (your scenario)
- When a term is used in multiple contexts, I'd like Contextive to draw attention to that fact, as I think that focusing on the current context's definition while noting the other definition, could be a good way to aid clarity for teams that have to work across multiple contexts.
In either case, there are a few options:
- Update the
contextive.path
vscode setting to contain a git url and rely on vscode to obtain the file - this won't work with the current version, but shouldn't be hard to do. It would support both use cases - the first, unambiguously. The second, only if all contexts were defined in the same definitions file in some central repo. - Update the definitions file to have an
imports
array at the top level, which would allow to import definitions from a remote git or https url(s) and merge them with the current definitions file
Given your use case, I think for now, I will see about the first option first - just allowing the existing contextive.path
setting to support a git url - and will see how we go.
Stay tuned!
from contextive.
See v1.5.0 for support for the 'shell escape' approach, and https://github.com/dev-cycles/contextive-demo-go-service for a sample of it in operation with a shared golang
package.
More details in the readme here: https://github.com/dev-cycles/contextive/blob/main/src/vscode/contextive/README.md#single-bounded-context-multiple-repositories
from contextive.
From initial spikes on this, it's not as straightforward as I'd hoped. Support for vscode just working when requesting to load a git://
url depends on an extension the user may not have - and there are authentication questions on top of that. Similar authentication issues are likely to affect using an https://
url to define the definitions file assuming it's in a private repo and we're trying to use the https://.../raw/...
url of the git host. Not to mention, this pushes more responsibility into the IDE which would lead to conflicting experiences in different IDEs in the future.
An alternative approach that I'm considering which might make a lot of sense, is to include the definitions file in a package and distribute it to other 'services'/'repos' via the native package management tools of the programming languages in question.
Consider a bounded context Demo
which has three repos:
demo-common
demo-service-a
demo-service-b
As demo-common
contains all the common code for the bounded context (possibly some entity definitions? or other domain-specific logic that needs sharing with other services as a library), it actually makes sense that that would be the owner of the definitions.yml
file, and that the definitions.yml
file should be versioned along-side that code.
If we ensure that the definitions.yml
file is included in the published package from demo-common
then when demo-service-a
and demo-service-b
retrieve demo-common
via their package distribution tools (e.g. go get
, nuget
, npm
, gem
) the definitions.yml
file will come down with it.
demo-service-a
and demo-service-b
could have a vscode workspace settings file that sets the contextive.path
setting to point at the package manager's copy of the definitions.yml
file.
The challenge with this approach is differences in the way package management tools store the downloaded packages. There are three common options, not exhaustive, but to illustrate the breadth of possibilities:
- store directly in the working folder (e.g.
npm
innode_modules
)- this is easy -
contextive.path
can just be set tonode_modules/demo-common/.contextive/definitions.yml
- this is easy -
- store in a global package cache, but copy assets from the package into the binaries folder on build (e.g.
dotnet
)- this is also easy,
contextive.path
can be set toDemo.ServiceA/bin/Debug/.contextive/definitions.yml
(assumingDemo.Common
package is setup to include the definitions.yml file correctly by including it in thelib
folder)
- this is also easy,
- store in a global package cache, and don't copy assets into the local folder (e.g.
go get
,python
,java
).- this is a bit trickier, as the location could vary on dev machine to dev machine depending on local configuration, so a workspace vscode setting isn't great. Individuals could setup user-level settings to override, but that is an extra level of friction I'd like to avoid.
A proposal for resolving scenario 3:
Contextive will shell out and
echo %contextive.path%
and use the result as the file location.
As an example, with go
:
In demo-service-a
and demo-service-b
, set contextive.path
to:
$(go list -m -f '{{.Dir}}' org.git.domain/org/demo-common)/.contextive/definitions.yml
Contextive will execute:
echo "$(go list -m -f '{{.Dir}}' org.git.domain/org/demo-common)/.contextive/definitions.yml
"
Which on both linux and windows will return the exact path of the file in the package manager's cache.
I'll need to check, but I suspect it will be possible to find similar shell commands for other package managers that will help identify the local path of the package, and thus the location of the definitions file.
Pros
- With this approach, a common
contextive.path
setting could be stored in the workspace, and once the extension is installed, and thecommon
package is setup correctly, Contextive should just work for all developers. - Leverages existing package distribution tools including hosting and authentication (e.g. should work with private package hosts and any source control system).
Cons
- Are there security risks of having Contextive execute arbitrary scripts via the
echo $()
mechanism? Contextive does not run privileged, and it will only be executing scripts that are stored in a trusted and reviewed repository, so perhaps it's ok? - Having to publish a new
common
package, just to update some contextive definitions. - Harder to update definitions if you identify a need to update them while working in
service-a
. - May be more challenging when working in a polyglot environment, as
service-b
may not be in the same language asdemo-common
and thus wouldn't depend on it via the package management system. As there are no real users with this use case yet, I'm deferring consideration of this scenario until I can get more details of a real-world situation.
Next Steps
I'm proceeding with a spikes to verify the feasibility of this approach, but thought I'd throw it out here for feedback - any thoughts?
from contextive.
Related Issues (20)
- Support multi-root workspaces in vscode with different definitions files in each root
- Context information is not shown when using LF Line endings, only with CRLF HOT 5
- Multiple context definition files HOT 5
- Support multiple definition files in a single repository
- Support sharing definitions from multiple sources into the current work environment
- Language Server process doesn't exit when LanguageClient or vscode stops.
- Support JetBrains Fleet
- Omnisharp error after installing Contextive HOT 4
- Multi-line yaml can result in additional underscores HOT 6
- Problem running contextive HOT 2
- Release Language Server as independent Component
- Move `contextive.path` default to `Contextive.LanguageServer` for vscode extension HOT 7
- Add a `LICENSE` file HOT 2
- Editor agnostic configuration HOT 6
- Neovim setup not working HOT 4
- Contextive LSP fails with unhandled exception HOT 7
- Exception starting 1.10.4 due to dotnet trimming HOT 8
- IntelliJ doesn't show completion list in certain positions
- Contextive reports warning in IntelliJ 'cannot load definitions file' when opening a project without a definitions file
- Context menu not showing in .cs files with Rider HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from contextive.