@itwin/presentation-testing 5.0.9 → 5.0.11

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Change Log - @itwin/presentation-testing
2
2
 
3
+ ## 5.0.11
4
+
5
+ ### Patch Changes
6
+
7
+ - [#613](https://github.com/iTwin/presentation/pull/613): When creating a test iModel, limit its file name length to fit into file system limits.
8
+
9
+ ## 5.0.10
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies:
14
+ - @itwin/presentation-components@5.3.2
15
+
3
16
  ## 5.0.9
4
17
 
5
18
  ### Patch Changes
@@ -8,10 +8,18 @@ export declare function setTestOutputDir(directoryPath: string | undefined): voi
8
8
  * - Resolving the output file name under the known test output directory
9
9
  * - Making directories as necessary
10
10
  * - Removing a previous copy of the output file
11
- * @param fileName Name of output file
11
+ * @param fileName Name of output file. The actual file name may get modified to fit within the file system limits.
12
12
  * @internal
13
13
  */
14
14
  export declare function setupOutputFileLocation(fileName: string): LocalFileName;
15
15
  /** @internal */
16
16
  export declare function createFileNameFromString(str: string): string;
17
+ /**
18
+ * `itwinjs-core` creates some accompanying files for each iModels and their names are formed by appending
19
+ * a suffix to iModel file name. This constant should account for the maximum suffix length.
20
+ * @internal
21
+ */
22
+ export declare const FILE_PATH_RESERVED_CHARACTERS = 12;
23
+ /** @internal */
24
+ export declare function limitFilePathLength(filePath: string): string;
17
25
  //# sourceMappingURL=InternalUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"InternalUtils.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/InternalUtils.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKnD,gBAAgB;AAChB,wBAAgB,gBAAgB,WAE/B;AAED,gBAAgB;AAChB,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,QAEjE;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,CAOvE;AAED,gBAAgB;AAChB,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,UAEnD"}
1
+ {"version":3,"file":"InternalUtils.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/InternalUtils.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKnD,gBAAgB;AAChB,wBAAgB,gBAAgB,WAE/B;AAED,gBAAgB;AAChB,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,QAEjE;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,CAOvE;AAED,gBAAgB;AAChB,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,UAEnD;AAED;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,KAAK,CAAC;AAEhD,gBAAgB;AAChB,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,UAiBnD"}
@@ -7,7 +7,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
7
7
  return (mod && mod.__esModule) ? mod : { "default": mod };
8
8
  };
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.createFileNameFromString = exports.setupOutputFileLocation = exports.setTestOutputDir = exports.getTestOutputDir = void 0;
10
+ exports.limitFilePathLength = exports.FILE_PATH_RESERVED_CHARACTERS = exports.createFileNameFromString = exports.setupOutputFileLocation = exports.setTestOutputDir = exports.getTestOutputDir = void 0;
11
11
  const os_1 = require("os");
12
12
  const path_1 = __importDefault(require("path"));
13
13
  const sanitize_filename_1 = __importDefault(require("sanitize-filename"));
@@ -29,15 +29,15 @@ exports.setTestOutputDir = setTestOutputDir;
29
29
  * - Resolving the output file name under the known test output directory
30
30
  * - Making directories as necessary
31
31
  * - Removing a previous copy of the output file
32
- * @param fileName Name of output file
32
+ * @param fileName Name of output file. The actual file name may get modified to fit within the file system limits.
33
33
  * @internal
34
34
  */
35
35
  function setupOutputFileLocation(fileName) {
36
36
  const outputDirectoryPath = getTestOutputDir();
37
37
  !core_backend_1.IModelJsFs.existsSync(outputDirectoryPath) && core_backend_1.IModelJsFs.mkdirSync(outputDirectoryPath);
38
- const outputFile = path_1.default.join(outputDirectoryPath, `${fileName}.bim`);
39
- core_backend_1.IModelJsFs.existsSync(outputFile) && core_backend_1.IModelJsFs.unlinkSync(outputFile);
40
- return outputFile;
38
+ const outputFilePath = limitFilePathLength(path_1.default.join(outputDirectoryPath, `${fileName}.bim`));
39
+ core_backend_1.IModelJsFs.existsSync(outputFilePath) && core_backend_1.IModelJsFs.unlinkSync(outputFilePath);
40
+ return outputFilePath;
41
41
  }
42
42
  exports.setupOutputFileLocation = setupOutputFileLocation;
43
43
  /** @internal */
@@ -45,4 +45,27 @@ function createFileNameFromString(str) {
45
45
  return (0, sanitize_filename_1.default)(str.replace(/[ ]+/g, "-").replaceAll("`", "").replaceAll("'", "")).toLocaleLowerCase();
46
46
  }
47
47
  exports.createFileNameFromString = createFileNameFromString;
48
+ /**
49
+ * `itwinjs-core` creates some accompanying files for each iModels and their names are formed by appending
50
+ * a suffix to iModel file name. This constant should account for the maximum suffix length.
51
+ * @internal
52
+ */
53
+ exports.FILE_PATH_RESERVED_CHARACTERS = 12;
54
+ /** @internal */
55
+ function limitFilePathLength(filePath) {
56
+ const { dir, name, ext } = path_1.default.parse(filePath);
57
+ const THREE_DOTS_LENGTH = 3;
58
+ let allowedFileNameLength = 260 - exports.FILE_PATH_RESERVED_CHARACTERS - (dir.length + 1) - ext.length;
59
+ if (name.length <= allowedFileNameLength) {
60
+ return filePath;
61
+ }
62
+ allowedFileNameLength -= THREE_DOTS_LENGTH;
63
+ if (allowedFileNameLength <= 0) {
64
+ throw new Error(`File path "${filePath}" is too long.`);
65
+ }
66
+ const pieceLength = allowedFileNameLength / 2;
67
+ const shortenedName = `${name.slice(0, Math.ceil(pieceLength))}...${name.slice(Math.ceil(name.length - pieceLength))}`;
68
+ return path_1.default.join(dir, `${shortenedName}${ext}`);
69
+ }
70
+ exports.limitFilePathLength = limitFilePathLength;
48
71
  //# sourceMappingURL=InternalUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InternalUtils.js","sourceRoot":"","sources":["../../../src/presentation-testing/InternalUtils.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;AAEhG,2BAA4B;AAC5B,gDAAwB;AACxB,0EAAyC;AACzC,sDAAiD;AAGjD,MAAM,oBAAoB,GAAG,IAAA,WAAM,GAAE,CAAC;AACtC,IAAI,aAAiC,CAAC;AAEtC,gBAAgB;AAChB,SAAgB,gBAAgB;IAC9B,OAAO,aAAa,IAAI,oBAAoB,CAAC;AAC/C,CAAC;AAFD,4CAEC;AAED,gBAAgB;AAChB,SAAgB,gBAAgB,CAAC,aAAiC;IAChE,aAAa,GAAG,aAAa,CAAC;AAChC,CAAC;AAFD,4CAEC;AAED;;;;;;;GAOG;AACH,SAAgB,uBAAuB,CAAC,QAAgB;IACtD,MAAM,mBAAmB,GAAG,gBAAgB,EAAE,CAAC;IAC/C,CAAC,yBAAU,CAAC,UAAU,CAAC,mBAAmB,CAAC,IAAI,yBAAU,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;IAEzF,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,QAAQ,MAAM,CAAC,CAAC;IACrE,yBAAU,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,yBAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACvE,OAAO,UAAU,CAAC;AACpB,CAAC;AAPD,0DAOC;AAED,gBAAgB;AAChB,SAAgB,wBAAwB,CAAC,GAAW;IAClD,OAAO,IAAA,2BAAQ,EAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;AACzG,CAAC;AAFD,4DAEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { tmpdir } from \"os\";\nimport path from \"path\";\nimport sanitize from \"sanitize-filename\";\nimport { IModelJsFs } from \"@itwin/core-backend\";\nimport { LocalFileName } from \"@itwin/core-common\";\n\nconst defaultTestOutputDir = tmpdir();\nlet testOutputDir: string | undefined;\n\n/** @internal */\nexport function getTestOutputDir() {\n return testOutputDir ?? defaultTestOutputDir;\n}\n\n/** @internal */\nexport function setTestOutputDir(directoryPath: string | undefined) {\n testOutputDir = directoryPath;\n}\n\n/**\n * Prepare for an output file by:\n * - Resolving the output file name under the known test output directory\n * - Making directories as necessary\n * - Removing a previous copy of the output file\n * @param fileName Name of output file\n * @internal\n */\nexport function setupOutputFileLocation(fileName: string): LocalFileName {\n const outputDirectoryPath = getTestOutputDir();\n !IModelJsFs.existsSync(outputDirectoryPath) && IModelJsFs.mkdirSync(outputDirectoryPath);\n\n const outputFile = path.join(outputDirectoryPath, `${fileName}.bim`);\n IModelJsFs.existsSync(outputFile) && IModelJsFs.unlinkSync(outputFile);\n return outputFile;\n}\n\n/** @internal */\nexport function createFileNameFromString(str: string) {\n return sanitize(str.replace(/[ ]+/g, \"-\").replaceAll(\"`\", \"\").replaceAll(\"'\", \"\")).toLocaleLowerCase();\n}\n"]}
1
+ {"version":3,"file":"InternalUtils.js","sourceRoot":"","sources":["../../../src/presentation-testing/InternalUtils.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;AAEhG,2BAA4B;AAC5B,gDAAwB;AACxB,0EAAyC;AACzC,sDAAiD;AAGjD,MAAM,oBAAoB,GAAG,IAAA,WAAM,GAAE,CAAC;AACtC,IAAI,aAAiC,CA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6B,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC;IAChG,IAAI,IAAI,CAAC,MAAM,IAAI,qBAAqB,EAAE,CAAC;QACzC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,qBAAqB,IAAI,iBAAiB,CAAC;IAC3C,IAAI,qBAAqB,IAAI,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,cAAc,QAAQ,gBAAgB,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,WAAW,GAAG,qBAAqB,GAAG,CAAC,CAAC;IAC9C,MAAM,aAAa,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC;IACvH,OAAO,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,aAAa,GAAG,GAAG,EAAE,CAAC,CAAC;AAClD,CAAC;AAjBD,kDAiBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { tmpdir } from \"os\";\nimport path from \"path\";\nimport sanitize from \"sanitize-filename\";\nimport { IModelJsFs } from \"@itwin/core-backend\";\nimport { LocalFileName } from \"@itwin/core-common\";\n\nconst defaultTestOutputDir = tmpdir();\nlet testOutputDir: string | undefined;\n\n/** @internal */\nexport function getTestOutputDir() {\n return testOutputDir ?? defaultTestOutputDir;\n}\n\n/** @internal */\nexport function setTestOutputDir(directoryPath: string | undefined) {\n testOutputDir = directoryPath;\n}\n\n/**\n * Prepare for an output file by:\n * - Resolving the output file name under the known test output directory\n * - Making directories as necessary\n * - Removing a previous copy of the output file\n * @param fileName Name of output file. The actual file name may get modified to fit within the file system limits.\n * @internal\n */\nexport function setupOutputFileLocation(fileName: string): LocalFileName {\n const outputDirectoryPath = getTestOutputDir();\n !IModelJsFs.existsSync(outputDirectoryPath) && IModelJsFs.mkdirSync(outputDirectoryPath);\n\n const outputFilePath = limitFilePathLength(path.join(outputDirectoryPath, `${fileName}.bim`));\n IModelJsFs.existsSync(outputFilePath) && IModelJsFs.unlinkSync(outputFilePath);\n return outputFilePath;\n}\n\n/** @internal */\nexport function createFileNameFromString(str: string) {\n return sanitize(str.replace(/[ ]+/g, \"-\").replaceAll(\"`\", \"\").replaceAll(\"'\", \"\")).toLocaleLowerCase();\n}\n\n/**\n * `itwinjs-core` creates some accompanying files for each iModels and their names are formed by appending\n * a suffix to iModel file name. This constant should account for the maximum suffix length.\n * @internal\n */\nexport const FILE_PATH_RESERVED_CHARACTERS = 12;\n\n/** @internal */\nexport function limitFilePathLength(filePath: string) {\n const { dir, name, ext } = path.parse(filePath);\n const THREE_DOTS_LENGTH = 3;\n\n let allowedFileNameLength = 260 - FILE_PATH_RESERVED_CHARACTERS - (dir.length + 1) - ext.length;\n if (name.length <= allowedFileNameLength) {\n return filePath;\n }\n\n allowedFileNameLength -= THREE_DOTS_LENGTH;\n if (allowedFileNameLength <= 0) {\n throw new Error(`File path \"${filePath}\" is too long.`);\n }\n\n const pieceLength = allowedFileNameLength / 2;\n const shortenedName = `${name.slice(0, Math.ceil(pieceLength))}...${name.slice(Math.ceil(name.length - pieceLength))}`;\n return path.join(dir, `${shortenedName}${ext}`);\n}\n"]}
@@ -8,10 +8,18 @@ export declare function setTestOutputDir(directoryPath: string | undefined): voi
8
8
  * - Resolving the output file name under the known test output directory
