@@ -2,15 +2,31 @@ import { spawnSync } from "node:child_process";
22import { existsSync , readFileSync } from "node:fs" ;
33import { join } from "node:path" ;
44import open from "open" ;
5- import ora from "ora" ;
5+ import ora , { type Ora } from "ora" ;
66import { createThirdwebClient } from "../../../client/client.js" ;
77import { upload } from "../../../storage/upload.js" ;
88
99const THIRDWEB_URL = "https://thirdweb.com" ;
1010
1111export async function publishStylus ( secretKey ?: string ) {
1212 const spinner = ora ( "Checking if this is a Stylus project..." ) . start ( ) ;
13+ const uri = await buildStylus ( spinner , secretKey ) ;
1314
15+ const url = getUrl ( uri , "publish" ) . toString ( ) ;
16+ spinner . succeed ( `Upload complete, navigate to ${ url } ` ) ;
17+ await open ( url ) ;
18+ }
19+
20+ export async function deployStylus ( secretKey ?: string ) {
21+ const spinner = ora ( "Checking if this is a Stylus project..." ) . start ( ) ;
22+ const uri = await buildStylus ( spinner , secretKey ) ;
23+
24+ const url = getUrl ( uri , "deploy" ) . toString ( ) ;
25+ spinner . succeed ( `Upload complete, navigate to ${ url } ` ) ;
26+ await open ( url ) ;
27+ }
28+
29+ async function buildStylus ( spinner : Ora , secretKey ?: string ) {
1430 if ( ! secretKey ) {
1531 spinner . fail ( "Error: Secret key is required." ) ;
1632 process . exit ( 1 ) ;
@@ -122,7 +138,7 @@ export async function publishStylus(secretKey?: string) {
122138 } ) ;
123139 console . log ( bytecodeUri ) ;
124140
125- const publishUri = await upload ( {
141+ const uri = await upload ( {
126142 client,
127143 files : [
128144 {
@@ -143,11 +159,9 @@ export async function publishStylus(secretKey?: string) {
143159 } ,
144160 ] ,
145161 } ) ;
162+ spinner . succeed ( "Upload complete" ) ;
146163
147- const url = getUrl ( publishUri , "publish" ) . toString ( ) ;
148- spinner . succeed ( `Upload complete: ${ url } ` ) ;
149-
150- await open ( url ) ;
164+ return uri ;
151165 } catch ( error ) {
152166 spinner . fail ( `Error: ${ error } ` ) ;
153167 process . exit ( 1 ) ;
0 commit comments