@fto-consult/expo-ui 7.5.43 → 7.5.45

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/bin/index.js CHANGED
@@ -60,7 +60,6 @@ program.command('electron')
60
60
  const electronProjectRoot = path.resolve(projectRoot,"electron");
61
61
  const opts = Object.assign({},typeof options.opts =='function'? options.opts() : options);
62
62
  let {out,arch,url,build,platform,import:packageImport,icon} = opts;
63
- //let {projectRoot} = opts;
64
63
  if(projectRoot == dir){
65
64
  throwError(`Invalid project root ${projectRoot}; project root must be different to ${dir}`);
66
65
  }
@@ -84,7 +83,7 @@ program.command('electron')
84
83
  const mainPackagePath = path.resolve(electronProjectRoot,"package.app.json");
85
84
  try {
86
85
  const mainPackageAppJSON = fs.existsSync(mainPackagePath)? require(mainPackagePath) : {};
87
- writeFile(mainPackagePath,JSON.stringify({...packageObj,...mainPackageAppJSON,icon:icon||mainPackageAppJSON.icon||undefined},null,"\t"));
86
+ writeFile(mainPackagePath,JSON.stringify({...packageObj,...mainPackageAppJSON,name:packageObj.name,icon:icon||mainPackageAppJSON.icon||undefined},null,"\t"));
88
87
  } catch{}
89
88
  }
90
89
 
@@ -105,7 +104,7 @@ program.command('electron')
105
104
  }
