This commit is contained in:
2022-09-30 05:39:11 +00:00
parent 41ee9463ae
commit 4687fa49bc
11418 changed files with 1312504 additions and 0 deletions

View File

@ -0,0 +1,8 @@
import { SpawnOptions, ExecFileOptions } from "child_process";
import { ExtraSpawnOptions } from "builder-util";
import { VmManager } from "./vm";
export declare class MonoVmManager extends VmManager {
constructor();
exec(file: string, args: Array<string>, options?: ExecFileOptions, isLogOutIfDebug?: boolean): Promise<string>;
spawn(file: string, args: Array<string>, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions): Promise<any>;
}

View File

@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.MonoVmManager = void 0;
function _builderUtil() {
const data = require("builder-util");
_builderUtil = function () {
return data;
};
return data;
}
function _vm() {
const data = require("./vm");
_vm = function () {
return data;
};
return data;
}
class MonoVmManager extends _vm().VmManager {
constructor() {
super();
}
exec(file, args, options, isLogOutIfDebug = true) {
return (0, _builderUtil().exec)("mono", [file].concat(args), { ...options
}, isLogOutIfDebug);
}
spawn(file, args, options, extraOptions) {
return (0, _builderUtil().spawn)("mono", [file].concat(args), options, extraOptions);
}
} exports.MonoVmManager = MonoVmManager;
// __ts-babel@6.0.4
//# sourceMappingURL=MonoVm.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/vm/MonoVm.ts"],"names":[],"mappings":";;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEM,MAAO,aAAP,SAA6B,eAA7B,CAAsC;AAC1C,EAAA,WAAA,GAAA;AACE;AACD;;AAED,EAAA,IAAI,CAAC,IAAD,EAAe,IAAf,EAAoC,OAApC,EAA+D,eAAe,GAAG,IAAjF,EAAqF;AACvF,WAAO,yBAAK,MAAL,EAAa,CAAC,IAAD,EAAO,MAAP,CAAc,IAAd,CAAb,EAAkC,EACvC,GAAG;AADoC,KAAlC,EAEJ,eAFI,CAAP;AAGD;;AAED,EAAA,KAAK,CAAC,IAAD,EAAe,IAAf,EAAoC,OAApC,EAA4D,YAA5D,EAA4F;AAC/F,WAAO,0BAAM,MAAN,EAAc,CAAC,IAAD,EAAO,MAAP,CAAc,IAAd,CAAd,EAAmC,OAAnC,EAA4C,YAA5C,CAAP;AACD;;AAbyC,C","sourcesContent":["import { SpawnOptions, ExecFileOptions } from \"child_process\"\nimport { exec, ExtraSpawnOptions, spawn } from \"builder-util\"\nimport { VmManager } from \"./vm\"\n\nexport class MonoVmManager extends VmManager {\n constructor() {\n super()\n }\n\n exec(file: string, args: Array<string>, options?: ExecFileOptions, isLogOutIfDebug = true): Promise<string> {\n return exec(\"mono\", [file].concat(args), {\n ...options,\n }, isLogOutIfDebug)\n }\n\n spawn(file: string, args: Array<string>, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions): Promise<any> {\n return spawn(\"mono\", [file].concat(args), options, extraOptions)\n }\n}"],"sourceRoot":""}

View File

@ -0,0 +1,7 @@
export declare function macPathToParallelsWindows(file: string): string;
export interface ParallelsVm {
id: string;
name: string;
os: "win-10" | "ubuntu" | "elementary";
state: "running" | "suspended" | "stopped";
}

View File

