@fto-consult/expo-ui 7.5.45 → 7.6.2

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.
Files changed (49) hide show
  1. package/babel.config.alias.js +1 -19
  2. package/bin/index.js +0 -152
  3. package/bin/update-appex-chart.js +1 -1
  4. package/bin/update-pdfmake.js +1 -1
  5. package/bin/utils.js +1 -1
  6. package/copy-env-file.js +3 -6
  7. package/create-transpile-module-transformer.js +1 -1
  8. package/find-licenses.js +1 -1
  9. package/package.json +3 -4
  10. package/src/screens/Help/openLibraries.js +339 -1
  11. package/bin/init.js +0 -95
  12. package/electron/app/desktopCapturer.js +0 -123
  13. package/electron/app/email.js +0 -55
  14. package/electron/app/file.js +0 -501
  15. package/electron/app/index.html +0 -32
  16. package/electron/app/index.js +0 -19
  17. package/electron/app/instance.js +0 -46
  18. package/electron/create-index-file.js +0 -15
  19. package/electron/dependencies.js +0 -13
  20. package/electron/index.js +0 -560
  21. package/electron/init/index.js +0 -0
  22. package/electron/init/main.js +0 -55
  23. package/electron/init/renderer.js +0 -6
  24. package/electron/is-initialized.js +0 -11
  25. package/electron/pload.js +0 -88
  26. package/electron/preload.js +0 -461
  27. package/electron/tools.js +0 -0
  28. package/electron/utils/config.js +0 -30
  29. package/electron/utils/copy.js +0 -20
  30. package/electron/utils/createDir.js +0 -30
  31. package/electron/utils/createDirSync.js +0 -31
  32. package/electron/utils/debounce.js +0 -19
  33. package/electron/utils/dependencies.js +0 -10
  34. package/electron/utils/env.js +0 -80
  35. package/electron/utils/exec.js +0 -81
  36. package/electron/utils/getDirname.js +0 -14
  37. package/electron/utils/getIcon.js +0 -25
  38. package/electron/utils/index.js +0 -24
  39. package/electron/utils/isBase64.js +0 -14
  40. package/electron/utils/isDataURL.js +0 -13
  41. package/electron/utils/isValidUrl.js +0 -4
  42. package/electron/utils/json.js +0 -57
  43. package/electron/utils/parseArgs.js +0 -21
  44. package/electron/utils/paths.js +0 -11
  45. package/electron/utils/postMessage.js +0 -19
  46. package/electron/utils/replaceAll.js +0 -12
  47. package/electron/utils/session.js +0 -5
  48. package/electron/utils/uniqid.js +0 -33
  49. package/electron/utils/writeFile.js +0 -14
