@fluidframework/fluid-runner 2.0.0-dev.2.3.0.115467 → 2.0.0-dev.3.1.0.125672

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.
Files changed (77) hide show
  1. package/.eslintrc.js +11 -13
  2. package/.mocharc.js +2 -2
  3. package/README.md +23 -10
  4. package/dist/codeLoaderBundle.d.ts.map +1 -1
  5. package/dist/codeLoaderBundle.js +4 -2
  6. package/dist/codeLoaderBundle.js.map +1 -1
  7. package/dist/exportFile.d.ts.map +1 -1
  8. package/dist/exportFile.js +6 -3
  9. package/dist/exportFile.js.map +1 -1
  10. package/dist/fakeUrlResolver.d.ts.map +1 -1
  11. package/dist/fakeUrlResolver.js.map +1 -1
  12. package/dist/fluidRunner.d.ts.map +1 -1
  13. package/dist/fluidRunner.js +5 -6
  14. package/dist/fluidRunner.js.map +1 -1
  15. package/dist/getArgsValidationError.d.ts.map +1 -1
  16. package/dist/getArgsValidationError.js.map +1 -1
  17. package/dist/logger/baseFileLogger.d.ts.map +1 -1
  18. package/dist/logger/baseFileLogger.js.map +1 -1
  19. package/dist/logger/csvFileLogger.d.ts.map +1 -1
  20. package/dist/logger/csvFileLogger.js.map +1 -1
  21. package/dist/logger/fileLogger.d.ts.map +1 -1
  22. package/dist/logger/fileLogger.js.map +1 -1
  23. package/dist/logger/jsonFileLogger.d.ts.map +1 -1
  24. package/dist/logger/jsonFileLogger.js.map +1 -1
  25. package/dist/logger/loggerUtils.d.ts.map +1 -1
  26. package/dist/logger/loggerUtils.js +11 -3
  27. package/dist/logger/loggerUtils.js.map +1 -1
  28. package/dist/parseBundleAndExportFile.d.ts.map +1 -1
  29. package/dist/parseBundleAndExportFile.js.map +1 -1
  30. package/dist/utils.d.ts.map +1 -1
  31. package/dist/utils.js +2 -3
  32. package/dist/utils.js.map +1 -1
  33. package/lib/codeLoaderBundle.d.ts.map +1 -1
  34. package/lib/codeLoaderBundle.js +4 -2
  35. package/lib/codeLoaderBundle.js.map +1 -1
  36. package/lib/exportFile.d.ts.map +1 -1
  37. package/lib/exportFile.js +6 -3
  38. package/lib/exportFile.js.map +1 -1
  39. package/lib/fakeUrlResolver.d.ts.map +1 -1
  40. package/lib/fakeUrlResolver.js.map +1 -1
  41. package/lib/fluidRunner.d.ts.map +1 -1
  42. package/lib/fluidRunner.js +5 -6
  43. package/lib/fluidRunner.js.map +1 -1
  44. package/lib/getArgsValidationError.d.ts.map +1 -1
  45. package/lib/getArgsValidationError.js.map +1 -1
  46. package/lib/logger/baseFileLogger.d.ts.map +1 -1
  47. package/lib/logger/baseFileLogger.js.map +1 -1
  48. package/lib/logger/csvFileLogger.d.ts.map +1 -1
  49. package/lib/logger/csvFileLogger.js.map +1 -1
  50. package/lib/logger/fileLogger.d.ts.map +1 -1
  51. package/lib/logger/fileLogger.js.map +1 -1
  52. package/lib/logger/jsonFileLogger.d.ts.map +1 -1
  53. package/lib/logger/jsonFileLogger.js.map +1 -1
  54. package/lib/logger/loggerUtils.d.ts.map +1 -1
  55. package/lib/logger/loggerUtils.js +11 -3
  56. package/lib/logger/loggerUtils.js.map +1 -1
  57. package/lib/parseBundleAndExportFile.d.ts.map +1 -1
  58. package/lib/parseBundleAndExportFile.js.map +1 -1
  59. package/lib/utils.d.ts.map +1 -1
  60. package/lib/utils.js +2 -3
  61. package/lib/utils.js.map +1 -1
  62. package/package.json +21 -19
  63. package/prettier.config.cjs +1 -1
  64. package/src/codeLoaderBundle.ts +28 -24
  65. package/src/exportFile.ts +69 -58
  66. package/src/fakeUrlResolver.ts +35 -31
  67. package/src/fluidRunner.ts +92 -85
  68. package/src/getArgsValidationError.ts +14 -17
  69. package/src/logger/baseFileLogger.ts +44 -44
  70. package/src/logger/csvFileLogger.ts +20 -20
  71. package/src/logger/fileLogger.ts +15 -15
  72. package/src/logger/jsonFileLogger.ts +12 -12
  73. package/src/logger/loggerUtils.ts +47 -39
  74. package/src/parseBundleAndExportFile.ts +58 -50
  75. package/src/utils.ts +14 -15
  76. package/tsconfig.esnext.json +6 -6
  77. package/tsconfig.json +10 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/fluid-runner",
3
- "version": "2.0.0-dev.2.3.0.115467",
3
+ "version": "2.0.0-dev.3.1.0.125672",
4
4
  "description": "Utility for running various functionality inside a Fluid Framework environment",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -27,8 +27,8 @@
27
27
  "eslint": "eslint --format stylish src",
28
28
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
29
29
  "format": "npm run prettier:fix",
30
- "lint": "npm run eslint",
31
- "lint:fix": "npm run eslint:fix",
30
+ "lint": "npm run prettier && npm run eslint",
31
+ "lint:fix": "npm run prettier:fix && npm run eslint:fix",
32
32
  "prettier": "prettier --check . --ignore-path ../../../.prettierignore",
33
33
  "prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
34
34
  "test": "npm run test:mocha",
@@ -58,27 +58,28 @@
58
58
  "temp-directory": "nyc/.nyc_output"
59
59
  },
60
60
  "dependencies": {
61
- "@fluidframework/aqueduct": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
61
+ "@fluidframework/aqueduct": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
62
62
  "@fluidframework/common-definitions": "^0.20.1",
63
- "@fluidframework/container-definitions": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
64
- "@fluidframework/container-loader": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
65
- "@fluidframework/core-interfaces": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
66
- "@fluidframework/driver-definitions": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
67
- "@fluidframework/odsp-driver": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
68
- "@fluidframework/odsp-driver-definitions": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
69
- "@fluidframework/telemetry-utils": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
63
+ "@fluidframework/container-definitions": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
64
+ "@fluidframework/container-loader": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
65
+ "@fluidframework/core-interfaces": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
66
+ "@fluidframework/driver-definitions": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
67
+ "@fluidframework/odsp-driver": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
68
+ "@fluidframework/odsp-driver-definitions": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
69
+ "@fluidframework/telemetry-utils": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
70
70
  "json2csv": "^5.0.7",
71
71
  "yargs": "13.2.2"
72
72
  },
73
73
  "devDependencies": {
74
- "@fluid-tools/build-cli": "^0.7.0",
74
+ "@fluid-tools/build-cli": "^0.8.0",
75
75
  "@fluidframework/build-common": "^1.1.0",
76
- "@fluidframework/eslint-config-fluid": "^1.2.0",
77
- "@fluidframework/fluid-runner-previous": "npm:@fluidframework/fluid-runner@2.0.0-internal.2.2.0",
78
- "@fluidframework/mocha-test-setup": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
76
+ "@fluidframework/eslint-config-fluid": "^2.0.0",
77
+ "@fluidframework/fluid-runner-previous": "npm:@fluidframework/fluid-runner@2.0.0-internal.3.0.0",
78
+ "@fluidframework/mocha-test-setup": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
79
79
  "@rushstack/eslint-config": "^2.5.1",
80
80
  "@types/mocha": "^9.1.1",
81
- "@types/node": "^14.18.0",
81
+ "@types/node": "^14.18.36",
82
+ "@types/yargs": "^13",
82
83
  "concurrently": "^6.2.0",
83
84
  "cross-env": "^7.0.2",
84
85
  "eslint": "~8.6.0",
@@ -89,9 +90,10 @@
89
90
  "typescript": "~4.5.5"
90
91
  },
