keycloakify 11.8.37-rc.1 → 11.8.37
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/712.index.js +12 -32
- package/bin/{783.index.js → 864.index.js} +1460 -2
- package/bin/930.index.js +29 -45
- package/bin/97.index.js +108 -145
- package/bin/keycloakify/generateResources/generateResources.d.ts +0 -1
- package/bin/main.js +3 -17
- package/bin/own.d.ts +0 -1
- package/bin/sync-extensions/extensionModuleMeta.d.ts +0 -1
- package/bin/sync-extensions/getExtensionModuleFileSourceCodeReadyToBeCopied.d.ts +0 -2
- package/bin/sync-extensions/managedGitignoreFile.d.ts +14 -0
- package/package.json +6 -5
- package/src/bin/keycloakify/generateResources/generateMessageProperties.ts +2 -1
- package/src/bin/keycloakify/generateResources/generateResources.ts +3 -43
- package/src/bin/main.ts +2 -19
- package/src/bin/own.ts +27 -60
- package/src/bin/sync-extensions/extensionModuleMeta.ts +41 -52
- package/src/bin/sync-extensions/getExtensionModuleFileSourceCodeReadyToBeCopied.ts +3 -11
- package/src/bin/sync-extensions/managedGitignoreFile.ts +136 -0
- package/src/bin/sync-extensions/sync-extension.ts +8 -21
- package/src/vite-plugin/vite-plugin.ts +1 -8
- package/vite-plugin/index.js +0 -5
- package/bin/sync-extensions/managedGitignoreFiles.d.ts +0 -29
- package/src/bin/sync-extensions/managedGitignoreFiles.ts +0 -189
@@ -0,0 +1,136 @@
|
|
1
|
+
import * as fsPr from "fs/promises";
|
2
|
+
import {
|
3
|
+
join as pathJoin,
|
4
|
+
sep as pathSep,
|
5
|
+
dirname as pathDirname,
|
6
|
+
relative as pathRelative
|
7
|
+
} from "path";
|
8
|
+
import { assert } from "tsafe/assert";
|
9
|
+
import type { BuildContext } from "../shared/buildContext";
|
10
|
+
import type { ExtensionModuleMeta } from "./extensionModuleMeta";
|
11
|
+
import { existsAsync } from "../tools/fs.existsAsync";
|
12
|
+
import { getAbsoluteAndInOsFormatPath } from "../tools/getAbsoluteAndInOsFormatPath";
|
13
|
+
|
14
|
+
export type BuildContextLike = {
|
15
|
+
themeSrcDirPath: string;
|
16
|
+
};
|
17
|
+
|
18
|
+
assert<BuildContext extends BuildContextLike ? true : false>();
|
19
|
+
|
20
|
+
const DELIMITER_START = `# === Owned files start ===`;
|
21
|
+
const DELIMITER_END = `# === Owned files end =====`;
|
22
|
+
|
23
|
+
export async function writeManagedGitignoreFile(params: {
|
24
|
+
buildContext: BuildContextLike;
|
25
|
+
extensionModuleMetas: ExtensionModuleMeta[];
|
26
|
+
ownedFilesRelativePaths: string[];
|
27
|
+
}): Promise<void> {
|
28
|
+
const { buildContext, extensionModuleMetas, ownedFilesRelativePaths } = params;
|
29
|
+
|
30
|
+
if (extensionModuleMetas.length === 0) {
|
31
|
+
return;
|
32
|
+
}
|
33
|
+
|
34
|
+
const filePath = pathJoin(buildContext.themeSrcDirPath, ".gitignore");
|
35
|
+
|
36
|
+
const content_new = Buffer.from(
|
37
|
+
[
|
38
|
+
`# This file is managed by Keycloakify, do not edit it manually.`,
|
39
|
+
``,
|
40
|
+
DELIMITER_START,
|
41
|
+
...ownedFilesRelativePaths
|
42
|
+
.map(fileRelativePath => fileRelativePath.split(pathSep).join("/"))
|
43
|
+
.map(line => `# ${line}`),
|
44
|
+
DELIMITER_END,
|
45
|
+
``,
|
46
|
+
...extensionModuleMetas
|
47
|
+
.map(extensionModuleMeta => [
|
48
|
+
`# === ${extensionModuleMeta.moduleName} v${extensionModuleMeta.version} ===`,
|
49
|
+
...extensionModuleMeta.files
|
50
|
+
.map(({ fileRelativePath }) => fileRelativePath)
|
51
|
+
.filter(
|
52
|
+
fileRelativePath =>
|
53
|
+
!ownedFilesRelativePaths.includes(fileRelativePath)
|
54
|
+
)
|
55
|
+
.map(
|
56
|
+
fileRelativePath =>
|
57
|
+
`/${fileRelativePath.split(pathSep).join("/").replace(/^\.\//, "")}`
|
58
|
+
),
|
59
|
+
|
60
|
+
``
|
61
|
+
])
|
62
|
+
.flat()
|
63
|
+
].join("\n"),
|
64
|
+
"utf8"
|
65
|
+
);
|
66
|
+
|
67
|
+
const content_current = await (async () => {
|
68
|
+
if (!(await existsAsync(filePath))) {
|
69
|
+
return undefined;
|
70
|
+
}
|
71
|
+
|
72
|
+
return await fsPr.readFile(filePath);
|
73
|
+
})();
|
74
|
+
|
75
|
+
if (content_current !== undefined && content_current.equals(content_new)) {
|
76
|
+
return;
|
77
|
+
}
|
78
|
+
|
79
|
+
create_dir: {
|
80
|
+
const dirPath = pathDirname(filePath);
|
81
|
+
|
82
|
+
if (await existsAsync(dirPath)) {
|
83
|
+
break create_dir;
|
84
|
+
}
|
85
|
+
|
86
|
+
await fsPr.mkdir(dirPath, { recursive: true });
|
87
|
+
}
|
88
|
+
|
89
|
+
await fsPr.writeFile(filePath, content_new);
|
90
|
+
}
|
91
|
+
|
92
|
+
export async function readManagedGitignoreFile(params: {
|
93
|
+
buildContext: BuildContextLike;
|
94
|
+
}): Promise<{
|
95
|
+
ownedFilesRelativePaths: string[];
|
96
|
+
}> {
|
97
|
+
const { buildContext } = params;
|
98
|
+
|
99
|
+
const filePath = pathJoin(buildContext.themeSrcDirPath, ".gitignore");
|
100
|
+
|
101
|
+
if (!(await existsAsync(filePath))) {
|
102
|
+
return { ownedFilesRelativePaths: [] };
|
103
|
+
}
|
104
|
+
|
105
|
+
const contentStr = (await fsPr.readFile(filePath)).toString("utf8");
|
106
|
+
|
107
|
+
const payload = (() => {
|
108
|
+
const index_start = contentStr.indexOf(DELIMITER_START);
|
109
|
+
const index_end = contentStr.indexOf(DELIMITER_END);
|
110
|
+
|
111
|
+
if (index_start === -1 || index_end === -1) {
|
112
|
+
return undefined;
|
113
|
+
}
|
114
|
+
|
115
|
+
return contentStr.slice(index_start + DELIMITER_START.length, index_end).trim();
|
116
|
+
})();
|
117
|
+
|
118
|
+
if (payload === undefined) {
|
119
|
+
return { ownedFilesRelativePaths: [] };
|
120
|
+
}
|
121
|
+
|
122
|
+
const ownedFilesRelativePaths = payload
|
123
|
+
.split("\n")
|
124
|
+
.map(line => line.trim())
|
125
|
+
.map(line => line.replace(/^# /, ""))
|
126
|
+
.filter(line => line !== "")
|
127
|
+
.map(line =>
|
128
|
+
getAbsoluteAndInOsFormatPath({
|
129
|
+
cwd: buildContext.themeSrcDirPath,
|
130
|
+
pathIsh: line
|
131
|
+
})
|
132
|
+
)
|
133
|
+
.map(filePath => pathRelative(buildContext.themeSrcDirPath, filePath));
|
134
|
+
|
135
|
+
return { ownedFilesRelativePaths };
|
136
|
+
}
|
@@ -2,9 +2,9 @@ import type { BuildContext } from "../shared/buildContext";
|
|
2
2
|
import { getExtensionModuleMetas, computeHash } from "./extensionModuleMeta";
|
3
3
|
import { installExtensionModulesPeerDependencies } from "./installExtensionModulesPeerDependencies";
|
4
4
|
import {
|
5
|
-
|
6
|
-
|
7
|
-
} from "./
|
5
|
+
readManagedGitignoreFile,
|
6
|
+
writeManagedGitignoreFile
|
7
|
+
} from "./managedGitignoreFile";
|
8
8
|
import { dirname as pathDirname } from "path";
|
9
9
|
import { join as pathJoin } from "path";
|
10
10
|
import { existsAsync } from "../tools/fs.existsAsync";
|
@@ -12,8 +12,6 @@ import * as fsPr from "fs/promises";
|
|
12
12
|
import { getIsKnownByGit, untrackFromGit } from "../tools/gitUtils";
|
13
13
|
import { command as updateKcGenCommand } from "../update-kc-gen";
|
14
14
|
import { getBuildContext } from "../shared/buildContext";
|
15
|
-
import { KEYCLOAK_THEME } from "../shared/constants";
|
16
|
-
import { same } from "evt/tools/inDepth/same";
|
17
15
|
|
18
16
|
export async function command(params: { buildContext: BuildContext }) {
|
19
17
|
const { buildContext } = params;
|
@@ -25,11 +23,11 @@ export async function command(params: { buildContext: BuildContext }) {
|
|
25
23
|
extensionModuleMetas
|
26
24
|
});
|
27
25
|
|
28
|
-
const { ownedFilesRelativePaths } = await
|
26
|
+
const { ownedFilesRelativePaths } = await readManagedGitignoreFile({
|
29
27
|
buildContext
|
30
28
|
});
|
31
29
|
|
32
|
-
await
|
30
|
+
await writeManagedGitignoreFile({
|
33
31
|
buildContext,
|
34
32
|
ownedFilesRelativePaths,
|
35
33
|
extensionModuleMetas
|
@@ -40,24 +38,13 @@ export async function command(params: { buildContext: BuildContext }) {
|
|
40
38
|
.map(extensionModuleMeta =>
|
41
39
|
Promise.all(
|
42
40
|
extensionModuleMeta.files.map(
|
43
|
-
async ({
|
44
|
-
|
45
|
-
fileRelativePath,
|
46
|
-
copyableFilePath,
|
47
|
-
hash
|
48
|
-
}) => {
|
49
|
-
if (
|
50
|
-
ownedFilesRelativePaths.some(entry =>
|
51
|
-
same(entry, { isPublic, fileRelativePath })
|
52
|
-
)
|
53
|
-
) {
|
41
|
+
async ({ fileRelativePath, copyableFilePath, hash }) => {
|
42
|
+
if (ownedFilesRelativePaths.includes(fileRelativePath)) {
|
54
43
|
return;
|
55
44
|
}
|
56
45
|
|
57
46
|
const destFilePath = pathJoin(
|
58
|
-
|
59
|
-
? pathJoin(buildContext.publicDirPath, KEYCLOAK_THEME)
|
60
|
-
: buildContext.themeSrcDirPath,
|
47
|
+
buildContext.themeSrcDirPath,
|
61
48
|
fileRelativePath
|
62
49
|
);
|
63
50
|
|
@@ -2,8 +2,7 @@ import { join as pathJoin, relative as pathRelative, sep as pathSep } from "path
|
|
2
2
|
import type { Plugin } from "vite";
|
3
3
|
import {
|
4
4
|
WELL_KNOWN_DIRECTORY_BASE_NAME,
|
5
|
-
VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES
|
6
|
-
KEYCLOAK_THEME
|
5
|
+
VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES
|
7
6
|
} from "../bin/shared/constants";
|
8
7
|
import { id } from "tsafe/id";
|
9
8
|
import { rm } from "../bin/tools/fs.rm";
|
@@ -204,7 +203,6 @@ export function keycloakify(params: keycloakify.Params) {
|
|
204
203
|
|
205
204
|
assert(buildDirPath !== undefined);
|
206
205
|
|
207
|
-
// NOTE: This is legacy and should eventually be removed
|
208
206
|
await rm(
|
209
207
|
pathJoin(
|
210
208
|
buildDirPath,
|
@@ -215,11 +213,6 @@ export function keycloakify(params: keycloakify.Params) {
|
|
215
213
|
force: true
|
216
214
|
}
|
217
215
|
);
|
218
|
-
|
219
|
-
await rm(pathJoin(buildDirPath, KEYCLOAK_THEME), {
|
220
|
-
recursive: true,
|
221
|
-
force: true
|
222
|
-
});
|
223
216
|
},
|
224
217
|
transformIndexHtml: html => {
|
225
218
|
const doReadKcContextFromUrl =
|
package/vite-plugin/index.js
CHANGED
@@ -2118,15 +2118,10 @@ function keycloakify(params) {
|
|
2118
2118
|
return;
|
2119
2119
|
}
|
2120
2120
|
(0, assert_1.assert)(buildDirPath !== undefined);
|
2121
|
-
// NOTE: This is legacy and should eventually be removed
|
2122
2121
|
await (0, fs_rm_1.rm)((0, path_1.join)(buildDirPath, constants_1.WELL_KNOWN_DIRECTORY_BASE_NAME.KEYCLOAKIFY_DEV_RESOURCES), {
|
2123
2122
|
recursive: true,
|
2124
2123
|
force: true
|
2125
2124
|
});
|
2126
|
-
await (0, fs_rm_1.rm)((0, path_1.join)(buildDirPath, constants_1.KEYCLOAK_THEME), {
|
2127
|
-
recursive: true,
|
2128
|
-
force: true
|
2129
|
-
});
|
2130
2125
|
},
|
2131
2126
|
transformIndexHtml: html => {
|
2132
2127
|
const doReadKcContextFromUrl = process.env.NODE_ENV === "development" &&
|
@@ -1,29 +0,0 @@
|
|
1
|
-
export type BuildContextLike = {
|
2
|
-
themeSrcDirPath: string;
|
3
|
-
publicDirPath: string;
|
4
|
-
};
|
5
|
-
type ExtensionModuleMetaLike = {
|
6
|
-
moduleName: string;
|
7
|
-
version: string;
|
8
|
-
files: {
|
9
|
-
isPublic: boolean;
|
10
|
-
fileRelativePath: string;
|
11
|
-
}[];
|
12
|
-
};
|
13
|
-
export declare function writeManagedGitignoreFiles(params: {
|
14
|
-
buildContext: BuildContextLike;
|
15
|
-
extensionModuleMetas: ExtensionModuleMetaLike[];
|
16
|
-
ownedFilesRelativePaths: {
|
17
|
-
isPublic: boolean;
|
18
|
-
fileRelativePath: string;
|
19
|
-
}[];
|
20
|
-
}): Promise<void>;
|
21
|
-
export declare function readManagedGitignoresFile(params: {
|
22
|
-
buildContext: BuildContextLike;
|
23
|
-
}): Promise<{
|
24
|
-
ownedFilesRelativePaths: {
|
25
|
-
isPublic: boolean;
|
26
|
-
fileRelativePath: string;
|
27
|
-
}[];
|
28
|
-
}>;
|
29
|
-
export {};
|
@@ -1,189 +0,0 @@
|
|
1
|
-
import * as fsPr from "fs/promises";
|
2
|
-
import {
|
3
|
-
join as pathJoin,
|
4
|
-
sep as pathSep,
|
5
|
-
dirname as pathDirname,
|
6
|
-
relative as pathRelative
|
7
|
-
} from "path";
|
8
|
-
import { assert } from "tsafe/assert";
|
9
|
-
import type { BuildContext } from "../shared/buildContext";
|
10
|
-
import type { ExtensionModuleMeta } from "./extensionModuleMeta";
|
11
|
-
import { existsAsync } from "../tools/fs.existsAsync";
|
12
|
-
import { getAbsoluteAndInOsFormatPath } from "../tools/getAbsoluteAndInOsFormatPath";
|
13
|
-
import { KEYCLOAK_THEME } from "../shared/constants";
|
14
|
-
|
15
|
-
export type BuildContextLike = {
|
16
|
-
themeSrcDirPath: string;
|
17
|
-
publicDirPath: string;
|
18
|
-
};
|
19
|
-
|
20
|
-
assert<BuildContext extends BuildContextLike ? true : false>();
|
21
|
-
|
22
|
-
type ExtensionModuleMetaLike = {
|
23
|
-
moduleName: string;
|
24
|
-
version: string;
|
25
|
-
files: {
|
26
|
-
isPublic: boolean;
|
27
|
-
fileRelativePath: string;
|
28
|
-
}[];
|
29
|
-
};
|
30
|
-
|
31
|
-
assert<ExtensionModuleMeta extends ExtensionModuleMetaLike ? true : false>();
|
32
|
-
|
33
|
-
const DELIMITER_START = `# === Owned files start ===`;
|
34
|
-
const DELIMITER_END = `# === Owned files end =====`;
|
35
|
-
|
36
|
-
export async function writeManagedGitignoreFiles(params: {
|
37
|
-
buildContext: BuildContextLike;
|
38
|
-
extensionModuleMetas: ExtensionModuleMetaLike[];
|
39
|
-
ownedFilesRelativePaths: { isPublic: boolean; fileRelativePath: string }[];
|
40
|
-
}): Promise<void> {
|
41
|
-
const { buildContext } = params;
|
42
|
-
|
43
|
-
for (const isPublicIteration of [false, true] as const) {
|
44
|
-
const extensionModuleMetas_ctx = params.extensionModuleMetas
|
45
|
-
.map(extensionModuleMeta => ({
|
46
|
-
...extensionModuleMeta,
|
47
|
-
files: extensionModuleMeta.files.filter(
|
48
|
-
({ isPublic }) => isPublic === isPublicIteration
|
49
|
-
)
|
50
|
-
}))
|
51
|
-
.filter(extensionModuleMeta => extensionModuleMeta.files.length !== 0);
|
52
|
-
|
53
|
-
if (extensionModuleMetas_ctx.length === 0) {
|
54
|
-
continue;
|
55
|
-
}
|
56
|
-
|
57
|
-
const ownedFilesRelativePaths_ctx = params.ownedFilesRelativePaths.filter(
|
58
|
-
({ isPublic }) => isPublic === isPublicIteration
|
59
|
-
);
|
60
|
-
|
61
|
-
const filePath = pathJoin(
|
62
|
-
isPublicIteration
|
63
|
-
? pathJoin(buildContext.publicDirPath, KEYCLOAK_THEME)
|
64
|
-
: buildContext.themeSrcDirPath,
|
65
|
-
".gitignore"
|
66
|
-
);
|
67
|
-
|
68
|
-
const content_new = Buffer.from(
|
69
|
-
[
|
70
|
-
`# This file is managed by Keycloakify, do not edit it manually.`,
|
71
|
-
``,
|
72
|
-
DELIMITER_START,
|
73
|
-
...ownedFilesRelativePaths_ctx
|
74
|
-
.map(({ fileRelativePath }) => fileRelativePath)
|
75
|
-
.map(fileRelativePath => fileRelativePath.split(pathSep).join("/"))
|
76
|
-
.map(line => `# ${line}`),
|
77
|
-
DELIMITER_END,
|
78
|
-
``,
|
79
|
-
...extensionModuleMetas_ctx
|
80
|
-
.map(extensionModuleMeta => [
|
81
|
-
`# === ${extensionModuleMeta.moduleName} v${extensionModuleMeta.version} ===`,
|
82
|
-
...extensionModuleMeta.files
|
83
|
-
.map(({ fileRelativePath }) => fileRelativePath)
|
84
|
-
.filter(
|
85
|
-
fileRelativePath =>
|
86
|
-
!ownedFilesRelativePaths_ctx
|
87
|
-
.map(({ fileRelativePath }) => fileRelativePath)
|
88
|
-
.includes(fileRelativePath)
|
89
|
-
)
|
90
|
-
.map(
|
91
|
-
fileRelativePath =>
|
92
|
-
`/${fileRelativePath.split(pathSep).join("/").replace(/^\.\//, "")}`
|
93
|
-
),
|
94
|
-
|
95
|
-
``
|
96
|
-
])
|
97
|
-
.flat()
|
98
|
-
].join("\n"),
|
99
|
-
"utf8"
|
100
|
-
);
|
101
|
-
|
102
|
-
const content_current = await (async () => {
|
103
|
-
if (!(await existsAsync(filePath))) {
|
104
|
-
return undefined;
|
105
|
-
}
|
106
|
-
|
107
|
-
return await fsPr.readFile(filePath);
|
108
|
-
})();
|
109
|
-
|
110
|
-
if (content_current !== undefined && content_current.equals(content_new)) {
|
111
|
-
continue;
|
112
|
-
}
|
113
|
-
|
114
|
-
create_dir: {
|
115
|
-
const dirPath = pathDirname(filePath);
|
116
|
-
|
117
|
-
if (await existsAsync(dirPath)) {
|
118
|
-
break create_dir;
|
119
|
-
}
|
120
|
-
|
121
|
-
await fsPr.mkdir(dirPath, { recursive: true });
|
122
|
-
}
|
123
|
-
|
124
|
-
await fsPr.writeFile(filePath, content_new);
|
125
|
-
}
|
126
|
-
}
|
127
|
-
|
128
|
-
export async function readManagedGitignoresFile(params: {
|
129
|
-
buildContext: BuildContextLike;
|
130
|
-
}): Promise<{
|
131
|
-
ownedFilesRelativePaths: { isPublic: boolean; fileRelativePath: string }[];
|
132
|
-
}> {
|
133
|
-
const { buildContext } = params;
|
134
|
-
|
135
|
-
const ownedFilesRelativePaths: { isPublic: boolean; fileRelativePath: string }[] = [];
|
136
|
-
|
137
|
-
for (const isPublicIteration of [false, true] as const) {
|
138
|
-
const filePath = pathJoin(
|
139
|
-
isPublicIteration
|
140
|
-
? pathJoin(buildContext.publicDirPath, KEYCLOAK_THEME)
|
141
|
-
: buildContext.themeSrcDirPath,
|
142
|
-
".gitignore"
|
143
|
-
);
|
144
|
-
|
145
|
-
if (!(await existsAsync(filePath))) {
|
146
|
-
continue;
|
147
|
-
}
|
148
|
-
|
149
|
-
const contentStr = (await fsPr.readFile(filePath)).toString("utf8");
|
150
|
-
|
151
|
-
const payload = (() => {
|
152
|
-
const index_start = contentStr.indexOf(DELIMITER_START);
|
153
|
-
const index_end = contentStr.indexOf(DELIMITER_END);
|
154
|
-
|
155
|
-
if (index_start === -1 || index_end === -1) {
|
156
|
-
return undefined;
|
157
|
-
}
|
158
|
-
|
159
|
-
return contentStr
|
160
|
-
.slice(index_start + DELIMITER_START.length, index_end)
|
161
|
-
.trim();
|
162
|
-
})();
|
163
|
-
|
164
|
-
if (payload === undefined) {
|
165
|
-
continue;
|
166
|
-
}
|
167
|
-
|
168
|
-
payload
|
169
|
-
.split("\n")
|
170
|
-
.map(line => line.trim())
|
171
|
-
.map(line => line.replace(/^# /, ""))
|
172
|
-
.filter(line => line !== "")
|
173
|
-
.map(line =>
|
174
|
-
getAbsoluteAndInOsFormatPath({
|
175
|
-
cwd: buildContext.themeSrcDirPath,
|
176
|
-
pathIsh: line
|
177
|
-
})
|
178
|
-
)
|
179
|
-
.map(filePath => pathRelative(buildContext.themeSrcDirPath, filePath))
|
180
|
-
.forEach(fileRelativePath =>
|
181
|
-
ownedFilesRelativePaths.push({
|
182
|
-
isPublic: isPublicIteration,
|
183
|
-
fileRelativePath
|
184
|
-
})
|
185
|
-
);
|
186
|
-
}
|
187
|
-
|
188
|
-
return { ownedFilesRelativePaths };
|
189
|
-
}
|