package/electron/pload.js DELETED
@@ -1,88 +0,0 @@
1
- const { machineIdSync} = require('node-machine-id');
2
- const fs = require("fs");
3
- const path = require("path");
4
- module.exports = (ELECTRON,{projectRoot})=>{
5
- const isWin = process.platform === "win32"? true : false;
6
- const isLinux = process.platform === "linux"? true : false;
7
- const {ipcRenderer} = require("electron");
8
- const os = require("os");
9
- let totalRAM = os.totalmem();
10
- if(typeof totalRAM !=="number"){
11
- totalRAM = 0;
12
- }
13
- const getMem = (unit,key)=>{
14
- let memory = 0;
15
- if(typeof os[key] =="function"){
16
- memory = os[key]();
17
- }
18
- if(typeof memory !=="number"){
19
- memory = 0;
20
- }
21
- if(!memory) return 0;
22
- if(typeof unit !=="string") unit = "gb";
23
- switch(unit.toLowerCase()){
24
- case "kb" :
25
- return memory / 1024;
26
- case "mb" :
27
- return memory / (1024 * 1024);
28
- case "gb" :
29
- return memory / (1024 * 1024 * 1024);
30
- }
31
- return memory;
32
- }
33
- const ext = {
34
- toggleDevTools : (value)=>{
35
- ipcRenderer.send("toggle-dev-tools",defaultBool(value,true));
36
- },
37
- gc : x =>{
38
- if(typeof global.gc =='function') return global.gc();
39
- return false;
40
- },
41
- DEVICE : {
42
- computerName : os.hostname(),
43
- operatingSystem : os.type(),
44
- isWindows : isWin,
45
- isLinux,
46
- isMac : process.platform =='darwin'? true : false,
47
- isDarwin : process.platform =='darwin'? true : false,
48
- arch : os.arch(),
49
- totalRAMInGB : totalRAM / (1024 * 1024 * 1024),
50
- getFreeRAM : (unit)=> getMem(unit,"freemem"),
51
- getTotalRAM : (unit)=> getMem(unit,'totalmem')
52
- },
53
- getAutoUpdaterEvents : ()=> [
54
- //'checking-for-update',
55
- 'update-available',
56
- 'update-not-available',
57
- 'error',
58
- 'download-progress',
59
- 'update-downloaded'
60
- ],
61
- };
62
- for(var i in ext){
63
- ELECTRON[i] = ext[i];
64
- }
65
- if(process.env && typeof process.env =="object"){
66
- const logName = process.env["LOGNAME"] || process.env["USER"];
67
- if(logName && typeof logName =="string"){
68
- ELECTRON.DEVICE.computerUserName = logName;
69
- }
70
- }
71
- const uuid = machineIdSync({original: true});
72
- if(uuid && typeof uuid =='string') ELECTRON.DEVICE.uuid = uuid;
73
-
74
- ELECTRON.DEVICE.computerUserName = process.env.SUDO_USER ||
75
- process.env.C9_USER ||
76
- process.env.LOGNAME ||
77
- process.env.USER ||
78
- process.env.LNAME ||
79
- process.env.USERNAME || '';
80
-
81
- const mainRendererPath = path.resolve('processes',"renderer","index.js");
82
- const rendererProcessIndex = projectRoot && fs.existsSync(path.resolve(projectRoot,mainRendererPath)) && path.resolve(projectRoot,mainRendererPath);
83
- //pour étendre les fonctionnalités au niveau du renderer proceess, bien vouloir écrire dans le fichier projectRoot/electron/processes/renderer/index.js
84
- // dans lequel exporter une fonction prenant en paramètre l'objet electron, que l'on peut étendre et le rendre accessible depuis l'application
85
- const rendererProcess = rendererProcessIndex && require(`${rendererProcessIndex}`);
86
- (typeof rendererProcess ==='function') && rendererProcess(ELECTRON);
87
- return ELECTRON;
88
- }
@@ -1,461 +0,0 @@
1
- const createDir = require("./utils/createDir");
2
- const postMessage = require("./utils/postMessage");
3
- const { contextBridge, ipcRenderer, shell } = require('electron')
4
- const appInstance = require("./app/instance");
5
- const path = require("path");
6
- const fs = require("fs");
7
- const isDataURL = require("./utils/isDataURL");
8
- const isBase64 = require("./utils/isBase64");
9
- const isNonNullString = x=>x && typeof x =='string';
10
- require("./utils/replaceAll");
11
- const appName = ipcRenderer.sendSync("get-app-name");
12
- const projectRoot = ipcRenderer.sendSync("get-project-root");
13
- const sanitize = require("sanitize-filename");
14
- const uniqid = require("./utils/uniqid");
15
- if(!appName || typeof appName !=='string'){
16
- console.error("Nom de l'application invalide!! Veuillez spécifier un nom valide d'application ",projectRoot," is electron project root")
17
- }
18
- const APP_NAME = appName?.toUpperCase() || "";
19
- let backupPathField = "_e_backupDataPath";
20
- let cBackupPathField = "company"+backupPathField;
21
- let dbPathField = "_electron_DBPathField";
22
-
23
- const getPath = function(pathName){
24
- if(typeof pathName !=='string' || !pathName) return;
25
- return ipcRenderer.sendSync("get-path",pathName);
26
- }
27
- const APP_PATH = path.join(getPath("appData"),APP_NAME).toLowerCase();
28
- let databasePath = path.join(APP_PATH,"databases");
29
- let ROOT_APP_FOLDER = undefined;
30
- let appBackupPathRef = undefined;
31
- const defaultStr = (...args)=>{
32
- for(let i in args){
33
- if(args[i] && typeof args[i] ==='string') return args[i];
34
- }
35
- return "";
36
- }
37
- const separator = (path.sep)
38
- if(typeof separator != 'string' || !separator){
39
- separator = (()=>{
40
- let filePath = databasePath;
41
- var sepIndex = filePath.lastIndexOf('/');
42
- if(sepIndex == -1){
43
- sepIndex = filePath.lastIndexOf('\\');
44
- }
45
- // include the trailing separator
46
- return filePath.substring(0, sepIndex+1);
47
- })();
48
- }
49
- const Config = require('./utils/config');
50
- let confPath = process.env.ProgramData || process.env.ALLUSERSPROFILE;
51
- if(confPath && typeof confPath =="string"){
52
- if(fs.existsSync(confPath)){
53
- confPath = path.join(confPath,APP_NAME);
54
- if(createDir(confPath)){
55
- ROOT_APP_FOLDER = confPath;
56
- databasePath = path.join(confPath,"databases");
57
- createDir(databasePath);
58
- confPath = path.join(confPath,"CONFIG");
59
- createDir(confPath);
60
- }
61
- } else confPath = undefined;
62
- } else confPath = undefined;
63
- const config = new Config({cwd:confPath});
64
-
65
- const getDatabasePath = ()=>{
66
- const p = config.get(dbPathField);
67
- if(fs.existsSync(p)){
68
- databasePath = p
69
- }
70
- if(!fs.existsSync(databasePath)){
71
- createDir(databasePath);
72
- }
73
- return databasePath;
74
- }
75
- const setDatabasePath = (newPath)=>{
76
- config.set(dbPathField,newPath)
77
- };
78
- const setBackupPath = (newPath)=>{
79
- newPath = typeof newPath =='string' && newPath || typeof ROOT_APP_FOLDER =='string' && ROOT_APP_FOLDER || path.join(getPath("documents"),APP_NAME);
80
- appBackupPathRef = newPath;
81
- config.set(cBackupPathField,appBackupPathRef)
82
- };
83
- const APPRef = {
84
- current : null,
85
- };
86
- ///invoke event name
87
- const ipcInvoke = async (eventName, ...params)=> {
88
- return await ipcRenderer.invoke(eventName, ...params);
89
- }
90
- const validChannels = ["toMain", "myRenderChannel"];
91
- const removeListener = (channel, callback) => {
92
- if (isNonNullString(channel) /*&& validChannels.includes(channel)*/) {
93
- ipcRenderer.removeListener(channel, callback);
94
- }
95
- }, removeAllListeners = (channel) => {
96
- if (isNonNullString(channel) /*&& validChannels.includes(channel)*/) {
97
- ipcRenderer.removeAllListeners(channel)
98
- }
99
- };
100
-
101
- const createWindow = (options)=>{
102
- options = Object.assign({},options);
103
- options.showOnLoad = typeof options.showOnLoad =='boolean'? options.showOnLoad : true;
104
- return ipcRenderer.invoke("create-browser-windows",JSON.stringify(options));
105
- };
106
-
107
- const createPDFFile = (options)=>{
108
- return new Promise((resolve,reject)=>{
109
- const dir = getPath("temp");
110
- options = Object.assign({},options);
111
- let {content,filename,fileName,charset,fileExtension,extension} = options;
112
- fileName = defaultStr(filename,fileName)
113
- if(isDataURL(content)){
114
- content = isDataURL.toBase64(content);
115
- }
116
- if(isBase64(content)){
117
- content = Buffer.from(content,'base64');
118
- } else {
119
- content = null;
120
- }
121
- if(!content){
122
- console.warn('type de contenu invalide!! impression création fichier electron');
123
- return null;
124
- }
125
- fileName = defaultStr(fileName,uniqid("generated-printed-pdf-file-name"))
126
- fileExtension = defaultStr(fileExtension,extension,'pdf').split(".")[0];
127
- charset = defaultStr(charset,'utf-8')
128
- fileName = sanitize(fileName);
129
- if(!fileName.endsWith(`.${fileExtension}`)){
130
- fileName += "."+fileExtension
131
- }
132
- return fs.writeFile(path.join(dir,fileName), content,{charset},(err)=>{
133
- if(!err) {
134
- const p = path.join(dir,fileName);
135
- const fileUrl = 'file://'+p.replaceAll("\\","/");
136
- const filePathUrl = 'file://'+p;
137
- resolve({content,fileName,filename:fileName,path:p,filePathUrl,filePathUri:filePathUrl,fileUrl,filePath:p,fileUri:fileUrl})
138
- } else {
139
- reject(err);
140
- }
141
- })
142
- })
143
- }
144
-
145
-
146
- const ELECTRON = {
147
- get getPouchdb(){
148
- return ({PouchDB,sqlPouch})=> {
149
- window.sqlitePlugin = {openDatabase:require('websql')};
150
- PouchDB.plugin(function CapacitorSqlitePlugin (PouchDB) {
151
- PouchDB.adapter('node-sqlite', sqlPouch(), true)
152
- });
153
- return {adapter:"node-sqlite"};
154
- };
155
- },
156
- get getBackupPath(){
157
- return (p)=>{
158
- const eePath = config.get(cBackupPathField);
159
- const defPath = ROOT_APP_FOLDER || path.join(getPath("documents"),APP_NAME);
160
- appBackupPathRef = typeof eePath =='string' && eePath || typeof defPath =='string' && defPath || '';
161
- if(!fs.existsSync(appBackupPathRef)){
162
- appBackupPathRef = defPath;
163
- }
164
- if(p && typeof (p) ==='string'){
165
- return path.join(appBackupPathRef,p);
166
- }
167
- return appBackupPathRef;
168
- };
169
- },
170
- get databasePath (){
171
- return getDatabasePath();
172
- },
173
- get getDatabasePath(){
174
- return getDatabasePath;
175
- },
176
- set databasePath(dPath){
177
- return setDatabasePath(dPath);
178
- },
179
- get setDatabasePath (){
180
- return setDatabasePath;
181
- },
182
- set backupPath (backupPath){
183
- return setBackupPath(backupPath);
184
- },
185
- get setBackupPath (){
186
- return setBackupPath;
187
- } ,
188
- get CONFIG (){
189
- return config;
190
- },
191
- get showOpenDialog(){
192
- return (options)=>{
193
- options = typeof options =='object' && options && !Array.isArray(options)? options : {};
194
- return ipcRenderer.invoke("show-open-dialog",options);
195
- }
196
- },
197
- get showSaveDialog(){
198
- return (options)=>{
199
- options = typeof options =='object' && options && !Array.isArray(options)? options : {};
200
- return ipcRenderer.invoke("show-save-dialog",options);
201
- };
202
- },
203
- get restartApp(){
204
- return ()=>{
205
- ipcRenderer.sendSync("restart-app")
206
- };
207
- },
208
- get is() {
209
- return true;
210
- },
211
- get APP_PATH(){
212
- return APP_PATH;
213
- },
214
- get initializeAPPInstance(){
215
- return ({APP,notify})=>{
216
- ELECTRON.notify = notify;
217
- ELECTRON.APP = APP;
218
- }
219
- },
220
- get PATH (){
221
- return {
222
- SEPARATOR : separator,
223
- SEP : separator,
224
- get : getPath,
225
- HOME : getPath("home"),
226
- USERDATA : getPath("userData"),
227
- /***
228
- * Per-user application data directory, which by default points to:
229
- * %APPDATA% on Windows
230
- * $XDG_CONFIG_HOME or ~/.config on Linux
231
- * ~/Library/Application Support on macOS
232
- */
233
- APPDATA : getPath("appData"),
234
- CACHE : getPath("cache"),
235
- TEMP : getPath("temp"),//Temporary directory.
236
- EXECUTABLE : getPath("exe"),//The current executable file.
237
- EXE : getPath("exe"),//The current executable file.
238
- DOCUMENTS : getPath("documents"),
239
- DOWNLOADS : path.join(APP_PATH,"downloads"),
240
- DESKTOP : getPath("desktop"),//The current user's Desktop directory.
241
- }
242
- },
243
- ///retourne le chemin dont la chaine de caractère est passé en paramètre
244
- get getPath(){
245
- return getPath;
246
- },
247
- get updateSystemTheme(){
248
- return (theme)=>{
249
- return ipcRenderer.invoke("set-system-theme:toggle",theme);
250
- };
251
- },
252
- get SESSION (){
253
- return {
254
- set : (key,value) =>{
255
- return config.set(key,value);
256
- },
257
- get : (key) =>{
258
- return config.get(key);
259
- }
260
- };
261
- },
262
- get on (){
263
- return (eventName, callback)=> {
264
- console.log(eventName," is evname eee",callback);
265
- return ipcRenderer.on(eventName, callback)
266
- };
267
- },
268
- get shellOpenExternal(){
269
- return async (url)=> {
270
- await shell.openExternal(url)
271
- }
272
- },
273
- get shellOpenPath(){
274
- return async (file)=> {
275
- await shell.openPath(file)
276
- };
277
- },
278
- get shellTrashItem(){
279
- return async (file)=> {
280
- await shell.trashItem(file)
281
- };
282
- },
283
- get trigger (){
284
- return (channel, ...data) => {
285
- if (isNonNullString(channel) /*&& validChannels.includes(channel)*/) {
286
- ipcRenderer.send(channel);
287
- }
288
- };
289
- },
290
- get on (){
291
- return (channel, callback) => {
292
- if (isNonNullString(channel) /*&& validChannels.includes(channel)*/) {
293
- // Filtering the event param from ipcRenderer
294
- const newCallback = (_, data) => callback(data);
295
- ipcRenderer.on(channel, newCallback);
296
- }
297
- };
298
- },
299
- get once (){
300
- return (channel, callback) => {
301
- if (isNonNullString(channel) /*&& validChannels.includes(channel)*/) {
302
- const newCallback = (_, data) => callback(data);
303
- ipcRenderer.once(channel, newCallback);
304
- }
305
- };
306
- },
307
- get removeListener(){
308
- return removeListener;
309
- },
310
- get removeAllListeners(){
311
- return removeAllListeners;
312
- },
313
- get off (){
314
- return removeListener;
315
- },
316
- get offAll(){
317
- return removeAllListeners;
318
- },
319
- get version(){
320
- return process.versions.electron;
321
- },
322
- get isWindowsStore(){
323
- return process.windowsStore;
324
- },
325
- get versions(){
326
- return {
327
- node: () => process.versions.node,
328
- chrome: () => process.versions.chrome,
329
- electron: () => process.versions.electron,
330
- };
331
- },
332
- /****@see : https://www.electronjs.org/docs/latest/tutorial/ipc */
333
- get openFile(){
334
- return () => ipcRenderer.invoke('dialog:openFile');
335
- },
336
- get ping(){
337
- return () => ipcRenderer.invoke('ping');
338
- },
339
- get exitApp (){
340
- return x=>ipcRenderer.send("close-main-render-process");
341
- },
342
- get onGetAppInstance(){
343
- return (APP)=>{
344
- appInstance.set(APP);
345
- }
346
- },
347
- get toggleDevTools(){
348
- return async (toggle)=>{
349
- return await ipcRenderer.send("toggle-dev-tools",toggle);
350
- }
351
- },
352
- get createWindow (){
353
- return createWindow;
354
- },
355
- get createPDFWindow(){
356
- return (options)=>{
357
- options = Object.assign({},options);
358
- options.modal = true;
359
- return createWindow(options);
360
- }
361
- },
362
- get createPDFFile(){
363
- return createPDFFile;
364
- },
365
- get createPdfFile(){
366
- return createPDFFile;
367
- },
368
- createProgressBar : (options)=>{
369
- if(!options || typeof options != 'object' || Array.isArray(options)){
370
- options = {};
371
- }
372
- return //new ProgressBar(options,app);
373
- },
374
- get setTitle(){
375
- return (title) =>{
376
- if(title && typeof title =="string"){
377
- ipcRenderer.send("set-main-window-title",title);
378
- }
379
- };
380
- },
381
- get printPDF (){
382
- return (options)=>{
383
- options = Object.assign({},options);
384
- return createPDFFile(options).then(({path:mainPath,filePathUrl,fileName})=>{
385
- if(fs.existsSync(mainPath)){
386
- const opts = {
387
- file : mainPath,
388
- fileName,
389
- pdfFilePath : mainPath,
390
- showOnLoad : true,
391
- isPDFWindow : true,//spécifie s'il s'agit de la fenêtre pdf
392
- webPreferences: {
393
- plugins: true
394
- }
395
- };
396
- return this.createPDFWindow(opts)
397
- }
398
- })
399
- }
400
- },
401
- get toggleDarkMode(){
402
- return ()=>{
403
- return ipcRenderer.invoke('dark-mode:toggle');
404
- }
405
- },
406
- get setThemeToSystem (){
407
- return ()=>{
408
- return ipcRenderer.invoke('dark-mode:system');
409
- }
410
- },
411
- /***** fait passer le theme au mode dark */
412
- get setThemeToDark(){
413
- return ()=>{
414
- return ipcRenderer.invoke('set-system-theme:dark-mode');
415
- }
416
- },
417
- get setThemeToLight(){
418
- return ()=>{
419
- return ipcRenderer.invoke('set-system-theme:light-mode');
420
- }
421
- },
422
- get appPath(){
423
- return ipcRenderer.sendSync("get-app-path");
424
- }
425
- };
426
-
427
- require("./pload")(ELECTRON,{projectRoot});
428
- ELECTRON.getBackupPath();
429
- //require("./app/index")(ELECTRON)
430
- //require('v8-compile-cache');
431
- //require("v8").setFlagsFromString('--expose_gc');
432
-
433
- ipcRenderer.on('before-app-exit', () => {
434
- return postMessage("BEFORE_EXIT");
435
- });
436
-
437
- ipcRenderer.on("main-app-suspended",()=>{
438
- postMessage({
439
- message : "STOP_IDLE",
440
- });
441
- })
442
- ipcRenderer.on("main-app-restaured",()=>{
443
- postMessage({
444
- message : "TRACK_IDLE",
445
- });
446
- });
447
- ipcRenderer.on('console.log',(event,...message)=>{
448
- console.log(...message);
449
- })
450
- ipcRenderer.on('appReady',()=>{})
451
- ipcRenderer.on("main-window-focus",()=>{
452
- postMessage("WINDOW_FOCUS");
453
- })
454
- ipcRenderer.on("main-window-blur",()=>{
455
- postMessage("WINDOW_BLUR");
456
- });
457
-
458
- process.once('loaded', () => {
459
- contextBridge.exposeInMainWorld('isElectron',true);
460
- contextBridge.exposeInMainWorld('ELECTRON',ELECTRON);
461
- })
package/electron/tools.js DELETED
File without changes
@@ -1,30 +0,0 @@
1
- 'use strict';
2
- const path = require('path');
3
- const electron = require('electron');
4
- const Conf = require('conf');
5
-
6
- class ElectronStore extends Conf {
7
- constructor(options) {
8
- const defaultCwd = "";
9
-
10
- options = options && typeof options == 'object' ? options : {}
11
- options = {
12
- name: 'config',
13
- ...options
14
- };
15
-
16
- if (options.cwd) {
17
- options.cwd = path.isAbsolute(options.cwd) ? options.cwd : path.join(defaultCwd, options.cwd);
18
- } else {
19
- options.cwd = defaultCwd;
20
- }
21
- options.configName = options.name;
22
- delete options.name;
23
- super(options);
24
- }
25
- openInEditor() {
26
- electron.shell.openItem(this.path);
27
- }
28
- }
29
-
30
- module.exports = ElectronStore;
@@ -1,20 +0,0 @@
1
- const fse = require('fs-extra');
2
- const createDir = require("./createDir");
3
- const path = require("path");
4
- /*** copy file or folder using fs-extra : @see : https://github.com/jprichardson/node-fs-extra/blob/HEAD/docs/copy-sync.md */
5
- module.exports = (srcPath,destPath,options)=>{
6
- options = typeof options =='object' && options ? options : {};
7
- options.overwrite = typeof options.overwrite =='boolean'? options.overwrite : true;
8
- return new Promise((resolve,reject)=>{
9
- try {
10
- if(!destPath || !createDir(path.resolve(path.dirname(destPath)))){
11
- throw "Chemin destination invalide!!\n impossible de créer le repertoire destination pour la copie du dossier|fichier(s)";
12
- }
13
- fse.copySync(srcPath, destPath, options);
14
- resolve(destPath);
15
- } catch (err) {
16
- console.error(err)
17
- reject(err);
18
- }
19
- })
20
- }
@@ -1,30 +0,0 @@
1
- const fs = require("fs");
2
- module.exports = function createDir(path,cb) {
3
- if(!path || typeof path !='string') return false;
4
- const p = require("./getDirname")(path);
5
- if(!p) return false;
6
- if(!fs.existsSync(p)){
7
- try {
8
- fs.mkdirSync(p,{ recursive: true});
9
- } catch(e){
10
- if (e.code === 'EEXIST') { // p already exists!
11
- return p;
12
- }
13
- // To avoid `EISDIR` error on Mac and `EACCES`-->`ENOENT` and `EPERM` on Windows.
14
- if (e.code === 'ENOENT') { // Throw the original parentDir error on curDir `ENOENT` failure.
15
- throw new Error(`EACCES: permission denied, mkdir '${path.resolve(p,"..")}'`);
16
- } else {
17
- console.log(e," making write file directory")
18
- }
19
- /*const caughtErr = ['EACCES', 'EPERM', 'EISDIR'].indexOf(e.code) > -1;
20
- if (!caughtErr || caughtErr && curDir === path.resolve(targetDir)) {
21
- throw err; // Throw if it's just the last created dir.
22
- }*/
23
- }
24
- }
25
- const ex = fs.existsSync(p);
26
- if(ex && typeof cb =='function'){
27
- cb(p);
28
- }
29
- return ex ? p : false;
30
- }
@@ -1,31 +0,0 @@
1
- const path = require("path");
2
- const getDirName = require('path').dirname;
3
- const fs = require("fs");
4
- module.exports = function createDirSync(targetDir, { isRelativeToScript = false } = {}) {
5
- if(!targetDir || typeof targetDir != 'string') return false;
6
- const sep = path.sep;
7
- const initDir = path.isAbsolute(targetDir) ? sep : '';
8
- const baseDir = isRelativeToScript ? __dirname : '.';
9
-
10
- return targetDir.split(sep).reduce((parentDir, childDir) => {
11
- const curDir = path.resolve(baseDir, parentDir, childDir);
12
- try {
13
- fs.mkdirSync(curDir);
14
- } catch (err) {
15
- if (err.code === 'EEXIST') { // curDir already exists!
16
- return curDir;
17
- }
18
-
19
- // To avoid `EISDIR` error on Mac and `EACCES`-->`ENOENT` and `EPERM` on Windows.
20
- if (err.code === 'ENOENT') { // Throw the original parentDir error on curDir `ENOENT` failure.
21
- throw new Error(`EACCES: permission denied, mkdir '${parentDir}'`);
22
- }
23
-
24
- const caughtErr = ['EACCES', 'EPERM', 'EISDIR'].indexOf(err.code) > -1;
25
- if (!caughtErr || caughtErr && curDir === path.resolve(targetDir)) {
26
- throw err; // Throw if it's just the last created dir.
27
- }
28
- }
29
- return curDir;
30
- }, initDir);
31
- }
@@ -1,19 +0,0 @@
1
- module.exports = function debounce(func, wait, immediate) {
2
- var timeout;
3
- return function executedFunction(...args) {
4
- var context = this;
5
-
6
- var later = function() {
7
- timeout = null;
8
- if (!immediate) func.apply(context, args);
9
- };
10
-
11
- var callNow = immediate && !timeout;
12
-
13
- clearTimeout(timeout);
14
-
15
- timeout = setTimeout(later, wait);
16
-
17
- if (callNow) func.apply(context, args);
18
- };
19
- };
@@ -1,10 +0,0 @@
1
- module.exports = {
2
- getDependencyVersion : (obj,packageName)=>{
3
- if(!obj || typeof obj !=='object' || !obj?.dependencies) return "";
4
- return obj.dependencies[packageName] || "";
5
- },
6
- getDevDependencyVersion : (obj,packageName)=>{
7
- if(!obj || typeof obj !=='object' || !obj?.devDependencies) return "";
8
- return obj.devDependencies[packageName] || "";
9
- }
10
- }