Rename scripts

This commit is contained in:
Joseph Garrone 2024-05-19 10:46:26 +02:00
parent d52252cd55
commit 189bd4697a
9 changed files with 24 additions and 17 deletions

View File

@ -3,6 +3,11 @@ import * as fs from "fs";
import { join } from "path"; import { join } from "path";
import { assert } from "tsafe/assert"; import { assert } from "tsafe/assert";
import { transformCodebase } from "../src/bin/tools/transformCodebase"; import { transformCodebase } from "../src/bin/tools/transformCodebase";
import chalk from "chalk";
console.log(chalk.cyan("Building Keycloakify..."));
const startTime = Date.now();
if (fs.existsSync(join("dist", "bin", "main.original.js"))) { if (fs.existsSync(join("dist", "bin", "main.original.js"))) {
fs.renameSync(join("dist", "bin", "main.original.js"), join("dist", "bin", "main.js")); fs.renameSync(join("dist", "bin", "main.original.js"), join("dist", "bin", "main.js"));
@ -71,8 +76,10 @@ fs.rmSync(join("dist", "ncc_out"), { "recursive": true });
patchDeprecatedBufferApiUsage(join("dist", "vite-plugin", "index.js")); patchDeprecatedBufferApiUsage(join("dist", "vite-plugin", "index.js"));
console.log(chalk.green(`✓ built in ${((Date.now() - startTime) / 1000).toFixed(2)}s`));
function run(command: string) { function run(command: string) {
console.log(`$ ${command}`); console.log(chalk.grey(`$ ${command}`));
child_process.execSync(command, { "stdio": "inherit" }); child_process.execSync(command, { "stdio": "inherit" });
} }

View File

@ -2,7 +2,7 @@ import "minimal-polyfills/Object.fromEntries";
import * as fs from "fs"; import * as fs from "fs";
import { join as pathJoin, relative as pathRelative, dirname as pathDirname, sep as pathSep } from "path"; import { join as pathJoin, relative as pathRelative, dirname as pathDirname, sep as pathSep } from "path";
import { crawl } from "../src/bin/tools/crawl"; import { crawl } from "../src/bin/tools/crawl";
import { downloadBuiltinKeycloakTheme } from "../src/bin/shared/downloadBuiltinKeycloakTheme"; import { downloadKeycloakDefaultTheme } from "../src/bin/shared/downloadKeycloakDefaultTheme";
import { getThisCodebaseRootDirPath } from "../src/bin/tools/getThisCodebaseRootDirPath"; import { getThisCodebaseRootDirPath } from "../src/bin/tools/getThisCodebaseRootDirPath";
import { rmSync } from "../src/bin/tools/fs.rmSync"; import { rmSync } from "../src/bin/tools/fs.rmSync";
@ -25,7 +25,7 @@ async function main() {
fs.writeFileSync(pathJoin(tmpDirPath, ".gitignore"), Buffer.from("/*\n!.gitignore\n", "utf8")); fs.writeFileSync(pathJoin(tmpDirPath, ".gitignore"), Buffer.from("/*\n!.gitignore\n", "utf8"));
await downloadBuiltinKeycloakTheme({ await downloadKeycloakDefaultTheme({
keycloakVersion, keycloakVersion,
"destDirPath": tmpDirPath, "destDirPath": tmpDirPath,
"buildOptions": { "buildOptions": {

View File

@ -1,7 +1,7 @@
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 { promptKeycloakVersion } from "./shared/promptKeycloakVersion"; import { promptKeycloakVersion } from "./shared/promptKeycloakVersion";
import { readBuildOptions } from "./shared/buildOptions"; import { readBuildOptions } from "./shared/buildOptions";
import { downloadBuiltinKeycloakTheme } from "./shared/downloadBuiltinKeycloakTheme"; import { downloadKeycloakDefaultTheme } from "./shared/downloadKeycloakDefaultTheme";
import type { CliCommandOptions } from "./main"; import type { CliCommandOptions } from "./main";
import chalk from "chalk"; import chalk from "chalk";
@ -27,7 +27,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
`Downloading builtins theme of Keycloak ${keycloakVersion} here ${chalk.bold(`.${pathSep}${pathRelative(process.cwd(), destDirPath)}`)}` `Downloading builtins theme of Keycloak ${keycloakVersion} here ${chalk.bold(`.${pathSep}${pathRelative(process.cwd(), destDirPath)}`)}`
); );
await downloadBuiltinKeycloakTheme({ await downloadKeycloakDefaultTheme({
keycloakVersion, keycloakVersion,
destDirPath, destDirPath,
buildOptions buildOptions

View File

@ -1,4 +1,4 @@
import { downloadBuiltinKeycloakTheme } from "./shared/downloadBuiltinKeycloakTheme"; import { downloadKeycloakDefaultTheme } from "./shared/downloadKeycloakDefaultTheme";
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";
@ -37,7 +37,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
rmSync(builtinKeycloakThemeTmpDirPath, { "recursive": true, "force": true }); rmSync(builtinKeycloakThemeTmpDirPath, { "recursive": true, "force": true });
await downloadBuiltinKeycloakTheme({ await downloadKeycloakDefaultTheme({
keycloakVersion, keycloakVersion,
"destDirPath": builtinKeycloakThemeTmpDirPath, "destDirPath": builtinKeycloakThemeTmpDirPath,
buildOptions buildOptions

View File

@ -3,7 +3,7 @@ import { join as pathJoin } from "path";
import { assert } from "tsafe/assert"; import { assert } from "tsafe/assert";
import type { BuildOptions } from "../../shared/buildOptions"; import type { BuildOptions } from "../../shared/buildOptions";
import { resources_common, lastKeycloakVersionWithAccountV1, accountV1ThemeName } from "../../shared/constants"; import { resources_common, lastKeycloakVersionWithAccountV1, accountV1ThemeName } from "../../shared/constants";
import { downloadBuiltinKeycloakTheme } from "../../shared/downloadBuiltinKeycloakTheme"; import { downloadKeycloakDefaultTheme } from "../../shared/downloadKeycloakDefaultTheme";
import { transformCodebase } from "../../tools/transformCodebase"; import { transformCodebase } from "../../tools/transformCodebase";
import { rmSync } from "../../tools/fs.rmSync"; import { rmSync } from "../../tools/fs.rmSync";
@ -20,7 +20,7 @@ export async function bringInAccountV1(params: { buildOptions: BuildOptionsLike
const builtinKeycloakThemeTmpDirPath = pathJoin(buildOptions.cacheDirPath, "bringInAccountV1_tmp"); const builtinKeycloakThemeTmpDirPath = pathJoin(buildOptions.cacheDirPath, "bringInAccountV1_tmp");
await downloadBuiltinKeycloakTheme({ await downloadKeycloakDefaultTheme({
"destDirPath": builtinKeycloakThemeTmpDirPath, "destDirPath": builtinKeycloakThemeTmpDirPath,
"keycloakVersion": lastKeycloakVersionWithAccountV1, "keycloakVersion": lastKeycloakVersionWithAccountV1,
buildOptions buildOptions

View File

@ -107,13 +107,13 @@ program
program program
.command({ .command({
"name": "download-builtin-keycloak-theme", "name": "download-keycloak-default-theme",
"description": "Download the built-in Keycloak theme." "description": "Download the built-in Keycloak theme."
}) })
.task({ .task({
skip, skip,
"handler": async cliCommandOptions => { "handler": async cliCommandOptions => {
const { command } = await import("./download-builtin-keycloak-theme"); const { command } = await import("./download-keycloak-default-theme");
await command({ cliCommandOptions }); await command({ cliCommandOptions });
} }
@ -121,13 +121,13 @@ program
program program
.command({ .command({
"name": "eject-keycloak-page", "name": "eject-page",
"description": "Eject a Keycloak page." "description": "Eject a Keycloak page."
}) })
.task({ .task({
skip, skip,
"handler": async cliCommandOptions => { "handler": async cliCommandOptions => {
const { command } = await import("./eject-keycloak-page"); const { command } = await import("./eject-page");
await command({ cliCommandOptions }); await command({ cliCommandOptions });
} }

View File

@ -5,7 +5,7 @@ import { assert } from "tsafe/assert";
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 { rmSync } from "../tools/fs.rmSync"; import { rmSync } from "../tools/fs.rmSync";
import { lastKeycloakVersionWithAccountV1 } from "../shared/constants"; import { lastKeycloakVersionWithAccountV1 } from "./constants";
import { transformCodebase } from "../tools/transformCodebase"; import { transformCodebase } from "../tools/transformCodebase";
export type BuildOptionsLike = { export type BuildOptionsLike = {
@ -15,7 +15,7 @@ export type BuildOptionsLike = {
assert<BuildOptions extends BuildOptionsLike ? true : false>(); assert<BuildOptions extends BuildOptionsLike ? true : false>();
export async function downloadBuiltinKeycloakTheme(params: { keycloakVersion: string; destDirPath: string; buildOptions: BuildOptionsLike }) { export async function downloadKeycloakDefaultTheme(params: { keycloakVersion: string; destDirPath: string; buildOptions: BuildOptionsLike }) {
const { keycloakVersion, destDirPath, buildOptions } = params; const { keycloakVersion, destDirPath, buildOptions } = params;
await downloadAndUnzip({ await downloadAndUnzip({

View File

@ -1,6 +1,6 @@
import { transformCodebase } from "../tools/transformCodebase"; import { transformCodebase } from "../tools/transformCodebase";
import { join as pathJoin } from "path"; import { join as pathJoin } from "path";
import { downloadBuiltinKeycloakTheme } from "./downloadBuiltinKeycloakTheme"; import { downloadKeycloakDefaultTheme } from "./downloadKeycloakDefaultTheme";
import { resources_common, type ThemeType } from "./constants"; import { resources_common, type ThemeType } from "./constants";
import type { BuildOptions } from "./buildOptions"; import type { BuildOptions } from "./buildOptions";
import { assert } from "tsafe/assert"; import { assert } from "tsafe/assert";
@ -27,7 +27,7 @@ export async function downloadKeycloakStaticResources(params: {
`downloadKeycloakStaticResources_tmp_${crypto.createHash("sha256").update(`${themeType}-${keycloakVersion}`).digest("hex").slice(0, 8)}` `downloadKeycloakStaticResources_tmp_${crypto.createHash("sha256").update(`${themeType}-${keycloakVersion}`).digest("hex").slice(0, 8)}`
); );
await downloadBuiltinKeycloakTheme({ await downloadKeycloakDefaultTheme({
keycloakVersion, keycloakVersion,
"destDirPath": tmpDirPath, "destDirPath": tmpDirPath,
buildOptions buildOptions