91
92
  "typeValidation": {
92
- "version": "2.0.0-internal.2.3.0",
93
- "baselineRange": ">=2.0.0-internal.2.2.0 <2.0.0-internal.2.3.0",
94
- "baselineVersion": "2.0.0-internal.2.2.0",
93
+ "version": "2.0.0-internal.3.1.0",
94
+ "previousVersionStyle": "~previousMinor",
95
+ "baselineRange": ">=2.0.0-internal.3.0.0 <2.0.0-internal.3.1.0",
96
+ "baselineVersion": "2.0.0-internal.3.0.0",
95
97
  "broken": {}
96
98
  }
97
99
  }
@@ -4,5 +4,5 @@
4
4
  */
5
5
 
6
6
  module.exports = {
7
- ...require("@fluidframework/build-common/prettier.config.cjs"),
7
+ ...require("@fluidframework/build-common/prettier.config.cjs"),
8
8
  };
@@ -12,33 +12,33 @@ import { FluidObject } from "@fluidframework/core-interfaces";
12
12
  * For an example, see "src/test/sampleCodeLoaders/sampleCodeLoader.ts"
13
13
  */
14
14
  export interface ICodeLoaderBundle {
15
- /**
16
- * Fluid export of all the required objects and functions
17
- */
18
- fluidExport: Promise<IFluidFileConverter>;
15
+ /**
16
+ * Fluid export of all the required objects and functions
17
+ */
18
+ fluidExport: Promise<IFluidFileConverter>;
19
19
  }
20
20
 
21
21
  /**
22
22
  * Instance that holds all the details for Fluid file conversion
23
23
  */
24
24
  export interface IFluidFileConverter {
25
- /**
26
- * Get code loader details to provide at Loader creation
27
- * @param logger - created logger object to pass to code loader
28
- */
29
- getCodeLoader(logger: ITelemetryBaseLogger): Promise<ICodeDetailsLoader>;
25
+ /**
26
+ * Get code loader details to provide at Loader creation
27
+ * @param logger - created logger object to pass to code loader
28
+ */
29
+ getCodeLoader(logger: ITelemetryBaseLogger): Promise<ICodeDetailsLoader>;
30
30
 
31
- /**
32
- * Scope object to provide at Loader creation
33
- */
34
- scope?: FluidObject;
31
+ /**
32
+ * Scope object to provide at Loader creation
33
+ */
34
+ scope?: FluidObject;
35
35
 
36
- /**
37
- * Executes code on container and returns the result
38
- * @param container - container created by this application
39
- * @param options - additional options
40
- */
41
- execute(container: IContainer, options?: string): Promise<string>;
36
+ /**
37
+ * Executes code on container and returns the result
38
+ * @param container - container created by this application
39
+ * @param options - additional options
40
+ */
41
+ execute(container: IContainer, options?: string): Promise<string>;
42
42
  }
43
43
 
44
44
  /**
@@ -46,12 +46,16 @@ export interface IFluidFileConverter {
46
46
  * @param bundle - bundle provided to this application
47
47
  */
48
48
  export function isCodeLoaderBundle(bundle: any): bundle is ICodeLoaderBundle {
49
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
50
- return bundle?.fluidExport && typeof bundle.fluidExport === "object";
49
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
50
+ return bundle?.fluidExport && typeof bundle.fluidExport === "object";
51
51
  }
52
52
 
53
53
  export function isFluidFileConverter(obj: any): obj is IFluidFileConverter {
54
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
55
- return obj?.getCodeLoader && typeof obj.getCodeLoader === "function"
56
- && obj.execute && typeof obj.execute === "function";
54
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
55
+ return (
56
+ obj?.getCodeLoader &&
57
+ typeof obj.getCodeLoader === "function" &&
58
+ obj.execute &&
59
+ typeof obj.execute === "function"
60
+ );
57
61
  }
package/src/exportFile.ts CHANGED
@@ -21,14 +21,14 @@ import { createLogger, getTelemetryFileValidationError } from "./logger/loggerUt
21
21
  export type IExportFileResponse = IExportFileResponseSuccess | IExportFileResponseFailure;
22
22
 
23
23
  interface IExportFileResponseSuccess {
24
- success: true;
24
+ success: true;
25
25
  }
26
26
 
27
27
  interface IExportFileResponseFailure {
28
- success: false;
29
- eventName: string;
30
- errorMessage: string;
31
- error?: any;
28
+ success: false;
29
+ eventName: string;
30
+ errorMessage: string;
31
+ error?: any;
32
32
  }
33
33
 
34
34
  const clientArgsValidationError = "Client_ArgsValidationError";
