* Add Cloudflare generator with Wrangler and OpenNext support This update introduces a new Cloudflare generator to streamline configuration and deployment via Wrangler and OpenNext. It registers the necessary templates, modifies project files, and adds Cloudflare-specific scripts and dependencies to the package.json. Additionally, .hbs files are updated in .prettierignore for formatting consistency. * Add GitHub username prompt and improve setup scripts Introduce a prompt for GitHub username to personalize project setup. Enhance the setup scripts by adding PNPM verification, configuring `upstream` remote, and removing the `origin` remote. Adjust health check and error handling for better reliability. * Add Dockerfile generator to turbo generators Introduced a new generator to create Dockerfile configurations for standalone Next.js applications. This includes modifying `next.config.mjs` for standalone output, updating dependencies in `package.json`, and adding a Dockerfile template. The generator is now registered in the turbo setup. * Add console-based logger implementation. This is required for edge environments such as Cloudflare. * Remove deprecated Supabase client utilities The `server-actions-client`, `route-handler-client`, and `server-component-client` utilities have been removed in favor of `getSupabaseServerClient`. This simplifies and consolidates the API, ensuring consistency across server-side usage. Version bumped to 2.9.0 to reflect breaking changes.
91 lines
2.4 KiB
TypeScript
91 lines
2.4 KiB
TypeScript
import type { PlopTypes } from '@turbo/gen';
|
|
import { execSync } from 'node:child_process';
|
|
|
|
import packageJson from '../../../../package.json';
|
|
|
|
export function createCloudflareGenerator(plop: PlopTypes.NodePlopAPI) {
|
|
plop.setGenerator('cloudflare', {
|
|
description: 'Cloudflare generator',
|
|
actions: [
|
|
{
|
|
type: 'add',
|
|
templateFile: 'templates/cloudflare/wrangler.jsonc.hbs',
|
|
path: 'apps/web/wrangler.jsonc',
|
|
data: {
|
|
name: packageJson.name,
|
|
},
|
|
},
|
|
{
|
|
type: 'add',
|
|
templateFile: 'templates/cloudflare/open-next.config.ts.hbs',
|
|
path: 'apps/web/open-next.config.ts',
|
|
},
|
|
{
|
|
type: 'add',
|
|
templateFile: 'templates/cloudflare/dev.vars.hbs',
|
|
path: 'apps/web/.dev.vars',
|
|
},
|
|
{
|
|
type: 'modify',
|
|
path: 'apps/web/next.config.mjs',
|
|
async transform(content) {
|
|
content += `
|
|
import { initOpenNextCloudflareForDev } from '@opennextjs/cloudflare';
|
|
|
|
void initOpenNextCloudflareForDev();
|
|
`;
|
|
|
|
return content;
|
|
},
|
|
},
|
|
{
|
|
type: 'modify',
|
|
path: 'apps/web/package.json',
|
|
async transform(content) {
|
|
const pkg = JSON.parse(content);
|
|
|
|
const deps = ['wrangler', '@opennextjs/cloudflare'];
|
|
|
|
const getVersion = async (dep: string) => {
|
|
const res = await fetch(
|
|
`https://registry.npmjs.org/-/package/${dep}/dist-tags`,
|
|
);
|
|
|
|
const json = await res.json();
|
|
return json.latest;
|
|
};
|
|
|
|
for (const dep of deps) {
|
|
const version = await getVersion(dep);
|
|
pkg.devDependencies![dep] = `^${version}`;
|
|
}
|
|
|
|
pkg.scripts['preview'] =
|
|
'opennextjs-cloudflare build && opennextjs-cloudflare preview';
|
|
pkg.scripts['deploy'] =
|
|
'opennextjs-cloudflare build && opennextjs-cloudflare deploy';
|
|
pkg.scripts['cf-typegen'] =
|
|
'wrangler types --env-interface CloudflareEnv cloudflare-env.d.ts';
|
|
|
|
return JSON.stringify(pkg, null, 2);
|
|
},
|
|
},
|
|
async () => {
|
|
/**
|
|
* Install deps and format everything
|
|
*/
|
|
execSync('pnpm i', {
|
|
stdio: 'inherit',
|
|
});
|
|
|
|
execSync(
|
|
`pnpm run format:fix`,
|
|
);
|
|
|
|
return 'Package scaffolded';
|
|
},
|
|
],
|
|
prompts: [],
|
|
});
|
|
}
|