From 4cfb0ed06e144f82faf510677c81bf586161682f Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Fri, 28 Feb 2020 17:07:17 -0600 Subject: [PATCH 1/4] First pass --- packages/@ionic/cli/src/commands/start.ts | 6 ++++++ packages/@ionic/cli/src/lib/session.ts | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/packages/@ionic/cli/src/commands/start.ts b/packages/@ionic/cli/src/commands/start.ts index 9c8db7fad0..79328f13a5 100644 --- a/packages/@ionic/cli/src/commands/start.ts +++ b/packages/@ionic/cli/src/commands/start.ts @@ -12,6 +12,7 @@ import { Command } from '../lib/command'; import { FatalException } from '../lib/errors'; import { runCommand } from '../lib/executor'; import { createProjectFromDetails, createProjectFromDirectory, isValidProjectId } from '../lib/project'; +import { promptToSignup } from '../lib/session'; import { prependNodeModulesBinToPath } from '../lib/shell'; import { AppSchema, STARTER_BASE_URL, STARTER_TEMPLATES, SUPPORTED_FRAMEWORKS, getAdvertisement, getStarterList, getStarterProjectTypes, readStarterManifest, verifyOptions } from '../lib/start'; import { emoji } from '../lib/utils/emoji'; @@ -480,6 +481,11 @@ Use the ${input('--type')} option to start projects using older versions of Ioni } } + // Prompt to create account + if (!this.env.session.isLoggedIn()) { + await promptToSignup(this.env); + } + if (options['link']) { const cmdArgs = ['link']; diff --git a/packages/@ionic/cli/src/lib/session.ts b/packages/@ionic/cli/src/lib/session.ts index 1458f88c40..3434504525 100644 --- a/packages/@ionic/cli/src/lib/session.ts +++ b/packages/@ionic/cli/src/lib/session.ts @@ -6,6 +6,7 @@ import { isLoginResponse, isSuperAgentError } from '../guards'; import { input } from './color'; import { FatalException, SessionException } from './errors'; import { formatResponseError } from './http'; +import { openUrl } from './open'; export interface SessionDeps { readonly config: IConfig; @@ -160,6 +161,27 @@ export async function promptToLogin(env: IonicEnvironment): Promise { await env.session.login(email, password); } +export async function promptToSignup(env: IonicEnvironment): Promise { + env.log.msg( + `Join the Ionic Community\n` + + `Join the millions of developers on the Ionic Forum,\n` + + `get access to live events, news updates, and more.\n\n` + ); + + const create = await env.prompt({ + type: 'confirm', + name: 'create', + message: 'Create free Ionic account?', + default: true, + }); + + if (create) { + const dashUrl = env.config.getDashUrl(); + + await openUrl(`${dashUrl}/signup?source=cli`); + } +} + function hasTokenAttribute(r: any): r is { token: string; } { return r && typeof r === 'object' && typeof r.token === 'string'; } From e377bf4a4ed35a1fb24b8976ada23b002951c5e1 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Fri, 28 Feb 2020 17:33:29 -0600 Subject: [PATCH 2/4] Tweak copy --- packages/@ionic/cli/src/lib/session.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@ionic/cli/src/lib/session.ts b/packages/@ionic/cli/src/lib/session.ts index 3434504525..0a81782c0c 100644 --- a/packages/@ionic/cli/src/lib/session.ts +++ b/packages/@ionic/cli/src/lib/session.ts @@ -164,7 +164,7 @@ export async function promptToLogin(env: IonicEnvironment): Promise { export async function promptToSignup(env: IonicEnvironment): Promise { env.log.msg( `Join the Ionic Community\n` + - `Join the millions of developers on the Ionic Forum,\n` + + `Connect with millions of developers on the Ionic Forum and\n` + `get access to live events, news updates, and more.\n\n` ); From e080f832431f0f668d09a2b44a4e600361ce1f76 Mon Sep 17 00:00:00 2001 From: Daniel Imhoff Date: Mon, 2 Mar 2020 12:45:49 -0800 Subject: [PATCH 3/4] emojify & remove line break --- packages/@ionic/cli/src/lib/session.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/@ionic/cli/src/lib/session.ts b/packages/@ionic/cli/src/lib/session.ts index 0a81782c0c..6a548c279e 100644 --- a/packages/@ionic/cli/src/lib/session.ts +++ b/packages/@ionic/cli/src/lib/session.ts @@ -138,8 +138,9 @@ export class ProSession extends BaseSession implements ISession { export async function promptToLogin(env: IonicEnvironment): Promise { const { validators } = await import('@ionic/cli-framework'); + env.log.nl(); env.log.msg( - `Log in to your Ionic account\n` + + `Log in to your Ionic account!\n` + `If you don't have one yet, create yours by running: ${input(`ionic signup`)}\n` ); @@ -162,10 +163,10 @@ export async function promptToLogin(env: IonicEnvironment): Promise { } export async function promptToSignup(env: IonicEnvironment): Promise { + env.log.nl(); env.log.msg( - `Join the Ionic Community\n` + - `Connect with millions of developers on the Ionic Forum and\n` + - `get access to live events, news updates, and more.\n\n` + `Join the Ionic Community! 💙\n` + + `Connect with millions of developers on the Ionic Forum and get access to live events, news updates, and more.\n\n` ); const create = await env.prompt({ From c0a9d05dacf84c9acdb377288d52ae51d680263f Mon Sep 17 00:00:00 2001 From: Daniel Imhoff Date: Mon, 2 Mar 2020 12:47:19 -0800 Subject: [PATCH 4/4] default to no --- packages/@ionic/cli/src/lib/session.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@ionic/cli/src/lib/session.ts b/packages/@ionic/cli/src/lib/session.ts index 6a548c279e..b6f3db3ffd 100644 --- a/packages/@ionic/cli/src/lib/session.ts +++ b/packages/@ionic/cli/src/lib/session.ts @@ -173,7 +173,7 @@ export async function promptToSignup(env: IonicEnvironment): Promise { type: 'confirm', name: 'create', message: 'Create free Ionic account?', - default: true, + default: false, }); if (create) {