Initial commit

This commit is contained in:
2025-03-07 19:22:02 +01:00
commit 4a98255d83
55743 changed files with 5280367 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
#!/usr/bin/env node
export {};
+72
View File
@@ -0,0 +1,72 @@
#!/usr/bin/env node
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const commander_1 = require("commander");
const office_addin_usage_data_1 = require("office-addin-usage-data");
const commands = __importStar(require("./commands"));
/* global process */
const commander = new commander_1.Command();
commander.name("office-addin-debugging");
commander.version(process.env.npm_package_version || "(version not available)");
commander
.command("start <manifest-path> [platform]")
.option("--app <app>", "Specify which Office app to use.")
.option("--debug-method <method>", "The debug method to use.")
.option("--dev-server <command>", "Run the dev server.")
.option("--dev-server-port <port>", "Verify the dev server is running using this port.")
.option("--document <document>", "Document to be used for sideloading.")
.option("--no-debug", "Start without debugging.")
.option("--no-live-reload", "Do not enable live-reload.")
.option("--no-sideload", "Do not start the Office app and load the add-in.")
.option("--dev-tools", "Open the web browser developer tools when debugging (if supported).")
.option("--packager <command>", "Run the packager.")
.option("--packager-host <host>")
.option("--packager-port <port>")
.option("--prod", "Specifies that debugging session is for production mode. Default is dev mode.")
.option("--source-bundle-url-host <host>")
.option("--source-bundle-url-port <port>")
.option("--source-bundle-url-path <path>")
.option("--source-bundle-url-extension <extension>")
.action(commands.start);
commander
.command("stop <manifest-path> [platform]")
.option("--prod", "Specifies production mode.")
.action(commands.stop);
// if the command is not known, display an error
commander.on("command:*", function () {
(0, office_addin_usage_data_1.logErrorMessage)(`The command syntax is not valid.\n`);
process.exitCode = 1;
commander.help();
});
if (process.argv.length > 2) {
commander.parse(process.argv);
}
else {
commander.help();
}
//# sourceMappingURL=cli.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AAEA,4DAA4D;AAC5D,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;AAElC,yCAAoC;AACpC,qEAA0D;AAC1D,qDAAuC;AAEvC,oBAAoB;AAEpB,MAAM,SAAS,GAAG,IAAI,mBAAO,EAAE,CAAC;AAEhC,SAAS,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;AACzC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,yBAAyB,CAAC,CAAC;AAEhF,SAAS;KACN,OAAO,CAAC,kCAAkC,CAAC;KAC3C,MAAM,CAAC,aAAa,EAAE,kCAAkC,CAAC;KACzD,MAAM,CAAC,yBAAyB,EAAE,0BAA0B,CAAC;KAC7D,MAAM,CAAC,wBAAwB,EAAE,qBAAqB,CAAC;KACvD,MAAM,CAAC,0BAA0B,EAAE,mDAAmD,CAAC;KACvF,MAAM,CAAC,uBAAuB,EAAE,sCAAsC,CAAC;KACvE,MAAM,CAAC,YAAY,EAAE,0BAA0B,CAAC;KAChD,MAAM,CAAC,kBAAkB,EAAE,4BAA4B,CAAC;KACxD,MAAM,CAAC,eAAe,EAAE,kDAAkD,CAAC;KAC3E,MAAM,CAAC,aAAa,EAAE,qEAAqE,CAAC;KAC5F,MAAM,CAAC,sBAAsB,EAAE,mBAAmB,CAAC;KACnD,MAAM,CAAC,wBAAwB,CAAC;KAChC,MAAM,CAAC,wBAAwB,CAAC;KAChC,MAAM,CAAC,QAAQ,EAAE,+EAA+E,CAAC;KACjG,MAAM,CAAC,iCAAiC,CAAC;KACzC,MAAM,CAAC,iCAAiC,CAAC;KACzC,MAAM,CAAC,iCAAiC,CAAC;KACzC,MAAM,CAAC,2CAA2C,CAAC;KACnD,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAE1B,SAAS;KACN,OAAO,CAAC,iCAAiC,CAAC;KAC1C,MAAM,CAAC,QAAQ,EAAE,4BAA4B,CAAC;KAC9C,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAEzB,gDAAgD;AAChD,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE;IACxB,IAAA,yCAAe,EAAC,oCAAoC,CAAC,CAAC;IACtD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACrB,SAAS,CAAC,IAAI,EAAE,CAAC;AACnB,CAAC,CAAC,CAAC;AAEH,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;IAC3B,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B;KAAM;IACL,SAAS,CAAC,IAAI,EAAE,CAAC;CAClB"}
+3
View File
@@ -0,0 +1,3 @@
import { OptionValues } from "commander";
export declare function start(manifestPath: string, platform: string | undefined, options: OptionValues): Promise<void>;
export declare function stop(manifestPath: string, platform: string | undefined, options: OptionValues): Promise<void>;
+151
View File
@@ -0,0 +1,151 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.stop = exports.start = void 0;
const fs_1 = __importDefault(require("fs"));
const office_addin_cli_1 = require("office-addin-cli");
const office_addin_usage_data_1 = require("office-addin-usage-data");
const devSettings = __importStar(require("office-addin-dev-settings"));
const office_addin_manifest_1 = require("office-addin-manifest");
const start_1 = require("./start");
const stop_1 = require("./stop");
const defaults_1 = require("./defaults");
const office_addin_usage_data_2 = require("office-addin-usage-data");
/* global process */
function determineManifestPath(platform, dev) {
let manifestPath = process.env.npm_package_config_manifest_location || "";
manifestPath = manifestPath
.replace("${flavor}", dev ? "dev" : "prod")
.replace("${platform}", platform);
if (!manifestPath) {
throw new office_addin_usage_data_2.ExpectedError(`The manifest path was not provided.`);
}
if (!fs_1.default.existsSync(manifestPath)) {
throw new office_addin_usage_data_2.ExpectedError(`The manifest path does not exist: ${manifestPath}.`);
}
return manifestPath;
}
function parseDevServerPort(optionValue) {
const devServerPort = (0, office_addin_cli_1.parseNumber)(optionValue, "--dev-server-port should specify a number.");
if (devServerPort !== undefined) {
if (!Number.isInteger(devServerPort)) {
throw new office_addin_usage_data_2.ExpectedError("--dev-server-port should be an integer.");
}
if (devServerPort < 0 || devServerPort > 65535) {
throw new office_addin_usage_data_2.ExpectedError("--dev-server-port should be between 0 and 65535.");
}
}
return devServerPort;
}
function start(manifestPath, platform, options) {
return __awaiter(this, void 0, void 0, function* () {
try {
const appPlatformToDebug = (0, start_1.parsePlatform)(platform || process.env.npm_package_config_app_platform_to_debug || start_1.Platform.Win32);
const appTypeToDebug = devSettings.parseAppType(appPlatformToDebug || process.env.npm_package_config_app_type_to_debug || start_1.AppType.Desktop);
const appToDebug = options.app || process.env.npm_package_config_app_to_debug;
const app = appToDebug ? (0, office_addin_manifest_1.parseOfficeApp)(appToDebug) : undefined;
const dev = options.prod ? false : true;
const debuggingMethod = (0, start_1.parseDebuggingMethod)(options.debugMethod);
const devServer = options.devServer || (yield (0, office_addin_cli_1.getPackageJsonScript)("dev-server"));
const devServerPort = parseDevServerPort(options.devServerPort || process.env.npm_package_config_dev_server_port);
const document = options.document || process.env.npm_package_config_document;
const enableDebugging = options.debug;
const enableLiveReload = options.liveReload === true;
const enableSideload = options.sideload !== false; // enable if true or undefined; only disable if false
const openDevTools = options.devTools === true;
const packager = options.packager || (yield (0, office_addin_cli_1.getPackageJsonScript)("packager"));
const packagerHost = options.PackagerHost || process.env.npm_package_config_packager_host;
const packagerPort = options.PackagerPort || process.env.npm_package_config_packager_port;
const sourceBundleUrlComponents = new devSettings.SourceBundleUrlComponents(options.sourceBundleUrlHost, options.sourceBundleUrlPort, options.sourceBundleUrlPath, options.sourceBundleUrlExtension);
if (appPlatformToDebug === undefined) {
throw new office_addin_usage_data_2.ExpectedError("Please specify the platform to debug.");
}
if (appTypeToDebug === undefined) {
throw new office_addin_usage_data_2.ExpectedError("Please specify the application type to debug.");
}
if (appPlatformToDebug === start_1.Platform.Android || appPlatformToDebug === start_1.Platform.iOS) {
throw new office_addin_usage_data_2.ExpectedError(`Platform type ${appPlatformToDebug} not currently supported for debugging`);
}
if (!manifestPath) {
manifestPath = determineManifestPath(appPlatformToDebug, dev);
}
yield (0, start_1.startDebugging)(manifestPath, {
appType: appTypeToDebug,
app,
debuggingMethod,
sourceBundleUrlComponents,
devServerCommandLine: devServer,
devServerPort,
packagerCommandLine: packager,
packagerHost,
packagerPort,
enableDebugging,
enableLiveReload,
enableSideload,
openDevTools,
document,
});
defaults_1.usageDataObject.reportSuccess("start");
}
catch (err) {
defaults_1.usageDataObject.reportException("start", err);
(0, office_addin_usage_data_1.logErrorMessage)(`Unable to start debugging.\n${err}`);
}
});
}
exports.start = start;
function stop(manifestPath, platform, options) {
return __awaiter(this, void 0, void 0, function* () {
try {
const appPlatformToDebug = (0, start_1.parsePlatform)(platform || process.env.npm_package_config_app_plaform_to_debug || start_1.Platform.Win32);
const dev = options.prod ? false : true;
if (manifestPath === "" && appPlatformToDebug !== undefined) {
manifestPath = determineManifestPath(appPlatformToDebug, dev);
}
yield (0, stop_1.stopDebugging)(manifestPath);
defaults_1.usageDataObject.reportSuccess("stop");
}
catch (err) {
defaults_1.usageDataObject.reportException("stop", err);
(0, office_addin_usage_data_1.logErrorMessage)(`Unable to stop debugging.\n${err}`);
}
});
}
exports.stop = stop;
//# sourceMappingURL=commands.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGlC,4CAAoB;AACpB,uDAAqE;AACrE,qEAA0D;AAC1D,uEAAyD;AACzD,iEAAkE;AAClE,mCAAiG;AACjG,iCAAuC;AACvC,yCAA6C;AAC7C,q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AsB,IAAI,CACxB,YAAoB,EACpB,QAA4B,EAC5B,OAAqB;;QAErB,IAAI;YACF,MAAM,kBAAkB,GAAyB,IAAA,qBAAa,EAC5D,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,uCAAuC,IAAI,gBAAQ,CAAC,KAAK,CAClF,CAAC;YACF,MAAM,GAAG,GAAY,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;YAEjD,IAAI,YAAY,KAAK,EAAE,IAAI,kBAAkB,KAAK,SAAS,EAAE;gBAC3D,YAAY,GAAG,qBAAqB,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;aAC/D;YAED,MAAM,IAAA,oBAAa,EAAC,YAAY,CAAC,CAAC;YAClC,0BAAe,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;SACvC;QAAC,OAAO,GAAQ,EAAE;YACjB,0BAAe,CAAC,eAAe,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YAC7C,IAAA,yCAAe,EAAC,8BAA8B,GAAG,EAAE,CAAC,CAAC;SACtD;IACH,CAAC;CAAA;AArBD,oBAqBC"}
+22
View File
@@ -0,0 +1,22 @@
export interface IDebuggingInfo {
devServer: IDevServerInfo;
}
export interface IDevServerInfo {
processId: number | undefined;
}
export declare function getDebuggingInfoPath(): string;
/**
* Saves the process id of the dev server
* @param id process id
*/
export declare function saveDevServerProcessId(id: number): Promise<void>;
/**
* Read the process id from either the environment variable or
* from the json file containing the debug info
*/
export declare function readDevServerProcessId(): number | undefined;
/**
* Deletes the environment variable containing process id
* and deletes the debug info json file if it exists
*/
export declare function clearDevServerProcessId(): void;
+109
View File
@@ -0,0 +1,109 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.clearDevServerProcessId = exports.readDevServerProcessId = exports.saveDevServerProcessId = exports.getDebuggingInfoPath = void 0;
const fs_1 = __importDefault(require("fs"));
const office_addin_cli_1 = require("office-addin-cli");
const os_1 = __importDefault(require("os"));
const path_1 = __importDefault(require("path"));
/* global process */
const processIdFile = "office-addin-debugging.json";
const processIdFilePath = path_1.default.join(os_1.default.tmpdir(), processIdFile);
function getDebuggingInfoPath() {
return processIdFilePath;
}
exports.getDebuggingInfoPath = getDebuggingInfoPath;
/**
* Creates the DebuggingInfo object
*/
function createDebuggingInfo() {
const devServer = {
processId: undefined,
};
const debuggingInfo = {
devServer,
};
return debuggingInfo;
}
/**
* Set the process id of the dev server in the Debugging object
* @param debuggingInfo DebuggingInfo object
* @param id dev server process id
*/
function setDevServerProcessId(debuggingInfo, id) {
debuggingInfo.devServer.processId = id;
}
/**
* Write the DebuggingInfo to the json file
* @param debuggingInfo DebuggingInfo object
* @param pathToFile Path to the json file containing debug info
*/
function writeDebuggingInfo(debuggingInfo, pathToFile) {
const debuggingInfoJSON = JSON.stringify(debuggingInfo, null, 4);
fs_1.default.writeFileSync(pathToFile, debuggingInfoJSON);
}
/**
* Read the DebuggingInfo object
* @param pathToFile Path to the json file containing debug info
*/
function readDebuggingInfo(pathToFile) {
const json = fs_1.default.readFileSync(pathToFile);
return JSON.parse(json.toString());
}
/**
* Saves the process id of the dev server
* @param id process id
*/
function saveDevServerProcessId(id) {
return __awaiter(this, void 0, void 0, function* () {
process.env.OfficeAddinDevServerProcessId = id.toString();
const debuggingInfo = createDebuggingInfo();
setDevServerProcessId(debuggingInfo, id);
writeDebuggingInfo(debuggingInfo, processIdFilePath);
});
}
exports.saveDevServerProcessId = saveDevServerProcessId;
/**
* Read the process id from either the environment variable or
* from the json file containing the debug info
*/
function readDevServerProcessId() {
let id;
if (process.env.OfficeAddinDevServerProcessId) {
id = (0, office_addin_cli_1.parseNumber)(process.env.OfficeAddinDevServerProcessId);
}
else if (fs_1.default.existsSync(processIdFilePath)) {
const devServerProperties = readDebuggingInfo(processIdFilePath);
if (devServerProperties.devServer && devServerProperties.devServer.processId) {
const pid = devServerProperties.devServer.processId;
id = (0, office_addin_cli_1.parseNumber)(pid.toString(), `Invalid process id found in ${processIdFilePath}`);
}
}
return id;
}
exports.readDevServerProcessId = readDevServerProcessId;
/**
* Deletes the environment variable containing process id
* and deletes the debug info json file if it exists
*/
function clearDevServerProcessId() {
if (fs_1.default.existsSync(processIdFilePath)) {
fs_1.default.unlinkSync(processIdFilePath);
}
delete process.env.OfficeAddinDevServerProcessId;
}
exports.clearDevServerProcessId = clearDevServerProcessId;
//# sourceMappingURL=debugInfo.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"debugInfo.js","sourceRoot":"","sources":["../src/debugInfo.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;;;;;;;;;;AAElC,4CAAoB;AACpB,uDAA+C;AAC/C,4CAAoB;AACpB,gDAAwB;AAExB,oBAAoB;AAEpB,MAAM,aAAa,GAAG,6BAA6B,CAAC;AACpD,MAAM,iBAAiB,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,MAAM,EAAE,EAAE,aAAa,CAAC,CAAC;AAUhE,SAAgB,oBAAoB;IAClC,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAFD,oDAEC;AAED;;GAEG;AACH,SAAS,mBAAmB;IAC1B,MAAM,SAAS,GAAmB;QAChC,SAAS,EAAE,SAAS;KACrB,CAAC;IACF,MAAM,aAAa,GAAmB;QACpC,SAAS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BAAmB,CAAC,SAAS,IAAI,mBAAmB,CAAC,SAAS,CAAC,SAAS,EAAE;YAC5E,MAAM,GAAG,GAAG,mBAAmB,CAAC,SAAS,CAAC,SAAS,CAAC;YACpD,EAAE,GAAG,IAAA,8BAAW,EAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,+BAA+B,iBAAiB,EAAE,CAAC,CAAC;SACtF;KACF;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAZD,wDAYC;AAED;;;GAGG;AACH,SAAgB,uBAAuB;IACrC,IAAI,YAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE;QACpC,YAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;KAClC;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC;AACnD,CAAC;AALD,0DAKC"}
+2
View File
@@ -0,0 +1,2 @@
import { OfficeAddinUsageData } from "office-addin-usage-data";
export declare const usageDataObject: OfficeAddinUsageData;
+13
View File
@@ -0,0 +1,13 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.usageDataObject = void 0;
const office_addin_usage_data_1 = require("office-addin-usage-data");
// Usage data defaults
exports.usageDataObject = new office_addin_usage_data_1.OfficeAddinUsageData({
projectName: "office-addin-debugging",
instrumentationKey: office_addin_usage_data_1.instrumentationKeyForOfficeAddinCLITools,
raisePrompt: false,
});
//# sourceMappingURL=defaults.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAElC,qEAGiC;AAEjC,sBAAsB;AACT,QAAA,eAAe,GAAyB,IAAI,8CAAoB,CAAC;IAC5E,WAAW,EAAE,wBAAwB;IACrC,kBAAkB,EAAE,kEAAwC;IAC5D,WAAW,EAAE,KAAK;CACnB,CAAC,CAAC"}
+4
View File
@@ -0,0 +1,4 @@
export * from "./port";
export * from "./process";
export * from "./start";
export * from "./stop";
+23
View File
@@ -0,0 +1,23 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./port"), exports);
__exportStar(require("./process"), exports);
__exportStar(require("./start"), exports);
__exportStar(require("./stop"), exports);
//# sourceMappingURL=main.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;;;;;;;;;;;AAElC,yCAAuB;AACvB,4CAA0B;AAC1B,0CAAwB;AACxB,yCAAuB"}
+17
View File
@@ -0,0 +1,17 @@
/**
* Determines whether a port is in use.
* @param port port number (0 - 65535)
* @returns true if port is in use; false otherwise.
*/
export declare function isPortInUse(port: number): Promise<boolean>;
/**
* Return the process ids using the port.
* @param port port number (0 - 65535)
* @returns Promise to array containing process ids, or empty if none.
*/
export declare function getProcessIdsForPort(port: number): Promise<number[]>;
/**
* Returns a random port number which is not in use.
* @returns Promise to number from 0 to 65535
*/
export declare function randomPortNotInUse(): Promise<number>;
+163
View File
@@ -0,0 +1,163 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.randomPortNotInUse = exports.getProcessIdsForPort = exports.isPortInUse = void 0;
const child_process_1 = __importDefault(require("child_process"));
const crypto_1 = __importDefault(require("crypto"));
const net_1 = __importDefault(require("net"));
const office_addin_usage_data_1 = require("office-addin-usage-data");
/* global process */
/**
* Determines whether a port is in use.
* @param port port number (0 - 65535)
* @returns true if port is in use; false otherwise.
*/
function isPortInUse(port) {
validatePort(port);
return new Promise((resolve) => {
const server = net_1.default
.createServer()
.once("error", () => {
resolve(true);
})
.once("listening", () => {
server.close();
resolve(false);
})
.listen(port);
});
}
exports.isPortInUse = isPortInUse;
/**
* Parse the port from a string which ends with colon and a number.
* @param text string to parse
* @example "127.0.0.1:3000" returns 3000
* @example "[::1]:1900" returns 1900
* @example "Local Address" returns undefined
*/
function parsePort(text) {
const result = text.match(/:(\d+)$/);
return result ? parseInt(result[1], 10) : undefined;
}
/**
* Return the process ids using the port.
* @param port port number (0 - 65535)
* @returns Promise to array containing process ids, or empty if none.
*/
function getProcessIdsForPort(port) {
validatePort(port);
return new Promise((resolve, reject) => {
const isWin32 = process.platform === "win32";
const isLinux = process.platform === "linux";
const command = isWin32
? `netstat -ano | findstr :${port}`
: isLinux
? `netstat -tlpna | grep :${port}`
: `lsof -n -i:${port}`;
child_process_1.default.exec(command, (error, stdout) => {
if (error) {
if (error.code === 1) {
// no processes are using the port
resolve([]);
}
else {
reject(error);
}
}
else {
const processIds = new Set();
const lines = stdout.trim().split("\n");
if (isWin32) {
lines.forEach((line) => {
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
const [protocol, localAddress, foreignAddress, status, processId] = line
.trim()
.split(" ")
.filter((text) => text);
if (processId !== undefined && processId.trim() !== "0") {
const localAddressPort = parsePort(localAddress);
if (localAddressPort === port) {
processIds.add(parseInt(processId, 10));
}
}
});
}
else if (isLinux) {
lines.forEach((line) => {
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
const [proto, recv, send, local_address, remote_address, state, program] = line
.trim()
.split(" ")
.filter((text) => text);
if (local_address !== undefined &&
local_address.endsWith(`:${port}`) &&
program !== undefined) {
const pid = parseInt(program, 10);
if (!isNaN(pid)) {
processIds.add(pid);
}
}
});
}
else {
lines.forEach((line) => {
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
const [process, processId, user, fd, type, device, size, node, name] = line
.trim()
.split(" ")
.filter((text) => text);
if (processId !== undefined && processId !== "PID") {
processIds.add(parseInt(processId, 10));
}
});
}
resolve(Array.from(processIds));
}
});
});
}
exports.getProcessIdsForPort = getProcessIdsForPort;
/**
* Returns a random port number which is not in use.
* @returns Promise to number from 0 to 65535
*/
function randomPortNotInUse() {
return __awaiter(this, void 0, void 0, function* () {
let port;
do {
port = randomPortNumber();
} while (yield isPortInUse(port));
return port;
});
}
exports.randomPortNotInUse = randomPortNotInUse;
/**
* Returns a random number between 0 and 65535
*/
function randomPortNumber() {
return crypto_1.default.randomBytes(2).readUInt16LE(0);
}
/**
* Throw an error if the port is not a valid number.
* @param port port number
* @throws Error if port is not a number from 0 to 65535.
*/
function validatePort(port) {
if (typeof port !== "number" || port < 0 || port > 65535) {
throw new office_addin_usage_data_1.ExpectedError("Port should be a number from 0 to 65535.");
}
}
//# sourceMappingURL=port.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"port.js","sourceRoot":"","sources":["../src/port.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;;;;;;;;;;AAElC,kEAA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C3B,QAAQ,MAAM,WAAW,CAAC,IAAI,CAAC,EAAE;QAElC,OAAO,IAAI,CAAC;IACd,CAAC;CAAA;AAPD,gDAOC;AAED;;GAEG;AACH,SAAS,gBAAgB;IACvB,OAAO,gBAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED;;;;GAIG;AACH,SAAS,YAAY,CAAC,IAAY;IAChC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,KAAK,EAAE;QACxD,MAAM,IAAI,uCAAa,CAAC,0CAA0C,CAAC,CAAC;KACrE;AACH,CAAC"}
+5
View File
@@ -0,0 +1,5 @@
/// <reference types="node" />
import { ChildProcess } from "child_process";
export declare function startProcess(commandLine: string, verbose?: boolean): Promise<void>;
export declare function startDetachedProcess(commandLine: string, verbose?: boolean): ChildProcess;
export declare function stopProcess(processId: number): void;
+53
View File
@@ -0,0 +1,53 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.stopProcess = exports.startDetachedProcess = exports.startProcess = void 0;
const devSettings = __importStar(require("office-addin-dev-settings"));
function startProcess(commandLine, verbose = false) {
return __awaiter(this, void 0, void 0, function* () {
yield devSettings.startProcess(commandLine, verbose);
});
}
exports.startProcess = startProcess;
function startDetachedProcess(commandLine, verbose = false) {
return devSettings.startDetachedProcess(commandLine, verbose);
}
exports.startDetachedProcess = startDetachedProcess;
function stopProcess(processId) {
devSettings.stopProcess(processId);
}
exports.stopProcess = stopProcess;
//# sourceMappingURL=process.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"process.js","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGlC,uEAAyD;AAEzD,SAAsB,YAAY,CAAC,WAAmB,EAAE,UAAmB,KAAK;;QAC9E,MAAM,WAAW,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;CAAA;AAFD,oCAEC;AAED,SAAgB,oBAAoB,CAAC,WAAmB,EAAE,UAAmB,KAAK;IAChF,OAAO,WAAW,CAAC,oBAAoB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AAChE,CAAC;AAFD,oDAEC;AAED,SAAgB,WAAW,CAAC,SAAiB;IAC3C,WAAW,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC;AAFD,kCAEC"}
+94
View File
@@ -0,0 +1,94 @@
import * as devSettings from "office-addin-dev-settings";
import { DebuggingMethod } from "office-addin-dev-settings";
import { OfficeApp } from "office-addin-manifest";
export declare enum AppType {
Desktop = "desktop",
Web = "web"
}
export declare enum Platform {
Android = "android",
Desktop = "desktop",
iOS = "ios",
MacOS = "macos",
Win32 = "win32",
Web = "web"
}
export declare function isDevServerRunning(port: number): Promise<boolean>;
export declare function isPackagerRunning(statusUrl: string): Promise<boolean>;
export declare function parseDebuggingMethod(text: string): DebuggingMethod | undefined;
export declare function parsePlatform(text: string): Platform | undefined;
export declare function runDevServer(commandLine: string, port?: number): Promise<void>;
export declare function runNodeDebugger(host?: string, port?: string): Promise<void>;
export declare function runPackager(commandLine: string, host?: string, port?: string): Promise<void>;
/**
* `startDebugging` options.
*/
export interface StartDebuggingOptions {
/**
* The type of application to debug.
*/
appType: AppType;
/**
* The Office application to debug.
* If unspecified and there is more than one application in the manifest will prompt to specify the application.
*/
app?: OfficeApp;
/**
* The method to use when debugging.
*/
debuggingMethod?: DebuggingMethod;
/**
* Specify components of the source bundle url.
*/
sourceBundleUrlComponents?: devSettings.SourceBundleUrlComponents;
/**
* If provided, starts the dev server.
*/
devServerCommandLine?: string;
/**
* If provided, port to verify that the dev server is running.
*/
devServerPort?: number;
/**
* If provided, starts the packager.
*/
packagerCommandLine?: string;
/**
* Specifies the host name of the packager.
*/
packagerHost?: string;
/**
* Specifies the port of the packager.
*/
packagerPort?: string;
/**
* Enable debugging.
* Starts with debugging if true or undefined.
*/
enableDebugging?: boolean;
/**
* Enable live reload.
*/
enableLiveReload?: boolean;
/**
* Enables launch of the Office host app and sideload of the add-in (if true or undefined).
* Set to false to disable sideload.
*/
enableSideload?: boolean;
/**
* Open Dev Tools.
*/
openDevTools?: boolean;
/**
* If provided, the document to open for sideloading to web.
*/
document?: string;
}
/**
* Start debugging
* @param options startDebugging options.
*/
export declare function startDebugging(manifestPath: string, options: StartDebuggingOptions): Promise<void>;
export declare function waitUntil(callback: () => Promise<boolean>, retryCount: number, retryDelay: number): Promise<boolean>;
export declare function waitUntilDevServerIsRunning(port: number, retryCount?: number, retryDelay?: number): Promise<boolean>;
export declare function waitUntilPackagerIsRunning(statusUrl: string, retryCount?: number, retryDelay?: number): Promise<boolean>;
+385
View File
@@ -0,0 +1,385 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.waitUntilPackagerIsRunning = exports.waitUntilDevServerIsRunning = exports.waitUntil = exports.startDebugging = exports.runPackager = exports.runNodeDebugger = exports.runDevServer = exports.parsePlatform = exports.parseDebuggingMethod = exports.isPackagerRunning = exports.isDevServerRunning = exports.Platform = exports.AppType = void 0;
const adm_zip_1 = __importDefault(require("adm-zip"));
const node_fetch_1 = __importDefault(require("node-fetch"));
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const devCerts = __importStar(require("office-addin-dev-certs"));
const devSettings = __importStar(require("office-addin-dev-settings"));
const os_1 = __importDefault(require("os"));
const office_addin_dev_settings_1 = require("office-addin-dev-settings");
const office_addin_manifest_1 = require("office-addin-manifest");
const nodeDebugger = __importStar(require("office-addin-node-debugger"));
const debugInfo = __importStar(require("./debugInfo"));
const port_1 = require("./port");
const process_1 = require("./process");
const defaults_1 = require("./defaults");
const office_addin_usage_data_1 = require("office-addin-usage-data");
/* global console process setTimeout */
var AppType;
(function (AppType) {
AppType["Desktop"] = "desktop";
AppType["Web"] = "web";
})(AppType = exports.AppType || (exports.AppType = {}));
var Platform;
(function (Platform) {
Platform["Android"] = "android";
Platform["Desktop"] = "desktop";
Platform["iOS"] = "ios";
Platform["MacOS"] = "macos";
Platform["Win32"] = "win32";
Platform["Web"] = "web";
})(Platform = exports.Platform || (exports.Platform = {}));
function defaultDebuggingMethod() {
return office_addin_dev_settings_1.DebuggingMethod.Direct;
}
function delay(milliseconds) {
return new Promise((resolve) => {
setTimeout(resolve, milliseconds);
});
}
function isDevServerRunning(port) {
return __awaiter(this, void 0, void 0, function* () {
// isPortInUse(port) will return false when webpack-dev-server is running.
// it should be fixed, but for now, use getProcessIdsForPort(port)
const processIds = yield (0, port_1.getProcessIdsForPort)(port);
const isRunning = processIds.length > 0;
return isRunning;
});
}
exports.isDevServerRunning = isDevServerRunning;
function isPackagerRunning(statusUrl) {
return __awaiter(this, void 0, void 0, function* () {
const statusRunningResponse = `packager-status:running`;
try {
const response = yield node_fetch_1.default.default(statusUrl);
console.log(`packager: ${response.status} ${response.statusText}`);
const text = yield response.text();
console.log(`packager: ${text}`);
return statusRunningResponse === text;
}
catch (_a) {
return false;
}
});
}
exports.isPackagerRunning = isPackagerRunning;
function parseDebuggingMethod(text) {
switch (text) {
case "direct":
return office_addin_dev_settings_1.DebuggingMethod.Direct;
case "proxy":
return office_addin_dev_settings_1.DebuggingMethod.Proxy;
default:
return undefined;
}
}
exports.parseDebuggingMethod = parseDebuggingMethod;
function parsePlatform(text) {
if (text === AppType.Desktop) {
text = process.platform;
}
switch (text) {
case "android":
return Platform.Android;
case "darwin":
return Platform.MacOS;
case "ios":
return Platform.iOS;
case "macos":
return Platform.MacOS;
case "web":
return Platform.Web;
case "win32":
return Platform.Win32;
default:
throw new office_addin_usage_data_1.ExpectedError(`The current platform is not supported: ${text}`);
}
}
exports.parsePlatform = parsePlatform;
function runDevServer(commandLine, port) {
return __awaiter(this, void 0, void 0, function* () {
if (commandLine) {
// if the dev server is running
if (port !== undefined && (yield isDevServerRunning(port))) {
console.log(`The dev server is already running on port ${port}.`);
}
else {
// On non-Windows platforms, prompt for installing the dev certs before starting the dev server.
// This is a workaround for the fact that the detached process does not show a window on Mac,
// therefore the user cannot enter the password when prompted.
if (process.platform !== "win32") {
if (!devCerts.verifyCertificates()) {
yield devCerts.ensureCertificatesAreInstalled();
}
}
// start the dev server
console.log(`Starting the dev server... (${commandLine})`);
const devServerProcess = (0, process_1.startDetachedProcess)(commandLine);
yield debugInfo.saveDevServerProcessId(devServerProcess.pid);
if (port !== undefined) {
// wait until the dev server is running
const isRunning = yield waitUntilDevServerIsRunning(port);
if (isRunning) {
console.log(`The dev server is running on port ${port}. Process id: ${devServerProcess.pid}`);
}
else {
throw new Error(`The dev server is not running on port ${port}.`);
}
}
}
}
});
}
exports.runDevServer = runDevServer;
function runNodeDebugger(host, port) {
return __awaiter(this, void 0, void 0, function* () {
nodeDebugger.run(host, port);
console.log("The node debugger is running.");
});
}
exports.runNodeDebugger = runNodeDebugger;
function runPackager(commandLine, host = "localhost", port = "8081") {
return __awaiter(this, void 0, void 0, function* () {
if (commandLine) {
// eslint-disable-next-line @microsoft/sdl/no-insecure-url
const packagerUrl = `http://${host}:${port}`;
const statusUrl = `${packagerUrl}/status`;
// if the packager is running
if (yield isPackagerRunning(statusUrl)) {
console.log(`The packager is already running. ${packagerUrl}`);
}
else {
// start the packager
console.log(`Starting the packager... (${commandLine})`);
yield (0, process_1.startDetachedProcess)(commandLine);
// wait until the packager is running
if (yield waitUntilPackagerIsRunning(statusUrl)) {
console.log(`The packager is running. ${packagerUrl}`);
}
else {
throw new Error(`The packager is not running. ${packagerUrl}`);
}
}
}
});
}
exports.runPackager = runPackager;
/**
* Start debugging
* @param options startDebugging options.
*/
function startDebugging(manifestPath, options) {
var _a, _b, _c;
return __awaiter(this, void 0, void 0, function* () {
const { appType, app, debuggingMethod, sourceBundleUrlComponents, devServerCommandLine, devServerPort, packagerCommandLine, packagerHost, packagerPort, enableDebugging, enableLiveReload, enableSideload, openDevTools, document, } = Object.assign(Object.assign({}, options), {
// Defaults when variable is undefined.
debuggingMethod: options.debuggingMethod || defaultDebuggingMethod(), enableDebugging: (_a = options.enableDebugging) !== null && _a !== void 0 ? _a : true, enableSideload: (_b = options.enableSideload) !== null && _b !== void 0 ? _b : true, enableLiveReload: (_c = options.enableLiveReload) !== null && _c !== void 0 ? _c : true });
try {
if (appType === undefined) {
throw new office_addin_usage_data_1.ExpectedError("Please specify the application type to debug.");
}
const isWindowsPlatform = process.platform === "win32";
const isDesktopAppType = appType === AppType.Desktop;
const isProxyDebuggingMethod = debuggingMethod === office_addin_dev_settings_1.DebuggingMethod.Proxy;
// live reload can only be enabled for the desktop app type
// when using proxy debugging and the packager
const canEnableLiveReload = isDesktopAppType && isProxyDebuggingMethod && !!packagerCommandLine;
// only use live reload if enabled and it can be enabled
const useLiveReload = enableLiveReload && canEnableLiveReload;
console.log(enableDebugging ? "Debugging is being started..." : "Starting without debugging...");
console.log(`App type: ${appType}`);
if (manifestPath.endsWith(".zip")) {
manifestPath = yield extractManifest(manifestPath);
}
const manifestInfo = yield office_addin_manifest_1.OfficeAddinManifest.readManifestFile(manifestPath);
if (!manifestInfo.id) {
throw new office_addin_usage_data_1.ExpectedError("Manifest does not contain the id for the Office Add-in.");
}
// enable loopback for Edge
if (isWindowsPlatform && parseInt(os_1.default.release(), 10) === 10) {
const name = isDesktopAppType ? "EdgeWebView" : "EdgeWebBrowser";
try {
yield devSettings.ensureLoopbackIsEnabled(name);
}
catch (err) {
// if add loopback exemption failed, report the error then continue
console.error(err);
console.warn("Failed to add loopback exemption.\nWill try to sideload the Office Add-in without the loopback exemption, but it might not load correctly from localhost.\n");
defaults_1.usageDataObject.reportException("startDebugging()", err, {
app: app,
document: document,
appType: appType,
});
}
}
// enable debugging
if (isDesktopAppType && isWindowsPlatform) {
yield devSettings.enableDebugging(manifestInfo.id, enableDebugging, debuggingMethod, openDevTools);
if (enableDebugging) {
console.log(`Enabled debugging for add-in ${manifestInfo.id}.`);
}
}
// enable runtimelogging
if (isDesktopAppType && isWindowsPlatform) {
const path = yield devSettings.getRuntimeLoggingPath();
if (path) {
console.log(`Runtime logging is enabled. File: ${path}`);
}
else {
console.log("Enabling runtime logging..");
yield devSettings.enableRuntimeLogging(path);
const logPath = yield devSettings.getRuntimeLoggingPath();
console.log(`Runtime logging has been enabled. File: ${logPath}`);
}
}
// enable live reload
if (isDesktopAppType && isWindowsPlatform) {
yield devSettings.enableLiveReload(manifestInfo.id, useLiveReload);
if (useLiveReload) {
console.log(`Enabled live-reload for add-in ${manifestInfo.id}.`);
}
}
// set source bundle url
if (isDesktopAppType && isWindowsPlatform) {
if (sourceBundleUrlComponents) {
yield devSettings.setSourceBundleUrl(manifestInfo.id, sourceBundleUrlComponents);
}
}
// Run packager and dev server at the same time and wait for them to complete.
let packagerPromise;
let devServerPromise;
if (packagerCommandLine && isProxyDebuggingMethod && isDesktopAppType) {
packagerPromise = runPackager(packagerCommandLine, packagerHost, packagerPort);
}
if (devServerCommandLine) {
devServerPromise = runDevServer(devServerCommandLine, devServerPort);
}
if (packagerPromise !== undefined) {
try {
yield packagerPromise;
}
catch (err) {
console.log(`Unable to start the packager. ${err}`);
}
}
if (devServerPromise !== undefined) {
try {
yield devServerPromise;
}
catch (err) {
console.log(`Unable to start the dev server. ${err}`);
}
}
if (enableDebugging && isProxyDebuggingMethod && isDesktopAppType) {
try {
yield runNodeDebugger();
}
catch (err) {
console.log(`Unable to start the node debugger. ${err}`);
}
}
if (enableSideload) {
try {
console.log(`Sideloading the Office Add-in...`);
yield (0, office_addin_dev_settings_1.sideloadAddIn)(manifestPath, app, true, appType, document);
}
catch (err) {
throw new Error(`Unable to sideload the Office Add-in. \n${err}`);
}
}
console.log(enableDebugging ? "Debugging started." : "Started.");
defaults_1.usageDataObject.reportSuccess("startDebugging()", {
app: app,
document: document,
appType: appType,
});
}
catch (err) {
defaults_1.usageDataObject.reportException("startDebugging()", err, {
app: app,
document: document,
appType: appType,
});
throw err;
}
});
}
exports.startDebugging = startDebugging;
function waitUntil(callback, retryCount, retryDelay) {
return __awaiter(this, void 0, void 0, function* () {
let done = yield callback();
while (!done && retryCount) {
--retryCount;
yield delay(retryDelay);
done = yield callback();
}
return done;
});
}
exports.waitUntil = waitUntil;
function waitUntilDevServerIsRunning(port, retryCount = 30, retryDelay = 1000) {
return __awaiter(this, void 0, void 0, function* () {
return waitUntil(() => __awaiter(this, void 0, void 0, function* () { return yield isDevServerRunning(port); }), retryCount, retryDelay);
});
}
exports.waitUntilDevServerIsRunning = waitUntilDevServerIsRunning;
function waitUntilPackagerIsRunning(statusUrl, retryCount = 30, retryDelay = 1000) {
return __awaiter(this, void 0, void 0, function* () {
return waitUntil(() => __awaiter(this, void 0, void 0, function* () { return yield isPackagerRunning(statusUrl); }), retryCount, retryDelay);
});
}
exports.waitUntilPackagerIsRunning = waitUntilPackagerIsRunning;
function extractManifest(zipPath) {
return __awaiter(this, void 0, void 0, function* () {
const targetPath = path_1.default.join(process.env.TEMP, "addinManifest");
const zip = new adm_zip_1.default(zipPath); // reading archives
zip.extractAllTo(targetPath, true); // overwrite
const manifestPath = path_1.default.join(targetPath, "manifest.json");
if (fs_1.default.existsSync(manifestPath)) {
return manifestPath;
}
else {
throw new Error(`The zip file '${zipPath}' does not contain a "manifest.json" file`);
}
});
}
//# sourceMappingURL=start.js.map
File diff suppressed because one or more lines are too long
+1
View File
@@ -0,0 +1 @@
export declare function stopDebugging(manifestPath: string): Promise<void>;
+81
View File
@@ -0,0 +1,81 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.stopDebugging = void 0;
const office_addin_dev_settings_1 = require("office-addin-dev-settings");
const office_addin_manifest_1 = require("office-addin-manifest");
const debugInfo = __importStar(require("./debugInfo"));
const process_1 = require("./process");
const defaults_1 = require("./defaults");
const office_addin_usage_data_1 = require("office-addin-usage-data");
/* global console process */
function stopDebugging(manifestPath) {
return __awaiter(this, void 0, void 0, function* () {
try {
console.log("Debugging is being stopped...");
const isWindowsPlatform = process.platform === "win32";
const manifestInfo = yield office_addin_manifest_1.OfficeAddinManifest.readManifestFile(manifestPath);
if (!manifestInfo.id) {
throw new office_addin_usage_data_1.ExpectedError("Manifest does not contain the id for the Office Add-in.");
}
// clear dev settings
if (isWindowsPlatform) {
yield (0, office_addin_dev_settings_1.clearDevSettings)(manifestInfo.id);
}
// unregister
try {
yield (0, office_addin_dev_settings_1.unregisterAddIn)(manifestPath);
}
catch (err) {
console.log(`Unable to unregister the Office Add-in. ${err}`);
}
const processId = debugInfo.readDevServerProcessId();
if (processId) {
(0, process_1.stopProcess)(processId);
console.log(`Stopped dev server. Process id: ${processId}`);
debugInfo.clearDevServerProcessId();
}
console.log("Debugging has been stopped.");
defaults_1.usageDataObject.reportSuccess("stopDebugging()");
}
catch (err) {
defaults_1.usageDataObject.reportException("stopDebugging()", err);
throw err;
}
});
}
exports.stopDebugging = stopDebugging;
//# sourceMappingURL=stop.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"stop.js","sourceRoot":"","sources":["../src/stop.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElC,yEAA8E;AAC9E,iEAA4D;AAC5D,uDAAyC;AACzC,uCAAwC;AACxC,yCAA6C;AAC7C,qEAAwD;AAExD,4BAA4B;AAE5B,SAAsB,aAAa,CAAC,YAAoB;;QACtD,IAAI;YACF,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;YAE7C,MAAM,iBAAiB,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC;YACvD,MAAM,YAAY,GAAG,MAAM,2CAAmB,CAAC,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