@fto-consult/expo-ui 7.5.42 → 7.5.44

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
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  /**
4
4
  toujours ajouter l'instruction ci-dessus à la première ligne de chaque script npx
@@ -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
  }
@@ -80,6 +79,14 @@ program.command('electron')
80
79
  let cmd = undefined;
81
80
  icon = icon && typeof icon =="string" && fs.existsSync(path.resolve(icon)) && icon || undefined;
82
81
  require("../electron/create-index-file")({electronProjectRoot,appName:packageObj.name,icon});
82
+ if(fs.existsSync(electronProjectRoot)){
83
+ const mainPackagePath = path.resolve(electronProjectRoot,"package.app.json");
84
+ try {
85
+ const mainPackageAppJSON = fs.existsSync(mainPackagePath)? require(mainPackagePath) : {};
86
+ writeFile(mainPackagePath,JSON.stringify({...packageObj,...mainPackageAppJSON,icon:icon||mainPackageAppJSON.icon||undefined},null,"\t"));
87
+ } catch{}
88
+ }
89
+
83
90
  if(!isElectionInitialized || script =='init'){
84
91
  if(script !=='init'){
85
92
  console.log("initializing electron application before ....");
@@ -88,6 +95,7 @@ program.command('electron')
88
95
  projectRoot,
89
96
  electronDir,
90
97
  electronProjectRoot,
98
+ icon,
91
99
  });
92
100
  }
93
101
  const outDir = out && path.dirname(out) && path.resolve(path.dirname(out),"electron") || path.resolve(electronProjectRoot,"bin")
@@ -96,7 +104,7 @@ program.command('electron')
96
104
  }
97
105
  const start = x=>{
98
106
  return new Promise((resolve,reject)=>{
99
- 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}
100
108
  exec({
101
109
  cmd,
102
110
  projectRoot : electronProjectRoot,
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})=>{
13
+ module.exports = ({projectRoot,electronProjectRoot,icon})=>{
14
14
  return new Promise((resolve,reject)=>{
15
15
  //make shure electron project root exists
16
16
  if(!createDir(electronProjectRoot)){
@@ -19,7 +19,7 @@ module.exports = ({projectRoot,electronProjectRoot})=>{
19
19
  const mPackageJSON = Object.assign({},require(`${path.resolve(projectRoot,'package.json')}`));
20
20
  const electronPackagePath = path.resolve(electronProjectRoot,"package.json");
21
21
  const electronPackageJSON = Object.assign({},fs.existsSync(electronPackagePath)? require(electronPackagePath) : {});
22
- const projectRootPackage = {...mPackageJSON,...electronPackageJSON};
22
+ const projectRootPackage = {icon,...mPackageJSON,...electronPackageJSON};
23
23
  const dependencies = require("../electron/dependencies");
24
24
  const electronProjectRootPackage = path.resolve(electronProjectRoot,"package.json");
25
25
  projectRootPackage.main = `index.js`;
package/electron/index.js CHANGED
@@ -16,7 +16,7 @@ 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
 
@@ -27,17 +27,11 @@ if(iconPath && fs.existsSync(path.resolve(iconPath,iconName))){
27
27
  iconPath = path.resolve(iconPath,iconName);
28
28
  }
29
29
 
30
- const isAsar = (typeof require.main =="string" && require.main ||"").indexOf('app.asar') !== -1;
31
30
  const distPath = path.join("dist",'index.html');
32
-
33
31
  const processCWD = process.cwd();
34
32
  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(processCWD,"electron")) && fs.existsSync(path.resolve(processCWD,"electron",distPath)) && path.resolve(processCWD,"electron")
38
- || fs.existsSync(path.resolve(processCWD,distPath)) && path.resolve(processCWD) || fs.existsSync(asarPath) && fs.existsSync(path.relative(asarPath,"dist")) && asarPath ||
39
- processCWD;
40
- const packageJSONPath = fs.existsSync(processCWD,"package.json")? path.resolve(processCWD,"package.json") : path.resolve(projectRoot,"package.json");
33
+ const isAsar = appPath.indexOf('app.asar') !== -1;
34
+ const packageJSONPath = fs.existsSync(processCWD,"package.json")? path.resolve(processCWD,"package.json") : fs.existsSync(path.resolve(appPath,"package.app.json")) ? path.resolve(appPath,"package.app.json") : path.resolve(appPath,"package.json") ;
41
35
  const packageJSON = fs.existsSync(packageJSONPath) ? Object.assign({},require(`${packageJSONPath}`)) : {};
42
36
  const appName = typeof packageJSON.realAppName =='string' && packageJSON.realAppName || typeof packageJSON.name =="string" && packageJSON.name || "";
43
37
 
@@ -46,17 +40,17 @@ let mainWindow = undefined;
46
40
 
47
41
  Menu.setApplicationMenu(null);
48
42
 
49
- const indexFilePath = path.resolve(path.join(projectRoot,distPath));
43
+ const indexFilePath = path.resolve(path.join(appPath,distPath));
50
44
  const mainProcessPath = path.resolve('processes',"main","index.js");
51
- const mainProcessIndex = projectRoot && fs.existsSync(path.resolve(projectRoot,mainProcessPath)) && path.resolve(projectRoot,mainProcessPath);
45
+ const mainProcessIndex = fs.existsSync(path.resolve(appPath,mainProcessPath)) && path.resolve(appPath,mainProcessPath);
52
46
  const mainProcessRequired = mainProcessIndex && require(`${mainProcessIndex}`);
53
- //pour étendre les fonctionnalités au niveau du main proceess, bien vouloir écrire dans le fichier projectRoot/electron/main/index.js
47
+ //pour étendre les fonctionnalités au niveau du main proceess, bien vouloir écrire dans le fichier ../electron/main/index.js
54
48
  const mainProcess = mainProcessRequired && typeof mainProcessRequired =='object'? mainProcessRequired : {};
55
49
  const execPath = app.getPath ('exe') || process.execPath;
56
50
 
57
51
  // Gardez une reference globale de l'objet window, si vous ne le faites pas, la fenetre sera
58
- if(true || !isValidUrl(pUrl) && !fs.existsSync(indexFilePath)){
59
- throw {message:`Unable to start the application: index file located at [${indexFilePath}] does not exists : appPath = [${appPath}] projectRoot = [${projectRoot}], exec path is ${execPath}`}
52
+ if(!isValidUrl(pUrl) && !fs.existsSync(indexFilePath)){
53
+ throw {message:`Unable to start the application: index file located at [${indexFilePath}] does not exists : appPath = [${appPath}], exec path is ${execPath}`}
60
54
  }
61
55
 
62
56
  const quit = ()=>{
@@ -353,12 +347,17 @@ function createWindow () {
353
347
  event.returnValue = p;
354
348
  return p;
355
349
  });
350
+ ipcMain.on("get-app-path",(event,pathName)=>{
351
+ event.returnValue = appPath;
352
+ return appPath;
353
+ });
356
354
  ipcMain.on("get-project-root",(event)=>{
357
- event.returnValue = projectRoot;
355
+ event.returnValue = appPath;
358
356
  return event.returnValue;
359
357
  });
360
- ipcMain.on("get-electron-project-root",(event)=>{
361
- event.returnValue = projectRoot;
358
+
359
+ ipcMain.on("get-process-cwd",(event)=>{
360
+ event.returnValue = processCWD;
362
361
  return event.returnValue ;
363
362
  });
364
363
 
@@ -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.42",
3
+ "version": "7.5.44",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "scripts": {
6
6
  "clear-npx-cache": "npx clear-npx-cache",