This pull request is a following up my question in archimatetool/archi-scripting-plugin#77 (comment)
Btw, I am planning to use this feature when a user publishes a Change via the "coArchi" Plugin to the git Repo. Is there some way of "event hook" for "before commit" or "after push" to hook into this workflow with a jArchi script?
Thanks in advance!
For realizing my envisioned Archi workflow it prepared this pull request since there is currently no integration of jArchi & coArchi.
This pull-request realizes the following:
Add support for jArchi RunScriptHandler via Command
Add "$.fs.cleanFolder" function for cleaning a folder under the git workdirectory (e.g. "Views")
As an example how i use this new integration between jArchi & coArchi is the following jArchi script ExportSVG.ajs:
/*
* JArchi Script "Export SVG & PNG pre-commit"
*/
console.clear();
console.log("Export all views as PNG [pre-commit]...");
console.log($('archimate-diagram-model').first());
function getFolderStruct(o, delim) {
var folder_struct = '';
$('#'+o.id).parents().each(function(p) {
if (p.type == 'folder') {
folder_struct = p.name.replaceAll(" ","-") + delim + folder_struct;
}
});
console.log(folder_struct);
return folder_struct;
}
function getFolderRoot(o) {
var svgpath = false;
var rootpath = o.model.getPath();
var delim = "";
if (rootpath.indexOf("/.git/temp.archimate") !== -1) {
delim = "/";
svgpath = rootpath.replace("/.git/temp.archimate", "/");
} else if (rootpath.indexOf("\\.git\\temp.archimate") !== -1) {
delim = "\\";
svgpath = rootpath.replace("\\.git\\temp.archimate", "\\");
}
return svgpath;
}
function emptyFolder() {
var model = $('archimate-diagram-model').first();
var root = getFolderRoot(model)
if (root != false) {
var delim = root.charAt(root.length-1);
console.log("delim", delim);
console.log("Empty folder", root);
$.fs.cleanFolder(root + "Views")
}
}
emptyFolder();
$('archimate-diagram-model').each(function(o) {
console.log("Exporting " + o.name + " ...");
var svgpath = getFolderRoot(o);
var delim = svgpath.charAt(svgpath.length-1);
var filepath = getFolderStruct(o, delim);
var filename = o.name.replaceAll(" ","-");
svgpath += filepath + filename;
console.log(" to " + svgpath + ".png");
if (svgpath) {
$.model.renderViewToSVG(o, svgpath + ".svg", true);
$.model.renderViewToFile(o, svgpath + ".png", "PNG", {scale: 1, margin: 20});
}
});
Hi @Phillipus,
This pull request is a following up my question in archimatetool/archi-scripting-plugin#77 (comment)
For realizing my envisioned Archi workflow it prepared this pull request since there is currently no integration of jArchi & coArchi.
This pull-request realizes the following:
As an example how i use this new integration between jArchi & coArchi is the following jArchi script
ExportSVG.ajs
:In my workflow I use the pre-commit coArchi integration from my pull-request: https://github.com/archimatetool/archi-modelrepository-plugin/pull/183 and i configured![image](https://user-images.githubusercontent.com/88032369/145792339-9f022562-e117-4969-b04b-90256ff0fcf1.png)
ExportSVG
as script name: