keycloakify 11.7.3 → 11.8.0

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 (30) hide show
  1. package/bin/{911.index.js → 297.index.js} +18918 -11359
  2. package/bin/355.index.js +41 -703
  3. package/bin/363.index.js +3 -0
  4. package/bin/369.index.js +968 -0
  5. package/bin/656.index.js +111 -0
  6. package/bin/{288.index.js → 664.index.js} +13 -119
  7. package/bin/780.index.js +9 -7
  8. package/bin/880.index.js +215 -160
  9. package/bin/932.index.js +965 -0
  10. package/bin/97.index.js +2092 -770
  11. package/bin/main.js +52 -24
  12. package/bin/shared/buildContext.d.ts +11 -3
  13. package/package.json +10 -13
  14. package/src/bin/initialize-account-theme/initialize-account-theme.ts +29 -27
  15. package/src/bin/initialize-account-theme/multi-page-boilerplate/i18n.ts +2 -2
  16. package/src/bin/initialize-email-theme.ts +103 -53
  17. package/src/bin/keycloakify/generateResources/generateResources.ts +285 -205
  18. package/src/bin/shared/{initializeSpa/addSyncExtensionsToPostinstallScript.ts → addSyncExtensionsToPostinstallScript.ts} +1 -1
  19. package/src/bin/shared/buildContext.ts +69 -24
  20. package/src/bin/shared/{initializeSpa/initializeSpa.ts → initializeSpa.ts} +3 -3
  21. package/src/bin/sync-extensions/getExtensionModuleFileSourceCodeReadyToBeCopied.ts +6 -0
  22. package/vite-plugin/index.js +48 -20
  23. package/bin/313.index.js +0 -377
  24. package/bin/678.index.js +0 -7565
  25. package/bin/9.index.js +0 -850
  26. package/bin/947.index.js +0 -1565
  27. package/bin/shared/initializeSpa/index.d.ts +0 -1
  28. package/src/bin/shared/initializeSpa/index.ts +0 -1
  29. /package/bin/shared/{initializeSpa/addSyncExtensionsToPostinstallScript.d.ts → addSyncExtensionsToPostinstallScript.d.ts} +0 -0
  30. /package/bin/shared/{initializeSpa/initializeSpa.d.ts → initializeSpa.d.ts} +0 -0
