Skip to content
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

Add support for Prisma #258

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from
Prev Previous commit
Next Next commit
Refactor plugins to use addFiles plugin property
akd-io committed Jun 22, 2023
commit 4e12adcf1e413340b7e9dfd700c5078eb3fe293a
26 changes: 15 additions & 11 deletions packages/create-next-stack/src/main/plugins/chakra-ui/chakra-ui.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import endent from "endent"
import { writeFile } from "../../helpers/io"
import { createPlugin } from "../../plugin"
import { chakraTheme } from "./setup/chakra-theme"

export const chakraUIPlugin = createPlugin({
id: "chakra-ui",
@@ -25,15 +23,6 @@ export const chakraUIPlugin = createPlugin({
],
},
],
steps: {
setUpChakraUI: {
id: "setUpChakraUI",
description: "setting up Chakra UI",
run: async () => {
await writeFile("chakra-theme.ts", chakraTheme)
},
},
},
slots: {
app: {
imports: endent`
@@ -55,4 +44,19 @@ export const chakraUIPlugin = createPlugin({
body: `<ColorModeScript initialColorMode={chakraTheme.config.initialColorMode} />`,
},
},
addFiles: [
{
destination: "chakra-theme.ts",
content: endent`
import { extendTheme, ThemeConfig } from "@chakra-ui/react";

const config: ThemeConfig = {
initialColorMode: "light",
useSystemColorMode: false,
};

export const chakraTheme = extendTheme({ config });
`,
},
],
} as const)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -6,9 +6,7 @@ import { nonNull } from "../../../helpers/non-null"
import { stringify } from "../../../helpers/stringify"
import { filterPlugins } from "../../../setup/setup"

export const generateNextConfig = async (
inputs: ValidCNSInputs
): Promise<string> => {
export const generateNextConfig = (inputs: ValidCNSInputs): string => {
const defaultNextConfig: NextConfig = {
reactStrictMode: true,
}
Original file line number Diff line number Diff line change
@@ -2,12 +2,7 @@ import endent from "endent"
import path from "path"
import { copyDirectory } from "../../helpers/copy-directory"
import { getCreateNextStackDir } from "../../helpers/get-create-next-stack-dir"
import {
makeDirectory,
modifyJsonFile,
toObject,
writeFile,
} from "../../helpers/io"
import { modifyJsonFile, toObject, writeFile } from "../../helpers/io"
import { isGitInitialized } from "../../helpers/is-git-initialized"
import { nonNull } from "../../helpers/non-null"
import { runCommand } from "../../helpers/run-command"

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
import { writeFile } from "../../helpers/io"
import endent from "endent"
import { createPlugin } from "../../plugin"
import { generateGlobalStyles } from "./add-content/styles/global-styles"

const globalStyles = endent`
* {
box-sizing: border-box;
}

html,
body {
padding: 0;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
line-height: 1.5;
}

code {
font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono,
Bitstream Vera Sans Mono, Courier New, monospace;
}

a {
color: inherit;
text-decoration: none;
font-weight: bold;
}
`

export const cssModulesPlugin = createPlugin({
id: "css-modules",
@@ -23,18 +48,15 @@ export const cssModulesPlugin = createPlugin({
],
},
],
steps: {
setUpCssModules: {
id: "setUpCssModules",
description: "setting up CSS Modules",
run: async () => {
await writeFile("styles/global-styles.css", generateGlobalStyles())
},
},
},
slots: {
app: {
imports: `import "../styles/global-styles.css";`,
},
},
addFiles: [
{
destination: "styles/global-styles.css",
content: globalStyles,
},
],
} as const)
23 changes: 12 additions & 11 deletions packages/create-next-stack/src/main/plugins/mantine/mantine.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import endent from "endent"
import { writeFile } from "../../helpers/io"
import { createPlugin } from "../../plugin"
import { mantineTheme } from "./setup/mantine-theme"

export const mantinePlugin = createPlugin({
id: "mantine",
@@ -27,15 +25,6 @@ export const mantinePlugin = createPlugin({
],
},
],
steps: {
setUpMantine: {
id: "setUpMantine",
description: "setting up Mantine",
run: async () => {
await writeFile("mantine-theme.ts", mantineTheme)
},
},
},
slots: {
app: {
imports: endent`
@@ -65,4 +54,16 @@ export const mantinePlugin = createPlugin({
`,
},
},
addFiles: [
{
destination: "mantine-theme.ts",
content: endent`
import { MantineThemeOverride } from "@mantine/core";

export const mantineTheme: MantineThemeOverride = {
colorScheme: "light",
};
`,
},
],
} as const)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,36 @@
import endent from "endent"
import { writeFile } from "../../helpers/io"
import { createPlugin } from "../../plugin"
import { materialTheme } from "./setup/material-theme"

const materialTheme = endent`
import { Roboto } from 'next/font/google';
import { createTheme } from '@mui/material/styles';
import { red } from '@mui/material/colors';

export const roboto = Roboto({
weight: ['300', '400', '500', '700'],
subsets: ['latin'],
display: 'swap',
fallback: ['Helvetica', 'Arial', 'sans-serif'],
});

// Create a theme instance.
export default createTheme({
palette: {
primary: {
main: '#556cd6',
},
secondary: {
main: '#19857b',
},
error: {
main: red.A400,
},
},
typography: {
fontFamily: roboto.style.fontFamily,
},
});
`

export const materialUIPlugin = createPlugin({
id: "material-ui",
@@ -25,15 +54,6 @@ export const materialUIPlugin = createPlugin({
],
},
],
steps: {
setUpMaterialUI: {
id: "setUpMaterialUI",
description: "setting up Material UI",
run: async () => {
await writeFile("material-theme.ts", materialTheme)
},
},
},
slots: {
app: {
imports: endent`
@@ -53,4 +73,10 @@ export const materialUIPlugin = createPlugin({
headTags: `<meta name="theme-color" content={materialTheme.palette.primary.main} />`,
},
},
addFiles: [
{
destination: "material-theme.ts",
content: materialTheme,
},
],
} as const)

This file was deleted.

This file was deleted.

Loading