11/**
22 * Creates test apps in the authenticated org and prints their client IDs.
3- * Run: npx tsx packages/e2e/scripts/create-test-apps.ts
3+ * Run: pnpx tsx packages/e2e/scripts/create-test-apps.ts
44 */
55
66import * as fs from 'fs'
@@ -39,7 +39,7 @@ if (!email || !password) {
3939}
4040
4141const baseEnv : Record < string , string > = {
42- ...process . env as Record < string , string > ,
42+ ...( process . env as Record < string , string > ) ,
4343 NODE_OPTIONS : '' ,
4444 SHOPIFY_RUN_AS_USER : '0' ,
4545 FORCE_COLOR : '0' ,
@@ -86,16 +86,16 @@ async function createAppInteractive(tmpDir: string, appName: string): Promise<st
8686 fs . mkdirSync ( appDir )
8787
8888 const nodePty = await import ( 'node-pty' )
89- const pty = nodePty . spawn ( 'node' , [
90- createAppPath ,
91- '--name' , appName ,
92- '--path' , appDir ,
93- '--template' , 'none ',
94- '--package-manager' , 'npm' ,
95- '--local' ,
96- ] , {
97- name : 'xterm-color' , cols : 120 , rows : 30 , env : baseEnv ,
98- } )
89+ const pty = nodePty . spawn (
90+ 'node' ,
91+ [ createAppPath , '--name' , appName , '--path' , appDir , '--template' , 'none' , '--package-manager' , 'pnpm' , '--local' ] ,
92+ {
93+ name : 'xterm-color ',
94+ cols : 120 ,
95+ rows : 30 ,
96+ env : baseEnv ,
97+ } ,
98+ )
9999
100100 let output = ''
101101 pty . onData ( ( data : string ) => {
@@ -104,11 +104,7 @@ async function createAppInteractive(tmpDir: string, appName: string): Promise<st
104104 } )
105105
106106 // Answer each interactive prompt as it appears
107- const prompts = [
108- 'Which organization' ,
109- 'Create this project as a new app' ,
110- 'App name' ,
111- ]
107+ const prompts = [ 'Which organization' , 'Create this project as a new app' , 'App name' ]
112108 for ( const prompt of prompts ) {
113109 try {
114110 await waitForText ( ( ) => output , prompt , 60_000 )
@@ -130,9 +126,7 @@ async function createAppInteractive(tmpDir: string, appName: string): Promise<st
130126
131127 // Find the app dir and extract client_id
132128 const entries = fs . readdirSync ( appDir , { withFileTypes : true } )
133- const created = entries . find (
134- ( e ) => e . isDirectory ( ) && fs . existsSync ( path . join ( appDir , e . name , 'shopify.app.toml' ) ) ,
135- )
129+ const created = entries . find ( ( e ) => e . isDirectory ( ) && fs . existsSync ( path . join ( appDir , e . name , 'shopify.app.toml' ) ) )
136130 if ( ! created ) throw new Error ( `No app directory found in ${ appDir } ` )
137131
138132 const tomlPath = path . join ( appDir , created . name , 'shopify.app.toml' )
@@ -147,11 +141,16 @@ async function oauthLogin() {
147141 const nodePty = await import ( 'node-pty' )
148142 const spawnEnv = { ...baseEnv , BROWSER : 'none' }
149143 const pty = nodePty . spawn ( 'node' , [ cliPath , 'auth' , 'login' ] , {
150- name : 'xterm-color' , cols : 120 , rows : 30 , env : spawnEnv ,
144+ name : 'xterm-color' ,
145+ cols : 120 ,
146+ rows : 30 ,
147+ env : spawnEnv ,
151148 } )
152149
153150 let output = ''
154- pty . onData ( ( data : string ) => { output += data } )
151+ pty . onData ( ( data : string ) => {
152+ output += data
153+ } )
155154
156155 await waitForText ( ( ) => output , 'Press any key to open the login page' , 30_000 )
157156 pty . write ( ' ' )
@@ -169,7 +168,9 @@ async function oauthLogin() {
169168 await completeLogin ( page , urlMatch [ 0 ] , email ! , password ! )
170169
171170 await waitForText ( ( ) => output , 'Logged in' , 60_000 )
172- try { pty . kill ( ) } catch { }
171+ try {
172+ pty . kill ( )
173+ } catch { }
173174 await browser . close ( )
174175}
175176
0 commit comments