1+ import { Command } from 'commander' ;
2+ import chalk from 'chalk' ;
3+ import open from 'open' ;
4+ import inquirer from 'inquirer' ;
5+
6+ export function registerSignupCommand ( program : Command ) : void {
7+ program
8+ . command ( 'signup' )
9+ . alias ( 'register' )
10+ . description ( 'Sign up for StackMemory hosted service' )
11+ . option ( '--no-open' , 'Do not automatically open browser' )
12+ . action ( async ( options ) => {
13+ console . log ( chalk . cyan ( '🚀 StackMemory Hosted Service Signup\n' ) ) ;
14+
15+ const signupUrl = 'https://stackmemory.ai/signup' ;
16+
17+ if ( options . open !== false ) {
18+ console . log ( chalk . gray ( 'Opening signup page in your browser...' ) ) ;
19+ try {
20+ await open ( signupUrl ) ;
21+ console . log ( chalk . green ( '✓ Opened: ' ) + chalk . cyan ( signupUrl ) ) ;
22+ } catch ( error ) {
23+ console . log ( chalk . yellow ( 'Could not open browser automatically.' ) ) ;
24+ console . log ( chalk . gray ( 'Please visit: ' ) + chalk . cyan ( signupUrl ) ) ;
25+ }
26+ } else {
27+ console . log ( chalk . gray ( 'Visit this URL to sign up:' ) ) ;
28+ console . log ( chalk . cyan ( signupUrl ) ) ;
29+ }
30+
31+ console . log ( chalk . gray ( '\nAfter signing up, you can login with:' ) ) ;
32+ console . log ( chalk . cyan ( ' stackmemory login' ) ) ;
33+
34+ // Optional: Ask if they want to login now
35+ const { proceed } = await inquirer . prompt ( [
36+ {
37+ type : 'confirm' ,
38+ name : 'proceed' ,
39+ message : 'Have you completed signup and want to login now?' ,
40+ default : false ,
41+ } ,
42+ ] ) ;
43+
44+ if ( proceed ) {
45+ // Import and run login command
46+ const { registerLoginCommand } = await import ( './login.js' ) ;
47+ const loginCmd = new Command ( ) ;
48+ registerLoginCommand ( loginCmd ) ;
49+
50+ // Execute login
51+ console . log ( chalk . cyan ( '\n🔐 Proceeding to login...\n' ) ) ;
52+ await loginCmd . parseAsync ( [ 'node' , 'stackmemory' , 'login' ] ) ;
53+ } else {
54+ console . log ( chalk . gray ( '\nWhen ready, run: ' ) + chalk . cyan ( 'stackmemory login' ) ) ;
55+ }
56+ } ) ;
57+ }
0 commit comments