From e0448132408d19d939f93acc2fd986a76f88b6cd Mon Sep 17 00:00:00 2001 From: Slawomir Koszewski Date: Tue, 27 Jan 2026 06:24:09 +0100 Subject: [PATCH] Refactor: changed appId configuration variable to clientId. --- bin/setup-app.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bin/setup-app.js b/bin/setup-app.js index 04b8ddd..ada2a38 100755 --- a/bin/setup-app.js +++ b/bin/setup-app.js @@ -50,18 +50,18 @@ try { if (appIdList.length !== 1) { throw new Error("App not found or multiple apps with the same name."); } - config.appId = appIdList[0].appId; + config.clientId = appIdList[0].appId; } catch (error) { console.error("Failed to query Azure AD applications."); process.exit(1); } -if (config.appId) { - console.log(`App already exists with ID: ${config.appId}`); +if (config.clientId) { + console.log(`App already exists with Client ID: ${config.clientId}`); } else { // Create the Azure AD application, capturing the JSON output, and extracting the .appId try { - config.appId = execSync( + config.clientId = execSync( `az ad app create --display-name "${config.appName}" --query "appId" -o tsv`, ) .toString() @@ -70,15 +70,15 @@ if (config.appId) { console.error("Failed to create Azure AD application."); process.exit(1); } - console.log(`Created App with ID: ${config.appId}`); + console.log(`Created App with Client ID: ${config.clientId}`); } -// Chech if service principal exists +// Check if service principal exists let spObjId; try { const spIdList = JSON.parse( - execSync(`az ad sp list --filter "appId eq '${config.appId}'" -o json`) + execSync(`az ad sp list --filter "appId eq '${config.clientId}'" -o json`) .toString() .trim(), ); @@ -98,7 +98,7 @@ if (spObjId) { // Now create the service principal for the app try { spObjId = execSync( - `az ad sp create --id ${config.appId} --query "id" -o tsv`, + `az ad sp create --id ${config.clientId} --query "id" -o tsv`, ); console.log("Service principal created."); } catch (error) { @@ -117,7 +117,7 @@ if (args.values["generate-client-secret"]) { "credential", "reset", "--id", - config.appId, + config.clientId, "--query", "password", "-o", @@ -138,7 +138,7 @@ if (args.values["write-env"] || args.values["generate-client-secret"]) { // Write the APP_ID to the .env file const envContent = `AZ_APP_NAME="${config.appName}" ARM_TENANT_ID=${config.tenantId} -ARM_CLIENT_ID=${config.appId} +ARM_CLIENT_ID=${config.clientId} ARM_CLIENT_SECRET=${config.clientSecret || ""} `;