Is it possible to get the preferences settings from jArchi

Started by Manj75, June 23, 2021, 11:31:48 AM

Previous topic - Next topic

Manj75

If the collaboration plugin is installed and setup I want to script the ability to fetch the Tools -> Preferences -> Collaboration -> Name text field value.

The script would throw an exception of the coArchi was not installed or if that field does not exist.

I'm want to create a script where you can append to the documentation that stamps the date and Name of the text appended.  This would also work on appending to multiple elements in one operation.

Phil Beauvoir

June 23, 2021, 12:38:59 PM #1 Last Edit: June 23, 2021, 12:45:29 PM by Phil Beauvoir
jArchi does not have an API for Archi's preferences.

If you are trying to access the user name that is used for coArchi (i.e. git) commits, this can be found in the ~/.gitconfig file which could be loaded in JS and parsed.

Or for other preferences, load and read Archi's preference files directly - %Home%\AppData\Roaming\Archi4\.metadata\.plugins\org.eclipse.core.runtime\.settings
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

Manj75

Phil - your suggestion of using the plugin preferences config file would've been perfect, however I don't see all the settings from the preferences Collaboration tab, only the following is there in the file:

eclipse.preferences.version=1
sshIdentityFile=
sshIdentityRequiresPassword=false


I'm I missing anything - could it be that the Name and Email values are only stored in the encrypted file?

Phil Beauvoir

June 23, 2021, 16:39:58 PM #3 Last Edit: June 23, 2021, 18:23:19 PM by Phil Beauvoir
I did say "Or for other preferences"  ;)

The name and email used by git (and coArchi) are stored in the <user.home>/.gitconfig file not the preferences file (I think it does say that on the Preferences dialog)
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

Manj75

Looking at the .gitconfig file it has exactly what I need and as it's basically an ini file I need to load and parse it, however I see no examples from community of file IO in jArchi/JS.  I've tried the FileReader but this doesn't seem to be supported - can you or anyone please point me to an example that'll work in jArchi to load a local file that I can parse or even if there is already an available JS library script that readily does this.  Thanks.

projetnumero9

This gist (https://gist.github.com/search?q=%23jarchi+extension%3Aajs+readfully&ref=searchresults) served me right on the spot (see the polyfill readFully)! (so happy you could publish it, JB!)

Another/similar example would be:
- https://gist.github.com/smileham/1e57a5946235e780dee5a824f664aa3d

Regards,
PN9

Jean-Baptiste Sarrodie

If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

Jean-Baptiste Sarrodie

If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

projetnumero9


Jean-Baptiste Sarrodie

Quote from: projetnumero9 on June 25, 2021, 12:50:56 PM
Making it publicly available,

PN9

You mean, in a dedicated gist, a real git repo, somewhere else ? (BTW, this is not my work but someone else's work I used).

Maybe have a set of wiki page on jArchi repo with a list of really useful snippets ?

Don't know what's the best.

JB
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

Manj75

I've used the second example mentioned by PN9 in combination with a parse_ini_string function I found on https://gist.github.com/anonymous/dad852cde5df545ed81f1bc334ea6f72

Now, I just need to be able to get the user homedirectory, i.e. %userprofile% for win32 and $home for mac.

I was pointed to the $.process but not sure if it supports .env for environment variable.  I want to do something like:

process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'];

but, I get undefined for $.process.env, so not if this is supported.