9
9
  * - Making directories as necessary
10
10
  * - Removing a previous copy of the output file
11
- * @param fileName Name of output file
11
+ * @param fileName Name of output file. The actual file name may get modified to fit within the file system limits.
12
12
  * @internal
13
13
  */
14
14
  export declare function setupOutputFileLocation(fileName: string): LocalFileName;
15
15
  /** @internal */
16
16
  export declare function createFileNameFromString(str: string): string;
17
+ /**
18
+ * `itwinjs-core` creates some accompanying files for each iModels and their names are formed by appending
19
+ * a suffix to iModel file name. This constant should account for the maximum suffix length.
20
+ * @internal
21
+ */
22
+ export declare const FILE_PATH_RESERVED_CHARACTERS = 12;
23
+ /** @internal */
24
+ export declare function limitFilePathLength(filePath: string): string;
17
25
  //# sourceMappingURL=InternalUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"InternalUtils.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/InternalUtils.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKnD,gBAAgB;AAChB,wBAAgB,gBAAgB,WAE/B;AAED,gBAAgB;AAChB,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,QAEjE;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,CAOvE;AAED,gBAAgB;AAChB,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,UAEnD"}
1
+ {"version":3,"file":"InternalUtils.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/InternalUtils.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKnD,gBAAgB;AAChB,wBAAgB,gBAAgB,WAE/B;AAED,gBAAgB;AAChB,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,QAEjE;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,CAOvE;AAED,gBAAgB;AAChB,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,UAEnD;AAED;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,KAAK,CAAC;AAEhD,gBAAgB;AAChB,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,UAiBnD"}
@@ -21,18 +21,40 @@ export function setTestOutputDir(directoryPath) {
21
21
  * - Resolving the output file name under the known test output directory
22
22
  * - Making directories as necessary
23
23
  * - Removing a previous copy of the output file
24
- * @param fileName Name of output file
24
+ * @param fileName Name of output file. The actual file name may get modified to fit within the file system limits.
25
25
  * @internal
26
26
  */
27
27
  export function setupOutputFileLocation(fileName) {
28
28
  const outputDirectoryPath = getTestOutputDir();
29
29
  !IModelJsFs.existsSync(outputDirectoryPath) && IModelJsFs.mkdirSync(outputDirectoryPath);
30
- const outputFile = path.join(outputDirectoryPath, `${fileName}.bim`);
31
- IModelJsFs.existsSync(outputFile) && IModelJsFs.unlinkSync(outputFile);
32
- return outputFile;
30
+ const outputFilePath = limitFilePathLength(path.join(outputDirectoryPath, `${fileName}.bim`));
31
+ IModelJsFs.existsSync(outputFilePath) && IModelJsFs.unlinkSync(outputFilePath);
32
+ return outputFilePath;
33
33
  }
34
34
  /** @internal */
35
35
  export function createFileNameFromString(str) {
36
36
  return sanitize(str.replace(/[ ]+/g, "-").replaceAll("`", "").replaceAll("'", "")).toLocaleLowerCase();
37
37
  }
38
+ /**
39
+ * `itwinjs-core` creates some accompanying files for each iModels and their names are formed by appending
40
+ * a suffix to iModel file name. This constant should account for the maximum suffix length.
41
+ * @internal
42
+ */
43
+ export const FILE_PATH_RESERVED_CHARACTERS = 12;
44
+ /** @internal */
45
+ export function limitFilePathLength(filePath) {
46
+ const { dir, name, ext } = path.parse(filePath);
47
+ const THREE_DOTS_LENGTH = 3;
48
+ let allowedFileNameLength = 260 - FILE_PATH_RESERVED_CHARACTERS - (dir.length + 1) - ext.length;
49
+ if (name.length <= allowedFileNameLength) {
50
+ return filePath;
51
+ }
52
+ allowedFileNameLength -= THREE_DOTS_LENGTH;
53
+ if (allowedFileNameLength <= 0) {
54
+ throw new Error(`File path "${filePath}" is too long.`);
55
+ }
56
+ const pieceLength = allowedFileNameLength / 2;
57
+ const shortenedName = `${name.slice(0, Math.ceil(pieceLength))}...${name.slice(Math.ceil(name.length - pieceLength))}`;
58
+ return path.join(dir, `${shortenedName}${ext}`);
59
+ }
38
60
  //# sourceMappingURL=InternalUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InternalUtils.js","sourceRoot":"","sources":["../../../src/presentation-testing/InternalUtils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGjD,MAAM,oBAAoB,GAAG,MAAM,EAAE,CAAC;AACtC,IAAI,aAAiC,CAAC;AAEtC,gBAAgB;AAChB,MAAM,UAAU,gBAAgB;IAC9B,OAAO,aAAa,IAAI,oBAAoB,CAAC;AAC/C,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,gBAAgB,CAAC,aAAiC;IAChE,aAAa,GAAG,aAAa,CAAC;AAChC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CAAC,QAAgB;IACtD,MAAM,mBAAmB,GAAG,gBAAgB,EAAE,CAAC;IAC/C,CAAC,UAAU,CAAC,UAAU,CAAC,mBAAmB,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;IAEzF,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,QAAQ,MAAM,CAAC,CAAC;IACrE,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACvE,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,wBAAwB,CAAC,GAAW;IAClD,OAAO,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;AACzG,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { tmpdir } from \"os\";\nimport path from \"path\";\nimport sanitize from \"sanitize-filename\";\nimport { IModelJsFs } from \"@itwin/core-backend\";\nimport { LocalFileName } from \"@itwin/core-common\";\n\nconst defaultTestOutputDir = tmpdir();\nlet testOutputDir: string | undefined;\n\n/** @internal */\nexport function getTestOutputDir() {\n return testOutputDir ?? defaultTestOutputDir;\n}\n\n/** @internal */\nexport function setTestOutputDir(directoryPath: string | undefined) {\n testOutputDir = directoryPath;\n}\n\n/**\n * Prepare for an output file by:\n * - Resolving the output file name under the known test output directory\n * - Making directories as necessary\n * - Removing a previous copy of the output file\n * @param fileName Name of output file\n * @internal\n */\nexport function setupOutputFileLocation(fileName: string): LocalFileName {\n const outputDirectoryPath = getTestOutputDir();\n !IModelJsFs.existsSync(outputDirectoryPath) && IModelJsFs.mkdirSync(outputDirectoryPath);\n\n const outputFile = path.join(outputDirectoryPath, `${fileName}.bim`);\n IModelJsFs.existsSync(outputFile) && IModelJsFs.unlinkSync(outputFile);\n return outputFile;\n}\n\n/** @internal */\nexport function createFileNameFromString(str: string) {\n return sanitize(str.replace(/[ ]+/g, \"-\").replaceAll(\"`\", \"\").replaceAll(\"'\", \"\")).toLocaleLowerCase();\n}\n"]}
1
+ {"version":3,"file":"InternalUtils.js","sourceRoot":"","sources":["../../../src/presentation-testing/InternalUtils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,UAAU,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B,GAAG,CAAC,CAAC;IAE5B,IAAI,qBAAqB,GAAG,GAAG,GAAG,6BAA6B,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC;IAChG,IAAI,IAAI,CAAC,MAAM,IAAI,qBAAqB,EAAE,CAAC;QACzC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,qBAAqB,IAAI,iBAAiB,CAAC;IAC3C,IAAI,qBAAqB,IAAI,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,cAAc,QAAQ,gBAAgB,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,WAAW,GAAG,qBAAqB,GAAG,CAAC,CAAC;IAC9C,MAAM,aAAa,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC;IACvH,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,aAAa,GAAG,GAAG,EAAE,CAAC,CAAC;AAClD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { tmpdir } from \"os\";\nimport path from \"path\";\nimport sanitize from \"sanitize-filename\";\nimport { IModelJsFs } from \"@itwin/core-backend\";\nimport { LocalFileName } from \"@itwin/core-common\";\n\nconst defaultTestOutputDir = tmpdir();\nlet testOutputDir: string | undefined;\n\n/** @internal */\nexport function getTestOutputDir() {\n return testOutputDir ?? defaultTestOutputDir;\n}\n\n/** @internal */\nexport function setTestOutputDir(directoryPath: string | undefined) {\n testOutputDir = directoryPath;\n}\n\n/**\n * Prepare for an output file by:\n * - Resolving the output file name under the known test output directory\n * - Making directories as necessary\n * - Removing a previous copy of the output file\n * @param fileName Name of output file. The actual file name may get modified to fit within the file system limits.\n * @internal\n */\nexport function setupOutputFileLocation(fileName: string): LocalFileName {\n const outputDirectoryPath = getTestOutputDir();\n !IModelJsFs.existsSync(outputDirectoryPath) && IModelJsFs.mkdirSync(outputDirectoryPath);\n\n const outputFilePath = limitFilePathLength(path.join(outputDirectoryPath, `${fileName}.bim`));\n IModelJsFs.existsSync(outputFilePath) && IModelJsFs.unlinkSync(outputFilePath);\n return outputFilePath;\n}\n\n/** @internal */\nexport function createFileNameFromString(str: string) {\n return sanitize(str.replace(/[ ]+/g, \"-\").replaceAll(\"`\", \"\").replaceAll(\"'\", \"\")).toLocaleLowerCase();\n}\n\n/**\n * `itwinjs-core` creates some accompanying files for each iModels and their names are formed by appending\n * a suffix to iModel file name. This constant should account for the maximum suffix length.\n * @internal\n */\nexport const FILE_PATH_RESERVED_CHARACTERS = 12;\n\n/** @internal */\nexport function limitFilePathLength(filePath: string) {\n const { dir, name, ext } = path.parse(filePath);\n const THREE_DOTS_LENGTH = 3;\n\n let allowedFileNameLength = 260 - FILE_PATH_RESERVED_CHARACTERS - (dir.length + 1) - ext.length;\n if (name.length <= allowedFileNameLength) {\n return filePath;\n }\n\n allowedFileNameLength -= THREE_DOTS_LENGTH;\n if (allowedFileNameLength <= 0) {\n throw new Error(`File path \"${filePath}\" is too long.`);\n }\n\n const pieceLength = allowedFileNameLength / 2;\n const shortenedName = `${name.slice(0, Math.ceil(pieceLength))}...${name.slice(Math.ceil(name.length - pieceLength))}`;\n return path.join(dir, `${shortenedName}${ext}`);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/presentation-testing",
3
- "version": "5.0.9",
3
+ "version": "5.0.11",
4
4
  "description": "Testing utilities for iTwin.js Presentation library",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -24,7 +24,7 @@
24
24
  "dependencies": {
25
25
  "rimraf": "^5.0.5",
26
26
  "sanitize-filename": "^1.6.3",
27
- "@itwin/presentation-components": "^5.3.1"
27
+ "@itwin/presentation-components": "^5.3.2"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@itwin/appui-abstract": "^4.1.0",