Olivier Massot il y a 2 mois
Parent
commit
a26e7bff7f

+ 1 - 1
components/Layout/Header/Menu.vue

@@ -93,7 +93,7 @@ header principal (configuration, paramètres du compte...)
 <script setup lang="ts">
 import { computed, ref } from 'vue'
 import { useMenu } from '~/composables/layout/useMenu'
-import {IMAGE_SIZE} from "~/types/enum/enums";
+import { IMAGE_SIZE } from '~/types/enum/enums'
 
 const props = defineProps({
   name: {

+ 1 - 1
components/Ui/EventList.vue

@@ -93,7 +93,7 @@ import type { Collection } from 'pinia-orm'
 import type Event from '~/models/Freemium/Event'
 import type { Pagination } from '~/types/data'
 import { useDate } from 'vuetify'
-import {IMAGE_SIZE} from "~/types/enum/enums";
+import { IMAGE_SIZE } from '~/types/enum/enums'
 
 const props = defineProps<{
   events: Collection<Event>

+ 41 - 35
prepare/compileAbilitiesConfig.js

@@ -1,35 +1,39 @@
 /**
  * Precompile the abilities config from Yaml to TS
  */
-import * as fs from 'fs';
-import * as path from 'path';
-import * as yaml from 'js-yaml';
+import * as fs from 'fs'
+import * as path from 'path'
+import * as yaml from 'js-yaml'
 function loadYamlFile(filePath) {
-    try {
-        const fileContents = fs.readFileSync(filePath, 'utf8');
-        return yaml.load(fileContents);
-    }
-    catch (error) {
-        console.error(`Error loading YAML file ${filePath}:`, error);
-        return {};
-    }
+  try {
+    const fileContents = fs.readFileSync(filePath, 'utf8')
+    return yaml.load(fileContents)
+  } catch (error) {
+    console.error(`Error loading YAML file ${filePath}:`, error)
+    return {}
+  }
 }
 function compileAbilitiesConfig() {
-    const configDir = path.join(process.cwd(), 'config/abilities/pages');
-    const outputPath = path.join(process.cwd(), 'config/abilities-config-precompiled.ts');
-    console.log('Starting abilities config compilation...');
-    // Read all YAML files from the pages directory
-    const yamlFiles = fs.readdirSync(configDir).filter(file => file.endsWith('.yaml'));
-    const compiledAbilities = {};
-    yamlFiles.forEach(file => {
-        const filePath = path.join(configDir, file);
-        console.log(`Processing ${file}...`);
-        const config = loadYamlFile(filePath);
-        // Merge all abilities from this file into the compiled config
-        Object.assign(compiledAbilities, config);
-    });
-    // Generate TypeScript content
-    const header = `/**
+  const configDir = path.join(process.cwd(), 'config/abilities/pages')
+  const outputPath = path.join(
+    process.cwd(),
+    'config/abilities-config-precompiled.ts',
+  )
+  console.log('Starting abilities config compilation...')
+  // Read all YAML files from the pages directory
+  const yamlFiles = fs
+    .readdirSync(configDir)
+    .filter((file) => file.endsWith('.yaml'))
+  const compiledAbilities = {}
+  yamlFiles.forEach((file) => {
+    const filePath = path.join(configDir, file)
+    console.log(`Processing ${file}...`)
+    const config = loadYamlFile(filePath)
+    // Merge all abilities from this file into the compiled config
+    Object.assign(compiledAbilities, config)
+  })
+  // Generate TypeScript content
+  const header = `/**
  * AUTO-GENERATED FILE - DO NOT MODIFY MANUALLY
  *
  * This file is automatically generated from YAML configuration files
@@ -41,14 +45,16 @@ function compileAbilitiesConfig() {
  * Generated on: ${new Date().toISOString()}
  */
 
-`;
-    const tsContent = `${header}export default ${JSON.stringify(compiledAbilities, null, 2)} as const
-`;
-    // Write the compiled TypeScript file
-    fs.writeFileSync(outputPath, tsContent, 'utf8');
-    console.log(`✓ Abilities config compiled successfully to ${outputPath}`);
-    console.log(`✓ Processed ${yamlFiles.length} YAML files`);
-    console.log(`✓ Generated ${Object.keys(compiledAbilities).length} ability definitions`);
+`
+  const tsContent = `${header}export default ${JSON.stringify(compiledAbilities, null, 2)} as const
+`
+  // Write the compiled TypeScript file
+  fs.writeFileSync(outputPath, tsContent, 'utf8')
+  console.log(`✓ Abilities config compiled successfully to ${outputPath}`)
+  console.log(`✓ Processed ${yamlFiles.length} YAML files`)
+  console.log(
+    `✓ Generated ${Object.keys(compiledAbilities).length} ability definitions`,
+  )
 }
 // Run the compilation
-compileAbilitiesConfig();
+compileAbilitiesConfig()

+ 13 - 7
prepare/compileAbilitiesConfig.ts

@@ -8,7 +8,7 @@ import * as yaml from 'js-yaml'
 
 interface AbilityCondition {
   function: string
-  parameters?: any[]
+  parameters?: unknown[]
   expectedResult?: boolean
 }
 
@@ -21,7 +21,7 @@ interface CompiledAbilities {
   [key: string]: AbilityConfig
 }
 
-function loadYamlFile(filePath: string): any {
+function loadYamlFile(filePath: string): unknown {
   try {
     const fileContents = fs.readFileSync(filePath, 'utf8')
     return yaml.load(fileContents)
@@ -33,15 +33,20 @@ function loadYamlFile(filePath: string): any {
 
 function compileAbilitiesConfig(): void {
   const configDir = path.join(process.cwd(), 'config/abilities/pages')
-  const outputPath = path.join(process.cwd(), 'config/abilities/config-precompiled.ts')
+  const outputPath = path.join(
+    process.cwd(),
+    'config/abilities/config-precompiled.ts',
+  )
 
   console.log('Starting abilities config compilation...')
 
   // Read all YAML files from the pages directory
-  const yamlFiles = fs.readdirSync(configDir).filter(file => file.endsWith('.yaml'))
+  const yamlFiles = fs
+    .readdirSync(configDir)
+    .filter((file) => file.endsWith('.yaml'))
   const compiledAbilities: CompiledAbilities = {}
 
-  yamlFiles.forEach(file => {
+  yamlFiles.forEach((file) => {
     const filePath = path.join(configDir, file)
     console.log(`Processing ${file}...`)
 
@@ -74,9 +79,10 @@ function compileAbilitiesConfig(): void {
 
   console.log(`✓ Abilities config compiled successfully to ${outputPath}`)
   console.log(`✓ Processed ${yamlFiles.length} YAML files`)
-  console.log(`✓ Generated ${Object.keys(compiledAbilities).length} ability definitions`)
+  console.log(
+    `✓ Generated ${Object.keys(compiledAbilities).length} ability definitions`,
+  )
 }
 
 // Run the compilation
 compileAbilitiesConfig()
-

+ 0 - 1
services/rights/abilityBuilder.ts

@@ -1,4 +1,3 @@
-import * as yaml from 'yaml-import'
 import * as _ from 'lodash-es'
 import type { MongoAbility } from '@casl/ability/dist/types/Ability'
 import RoleUtils from '~/services/rights/roleUtils'