@fto-consult/expo-ui 6.20.8 → 6.20.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.
- package/bin/create-app.js +15 -15
- package/package.json +1 -1
package/bin/create-app.js
CHANGED
|
@@ -1,24 +1,29 @@
|
|
|
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
|
-
module.exports = function(parsedArgs
|
|
4
|
+
module.exports = function(parsedArgs){
|
|
5
5
|
const argvName = process.argv[3];
|
|
6
6
|
const packageObj = require("../package.json");
|
|
7
|
-
|
|
8
|
-
let mainPackage = fs.existsSync(
|
|
7
|
+
const root = process.cwd();
|
|
8
|
+
let mainPackage = fs.existsSync(path.resolve(root,"package.json")) && require(`${path.resolve(root,"package.json")}`) || null;
|
|
9
9
|
const name = argvName && argvName.trim() || mainPackage?.name && typeof mainPackage?.name=="string" && mainPackage.name.trim() || "";
|
|
10
10
|
if(!name){
|
|
11
11
|
return thowError(name," nom de l'application invalide, veuillez spécifier un nom d'application valide",argvName,process.argv);
|
|
12
12
|
}
|
|
13
13
|
const devDependencies = packageObj.devDependencies;
|
|
14
|
-
|
|
14
|
+
const inSameFolder = typeof mainPackage?.name =="string" && mainPackage?.name.trim().toLowerCase() === name?.toLowerCase().trim();
|
|
15
|
+
const projectRoot = path.join(`${root}/${inSameFolder && name || ""}`);
|
|
16
|
+
createDirSync(projectRoot);
|
|
17
|
+
const mainPackagePath = path.join(projectRoot,"package.json");
|
|
18
|
+
mainPackage = fs.existsSync(mainPackagePath) && require(`${mainPackagePath}`) || null;
|
|
19
|
+
let hasPackage = !!mainPackage;
|
|
15
20
|
const devDeps = {
|
|
16
21
|
...defaultDevDependencies,
|
|
17
22
|
...(devDependencies && typeof devDependencies ==='object'? devDependencies : {}),
|
|
18
23
|
};
|
|
19
24
|
const euModule = "@fto-consult/expo-ui";
|
|
20
25
|
let hasUpdateDeps = false;
|
|
21
|
-
if(!hasPackage
|
|
26
|
+
if(!hasPackage){
|
|
22
27
|
mainPackage = {
|
|
23
28
|
name,
|
|
24
29
|
version : "1.0.0",
|
|
@@ -45,12 +50,8 @@ module.exports = function(parsedArgs,{projectRoot}){
|
|
|
45
50
|
hasUpdateDeps = true;
|
|
46
51
|
mainPackage.dependencies[euModule] = "latest";
|
|
47
52
|
}
|
|
48
|
-
const pRoot = path.resolve(root,name.trim());
|
|
49
|
-
const newDir = createDirSync(pRoot);
|
|
50
|
-
projectRoot = newDir || fs.existsSync(pRoot) & pRoot || projectRoot;
|
|
51
|
-
mainPackagePath = path.resolve(projectRoot,"package.json");
|
|
52
53
|
}
|
|
53
|
-
if(hasUpdateDeps || !hasPackage){
|
|
54
|
+
if(hasUpdateDeps || !hasPackage || !fs.existsSync(mainPackagePath)){
|
|
54
55
|
writeFile(mainPackagePath,JSON.stringify(mainPackage,null,2),{overwrite:true});
|
|
55
56
|
}
|
|
56
57
|
console.log("creating application .....");
|
|
@@ -64,11 +65,10 @@ module.exports = function(parsedArgs,{projectRoot}){
|
|
|
64
65
|
createAPPJSONFile(projectRoot,{...mainPackage,name});
|
|
65
66
|
copy(path.resolve(createAppDir,"src"),path.resolve(projectRoot,"src"),{recursive:true,overwrite:false});
|
|
66
67
|
console.log("intalling dependencies ...");
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
68
|
+
return exec(`npm install`,{projectRoot}).finally(()=>{
|
|
69
|
+
console.log("application ready");
|
|
70
|
+
process.exit();
|
|
71
|
+
});
|
|
72
72
|
}
|
|
73
73
|
const defaultDevDependencies = {
|
|
74
74
|
"@expo/webpack-config":"latest",
|