-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathcmd-action.ts
More file actions
61 lines (54 loc) · 1.63 KB
/
cmd-action.ts
File metadata and controls
61 lines (54 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// https://github.com/SocketDev/socket-python-cli/blob/6d4fc56faee68d3a4764f1f80f84710635bdaf05/socketsecurity/socketcli.py
import meowOrExit from 'meow'
import { runAction } from './run-action.ts'
import { type CliCommandConfig } from '../../utils/meow-with-subcommands'
import { getFlagListOutput } from '../../utils/output-formatting.ts'
const config: CliCommandConfig = {
commandName: 'action',
description: 'Socket action command', // GitHub Action ?
hidden: true,
flags: {
// This flag is unused
// socketSecurityApiKey: { // deprecate this asap.
// type: 'string',
// default: 'env var SOCKET_SECURITY_API_KEY',
// description: 'Socket API token'
// },
githubEventBefore: {
type: 'string',
default: '',
description: 'Before marker'
},
githubEventAfter: {
type: 'string',
default: '',
description: 'After marker'
}
},
help: (parentName, { commandName, flags }) => `
Usage
$ ${parentName} ${commandName} [options]
Options
${getFlagListOutput(flags, 6)}
`
}
export const cmdAction = {
description: config.description,
hidden: config.hidden,
run: run
}
async function run(
argv: readonly string[],
importMeta: ImportMeta,
{ parentName }: { parentName: string }
): Promise<void> {
const cli = meowOrExit(config.help(parentName, config), {
argv,
description: config.description,
importMeta,
flags: config.flags
})
const githubEventBefore = String(cli.flags['githubEventBefore'] || '')
const githubEventAfter = String(cli.flags['githubEventAfter'] || '')
await runAction(githubEventBefore, githubEventAfter)
}