-
-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make contexts shareable #38
Comments
I like this idea a lot! |
would like to start by talking about the data structure for context. All context is doing right now is storing file paths that supposedly point to a spec path. Storing it in a key-value pair. So context in general looks something like this. interface Context {
current?: string,
store: {
[name: string]: string
}
}
While autoloading the spec file, there was a case where when there was no global cli/src/hooks/context/hooks.tsx Lines 158 to 168 in 87970d1
Was playing around with the idea that we don't throw an error rather return an object with undefined context. Something like this.import * as fs from 'fs';
import * as path from 'path';
const SPEC_FILE_PATH = path.resolve(__dirname, 'asyncapi');
interface Context {
current?: string,
store: {
[name: string]: string
}
}
const saveContext = (ctx: Context) => {
fs.writeFileSync(SPEC_FILE_PATH, JSON.stringify(ctx), {encoding: 'utf-8'});
}
class ContextService{
constructor(private _context:Context | undefined){
}
current(){
return this._context?.current;
}
context(contextName?:string){
if(!contextName) return this._context;
return this._context?.store[contextName];
}
isContext(){
return typeof this._context !== 'undefined'
}
addContext(name: string, specPath: string){
if(this._context) {
this._context.store[name] = specPath;
saveContext(this._context)
}
return true
}
static load(){
try{
const ctx = fs.readFileSync(SPEC_FILE_PATH, 'utf-8');
return new ContextService(JSON.parse(ctx) as Context);
}catch(e) {
return new ContextService(undefined);
}
}
}
const ctxService = ContextService.load();
console.log(ctxService.isContext());
console.log(ctxService.addContext('test', 'url/to/specFile')) |
Yeah, I don't think it should throw an error as it's optional to have |
This issue has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
Removing |
This issue has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
This issue has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
Dear bot, keep this issue open. Thanks! |
This issue has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
Still relevant. |
The scope here is to:
|
This issue is part of the AsyncAPI Bounty Program, interested contributors need to follow the guidelines below to ensure fairness and timely completion of assigned tasks: Task AssignmentThe assignment of tasks will be prioritized in the following order:
We encouraged everyone to apply as long as the task is for you (falls under your skill set). We will not be using the first comment - get assigned method for assignments. Instead, we will provide 3 days to consider all individuals interested before assigning any bounty task. DeadlineTo maintain accountability and ensure the timely completion of the deadline for this task will be 6 - 8 weeks from the date of assignment. If a contributor requires an extension on their task, it should be communicated and approved by the maintainer. Issue Tracking and UpdatesContributors must provide weekly updates on the task they are working on to help maintainers stay informed of progress. If a contributor fails to provide an update, they will be reminded via a ping. If a contributor fails to provide an update after three pings over three weeks, we will assume they have silently dropped the issue, and it will be reassigned to someone else. Issue Drop-outsAny contributor who drops an assigned issue will be penalized and will not be eligible to participate in the bounty program for 6 months. We understand that unforeseen circumstances can arise, and dropping an assigned issue may be unavoidable in some cases. However, we believe that enforcing this penalty is necessary to ensure the effectiveness of the bounty program, respect maintainer time, and honor the efforts of other contributors who could have solved the issue but were unable to do so due to the drop-out. We encourage all contributors to follow these guidelines to ensure a fair and timely completion of tasks assigned through our bounty program. |
more context for the issue: for now context are a “global” thing, like bash profile or git config -> the idea is that this approach should not be default, but a fallback by default, CLI should search for so for example you have context file only for given repository, keep it in git with rest of the code, or have few context files in one repo in case you have mono repo |
I would like to work on this issue. |
@aeworxet perfect, please go ahead and ask questions whenever help is needed. |
Some questions. 1What should happen in this situation?
Should the search stop on first found 2Is there a real |
if you run not sure it answers your question? cwd basically
you can create it yourself, just do and here is an example with complex project structure and multiple documents https://github.com/asyncapi/spec/tree/master/examples/social-media |
Hey @aeworxet how is it going so far? |
Working closely with @derberg to ensure the development is going in right direction. |
Bounty Program Timeline
Please note that dates represent deadlines, not specific dates, so if the goal is reached sooner, it's better. |
Should CLI context file's name be changed from |
no strong opinion from my side, both are ok I think, I do not see scenario where in one repo someone would have |
If there's no strong opinion, I'd rather make it |
I like that! 😃 |
A break for you 😊 |
next time please do not feel blocked by me, there is also @Souvikns that maintains CLI and also the request for shared context came from @fmvilas but I also understand that you preferred to wait as we discusses some technical details before my holidays. PR is in |
This was at the same time a Bounty Program usecase. If your vacation would INDEED be a blocking issue, how would the Bounty Program timeline change? |
As a giggly alternative I also have |
ok, but only if we write it
if I'm a blocker and on holidays or basically maintainer is off and do not respond for some time -> for me it is clear that the time is then like on hold, counter stops |
It's logical that the time of actual absence is added to the timeline. It is |
sounds good to me, makes sense to add |
Bounty Program Timeline(target dates are updated by the duration of absence of the person in charge from AsyncAPI side in the amount of two weeks + one week)
|
@thulieblack fyi it is taking a bit longer because @aeworxet is adding one more small docs to it and also documentation for the context concept that we did not have initially in the scope |
@thulieblack last bounty issue completed 🥳 @aeworxet congrats 👏🏼 |
Congratulations @aeworxet 🎉🎉 Please submit an expense via open collective to claim` your bounty |
Reason/Context
Currently, contexts are stored in the user's home directory. I think it would be cool to store the contexts in the repo directory so they can be shared.
Description
This would work the same way package.json works. The
asyncapi
CLI would seek for the file (let's call it.asyncapi
) in the CWD and, if not found, it would look for it in the parent directory, then the parent of the parent, etc.The cool thing is that if you don't want to share it, you could just place the file in your home dir, effectively behaving as it is now (global). Also, the global context would be the fallback if a "local" one is not found in a specific project.
Also, this would remove the need to set up contexts yourself manually. Since the file is already in the repo, running
asyncapi
will already load the context automatically.Additionally, this eliminates the problem where a user doesn't have permission to write to disk. Very likely to happen in private built in-house CI systems (this was the case at New Relic).
The text was updated successfully, but these errors were encountered: