Skip to content

console messaging for config-manager#100

Open
devintrivir wants to merge 1 commit into
mainfrom
feature/config-manager-pull-console-messages
Open

console messaging for config-manager#100
devintrivir wants to merge 1 commit into
mainfrom
feature/config-manager-pull-console-messages

Conversation

@devintrivir

Copy link
Copy Markdown

No description provided.

@devintrivir
devintrivir marked this pull request as draft April 24, 2026 17:21
@devintrivir
devintrivir marked this pull request as ready for review April 24, 2026 17:25
@devintrivir
devintrivir marked this pull request as draft April 24, 2026 17:33
@devintrivir
devintrivir force-pushed the feature/config-manager-pull-console-messages branch 2 times, most recently from 15ca7cf to 436a8eb Compare April 24, 2026 18:06
@devintrivir
devintrivir force-pushed the feature/config-manager-pull-console-messages branch from 436a8eb to 85f4b54 Compare April 24, 2026 18:55
@devintrivir
devintrivir marked this pull request as ready for review April 27, 2026 16:23

@phalestrivir phalestrivir left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing some indicators, and a few wording things that I mentioned, but mostly looks good. Keep in mind that since this PR was created there might've been some new commands added, so you will want to make sure to rebase and get indicators added to those as well. For future PRs though I'll make sure we include indicators for each command that we add.

