@edgedev/create-edge-app 1.0.16 → 1.0.18
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/cli.js +1 -61
- package/firebase_init.sh +40 -2
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
console.log('Script started')
|
|
3
3
|
const { execSync } = require('child_process')
|
|
4
|
-
const fs = require('fs')
|
|
5
|
-
const readline = require('readline')
|
|
6
4
|
|
|
7
5
|
const runCommand = (command) => {
|
|
8
6
|
try {
|
|
@@ -16,58 +14,6 @@ const runCommand = (command) => {
|
|
|
16
14
|
return true
|
|
17
15
|
}
|
|
18
16
|
|
|
19
|
-
const promptForProjectId = () => {
|
|
20
|
-
const rl = readline.createInterface({
|
|
21
|
-
input: process.stdin,
|
|
22
|
-
output: process.stdout,
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
return new Promise((resolve, reject) => {
|
|
26
|
-
rl.question('Please enter your Firebase project ID: ', (projectId) => {
|
|
27
|
-
rl.close()
|
|
28
|
-
resolve(projectId)
|
|
29
|
-
})
|
|
30
|
-
})
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const initializeFirebase = async (projectId, repoName) => {
|
|
34
|
-
if (!projectId) {
|
|
35
|
-
console.error('Error: Firebase project ID cannot be empty.')
|
|
36
|
-
process.exit(1)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
execSync('firebase --version', { stdio: 'inherit' })
|
|
41
|
-
}
|
|
42
|
-
catch (err) {
|
|
43
|
-
console.error('Firebase CLI could not be found. Please install it and try again.')
|
|
44
|
-
process.exit(1)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const pathToFirebaseJson = `${repoName}/firebase.json`
|
|
48
|
-
const pathToFirestoreRules = `${repoName}/firestore.rules`
|
|
49
|
-
|
|
50
|
-
if (fs.existsSync(pathToFirebaseJson)) {
|
|
51
|
-
fs.renameSync(pathToFirebaseJson, `${pathToFirebaseJson}.temp`)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (fs.existsSync(pathToFirestoreRules)) {
|
|
55
|
-
fs.renameSync(pathToFirestoreRules, `${pathToFirestoreRules}.temp`)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
console.log(`Initializing Firebase for ${repoName}...`)
|
|
59
|
-
runCommand(`cd ${repoName} && firebase use --add ${projectId} --alias default`)
|
|
60
|
-
runCommand(`cd ${repoName} && firebase init firestore functions hosting storage emulators --project default`)
|
|
61
|
-
|
|
62
|
-
if (fs.existsSync(`${pathToFirebaseJson}.temp`)) {
|
|
63
|
-
fs.renameSync(`${pathToFirebaseJson}.temp`, pathToFirebaseJson)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (fs.existsSync(`${pathToFirestoreRules}.temp`)) {
|
|
67
|
-
fs.renameSync(`${pathToFirestoreRules}.temp`, pathToFirestoreRules)
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
17
|
const repoName = process.argv[2]
|
|
72
18
|
const gitCheckoutCommand = `git clone --depth 1 https://github.com/Edge-Marketing-and-Design/edgeApp.git ${repoName}`
|
|
73
19
|
const installDependenciesCommand = `cd ${repoName} && pnpm install`
|
|
@@ -92,10 +38,4 @@ if (!installedFunctionDeps) {
|
|
|
92
38
|
}
|
|
93
39
|
|
|
94
40
|
console.log(`Successfully created ${repoName}!`)
|
|
95
|
-
|
|
96
|
-
const main = async () => {
|
|
97
|
-
const projectId = await promptForProjectId()
|
|
98
|
-
await initializeFirebase(projectId, repoName)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
main()
|
|
41
|
+
console.log(`cd into ${repoName} and run 'sh firebase_init.sh' to initialize your firebase project.`)
|
package/firebase_init.sh
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
# Prompt for the
|
|
1
|
+
# Prompt for the Firebase configuration values
|
|
2
2
|
echo "Please enter your Firebase project ID:"
|
|
3
3
|
read project_id
|
|
4
|
+
echo "Please enter your Firebase API key:"
|
|
5
|
+
read api_key
|
|
6
|
+
echo "Please enter your Firebase Auth domain:"
|
|
7
|
+
read auth_domain
|
|
8
|
+
echo "Please enter your Firebase storage bucket:"
|
|
9
|
+
read storage_bucket
|
|
10
|
+
echo "Please enter your Firebase messaging sender ID:"
|
|
11
|
+
read messaging_sender_id
|
|
12
|
+
echo "Please enter your Firebase app ID:"
|
|
13
|
+
read app_id
|
|
14
|
+
echo "Please enter your Firebase measurement ID:"
|
|
15
|
+
read measurement_id
|
|
4
16
|
|
|
5
17
|
# Check if project_id is empty
|
|
6
18
|
if [ -z "$project_id" ]; then
|
|
@@ -36,4 +48,30 @@ fi
|
|
|
36
48
|
# Restore firestore.rules from backup
|
|
37
49
|
if [ -f ./firestore.rules.temp ]; then
|
|
38
50
|
mv ./firestore.rules.temp ./firestore.rules
|
|
39
|
-
fi
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
# Create the .env file
|
|
54
|
+
echo "VITE_FIREBASE_API_KEY=$api_key" > .env
|
|
55
|
+
echo "VITE_FIREBASE_AUTH_DOMAIN=$auth_domain" >> .env
|
|
56
|
+
echo "VITE_FIREBASE_PROJECT_ID=$project_id" >> .env
|
|
57
|
+
echo "VITE_FIREBASE_STORAGE_BUCKET=$storage_bucket" >> .env
|
|
58
|
+
echo "VITE_FIREBASE_MESSAGING_SENDER_ID=$messaging_sender_id" >> .env
|
|
59
|
+
echo "VITE_FIREBASE_APP_ID=$app_id" >> .env
|
|
60
|
+
echo "VITE_FIREBASE_MEASUREMENT_ID=$measurement_id" >> .env
|
|
61
|
+
echo "VITE_FIREBASE_EMULATOR_AUTH=" >> .env
|
|
62
|
+
echo "VITE_FIREBASE_EMULATOR_FIRESTORE=" >> .env
|
|
63
|
+
echo "VITE_FIREBASE_EMULATOR_FUNCTIONS=" >> .env
|
|
64
|
+
echo "REGISTRATION_CODE=organization-registration-template" >> .env
|
|
65
|
+
|
|
66
|
+
# Create the .env.dev file
|
|
67
|
+
echo "VITE_FIREBASE_API_KEY=$api_key" > .env.dev
|
|
68
|
+
echo "VITE_FIREBASE_AUTH_DOMAIN=$auth_domain" >> .env.dev
|
|
69
|
+
echo "VITE_FIREBASE_PROJECT_ID=$project_id" >> .env.dev
|
|
70
|
+
echo "VITE_FIREBASE_STORAGE_BUCKET=$storage_bucket" >> .env.dev
|
|
71
|
+
echo "VITE_FIREBASE_MESSAGING_SENDER_ID=$messaging_sender_id" >> .env.dev
|
|
72
|
+
echo "VITE_FIREBASE_APP_ID=$app_id" >> .env.dev
|
|
73
|
+
echo "VITE_FIREBASE_MEASUREMENT_ID=$measurement_id" >> .env.dev
|
|
74
|
+
echo "VITE_FIREBASE_EMULATOR_AUTH=9099" >> .env.dev
|
|
75
|
+
echo "VITE_FIREBASE_EMULATOR_FIRESTORE=8080" >> .env.dev
|
|
76
|
+
echo "VITE_FIREBASE_EMULATOR_FUNCTIONS=5001" >> .env.dev
|
|
77
|
+
echo "REGISTRATION_CODE=organization-registration-template" >> .env.dev
|