Skip to content

Commit 0886360

Browse files
committed
feat: use yargs to provide help for destroy script
1 parent 361f73b commit 0886360

File tree

2 files changed

+31
-13
lines changed

2 files changed

+31
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export interface AWSAdapterProps {
9292
## Server Environment Variables
9393

9494
Variables can be included in the environment of the SSR server by defining them
95-
in a `.env` file. For example:
95+
in a `.env` file. For example:
9696

9797
```.env
9898
AUTH_SECRET=

bin/destroy.ts

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,51 @@ import { fileURLToPath, pathToFileURL } from 'url'
66
import { spawnSync, SpawnSyncReturns } from 'child_process'
77
import { createRequire } from 'module'
88

9-
import yargs from 'yargs/yargs';
9+
import yargs from 'yargs/yargs'
1010

1111
import { AWSAdapterProps } from '../adapter'
1212

1313
const __dirname = fileURLToPath(new URL('.', import.meta.url))
1414

15+
interface Arguments {
16+
[x: string]: unknown
17+
_: (string | number)[]
18+
$0: string
19+
s: string | undefined
20+
'default-projects': string | undefined
21+
}
22+
1523
export async function main(args: string[]): Promise<void> {
1624
let pulumiPaths: string[] | undefined
1725
let stackName: string | undefined
1826

1927
var argv = yargs(process.argv.slice(2))
20-
.usage('Usage: $0 [options]')
21-
.command('$0', 'Destroy the pulumi stacks for sveltekit-adapter-aws-pulumi')
22-
.example('$0', 'count the lines in the given file')
23-
.alias('f', 'file')
24-
.nargs('f', 1)
25-
.describe('f', 'Load a file')
26-
.demandOption(['f'])
27-
.help('h')
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+
})
2844
.alias('h', 'help')
29-
.epilog('copyright 2019')
30-
.argv;
45+
.help()
46+
.parseSync() as Arguments
47+
48+
console.log(argv)
3149

3250
let artifactPath = 'build'
3351

3452
if (argv._.length) {
35-
artifactPath = argv._[0]
53+
artifactPath = String(argv._[0])
3654
}
3755

3856
const absArtifactPath = path.resolve(process.cwd(), artifactPath)

0 commit comments

Comments
 (0)