@@ -37,45 +37,52 @@ const clientArgsValidationError = "Client_ArgsValidationError";
37
37
  * Execute code on Container based on ODSP snapshot and write result to file
38
38
  */
39
39
  export async function exportFile(
40
- fluidFileConverter: IFluidFileConverter,
41
- inputFile: string,
42
- outputFile: string,
43
- telemetryFile: string,
44
- options?: string,
45
- telemetryOptions?: ITelemetryOptions,
40
+ fluidFileConverter: IFluidFileConverter,
41
+ inputFile: string,
42
+ outputFile: string,
43
+ telemetryFile: string,
44
+ options?: string,
45
+ telemetryOptions?: ITelemetryOptions,
46
46
  ): Promise<IExportFileResponse> {
47
- const telemetryArgError = getTelemetryFileValidationError(telemetryFile);
48
- if (telemetryArgError) {
49
- const eventName = clientArgsValidationError;
50
- return { success: false, eventName, errorMessage: telemetryArgError };
51
- }
52
- const { fileLogger, logger } = createLogger(telemetryFile, telemetryOptions);
47
+ const telemetryArgError = getTelemetryFileValidationError(telemetryFile);
48
+ if (telemetryArgError) {
49
+ const eventName = clientArgsValidationError;
50
+ return { success: false, eventName, errorMessage: telemetryArgError };
51
+ }
52
+ const { fileLogger, logger } = createLogger(telemetryFile, telemetryOptions);
53
53
 
54
- try {
55
- return await PerformanceEvent.timedExecAsync(logger, { eventName: "ExportFile" }, async () => {
56
- const argsValidationError = getArgsValidationError(inputFile, outputFile);
57
- if (argsValidationError) {
58
- const eventName = clientArgsValidationError;
59
- logger.sendErrorEvent({ eventName, message: argsValidationError });
60
- return { success: false, eventName, errorMessage: argsValidationError };
61
- }
54
+ try {
55
+ return await PerformanceEvent.timedExecAsync(
56
+ logger,
57
+ { eventName: "ExportFile" },
58
+ async () => {
59
+ const argsValidationError = getArgsValidationError(inputFile, outputFile);
60
+ if (argsValidationError) {
61
+ const eventName = clientArgsValidationError;
62
+ logger.sendErrorEvent({ eventName, message: argsValidationError });
63
+ return { success: false, eventName, errorMessage: argsValidationError };
64
+ }
62
65
 
63
- fs.writeFileSync(outputFile, await createContainerAndExecute(
64
- getSnapshotFileContent(inputFile),
65
- fluidFileConverter,
66
- logger,
67
- options,
68
- ));
66
+ fs.writeFileSync(
67
+ outputFile,
68
+ await createContainerAndExecute(
69
+ getSnapshotFileContent(inputFile),
70
+ fluidFileConverter,
71
+ logger,
72
+ options,
73
+ ),
74
+ );
69
75
 
70
- return { success: true };
71
- });
72
- } catch (error) {
73
- const eventName = "Client_UnexpectedError";
74
- logger.sendErrorEvent({ eventName }, error);
75
- return { success: false, eventName, errorMessage: "Unexpected error", error };
76
- } finally {
77
- await fileLogger.close();
78
- }
76
+ return { success: true };
77
+ },
78
+ );
79
+ } catch (error) {
80
+ const eventName = "Client_UnexpectedError";
81
+ logger.sendErrorEvent({ eventName }, error);
82
+ return { success: false, eventName, errorMessage: "Unexpected error", error };
83
+ } finally {
84
+ await fileLogger.close();
85
+ }
79
86
  }
80
87
 
81
88
  /**
@@ -83,25 +90,29 @@ export async function exportFile(
83
90
  * @returns result of execution
84
91
  */
