@fto-consult/expo-ui 6.66.6 → 6.67.1
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.
- package/babel.config.js +1 -68
- package/bin/generate-tables.js +69 -0
- package/bin/index.js +5 -1
- package/package.json +1 -1
package/babel.config.js
CHANGED
@@ -14,34 +14,7 @@ module.exports = function(api,opts) {
|
|
14
14
|
}
|
15
15
|
/*** 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 */
|
16
16
|
const alias = require("./babel.config.alias")(options);
|
17
|
-
|
18
|
-
const packageRootPath = path.resolve(process.cwd(),"package.json");
|
19
|
-
const packageJSON = fs.existsSync(packageRootPath) && require(`${packageRootPath}`) || {};
|
20
|
-
const envObj = require("./parse-env")();
|
21
|
-
const writeFilePath = path.resolve($eelectron,"utils","writeFile.js");
|
22
|
-
if($eelectron && fs.existsSync($eelectron)){
|
23
|
-
if(fs.existsSync(writeFilePath)){
|
24
|
-
const writeFile = require(`${writeFilePath}`);
|
25
|
-
//generate getTable.js file
|
26
|
-
const tableDataPath = envObj.TABLES_DATA_PATH && path.resolve(String(envObj.TABLES_DATA_PATH)) || packageJSON?.tablesDataPath && path.resolve(String(packageJSON.tablesDataPath)) || null;
|
27
|
-
if(tableDataPath && fs.existsSync(tableDataPath)){
|
28
|
-
const getTableJSContent = generateTableOrStructDataStr(tableDataPath);
|
29
|
-
if(getTableJSContent){
|
30
|
-
writeFile(path.resolve(tableDataPath,"getTable.js"),getTableJSContent);
|
31
|
-
}
|
32
|
-
}
|
33
|
-
|
34
|
-
//generate getStructData.js file
|
35
|
-
const structsDataPath = envObj.STRUCTS_DATA_PATH && path.resolve(String(envObj.STRUCTS_DATA_PATH)) || packageJSON?.structsDataPath && path.resolve(String(packageJSON.structsDataPath)) || null;
|
36
|
-
if(structsDataPath && fs.existsSync(structsDataPath)){
|
37
|
-
const getStructDataJSContent = generateTableOrStructDataStr(structsDataPath);
|
38
|
-
if(getStructDataJSContent){
|
39
|
-
writeFile(path.resolve(structsDataPath,"getStructData.js"),getStructDataJSContent);
|
40
|
-
}
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
}
|
17
|
+
require("@fto-consult/expo-ui/bin/generate-tables")();//génère les tables des bases de données
|
45
18
|
return {
|
46
19
|
presets: [
|
47
20
|
['babel-preset-expo']
|
@@ -57,43 +30,3 @@ module.exports = function(api,opts) {
|
|
57
30
|
};
|
58
31
|
|
59
32
|
|
60
|
-
/****
|
61
|
-
retourne la chaine de caractère liée à la fonction getTable.js ou getStructData.js
|
62
|
-
@param {string} tableDataPath, le chemin de la tableDataPath
|
63
|
-
@return {string}, la chaine de caractère à enregistrer dans la fonction getTable.js ou getStructData.js
|
64
|
-
*/
|
65
|
-
const generateTableOrStructDataStr = (tableDataPath)=>{
|
66
|
-
if(typeof tableDataPath !== 'string' || !tableDataPath.trim()) return null;
|
67
|
-
tableDataPath = tableDataPath.trim();
|
68
|
-
const fs = require("fs"), path = require("path");
|
69
|
-
if(fs.lstatSync(tableDataPath).isDirectory()){
|
70
|
-
let getTableJSContent = '';
|
71
|
-
const tables = fs.readdirSync(tableDataPath);
|
72
|
-
if(Array.isArray(tables)){
|
73
|
-
tables.map((table,i)=>{
|
74
|
-
table = table.trim();
|
75
|
-
const tableName = table.toUpperCase();
|
76
|
-
const tablePath = path.join(tableDataPath, table);
|
77
|
-
const indexTablePath = path.join(tablePath,"index.js");
|
78
|
-
const stat = fs.lstatSync(tablePath);
|
79
|
-
if(!stat.isDirectory() || !fs.existsSync(indexTablePath)) return;
|
80
|
-
const indexContent = fs.readFileSync(indexTablePath,'utf8') ;
|
81
|
-
if(!indexContent || (!indexContent.includes("table") && !indexContent.includes("tableName"))){
|
82
|
-
return;
|
83
|
-
}
|
84
|
-
getTableJSContent+=`\t\tif(tableName === "${tableName}"){return require("./${table}").default;}\n`;
|
85
|
-
});
|
86
|
-
//on génère le fichier getTable des tables data de l'application
|
87
|
-
if(getTableJSContent){
|
88
|
-
return (`
|
89
|
-
export default function(tableName){
|
90
|
-
\tif(!tableName || typeof tableName !=="string") return null;
|
91
|
-
\ttableName = tableName.toUpperCase().trim();
|
92
|
-
${getTableJSContent}\treturn null;
|
93
|
-
}
|
94
|
-
`);
|
95
|
-
}
|
96
|
-
}
|
97
|
-
}
|
98
|
-
return null;
|
99
|
-
}
|
@@ -0,0 +1,69 @@
|
|
1
|
+
|
2
|
+
const path = require("path"), fs = require("fs");
|
3
|
+
const {writeFile} = require("./utils");
|
4
|
+
|
5
|
+
/*** permet de générer les tables des bases de données de l'application
|
6
|
+
*/
|
7
|
+
module.exports = ()=>{
|
8
|
+
const projectRoot = path.resolve(process.cwd());
|
9
|
+
const packageRootPath = path.resolve(projectRoot,"package.json");
|
10
|
+
const packageJSON = fs.existsSync(packageRootPath) && require(`${packageRootPath}`) || {};
|
11
|
+
if(!packageJSON) return;
|
12
|
+
|
13
|
+
//generate getTable.js file
|
14
|
+
const tableDataPath = packageJSON?.tablesDataPath && path.resolve(String(packageJSON.tablesDataPath)) || null;
|
15
|
+
if(tableDataPath && fs.existsSync(tableDataPath)){
|
16
|
+
const getTableJSContent = generateTableOrStructDataStr(tableDataPath);
|
17
|
+
if(getTableJSContent){
|
18
|
+
writeFile(path.resolve(tableDataPath,"getTable.js"),getTableJSContent);
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
//generate getStructData.js file
|
23
|
+
const structsDataPath = packageJSON?.structsDataPath && path.resolve(String(packageJSON.structsDataPath)) || null;
|
24
|
+
if(structsDataPath && fs.existsSync(structsDataPath)){
|
25
|
+
const getStructDataJSContent = generateTableOrStructDataStr(structsDataPath);
|
26
|
+
if(getStructDataJSContent){
|
27
|
+
writeFile(path.resolve(structsDataPath,"getStructData.js"),getStructDataJSContent);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
/****
|
32
|
+
retourne la chaine de caractère liée à la fonction getTable.js ou getStructData.js
|
33
|
+
@param {string} tableDataPath, le chemin de la tableDataPath
|
34
|
+
@return {string}, la chaine de caractère à enregistrer dans la fonction getTable.js ou getStructData.js
|
35
|
+
*/
|
36
|
+
const generateTableOrStructDataStr = (tableDataPath)=>{
|
37
|
+
if(typeof tableDataPath !== 'string' || !tableDataPath.trim()) return null;
|
38
|
+
tableDataPath = tableDataPath.trim();
|
39
|
+
if(fs.lstatSync(tableDataPath).isDirectory()){
|
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+=`\tif(tableName === "${tableName}"){return require("./${table}").default;}\n`;
|
55
|
+
});
|
56
|
+
//on génère le fichier getTable des tables data de l'application
|
57
|
+
if(getTableJSContent){
|
58
|
+
return (`
|
59
|
+
export default function(tableName){
|
60
|
+
\tif(!tableName || typeof tableName !=="string") return null;
|
61
|
+
\ttableName = tableName.toUpperCase().trim();
|
62
|
+
${getTableJSContent}\treturn null;
|
63
|
+
}
|
64
|
+
`);
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
return null;
|
69
|
+
}
|
package/bin/index.js
CHANGED
@@ -15,9 +15,10 @@ const supportedScript = {
|
|
15
15
|
"start" : true,//start electron
|
16
16
|
"build" : true, //script pour faire un build,
|
17
17
|
"package" : true, ///script pour le packagin de l'application
|
18
|
+
"generate-getTable" : true,/// script pour la génération de la fonction getTable des tables de l'application
|
18
19
|
[createAppScript] : true,//les script de création de l'application
|
19
20
|
}
|
20
|
-
const {createDir,
|
21
|
+
const {createDir,electronDir,copy,exec,throwError} = require("./utils");
|
21
22
|
const path= require("path");
|
22
23
|
const fs = require("fs");
|
23
24
|
const dir = path.resolve(__dirname);
|
@@ -124,6 +125,9 @@ if(parsedArgs.electron){
|
|
124
125
|
break;
|
125
126
|
case "build":
|
126
127
|
break;
|
128
|
+
case "generate-getTable" :
|
129
|
+
require("./generate-tables")();
|
130
|
+
break;
|
127
131
|
default :
|
128
132
|
if(!fs.existsSync(packagePath)){
|
129
133
|
throwError("package.json file does not exist in "+projectRoot+". please make jure that your have running package script in expo root application");
|