Comment on lines 50 to 59
export async function configManagerImportCookieDomains(): Promise<boolean> {
try {
const getFile = getFilePath('cookie-domains/cookie-domains.json');
const readFile = fs.readFileSync(getFile, 'utf-8');
const importData = JSON.parse(readFile);
await updateCookieDomains(importData);
return true;
} catch (error) {
printError(error, `Error importing custom domains`);
printError(error, `Error importing cookie domains`);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add indicator here as well

Comment on lines 50 to 65
export async function configManagerImportEmailProvider(): Promise<boolean> {
try {
const filePath = getFilePath('email-provider');
const fileData = fs.readFileSync(
`${filePath}/external.email.json`,
'utf-8'
);
let importData = JSON.parse(fileData);
importData = { idm: { [importData._id]: importData } };
await config.importConfigEntities(importData);
return true;
} catch (error) {
printError(error);
}
return false;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add indicator here as well

Comment on lines 90 to 141
export async function configManagerImportEmailTemplates(
templateName?: string
): Promise<boolean> {
try {
const templateDir = getFilePath('email-templates');
const templateFiles = fs.readdirSync(templateDir);
const importTemplateData = { emailTemplate: {} };

for (const templateFile of templateFiles) {
const templateJsonPath = getFilePath(
`email-templates/${templateFile}/${templateFile}.json`
);
const readTemplate = fs.readFileSync(templateJsonPath, 'utf8');
const importData = JSON.parse(readTemplate);
const id = importData._id;

if (templateName && id !== `emailTemplate/${templateName}`) {
continue;
}

if (importData.html && typeof importData.html === 'object') {
for (const locale in importData.html) {
const htmlFilePath = getFilePath(
`email-templates/${templateFile}/${importData.html[locale].file}`
);
importData.html[locale] = fs.readFileSync(htmlFilePath, 'utf8');
}
}
if (importData.message && typeof importData.message === 'object') {
for (const locale in importData.message) {
const messageFilePath = getFilePath(
`email-templates/${templateFile}/${importData.message[locale].file}`
);
importData.message[locale] = fs.readFileSync(messageFilePath, 'utf8');
}
}
if (importData.styles && typeof importData.styles === 'object') {
const stylesFilePath = getFilePath(
`email-templates/${templateFile}/${importData.styles.file}`
);
importData.styles = fs.readFileSync(stylesFilePath, 'utf8');
}
importTemplateData.emailTemplate[id.replace('emailTemplate/', '')] =
importData;
}
await importEmailTemplates(importTemplateData);
return true;
} catch (error) {
printError(error, `Error importing email templates to files`);
}
return false;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have progress indicator here as well

Comment on lines 76 to 110
export async function configManagerImportEndpoints(
endpointName?: string
): Promise<boolean> {
try {
const endpointsDir = getFilePath(`endpoints`);
const endpointsFiles = fs.readdirSync(endpointsDir);
const importEndpointData = { idm: {} };
for (const endpointsFile of endpointsFiles) {
const jsonFilePath = getFilePath(
`endpoints/${endpointsFile}/${endpointsFile}.json`
);
const readJsonEndpoint = fs.readFileSync(jsonFilePath, 'utf8') as any;
const importData = JSON.parse(readJsonEndpoint) as any;
const id = importData._id;

if (endpointName && id !== `endpoint/${endpointName}`) {
continue;
}
if (importData.file) {
const scriptPath = getFilePath(
`endpoints/${endpointsFile}/${importData.file}`
);
importData.source = fs.readFileSync(scriptPath, 'utf8');
delete importData.file;
}

importEndpointData.idm[id] = importData;
}
await importConfigEntities(importEndpointData);
return true;
} catch (error) {
printError(error, `Error importing config entity endpoints`);
printError(error, `Error importing endpoints`);
}
return false;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add indicator here as well

Comment on lines 51 to 73
export async function configManagerImportInternalRoles(
internalRoleName?: string
): Promise<boolean> {
try {
const internalRolesDir = getFilePath('internal-roles');
const internalRolesFiles = fs.readdirSync(internalRolesDir);
const importData = { internalRole: {} };
for (const internalRolesFile of internalRolesFiles) {
const filePath = getFilePath(`internal-roles/${internalRolesFile}`);
const readFile = fs.readFileSync(filePath, 'utf-8');
const roleData = JSON.parse(readFile);
if (internalRoleName && roleData.name !== internalRoleName) {
continue;
}
importData.internalRole[roleData._id] = roleData;
}
await importInternalRoles(importData);
return true;
} catch (error) {
printError(error, `Error importing internal roles to files`);
printError(error, `Error importing internal roles`);
}
return false;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have an indicator here as well

Comment on lines 153 to 178
export async function configManagerImportServiceObjects(): Promise<boolean> {
try {
const objectsDir = getFilePath('service-objects/');
const objectTypes = fs.readdirSync(objectsDir);

for (const objectType of objectTypes) {
const objectPath = `${objectsDir}/${objectType}`;
const objectFiles = fs.readdirSync(objectPath);

for (const objectFile of objectFiles) {
const fullPath = `${objectPath}/${objectFile}`;
const readFiles = fs.readFileSync(fullPath, 'utf8');
const importData = JSON.parse(readFiles);
delete importData._rev;
delete importData._refProperties;

await updateManagedObject(objectType, importData._id, importData);
}
}

return true;
} catch (err) {
printError(err, `Error importing service-objects`);
}
return false;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have an indicator here as well

Comment on lines 64 to 85
export async function configManagerImportTermsAndConditions(): Promise<boolean> {
try {
const mainFile = getFilePath('terms-conditions/terms-conditions.json');
const readMain = fs.readFileSync(mainFile, 'utf8') as any;
let importData = JSON.parse(readMain) as any;
const id = importData._id;
importData = { idm: { [id]: importData } };
for (const version of importData.idm[id].versions) {
for (const [language] of Object.entries(version.termsTranslations)) {
const languageFileName = `${version.version}/${language}.html`;
const directoryName = `terms-conditions`;
const fileDir = getFilePath(`${directoryName}/${languageFileName}`);
version.termsTranslations[language] = fs.readFileSync(fileDir, 'utf8');
}
}
await importConfigEntities(importData);
return true;
} catch (error) {
printError(error);
return false;
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have an indicator here as well

Comment on lines 106 to 148
export async function configManagerImportThemes(): Promise<boolean> {
try {
const realms = await readRealms();
for (const realm of realms) {
// fr-config-manager doesn't support root themes
if (realm.name === '/') continue;
state.setRealm(realm.name);
const importDir = getFilePath(
`realms${realm.parentPath + realm.name}/themes`
);
const themesDir = fs
.readdirSync(importDir, { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name);
const themeMap: Record<string, ThemeSkeleton> = {};
for (const themeName of themesDir) {
const themeDir = `${importDir}/${themeName}`;
const themeJsonPath = `${themeDir}/${themeName}.json`;
const theme: ThemeSkeleton = JSON.parse(
fs.readFileSync(themeJsonPath, 'utf8')
);
for (const field of THEME_HTML_FIELDS) {
if (
!theme[field.name] ||
typeof theme[field.name] !== 'object' ||
typeof (theme[field.name] as any).file !== 'string'
)
continue;
const fileName = (theme[field.name] as any).file;
const filePath = `${themeDir}/${fileName}`;
const fileContent = fs.readFileSync(filePath, 'utf8');
theme[field.name] = fileContent;
}
themeMap[theme._id] = theme;
}
await importThemes({ theme: themeMap });
}
return true;
} catch (error) {
printError(error);
return false;
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have an indicator here as well

Comment on lines 61 to 73
export async function configManagerImportUiConfig(): Promise<boolean> {
try {
const fileData = getFilePath(`ui/ui-configuration.json`);
const readFile = fs.readFileSync(fileData, 'utf8');
let importData = JSON.parse(readFile);
importData = { idm: { [importData._id]: importData } };
await importConfigEntities(importData);
return true;
} catch (error) {
printError(error);
}
return false;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have an indicator here as well

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fun fact, this file is completely useless, the function is not being used anywhere, so no need for changes here, although you can keep them in if you want. We'll have a separate PR that removes it, but just thought I'd let you know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants