Rebuild and reinstall .xpi file

Hi,
I’m trying to make some enhancements to an add-on but I can’t figure out if there is a wise way to rebuild the .xpi file without 1) unistal the add-on 2) restart Komodo 3) install the new .xpi file 4) restart Komodo.

At the moment the easiest way seems 1) to substitute the .xpi file, inside its folder, and then 2) close and 3) open Komodo.

I read this doc page http://docs.komodoide.com/Manual/extensions#creating-your-first-add-on_working-on-your-add-on but unfortunately, something goes wrong when I try the build and install.

Is there any other tool? (I know Komodo Developer add-on, but it’s not my cup of tea)

I’m using Komodo Edit 11 on Linux.

Thanks

If you’re just asking if there is a way to not have to restart , there is not.

Could you elaborate on this? What goes wrong?

Well, You have (almost) answered my question, and in the meanwhile I was able to solve the problem.

So the following steps describes how I’ve set up my Komodo Edit to work on an already existing add-on, just to make some test and enhancements.
Let me know if there is a better way to do what I did.

Let’s call <MyProject> the generic name of the add-on on which I want to work.

  1. From Project > New from template > Create Komodo Extension I created a new project in a folder called <MyProject>, in my home directory.
    Here whitin there is a folder (on Linux is hidden) called .komodotools containing important userscripts and among these there is the one called Build and Install which I need to edit in accord with my needs.

  2. I deleted all the files in the folder <MyProject>, except the one called <MyProject>.komodoproject, and I copied the ones from the add-on <MyProject>, that is:

  • install.rdf
  • chrome.manifest
  • skin/
  • content/
  • <other-folder>/
  1. Then I edited the userscript Build and Install. It builds the .xpi file using koext (which is in <Komodo-Edit-path>/lib/sdk/bin/) but, for default, it creates a .jar file of the chrome directory, and, in my case, I have to change this option (see also https://community.komodoide.com/packages/install-instructions/#pane-addon).
    This is the file already edited:

    /**

    • Script to build an xpi, running koext build in the current project root and
    • then install it into the currently running Komodo.
      */

    var project = ko.macros.current.project;
    var projectDir = ko.interpolate.interpolateString(’%p’);
    var callback = function() {
    require(“notify/notify”).interact(“Build complete”, “projects”);
    ko.projects.manager.saveProject(project);
    var os = Components.classes["@activestate.com/koOs;1"].
    getService(Components.interfaces.koIOs);
    var entries = os.listdir(projectDir, {});
    var xpi_entries = entries.filter(function(name) { return /.xpi$/.test(name); } );
    if (xpi_entries.length == 0) {
    ko.dialogs.alert("No xpi file found in project dir: " + projectDir);
    } else if (xpi_entries.length == 1) {
    ko.open.URI(os.path.join(projectDir, xpi_entries[0]));
    } else {
    var result = ko.dialogs.selectFromList(“Extension Installation”,
    "Pick the xpi to install: “,
    xpi_entries,
    “one”);
    if (result) {
    ko.open.URI(os.path.join(projectDir, result));
    }
    }
    };
    ko.koextgen.extensionLib.command('build -i / --unjarred ’ +
    ‘-d "’ + projectDir + '”’,
    callback);

Note the edit done:
this:

var osPath = Components.classes["@activestate.com/koOsPath;1"].
                getService(Components.interfaces.koIOsPath);
var preprocessedChromePath = osPath.join(projectDir, "chrome.p.manifest");
if (osPath.exists(preprocessedChromePath)) {
  ko.koextgen.extensionLib.command('build -i chrome.manifest -i chrome.p.manifest ' +
                                   '-d "' + projectDir + '"',
                                   callback);
} else {
  ko.koextgen.extensionLib.command('build -i chrome.manifest ' +
                                   '-d "' + projectDir + '"',
                                   callback);
}

becomes this:

ko.koextgen.extensionLib.command('build -i <other-folder>/ --unjarred ' +
                                 '-d "' + projectDir + '"',
                                 callback);
  1. That’s all. Now I can do my changes and when I want to see the result I’ve just to execute Build and Install.

@Tormec, you are amazing. Thank you for sharing your findings. It looks like there is a bug to be reported here. Could you do that so we can make sure this gets fixed?

IMHO there is no bug because when one goes in Project > New From Template > Create Komodo Extension it works as expected, that is Komodo creates all the files necessary to start to build a NEW extension.

What I did was to adapt the script Build and Install able to build an EXISTENT extension.

If the add-on on which I wanted to work had had already the folder .komodotools with the file Build and Install ready to be used, the previous steps weren’t necessary.

Ahhh thank you for clarifying @Tormec, and thank you again for the thorough response. This will be very helpful to others in the community.