11/* eslint-disable tsdoc/syntax */
22import { hasRequiredThemeDirectories , mountThemeFileSystem } from '../utilities/theme-fs.js'
3- import { uploadTheme } from '../utilities/theme-uploader.js'
43import { ensureDirectoryConfirmed , themeComponent } from '../utilities/theme-ui.js'
5- import { ensureThemeStore } from '../utilities/theme-store.js'
64import { DevelopmentThemeManager } from '../utilities/development-theme-manager.js'
75import { findOrSelectTheme } from '../utilities/theme-selector.js'
86import { Role } from '../utilities/theme-selector/fetch.js'
97import { configureCLIEnvironment } from '../utilities/cli-config.js'
108import { runThemeCheck } from '../commands/theme/check.js'
11- import { AdminSession , ensureAuthenticatedThemes } from '@shopify/cli-kit/node/session'
9+ import { uploadTheme4 } from '../utilities/theme-uploader.js'
10+ import { AdminSession } from '@shopify/cli-kit/node/session'
1211import { themeCreate , fetchChecksums , themePublish } from '@shopify/cli-kit/node/themes/api'
1312import { Result , Theme } from '@shopify/cli-kit/node/themes/types'
1413import { outputResult } from '@shopify/cli-kit/node/output'
@@ -33,6 +32,7 @@ interface PushOptions {
3332 publish ?: boolean
3433 ignore ?: string [ ]
3534 only ?: string [ ]
35+ environment ?: string
3636}
3737
3838interface JsonOutput {
@@ -99,14 +99,17 @@ export interface PushFlags {
9999
100100 /** Require theme check to pass without errors before pushing. Warnings are allowed. */
101101 strict ?: boolean
102+
103+ /** The environment to push the theme to. */
104+ environment ?: string
102105}
103106
104107/**
105108 * Initiates the push process based on provided flags.
106109 *
107110 * @param flags - The flags for the push operation.
108111 */
109- export async function push ( flags : PushFlags ) : Promise < void > {
112+ export async function push ( flags : PushFlags , adminSession ?: AdminSession ) {
110113 if ( flags . strict ) {
111114 const outputType = flags . json ? 'json' : 'text'
112115 const { offenses} = await runThemeCheck ( flags . path ?? cwd ( ) , outputType )
@@ -127,22 +130,20 @@ export async function push(flags: PushFlags): Promise<void> {
127130 } )
128131
129132 const force = flags . force ?? false
130- const store = ensureThemeStore ( { store : flags . store } )
131- const adminSession = await ensureAuthenticatedThemes ( store , flags . password )
132133
133134 const workingDirectory = path ? resolvePath ( path ) : cwd ( )
134135 if ( ! ( await hasRequiredThemeDirectories ( workingDirectory ) ) && ! ( await ensureDirectoryConfirmed ( force ) ) ) {
135136 return
136137 }
137138
138- const selectedTheme : Theme | undefined = await createOrSelectTheme ( adminSession , flags )
139+ const selectedTheme : Theme | undefined = await createOrSelectTheme ( adminSession as unknown as AdminSession , flags )
139140 if ( ! selectedTheme ) {
140141 return
141142 }
142143
143144 recordTiming ( 'theme-service:push:setup' )
144145
145- await executePush ( selectedTheme , adminSession , {
146+ await executePush ( selectedTheme , adminSession as unknown as AdminSession , {
146147 path : workingDirectory ,
147148 nodelete : flags . nodelete ?? false ,
148149 publish : flags . publish ?? false ,
@@ -166,7 +167,7 @@ async function executePush(theme: Theme, session: AdminSession, options: PushOpt
166167 const themeFileSystem = mountThemeFileSystem ( options . path , { filters : options } )
167168 recordTiming ( 'theme-service:push:file-system' )
168169
169- const { uploadResults, renderThemeSyncProgress} = await uploadTheme (
170+ const { uploadResults, renderThemeSyncProgress} = await uploadTheme4 (
170171 theme ,
171172 session ,
172173 themeChecksums ,
0 commit comments