welsonjs/lib/ovftool.js
Namhyeon, Go 33c64d50c9 Add afterInstall.ps1 and update tool paths to APPDATA
Introduces afterInstall.ps1 for post-install setup, downloading and extracting required tools to the APPDATA\WelsonJS directory. Updates code in http.js, python3.js, ovftool.js, wamr.js, and system.js to reference binaries from the new APPDATA location. Modifies setup.iss to run the PowerShell script after installation.
2025-11-20 16:44:20 +09:00

74 lines
2.0 KiB
JavaScript

// ovftool.js
// Namhyeon Go <gnh1201@catswords.re.kr> and the WelsonJS contributors.
// SPDX-License-Identifier: GPL-3.0-or-later
// https://github.com/gnh1201/welsonjs
//
// Download OVFTool (Open Virtualization Format (OVF) Tool):
// https://developer.broadcom.com/tools/open-virtualization-format-ovf-tool/latest
//
var SYS = require("lib/system");
var SHELL = require("lib/shell");
var CRED = require("lib/credentials");
function OVFObject() {
this.binPath = SYS.getAppDataDir() + "\\ovftool\\ovftool.exe";
this.hostname = "";
this.port = 443;
this.resourceName = "";
this.setBinPath = function(binPath) {
this.binPath = binPath;
};
this.setHostName = function(hostname) {
this.hostname = hostname;
};
this.setPort = function(port) {
this.port = port;
};
this.setResourceName = function(resourceName) {
this.resourceName = resourceName;
};
this.saveTo = function(filename) {
var cred = CRED.get("password", "ovftool");
var connectionString = "vi://" +
encodeURIComponent(cred.username) + ":" +
encodeURIComponent(cred.password) + "@" +
this.hostname + (this.port == 443 ? "" : ":" + this.port) +
this.resourceName
;
var cmd = [
this.binPath,
connectionString,
filename
];
console.log("Use this connection string:", connectionString);
// run the command synchronously
SHELL.show(cmd, false);
};
}
function setCredential(username, password) {
CRED.push("password", "ovftool", {
"username": username,
"password": password
});
}
function create() {
return new OVFObject();
}
exports.setCredential = setCredential;
exports.create = create;
exports.VERSIONINFO = "Broadcom/VMware OVF Tool interface (ovftool.js) version 0.1.3";
exports.AUTHOR = "gnh1201@catswords.re.kr";
exports.global = global;
exports.require = global.require;