2023-02-11 17:59:00 +03:00
|
|
|
#!/usr/bin/env tea
|
2023-02-01 09:13:09 +03:00
|
|
|
|
|
|
|
/*---
|
|
|
|
args:
|
|
|
|
- deno
|
|
|
|
- run
|
|
|
|
- --allow-read
|
|
|
|
- --allow-env
|
|
|
|
- --allow-net
|
|
|
|
- --allow-sys
|
|
|
|
---*/
|
|
|
|
|
|
|
|
import { usePantry } from "hooks"
|
|
|
|
import * as ARGV from "./utils/args.ts"
|
2023-02-03 00:51:19 +03:00
|
|
|
import { SQSClient, SendMessageCommand } from "npm:@aws-sdk/client-sqs@^3"
|
|
|
|
import { panic } from "utils"
|
2023-02-01 09:13:09 +03:00
|
|
|
|
2023-02-03 00:51:19 +03:00
|
|
|
const sqsClient = new SQSClient({ region: Deno.env.get("AWS_REGION") ?? panic("No region specified") })
|
2023-02-01 09:13:09 +03:00
|
|
|
const pantry = usePantry()
|
|
|
|
|
|
|
|
const pkgs = await ARGV.toArray(ARGV.pkgs())
|
2023-02-03 00:51:19 +03:00
|
|
|
for(const pkg of pkgs) {
|
2023-02-01 09:13:09 +03:00
|
|
|
try {
|
2023-02-03 00:51:19 +03:00
|
|
|
const yml = await pantry.getYAML(pkg).parse()
|
|
|
|
|
|
|
|
const project = pkg.project
|
2023-02-01 09:13:09 +03:00
|
|
|
|
|
|
|
const taskMessage = {
|
|
|
|
project,
|
|
|
|
github: yml?.versions?.github || "",
|
|
|
|
// TODO: add other useable data here eventually
|
|
|
|
}
|
|
|
|
const res = await sqsClient.send(new SendMessageCommand({
|
|
|
|
MessageGroupId: 'project',
|
|
|
|
MessageDeduplicationId: project,
|
|
|
|
MessageBody: JSON.stringify(taskMessage),
|
|
|
|
QueueUrl: Deno.env.get("SQS_GENERATE_PACKAGE_DETAILS_URL")!,
|
|
|
|
}))
|
|
|
|
console.log(`SQS task for pkg:${project} messageId:${res.MessageId}`)
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
|
|
|
}
|
|
|
|
}
|