Skip to content

Commit

Permalink
chore(turbo): updated Turbo version
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaiah Hall committed Aug 5, 2024
1 parent 0de2971 commit 587c053
Showing 1 changed file with 4 additions and 31 deletions.
35 changes: 4 additions & 31 deletions scripts/turbo/index.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,13 @@
const fs = require("fs");
// Build script to handle Turborepo build execution
const { spawnProcess } = require("../utils/spawn-process");
const path = require("path");

// Fetch Secrets In CI Environments
const fetchSecret = async (secretName) => {
const account = process.env.TURBO_CACHE_AWS_ACCOUNT_ID;
if (!account) {
return null;
}
try {
if (!fs.existsSync(path.join(__dirname, "node_modules/"))) {
await installDeps();
}
const { SecretsManagerClient, GetSecretValueCommand } = require("@aws-sdk/client-secrets-manager");
const partialArn = `arn:aws:secretsmanager:us-west-2:${account}:secret:${secretName}`;
const secretsManager = new SecretsManagerClient({ region: "us-west-2" });
const command = new GetSecretValueCommand({ SecretId: partialArn });

const response = await secretsManager.send(command);
return response.SecretString;
} catch (error) {
console.error("Error fetching turbo remote cache secret:", error);
return null;
}
};

const installDeps = async () => {
return spawnProcess("npm", ["install"], { stdio: "inherit", cwd: __dirname });
};

const runTurbo = async (task, args, apiSecret, apiEndpoint) => {
let command = ["turbo", "run", task];
if (apiSecret && apiEndpoint) {
command = command.concat([
`--api=${apiEndpoint}`,
`--team=aws-sdk-js`,
"--team=aws-sdk-js",
`--token=${apiSecret}`,
"--concurrency=100%",
]);
Expand All @@ -49,8 +22,8 @@ const runTurbo = async (task, args, apiSecret, apiEndpoint) => {
};

const main = async () => {
const apiSecret = process.env.AWS_JS3_TURBO_CACHE_API_SECRET || (await fetchSecret("TURBO_CACHE_API_SECRET"));
const apiEndpoint = process.env.AWS_JS3_TURBO_CACHE_API_ENDPOINT || (await fetchSecret("TURBO_CACHE_API_ENDPOINT"));
const apiSecret = process.env.AWS_JSV3_TURBO_CACHE_API_SECRET;
const apiEndpoint = process.env.AWS_JSV3_TURBO_CACHE_API_ENDPOINT;

const args = process.argv.slice(2);

Expand Down

0 comments on commit 587c053

Please sign in to comment.