@ -0,0 +1,160 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.parseVmList = parseVmList;
exports.macPathToParallelsWindows = macPathToParallelsWindows;
exports.ParallelsVmManager = void 0;
function _builderUtil() {
const data = require("builder-util");
_builderUtil = function () {
return data;
};
return data;
}
function _child_process() {
const data = require("child_process");
_child_process = function () {
return data;
};
return data;
}
function _vm() {
const data = require("./vm");
_vm = function () {
return data;
};
return data;
}
/** @internal */
async function parseVmList(debugLogger) {
// do not log output if debug - it is huge, logged using debugLogger
let rawList = await (0, _builderUtil().exec)("prlctl", ["list", "-i", "-s", "name"], undefined, false);
debugLogger.add("parallels.list", rawList);
rawList = rawList.substring(rawList.indexOf("ID:")); // let match: Array<string> | null
const result = [];
for (const info of rawList.split("\n\n").map(it => it.trim()).filter(it => it.length > 0)) {
const vm = {};
for (const line of info.split("\n")) {
const meta = /^([^:("]+): (.*)$/.exec(line);
if (meta == null) {
continue;
}
const key = meta[1].toLowerCase();
if (key === "id" || key === "os" || key === "name" || key === "state" || key === "name") {
vm[key] = meta[2].trim();
}
}
result.push(vm);
}
return result;
}
/** @internal */
class ParallelsVmManager extends _vm().VmManager {
constructor(vm) {
super();
this.vm = vm;
this.isExitHookAdded = false;
this.startPromise = this.doStartVm();
}
get pathSep() {
return "/";
}
handleExecuteError(error) {
if (error.message.includes("Unable to open new session in this virtual machine")) {
throw new Error(`Please ensure that your are logged in "${this.vm.name}" parallels virtual machine. In the future please do not stop VM, but suspend.\n\n${error.message}`);
}
_builderUtil().log.warn("ensure that 'Share folders' is set to 'All Disks', see https://goo.gl/E6XphP");
throw error;
}
async exec(file, args, options) {
await this.ensureThatVmStarted(); // it is important to use "--current-user" to execute command under logged in user - to access certs.
return await (0, _builderUtil().exec)("prlctl", ["exec", this.vm.id, "--current-user", file.startsWith("/") ? macPathToParallelsWindows(file) : file].concat(args), options).catch(error => this.handleExecuteError(error));
}
async spawn(file, args, options, extraOptions) {
await this.ensureThatVmStarted();
return await (0, _builderUtil().spawn)("prlctl", ["exec", this.vm.id, file].concat(args), options, extraOptions).catch(error => this.handleExecuteError(error));
}
async doStartVm() {
const vmId = this.vm.id;
const state = this.vm.state;
if (state === "running") {
return;
}
if (!this.isExitHookAdded) {
this.isExitHookAdded = true; // eslint-disable-next-line @typescript-eslint/no-var-requires
require("async-exit-hook")(callback => {
const stopArgs = ["suspend", vmId];
if (callback == null) {
(0, _child_process().execFileSync)("prlctl", stopArgs);
} else {
(0, _builderUtil().exec)("prlctl", stopArgs).then(callback).catch(callback);
}
});
}
await (0, _builderUtil().exec)("prlctl", ["start", vmId]);
}
ensureThatVmStarted() {
let startPromise = this.startPromise;
if (startPromise == null) {
startPromise = this.doStartVm();
this.startPromise = startPromise;
}
return startPromise;
}
toVmFile(file) {
// https://stackoverflow.com/questions/4742992/cannot-access-network-drive-in-powershell-running-as-administrator
return macPathToParallelsWindows(file);
}
}
exports.ParallelsVmManager = ParallelsVmManager;
function macPathToParallelsWindows(file) {
if (file.startsWith("C:\\")) {
return file;
}
return "\\\\Mac\\Host\\" + file.replace(/\//g, "\\");
}
// __ts-babel@6.0.4
//# sourceMappingURL=ParallelsVm.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,9 @@
import { SpawnOptions, ExecFileOptions } from "child_process";
import { ExtraSpawnOptions } from "builder-util";
import { VmManager } from "./vm";
export declare class WineVmManager extends VmManager {
constructor();
exec(file: string, args: Array<string>, options?: ExecFileOptions, isLogOutIfDebug?: boolean): Promise<string>;
spawn(file: string, args: Array<string>, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions): Promise<any>;
toVmFile(file: string): string;
}

View File

@ -0,0 +1,55 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.WineVmManager = void 0;
function _wine() {
const data = require("../wine");
_wine = function () {
return data;
};
return data;
}
function _vm() {
const data = require("./vm");
_vm = function () {
return data;
};
return data;
}
var path = _interopRequireWildcard(require("path"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
class WineVmManager extends _vm().VmManager {
constructor() {
super();
} // eslint-disable-next-line @typescript-eslint/no-unused-vars
exec(file, args, options, isLogOutIfDebug = true) {
return (0, _wine().execWine)(file, null, args, options);
} // eslint-disable-next-line @typescript-eslint/no-unused-vars
spawn(file, args, options, extraOptions) {
throw new Error("Unsupported");
}
toVmFile(file) {
return path.win32.join("Z:", file);
}
} exports.WineVmManager = WineVmManager;
// __ts-babel@6.0.4
//# sourceMappingURL=WineVm.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/vm/WineVm.ts"],"names":[],"mappings":";;;;;;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;;;;;;AAEM,MAAO,aAAP,SAA6B,eAA7B,CAAsC;AAC1C,EAAA,WAAA,GAAA;AACE;AACD,GAHyC,CAK1C;;;AACA,EAAA,IAAI,CAAC,IAAD,EAAe,IAAf,EAAoC,OAApC,EAA+D,eAAA,GAA2B,IAA1F,EAA8F;AAChG,WAAO,sBAAS,IAAT,EAAe,IAAf,EAAqB,IAArB,EAA2B,OAA3B,CAAP;AACD,GARyC,CAU1C;;;AACA,EAAA,KAAK,CAAC,IAAD,EAAe,IAAf,EAAoC,OAApC,EAA4D,YAA5D,EAA4F;AAC/F,UAAM,IAAI,KAAJ,CAAU,aAAV,CAAN;AACD;;AAED,EAAA,QAAQ,CAAC,IAAD,EAAa;AACnB,WAAO,IAAI,CAAC,KAAL,CAAW,IAAX,CAAgB,IAAhB,EAAsB,IAAtB,CAAP;AACD;;AAjByC,C","sourcesContent":["import { SpawnOptions, ExecFileOptions } from \"child_process\"\nimport { ExtraSpawnOptions } from \"builder-util\"\nimport { execWine } from \"../wine\"\nimport { VmManager } from \"./vm\"\nimport * as path from \"path\"\n\nexport class WineVmManager extends VmManager {\n constructor() {\n super()\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n exec(file: string, args: Array<string>, options?: ExecFileOptions, isLogOutIfDebug: boolean = true): Promise<string> {\n return execWine(file, null, args, options)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n spawn(file: string, args: Array<string>, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions): Promise<any> {\n throw new Error(\"Unsupported\")\n }\n\n toVmFile(file: string): string {\n return path.win32.join(\"Z:\", file)\n }\n}\n"],"sourceRoot":""}

View File

@ -0,0 +1,9 @@
import { DebugLogger, ExtraSpawnOptions } from "builder-util";
import { ExecFileOptions, SpawnOptions } from "child_process";
export declare class VmManager {
get pathSep(): string;
exec(file: string, args: Array<string>, options?: ExecFileOptions, isLogOutIfDebug?: boolean): Promise<string>;
spawn(file: string, args: Array<string>, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions): Promise<any>;
toVmFile(file: string): string;
}
export declare function getWindowsVm(debugLogger: DebugLogger): Promise<VmManager>;

67
buildfiles/node_modules/app-builder-lib/out/vm/vm.js generated vendored Normal file
View File

@ -0,0 +1,67 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getWindowsVm = getWindowsVm;
exports.VmManager = void 0;
function _builderUtil() {
const data = require("builder-util");
_builderUtil = function () {
return data;
};
return data;
}
var path = _interopRequireWildcard(require("path"));
function _ParallelsVm() {
const data = require("./ParallelsVm");
_ParallelsVm = function () {
return data;
};
return data;
}
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
class VmManager {
get pathSep() {
return path.sep;
}
exec(file, args, options, isLogOutIfDebug = true) {
return (0, _builderUtil().exec)(file, args, options, isLogOutIfDebug);
}
spawn(file, args, options, extraOptions) {
return (0, _builderUtil().spawn)(file, args, options, extraOptions);
}
toVmFile(file) {
return file;
}
}
exports.VmManager = VmManager;
async function getWindowsVm(debugLogger) {
const vmList = (await (0, _ParallelsVm().parseVmList)(debugLogger)).filter(it => it.os === "win-10");
if (vmList.length === 0) {
throw new (_builderUtil().InvalidConfigurationError)("Cannot find suitable Parallels Desktop virtual machine (Windows 10 is required)");
} // prefer running or suspended vm
return new (_ParallelsVm().ParallelsVmManager)(vmList.find(it => it.state === "running") || vmList.find(it => it.state === "suspended") || vmList[0]);
}
// __ts-babel@6.0.4
//# sourceMappingURL=vm.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/vm/vm.ts"],"names":[],"mappings":";;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;AAEM,MAAO,SAAP,CAAgB;AACpB,MAAI,OAAJ,GAAW;AACT,WAAO,IAAI,CAAC,GAAZ;AACD;;AAED,EAAA,IAAI,CAAC,IAAD,EAAe,IAAf,EAAoC,OAApC,EAA+D,eAAe,GAAG,IAAjF,EAAqF;AACvF,WAAO,yBAAK,IAAL,EAAW,IAAX,EAAiB,OAAjB,EAA0B,eAA1B,CAAP;AACD;;AAED,EAAA,KAAK,CAAC,IAAD,EAAe,IAAf,EAAoC,OAApC,EAA4D,YAA5D,EAA4F;AAC/F,WAAO,0BAAM,IAAN,EAAY,IAAZ,EAAkB,OAAlB,EAA2B,YAA3B,CAAP;AACD;;AAED,EAAA,QAAQ,CAAC,IAAD,EAAa;AACnB,WAAO,IAAP;AACD;;AAfmB;;;;AAkBf,eAAe,YAAf,CAA4B,WAA5B,EAAoD;AACzD,QAAM,MAAM,GAAG,CAAC,MAAM,gCAAY,WAAZ,CAAP,EAAiC,MAAjC,CAAwC,EAAE,IAAI,EAAE,CAAC,EAAH,KAAU,QAAxD,CAAf;;AACA,MAAI,MAAM,CAAC,MAAP,KAAkB,CAAtB,EAAyB;AACvB,UAAM,KAAI,wCAAJ,EAA8B,iFAA9B,CAAN;AACD,GAJwD,CAMzD;;;AACA,SAAO,KAAI,iCAAJ,EAAuB,MAAM,CAAC,IAAP,CAAY,EAAE,IAAI,EAAE,CAAC,KAAH,KAAa,SAA/B,KAA6C,MAAM,CAAC,IAAP,CAAY,EAAE,IAAI,EAAE,CAAC,KAAH,KAAa,WAA/B,CAA7C,IAA4F,MAAM,CAAC,CAAD,CAAzH,CAAP;AACD,C","sourcesContent":["import { DebugLogger, exec, ExtraSpawnOptions, InvalidConfigurationError, spawn } from \"builder-util\"\nimport { ExecFileOptions, SpawnOptions } from \"child_process\"\nimport * as path from \"path\"\nimport { ParallelsVmManager, parseVmList } from \"./ParallelsVm\"\n\nexport class VmManager {\n get pathSep(): string {\n return path.sep\n }\n\n exec(file: string, args: Array<string>, options?: ExecFileOptions, isLogOutIfDebug = true): Promise<string> {\n return exec(file, args, options, isLogOutIfDebug)\n }\n\n spawn(file: string, args: Array<string>, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions): Promise<any> {\n return spawn(file, args, options, extraOptions)\n }\n\n toVmFile(file: string): string {\n return file\n }\n}\n\nexport async function getWindowsVm(debugLogger: DebugLogger): Promise<VmManager> {\n const vmList = (await parseVmList(debugLogger)).filter(it => it.os === \"win-10\")\n if (vmList.length === 0) {\n throw new InvalidConfigurationError(\"Cannot find suitable Parallels Desktop virtual machine (Windows 10 is required)\")\n }\n\n // prefer running or suspended vm\n return new ParallelsVmManager(vmList.find(it => it.state === \"running\") || vmList.find(it => it.state === \"suspended\") || vmList[0])\n}"],"sourceRoot":""}