@@ -45,12 +45,16 @@ export type BuildContext = {
45
45
  environmentVariables: { name: string; default: string }[];
46
46
  themeSrcDirPath: string;
47
47
  implementedThemeTypes: {
48
- login: { isImplemented: boolean };
49
- email: { isImplemented: boolean };
48
+ login:
49
+ | { isImplemented: true }
50
+ | { isImplemented: false; isImplemented_native: boolean };
51
+ email: { isImplemented: false; isImplemented_native: boolean };
50
52
  account:
51
- | { isImplemented: false }
53
+ | { isImplemented: false; isImplemented_native: boolean }
52
54
  | { isImplemented: true; type: "Single-Page" | "Multi-Page" };
53
- admin: { isImplemented: boolean };
55
+ admin:
56
+ | { isImplemented: true }
57
+ | { isImplemented: false; isImplemented_native: boolean };
54
58
  };
55
59
  packageJsonFilePath: string;
56
60
  bundler: "vite" | "webpack";
@@ -434,27 +438,68 @@ export function getBuildContext(params: {
434
438
  assert<Equals<typeof bundler, never>>(false);
435
439
  })();
436
440
 
437
- const implementedThemeTypes: BuildContext["implementedThemeTypes"] = {
438
- login: {
439
- isImplemented: fs.existsSync(pathJoin(themeSrcDirPath, "login"))
440
- },
441
- email: {
442
- isImplemented: fs.existsSync(pathJoin(themeSrcDirPath, "email"))
443
- },
444
- account: (() => {
445
- if (buildOptions.accountThemeImplementation === "none") {
446
- return { isImplemented: false };
447
- }
441
+ const implementedThemeTypes: BuildContext["implementedThemeTypes"] = (() => {
442
+ const getIsNative = (dirPath: string) =>
443
+ fs.existsSync(pathJoin(dirPath, "theme.properties"));
448
444
 
449
- return {
450
- isImplemented: true,
451
- type: buildOptions.accountThemeImplementation
452
- };
453
- })(),
454
- admin: {
455
- isImplemented: fs.existsSync(pathJoin(themeSrcDirPath, "admin"))
456
- }
457
- };
445
+ return {
446
+ login: (() => {
447
+ const dirPath = pathJoin(themeSrcDirPath, "login");
448
+
449
+ if (!fs.existsSync(dirPath)) {
450
+ return { isImplemented: false, isImplemented_native: false };
451
+ }
452
+
453
+ if (getIsNative(dirPath)) {
454
+ return { isImplemented: false, isImplemented_native: true };
455
+ }
456
+
457
+ return { isImplemented: true };
458
+ })(),
459
+ email: (() => {
460
+ const dirPath = pathJoin(themeSrcDirPath, "email");
461
+
462
+ if (!fs.existsSync(dirPath) || !getIsNative(dirPath)) {
463
+ return { isImplemented: false, isImplemented_native: false };
464
+ }
465
+
466
+ return { isImplemented: false, isImplemented_native: true };
467
+ })(),
468
+ account: (() => {
469
+ const dirPath = pathJoin(themeSrcDirPath, "account");
470
+
471
+ if (!fs.existsSync(dirPath)) {
472
+ return { isImplemented: false, isImplemented_native: false };
473
+ }
474
+
475
+ if (getIsNative(dirPath)) {
476
+ return { isImplemented: false, isImplemented_native: true };
477
+ }
478
+
479
+ if (buildOptions.accountThemeImplementation === "none") {
480
+ return { isImplemented: false, isImplemented_native: false };
481
+ }
482
+
483
+ return {
484
+ isImplemented: true,
485
+ type: buildOptions.accountThemeImplementation
486
+ };
487
+ })(),
488
+ admin: (() => {
489
+ const dirPath = pathJoin(themeSrcDirPath, "admin");
490
+
491
+ if (!fs.existsSync(dirPath)) {
492
+ return { isImplemented: false, isImplemented_native: false };
493
+ }
494
+
495
+ if (getIsNative(dirPath)) {
496
+ return { isImplemented: false, isImplemented_native: true };
497
+ }
498
+
499
+ return { isImplemented: true };
500
+ })()
501
+ };
502
+ })();
458
503
 
459
504
  if (
460
505
  implementedThemeTypes.account.isImplemented &&
@@ -1,5 +1,5 @@
1
1
  import { dirname as pathDirname, join as pathJoin, relative as pathRelative } from "path";
2
- import type { BuildContext } from "../buildContext";
2
+ import type { BuildContext } from "./buildContext";
3
3
  import * as fs from "fs";
4
4
  import { assert, is, type Equals } from "tsafe/assert";
5
5
  import { id } from "tsafe/id";
@@ -7,8 +7,8 @@ import {
7
7
  addSyncExtensionsToPostinstallScript,
8
8
  type BuildContextLike as BuildContextLike_addSyncExtensionsToPostinstallScript
9
9
  } from "./addSyncExtensionsToPostinstallScript";
10
- import { getIsPrettierAvailable, runPrettier } from "../../tools/runPrettier";
11
- import { npmInstall } from "../../tools/npmInstall";
10
+ import { getIsPrettierAvailable, runPrettier } from "../tools/runPrettier";
11
+ import { npmInstall } from "../tools/npmInstall";
12
12
  import * as child_process from "child_process";
13
13
  import { z } from "zod";
14
14
  import chalk from "chalk";
@@ -99,6 +99,12 @@ function addCommentToSourceCode(params: {
99
99
  return toResult(commentLines.map(line => `# ${line}`).join("\n"));
100
100
  }
101
101
 
102
+ if (fileRelativePath.endsWith(".ftl")) {
103
+ return toResult(
104
+ [`<#--`, ...commentLines.map(line => ` ${line}`), `-->`].join("\n")
105
+ );
106
+ }
107
+
102
108
  if (fileRelativePath.endsWith(".html") || fileRelativePath.endsWith(".svg")) {
103
109
  const comment = [
104
110
  `<!--`,
@@ -4524,26 +4524,54 @@ function getBuildContext(params) {
4524
4524
  }
4525
4525
  (0,assert/* assert */.h)(false);
4526
4526
  })();
4527
- const implementedThemeTypes = {
4528
- login: {
4529
- isImplemented: external_fs_.existsSync((0,external_path_.join)(themeSrcDirPath, "login"))
4530
- },
4531
- email: {
4532
- isImplemented: external_fs_.existsSync((0,external_path_.join)(themeSrcDirPath, "email"))
4533
- },
4534
- account: (() => {
4535
- if (buildOptions.accountThemeImplementation === "none") {
4536
- return { isImplemented: false };
4537
- }
4538
- return {
4539
- isImplemented: true,
4540
- type: buildOptions.accountThemeImplementation
4541
- };
4542
- })(),
4543
- admin: {
4544
- isImplemented: external_fs_.existsSync((0,external_path_.join)(themeSrcDirPath, "admin"))
4545
- }
4546
- };
4527
+ const implementedThemeTypes = (() => {
4528
+ const getIsNative = (dirPath) => external_fs_.existsSync((0,external_path_.join)(dirPath, "theme.properties"));
4529
+ return {
4530
+ login: (() => {
4531
+ const dirPath = (0,external_path_.join)(themeSrcDirPath, "login");
4532
+ if (!external_fs_.existsSync(dirPath)) {
4533
+ return { isImplemented: false, isImplemented_native: false };
4534
+ }
4535
+ if (getIsNative(dirPath)) {
4536
+ return { isImplemented: false, isImplemented_native: true };
4537
+ }
4538
+ return { isImplemented: true };
4539
+ })(),
4540
+ email: (() => {
4541
+ const dirPath = (0,external_path_.join)(themeSrcDirPath, "email");
4542
+ if (!external_fs_.existsSync(dirPath) || !getIsNative(dirPath)) {
4543
+ return { isImplemented: false, isImplemented_native: false };
4544
+ }
4545
+ return { isImplemented: false, isImplemented_native: true };
4546
+ })(),
4547
+ account: (() => {
4548
+ const dirPath = (0,external_path_.join)(themeSrcDirPath, "account");
4549
+ if (!external_fs_.existsSync(dirPath)) {
4550
+ return { isImplemented: false, isImplemented_native: false };
4551
+ }
4552
+ if (getIsNative(dirPath)) {
4553
+ return { isImplemented: false, isImplemented_native: true };
4554
+ }
4555
+ if (buildOptions.accountThemeImplementation === "none") {
4556
+ return { isImplemented: false, isImplemented_native: false };
4557
+ }
4558
+ return {
4559
+ isImplemented: true,
4560
+ type: buildOptions.accountThemeImplementation
4561
+ };
4562
+ })(),
4563
+ admin: (() => {
4564
+ const dirPath = (0,external_path_.join)(themeSrcDirPath, "admin");
4565
+ if (!external_fs_.existsSync(dirPath)) {
4566
+ return { isImplemented: false, isImplemented_native: false };
4567
+ }
4568
+ if (getIsNative(dirPath)) {
4569
+ return { isImplemented: false, isImplemented_native: true };
4570
+ }
4571
+ return { isImplemented: true };
4572
+ })()
4573
+ };
4574
+ })();
4547
4575
  if (implementedThemeTypes.account.isImplemented &&
4548
4576
  !external_fs_.existsSync((0,external_path_.join)(themeSrcDirPath, "account"))) {
4549
4577
  console.error(source_default().red([
package/bin/313.index.js DELETED
@@ -1,377 +0,0 @@
1
- "use strict";
2
- exports.id = 313;
3
- exports.ids = [313];
4
- exports.modules = {
5
-
6
- /***/ 16932:
7
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
-
9
- __webpack_require__.r(__webpack_exports__);
10
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11
- /* harmony export */ "command": () => (/* binding */ command)
12
- /* harmony export */ });
13
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(71017);
14
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
15
- /* harmony import */ var _tools_transformCodebase__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(60332);
16
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(57147);
17
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_2__);
18
- /* harmony import */ var _tools_downloadAndExtractArchive__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(38367);
19
- /* harmony import */ var _shared_customHandler_delegate__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(72138);
20
- /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(29041);
21
- /* harmony import */ var _start_keycloak_getSupportedDockerImageTags__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(28434);
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
- async function command(params) {
30
- const { buildContext } = params;
31
- const { hasBeenHandled } = (0,_shared_customHandler_delegate__WEBPACK_IMPORTED_MODULE_4__/* .maybeDelegateCommandToCustomHandler */ .q)({
32
- commandName: "initialize-email-theme",
33
- buildContext
34
- });
35
- if (hasBeenHandled) {
36
- return;
37
- }
38
- const emailThemeSrcDirPath = (0,path__WEBPACK_IMPORTED_MODULE_0__.join)(buildContext.themeSrcDirPath, "email");
39
- if (fs__WEBPACK_IMPORTED_MODULE_2__.existsSync(emailThemeSrcDirPath) &&
40
- fs__WEBPACK_IMPORTED_MODULE_2__.readdirSync(emailThemeSrcDirPath).length > 0) {
41
- console.warn(`There is already a non empty ${(0,path__WEBPACK_IMPORTED_MODULE_0__.relative)(process.cwd(), emailThemeSrcDirPath)} directory in your project. Aborting.`);
42
- process.exit(-1);
43
- }
44
- console.log("Initialize with the base email theme from which version of Keycloak?");
45
- const { extractedDirPath } = await (0,_tools_downloadAndExtractArchive__WEBPACK_IMPORTED_MODULE_3__/* .downloadAndExtractArchive */ .I)({
46
- url: await (async () => {
47
- const { latestMajorTags } = await (0,_start_keycloak_getSupportedDockerImageTags__WEBPACK_IMPORTED_MODULE_6__/* .getSupportedDockerImageTags */ .z)({
48
- buildContext
49
- });
50
- const keycloakVersion = latestMajorTags[0];
51
- (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .h)(keycloakVersion !== undefined);
52
- return `https://repo1.maven.org/maven2/org/keycloak/keycloak-themes/${keycloakVersion}/keycloak-themes-${keycloakVersion}.jar`;
53
- })(),
54
- cacheDirPath: buildContext.cacheDirPath,
55
- fetchOptions: buildContext.fetchOptions,
56
- uniqueIdOfOnArchiveFile: "extractOnlyEmailTheme",
57
- onArchiveFile: async ({ fileRelativePath, writeFile }) => {
58
- const fileRelativePath_target = (0,path__WEBPACK_IMPORTED_MODULE_0__.relative)((0,path__WEBPACK_IMPORTED_MODULE_0__.join)("theme", "base", "email"), fileRelativePath);
59
- if (fileRelativePath_target.startsWith("..")) {
60
- return;
61
- }
62
- await writeFile({ fileRelativePath: fileRelativePath_target });
63
- }
64
- });
65
- (0,_tools_transformCodebase__WEBPACK_IMPORTED_MODULE_1__/* .transformCodebase */ .N)({
66
- srcDirPath: extractedDirPath,
67
- destDirPath: emailThemeSrcDirPath
68
- });
69
- {
70
- const themePropertyFilePath = (0,path__WEBPACK_IMPORTED_MODULE_0__.join)(emailThemeSrcDirPath, "theme.properties");
71
- fs__WEBPACK_IMPORTED_MODULE_2__.writeFileSync(themePropertyFilePath, Buffer.from([
72
- `parent=base`,
73
- fs__WEBPACK_IMPORTED_MODULE_2__.readFileSync(themePropertyFilePath).toString("utf8")
74
- ].join("\n"), "utf8"));
75
- }
76
- console.log(`The \`${(0,path__WEBPACK_IMPORTED_MODULE_0__.join)(".", (0,path__WEBPACK_IMPORTED_MODULE_0__.relative)(process.cwd(), emailThemeSrcDirPath))}\` directory have been created.`);
77
- console.log("You can delete any file you don't modify.");
78
- }
79
- //# sourceMappingURL=initialize-email-theme.js.map
80
-
81
- /***/ }),
82
-
83
- /***/ 72138:
84
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
85
-
86
-
87
- // EXPORTS
88
- __webpack_require__.d(__webpack_exports__, {
89
- "q": () => (/* binding */ maybeDelegateCommandToCustomHandler)
90
- });
91
-
92
- // EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
93
- var esm_assert = __webpack_require__(29041);
94
- // EXTERNAL MODULE: ./dist/bin/shared/constants.js
95
- var constants = __webpack_require__(173);
96
- ;// CONCATENATED MODULE: ./dist/bin/shared/customHandler.js
97
-
98
-
99
- const BIN_NAME = "_keycloakify-custom-handler";
100
- const NOT_IMPLEMENTED_EXIT_CODE = 78;
101
- function readParams(params) {
102
- const { apiVersion } = params;
103
- assert(apiVersion === "v1");
104
- const commandName = (() => {
105
- const envValue = process.env[CUSTOM_HANDLER_ENV_NAMES.COMMAND_NAME];
106
- assert(envValue !== undefined);
107
- return envValue;
108
- })();
109
- const buildContext = (() => {
110
- const envValue = process.env[CUSTOM_HANDLER_ENV_NAMES.BUILD_CONTEXT];
111
- assert(envValue !== undefined);
112
- return JSON.parse(envValue);
113
- })();
114
- return { commandName, buildContext };
115
- }
116
- //# sourceMappingURL=customHandler.js.map
117
- // EXTERNAL MODULE: external "child_process"
118
- var external_child_process_ = __webpack_require__(32081);
119
- // EXTERNAL MODULE: ./dist/bin/tools/nodeModulesBinDirPath.js
120
- var tools_nodeModulesBinDirPath = __webpack_require__(73776);
121
- // EXTERNAL MODULE: external "fs"
122
- var external_fs_ = __webpack_require__(57147);
123
- ;// CONCATENATED MODULE: ./dist/bin/shared/customHandler_delegate.js
124
-
125
-
126
-
127
-
128
-
129
-
130
- (0,esm_assert/* assert */.h)();
131
- function maybeDelegateCommandToCustomHandler(params) {
132
- const { commandName, buildContext } = params;
133
- const nodeModulesBinDirPath = (0,tools_nodeModulesBinDirPath/* getNodeModulesBinDirPath */.K)();
134
- if (!external_fs_.readdirSync(nodeModulesBinDirPath).includes(BIN_NAME)) {
135
- return { hasBeenHandled: false };
136
- }
137
- try {
138
- external_child_process_.execSync(`npx ${BIN_NAME}`, {
139
- stdio: "inherit",
140
- env: Object.assign(Object.assign({}, process.env), { [constants/* CUSTOM_HANDLER_ENV_NAMES.COMMAND_NAME */._S.COMMAND_NAME]: commandName, [constants/* CUSTOM_HANDLER_ENV_NAMES.BUILD_CONTEXT */._S.BUILD_CONTEXT]: JSON.stringify(buildContext) })
141
- });
142
- }
143
- catch (error) {
144
- const status = error.status;
145
- if (status === NOT_IMPLEMENTED_EXIT_CODE) {
146
- return { hasBeenHandled: false };
147
- }
148
- process.exit(status);
149
- }
150
- return { hasBeenHandled: true };
151
- }
152
- //# sourceMappingURL=customHandler_delegate.js.map
153
-
154
- /***/ }),
155
-
156
- /***/ 89693:
157
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
158
-
159
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
160
- /* harmony export */ "a": () => (/* binding */ rmSync)
161
- /* harmony export */ });
162
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(57147);
163
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
164
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71017);
165
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
166
- /* harmony import */ var _SemVer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(12171);
167
-
168
-
169
-
170
- /**
171
- * Polyfill of fs.rmSync(dirPath, { "recursive": true })
172
- * For older version of Node
173
- */
174
- function rmSync(dirPath, options) {
175
- if (_SemVer__WEBPACK_IMPORTED_MODULE_2__/* .SemVer.compare */ .h.compare(_SemVer__WEBPACK_IMPORTED_MODULE_2__/* .SemVer.parse */ .h.parse(process.version), _SemVer__WEBPACK_IMPORTED_MODULE_2__/* .SemVer.parse */ .h.parse("14.14.0")) > 0) {
176
- fs__WEBPACK_IMPORTED_MODULE_0__.rmSync(dirPath, options);
177
- return;
178
- }
179
- const { force = true } = options;
180
- if (force && !fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(dirPath)) {
181
- return;
182
- }
183
- const removeDir_rec = (dirPath) => fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync(dirPath).forEach(basename => {
184
- const fileOrDirPath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(dirPath, basename);
185
- if (fs__WEBPACK_IMPORTED_MODULE_0__.lstatSync(fileOrDirPath).isDirectory()) {
186
- removeDir_rec(fileOrDirPath);
187
- return;
188
- }
189
- else {
190
- fs__WEBPACK_IMPORTED_MODULE_0__.unlinkSync(fileOrDirPath);
191
- }
192
- });
193
- removeDir_rec(dirPath);
194
- }
195
- //# sourceMappingURL=fs.rmSync.js.map
196
-
197
- /***/ }),
198
-
199
- /***/ 60332:
200
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
201
-
202
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
203
- /* harmony export */ "N": () => (/* binding */ transformCodebase)
204
- /* harmony export */ });
205
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(57147);
206
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
207
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71017);
208
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
209
- /* harmony import */ var _crawl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(73036);
210
- /* harmony import */ var _tools_fs_rmSync__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(89693);
211
-
212
-
213
-
214
-
215
- /**
216
- * Apply a transformation function to every file of directory
217
- * If source and destination are the same this function can be used to apply the transformation in place
218
- * like filtering out some files or modifying them.
219
- * */
220
- function transformCodebase(params) {
221
- const { srcDirPath, transformSourceCode } = params;
222
- const isTargetSameAsSource = path__WEBPACK_IMPORTED_MODULE_1__.relative(srcDirPath, params.destDirPath) === "";
223
- const destDirPath = isTargetSameAsSource
224
- ? path__WEBPACK_IMPORTED_MODULE_1__.join(srcDirPath, "..", "tmp_xOsPdkPsTdzPs34sOkHs")
225
- : params.destDirPath;
226
- fs__WEBPACK_IMPORTED_MODULE_0__.mkdirSync(destDirPath, {
227
- recursive: true
228
- });
229
- for (const fileRelativePath of (0,_crawl__WEBPACK_IMPORTED_MODULE_2__/* .crawl */ .J)({
230
- dirPath: srcDirPath,
231
- returnedPathsType: "relative to dirPath"
232
- })) {
233
- const filePath = path__WEBPACK_IMPORTED_MODULE_1__.join(srcDirPath, fileRelativePath);
234
- const destFilePath = path__WEBPACK_IMPORTED_MODULE_1__.join(destDirPath, fileRelativePath);
235
- // NOTE: Optimization, if we don't need to transform the file, just copy
236
- // it using the lower level implementation.
237
- if (transformSourceCode === undefined) {
238
- fs__WEBPACK_IMPORTED_MODULE_0__.mkdirSync(path__WEBPACK_IMPORTED_MODULE_1__.dirname(destFilePath), {
239
- recursive: true
240
- });
241
- fs__WEBPACK_IMPORTED_MODULE_0__.copyFileSync(filePath, destFilePath);
242
- continue;
243
- }
244
- const transformSourceCodeResult = transformSourceCode({
245
- sourceCode: fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(filePath),
246
- filePath,
247
- fileRelativePath
248
- });
249
- if (transformSourceCodeResult === undefined) {
250
- continue;
251
- }
252
- fs__WEBPACK_IMPORTED_MODULE_0__.mkdirSync(path__WEBPACK_IMPORTED_MODULE_1__.dirname(destFilePath), {
253
- recursive: true
254
- });
255
- const { newFileName, modifiedSourceCode } = transformSourceCodeResult;
256
- fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(path__WEBPACK_IMPORTED_MODULE_1__.join(path__WEBPACK_IMPORTED_MODULE_1__.dirname(destFilePath), newFileName !== null && newFileName !== void 0 ? newFileName : path__WEBPACK_IMPORTED_MODULE_1__.basename(destFilePath)), modifiedSourceCode);
257
- }
258
- if (isTargetSameAsSource) {
259
- (0,_tools_fs_rmSync__WEBPACK_IMPORTED_MODULE_3__/* .rmSync */ .a)(srcDirPath, { recursive: true });
260
- fs__WEBPACK_IMPORTED_MODULE_0__.renameSync(destDirPath, srcDirPath);
261
- }
262
- }
263
- //# sourceMappingURL=transformCodebase.js.map
264
-
265
- /***/ }),
266
-
267
- /***/ 50689:
268
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
269
-
270
-
271
- var __extends = (this && this.__extends) || (function () {
272
- var extendStatics = function (d, b) {
273
- extendStatics = Object.setPrototypeOf ||
274
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
275
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
276
- return extendStatics(d, b);
277
- };
278
- return function (d, b) {
279
- if (typeof b !== "function" && b !== null)
280
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
281
- extendStatics(d, b);
282
- function __() { this.constructor = d; }
283
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
284
- };
285
- })();
286
- Object.defineProperty(exports, "__esModule", ({ value: true }));
287
- exports.VoidDeferred = exports.Deferred = void 0;
288
- var overwriteReadonlyProp_1 = __webpack_require__(47803);
289
- var Deferred = /** @class */ (function () {
290
- function Deferred() {
291
- var _this_1 = this;
292
- this.isPending = true;
293
- var resolve;
294
- var reject;
295
- this.pr = new Promise(function (resolve_, reject_) {
296
- resolve = function (value) {
297
- (0, overwriteReadonlyProp_1.overwriteReadonlyProp)(_this_1, "isPending", false);
298
- resolve_(value);
299
- };
300
- reject = function (error) {
301
- (0, overwriteReadonlyProp_1.overwriteReadonlyProp)(_this_1, "isPending", false);
302
- reject_(error);
303
- };
304
- });
305
- this.resolve = resolve;
306
- this.reject = reject;
307
- }
308
- return Deferred;
309
- }());
310
- exports.Deferred = Deferred;
311
- var VoidDeferred = /** @class */ (function (_super) {
312
- __extends(VoidDeferred, _super);
313
- function VoidDeferred() {
314
- return _super !== null && _super.apply(this, arguments) || this;
315
- }
316
- return VoidDeferred;
317
- }(Deferred));
318
- exports.VoidDeferred = VoidDeferred;
319
- //# sourceMappingURL=Deferred.js.map
320
-
321
- /***/ }),
322
-
323
- /***/ 47803:
324
- /***/ (function(__unused_webpack_module, exports) {
325
-
326
-
327
- var __assign = (this && this.__assign) || function () {
328
- __assign = Object.assign || function(t) {
329
- for (var s, i = 1, n = arguments.length; i < n; i++) {
330
- s = arguments[i];
331
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
332
- t[p] = s[p];
333
- }
334
- return t;
335
- };
336
- return __assign.apply(this, arguments);
337
- };
338
- Object.defineProperty(exports, "__esModule", ({ value: true }));
339
- exports.overwriteReadonlyProp = void 0;
340
- /**
341
- * Assign a value to a property even if the object is freezed or if the property is not writable
342
- * Throw if the assignation fail ( for example if the property is non configurable write: false )
343
- * */
344
- var overwriteReadonlyProp = function (obj, propertyName, value) {
345
- try {
346
- obj[propertyName] = value;
347
- }
348
- catch (_a) { }
349
- if (obj[propertyName] === value) {
350
- return value;
351
- }
352
- var errorDefineProperty = undefined;
353
- var propertyDescriptor = Object.getOwnPropertyDescriptor(obj, propertyName) || {
354
- "enumerable": true,
355
- "configurable": true,
356
- };
357
- if (!!propertyDescriptor.get) {
358
- throw new Error("Probably a wrong ides to overwrite ".concat(String(propertyName), " getter"));
359
- }
360
- try {
361
- Object.defineProperty(obj, propertyName, __assign(__assign({}, propertyDescriptor), { value: value }));
362
- }
363
- catch (error) {
364
- errorDefineProperty = error;
365
- }
366
- if (obj[propertyName] !== value) {
367
- throw errorDefineProperty || new Error("Can't assign");
368
- }
369
- return value;
370
- };
371
- exports.overwriteReadonlyProp = overwriteReadonlyProp;
372
- //# sourceMappingURL=overwriteReadonlyProp.js.map
373
-
374
- /***/ })
375
-
376
- };
377
- ;