@@ -16,41 +16,52 @@ interface Arguments {
1616 [ x : string ] : unknown
1717 _: ( string | number ) [ ]
1818 $0: string
19+ f: boolean
1920 s: string | undefined
20- 'default-projects' : string | undefined
21+ artifactPath: string
22+ defaultProjects: boolean
23+ force: boolean
2124}
2225
2326export async function main ( args : string [ ] ) : Promise < void > {
2427 let pulumiPaths : string [ ] | undefined
2528 let stackName : string | undefined
2629
27- var argv = yargs ( process . argv . slice ( 2 ) )
28- . usage ( 'Usage: $0 [options] <artifactPath>' )
29- . command ( '$0' , '' , ( yargs ) => {
30- yargs
31- . positional ( 'artifactPath' , {
32- describe : 'directory containing the build artifacts' ,
33- type : 'string' ,
34- } )
35- . option ( 's' , {
36- describe : 'stack name' ,
37- type : 'string' ,
38- } )
39- . option ( 'default-projects' , {
40- describe : 'use the built-in Pulumi projects' ,
41- type : 'boolean' ,
42- } )
43- } )
30+ var argv = yargs ( args . slice ( 2 ) )
31+ . scriptName ( 'adapter-stack-destroy' )
32+ . usage (
33+ '$0 [artifactPath]' ,
34+ "Destroy the SvelteKit adapter's Pulumi stacks" ,
35+ ( yargs ) => {
36+ return yargs
37+ . positional ( 'artifactPath' , {
38+ describe :
39+ "directory containing the build artifacts. Defaults to 'build'" ,
40+ type : 'string' ,
41+ } )
42+ . option ( 's' , {
43+ describe : 'stack name' ,
44+ type : 'string' ,
45+ } )
46+ . option ( 'default-projects' , {
47+ describe : 'use the built-in Pulumi projects' ,
48+ type : 'boolean' ,
49+ } )
50+ . option ( 'f' , {
51+ alias : 'force' ,
52+ describe : 'cancel ongoing stack updates' ,
53+ type : 'boolean' ,
54+ } )
55+ }
56+ )
4457 . alias ( 'h' , 'help' )
4558 . help ( )
4659 . parseSync ( ) as Arguments
4760
48- console . log ( argv )
49-
5061 let artifactPath = 'build '
5162
52- if ( argv . _ . length ) {
53- artifactPath = String ( argv . _ [ 0 ] )
63+ if ( argv . artifactPath ) {
64+ artifactPath = argv . artifactPath
5465 }
5566
5667 const absArtifactPath = path . resolve ( process . cwd ( ) , artifactPath )
@@ -69,7 +80,7 @@ export async function main(args: string[]): Promise<void> {
6980 }
7081 }
7182
72- if ( 'default-projects' in argv ) {
83+ if ( argv . defaultProjects ) {
7384 const serverPath = path . resolve ( __dirname , '..' , 'stacks' , 'server' )
7485 const mainPath = path . resolve ( __dirname , '..' , 'stacks' , 'main' )
7586 pulumiPaths = [ serverPath , mainPath ]
@@ -82,11 +93,11 @@ export async function main(args: string[]): Promise<void> {
8293 let abort : boolean = false
8394
8495 if ( pulumiPaths === undefined ) {
85- console . log ( 'Paths to pulumi projects could not be determined. ' )
96+ console . log ( 'Paths to pulumi projects could not be determined' )
8697 abort = true
8798 }
8899
89- if ( pulumiPaths === undefined ) {
100+ if ( stackName === undefined ) {
90101 console . log ( 'Stack name could not be determined' )
91102 abort = true
92103 }
@@ -105,7 +116,7 @@ export async function main(args: string[]): Promise<void> {
105116 retries = 0
106117 exitCode = 1
107118
108- if ( 'f' in argv || 'force' in argv ) {
119+ if ( argv . f || argv . force ) {
109120 spawnSync ( 'pulumi' , [ 'cancel' , '-s' , stackName ! , '-y' ] , {
110121 cwd : pulumiPath ,
111122 stdio : [ process . stdin , process . stdout , process . stderr ] ,
0 commit comments