@fluidframework/fluid-runner 2.0.0-internal.1.0.0
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/.eslintrc.js +18 -0
- package/LICENSE +21 -0
- package/README.md +16 -0
- package/bin/fluidRunner +2 -0
- package/dist/codeLoaderBundle.d.ts +44 -0
- package/dist/codeLoaderBundle.d.ts.map +1 -0
- package/dist/codeLoaderBundle.js +17 -0
- package/dist/codeLoaderBundle.js.map +1 -0
- package/dist/exportFile.d.ts +20 -0
- package/dist/exportFile.d.ts.map +1 -0
- package/dist/exportFile.js +84 -0
- package/dist/exportFile.js.map +1 -0
- package/dist/fakeUrlResolver.d.ts +14 -0
- package/dist/fakeUrlResolver.d.ts.map +1 -0
- package/dist/fakeUrlResolver.js +42 -0
- package/dist/fakeUrlResolver.js.map +1 -0
- package/dist/fluidRunner.d.ts +6 -0
- package/dist/fluidRunner.d.ts.map +1 -0
- package/dist/fluidRunner.js +88 -0
- package/dist/fluidRunner.js.map +1 -0
- package/dist/getArgsValidationError.d.ts +6 -0
- package/dist/getArgsValidationError.d.ts.map +1 -0
- package/dist/getArgsValidationError.js +54 -0
- package/dist/getArgsValidationError.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/logger/FileLogger.d.ts +23 -0
- package/dist/logger/FileLogger.d.ts.map +1 -0
- package/dist/logger/FileLogger.js +58 -0
- package/dist/logger/FileLogger.js.map +1 -0
- package/dist/packageVersion.d.ts +9 -0
- package/dist/packageVersion.d.ts.map +1 -0
- package/dist/packageVersion.js +12 -0
- package/dist/packageVersion.js.map +1 -0
- package/lib/codeLoaderBundle.d.ts +44 -0
- package/lib/codeLoaderBundle.d.ts.map +1 -0
- package/lib/codeLoaderBundle.js +13 -0
- package/lib/codeLoaderBundle.js.map +1 -0
- package/lib/exportFile.d.ts +20 -0
- package/lib/exportFile.d.ts.map +1 -0
- package/lib/exportFile.js +57 -0
- package/lib/exportFile.js.map +1 -0
- package/lib/fakeUrlResolver.d.ts +14 -0
- package/lib/fakeUrlResolver.d.ts.map +1 -0
- package/lib/fakeUrlResolver.js +38 -0
- package/lib/fakeUrlResolver.js.map +1 -0
- package/lib/fluidRunner.d.ts +6 -0
- package/lib/fluidRunner.d.ts.map +1 -0
- package/lib/fluidRunner.js +67 -0
- package/lib/fluidRunner.js.map +1 -0
- package/lib/getArgsValidationError.d.ts +6 -0
- package/lib/getArgsValidationError.d.ts.map +1 -0
- package/lib/getArgsValidationError.js +31 -0
- package/lib/getArgsValidationError.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -0
- package/lib/logger/FileLogger.d.ts +23 -0
- package/lib/logger/FileLogger.d.ts.map +1 -0
- package/lib/logger/FileLogger.js +35 -0
- package/lib/logger/FileLogger.js.map +1 -0
- package/lib/packageVersion.d.ts +9 -0
- package/lib/packageVersion.d.ts.map +1 -0
- package/lib/packageVersion.js +9 -0
- package/lib/packageVersion.js.map +1 -0
- package/package.json +86 -0
- package/src/codeLoaderBundle.ts +52 -0
- package/src/exportFile.ts +94 -0
- package/src/fakeUrlResolver.ts +49 -0
- package/src/fluidRunner.ts +83 -0
- package/src/getArgsValidationError.ts +36 -0
- package/src/index.ts +7 -0
- package/src/logger/FileLogger.ts +44 -0
- package/src/packageVersion.ts +9 -0
- package/tsconfig.esnext.json +7 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,58 @@
|
|
|
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.FileLogger = void 0;
|
|
27
|
+
const fs = __importStar(require("fs"));
|
|
28
|
+
/**
|
|
29
|
+
* Logger that writes events into a defined file
|
|
30
|
+
*/
|
|
31
|
+
class FileLogger {
|
|
32
|
+
/**
|
|
33
|
+
* @param filePath - file path to write logs to
|
|
34
|
+
* @param eventsPerFlush - number of events per flush
|
|
35
|
+
*/
|
|
36
|
+
constructor(filePath, eventsPerFlush = 50) {
|
|
37
|
+
this.filePath = filePath;
|
|
38
|
+
this.eventsPerFlush = eventsPerFlush;
|
|
39
|
+
/** Hold events in memory until flushed */
|
|
40
|
+
this.events = [];
|
|
41
|
+
}
|
|
42
|
+
async flush() {
|
|
43
|
+
if (this.events.length > 0) {
|
|
44
|
+
fs.appendFileSync(this.filePath, this.events.join("\n"));
|
|
45
|
+
this.events = [];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
send(event) {
|
|
49
|
+
const logEvent = JSON.stringify(event);
|
|
50
|
+
this.events.push(logEvent);
|
|
51
|
+
if (this.events.length >= this.eventsPerFlush || event.category === "error") {
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
53
|
+
this.flush();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.FileLogger = FileLogger;
|
|
58
|
+
//# sourceMappingURL=FileLogger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileLogger.js","sourceRoot":"","sources":["../../src/logger/FileLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AAGzB;;GAEG;AACH,MAAa,UAAU;IAMnB;;;OAGG;IACH,YACqB,QAAgB,EAChB,iBAAyB,EAAE;QAD3B,aAAQ,GAAR,QAAQ,CAAQ;QAChB,mBAAc,GAAd,cAAc,CAAa;QAThD,0CAA0C;QAClC,WAAM,GAAa,EAAE,CAAC;IAS1B,CAAC;IAEE,KAAK,CAAC,KAAK;QACd,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YACxB,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACzD,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;SACpB;IACL,CAAC;IAEM,IAAI,CAAC,KAA0B;QAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAEvC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE3B,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,cAAc,IAAI,KAAK,CAAC,QAAQ,KAAK,OAAO,EAAE;YACzE,mEAAmE;YACnE,IAAI,CAAC,KAAK,EAAE,CAAC;SAChB;IACL,CAAC;CACJ;AAhCD,gCAgCC","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 { ITelemetryBaseEvent, ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\n\n/**\n * Logger that writes events into a defined file\n */\nexport class FileLogger implements ITelemetryBaseLogger {\n public supportsTags?: true | undefined;\n\n /** Hold events in memory until flushed */\n private events: string[] = [];\n\n /**\n * @param filePath - file path to write logs to\n * @param eventsPerFlush - number of events per flush\n */\n public constructor(\n private readonly filePath: string,\n private readonly eventsPerFlush: number = 50,\n ) { }\n\n public async flush(): Promise<void> {\n if (this.events.length > 0) {\n fs.appendFileSync(this.filePath, this.events.join(\"\\n\"));\n this.events = [];\n }\n }\n\n public send(event: ITelemetryBaseEvent): void {\n const logEvent = JSON.stringify(event);\n\n this.events.push(logEvent);\n\n if (this.events.length >= this.eventsPerFlush || event.category === \"error\") {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.flush();\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
|
+
*/
|
|
7
|
+
export declare const pkgName = "@fluidframework/fluid-runner";
|
|
8
|
+
export declare const pkgVersion = "1.2.0";
|
|
9
|
+
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,iCAAiC,CAAC;AACtD,eAAO,MAAM,UAAU,UAAU,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*
|
|
6
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
|
+
exports.pkgName = "@fluidframework/fluid-runner";
|
|
11
|
+
exports.pkgVersion = "1.2.0";
|
|
12
|
+
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,8BAA8B,CAAC;AACzC,QAAA,UAAU,GAAG,OAAO,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/fluid-runner\";\nexport const pkgVersion = \"1.2.0\";\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { ITelemetryBaseLogger } from "@fluidframework/common-definitions";
|
|
6
|
+
import { ICodeDetailsLoader, IContainer } from "@fluidframework/container-definitions";
|
|
7
|
+
import { FluidObject } from "@fluidframework/core-interfaces";
|
|
8
|
+
/**
|
|
9
|
+
* Contract that defines the necessary exports for the bundle provided at runtime
|
|
10
|
+
* For an example, see "src/test/sampleCodeLoader.ts"
|
|
11
|
+
*/
|
|
12
|
+
export interface ICodeLoaderBundle {
|
|
13
|
+
/**
|
|
14
|
+
* Fluid export of all the required objects and functions
|
|
15
|
+
*/
|
|
16
|
+
fluidExport: Promise<IFluidFileConverter>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Instance that holds all the details for Fluid file conversion
|
|
20
|
+
*/
|
|
21
|
+
export interface IFluidFileConverter {
|
|
22
|
+
/**
|
|
23
|
+
* Code loader details to provide at Loader creation
|
|
24
|
+
*/
|
|
25
|
+
codeLoader: ICodeDetailsLoader;
|
|
26
|
+
/**
|
|
27
|
+
* Scope object to provide at Loader creation
|
|
28
|
+
*/
|
|
29
|
+
scope?: FluidObject;
|
|
30
|
+
/**
|
|
31
|
+
* Execute code and return the results
|
|
32
|
+
* @param container - container created by this application
|
|
33
|
+
* @param scenario - scenario this execution is related to
|
|
34
|
+
* @param logger - passed through logger object
|
|
35
|
+
* @returns - object containing file names as property keys and file content as values
|
|
36
|
+
*/
|
|
37
|
+
execute(container: IContainer, scenario: string, logger: ITelemetryBaseLogger): Promise<Record<string, string>>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Type cast to ensure necessary methods are present in the provided bundle
|
|
41
|
+
* @param bundle - bundle provided to this application
|
|
42
|
+
*/
|
|
43
|
+
export declare function isCodeLoaderBundle(bundle: any): bundle is ICodeLoaderBundle;
|
|
44
|
+
//# sourceMappingURL=codeLoaderBundle.d.ts.map
|
|
@@ -0,0 +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;AACF,MAAM,WAAW,iBAAiB;IAC/B;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC;;OAEG;IACH,UAAU,EAAE,kBAAkB,CAAC;IAE/B;;OAEG;IACH,KAAK,CAAC,EAAE,WAAW,CAAC;IAEpB;;;;;;OAMG;IACH,OAAO,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACnH;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,iBAAiB,CAG3E"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Type cast to ensure necessary methods are present in the provided bundle
|
|
7
|
+
* @param bundle - bundle provided to this application
|
|
8
|
+
*/
|
|
9
|
+
export function isCodeLoaderBundle(bundle) {
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
11
|
+
return (bundle === null || bundle === void 0 ? void 0 : bundle.fluidExport) && typeof bundle.fluidExport === "object";
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=codeLoaderBundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codeLoaderBundle.js","sourceRoot":"","sources":["../src/codeLoaderBundle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAyCH;;;GAGG;AACH,MAAM,UAAU,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","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/sampleCodeLoader.ts\"\n */\n export 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 * Code loader details to provide at Loader creation\n */\n codeLoader: ICodeDetailsLoader;\n\n /**\n * Scope object to provide at Loader creation\n */\n scope?: FluidObject;\n\n /**\n * Execute code and return the results\n * @param container - container created by this application\n * @param scenario - scenario this execution is related to\n * @param logger - passed through logger object\n * @returns - object containing file names as property keys and file content as values\n */\n execute(container: IContainer, scenario: string, logger: ITelemetryBaseLogger): Promise<Record<string, 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"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 { IFluidFileConverter } from "./codeLoaderBundle";
|
|
7
|
+
export declare type IExportFileResponse = IExportFileResponseSuccess | IExportFileResponseFailure;
|
|
8
|
+
interface IExportFileResponseSuccess {
|
|
9
|
+
success: true;
|
|
10
|
+
}
|
|
11
|
+
interface IExportFileResponseFailure {
|
|
12
|
+
success: false;
|
|
13
|
+
eventName: string;
|
|
14
|
+
errorMessage: string;
|
|
15
|
+
error?: any;
|
|
16
|
+
}
|
|
17
|
+
export declare function exportFile(codeLoader: string, inputFile: string, outputFolder: string, scenario: string, logger: ITelemetryLogger): Promise<IExportFileResponse>;
|
|
18
|
+
export declare function createContainerAndExecute(localOdspSnapshot: string, fluidFileConverter: IFluidFileConverter, scenario: string, logger: ITelemetryLogger): Promise<Record<string, string>>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=exportFile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exportFile.d.ts","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAMtE,OAAO,EAAE,mBAAmB,EAAsB,MAAM,oBAAoB,CAAC;AAG7E,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,wBAAsB,UAAU,CAC5B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,gBAAgB,GACzB,OAAO,CAAC,mBAAmB,CAAC,CAoC9B;AAED,wBAAsB,yBAAyB,CAC3C,iBAAiB,EAAE,MAAM,EACzB,kBAAkB,EAAE,mBAAmB,EACvC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,gBAAgB,GACzB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAajC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from "fs";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import { LoaderHeader } from "@fluidframework/container-definitions";
|
|
8
|
+
import { Loader } from "@fluidframework/container-loader";
|
|
9
|
+
import { createLocalOdspDocumentServiceFactory } from "@fluidframework/odsp-driver";
|
|
10
|
+
import { PerformanceEvent } from "@fluidframework/telemetry-utils";
|
|
11
|
+
import { getArgsValidationError } from "./getArgsValidationError";
|
|
12
|
+
import { isCodeLoaderBundle } from "./codeLoaderBundle";
|
|
13
|
+
import { FakeUrlResolver } from "./fakeUrlResolver";
|
|
14
|
+
const clientArgsValidationError = "Client_ArgsValidationError";
|
|
15
|
+
export async function exportFile(codeLoader, inputFile, outputFolder, scenario, logger) {
|
|
16
|
+
try {
|
|
17
|
+
return await PerformanceEvent.timedExecAsync(logger, { eventName: "ExportFile" }, async () => {
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
19
|
+
const codeLoaderBundle = require(codeLoader);
|
|
20
|
+
if (!isCodeLoaderBundle(codeLoaderBundle)) {
|
|
21
|
+
const eventName = clientArgsValidationError;
|
|
22
|
+
const message = "Code loader bundle is not of type CodeLoaderBundle";
|
|
23
|
+
return { success: false, eventName, errorMessage: message };
|
|
24
|
+
}
|
|
25
|
+
const argsValidationError = getArgsValidationError(inputFile, outputFolder, scenario);
|
|
26
|
+
if (argsValidationError) {
|
|
27
|
+
const eventName = clientArgsValidationError;
|
|
28
|
+
return { success: false, eventName, errorMessage: argsValidationError };
|
|
29
|
+
}
|
|
30
|
+
// TODO: read file stream
|
|
31
|
+
const inputFileContent = fs.readFileSync(inputFile, { encoding: "utf-8" });
|
|
32
|
+
const results = await createContainerAndExecute(inputFileContent, await codeLoaderBundle.fluidExport, scenario, logger);
|
|
33
|
+
// eslint-disable-next-line guard-for-in, no-restricted-syntax
|
|
34
|
+
for (const key in results) {
|
|
35
|
+
fs.appendFileSync(path.join(outputFolder, key), results[key]);
|
|
36
|
+
}
|
|
37
|
+
return { success: true };
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
const eventName = "Client_UnexpectedError";
|
|
42
|
+
return { success: false, eventName, errorMessage: "Unexpected error", error };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export async function createContainerAndExecute(localOdspSnapshot, fluidFileConverter, scenario, logger) {
|
|
46
|
+
const loader = new Loader({
|
|
47
|
+
urlResolver: new FakeUrlResolver(),
|
|
48
|
+
documentServiceFactory: createLocalOdspDocumentServiceFactory(localOdspSnapshot),
|
|
49
|
+
codeLoader: fluidFileConverter.codeLoader,
|
|
50
|
+
scope: fluidFileConverter.scope,
|
|
51
|
+
});
|
|
52
|
+
const container = await loader.resolve({ url: "/fakeUrl/", headers: {
|
|
53
|
+
[LoaderHeader.loadMode]: { opsBeforeReturn: "cached" }
|
|
54
|
+
} });
|
|
55
|
+
return PerformanceEvent.timedExecAsync(logger, { eventName: "ExportFile" }, async () => fluidFileConverter.execute(container, scenario, logger));
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=exportFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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 path from \"path\";\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, isCodeLoaderBundle } from \"./codeLoaderBundle\";\nimport { FakeUrlResolver } from \"./fakeUrlResolver\";\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\nexport async function exportFile(\n codeLoader: string,\n inputFile: string,\n outputFolder: string,\n scenario: string,\n logger: ITelemetryLogger,\n): Promise<IExportFileResponse> {\n try {\n return await PerformanceEvent.timedExecAsync(logger, { eventName: \"ExportFile\" }, 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 message = \"Code loader bundle is not of type CodeLoaderBundle\";\n return { success: false, eventName, errorMessage: message };\n }\n\n const argsValidationError = getArgsValidationError(inputFile, outputFolder, scenario);\n if (argsValidationError) {\n const eventName = clientArgsValidationError;\n return { success: false, eventName, errorMessage: argsValidationError };\n }\n\n // TODO: read file stream\n const inputFileContent = fs.readFileSync(inputFile, { encoding: \"utf-8\" });\n\n const results = await createContainerAndExecute(\n inputFileContent,\n await codeLoaderBundle.fluidExport,\n scenario,\n logger,\n );\n // eslint-disable-next-line guard-for-in, no-restricted-syntax\n for (const key in results) {\n fs.appendFileSync(path.join(outputFolder, key), results[key]);\n }\n return { success: true };\n });\n } catch (error) {\n const eventName = \"Client_UnexpectedError\";\n return { success: false, eventName, errorMessage: \"Unexpected error\", error };\n }\n}\n\nexport async function createContainerAndExecute(\n localOdspSnapshot: string,\n fluidFileConverter: IFluidFileConverter,\n scenario: string,\n logger: ITelemetryLogger,\n): Promise<Record<string, string>> {\n const loader = new Loader({\n urlResolver: new FakeUrlResolver(),\n documentServiceFactory: createLocalOdspDocumentServiceFactory(localOdspSnapshot),\n codeLoader: fluidFileConverter.codeLoader,\n scope: fluidFileConverter.scope,\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, scenario, logger));\n}\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 { IRequest } from "@fluidframework/core-interfaces";
|
|
6
|
+
import { IContainerPackageInfo, IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions";
|
|
7
|
+
/**
|
|
8
|
+
* Fake URL resolver that returns hard coded values on every request
|
|
9
|
+
*/
|
|
10
|
+
export declare class FakeUrlResolver implements IUrlResolver {
|
|
11
|
+
resolve(_request: IRequest): Promise<IResolvedUrl | undefined>;
|
|
12
|
+
getAbsoluteUrl(_resolvedUrl: IResolvedUrl, _relativeUrl: string, _packageInfoSource?: IContainerPackageInfo): Promise<string>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=fakeUrlResolver.d.ts.map
|
|
@@ -0,0 +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;;GAEG;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"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
const fakeId = "FakeUrlResolver";
|
|
6
|
+
const fakeUrl = "/FakeUrlResolver/";
|
|
7
|
+
/**
|
|
8
|
+
* Fake URL resolver that returns hard coded values on every request
|
|
9
|
+
*/
|
|
10
|
+
export class FakeUrlResolver {
|
|
11
|
+
async resolve(_request) {
|
|
12
|
+
const fakeOdspResolvedUrl = {
|
|
13
|
+
type: "fluid",
|
|
14
|
+
odspResolvedUrl: true,
|
|
15
|
+
id: fakeId,
|
|
16
|
+
siteUrl: fakeUrl,
|
|
17
|
+
driveId: fakeId,
|
|
18
|
+
itemId: fakeId,
|
|
19
|
+
url: fakeUrl,
|
|
20
|
+
hashedDocumentId: fakeId,
|
|
21
|
+
endpoints: {
|
|
22
|
+
snapshotStorageUrl: fakeUrl,
|
|
23
|
+
attachmentPOSTStorageUrl: fakeUrl,
|
|
24
|
+
attachmentGETStorageUrl: fakeUrl,
|
|
25
|
+
deltaStorageUrl: fakeUrl,
|
|
26
|
+
},
|
|
27
|
+
tokens: {},
|
|
28
|
+
fileName: fakeId,
|
|
29
|
+
summarizer: false,
|
|
30
|
+
fileVersion: fakeId,
|
|
31
|
+
};
|
|
32
|
+
return fakeOdspResolvedUrl;
|
|
33
|
+
}
|
|
34
|
+
async getAbsoluteUrl(_resolvedUrl, _relativeUrl, _packageInfoSource) {
|
|
35
|
+
return "";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=fakeUrlResolver.js.map
|
|
@@ -0,0 +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;;GAEG;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 */\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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fluidRunner.d.ts","sourceRoot":"","sources":["../src/fluidRunner.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from "fs";
|
|
6
|
+
import * as yargs from "yargs";
|
|
7
|
+
import { ChildLogger } from "@fluidframework/telemetry-utils";
|
|
8
|
+
import { exportFile } from "./exportFile";
|
|
9
|
+
// eslint-disable-next-line import/no-internal-modules
|
|
10
|
+
import { FileLogger } from "./logger/FileLogger";
|
|
11
|
+
function fluidRunner() {
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
13
|
+
yargs
|
|
14
|
+
.strict()
|
|
15
|
+
.version(false)
|
|
16
|
+
.command("exportFile", "Generate an output for a local snapshot",
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
18
|
+
(yargs) => yargs
|
|
19
|
+
.option("codeLoader", {
|
|
20
|
+
describe: "Name of the code loader bundle",
|
|
21
|
+
type: "string",
|
|
22
|
+
demandOption: true,
|
|
23
|
+
})
|
|
24
|
+
.option("inputFile", {
|
|
25
|
+
describe: "Name of the file containing local ODSP snapshot",
|
|
26
|
+
type: "string",
|
|
27
|
+
demandOption: true,
|
|
28
|
+
})
|
|
29
|
+
.option("outputFolder", {
|
|
30
|
+
describe: "Name of the output file",
|
|
31
|
+
type: "string",
|
|
32
|
+
demandOption: true,
|
|
33
|
+
})
|
|
34
|
+
.option("scenario", {
|
|
35
|
+
describe: "Name of scenario to invoke",
|
|
36
|
+
type: "string",
|
|
37
|
+
demandOption: true,
|
|
38
|
+
})
|
|
39
|
+
.option("telemetryFile", {
|
|
40
|
+
describe: "Config and session data for telemetry",
|
|
41
|
+
type: "string",
|
|
42
|
+
demandOption: true,
|
|
43
|
+
}),
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
45
|
+
async (argv) => {
|
|
46
|
+
if (fs.existsSync(argv.telemetryFile)) {
|
|
47
|
+
console.error(`Telemetry file already exists [${argv.telemetryFile}]`);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
const fileLogger = new FileLogger(argv.telemetryFile);
|
|
51
|
+
const logger = ChildLogger.create(fileLogger, "LocalSnapshotRunnerApp", { all: { Event_Time: () => Date.now() } });
|
|
52
|
+
const result = await exportFile(argv.codeLoader, argv.inputFile, argv.outputFolder, argv.scenario, logger);
|
|
53
|
+
if (!result.success) {
|
|
54
|
+
console.error(`${result.eventName}: ${result.errorMessage}`);
|
|
55
|
+
logger.sendErrorEvent({ eventName: result.eventName, message: result.errorMessage }, result.error);
|
|
56
|
+
await fileLogger.flush();
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
await fileLogger.flush();
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
.help()
|
|
64
|
+
.demandCommand().argv;
|
|
65
|
+
}
|
|
66
|
+
fluidRunner();
|
|
67
|
+
//# sourceMappingURL=fluidRunner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fluidRunner.js","sourceRoot":"","sources":["../src/fluidRunner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,sDAAsD;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,SAAS,WAAW;IAChB,oEAAoE;IACpE,KAAK;SACA,MAAM,EAAE;SACR,OAAO,CAAC,KAAK,CAAC;SACd,OAAO,CACJ,YAAY,EACZ,yCAAyC;IACzC,wDAAwD;IACxD,CAAC,KAAK,EAAE,EAAE,CACN,KAAK;SACA,MAAM,CAAC,YAAY,EAAE;QAClB,QAAQ,EAAE,gCAAgC;QAC1C,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,IAAI;KACrB,CAAC;SACD,MAAM,CAAC,WAAW,EAAE;QACjB,QAAQ,EAAE,iDAAiD;QAC3D,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,IAAI;KACrB,CAAC;SACD,MAAM,CAAC,cAAc,EAAE;QACpB,QAAQ,EAAE,yBAAyB;QACnC,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,IAAI;KACrB,CAAC;SACD,MAAM,CAAC,UAAU,EAAE;QAChB,QAAQ,EAAE,4BAA4B;QACtC,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,IAAI;KACrB,CAAC;SACD,MAAM,CAAC,eAAe,EAAE;QACrB,QAAQ,EAAE,uCAAuC;QACjD,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,IAAI;KACrB,CAAC;IACV,kEAAkE;IAClE,KAAK,EAAE,IAAI,EAAE,EAAE;QACX,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE;YACnC,OAAO,CAAC,KAAK,CAAC,kCAAkC,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;YACvE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACnB;QAED,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAEtD,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,UAAU,EAAE,wBAAwB,EAClE,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;QAE/C,MAAM,MAAM,GAAG,MAAM,UAAU,CAC3B,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,QAAQ,EACb,MAAM,CACT,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;YACjB,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,SAAS,KAAK,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;YAC7D,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,YAAY,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;YACnG,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACnB;aAAM;YACH,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;SAC5B;IACL,CAAC,CACJ;SACA,IAAI,EAAE;SACN,aAAa,EAAE,CAAC,IAAI,CAAC;AAC9B,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 fs from \"fs\";\nimport * as yargs from \"yargs\";\nimport { ChildLogger } from \"@fluidframework/telemetry-utils\";\nimport { exportFile } from \"./exportFile\";\n// eslint-disable-next-line import/no-internal-modules\nimport { FileLogger } from \"./logger/FileLogger\";\n\nfunction fluidRunner() {\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 snapshot\",\n // eslint-disable-next-line @typescript-eslint/no-shadow\n (yargs) =>\n yargs\n .option(\"codeLoader\", {\n describe: \"Name of the code loader bundle\",\n type: \"string\",\n demandOption: true,\n })\n .option(\"inputFile\", {\n describe: \"Name of the file containing local ODSP snapshot\",\n type: \"string\",\n demandOption: true,\n })\n .option(\"outputFolder\", {\n describe: \"Name of the output file\",\n type: \"string\",\n demandOption: true,\n })\n .option(\"scenario\", {\n describe: \"Name of scenario to invoke\",\n type: \"string\",\n demandOption: true,\n })\n .option(\"telemetryFile\", {\n describe: \"Config and session data for telemetry\",\n type: \"string\",\n demandOption: true,\n }),\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (argv) => {\n if (fs.existsSync(argv.telemetryFile)) {\n console.error(`Telemetry file already exists [${argv.telemetryFile}]`);\n process.exit(1);\n }\n\n const fileLogger = new FileLogger(argv.telemetryFile);\n\n const logger = ChildLogger.create(fileLogger, \"LocalSnapshotRunnerApp\",\n { all: { Event_Time: () => Date.now() } });\n\n const result = await exportFile(\n argv.codeLoader,\n argv.inputFile,\n argv.outputFolder,\n argv.scenario,\n logger,\n );\n\n if (!result.success) {\n console.error(`${result.eventName}: ${result.errorMessage}`);\n logger.sendErrorEvent({ eventName: result.eventName, message: result.errorMessage }, result.error);\n await fileLogger.flush();\n process.exit(1);\n } else {\n await fileLogger.flush();\n }\n },\n )\n .help()\n .demandCommand().argv;\n}\n\nfluidRunner();\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getArgsValidationError(inputFile: string, outputFolder: string, scenario: string): string | undefined;
|
|
6
|
+
//# sourceMappingURL=getArgsValidationError.d.ts.map
|
|
@@ -0,0 +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,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,GACjB,MAAM,GAAG,SAAS,CAwBpB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from "fs";
|
|
6
|
+
export function getArgsValidationError(inputFile, outputFolder, scenario) {
|
|
7
|
+
// Validate input file
|
|
8
|
+
if (!inputFile) {
|
|
9
|
+
// TODO: Do not log file name. It can be customer content
|
|
10
|
+
return "Input file name is missing.";
|
|
11
|
+
}
|
|
12
|
+
else if (!fs.existsSync(inputFile)) {
|
|
13
|
+
return "Input file does not exist.";
|
|
14
|
+
}
|
|
15
|
+
// Validate output file
|
|
16
|
+
if (!outputFolder) {
|
|
17
|
+
return "Output folder name is missing.";
|
|
18
|
+
}
|
|
19
|
+
else if (!fs.existsSync(outputFolder)) {
|
|
20
|
+
return "Output folder does not exist.";
|
|
21
|
+
}
|
|
22
|
+
else if (fs.existsSync(`${outputFolder}/index.html`)) {
|
|
23
|
+
return "Output file already exists.";
|
|
24
|
+
}
|
|
25
|
+
// Validate scenario name
|
|
26
|
+
if (!scenario) {
|
|
27
|
+
return "Scenario name is missing.";
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=getArgsValidationError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getArgsValidationError.js","sourceRoot":"","sources":["../src/getArgsValidationError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,MAAM,UAAU,sBAAsB,CAClC,SAAiB,EACjB,YAAoB,EACpB,QAAgB;IAEhB,sBAAsB;IACtB,IAAI,CAAC,SAAS,EAAE;QACZ,yDAAyD;QACzD,OAAO,6BAA6B,CAAC;KACxC;SAAM,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QAClC,OAAO,4BAA4B,CAAC;KACvC;IAED,uBAAuB;IACvB,IAAI,CAAC,YAAY,EAAE;QACf,OAAO,gCAAgC,CAAC;KAC3C;SAAM,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE;QACrC,OAAO,+BAA+B,CAAC;KAC1C;SAAM,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,YAAY,aAAa,CAAC,EAAE;QACpD,OAAO,6BAA6B,CAAC;KACxC;IAED,yBAAyB;IACzB,IAAI,CAAC,QAAQ,EAAE;QACX,OAAO,2BAA2B,CAAC;KACtC;IAED,OAAO,SAAS,CAAC;AACrB,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\";\n\nexport function getArgsValidationError(\n inputFile: string,\n outputFolder: string,\n scenario: 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 is missing.\";\n } else if (!fs.existsSync(inputFile)) {\n return \"Input file does not exist.\";\n }\n\n // Validate output file\n if (!outputFolder) {\n return \"Output folder name is missing.\";\n } else if (!fs.existsSync(outputFolder)) {\n return \"Output folder does not exist.\";\n } else if (fs.existsSync(`${outputFolder}/index.html`)) {\n return \"Output file already exists.\";\n }\n\n // Validate scenario name\n if (!scenario) {\n return \"Scenario name is missing.\";\n }\n\n return undefined;\n}\n"]}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC"}
|
package/lib/index.js
ADDED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport * from \"./codeLoaderBundle\";\nexport * from \"./exportFile\";\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { ITelemetryBaseEvent, ITelemetryBaseLogger } from "@fluidframework/common-definitions";
|
|
6
|
+
/**
|
|
7
|
+
* Logger that writes events into a defined file
|
|
8
|
+
*/
|
|
9
|
+
export declare class FileLogger implements ITelemetryBaseLogger {
|
|
10
|
+
private readonly filePath;
|
|
11
|
+
private readonly eventsPerFlush;
|
|
12
|
+
supportsTags?: true | undefined;
|
|
13
|
+
/** Hold events in memory until flushed */
|
|
14
|
+
private events;
|
|
15
|
+
/**
|
|
16
|
+
* @param filePath - file path to write logs to
|
|
17
|
+
* @param eventsPerFlush - number of events per flush
|
|
18
|
+
*/
|
|
19
|
+
constructor(filePath: string, eventsPerFlush?: number);
|
|
20
|
+
flush(): Promise<void>;
|
|
21
|
+
send(event: ITelemetryBaseEvent): void;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=FileLogger.d.ts.map
|
|
@@ -0,0 +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;AAE/F;;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"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from "fs";
|
|
6
|
+
/**
|
|
7
|
+
* Logger that writes events into a defined file
|
|
8
|
+
*/
|
|
9
|
+
export class FileLogger {
|
|
10
|
+
/**
|
|
11
|
+
* @param filePath - file path to write logs to
|
|
12
|
+
* @param eventsPerFlush - number of events per flush
|
|
13
|
+
*/
|
|
14
|
+
constructor(filePath, eventsPerFlush = 50) {
|
|
15
|
+
this.filePath = filePath;
|
|
16
|
+
this.eventsPerFlush = eventsPerFlush;
|
|
17
|
+
/** Hold events in memory until flushed */
|
|
18
|
+
this.events = [];
|
|
19
|
+
}
|
|
20
|
+
async flush() {
|
|
21
|
+
if (this.events.length > 0) {
|
|
22
|
+
fs.appendFileSync(this.filePath, this.events.join("\n"));
|
|
23
|
+
this.events = [];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
send(event) {
|
|
27
|
+
const logEvent = JSON.stringify(event);
|
|
28
|
+
this.events.push(logEvent);
|
|
29
|
+
if (this.events.length >= this.eventsPerFlush || event.category === "error") {
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
31
|
+
this.flush();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=FileLogger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileLogger.js","sourceRoot":"","sources":["../../src/logger/FileLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAGzB;;GAEG;AACH,MAAM,OAAO,UAAU;IAMnB;;;OAGG;IACH,YACqB,QAAgB,EAChB,iBAAyB,EAAE;QAD3B,aAAQ,GAAR,QAAQ,CAAQ;QAChB,mBAAc,GAAd,cAAc,CAAa;QAThD,0CAA0C;QAClC,WAAM,GAAa,EAAE,CAAC;IAS1B,CAAC;IAEE,KAAK,CAAC,KAAK;QACd,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YACxB,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACzD,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;SACpB;IACL,CAAC;IAEM,IAAI,CAAC,KAA0B;QAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAEvC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE3B,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,cAAc,IAAI,KAAK,CAAC,QAAQ,KAAK,OAAO,EAAE;YACzE,mEAAmE;YACnE,IAAI,CAAC,KAAK,EAAE,CAAC;SAChB;IACL,CAAC;CACJ","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 { ITelemetryBaseEvent, ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\n\n/**\n * Logger that writes events into a defined file\n */\nexport class FileLogger implements ITelemetryBaseLogger {\n public supportsTags?: true | undefined;\n\n /** Hold events in memory until flushed */\n private events: string[] = [];\n\n /**\n * @param filePath - file path to write logs to\n * @param eventsPerFlush - number of events per flush\n */\n public constructor(\n private readonly filePath: string,\n private readonly eventsPerFlush: number = 50,\n ) { }\n\n public async flush(): Promise<void> {\n if (this.events.length > 0) {\n fs.appendFileSync(this.filePath, this.events.join(\"\\n\"));\n this.events = [];\n }\n }\n\n public send(event: ITelemetryBaseEvent): void {\n const logEvent = JSON.stringify(event);\n\n this.events.push(logEvent);\n\n if (this.events.length >= this.eventsPerFlush || event.category === \"error\") {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.flush();\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
|
+
*/
|
|
7
|
+
export declare const pkgName = "@fluidframework/fluid-runner";
|
|
8
|
+
export declare const pkgVersion = "1.2.0";
|
|
9
|
+
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,iCAAiC,CAAC;AACtD,eAAO,MAAM,UAAU,UAAU,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
|
+
*/
|
|
7
|
+
export const pkgName = "@fluidframework/fluid-runner";
|
|
8
|
+
export const pkgVersion = "1.2.0";
|
|
9
|
+
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,8BAA8B,CAAC;AACtD,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/fluid-runner\";\nexport const pkgVersion = \"1.2.0\";\n"]}
|