keycloakify
Version:
Framework to create custom Keycloak UIs
1,172 lines (1,055 loc) • 71.2 kB
JavaScript
"use strict";
exports.id = 363;
exports.ids = [363];
exports.modules = {
/***/ 77372:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
"x": () => (/* binding */ computeHash),
"f": () => (/* binding */ getExtensionModuleMetas)
});
// EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
var assert = __webpack_require__(29041);
// EXTERNAL MODULE: ./node_modules/tsafe/esm/id.mjs
var id = __webpack_require__(38469);
// EXTERNAL MODULE: ./node_modules/zod/lib/index.mjs
var lib = __webpack_require__(52300);
// EXTERNAL MODULE: external "path"
var external_path_ = __webpack_require__(71017);
// EXTERNAL MODULE: external "fs/promises"
var promises_ = __webpack_require__(73292);
// EXTERNAL MODULE: ./dist/bin/tools/fs.existsAsync.js
var fs_existsAsync = __webpack_require__(43765);
// EXTERNAL MODULE: ./dist/bin/tools/listInstalledModules.js
var listInstalledModules = __webpack_require__(75564);
;// CONCATENATED MODULE: ./dist/bin/tools/crawlAsync.js
/** List all files in a given directory return paths relative to the dir_path */
async function crawlAsync(params) {
const { dirPath, returnedPathsType, onFileFound } = params;
await crawlAsyncRec({
dirPath,
onFileFound: async ({ filePath }) => {
switch (returnedPathsType) {
case "absolute":
await onFileFound(filePath);
return;
case "relative to dirPath":
await onFileFound((0,external_path_.relative)(dirPath, filePath));
return;
}
(0,assert/* assert */.h)();
}
});
}
async function crawlAsyncRec(params) {
const { dirPath, onFileFound } = params;
await Promise.all((await promises_.readdir(dirPath)).map(async (basename) => {
const fileOrDirPath = (0,external_path_.join)(dirPath, basename);
const isDirectory = await promises_.lstat(fileOrDirPath)
.then(stat => stat.isDirectory());
if (isDirectory) {
await crawlAsyncRec({ dirPath: fileOrDirPath, onFileFound });
return;
}
await onFileFound({ filePath: fileOrDirPath });
}));
}
//# sourceMappingURL=crawlAsync.js.map
// EXTERNAL MODULE: ./dist/bin/tools/runPrettier.js
var runPrettier = __webpack_require__(48433);
// EXTERNAL MODULE: ./dist/bin/tools/readThisNpmPackageVersion.js
var readThisNpmPackageVersion = __webpack_require__(64795);
// EXTERNAL MODULE: ./dist/bin/sync-extensions/getExtensionModuleFileSourceCodeReadyToBeCopied.js
var getExtensionModuleFileSourceCodeReadyToBeCopied = __webpack_require__(2237);
// EXTERNAL MODULE: external "crypto"
var external_crypto_ = __webpack_require__(6113);
// EXTERNAL MODULE: ./dist/bin/shared/constants.js
var constants = __webpack_require__(173);
// EXTERNAL MODULE: ./node_modules/tsafe/esm/exclude.mjs
var exclude = __webpack_require__(83101);
;// CONCATENATED MODULE: ./node_modules/tsafe/esm/isAmong.mjs
/** https://docs.tsafe.dev/isamong */
function isAmong(names, value) {
for (const name of names) {
if (name === value) {
return true;
}
}
return false;
}
//# sourceMappingURL=isAmong.mjs.map
;// CONCATENATED MODULE: ./dist/bin/sync-extensions/extensionModuleMeta.js
const zExtensionModuleMeta = (() => {
const zTargetType = lib.z.object({
moduleName: lib.z.string(),
version: lib.z.string(),
files: lib.z.array(lib.z.object({
fileRelativePath: lib.z.string(),
hash: lib.z.string(),
copyableFilePath: lib.z.string()
})),
peerDependencies: lib.z.record(lib.z.string())
});
(0,assert/* assert */.h)();
return (0,id.id)(zTargetType);
})();
const zParsedCacheFile = (() => {
const zTargetType = lib.z.object({
keycloakifyVersion: lib.z.string(),
prettierConfigHash: lib.z.union([lib.z.string(), lib.z["null"]()]),
thisFilePath: lib.z.string(),
extensionModuleMetas: lib.z.array(zExtensionModuleMeta)
});
(0,assert/* assert */.h)();
return (0,id.id)(zTargetType);
})();
const CACHE_FILE_RELATIVE_PATH = (0,external_path_.join)("extension-modules", "cache.json");
(0,assert/* assert */.h)();
async function getExtensionModuleMetas(params) {
const { buildContext } = params;
const cacheFilePath = (0,external_path_.join)(buildContext.cacheDirPath, CACHE_FILE_RELATIVE_PATH);
const keycloakifyVersion = (0,readThisNpmPackageVersion/* readThisNpmPackageVersion */.K)();
const prettierConfigHash = await (async () => {
if (!(await (0,runPrettier/* getIsPrettierAvailable */.MT)())) {
return null;
}
const { configHash } = await (0,runPrettier/* getPrettier */.LG)();
return configHash;
})();
const installedExtensionModules = await (async () => {
const installedModulesWithKeycloakifyInTheName = await (0,listInstalledModules/* listInstalledModules */.P)({
packageJsonFilePath: buildContext.packageJsonFilePath,
filter: ({ moduleName }) => moduleName.includes("keycloakify") && moduleName !== "keycloakify"
});
return (await Promise.all(installedModulesWithKeycloakifyInTheName.map(async (entry) => {
if (!(await (0,fs_existsAsync/* existsAsync */.o)((0,external_path_.join)(entry.dirPath, constants/* KEYCLOAK_THEME */.PC)))) {
return undefined;
}
return entry;
}))).filter((0,exclude/* exclude */.D)(undefined));
})();
const cacheContent = await (async () => {
if (!(await (0,fs_existsAsync/* existsAsync */.o)(cacheFilePath))) {
return undefined;
}
return await promises_.readFile(cacheFilePath);
})();
const extensionModuleMetas_cacheUpToDate = await (async () => {
const parsedCacheFile = await (async () => {
if (cacheContent === undefined) {
return undefined;
}
const cacheContentStr = cacheContent.toString("utf8");
let parsedCacheFile;
try {
parsedCacheFile = JSON.parse(cacheContentStr);
}
catch (_a) {
return undefined;
}
try {
zParsedCacheFile.parse(parsedCacheFile);
}
catch (_b) {
return undefined;
}
(0,assert/* assert */.h)((0,assert.is)(parsedCacheFile));
return parsedCacheFile;
})();
if (parsedCacheFile === undefined) {
return [];
}
if (parsedCacheFile.keycloakifyVersion !== keycloakifyVersion) {
return [];
}
if (parsedCacheFile.prettierConfigHash !== prettierConfigHash) {
return [];
}
if (parsedCacheFile.thisFilePath !== cacheFilePath) {
return [];
}
const extensionModuleMetas_cacheUpToDate = parsedCacheFile.extensionModuleMetas.filter(extensionModuleMeta => {
const correspondingInstalledExtensionModule = installedExtensionModules.find(installedExtensionModule => installedExtensionModule.moduleName ===
extensionModuleMeta.moduleName);
if (correspondingInstalledExtensionModule === undefined) {
return false;
}
return (correspondingInstalledExtensionModule.version ===
extensionModuleMeta.version);
});
return extensionModuleMetas_cacheUpToDate;
})();
const extensionModuleMetas = await Promise.all(installedExtensionModules.map(async ({ moduleName, version, peerDependencies, dirPath }) => {
use_cache: {
const extensionModuleMeta_cache = extensionModuleMetas_cacheUpToDate.find(extensionModuleMeta => extensionModuleMeta.moduleName === moduleName);
if (extensionModuleMeta_cache === undefined) {
break use_cache;
}
return extensionModuleMeta_cache;
}
const files = [];
{
const srcDirPath = (0,external_path_.join)(dirPath, constants/* KEYCLOAK_THEME */.PC);
await crawlAsync({
dirPath: srcDirPath,
returnedPathsType: "relative to dirPath",
onFileFound: async (fileRelativePath) => {
const sourceCode = await (0,getExtensionModuleFileSourceCodeReadyToBeCopied/* getExtensionModuleFileSourceCodeReadyToBeCopied */.p)({
buildContext,
fileRelativePath,
isOwnershipAction: false,
extensionModuleDirPath: dirPath,
extensionModuleName: moduleName,
extensionModuleVersion: version
});
const hash = computeHash(sourceCode);
const copyableFilePath = (0,external_path_.join)((0,external_path_.dirname)(cacheFilePath), constants/* KEYCLOAK_THEME */.PC, fileRelativePath);
{
const dirPath = (0,external_path_.dirname)(copyableFilePath);
if (!(await (0,fs_existsAsync/* existsAsync */.o)(dirPath))) {
await promises_.mkdir(dirPath, { recursive: true });
}
}
promises_.writeFile(copyableFilePath, sourceCode);
files.push({
fileRelativePath,
hash,
copyableFilePath
});
}
});
}
return (0,id.id)({
moduleName,
version,
files,
peerDependencies: Object.fromEntries(Object.entries(peerDependencies).filter(([moduleName]) => !isAmong(["react", "@types/react"], moduleName)))
});
}));
update_cache: {
const parsedCacheFile = (0,id.id)({
keycloakifyVersion,
prettierConfigHash,
thisFilePath: cacheFilePath,
extensionModuleMetas
});
const cacheContent_new = Buffer.from(JSON.stringify(parsedCacheFile, null, 2), "utf8");
if (cacheContent !== undefined && cacheContent_new.equals(cacheContent)) {
break update_cache;
}
create_dir: {
const dirPath = (0,external_path_.dirname)(cacheFilePath);
if (await (0,fs_existsAsync/* existsAsync */.o)(dirPath)) {
break create_dir;
}
await promises_.mkdir(dirPath, { recursive: true });
}
await promises_.writeFile(cacheFilePath, cacheContent_new);
}
return extensionModuleMetas;
}
function computeHash(data) {
return external_crypto_.createHash("sha256").update(data).digest("hex");
}
//# sourceMappingURL=extensionModuleMeta.js.map
/***/ }),
/***/ 2237:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "p": () => (/* binding */ getExtensionModuleFileSourceCodeReadyToBeCopied)
/* harmony export */ });
/* harmony import */ var _tools_runPrettier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(48433);
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(73292);
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(71017);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(29041);
/* harmony import */ var _shared_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(173);
(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)();
async function getExtensionModuleFileSourceCodeReadyToBeCopied(params) {
const { buildContext, extensionModuleDirPath, fileRelativePath, isOwnershipAction, extensionModuleName, extensionModuleVersion } = params;
let sourceCode = (await fs_promises__WEBPACK_IMPORTED_MODULE_1__.readFile((0,path__WEBPACK_IMPORTED_MODULE_2__.join)(extensionModuleDirPath, _shared_constants__WEBPACK_IMPORTED_MODULE_4__/* .KEYCLOAK_THEME */ .PC, fileRelativePath))).toString("utf8");
sourceCode = addCommentToSourceCode({
sourceCode,
fileRelativePath,
commentLines: (() => {
const path = fileRelativePath.split(path__WEBPACK_IMPORTED_MODULE_2__.sep).join("/");
return isOwnershipAction
? [
`This file has been claimed for ownership from ${extensionModuleName} version ${extensionModuleVersion}.`,
`To relinquish ownership and restore this file to its original content, run the following command:`,
``,
`$ npx keycloakify own --path "${path}" --revert`
]
: [
`WARNING: Before modifying this file, run the following command:`,
``,
`$ npx keycloakify own --path "${path}"`,
``,
`This file is provided by ${extensionModuleName} version ${extensionModuleVersion}.`,
`It was copied into your repository by the postinstall script: \`keycloakify sync-extensions\`.`
];
})()
});
const destFilePath = (0,path__WEBPACK_IMPORTED_MODULE_2__.join)(buildContext.themeSrcDirPath, fileRelativePath);
format: {
if (!(await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_0__/* .getIsPrettierAvailable */ .MT)())) {
break format;
}
sourceCode = await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_0__/* .runPrettier */ .eY)({
filePath: destFilePath,
sourceCode
});
}
return Buffer.from(sourceCode, "utf8");
}
function addCommentToSourceCode(params) {
const { sourceCode, fileRelativePath, commentLines } = params;
const toResult = (comment) => {
return [comment, ``, sourceCode].join("\n");
};
for (const ext of [".ts", ".tsx", ".css", ".less", ".sass", ".js", ".jsx"]) {
if (!fileRelativePath.endsWith(ext)) {
continue;
}
return toResult([`/**`, ...commentLines.map(line => ` * ${line}`), ` */`].join("\n"));
}
if (fileRelativePath.endsWith(".properties")) {
return toResult(commentLines.map(line => `# ${line}`).join("\n"));
}
if (fileRelativePath.endsWith(".ftl")) {
const comment = [`<#--`, ...commentLines.map(line => ` ${line}`), `-->`].join("\n");
if (sourceCode.trim().startsWith("<#ftl")) {
const [first, ...rest] = sourceCode.split(">");
const last = rest.join(">");
return [`${first}>`, comment, last].join("\n");
}
return toResult(comment);
}
if (fileRelativePath.endsWith(".html") || fileRelativePath.endsWith(".svg")) {
const comment = [
`<!--`,
...commentLines.map(line => ` ${line
.replace("--path", "-t")
.replace("--revert", "-r")
.replace("Before modifying", "Before modifying or replacing")}`),
`-->`
].join("\n");
if (fileRelativePath.endsWith(".html") && sourceCode.trim().startsWith("<!")) {
const [first, ...rest] = sourceCode.split(">");
const last = rest.join(">");
return [`${first}>`, comment, last].join("\n");
}
if (fileRelativePath.endsWith(".svg") && sourceCode.trim().startsWith("<?")) {
const [first, ...rest] = sourceCode.split("?>");
const last = rest.join("?>");
return [`${first}?>`, comment, last].join("\n");
}
return toResult(comment);
}
return sourceCode;
}
//# sourceMappingURL=getExtensionModuleFileSourceCodeReadyToBeCopied.js.map
/***/ }),
/***/ 69674:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Y": () => (/* binding */ writeManagedGitignoreFile),
/* harmony export */ "w": () => (/* binding */ readManagedGitignoreFile)
/* harmony export */ });
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73292);
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71017);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(29041);
/* harmony import */ var _tools_fs_existsAsync__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(43765);
/* harmony import */ var _tools_getAbsoluteAndInOsFormatPath__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(84794);
(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_2__/* .assert */ .h)();
const DELIMITER_START = `# === Owned files start ===`;
const DELIMITER_END = `# === Owned files end =====`;
async function writeManagedGitignoreFile(params) {
const { buildContext, extensionModuleMetas, ownedFilesRelativePaths } = params;
if (extensionModuleMetas.length === 0) {
return;
}
const filePath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(buildContext.themeSrcDirPath, ".gitignore");
const content_new = Buffer.from([
`# This file is managed by Keycloakify, do not edit it manually.`,
``,
DELIMITER_START,
...ownedFilesRelativePaths
.map(fileRelativePath => fileRelativePath.split(path__WEBPACK_IMPORTED_MODULE_1__.sep).join("/"))
.map(line => `# ${line}`),
DELIMITER_END,
``,
...extensionModuleMetas
.map(extensionModuleMeta => [
`# === ${extensionModuleMeta.moduleName} v${extensionModuleMeta.version} ===`,
...extensionModuleMeta.files
.map(({ fileRelativePath }) => fileRelativePath)
.filter(fileRelativePath => !ownedFilesRelativePaths.includes(fileRelativePath))
.map(fileRelativePath => `/${fileRelativePath.split(path__WEBPACK_IMPORTED_MODULE_1__.sep).join("/").replace(/^\.\//, "")}`),
``
])
.flat()
].join("\n"), "utf8");
const content_current = await (async () => {
if (!(await (0,_tools_fs_existsAsync__WEBPACK_IMPORTED_MODULE_3__/* .existsAsync */ .o)(filePath))) {
return undefined;
}
return await fs_promises__WEBPACK_IMPORTED_MODULE_0__.readFile(filePath);
})();
if (content_current !== undefined && content_current.equals(content_new)) {
return;
}
create_dir: {
const dirPath = (0,path__WEBPACK_IMPORTED_MODULE_1__.dirname)(filePath);
if (await (0,_tools_fs_existsAsync__WEBPACK_IMPORTED_MODULE_3__/* .existsAsync */ .o)(dirPath)) {
break create_dir;
}
await fs_promises__WEBPACK_IMPORTED_MODULE_0__.mkdir(dirPath, { recursive: true });
}
await fs_promises__WEBPACK_IMPORTED_MODULE_0__.writeFile(filePath, content_new);
}
async function readManagedGitignoreFile(params) {
const { buildContext } = params;
const filePath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(buildContext.themeSrcDirPath, ".gitignore");
if (!(await (0,_tools_fs_existsAsync__WEBPACK_IMPORTED_MODULE_3__/* .existsAsync */ .o)(filePath))) {
return { ownedFilesRelativePaths: [] };
}
const contentStr = (await fs_promises__WEBPACK_IMPORTED_MODULE_0__.readFile(filePath)).toString("utf8");
const payload = (() => {
const index_start = contentStr.indexOf(DELIMITER_START);
const index_end = contentStr.indexOf(DELIMITER_END);
if (index_start === -1 || index_end === -1) {
return undefined;
}
return contentStr.slice(index_start + DELIMITER_START.length, index_end).trim();
})();
if (payload === undefined) {
return { ownedFilesRelativePaths: [] };
}
const ownedFilesRelativePaths = payload
.split("\n")
.map(line => line.trim())
.map(line => line.replace(/^# /, ""))
.filter(line => line !== "")
.map(line => (0,_tools_getAbsoluteAndInOsFormatPath__WEBPACK_IMPORTED_MODULE_4__/* .getAbsoluteAndInOsFormatPath */ .c)({
cwd: buildContext.themeSrcDirPath,
pathIsh: line
}))
.map(filePath => (0,path__WEBPACK_IMPORTED_MODULE_1__.relative)(buildContext.themeSrcDirPath, filePath));
return { ownedFilesRelativePaths };
}
//# sourceMappingURL=managedGitignoreFile.js.map
/***/ }),
/***/ 28363:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
"W": () => (/* binding */ command)
});
// EXTERNAL MODULE: ./dist/bin/sync-extensions/extensionModuleMeta.js + 2 modules
var sync_extensions_extensionModuleMeta = __webpack_require__(77372);
// EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
var assert = __webpack_require__(29041);
// EXTERNAL MODULE: ./node_modules/zod/lib/index.mjs
var lib = __webpack_require__(52300);
// EXTERNAL MODULE: ./node_modules/tsafe/esm/id.mjs
var id = __webpack_require__(38469);
// EXTERNAL MODULE: external "fs/promises"
var promises_ = __webpack_require__(73292);
// EXTERNAL MODULE: ./dist/bin/tools/SemVer.js
var SemVer = __webpack_require__(12171);
// EXTERNAL MODULE: ./node_modules/evt/tools/inDepth/same.js
var same = __webpack_require__(33805);
// EXTERNAL MODULE: ./dist/bin/tools/runPrettier.js
var runPrettier = __webpack_require__(48433);
// EXTERNAL MODULE: ./dist/bin/tools/npmInstall.js + 1 modules
var npmInstall = __webpack_require__(63046);
// EXTERNAL MODULE: external "path"
var external_path_ = __webpack_require__(71017);
;// CONCATENATED MODULE: ./dist/bin/sync-extensions/installExtensionModulesPeerDependencies.js
(0,assert/* assert */.h)();
(0,assert/* assert */.h)();
async function installExtensionModulesPeerDependencies(params) {
var _a, _b;
const { buildContext, extensionModuleMetas } = params;
const { extensionModulesPerDependencies } = (() => {
const extensionModulesPerDependencies = {};
for (const { peerDependencies } of extensionModuleMetas) {
for (const [peerDependencyName, versionRange_candidate] of Object.entries(peerDependencies)) {
const versionRange = (() => {
const versionRange_current = extensionModulesPerDependencies[peerDependencyName];
if (versionRange_current === undefined) {
return versionRange_candidate;
}
if (versionRange_current === "*") {
return versionRange_candidate;
}
if (versionRange_candidate === "*") {
return versionRange_current;
}
const { versionRange } = [
versionRange_current,
versionRange_candidate
]
.map(versionRange => ({
versionRange,
semVer: SemVer/* SemVer.parse */.h.parse((() => {
if (versionRange.startsWith("^") ||
versionRange.startsWith("~")) {
return versionRange.slice(1);
}
return versionRange;
})())
}))
.sort((a, b) => SemVer/* SemVer.compare */.h.compare(b.semVer, a.semVer))[0];
return versionRange;
})();
extensionModulesPerDependencies[peerDependencyName] = versionRange;
}
}
return { extensionModulesPerDependencies };
})();
const parsedPackageJson = await (async () => {
const zParsedPackageJson = (() => {
const zParsedPackageJson = lib.z.object({
dependencies: lib.z.record(lib.z.string()).optional(),
devDependencies: lib.z.record(lib.z.string()).optional()
});
(0,assert/* assert */.h)();
return (0,id.id)(zParsedPackageJson);
})();
const parsedPackageJson = JSON.parse((await promises_.readFile(buildContext.packageJsonFilePath)).toString("utf8"));
zParsedPackageJson.parse(parsedPackageJson);
(0,assert/* assert */.h)((0,assert.is)(parsedPackageJson));
return parsedPackageJson;
})();
const parsedPackageJson_before = JSON.parse(JSON.stringify(parsedPackageJson));
for (const [moduleName, versionRange] of Object.entries(extensionModulesPerDependencies)) {
if (moduleName.startsWith("@types/")) {
((_a = parsedPackageJson.devDependencies) !== null && _a !== void 0 ? _a : (parsedPackageJson.devDependencies = {}))[moduleName] = versionRange;
continue;
}
if (parsedPackageJson.devDependencies !== undefined) {
delete parsedPackageJson.devDependencies[moduleName];
}
((_b = parsedPackageJson.dependencies) !== null && _b !== void 0 ? _b : (parsedPackageJson.dependencies = {}))[moduleName] = versionRange;
}
if ((0,same.same)(parsedPackageJson, parsedPackageJson_before)) {
return;
}
let packageJsonContentStr = JSON.stringify(parsedPackageJson, null, 2);
format: {
if (!(await (0,runPrettier/* getIsPrettierAvailable */.MT)())) {
break format;
}
packageJsonContentStr = await (0,runPrettier/* runPrettier */.eY)({
sourceCode: packageJsonContentStr,
filePath: buildContext.packageJsonFilePath
});
}
await promises_.writeFile(buildContext.packageJsonFilePath, packageJsonContentStr);
await (0,npmInstall/* npmInstall */.c)({
packageJsonDirPath: (0,external_path_.dirname)(buildContext.packageJsonFilePath)
});
process.exit(0);
}
//# sourceMappingURL=installExtensionModulesPeerDependencies.js.map
// EXTERNAL MODULE: ./dist/bin/sync-extensions/managedGitignoreFile.js
var managedGitignoreFile = __webpack_require__(69674);
// EXTERNAL MODULE: ./dist/bin/tools/fs.existsAsync.js
var fs_existsAsync = __webpack_require__(43765);
// EXTERNAL MODULE: external "child_process"
var external_child_process_ = __webpack_require__(32081);
// EXTERNAL MODULE: ./node_modules/evt/tools/Deferred.js
var Deferred = __webpack_require__(50689);
// EXTERNAL MODULE: external "fs"
var external_fs_ = __webpack_require__(57147);
;// CONCATENATED MODULE: ./dist/bin/tools/isKnownByGit.js
function getIsKnownByGit(params) {
const { filePath } = params;
const dIsKnownByGit = new Deferred.Deferred();
let relativePath = (0,external_path_.basename)(filePath);
let dirPath = (0,external_path_.dirname)(filePath);
while (!external_fs_.existsSync(dirPath)) {
relativePath = (0,external_path_.join)((0,external_path_.basename)(dirPath), relativePath);
dirPath = (0,external_path_.dirname)(dirPath);
}
external_child_process_.exec(`git ls-files --error-unmatch '${relativePath.split(external_path_.sep).join("/")}'`, { cwd: dirPath }, error => {
if (error === null) {
dIsKnownByGit.resolve(true);
return;
}
if (error.code === 1) {
dIsKnownByGit.resolve(false);
return;
}
dIsKnownByGit.reject(error);
});
return dIsKnownByGit.pr;
}
//# sourceMappingURL=isKnownByGit.js.map
;// CONCATENATED MODULE: ./dist/bin/tools/untrackFromGit.js
async function untrackFromGit(params) {
const { filePath } = params;
const dDone = new Deferred.Deferred();
let relativePath = (0,external_path_.basename)(filePath);
let dirPath = (0,external_path_.dirname)(filePath);
while (!(await (0,fs_existsAsync/* existsAsync */.o)(dirPath))) {
relativePath = (0,external_path_.join)((0,external_path_.basename)(dirPath), relativePath);
dirPath = (0,external_path_.dirname)(dirPath);
}
external_child_process_.exec(`git rm --cached '${relativePath.split(external_path_.sep).join("/")}'`, { cwd: dirPath }, error => {
if (error !== null) {
dDone.reject(error);
return;
}
dDone.resolve();
});
await dDone.pr;
}
//# sourceMappingURL=untrackFromGit.js.map
;// CONCATENATED MODULE: ./dist/bin/sync-extensions/sync-extension.js
async function command(params) {
const { buildContext } = params;
const extensionModuleMetas = await (0,sync_extensions_extensionModuleMeta/* getExtensionModuleMetas */.f)({ buildContext });
await installExtensionModulesPeerDependencies({
buildContext,
extensionModuleMetas
});
const { ownedFilesRelativePaths } = await (0,managedGitignoreFile/* readManagedGitignoreFile */.w)({
buildContext
});
await (0,managedGitignoreFile/* writeManagedGitignoreFile */.Y)({
buildContext,
ownedFilesRelativePaths,
extensionModuleMetas
});
await Promise.all(extensionModuleMetas
.map(extensionModuleMeta => Promise.all(extensionModuleMeta.files.map(async ({ fileRelativePath, copyableFilePath, hash }) => {
if (ownedFilesRelativePaths.includes(fileRelativePath)) {
return;
}
const destFilePath = (0,external_path_.join)(buildContext.themeSrcDirPath, fileRelativePath);
const doesFileExist = await (0,fs_existsAsync/* existsAsync */.o)(destFilePath);
skip_condition: {
if (!doesFileExist) {
break skip_condition;
}
const destFileHash = (0,sync_extensions_extensionModuleMeta/* computeHash */.x)(await promises_.readFile(destFilePath));
if (destFileHash !== hash) {
break skip_condition;
}
return;
}
if (await getIsKnownByGit({ filePath: destFilePath })) {
await untrackFromGit({
filePath: destFilePath
});
}
{
const dirName = (0,external_path_.dirname)(destFilePath);
if (!(await (0,fs_existsAsync/* existsAsync */.o)(dirName))) {
await promises_.mkdir(dirName, { recursive: true });
}
}
await promises_.copyFile(copyableFilePath, destFilePath);
})))
.flat());
}
//# sourceMappingURL=sync-extension.js.map
/***/ }),
/***/ 12171:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "h": () => (/* binding */ SemVer)
/* harmony export */ });
var SemVer;
(function (SemVer) {
const bumpTypes = ["major", "minor", "patch", "rc", "no bump"];
function parse(versionStr) {
const match = versionStr.match(/^v?([0-9]+)\.([0-9]+)(?:\.([0-9]+))?(?:-rc.([0-9]+))?$/);
if (!match) {
throw new Error(`${versionStr} is not a valid semantic version`);
}
const semVer = Object.assign({ major: parseInt(match[1]), minor: parseInt(match[2]), patch: (() => {
const str = match[3];
return str === undefined ? 0 : parseInt(str);
})() }, (() => {
const str = match[4];
return str === undefined ? {} : { rc: parseInt(str) };
})());
const initialStr = stringify(semVer);
Object.defineProperty(semVer, "parsedFrom", {
enumerable: true,
get: function () {
const currentStr = stringify(this);
if (currentStr !== initialStr) {
throw new Error(`SemVer.parsedFrom can't be read anymore, the version have been modified from ${initialStr} to ${currentStr}`);
}
return versionStr;
}
});
return semVer;
}
SemVer.parse = parse;
function stringify(v) {
return `${v.major}.${v.minor}.${v.patch}${v.rc === undefined ? "" : `-rc.${v.rc}`}`;
}
SemVer.stringify = stringify;
/**
*
* v1 < v2 => -1
* v1 === v2 => 0
* v1 > v2 => 1
*
*/
function compare(v1, v2) {
const sign = (diff) => (diff === 0 ? 0 : diff < 0 ? -1 : 1);
const noUndefined = (n) => n !== null && n !== void 0 ? n : Infinity;
for (const level of ["major", "minor", "patch", "rc"]) {
if (noUndefined(v1[level]) !== noUndefined(v2[level])) {
return sign(noUndefined(v1[level]) - noUndefined(v2[level]));
}
}
return 0;
}
SemVer.compare = compare;
/*
console.log(compare(parse("3.0.0-rc.3"), parse("3.0.0")) === -1 )
console.log(compare(parse("3.0.0-rc.3"), parse("3.0.0-rc.4")) === -1 )
console.log(compare(parse("3.0.0-rc.3"), parse("4.0.0")) === -1 )
*/
function bumpType(params) {
const versionAhead = typeof params.versionAhead === "string"
? parse(params.versionAhead)
: params.versionAhead;
const versionBehind = typeof params.versionBehind === "string"
? parse(params.versionBehind)
: params.versionBehind;
if (compare(versionBehind, versionAhead) === 1) {
throw new Error(`Version regression ${stringify(versionBehind)} -> ${stringify(versionAhead)}`);
}
for (const level of ["major", "minor", "patch", "rc"]) {
if (versionBehind[level] !== versionAhead[level]) {
return level;
}
}
return "no bump";
}
SemVer.bumpType = bumpType;
})(SemVer || (SemVer = {}));
//# sourceMappingURL=SemVer.js.map
/***/ }),
/***/ 43765:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "o": () => (/* binding */ existsAsync)
/* harmony export */ });
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73292);
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_0__);
async function existsAsync(path) {
try {
await fs_promises__WEBPACK_IMPORTED_MODULE_0__.stat(path);
return true;
}
catch (error) {
if (error.code === "ENOENT")
return false;
throw error;
}
}
//# sourceMappingURL=fs.existsAsync.js.map
/***/ }),
/***/ 89693:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "a": () => (/* binding */ rmSync)
/* harmony export */ });
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(57147);
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71017);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _SemVer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(12171);
/**
* Polyfill of fs.rmSync(dirPath, { "recursive": true })
* For older version of Node
*/
function rmSync(dirPath, options) {
if (_SemVer__WEBPACK_IMPORTED_MODULE_2__/* .SemVer.compare */ .h.compare(_SemVer__WEBPACK_IMPORTED_MODULE_2__/* .SemVer.parse */ .h.parse(process.version), _SemVer__WEBPACK_IMPORTED_MODULE_2__/* .SemVer.parse */ .h.parse("14.14.0")) > 0) {
fs__WEBPACK_IMPORTED_MODULE_0__.rmSync(dirPath, options);
return;
}
const { force = true } = options;
if (force && !fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(dirPath)) {
return;
}
const removeDir_rec = (dirPath) => fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync(dirPath).forEach(basename => {
const fileOrDirPath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(dirPath, basename);
if (fs__WEBPACK_IMPORTED_MODULE_0__.lstatSync(fileOrDirPath).isDirectory()) {
removeDir_rec(fileOrDirPath);
return;
}
else {
fs__WEBPACK_IMPORTED_MODULE_0__.unlinkSync(fileOrDirPath);
}
});
removeDir_rec(dirPath);
}
//# sourceMappingURL=fs.rmSync.js.map
/***/ }),
/***/ 93721:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
"p": () => (/* binding */ getInstalledModuleDirPath)
});
// EXTERNAL MODULE: external "path"
var external_path_ = __webpack_require__(71017);
// EXTERNAL MODULE: ./dist/bin/tools/fs.existsAsync.js
var fs_existsAsync = __webpack_require__(43765);
// EXTERNAL MODULE: external "child_process"
var external_child_process_ = __webpack_require__(32081);
// EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
var assert = __webpack_require__(29041);
;// CONCATENATED MODULE: ./dist/bin/tools/isRootPath.js
function getIsRootPath(filePath) {
const path_normalized = (0,external_path_.normalize)(filePath);
// Unix-like root ("/")
if (path_normalized === "/") {
return true;
}
// Check for Windows drive root (e.g., "C:\\")
if (/^[a-zA-Z]:\\$/.test(path_normalized)) {
return true;
}
// Check for UNC root (e.g., "\\server\share")
if (/^\\\\[^\\]+\\[^\\]+\\?$/.test(path_normalized)) {
return true;
}
return false;
}
//# sourceMappingURL=isRootPath.js.map
;// CONCATENATED MODULE: ./dist/bin/tools/getInstalledModuleDirPath.js
async function getInstalledModuleDirPath(params) {
const { moduleName, packageJsonDirPath } = params;
{
let dirPath = packageJsonDirPath;
while (true) {
const dirPath_candidate = (0,external_path_.join)(dirPath, "node_modules", ...moduleName.split("/"));
let doesExist;
try {
doesExist = await (0,fs_existsAsync/* existsAsync */.o)(dirPath_candidate);
}
catch (_a) {
doesExist = false;
}
if (doesExist) {
return dirPath_candidate;
}
if (getIsRootPath(dirPath)) {
break;
}
dirPath = (0,external_path_.join)(dirPath, "..");
}
}
const dirPath = external_child_process_.execSync(`npm list ${moduleName}`, {
cwd: packageJsonDirPath
})
.toString("utf8")
.trim();
(0,assert/* assert */.h)(dirPath !== "");
return dirPath;
}
//# sourceMappingURL=getInstalledModuleDirPath.js.map
/***/ }),
/***/ 75564:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "P": () => (/* binding */ listInstalledModules)
/* harmony export */ });
/* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(29041);
/* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(38469);
/* harmony import */ var zod__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(52300);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71017);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(73292);
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _tools_getInstalledModuleDirPath__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(93721);
/* harmony import */ var tsafe_exclude__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(83101);
async function listInstalledModules(params) {
const { packageJsonFilePath, filter } = params;
const parsedPackageJson = await readPackageJsonDependencies({
packageJsonFilePath
});
const extensionModuleNames = [parsedPackageJson.dependencies, parsedPackageJson.devDependencies]
.filter((0,tsafe_exclude__WEBPACK_IMPORTED_MODULE_4__/* .exclude */ .D)(undefined))
.map(obj => Object.keys(obj))
.flat()
.filter(moduleName => filter({ moduleName }));
const result = await Promise.all(extensionModuleNames.map(async (moduleName) => {
const dirPath = await (0,_tools_getInstalledModuleDirPath__WEBPACK_IMPORTED_MODULE_3__/* .getInstalledModuleDirPath */ .p)({
moduleName,
packageJsonDirPath: (0,path__WEBPACK_IMPORTED_MODULE_1__.dirname)(packageJsonFilePath)
});
const { version, peerDependencies } = await readPackageJsonVersionAndPeerDependencies({
packageJsonFilePath: (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(dirPath, "package.json")
});
return { moduleName, version, peerDependencies, dirPath };
}));
return result;
}
const { readPackageJsonDependencies } = (() => {
const zParsedPackageJson = (() => {
const zTargetType = zod__WEBPACK_IMPORTED_MODULE_5__.z.object({
dependencies: zod__WEBPACK_IMPORTED_MODULE_5__.z.record(zod__WEBPACK_IMPORTED_MODULE_5__.z.string()).optional(),
devDependencies: zod__WEBPACK_IMPORTED_MODULE_5__.z.record(zod__WEBPACK_IMPORTED_MODULE_5__.z.string()).optional()
});
(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_0__/* .assert */ .h)();
return (0,tsafe_id__WEBPACK_IMPORTED_MODULE_6__.id)(zTargetType);
})();
async function readPackageJsonDependencies(params) {
const { packageJsonFilePath } = params;
const parsedPackageJson = JSON.parse((await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(packageJsonFilePath)).toString("utf8"));
zParsedPackageJson.parse(parsedPackageJson);
(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_0__/* .assert */ .h)((0,tsafe_assert__WEBPACK_IMPORTED_MODULE_0__.is)(parsedPackageJson));
return parsedPackageJson;
}
return { readPackageJsonDependencies };
})();
const { readPackageJsonVersionAndPeerDependencies } = (() => {
const zParsedPackageJson = (() => {
const zTargetType = zod__WEBPACK_IMPORTED_MODULE_5__.z.object({
version: zod__WEBPACK_IMPORTED_MODULE_5__.z.string(),
peerDependencies: zod__WEBPACK_IMPORTED_MODULE_5__.z.record(zod__WEBPACK_IMPORTED_MODULE_5__.z.string()).optional()
});
(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_0__/* .assert */ .h)();
return (0,tsafe_id__WEBPACK_IMPORTED_MODULE_6__.id)(zTargetType);
})();
async function readPackageJsonVersionAndPeerDependencies(params) {
var _a;
const { packageJsonFilePath } = params;
const parsedPackageJson = JSON.parse((await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(packageJsonFilePath)).toString("utf8"));
zParsedPackageJson.parse(parsedPackageJson);
(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_0__/* .assert */ .h)((0,tsafe_assert__WEBPACK_IMPORTED_MODULE_0__.is)(parsedPackageJson));
return {
version: parsedPackageJson.version,
peerDependencies: (_a = parsedPackageJson.peerDependencies) !== null && _a !== void 0 ? _a : {}
};
}
return { readPackageJsonVersionAndPeerDependencies };
})();
//# sourceMappingURL=listInstalledModules.js.map
/***/ }),
/***/ 73776:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "K": () => (/* binding */ getNodeModulesBinDirPath)
/* harmony export */ });
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(71017);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(58822);
/* harmony import */ var _getInstalledModuleDirPath__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(93721);
/* harmony import */ var _fs_existsAsync__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(43765);
/* harmony import */ var zod__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(52300);
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(73292);
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(29041);
/* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(38469);
let cache_bestEffort = undefined;
/** NOTE: Careful, this function can fail when the binary
* Used is not in the node_modules directory of the project
* (for example when running tests with vscode extension we'll get
* '/Users/dylan/.vscode/extensions/vitest.explorer-1.16.0/dist/worker.js'
*
* instead of
* '/Users/joseph/.nvm/versions/node/v22.12.0/bin/node'
* or
* '/Users/joseph/github/keycloakify-starter/node_modules/.bin/vite'
*
* as the value of process.argv[1]
*/
function getNodeModulesBinDirPath_bestEffort() {
if (cache_bestEffort !== undefined) {
return cache_bestEffort;
}
const binPath = process.argv[1];
const segments = [".bin"];
let foundNodeModules = false;
for (const segment of binPath.split(path__WEBPACK_IMPORTED_MODULE_0__.sep).reverse()) {
skip_segment: {
if (foundNodeModules) {
break skip_segment;
}
if (segment === "node_modules") {
foundNodeModules = true;
break skip_segment;
}
continue;
}
segments.unshift(segment);
}
if (!foundNodeModules) {
throw new Error(`Could not find node_modules in path ${binPath}`);
}
const nodeModulesBinDirPath = segments.join(path__WEBPACK_IMPORTED_MODULE_0__.sep);
cache_bestEffort = nodeModulesBinDirPath;
return nodeModulesBinDirPath;
}
let cache_withPackageJsonFileDirPath = undefined;
async function getNodeModulesBinDirPath_withPackageJsonFileDirPath(params) {
const { packageJsonFilePath } = params;
use_cache: {
if (cache_withPackageJsonFileDirPath === undefined) {
break use_cache;
}
if (cache_withPackageJsonFileDirPath.packageJsonFilePath !== packageJsonFilePath) {
cache_withPackageJsonFileDirPath = undefined;
break use_cache;
}
return cache_withPackageJsonFileDirPath.nodeModulesBinDirPath;
}
// [...]node_modules/keycloakify
const installedModuleDirPath = await (0,_getInstalledModuleDirPath__WEBPACK_IMPORTED_MODULE_2__/* .getInstalledModuleDirPath */ .p)({
// Here it will always be "keycloakify" but since we are in tools/ we make something generic
moduleName: await (async () => {
const zParsedPackageJson = (() => {
const zTargetType = zod__WEBPACK_IMPORTED_MODULE_6__.z.object({
name: zod__WEBPACK_IMPORTED_MODULE_6__.z.string()
});
tsafe_assert__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .h;
return (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(zTargetType);
})();
const parsedPackageJson = JSON.parse((await fs_promises__WEBPACK_IMPORTED_MODULE_4__.readFile((0,path__WEBPACK_IMPORTED_MODULE_0__.join)((0,_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_1__/* .getThisCodebaseRootDirPath */ .e)(), "package.json"))).toString("utf8"));
zParsedPackageJson.parse(parsedPackageJson);
(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .h)((0,tsafe_assert__WEBPACK_IMPORTED_MODULE_5__.is)(parsedPackageJson));
return parsedPackageJson.name;
})(),
packageJsonDirPath: (0,path__WEBPACK_IMPORTED_MODULE_0__.dirname)(packageJsonFilePath)
});
const segments = installedModuleDirPath.split(path__WEBPACK_IMPORTED_MODULE_0__.sep);
while (true) {
const segment = segments.pop();
if (segment === undefined) {
throw new Error(`Could not find .bin directory relative to ${packageJsonFilePath}`);
}
if (segment !== "node_modules") {
continue;
}
const candidate = (0,path__WEBPACK_IMPORTED_MODULE_0__.join)(segments.join(path__WEBPACK_IMPORTED_MODULE_0__.sep), segment, ".bin");
if (!(await (0,_fs_existsAsync__WEBPACK_IMPORTED_MODULE_3__/* .existsAsync */ .o)(candidate))) {
continue;
}
cache_withPackageJsonFileDirPath = {
packageJsonFilePath,
nodeModulesBinDirPath: candidate
};
break;
}
return cache_withPackageJsonFileDirPath.nodeModulesBinDirPath;
}
function getNodeModulesBinDirPath(params) {
const { packageJsonFilePath } = params !== null && params !== void 0 ? par