@@ -255,6 +255,7 @@ export default {
255255
256256 if (componentName === " App" ) {
257257 str += ` <div id="app">\n\t\t <div id="nav">\n ` ;
258+
258259 for (let route in routes) {
259260 if (route === " HomeView" ) {
260261 str += ` \t\t\t <router-link to="/" class = "componentLinks">${ route} </router-link>\n ` ;
@@ -277,6 +278,7 @@ export default {
277278 let childNameClassFullStr = (childNameClass === " " ) ? " " : ` class = '${ childNameClass} '` ;
278279 routeStr += ` <${ childName}${ childNameClassFullStr} ></${ childName} >\n `
279280 });
281+
280282 return ` <template>\n <div id = "${ componentName} ">\n ${ templateTagStr}${ routeStr} \t </div>\n </template>` ;
281283 }
282284
@@ -287,19 +289,29 @@ export default {
287289 let compClass = (this .routes .hasOwnProperty (componentName)) ? componentName : this .componentMap [componentName].htmlAttributes .class ;
288290
289291 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+ }
290296 return ` <template>\n <div id = "${ compID} " class = "${ compClass} ">\n ${ templateTagStr}${ routeStr} </div>\n </template>` ;
291297 }
292298 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+ }
293302 return ` <template>\n <div class = "${ compClass} ">\n ${ templateTagStr}${ routeStr} </div>\n </template>` ;
294303 }
295304 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>` ;}
296306 return ` <template>\n <div id = "${ compID} ">\n ${ templateTagStr}${ routeStr} </div>\n </template>` ;
297307 }
298308 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>` ;}
299310 return ` <template>\n <div>\n\t ${ str}${ templateTagStr}${ routeStr} </div>\n </template>` ;
300311 }
301312 }
302313 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>` }
303315 return ` <template>\n\t ${ str}${ templateTagStr}${ routeStr} </div>\n </template>`
304316 }
305317 },
@@ -378,12 +390,22 @@ export default {
378390 let output;
379391 if (this .exportAsTypescript === " on" ) {
380392 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+ }
381396 output += imports + " \n export default defineComponent ({\n name: '" + componentName + " '" ;
382397 } else {
383398 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+ }
384402 output += imports + " \n export default {\n name: '" + componentName + " '" ;
403+
385404 }
386405 output += " ,\n components: {\n " ;
406+ if (this .$store .state .exportOauth === ' on' || this .$store .state .exportOauthGithub === ' on' ){
407+ output+= ` Oauth,`
408+ }
387409 output += childrenComponentNames + " },\n " ;
388410 output += data;
389411 output += computed;
@@ -431,17 +453,12 @@ export default {
431453 return str
432454 }
433455 },
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 */
440456 writeStyle (componentName ) {
441457 let htmlArray = this .componentMap [componentName].htmlList ;
442458 let styleString = " " ;
443459 console .log (componentName);
444460 // Add grid css property to view component div
461+ if (this .routes )
445462 // adds view component id grid style and adds child component css styling
446463 if (this .routes .hasOwnProperty (componentName)) {
447464 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 {
469486.router-view {
470487 margin:auto;
471488 background-color: gray;
472- height: 720px;
473- width: 1280px;
474489}
475490</style >`
476491 } else return ` \n\n <style scoped>\n ${ styleString} </style >` ;
477492 },
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` ;
478507
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+ },
480595 createIndexFile (location ) {
481596 let str = ` <!DOCTYPE html>\n <html lang="en">\n\n <head>` ;
482597 str += ` \n\t <meta charset="utf-8">` ;
@@ -500,22 +615,6 @@ export default {
500615 str += ` </html>\n ` ;
501616 fs .writeFileSync (path .join (location, " index.html" ), str);
502617 },
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- },
519618 // creates main.js boilerplate
520619 createMainFile (location ) {
521620 let str = ` import { createApp } from 'vue';` ;
@@ -676,7 +775,7 @@ export default {
676775 if (this .$store .state .importLibraries .includes (' element' )){
677776 str += ` ,\n\t\t "element-plus": "^2.2.16"` ;
678777 };
679- if (this .$store .state .exportOauth === ' on' ){
778+ if (this .$store .state .exportOauth === ' on' || this . $store . state . exportOauthGithub === ' on ' ){
680779 str += ` ,\n\t\t "firebase": "^9.6.9"`
681780 }
682781 str += ` \n\t },` ;
@@ -719,6 +818,7 @@ export default {
719818 this .createPackage (data);
720819 this .createStore (data);
721820 this .createFirebaseConfigFile (data);
821+ this .createOauthFile (data);
722822 // exports images to the /assets folder
723823 // eslint-disable-next-line no-unused-vars
724824 for (let [routeImage, imageLocation] of Object .entries (this .imagePath )) {
0 commit comments