85
92
  export async function createContainerAndExecute(
86
- localOdspSnapshot: string | Uint8Array,
87
- fluidFileConverter: IFluidFileConverter,
88
- logger: ITelemetryLogger,
89
- options?: string,
93
+ localOdspSnapshot: string | Uint8Array,
94
+ fluidFileConverter: IFluidFileConverter,
95
+ logger: ITelemetryLogger,
96
+ options?: string,
90
97
  ): Promise<string> {
91
- const loader = new Loader({
92
- urlResolver: new FakeUrlResolver(),
93
- documentServiceFactory: createLocalOdspDocumentServiceFactory(localOdspSnapshot),
94
- codeLoader: await fluidFileConverter.getCodeLoader(logger),
95
- scope: fluidFileConverter.scope,
96
- logger,
97
- });
98
+ const loader = new Loader({
99
+ urlResolver: new FakeUrlResolver(),
100
+ documentServiceFactory: createLocalOdspDocumentServiceFactory(localOdspSnapshot),
101
+ codeLoader: await fluidFileConverter.getCodeLoader(logger),
102
+ scope: fluidFileConverter.scope,
103
+ logger,
104
+ });
98
105
 
99
- const container = await loader.resolve({ url: "/fakeUrl/", headers: {
100
- [LoaderHeader.loadMode]: { opsBeforeReturn: "cached" } } });
106
+ const container = await loader.resolve({
107
+ url: "/fakeUrl/",
108
+ headers: {
109
+ [LoaderHeader.loadMode]: { opsBeforeReturn: "cached" },
110
+ },
111
+ });
101
112
 
102
- return PerformanceEvent.timedExecAsync(logger, { eventName: "ExportFile" }, async () => {
103
- const result = await fluidFileConverter.execute(container, options);
104
- container.close();
105
- return result;
106
- });
113
+ return PerformanceEvent.timedExecAsync(logger, { eventName: "ExportFile" }, async () => {
114
+ const result = await fluidFileConverter.execute(container, options);
115
+ container.close();
116
+ return result;
117
+ });
107
118
  }
@@ -4,7 +4,11 @@
4
4
  */
5
5
 
6
6
  import { IRequest } from "@fluidframework/core-interfaces";
