@fto-consult/expo-ui 6.19.3 → 6.19.5
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/create-app.js +17 -18
- package/bin/index.js +1 -1
- package/electron/utils/exec.js +24 -6
- package/package.json +1 -1
package/bin/create-app.js
CHANGED
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
const {exec,thowError,copy,writeFile,createDirSync} = require("./utils");
|
|
2
2
|
const fs = require("fs"), path = require("path");
|
|
3
3
|
const createAppDir = path.resolve(__dirname,"create-app");
|
|
4
|
+
const argv = process.argv[2];
|
|
4
5
|
module.exports = function(parsedArgs,{projectRoot}){
|
|
5
6
|
const packageObj = require("../package.json");
|
|
6
7
|
let root = process.cwd(), mainPackagePath = path.resolve(root,"package.json");
|
|
7
8
|
let mainPackage = fs.existsSync(mainPackagePath) && require(`${mainPackagePath}`) || null;
|
|
8
9
|
const name = String(parsedArgs.name||parsedArgs.appName || mainPackage?.name).trim();
|
|
9
10
|
if(!name){
|
|
10
|
-
return thowError(name," nom de l'application invalide, veuillez spécifier un nom d'application valide");
|
|
11
|
+
return thowError(name," nom de l'application invalide, veuillez spécifier un nom d'application valide",argv);
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
+
let hasPackage = !!mainPackage && typeof mainPackage =='object';
|
|
14
|
+
if(!hasPackage){
|
|
15
|
+
mainPackage = {
|
|
16
|
+
name,
|
|
17
|
+
version : "1.0.0",
|
|
18
|
+
"description": "",
|
|
19
|
+
"main": "index.js",
|
|
20
|
+
scripts : {
|
|
21
|
+
start : "npx expo start -c",
|
|
22
|
+
}
|
|
23
|
+
}
|
|
13
24
|
const newDir = createDirSync(path.resolve(root,name.trim()));
|
|
14
25
|
projectRoot = newDir || projectRoot;
|
|
15
26
|
mainPackagePath = path.resolve(projectRoot,"package.json");
|
|
16
27
|
console.log(projectRoot," is new project root ",mainPackage);
|
|
17
28
|
}
|
|
18
|
-
const cb = (
|
|
19
|
-
mainPackage = pkg && typeof pkg =='object' && pkg || mainPackage;
|
|
29
|
+
const cb = ()=>{
|
|
20
30
|
const devDpendencies = packageObj.devDependencies;
|
|
21
31
|
const deps = devDpendencies && typeof devDpendencies =="object" && Object.keys(devDpendencies).join(" ") || "";
|
|
22
32
|
new Promise((resolve,reject)=>{
|
|
23
33
|
console.log("installing dev dependencies ....");
|
|
24
|
-
return exec(`npm i -D @expo/webpack-config @expo/metro-config ${typeof deps=="string" && deps||""}
|
|
34
|
+
return exec(`npm i -D @expo/webpack-config @expo/metro-config ${typeof deps=="string" && deps||""}`,{projectRoot}).then(resolve).catch(reject);
|
|
25
35
|
}).then(()=>{}).finally(()=>{
|
|
26
36
|
console.log("creating application .....");
|
|
27
37
|
createEntryFile(projectRoot);
|
|
@@ -36,20 +46,9 @@ module.exports = function(parsedArgs,{projectRoot}){
|
|
|
36
46
|
process.exit();
|
|
37
47
|
});
|
|
38
48
|
}
|
|
39
|
-
if(!
|
|
40
|
-
mainPackage = {
|
|
41
|
-
name,
|
|
42
|
-
version : "1.0.0",
|
|
43
|
-
"description": "",
|
|
44
|
-
"main": "index.js",
|
|
45
|
-
scripts : {
|
|
46
|
-
start : "npx expo start -c",
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
+
if(!hasPackage){
|
|
49
50
|
writeFile(mainPackagePath,JSON.stringify(mainPackage,null,2));
|
|
50
|
-
exec("npm i @fto-consult/expo-ui").finally(
|
|
51
|
-
return cb(mainPackage);
|
|
52
|
-
});
|
|
51
|
+
exec("npm i @fto-consult/expo-ui",{projectRoot}).finally(cb);
|
|
53
52
|
} else {
|
|
54
53
|
return cb();
|
|
55
54
|
}
|
package/bin/index.js
CHANGED
|
@@ -36,7 +36,7 @@ const script = parsedArgs.script;
|
|
|
36
36
|
* */
|
|
37
37
|
if(parsedArgs.electron){
|
|
38
38
|
if(projectRoot == dir){
|
|
39
|
-
|
|
39
|
+
throwError(`Invalid project root ${projectRoot}; project root must be different to ${dir}`);
|
|
40
40
|
}
|
|
41
41
|
const pathsJSON = path.resolve(electronDir,"paths.json");
|
|
42
42
|
if(!fs.existsSync(pathsJSON)){
|
package/electron/utils/exec.js
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
const exec = require('child_process')
|
|
1
|
+
const {exec,execSync} = require('child_process');
|
|
2
2
|
const fs = require("fs");
|
|
3
|
-
const _exec = (cmd,cmdOpts,logMessages)=>{
|
|
3
|
+
const _exec = (cmd,cmdOpts,logMessages,sync)=>{
|
|
4
4
|
cmdOpts = typeof cmdOpts =='object' && cmdOpts || {};
|
|
5
5
|
cmdOpts.env = typeof cmdOpts.env =="object" && cmdOpts.env || {};
|
|
6
6
|
cmdOpts.env = {...process.env,...cmdOpts.env};
|
|
7
7
|
cmdOpts.env.platform = cmdOpts.env.platform || "electron";
|
|
8
|
+
cmdOpts.stdio = cmdOpts.stdio || "inherit";
|
|
9
|
+
const timer = cmdOpts.loader !==false ? loaderTimer(cmd) : null;
|
|
10
|
+
if(sync){
|
|
11
|
+
try {
|
|
12
|
+
return execSync(cmd,cmdOpts);
|
|
13
|
+
} catch(e){
|
|
14
|
+
clearInterval(timer);
|
|
15
|
+
throw e;
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
8
19
|
return new Promise((resolve,reject)=>{
|
|
9
|
-
const timer = cmdOpts.loader !==false ? loaderTimer(cmd) : null;
|
|
10
20
|
exec(cmd,cmdOpts, (error, stdout, stderr) => {
|
|
11
21
|
if (error) {
|
|
12
22
|
logMessages !== false && console.log(`error: ${error.message}`);;
|
|
@@ -38,7 +48,8 @@ const loaderTimer = function(timout) {
|
|
|
38
48
|
x &= 3;
|
|
39
49
|
}, timout);
|
|
40
50
|
};
|
|
41
|
-
|
|
51
|
+
|
|
52
|
+
const runExec = function(cmdOpts,options,sync){
|
|
42
53
|
if(typeof cmdOpts =='string'){
|
|
43
54
|
cmdOpts = {cmd:cmdOpts};
|
|
44
55
|
}
|
|
@@ -57,5 +68,12 @@ module.exports = function(cmdOpts,options){
|
|
|
57
68
|
return _exec(cmd,cmdOpts,logMessages);
|
|
58
69
|
})
|
|
59
70
|
}
|
|
60
|
-
return _exec(cmd,cmdOpts,logMessages);
|
|
61
|
-
}
|
|
71
|
+
return _exec(cmd,cmdOpts,logMessages,sync);
|
|
72
|
+
}
|
|
73
|
+
module.exports = function(cmdOpts,options){
|
|
74
|
+
return runExec(cmdOpts,options,false);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
module.exports.execSync = module.exports.sync = function(cmdOpts,options){
|
|
78
|
+
return runExec(cmdOpts,options,true);
|
|
79
|
+
}
|