From 6349710e84401dd9e728b62a69037c31556d6ed1 Mon Sep 17 00:00:00 2001 From: Aditya Vyas Date: Thu, 9 Jan 2020 02:23:41 +0530 Subject: [PATCH 1/3] feat:prompt-google-form examples added --- examples/googleform/enquirer.js | 25 +++++++++++++++++++++++ examples/googleform/prompt.js | 11 ++++++++++ examples/googleform/selectForm.js | 34 +++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 examples/googleform/enquirer.js create mode 100644 examples/googleform/prompt.js create mode 100644 examples/googleform/selectForm.js diff --git a/examples/googleform/enquirer.js b/examples/googleform/enquirer.js new file mode 100644 index 00000000..56fba509 --- /dev/null +++ b/examples/googleform/enquirer.js @@ -0,0 +1,25 @@ +const Enquirer = require("enquirer"); +const GoogleFormPrompt = require("prompt-google-form"); + +const enquirer = new Enquirer(); +enquirer.register("google", GoogleFormPrompt); + +enquirer + .prompt([ + { + type: "confirm", + name: "confirm", + message: "Would you like fill out our Survey?" + }, + { + name: "Google Form", + message: "Please provide the information:", + form_id: process.argv[2], + type: "google", + skip() { + return this.state.answers.confirm !== true; + } + } + ]) + .then(res => console.log(res)) + .catch(err => console.log(err)); \ No newline at end of file diff --git a/examples/googleform/prompt.js b/examples/googleform/prompt.js new file mode 100644 index 00000000..10e194ab --- /dev/null +++ b/examples/googleform/prompt.js @@ -0,0 +1,11 @@ +const GoogleFormPrompt = require("prompt-google-form"); + +const prompt = new GoogleFormPrompt({ + name: "Google Form", + message: "Please provide the information:", + form_id: process.argv[2], +}); + +prompt.run() +.then(res => console.log(res)) +.catch(err => console.log(err)); \ No newline at end of file diff --git a/examples/googleform/selectForm.js b/examples/googleform/selectForm.js new file mode 100644 index 00000000..3a31734b --- /dev/null +++ b/examples/googleform/selectForm.js @@ -0,0 +1,34 @@ +const Enquirer = require("enquirer"); +const GoogleFormPrompt = require("prompt-google-form"); + +const enquirer = new Enquirer(); +enquirer.register("google", GoogleFormPrompt); + +enquirer + .prompt([ + { + type: "select", + name: "form", + message: "Which Form Would you like to fill out?", + choices: [{ + value: '1FAIpQLSdniaX5nAjywbvnT9tQp1OTryh7148Lkl5LnvJV1mBOy1QXdA', + message: 'Contact Form' + },{ + value: '1FAIpQLSfb_pdS57UJTS1qKaKfSLoDs9pudHLbNbkpp74kdpUYoEKz9Q', + message: 'T-Shirt Form' + },{ + value: '1FAIpQLSd5YEpcRFJAE47OuvHyI6equ66DEspA9S2AZHCafhokHUbjWg', + message: 'Event Form' + }] + }, + { + name: "Google Form", + message: "Please provide the information:", + formId(state){ + return state.answers.form; + }, + type: "google" + } + ]) + .then(res => console.log(res)) + .catch(err => console.log(err)); \ No newline at end of file From b907d5dfa5f9d2c7be55d636fa5b67535c12cb92 Mon Sep 17 00:00:00 2001 From: Aditya Vyas Date: Wed, 15 Jan 2020 22:54:49 +0530 Subject: [PATCH 2/3] feat: Google form examples --- examples/googleform/constants.js | 5 +++++ examples/googleform/enquirer.js | 27 +++++++++++++++------------ examples/googleform/prompt.js | 15 +++++++++------ examples/googleform/selectForm.js | 28 +++++++++++++++------------- 4 files changed, 44 insertions(+), 31 deletions(-) create mode 100644 examples/googleform/constants.js diff --git a/examples/googleform/constants.js b/examples/googleform/constants.js new file mode 100644 index 00000000..65bd8820 --- /dev/null +++ b/examples/googleform/constants.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = { + FORM_ID: '1FAIpQLSdniaX5nAjywbvnT9tQp1OTryh7148Lkl5LnvJV1mBOy1QXdA' +}; diff --git a/examples/googleform/enquirer.js b/examples/googleform/enquirer.js index 56fba509..7f5656bd 100644 --- a/examples/googleform/enquirer.js +++ b/examples/googleform/enquirer.js @@ -1,25 +1,28 @@ -const Enquirer = require("enquirer"); -const GoogleFormPrompt = require("prompt-google-form"); +'use strict'; + +const Enquirer = require('enquirer'); +const GoogleFormPrompt = require('..'); +const { FORM_ID } = require('./constants'); const enquirer = new Enquirer(); -enquirer.register("google", GoogleFormPrompt); +enquirer.register('google', GoogleFormPrompt); enquirer .prompt([ { - type: "confirm", - name: "confirm", - message: "Would you like fill out our Survey?" + type: 'confirm', + name: 'confirm', + message: 'Would you like fill out our Survey?' }, { - name: "Google Form", - message: "Please provide the information:", - form_id: process.argv[2], - type: "google", + name: 'Google Form', + message: 'Please provide the information:', + formId: process.argv[2] || FORM_ID, + type: 'google', skip() { - return this.state.answers.confirm !== true; + return this.state.answers.confirm !== true; } } ]) .then(res => console.log(res)) - .catch(err => console.log(err)); \ No newline at end of file + .catch(err => console.log(err)); diff --git a/examples/googleform/prompt.js b/examples/googleform/prompt.js index 10e194ab..584cd94b 100644 --- a/examples/googleform/prompt.js +++ b/examples/googleform/prompt.js @@ -1,11 +1,14 @@ -const GoogleFormPrompt = require("prompt-google-form"); +'use strict'; + +const GoogleFormPrompt = require('..'); +const { FORM_ID } = require('./constants'); const prompt = new GoogleFormPrompt({ - name: "Google Form", - message: "Please provide the information:", - form_id: process.argv[2], + name: 'Google Form', + message: 'Please provide the information:', + formId: process.argv[2] || FORM_ID, }); prompt.run() -.then(res => console.log(res)) -.catch(err => console.log(err)); \ No newline at end of file + .then(res => console.log(res)) + .catch(err => console.log(err)); diff --git a/examples/googleform/selectForm.js b/examples/googleform/selectForm.js index 3a31734b..8f0ac9e8 100644 --- a/examples/googleform/selectForm.js +++ b/examples/googleform/selectForm.js @@ -1,34 +1,36 @@ -const Enquirer = require("enquirer"); -const GoogleFormPrompt = require("prompt-google-form"); +'use strict'; + +const Enquirer = require('enquirer'); +const GoogleFormPrompt = require('..'); const enquirer = new Enquirer(); -enquirer.register("google", GoogleFormPrompt); +enquirer.register('google', GoogleFormPrompt); enquirer .prompt([ { - type: "select", - name: "form", - message: "Which Form Would you like to fill out?", + type: 'select', + name: 'form', + message: 'Which Form Would you like to fill out?', choices: [{ value: '1FAIpQLSdniaX5nAjywbvnT9tQp1OTryh7148Lkl5LnvJV1mBOy1QXdA', message: 'Contact Form' - },{ + }, { value: '1FAIpQLSfb_pdS57UJTS1qKaKfSLoDs9pudHLbNbkpp74kdpUYoEKz9Q', message: 'T-Shirt Form' - },{ + }, { value: '1FAIpQLSd5YEpcRFJAE47OuvHyI6equ66DEspA9S2AZHCafhokHUbjWg', message: 'Event Form' }] }, { - name: "Google Form", - message: "Please provide the information:", - formId(state){ + name: 'Google Form', + message: 'Please provide the information:', + formId(state) { return state.answers.form; }, - type: "google" + type: 'google' } ]) .then(res => console.log(res)) - .catch(err => console.log(err)); \ No newline at end of file + .catch(err => console.log(err)); From 9ccfa83c80662c5859b02f346ea746158bf768dd Mon Sep 17 00:00:00 2001 From: Aditya Vyas Date: Fri, 17 Jan 2020 10:54:25 +0530 Subject: [PATCH 3/3] feat: google forms example fixing require statement --- examples/googleform/enquirer.js | 2 +- examples/googleform/prompt.js | 2 +- examples/googleform/selectForm.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/googleform/enquirer.js b/examples/googleform/enquirer.js index 7f5656bd..031f5139 100644 --- a/examples/googleform/enquirer.js +++ b/examples/googleform/enquirer.js @@ -1,7 +1,7 @@ 'use strict'; const Enquirer = require('enquirer'); -const GoogleFormPrompt = require('..'); +const GoogleFormPrompt = require('prompt-google-form'); const { FORM_ID } = require('./constants'); const enquirer = new Enquirer(); diff --git a/examples/googleform/prompt.js b/examples/googleform/prompt.js index 584cd94b..e04aad3d 100644 --- a/examples/googleform/prompt.js +++ b/examples/googleform/prompt.js @@ -1,6 +1,6 @@ 'use strict'; -const GoogleFormPrompt = require('..'); +const GoogleFormPrompt = require('prompt-google-form'); const { FORM_ID } = require('./constants'); const prompt = new GoogleFormPrompt({ diff --git a/examples/googleform/selectForm.js b/examples/googleform/selectForm.js index 8f0ac9e8..3f6b6259 100644 --- a/examples/googleform/selectForm.js +++ b/examples/googleform/selectForm.js @@ -1,7 +1,7 @@ 'use strict'; const Enquirer = require('enquirer'); -const GoogleFormPrompt = require('..'); +const GoogleFormPrompt = require('prompt-google-form'); const enquirer = new Enquirer(); enquirer.register('google', GoogleFormPrompt);