keycloakify 10.0.0-rc.20 → 10.0.0-rc.21

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/bin/main.js CHANGED
@@ -6624,6 +6624,7 @@ var yauzl_1 = __importDefault(__nccwpck_require__(78781));
6624
6624
  var stream_1 = __importDefault(__nccwpck_require__(12781));
6625
6625
  var Deferred_1 = __nccwpck_require__(50689);
6626
6626
  var path_1 = __nccwpck_require__(71017);
6627
+ var fs_existsAsync_1 = __nccwpck_require__(43765);
6627
6628
  function extractArchive(params) {
6628
6629
  return __awaiter(this, void 0, void 0, function () {
6629
6630
  var archiveFilePath, onArchiveFile, zipFile, dDone, writeFile, readFile;
@@ -6652,21 +6653,27 @@ function extractArchive(params) {
6652
6653
  dDone.resolve();
6653
6654
  });
6654
6655
  writeFile = function (entry, params) { return __awaiter(_this, void 0, void 0, function () {
6655
- var filePath, modifiedData, readStream, dDoneWithFile;
6656
+ var filePath, modifiedData, dirPath, readStream, dDoneWithFile;
6656
6657
  var _this = this;
6657
6658
  return __generator(this, function (_a) {
6658
6659
  switch (_a.label) {
6659
6660
  case 0:
6660
6661
  filePath = params.filePath, modifiedData = params.modifiedData;
6661
- return [4 /*yield*/, promises_1.default.mkdir((0, path_1.dirname)(filePath), { recursive: true })];
6662
+ dirPath = (0, path_1.dirname)(filePath);
6663
+ return [4 /*yield*/, (0, fs_existsAsync_1.existsAsync)(dirPath)];
6662
6664
  case 1:
6665
+ if (!!(_a.sent())) return [3 /*break*/, 3];
6666
+ return [4 /*yield*/, promises_1.default.mkdir(dirPath, { recursive: true })];
6667
+ case 2:
6663
6668
  _a.sent();
6664
- if (!(modifiedData !== undefined)) return [3 /*break*/, 3];
6669
+ _a.label = 3;
6670
+ case 3:
6671
+ if (!(modifiedData !== undefined)) return [3 /*break*/, 5];
6665
6672
  return [4 /*yield*/, promises_1.default.writeFile(filePath, modifiedData)];
6666
- case 2:
6673
+ case 4:
6667
6674
  _a.sent();
6668
6675
  return [2 /*return*/];
6669
- case 3: return [4 /*yield*/, new Promise(function (resolve) {
6676
+ case 5: return [4 /*yield*/, new Promise(function (resolve) {
6670
6677
  return zipFile.openReadStream(entry, function (error, readStream) { return __awaiter(_this, void 0, void 0, function () {
6671
6678
  return __generator(this, function (_a) {
6672
6679
  if (error) {
@@ -6678,7 +6685,7 @@ function extractArchive(params) {
6678
6685
  });
6679
6686
  }); });
6680
6687
  })];
6681
- case 4:
6688
+ case 6:
6682
6689
  readStream = _a.sent();
6683
6690
  dDoneWithFile = new Deferred_1.Deferred();
6684
6691
  stream_1.default.pipeline(readStream, fs_1.default.createWriteStream(filePath), function (error) {
@@ -6689,7 +6696,7 @@ function extractArchive(params) {
6689
6696
  dDoneWithFile.resolve();
6690
6697
  });
6691
6698
  return [4 /*yield*/, dDoneWithFile.pr];
6692
- case 5:
6699
+ case 7:
6693
6700
  _a.sent();
6694
6701
  return [2 /*return*/];
6695
6702
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keycloakify",
3
- "version": "10.0.0-rc.20",
3
+ "version": "10.0.0-rc.21",
4
4
  "description": "Create Keycloak themes using React",
5
5
  "repository": {
6
6
  "type": "git",
@@ -4,12 +4,14 @@ import yauzl from "yauzl";
4
4
  import stream from "stream";
5
5
  import { Deferred } from "evt/tools/Deferred";
6
6
  import { dirname as pathDirname, sep as pathSep } from "path";
7
+ import { existsAsync } from "./fs.existsAsync";
7
8
 
8
9
  export async function extractArchive(params: {
9
10
  archiveFilePath: string;
10
11
  onArchiveFile: (params: {
11
12
  relativeFilePathInArchive: string;
12
13
  readFile: () => Promise<Buffer>;
14
+ /** NOTE: Will create the directory if it does not exist */
13
15
  writeFile: (params: { filePath: string; modifiedData?: Buffer }) => Promise<void>;
14
16
  earlyExit: () => void;
15
17
  }) => Promise<void>;
@@ -42,7 +44,13 @@ export async function extractArchive(params: {
42
44
  ): Promise<void> => {
43
45
  const { filePath, modifiedData } = params;
44
46
 
45
- await fs.mkdir(pathDirname(filePath), { recursive: true });
47
+ {
48
+ const dirPath = pathDirname(filePath);
49
+
50
+ if (!(await existsAsync(dirPath))) {
51
+ await fs.mkdir(dirPath, { recursive: true });
52
+ }
53
+ }
46
54
 
47
55
  if (modifiedData !== undefined) {
48
56
  await fs.writeFile(filePath, modifiedData);
@@ -1704,6 +1704,7 @@ var yauzl_1 = __importDefault(__nccwpck_require__(8781));
1704
1704
  var stream_1 = __importDefault(__nccwpck_require__(2781));
1705
1705
  var Deferred_1 = __nccwpck_require__(689);
1706
1706
  var path_1 = __nccwpck_require__(1017);
1707
+ var fs_existsAsync_1 = __nccwpck_require__(3765);
1707
1708
  function extractArchive(params) {
1708
1709
  return __awaiter(this, void 0, void 0, function () {
1709
1710
  var archiveFilePath, onArchiveFile, zipFile, dDone, writeFile, readFile;
@@ -1732,21 +1733,27 @@ function extractArchive(params) {
1732
1733
  dDone.resolve();
1733
1734
  });
1734
1735
  writeFile = function (entry, params) { return __awaiter(_this, void 0, void 0, function () {
1735
- var filePath, modifiedData, readStream, dDoneWithFile;
1736
+ var filePath, modifiedData, dirPath, readStream, dDoneWithFile;
1736
1737
  var _this = this;
1737
1738
  return __generator(this, function (_a) {
1738
1739
  switch (_a.label) {
1739
1740
  case 0:
1740
1741
  filePath = params.filePath, modifiedData = params.modifiedData;
1741
- return [4 /*yield*/, promises_1.default.mkdir((0, path_1.dirname)(filePath), { recursive: true })];
1742
+ dirPath = (0, path_1.dirname)(filePath);
1743
+ return [4 /*yield*/, (0, fs_existsAsync_1.existsAsync)(dirPath)];
1742
1744
  case 1:
1745
+ if (!!(_a.sent())) return [3 /*break*/, 3];
1746
+ return [4 /*yield*/, promises_1.default.mkdir(dirPath, { recursive: true })];
1747
+ case 2:
1743
1748
  _a.sent();
1744
- if (!(modifiedData !== undefined)) return [3 /*break*/, 3];
1749
+ _a.label = 3;
1750
+ case 3:
1751
+ if (!(modifiedData !== undefined)) return [3 /*break*/, 5];
1745
1752
  return [4 /*yield*/, promises_1.default.writeFile(filePath, modifiedData)];
1746
- case 2:
1753
+ case 4:
1747
1754
  _a.sent();
1748
1755
  return [2 /*return*/];
1749
- case 3: return [4 /*yield*/, new Promise(function (resolve) {
1756
+ case 5: return [4 /*yield*/, new Promise(function (resolve) {
1750
1757
  return zipFile.openReadStream(entry, function (error, readStream) { return __awaiter(_this, void 0, void 0, function () {
1751
1758
  return __generator(this, function (_a) {
1752
1759
  if (error) {
@@ -1758,7 +1765,7 @@ function extractArchive(params) {
1758
1765
  });
1759
1766
  }); });
1760
1767
  })];
1761
- case 4:
1768
+ case 6:
1762
1769
  readStream = _a.sent();
1763
1770
  dDoneWithFile = new Deferred_1.Deferred();
1764
1771
  stream_1.default.pipeline(readStream, fs_1.default.createWriteStream(filePath), function (error) {
@@ -1769,7 +1776,7 @@ function extractArchive(params) {
1769
1776
  dDoneWithFile.resolve();
1770
1777
  });
1771
1778
  return [4 /*yield*/, dDoneWithFile.pr];
1772
- case 5:
1779
+ case 7:
1773
1780
  _a.sent();
1774
1781
  return [2 /*return*/];
1775
1782
  }