@fluidframework/fluid-runner 2.0.0-internal.1.2.1 → 2.0.0-internal.1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -2
- package/dist/exportFile.d.ts +2 -1
- package/dist/exportFile.d.ts.map +1 -1
- package/dist/exportFile.js +5 -7
- package/dist/exportFile.js.map +1 -1
- package/dist/fakeUrlResolver.d.ts +1 -0
- package/dist/fakeUrlResolver.d.ts.map +1 -1
- package/dist/fakeUrlResolver.js +1 -0
- package/dist/fakeUrlResolver.js.map +1 -1
- package/dist/fluidRunner.d.ts.map +1 -1
- package/dist/fluidRunner.js +23 -13
- package/dist/fluidRunner.js.map +1 -1
- package/dist/getArgsValidationError.d.ts.map +1 -1
- package/dist/getArgsValidationError.js +0 -1
- package/dist/getArgsValidationError.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/logger/baseFileLogger.d.ts +28 -0
- package/dist/logger/baseFileLogger.d.ts.map +1 -0
- package/dist/logger/{FileLogger.js → baseFileLogger.js} +26 -34
- package/dist/logger/baseFileLogger.js.map +1 -0
- package/dist/logger/csvFileLogger.d.ts +18 -0
- package/dist/logger/csvFileLogger.d.ts.map +1 -0
- package/dist/logger/csvFileLogger.js +60 -0
- package/dist/logger/csvFileLogger.js.map +1 -0
- package/dist/logger/fileLogger.d.ts +38 -0
- package/dist/logger/fileLogger.d.ts.map +1 -0
- package/dist/logger/fileLogger.js +17 -0
- package/dist/logger/fileLogger.js.map +1 -0
- package/dist/logger/jsonFileLogger.d.ts +14 -0
- package/dist/logger/jsonFileLogger.d.ts.map +1 -0
- package/dist/logger/jsonFileLogger.js +44 -0
- package/dist/logger/jsonFileLogger.js.map +1 -0
- package/dist/logger/loggerUtils.d.ts +36 -0
- package/dist/logger/loggerUtils.d.ts.map +1 -0
- package/dist/logger/loggerUtils.js +90 -0
- package/dist/logger/loggerUtils.js.map +1 -0
- package/dist/parseBundleAndExportFile.d.ts +2 -1
- package/dist/parseBundleAndExportFile.d.ts.map +1 -1
- package/dist/parseBundleAndExportFile.js +6 -7
- package/dist/parseBundleAndExportFile.js.map +1 -1
- package/dist/utils.d.ts +7 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +17 -1
- package/dist/utils.js.map +1 -1
- package/lib/exportFile.d.ts +2 -1
- package/lib/exportFile.d.ts.map +1 -1
- package/lib/exportFile.js +4 -6
- package/lib/exportFile.js.map +1 -1
- package/lib/fakeUrlResolver.d.ts +1 -0
- package/lib/fakeUrlResolver.d.ts.map +1 -1
- package/lib/fakeUrlResolver.js +1 -0
- package/lib/fakeUrlResolver.js.map +1 -1
- package/lib/fluidRunner.d.ts.map +1 -1
- package/lib/fluidRunner.js +23 -13
- package/lib/fluidRunner.js.map +1 -1
- package/lib/getArgsValidationError.d.ts.map +1 -1
- package/lib/getArgsValidationError.js +0 -1
- package/lib/getArgsValidationError.js.map +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -2
- package/lib/index.js.map +1 -1
- package/lib/logger/baseFileLogger.d.ts +28 -0
- package/lib/logger/baseFileLogger.d.ts.map +1 -0
- package/lib/logger/baseFileLogger.js +49 -0
- package/lib/logger/baseFileLogger.js.map +1 -0
- package/lib/logger/csvFileLogger.d.ts +18 -0
- package/lib/logger/csvFileLogger.d.ts.map +1 -0
- package/lib/logger/csvFileLogger.js +37 -0
- package/lib/logger/csvFileLogger.js.map +1 -0
- package/lib/logger/fileLogger.d.ts +38 -0
- package/lib/logger/fileLogger.d.ts.map +1 -0
- package/lib/logger/fileLogger.js +14 -0
- package/lib/logger/fileLogger.js.map +1 -0
- package/lib/logger/jsonFileLogger.d.ts +14 -0
- package/lib/logger/jsonFileLogger.d.ts.map +1 -0
- package/lib/logger/jsonFileLogger.js +21 -0
- package/lib/logger/jsonFileLogger.js.map +1 -0
- package/lib/logger/loggerUtils.d.ts +36 -0
- package/lib/logger/loggerUtils.d.ts.map +1 -0
- package/lib/logger/loggerUtils.js +65 -0
- package/lib/logger/loggerUtils.js.map +1 -0
- package/lib/parseBundleAndExportFile.d.ts +2 -1
- package/lib/parseBundleAndExportFile.d.ts.map +1 -1
- package/lib/parseBundleAndExportFile.js +5 -6
- package/lib/parseBundleAndExportFile.js.map +1 -1
- package/lib/utils.d.ts +7 -0
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +15 -0
- package/lib/utils.js.map +1 -1
- package/package.json +11 -10
- package/src/exportFile.ts +7 -5
- package/src/fakeUrlResolver.ts +1 -0
- package/src/fluidRunner.ts +24 -16
- package/src/getArgsValidationError.ts +0 -1
- package/src/index.ts +5 -2
- package/src/logger/baseFileLogger.ts +58 -0
- package/src/logger/csvFileLogger.ts +40 -0
- package/src/logger/fileLogger.ts +45 -0
- package/src/logger/jsonFileLogger.ts +27 -0
- package/src/logger/loggerUtils.ts +81 -0
- package/src/parseBundleAndExportFile.ts +7 -5
- package/src/utils.ts +20 -0
- package/dist/logger/FileLogger.d.ts +0 -32
- package/dist/logger/FileLogger.d.ts.map +0 -1
- package/dist/logger/FileLogger.js.map +0 -1
- package/lib/logger/FileLogger.d.ts +0 -32
- package/lib/logger/FileLogger.d.ts.map +0 -1
- package/lib/logger/FileLogger.js +0 -55
- package/lib/logger/FileLogger.js.map +0 -1
- package/src/logger/FileLogger.ts +0 -67
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileLogger.d.ts","sourceRoot":"","sources":["../../src/logger/fileLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E;;;GAGG;AACH,MAAM,WAAW,WAAY,SAAQ,oBAAoB;IACrD;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED;;GAEG;AACH,oBAAY,YAAY;IACpB,IAAI,IAAA;IACJ,GAAG,IAAA;CACN;AAGD;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAC9B,iFAAiF;IACjF,YAAY,CAAC,EAAE,YAAY,CAAC;IAE5B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IAE/C,6DAA6D;IAC7D,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.OutputFormat = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Desired output format for the telemetry
|
|
10
|
+
*/
|
|
11
|
+
var OutputFormat;
|
|
12
|
+
(function (OutputFormat) {
|
|
13
|
+
OutputFormat[OutputFormat["JSON"] = 0] = "JSON";
|
|
14
|
+
OutputFormat[OutputFormat["CSV"] = 1] = "CSV";
|
|
15
|
+
})(OutputFormat = exports.OutputFormat || (exports.OutputFormat = {}));
|
|
16
|
+
/* eslint-enable tsdoc/syntax */
|
|
17
|
+
//# sourceMappingURL=fileLogger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileLogger.js","sourceRoot":"","sources":["../../src/logger/fileLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAeH;;GAEG;AACH,IAAY,YAGX;AAHD,WAAY,YAAY;IACpB,+CAAI,CAAA;IACJ,6CAAG,CAAA;AACP,CAAC,EAHW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAGvB;AAoBD,gCAAgC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\n\n/**\n * Contract for logger that writes telemetry to a file\n * @internal\n */\nexport interface IFileLogger extends ITelemetryBaseLogger {\n /**\n * This method acts as a \"dispose\" and should be explicitly called at the end of execution\n */\n close(): Promise<void>;\n}\n\n/**\n * Desired output format for the telemetry\n */\nexport enum OutputFormat {\n JSON,\n CSV,\n}\n\n/* eslint-disable tsdoc/syntax */\n/**\n * Options to provide upon creation of IFileLogger\n * @internal\n */\nexport interface ITelemetryOptions {\n /** Desired output format used to create a specific IFileLogger implementation */\n outputFormat?: OutputFormat;\n\n /**\n * Properties that should be added to every telemetry event\n * Example: { \"prop1\": \"value1\", \"prop2\": 10.0 }\n */\n defaultProps?: Record<string, string | number>;\n\n /** Number of telemetry events per flush to telemetry file */\n eventsPerFlush?: number;\n}\n/* eslint-enable tsdoc/syntax */\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { BaseFileLogger } from "./baseFileLogger";
|
|
6
|
+
/**
|
|
7
|
+
* FileLogger that writes events into a defined CSV file
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare class JSONFileLogger extends BaseFileLogger {
|
|
11
|
+
constructor(filePath: string, eventsPerFlush?: number, defaultProps?: Record<string, string | number>);
|
|
12
|
+
close(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=jsonFileLogger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonFileLogger.d.ts","sourceRoot":"","sources":["../../src/logger/jsonFileLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;GAGG;AACH,qBAAa,cAAe,SAAQ,cAAc;gBAE1C,QAAQ,EAAE,MAAM,EAChB,cAAc,GAAE,MAAW,EAC3B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IAMrC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAItC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.JSONFileLogger = void 0;
|
|
27
|
+
const fs = __importStar(require("fs"));
|
|
28
|
+
const baseFileLogger_1 = require("./baseFileLogger");
|
|
29
|
+
/**
|
|
30
|
+
* FileLogger that writes events into a defined CSV file
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
class JSONFileLogger extends baseFileLogger_1.BaseFileLogger {
|
|
34
|
+
constructor(filePath, eventsPerFlush = 50, defaultProps) {
|
|
35
|
+
super(filePath, eventsPerFlush, defaultProps);
|
|
36
|
+
fs.appendFileSync(this.filePath, "[");
|
|
37
|
+
}
|
|
38
|
+
async close() {
|
|
39
|
+
await super.close();
|
|
40
|
+
fs.appendFileSync(this.filePath, "]");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.JSONFileLogger = JSONFileLogger;
|
|
44
|
+
//# sourceMappingURL=jsonFileLogger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonFileLogger.js","sourceRoot":"","sources":["../../src/logger/jsonFileLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,qDAAkD;AAElD;;;GAGG;AACH,MAAa,cAAe,SAAQ,+BAAc;IAC9C,YACI,QAAgB,EAChB,iBAAyB,EAAE,EAC3B,YAA8C;QAE9C,KAAK,CAAC,QAAQ,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;QAC9C,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC;IAEM,KAAK,CAAC,KAAK;QACd,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;QACpB,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC;CACJ;AAdD,wCAcC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as fs from \"fs\";\nimport { BaseFileLogger } from \"./baseFileLogger\";\n\n/**\n * FileLogger that writes events into a defined CSV file\n * @internal\n */\nexport class JSONFileLogger extends BaseFileLogger {\n constructor(\n filePath: string,\n eventsPerFlush: number = 50,\n defaultProps?: Record<string, string | number>,\n ) {\n super(filePath, eventsPerFlush, defaultProps);\n fs.appendFileSync(this.filePath, \"[\");\n }\n\n public async close(): Promise<void> {\n await super.close();\n fs.appendFileSync(this.filePath, \"]\");\n }\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
6
|
+
import { IFileLogger, ITelemetryOptions } from "./fileLogger";
|
|
7
|
+
/**
|
|
8
|
+
* Create a ITelemetryLogger wrapped around provided IFileLogger
|
|
9
|
+
* ! It is expected that all events be sent through the returned "logger" value
|
|
10
|
+
* ! The "fileLogger" value should have its "close()" method called at the end of execution
|
|
11
|
+
* Note: if an output format is not supplied, default is JSON
|
|
12
|
+
* @returns - both the IFileLogger implementation and ITelemetryLogger wrapper to be called
|
|
13
|
+
*/
|
|
14
|
+
export declare function createLogger(filePath: string, options?: ITelemetryOptions): {
|
|
15
|
+
logger: ITelemetryLogger;
|
|
16
|
+
fileLogger: IFileLogger;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Validate the telemetryFile command line argument
|
|
20
|
+
* @param telemetryFile - path where telemetry will be written
|
|
21
|
+
*/
|
|
22
|
+
export declare function getTelemetryFileValidationError(telemetryFile: string): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Validate the provided output format and default properties
|
|
25
|
+
* @param format - desired output format of the telemetry
|
|
26
|
+
* @param props - default properties to be added to every telemetry entry
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export declare function validateAndParseTelemetryOptions(format?: string, props?: (string | number)[]): {
|
|
30
|
+
success: false;
|
|
31
|
+
error: string;
|
|
32
|
+
} | {
|
|
33
|
+
success: true;
|
|
34
|
+
telemetryOptions: ITelemetryOptions;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=loggerUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loggerUtils.d.ts","sourceRoot":"","sources":["../../src/logger/loggerUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGtE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAgB,MAAM,cAAc,CAAC;AAG5E;;;;;;GAMG;AACF,wBAAgB,YAAY,CACzB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,iBAAiB,GAC5B;IAAE,MAAM,EAAE,gBAAgB,CAAC;IAAC,UAAU,EAAE,WAAW,CAAC;CAAE,CASxD;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQzF;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAC5C,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GAC5B;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;CAAE,GAAG;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,gBAAgB,EAAE,iBAAiB,CAAC;CAAE,CAwB9F"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.validateAndParseTelemetryOptions = exports.getTelemetryFileValidationError = exports.createLogger = void 0;
|
|
27
|
+
const fs = __importStar(require("fs"));
|
|
28
|
+
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
29
|
+
const csvFileLogger_1 = require("./csvFileLogger");
|
|
30
|
+
const fileLogger_1 = require("./fileLogger");
|
|
31
|
+
const jsonFileLogger_1 = require("./jsonFileLogger");
|
|
32
|
+
/**
|
|
33
|
+
* Create a ITelemetryLogger wrapped around provided IFileLogger
|
|
34
|
+
* ! It is expected that all events be sent through the returned "logger" value
|
|
35
|
+
* ! The "fileLogger" value should have its "close()" method called at the end of execution
|
|
36
|
+
* Note: if an output format is not supplied, default is JSON
|
|
37
|
+
* @returns - both the IFileLogger implementation and ITelemetryLogger wrapper to be called
|
|
38
|
+
*/
|
|
39
|
+
function createLogger(filePath, options) {
|
|
40
|
+
const fileLogger = (options === null || options === void 0 ? void 0 : options.outputFormat) === fileLogger_1.OutputFormat.CSV
|
|
41
|
+
? new csvFileLogger_1.CSVFileLogger(filePath, options === null || options === void 0 ? void 0 : options.eventsPerFlush, options === null || options === void 0 ? void 0 : options.defaultProps)
|
|
42
|
+
: new jsonFileLogger_1.JSONFileLogger(filePath, options === null || options === void 0 ? void 0 : options.eventsPerFlush, options === null || options === void 0 ? void 0 : options.defaultProps);
|
|
43
|
+
const logger = telemetry_utils_1.ChildLogger.create(fileLogger, "LocalSnapshotRunnerApp", { all: { Event_Time: () => Date.now() } });
|
|
44
|
+
return { logger, fileLogger };
|
|
45
|
+
}
|
|
46
|
+
exports.createLogger = createLogger;
|
|
47
|
+
/**
|
|
48
|
+
* Validate the telemetryFile command line argument
|
|
49
|
+
* @param telemetryFile - path where telemetry will be written
|
|
50
|
+
*/
|
|
51
|
+
function getTelemetryFileValidationError(telemetryFile) {
|
|
52
|
+
if (!telemetryFile) {
|
|
53
|
+
return "Telemetry file argument is missing.";
|
|
54
|
+
}
|
|
55
|
+
else if (fs.existsSync(telemetryFile)) {
|
|
56
|
+
return `Telemetry file already exists [${telemetryFile}].`;
|
|
57
|
+
}
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
exports.getTelemetryFileValidationError = getTelemetryFileValidationError;
|
|
61
|
+
/**
|
|
62
|
+
* Validate the provided output format and default properties
|
|
63
|
+
* @param format - desired output format of the telemetry
|
|
64
|
+
* @param props - default properties to be added to every telemetry entry
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
function validateAndParseTelemetryOptions(format, props) {
|
|
68
|
+
let outputFormat;
|
|
69
|
+
const defaultProps = {};
|
|
70
|
+
if (format) {
|
|
71
|
+
outputFormat = fileLogger_1.OutputFormat[format];
|
|
72
|
+
if (outputFormat === undefined) {
|
|
73
|
+
return { success: false, error: `Invalid telemetry format [${format}]` };
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (props && props.length > 0) {
|
|
77
|
+
if (props.length % 2 !== 0) {
|
|
78
|
+
return { success: false, error: `Invalid number of telemetry properties to add [${props.length}]` };
|
|
79
|
+
}
|
|
80
|
+
for (let i = 0; i < props.length; i += 2) {
|
|
81
|
+
if (typeof props[i] === "number") {
|
|
82
|
+
return { success: false, error: `Property name cannot be number at index [${i}] -> [${props[i]}]` };
|
|
83
|
+
}
|
|
84
|
+
defaultProps[props[i]] = props[i + 1];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return { success: true, telemetryOptions: { outputFormat, defaultProps } };
|
|
88
|
+
}
|
|
89
|
+
exports.validateAndParseTelemetryOptions = validateAndParseTelemetryOptions;
|
|
90
|
+
//# sourceMappingURL=loggerUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loggerUtils.js","sourceRoot":"","sources":["../../src/logger/loggerUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AAEzB,qEAA8D;AAC9D,mDAAgD;AAChD,6CAA4E;AAC5E,qDAAkD;AAElD;;;;;;GAMG;AACF,SAAgB,YAAY,CACzB,QAAgB,EAChB,OAA2B;IAE3B,MAAM,UAAU,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,MAAK,yBAAY,CAAC,GAAG;QACzD,CAAC,CAAC,IAAI,6BAAa,CAAC,QAAQ,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,cAAc,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,CAAC;QAC7E,CAAC,CAAC,IAAI,+BAAc,CAAC,QAAQ,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,cAAc,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,CAAC,CAAC;IAEnF,MAAM,MAAM,GAAG,6BAAW,CAAC,MAAM,CAAC,UAAU,EAAE,wBAAwB,EAClE,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IAE/C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AAClC,CAAC;AAZA,oCAYA;AAED;;;GAGG;AACH,SAAgB,+BAA+B,CAAC,aAAqB;IACjE,IAAI,CAAC,aAAa,EAAE;QAChB,OAAO,qCAAqC,CAAC;K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C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as fs from \"fs\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { ChildLogger } from \"@fluidframework/telemetry-utils\";\nimport { CSVFileLogger } from \"./csvFileLogger\";\nimport { IFileLogger, ITelemetryOptions, OutputFormat } from \"./fileLogger\";\nimport { JSONFileLogger } from \"./jsonFileLogger\";\n\n/**\n * Create a ITelemetryLogger wrapped around provided IFileLogger\n * ! It is expected that all events be sent through the returned \"logger\" value\n * ! The \"fileLogger\" value should have its \"close()\" method called at the end of execution\n * Note: if an output format is not supplied, default is JSON\n * @returns - both the IFileLogger implementation and ITelemetryLogger wrapper to be called\n */\n export function createLogger(\n filePath: string,\n options?: ITelemetryOptions,\n): { logger: ITelemetryLogger; fileLogger: IFileLogger; } {\n const fileLogger = options?.outputFormat === OutputFormat.CSV\n ? new CSVFileLogger(filePath, options?.eventsPerFlush, options?.defaultProps)\n : new JSONFileLogger(filePath, options?.eventsPerFlush, options?.defaultProps);\n\n const logger = ChildLogger.create(fileLogger, \"LocalSnapshotRunnerApp\",\n { all: { Event_Time: () => Date.now() } });\n\n return { logger, fileLogger };\n}\n\n/**\n * Validate the telemetryFile command line argument\n * @param telemetryFile - path where telemetry will be written\n */\nexport function getTelemetryFileValidationError(telemetryFile: string): string | undefined {\n if (!telemetryFile) {\n return \"Telemetry file argument is missing.\";\n } else if (fs.existsSync(telemetryFile)) {\n return `Telemetry file already exists [${telemetryFile}].`;\n }\n\n return undefined;\n}\n\n/**\n * Validate the provided output format and default properties\n * @param format - desired output format of the telemetry\n * @param props - default properties to be added to every telemetry entry\n * @internal\n */\nexport function validateAndParseTelemetryOptions(\n format?: string,\n props?: (string | number)[],\n): { success: false; error: string; } | { success: true; telemetryOptions: ITelemetryOptions; } {\n let outputFormat: OutputFormat | undefined;\n const defaultProps: Record<string, string | number> = {};\n\n if (format) {\n outputFormat = OutputFormat[format];\n if (outputFormat === undefined) {\n return { success: false, error: `Invalid telemetry format [${format}]` };\n }\n }\n\n if (props && props.length > 0) {\n if (props.length % 2 !== 0) {\n return { success: false, error: `Invalid number of telemetry properties to add [${props.length}]` };\n }\n for (let i = 0; i < props.length; i += 2) {\n if (typeof props[i] === \"number\") {\n return { success: false, error: `Property name cannot be number at index [${i}] -> [${props[i]}]` };\n }\n defaultProps[props[i]] = props[i + 1];\n }\n }\n\n return { success: true, telemetryOptions: { outputFormat, defaultProps } };\n}\n"]}
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { IExportFileResponse } from "./exportFile";
|
|
6
|
+
import { ITelemetryOptions } from "./logger/fileLogger";
|
|
6
7
|
/**
|
|
7
8
|
* Parse a provided JS bundle, execute code on Container based on ODSP snapshot, and write result to file
|
|
8
9
|
* @param codeLoader - path to provided JS bundle that implements ICodeLoaderBundle (see codeLoaderBundle.ts)
|
|
9
10
|
*/
|
|
10
|
-
export declare function parseBundleAndExportFile(codeLoader: string, inputFile: string, outputFile: string, telemetryFile: string, options?: string): Promise<IExportFileResponse>;
|
|
11
|
+
export declare function parseBundleAndExportFile(codeLoader: string, inputFile: string, outputFile: string, telemetryFile: string, options?: string, telemetryOptions?: ITelemetryOptions): Promise<IExportFileResponse>;
|
|
11
12
|
//# sourceMappingURL=parseBundleAndExportFile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseBundleAndExportFile.d.ts","sourceRoot":"","sources":["../src/parseBundleAndExportFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAA6B,mBAAmB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"parseBundleAndExportFile.d.ts","sourceRoot":"","sources":["../src/parseBundleAndExportFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAA6B,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAG9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAOxD;;;GAGG;AACH,wBAAsB,wBAAwB,CAC1C,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,MAAM,EAChB,gBAAgB,CAAC,EAAE,iBAAiB,GACrC,OAAO,CAAC,mBAAmB,CAAC,CAkD9B"}
|
|
@@ -29,22 +29,21 @@ const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
|
29
29
|
const codeLoaderBundle_1 = require("./codeLoaderBundle");
|
|
30
30
|
const exportFile_1 = require("./exportFile");
|
|
31
31
|
const getArgsValidationError_1 = require("./getArgsValidationError");
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const loggerUtils_1 = require("./logger/loggerUtils");
|
|
33
|
+
/* eslint-enable import/no-internal-modules */
|
|
34
34
|
const utils_1 = require("./utils");
|
|
35
35
|
const clientArgsValidationError = "Client_ArgsValidationError";
|
|
36
36
|
/**
|
|
37
37
|
* Parse a provided JS bundle, execute code on Container based on ODSP snapshot, and write result to file
|
|
38
38
|
* @param codeLoader - path to provided JS bundle that implements ICodeLoaderBundle (see codeLoaderBundle.ts)
|
|
39
39
|
*/
|
|
40
|
-
async function parseBundleAndExportFile(codeLoader, inputFile, outputFile, telemetryFile, options) {
|
|
41
|
-
const telemetryArgError = (0,
|
|
40
|
+
async function parseBundleAndExportFile(codeLoader, inputFile, outputFile, telemetryFile, options, telemetryOptions) {
|
|
41
|
+
const telemetryArgError = (0, loggerUtils_1.getTelemetryFileValidationError)(telemetryFile);
|
|
42
42
|
if (telemetryArgError) {
|
|
43
43
|
const eventName = clientArgsValidationError;
|
|
44
44
|
return { success: false, eventName, errorMessage: telemetryArgError };
|
|
45
45
|
}
|
|
46
|
-
const fileLogger =
|
|
47
|
-
const logger = (0, FileLogger_1.createLogger)(fileLogger);
|
|
46
|
+
const { fileLogger, logger } = (0, loggerUtils_1.createLogger)(telemetryFile, telemetryOptions);
|
|
48
47
|
try {
|
|
49
48
|
return await telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, { eventName: "ParseBundleAndExportFile" }, async () => {
|
|
50
49
|
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
@@ -78,7 +77,7 @@ async function parseBundleAndExportFile(codeLoader, inputFile, outputFile, telem
|
|
|
78
77
|
return { success: false, eventName, errorMessage: "Unexpected error", error };
|
|
79
78
|
}
|
|
80
79
|
finally {
|
|
81
|
-
await fileLogger.
|
|
80
|
+
await fileLogger.close();
|
|
82
81
|
}
|
|
83
82
|
}
|
|
84
83
|
exports.parseBundleAndExportFile = parseBundleAndExportFile;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseBundleAndExportFile.js","sourceRoot":"","sources":["../src/parseBundleAndExportFile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,qEAAmE;AACnE,yDAA8E;AAC9E,6CAA8E;AAC9E,qEAAkE;
|
|
1
|
+
{"version":3,"file":"parseBundleAndExportFile.js","sourceRoot":"","sources":["../src/parseBundleAndExportFile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,qEAAmE;AACnE,yDAA8E;AAC9E,6CAA8E;AAC9E,qEAAkE;AAGlE,sDAAqF;AACrF,8CAA8C;AAC9C,mCAAiD;AAEjD,MAAM,yBAAyB,GAAG,4BAA4B,CAAC;AAE/D;;;GAGG;AACI,KAAK,UAAU,wBAAwB,CAC1C,UAAkB,EAClB,SAAiB,EACjB,UAAkB,EAClB,aAAqB,EACrB,OAAgB,EAChB,gBAAoC;IAEpC,MAAM,iBAAiB,GAAG,IAAA,6CAA+B,EAAC,aAAa,CAAC,CAAC;IACzE,IAAI,iBAAiB,EAAE;QACnB,MAAM,SAAS,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M,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,mBAAmB,EAAE,CAAC,CAAC;gBACnE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,mBAAmB,EAAE,CAAC;aAC3E;YAED,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,MAAM,IAAA,sCAAyB,EACxD,IAAA,8BAAsB,EAAC,SAAS,CAAC,EACjC,WAAW,EACX,MAAM,EACN,OAAO,CACV,CAAC,CAAC;YAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC7B,CAAC,CAAC,CAAC;KACN;IAAC,OAAO,KAAK,EAAE;QACZ,MAAM,SAAS,GAAG,wBAAwB,CAAC;QAC3C,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,EAAE,KAAK,CAAC,CAAC;QAC5C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC;KACjF;YAAS;QACN,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;KAC5B;AACL,CAAC;AAzDD,4DAyDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as fs from \"fs\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { isCodeLoaderBundle, isFluidFileConverter } from \"./codeLoaderBundle\";\nimport { createContainerAndExecute, IExportFileResponse } from \"./exportFile\";\nimport { getArgsValidationError } from \"./getArgsValidationError\";\n/* eslint-disable import/no-internal-modules */\nimport { ITelemetryOptions } from \"./logger/fileLogger\";\nimport { createLogger, getTelemetryFileValidationError } from \"./logger/loggerUtils\";\n/* eslint-enable import/no-internal-modules */\nimport { getSnapshotFileContent } from \"./utils\";\n\nconst clientArgsValidationError = \"Client_ArgsValidationError\";\n\n/**\n * Parse a provided JS bundle, execute code on Container based on ODSP snapshot, and write result to file\n * @param codeLoader - path to provided JS bundle that implements ICodeLoaderBundle (see codeLoaderBundle.ts)\n */\nexport async function parseBundleAndExportFile(\n codeLoader: string,\n inputFile: string,\n outputFile: string,\n telemetryFile: string,\n options?: string,\n telemetryOptions?: ITelemetryOptions,\n): Promise<IExportFileResponse> {\n const telemetryArgError = getTelemetryFileValidationError(telemetryFile);\n if (telemetryArgError) {\n const eventName = clientArgsValidationError;\n return { success: false, eventName, errorMessage: telemetryArgError };\n }\n const { fileLogger, logger } = createLogger(telemetryFile, telemetryOptions);\n\n try {\n return await PerformanceEvent.timedExecAsync(logger, { eventName: \"ParseBundleAndExportFile\" }, async () => {\n // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires\n const codeLoaderBundle = require(codeLoader);\n if (!isCodeLoaderBundle(codeLoaderBundle)) {\n const eventName = clientArgsValidationError;\n const errorMessage = \"Code loader bundle is not of type ICodeLoaderBundle\";\n logger.sendErrorEvent({ eventName, message: errorMessage });\n return { success: false, eventName, errorMessage };\n }\n\n const fluidExport = await codeLoaderBundle.fluidExport;\n if (!isFluidFileConverter(fluidExport)) {\n const eventName = clientArgsValidationError;\n const errorMessage = \"Fluid export from CodeLoaderBundle is not of type IFluidFileConverter\";\n logger.sendErrorEvent({ eventName, message: errorMessage });\n return { success: false, eventName, errorMessage };\n }\n\n const argsValidationError = getArgsValidationError(inputFile, outputFile);\n if (argsValidationError) {\n const eventName = clientArgsValidationError;\n logger.sendErrorEvent({ eventName, message: argsValidationError });\n return { success: false, eventName, errorMessage: argsValidationError };\n }\n\n fs.writeFileSync(outputFile, await createContainerAndExecute(\n getSnapshotFileContent(inputFile),\n fluidExport,\n logger,\n options,\n ));\n\n return { success: true };\n });\n } catch (error) {\n const eventName = \"Client_UnexpectedError\";\n logger.sendErrorEvent({ eventName }, error);\n return { success: false, eventName, errorMessage: \"Unexpected error\", error };\n } finally {\n await fileLogger.close();\n }\n}\n"]}
|
package/dist/utils.d.ts
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
/// <reference types="node" />
|
|
6
|
+
import { IFluidFileConverter } from "./codeLoaderBundle";
|
|
6
7
|
/**
|
|
7
8
|
* Is the given snapshot in JSON format
|
|
8
9
|
* @param content - snapshot file content
|
|
10
|
+
* @internal
|
|
9
11
|
*/
|
|
10
12
|
export declare function isJsonSnapshot(content: Buffer): boolean;
|
|
11
13
|
/**
|
|
@@ -14,4 +16,9 @@ export declare function isJsonSnapshot(content: Buffer): boolean;
|
|
|
14
16
|
* @param filePath - path to the ODSP snapshot file
|
|
15
17
|
*/
|
|
16
18
|
export declare function getSnapshotFileContent(filePath: string): string | Buffer;
|
|
19
|
+
/**
|
|
20
|
+
* Validate provided command line arguments
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export declare function validateCommandLineArgs(codeLoader?: string, fluidFileConverter?: IFluidFileConverter): string | undefined;
|
|
17
24
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAIxE;AAED;;;GAGG;AACF,wBAAgB,uBAAuB,CACpC,UAAU,CAAC,EAAE,MAAM,EACnB,kBAAkB,CAAC,EAAE,mBAAmB,GACzC,MAAM,GAAG,SAAS,CASpB"}
|
package/dist/utils.js
CHANGED
|
@@ -23,11 +23,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getSnapshotFileContent = exports.isJsonSnapshot = void 0;
|
|
26
|
+
exports.validateCommandLineArgs = exports.getSnapshotFileContent = exports.isJsonSnapshot = void 0;
|
|
27
27
|
const fs = __importStar(require("fs"));
|
|
28
28
|
/**
|
|
29
29
|
* Is the given snapshot in JSON format
|
|
30
30
|
* @param content - snapshot file content
|
|
31
|
+
* @internal
|
|
31
32
|
*/
|
|
32
33
|
function isJsonSnapshot(content) {
|
|
33
34
|
return content.toString(undefined, 0, 1) === "{";
|
|
@@ -44,4 +45,19 @@ function getSnapshotFileContent(filePath) {
|
|
|
44
45
|
return isJsonSnapshot(content) ? content.toString() : content;
|
|
45
46
|
}
|
|
46
47
|
exports.getSnapshotFileContent = getSnapshotFileContent;
|
|
48
|
+
/**
|
|
49
|
+
* Validate provided command line arguments
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
function validateCommandLineArgs(codeLoader, fluidFileConverter) {
|
|
53
|
+
if (codeLoader && fluidFileConverter !== undefined) {
|
|
54
|
+
return "\"codeLoader\" and \"fluidFileConverter\" cannot both be provided. See README for details.";
|
|
55
|
+
}
|
|
56
|
+
if (!codeLoader && fluidFileConverter === undefined) {
|
|
57
|
+
// eslint-disable-next-line max-len
|
|
58
|
+
return "\"codeLoader\" must be provided if there is no explicit \"fluidFileConverter\". See README for details.";
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
exports.validateCommandLineArgs = validateCommandLineArgs;
|
|
47
63
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AAGzB;;;;GAIG;AACH,SAAgB,cAAc,CAAC,OAAe;IAC1C,OAAO,OAAO,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC;AACrD,CAAC;AAFD,wCAEC;AAED;;;;GAIG;AACH,SAAgB,sBAAsB,CAAC,QAAgB;IACnD,yBAAyB;IACzB,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC1C,OAAO,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;AAClE,CAAC;AAJD,wDAIC;AAED;;;GAGG;AACF,SAAgB,uBAAuB,CACpC,UAAmB,EACnB,kBAAwC;IAExC,IAAI,UAAU,IAAI,kBAAkB,KAAK,SAAS,EAAE;QAChD,OAAO,4FAA4F,CAAC;KACvG;IACD,IAAI,CAAC,UAAU,IAAI,kBAAkB,KAAK,SAAS,EAAE;QACjD,mCAAmC;QACnC,OAAO,yGAAyG,CAAC;KACpH;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAZA,0DAYA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as fs from \"fs\";\nimport { IFluidFileConverter } from \"./codeLoaderBundle\";\n\n/**\n * Is the given snapshot in JSON format\n * @param content - snapshot file content\n * @internal\n */\nexport function isJsonSnapshot(content: Buffer): boolean {\n return content.toString(undefined, 0, 1) === \"{\";\n}\n\n/**\n * Get the ODSP snapshot file content\n * Works on both JSON and binary snapshot formats\n * @param filePath - path to the ODSP snapshot file\n */\nexport function getSnapshotFileContent(filePath: string): string | Buffer {\n // TODO: read file stream\n const content = fs.readFileSync(filePath);\n return isJsonSnapshot(content) ? content.toString() : content;\n}\n\n/**\n * Validate provided command line arguments\n * @internal\n */\n export function validateCommandLineArgs(\n codeLoader?: string,\n fluidFileConverter?: IFluidFileConverter,\n): string | undefined {\n if (codeLoader && fluidFileConverter !== undefined) {\n return \"\\\"codeLoader\\\" and \\\"fluidFileConverter\\\" cannot both be provided. See README for details.\";\n }\n if (!codeLoader && fluidFileConverter === undefined) {\n // eslint-disable-next-line max-len\n return \"\\\"codeLoader\\\" must be provided if there is no explicit \\\"fluidFileConverter\\\". See README for details.\";\n }\n return undefined;\n}\n"]}
|
package/lib/exportFile.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
6
6
|
import { IFluidFileConverter } from "./codeLoaderBundle";
|
|
7
|
+
import { ITelemetryOptions } from "./logger/fileLogger";
|
|
7
8
|
export declare type IExportFileResponse = IExportFileResponseSuccess | IExportFileResponseFailure;
|
|
8
9
|
interface IExportFileResponseSuccess {
|
|
9
10
|
success: true;
|
|
@@ -17,7 +18,7 @@ interface IExportFileResponseFailure {
|
|
|
17
18
|
/**
|
|
18
19
|
* Execute code on Container based on ODSP snapshot and write result to file
|
|
19
20
|
*/
|
|
20
|
-
export declare function exportFile(fluidFileConverter: IFluidFileConverter, inputFile: string, outputFile: string, telemetryFile: string, options?: string): Promise<IExportFileResponse>;
|
|
21
|
+
export declare function exportFile(fluidFileConverter: IFluidFileConverter, inputFile: string, outputFile: string, telemetryFile: string, options?: string, telemetryOptions?: ITelemetryOptions): Promise<IExportFileResponse>;
|
|
21
22
|
/**
|
|
22
23
|
* Create the container based on an ODSP snapshot and execute code on it
|
|
23
24
|
* @returns result of execution
|
package/lib/exportFile.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exportFile.d.ts","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAMtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"exportFile.d.ts","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAMtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAIzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAIxD,oBAAY,mBAAmB,GAAG,0BAA0B,GAAG,0BAA0B,CAAC;AAE1F,UAAU,0BAA0B;IAChC,OAAO,EAAE,IAAI,CAAC;CACjB;AAED,UAAU,0BAA0B;IAChC,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,GAAG,CAAC;CACf;AAID;;GAEG;AACH,wBAAsB,UAAU,CAC5B,kBAAkB,EAAE,mBAAmB,EACvC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,MAAM,EAChB,gBAAgB,CAAC,EAAE,iBAAiB,GACrC,OAAO,CAAC,mBAAmB,CAAC,CAiC9B;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,CAC3C,iBAAiB,EAAE,MAAM,GAAG,UAAU,EACtC,kBAAkB,EAAE,mBAAmB,EACvC,MAAM,EAAE,gBAAgB,EACxB,OAAO,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,CAcjB"}
|
package/lib/exportFile.js
CHANGED
|
@@ -10,20 +10,18 @@ import { PerformanceEvent } from "@fluidframework/telemetry-utils";
|
|
|
10
10
|
import { getArgsValidationError } from "./getArgsValidationError";
|
|
11
11
|
import { FakeUrlResolver } from "./fakeUrlResolver";
|
|
12
12
|
import { getSnapshotFileContent } from "./utils";
|
|
13
|
-
|
|
14
|
-
import { createLogger, FileLogger, getTelemetryFileValidationError } from "./logger/FileLogger";
|
|
13
|
+
import { createLogger, getTelemetryFileValidationError } from "./logger/loggerUtils";
|
|
15
14
|
const clientArgsValidationError = "Client_ArgsValidationError";
|
|
16
15
|
/**
|
|
17
16
|
* Execute code on Container based on ODSP snapshot and write result to file
|
|
18
17
|
*/
|
|
19
|
-
export async function exportFile(fluidFileConverter, inputFile, outputFile, telemetryFile, options) {
|
|
18
|
+
export async function exportFile(fluidFileConverter, inputFile, outputFile, telemetryFile, options, telemetryOptions) {
|
|
20
19
|
const telemetryArgError = getTelemetryFileValidationError(telemetryFile);
|
|
21
20
|
if (telemetryArgError) {
|
|
22
21
|
const eventName = clientArgsValidationError;
|
|
23
22
|
return { success: false, eventName, errorMessage: telemetryArgError };
|
|
24
23
|
}
|
|
25
|
-
const fileLogger =
|
|
26
|
-
const logger = createLogger(fileLogger);
|
|
24
|
+
const { fileLogger, logger } = createLogger(telemetryFile, telemetryOptions);
|
|
27
25
|
try {
|
|
28
26
|
return await PerformanceEvent.timedExecAsync(logger, { eventName: "ExportFile" }, async () => {
|
|
29
27
|
const argsValidationError = getArgsValidationError(inputFile, outputFile);
|
|
@@ -42,7 +40,7 @@ export async function exportFile(fluidFileConverter, inputFile, outputFile, tele
|
|
|
42
40
|
return { success: false, eventName, errorMessage: "Unexpected error", error };
|
|
43
41
|
}
|
|
44
42
|
finally {
|
|
45
|
-
await fileLogger.
|
|
43
|
+
await fileLogger.close();
|
|
46
44
|
}
|
|
47
45
|
}
|
|
48
46
|
/**
|
package/lib/exportFile.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exportFile.js","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CA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AuC,EACvC,MAAwB,EACxB,OAAgB;IAEhB,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;QACtB,WAAW,EAAE,IAAI,eAAe,EAAE;QAClC,sBAAsB,EAAE,qCAAqC,CAAC,iBAAiB,CAAC;QAChF,UAAU,EAAE,MAAM,kBAAkB,CAAC,aAAa,CAAC,MAAM,CAAC;QAC1D,KAAK,EAAE,kBAAkB,CAAC,KAAK;QAC/B,MAAM;KACT,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE;YAChE,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,EAAE,eAAe,EAAE,QAAQ,EAAE;SAAE,EAAE,CAAC,CAAC;IAEhE,OAAO,gBAAgB,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,KAAK,IAAI,EAAE,CACnF,kBAAkB,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;AACxD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as fs from \"fs\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { LoaderHeader } from \"@fluidframework/container-definitions\";\nimport { Loader } from \"@fluidframework/container-loader\";\nimport { createLocalOdspDocumentServiceFactory } from \"@fluidframework/odsp-driver\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { getArgsValidationError } from \"./getArgsValidationError\";\nimport { IFluidFileConverter } from \"./codeLoaderBundle\";\nimport { FakeUrlResolver } from \"./fakeUrlResolver\";\nimport { getSnapshotFileContent } from \"./utils\";\n/* eslint-disable import/no-internal-modules */\nimport { ITelemetryOptions } from \"./logger/fileLogger\";\nimport { createLogger, getTelemetryFileValidationError } from \"./logger/loggerUtils\";\n/* eslint-enable import/no-internal-modules */\n\nexport type IExportFileResponse = IExportFileResponseSuccess | IExportFileResponseFailure;\n\ninterface IExportFileResponseSuccess {\n success: true;\n}\n\ninterface IExportFileResponseFailure {\n success: false;\n eventName: string;\n errorMessage: string;\n error?: any;\n}\n\nconst clientArgsValidationError = \"Client_ArgsValidationError\";\n\n/**\n * Execute code on Container based on ODSP snapshot and write result to file\n */\nexport async function exportFile(\n fluidFileConverter: IFluidFileConverter,\n inputFile: string,\n outputFile: string,\n telemetryFile: string,\n options?: string,\n telemetryOptions?: ITelemetryOptions,\n): Promise<IExportFileResponse> {\n const telemetryArgError = getTelemetryFileValidationError(telemetryFile);\n if (telemetryArgError) {\n const eventName = clientArgsValidationError;\n return { success: false, eventName, errorMessage: telemetryArgError };\n }\n const { fileLogger, logger } = createLogger(telemetryFile, telemetryOptions);\n\n try {\n return await PerformanceEvent.timedExecAsync(logger, { eventName: \"ExportFile\" }, async () => {\n const argsValidationError = getArgsValidationError(inputFile, outputFile);\n if (argsValidationError) {\n const eventName = clientArgsValidationError;\n logger.sendErrorEvent({ eventName, message: argsValidationError });\n return { success: false, eventName, errorMessage: argsValidationError };\n }\n\n fs.writeFileSync(outputFile, await createContainerAndExecute(\n getSnapshotFileContent(inputFile),\n fluidFileConverter,\n logger,\n options,\n ));\n\n return { success: true };\n });\n } catch (error) {\n const eventName = \"Client_UnexpectedError\";\n logger.sendErrorEvent({ eventName }, error);\n return { success: false, eventName, errorMessage: \"Unexpected error\", error };\n } finally {\n await fileLogger.close();\n }\n}\n\n/**\n * Create the container based on an ODSP snapshot and execute code on it\n * @returns result of execution\n */\nexport async function createContainerAndExecute(\n localOdspSnapshot: string | Uint8Array,\n fluidFileConverter: IFluidFileConverter,\n logger: ITelemetryLogger,\n options?: string,\n): Promise<string> {\n const loader = new Loader({\n urlResolver: new FakeUrlResolver(),\n documentServiceFactory: createLocalOdspDocumentServiceFactory(localOdspSnapshot),\n codeLoader: await fluidFileConverter.getCodeLoader(logger),\n scope: fluidFileConverter.scope,\n logger,\n });\n\n const container = await loader.resolve({ url: \"/fakeUrl/\", headers: {\n [LoaderHeader.loadMode]: { opsBeforeReturn: \"cached\" } } });\n\n return PerformanceEvent.timedExecAsync(logger, { eventName: \"ExportFile\" }, async () =>\n fluidFileConverter.execute(container, options));\n}\n"]}
|
package/lib/fakeUrlResolver.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { IRequest } from "@fluidframework/core-interfaces";
|
|
|
6
6
|
import { IContainerPackageInfo, IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions";
|
|
7
7
|
/**
|
|
8
8
|
* Fake URL resolver that returns hard coded values on every request
|
|
9
|
+
* @internal
|
|
9
10
|
*/
|
|
10
11
|
export declare class FakeUrlResolver implements IUrlResolver {
|
|
11
12
|
resolve(_request: IRequest): Promise<IResolvedUrl | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fakeUrlResolver.d.ts","sourceRoot":"","sources":["../src/fakeUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAMvG
|
|
1
|
+
{"version":3,"file":"fakeUrlResolver.d.ts","sourceRoot":"","sources":["../src/fakeUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAMvG;;;GAGG;AACH,qBAAa,eAAgB,YAAW,YAAY;IACnC,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IAyB9D,cAAc,CACvB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,MAAM,EACpB,kBAAkB,CAAC,EAAE,qBAAqB,GAC3C,OAAO,CAAC,MAAM,CAAC;CAGrB"}
|
package/lib/fakeUrlResolver.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fakeUrlResolver.js","sourceRoot":"","sources":["../src/fakeUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,MAAM,GAAG,iBAAiB,CAAC;AACjC,MAAM,OAAO,GAAG,mBAAmB,CAAC;AAEpC
|
|
1
|
+
{"version":3,"file":"fakeUrlResolver.js","sourceRoot":"","sources":["../src/fakeUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,MAAM,GAAG,iBAAiB,CAAC;AACjC,MAAM,OAAO,GAAG,mBAAmB,CAAC;AAEpC;;;GAGG;AACH,MAAM,OAAO,eAAe;IACjB,KAAK,CAAC,OAAO,CAAC,QAAkB;QACnC,MAAM,mBAAmB,GAAqB;YAC1C,IAAI,EAAE,OAAO;YACb,eAAe,EAAE,IAAI;YACrB,EAAE,EAAE,MAAM;YACV,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE,MAAM;YACf,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,OAAO;YACZ,gBAAgB,EAAE,MAAM;YACxB,SAAS,EAAE;gBACP,kBAAkB,EAAE,OAAO;gBAC3B,wBAAwB,EAAE,OAAO;gBACjC,uBAAuB,EAAE,OAAO;gBAChC,eAAe,EAAE,OAAO;aAC3B;YACD,MAAM,EAAE,EAAE;YACV,QAAQ,EAAE,MAAM;YAChB,UAAU,EAAE,KAAK;YACjB,WAAW,EAAE,MAAM;SACtB,CAAC;QAEF,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEM,KAAK,CAAC,cAAc,CACvB,YAA0B,EAC1B,YAAoB,EACpB,kBAA0C;QAE1C,OAAO,EAAE,CAAC;IACd,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { IContainerPackageInfo, IResolvedUrl, IUrlResolver } from \"@fluidframework/driver-definitions\";\nimport { IOdspResolvedUrl } from \"@fluidframework/odsp-driver-definitions\";\n\nconst fakeId = \"FakeUrlResolver\";\nconst fakeUrl = \"/FakeUrlResolver/\";\n\n/**\n * Fake URL resolver that returns hard coded values on every request\n * @internal\n */\nexport class FakeUrlResolver implements IUrlResolver {\n public async resolve(_request: IRequest): Promise<IResolvedUrl | undefined> {\n const fakeOdspResolvedUrl: IOdspResolvedUrl = {\n type: \"fluid\",\n odspResolvedUrl: true,\n id: fakeId,\n siteUrl: fakeUrl,\n driveId: fakeId,\n itemId: fakeId,\n url: fakeUrl,\n hashedDocumentId: fakeId,\n endpoints: {\n snapshotStorageUrl: fakeUrl,\n attachmentPOSTStorageUrl: fakeUrl,\n attachmentGETStorageUrl: fakeUrl,\n deltaStorageUrl: fakeUrl,\n },\n tokens: {},\n fileName: fakeId,\n summarizer: false,\n fileVersion: fakeId,\n };\n\n return fakeOdspResolvedUrl;\n }\n\n public async getAbsoluteUrl(\n _resolvedUrl: IResolvedUrl,\n _relativeUrl: string,\n _packageInfoSource?: IContainerPackageInfo,\n ): Promise<string> {\n return \"\";\n }\n}\n"]}
|
package/lib/fluidRunner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluidRunner.d.ts","sourceRoot":"","sources":["../src/fluidRunner.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"fluidRunner.d.ts","sourceRoot":"","sources":["../src/fluidRunner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAMzD;;GAEG;AACH,wBAAgB,WAAW,CAAC,kBAAkB,CAAC,EAAE,mBAAmB,QAqFnE"}
|
package/lib/fluidRunner.js
CHANGED
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
+
/* eslint-disable max-len */
|
|
5
6
|
import * as yargs from "yargs";
|
|
6
7
|
import { exportFile } from "./exportFile";
|
|
7
8
|
import { parseBundleAndExportFile } from "./parseBundleAndExportFile";
|
|
9
|
+
// eslint-disable-next-line import/no-internal-modules
|
|
10
|
+
import { validateAndParseTelemetryOptions } from "./logger/loggerUtils";
|
|
11
|
+
import { validateCommandLineArgs } from "./utils";
|
|
8
12
|
/**
|
|
9
13
|
* @param fluidFileConverter - needs to be provided if "codeLoaderBundle" is not and vice versa
|
|
10
14
|
*/
|
|
@@ -17,7 +21,6 @@ export function fluidRunner(fluidFileConverter) {
|
|
|
17
21
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
18
22
|
(yargs) => yargs
|
|
19
23
|
.option("codeLoader", {
|
|
20
|
-
// eslint-disable-next-line max-len
|
|
21
24
|
describe: "Path to code loader bundle. Required if this application is being called without modification.\nSee \"README.md\" for more details.",
|
|
22
25
|
type: "string",
|
|
23
26
|
demandOption: false,
|
|
@@ -41,16 +44,32 @@ export function fluidRunner(fluidFileConverter) {
|
|
|
41
44
|
describe: "Additional options passed to container on execution",
|
|
42
45
|
type: "string",
|
|
43
46
|
demandOption: false,
|
|
47
|
+
})
|
|
48
|
+
.option("telemetryFormat", {
|
|
49
|
+
describe: "Output format for telemetry. Current options are: [\"JSON\", \"CSV\"]",
|
|
50
|
+
type: "string",
|
|
51
|
+
demandOption: false,
|
|
52
|
+
default: "JSON",
|
|
53
|
+
})
|
|
54
|
+
.option("telemetryProp", {
|
|
55
|
+
describe: "Property to add to every telemetry entry. Formatted like \"--telemetryProp prop1 value1 --telemetryProp prop2 \\\"value 2\\\"\".",
|
|
56
|
+
type: "array",
|
|
57
|
+
demandOption: false,
|
|
44
58
|
}),
|
|
45
59
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
46
60
|
async (argv) => {
|
|
47
|
-
const argsError =
|
|
61
|
+
const argsError = validateCommandLineArgs(argv.codeLoader, fluidFileConverter);
|
|
48
62
|
if (argsError) {
|
|
49
63
|
console.error(argsError);
|
|
50
64
|
process.exit(1);
|
|
51
65
|
}
|
|
66
|
+
const telemetryOptionsResult = validateAndParseTelemetryOptions(argv.telemetryFormat, argv.telemetryProp);
|
|
67
|
+
if (!telemetryOptionsResult.success) {
|
|
68
|
+
console.error(telemetryOptionsResult.error);
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
52
71
|
const result = await (argv.codeLoader
|
|
53
|
-
? parseBundleAndExportFile(argv.codeLoader, argv.inputFile, argv.outputFile, argv.telemetryFile, argv.options) : exportFile(fluidFileConverter, argv.inputFile, argv.outputFile, argv.telemetryFile, argv.options));
|
|
72
|
+
? parseBundleAndExportFile(argv.codeLoader, argv.inputFile, argv.outputFile, argv.telemetryFile, argv.options, telemetryOptionsResult.telemetryOptions) : exportFile(fluidFileConverter, argv.inputFile, argv.outputFile, argv.telemetryFile, argv.options, telemetryOptionsResult.telemetryOptions));
|
|
54
73
|
if (!result.success) {
|
|
55
74
|
console.error(`${result.eventName}: ${result.errorMessage}`);
|
|
56
75
|
process.exit(1);
|
|
@@ -59,15 +78,6 @@ export function fluidRunner(fluidFileConverter) {
|
|
|
59
78
|
.help()
|
|
60
79
|
.demandCommand().argv;
|
|
61
80
|
}
|
|
62
|
-
function validateProvidedArgs(codeLoader, fluidFileConverter) {
|
|
63
|
-
if (codeLoader !== undefined && fluidFileConverter !== undefined) {
|
|
64
|
-
return "\"codeLoader\" and \"fluidFileConverter\" cannot both be provided. See \"fluidRunner.ts\" for details.";
|
|
65
|
-
}
|
|
66
|
-
if (codeLoader === undefined && fluidFileConverter === undefined) {
|
|
67
|
-
// eslint-disable-next-line max-len
|
|
68
|
-
return "\"codeLoader\" must be provided if there is no explicit \"fluidFileConverter\". See \"fluidRunner.ts\" for details.";
|
|
69
|
-
}
|
|
70
|
-
return undefined;
|
|
71
|
-
}
|
|
72
81
|
fluidRunner();
|
|
82
|
+
/* eslint-enable max-len */
|
|
73
83
|
//# sourceMappingURL=fluidRunner.js.map
|