@fto-consult/expo-ui 1.0.9 → 1.0.10

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,41 @@
1
+ /*** met à jour dynamiquement la version de l'application */
2
+ const jsonfile = require('jsonfile');
3
+ const fs = require('fs')
4
+
5
+ function recursiveUpdate(initial, update,recursiveArray){
6
+ initial = initial && typeof initial == 'object'? initial : {};
7
+ for(prop in update){
8
+ if({}.hasOwnProperty.call(update, prop)){
9
+ if(update[prop] && typeof update[prop] === 'object'){
10
+ if(Array.isArray(update[prop]) && recursiveArray !==false){
11
+ initial[prop] = update[prop];
12
+ } else {
13
+ recursiveUpdate(initial[prop], update[prop],recursiveArray);
14
+ }
15
+ } else if(typeof update[prop] == 'string' && update[prop] ) {
16
+ initial[prop] = update[prop].toString().replace(/\+/g, ' ');
17
+ }
18
+ }
19
+ }
20
+ return initial;
21
+ }
22
+
23
+ function editJsonFile(packagePath,config){
24
+ if(!fs.existsSync(packagePath)) return;
25
+ try {
26
+ let packaged = jsonfile.readFileSync(packagePath);
27
+ if(!config || typeof config != 'object') return false;
28
+ recursiveUpdate(packaged,config);
29
+ jsonfile.writeFileSync(packagePath, packaged, {spaces: 4})
30
+ return true;
31
+ }
32
+ catch (e) {
33
+ process.stdout.write('An exception occurred:\n')
34
+ process.stdout.write(' ' + e.message)
35
+ process.stdout.write('\n')
36
+ process.exit(1)
37
+ }
38
+ }
39
+
40
+
41
+ module.exports = editJsonFile;
@@ -0,0 +1,449 @@
1
+ const {app, BrowserWindow,Tray,Menu,MenuItem,systemPreferences,powerMonitor,dialog, nativeTheme} = require('electron')
2
+ let appConfig = require("../src/app/config");
3
+ let appReady = false;
4
+ const path = require("path");
5
+ const parentDir = path.resolve(__dirname);
6
+ // Gardez une reference globale de l'objet window, si vous ne le faites pas, la fenetre sera
7
+ // fermee automatiquement quand l'objet JavaScript sera garbage collected.
8
+ let win = undefined;
9
+ let fs = require("fs");
10
+ let icon = undefined;
11
+ const imagesPath = path.join(__dirname,"assets/images")
12
+ if(process.platform =="win32" && fs.existsSync(path.join(imagesPath, "icon.ico"))){
13
+ icon = path.join(imagesPath, "icon.ico");
14
+ } else if(process.platform =="linux" && fs.existsSync(path.join(imagesPath, "icon.png"))){
15
+ icon = path.join(imagesPath, "icon.png");
16
+ } else if(process.platform =='darwin' && fs.existsSync(path.join(imagesPath, "icon.incs"))){
17
+ icon = path.join(imagesPath, "icon.incs");
18
+ }
19
+
20
+ Menu.setApplicationMenu(null);
21
+ let clipboadContextMenu = (_, props) => {
22
+ if (props.isEditable || props.selectionText) {
23
+ const menu = new Menu();
24
+ if(props.selectionText){
25
+ menu.append(new MenuItem({ label: 'Copier', role: 'copy' }));
26
+ if(props.isEditable){
27
+ menu.append(new MenuItem({ label: 'Couper', role: 'cut' }));
28
+ }
29
+ }
30
+ if(props.isEditable){
31
+ menu.append(new MenuItem({ label: 'Coller', role: 'paste' }));
32
+ }
33
+ menu.popup();
34
+ }
35
+ };
36
+
37
+ let Conf = require('./src/config');
38
+ let session = new Conf({cwd:app.getPath('userData')});
39
+
40
+ const setOSTheme = (theme) => {
41
+ theme = theme && typeof theme == "string"? theme : "light";
42
+ theme = theme.toLowerCase().trim();
43
+ if(theme !== 'system' && theme !=='dark'){
44
+ theme = "light";
45
+ }
46
+ nativeTheme.themeSource = theme;
47
+ session.set("electron-os-theme",theme);
48
+ return nativeTheme.shouldUseDarkColors
49
+ }
50
+ setOSTheme(session.get("electron-os-theme"));
51
+ let isObj = x => x && typeof x =='object';
52
+ function createBrowserWindow (options){
53
+ options = options && typeof options =='object'? options : {};
54
+ let menu = options.menu;
55
+ options.webPreferences = isObj(options.webPreferences)? options.webPreferences : {}
56
+ options.webPreferences = {
57
+ ...options.webPreferences,
58
+ devTools: typeof options.webPreferences.devTools === 'boolean'? options.webPreferences.devTools : false,
59
+ icon,
60
+ contextIsolation: false,
61
+ webSecurity : true,
62
+ autoHideMenuBar: true,
63
+ allowRunningInsecureContent: false,
64
+ nodeIntegration: false,
65
+ preload: options.preload ? options.preload : null,
66
+ plugin:false,
67
+ contentSecurityPolicy: `
68
+ default-src 'none';
69
+ script-src 'self';
70
+ img-src 'self' data:;
71
+ style-src 'self';
72
+ font-src 'self';
73
+ `
74
+ }
75
+ if(options.modal && !options.parent && win){
76
+ options.parent = win;
77
+ }
78
+ if(typeof options.show ==='undefined'){
79
+ options.show = false;
80
+ }
81
+ let showOnLoad = options.showOnLoad ===true ? true : undefined;
82
+ if(showOnLoad){
83
+ options.show = false;
84
+ }
85
+ let _win = new BrowserWindow(options);
86
+ if(!menu){
87
+ _win.setMenu(null);
88
+ _win.removeMenu();
89
+ _win.setMenuBarVisibility(false)
90
+ _win.setAutoHideMenuBar(true)
91
+ }
92
+ let url = options.loadURL && typeof options.loadURL ==='string'? options.loadURL : undefined;
93
+ if(url){
94
+ _win.loadURL(url);
95
+ }
96
+ if(showOnLoad){
97
+ _win.once('ready-to-show', () => {
98
+ _win.show();
99
+ });
100
+ }
101
+ _win.on('closed', function() {
102
+ _win = null;
103
+ });
104
+ return _win;
105
+ }
106
+
107
+
108
+ function createWindow () {
109
+ // Créer le browser window
110
+ win = createBrowserWindow({
111
+ showOnLoad : false,
112
+ loadURL : undefined,
113
+ preload : path.resolve(__dirname,'src/preload.js'),
114
+ webPreferences : {
115
+ devTools : true,
116
+ }
117
+ });
118
+ // create a new `splash`-Window
119
+ /*** @see : http://leftstick.github.io/splash-screen/ */
120
+ let splash = new BrowserWindow({
121
+ width: 500, height: 400, transparent: true, frame: false, alwaysOnTop: true});
122
+ let copyRight = appConfig.name+" version "+appConfig.version+". "+appConfig.copyRight;
123
+ copyRight = encodeURI(copyRight);
124
+ splash.loadURL(`file://${__dirname}/src/splash/index.html?copyRight=${copyRight}`);
125
+ let hasInitWindows = false;
126
+ win.on('show', () => {
127
+ //win.blur();
128
+ setTimeout(() => {
129
+ win.focus();
130
+ win.moveTop();
131
+ win.webContents.focus();
132
+ if(!hasInitWindows){
133
+ hasInitWindows = true;
134
+ win.webContents.send('appReady');
135
+ }
136
+ }, 200);
137
+ });
138
+
139
+ win.on("focus",()=>{
140
+ if(win && hasInitWindows){
141
+ win.webContents.send("main-window-focus");
142
+ }
143
+ });
144
+ win.on("blur",()=>{
145
+ if(win && hasInitWindows){
146
+ win.webContents.send("main-window-blur");
147
+ }
148
+ });
149
+
150
+
151
+ win.once("ready-to-show",function(){
152
+ win.minimize()
153
+ if(splash !== null)splash.destroy();
154
+ splash = null;
155
+ win.restore();
156
+ win.show();
157
+ })
158
+
159
+ win.on('close', (e) => {
160
+ if (win) {
161
+ e.preventDefault();
162
+ win.webContents.send('before-app-exit');
163
+ }
164
+ });
165
+ win.loadFile(path.resolve(path.join(__dirname,"dist",'index.html')))
166
+
167
+ win.on('unresponsive', async () => {
168
+ const { response } = await dialog.showMessageBox({
169
+ title: "L'application a cessé de répondre",
170
+ message : 'Voulez vous relancer l\'application?',
171
+ buttons: ['Relancer', 'Arrêter'],
172
+ cancelId: 1
173
+ })
174
+ if (response === 0) {
175
+ win.forcefullyCrashRenderer()
176
+ win.reload()
177
+ } else {
178
+ win.forcefullyCrashRenderer()
179
+ app.exit();
180
+ }
181
+ })
182
+
183
+ // Ouvre les DevTools.
184
+ win.webContents.openDevTools()
185
+
186
+ // Émit lorsque la fenêtre est fermée.
187
+ win.on('closed', () => {
188
+ win = null
189
+ })
190
+ win.webContents.on('context-menu',clipboadContextMenu);
191
+ win.setMenu(null);
192
+
193
+ /*** les dimenssions de la fenêtre principale */
194
+ let mWindowSessinName = "mainWindowSizes";
195
+ let mWindowPositionSName = mWindowSessinName+"-positions";
196
+ let sizeW = session.get(mWindowSessinName);
197
+ if(!sizeW || typeof sizeW !== 'object'){
198
+ sizeW = {};
199
+ }
200
+ let sPositions = session.get(mWindowPositionSName);
201
+ if(!sPositions || typeof sPositions !=='object'){
202
+ sPositions = {};
203
+ }
204
+ let isNumber = x => typeof x =="number";
205
+ if(isNumber(sizeW.width) && isNumber(sizeW.height)){
206
+ win.setSize(sizeW.width,sizeW.height);
207
+ if(isNumber(sPositions.x) && isNumber(sPositions.y)){
208
+ win.setPosition(sPositions.x,sPositions.y);
209
+ }
210
+ }
211
+ let onWinResizeEv = debounce(function () {
212
+ if(win){
213
+ let wSize = win.getSize();
214
+ if(Array.isArray(wSize) && wSize.length == 2){
215
+ let [width,height] = wSize;
216
+ if(width && height){
217
+ session.set(mWindowSessinName,{width,height});
218
+ }
219
+ let [x,y] = win.getPosition();
220
+ session.set(mWindowPositionSName,{x,y});
221
+ }
222
+ }
223
+ }, 100);
224
+ win.off('resize',onWinResizeEv);
225
+ win.on('resize',onWinResizeEv);
226
+ win.off('move',onWinResizeEv);
227
+ win.on('move',onWinResizeEv);
228
+ }
229
+ let quit = ()=>{
230
+ try {
231
+ app.quit();
232
+ } catch(e){
233
+ console.log(e," triing kit app")
234
+ }
235
+ }
236
+ // Quitte l'application quand toutes les fenêtres sont fermées.
237
+ app.on('window-all-closed', () => {
238
+ // Sur macOS, il est commun pour une application et leur barre de menu
239
+ // de rester active tant que l'utilisateur ne quitte pas explicitement avec Cmd + Q
240
+ if (process.platform !== 'darwin') {
241
+ quit();
242
+ }
243
+ })
244
+
245
+ app.whenReady().then(() => {
246
+ appReady = true;
247
+ createWindow();
248
+ app.on('activate', function () {
249
+ if (win == null || (BrowserWindow.getAllWindows().length === 0)) createWindow()
250
+ });
251
+ })
252
+
253
+ let {ipcMain} = require("electron");
254
+
255
+ ipcMain.on("electron-restart-app",x =>{
256
+ app.relaunch();
257
+ })
258
+ let tray = null;
259
+ let isJSON = function (json_string){
260
+ if(!json_string || typeof json_string != 'string') return false;
261
+ var text = json_string;
262
+ return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(text.replace(/"(\\.|[^"\\])*"/g, '')));
263
+ }
264
+ ipcMain.on("update-system-tray",(event,opts)=>{
265
+ opts = opts && typeof opts == 'object'? opts : {};
266
+ let {contextMenu,tooltip} = opts;
267
+ if(tray){
268
+ } else {
269
+ tray = new Tray(icon? icon : undefined);
270
+ }
271
+ if(!tooltip || typeof tooltip !=="string"){
272
+ tooltip = ""
273
+ }
274
+ tray.setToolTip(tooltip);
275
+ if(isJSON(contextMenu)){
276
+ contextMenu = JSON.parse(contextMenu);
277
+ }
278
+ if(Array.isArray(contextMenu) && contextMenu.length) {
279
+ let tpl = []
280
+ contextMenu.map((m,index)=>{
281
+ if(!m || typeof m !=='object') return;
282
+ m.click = (e)=>{
283
+ if(win && win.webContents) win.webContents.send("click-on-system-tray-menu-item",{
284
+ action : m.action && typeof m.action =='string'? m.action : undefined,
285
+ index,
286
+ menuItem : JSON.stringify(m),
287
+ })
288
+ }
289
+ tpl.push(m);
290
+ })
291
+ contextMenu = Menu.buildFromTemplate(tpl);
292
+ } else contextMenu = null;
293
+ tray.setContextMenu(contextMenu)
294
+ })
295
+ ipcMain.on("electron-get-path",(event,pathName)=>{
296
+ let p = app.getPath(pathName);
297
+ event.returnValue = p;
298
+ return p;
299
+ });
300
+
301
+ ipcMain.on("electron-get-media-access-status",(event,mediaType)=>{
302
+ let p = systemPreferences.getMediaAccessStatus(mediaType);
303
+ event.returnValue = p;
304
+ return p;
305
+ });
306
+
307
+ ipcMain.on("electron-ask-for-media-access",(event,mediaType)=>{
308
+ systemPreferences.askForMediaAccess(mediaType);
309
+ });
310
+
311
+ ipcMain.on("electron-get-app-icon",(event)=>{
312
+ event.returnValue = icon;
313
+ return icon;
314
+ });
315
+
316
+ ipcMain.on('minimize-main-window', () => {
317
+ if(win !== null && win){
318
+ win.blur();
319
+ win.minimize();
320
+ }
321
+ })
322
+ ipcMain.on('restore-main-window', () => {
323
+ if(win && win !== null){
324
+ win.restore()
325
+ win.blur();
326
+ setTimeout(() => {
327
+ win.focus();
328
+ win.moveTop();
329
+ win.webContents.focus();
330
+ }, 200);
331
+ }
332
+ })
333
+ ipcMain.on('close-main-render-process', _ => {
334
+ if(win){
335
+ win.destroy();
336
+ }
337
+ win = null;
338
+ if(typeof gc =="function"){
339
+ gc();
340
+ }
341
+ quit();
342
+ });
343
+
344
+
345
+ function debounce(func, wait, immediate) {
346
+ var timeout;
347
+
348
+ return function executedFunction() {
349
+ var context = this;
350
+ var args = arguments;
351
+
352
+ var later = function() {
353
+ timeout = null;
354
+ if (!immediate) func.apply(context, args);
355
+ };
356
+
357
+ var callNow = immediate && !timeout;
358
+
359
+ clearTimeout(timeout);
360
+
361
+ timeout = setTimeout(later, wait);
362
+
363
+ if (callNow) func.apply(context, args);
364
+ };
365
+ };
366
+ //app.disableHardwareAcceleration();
367
+
368
+
369
+ const gotTheLock = app.requestSingleInstanceLock()
370
+
371
+ if (!gotTheLock) {
372
+ quit()
373
+ } else {
374
+ app.on('second-instance', (event, commandLine, workingDirectory) => {
375
+ // Someone tried to run a second instance, we should focus our window.
376
+ //pour plus tard il sera possible d'afficher la gestion multi fenêtre en environnement electron
377
+ if (win) {
378
+ if (win.isMinimized()) win.restore()
379
+ win.focus()
380
+ }
381
+ })
382
+ }
383
+
384
+ const powerMonitorCallbackEvent = (action)=>{
385
+ if(!win || !win.webContents) return;
386
+ if(action =="suspend" || action =="lock-screen"){
387
+ win.webContents.send("main-app-suspended",action);
388
+ return;
389
+ }
390
+ win.webContents.send("main-app-restaured",action);
391
+ win.webContents.focus();
392
+ return null;
393
+ }
394
+ if(powerMonitor){
395
+ ["suspend","resume","lock-screen","unlock-screen"].map((action)=>{
396
+ powerMonitor.on(action,(event)=>{
397
+ powerMonitorCallbackEvent(action,event);
398
+ })
399
+ })
400
+ }
401
+ ipcMain.on("electron-set-main-window-title",(event,title)=>{
402
+ if(win !== null){
403
+ win.setTitle(title);
404
+ }
405
+ })
406
+
407
+
408
+ ipcMain.handle("electron-create-browser-windows",function(event,options){
409
+ if(!isObj(options)){
410
+ options = {};
411
+ }
412
+ createBrowserWindow(options);
413
+ })
414
+
415
+ ipcMain.handle("electron-show-open-dialog",function(event,options){
416
+ if(!isObj(options)){
417
+ options = {};
418
+ }
419
+ return dialog.showOpenDialog(win,options)
420
+ })
421
+
422
+ ipcMain.handle("electron-show-save-dialog",function(event,options){
423
+ if(!isObj(options)){
424
+ options = {};
425
+ }
426
+ return dialog.showSaveDialog(win,options)
427
+ })
428
+ ipcMain.on("electron-toggle-dev-tools",function(event,value) {
429
+ if(win !==null && win.webContents){
430
+ if(value){
431
+ if(!win.webContents.isDevToolsOpened()) win.webContents.openDevTools();
432
+ } else {
433
+ if(win.webContents.isDevToolsOpened()) win.webContents.closeDevTools();
434
+ }
435
+ }
436
+ })
437
+
438
+ ipcMain.on("electron-window-set-progressbar",(event,interval)=>{
439
+ if(typeof interval !="number" || interval <0) interval = 0;
440
+ interval = Math.floor(interval);
441
+ if(win){
442
+ win.setProgressBar(interval);
443
+ }
444
+ })
445
+
446
+ /**** customisation des thèmes de l'application */
447
+ ipcMain.handle('electron-set-system-theme:toggle', (event,theme) => {
448
+ return setOSTheme(theme);
449
+ });
@@ -0,0 +1,45 @@
1
+ const createExpoWebpackConfigAsync = require('@expo/webpack-config');
2
+ const envManager = require("@expo/webpack-config/env");
3
+ const addons = require("@expo/webpack-config/addons");
4
+ const jsonfile = require('jsonfile');
5
+ const path = require("path");
6
+ const mode = 'development';
7
+ const isObj = x => x && typeof x =='object' && !Array.isArray(x);
8
+ /***@see : https://www.npmjs.com/package/@expo/webpack-config */
9
+ module.exports = async function(env, argv) {
10
+ const projectRoot = process.cwd()
11
+ const electronPath = path.join(projectRoot,'electron');
12
+ env = env || {};
13
+ env.projectRoot = projectRoot;
14
+ env.platform = "electron";//isObj(env.platform)? env.platform : {};//'web'///electron;
15
+ //env.platform.type = "electron";
16
+ env.locations = (0, envManager.getPaths)(projectRoot)
17
+ env.pwa = false;
18
+ let config = (0, addons.withAlias)({}, (0, envManager.getAliases)(projectRoot));
19
+ if(argv && typeof argv =='object' && (argv.mode =='production' || argv.mode =="development")){
20
+ env.mode = argv.mode;
21
+ } else {
22
+ env.mode = mode;
23
+ }
24
+ config = await createExpoWebpackConfigAsync(env, argv);
25
+ config.output = config.output || {};
26
+ config.output.publicPath = "./";
27
+ config.output.path = path.join(electronPath,"dist");
28
+ if (!config.plugins) config.plugins = [];
29
+ if (!config.resolve) config.resolve = {};
30
+ for(let i in config.plugins){
31
+ let pl = config.plugins[i];
32
+ //on recherche le fichier html build de webpack
33
+ if(pl && typeof pl =='object' && pl.options && typeof pl.options =='object'){
34
+ if(typeof pl.options.filename =="string" && pl.options.filename.toLowerCase().includes("index.html")){
35
+ pl.options.filename = path.join(config.output.path,"index.html");
36
+ break;
37
+ }
38
+ }
39
+ }
40
+ //console.log(config.resolve.extensions, "is r extensions")
41
+ config.resolve.extensions = (0, envManager.getModuleFileExtensions)('electron', 'web');
42
+ //jsonfile.writeFileSync("electron/config.back.json", config, {spaces: 4});
43
+ console.log("******electron config file generated**********");
44
+ return config;
45
+ };
@@ -0,0 +1,71 @@
1
+ const path = require('path');
2
+ const dir = path.resolve(__dirname);
3
+ let filePath = path.resolve(dir,"src/help/openLibraries.js")
4
+ let isObj = x => x && typeof x == 'object';
5
+ const fs = require('fs')
6
+ let openLibraries = {};
7
+ function isValidUrl(str) {
8
+ if(!str || typeof str !== 'string') return false;
9
+ var pattern = new RegExp('^(https?:\\/\\/)?'+ // protocol
10
+ '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // domain name
11
+ '((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address
12
+ '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path
13
+ '(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string
14
+ '(\\#[-a-z\\d_]*)?$','i'); // fragment locator
15
+ return !!pattern.test(str);
16
+ }
17
+
18
+ const loopPackages = (packages,_path)=>{
19
+ if(!isObj(packages)) return;
20
+ let p = path.resolve(_path,"node_modules");
21
+ for(let i in packages){
22
+ let packagePath = path.resolve(p,i,"package.json");
23
+ if(fs.existsSync(packagePath)){
24
+ let package = require(packagePath);
25
+ if(!isObj(package) || !package.name) return;
26
+ let op = {};
27
+ openLibraries[package.name] = op;
28
+ if(package.version){
29
+ op.version = package.version;
30
+ }
31
+ if(isValidUrl(package.homepage)){
32
+ op.url = package.homepage
33
+ } else if(isValidUrl(package.repository)) {
34
+ op.url = package.repository;
35
+ } else if(isObj(package.repository) && package.repository.url){
36
+ op.url = package.repository.url;
37
+ }
38
+ if(package.license || package.licence){
39
+ op.license = typeof package.license =="string"? package.license : typeof package.licence =="string"? package.licence : "";
40
+ }
41
+ }
42
+ }
43
+ }
44
+
45
+ const findLicences = (_path)=> new Promise((resolve,reject)=>{
46
+ let pD = path.resolve(_path,"package.json");
47
+ if(fs.existsSync(pD)){
48
+ let packages = require(pD);
49
+ if(isObj(packages)){
50
+ loopPackages(packages.devDependencies,_path);
51
+ loopPackages(packages.dependencies,_path);
52
+ }
53
+ }
54
+ resolve(openLibraries);
55
+ })
56
+ const parentPath = require("./parent-package")();
57
+ Promise.all([
58
+ parentPath ? path.resolve(path.dirname(parentPath)): findLicences(dir),
59
+ ]).then(()=>{
60
+ let s = Object.keys(openLibraries).sort((a,b)=>{
61
+ if (a.toLowerCase() < b.toLowerCase()) return -1;
62
+ if (a.toLowerCase() > b.toLowerCase()) return 1;
63
+ return 0;
64
+ });
65
+ let content = {};
66
+ for(let i in s){
67
+ content[s[i]] = openLibraries[s[i]]
68
+ }
69
+ content = "export default "+JSON.stringify(content);
70
+ fs.writeFileSync(filePath, content)
71
+ });
package/package.json CHANGED
@@ -1,11 +1,45 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "publish": "npm publish --access=public",
8
- "unpublish": "npm -f unpublish @fto-consult/expo-ui"
8
+ "unpublish": "npm -f unpublish @fto-consult/expo-ui",
9
+ "build-web": "",
10
+ "dev": "npx expo start -c --no-minify",
11
+ "start": "npx expo start --dev --no-minify",
12
+ "start-d": "npx expo start -c --no-dev --no-minify",
13
+ "start-p": "npm run start-d",
14
+ "expo-start-client": "npx expo start --dev --no-minify --dev-client",
15
+ "start-m": "npx expo start - c--dev--no -minify",
16
+ "android": "npx expo start --android -c",
17
+ "ios": "npx expo start --ios",
18
+ "web": "npx expo start --web",
19
+ "web-c": "npx expo start --web -c",
20
+ "eject": "expo eject",
21
+ "emulator": "npm run android-emulator",
22
+ "web-server": "npx serve web-build",
23
+ "build-android": "eas build --clear-cache -p android --profile preview",
24
+ "build-android-local": "eas build --platform android --local",
25
+ "build-android-dist": "eas build --clear-cache -p android",
26
+ "build-ios": "eas build --clear-cache -p ios --profile preview",
27
+ "build-ios-dist": "eas build --clear-cache -p ios",
28
+ "install-apk": "adb -s emulator-5554 install myapp.apk",
29
+ "android-emulator": "emulator -avd EMULATOR",
30
+ "flipper": "npx cross-env METRO_SERVER_PORT=19000 E:\\Studies\\react-native\\debugger\\Flipper-win\\Flipper.exe",
31
+ "build-electron": "electron-webpack && electron-builder --dir -c.compression=store",
32
+ "test:build": "electron-webpack && electron-builder --dir -c.compression=store -c.mac.identity=null",
33
+ "compile-electron": "webpack --config ./electron/webpack.config.js",
34
+ "compile-electron-p": "webpack --config ./electron/webpack.config.js --mode=production",
35
+ "electron": "electron ./electron",
36
+ "logcat": "adb -d logcat com.ftc.apps.salite1:E > errors.txt",
37
+ "logcat-export": "adb -d logcat com.ftc.apps.salite1 *:S > logcat.txt",
38
+ "electron-c": "npm run compile-electron && npm run electron",
39
+ "electron-p": "npm run compile-electron-p && npm run electron",
40
+ "update-app-version": "node ./update-app-version.js",
41
+ "find-licenses": "node ./find-licenses.js",
42
+ "fix-dependencies": "expo doctor --fix-dependencies"
9
43
  },
