keycloakify 11.3.0 → 11.3.2

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,95 +0,0 @@
1
- import { join as pathJoin, dirname as pathDirname } from "path";
2
- import { WELL_KNOWN_DIRECTORY_BASE_NAME } from "../shared/constants";
3
- import { readThisNpmPackageVersion } from "../tools/readThisNpmPackageVersion";
4
- import { assert } from "tsafe/assert";
5
- import * as fs from "fs";
6
- import { rmSync } from "../tools/fs.rmSync";
7
- import type { BuildContext } from "./buildContext";
8
- import { transformCodebase } from "../tools/transformCodebase";
9
- import { getThisCodebaseRootDirPath } from "../tools/getThisCodebaseRootDirPath";
10
-
11
- export type BuildContextLike = {
12
- publicDirPath: string;
13
- };
14
-
15
- assert<BuildContext extends BuildContextLike ? true : false>();
16
-
17
- export function copyKeycloakResourcesToPublic(params: {
18
- buildContext: BuildContextLike;
19
- }) {
20
- const { buildContext } = params;
21
-
22
- const destDirPath = pathJoin(
23
- buildContext.publicDirPath,
24
- WELL_KNOWN_DIRECTORY_BASE_NAME.KEYCLOAKIFY_DEV_RESOURCES
25
- );
26
-
27
- const keycloakifyBuildinfoFilePath = pathJoin(destDirPath, "keycloakify.buildinfo");
28
-
29
- const keycloakifyBuildinfoRaw = JSON.stringify(
30
- {
31
- keycloakifyVersion: readThisNpmPackageVersion()
32
- },
33
- null,
34
- 2
35
- );
36
-
37
- skip_if_already_done: {
38
- if (!fs.existsSync(keycloakifyBuildinfoFilePath)) {
39
- break skip_if_already_done;
40
- }
41
-
42
- const keycloakifyBuildinfoRaw_previousRun = fs
43
- .readFileSync(keycloakifyBuildinfoFilePath)
44
- .toString("utf8");
45
-
46
- if (keycloakifyBuildinfoRaw_previousRun !== keycloakifyBuildinfoRaw) {
47
- break skip_if_already_done;
48
- }
49
-
50
- return;
51
- }
52
-
53
- rmSync(destDirPath, { force: true, recursive: true });
54
-
55
- // NOTE: To remove in a while, remove the legacy keycloak-resources directory
56
- rmSync(pathJoin(pathDirname(destDirPath), "keycloak-resources"), {
57
- force: true,
58
- recursive: true
59
- });
60
- rmSync(pathJoin(pathDirname(destDirPath), ".keycloakify"), {
61
- force: true,
62
- recursive: true
63
- });
64
-
65
- fs.mkdirSync(destDirPath, { recursive: true });
66
-
67
- fs.writeFileSync(pathJoin(destDirPath, ".gitignore"), Buffer.from("*", "utf8"));
68
-
69
- transformCodebase({
70
- srcDirPath: pathJoin(
71
- getThisCodebaseRootDirPath(),
72
- "res",
73
- "public",
74
- WELL_KNOWN_DIRECTORY_BASE_NAME.KEYCLOAKIFY_DEV_RESOURCES
75
- ),
76
- destDirPath
77
- });
78
-
79
- fs.writeFileSync(
80
- pathJoin(destDirPath, "README.txt"),
81
- Buffer.from(
82
- // prettier-ignore
83
- [
84
- "This directory is only used in dev mode by Keycloakify",
85
- "It won't be included in your final build.",
86
- "Do not modify anything in this directory.",
87
- ].join("\n")
88
- )
89
- );
90
-
91
- fs.writeFileSync(
92
- keycloakifyBuildinfoFilePath,
93
- Buffer.from(keycloakifyBuildinfoRaw, "utf8")
94
- );
95
- }