@fluidframework/fluid-runner 2.0.0-internal.1.1.0 → 2.0.0-internal.1.1.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 +25 -2
- package/bin/{fluidRunner → fluid-runner} +0 -0
- package/dist/codeLoaderBundle.d.ts +6 -7
- package/dist/codeLoaderBundle.d.ts.map +1 -1
- package/dist/codeLoaderBundle.js +1 -1
- package/dist/codeLoaderBundle.js.map +1 -1
- package/dist/exportFile.d.ts +9 -2
- package/dist/exportFile.d.ts.map +1 -1
- package/dist/exportFile.js +28 -30
- package/dist/exportFile.js.map +1 -1
- package/dist/fluidRunner.d.ts +5 -1
- package/dist/fluidRunner.d.ts.map +1 -1
- package/dist/fluidRunner.js +39 -26
- package/dist/fluidRunner.js.map +1 -1
- package/dist/getArgsValidationError.d.ts +1 -1
- package/dist/getArgsValidationError.d.ts.map +1 -1
- package/dist/getArgsValidationError.js +6 -10
- package/dist/getArgsValidationError.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/logger/FileLogger.d.ts +11 -1
- package/dist/logger/FileLogger.d.ts.map +1 -1
- package/dist/logger/FileLogger.js +24 -1
- package/dist/logger/FileLogger.js.map +1 -1
- package/dist/parseBundleAndExportFile.d.ts +11 -0
- package/dist/parseBundleAndExportFile.d.ts.map +1 -0
- package/dist/parseBundleAndExportFile.js +85 -0
- package/dist/parseBundleAndExportFile.js.map +1 -0
- package/dist/utils.d.ts +17 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +47 -0
- package/dist/utils.js.map +1 -0
- package/lib/codeLoaderBundle.d.ts +6 -7
- package/lib/codeLoaderBundle.d.ts.map +1 -1
- package/lib/codeLoaderBundle.js +1 -1
- package/lib/codeLoaderBundle.js.map +1 -1
- package/lib/exportFile.d.ts +9 -2
- package/lib/exportFile.d.ts.map +1 -1
- package/lib/exportFile.js +28 -27
- package/lib/exportFile.js.map +1 -1
- package/lib/fluidRunner.d.ts +5 -1
- package/lib/fluidRunner.d.ts.map +1 -1
- package/lib/fluidRunner.js +37 -26
- package/lib/fluidRunner.js.map +1 -1
- package/lib/getArgsValidationError.d.ts +1 -1
- package/lib/getArgsValidationError.d.ts.map +1 -1
- package/lib/getArgsValidationError.js +6 -10
- package/lib/getArgsValidationError.js.map +1 -1
- package/lib/index.d.ts +4 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/lib/logger/FileLogger.d.ts +11 -1
- package/lib/logger/FileLogger.d.ts.map +1 -1
- package/lib/logger/FileLogger.js +21 -0
- package/lib/logger/FileLogger.js.map +1 -1
- package/lib/parseBundleAndExportFile.d.ts +11 -0
- package/lib/parseBundleAndExportFile.d.ts.map +1 -0
- package/lib/parseBundleAndExportFile.js +62 -0
- package/lib/parseBundleAndExportFile.js.map +1 -0
- package/lib/utils.d.ts +17 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +23 -0
- package/lib/utils.js.map +1 -0
- package/package.json +11 -11
- package/src/codeLoaderBundle.ts +8 -9
- package/src/exportFile.ts +38 -40
- package/src/fluidRunner.ts +54 -35
- package/src/getArgsValidationError.ts +6 -12
- package/src/index.ts +5 -1
- package/src/logger/FileLogger.ts +25 -1
- package/src/parseBundleAndExportFile.ts +78 -0
- package/src/utils.ts +25 -0
package/README.md
CHANGED
|
@@ -6,15 +6,38 @@ Allows some execution to be made on a container given a provided ODSP snapshot.
|
|
|
6
6
|
|
|
7
7
|
### Sample command
|
|
8
8
|
If package is installed globally:
|
|
9
|
-
`node fluid-runner exportFile --codeLoader=compiledBundle.js --inputFile=inputFileName.fluid --
|
|
9
|
+
`node fluid-runner exportFile --codeLoader=compiledBundle.js --inputFile=inputFileName.fluid --outputFile=result.txt --telemetryFile=telemetryFile.txt`
|
|
10
10
|
|
|
11
11
|
If working directly on this package:
|
|
12
|
-
|
|
12
|
+
```node bin/fluid-runner exportFile --codeLoader=compiledBundle.js --inputFile=inputFileName.fluid --outputFile=result.txt --telemetryFile=telemetryFile.txt```
|
|
13
13
|
|
|
14
14
|
### Code Loader bundle format
|
|
15
15
|
The Code Loader bundle should provide defined exports required for this functionality.
|
|
16
16
|
For more details on what exports are needed, see [codeLoaderBundle.ts](./src/codeLoaderBundle.ts).
|
|
17
17
|
|
|
18
|
+
#### "codeLoader" vs "IFluidFileConverter" argument
|
|
19
|
+
You may notice the command line argument `codeLoader` is optional. If you choose not to provide a value for `codeLoader`, you must extend this library
|
|
20
|
+
and provide a [`IFluidFileConverter`](./src/codeLoaderBundle.ts) implementation to the [`fluidRunner(...)`](./src/fluidRunner.ts) method.
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
import { fluidRunner } from "@fluidframework/fluid-runner";
|
|
24
|
+
|
|
25
|
+
fluidRunner({ /* IFluidFileConverter implementation here */ });
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
> **Note**: Only one of `codeLoader` or `fluidRunner(...)` argument is allowed. If both or none are provided, an error will be thrown at the start of execution.
|
|
29
|
+
|
|
18
30
|
### Input file format
|
|
19
31
|
The input file is expected to be an ODSP snapshot.
|
|
20
32
|
For some examples, see the files in the [localOdspSnapshots folder](./src/test/localOdspSnapshots).
|
|
33
|
+
|
|
34
|
+
### Consumption
|
|
35
|
+
The code around `exportFile` can be consumed in multiple different layers. It is not necessary to run all this code fully as is, and the following are some interesting code bits involved in this workflow:
|
|
36
|
+
- [`createLogger(...)`](./src/logger/FileLogger.ts)
|
|
37
|
+
- Wraps a provided `FileLogger` and adds some useful telemetry data to every entry
|
|
38
|
+
- [`createContainerAndExecute(...)`](./src/exportFile.ts)
|
|
39
|
+
- This is the core logic for running some action based on a local ODSP snapshot
|
|
40
|
+
- [`getSnapshotFileContent(...)`](./src/utils.ts)
|
|
41
|
+
- Reads a local ODSP snapshot from both JSON and binary formats for usage in `createContainerAndExecute(...)`
|
|
42
|
+
|
|
43
|
+
For an example of a consumption path that differs slightly to [`exportFile(...)`](./src/exportFile.ts), see [`parseBundleAndExportFile(...)`](./src/parseBundleAndExportFile.ts). In addition to running the same logic as [`exportFile`](./src/exportFile.ts) method, it implements the logic around parsing a dynamically provided bundle path into an `IFluidFileConverter` object.
|
|
File without changes
|
|
@@ -20,21 +20,20 @@ export interface ICodeLoaderBundle {
|
|
|
20
20
|
*/
|
|
21
21
|
export interface IFluidFileConverter {
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Get code loader details to provide at Loader creation
|
|
24
|
+
* @param logger - created logger object to pass to code loader
|
|
24
25
|
*/
|
|
25
|
-
|
|
26
|
+
getCodeLoader(logger: ITelemetryBaseLogger): Promise<ICodeDetailsLoader>;
|
|
26
27
|
/**
|
|
27
28
|
* Scope object to provide at Loader creation
|
|
28
29
|
*/
|
|
29
30
|
scope?: FluidObject;
|
|
30
31
|
/**
|
|
31
|
-
*
|
|
32
|
+
* Executes code on container and returns the result
|
|
32
33
|
* @param container - container created by this application
|
|
33
|
-
* @param
|
|
34
|
-
* @param logger - passed through logger object
|
|
35
|
-
* @returns - object containing file names as property keys and file content as values
|
|
34
|
+
* @param options - additional options
|
|
36
35
|
*/
|
|
37
|
-
execute(container: IContainer,
|
|
36
|
+
execute(container: IContainer, options?: string): Promise<string>;
|
|
38
37
|
}
|
|
39
38
|
/**
|
|
40
39
|
* Type cast to ensure necessary methods are present in the provided bundle
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codeLoaderBundle.d.ts","sourceRoot":"","sources":["../src/codeLoaderBundle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D;;;GAGG;
|
|
1
|
+
{"version":3,"file":"codeLoaderBundle.d.ts","sourceRoot":"","sources":["../src/codeLoaderBundle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAC9B;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC;;;OAGG;IACH,aAAa,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAEzE;;OAEG;IACH,KAAK,CAAC,EAAE,WAAW,CAAC;IAEpB;;;;OAIG;IACH,OAAO,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACrE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,iBAAiB,CAG3E;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,mBAAmB,CAIzE"}
|
package/dist/codeLoaderBundle.js
CHANGED
|
@@ -16,7 +16,7 @@ function isCodeLoaderBundle(bundle) {
|
|
|
16
16
|
exports.isCodeLoaderBundle = isCodeLoaderBundle;
|
|
17
17
|
function isFluidFileConverter(obj) {
|
|
18
18
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
19
|
-
return (obj === null || obj === void 0 ? void 0 : obj.
|
|
19
|
+
return (obj === null || obj === void 0 ? void 0 : obj.getCodeLoader) && typeof obj.getCodeLoader === "function"
|
|
20
20
|
&& obj.execute && typeof obj.execute === "function";
|
|
21
21
|
}
|
|
22
22
|
exports.isFluidFileConverter = isFluidFileConverter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codeLoaderBundle.js","sourceRoot":"","sources":["../src/codeLoaderBundle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"codeLoaderBundle.js","sourceRoot":"","sources":["../src/codeLoaderBundle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAwCH;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,MAAW;IAC1C,+DAA+D;IAC/D,OAAO,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,KAAI,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ,CAAC;AACzE,CAAC;AAHD,gDAGC;AAED,SAAgB,oBAAoB,CAAC,GAAQ;IACzC,+DAA+D;IAC/D,OAAO,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,aAAa,KAAI,OAAO,GAAG,CAAC,aAAa,KAAK,UAAU;WAC7D,GAAG,CAAC,OAAO,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,UAAU,CAAC;AAC5D,CAAC;AAJD,oDAIC","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\";\nimport { ICodeDetailsLoader, IContainer } from \"@fluidframework/container-definitions\";\nimport { FluidObject } from \"@fluidframework/core-interfaces\";\n\n/**\n * Contract that defines the necessary exports for the bundle provided at runtime\n * For an example, see \"src/test/sampleCodeLoaders/sampleCodeLoader.ts\"\n */\nexport interface ICodeLoaderBundle {\n /**\n * Fluid export of all the required objects and functions\n */\n fluidExport: Promise<IFluidFileConverter>;\n}\n\n/**\n * Instance that holds all the details for Fluid file conversion\n */\nexport interface IFluidFileConverter {\n /**\n * Get code loader details to provide at Loader creation\n * @param logger - created logger object to pass to code loader\n */\n getCodeLoader(logger: ITelemetryBaseLogger): Promise<ICodeDetailsLoader>;\n\n /**\n * Scope object to provide at Loader creation\n */\n scope?: FluidObject;\n\n /**\n * Executes code on container and returns the result\n * @param container - container created by this application\n * @param options - additional options\n */\n execute(container: IContainer, options?: string): Promise<string>;\n}\n\n/**\n * Type cast to ensure necessary methods are present in the provided bundle\n * @param bundle - bundle provided to this application\n */\nexport function isCodeLoaderBundle(bundle: any): bundle is ICodeLoaderBundle {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return bundle?.fluidExport && typeof bundle.fluidExport === \"object\";\n}\n\nexport function isFluidFileConverter(obj: any): obj is IFluidFileConverter {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return obj?.getCodeLoader && typeof obj.getCodeLoader === \"function\"\n && obj.execute && typeof obj.execute === \"function\";\n}\n"]}
|
package/dist/exportFile.d.ts
CHANGED
|
@@ -14,7 +14,14 @@ interface IExportFileResponseFailure {
|
|
|
14
14
|
errorMessage: string;
|
|
15
15
|
error?: any;
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Execute code on Container based on ODSP snapshot and write result to file
|
|
19
|
+
*/
|
|
20
|
+
export declare function exportFile(fluidFileConverter: IFluidFileConverter, inputFile: string, outputFile: string, telemetryFile: string, options?: string): Promise<IExportFileResponse>;
|
|
21
|
+
/**
|
|
22
|
+
* Create the container based on an ODSP snapshot and execute code on it
|
|
23
|
+
* @returns result of execution
|
|
24
|
+
*/
|
|
25
|
+
export declare function createContainerAndExecute(localOdspSnapshot: string | Uint8Array, fluidFileConverter: IFluidFileConverter, logger: ITelemetryLogger, options?: string): Promise<string>;
|
|
19
26
|
export {};
|
|
20
27
|
//# sourceMappingURL=exportFile.d.ts.map
|
package/dist/exportFile.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exportFile.d.ts","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
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;AAMzD,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,GACjB,OAAO,CAAC,mBAAmB,CAAC,CAkC9B;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/dist/exportFile.js
CHANGED
|
@@ -22,70 +22,68 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
26
|
exports.createContainerAndExecute = exports.exportFile = void 0;
|
|
30
27
|
const fs = __importStar(require("fs"));
|
|
31
|
-
const path_1 = __importDefault(require("path"));
|
|
32
28
|
const container_definitions_1 = require("@fluidframework/container-definitions");
|
|
33
29
|
const container_loader_1 = require("@fluidframework/container-loader");
|
|
34
30
|
const odsp_driver_1 = require("@fluidframework/odsp-driver");
|
|
35
31
|
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
36
32
|
const getArgsValidationError_1 = require("./getArgsValidationError");
|
|
37
|
-
const codeLoaderBundle_1 = require("./codeLoaderBundle");
|
|
38
33
|
const fakeUrlResolver_1 = require("./fakeUrlResolver");
|
|
34
|
+
const utils_1 = require("./utils");
|
|
35
|
+
// eslint-disable-next-line import/no-internal-modules
|
|
36
|
+
const FileLogger_1 = require("./logger/FileLogger");
|
|
39
37
|
const clientArgsValidationError = "Client_ArgsValidationError";
|
|
40
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Execute code on Container based on ODSP snapshot and write result to file
|
|
40
|
+
*/
|
|
41
|
+
async function exportFile(fluidFileConverter, inputFile, outputFile, telemetryFile, options) {
|
|
42
|
+
const telemetryArgError = (0, FileLogger_1.getTelemetryFileValidationError)(telemetryFile);
|
|
43
|
+
if (telemetryArgError) {
|
|
44
|
+
const eventName = clientArgsValidationError;
|
|
45
|
+
return { success: false, eventName, errorMessage: telemetryArgError };
|
|
46
|
+
}
|
|
47
|
+
const fileLogger = new FileLogger_1.FileLogger(telemetryFile);
|
|
48
|
+
const logger = (0, FileLogger_1.createLogger)(fileLogger);
|
|
41
49
|
try {
|
|
42
50
|
return await telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, { eventName: "ExportFile" }, async () => {
|
|
43
|
-
const argsValidationError = (0, getArgsValidationError_1.getArgsValidationError)(inputFile,
|
|
51
|
+
const argsValidationError = (0, getArgsValidationError_1.getArgsValidationError)(inputFile, outputFile);
|
|
44
52
|
if (argsValidationError) {
|
|
45
53
|
const eventName = clientArgsValidationError;
|
|
54
|
+
logger.sendErrorEvent({ eventName, message: argsValidationError });
|
|
46
55
|
return { success: false, eventName, errorMessage: argsValidationError };
|
|
47
56
|
}
|
|
48
|
-
|
|
49
|
-
const codeLoaderBundle = require(codeLoader);
|
|
50
|
-
if (!(0, codeLoaderBundle_1.isCodeLoaderBundle)(codeLoaderBundle)) {
|
|
51
|
-
const eventName = clientArgsValidationError;
|
|
52
|
-
const errorMessage = "Code loader bundle is not of type ICodeLoaderBundle";
|
|
53
|
-
return { success: false, eventName, errorMessage };
|
|
54
|
-
}
|
|
55
|
-
const fluidExport = await codeLoaderBundle.fluidExport;
|
|
56
|
-
if (!(0, codeLoaderBundle_1.isFluidFileConverter)(fluidExport)) {
|
|
57
|
-
const eventName = clientArgsValidationError;
|
|
58
|
-
const errorMessage = "Fluid export from CodeLoaderBundle is not of type IFluidFileConverter";
|
|
59
|
-
return { success: false, eventName, errorMessage };
|
|
60
|
-
}
|
|
61
|
-
// TODO: read file stream
|
|
62
|
-
const inputFileContent = fs.readFileSync(inputFile, { encoding: "utf-8" });
|
|
63
|
-
const results = await createContainerAndExecute(inputFileContent, fluidExport, scenario, logger);
|
|
64
|
-
// eslint-disable-next-line guard-for-in, no-restricted-syntax
|
|
65
|
-
for (const key in results) {
|
|
66
|
-
fs.appendFileSync(path_1.default.join(outputFolder, key), results[key]);
|
|
67
|
-
}
|
|
57
|
+
fs.writeFileSync(outputFile, await createContainerAndExecute((0, utils_1.getSnapshotFileContent)(inputFile), fluidFileConverter, logger, options));
|
|
68
58
|
return { success: true };
|
|
69
59
|
});
|
|
70
60
|
}
|
|
71
61
|
catch (error) {
|
|
72
62
|
const eventName = "Client_UnexpectedError";
|
|
63
|
+
logger.sendErrorEvent({ eventName }, error);
|
|
73
64
|
return { success: false, eventName, errorMessage: "Unexpected error", error };
|
|
74
65
|
}
|
|
66
|
+
finally {
|
|
67
|
+
await fileLogger.flush();
|
|
68
|
+
}
|
|
75
69
|
}
|
|
76
70
|
exports.exportFile = exportFile;
|
|
77
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Create the container based on an ODSP snapshot and execute code on it
|
|
73
|
+
* @returns result of execution
|
|
74
|
+
*/
|
|
75
|
+
async function createContainerAndExecute(localOdspSnapshot, fluidFileConverter, logger, options) {
|
|
78
76
|
const loader = new container_loader_1.Loader({
|
|
79
77
|
urlResolver: new fakeUrlResolver_1.FakeUrlResolver(),
|
|
80
78
|
documentServiceFactory: (0, odsp_driver_1.createLocalOdspDocumentServiceFactory)(localOdspSnapshot),
|
|
81
|
-
codeLoader: fluidFileConverter.
|
|
79
|
+
codeLoader: await fluidFileConverter.getCodeLoader(logger),
|
|
82
80
|
scope: fluidFileConverter.scope,
|
|
83
81
|
logger,
|
|
84
82
|
});
|
|
85
83
|
const container = await loader.resolve({ url: "/fakeUrl/", headers: {
|
|
86
84
|
[container_definitions_1.LoaderHeader.loadMode]: { opsBeforeReturn: "cached" }
|
|
87
85
|
} });
|
|
88
|
-
return telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, { eventName: "ExportFile" }, async () => fluidFileConverter.execute(container,
|
|
86
|
+
return telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, { eventName: "ExportFile" }, async () => fluidFileConverter.execute(container, options));
|
|
89
87
|
}
|
|
90
88
|
exports.createContainerAndExecute = createContainerAndExecute;
|
|
91
89
|
//# sourceMappingURL=exportFile.js.map
|
package/dist/exportFile.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exportFile.js","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":";AAAA;;;GAGG
|
|
1
|
+
{"version":3,"file":"exportFile.js","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":"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","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-next-line import/no-internal-modules\nimport { createLogger, FileLogger, getTelemetryFileValidationError } from \"./logger/FileLogger\";\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): 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 = new FileLogger(telemetryFile);\n const logger = createLogger(fileLogger);\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.flush();\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/dist/fluidRunner.d.ts
CHANGED
|
@@ -2,5 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
import { IFluidFileConverter } from "./codeLoaderBundle";
|
|
6
|
+
/**
|
|
7
|
+
* @param fluidFileConverter - needs to be provided if "codeLoaderBundle" is not and vice versa
|
|
8
|
+
*/
|
|
9
|
+
export declare function fluidRunner(fluidFileConverter?: IFluidFileConverter): void;
|
|
6
10
|
//# sourceMappingURL=fluidRunner.d.ts.map
|
|
@@ -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;AAIH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAGzD;;GAEG;AACH,wBAAgB,WAAW,CAAC,kBAAkB,CAAC,EAAE,mBAAmB,QAwEnE"}
|
package/dist/fluidRunner.js
CHANGED
|
@@ -23,66 +23,79 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
|
|
26
|
+
exports.fluidRunner = void 0;
|
|
27
27
|
const yargs = __importStar(require("yargs"));
|
|
28
|
-
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
29
28
|
const exportFile_1 = require("./exportFile");
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
const parseBundleAndExportFile_1 = require("./parseBundleAndExportFile");
|
|
30
|
+
/**
|
|
31
|
+
* @param fluidFileConverter - needs to be provided if "codeLoaderBundle" is not and vice versa
|
|
32
|
+
*/
|
|
33
|
+
function fluidRunner(fluidFileConverter) {
|
|
33
34
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
34
35
|
yargs
|
|
35
36
|
.strict()
|
|
36
37
|
.version(false)
|
|
37
|
-
.command("exportFile", "Generate an output for a local snapshot",
|
|
38
|
+
.command("exportFile", "Generate an output for a local ODSP snapshot",
|
|
38
39
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
39
40
|
(yargs) => yargs
|
|
40
41
|
.option("codeLoader", {
|
|
41
|
-
|
|
42
|
+
// eslint-disable-next-line max-len
|
|
43
|
+
describe: "Path to code loader bundle. Required if this application is being called without modification.\nSee \"README.md\" for more details.",
|
|
42
44
|
type: "string",
|
|
43
|
-
demandOption:
|
|
45
|
+
demandOption: false,
|
|
44
46
|
})
|
|
45
47
|
.option("inputFile", {
|
|
46
|
-
describe: "
|
|
48
|
+
describe: "Path to local ODSP snapshot",
|
|
47
49
|
type: "string",
|
|
48
50
|
demandOption: true,
|
|
49
51
|
})
|
|
50
|
-
.option("
|
|
51
|
-
describe: "
|
|
52
|
+
.option("outputFile", {
|
|
53
|
+
describe: "Path of output file (cannot already exist).\nExecution result will be written here",
|
|
52
54
|
type: "string",
|
|
53
55
|
demandOption: true,
|
|
54
56
|
})
|
|
55
|
-
.option("
|
|
56
|
-
describe: "
|
|
57
|
+
.option("telemetryFile", {
|
|
58
|
+
describe: "Path of telemetry file for config and session data (cannot already exist)",
|
|
57
59
|
type: "string",
|
|
58
60
|
demandOption: true,
|
|
59
61
|
})
|
|
60
|
-
.option("
|
|
61
|
-
describe: "
|
|
62
|
+
.option("options", {
|
|
63
|
+
describe: "Additional options passed to container on execution",
|
|
62
64
|
type: "string",
|
|
63
|
-
demandOption:
|
|
65
|
+
demandOption: false,
|
|
64
66
|
}),
|
|
65
67
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
66
68
|
async (argv) => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
const argsError = validateProvidedArgs(argv.codeLoader, fluidFileConverter);
|
|
70
|
+
if (argsError) {
|
|
71
|
+
console.error(argsError);
|
|
69
72
|
process.exit(1);
|
|
70
73
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
let result;
|
|
75
|
+
if (argv.codeLoader) {
|
|
76
|
+
result = await (0, parseBundleAndExportFile_1.parseBundleAndExportFile)(argv.codeLoader, argv.inputFile, argv.outputFile, argv.telemetryFile, argv.options);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
result = await (0, exportFile_1.exportFile)(fluidFileConverter, argv.inputFile, argv.outputFile, argv.telemetryFile, argv.options);
|
|
80
|
+
}
|
|
74
81
|
if (!result.success) {
|
|
75
82
|
console.error(`${result.eventName}: ${result.errorMessage}`);
|
|
76
|
-
logger.sendErrorEvent({ eventName: result.eventName, message: result.errorMessage }, result.error);
|
|
77
|
-
await fileLogger.flush();
|
|
78
83
|
process.exit(1);
|
|
79
84
|
}
|
|
80
|
-
else {
|
|
81
|
-
await fileLogger.flush();
|
|
82
|
-
}
|
|
83
85
|
})
|
|
84
86
|
.help()
|
|
85
87
|
.demandCommand().argv;
|
|
86
88
|
}
|
|
89
|
+
exports.fluidRunner = fluidRunner;
|
|
90
|
+
function validateProvidedArgs(codeLoader, fluidFileConverter) {
|
|
91
|
+
if (codeLoader !== undefined && fluidFileConverter !== undefined) {
|
|
92
|
+
return "\"codeLoader\" and \"fluidFileConverter\" cannot both be provided. See \"fluidRunner.ts\" for details.";
|
|
93
|
+
}
|
|
94
|
+
if (codeLoader === undefined && fluidFileConverter === undefined) {
|
|
95
|
+
// eslint-disable-next-line max-len
|
|
96
|
+
return "\"codeLoader\" must be provided if there is no explicit \"fluidFileConverter\". See \"fluidRunner.ts\" for details.";
|
|
97
|
+
}
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
87
100
|
fluidRunner();
|
|
88
101
|
//# sourceMappingURL=fluidRunner.js.map
|
package/dist/fluidRunner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluidRunner.js","sourceRoot":"","sources":["../src/fluidRunner.ts"],"names":[],"mappings":";AAAA;;;GAGG
|
|
1
|
+
{"version":3,"file":"fluidRunner.js","sourceRoot":"","sources":["../src/fluidRunner.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAC/B,6CAA+D;AAE/D,yEAAsE;AAEtE;;GAEG;AACH,SAAgB,WAAW,CAAC,kBAAwC;IAChE,oEAAoE;IACpE,KAAK;SACA,MAAM,EAAE;SACR,OAAO,CAAC,KAAK,CAAC;SACd,OAAO,CACJ,YAAY,EACZ,8CAA8C;IAC9C,wDAAwD;IACxD,CAAC,KAAK,EAAE,EAAE,CACN,KAAK;SACA,MAAM,CAAC,YAAY,EAAE;QAClB,mCAAmC;QACnC,QAAQ,EAAE,qIAAqI;QAC/I,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,KAAK;KACtB,CAAC;SACD,MAAM,CAAC,WAAW,EAAE;QACjB,QAAQ,EAAE,6BAA6B;QACvC,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,IAAI;KACrB,CAAC;SACD,MAAM,CAAC,YAAY,EAAE;QAClB,QAAQ,EAAE,oFAAoF;QAC9F,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,IAAI;KACrB,CAAC;SACD,MAAM,CAAC,eAAe,EAAE;QACrB,QAAQ,EAAE,2EAA2E;QACrF,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,IAAI;KACrB,CAAC;SACD,MAAM,CAAC,SAAS,EAAE;QACf,QAAQ,EAAE,qDAAqD;QAC/D,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,KAAK;KACtB,CAAC;IACV,kEAAkE;IAClE,KAAK,EAAE,IAAI,EAAE,EAAE;QACX,MAAM,SAAS,GAAG,oBAAoB,CAAC,IAAI,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;QAC5E,IAAI,SAAS,EAAE;YACX,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACnB;QAED,IAAI,MAA2B,CAAC;QAChC,IAAI,IAAI,CAAC,UAAU,EAAE;YACjB,MAAM,GAAG,MAAM,IAAA,mDAAwB,EACnC,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,OAAO,CACf,CAAC;SACL;aAAM;YACH,MAAM,GAAG,MAAM,IAAA,uBAAU,EACrB,kBAAmB,EACnB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,OAAO,CACf,CAAC;SACL;QAED,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;YACjB,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,SAAS,KAAK,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;YAC7D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACnB;IACL,CAAC,CACJ;SACA,IAAI,EAAE;SACN,aAAa,EAAE,CAAC,IAAI,CAAC;AAC9B,CAAC;AAxED,kCAwEC;AAED,SAAS,oBAAoB,CACzB,UAAmB,EACnB,kBAAwC;IAExC,IAAI,UAAU,KAAK,SAAS,IAAI,kBAAkB,KAAK,SAAS,EAAE;QAC9D,OAAO,wGAAwG,CAAC;KACnH;IACD,IAAI,UAAU,KAAK,SAAS,IAAI,kBAAkB,KAAK,SAAS,EAAE;QAC9D,mCAAmC;QACnC,OAAO,qHAAqH,CAAC;KAChI;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,WAAW,EAAE,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as yargs from \"yargs\";\nimport { exportFile, IExportFileResponse } from \"./exportFile\";\nimport { IFluidFileConverter } from \"./codeLoaderBundle\";\nimport { parseBundleAndExportFile } from \"./parseBundleAndExportFile\";\n\n/**\n * @param fluidFileConverter - needs to be provided if \"codeLoaderBundle\" is not and vice versa\n */\nexport function fluidRunner(fluidFileConverter?: IFluidFileConverter) {\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n yargs\n .strict()\n .version(false)\n .command(\n \"exportFile\",\n \"Generate an output for a local ODSP snapshot\",\n // eslint-disable-next-line @typescript-eslint/no-shadow\n (yargs) =>\n yargs\n .option(\"codeLoader\", {\n // eslint-disable-next-line max-len\n describe: \"Path to code loader bundle. Required if this application is being called without modification.\\nSee \\\"README.md\\\" for more details.\",\n type: \"string\",\n demandOption: false,\n })\n .option(\"inputFile\", {\n describe: \"Path to local ODSP snapshot\",\n type: \"string\",\n demandOption: true,\n })\n .option(\"outputFile\", {\n describe: \"Path of output file (cannot already exist).\\nExecution result will be written here\",\n type: \"string\",\n demandOption: true,\n })\n .option(\"telemetryFile\", {\n describe: \"Path of telemetry file for config and session data (cannot already exist)\",\n type: \"string\",\n demandOption: true,\n })\n .option(\"options\", {\n describe: \"Additional options passed to container on execution\",\n type: \"string\",\n demandOption: false,\n }),\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (argv) => {\n const argsError = validateProvidedArgs(argv.codeLoader, fluidFileConverter);\n if (argsError) {\n console.error(argsError);\n process.exit(1);\n }\n\n let result: IExportFileResponse;\n if (argv.codeLoader) {\n result = await parseBundleAndExportFile(\n argv.codeLoader,\n argv.inputFile,\n argv.outputFile,\n argv.telemetryFile,\n argv.options,\n );\n } else {\n result = await exportFile(\n fluidFileConverter!,\n argv.inputFile,\n argv.outputFile,\n argv.telemetryFile,\n argv.options,\n );\n }\n\n if (!result.success) {\n console.error(`${result.eventName}: ${result.errorMessage}`);\n process.exit(1);\n }\n },\n )\n .help()\n .demandCommand().argv;\n}\n\nfunction validateProvidedArgs(\n codeLoader?: string,\n fluidFileConverter?: IFluidFileConverter,\n): string | undefined {\n if (codeLoader !== undefined && fluidFileConverter !== undefined) {\n return \"\\\"codeLoader\\\" and \\\"fluidFileConverter\\\" cannot both be provided. See \\\"fluidRunner.ts\\\" for details.\";\n }\n if (codeLoader === undefined && fluidFileConverter === undefined) {\n // eslint-disable-next-line max-len\n return \"\\\"codeLoader\\\" must be provided if there is no explicit \\\"fluidFileConverter\\\". See \\\"fluidRunner.ts\\\" for details.\";\n }\n return undefined;\n}\n\nfluidRunner();\n"]}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export declare function getArgsValidationError(inputFile: string,
|
|
5
|
+
export declare function getArgsValidationError(inputFile: string, outputFile: string): string | undefined;
|
|
6
6
|
//# sourceMappingURL=getArgsValidationError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getArgsValidationError.d.ts","sourceRoot":"","sources":["../src/getArgsValidationError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,wBAAgB,sBAAsB,CAClC,SAAS,EAAE,MAAM,EACjB,
|
|
1
|
+
{"version":3,"file":"getArgsValidationError.d.ts","sourceRoot":"","sources":["../src/getArgsValidationError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,wBAAgB,sBAAsB,CAClC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACnB,MAAM,GAAG,SAAS,CAiBpB"}
|
|
@@ -25,25 +25,21 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.getArgsValidationError = void 0;
|
|
27
27
|
const fs = __importStar(require("fs"));
|
|
28
|
-
function getArgsValidationError(inputFile,
|
|
28
|
+
function getArgsValidationError(inputFile, outputFile) {
|
|
29
29
|
// Validate input file
|
|
30
30
|
if (!inputFile) {
|
|
31
31
|
// TODO: Do not log file name. It can be customer content
|
|
32
|
-
return "Input file name is missing.";
|
|
32
|
+
return "Input file name argument is missing.";
|
|
33
33
|
}
|
|
34
34
|
else if (!fs.existsSync(inputFile)) {
|
|
35
35
|
return "Input file does not exist.";
|
|
36
36
|
}
|
|
37
37
|
// Validate output file
|
|
38
|
-
if (!
|
|
39
|
-
return "Output
|
|
38
|
+
if (!outputFile) {
|
|
39
|
+
return "Output file argument is missing.";
|
|
40
40
|
}
|
|
41
|
-
else if (
|
|
42
|
-
return
|
|
43
|
-
}
|
|
44
|
-
// Validate scenario name
|
|
45
|
-
if (!scenario) {
|
|
46
|
-
return "Scenario name is missing.";
|
|
41
|
+
else if (fs.existsSync(outputFile)) {
|
|
42
|
+
return `Output file already exists [${outputFile}].`;
|
|
47
43
|
}
|
|
48
44
|
return undefined;
|
|
49
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getArgsValidationError.js","sourceRoot":"","sources":["../src/getArgsValidationError.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AAEzB,SAAgB,sBAAsB,CAClC,SAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"getArgsValidationError.js","sourceRoot":"","sources":["../src/getArgsValidationError.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AAEzB,SAAgB,sBAAsB,CAClC,SAAiB,EACjB,UAAkB;IAElB,sBAAsB;IACtB,IAAI,CAAC,SAAS,EAAE;QACZ,yDAAyD;QACzD,OAAO,sCAAsC,CAAC;KACjD;SAAM,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QAClC,OAAO,4BAA4B,CAAC;KACvC;IAED,uBAAuB;IACvB,IAAI,CAAC,UAAU,EAAE;QACb,OAAO,kCAAkC,CAAC;KAC7C;SAAM,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;QAClC,OAAO,+BAA+B,UAAU,IAAI,CAAC;KACxD;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AApBD,wDAoBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as fs from \"fs\";\n\nexport function getArgsValidationError(\n inputFile: string,\n outputFile: string,\n): string | undefined {\n // Validate input file\n if (!inputFile) {\n // TODO: Do not log file name. It can be customer content\n return \"Input file name argument is missing.\";\n } else if (!fs.existsSync(inputFile)) {\n return \"Input file does not exist.\";\n }\n\n // Validate output file\n if (!outputFile) {\n return \"Output file argument is missing.\";\n } else if (fs.existsSync(outputFile)) {\n return `Output file already exists [${outputFile}].`;\n }\n\n return undefined;\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export { ICodeLoaderBundle, IFluidFileConverter } from "./codeLoaderBundle";
|
|
6
6
|
export * from "./exportFile";
|
|
7
|
+
export { fluidRunner } from "./fluidRunner";
|
|
8
|
+
export * from "./logger/FileLogger";
|
|
9
|
+
export * from "./parseBundleAndExportFile";
|
|
7
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
17
|
+
exports.fluidRunner = void 0;
|
|
18
18
|
__exportStar(require("./exportFile"), exports);
|
|
19
|
+
var fluidRunner_1 = require("./fluidRunner");
|
|
20
|
+
Object.defineProperty(exports, "fluidRunner", { enumerable: true, get: function () { return fluidRunner_1.fluidRunner; } });
|
|
21
|
+
// eslint-disable-next-line import/no-internal-modules
|
|
22
|
+
__exportStar(require("./logger/FileLogger"), exports);
|
|
23
|
+
__exportStar(require("./parseBundleAndExportFile"), exports);
|
|
19
24
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;AAGH,+CAA6B;AAC7B,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,sDAAsD;AACtD,sDAAoC;AACpC,6DAA2C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ICodeLoaderBundle, IFluidFileConverter } from \"./codeLoaderBundle\";\nexport * from \"./exportFile\";\nexport { fluidRunner } from \"./fluidRunner\";\n// eslint-disable-next-line import/no-internal-modules\nexport * from \"./logger/FileLogger\";\nexport * from \"./parseBundleAndExportFile\";\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { ITelemetryBaseEvent, ITelemetryBaseLogger } from "@fluidframework/common-definitions";
|
|
5
|
+
import { ITelemetryBaseEvent, ITelemetryBaseLogger, ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
6
6
|
/**
|
|
7
7
|
* Logger that writes events into a defined file
|
|
8
8
|
*/
|
|
@@ -20,4 +20,14 @@ export declare class FileLogger implements ITelemetryBaseLogger {
|
|
|
20
20
|
flush(): Promise<void>;
|
|
21
21
|
send(event: ITelemetryBaseEvent): void;
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Create a ITelemetryLogger wrapped around provided FileLogger
|
|
25
|
+
*/
|
|
26
|
+
export declare function createLogger(fileLogger: FileLogger): ITelemetryLogger;
|
|
27
|
+
/**
|
|
28
|
+
* Validate the telemetryFile command line argument
|
|
29
|
+
* @param telemetryFile - path where telemetry will be written
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
export declare function getTelemetryFileValidationError(telemetryFile: string): string | undefined;
|
|
23
33
|
//# sourceMappingURL=FileLogger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileLogger.d.ts","sourceRoot":"","sources":["../../src/logger/FileLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"FileLogger.d.ts","sourceRoot":"","sources":["../../src/logger/FileLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGjH;;GAEG;AACH,qBAAa,UAAW,YAAW,oBAAoB;IAW/C,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAX5B,YAAY,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAEvC,0CAA0C;IAC1C,OAAO,CAAC,MAAM,CAAgB;IAE9B;;;OAGG;gBAEkB,QAAQ,EAAE,MAAM,EAChB,cAAc,GAAE,MAAW;IAGnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAO5B,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI;CAUhD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,UAAU,GAAG,gBAAgB,CAGrE;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQzF"}
|
|
@@ -23,8 +23,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.FileLogger = void 0;
|
|
26
|
+
exports.getTelemetryFileValidationError = exports.createLogger = exports.FileLogger = void 0;
|
|
27
27
|
const fs = __importStar(require("fs"));
|
|
28
|
+
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
28
29
|
/**
|
|
29
30
|
* Logger that writes events into a defined file
|
|
30
31
|
*/
|
|
@@ -55,4 +56,26 @@ class FileLogger {
|
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
exports.FileLogger = FileLogger;
|
|
59
|
+
/**
|
|
60
|
+
* Create a ITelemetryLogger wrapped around provided FileLogger
|
|
61
|
+
*/
|
|
62
|
+
function createLogger(fileLogger) {
|
|
63
|
+
return telemetry_utils_1.ChildLogger.create(fileLogger, "LocalSnapshotRunnerApp", { all: { Event_Time: () => Date.now() } });
|
|
64
|
+
}
|
|
65
|
+
exports.createLogger = createLogger;
|
|
66
|
+
/**
|
|
67
|
+
* Validate the telemetryFile command line argument
|
|
68
|
+
* @param telemetryFile - path where telemetry will be written
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
71
|
+
function getTelemetryFileValidationError(telemetryFile) {
|
|
72
|
+
if (!telemetryFile) {
|
|
73
|
+
return "Telemetry file argument is missing.";
|
|
74
|
+
}
|
|
75
|
+
else if (fs.existsSync(telemetryFile)) {
|
|
76
|
+
return `Telemetry file already exists [${telemetryFile}].`;
|
|
77
|
+
}
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
exports.getTelemetryFileValidationError = getTelemetryFileValidationError;
|
|
58
81
|
//# sourceMappingURL=FileLogger.js.map
|