jArchi 1.6

Started by Phil Beauvoir, February 19, 2024, 11:43:37 AM

Previous topic - Next topic

Phil Beauvoir

Hello jArchi scripters!

jArchi 1.6 is available at the usual outlets.

This version includes support for Node.js modules (thanks to @Jean-Baptiste Sarrodie for that), some fixes and a few new features.

Please note that this version requires Archi 5.2 or later.

Change log - https://github.com/archimatetool/archi-scripting-plugin/wiki/Change-Log

Cheers,

Phil
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Alexis_H

Many Thanks Phil !

Very good enhancements : Node.js support should help a lot to integrate third party JS libs (eg : a unit-testing fwk for QA checks on the model, I was digging in Jasmine code to make it run outside of a browser or Node.js context.. no more headache now).
+ the line-width/color I was missing to port a 'Heatmap' jArchi script.

Alexis.


Jean-Baptiste Sarrodie

Hi All,

Some comments on importing Node.js modules into jArchi scripts:
- By "Node.js" modules we mean CommonJS modules. So a modules doesn't have to be specifically written for Node.js: as soon as it respects CommonJS specification, it should be usable.
- Not all modules will work within Archi because Archi doesn't implement core/native/builtin (call them whatever you want) modules. A rule of thumb: the less dependencies a module have, the higher the chance it will be usable.
- Archi doesn't come with npm, so if you want to reuse real Node.js modules, you will have either to install Node.js and npm on your workstation and make sure it downloads modules at the right place. You can also download modules manually (only doable for modules with no, or really few, dependencies)
- The wiki contains an example of a very simple module, I would encourage people to do so for scripts that serve as common libraries.

Regards,

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Phil Beauvoir

Thanks JB, I added your comments to the wiki.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

fanievh

Thank you for the new version, @Phil Beauvoir!

I noticed a change and I'm not sure if the problem is on my side.  When running @smileham CSV import script (https://gist.github.com/smileham/1e57a5946235e780dee5a824f664aa3d) which uses Papa Parse, I get this error which I didn't get with jArchi 1.5:

> Import CSV
> Loaded Papa Parse
> Please Wait...
> File Loaded
org.graalvm.polyglot.PolyglotException: ReferenceError: "Papa" is not defined
   at <js>.:program(Import from CSV.ajs:48)
   at <js>.:program(<eval>:1)
   at org.graalvm.polyglot.Context.eval(Context.java:399)
   at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:478)
   at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:446)

Any idea what could be causing this change in behaviour?

Phil Beauvoir

#5
Hi, yes I get the same error.

@Jean-Baptiste Sarrodie This is caused by the new property entries to support CommonJS modules. Do you know why?

I opened an issue - https://github.com/archimatetool/archi-scripting-plugin/issues/127
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Phil Beauvoir

#6
@fanievh Please do the following:

In your script, replace the line:

load(__DIR__ + "lib/papaparse.min.js");
with:

const Papa = require(__DIR__ + "lib/papaparse.min.js");
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

fanievh

Thank you very much @Phil Beauvoir, that does the trick  :)

Phil Beauvoir

I've released jArchi 1.6.1 (available at the usual outlets). This adds an option in Scripting Preferences to enable/disable support for CommonJS. It's enabled by default so if your script is not working you should consider if it needs to reference another file using "require" rather than "load" (see my comment above).

Phil
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.