@fto-consult/expo-ui 7.5.28 → 7.5.30

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.
@@ -1,7 +1,5 @@
1
1
  const path = require("path");
2
2
  const fs = require("fs");
3
- const writeFile = require("./electron/utils/writeFile");
4
- const paths = require("./electron/utils/paths");
5
3
  module.exports = (opts)=>{
6
4
  const isLocalDev = require("./is-local-dev")();
7
5
  const dir = path.resolve(__dirname);
@@ -109,15 +107,6 @@ module.exports = (opts)=>{
109
107
  electronPaths.logo = logoPath;
110
108
  }
111
109
  }
112
- const expoUIElectronPath = path.resolve(projectRoot,"electron")
113
- const pathsSringified = JSON.stringify(electronPaths, null, "\t");
114
- ///on sauvegarde les chemins des fichiers utiles, qui seront utilisées par la variable electron plus tard
115
- try {
116
- writeFile(paths(projectRoot),pathsSringified);
117
- } catch{}
118
- if(fs.existsSync(expoUIElectronPath)){
119
- writeFile(path.resolve(expoUIElectronPath,"paths.json"),pathsSringified);
120
- }
121
110
  r["$erealm"] = path.resolve(expo,'realm');
122
111
  if(!r.$realm){
123
112
  r.$realm = r.$erealm;
package/bin/index.js CHANGED
@@ -10,7 +10,7 @@
10
10
  const { program } = require('commander');
11
11
  const path= require("path");
12
12
  const fs = require("fs");
13
- const {createDir,electronDir,copy,exec,throwError,paths:getPaths,writeFile,isValidUrl} = require("./utils");
13
+ const {createDir,electronDir,copy,exec,throwError,writeFile,isValidUrl} = require("./utils");
14
14
 
15
15
 
16
16
  const dir = path.resolve(__dirname);
@@ -53,39 +53,17 @@ program.command('electron')
53
53
  .option('-b, --build [boolean]', 'si ce flag est spécfifié alors l\'application sera compilée; combinée avec la commande start|package pour indiquer que l\'application sera à nouveau exportée ou pas.')
54
54
  .option('-a, --arch [architecture]', 'l\'architecture de la plateforme; Commande package')
55
55
  .option('-p, --platform [platform]', 'la plateforme à utiliser pour la compilation; commande package')
56
+ .option('-l, --logo [logoPath]', 'le chemin vers le logo de l\'application : (.ico pour window, .incs pour mac et .png pour linux)')
56
57
  .option('-i, --import [boolean]', 'la commande d\'initialisation du package electron forge, utile pour le packaging de l\'application. Elle permet d\'exécuter le cli electron package, pour l\'import d\'un projet existant. Commande package. exemple : expo-ui electron package --import')
57
58
 
58
59
  .action((script, options) => {
59
60
  const electronProjectRoot = path.resolve(projectRoot,"electron");
60
61
  const opts = Object.assign({},typeof options.opts =='function'? options.opts() : options);
61
- let {out,arch,url,build,platform,import:packageImport} = opts;
62
+ let {out,arch,url,build,platform,import:packageImport,logo} = opts;
62
63
  //let {projectRoot} = opts;
63
64
  if(projectRoot == dir){
64
65
  throwError(`Invalid project root ${projectRoot}; project root must be different to ${dir}`);
65
66
  }
66
- let pathsJSON = path.resolve(getPaths(projectRoot));
67
- const electronPathsJSON = path.resolve(electronProjectRoot,"paths.json");
68
- if(!fs.existsSync(pathsJSON)){
69
- if(fs.existsSync(electronPathsJSON)){
70
- pathsJSON = electronPathsJSON
71
- } else {
72
- throwError("Le fichier des chemins d'accès à l'application est innexistant, rassurez vous de tester l'application en environnement web, via la cmde <npx expo start>, avant l'exécution du script electron.");
73
- }
74
- }
75
- const paths = require(`${pathsJSON}`);
76
- if(typeof paths !=='object' || !paths || !paths.projectRoot || !fs.existsSync(paths.projectRoot)){
77
- throwError("Fichiers des chemins d'application invalide!!! merci d'exécuter l'application en environnement web|android|ios puis réessayez");
78
- }
79
- if(fs.existsSync(localElectronPackageElectron)){
80
- try {
81
- writeFile(path.resolve(localElectronPackageElectron,"paths.json"),JSON.stringify(paths,null,"\t"));
82
- } catch{}
83
- }
84
-
85
- /**** le project root d'où a été lancé le script electron doit être le même que celui de l'application principale */
86
- if(projectRoot !== paths.projectRoot){
87
- throwError(`main app project root ${paths.projectRoot} must be equals to ${projectRoot} in which you want to generate electron app`);
88
- }
89
67
 
90
68
  const isElectionInitialized = require("../electron/is-initialized")(electronProjectRoot);
91
69
  process.env.isElectron = true;
@@ -100,7 +78,8 @@ program.command('electron')
100
78
  const packageObj = require(`${packagePath}`);
101
79
  const homepage = packageObj.homepage;
102
80
  let cmd = undefined;
103
- require("../electron/create-index-file")({electronProjectRoot,appName:packageObj.name});
81
+ logo = logo && typeof logo =="string" && fs.existsSync(path.resolve(logo)) && logo || undefined;
82
+ require("../electron/create-index-file")({electronProjectRoot,appName:packageObj.name,logo});
104
83
  if(!isElectionInitialized || script =='init'){
105
84
  if(script !=='init'){
106
85
  console.log("initializing electron application before ....");
@@ -109,20 +88,12 @@ program.command('electron')
109
88
  projectRoot,
110
89
  electronDir,
111
90
  electronProjectRoot,
112
- paths,
113
- pathsJSON
114
91
  });
115
92
  }
116
93
  const outDir = out && path.dirname(out) && path.resolve(path.dirname(out),"electron") || path.resolve(electronProjectRoot,"bin")
117
94
  if(!createDir(outDir)){
118
95
  throwError("Impossible de créer le répertoire <<"+outDir+">> du fichier binaire!!");
119
96
  }
120
- const logoPath = paths.logo || paths.$assets && path.resolve(paths.$assets,"logo.png") || paths.$images && path.resolve(paths.$images,"logo.png");
121
- if(!logoPath || !fs.existsSync(logoPath)){
122
- if(logoPath){
123
- console.warn("Logo de l'application innexistant!! Vous devez spécifier le logo de votre application, fichier ["+(logoPath)+"]")
124
- }
125
- }
126
97
  const start = x=>{
127
98
  return new Promise((resolve,reject)=>{
128
99
  cmd = `electron "${electronProjectRoot}" --root ${electronProjectRoot} ${isValidUrl(url)? ` --url ${url}`:''}`;
package/bin/init.js CHANGED
@@ -10,7 +10,7 @@ const appSuffix = "-desk";
10
10
  const mainPackage = require("../package.json");
11
11
  const mainPackageName = mainPackage.name;
12
12
 
13
- module.exports = ({projectRoot,electronProjectRoot,paths,pathsJSON})=>{
13
+ module.exports = ({projectRoot,electronProjectRoot})=>{
14
14
  return new Promise((resolve,reject)=>{
15
15
  //make shure electron project root exists
16
16
  if(!createDir(electronProjectRoot)){
@@ -62,17 +62,6 @@ module.exports = ({projectRoot,electronProjectRoot,paths,pathsJSON})=>{
62
62
  /**** copying all electron utils files */
63
63
  const utilsPath = path.resolve(electronProjectRoot,"utils");
64
64
  copy(path.resolve(electronDir,"utils"),utilsPath);
65
- const destPathJSON = path.resolve(electronProjectRoot,"paths.json");
66
- try {
67
- if(paths && typeof paths =='object' && paths.$src && fs.existsSync(paths.$src)){
68
- writeFile(destPathJSON,JSON.stringify(paths, null, "\t"));
69
- }
70
- } catch{}
71
- if(!fs.existsSync(destPathJSON) && pathsJSON && fs.existsSync(pathsJSON)){
72
- try {
73
- copy(pathsJSON,destPathJSON);
74
- } catch(e){}
75
- }
76
65
  const gP = path.resolve(electronProjectRoot,".gitignore") ;
77
66
  if(!fs.existsSync(gP)){
78
67
  try {
@@ -3,7 +3,7 @@ const writeFile = require("../electron/utils/writeFile");
3
3
  const path = require("path");
4
4
  const packageJSON = require("../package.json");
5
5
 
6
- module.exports = ({electronProjectRoot,force,appName})=>{
6
+ module.exports = ({electronProjectRoot,force,logo,appName})=>{
7
7
  if(!electronProjectRoot || typeof electronProjectRoot !='string' || !fs.existsSync(electronProjectRoot)){
8
8
  return null;
9
9
  }
@@ -12,7 +12,8 @@ module.exports = ({electronProjectRoot,force,appName})=>{
12
12
  writeFile(indexPath,`
13
13
  module.exports = require("${packageJSON.name}/electron/index.js")({
14
14
  projectRoot : __dirname,
15
- appName : "${appName}"
15
+ appName : "${appName}",
16
+ logo : ${logo}? "${logo}" : undefined,
16
17
  })
17
18
  `);
18
19
  }
package/electron/index.js CHANGED
@@ -4,27 +4,23 @@ const mainApp = require("./main-app");
4
4
  program
5
5
  .option('-u, --url <url>', 'L\'adresse url à ouvrir au lancement de l\'application')
6
6
  .option('-r, --root <projectRoot>', 'le chemin du project root de l\'application')
7
- //.option('-p, --paths <paths>', 'le chemin vers le fichiers paths.json contenant la liste des alias de l\'application, exportés au moment de la compilation')
8
7
  .parse();
9
8
 
10
9
  const programOptions = program.opts();
11
- const {url:pUrl,root:mainProjectRoot} = programOptions;
10
+ const {url,root:mainProjectRoot} = programOptions;
12
11
 
13
12
  const isAsar = (typeof require.main =="string" && require.main ||"").indexOf('app.asar') !== -1;
14
13
  const path = require("path");
15
14
  const fs = require("fs");
16
15
  const isValidUrl = require("./utils/isValidUrl");
17
-
18
- throw "Before begin "+mainProjectRoot;
19
16
  const distPath = path.join("dist",'index.html');
17
+
20
18
  const processCWD = process.cwd();
21
- const electronProjectRoot = mainProjectRoot && typeof mainProjectRoot =='string' && fs.existsSync(mainProjectRoot) && fs.existsSync(path.resolve(mainProjectRoot,distPath)) && mainProjectRoot || null;
19
+ const electronProjectRoot = mainProjectRoot && typeof mainProjectRoot =='string' && fs.existsSync(path.resolve(mainProjectRoot)) && fs.existsSync(path.resolve(mainProjectRoot,distPath)) && path.resolve(mainProjectRoot) || null;
22
20
  const projectRoot = electronProjectRoot || fs.existsSync(path.resolve(processCWD,"electron")) && fs.existsSync(path.resolve(processCWD,"electron",distPath)) && path.resolve(processCWD,"electron") || undefined;
23
21
  const packageJSONPath = fs.existsSync(processCWD,"package.json")? path.resolve(processCWD,"package.json") : path.resolve(projectRoot,"package.json");
24
22
  const packageJSON = fs.existsSync(packageJSONPath) ? require(`${packageJSONPath}`) : {};
25
23
 
26
- throw `electron project root is ${electronProjectRoot} and project root is ${projectRoot}`;
27
-
28
24
  const ObjectSize = (object)=>{
29
25
  if(!object || typeof object !=='object' || Array.isArray(object)) return false;
30
26
  for(let i in object){
@@ -36,7 +32,7 @@ const ObjectSize = (object)=>{
36
32
  function mainExportedApp (options){
37
33
  options = Object.assign({},options);
38
34
  options.isAsar = isAsar;
39
- options.url = isValidUrl(options.url)? options.url : isValidUrl(pUrl)? pUrl : undefined;
35
+ options.url = isValidUrl(options.url)? options.url : isValidUrl(url)? url : undefined;
40
36
  if(!options.projectRoot || typeof options.projectRoot !=='string' || !fs.existsSync(options.projectRoot) || !fs.existsSync(path.resolve(options.projectRoot,distPath))){
41
37
  options.projectRoot = projectRoot;
42
38
  }
@@ -49,14 +45,13 @@ function mainExportedApp (options){
49
45
  options.appName = typeof options.appName =="string" && options.appName ||
50
46
  typeof options.packageJSON?.realAppName =='string' && options?.packageJSON?.realAppName || typeof packageJSON?.realAppName =="string" && packageJSON?.realAppName ||
51
47
  typeof option?.packageJSON?.name =="string" && options?.packageJSON?.name || typeof packageJSON.name =="string" && packageJSON.name || undefined;
52
- throw JSON.stringify(options);
53
48
  return mainApp(options);
54
49
  }
55
50
 
56
51
  module.exports = mainExportedApp;
57
52
 
58
- if(isValidUrl(pUrl) || electronProjectRoot){
59
- mainExportedApp({url:pUrl,projectRoot,packageJSON});
53
+ if(isValidUrl(url) || electronProjectRoot){
54
+ mainExportedApp({url:url,projectRoot,packageJSON});
60
55
  }
61
56
 
62
57
  module.exports.createBrowserWindow = mainApp.createBrowserWindow;
@@ -6,8 +6,6 @@ module.exports = (projectRoot)=>{
6
6
  return fs.existsSync(path.resolve(projectRoot,"node_modules")) && fs.existsSync(path.resolve(projectRoot,"index.js"))
7
7
  && fs.existsSync(path.resolve(projectRoot,"package.json"))
8
8
  && fs.existsSync(path.resolve(projectRoot,'processes',"main","index.js"))
9
- && fs.existsSync(path.resolve(projectRoot,'processes',"renderer","index.js"))
10
- && fs.existsSync(path.resolve(projectRoot,"paths.json"))
11
-
9
+ && fs.existsSync(path.resolve(projectRoot,'processes',"renderer","index.js"))
12
10
  && true || false;
13
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "7.5.28",
3
+ "version": "7.5.30",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "scripts": {
6
6
  "clear-npx-cache": "npx clear-npx-cache",