@fto-consult/expo-ui 6.5.5 → 6.6.0

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.
@@ -0,0 +1,8 @@
1
+ //les paramètres d'environnement utilse :
2
+
3
+ GENETE_GET_TABLE_JS_FILE = 1|0|true|false //si le fichier getTable.js sera généré dans le dossier des tables de données de l'application
4
+ pour que ce soit possible, la variable TABLES_DATA_PATH doit exister et doit pointer sur le repertoire des tables de données de l'application
5
+
6
+ TABLES_DATAS_PATH = //path, chemin vers le dossier des tables de données de l'application
7
+
8
+
package/babel.config.js CHANGED
@@ -1,6 +1,9 @@
1
1
  module.exports = function(api,opts) {
2
2
  opts = typeof opts =='object' && opts ? opts : {};
3
3
  api = api && typeof api =='object'? api : {};
4
+
5
+
6
+
4
7
  ///les chemin vers la variable d'environnement, le chemin du fichier .env,@see : https://github.com/brysgo/babel-plugin-inline-dotenv
5
8
  //console.log(environmentPath," is envvv ",opts);
6
9
  const path = require("path");
@@ -15,36 +18,86 @@ module.exports = function(api,opts) {
15
18
  }
16
19
  /*** par défaut, les variables d'environnements sont stockés dans le fichier .env situé à la racine du projet, référencée par la prop base */
17
20
  const alias = require("./babel.config.alias")(options);
21
+ const $eelectron = alias.$eelectron || null;
18
22
  const $ecomponents = alias.$ecomponents|| null;
19
- const eAppex = $ecomponents && path.resolve($ecomponents,"Chart","appexChart");
20
- if(eAppex && fs.existsSync(eAppex)){
21
- const appexPathHtml = path.resolve(eAppex,"index.html");
22
- const $eelectron = alias.$eelectron || null;
23
- const expoRoot = alias["$expo-ui-root-path"] || null;
24
- const expoRootModulesP = expoRoot && fs.existsSync(path.resolve(expoRoot,"node_modules")) && path.resolve(expoRoot,"node_modules") || null;
25
- const aDistPath = path.join("apexcharts","dist","apexcharts.min.js");
26
- const nodeModulesPath = expoRootModulesP && fs.existsSync(path.resolve(expoRootModulesP,aDistPath)) ? expoRootModulesP : alias.$enodeModulesPath;
27
- if(nodeModulesPath && fs.existsSync(nodeModulesPath) && $eelectron && fs.existsSync($eelectron)){
28
- const writeFilePath = path.resolve($eelectron,"utils","writeFile.js");
29
- const appexDistPath = path.resolve(nodeModulesPath,"apexcharts","dist","apexcharts.min.js");
30
- if(fs.existsSync(writeFilePath) && fs.existsSync(appexDistPath)){
31
- const jsContent = fs.readFileSync(appexDistPath, 'utf8')
32
- const writeFile = require(`${writeFilePath}`);
33
- //overite appex chart html file
34
- writeFile(appexPathHtml,`
35
- <html>
36
- <head>
37
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
38
- <script>${jsContent}</script>
39
- </head>
40
- <body>
41
- </body>
42
- </html>
43
- `);
23
+ const expoRoot = alias["$expo-ui-root-path"] || null;
24
+ const aDistPath = path.join("apexcharts","dist","apexcharts.min.js");
25
+ const expoRootModulesP = expoRoot && fs.existsSync(path.resolve(expoRoot,"node_modules")) && path.resolve(expoRoot,"node_modules") || null;
26
+ const nodeModulesPath = expoRootModulesP && fs.existsSync(path.resolve(expoRootModulesP,aDistPath)) ? expoRootModulesP : alias.$enodeModulesPath;
27
+ const envObj = require("./parse-env")();
28
+
29
+ if(nodeModulesPath && fs.existsSync(nodeModulesPath) && $eelectron && fs.existsSync($eelectron)){
30
+ const writeFilePath = path.resolve($eelectron,"utils","writeFile.js");
31
+ if(fs.existsSync(writeFilePath)){
32
+ //generate getTable.js file
33
+ const generateGetTable = String(envObj.GENETE_GET_TABLE_JS_FILE).trim().toLowerCase();
34
+ const willGenerateGetTableJs = generateGetTable === "false" || generateGetTable ==="0" ? false : generateGetTable ==="1" || generateGetTable ==='true';
35
+ if(willGenerateGetTableJs){
36
+ const tableDataPath = envObj.TABLES_DATAS_PATH;
37
+ if(tableDataPath && fs.existsSync(tableDataPath) && fs.lstatSync(tableDataPath).isDirectory()){
38
+ const path = path.resolve(tableDataPath);
39
+ const getTableJsPath = path.resolve(tableDataPath,"getTable.js");
40
+ let getTableJSContent = '';
41
+ const tables = fs.readdirSync(tableDataPath);
42
+ if(Array.isArray(tables)){
43
+ tables.map((table,i)=>{
44
+ table = table.trim();
45
+ const tableName = table.toUpperCase();
46
+ const tablePath = path.join(tableDataPath, table);
47
+ const indexTablePath = path.join(tablePath,"index.js");
48
+ const stat = fs.lstatSync(tablePath);
49
+ if(!stat.isDirectory() || !fs.existsSync(indexTablePath)) return;
50
+ const indexContent = fs.readFileSync(indexTablePath,'utf8') ;
51
+ if(!indexContent || (!indexContent.includes("table") && !indexContent.includes("tableName"))){
52
+ return;
53
+ }
54
+ getTableJSContent+=`
55
+ if(tableName === "${tableName}"){
56
+ return require("./${table}").default;
57
+ }
58
+ `;
59
+ });
60
+ //on génère le fichier getTable des tables data de l'application
61
+ if(getTableJSContent){
62
+ writeFile(getTableJsPath,`
63
+ module.exports = function(tableName){
64
+ if(!tableName || tyepof tableName !=="string") return null;
65
+ tableName = tableName.toUpperCase().trim();
66
+ ${getTableJSContent}
67
+ return null;
68
+ }
69
+ `);
70
+ }
71
+ }
72
+ }
73
+ }
74
+
75
+ //generating appex js file
76
+ const eAppex = $ecomponents && path.resolve($ecomponents,"Chart","appexChart");
77
+ if(eAppex && fs.existsSync(eAppex)){
78
+ const appexPathHtml = path.resolve(eAppex,"index.html");
79
+ const appexDistPath = path.resolve(nodeModulesPath,"apexcharts","dist","apexcharts.min.js");
80
+ if(fs.existsSync(appexDistPath)){
81
+ const jsContent = fs.readFileSync(appexDistPath, 'utf8')
82
+ const writeFile = require(`${writeFilePath}`);
83
+ //overite appex chart html file
84
+ writeFile(appexPathHtml,`
85
+ <html>
86
+ <head>
87
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
88
+ <script>${jsContent}</script>
89
+ </head>
90
+ <body>
91
+ </body>
92
+ </html>
93
+ `);
94
+ }
44
95
  }
45
- }
96
+ }
97
+
46
98
  }
47
99
 
100
+
48
101
  return {
49
102
  presets: [
50
103
  ['babel-preset-expo']
package/env.js ADDED
@@ -0,0 +1,11 @@
1
+
2
+ //permet de retourner le contenu de la variable d'environnement .env de l'application//
3
+ module.exports = function(){
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ try {
7
+ const envPath = path.resolve(process.cwd(),".env");
8
+ return fs.existsSync(envPath)? require("./parse-env")(fs.readFileSync(envPath,'utf8')) : {};
9
+ } catch{}
10
+ return {};
11
+ }
package/expo-ui-path.js CHANGED
@@ -18,8 +18,7 @@ module.exports = function (){
18
18
  const rootPath = process.cwd();
19
19
  const src = path.resolve(rootPath,"src");
20
20
  try {
21
- const envPath = path.resolve(rootPath,".env");
22
- const envObj = fs.existsSync(envPath)? require("./parse-env")(fs.readFileSync(envPath,'utf8')) : {};
21
+ const envObj = require("./parse-env")();
23
22
  const euPathm = typeof envObj.EXPO_UI_ROOT_PATH =="string" && envObj.EXPO_UI_ROOT_PATH && path.resolve(envObj.EXPO_UI_ROOT_PATH)||'';
24
23
  const eu = euPathm && fs.existsSync(euPathm)? euPathm : null;
25
24
  if(eu && fs.existsSync(path.resolve(eu,"src")) && fs.existsSync(path.resolve(eu,"webpack.config.js"))){
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "6.5.5",
3
+ "version": "6.6.0",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/parse-env.js CHANGED
@@ -1,10 +1,17 @@
1
1
  const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg
2
-
2
+ const fs = require("fs");
3
+ const path = require("path");
3
4
  // Parser src into an Object
4
5
  module.exports = function parse (src) {
6
+ if(typeof src !=='string' || !src.trim()){
7
+ try {
8
+ const envPath = path.resolve(process.cwd(),".env");
9
+ src = fs.existsSync(envPath)? fs.readFileSync(envPath,'utf8') :"";
10
+ } catch{}
11
+ return {};
12
+ }
5
13
  if(typeof src !=='string' || !src) return {};
6
14
  const obj = {}
7
-
8
15
  // Convert buffer to string
9
16
  let lines = src.toString()
10
17
 
@@ -3,7 +3,7 @@ import appConfig from "$capp/config";
3
3
  import {MD3LightTheme,MD3DarkTheme} from "react-native-paper";
4
4
  import { useMaterial3Theme } from '@pchmn/expo-material3-theme';
5
5
  import {colorsAlias,Colors} from "$theme";
6
- import {isObj} from "$cutils";
6
+ import {isObj,isNonNullString} from "$cutils";
7
7
  import eMainScreens from "$escreens/mainScreens";
8
8
  import {ExpoUIContext} from "./hooks";
9
9
  import Login from "$eauth/Login";
@@ -41,7 +41,14 @@ const Provider = ({children,getTableData,navigation,components,getStructData,tab
41
41
  structsData = isObj(structsData)? structsData : null;
42
42
  appConfig.tablesData = tablesData;
43
43
  appConfig.structsData = appConfig.structsData = isObj(structsData)? structsData : null;
44
- appConfig.getTableData = getTableData;
44
+ if(isObj(tablesData) && Object.size(tablesData,true)){
45
+ appConfig.getTableData = (tableName)=>{
46
+ if(!isNonNullString(tableName)) return null;
47
+ tableName = tableName.trim();
48
+ }
49
+ } else if(typeof getTableData =='function'){
50
+ appConfig.getTableData = getTableData;
51
+ }
45
52
  appConfig.getStructData = getStructData;
46
53
  appConfig.LoginComponent = Login;
47
54
  //const colorScheme = useColorScheme();