@itwin/presentation-testing 5.0.11 → 5.0.12

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,11 @@
1
1
  # Change Log - @itwin/presentation-testing
2
2
 
3
+ ## 5.0.12
4
+
5
+ ### Patch Changes
6
+
7
+ - [#616](https://github.com/iTwin/presentation/pull/616): Reserve more characters for iModel file name suffixes
8
+
3
9
  ## 5.0.11
4
10
 
5
11
  ### Patch Changes
@@ -19,7 +19,7 @@ export declare function createFileNameFromString(str: string): string;
19
19
  * a suffix to iModel file name. This constant should account for the maximum suffix length.
20
20
  * @internal
21
21
  */
22
- export declare const FILE_PATH_RESERVED_CHARACTERS = 12;
22
+ export declare const FILE_PATH_RESERVED_CHARACTERS = 13;
23
23
  /** @internal */
24
24
  export declare function limitFilePathLength(filePath: string): string;
25
25
  //# sourceMappingURL=InternalUtils.d.ts.map
@@ -50,7 +50,7 @@ exports.createFileNameFromString = createFileNameFromString;
50
50
  * a suffix to iModel file name. This constant should account for the maximum suffix length.
51
51
  * @internal
52
52
  */
53
- exports.FILE_PATH_RESERVED_CHARACTERS = 12;
53
+ exports.FILE_PATH_RESERVED_CHARACTERS = 13;
54
54
  /** @internal */
55
55
  function limitFilePathLength(filePath) {
56
56
  const { dir, name, ext } = path_1.default.parse(filePath);
@@ -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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BAAqB,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"]}
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,C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,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 = 13;\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"]}
@@ -19,7 +19,7 @@ export declare function createFileNameFromString(str: string): string;
19
19
  * a suffix to iModel file name. This constant should account for the maximum suffix length.
20
20
  * @internal
21
21
  */
22
- export declare const FILE_PATH_RESERVED_CHARACTERS = 12;
22
+ export declare const FILE_PATH_RESERVED_CHARACTERS = 13;
23
23
  /** @internal */
24
24
  export declare function limitFilePathLength(filePath: string): string;
25
25
  //# sourceMappingURL=InternalUtils.d.ts.map
@@ -40,7 +40,7 @@ export function createFileNameFromString(str) {
40
40
  * a suffix to iModel file name. This constant should account for the maximum suffix length.
41
41
  * @internal
42
42
  */
43
- export const FILE_PATH_RESERVED_CHARACTERS = 12;
43
+ export const FILE_PATH_RESERVED_CHARACTERS = 13;
44
44
  /** @internal */
45
45
  export function limitFilePathLength(filePath) {
46
46
  const { dir, name, ext } = path.parse(filePath);
@@ -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,cAAc,GAAG,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,QAAQ,MAAM,CAAC,CAAC,CAAC;IAC9F,UAAU,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;IAC/E,OAAO,cAAc,CAAC;AACxB,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;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,CAAC;AAEhD,gBAAgB;AAChB,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,iBAAiB,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"]}
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,cAAc,GAAG,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,QAAQ,MAAM,CAAC,CAAC,CAAC;IAC9F,UAAU,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;IAC/E,OAAO,cAAc,CAAC;AACxB,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;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,CAAC;AAEhD,gBAAgB;AAChB,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,iBAAiB,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 = 13;\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.11",
3
+ "version": "5.0.12",
4
4
  "description": "Testing utilities for iTwin.js Presentation library",
5
5
  "license": "MIT",
6
6
  "repository": {