# Node-red-contrib-context-project

**URL:** <https://discourse.nodered.org/t/node-red-contrib-context-project/55064>\
**Category:** Developing Nodes\
**Created:** [11 December 2021 21:53 UTC](https://discourse.nodered.org/t/node-red-contrib-context-project/55064 "2021-12-11T21:53:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mw75](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mw75/32/52490_2.png) [@mw75](https://discourse.nodered.org/u/mw75)\
**Post date:** [11 December 2021 21:53 UTC](https://discourse.nodered.org/t/node-red-contrib-context-project/55064/1 "2021-12-11T21:53:38Z")

</div>

I would like to create node-red-contrib-context-project that behaves just like @node-red/runtime/lib/nodes/context/localfilesystem.js but uses the current project folder as dir option.  
I would appreciate feedback on that idea already!

Problem from my first Context Store API discovery:

- i have no access to settings which would give access to settings.get("projects").activeProject and the corresponding parent directory settings
- i could not find a proper project api to trigger a commit if auto-commit is enabled  
Recommendations for this?

Btw: would it be possible to use git-http transport by creating git-credentials and changing remote origin in the project folder or would it get reset by Node-Red?

Thanks for comments!

Regards,  
Mario Wolff

---

<div class="post-metadata">

**Author:** ![mw75](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mw75/32/52490_2.png) [@mw75](https://discourse.nodered.org/u/mw75)\
**Post date:** [5 February 2022 07:50 UTC](https://discourse.nodered.org/t/node-red-contrib-context-project/55064/2 "2022-02-05T07:50:27Z")

</div>

Any feedback on my thoughts and questions?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [5 February 2022 15:01 UTC](https://discourse.nodered.org/t/node-red-contrib-context-project/55064/3 "2022-02-05T15:01:52Z")

</div>

I’d rather see this be in the core than another node. I’ve thought it should have been that way since projects first appeared.

@knolleary Nick any thoughts?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [5 February 2022 15:10 UTC](https://discourse.nodered.org/t/node-red-contrib-context-project/55064/4 "2022-02-05T15:10:37Z")

</div>

> [@zenofmud](#):
>
> any thoughts

What is the use case this is solving? Rather than jump to a solution, I'd prefer to understand the problem.

The projects directory is a git repository and contains the version controlled contents of the project. Putting the non-version controlled runtime state in that same directory doesn't fit my mental model of the world.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [5 February 2022 17:53 UTC](https://discourse.nodered.org/t/node-red-contrib-context-project/55064/5 "2022-02-05T17:53:24Z")

</div>

If have project A and save context X and Y and then switch to project B which also has a context variable X, it will pick up the X data from project A. In addition, it now had a context Y avialable.

Maybe the answer is that when you switch projects, the context variables shoud be deleted.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [5 February 2022 18:37 UTC](https://discourse.nodered.org/t/node-red-contrib-context-project/55064/6 "2022-02-05T18:37:52Z")

</div>

> [@zenofmud](#):
>
> Maybe the answer is that when you switch projects, the context variables shoud be deleted.

Which is now an option in the Open Project dialog with 2.2.0

---

<div class="post-metadata">

**Author:** ![mw75](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mw75/32/52490_2.png) [@mw75](https://discourse.nodered.org/u/mw75)\
**Post date:** [5 February 2022 23:45 UTC](https://discourse.nodered.org/t/node-red-contrib-context-project/55064/7 "2022-02-05T23:45:37Z")

</div>

I see the flow as business-logic that acts in a (stored) context to give a project.  
Currently i set inMemory context in an onStart-function node to keep context and flow together, but it feels wrong.  
I use context for a kind of shared, flow wide, base setting. In my case it includes a tenant and some service endpoints belonging to that tenant. I run the almost same flow on different node-red instances by patching the onStart-function. Im currently moving to a custom wrapper embedding node-red where i can set the global inMemory context depending on the hostname i'm running on.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [6 February 2022 00:06 UTC](https://discourse.nodered.org/t/node-red-contrib-context-project/55064/8 "2022-02-06T00:06:52Z")

</div>

Ahhh, I missed that in the change log. GREAT!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [7 April 2022 00:07 UTC](https://discourse.nodered.org/t/node-red-contrib-context-project/55064/9 "2022-04-07T00:07:50Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
