@@ -255,6 +255,7 @@ export default {
255
255
256
256
if (componentName === " App" ) {
257
257
str += ` <div id="app">\n\t\t <div id="nav">\n ` ;
258
+
258
259
for (let route in routes) {
259
260
if (route === " HomeView" ) {
260
261
str += ` \t\t\t <router-link to="/" class = "componentLinks">${ route} </router-link>\n ` ;
@@ -277,6 +278,7 @@ export default {
277
278
let childNameClassFullStr = (childNameClass === " " ) ? " " : ` class = '${ childNameClass} '` ;
278
279
routeStr += ` <${ childName}${ childNameClassFullStr} ></${ childName} >\n `
279
280
});
281
+
280
282
return ` <template>\n <div id = "${ componentName} ">\n ${ templateTagStr}${ routeStr} \t </div>\n </template>` ;
281
283
}
282
284
@@ -287,19 +289,29 @@ export default {
287
289
let compClass = (this .routes .hasOwnProperty (componentName)) ? componentName : this .componentMap [componentName].htmlAttributes .class ;
288
290
289
291
if (compClass !== " " && compID !== " " ) {
292
+
293
+ if (this .$store .state .exportOauth === ' on' || this .$store .state .exportOauthGithub === ' on' ){
294
+ return ` <template>\n <div id = "${ compID} " class = "${ compClass} ">\n ${ templateTagStr}${ routeStr} </div>\n <Oauth/>\n </template>` ;
295
+ }
290
296
return ` <template>\n <div id = "${ compID} " class = "${ compClass} ">\n ${ templateTagStr}${ routeStr} </div>\n </template>` ;
291
297
}
292
298
else if (compClass !== " " && compID === " " ) {
299
+ if (this .$store .state .exportOauth === ' on' || this .$store .state .exportOauthGithub === ' on' ){
300
+ return ` <template>\n <div class = "${ compClass} ">\n ${ templateTagStr}${ routeStr} </div>\n <Oauth/>\n </template>` ;
301
+ }
293
302
return ` <template>\n <div class = "${ compClass} ">\n ${ templateTagStr}${ routeStr} </div>\n </template>` ;
294
303
}
295
304
else if (compClass === " " && compID !== " " ) {
305
+ if (this .$store .state .exportOauth === ' on' || this .$store .state .exportOauthGithub === ' on' ){return ` <template>\n <div id = "${ compID} ">\n ${ templateTagStr}${ routeStr} </div>\n <Oauth/>\n </template>` ;}
296
306
return ` <template>\n <div id = "${ compID} ">\n ${ templateTagStr}${ routeStr} </div>\n </template>` ;
297
307
}
298
308
else {
309
+ if (this .$store .state .exportOauth === ' on' || this .$store .state .exportOauthGithub === ' on' ){return ` <template>\n <div>\n\t ${ str}${ templateTagStr}${ routeStr} </div>\n <Oauth/>\n </template>` ;}
299
310
return ` <template>\n <div>\n\t ${ str}${ templateTagStr}${ routeStr} </div>\n </template>` ;
300
311
}
301
312
}
302
313
else {
314
+ if (this .$store .state .exportOauth === ' on' || this .$store .state .exportOauthGithub === ' on' ){return ` <template>\n\t ${ str}${ templateTagStr}${ routeStr} </div>\n <Oauth/>\n </template>` }
303
315
return ` <template>\n\t ${ str}${ templateTagStr}${ routeStr} </div>\n </template>`
304
316
}
305
317
},
@@ -378,12 +390,22 @@ export default {
378
390
let output;
379
391
if (this .exportAsTypescript === " on" ) {
380
392
output = " \n\n <script lang='ts'>\n " ;
393
+ if (this .$store .state .exportOauth === ' on' || this .$store .state .exportOauthGithub === ' on' ){
394
+ output+= ` import Oauth from '../components/oauth.vue';`
395
+ }
381
396
output += imports + " \n export default defineComponent ({\n name: '" + componentName + " '" ;
382
397
} else {
383
398
output = " \n\n <script>\n " ;
399
+ if (this .$store .state .exportOauth === ' on' || this .$store .state .exportOauthGithub === ' on' ){
400
+ output+= ` import Oauth from '../components/oauth.vue';`
401
+ }
384
402
output += imports + " \n export default {\n name: '" + componentName + " '" ;
403
+
385
404
}
386
405
output += " ,\n components: {\n " ;
406
+ if (this .$store .state .exportOauth === ' on' || this .$store .state .exportOauthGithub === ' on' ){
407
+ output+= ` Oauth,`
408
+ }
387
409
output += childrenComponentNames + " },\n " ;
388
410
output += data;
389
411
output += computed;
@@ -431,17 +453,12 @@ export default {
431
453
return str
432
454
}
433
455
},
434
- /**
435
- * @description writes the <style> in vue component for all components in Canvas
436
- * Do not update code styling. Lack of styling is intentional to properly export the styling string.
437
- */
438
- /* UPDATE THIS TO GRAB INFORMATION FROM this.componentMap NOT this.routes*/
439
- /* this.componentMap does not have x-y positioning stored */
440
456
writeStyle (componentName ) {
441
457
let htmlArray = this .componentMap [componentName].htmlList ;
442
458
let styleString = " " ;
443
459
console .log (componentName);
444
460
// Add grid css property to view component div
461
+ if (this .routes )
445
462
// adds view component id grid style and adds child component css styling
446
463
if (this .routes .hasOwnProperty (componentName)) {
447
464
styleString += ` #${ componentName} {\n\t display: grid; \n\t grid-template-columns: repeat(${ this .gridLayout [0 ]} , 1fr);\n\t grid-template-rows: repeat(${ this .gridLayout [1 ]} , 1fr);\n\t grid-column-gap: 0px;\n\t grid-row-gap: 0px;\n }\n ` ;
@@ -469,14 +486,112 @@ export default {
469
486
.router-view {
470
487
margin:auto;
471
488
background-color: gray;
472
- height: 720px;
473
- width: 1280px;
474
489
}
475
490
</style >`
476
491
} else return ` \n\n <style scoped>\n ${ styleString} </style >` ;
477
492
},
493
+ createFirebaseConfigFile (location ) {
494
+ if (this .$store .state .exportOauth === ' on' ){
495
+ let str = ` import { initializeApp } from 'firebase/app';` ;
496
+ str += ` \n\t const firebaseConfig = {` ;
497
+ str += ` \n\t apiKey: "AIzaSyBR4o9xj4LtDaZ37-mC-FqRQWaz67_9Fq0",` ;
498
+ str += ` \n\t authDomain: "oauth-74279.firebaseapp.com",` ;
499
+ str += ` \n\t projectId: "oauth-74279",` ;
500
+ str += ` \n\t storageBucket: "oauth-74279.appspot.com",` ;
501
+ str += ` \n\t messagingSenderId: "91801023441",` ;
502
+ str += ` \n\t appId: "1:91801023441:web:4d923f26f5ce9c7384e6f0",` ;
503
+ str += ` \n\t measurementId: "G-ZZQMS6RRWR"` ;
504
+ str += ` \n };` ;
505
+ str += ` \n const firebaseApp = initializeApp(firebaseConfig);` ;
506
+ str += ` \n export default firebaseApp` ;
478
507
479
- // creates index html
508
+ fs .writeFileSync (path .join (location, " firebaseConfig.js" ), str);
509
+ }
510
+ },
511
+ createOauthFile (location ){
512
+ if (this .$store .state .exportOauth === ' on' || this .$store .state .exportOauthGithub === ' on' ){
513
+ let str = ` <template>` ;
514
+ str += ` \n\t <!-- you can see the username when you log in -->` ;
515
+ str += ` \n\t <h1 v-if="user">Username: {{ user }}</h1>` ;
516
+ str += ` \n\t <div id="logout" v-if="isSignedIn">` ;
517
+ str += ` \n\t\t <button @click="handleSignOut">logout</button>` ;
518
+ str += ` \n\t </div>` ;
519
+ if (this .$store .state .exportOauth === ' on' ){
520
+ str += ` \n\t <div id="GoogleSignIn" v-if="!isSignedIn">` ;
521
+ str += ` \n\t\t <h3>Google Signin</h3>` ;
522
+ str += ` \n\t\t <button @click="handleSignInGoogle">login</button>` ;
523
+ str += ` \n\t </div>` ;
524
+ }
525
+
526
+ if (this .$store .state .exportOauthGithub === ' on' ){
527
+ str += ` \n\t <div id="GitHubSignIn" v-if="!isSignedIn">` ;
528
+ str += ` \n\t\t <h3>GitHub Signin</h3>` ;
529
+ str += ` \n\t\t <button @click="handleSignInGitHub">login</button>` ;
530
+ str += ` \n\t </div>` ;
531
+ }
532
+
533
+ str += ` \n </template>` ;
534
+ str += ` \n\n <script>` ;
535
+ str += ` \n import firebaseConfig from '../../firebaseConfig';` ;
536
+ str += ` \n import { getAuth, signInWithPopup, signOut, GoogleAuthProvider, TwitterAuthProvider, GithubAuthProvider } from "firebase/auth";` ;
537
+ str += ` \n firebaseConfig` ;
538
+ if (this .$store .state .exportOauth === ' on' ){
539
+ str += ` \n const provider = new GoogleAuthProvider();` ;
540
+ }
541
+ if (this .$store .state .exportOauthGithub === ' on' ){
542
+ str += ` \n const providerGithub = new GithubAuthProvider();` ;
543
+ }
544
+ str += ` \n const auth = getAuth();` ;
545
+ str += ` \n\n export default {` ;
546
+ str += ` \n\t name: 'OauthComponent',` ;
547
+ str += ` \n\t props: {` ;
548
+ str += ` \n\t },` ;
549
+ str += ` \n\t data() {` ;
550
+ str += ` \n\t\t return {` ;
551
+ str += ` \n\t\t\t user: '',` ;
552
+ str += ` \n\t\t\t isSignedIn: false,` ;
553
+ str += ` \n\t\t }` ;
554
+ str += ` \n\t },` ;
555
+ str += ` \n\t methods: {` ;
556
+ if (this .$store .state .exportOauth === ' on' ){
557
+ str += ` \n\t\t handleSignInGoogle() {` ;
558
+ str += ` \n\t\t\t signInWithPopup(auth, provider)` ;
559
+ str += ` \n\t\t\t\t .then((result) => { ` ;
560
+ str += ` \n\t\t\t\t\t this.user = result.user.displayName;` ;
561
+ str += ` \n\t\t\t\t\t this.isSignedIn = true;` ;
562
+ str += ` \n\t\t\t\t }).catch((error) => {` ;
563
+ str += ` \n\t\t\t\t\t console.log(error);` ;
564
+ str += ` \n\t\t\t\t });` ;
565
+ str += ` \n\t\t },` ;
566
+ }
567
+ if (this .$store .state .exportOauthGithub === ' on' ){
568
+ str += ` \n\t\t handleSignInGitHub() {` ;
569
+ str += ` \n\t\t\t signInWithPopup(auth, providerGithub)` ;
570
+ str += ` \n\t\t\t\t .then((result) => { ` ;
571
+ str += ` \n\t\t\t\t\t this.user = result.user.displayName;` ;
572
+ str += ` \n\t\t\t\t\t this.isSignedIn = true;` ;
573
+ str += ` \n\t\t\t\t }).catch((error) => {` ;
574
+ str += ` \n\t\t\t\t\t console.log(error);` ;
575
+ str += ` \n\t\t\t\t });` ;
576
+ str += ` \n\t\t },` ;
577
+ }
578
+
579
+ str += ` \n\t\t handleSignOut() {` ;
580
+ str += ` \n\t\t\t signOut(auth).then(() => {` ;
581
+ str += ` \n\t\t\t\t\t this.user = ''; ` ;
582
+ str += ` \n\t\t\t\t\t this.isSignedIn = false;` ;
583
+ str += ` \n\t\t\t\t }).catch((error) => {` ;
584
+ str += ` \n\t\t\t\t\t console.log(error);` ;
585
+ str += ` \n\t\t\t\t });` ;
586
+ str += ` \n\t\t }` ;
587
+ str += ` \n\t }` ;
588
+ str += ` \n }` ;
589
+ str += ` \n <\/ script>` ;
590
+ str += ` \n <style scoped>` ;
591
+ str += ` \n </style>` ;
592
+ fs .writeFileSync (path .join (location," src" ," components" ," oauth.vue" ), str);
593
+ }
594
+ },
480
595
createIndexFile (location ) {
481
596
let str = ` <!DOCTYPE html>\n <html lang="en">\n\n <head>` ;
482
597
str += ` \n\t <meta charset="utf-8">` ;
@@ -500,22 +615,6 @@ export default {
500
615
str += ` </html>\n ` ;
501
616
fs .writeFileSync (path .join (location, " index.html" ), str);
502
617
},
503
- createFirebaseConfigFile (location ) {
504
- let str = ` import { initializeApp } from 'firebase/app';` ;
505
- str += ` \n\t const firebaseConfig = {` ;
506
- str += ` \n\t apiKey: "AIzaSyBR4o9xj4LtDaZ37-mC-FqRQWaz67_9Fq0",` ;
507
- str += ` \n\t authDomain: "oauth-74279.firebaseapp.com",` ;
508
- str += ` \n\t projectId: "oauth-74279",` ;
509
- str += ` \n\t storageBucket: "oauth-74279.appspot.com",` ;
510
- str += ` \n\t messagingSenderId: "91801023441",` ;
511
- str += ` \n\t appId: "1:91801023441:web:4d923f26f5ce9c7384e6f0",` ;
512
- str += ` \n\t measurementId: "G-ZZQMS6RRWR"` ;
513
- str += ` \n };` ;
514
- str += ` \n const firebaseApp = initializeApp(firebaseConfig);` ;
515
- str += ` \n export default firebaseApp` ;
516
-
517
- fs .writeFileSync (path .join (location, " firebaseConfig.js" ), str);
518
- },
519
618
// creates main.js boilerplate
520
619
createMainFile (location ) {
521
620
let str = ` import { createApp } from 'vue';` ;
@@ -676,7 +775,7 @@ export default {
676
775
if (this .$store .state .importLibraries .includes (' element' )){
677
776
str += ` ,\n\t\t "element-plus": "^2.2.16"` ;
678
777
};
679
- if (this .$store .state .exportOauth === ' on' ){
778
+ if (this .$store .state .exportOauth === ' on' || this . $store . state . exportOauthGithub === ' on ' ){
680
779
str += ` ,\n\t\t "firebase": "^9.6.9"`
681
780
}
682
781
str += ` \n\t },` ;
@@ -719,6 +818,7 @@ export default {
719
818
this .createPackage (data);
720
819
this .createStore (data);
721
820
this .createFirebaseConfigFile (data);
821
+ this .createOauthFile (data);
722
822
// exports images to the /assets folder
723
823
// eslint-disable-next-line no-unused-vars
724
824
for (let [routeImage, imageLocation] of Object .entries (this .imagePath )) {
0 commit comments