@uipath/gov-tool 1.206.0-preview.312 → 1.206.0-preview.323

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 (2) hide show
  1. package/dist/tool.js +73 -13
  2. package/package.json +2 -2
package/dist/tool.js CHANGED
@@ -96,7 +96,7 @@ function settlePromiseLike(thenable) {
96
96
  }
97
97
 
98
98
  // ../../auth/src/constants.ts
99
- var UIPATH_HOME_DIR = ".uipath", AUTH_FILENAME = ".auth", DEFAULT_BASE_URL = "https://cloud.uipath.com", DEFAULT_AUTH_TIMEOUT_MS;
99
+ var UIPATH_HOME_DIR = ".uipath", AUTH_FILENAME = ".auth", AUTH_FILE_MODE = 384, AUTH_DIR_MODE = 448, DEFAULT_BASE_URL = "https://cloud.uipath.com", DEFAULT_AUTH_TIMEOUT_MS;
100
100
  var init_constants = __esm(() => {
101
101
  DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
102
102
  });
@@ -779,12 +779,26 @@ class NodeFileSystem {
779
779
  throw error;
780
780
  }
781
781
  }
782
- async writeFile(filePath, data) {
782
+ async writeFile(filePath, data, options) {
783
783
  const dir = path2.dirname(filePath);
784
784
  if (dir) {
785
785
  await fs6.mkdir(dir, { recursive: true });
786
786
  }
787
- await fs6.writeFile(filePath, data);
787
+ if (options?.mode === undefined || process.platform === "win32") {
788
+ if (options?.exclusive) {
789
+ await fs6.writeFile(filePath, data, { flag: "wx" });
790
+ } else {
791
+ await fs6.writeFile(filePath, data);
792
+ }
793
+ return;
794
+ }
795
+ const handle = await fs6.open(filePath, options.exclusive ? "wx" : "w", options.mode);
796
+ try {
797
+ await handle.chmod(options.mode);
798
+ await handle.writeFile(data);
799
+ } finally {
800
+ await handle.close();
801
+ }
788
802
  }
789
803
  async appendFile(filePath, data) {
790
804
  const dir = path2.dirname(filePath);
@@ -819,7 +833,8 @@ class NodeFileSystem {
819
833
  isDirectory: () => stats.isDirectory(),
820
834
  size: stats.size,
821
835
  mtimeMs: stats.mtimeMs,
822
- ctimeMs: stats.ctimeMs
836
+ ctimeMs: stats.ctimeMs,
837
+ mode: stats.mode
823
838
  };
824
839
  } catch (error) {
825
840
  if (this.isEnoent(error))
@@ -830,8 +845,13 @@ class NodeFileSystem {
830
845
  async exists(filePath) {
831
846
  return existsSync(filePath);
832
847
  }
833
- async mkdir(dirPath) {
834
- await fs6.mkdir(dirPath, { recursive: true });
848
+ async mkdir(dirPath, options) {
849
+ await fs6.mkdir(dirPath, { recursive: true, mode: options?.mode });
850
+ }
851
+ async chmod(targetPath, mode) {
852
+ if (process.platform === "win32")
853
+ return;
854
+ await fs6.chmod(targetPath, mode);
835
855
  }
836
856
  async acquireLock(lockPath) {
837
857
  const canonicalPath = await this.canonicalizeLockTarget(lockPath);
@@ -7691,7 +7711,7 @@ var package_default = {
7691
7711
  name: "@uipath/gov-tool",
7692
7712
  author: "UiPath",
7693
7713
  license: "SEE LICENSE IN LICENSE.txt",
7694
- version: "1.206.0-preview.312",
7714
+ version: "1.206.0-preview.323",
7695
7715
  description: "Manage UiPath governance — AOps policies, Access policies, and compliance packs.",
7696
7716
  private: false,
7697
7717
  repository: {
@@ -9737,6 +9757,38 @@ var loadEnvFileAsync = async ({ envPath }) => {
9737
9757
  }
9738
9758
  return parseEnvContent(content);
9739
9759
  };
9760
+ var findAuthHomeDir = (fs, dir) => {
9761
+ let current = dir;
9762
+ for (;; ) {
9763
+ if (fs.path.basename(current) === UIPATH_HOME_DIR)
9764
+ return current;
9765
+ const parent = fs.path.dirname(current);
9766
+ if (parent === current)
9767
+ return;
9768
+ current = parent;
9769
+ }
9770
+ };
9771
+ var TEMP_FILE_ATTEMPTS = 5;
9772
+ var isFileExists = (error) => error instanceof Error && error.code === "EEXIST";
9773
+ var writeTempFile = async (fs, targetPath, content) => {
9774
+ for (let attempt = 1;; attempt++) {
9775
+ const tempPath = `${targetPath}.${crypto.randomUUID()}.tmp`;
9776
+ try {
9777
+ await fs.writeFile(tempPath, content, {
9778
+ mode: AUTH_FILE_MODE,
9779
+ exclusive: true
9780
+ });
9781
+ return tempPath;
9782
+ } catch (error) {
9783
+ if (!isFileExists(error)) {
9784
+ await fs.rm(tempPath).catch(() => {});
9785
+ throw error;
9786
+ }
9787
+ if (attempt === TEMP_FILE_ATTEMPTS)
9788
+ throw error;
9789
+ }
9790
+ }
9791
+ };
9740
9792
  var saveEnvFileAsync = async ({
9741
9793
  envPath,
9742
9794
  data,
@@ -9764,10 +9816,18 @@ var saveEnvFileAsync = async ({
9764
9816
  `)}
9765
9817
  `;
9766
9818
  const dir = fs.path.dirname(absolutePath);
9767
- await fs.mkdir(dir);
9768
- const tempPath = `${absolutePath}.tmp`;
9769
- await fs.writeFile(tempPath, content);
9770
- await fs.rename(tempPath, absolutePath);
9819
+ await fs.mkdir(dir, { mode: AUTH_DIR_MODE });
9820
+ const authHomeDir = findAuthHomeDir(fs, dir);
9821
+ if (authHomeDir !== undefined) {
9822
+ await fs.chmod?.(authHomeDir, AUTH_DIR_MODE);
9823
+ }
9824
+ const tempPath = await writeTempFile(fs, absolutePath, content);
9825
+ try {
9826
+ await fs.rename(tempPath, absolutePath);
9827
+ } catch (error) {
9828
+ await fs.rm(tempPath).catch(() => {});
9829
+ throw error;
9830
+ }
9771
9831
  };
9772
9832
 
9773
9833
  // ../../auth/src/loginStatus.ts
@@ -15384,7 +15444,7 @@ var package_default3 = {
15384
15444
  name: "@uipath/aops-policy-sdk",
15385
15445
  author: "UiPath",
15386
15446
  license: "SEE LICENSE IN LICENSE.txt",
15387
- version: "1.206.0-preview.312",
15447
+ version: "1.206.0-preview.323",
15388
15448
  description: "SDK for the UiPath AOps Governance API — policy management and deployment.",
15389
15449
  repository: {
15390
15450
  type: "git",
@@ -24537,4 +24597,4 @@ export {
24537
24597
  registerCommands
24538
24598
  };
24539
24599
 
24540
- //# debugId=18840F2753E7D65A64756E2164756E21
24600
+ //# debugId=683FD4247B9F0E0164756E2164756E21
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/gov-tool",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.206.0-preview.312",
5
+ "version": "1.206.0-preview.323",
6
6
  "description": "Manage UiPath governance — AOps policies, Access policies, and compliance packs.",
7
7
  "private": false,
8
8
  "repository": {
@@ -24,5 +24,5 @@
24
24
  "files": [
25
25
  "dist"
26
26
  ],
27
- "gitHead": "ee91749054ba110153977dd920a4c84761ce82cd"
27
+ "gitHead": "a752d8a8d78de138e3be0a19642620fec7893d99"
28
28
  }