@biffo/cli 0.148.1 → 0.148.2

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 +42 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2028,6 +2028,13 @@ function standardArguments(pluginName, handler) {
2028
2028
  ["event_bus_name", "module.events.event_bus_name"],
2029
2029
  ["core_api_url", "module.api_gateway.api_endpoint"],
2030
2030
  ["core_api_execution_arn", "module.api_gateway.execution_arn"],
2031
+ // ADR-0021: a user-facing plugin has no Lambda of its own — its module
2032
+ // provisions a frontend S3 origin and REQUIRES the parent distribution's
2033
+ // ARN, with no default. Without this the generated block cannot plan at
2034
+ // all ("No value for required variable"), which is what made #685 break
2035
+ // `terraform plan` for a whole environment. Filtered by declaration below,
2036
+ // so a Lambda-backed legacy module that does not declare it is unaffected.
2037
+ ["cdn_distribution_arn", "module.cdn.distribution_arn"],
2031
2038
  ["tags", "local.tags"]
2032
2039
  ];
2033
2040
  }
@@ -2113,13 +2120,43 @@ function declaredVariables(moduleDir) {
2113
2120
  }
2114
2121
  return names;
2115
2122
  }
2123
+ function declaredOutputs(moduleDir) {
2124
+ const names = /* @__PURE__ */ new Set();
2125
+ let entries;
2126
+ try {
2127
+ entries = readdirSync3(moduleDir, { withFileTypes: true });
2128
+ } catch {
2129
+ return names;
2130
+ }
2131
+ for (const entry of entries) {
2132
+ if (!entry.isFile() || !entry.name.endsWith(".tf")) continue;
2133
+ let contents;
2134
+ try {
2135
+ contents = readFileSync7(join10(moduleDir, entry.name), "utf8");
2136
+ } catch {
2137
+ continue;
2138
+ }
2139
+ for (const match of contents.matchAll(/^\s*output\s+"([^"]+)"/gm)) {
2140
+ names.add(match[1]);
2141
+ }
2142
+ }
2143
+ return names;
2144
+ }
2116
2145
  function renderArguments(args, indent) {
2117
2146
  const width = Math.max(...args.map(([key]) => key.length));
2118
2147
  return args.map(([key, value]) => `${indent}${key.padEnd(width)} = ${value}`).join("\n");
2119
2148
  }
2120
- function renderModuleBlock(pluginName, declared, handler, source) {
2149
+ function renderModuleBlock(pluginName, declared, handler, source, outputs) {
2121
2150
  const args = standardArguments(pluginName, handler).filter(([key]) => declared.has(key));
2122
2151
  const quoted = JSON.stringify(pluginName);
2152
+ const exported = [...outputs].sort().map(
2153
+ (name) => [
2154
+ `output "plugin_${pluginName}_${name}" {`,
2155
+ ` description = "${name} of the ${pluginName} plugin, or null when it is not in enabled_plugins."`,
2156
+ ` value = try(module.plugin_${pluginName}[${quoted}].${name}, null)`,
2157
+ "}"
2158
+ ].join("\n")
2159
+ );
2123
2160
  const lines = [
2124
2161
  `module "plugin_${pluginName}" {`,
2125
2162
  ` source = "${source}"`,
@@ -2127,11 +2164,7 @@ function renderModuleBlock(pluginName, declared, handler, source) {
2127
2164
  "",
2128
2165
  renderArguments(args, " "),
2129
2166
  "}",
2130
- "",
2131
- `output "plugin_${pluginName}_function_arn" {`,
2132
- ` description = "Lambda ARN of the ${pluginName} plugin, or null when it is not in enabled_plugins."`,
2133
- ` value = try(module.plugin_${pluginName}[${quoted}].function_arn, null)`,
2134
- "}"
2167
+ ...exported.length > 0 ? ["", exported.join("\n\n")] : []
2135
2168
  ];
2136
2169
  return lines.join("\n");
2137
2170
  }
@@ -2163,7 +2196,8 @@ function renderGeneratedTerraform(plugins) {
2163
2196
  p.name,
2164
2197
  p.declaredVariables,
2165
2198
  p.handler ?? DEFAULT_PLUGIN_HANDLER,
2166
- p.source ?? THIRD_PARTY_TERRAFORM(p.name)
2199
+ p.source ?? THIRD_PARTY_TERRAFORM(p.name),
2200
+ p.declaredOutputs ?? /* @__PURE__ */ new Set()
2167
2201
  )
2168
2202
  );
2169
2203
  return `${GENERATED_HEADER}
@@ -2184,6 +2218,7 @@ function syncPluginTerraform(cwd) {
2184
2218
  return {
2185
2219
  name,
2186
2220
  declaredVariables: declaredVariables(moduleDir),
2221
+ declaredOutputs: declaredOutputs(moduleDir),
2187
2222
  source: pluginModuleSource(cwd, name)
2188
2223
  };
2189
2224
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biffo/cli",
3
- "version": "0.148.1",
3
+ "version": "0.148.2",
4
4
  "description": "Biffo project scaffolding CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",