keycloakify 11.8.47-rc.2 → 11.8.47
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/254.index.js +41 -3
- package/bin/main.js +13 -10
- package/package.json +1 -1
- package/src/bin/initialize-login-theme.ts +49 -3
- package/src/bin/shared/buildContext.ts +16 -10
- package/src/bin/tools/fetchProxyOptions.ts +1 -4
- package/vite-plugin/index.js +13 -10
package/bin/254.index.js
CHANGED
@@ -146,7 +146,7 @@ async function command(params) {
|
|
146
146
|
}
|
147
147
|
{
|
148
148
|
const moduleName = "@keycloakify/login-ui";
|
149
|
-
const latestVersion =
|
149
|
+
const latestVersion = getModuleLatestVersion({ moduleName });
|
150
150
|
((_c = parsedPackageJson.dependencies) !== null && _c !== void 0 ? _c : (parsedPackageJson.dependencies = {}))[moduleName] = `~${latestVersion}`;
|
151
151
|
if (parsedPackageJson.devDependencies !== undefined) {
|
152
152
|
delete parsedPackageJson.devDependencies[moduleName];
|
@@ -157,10 +157,48 @@ async function command(params) {
|
|
157
157
|
break install_stories;
|
158
158
|
}
|
159
159
|
const moduleName = "@keycloakify/login-ui-storybook";
|
160
|
-
const latestVersion =
|
160
|
+
const latestVersion = getModuleLatestVersion({ moduleName });
|
161
161
|
((_d = parsedPackageJson.devDependencies) !== null && _d !== void 0 ? _d : (parsedPackageJson.devDependencies = {}))[moduleName] = `~${latestVersion}`;
|
162
162
|
delete parsedPackageJson.dependencies[moduleName];
|
163
163
|
}
|
164
|
+
update_main_dev: {
|
165
|
+
for (const fileBasename of ["main-kc.dev.tsx", "main.dev.tsx"]) {
|
166
|
+
const filePath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(buildContext.themeSrcDirPath, fileBasename);
|
167
|
+
if (!(await (0,_tools_fs_existsAsync__WEBPACK_IMPORTED_MODULE_10__/* .existsAsync */ .o)(filePath))) {
|
168
|
+
continue;
|
169
|
+
}
|
170
|
+
const content = (await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(filePath)).toString("utf8");
|
171
|
+
if (!content.includes("export {}")) {
|
172
|
+
break update_main_dev;
|
173
|
+
}
|
174
|
+
let content_new = [
|
175
|
+
`import { createRoot } from "react-dom/client";`,
|
176
|
+
`import { StrictMode } from "react";`,
|
177
|
+
`import { KcPage } from "./kc.gen";`,
|
178
|
+
`import { getKcContextMock } from "./login/mocks/getKcContextMock";`,
|
179
|
+
``,
|
180
|
+
`const kcContext = getKcContextMock({`,
|
181
|
+
` pageId: "login.ftl",`,
|
182
|
+
` overrides: {}`,
|
183
|
+
`});`,
|
184
|
+
``,
|
185
|
+
`createRoot(document.getElementById("root")!).render(`,
|
186
|
+
` <StrictMode>`,
|
187
|
+
` <KcPage kcContext={kcContext} />`,
|
188
|
+
` </StrictMode>`,
|
189
|
+
`);`,
|
190
|
+
``
|
191
|
+
].join("\n");
|
192
|
+
if (await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_5__/* .getIsPrettierAvailable */ .MT)()) {
|
193
|
+
content_new = await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_5__/* .runPrettier */ .eY)({
|
194
|
+
sourceCode: content_new,
|
195
|
+
filePath
|
196
|
+
});
|
197
|
+
}
|
198
|
+
await fs_promises__WEBPACK_IMPORTED_MODULE_2__.writeFile(filePath, content_new);
|
199
|
+
break;
|
200
|
+
}
|
201
|
+
}
|
164
202
|
{
|
165
203
|
let sourceCode = JSON.stringify(parsedPackageJson, null, 2);
|
166
204
|
if (await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_5__/* .getIsPrettierAvailable */ .MT)()) {
|
@@ -175,7 +213,7 @@ async function command(params) {
|
|
175
213
|
packageJsonDirPath: (0,path__WEBPACK_IMPORTED_MODULE_1__.dirname)(buildContext.packageJsonFilePath)
|
176
214
|
});
|
177
215
|
}
|
178
|
-
|
216
|
+
function getModuleLatestVersion(params) {
|
179
217
|
const { moduleName } = params;
|
180
218
|
const versions = (() => {
|
181
219
|
const cmdOutput = child_process__WEBPACK_IMPORTED_MODULE_7__.execSync(`npm show ${moduleName} versions --json`)
|
package/bin/main.js
CHANGED
@@ -72,10 +72,7 @@ function getProxyFetchOptions(params) {
|
|
72
72
|
var _a, _b, _c;
|
73
73
|
const { npmConfigGetCwd } = params;
|
74
74
|
const cfg = (() => {
|
75
|
-
const output = external_child_process_.execSync("npm config get", {
|
76
|
-
cwd: npmConfigGetCwd,
|
77
|
-
stdio: ["pipe", "pipe", "ignore"]
|
78
|
-
})
|
75
|
+
const output = external_child_process_.execSync("npm config get", { cwd: npmConfigGetCwd })
|
79
76
|
.toString("utf8");
|
80
77
|
return output
|
81
78
|
.split("\n")
|
@@ -203,12 +200,18 @@ function getBuildContext(params) {
|
|
203
200
|
undefined) {
|
204
201
|
return { resolvedViteConfig: undefined };
|
205
202
|
}
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
203
|
+
let output;
|
204
|
+
try {
|
205
|
+
output = external_child_process_.execSync("npx vite", {
|
206
|
+
cwd: projectDirPath,
|
207
|
+
stdio: ["pipe", "pipe", "ignore"],
|
208
|
+
env: Object.assign(Object.assign({}, process.env), { [constants/* VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RESOLVE_VITE_CONFIG */.TE.RESOLVE_VITE_CONFIG]: "true" })
|
209
|
+
})
|
210
|
+
.toString("utf8");
|
211
|
+
}
|
212
|
+
catch (error) {
|
213
|
+
throw new Error(`Failed to run \`npx vite\`: ${error}`);
|
214
|
+
}
|
212
215
|
(0,assert/* assert */.h)(output.includes(constants/* VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RESOLVE_VITE_CONFIG */.TE.RESOLVE_VITE_CONFIG), "Seems like the Keycloakify's Vite plugin is not installed.");
|
213
216
|
const resolvedViteConfigStr = output
|
214
217
|
.split(constants/* VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RESOLVE_VITE_CONFIG */.TE.RESOLVE_VITE_CONFIG)
|
package/package.json
CHANGED
@@ -168,7 +168,7 @@ export async function command(params: { buildContext: BuildContext }) {
|
|
168
168
|
{
|
169
169
|
const moduleName = "@keycloakify/login-ui";
|
170
170
|
|
171
|
-
const latestVersion =
|
171
|
+
const latestVersion = getModuleLatestVersion({ moduleName });
|
172
172
|
|
173
173
|
(parsedPackageJson.dependencies ??= {})[moduleName] = `~${latestVersion}`;
|
174
174
|
|
@@ -184,13 +184,59 @@ export async function command(params: { buildContext: BuildContext }) {
|
|
184
184
|
|
185
185
|
const moduleName = "@keycloakify/login-ui-storybook";
|
186
186
|
|
187
|
-
const latestVersion =
|
187
|
+
const latestVersion = getModuleLatestVersion({ moduleName });
|
188
188
|
|
189
189
|
(parsedPackageJson.devDependencies ??= {})[moduleName] = `~${latestVersion}`;
|
190
190
|
|
191
191
|
delete parsedPackageJson.dependencies[moduleName];
|
192
192
|
}
|
193
193
|
|
194
|
+
update_main_dev: {
|
195
|
+
for (const fileBasename of ["main-kc.dev.tsx", "main.dev.tsx"]) {
|
196
|
+
const filePath = pathJoin(buildContext.themeSrcDirPath, fileBasename);
|
197
|
+
|
198
|
+
if (!(await existsAsync(filePath))) {
|
199
|
+
continue;
|
200
|
+
}
|
201
|
+
|
202
|
+
const content = (await fs.readFile(filePath)).toString("utf8");
|
203
|
+
|
204
|
+
if (!content.includes("export {}")) {
|
205
|
+
break update_main_dev;
|
206
|
+
}
|
207
|
+
|
208
|
+
let content_new = [
|
209
|
+
`import { createRoot } from "react-dom/client";`,
|
210
|
+
`import { StrictMode } from "react";`,
|
211
|
+
`import { KcPage } from "./kc.gen";`,
|
212
|
+
`import { getKcContextMock } from "./login/mocks/getKcContextMock";`,
|
213
|
+
``,
|
214
|
+
`const kcContext = getKcContextMock({`,
|
215
|
+
` pageId: "login.ftl",`,
|
216
|
+
` overrides: {}`,
|
217
|
+
`});`,
|
218
|
+
``,
|
219
|
+
`createRoot(document.getElementById("root")!).render(`,
|
220
|
+
` <StrictMode>`,
|
221
|
+
` <KcPage kcContext={kcContext} />`,
|
222
|
+
` </StrictMode>`,
|
223
|
+
`);`,
|
224
|
+
``
|
225
|
+
].join("\n");
|
226
|
+
|
227
|
+
if (await getIsPrettierAvailable()) {
|
228
|
+
content_new = await runPrettier({
|
229
|
+
sourceCode: content_new,
|
230
|
+
filePath
|
231
|
+
});
|
232
|
+
}
|
233
|
+
|
234
|
+
await fs.writeFile(filePath, content_new);
|
235
|
+
|
236
|
+
break;
|
237
|
+
}
|
238
|
+
}
|
239
|
+
|
194
240
|
{
|
195
241
|
let sourceCode = JSON.stringify(parsedPackageJson, null, 2);
|
196
242
|
|
@@ -212,7 +258,7 @@ export async function command(params: { buildContext: BuildContext }) {
|
|
212
258
|
});
|
213
259
|
}
|
214
260
|
|
215
|
-
|
261
|
+
function getModuleLatestVersion(params: { moduleName: string }) {
|
216
262
|
const { moduleName } = params;
|
217
263
|
|
218
264
|
const versions = ((): string[] => {
|
@@ -178,16 +178,22 @@ export function getBuildContext(params: {
|
|
178
178
|
return { resolvedViteConfig: undefined };
|
179
179
|
}
|
180
180
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
181
|
+
let output: string;
|
182
|
+
|
183
|
+
try {
|
184
|
+
output = child_process
|
185
|
+
.execSync("npx vite", {
|
186
|
+
cwd: projectDirPath,
|
187
|
+
stdio: ["pipe", "pipe", "ignore"],
|
188
|
+
env: {
|
189
|
+
...process.env,
|
190
|
+
[VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RESOLVE_VITE_CONFIG]: "true"
|
191
|
+
}
|
192
|
+
})
|
193
|
+
.toString("utf8");
|
194
|
+
} catch (error) {
|
195
|
+
throw new Error(`Failed to run \`npx vite\`: ${error}`);
|
196
|
+
}
|
191
197
|
|
192
198
|
assert(
|
193
199
|
output.includes(VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RESOLVE_VITE_CONFIG),
|
@@ -17,10 +17,7 @@ export function getProxyFetchOptions(params: {
|
|
17
17
|
|
18
18
|
const cfg = (() => {
|
19
19
|
const output = child_process
|
20
|
-
.execSync("npm config get", {
|
21
|
-
cwd: npmConfigGetCwd,
|
22
|
-
stdio: ["pipe", "pipe", "ignore"]
|
23
|
-
})
|
20
|
+
.execSync("npm config get", { cwd: npmConfigGetCwd })
|
24
21
|
.toString("utf8");
|
25
22
|
|
26
23
|
return output
|
package/vite-plugin/index.js
CHANGED
@@ -286,10 +286,7 @@ function getProxyFetchOptions(params) {
|
|
286
286
|
var _a, _b, _c;
|
287
287
|
const { npmConfigGetCwd } = params;
|
288
288
|
const cfg = (() => {
|
289
|
-
const output = external_child_process_.execSync("npm config get", {
|
290
|
-
cwd: npmConfigGetCwd,
|
291
|
-
stdio: ["pipe", "pipe", "ignore"]
|
292
|
-
})
|
289
|
+
const output = external_child_process_.execSync("npm config get", { cwd: npmConfigGetCwd })
|
293
290
|
.toString("utf8");
|
294
291
|
return output
|
295
292
|
.split("\n")
|
@@ -417,12 +414,18 @@ function getBuildContext(params) {
|
|
417
414
|
undefined) {
|
418
415
|
return { resolvedViteConfig: undefined };
|
419
416
|
}
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
417
|
+
let output;
|
418
|
+
try {
|
419
|
+
output = external_child_process_.execSync("npx vite", {
|
420
|
+
cwd: projectDirPath,
|
421
|
+
stdio: ["pipe", "pipe", "ignore"],
|
422
|
+
env: Object.assign(Object.assign({}, process.env), { [constants.VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RESOLVE_VITE_CONFIG]: "true" })
|
423
|
+
})
|
424
|
+
.toString("utf8");
|
425
|
+
}
|
426
|
+
catch (error) {
|
427
|
+
throw new Error(`Failed to run \`npx vite\`: ${error}`);
|
428
|
+
}
|
426
429
|
(0,assert/* assert */.h)(output.includes(constants.VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RESOLVE_VITE_CONFIG), "Seems like the Keycloakify's Vite plugin is not installed.");
|
427
430
|
const resolvedViteConfigStr = output
|
428
431
|
.split(constants.VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RESOLVE_VITE_CONFIG)
|