keycloakify 11.8.37 → 11.8.38
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/375.index.js +4 -2
- package/bin/712.index.js +26 -3
- package/bin/786.index.js +4 -2
- package/bin/84.index.js +4 -2
- package/bin/930.index.js +45 -29
- package/bin/949.index.js +4 -2
- package/bin/97.index.js +206 -134
- package/bin/keycloakify/generateResources/generateResources.d.ts +1 -0
- package/bin/main.js +16 -2
- package/bin/own.d.ts +1 -0
- package/bin/sync-extensions/extensionModuleMeta.d.ts +1 -0
- package/bin/sync-extensions/getExtensionModuleFileSourceCodeReadyToBeCopied.d.ts +2 -0
- package/bin/sync-extensions/managedGitignoreFiles.d.ts +29 -0
- package/bin/tools/runPrettier.d.ts +5 -0
- package/package.json +3 -3
- package/src/bin/keycloakify/generateResources/generateResources.ts +43 -3
- package/src/bin/main.ts +19 -2
- package/src/bin/own.ts +60 -27
- package/src/bin/sync-extensions/extensionModuleMeta.ts +52 -39
- package/src/bin/sync-extensions/getExtensionModuleFileSourceCodeReadyToBeCopied.ts +95 -39
- package/src/bin/sync-extensions/managedGitignoreFiles.ts +189 -0
- package/src/bin/sync-extensions/sync-extension.ts +21 -8
- package/src/bin/tools/runPrettier.ts +20 -7
- package/src/vite-plugin/vite-plugin.ts +8 -1
- package/vite-plugin/index.js +9 -2
- package/bin/sync-extensions/managedGitignoreFile.d.ts +0 -14
- package/src/bin/sync-extensions/managedGitignoreFile.ts +0 -136
@@ -7,12 +7,14 @@ import { KEYCLOAK_THEME } from "../shared/constants";
|
|
7
7
|
|
8
8
|
export type BuildContextLike = {
|
9
9
|
themeSrcDirPath: string;
|
10
|
+
publicDirPath: string;
|
10
11
|
};
|
11
12
|
|
12
13
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
13
14
|
|
14
15
|
export async function getExtensionModuleFileSourceCodeReadyToBeCopied(params: {
|
15
16
|
buildContext: BuildContextLike;
|
17
|
+
isPublic: boolean;
|
16
18
|
fileRelativePath: string;
|
17
19
|
isOwnershipAction: boolean;
|
18
20
|
extensionModuleDirPath: string;
|
@@ -22,17 +24,50 @@ export async function getExtensionModuleFileSourceCodeReadyToBeCopied(params: {
|
|
22
24
|
const {
|
23
25
|
buildContext,
|
24
26
|
extensionModuleDirPath,
|
27
|
+
isPublic,
|
25
28
|
fileRelativePath,
|
26
29
|
isOwnershipAction,
|
27
30
|
extensionModuleName,
|
28
31
|
extensionModuleVersion
|
29
32
|
} = params;
|
30
33
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
const { refSourceCode } = await (async () => {
|
35
|
+
let sourceCode: string | undefined = undefined;
|
36
|
+
|
37
|
+
const sourceCode_originalBuffer = await fsPr.readFile(
|
38
|
+
pathJoin(
|
39
|
+
extensionModuleDirPath,
|
40
|
+
KEYCLOAK_THEME,
|
41
|
+
isPublic ? "public" : ".",
|
42
|
+
fileRelativePath
|
43
|
+
)
|
44
|
+
);
|
45
|
+
|
46
|
+
let hasBeenUpdated = false;
|
47
|
+
|
48
|
+
const refSourceCode = {
|
49
|
+
get current(): string {
|
50
|
+
if (sourceCode === undefined) {
|
51
|
+
sourceCode = sourceCode_originalBuffer.toString("utf8");
|
52
|
+
}
|
53
|
+
|
54
|
+
return sourceCode;
|
55
|
+
},
|
56
|
+
set current(value: string) {
|
57
|
+
hasBeenUpdated = true;
|
58
|
+
sourceCode = value;
|
59
|
+
},
|
60
|
+
getAsBuffer: () => {
|
61
|
+
if (!hasBeenUpdated) {
|
62
|
+
return sourceCode_originalBuffer;
|
63
|
+
}
|
64
|
+
|
65
|
+
return Buffer.from(refSourceCode.current, "utf8");
|
66
|
+
}
|
67
|
+
};
|
68
|
+
|
69
|
+
return { refSourceCode };
|
70
|
+
})();
|
36
71
|
|
37
72
|
add_eslint_disable: {
|
38
73
|
if (isOwnershipAction) {
|
@@ -43,15 +78,17 @@ export async function getExtensionModuleFileSourceCodeReadyToBeCopied(params: {
|
|
43
78
|
break add_eslint_disable;
|
44
79
|
}
|
45
80
|
|
46
|
-
if (
|
81
|
+
if (refSourceCode.current.includes("/* eslint-disable */")) {
|
47
82
|
break add_eslint_disable;
|
48
83
|
}
|
49
84
|
|
50
|
-
|
85
|
+
refSourceCode.current = ["/* eslint-disable */", "", refSourceCode.current].join(
|
86
|
+
"\n"
|
87
|
+
);
|
51
88
|
}
|
52
89
|
|
53
|
-
|
54
|
-
|
90
|
+
addCommentToSourceCode({
|
91
|
+
refSourceCode,
|
55
92
|
fileRelativePath,
|
56
93
|
commentLines: (() => {
|
57
94
|
const path = fileRelativePath.split(pathSep).join("/");
|
@@ -61,12 +98,12 @@ export async function getExtensionModuleFileSourceCodeReadyToBeCopied(params: {
|
|
61
98
|
`This file has been claimed for ownership from ${extensionModuleName} version ${extensionModuleVersion}.`,
|
62
99
|
`To relinquish ownership and restore this file to its original content, run the following command:`,
|
63
100
|
``,
|
64
|
-
`$ npx keycloakify own --path "${path}" --revert`
|
101
|
+
`$ npx keycloakify own --path "${path}" ${isPublic ? "--public " : ""}--revert`
|
65
102
|
]
|
66
103
|
: [
|
67
104
|
`WARNING: Before modifying this file, run the following command:`,
|
68
105
|
``,
|
69
|
-
`$ npx keycloakify own --path "${path}"`,
|
106
|
+
`$ npx keycloakify own --path "${path}"${isPublic ? " --public" : ""}`,
|
70
107
|
``,
|
71
108
|
`This file is provided by ${extensionModuleName} version ${extensionModuleVersion}.`,
|
72
109
|
`It was copied into your repository by the postinstall script: \`keycloakify sync-extensions\`.`
|
@@ -74,31 +111,41 @@ export async function getExtensionModuleFileSourceCodeReadyToBeCopied(params: {
|
|
74
111
|
})()
|
75
112
|
});
|
76
113
|
|
77
|
-
const destFilePath = pathJoin(buildContext.themeSrcDirPath, fileRelativePath);
|
78
|
-
|
79
114
|
format: {
|
80
115
|
if (!(await getIsPrettierAvailable())) {
|
81
116
|
break format;
|
82
117
|
}
|
83
118
|
|
84
|
-
|
85
|
-
|
86
|
-
|
119
|
+
const sourceCode_buffer_before = refSourceCode.getAsBuffer();
|
120
|
+
const sourceCode_buffer_after = await runPrettier({
|
121
|
+
filePath: pathJoin(
|
122
|
+
isPublic
|
123
|
+
? pathJoin(buildContext.publicDirPath, KEYCLOAK_THEME)
|
124
|
+
: buildContext.themeSrcDirPath,
|
125
|
+
fileRelativePath
|
126
|
+
),
|
127
|
+
sourceCode: sourceCode_buffer_before
|
87
128
|
});
|
129
|
+
|
130
|
+
if (sourceCode_buffer_before.compare(sourceCode_buffer_after) === 0) {
|
131
|
+
break format;
|
132
|
+
}
|
133
|
+
|
134
|
+
refSourceCode.current = sourceCode_buffer_after.toString("utf8");
|
88
135
|
}
|
89
136
|
|
90
|
-
return
|
137
|
+
return refSourceCode.getAsBuffer();
|
91
138
|
}
|
92
139
|
|
93
140
|
function addCommentToSourceCode(params: {
|
94
|
-
|
141
|
+
refSourceCode: { current: string };
|
95
142
|
fileRelativePath: string;
|
96
143
|
commentLines: string[];
|
97
|
-
}):
|
98
|
-
const {
|
144
|
+
}): void {
|
145
|
+
const { refSourceCode, fileRelativePath, commentLines } = params;
|
99
146
|
|
100
|
-
const
|
101
|
-
|
147
|
+
const updateRef = (comment: string) => {
|
148
|
+
refSourceCode.current = [comment, ``, refSourceCode.current].join("\n");
|
102
149
|
};
|
103
150
|
|
104
151
|
for (const ext of [".ts", ".tsx", ".css", ".less", ".sass", ".js", ".jsx"]) {
|
@@ -106,13 +153,13 @@ function addCommentToSourceCode(params: {
|
|
106
153
|
continue;
|
107
154
|
}
|
108
155
|
|
109
|
-
|
110
|
-
|
111
|
-
);
|
156
|
+
updateRef([`/**`, ...commentLines.map(line => ` * ${line}`), ` */`].join("\n"));
|
157
|
+
return;
|
112
158
|
}
|
113
159
|
|
114
160
|
if (fileRelativePath.endsWith(".properties")) {
|
115
|
-
|
161
|
+
updateRef(commentLines.map(line => `# ${line}`).join("\n"));
|
162
|
+
return;
|
116
163
|
}
|
117
164
|
|
118
165
|
if (fileRelativePath.endsWith(".ftl")) {
|
@@ -120,15 +167,17 @@ function addCommentToSourceCode(params: {
|
|
120
167
|
"\n"
|
121
168
|
);
|
122
169
|
|
123
|
-
if (
|
124
|
-
const [first, ...rest] =
|
170
|
+
if (refSourceCode.current.trim().startsWith("<#ftl")) {
|
171
|
+
const [first, ...rest] = refSourceCode.current.split(">");
|
125
172
|
|
126
173
|
const last = rest.join(">");
|
127
174
|
|
128
|
-
|
175
|
+
refSourceCode.current = [`${first}>`, comment, last].join("\n");
|
176
|
+
return;
|
129
177
|
}
|
130
178
|
|
131
|
-
|
179
|
+
updateRef(comment);
|
180
|
+
return;
|
132
181
|
}
|
133
182
|
|
134
183
|
if (fileRelativePath.endsWith(".html") || fileRelativePath.endsWith(".svg")) {
|
@@ -144,24 +193,31 @@ function addCommentToSourceCode(params: {
|
|
144
193
|
`-->`
|
145
194
|
].join("\n");
|
146
195
|
|
147
|
-
if (
|
148
|
-
|
196
|
+
if (
|
197
|
+
fileRelativePath.endsWith(".html") &&
|
198
|
+
refSourceCode.current.trim().startsWith("<!")
|
199
|
+
) {
|
200
|
+
const [first, ...rest] = refSourceCode.current.split(">");
|
149
201
|
|
150
202
|
const last = rest.join(">");
|
151
203
|
|
152
|
-
|
204
|
+
refSourceCode.current = [`${first}>`, comment, last].join("\n");
|
205
|
+
return;
|
153
206
|
}
|
154
207
|
|
155
|
-
if (
|
156
|
-
|
208
|
+
if (
|
209
|
+
fileRelativePath.endsWith(".svg") &&
|
210
|
+
refSourceCode.current.trim().startsWith("<?")
|
211
|
+
) {
|
212
|
+
const [first, ...rest] = refSourceCode.current.split("?>");
|
157
213
|
|
158
214
|
const last = rest.join("?>");
|
159
215
|
|
160
|
-
|
216
|
+
refSourceCode.current = [`${first}?>`, comment, last].join("\n");
|
217
|
+
return;
|
161
218
|
}
|
162
219
|
|
163
|
-
|
220
|
+
updateRef(comment);
|
221
|
+
return;
|
164
222
|
}
|
165
|
-
|
166
|
-
return sourceCode;
|
167
223
|
}
|
@@ -0,0 +1,189 @@
|
|
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
|
+
}
|
@@ -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
|
+
readManagedGitignoresFile,
|
6
|
+
writeManagedGitignoreFiles
|
7
|
+
} from "./managedGitignoreFiles";
|
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,6 +12,8 @@ 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";
|
15
17
|
|
16
18
|
export async function command(params: { buildContext: BuildContext }) {
|
17
19
|
const { buildContext } = params;
|
@@ -23,11 +25,11 @@ export async function command(params: { buildContext: BuildContext }) {
|
|
23
25
|
extensionModuleMetas
|
24
26
|
});
|
25
27
|
|
26
|
-
const { ownedFilesRelativePaths } = await
|
28
|
+
const { ownedFilesRelativePaths } = await readManagedGitignoresFile({
|
27
29
|
buildContext
|
28
30
|
});
|
29
31
|
|
30
|
-
await
|
32
|
+
await writeManagedGitignoreFiles({
|
31
33
|
buildContext,
|
32
34
|
ownedFilesRelativePaths,
|
33
35
|
extensionModuleMetas
|
@@ -38,13 +40,24 @@ export async function command(params: { buildContext: BuildContext }) {
|
|
38
40
|
.map(extensionModuleMeta =>
|
39
41
|
Promise.all(
|
40
42
|
extensionModuleMeta.files.map(
|
41
|
-
async ({
|
42
|
-
|
43
|
+
async ({
|
44
|
+
isPublic,
|
45
|
+
fileRelativePath,
|
46
|
+
copyableFilePath,
|
47
|
+
hash
|
48
|
+
}) => {
|
49
|
+
if (
|
50
|
+
ownedFilesRelativePaths.some(entry =>
|
51
|
+
same(entry, { isPublic, fileRelativePath })
|
52
|
+
)
|
53
|
+
) {
|
43
54
|
return;
|
44
55
|
}
|
45
56
|
|
46
57
|
const destFilePath = pathJoin(
|
47
|
-
|
58
|
+
isPublic
|
59
|
+
? pathJoin(buildContext.publicDirPath, KEYCLOAK_THEME)
|
60
|
+
: buildContext.themeSrcDirPath,
|
48
61
|
fileRelativePath
|
49
62
|
);
|
50
63
|
|
@@ -111,7 +111,15 @@ export async function getPrettier(): Promise<PrettierAndConfigHash> {
|
|
111
111
|
export async function runPrettier(params: {
|
112
112
|
sourceCode: string;
|
113
113
|
filePath: string;
|
114
|
-
}): Promise<string
|
114
|
+
}): Promise<string>;
|
115
|
+
export async function runPrettier(params: {
|
116
|
+
sourceCode: Buffer;
|
117
|
+
filePath: string;
|
118
|
+
}): Promise<Buffer>;
|
119
|
+
export async function runPrettier(params: {
|
120
|
+
sourceCode: string | Buffer;
|
121
|
+
filePath: string;
|
122
|
+
}): Promise<string | Buffer> {
|
115
123
|
const { sourceCode, filePath } = params;
|
116
124
|
|
117
125
|
let formattedSourceCode: string;
|
@@ -129,11 +137,14 @@ export async function runPrettier(params: {
|
|
129
137
|
|
130
138
|
const config = await prettier.resolveConfig(filePath);
|
131
139
|
|
132
|
-
formattedSourceCode = await prettier.format(
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
140
|
+
formattedSourceCode = await prettier.format(
|
141
|
+
typeof sourceCode === "string" ? sourceCode : sourceCode.toString("utf8"),
|
142
|
+
{
|
143
|
+
...config,
|
144
|
+
filePath,
|
145
|
+
parser: inferredParser
|
146
|
+
}
|
147
|
+
);
|
137
148
|
} catch (error) {
|
138
149
|
console.log(
|
139
150
|
chalk.red(
|
@@ -144,5 +155,7 @@ export async function runPrettier(params: {
|
|
144
155
|
throw error;
|
145
156
|
}
|
146
157
|
|
147
|
-
return
|
158
|
+
return typeof sourceCode === "string"
|
159
|
+
? formattedSourceCode
|
160
|
+
: Buffer.from(formattedSourceCode, "utf8");
|
148
161
|
}
|
@@ -2,7 +2,8 @@ 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
|
5
|
+
VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES,
|
6
|
+
KEYCLOAK_THEME
|
6
7
|
} from "../bin/shared/constants";
|
7
8
|
import { id } from "tsafe/id";
|
8
9
|
import { rm } from "../bin/tools/fs.rm";
|
@@ -203,6 +204,7 @@ export function keycloakify(params: keycloakify.Params) {
|
|
203
204
|
|
204
205
|
assert(buildDirPath !== undefined);
|
205
206
|
|
207
|
+
// NOTE: This is legacy and should eventually be removed
|
206
208
|
await rm(
|
207
209
|
pathJoin(
|
208
210
|
buildDirPath,
|
@@ -213,6 +215,11 @@ export function keycloakify(params: keycloakify.Params) {
|
|
213
215
|
force: true
|
214
216
|
}
|
215
217
|
);
|
218
|
+
|
219
|
+
await rm(pathJoin(buildDirPath, KEYCLOAK_THEME), {
|
220
|
+
recursive: true,
|
221
|
+
force: true
|
222
|
+
});
|
216
223
|
},
|
217
224
|
transformIndexHtml: html => {
|
218
225
|
const doReadKcContextFromUrl =
|
package/vite-plugin/index.js
CHANGED
@@ -1790,13 +1790,15 @@ async function runPrettier(params) {
|
|
1790
1790
|
return sourceCode;
|
1791
1791
|
}
|
1792
1792
|
const config = await prettier.resolveConfig(filePath);
|
1793
|
-
formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser }));
|
1793
|
+
formattedSourceCode = await prettier.format(typeof sourceCode === "string" ? sourceCode : sourceCode.toString("utf8"), Object.assign(Object.assign({}, config), { filePath, parser: inferredParser }));
|
1794
1794
|
}
|
1795
1795
|
catch (error) {
|
1796
1796
|
console.log(chalk__WEBPACK_IMPORTED_MODULE_4___default().red(`You probably need to upgrade the version of prettier in your project`));
|
1797
1797
|
throw error;
|
1798
1798
|
}
|
1799
|
-
return
|
1799
|
+
return typeof sourceCode === "string"
|
1800
|
+
? formattedSourceCode
|
1801
|
+
: Buffer.from(formattedSourceCode, "utf8");
|
1800
1802
|
}
|
1801
1803
|
//# sourceMappingURL=runPrettier.js.map
|
1802
1804
|
|
@@ -2118,10 +2120,15 @@ function keycloakify(params) {
|
|
2118
2120
|
return;
|
2119
2121
|
}
|
2120
2122
|
(0, assert_1.assert)(buildDirPath !== undefined);
|
2123
|
+
// NOTE: This is legacy and should eventually be removed
|
2121
2124
|
await (0, fs_rm_1.rm)((0, path_1.join)(buildDirPath, constants_1.WELL_KNOWN_DIRECTORY_BASE_NAME.KEYCLOAKIFY_DEV_RESOURCES), {
|
2122
2125
|
recursive: true,
|
2123
2126
|
force: true
|
2124
2127
|
});
|
2128
|
+
await (0, fs_rm_1.rm)((0, path_1.join)(buildDirPath, constants_1.KEYCLOAK_THEME), {
|
2129
|
+
recursive: true,
|
2130
|
+
force: true
|
2131
|
+
});
|
2125
2132
|
},
|
2126
2133
|
transformIndexHtml: html => {
|
2127
2134
|
const doReadKcContextFromUrl = process.env.NODE_ENV === "development" &&
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import type { ExtensionModuleMeta } from "./extensionModuleMeta";
|
2
|
-
export type BuildContextLike = {
|
3
|
-
themeSrcDirPath: string;
|
4
|
-
};
|
5
|
-
export declare function writeManagedGitignoreFile(params: {
|
6
|
-
buildContext: BuildContextLike;
|
7
|
-
extensionModuleMetas: ExtensionModuleMeta[];
|
8
|
-
ownedFilesRelativePaths: string[];
|
9
|
-
}): Promise<void>;
|
10
|
-
export declare function readManagedGitignoreFile(params: {
|
11
|
-
buildContext: BuildContextLike;
|
12
|
-
}): Promise<{
|
13
|
-
ownedFilesRelativePaths: string[];
|
14
|
-
}>;
|