mirror of
https://github.com/seemueller-io/cluster.git
synced 2025-09-08 22:56:46 +00:00
Development environment functions
This commit is contained in:
14
packages/scripts/legacy/deploy.ts
Executable file
14
packages/scripts/legacy/deploy.ts
Executable file
@@ -0,0 +1,14 @@
|
||||
// Legacy: not used
|
||||
// Intended to run the entire deployment process and generate artifacts for client applications without requiring developer intervention
|
||||
|
||||
// #!/usr/bin/env bun
|
||||
//
|
||||
// import {execSync} from "child_process";
|
||||
//
|
||||
// function deployCdktf() {
|
||||
// execSync("cdktf deploy --auto-approve", {stdio: "inherit"})
|
||||
// execSync("./extract-outputs.ts", {stdio: "inherit"})
|
||||
// execSync("./update-vars.ts", {stdio: "inherit"})
|
||||
// }
|
||||
//
|
||||
// deployCdktf()
|
64
packages/scripts/legacy/extract-outputs.ts
Executable file
64
packages/scripts/legacy/extract-outputs.ts
Executable file
@@ -0,0 +1,64 @@
|
||||
// Legacy: not used
|
||||
|
||||
// #!/usr/bin/env bun
|
||||
//
|
||||
// import * as fs from 'fs';
|
||||
// import * as path from 'path';
|
||||
//
|
||||
// interface TerraformOutput {
|
||||
// value: any;
|
||||
// type: string | string[];
|
||||
// sensitive?: boolean;
|
||||
// }
|
||||
//
|
||||
// interface TerraformState {
|
||||
// outputs: Record<string, TerraformOutput>;
|
||||
// }
|
||||
//
|
||||
// export function extractOutputsToFile(successfulDeploy: boolean = true ) {
|
||||
// if(!successfulDeploy) {
|
||||
// console.log("[INFO] Skipping outputs extraction, because the deployment was not successful.")
|
||||
// return
|
||||
// }
|
||||
// const stateFilePath = path.join(__dirname, 'terraform.zitadel-dev.tfstate');
|
||||
// const outputFilePath = path.join(__dirname, 'terraform-outputs.json');
|
||||
//
|
||||
// try {
|
||||
// // Read the terraform state file
|
||||
// const stateContent = fs.readFileSync(stateFilePath, 'utf-8');
|
||||
// const state: TerraformState = JSON.parse(stateContent);
|
||||
//
|
||||
// // Extract outputs with their values (unmasked)
|
||||
// const outputs: Record<string, any> = {};
|
||||
//
|
||||
// for (const [key, output] of Object.entries(state.outputs)) {
|
||||
// outputs[key] = {
|
||||
// value: output.value,
|
||||
// type: output.type,
|
||||
// sensitive: output.sensitive || false
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// // Write outputs to file
|
||||
// fs.writeFileSync(outputFilePath, JSON.stringify(outputs, null, 2));
|
||||
//
|
||||
// console.log(`✅ Terraform outputs successfully written to: ${outputFilePath}`);
|
||||
// console.log(`📋 Extracted ${Object.keys(outputs).length} outputs:`);
|
||||
//
|
||||
// // Display summary without showing sensitive values in console
|
||||
// for (const [key, output] of Object.entries(outputs)) {
|
||||
// if (output.sensitive) {
|
||||
// console.log(` - ${key}: [SENSITIVE - written to file unmasked]`);
|
||||
// } else {
|
||||
// console.log(` - ${key}: ${JSON.stringify(output.value)}`);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// } catch (error) {
|
||||
// console.error('❌ Error extracting outputs:', error);
|
||||
// process.exit(1);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Run the extraction
|
||||
// extractOutputsToFile();
|
39
packages/scripts/legacy/update-vars.ts
Executable file
39
packages/scripts/legacy/update-vars.ts
Executable file
@@ -0,0 +1,39 @@
|
||||
// Legacy: not used
|
||||
// #!/usr/bin/env bun
|
||||
//
|
||||
// import {readFileSync, writeFileSync} from "fs";
|
||||
// import {execSync} from "child_process";
|
||||
//
|
||||
//
|
||||
// export function configureDevVars() {
|
||||
// const terraformOutputs = JSON.parse(readFileSync("terraform-outputs.json", 'utf-8'));
|
||||
//
|
||||
// interface DevVarsConfig {
|
||||
// CLIENT_ID: string;
|
||||
// CLIENT_SECRET: string;
|
||||
// AUTH_SERVER_URL: string;
|
||||
// APP_URL: string;
|
||||
// DEV_MODE: string;
|
||||
// ZITADEL_ORG_ID: string;
|
||||
// ZITADEL_PROJECT_ID: string;
|
||||
// }
|
||||
//
|
||||
// const destinationConfig: DevVarsConfig = {
|
||||
// CLIENT_ID: terraformOutputs.client_id.value,
|
||||
// CLIENT_SECRET: terraformOutputs.client_secret.value,
|
||||
// AUTH_SERVER_URL: "https://machine.127.0.0.1.sslip.io",
|
||||
// APP_URL: "http://localhost:8787",
|
||||
// DEV_MODE: "true",
|
||||
// ZITADEL_ORG_ID: terraformOutputs.created_org.value.id,
|
||||
// ZITADEL_PROJECT_ID: terraformOutputs.created_project.value.id,
|
||||
// }
|
||||
//
|
||||
// const repoRoot = execSync('git rev-parse --show-toplevel').toString().trim();
|
||||
// const formattedConfig = Object.entries(destinationConfig)
|
||||
// .map(([key, value]) => `${key}="${value}"`)
|
||||
// .join('\n');
|
||||
//
|
||||
// writeFileSync(`${repoRoot}/.dev.vars`, formattedConfig);
|
||||
// }
|
||||
//
|
||||
// configureDevVars()
|
Reference in New Issue
Block a user