@extrahorizon/exh-cli 1.8.2-feat-80-7fb183f → 1.8.2-feat-81-a86c1ff

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -74,34 +74,34 @@ async function syncFunctionUser(sdk, data) {
74
74
  }
75
75
  exports.syncFunctionUser = syncFunctionUser;
76
76
  async function syncRoleWithPermissions(sdk, taskName, roleName, targetPermissions) {
77
- console.log(chalk.white('⚙️ Checking if the role exists'));
77
+ console.group(chalk.white(`🔄 Syncing role: ${roleName}`));
78
+ if (targetPermissions.length === 0) {
79
+ console.log(chalk.yellow('⚠️ No permissions have been defined for the role'));
80
+ }
78
81
  let role = await userRepository.findGlobalRoleByName(sdk, roleName);
79
82
  if (!role) {
80
- console.log(chalk.white('⚙️ Role does not exist, creating a new role'));
83
+ console.log(chalk.white('⚙️ Creating the new role...'));
81
84
  const roleDescription = `A role created by the CLI for the execution of the task ${taskName}`;
82
85
  role = await userRepository.createGlobalRole(sdk, roleName, roleDescription);
83
- console.log(chalk.white('⚙️ Assigning permissions to the role'));
84
- if (targetPermissions.length === 0) {
85
- console.log(chalk.yellow('⚠️ No permissions defined for the role'));
86
- return role;
87
- }
86
+ console.log(chalk.white(' Successfully created the role'));
88
87
  await userRepository.addPermissionsToGlobalRole(sdk, roleName, targetPermissions);
89
- console.log(chalk.green('✅ Successfully assigned permissions to the role'));
88
+ console.log(chalk.white(`🔐 Permissions added: [${targetPermissions.join(',')}]`));
89
+ console.groupEnd();
90
90
  return role;
91
91
  }
92
92
  const currentPermissions = role.permissions?.flatMap(permission => permission.name) || [];
93
93
  const permissionsToAdd = targetPermissions.filter(targetPermission => !currentPermissions.includes(targetPermission));
94
94
  const permissionsToRemove = currentPermissions.filter(currentPermission => !targetPermissions.includes(currentPermission));
95
95
  if (permissionsToAdd.length > 0) {
96
- console.log(chalk.white('⚙️ Adding missing permissions to the role'));
97
96
  await userRepository.addPermissionsToGlobalRole(sdk, roleName, permissionsToAdd);
98
- console.log(chalk.green('✅ Successfully added missing permissions to the role'));
97
+ console.log(chalk.green(`+ Added permissions to the role: [${permissionsToAdd.join(',')}]`));
99
98
  }
100
99
  if (permissionsToRemove.length > 0) {
101
- console.log(chalk.white('⚙️ Removing excess permissions from the role'));
102
100
  await userRepository.removePermissionsFromGlobalRole(sdk, roleName, permissionsToRemove);
103
- console.log(chalk.green('✅ Successfully removed excess permissions from the role'));
101
+ console.log(chalk.white(`🔐 Permissions removed: [${permissionsToRemove.join(',')}]`));
104
102
  }
103
+ console.groupEnd();
104
+ console.log(chalk.green('✅ Successfully synced role'));
105
105
  return role;
106
106
  }
107
107
  async function assignRoleToUser(sdk, userId, roleId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@extrahorizon/exh-cli",
3
- "version": "1.8.2-feat-80-7fb183f",
3
+ "version": "1.8.2-feat-81-a86c1ff",
4
4
  "main": "build/index.js",
5
5
  "exports": "./build/index.js",
6
6
  "license": "MIT",