@itwin/core-backend 5.0.0-dev.16 → 5.0.0-dev.20

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.
@@ -1 +1 @@
1
- {"version":3,"file":"IModelJsFs.d.ts","sourceRoot":"","sources":["../../src/IModelJsFs.ts"],"names":[],"mappings":"AAeA;;GAEG;AACH,qBAAa,eAAe;IAEjB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,MAAM;IACf,WAAW,EAAE,MAAM;IACnB,WAAW,EAAE,OAAO;IACpB,MAAM,EAAE,OAAO;IACf,QAAQ,EAAE,OAAO;IACjB,cAAc,EAAE,OAAO;IACvB,UAAU,EAAE,OAAO;gBARnB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,OAAO,EACpB,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,OAAO,EACjB,cAAc,EAAE,OAAO,EACvB,UAAU,EAAE,OAAO;CAE7B;AAED;;GAEG;AACH,qBAAa,UAAU;IAErB,oCAAoC;WACtB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAEnD,qBAAqB;WACP,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAEhD,mDAAmD;WACrC,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAEhD,0BAA0B;WACZ,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAE/C,0BAA0B;WACZ,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAE/C,uBAAuB;WACT,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,KAAK,GAAE,MAAY,GAAG,IAAI;IAEnG,wBAAwB;WACV,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE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,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,GAAG,IAAI;IAkBnG,uEAAuE;WACzD,kBAAkB,CAAC,OAAO,EAAE,MAAM;IAehD,sCAAsC;WACxB,YAAY,CAAC,OAAO,EAAE,MAAM;CAc3C"}
@@ -118,7 +118,14 @@ class IModelJsFs {
118
118
  const parentPath = path.dirname(dirPath);
119
119
  if (parentPath !== dirPath)
120
120
  IModelJsFs.recursiveMkDirSync(parentPath);
121
- IModelJsFs.mkdirSync(dirPath);
121
+ try {
122
+ IModelJsFs.mkdirSync(dirPath);
123
+ }
124
+ catch (err) {
125
+ // Ignore the error if the folder has been created since the existence check
126
+ if (err?.code !== "EEXIST")
127
+ throw err;
128
+ }
122
129
  }
123
130
  /** Remove a directory, recursively */
124
131
  static purgeDirSync(dirPath) {
@@ -1 +1 @@
1
- {"version":3,"file":"IModelJsFs.js","sourceRoot":"","sources":["../../src/IModelJsFs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,uBAAuB;AAEvB,+BAA+B;AAC/B,6BAA6B;AAE7B,uDAAuD;AACvD;;GAEG;AACH,MAAa,eAAe;IAC1B,YACS,IAAY,EACZ,OAAe,EACf,OAAe,EACf,WAAmB,EACnB,WAAoB,EACpB,MAAe,EACf,QAAiB,EACjB,cAAuB,EACvB,UAAmB;QARnB,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAAQ;QACf,gBAAW,GAAX,WAAW,CAAQ;QACnB,gBAAW,GAAX,WAAW,CAAS;QACpB,WAAM,GAAN,MAAM,CAAS;QACf,aAAQ,GAAR,QAAQ,CAAS;QACjB,mBAAc,GAAd,cAAc,CAAS;QACvB,eAAU,GAAV,UAAU,CAAS;IACxB,CAAC;CACN;AAZD,0CAYC;AAED;;GAEG;AACH,MAAa,UAAU;IAErB,oCAAoC;IAC7B,MAAM,CAAC,UAAU,CAAC,QAAgB,IAAa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AAC;IAChC,CAAC;IAED,sCAAsC;IAC/B,MAAM,CAAC,YAAY,CAAC,OAAe;QACxC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC;YACjC,OAAO;QAET,UAAU,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC,QAAgB,EAAE,KAAc,EAAE,EAAE;YACnE,IAAI,KAAK,EAAE,CAAC;gBACV,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;gBAClC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YAClC,CAAC;iBAAM,CAAC;gBACN,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YAClC,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAhID,gCAgIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Portability\r\n */\r\n\r\n// cspell: ignore wflag\r\n\r\nimport * as fs from \"fs-extra\";\r\nimport * as path from \"path\";\r\n\r\n/* TODO: define File Mode Constants: S_IWUSR, et al. */\r\n/** Information about a file. See [[IModelJsFs.lstatSync]]\r\n * @public\r\n */\r\nexport class IModelJsFsStats {\r\n constructor(\r\n public size: number,\r\n public atimeMs: number,\r\n public mtimeMs: number,\r\n public birthtimeMs: number,\r\n public isDirectory: boolean,\r\n public isFile: boolean,\r\n public isSocket: boolean,\r\n public isSymbolicLink: boolean,\r\n public isReadOnly: boolean,\r\n ) { }\r\n}\r\n\r\n/** File system operations that are defined on all platforms. See also [[Platform]] and [[KnownLocations]]\r\n * @public\r\n */\r\nexport class IModelJsFs {\r\n\r\n /** Does file or directory exist? */\r\n public static existsSync(pathname: string): boolean { return fs.existsSync(pathname); }\r\n\r\n /** Delete a file. */\r\n public static unlinkSync(pathname: string): void { fs.unlinkSync(pathname); }\r\n\r\n /** Delete a file or remove a directory (rm -r). */\r\n public static removeSync(pathname: string): void { fs.removeSync(pathname); }\r\n\r\n /** Create a directory. */\r\n public static mkdirSync(pathname: string): void { fs.mkdirSync(pathname); }\r\n\r\n /** Remove a directory. */\r\n public static rmdirSync(pathname: string): void { fs.rmdirSync(pathname); }\r\n\r\n /** Write to a file. */\r\n public static writeFileSync(pathname: string, data: string | Uint8Array, wflag: string = \"w\"): void { fs.writeFileSync(pathname, data, { flag: wflag }); }\r\n\r\n /** Append to a file. */\r\n public static appendFileSync(pathname: string, str: string): void { fs.appendFileSync(pathname, str); }\r\n\r\n /** Make a copy of a file */\r\n public static copySync(src: string, dest: string, opts?: any): void { fs.copySync(src, dest, opts); }\r\n\r\n /** Gets the file and directory names in the specified directory. Excludes \".\" and \"..\". Returns an empty array if the specified directory does not exist. */\r\n public static readdirSync(pathname: string): string[] { return fs.existsSync(pathname) ? fs.readdirSync(pathname) : []; }\r\n\r\n /** Read file */\r\n public static readFileSync(pathname: string): string | Buffer { return fs.readFileSync(pathname); }\r\n\r\n /** Test if the current user has permission to write to a file. */\r\n private static isFileWritable(pathname: string): boolean {\r\n try {\r\n fs.accessSync(pathname, fs.constants.W_OK);\r\n return true;\r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n /** Get information about a file. */\r\n public static lstatSync(pathname: string): IModelJsFsStats | undefined {\r\n const stats = fs.lstatSync(pathname);\r\n if (stats === undefined)\r\n return undefined;\r\n\r\n return new IModelJsFsStats(\r\n stats.size,\r\n stats.atime.getTime(),\r\n stats.mtime.getTime(),\r\n stats.birthtime.getTime(),\r\n stats.isDirectory(),\r\n stats.isFile(),\r\n stats.isSocket(),\r\n stats.isSymbolicLink(),\r\n !IModelJsFs.isFileWritable(pathname));\r\n }\r\n\r\n /**\r\n * Finds files recursively based on a pattern\r\n * @param rootDir Directory from where to start searching for files.\r\n * @param pattern A Regex that would be match to basename of files including extension\r\n * @returns list of file that match the pattern.\r\n */\r\n public static recursiveFindSync(rootDir: string, pattern: RegExp): string[] {\r\n const files: string[] = [];\r\n IModelJsFs.walkDirSync(rootDir, (pathname: string, isDir: boolean) => {\r\n if (!isDir) {\r\n const fileName = path.basename(pathname);\r\n if (pattern.test(fileName)) {\r\n files.push(pathname);\r\n }\r\n }\r\n return true;\r\n });\r\n return files;\r\n }\r\n\r\n /**\r\n * Walks a directory in breadth first fashion\r\n * @param rootDir directory from where the traversal starts\r\n * @param cb callback that would be called with full path of file or directory\r\n */\r\n public static walkDirSync(rootDir: string, cb: (pathname: string, isDir: boolean) => boolean): void {\r\n const subDir = [];\r\n for (const childPath of IModelJsFs.readdirSync(rootDir)) {\r\n const fullPath = path.join(rootDir, childPath);\r\n const isDir = IModelJsFs.lstatSync(fullPath)?.isDirectory;\r\n if (!cb(fullPath, isDir ?? false)) {\r\n return;\r\n }\r\n // Need to check if the directory still exists in case the callback has deleted it.\r\n if (isDir && IModelJsFs.existsSync(fullPath)) {\r\n subDir.push(fullPath);\r\n }\r\n }\r\n subDir.forEach((v) => {\r\n IModelJsFs.walkDirSync(v, cb);\r\n });\r\n }\r\n\r\n /** Create a directory, recursively setting up the path as necessary */\r\n public static recursiveMkDirSync(dirPath: string) {\r\n if (IModelJsFs.existsSync(dirPath))\r\n return;\r\n const parentPath = path.dirname(dirPath);\r\n if (parentPath !== dirPath)\r\n IModelJsFs.recursiveMkDirSync(parentPath);\r\n IModelJsFs.mkdirSync(dirPath);\r\n }\r\n\r\n /** Remove a directory, recursively */\r\n public static purgeDirSync(dirPath: string) {\r\n if (!IModelJsFs.existsSync(dirPath))\r\n return;\r\n\r\n IModelJsFs.walkDirSync(dirPath, (pathName: string, isDir: boolean) => {\r\n if (isDir) {\r\n IModelJsFs.purgeDirSync(pathName);\r\n IModelJsFs.removeSync(pathName);\r\n } else {\r\n IModelJsFs.unlinkSync(pathName);\r\n }\r\n return true;\r\n });\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"IModelJsFs.js","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AAC,QAAQ,CAAC,CAAC;YAClC,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAtID,gCAsIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Portability\r\n */\r\n\r\n// cspell: ignore wflag\r\n\r\nimport * as fs from \"fs-extra\";\r\nimport * as path from \"path\";\r\n\r\n/* TODO: define File Mode Constants: S_IWUSR, et al. */\r\n/** Information about a file. See [[IModelJsFs.lstatSync]]\r\n * @public\r\n */\r\nexport class IModelJsFsStats {\r\n constructor(\r\n public size: number,\r\n public atimeMs: number,\r\n public mtimeMs: number,\r\n public birthtimeMs: number,\r\n public isDirectory: boolean,\r\n public isFile: boolean,\r\n public isSocket: boolean,\r\n public isSymbolicLink: boolean,\r\n public isReadOnly: boolean,\r\n ) { }\r\n}\r\n\r\n/** File system operations that are defined on all platforms. See also [[Platform]] and [[KnownLocations]]\r\n * @public\r\n */\r\nexport class IModelJsFs {\r\n\r\n /** Does file or directory exist? */\r\n public static existsSync(pathname: string): boolean { return fs.existsSync(pathname); }\r\n\r\n /** Delete a file. */\r\n public static unlinkSync(pathname: string): void { fs.unlinkSync(pathname); }\r\n\r\n /** Delete a file or remove a directory (rm -r). */\r\n public static removeSync(pathname: string): void { fs.removeSync(pathname); }\r\n\r\n /** Create a directory. */\r\n public static mkdirSync(pathname: string): void { fs.mkdirSync(pathname); }\r\n\r\n /** Remove a directory. */\r\n public static rmdirSync(pathname: string): void { fs.rmdirSync(pathname); }\r\n\r\n /** Write to a file. */\r\n public static writeFileSync(pathname: string, data: string | Uint8Array, wflag: string = \"w\"): void { fs.writeFileSync(pathname, data, { flag: wflag }); }\r\n\r\n /** Append to a file. */\r\n public static appendFileSync(pathname: string, str: string): void { fs.appendFileSync(pathname, str); }\r\n\r\n /** Make a copy of a file */\r\n public static copySync(src: string, dest: string, opts?: any): void { fs.copySync(src, dest, opts); }\r\n\r\n /** Gets the file and directory names in the specified directory. Excludes \".\" and \"..\". Returns an empty array if the specified directory does not exist. */\r\n public static readdirSync(pathname: string): string[] { return fs.existsSync(pathname) ? fs.readdirSync(pathname) : []; }\r\n\r\n /** Read file */\r\n public static readFileSync(pathname: string): string | Buffer { return fs.readFileSync(pathname); }\r\n\r\n /** Test if the current user has permission to write to a file. */\r\n private static isFileWritable(pathname: string): boolean {\r\n try {\r\n fs.accessSync(pathname, fs.constants.W_OK);\r\n return true;\r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n /** Get information about a file. */\r\n public static lstatSync(pathname: string): IModelJsFsStats | undefined {\r\n const stats = fs.lstatSync(pathname);\r\n if (stats === undefined)\r\n return undefined;\r\n\r\n return new IModelJsFsStats(\r\n stats.size,\r\n stats.atime.getTime(),\r\n stats.mtime.getTime(),\r\n stats.birthtime.getTime(),\r\n stats.isDirectory(),\r\n stats.isFile(),\r\n stats.isSocket(),\r\n stats.isSymbolicLink(),\r\n !IModelJsFs.isFileWritable(pathname));\r\n }\r\n\r\n /**\r\n * Finds files recursively based on a pattern\r\n * @param rootDir Directory from where to start searching for files.\r\n * @param pattern A Regex that would be match to basename of files including extension\r\n * @returns list of file that match the pattern.\r\n */\r\n public static recursiveFindSync(rootDir: string, pattern: RegExp): string[] {\r\n const files: string[] = [];\r\n IModelJsFs.walkDirSync(rootDir, (pathname: string, isDir: boolean) => {\r\n if (!isDir) {\r\n const fileName = path.basename(pathname);\r\n if (pattern.test(fileName)) {\r\n files.push(pathname);\r\n }\r\n }\r\n return true;\r\n });\r\n return files;\r\n }\r\n\r\n /**\r\n * Walks a directory in breadth first fashion\r\n * @param rootDir directory from where the traversal starts\r\n * @param cb callback that would be called with full path of file or directory\r\n */\r\n public static walkDirSync(rootDir: string, cb: (pathname: string, isDir: boolean) => boolean): void {\r\n const subDir = [];\r\n for (const childPath of IModelJsFs.readdirSync(rootDir)) {\r\n const fullPath = path.join(rootDir, childPath);\r\n const isDir = IModelJsFs.lstatSync(fullPath)?.isDirectory;\r\n if (!cb(fullPath, isDir ?? false)) {\r\n return;\r\n }\r\n // Need to check if the directory still exists in case the callback has deleted it.\r\n if (isDir && IModelJsFs.existsSync(fullPath)) {\r\n subDir.push(fullPath);\r\n }\r\n }\r\n subDir.forEach((v) => {\r\n IModelJsFs.walkDirSync(v, cb);\r\n });\r\n }\r\n\r\n /** Create a directory, recursively setting up the path as necessary */\r\n public static recursiveMkDirSync(dirPath: string) {\r\n if (IModelJsFs.existsSync(dirPath))\r\n return;\r\n const parentPath = path.dirname(dirPath);\r\n if (parentPath !== dirPath)\r\n IModelJsFs.recursiveMkDirSync(parentPath);\r\n try {\r\n IModelJsFs.mkdirSync(dirPath);\r\n } catch (err: any) {\r\n // Ignore the error if the folder has been created since the existence check\r\n if (err?.code !== \"EEXIST\")\r\n throw err;\r\n }\r\n }\r\n\r\n /** Remove a directory, recursively */\r\n public static purgeDirSync(dirPath: string) {\r\n if (!IModelJsFs.existsSync(dirPath))\r\n return;\r\n\r\n IModelJsFs.walkDirSync(dirPath, (pathName: string, isDir: boolean) => {\r\n if (isDir) {\r\n IModelJsFs.purgeDirSync(pathName);\r\n IModelJsFs.removeSync(pathName);\r\n } else {\r\n IModelJsFs.unlinkSync(pathName);\r\n }\r\n return true;\r\n });\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/core-backend",
3
- "version": "5.0.0-dev.16",
3
+ "version": "5.0.0-dev.20",
4
4
  "description": "iTwin.js backend components",
5
5
  "main": "lib/cjs/core-backend.js",
6
6
  "typings": "lib/cjs/core-backend",
@@ -25,9 +25,9 @@
25
25
  "url": "http://www.bentley.com"
26
26
  },
27
27
  "peerDependencies": {
28
- "@itwin/core-bentley": "^5.0.0-dev.16",
29
- "@itwin/core-common": "^5.0.0-dev.16",
30
- "@itwin/core-geometry": "^5.0.0-dev.16",
28
+ "@itwin/core-bentley": "^5.0.0-dev.20",
29
+ "@itwin/core-common": "^5.0.0-dev.20",
30
+ "@itwin/core-geometry": "^5.0.0-dev.20",
31
31
  "@opentelemetry/api": "^1.0.4"
32
32
  },
33
33
  "peerDependenciesMeta": {
@@ -68,16 +68,16 @@
68
68
  "source-map-loader": "^4.0.0",
69
69
  "typescript": "~5.6.2",
70
70
  "webpack": "^5.76.0",
71
- "@itwin/build-tools": "5.0.0-dev.16",
72
- "@itwin/core-bentley": "5.0.0-dev.16",
73
- "@itwin/core-geometry": "5.0.0-dev.16",
74
- "@itwin/core-common": "5.0.0-dev.16",
75
- "internal-tools": "3.0.0-dev.69",
76
- "@itwin/core-webpack-tools": "5.0.0-dev.16",
77
- "@itwin/ecsql-common": "5.0.0-dev.16"
71
+ "@itwin/build-tools": "5.0.0-dev.20",
72
+ "@itwin/core-common": "5.0.0-dev.20",
73
+ "@itwin/core-bentley": "5.0.0-dev.20",
74
+ "@itwin/ecsql-common": "5.0.0-dev.20",
75
+ "@itwin/core-geometry": "5.0.0-dev.20",
76
+ "@itwin/core-webpack-tools": "5.0.0-dev.20",
77
+ "internal-tools": "3.0.0-dev.69"
78
78
  },
79
79
  "dependencies": {
80
- "@bentley/imodeljs-native": "5.0.12",
80
+ "@bentley/imodeljs-native": "5.0.15",
81
81
  "@itwin/cloud-agnostic-core": "^2.2.4",
82
82
  "@itwin/object-storage-azure": "^2.2.5",
83
83
  "@itwin/object-storage-core": "^2.2.5",
@@ -91,7 +91,7 @@
91
91
  "semver": "^7.5.2",
92
92
  "touch": "^3.1.0",
93
93
  "ws": "^7.5.10",
94
- "@itwin/core-telemetry": "5.0.0-dev.16"
94
+ "@itwin/core-telemetry": "5.0.0-dev.20"
95
95
  },
96
96
  "nyc": {
97
97
  "extends": "./node_modules/@itwin/build-tools/.nycrc"
@@ -112,7 +112,7 @@
112
112
  "ios:webpack:tests": "TESTS_GLOB=./lib/**/*.test.js webpack --config ../../tools/internal/ios/ios.webpack.config.js",
113
113
  "ios:copy:assets": "cpx \"./src/test/assets/**/*\" ../../tools/internal/lib/ios/assets/assets && cpx \"./src/assets/**/*\" ../../tools/internal/lib/ios/assets/assets",
114
114
  "ios:build:tests": "npm run -s build && npm run -s ios:webpack:tests && npm run -s ios:copy:assets",
115
- "ios:build:core-test-runner": "cd ../../tools/internal/ios/core-test-runner && xcrun xcodebuild -derivedDataPath ./build/DerivedData build CODE_SIGN_STYLE=Manual CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO PROVISIONING_PROFILE_SPECIFIER= -scheme core-test-runner -arch x86_64 -sdk iphonesimulator -configuration Debug",
115
+ "ios:build:core-test-runner": "cd ../../tools/internal/ios/core-test-runner && xcrun xcodebuild -derivedDataPath ./build/DerivedData build CODE_SIGN_STYLE=Manual CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO PROVISIONING_PROFILE_SPECIFIER= -scheme core-test-runner -arch arm64 -sdk iphonesimulator -configuration Debug",
116
116
  "ios:tests:simulator": "node scripts/runUnitTestsIosSimulator.mjs",
117
117
  "ios:all": "npm run ios:build:tests && npm run ios:build:core-test-runner && npm run ios:tests:simulator"
118
118
  }