106
105
  const start = x=>{
107
106
  return new Promise((resolve,reject)=>{
108
- cmd = `electron "${electronProjectRoot}" --root ${electronProjectRoot} ${icon ? `--icon ${path.resolve(icon)}`:""} ${isValidUrl(url)? ` --url ${url}`:''}`;
107
+ cmd = `electron "${electronProjectRoot}" ${icon ? `--icon ${path.resolve(icon)}`:""} ${isValidUrl(url)? ` --url ${url}`:''}`; //--root ${electronProjectRoot}
109
108
  exec({
110
109
  cmd,
111
110
  projectRoot : electronProjectRoot,
package/electron/index.js CHANGED
@@ -16,45 +16,45 @@ const iconName = process.platform =="win32" ? "icon.ico" : process.platform =='d
16
16
 
17
17
  program
18
18
  .option('-u, --url <url>', 'L\'adresse url à ouvrir au lancement de l\'application')
19
- .option('-r, --root <projectRoot>', 'le chemin du project root de l\'application')
19
+ //.option('-r, --root <projectRoot>', 'le chemin du project root de l\'application')
20
20
  .option('-l, --icon [iconPath]', 'le chemin vers le dossier des icones de l\'application : (Dans ce dossier, doit contenir une image icon.ico pour window, icon.incs pour mac et icon.png pour linux)')
21
21
  .parse();
22
22
 
23
23
  const programOptions = program.opts();
24
24
  const {url:pUrl,root:mainProjectRoot,icon} = programOptions;
25
- let iconPath = icon && typeof icon =="string" && fs.existsSync(path.resolve(icon)) && path.resolve(icon) || undefined;
26
- if(iconPath && fs.existsSync(path.resolve(iconPath,iconName))){
27
- iconPath = path.resolve(iconPath,iconName);
28
- }
29
25
 
30
- const isAsar = (typeof require.main =="string" && require.main ||"").indexOf('app.asar') !== -1;
31
26
  const distPath = path.join("dist",'index.html');
32
-
33
27
  const processCWD = process.cwd();
34
28
  const appPath = app.getAppPath();
35
- const asarPath = path.resolve(processCWD,"resources","app.asar");
36
- const electronProjectRoot = mainProjectRoot && typeof mainProjectRoot =='string' && fs.existsSync(path.resolve(mainProjectRoot)) && fs.existsSync(path.resolve(mainProjectRoot,distPath)) && path.resolve(mainProjectRoot) || null;
37
- const projectRoot = electronProjectRoot || fs.existsSync(path.resolve(appPath,distPath)) && appPath || fs.existsSync(asarPath) && fs.existsSync(path.relative(asarPath,"dist")) && asarPath || appPath;
38
- const packageJSONPath = fs.existsSync(processCWD,"package.json")? path.resolve(processCWD,"package.json") : path.resolve(projectRoot,"package.json");
39
- const packageJSON = fs.existsSync(packageJSONPath) ? Object.assign({},require(`${packageJSONPath}`)) : fs.existsSync(path.resolve(projectRoot,"package.app.json")) ? require(path.resolve(projectRoot,"package.app.json")) : {};
40
- const appName = typeof packageJSON.realAppName =='string' && packageJSON.realAppName || typeof packageJSON.name =="string" && packageJSON.name || "";
29
+ const isAsar = appPath.indexOf('app.asar') !== -1;
30
+ const packageJSONPath = fs.existsSync(path.resolve(appPath,"package.app.json")) ? path.resolve(appPath,"package.app.json") : fs.existsSync(processCWD,"package.json")? path.resolve(processCWD,"package.json") : path.resolve(appPath,"package.json") ;
31
+ const packageJSON = fs.existsSync(packageJSONPath) ? Object.assign({},require(`${packageJSONPath}`)) : {};
32
+ const appName = typeof packageJSON.name =="string" && packageJSON.name || "";
33
+
34
+ let iconPath = icon && typeof icon =="string" && fs.existsSync(path.resolve(icon)) && path.resolve(icon) || undefined;
35
+ if(!iconPath && packageJSON.icon && typeof packageJSON.icon ==="string" && fs.existsSync(packageJSON.icon)){
36
+ iconPath = packageJSON.icon;
37
+ }
38
+ if(iconPath && fs.existsSync(path.resolve(iconPath,iconName))){
39
+ iconPath = path.resolve(iconPath,iconName);
40
+ }
41
41
 
42
42
  // fermee automatiquement quand l'objet JavaScript sera garbage collected.
43
43
  let mainWindow = undefined;
44
44
 
45
45
  Menu.setApplicationMenu(null);
46
46
 
47
- const indexFilePath = path.resolve(path.join(projectRoot,distPath));
47
+ const indexFilePath = path.resolve(path.join(appPath,distPath));
48
48
  const mainProcessPath = path.resolve('processes',"main","index.js");
49
- const mainProcessIndex = projectRoot && fs.existsSync(path.resolve(projectRoot,mainProcessPath)) && path.resolve(projectRoot,mainProcessPath);
49
+ const mainProcessIndex = fs.existsSync(path.resolve(appPath,mainProcessPath)) && path.resolve(appPath,mainProcessPath);
50
50
  const mainProcessRequired = mainProcessIndex && require(`${mainProcessIndex}`);
51
- //pour étendre les fonctionnalités au niveau du main proceess, bien vouloir écrire dans le fichier projectRoot/electron/main/index.js
51
+ //pour étendre les fonctionnalités au niveau du main proceess, bien vouloir écrire dans le fichier ../electron/main/index.js
52
52
  const mainProcess = mainProcessRequired && typeof mainProcessRequired =='object'? mainProcessRequired : {};
53
53
  const execPath = app.getPath ('exe') || process.execPath;
54
54
 
55
55
  // Gardez une reference globale de l'objet window, si vous ne le faites pas, la fenetre sera
56
- if(true || !isValidUrl(pUrl) && !fs.existsSync(indexFilePath)){
57
- throw {message:`Unable to start the application: index file located at [${indexFilePath}] does not exists : appPath = [${appPath}] projectRoot = [${projectRoot}], exec path is ${execPath}`}
56
+ if(!isValidUrl(pUrl) && !fs.existsSync(indexFilePath)){
57
+ throw {message:`Unable to start the application: index file located at [${indexFilePath}] does not exists : appPath = [${appPath}], exec path is ${execPath}`}
58
58
  }
59
59
 
60
60
  const quit = ()=>{
@@ -351,12 +351,17 @@ function createWindow () {
351
351
  event.returnValue = p;
352
352
  return p;
353
353
  });
354
+ ipcMain.on("get-app-path",(event,pathName)=>{
355
+ event.returnValue = appPath;
356
+ return appPath;
357
+ });
354
358
  ipcMain.on("get-project-root",(event)=>{
355
- event.returnValue = projectRoot;
359
+ event.returnValue = appPath;
356
360
  return event.returnValue;
357
361
  });
358
- ipcMain.on("get-electron-project-root",(event)=>{
359
- event.returnValue = projectRoot;
362
+
363
+ ipcMain.on("get-process-cwd",(event)=>{
364
+ event.returnValue = processCWD;
360
365
  return event.returnValue ;
361
366
  });
362
367
 
@@ -419,6 +419,9 @@ const ELECTRON = {
419
419
  return ipcRenderer.invoke('set-system-theme:light-mode');
420
420
  }
421
421
  },
422
+ get appPath(){
423
+ return ipcRenderer.sendSync("get-app-path");
424
+ }
422
425
  };
423
426
 
424
427
  require("./pload")(ELECTRON,{projectRoot});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "7.5.43",
3
+ "version": "7.5.45",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "scripts": {
6
6
  "clear-npx-cache": "npx clear-npx-cache",