Open-next Cloudflare / Docker / Setup (#248)
* 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.
This commit is contained in:
committed by
GitHub
parent
76bfeddd32
commit
4cfb4f936f
@@ -1,10 +1,17 @@
|
||||
import type {PlopTypes} from '@turbo/gen';
|
||||
import {execSync} from 'node:child_process';
|
||||
import type { PlopTypes } from '@turbo/gen';
|
||||
import { execSync } from 'node:child_process';
|
||||
import { writeFileSync } from 'node:fs';
|
||||
|
||||
export function createSetupGenerator(plop: PlopTypes.NodePlopAPI) {
|
||||
plop.setGenerator('setup', {
|
||||
description: 'Setup your Makerkit project',
|
||||
prompts: [
|
||||
{
|
||||
type: 'input',
|
||||
name: 'username',
|
||||
message:
|
||||
'What is your GitHub username? Please make sure you enter the same username you used to activate your Makerkit license.',
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'projectName',
|
||||
@@ -15,9 +22,21 @@ export function createSetupGenerator(plop: PlopTypes.NodePlopAPI) {
|
||||
name: 'setupHealthCheck',
|
||||
message: 'Do you want to setup a pre-commit hook for health checks?',
|
||||
default: false,
|
||||
}
|
||||
},
|
||||
],
|
||||
actions: [
|
||||
() => {
|
||||
execSync(`pnpm run --filter scripts requirements`);
|
||||
|
||||
return 'Requirements checked';
|
||||
},
|
||||
async (answers: any) => {
|
||||
execSync(`git config user.username "${answers.username}"`, {
|
||||
stdio: 'inherit',
|
||||
});
|
||||
|
||||
return 'Git user name set';
|
||||
},
|
||||
{
|
||||
type: 'modify',
|
||||
path: 'package.json',
|
||||
@@ -32,10 +51,15 @@ export function createSetupGenerator(plop: PlopTypes.NodePlopAPI) {
|
||||
},
|
||||
async (answers: any) => {
|
||||
try {
|
||||
setupRemote();
|
||||
setupPreCommit({setupHealthCheck: answers.setupHealthCheck});
|
||||
createMakerkitConfig({
|
||||
projectName: answers.projectName,
|
||||
username: answers.username,
|
||||
});
|
||||
|
||||
return 'Project setup complete';
|
||||
setupRemote();
|
||||
setupPreCommit({ setupHealthCheck: answers.setupHealthCheck });
|
||||
|
||||
return 'Project setup complete. Start developing your project!';
|
||||
} catch (error) {
|
||||
console.error('Project setup failed. Aborting package generation.');
|
||||
process.exit(1);
|
||||
@@ -45,17 +69,31 @@ export function createSetupGenerator(plop: PlopTypes.NodePlopAPI) {
|
||||
});
|
||||
}
|
||||
|
||||
function setupPreCommit(params: {
|
||||
setupHealthCheck: boolean;
|
||||
function createMakerkitConfig(params: {
|
||||
projectName: string;
|
||||
username: string;
|
||||
}) {
|
||||
const config = `{
|
||||
"projectName": "${params.projectName}",
|
||||
"username": "${params.username}"
|
||||
}`
|
||||
|
||||
writeFileSync('.makerkitrc', config, {
|
||||
encoding: 'utf-8',
|
||||
});
|
||||
|
||||
execSync('git add .makerkitrc');
|
||||
}
|
||||
|
||||
function setupPreCommit(params: { setupHealthCheck: boolean }) {
|
||||
try {
|
||||
const filePath = '.git/hooks/pre-commit';
|
||||
|
||||
const healthCheckCommands = params.setupHealthCheck
|
||||
? `pnpm run lint:fix\npnpm run typecheck\n`.trim()
|
||||
: ``;
|
||||
? `pnpm run lint:fix\npnpm run typecheck\n`.trim()
|
||||
: ``;
|
||||
|
||||
const licenseCommand = `pnpm run --filter license dev`;
|
||||
const licenseCommand = `pnpm run --filter scripts license`;
|
||||
const fileContent = `#!/bin/bash\n${healthCheckCommands}${licenseCommand}`;
|
||||
|
||||
// write file
|
||||
@@ -76,37 +114,37 @@ function setupPreCommit(params: {
|
||||
function setupRemote() {
|
||||
try {
|
||||
// Setup remote upstream
|
||||
const getRemoteUrl = execSync('git remote get-url origin', {
|
||||
stdio: 'inherit',
|
||||
});
|
||||
|
||||
const currentRemote = getRemoteUrl.toString().trim();
|
||||
const currentRemote = execSync('git remote get-url origin').toString();
|
||||
|
||||
console.log(`Setting upstream remote to ${currentRemote} ...`);
|
||||
|
||||
if (currentRemote && currentRemote.includes('github.com')) {
|
||||
|
||||
execSync(`git remote remove origin`, {
|
||||
stdio: 'inherit',
|
||||
});
|
||||
|
||||
execSync(`git remote set-url upstream ${currentRemote}`, {
|
||||
execSync(`git remote add upstream ${currentRemote}`, {
|
||||
stdio: 'inherit',
|
||||
});
|
||||
} else {
|
||||
console.error('Your current remote is not GitHub');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
console.info('No current remote found. Skipping upstream remote setup.');
|
||||
}
|
||||
|
||||
// Run license script
|
||||
try {
|
||||
execSync('turbo run --filter license dev', {
|
||||
execSync('pnpm run --filter scripts license', {
|
||||
stdio: 'inherit',
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`License script failed. Aborting package generation. Error: ${error}`);
|
||||
console.error(
|
||||
`License check failed. Aborting package generation. Error: ${error}`,
|
||||
);
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user