7
- import { IContainerPackageInfo, IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions";
7
+ import {
8
+ IContainerPackageInfo,
9
+ IResolvedUrl,
10
+ IUrlResolver,
11
+ } from "@fluidframework/driver-definitions";
8
12
  import { IOdspResolvedUrl } from "@fluidframework/odsp-driver-definitions";
9
13
 
10
14
  const fakeId = "FakeUrlResolver";
@@ -15,36 +19,36 @@ const fakeUrl = "/FakeUrlResolver/";
15
19
  * @internal
16
20
  */
17
21
  export class FakeUrlResolver implements IUrlResolver {
18
- public async resolve(_request: IRequest): Promise<IResolvedUrl | undefined> {
19
- const fakeOdspResolvedUrl: IOdspResolvedUrl = {
20
- type: "fluid",
21
- odspResolvedUrl: true,
22
- id: fakeId,
23
- siteUrl: fakeUrl,
24
- driveId: fakeId,
25
- itemId: fakeId,
26
- url: fakeUrl,
27
- hashedDocumentId: fakeId,
28
- endpoints: {
29
- snapshotStorageUrl: fakeUrl,
30
- attachmentPOSTStorageUrl: fakeUrl,
31
- attachmentGETStorageUrl: fakeUrl,
32
- deltaStorageUrl: fakeUrl,
33
- },
34
- tokens: {},
35
- fileName: fakeId,
36
- summarizer: false,
37
- fileVersion: fakeId,
38
- };
22
+ public async resolve(_request: IRequest): Promise<IResolvedUrl | undefined> {
23
+ const fakeOdspResolvedUrl: IOdspResolvedUrl = {
24
+ type: "fluid",
25
+ odspResolvedUrl: true,
26
+ id: fakeId,
27
+ siteUrl: fakeUrl,
28
+ driveId: fakeId,
29
+ itemId: fakeId,
30
+ url: fakeUrl,
31
+ hashedDocumentId: fakeId,
32
+ endpoints: {
33
+ snapshotStorageUrl: fakeUrl,
34
+ attachmentPOSTStorageUrl: fakeUrl,
35
+ attachmentGETStorageUrl: fakeUrl,
36
+ deltaStorageUrl: fakeUrl,
37
+ },
38
+ tokens: {},
39
+ fileName: fakeId,
40
+ summarizer: false,
41
+ fileVersion: fakeId,
42
+ };
39
43
 
40
- return fakeOdspResolvedUrl;
41
- }
44
+ return fakeOdspResolvedUrl;
45
+ }
42
46
 
43
- public async getAbsoluteUrl(
44
- _resolvedUrl: IResolvedUrl,
45
- _relativeUrl: string,
46
- _packageInfoSource?: IContainerPackageInfo,
47
- ): Promise<string> {
48
- return "";
49
- }
47
+ public async getAbsoluteUrl(
48
+ _resolvedUrl: IResolvedUrl,
49
+ _relativeUrl: string,
50
+ _packageInfoSource?: IContainerPackageInfo,
51
+ ): Promise<string> {
52
+ return "";
53
+ }
50
54
  }
@@ -3,7 +3,6 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- /* eslint-disable max-len */
7
6
  import * as yargs from "yargs";
8
7
  import { exportFile } from "./exportFile";
9
8
  import { IFluidFileConverter } from "./codeLoaderBundle";
@@ -16,90 +15,98 @@ import { validateCommandLineArgs } from "./utils";
16
15
  * @param fluidFileConverter - needs to be provided if "codeLoaderBundle" is not and vice versa
17
16
  */
18
17
  export function fluidRunner(fluidFileConverter?: IFluidFileConverter) {
19
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
20
- yargs
21
- .strict()
22
- .version(false)
23
- .command(
24
- "exportFile",
25
- "Generate an output for a local ODSP snapshot",
26
- // eslint-disable-next-line @typescript-eslint/no-shadow
27
- (yargs) =>
28
- yargs
29
- .option("codeLoader", {
30
- describe: "Path to code loader bundle. Required if this application is being called without modification.\nSee \"README.md\" for more details.",
31
- type: "string",
32
- demandOption: false,
33
- })
34
- .option("inputFile", {
35
- describe: "Path to local ODSP snapshot",
36
- type: "string",
37
- demandOption: true,
38
- })
39
- .option("outputFile", {
40
- describe: "Path of output file (cannot already exist).\nExecution result will be written here",
41
- type: "string",
42
- demandOption: true,
43
- })
44
- .option("telemetryFile", {
45
- describe: "Path of telemetry file for config and session data (cannot already exist)",
46
- type: "string",
47
- demandOption: true,
48
- })
49
- .option("options", {
50
- describe: "Additional options passed to container on execution",
51
- type: "string",
52
- demandOption: false,
53
- })
54
- .option("telemetryFormat", {
55
- describe: "Output format for telemetry. Current options are: [\"JSON\", \"CSV\"]",
56
- type: "string",
57
- demandOption: false,
58
- default: "JSON",
59
- })
60
- .option("telemetryProp", {
61
- describe: "Property to add to every telemetry entry. Formatted like \"--telemetryProp prop1 value1 --telemetryProp prop2 \\\"value 2\\\"\".",
62
- type: "array",
63
- demandOption: false,
64
- }),
65
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
66
- async (argv) => {
67
- const argsError = validateCommandLineArgs(argv.codeLoader, fluidFileConverter);
68
- if (argsError) {
69
- console.error(argsError);
70
- process.exit(1);
71
- }
72
- const telemetryOptionsResult = validateAndParseTelemetryOptions(argv.telemetryFormat, argv.telemetryProp);
73
- if (!telemetryOptionsResult.success) {
74
- console.error(telemetryOptionsResult.error);
75
- process.exit(1);
76
- }
18
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
19
+ yargs
20
+ .strict()
21
+ .version(false)
22
+ .command(
23
+ "exportFile",
24
+ "Generate an output for a local ODSP snapshot",
25
+ // eslint-disable-next-line @typescript-eslint/no-shadow
26
+ (yargs) =>
27
+ yargs
28
+ .option("codeLoader", {
29
+ describe:
30
+ 'Path to code loader bundle. Required if this application is being called without modification.\nSee "README.md" for more details.',
31
+ type: "string",
32
+ demandOption: false,
33
+ })
34
+ .option("inputFile", {
35
+ describe: "Path to local ODSP snapshot",
36
+ type: "string",
37
+ demandOption: true,
38
+ })
39
+ .option("outputFile", {
40
+ describe:
41
+ "Path of output file (cannot already exist).\nExecution result will be written here",
42
+ type: "string",
43
+ demandOption: true,
44
+ })
45
+ .option("telemetryFile", {
46
+ describe:
47
+ "Path of telemetry file for config and session data (cannot already exist)",
48
+ type: "string",
49
+ demandOption: true,
50
+ })
51
+ .option("options", {
52
+ describe: "Additional options passed to container on execution",
53
+ type: "string",
54
+ demandOption: false,
55
+ })
56
+ .option("telemetryFormat", {
57
+ describe:
58
+ 'Output format for telemetry. Current options are: ["JSON", "CSV"]',
59
+ type: "string",
60
+ demandOption: false,
61
+ default: "JSON",
62
+ })
63
+ .option("telemetryProp", {
64
+ describe:
65
+ 'Property to add to every telemetry entry. Formatted like "--telemetryProp prop1 value1 --telemetryProp prop2 \\"value 2\\"".',
66
+ type: "array",
67
+ demandOption: false,
68
+ }),
69
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
70
+ async (argv) => {
71
+ const argsError = validateCommandLineArgs(argv.codeLoader, fluidFileConverter);
72
+ if (argsError) {
73
+ console.error(argsError);
74
+ process.exit(1);
75
+ }
76
+ const telemetryOptionsResult = validateAndParseTelemetryOptions(
77
+ argv.telemetryFormat,
78
+ argv.telemetryProp,
79
+ );
80
+ if (!telemetryOptionsResult.success) {
81
+ console.error(telemetryOptionsResult.error);
82
+ process.exit(1);
83
+ }
77
84
 
78
- const result = await (argv.codeLoader
79
- ? parseBundleAndExportFile(
80
- argv.codeLoader,
81
- argv.inputFile,
82
- argv.outputFile,
83
- argv.telemetryFile,
84
- argv.options,
85
- telemetryOptionsResult.telemetryOptions,
86
- ) : exportFile(
87
- fluidFileConverter!,
88
- argv.inputFile,
89
- argv.outputFile,
90
- argv.telemetryFile,
91
- argv.options,
92
- telemetryOptionsResult.telemetryOptions,
93
- ));
85
+ const result = await (argv.codeLoader
86
+ ? parseBundleAndExportFile(
87
+ argv.codeLoader,
88
+ argv.inputFile,
89
+ argv.outputFile,
90
+ argv.telemetryFile,
91
+ argv.options,
92
+ telemetryOptionsResult.telemetryOptions,
93
+ )
94
+ : exportFile(
95
+ fluidFileConverter!,
96
+ argv.inputFile,
97
+ argv.outputFile,
98
+ argv.telemetryFile,
99
+ argv.options,
100
+ telemetryOptionsResult.telemetryOptions,
101
+ ));
94
102
 
95
- if (!result.success) {
96
- console.error(`${result.eventName}: ${result.errorMessage}`);
97
- process.exit(1);
98
- }
99
- process.exit(0);
100
- },
101
- )
102
- .help()
103
- .demandCommand().argv;
103
+ if (!result.success) {
104
+ console.error(`${result.eventName}: ${result.errorMessage}`);
105
+ process.exit(1);
106
+ }
107
+ process.exit(0);
108
+ },
109
+ )
110
+ .help()
111
+ .demandCommand().argv;
104
112
  }
105
- /* eslint-enable max-len */
@@ -5,23 +5,20 @@
5
5
 
6
6
  import * as fs from "fs";
7
7
 
8
- export function getArgsValidationError(
9
- inputFile: string,
10
- outputFile: string,
11
- ): string | undefined {
12
- // Validate input file
13
- if (!inputFile) {
14
- return "Input file name argument is missing.";
15
- } else if (!fs.existsSync(inputFile)) {
16
- return "Input file does not exist.";
17
- }
8
+ export function getArgsValidationError(inputFile: string, outputFile: string): string | undefined {
9
+ // Validate input file
10
+ if (!inputFile) {
11
+ return "Input file name argument is missing.";
12
+ } else if (!fs.existsSync(inputFile)) {
13
+ return "Input file does not exist.";
14
+ }
18
15
 
19
- // Validate output file
20
- if (!outputFile) {
21
- return "Output file argument is missing.";
22
- } else if (fs.existsSync(outputFile)) {
23
- return `Output file already exists [${outputFile}].`;
24
- }
16
+ // Validate output file
17
+ if (!outputFile) {
18
+ return "Output file argument is missing.";
19
+ } else if (fs.existsSync(outputFile)) {
20
+ return `Output file already exists [${outputFile}].`;
21
+ }
25
22
 
26
- return undefined;
23
+ return undefined;
27
24
  }