@fto-consult/expo-ui 6.18.13 → 6.18.15
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/babel.config.js +10 -0
- package/bin/create-app/metro.config.js +1 -0
- package/bin/create-app/registerApp.js +22 -0
- package/bin/create-app/webpack.config.js +1 -0
- package/bin/create-app.js +30 -3
- package/bin/index.js +5 -12
- package/bin/utils.js +11 -0
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
module.exports = function(api) {
|
|
2
|
+
const alias = {
|
|
3
|
+
//your custom module resolver alias, @see : https://www.npmjs.com/package/babel-plugin-module-resolver
|
|
4
|
+
}
|
|
5
|
+
return require("@fto-consult/expo-ui/babel.config")(api,{
|
|
6
|
+
base :dir,
|
|
7
|
+
alias,
|
|
8
|
+
withPouchDB:false,//toggle support of pouchdb database,
|
|
9
|
+
})
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("@fto-consult/expo-ui/metro.config.js");
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import registerApp from "$expo-ui-root-path";
|
|
2
|
+
registerApp({
|
|
3
|
+
navigation : {
|
|
4
|
+
screens : [],//all application screeens
|
|
5
|
+
drawerItems : [], //application main drawer items
|
|
6
|
+
},
|
|
7
|
+
components : {//application components
|
|
8
|
+
logo : null,//logo component's properties
|
|
9
|
+
loginPropsMutator : {},//login props mutator
|
|
10
|
+
},
|
|
11
|
+
init : function({appConfig}){ //for application initialization
|
|
12
|
+
return Promise.resolve('appInitialized');
|
|
13
|
+
},
|
|
14
|
+
onMount : function(){ //when main application component is mounted
|
|
15
|
+
|
|
16
|
+
},
|
|
17
|
+
onUnmount : function(){ //when main application component is unmounted
|
|
18
|
+
},
|
|
19
|
+
onRender : function(){
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("@fto-consult/expo-ui/webpack.config.js");
|
package/bin/create-app.js
CHANGED
|
@@ -1,19 +1,46 @@
|
|
|
1
1
|
|
|
2
2
|
const fs = require("fs");
|
|
3
3
|
const path = require("path");
|
|
4
|
-
|
|
4
|
+
const {exec,thowError,writeFile} = require("./utils");
|
|
5
|
+
const fs = require("fs"), path = require("path");
|
|
6
|
+
module.exports = function(parsedArgs,{projectRoot}){
|
|
5
7
|
const packageObj = require("../package.json");
|
|
6
8
|
const root = process.cwd(), mainPackagePath = path.resolve(root,"package.json");
|
|
7
9
|
const mainPackage = fs.existsSync(mainPackagePath) && require(`${mainPackagePath}`) || null;
|
|
10
|
+
if(!mainPackage || !mainPackage.name){
|
|
11
|
+
thowError("Nom de l'application invalide. Rassurez vous d'exécuter l'application dans un répertoire valide."," package : ",mainPackage);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const name = String(parsedArgs.name||mainPackage.name).trim();
|
|
15
|
+
if(name){
|
|
16
|
+
thowError(name," nom de l'application invalide, veuillez spécifier un nom d'application valide");
|
|
17
|
+
}
|
|
8
18
|
const devDpendencies = packageObj.devDependencies;
|
|
9
19
|
const deps = devDpendencies && typeof devDpendencies =="object" && Object.keys(devDpendencies).join(" ");
|
|
10
20
|
new Promise((resolve,reject)=>{
|
|
11
21
|
if(typeof deps =="string" && deps){
|
|
12
|
-
console.log("installing dev dependencies
|
|
22
|
+
console.log("installing dev dependencies ....");
|
|
13
23
|
return exec(`npm i -D ${deps}`).then(resolve).catch(reject);
|
|
14
24
|
}
|
|
15
25
|
return resolve({});
|
|
16
26
|
}).then(()=>{
|
|
17
|
-
|
|
27
|
+
console.log("creating application .....");
|
|
28
|
+
createEntryFile();
|
|
29
|
+
[path.join(projectRoot,"babel.config.js"),path.join(projectRoot,"metro.config.js"),path.join(projectRoot,"webpack.js")].map((p)=>{
|
|
30
|
+
if(!fs.existsSync(p)){
|
|
31
|
+
const file = path.basename(p);
|
|
32
|
+
writeFile(p,fs.readFileSync(`./${file}`));
|
|
33
|
+
}
|
|
34
|
+
});
|
|
18
35
|
}).finally(process.exit);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const createEntryFile = (projectRoot)=>{
|
|
39
|
+
const mainEntry = path.join(projectRoot,"index.js");
|
|
40
|
+
if(!fs.existsSync(mainEntry)){
|
|
41
|
+
console.log("creating main entry ...");
|
|
42
|
+
writeFile(mainEntry,fs.readFileSync(path.resolve("./create-app/registerApp.js")));
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
19
46
|
}
|
package/bin/index.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
toujours ajouter l'instruction ci-dessus à la première ligne de chaque script npx
|
|
4
|
+
@see : https://blog.shahednasser.com/how-to-create-a-npx-tool/ */
|
|
3
5
|
'use strict';
|
|
4
6
|
process.on('unhandledRejection', err => {
|
|
5
7
|
throw err;
|
|
6
8
|
});
|
|
7
|
-
const throwError = (...args)=>{
|
|
8
|
-
console.error(...args);
|
|
9
|
-
process.exit(-1);
|
|
10
|
-
}
|
|
11
9
|
const createAppScript = "create-app";
|
|
12
10
|
const supportedScript = {
|
|
13
11
|
"init" : true, //initialize electron app
|
|
@@ -16,19 +14,14 @@ const supportedScript = {
|
|
|
16
14
|
"package" : true, ///script pour le packagin de l'application
|
|
17
15
|
[createAppScript] : true,//les script de création de l'application
|
|
18
16
|
}
|
|
19
|
-
const
|
|
20
|
-
const writeFile = require("../electron/utils/writeFile");
|
|
21
|
-
const copy = require("../electron/utils/copy");
|
|
17
|
+
const {createDir,writeFile,electronDir,copy,exec,throwError} = require("./utils");
|
|
22
18
|
const path= require("path");
|
|
23
19
|
const fs = require("fs");
|
|
24
20
|
const dir = path.resolve(__dirname);
|
|
25
|
-
const electronDir = path.resolve(dir, "..","electron");
|
|
26
|
-
const exec = require("../electron/utils/exec");
|
|
27
21
|
const projectRoot = path.resolve(process.cwd());
|
|
28
22
|
if(projectRoot == dir){
|
|
29
23
|
throwError(`Invalid project root ${projectRoot}; project root must be different to ${dir}`);
|
|
30
24
|
}
|
|
31
|
-
|
|
32
25
|
const parsedArgs = require("../electron/utils/parseArgs")(null,supportedScript);
|
|
33
26
|
parsedArgs.script = typeof parsedArgs.script =='string' && parsedArgs.script && parsedArgs.script.toLowerCase().trim() || "";
|
|
34
27
|
if(!parsedArgs.script || !(parsedArgs.script in supportedScript)){
|
|
@@ -157,7 +150,7 @@ if(parsedArgs.electron){
|
|
|
157
150
|
} else {
|
|
158
151
|
if(script ===createAppScript){
|
|
159
152
|
console.log(createAppScript," is script ",parsedArgs," is parse arrrrrr");
|
|
160
|
-
return require("./create-app")(parsedArgs,{
|
|
153
|
+
return require("./create-app")(parsedArgs,{projectRoot});
|
|
161
154
|
}
|
|
162
155
|
process.exit();
|
|
163
156
|
}
|
package/bin/utils.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
createDir : require("../electron/utils/createDir"),
|
|
3
|
+
writeFile : require("../electron/utils/writeFile"),
|
|
4
|
+
copy : require("../electron/utils/copy"),
|
|
5
|
+
electronDir : path.resolve(dir, "..","electron"),
|
|
6
|
+
exec : require("../electron/utils/exec"),
|
|
7
|
+
thowError : (...args)=>{
|
|
8
|
+
console.error(...args);
|
|
9
|
+
process.exit(-1);
|
|
10
|
+
},
|
|
11
|
+
}
|