Compare commits
1 Commits
v11.3.0-rc
...
angular_in
Author | SHA1 | Date | |
---|---|---|---|
daf95b3dbb |
package.jsonyarn.lock
src
bin
add-story.tscopy-keycloak-resources-to-public.ts
eject-page
initialize-account-theme
initialize-email-theme.tskeycloakify
main.tsshared
start-keycloak
tools
update-kc-gen.tsvite-plugin
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "keycloakify",
|
"name": "keycloakify",
|
||||||
"version": "11.3.0-rc.3",
|
"version": "11.2.10",
|
||||||
"description": "Framework to create custom Keycloak UIs",
|
"description": "Framework to create custom Keycloak UIs",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -38,14 +38,12 @@
|
|||||||
"dist/",
|
"dist/",
|
||||||
"!dist/tsconfig.tsbuildinfo",
|
"!dist/tsconfig.tsbuildinfo",
|
||||||
"!dist/bin/",
|
"!dist/bin/",
|
||||||
"dist/bin/**/*.d.ts",
|
|
||||||
"dist/bin/main.js",
|
"dist/bin/main.js",
|
||||||
"dist/bin/*.index.js",
|
"dist/bin/*.index.js",
|
||||||
"dist/bin/*.node",
|
"dist/bin/*.node",
|
||||||
"dist/bin/shared/constants.js",
|
"dist/bin/shared/constants.js",
|
||||||
"dist/bin/shared/constants.js.map",
|
"dist/bin/shared/*.d.ts",
|
||||||
"dist/bin/shared/customHandler.js",
|
"dist/bin/shared/*.js.map",
|
||||||
"dist/bin/shared/customHandler.js.map",
|
|
||||||
"!dist/vite-plugin/",
|
"!dist/vite-plugin/",
|
||||||
"dist/vite-plugin/index.js",
|
"dist/vite-plugin/index.js",
|
||||||
"dist/vite-plugin/index.d.ts",
|
"dist/vite-plugin/index.d.ts",
|
||||||
@ -73,6 +71,7 @@
|
|||||||
"@babel/preset-env": "7.24.8",
|
"@babel/preset-env": "7.24.8",
|
||||||
"@babel/types": "^7.24.5",
|
"@babel/types": "^7.24.5",
|
||||||
"@emotion/react": "^11.11.4",
|
"@emotion/react": "^11.11.4",
|
||||||
|
"@keycloakify/angular": "^0.0.1-rc.19",
|
||||||
"@octokit/rest": "^20.1.1",
|
"@octokit/rest": "^20.1.1",
|
||||||
"@storybook/addon-a11y": "^6.5.16",
|
"@storybook/addon-a11y": "^6.5.16",
|
||||||
"@storybook/builder-webpack5": "^6.5.13",
|
"@storybook/builder-webpack5": "^6.5.13",
|
||||||
|
@ -13,11 +13,16 @@ import * as fs from "fs";
|
|||||||
import { join as pathJoin, relative as pathRelative, dirname as pathDirname } from "path";
|
import { join as pathJoin, relative as pathRelative, dirname as pathDirname } from "path";
|
||||||
import { kebabCaseToCamelCase } from "./tools/kebabCaseToSnakeCase";
|
import { kebabCaseToCamelCase } from "./tools/kebabCaseToSnakeCase";
|
||||||
import { assert, Equals } from "tsafe/assert";
|
import { assert, Equals } from "tsafe/assert";
|
||||||
import type { BuildContext } from "./shared/buildContext";
|
import type { CliCommandOptions } from "./main";
|
||||||
|
import { getBuildContext } from "./shared/buildContext";
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
|
|
||||||
export async function command(params: { buildContext: BuildContext }) {
|
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
||||||
const { buildContext } = params;
|
const { cliCommandOptions } = params;
|
||||||
|
|
||||||
|
const buildContext = getBuildContext({
|
||||||
|
cliCommandOptions
|
||||||
|
});
|
||||||
|
|
||||||
console.log(chalk.cyan("Theme type:"));
|
console.log(chalk.cyan("Theme type:"));
|
||||||
|
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
import { copyKeycloakResourcesToPublic } from "./shared/copyKeycloakResourcesToPublic";
|
import { copyKeycloakResourcesToPublic } from "./shared/copyKeycloakResourcesToPublic";
|
||||||
import type { BuildContext } from "./shared/buildContext";
|
import { getBuildContext } from "./shared/buildContext";
|
||||||
|
import type { CliCommandOptions } from "./main";
|
||||||
|
|
||||||
export async function command(params: { buildContext: BuildContext }) {
|
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
||||||
const { buildContext } = params;
|
const { cliCommandOptions } = params;
|
||||||
|
|
||||||
|
const buildContext = getBuildContext({ cliCommandOptions });
|
||||||
|
|
||||||
copyKeycloakResourcesToPublic({
|
copyKeycloakResourcesToPublic({
|
||||||
buildContext
|
buildContext
|
||||||
|
@ -20,11 +20,16 @@ import {
|
|||||||
} from "path";
|
} from "path";
|
||||||
import { kebabCaseToCamelCase } from "./tools/kebabCaseToSnakeCase";
|
import { kebabCaseToCamelCase } from "./tools/kebabCaseToSnakeCase";
|
||||||
import { assert, Equals } from "tsafe/assert";
|
import { assert, Equals } from "tsafe/assert";
|
||||||
import type { BuildContext } from "./shared/buildContext";
|
import type { CliCommandOptions } from "./main";
|
||||||
|
import { getBuildContext } from "./shared/buildContext";
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
|
|
||||||
export async function command(params: { buildContext: BuildContext }) {
|
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
||||||
const { buildContext } = params;
|
const { cliCommandOptions } = params;
|
||||||
|
|
||||||
|
const buildContext = getBuildContext({
|
||||||
|
cliCommandOptions
|
||||||
|
});
|
||||||
|
|
||||||
console.log(chalk.cyan("Theme type:"));
|
console.log(chalk.cyan("Theme type:"));
|
||||||
|
|
0
src/bin/eject-page/index.ts
Normal file
0
src/bin/eject-page/index.ts
Normal file
0
src/bin/eject-page/react.ts
Normal file
0
src/bin/eject-page/react.ts
Normal file
@ -1,4 +1,5 @@
|
|||||||
import type { BuildContext } from "../shared/buildContext";
|
import { getBuildContext } from "../shared/buildContext";
|
||||||
|
import type { CliCommandOptions } from "../main";
|
||||||
import cliSelect from "cli-select";
|
import cliSelect from "cli-select";
|
||||||
import child_process from "child_process";
|
import child_process from "child_process";
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
@ -7,8 +8,10 @@ import * as fs from "fs";
|
|||||||
import { updateAccountThemeImplementationInConfig } from "./updateAccountThemeImplementationInConfig";
|
import { updateAccountThemeImplementationInConfig } from "./updateAccountThemeImplementationInConfig";
|
||||||
import { generateKcGenTs } from "../shared/generateKcGenTs";
|
import { generateKcGenTs } from "../shared/generateKcGenTs";
|
||||||
|
|
||||||
export async function command(params: { buildContext: BuildContext }) {
|
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
||||||
const { buildContext } = params;
|
const { cliCommandOptions } = params;
|
||||||
|
|
||||||
|
const buildContext = getBuildContext({ cliCommandOptions });
|
||||||
|
|
||||||
const accountThemeSrcDirPath = pathJoin(buildContext.themeSrcDirPath, "account");
|
const accountThemeSrcDirPath = pathJoin(buildContext.themeSrcDirPath, "account");
|
||||||
|
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
import { join as pathJoin, relative as pathRelative } from "path";
|
import { join as pathJoin, relative as pathRelative } from "path";
|
||||||
import { transformCodebase } from "./tools/transformCodebase";
|
import { transformCodebase } from "./tools/transformCodebase";
|
||||||
import { promptKeycloakVersion } from "./shared/promptKeycloakVersion";
|
import { promptKeycloakVersion } from "./shared/promptKeycloakVersion";
|
||||||
import type { BuildContext } from "./shared/buildContext";
|
import { getBuildContext } from "./shared/buildContext";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
|
import type { CliCommandOptions } from "./main";
|
||||||
import { downloadAndExtractArchive } from "./tools/downloadAndExtractArchive";
|
import { downloadAndExtractArchive } from "./tools/downloadAndExtractArchive";
|
||||||
|
|
||||||
export async function command(params: { buildContext: BuildContext }) {
|
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
||||||
const { buildContext } = params;
|
const { cliCommandOptions } = params;
|
||||||
|
|
||||||
|
const buildContext = getBuildContext({ cliCommandOptions });
|
||||||
|
|
||||||
const emailThemeSrcDirPath = pathJoin(buildContext.themeSrcDirPath, "email");
|
const emailThemeSrcDirPath = pathJoin(buildContext.themeSrcDirPath, "email");
|
||||||
|
|
||||||
|
@ -2,16 +2,19 @@ import { generateResources } from "./generateResources";
|
|||||||
import { join as pathJoin, relative as pathRelative, sep as pathSep } from "path";
|
import { join as pathJoin, relative as pathRelative, sep as pathSep } from "path";
|
||||||
import * as child_process from "child_process";
|
import * as child_process from "child_process";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import type { BuildContext } from "../shared/buildContext";
|
import { getBuildContext } from "../shared/buildContext";
|
||||||
import { VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES } from "../shared/constants";
|
import { VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES } from "../shared/constants";
|
||||||
import { buildJars } from "./buildJars";
|
import { buildJars } from "./buildJars";
|
||||||
|
import type { CliCommandOptions } from "../main";
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import { readThisNpmPackageVersion } from "../tools/readThisNpmPackageVersion";
|
import { readThisNpmPackageVersion } from "../tools/readThisNpmPackageVersion";
|
||||||
import * as os from "os";
|
import * as os from "os";
|
||||||
import { rmSync } from "../tools/fs.rmSync";
|
import { rmSync } from "../tools/fs.rmSync";
|
||||||
|
|
||||||
export async function command(params: { buildContext: BuildContext }) {
|
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
||||||
const { buildContext } = params;
|
const { cliCommandOptions } = params;
|
||||||
|
|
||||||
|
const buildContext = getBuildContext({ cliCommandOptions });
|
||||||
|
|
||||||
exit_if_maven_not_installed: {
|
exit_if_maven_not_installed: {
|
||||||
let commandOutput: Buffer | undefined = undefined;
|
let commandOutput: Buffer | undefined = undefined;
|
||||||
|
109
src/bin/main.ts
109
src/bin/main.ts
@ -4,10 +4,8 @@ import { termost } from "termost";
|
|||||||
import { readThisNpmPackageVersion } from "./tools/readThisNpmPackageVersion";
|
import { readThisNpmPackageVersion } from "./tools/readThisNpmPackageVersion";
|
||||||
import * as child_process from "child_process";
|
import * as child_process from "child_process";
|
||||||
import { assertNoPnpmDlx } from "./tools/assertNoPnpmDlx";
|
import { assertNoPnpmDlx } from "./tools/assertNoPnpmDlx";
|
||||||
import { callHandlerIfAny } from "./shared/customHandler_caller";
|
|
||||||
import { getBuildContext } from "./shared/buildContext";
|
|
||||||
|
|
||||||
type CliCommandOptions = {
|
export type CliCommandOptions = {
|
||||||
projectDirPath: string | undefined;
|
projectDirPath: string | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -71,25 +69,20 @@ program
|
|||||||
})
|
})
|
||||||
.task({
|
.task({
|
||||||
skip,
|
skip,
|
||||||
handler: async ({ projectDirPath }) => {
|
handler: async cliCommandOptions => {
|
||||||
const buildContext = getBuildContext({ projectDirPath });
|
|
||||||
|
|
||||||
const { command } = await import("./keycloakify");
|
const { command } = await import("./keycloakify");
|
||||||
|
|
||||||
await command({ buildContext });
|
await command({ cliCommandOptions });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
{
|
|
||||||
const commandName = "start-keycloak";
|
|
||||||
|
|
||||||
program
|
program
|
||||||
.command<{
|
.command<{
|
||||||
port: number | undefined;
|
port: number | undefined;
|
||||||
keycloakVersion: string | undefined;
|
keycloakVersion: string | undefined;
|
||||||
realmJsonFilePath: string | undefined;
|
realmJsonFilePath: string | undefined;
|
||||||
}>({
|
}>({
|
||||||
name: commandName,
|
name: "start-keycloak",
|
||||||
description:
|
description:
|
||||||
"Spin up a pre configured Docker image of Keycloak to test your theme."
|
"Spin up a pre configured Docker image of Keycloak to test your theme."
|
||||||
})
|
})
|
||||||
@ -137,92 +130,54 @@ program
|
|||||||
})
|
})
|
||||||
.task({
|
.task({
|
||||||
skip,
|
skip,
|
||||||
handler: async ({
|
handler: async cliCommandOptions => {
|
||||||
projectDirPath,
|
|
||||||
keycloakVersion,
|
|
||||||
port,
|
|
||||||
realmJsonFilePath
|
|
||||||
}) => {
|
|
||||||
const buildContext = getBuildContext({ projectDirPath });
|
|
||||||
|
|
||||||
const { command } = await import("./start-keycloak");
|
const { command } = await import("./start-keycloak");
|
||||||
|
|
||||||
await command({
|
await command({ cliCommandOptions });
|
||||||
buildContext,
|
|
||||||
cliCommandOptions: { keycloakVersion, port, realmJsonFilePath }
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
const commandName = "eject-page";
|
|
||||||
|
|
||||||
program
|
program
|
||||||
.command({
|
.command({
|
||||||
name: commandName,
|
name: "eject-page",
|
||||||
description: "Eject a Keycloak page."
|
description: "Eject a Keycloak page."
|
||||||
})
|
})
|
||||||
.task({
|
.task({
|
||||||
skip,
|
skip,
|
||||||
handler: async ({ projectDirPath }) => {
|
handler: async cliCommandOptions => {
|
||||||
const buildContext = getBuildContext({ projectDirPath });
|
|
||||||
|
|
||||||
console.log("before callHandlerIfAny");
|
|
||||||
|
|
||||||
callHandlerIfAny({ buildContext, commandName });
|
|
||||||
|
|
||||||
console.log("after callHandlerIfAny");
|
|
||||||
|
|
||||||
const { command } = await import("./eject-page");
|
const { command } = await import("./eject-page");
|
||||||
|
|
||||||
await command({ buildContext });
|
await command({ cliCommandOptions });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
const commandName = "add-story";
|
|
||||||
|
|
||||||
program
|
program
|
||||||
.command({
|
.command({
|
||||||
name: commandName,
|
name: "add-story",
|
||||||
description:
|
description: "Add *.stories.tsx file for a specific page to in your Storybook."
|
||||||
"Add *.stories.tsx file for a specific page to in your Storybook."
|
|
||||||
})
|
})
|
||||||
.task({
|
.task({
|
||||||
skip,
|
skip,
|
||||||
handler: async ({ projectDirPath }) => {
|
handler: async cliCommandOptions => {
|
||||||
const buildContext = getBuildContext({ projectDirPath });
|
|
||||||
|
|
||||||
callHandlerIfAny({ buildContext, commandName });
|
|
||||||
|
|
||||||
const { command } = await import("./add-story");
|
const { command } = await import("./add-story");
|
||||||
|
|
||||||
await command({ buildContext });
|
await command({ cliCommandOptions });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
const comandName = "initialize-login-theme";
|
|
||||||
|
|
||||||
program
|
program
|
||||||
.command({
|
.command({
|
||||||
name: comandName,
|
name: "initialize-email-theme",
|
||||||
description: "Initialize an email theme."
|
description: "Initialize an email theme."
|
||||||
})
|
})
|
||||||
.task({
|
.task({
|
||||||
skip,
|
skip,
|
||||||
handler: async ({ projectDirPath }) => {
|
handler: async cliCommandOptions => {
|
||||||
const buildContext = getBuildContext({ projectDirPath });
|
|
||||||
|
|
||||||
const { command } = await import("./initialize-email-theme");
|
const { command } = await import("./initialize-email-theme");
|
||||||
|
|
||||||
await command({ buildContext });
|
await command({ cliCommandOptions });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
program
|
program
|
||||||
.command({
|
.command({
|
||||||
@ -231,58 +186,42 @@ program
|
|||||||
})
|
})
|
||||||
.task({
|
.task({
|
||||||
skip,
|
skip,
|
||||||
handler: async ({ projectDirPath }) => {
|
handler: async cliCommandOptions => {
|
||||||
const buildContext = getBuildContext({ projectDirPath });
|
|
||||||
|
|
||||||
const { command } = await import("./initialize-account-theme");
|
const { command } = await import("./initialize-account-theme");
|
||||||
|
|
||||||
await command({ buildContext });
|
await command({ cliCommandOptions });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
{
|
|
||||||
const commandName = "copy-keycloak-resources-to-public";
|
|
||||||
|
|
||||||
program
|
program
|
||||||
.command({
|
.command({
|
||||||
name: commandName,
|
name: "copy-keycloak-resources-to-public",
|
||||||
description:
|
description:
|
||||||
"(Webpack/Create-React-App only) Copy Keycloak default theme resources to the public directory."
|
"(Webpack/Create-React-App only) Copy Keycloak default theme resources to the public directory."
|
||||||
})
|
})
|
||||||
.task({
|
.task({
|
||||||
skip,
|
skip,
|
||||||
handler: async ({ projectDirPath }) => {
|
handler: async cliCommandOptions => {
|
||||||
const buildContext = getBuildContext({ projectDirPath });
|
|
||||||
|
|
||||||
const { command } = await import("./copy-keycloak-resources-to-public");
|
const { command } = await import("./copy-keycloak-resources-to-public");
|
||||||
|
|
||||||
await command({ buildContext });
|
await command({ cliCommandOptions });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
const commandName = "update-kc-gen";
|
|
||||||
|
|
||||||
program
|
program
|
||||||
.command({
|
.command({
|
||||||
name: commandName,
|
name: "update-kc-gen",
|
||||||
description:
|
description:
|
||||||
"(Webpack/Create-React-App only) Create/update the kc.gen.ts file in your project."
|
"(Webpack/Create-React-App only) Create/update the kc.gen.ts file in your project."
|
||||||
})
|
})
|
||||||
.task({
|
.task({
|
||||||
skip,
|
skip,
|
||||||
handler: async ({ projectDirPath }) => {
|
handler: async cliCommandOptions => {
|
||||||
const buildContext = getBuildContext({ projectDirPath });
|
|
||||||
|
|
||||||
callHandlerIfAny({ buildContext, commandName });
|
|
||||||
|
|
||||||
const { command } = await import("./update-kc-gen");
|
const { command } = await import("./update-kc-gen");
|
||||||
|
|
||||||
await command({ buildContext });
|
await command({ cliCommandOptions });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// Fallback to build command if no command is provided
|
// Fallback to build command if no command is provided
|
||||||
{
|
{
|
||||||
|
@ -7,6 +7,7 @@ import {
|
|||||||
dirname as pathDirname
|
dirname as pathDirname
|
||||||
} from "path";
|
} from "path";
|
||||||
import { getAbsoluteAndInOsFormatPath } from "../tools/getAbsoluteAndInOsFormatPath";
|
import { getAbsoluteAndInOsFormatPath } from "../tools/getAbsoluteAndInOsFormatPath";
|
||||||
|
import type { CliCommandOptions } from "../main";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { assert, type Equals } from "tsafe/assert";
|
import { assert, type Equals } from "tsafe/assert";
|
||||||
@ -23,7 +24,7 @@ import { objectEntries } from "tsafe/objectEntries";
|
|||||||
import { type ThemeType } from "./constants";
|
import { type ThemeType } from "./constants";
|
||||||
import { id } from "tsafe/id";
|
import { id } from "tsafe/id";
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import { getProxyFetchOptions, type FetchOptionsLike } from "../tools/fetchProxyOptions";
|
import { getProxyFetchOptions, type ProxyFetchOptions } from "../tools/fetchProxyOptions";
|
||||||
import { is } from "tsafe/is";
|
import { is } from "tsafe/is";
|
||||||
|
|
||||||
export type BuildContext = {
|
export type BuildContext = {
|
||||||
@ -42,7 +43,7 @@ export type BuildContext = {
|
|||||||
* In this case the urlPathname will be "/my-app/" */
|
* In this case the urlPathname will be "/my-app/" */
|
||||||
urlPathname: string | undefined;
|
urlPathname: string | undefined;
|
||||||
assetsDirPath: string;
|
assetsDirPath: string;
|
||||||
fetchOptions: FetchOptionsLike;
|
fetchOptions: ProxyFetchOptions;
|
||||||
kcContextExclusionsFtlCode: string | undefined;
|
kcContextExclusionsFtlCode: string | undefined;
|
||||||
environmentVariables: { name: string; default: string }[];
|
environmentVariables: { name: string; default: string }[];
|
||||||
themeSrcDirPath: string;
|
themeSrcDirPath: string;
|
||||||
@ -128,12 +129,14 @@ export type ResolvedViteConfig = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function getBuildContext(params: {
|
export function getBuildContext(params: {
|
||||||
projectDirPath: string | undefined;
|
cliCommandOptions: CliCommandOptions;
|
||||||
}): BuildContext {
|
}): BuildContext {
|
||||||
|
const { cliCommandOptions } = params;
|
||||||
|
|
||||||
const projectDirPath =
|
const projectDirPath =
|
||||||
params.projectDirPath !== undefined
|
cliCommandOptions.projectDirPath !== undefined
|
||||||
? getAbsoluteAndInOsFormatPath({
|
? getAbsoluteAndInOsFormatPath({
|
||||||
pathIsh: params.projectDirPath,
|
pathIsh: cliCommandOptions.projectDirPath,
|
||||||
cwd: process.cwd()
|
cwd: process.cwd()
|
||||||
})
|
})
|
||||||
: process.cwd();
|
: process.cwd();
|
||||||
|
@ -71,8 +71,3 @@ export type AccountThemePageId = (typeof ACCOUNT_THEME_PAGE_IDS)[number];
|
|||||||
export const CONTAINER_NAME = "keycloak-keycloakify";
|
export const CONTAINER_NAME = "keycloak-keycloakify";
|
||||||
|
|
||||||
export const FALLBACK_LANGUAGE_TAG = "en";
|
export const FALLBACK_LANGUAGE_TAG = "en";
|
||||||
|
|
||||||
export const CUSTOM_HANDLER_ENV_NAMES = {
|
|
||||||
COMMAND_NAME: "KEYCLOAKIFY_COMMAND_NAME",
|
|
||||||
BUILD_CONTEXT: "KEYCLOAKIFY_BUILD_CONTEXT"
|
|
||||||
};
|
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
import { assert } from "tsafe/assert";
|
|
||||||
import type { BuildContext } from "./buildContext";
|
|
||||||
import { CUSTOM_HANDLER_ENV_NAMES } from "./constants";
|
|
||||||
|
|
||||||
export const BIN_NAME = "_keycloakify-custom-handler";
|
|
||||||
|
|
||||||
export const NOT_IMPLEMENTED_EXIT_CODE = 78;
|
|
||||||
|
|
||||||
export type CommandName = "update-kc-gen" | "eject-page" | "add-story";
|
|
||||||
|
|
||||||
export type ApiVersion = "v1";
|
|
||||||
|
|
||||||
export function readParams(params: { apiVersion: ApiVersion }) {
|
|
||||||
const { apiVersion } = params;
|
|
||||||
|
|
||||||
assert(apiVersion === "v1");
|
|
||||||
|
|
||||||
const commandName = (() => {
|
|
||||||
const envValue = process.env[CUSTOM_HANDLER_ENV_NAMES.COMMAND_NAME];
|
|
||||||
|
|
||||||
assert(envValue !== undefined);
|
|
||||||
|
|
||||||
return envValue as CommandName;
|
|
||||||
})();
|
|
||||||
|
|
||||||
const buildContext = (() => {
|
|
||||||
const envValue = process.env[CUSTOM_HANDLER_ENV_NAMES.BUILD_CONTEXT];
|
|
||||||
|
|
||||||
assert(envValue !== undefined);
|
|
||||||
|
|
||||||
return JSON.parse(envValue) as BuildContext;
|
|
||||||
})();
|
|
||||||
|
|
||||||
return { commandName, buildContext };
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
import { assert, type Equals } from "tsafe/assert";
|
|
||||||
import type { BuildContext } from "./buildContext";
|
|
||||||
import { CUSTOM_HANDLER_ENV_NAMES } from "./constants";
|
|
||||||
import {
|
|
||||||
NOT_IMPLEMENTED_EXIT_CODE,
|
|
||||||
type CommandName,
|
|
||||||
BIN_NAME,
|
|
||||||
ApiVersion
|
|
||||||
} from "./customHandler";
|
|
||||||
import * as child_process from "child_process";
|
|
||||||
import { is } from "tsafe/is";
|
|
||||||
import { dirname as pathDirname } from "path";
|
|
||||||
import * as fs from "fs";
|
|
||||||
|
|
||||||
assert<Equals<ApiVersion, "v1">>();
|
|
||||||
|
|
||||||
export function callHandlerIfAny(params: {
|
|
||||||
commandName: CommandName;
|
|
||||||
buildContext: BuildContext;
|
|
||||||
}) {
|
|
||||||
const { commandName, buildContext } = params;
|
|
||||||
|
|
||||||
if (!fs.readdirSync(pathDirname(process.argv[1])).includes(BIN_NAME)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
child_process.execSync(`npx ${BIN_NAME}`, {
|
|
||||||
stdio: "inherit",
|
|
||||||
env: {
|
|
||||||
...process.env,
|
|
||||||
[CUSTOM_HANDLER_ENV_NAMES.COMMAND_NAME]: commandName,
|
|
||||||
[CUSTOM_HANDLER_ENV_NAMES.BUILD_CONTEXT]: JSON.stringify(buildContext)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (error: any) {
|
|
||||||
console.log(error.message);
|
|
||||||
console.log(error.status);
|
|
||||||
|
|
||||||
assert(is<child_process.ExecException>(error));
|
|
||||||
|
|
||||||
if (error.code === NOT_IMPLEMENTED_EXIT_CODE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
process.exit(error.code);
|
|
||||||
}
|
|
||||||
|
|
||||||
process.exit(0);
|
|
||||||
}
|
|
@ -1,5 +1,6 @@
|
|||||||
import type { BuildContext } from "../shared/buildContext";
|
import { getBuildContext } from "../shared/buildContext";
|
||||||
import { exclude } from "tsafe/exclude";
|
import { exclude } from "tsafe/exclude";
|
||||||
|
import type { CliCommandOptions as CliCommandOptions_common } from "../main";
|
||||||
import { promptKeycloakVersion } from "../shared/promptKeycloakVersion";
|
import { promptKeycloakVersion } from "../shared/promptKeycloakVersion";
|
||||||
import { CONTAINER_NAME } from "../shared/constants";
|
import { CONTAINER_NAME } from "../shared/constants";
|
||||||
import { SemVer } from "../tools/SemVer";
|
import { SemVer } from "../tools/SemVer";
|
||||||
@ -28,14 +29,13 @@ import { existsAsync } from "../tools/fs.existsAsync";
|
|||||||
import { rm } from "../tools/fs.rm";
|
import { rm } from "../tools/fs.rm";
|
||||||
import { downloadAndExtractArchive } from "../tools/downloadAndExtractArchive";
|
import { downloadAndExtractArchive } from "../tools/downloadAndExtractArchive";
|
||||||
|
|
||||||
export async function command(params: {
|
export type CliCommandOptions = CliCommandOptions_common & {
|
||||||
buildContext: BuildContext;
|
|
||||||
cliCommandOptions: {
|
|
||||||
port: number | undefined;
|
port: number | undefined;
|
||||||
keycloakVersion: string | undefined;
|
keycloakVersion: string | undefined;
|
||||||
realmJsonFilePath: string | undefined;
|
realmJsonFilePath: string | undefined;
|
||||||
};
|
};
|
||||||
}) {
|
|
||||||
|
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
||||||
exit_if_docker_not_installed: {
|
exit_if_docker_not_installed: {
|
||||||
let commandOutput: string | undefined = undefined;
|
let commandOutput: string | undefined = undefined;
|
||||||
|
|
||||||
@ -88,7 +88,9 @@ export async function command(params: {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { cliCommandOptions, buildContext } = params;
|
const { cliCommandOptions } = params;
|
||||||
|
|
||||||
|
const buildContext = getBuildContext({ cliCommandOptions });
|
||||||
|
|
||||||
const { dockerImageTag } = await (async () => {
|
const { dockerImageTag } = await (async () => {
|
||||||
if (cliCommandOptions.keycloakVersion !== undefined) {
|
if (cliCommandOptions.keycloakVersion !== undefined) {
|
||||||
|
@ -1,18 +1,16 @@
|
|||||||
|
import { type FetchOptions } from "make-fetch-happen";
|
||||||
import * as child_process from "child_process";
|
import * as child_process from "child_process";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { exclude } from "tsafe/exclude";
|
import { exclude } from "tsafe/exclude";
|
||||||
|
|
||||||
export type FetchOptionsLike = {
|
export type ProxyFetchOptions = Pick<
|
||||||
proxy: string | undefined;
|
FetchOptions,
|
||||||
noProxy: string | string[];
|
"proxy" | "noProxy" | "strictSSL" | "cert" | "ca"
|
||||||
strictSSL: boolean;
|
>;
|
||||||
cert: string | string[] | undefined;
|
|
||||||
ca: string[] | undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function getProxyFetchOptions(params: {
|
export function getProxyFetchOptions(params: {
|
||||||
npmConfigGetCwd: string;
|
npmConfigGetCwd: string;
|
||||||
}): FetchOptionsLike {
|
}): ProxyFetchOptions {
|
||||||
const { npmConfigGetCwd } = params;
|
const { npmConfigGetCwd } = params;
|
||||||
|
|
||||||
const cfg = (() => {
|
const cfg = (() => {
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
import type { BuildContext } from "./shared/buildContext";
|
import type { CliCommandOptions } from "./main";
|
||||||
|
import { getBuildContext } from "./shared/buildContext";
|
||||||
import { generateKcGenTs } from "./shared/generateKcGenTs";
|
import { generateKcGenTs } from "./shared/generateKcGenTs";
|
||||||
|
|
||||||
export async function command(params: { buildContext: BuildContext }) {
|
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
||||||
const { buildContext } = params;
|
const { cliCommandOptions } = params;
|
||||||
|
|
||||||
|
const buildContext = getBuildContext({
|
||||||
|
cliCommandOptions
|
||||||
|
});
|
||||||
|
|
||||||
await generateKcGenTs({ buildContext });
|
await generateKcGenTs({ buildContext });
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,9 @@ export function keycloakify(params: keycloakify.Params) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const buildContext = getBuildContext({
|
const buildContext = getBuildContext({
|
||||||
|
cliCommandOptions: {
|
||||||
projectDirPath
|
projectDirPath
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
copyKeycloakResourcesToPublic({ buildContext }),
|
copyKeycloakResourcesToPublic({ buildContext }),
|
||||||
|
13
yarn.lock
13
yarn.lock
@ -2545,6 +2545,14 @@
|
|||||||
"@jridgewell/resolve-uri" "^3.1.0"
|
"@jridgewell/resolve-uri" "^3.1.0"
|
||||||
"@jridgewell/sourcemap-codec" "^1.4.14"
|
"@jridgewell/sourcemap-codec" "^1.4.14"
|
||||||
|
|
||||||
|
"@keycloakify/angular@^0.0.1-rc.19":
|
||||||
|
version "0.0.1-rc.19"
|
||||||
|
resolved "https://registry.yarnpkg.com/@keycloakify/angular/-/angular-0.0.1-rc.19.tgz#56edbfc74dc66d6ea23ff3b0d2e5ce48fad200c6"
|
||||||
|
integrity sha512-C2etRoAv2jCv+BMaIaJcEBKWEV8uM47pUpO37ZRFj78jChM+o8a0/Q+ooadkidKupvOe9K5SB91fdL3aUwTyEw==
|
||||||
|
dependencies:
|
||||||
|
tsafe "^1.7.5"
|
||||||
|
tslib "^2.3.0"
|
||||||
|
|
||||||
"@mdx-js/mdx@^1.6.22":
|
"@mdx-js/mdx@^1.6.22":
|
||||||
version "1.6.22"
|
version "1.6.22"
|
||||||
resolved "https://registry.yarnpkg.com/@mdx-js/mdx/-/mdx-1.6.22.tgz#8a723157bf90e78f17dc0f27995398e6c731f1ba"
|
resolved "https://registry.yarnpkg.com/@mdx-js/mdx/-/mdx-1.6.22.tgz#8a723157bf90e78f17dc0f27995398e6c731f1ba"
|
||||||
@ -12606,6 +12614,11 @@ tslib@^2.0.0, tslib@^2.0.1, tslib@^2.0.3, tslib@^2.1.0:
|
|||||||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf"
|
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf"
|
||||||
integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==
|
integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==
|
||||||
|
|
||||||
|
tslib@^2.3.0:
|
||||||
|
version "2.7.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.7.0.tgz#d9b40c5c40ab59e8738f297df3087bf1a2690c01"
|
||||||
|
integrity sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==
|
||||||
|
|
||||||
tss-react@^4.9.10:
|
tss-react@^4.9.10:
|
||||||
version "4.9.10"
|
version "4.9.10"
|
||||||
resolved "https://registry.yarnpkg.com/tss-react/-/tss-react-4.9.10.tgz#287392f4459116ac83c51fc117fad138ac06f139"
|
resolved "https://registry.yarnpkg.com/tss-react/-/tss-react-4.9.10.tgz#287392f4459116ac83c51fc117fad138ac06f139"
|
||||||
|
Reference in New Issue
Block a user