From 433c563c7f03d77dc5c963fc25e53b8ad83a6e04 Mon Sep 17 00:00:00 2001 From: Hunter Cote Date: Wed, 17 Feb 2021 15:24:26 -0700 Subject: [PATCH] added nextjs, hasura templates. updated react template to include env file --- scaffolds/binance-smart-chain/scaffold.tsx | 2 +- scaffolds/hasura/scaffold.tsx | 86 +++++++++++++++++ scaffolds/hasura/template/.env.local | 4 + scaffolds/hasura/template/README.md | 16 +++ .../hasura/template/components/loading.js | 7 ++ scaffolds/hasura/template/magic.js | 5 + scaffolds/hasura/template/package.json | 19 ++++ scaffolds/hasura/template/pages/_app.js | 15 +++ scaffolds/hasura/template/pages/api/login.js | 91 ++++++++++++++++++ scaffolds/hasura/template/pages/callback.js | 22 +++++ scaffolds/hasura/template/pages/index.js | 39 ++++++++ scaffolds/hasura/template/pages/login.js | 59 ++++++++++++ scaffolds/hasura/template/public/favicon.ico | Bin 0 -> 15086 bytes scaffolds/hasura/template/style.css | 55 +++++++++++ scaffolds/hello-world-react/template/.env | 1 + .../hello-world-react/template/src/magic.js | 4 +- scaffolds/next/scaffold.tsx | 32 ++++++ scaffolds/next/template/.env.local | 2 + scaffolds/next/template/components/loading.js | 7 ++ scaffolds/next/template/magic.js | 5 + scaffolds/next/template/package.json | 17 ++++ scaffolds/next/template/pages/_app.js | 15 +++ scaffolds/next/template/pages/api/login.js | 13 +++ scaffolds/next/template/pages/callback.js | 22 +++++ scaffolds/next/template/pages/index.js | 39 ++++++++ scaffolds/next/template/pages/login.js | 59 ++++++++++++ scaffolds/next/template/public/favicon.ico | Bin 0 -> 15086 bytes scaffolds/next/template/style.css | 55 +++++++++++ scaffolds/prompts.ts | 24 +++++ 29 files changed, 712 insertions(+), 3 deletions(-) create mode 100644 scaffolds/hasura/scaffold.tsx create mode 100644 scaffolds/hasura/template/.env.local create mode 100644 scaffolds/hasura/template/README.md create mode 100644 scaffolds/hasura/template/components/loading.js create mode 100644 scaffolds/hasura/template/magic.js create mode 100644 scaffolds/hasura/template/package.json create mode 100644 scaffolds/hasura/template/pages/_app.js create mode 100644 scaffolds/hasura/template/pages/api/login.js create mode 100644 scaffolds/hasura/template/pages/callback.js create mode 100644 scaffolds/hasura/template/pages/index.js create mode 100644 scaffolds/hasura/template/pages/login.js create mode 100644 scaffolds/hasura/template/public/favicon.ico create mode 100644 scaffolds/hasura/template/style.css create mode 100644 scaffolds/hello-world-react/template/.env create mode 100644 scaffolds/next/scaffold.tsx create mode 100644 scaffolds/next/template/.env.local create mode 100644 scaffolds/next/template/components/loading.js create mode 100644 scaffolds/next/template/magic.js create mode 100644 scaffolds/next/template/package.json create mode 100644 scaffolds/next/template/pages/_app.js create mode 100644 scaffolds/next/template/pages/api/login.js create mode 100644 scaffolds/next/template/pages/callback.js create mode 100644 scaffolds/next/template/pages/index.js create mode 100644 scaffolds/next/template/pages/login.js create mode 100644 scaffolds/next/template/public/favicon.ico create mode 100644 scaffolds/next/template/style.css diff --git a/scaffolds/binance-smart-chain/scaffold.tsx b/scaffolds/binance-smart-chain/scaffold.tsx index e505a88..42f6e6b 100644 --- a/scaffolds/binance-smart-chain/scaffold.tsx +++ b/scaffolds/binance-smart-chain/scaffold.tsx @@ -15,7 +15,7 @@ export default createScaffold( { shortDescription: 'Binance Smart Chain', - order: 1, + order: 3, installDependenciesCommand: NpmClientPrompt.getInstallCommand, startCommand: NpmClientPrompt.getStartCommand, flags: { diff --git a/scaffolds/hasura/scaffold.tsx b/scaffolds/hasura/scaffold.tsx new file mode 100644 index 0000000..9962ac0 --- /dev/null +++ b/scaffolds/hasura/scaffold.tsx @@ -0,0 +1,86 @@ +import React from 'react'; +import { Template, Zombi } from 'compiled/zombi'; +import { createScaffold } from 'cli/utils/scaffold-helpers'; +import { mergePrompts } from 'cli/utils/merge-prompts'; +import { NpmClientPrompt, PublishableApiKeyPrompt, SecretApiKeyPrompt } from 'scaffolds/prompts'; +import type { Questions } from 'compiled/zombi'; +import type { Flags } from 'cli/flags'; + +// prompt specific to the Hasura template, therefore not in `scaffolds/prompts.ts` +namespace HasuraUrlPrompt { + export type Data = { + hasuraUrl: 'npm' | 'yarn'; + }; + + export const questions: Questions = { + type: 'input', + name: 'hasuraUrl', + message: "Enter your project's Hasura URL:", + }; + + export const flags: Flags = { + hasuraUrl: { + type: String, + description: 'The GraphQL URL for your Hasura app.', + }, + }; +} + +// prompt specific to the Hasura template, therefore not in `scaffolds/prompts.ts` +namespace JwtSecretPrompt { + export type Data = { + jwtSecret: 'npm' | 'yarn'; + }; + + export const questions: Questions = { + type: 'input', + name: 'jwtSecret', + message: 'Enter your 32+ character JWT secret:', + }; + + export const flags: Flags = { + jwtSecret: { + type: String, + description: 'The shared JWT secret between your app and Hasura.', + }, + }; +} + +type HasuraData = NpmClientPrompt.Data & + PublishableApiKeyPrompt.Data & + SecretApiKeyPrompt.Data & + HasuraUrlPrompt.Data & + JwtSecretPrompt.Data; + +export default createScaffold( + (props) => ( + +