10
44
  "repository": {
11
45
  "type": "git",
@@ -44,6 +78,7 @@
44
78
  "expo-system-ui": "~1.3.0",
45
79
  "expo-web-browser": "~11.0.0",
46
80
  "google-libphonenumber": "^3.2.31",
81
+ "parent-package-json": "^2.0.1",
47
82
  "prop-types": "^15.8.1",
48
83
  "react-content-loader": "^6.2.0",
49
84
  "react-dom": "18.0.0",
@@ -0,0 +1,12 @@
1
+ // Copyright 2022 @fto-consult/Boris Fouomene. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style
3
+ // license that can be found in the LICENSE file.
4
+
5
+ /**** cette fonction a pour rôle de retourner le package parent à celui ci */
6
+ module.export = ()=>{
7
+ const pathToParent = require("parent-package-json"); // Will return false if no parent exists
8
+ if (pathToParent !== false) {
9
+ return pathToParent.path;
10
+ }
11
+ return "";
12
+ }
@@ -0,0 +1,19 @@
1
+ const editJsonFile = require("./edit-json-file.js");
2
+ const fs = require("fs");
3
+ /***** le fichier de configuration doit être stocké dans le repertoire /src/config.js où src est le repertoire source du projet parent qui a installé l'application */
4
+ const run = () => {
5
+ const parentPackage = require("./parent-package")();
6
+ if(!parentPackage) return;
7
+ console.log("before updating parent package version ",parentPackage)
8
+ const srcParent = path.dirname(parentPackage,"src","config.js");
9
+ if(fs.existsSync(srcParent)){
10
+ const appConfig = require(srcParent);
11
+ if(appConfig && typeof appConfig =='object'){
12
+ console.log("updating parent package version ",parentPackage)
13
+ let config = {version:appConfig.version};
14
+ editJsonFile(parentPackage,config);
15
+ }
16
+ }
17
+ }
18
+
19
+ run();