Repository navigation
[C3] Bump create-analog from 2.9.7 to 3.0.0 in /packages/create-cloudflare/src/frameworks #17266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
petebacondarwin
merged 10 commits into
main
from
dependabot/npm_and_yarn/packages/create-cloudflare/src/frameworks/create-analog-3.0.0
Nov 30, 2026
+636
−90
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8e22473
[C3] Bump create-analog in /packages/create-cloudflare/src/frameworks
dependabot[bot] 80a1470
Update dependencies of "create-cloudflare"
6a6a227
Fix Analog 3 Workers scaffolding
petebacondarwin 99bc57b
Fail early on unexpected Analog Nitro configuration
petebacondarwin e0395a4
Reject NestJS before scaffolding Analog for Workers
petebacondarwin 3b96111
Respect Analog generator option delimiter
petebacondarwin ff384e6
Configure Analog 3 Nitro in Wrangler setup
petebacondarwin 04ceaf6
Handle Analog Minimal and named Nitro imports
petebacondarwin d15de15
Fix Analog static option precedence and starter routing
petebacondarwin 926a72a
Validate Analog starter and test generated SPA config
petebacondarwin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "create-cloudflare": patch | ||
| --- | ||
|
|
||
| Scaffold new Analog projects with `create-analog` 3.0.0 | ||
|
|
||
| C3 configures Analog 3's standalone Nitro plugin to build for Cloudflare Workers, so new projects can use the generated preview and deploy scripts. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| "@cloudflare/autoconfig": minor | ||
| "create-cloudflare": patch | ||
| "wrangler": minor | ||
| --- | ||
|
|
||
| Support Analog 3 in `wrangler setup` | ||
|
|
||
| Configure Analog’s standalone Nitro Vite plugin for Cloudflare Workers. Both `wrangler setup` and `create-cloudflare` configure the Minimal starter as a static site. Analog 2 projects continue to use the Nitro options on the Analog Vite plugin. Projects using native Nitro 3 (`nitro/vite`) should use Nitro’s generated Wrangler configuration instead. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,94 +1,173 @@ | ||
| import { existsSync } from "node:fs"; | ||
| import { existsSync, writeFileSync } from "node:fs"; | ||
| import { join } from "node:path"; | ||
| import { updateStatus } from "@cloudflare/cli-shared-helpers"; | ||
| import { blue } from "@cloudflare/cli-shared-helpers/colors"; | ||
| import { | ||
| isAnalogStaticSite, | ||
| mergeObjectProperties, | ||
| transformFile, | ||
| parseFile, | ||
| } from "@cloudflare/shared-ast-primitives"; | ||
| import { DEFAULT_COMPAT_DATE } from "@cloudflare/workers-utils"; | ||
| import * as recast from "recast"; | ||
| import { major } from "semver"; | ||
| import { AutoConfigFrameworkConfigurationError } from "../errors"; | ||
| import { Framework } from "./framework-class"; | ||
| import type { | ||
| ConfigurationOptions, | ||
| ConfigurationResults, | ||
| } from "./framework-class"; | ||
|
|
||
| export class Analog extends Framework { | ||
| async configure({ | ||
| configure({ | ||
| dryRun, | ||
| projectPath, | ||
| }: ConfigurationOptions): Promise<ConfigurationResults> { | ||
| if (!dryRun) { | ||
| await updateViteConfig(projectPath); | ||
| } | ||
| }: ConfigurationOptions): ConfigurationResults { | ||
| const staticSite = configureVite( | ||
| projectPath, | ||
| major(this.frameworkVersion) >= 3, | ||
| dryRun | ||
| ); | ||
|
|
||
| return { | ||
| buildTool: "wrangler", | ||
| workerConfig: { | ||
| entrypoint: "./dist/analog/server/index.mjs", | ||
| env: { | ||
| ASSETS: { type: "assets" }, | ||
| }, | ||
| }, | ||
| workerConfig: staticSite | ||
| ? { assets: { notFoundHandling: "single-page-application" } } | ||
| : { | ||
| entrypoint: "./dist/analog/server/index.mjs", | ||
| env: { ASSETS: { type: "assets" } }, | ||
| }, | ||
| buildConfig: { assetsDirectory: "./dist/analog/public" }, | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| async function updateViteConfig(projectPath: string) { | ||
| const viteConfigTsPAth = join(projectPath, "vite.config.ts"); | ||
| const viteConfigJsPath = join(projectPath, "vite.config.js"); | ||
|
|
||
| let viteConfigPath: string; | ||
|
|
||
| if (existsSync(viteConfigTsPAth)) { | ||
| viteConfigPath = viteConfigTsPAth; | ||
| } else if (existsSync(viteConfigJsPath)) { | ||
| viteConfigPath = viteConfigJsPath; | ||
| } else { | ||
| function configureVite( | ||
| projectPath: string, | ||
| standaloneNitro: boolean, | ||
| dryRun: boolean | ||
| ) { | ||
| const viteConfigPath = ["vite.config.ts", "vite.config.js"] | ||
| .map((file) => join(projectPath, file)) | ||
| .find(existsSync); | ||
| if (!viteConfigPath) { | ||
| throw new Error("Could not find Vite config file to modify"); | ||
| } | ||
|
|
||
| const compatDate = DEFAULT_COMPAT_DATE; | ||
|
|
||
| updateStatus(`Updating configuration in ${blue(viteConfigPath)}`); | ||
|
|
||
| transformFile(viteConfigPath, { | ||
| visitCallExpression: function (n) { | ||
| const callee = n.node.callee as recast.types.namedTypes.Identifier; | ||
| if (callee.name !== "analog") { | ||
| return this.traverse(n); | ||
| } | ||
| const config = parseFile(viteConfigPath); | ||
| if ( | ||
| standaloneNitro && | ||
| config?.body.some( | ||
| (statement) => | ||
| statement.type === "ImportDeclaration" && | ||
| statement.source.value === "nitro/vite" | ||
| ) | ||
| ) { | ||
| throw new AutoConfigFrameworkConfigurationError( | ||
| "Wrangler setup cannot configure Analog's native Nitro 3 integration (nitro/vite). Set the cloudflare_module preset in Nitro and deploy using the Wrangler configuration generated by Nitro.", | ||
| { telemetryMessage: "analog native nitro setup unsupported" } | ||
| ); | ||
| } | ||
| const nitroImport = config?.body.find( | ||
| (statement) => | ||
| statement.type === "ImportDeclaration" && | ||
| statement.source.value === "@analogjs/vite-plugin-nitro" | ||
| ); | ||
|
devin-ai-integration[bot] marked this conversation as resolved.
Resolved
|
||
| const nitroPlugin = | ||
| nitroImport?.type === "ImportDeclaration" | ||
| ? nitroImport.specifiers.find( | ||
| (specifier) => | ||
| specifier.type === "ImportDefaultSpecifier" || | ||
| (specifier.type === "ImportSpecifier" && | ||
| specifier.imported.type === "Identifier" && | ||
| specifier.imported.name === "nitro") | ||
| )?.local?.name | ||
| : undefined; | ||
|
devin-ai-integration[bot] marked this conversation as resolved.
Resolved
|
||
| const platformImport = config?.body.find( | ||
| (statement) => | ||
| statement.type === "ImportDeclaration" && | ||
| statement.source.value === "@analogjs/platform" | ||
| ); | ||
| const platformPlugin = | ||
| (platformImport?.type === "ImportDeclaration" | ||
| ? platformImport.specifiers.find( | ||
| (specifier) => specifier.type === "ImportDefaultSpecifier" | ||
| )?.local?.name | ||
| : undefined) ?? "analog"; | ||
| const pluginName = standaloneNitro ? nitroPlugin : platformPlugin; | ||
| const pluginDescription = standaloneNitro | ||
| ? "the @analogjs/vite-plugin-nitro plugin" | ||
| : "the Analog Vite plugin"; | ||
| let configured = false; | ||
| let platformOptions: recast.types.namedTypes.ObjectExpression | undefined; | ||
| let standaloneNitroOptions: | ||
| | recast.types.namedTypes.ObjectExpression | ||
| | undefined; | ||
| if (config && pluginName) { | ||
| recast.visit(config, { | ||
| visitCallExpression(call) { | ||
| const { callee, arguments: args } = call.node; | ||
| const pluginOptions = args[0]; | ||
| if (callee.type === "Identifier" && callee.name === platformPlugin) { | ||
| platformOptions = | ||
| pluginOptions?.type === "ObjectExpression" | ||
| ? pluginOptions | ||
| : undefined; | ||
| } | ||
| if (callee.type !== "Identifier" || callee.name !== pluginName) { | ||
| return this.traverse(call); | ||
| } | ||
|
|
||
| const b = recast.types.builders; | ||
| const presetDef = [ | ||
| b.objectProperty( | ||
| b.identifier("nitro"), | ||
| b.objectExpression([ | ||
| // preset: "cloudflare_module" | ||
| b.objectProperty( | ||
| b.identifier("preset"), | ||
| b.stringLiteral("cloudflare_module") | ||
| ), | ||
| b.objectProperty( | ||
| b.identifier("compatibilityDate"), | ||
| b.stringLiteral(compatDate) | ||
| ), | ||
| ]) | ||
| ), | ||
| ]; | ||
| const builders = recast.types.builders; | ||
| if (standaloneNitro && pluginOptions?.type === "ObjectExpression") { | ||
| standaloneNitroOptions = pluginOptions; | ||
| } | ||
| const nitroOptions = [ | ||
| builders.objectProperty( | ||
| builders.identifier("preset"), | ||
| builders.stringLiteral("cloudflare_module") | ||
| ), | ||
| builders.objectProperty( | ||
| builders.identifier("compatibilityDate"), | ||
| builders.stringLiteral(DEFAULT_COMPAT_DATE) | ||
| ), | ||
| ]; | ||
| const options = standaloneNitro | ||
| ? nitroOptions | ||
| : [ | ||
| builders.objectProperty( | ||
| builders.identifier("nitro"), | ||
| builders.objectExpression(nitroOptions) | ||
| ), | ||
| ]; | ||
|
|
||
| if (n.node.arguments.length === 0) { | ||
| n.node.arguments.push(b.objectExpression(presetDef)); | ||
| } else { | ||
| mergeObjectProperties( | ||
| n.node.arguments[0] as recast.types.namedTypes.ObjectExpression, | ||
| presetDef | ||
| ); | ||
| } | ||
| if (args.length === 0) { | ||
| args.push(builders.objectExpression(options)); | ||
| } else if (pluginOptions?.type === "ObjectExpression") { | ||
| mergeObjectProperties(pluginOptions, options); | ||
| } else { | ||
| throw new AutoConfigFrameworkConfigurationError( | ||
| `Cannot configure Analog for Cloudflare Workers: expected ${pluginDescription} in ${viteConfigPath} to receive an object literal or no arguments.`, | ||
| { telemetryMessage: "unexpected vite config" } | ||
| ); | ||
| } | ||
|
|
||
| return false; | ||
| }, | ||
| }); | ||
| configured = true; | ||
| return false; | ||
| }, | ||
| }); | ||
| } | ||
| if (!config || !configured) { | ||
| throw new AutoConfigFrameworkConfigurationError( | ||
| `Cannot configure Analog for Cloudflare Workers: no call to ${pluginDescription} found in ${viteConfigPath}.`, | ||
| { telemetryMessage: "unexpected vite config" } | ||
| ); | ||
| } | ||
| if (!dryRun) { | ||
| updateStatus(`Updating configuration in ${blue(viteConfigPath)}`); | ||
| writeFileSync(viteConfigPath, recast.print(config).code); | ||
| } | ||
| return ( | ||
| standaloneNitro && | ||
| isAnalogStaticSite(platformOptions, standaloneNitroOptions) | ||
| ); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.