From eb4acfdb24bab855adf3065a4d9edce02a1c7ec4 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Wed, 13 Sep 2023 13:48:41 -0700 Subject: [PATCH 1/2] Fixed network flag not getting parsed by adding it to global flag options --- core/cli.ts | 4 ++-- core/create-app.tsx | 18 +++++++++--------- core/global-options.ts | 5 ++++- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/core/cli.ts b/core/cli.ts index ff7be35..c6e750d 100644 --- a/core/cli.ts +++ b/core/cli.ts @@ -34,7 +34,7 @@ function sayHello() { useGracefulShutdown(); - const { version, help, projectName, template, branch } = await parseFlags(globalOptions); + const { version, help, projectName, template, branch, network } = await parseFlags(globalOptions); if (version) { console.log(getMakeMagicVersion()); @@ -56,7 +56,7 @@ function sayHello() { } // Run the scaffold... - await createApp({ projectName, template, branch }); + await createApp({ projectName, template, branch, network }); })().catch((err) => { SharedAnalytics.logEvent('cli-tool-error', { error: err }); if (err instanceof ZombiError && err.code === ZombiErrorCode.USER_CANCELED_PROMPT) { diff --git a/core/create-app.tsx b/core/create-app.tsx index 69ce4a6..13bfd37 100644 --- a/core/create-app.tsx +++ b/core/create-app.tsx @@ -21,10 +21,11 @@ import { parseFlags } from './flags'; import { addShutdownTask } from './utils/shutdown'; import { SharedAnalytics } from './analytics'; import { Chain, mapTemplateToChain, mapTemplateToProduct } from './utils/templateMappings'; +import { BlockchainNetworkPrompt } from 'scaffolds/prompts'; const { Select, Input } = require('enquirer'); -export interface CreateMagicAppData { +export interface CreateMagicAppData extends BlockchainNetworkPrompt.Data { /** * The `make-magic` project branch to source templates from. */ @@ -87,7 +88,6 @@ export async function createApp(config: CreateMagicAppConfig) { config.projectName = projectName; } - let network = ''; let chain: Chain | undefined = undefined; let product: 'universal' | 'dedicated' | undefined = undefined; if (!config.template) { @@ -102,7 +102,7 @@ export async function createApp(config: CreateMagicAppConfig) { if (configuration === 'quickstart') { config.template = 'nextjs-universal-wallet'; - network = 'polygon-mumbai'; + config.network = 'polygon-mumbai'; product = 'universal'; chain = 'evm'; isChosenTemplateValid = true; @@ -112,7 +112,7 @@ export async function createApp(config: CreateMagicAppConfig) { product = mapTemplateToProduct(config.template); } - if (!chain && !network) { + if (!chain && !config.network) { chain = await new Select({ name: 'chain', message: 'Which blockchain do you want to use?', @@ -124,9 +124,9 @@ export async function createApp(config: CreateMagicAppConfig) { }).run(); } - if (!network) { + if (!config.network) { if (chain === 'solana') { - network = await new Select({ + config.network = await new Select({ name: 'network', message: 'Which network would you like to use?', hint: 'We recommend starting with a test network', @@ -140,7 +140,7 @@ export async function createApp(config: CreateMagicAppConfig) { config.template = 'nextjs-solana-dedicated-wallet'; isChosenTemplateValid = true; } else if (chain === 'flow') { - network = await new Select({ + config.network = await new Select({ name: 'network', message: 'Which network would you like to use?', hint: 'We recommend starting with a test network', @@ -150,7 +150,7 @@ export async function createApp(config: CreateMagicAppConfig) { ], }).run(); } else if (chain === 'evm') { - network = await new Select({ + config.network = await new Select({ name: 'network', message: 'Which network would like to use?', hint: 'We recommend starting with a test network', @@ -197,7 +197,7 @@ export async function createApp(config: CreateMagicAppConfig) { branch: config?.branch ?? 'master', projectName: config?.projectName, template: isChosenTemplateValid ? config.template : undefined, - network: network.length > 0 ? network : undefined, + network: config.network, npmClient: 'npm', })} prompts={[ diff --git a/core/global-options.ts b/core/global-options.ts index 85f367e..ee06925 100644 --- a/core/global-options.ts +++ b/core/global-options.ts @@ -2,8 +2,9 @@ import chalk from 'chalk'; import { BINARY } from './config'; import { CreateMagicAppData } from './create-app'; import { Flags } from './flags'; +import { BlockchainNetworkPrompt } from 'scaffolds/prompts'; -export interface GlobalOptions extends Partial { +export interface GlobalOptions extends Partial { help?: boolean; version?: boolean; [key: string]: any; @@ -41,4 +42,6 @@ export const globalOptions: Flags = { alias: 'v', description: `Show which version of \`${BINARY}\` is currently in use.`, }, + + ...BlockchainNetworkPrompt.flags, }; From f18349dcac56396c5b6530c4fc230e604a2edf2f Mon Sep 17 00:00:00 2001 From: James Pacheco Date: Wed, 13 Sep 2023 16:53:48 -0600 Subject: [PATCH 2/2] Add github CI for staging env --- .github/workflows/publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6cf8204..8c3a71c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -4,6 +4,7 @@ on: branches: - 'master' - 'main' + - 'staging' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}