@cloudflare/autoconfig 0.5.0 → 0.6.0

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.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { WorkerConfigInput } from '@cloudflare/config';
1
+ import { WorkerConfig } from '@cloudflare/config';
2
2
  import { PackageManager, PackageJSON, RawConfig, Config, FatalError, TelemetryMessage, UserError } from '@cloudflare/workers-utils';
3
3
  export { getInstalledPackageVersion } from '@cloudflare/workers-utils';
4
4
 
@@ -177,7 +177,7 @@ type ConfigurationResults = {
177
177
  /** The tool that cf should delegate build and development commands to. */
178
178
  buildTool?: "vite" | "wrangler";
179
179
  /** Worker configuration generated by the framework. `null` if an external tool generates it. */
180
- workerConfig: Partial<WorkerConfigInput> | null;
180
+ workerConfig: Partial<WorkerConfig> | null;
181
181
  /** Build configuration that complements the Worker configuration. */
182
182
  buildConfig?: BuildConfig;
183
183
  packageJsonScriptsOverrides?: PackageJsonScriptsOverrides;
@@ -245,7 +245,7 @@ type AutoConfigOptions = {
245
245
  };
246
246
  type AutoConfigSummary = {
247
247
  scripts: Record<string, string>;
248
- workerConfig?: WorkerConfigInput;
248
+ workerConfig?: WorkerConfig;
249
249
  buildConfig?: BuildConfig;
250
250
  wranglerConfig?: RawConfig;
251
251
  frameworkConfiguration?: string;
@@ -322,7 +322,7 @@ declare function runAutoConfig(autoConfigDetails: AutoConfigDetails, autoConfigO
322
322
  */
323
323
  declare function buildOperationsSummary(autoConfigDetails: AutoConfigDetailsForNonConfiguredProject & {
324
324
  outputDir: NonNullable<AutoConfigDetails["outputDir"]>;
325
- }, workerConfig: WorkerConfigInput | null, configurationResults: ConfigurationResults, projectCommands: {
325
+ }, workerConfig: WorkerConfig | null, configurationResults: ConfigurationResults, projectCommands: {
326
326
  build?: string;
327
327
  deploy: string;
328
328
  version?: string;
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ import { fileURLToPath } from 'node:url';
17
17
  import os from 'node:os';
18
18
  import tty from 'node:tty';
19
19
  import { maybeAppendWranglerToGitIgnore, maybeAppendWranglerToGitIgnoreLikeFile } from '@cloudflare/cli-shared-helpers/gitignore';
20
- import { InputWorkerSchema, convertToWranglerConfig } from '@cloudflare/config';
20
+ import { InputConfigSchema, convertToWranglerConfig } from '@cloudflare/config';
21
21
 
22
22
  // ../../node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs
23
23
  var tslib_es6_exports = {};
@@ -52203,7 +52203,9 @@ async function detectFramework(projectPath, context, {
52203
52203
  context
52204
52204
  );
52205
52205
  if (maybeDetectedFramework && target === "cf") {
52206
- const detectedFrameworkSettings = project.frameworks.get(maybeDetectedFramework.baseDirectory ?? "")?.find(({ id }) => id === maybeDetectedFramework.framework.id);
52206
+ const frameworkId = maybeDetectedFramework.framework.id;
52207
+ const frameworkIsSupported = isKnownFramework(frameworkId) && isFrameworkSupported(frameworkId);
52208
+ const detectedFrameworkSettings = frameworkIsSupported ? project.frameworks.get(maybeDetectedFramework.baseDirectory ?? "")?.find(({ id }) => id === frameworkId) : void 0;
52207
52209
  maybeDetectedFramework.devCommand = detectedFrameworkSettings?.dev?.command;
52208
52210
  maybeDetectedFramework.buildCommand = detectedFrameworkSettings?.build?.command;
52209
52211
  }
@@ -52782,11 +52784,8 @@ function getWranglerConfig(workerConfig, configurationResults) {
52782
52784
  if (workerConfig === null) {
52783
52785
  return null;
52784
52786
  }
52785
- const parsedWorkerConfig = InputWorkerSchema.parse({
52786
- type: "worker",
52787
- ...workerConfig
52788
- });
52789
- const convertedWranglerConfig = convertToWranglerConfig(parsedWorkerConfig);
52787
+ const parsedConfig = InputConfigSchema.parse({ worker: workerConfig });
52788
+ const convertedWranglerConfig = convertToWranglerConfig(parsedConfig);
52790
52789
  const wranglerConfig = ensureNodejsCompatIsEnabled({
52791
52790
  $schema: "node_modules/wrangler/config-schema.json",
52792
52791
  ...convertedWranglerConfig,
@@ -52849,9 +52848,11 @@ async function saveWranglerConfigTs(projectPath, buildConfig) {
52849
52848
  }
52850
52849
  __name(saveWranglerConfigTs, "saveWranglerConfigTs");
52851
52850
  function renderCloudflareConfig(workerConfig) {
52852
- return `import { defineWorker } from "cf/config";
52851
+ return `import { defineConfig } from "cf/config";
52853
52852
 
52854
- export default defineWorker(${JSON.stringify(workerConfig, null, 2)});
52853
+ export default defineConfig({
52854
+ worker: ${JSON.stringify(workerConfig, null, 2).replaceAll("\n", "\n ")}
52855
+ });
52855
52856
  `;
52856
52857
  }
52857
52858
  __name(renderCloudflareConfig, "renderCloudflareConfig");