@bluealba/platform-cli 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +76 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1302,6 +1302,7 @@ async function createUiModule(params, logger) {
1302
1302
  import { spawn as spawn3 } from "child_process";
1303
1303
  import { access as access7 } from "fs/promises";
1304
1304
  import { join as join24, resolve as resolve5 } from "path";
1305
+ import { fetch as undiciFetch2, Agent as Agent2 } from "undici";
1305
1306
 
1306
1307
  // src/commands/local-scripts/docker-compose-orchestrator.ts
1307
1308
  import { spawn } from "child_process";
@@ -2015,6 +2016,40 @@ async function checkContainersPerApp(layout, manifest, allContainers) {
2015
2016
  }
2016
2017
  return groups;
2017
2018
  }
2019
+ async function checkIdpProviders(layout) {
2020
+ const envPath = join24(layout.localDir, ".env");
2021
+ let env;
2022
+ try {
2023
+ env = await readEnvFile(envPath);
2024
+ } catch {
2025
+ return { configured: false, providers: [], error: "could not read core/local/.env" };
2026
+ }
2027
+ const gatewayUrl = env.get("PAE_GATEWAY_HOST_URL");
2028
+ const accessSecret = env.get("PAE_GATEWAY_SERVICE_ACCESS_SECRET");
2029
+ if (!gatewayUrl || !accessSecret) {
2030
+ return { configured: false, providers: [], error: "PAE_GATEWAY_HOST_URL or PAE_GATEWAY_SERVICE_ACCESS_SECRET not set" };
2031
+ }
2032
+ const agent = new Agent2({ connect: { rejectUnauthorized: false } });
2033
+ let response;
2034
+ try {
2035
+ response = await undiciFetch2(`${gatewayUrl}/_/providers`, {
2036
+ method: "GET",
2037
+ headers: {
2038
+ Accept: "application/json",
2039
+ Authorization: `Bearer ${accessSecret}`
2040
+ },
2041
+ dispatcher: agent
2042
+ });
2043
+ } catch {
2044
+ return { configured: false, providers: [], error: "gateway unreachable" };
2045
+ }
2046
+ if (!response.ok) {
2047
+ return { configured: false, providers: [], error: `gateway responded with ${response.status}` };
2048
+ }
2049
+ const data = await response.json();
2050
+ const providers = data.map((p) => ({ name: p.name, type: p.type, active: p.active }));
2051
+ return { configured: providers.length > 0, providers };
2052
+ }
2018
2053
  async function gatherStatus() {
2019
2054
  const layout = await findPlatformLayout();
2020
2055
  const [nodeCheck, dockerCheck] = await Promise.all([checkNodeVersion(), checkDocker()]);
@@ -2033,7 +2068,8 @@ async function gatherStatus() {
2033
2068
  },
2034
2069
  containers: [],
2035
2070
  containersByApp: [],
2036
- coreDirName: null
2071
+ coreDirName: null,
2072
+ idp: null
2037
2073
  };
2038
2074
  }
2039
2075
  let manifest;
@@ -2053,7 +2089,8 @@ async function gatherStatus() {
2053
2089
  },
2054
2090
  containers: [],
2055
2091
  containersByApp: [],
2056
- coreDirName: layout.coreDirName
2092
+ coreDirName: layout.coreDirName,
2093
+ idp: null
2057
2094
  };
2058
2095
  }
2059
2096
  const [installedDetails, builtDetails, containers] = await Promise.all([
@@ -2062,6 +2099,8 @@ async function gatherStatus() {
2062
2099
  checkContainers(layout, manifest)
2063
2100
  ]);
2064
2101
  const containersByApp = await checkContainersPerApp(layout, manifest, containers);
2102
+ const running = containers.length > 0 && containers.every((c) => c.state === "running");
2103
+ const idp = running ? await checkIdpProviders(layout) : null;
2065
2104
  const projectInfo = {
2066
2105
  productName: manifest.product.name,
2067
2106
  displayName: manifest.product.displayName,
@@ -2079,11 +2118,12 @@ async function gatherStatus() {
2079
2118
  installedDetails,
2080
2119
  built: builtDetails.every((d) => d.exists),
2081
2120
  builtDetails,
2082
- running: containers.length > 0 && containers.every((c) => c.state === "running")
2121
+ running
2083
2122
  },
2084
2123
  containers,
2085
2124
  containersByApp,
2086
- coreDirName: layout.coreDirName
2125
+ coreDirName: layout.coreDirName,
2126
+ idp
2087
2127
  };
2088
2128
  }
2089
2129
 
