-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
91 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,7 @@ | |
"main": "index.js", | ||
"scripts": { | ||
"test": "jest src/test", | ||
"cli": "tsx src/cli.ts", | ||
"check": "tsx src/check.ts" | ||
"cli": "tsx src/cli.ts" | ||
}, | ||
"author": "nafis hossain <[email protected]>", | ||
"license": "BSD-3-Clause", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { S3Client } from "@aws-sdk/client-s3"; | ||
|
||
import { getClient } from "./s3"; | ||
import { buildState } from "./state"; | ||
import { getConfig } from "./config"; | ||
import { logger } from "./logger"; | ||
|
||
export const checkState = async (): Promise<void> => { | ||
try { | ||
const config = getConfig(); | ||
const { bucketName, inputConfig } = config; | ||
|
||
const s3Client: S3Client = await getClient(); | ||
|
||
await buildState(bucketName, inputConfig, s3Client); | ||
} catch (err) { | ||
if (err instanceof Error) { | ||
logger.error(err.message); | ||
} else { | ||
logger.error("An unknown error occurred."); | ||
} | ||
process.exit(1); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,28 @@ | ||
import { Command } from "commander"; | ||
|
||
import { run } from "./run"; | ||
import { checkState } from "./check"; | ||
|
||
const program = new Command(); | ||
|
||
program | ||
.command("run") | ||
.description("process all images") | ||
.action(async () => { | ||
await run(); | ||
}); | ||
|
||
program | ||
.command("check") | ||
.description( | ||
"check how many images have been processed and need to be processed" | ||
) | ||
.action(async () => { | ||
await checkState(); | ||
}); | ||
|
||
program.parse(process.argv); | ||
|
||
(async () => { | ||
await run(); | ||
})(); | ||
if (!process.argv.slice(2).length) { | ||
program.outputHelp(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters