Skip to content

Commit 379e5ab

Browse files
committed
version 0.0.1
1 parent 1cb319f commit 379e5ab

File tree

9 files changed

+249
-206
lines changed

9 files changed

+249
-206
lines changed

Commander/Commands.js

+62-31
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,77 @@
1-
/*
2-
Description: Firebase Command extension for DroidScript
3-
Author(s): D.Hurren, you?
4-
Copyright: droidscript.org
5-
License: Apache V2
6-
*/
1+
/**
2+
* @description
3+
* Commands.js File Recieves Command & Calls It By
4+
* Running Node Instance Of Our node_Firebase.js
5+
* File
6+
*
7+
* @authors
8+
* D. Hurren, O.Koore
9+
*/
710

811
//Make sure node sever is running.
9-
function Init() {
10-
//Start menu server (with unique context id) on first show of 'Firebase' context menu.
11-
if (!glob[ext_progId]) {
12-
var dir = "/sdcard/DroidScript/Extensions/Firebase/Server";
13-
ext_NodeRun(
14-
dir + "/node_Firebase.js",
15-
ext_progId,
16-
dir + "/node_modules",
17-
);
18-
glob[ext_progId] = true;
19-
}
12+
function Init () {
13+
/**
14+
* Start menu server (with unique context id)
15+
* on first show of 'Firebase' context menu.
16+
*/
17+
if( !glob[ext_progId] ) {
18+
var dir = "/sdcard/DroidScript/Extensions/Firebase/Server"
19+
ext_NodeRun( dir+"/node_Firebase.js", ext_progId, dir + "/node_modules" )
20+
glob[ext_progId] = true
21+
} else { ; }
2022
}
2123

22-
//Called when using menus or wifi ide '!firebase' commands.
23-
function Firebase_OnCommand(cmd) {
24-
Init();
24+
// Called when using menus or wifi ide '!firebase' commands.
25+
// Issue Why Does Wifi Ide Call firebase_OnCommand instead
26+
// of Firebase_OnCommand
2527

28+
function Firebase_OnCommand( cmd ) {
29+
Init()
30+
2631
//Execute menu command in our node node_Firebase.js file.
27-
ext_NodeExec(cmd.toLowerCase() + "()", ext_progId);
32+
ext_NodeExec( cmd.toLowerCase()+"()", ext_progId )
2833
}
2934

30-
//Called when 'Firebase' device context menu is selected.
31-
function Firebase_OnMenu() {
32-
Init();
35+
function firebase_OnCommand( cmd ) {
36+
Init()
37+
38+
ext_NodeExec( cmd.toLowerCase()+"()", ext_progId )
39+
}
3340

34-
//Show Firebase sub-menus.
35-
dlgFirebase = app.CreateListDialog("Firebase", "Serv,Deploy");
36-
dlgFirebase.Show();
3741

42+
// Called when 'Firebase' device context menu is selected.
43+
function Firebase_OnMenu() {
44+
Init()
45+
46+
//Show Firebase sub-menus.
47+
dlgFirebase = app.CreateListDialog( "Firebase", "Serv,Deploy" )
48+
dlgFirebase.Show()
49+
3850
//Handle menu selection.
39-
dlgFirebase.SetOnTouch((cmd) => {
51+
dlgFirebase.SetOnTouch( (cmd)=>{
52+
4053
//Show fresh debug window.
41-
app.ShowDebug(true, "dialog,clear");
54+
app.ShowDebug( true, "dialog,clear" )
55+
56+
//Execute menu command in our node node_Firebase.js file.
57+
ext_NodeExec( cmd.toLowerCase()+"()", ext_progId )
58+
})
59+
}
4260

61+
function firebase_OnMenu() {
62+
Init()
63+
64+
//Show Firebase sub-menus.
65+
dlgFirebase = app.CreateListDialog( "Firebase", "Serv,Deploy" )
66+
dlgFirebase.Show()
67+
68+
//Handle menu selection.
69+
dlgFirebase.SetOnTouch( (cmd)=>{
70+
71+
//Show fresh debug window.
72+
app.ShowDebug( true, "dialog,clear" )
73+
4374
//Execute menu command in our node node_Firebase.js file.
44-
ext_NodeExec(cmd.toLowerCase() + "()", ext_progId);
45-
});
75+
ext_NodeExec( cmd.toLowerCase()+"()", ext_progId )
76+
})
4677
}

Commander/Commands.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["firebase deploy", "firebase serv", "firebase login", "firebase list"]
1+
[ "firebase deploy", "firebase serv", "firebase serve", "firebase list", "firebase use" ]

README.md

+74-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,74 @@
1-
# Extension-Firebase
2-
DroidScript Firebase Extension
1+
# DroidScript Firebase Extension
2+
3+
The first thing that you should have is a firebase project, and a node based DroidScript project.
4+
5+
## Firebase Set-up
6+
7+
The next step is to get your firebase key (the config), you should find this in the project settings, copy the config and create the file `firebase.json`.
8+
It should be at the top level of your project, not in a subfolder.
9+
10+
Copy the json in that area, create a file called firebase.json
11+
![](docImages/slide1.png)
12+
13+
In your firebase.json code extend it to include the hosting object, the final thing should look like this :
14+
15+
```json
16+
{
17+
"apiKey": "Something",
18+
"authDomain": "Something.com",
19+
"projectId": "someId",
20+
"storageBucket": "somebucket.appspot.com",
21+
"messagingSenderId": "12345678",
22+
"appId": "2;498u88943u894i",
23+
"measurementId": "Krfhr94893",
24+
"hosting": {
25+
"public": "public",
26+
"ignore": [
27+
"firebase.json",
28+
"**/.*",
29+
"**/node_modules/**"
30+
],
31+
"rewrites": [
32+
{
33+
"source": "**",
34+
"destination": "/index.html"
35+
}
36+
]
37+
}
38+
}
39+
```
40+
41+
The next step is to configure admin access, so move to the DroidScript folder, you should find folders like .edit, Extensions.
42+
43+
In the DroidScript folder add a new folder called `.keys`.
44+
Then add a folder with the same name as your project.
45+
46+
![Folder in DroidScript/.keys](docImages/slide2.png)
47+
48+
In that folder add the file `firebase-key.json`, this file is not the same as the firebase.json file made earlier.
49+
50+
![Firebase Dashboard @ service accounts](docImages/slide3.png)
51+
52+
This file should have the service account json keys, click generate new private key, and a file will be downloaded, copy its contents and create firebase-key.json in the folder.
53+
54+
![Folder in DroidScript/.keys/projectname](docImages/slide4.png)
55+
56+
The last step is to create a public folder and add an index.html file, in your DroidScript project folder.
57+
58+
## Available Commands
59+
60+
1; !firebase deploy
61+
62+
Deploys your project, it will log the url to visit the deployment is the files in the public folder.
63+
64+
2; !firebase serv
65+
66+
It serves you static files in the public folder to port 5000
67+
To visit type in the ip adress provided by DroidScript Wifi Ide, and change the 8088 port to 5000
68+
69+
i.e;
70+
DroidScript Ip is : http://192.168.1.181:8088/ change to : http://192.168.1.181:5000/
71+
72+
3; !firebase list
73+
74+
It lists all your projects.

0 commit comments

Comments
 (0)