@@ -2097,7 +2137,7 @@ var statusCommand = {
2097
2137
 
2098
2138
  // src/commands/manage-platform-admins/manage-platform-admins.command.ts
2099
2139
  import { join as join25 } from "path";
2100
- import { fetch as undiciFetch2, Agent as Agent2 } from "undici";
2140
+ import { fetch as undiciFetch3, Agent as Agent3 } from "undici";
2101
2141
  var MANAGE_PLATFORM_ADMINS_COMMAND_NAME = "manage-platform-admins";
2102
2142
  var managePlatformAdminsCommand = {
2103
2143
  name: MANAGE_PLATFORM_ADMINS_COMMAND_NAME,
@@ -2134,10 +2174,10 @@ async function listPlatformAdmins(logger) {
2134
2174
  const config = await getGatewayConfig(logger);
2135
2175
  if (!config) return [];
2136
2176
  const { gatewayUrl, accessSecret } = config;
2137
- const agent = new Agent2({ connect: { rejectUnauthorized: false } });
2177
+ const agent = new Agent3({ connect: { rejectUnauthorized: false } });
2138
2178
  let response;
2139
2179
  try {
2140
- response = await undiciFetch2(`${gatewayUrl}/applications/platform/rules`, {
2180
+ response = await undiciFetch3(`${gatewayUrl}/applications/platform/rules`, {
2141
2181
  method: "GET",
2142
2182
  headers: {
2143
2183
  Accept: "application/json",
@@ -2165,10 +2205,10 @@ async function addPlatformAdmin(username, logger) {
2165
2205
  const config = await getGatewayConfig(logger);
2166
2206
  if (!config) return false;
2167
2207
  const { gatewayUrl, accessSecret } = config;
2168
- const agent = new Agent2({ connect: { rejectUnauthorized: false } });
2208
+ const agent = new Agent3({ connect: { rejectUnauthorized: false } });
2169
2209
  let response;
2170
2210
  try {
2171
- response = await undiciFetch2(`${gatewayUrl}/applications/platform/rules`, {
2211
+ response = await undiciFetch3(`${gatewayUrl}/applications/platform/rules`, {
2172
2212
  method: "POST",
2173
2213
  headers: {
2174
2214
  "Content-Type": "application/json",
@@ -2204,10 +2244,10 @@ async function removePlatformAdmin(ruleId, logger) {
2204
2244
  const config = await getGatewayConfig(logger);
2205
2245
  if (!config) return false;
2206
2246
  const { gatewayUrl, accessSecret } = config;
2207
- const agent = new Agent2({ connect: { rejectUnauthorized: false } });
2247
+ const agent = new Agent3({ connect: { rejectUnauthorized: false } });
2208
2248
  let response;
2209
2249
  try {
2210
- response = await undiciFetch2(`${gatewayUrl}/applications/platform/rules/${ruleId}`, {
2250
+ response = await undiciFetch3(`${gatewayUrl}/applications/platform/rules/${ruleId}`, {
2211
2251
  method: "DELETE",
2212
2252
  headers: {
2213
2253
  Authorization: `Bearer ${accessSecret}`
@@ -2551,6 +2591,20 @@ function formatStatusLines(result) {
2551
2591
  lines.push(` ${tick(ok)} ${c.name.padEnd(35)} ${stateStr}${ports}`);
2552
2592
  }
2553
2593
  }
2594
+ if (result.idp !== null) {
2595
+ lines.push("");
2596
+ lines.push(theme.section("Identity Providers"));
2597
+ if (result.idp.error) {
2598
+ lines.push(` ${CROSS} ${theme.warning(result.idp.error)}`);
2599
+ } else if (result.idp.configured) {
2600
+ for (const p of result.idp.providers) {
2601
+ const activeStr = p.active ? theme.success("active") : theme.warning("inactive");
2602
+ lines.push(` ${CHECK} ${p.name} ${theme.label(`(${p.type})`)} \u2014 ${activeStr}`);
2603
+ }
2604
+ } else {
2605
+ lines.push(` ${CROSS} ${theme.warning("No identity providers configured")}`);
2606
+ }
2607
+ }
2554
2608
  return lines;
2555
2609
  }
2556
2610
 
@@ -2568,6 +2622,13 @@ async function statusUiController(ctx) {
2568
2622
  }
2569
2623
  const { step, appNames, allApps } = computeNextStepInfo(result);
2570
2624
  if (step === null) {
2625
+ if (result.idp && !result.idp.configured && !result.idp.error) {
2626
+ const shouldConfigure = await ctx.confirm("No IDP configured. Configure one now?", true);
2627
+ if (shouldConfigure) {
2628
+ await configureIdpUiController(ctx);
2629
+ continue;
2630
+ }
2631
+ }
2571
2632
  ctx.log("");
2572
2633
  ctx.log("All checks passed!");
2573
2634
  return;
@@ -3333,6 +3394,10 @@ var statusCliController = async (_args) => {
3333
3394
  }
3334
3395
  process.exit(1);
3335
3396
  }
3397
+ if (result.idp && !result.idp.configured && !result.idp.error) {
3398
+ console.log("");
3399
+ console.log(`Hint: Run "platform configure-idp" to set up an identity provider.`);
3400
+ }
3336
3401
  };
3337
3402
 
3338
3403
  // src/controllers/cli/manage-platform-admins.cli-controller.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluealba/platform-cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Blue Alba Platform CLI",
5
5
  "license": "PolyForm-Noncommercial-1.0.0",
6
6
  "type": "module",