Skip to content

Commit

Permalink
Merge pull request #250 from akd-io/feature/247-add-support-for-netlify
Browse files Browse the repository at this point in the history
Add support for Vercel and Netlify
  • Loading branch information
akd-io authored Jun 15, 2023
2 parents f3ac613 + 775cde2 commit bae8cd4
Show file tree
Hide file tree
Showing 16 changed files with 143 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ type OptionKey =
| "formattingPreCommitHook"
| "reactQuery"
| "plausible"
| "vercel"
| "netlify"

const options = {
pnpm: { key: "pnpm", value: "pnpm", label: "pnpm" },
Expand Down Expand Up @@ -112,6 +114,16 @@ const options = {
value: "plausible",
label: "Plausible",
},
vercel: {
key: "vercel",
value: "vercel",
label: "Vercel",
},
netlify: {
key: "netlify",
value: "netlify",
label: "Netlify",
},
} satisfies {
[Key in OptionKey]: {
key: Key
Expand Down Expand Up @@ -157,6 +169,10 @@ const serverStateManagementLibraryOptionKeys = [
optionKeys.reactQuery,
] satisfies OptionKey[]
const analyticsOptionKeys = [optionKeys.plausible] satisfies OptionKey[]
const deploymentOptionKeys = [
optionKeys.vercel,
optionKeys.netlify,
] satisfies OptionKey[]

type ProjectName = string
type PackageManager = (typeof packageManagerOptionKeys)[number]
Expand All @@ -170,6 +186,7 @@ type ContinuousIntegration = (typeof continuousIntegrationOptionKeys)[number]
type ServerStateManagementLibrary =
(typeof serverStateManagementLibraryOptionKeys)[number]
type Analytics = (typeof analyticsOptionKeys)[number]
type Deployment = (typeof deploymentOptionKeys)[number]

type TechnologiesFormData = {
projectName: ProjectName
Expand All @@ -183,6 +200,7 @@ type TechnologiesFormData = {
continuousIntegration: ContinuousIntegration[]
serverStateManagementLibraries: ServerStateManagementLibrary[]
analytics: Analytics[]
deployment: Deployment[]
}
const defaultFormData: TechnologiesFormData = {
projectName: "my-app",
Expand All @@ -196,6 +214,7 @@ const defaultFormData: TechnologiesFormData = {
continuousIntegration: [optionKeys.githubActions],
serverStateManagementLibraries: [optionKeys.reactQuery],
analytics: [],
deployment: [optionKeys.vercel],
}
const formDataKeys = objectToKeyToKeyMap(defaultFormData)

Expand All @@ -213,6 +232,7 @@ const categoryLabels = {
continuousIntegration: "Continuous Integration",
serverStateManagementLibraries: "Server State Management",
analytics: "Analytics",
deployment: "Deployment",
} as const

export const TechnologiesForm: React.FC = () => {
Expand Down Expand Up @@ -250,6 +270,7 @@ export const TechnologiesForm: React.FC = () => {
pushArgs(formData.continuousIntegration)
pushArgs(formData.serverStateManagementLibraries)
pushArgs(formData.analytics)
pushArgs(formData.deployment)

const projectNameSegments = formData.projectName.split("/")
const lastPartOfProjectName = projectNameSegments.pop()!
Expand All @@ -271,7 +292,8 @@ export const TechnologiesForm: React.FC = () => {
| "animation"
| "continuousIntegration"
| "serverStateManagementLibraries"
| "analytics",
| "analytics"
| "deployment",
optionKeys: Array<keyof typeof options>,
validators?: {
[key in keyof typeof options]?: Array<{
Expand Down Expand Up @@ -567,6 +589,16 @@ export const TechnologiesForm: React.FC = () => {
continuousIntegrationOptionKeys
)}
</Flex>

<Flex direction="column" gap="4">
<Heading as="h3" size="md">
{categoryLabels.deployment}
</Heading>
{CheckboxesOfOptionKeys(
formDataKeys.deployment,
deploymentOptionKeys
)}
</Flex>
</Flex>
</Flex>

Expand Down
4 changes: 4 additions & 0 deletions packages/create-next-stack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ The table below provides an overview of the technologies currently supported by
| GitHub Actions | [Website](https://github.com/features/actions) - [Docs](https://docs.github.com/en/actions) - [Workflow syntax](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions) |
| Plausible Analytics | [Website](https://plausible.io/) - [Docs](https://plausible.io/docs) - [GitHub](https://github.com/plausible/analytics) |
| next-plausible | [Website](https://next-plausible.vercel.app/) - [GitHub](https://github.com/4lejandrito/next-plausible) |
| Vercel | [Website](https://vercel.com/) - [Docs](https://vercel.com/docs) - [CLI Docs](https://vercel.com/docs/cli) |
| Netlify | [Website](https://www.netlify.com/) - [Docs](https://docs.netlify.com/) - [CLI Docs](https://cli.netlify.com/) |

<!-- CNS-END-OF-TECHNOLOGIES-TABLE -->

Expand Down Expand Up @@ -96,6 +98,7 @@ FLAGS
Emotion)
--material-ui Adds Material UI. (Component library) (Requires
Emotion)
--netlify Adds Netlify. (Hosting)
--package-manager=<option> (required) Sets the preferred package manager.
(Required)
<options: pnpm|yarn|npm>
Expand All @@ -109,6 +112,7 @@ FLAGS
(Required) <styling-method> =
emotion|styled-components|tailwind-css|css-modul
es|css-modules-with-sass
--vercel Adds Vercel. (Hosting)
```

<!-- CNS-END-OF-HELP-OUTPUT -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ export default class CreateNextStack extends Command {
plausible: Flags.boolean({
description: "Adds Plausible. (Analytics)",
}),

// Hosting
netlify: Flags.boolean({
description: "Adds Netlify. (Hosting)",
}),
vercel: Flags.boolean({
description: "Adds Vercel. (Hosting)",
}),
}

async run(): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export const scriptsSortOrder: string[] = [
"lint",
"format",
"format:check",
"deploy:vercel",
"deploy:netlify",
]

export const getSortedFilteredScripts = (inputs: ValidCNSInputs) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export const technologiesSortOrder: string[] = [
"githubActions",
"plausible",
"nextPlausible",
"vercel",
"netlify",
]

export const getTechnologies = (
Expand Down
37 changes: 37 additions & 0 deletions packages/create-next-stack/src/main/plugins/netlify.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { createPlugin } from "../plugin"

export const netlifyPlugin = createPlugin({
id: "netlify",
name: "Netlify",
description: "Adds support for Netlify",
active: ({ flags }) => Boolean(flags["netlify"]),
devDependencies: {
"netlify-cli": {
name: "netlify-cli",
version: "^15.6.0",
},
},
scripts: [
{
name: "deploy:netlify",
command: "netlify deploy",
description: "Deploy a preview deployment to Netlify",
},
],
technologies: [
{
id: "netlify",
name: "Netlify",
description:
"Netlify is a modern hosting platform for websites and web apps. With zero configuration, it will build and deploy your site globally and serverlessly with a single command. It can also be set up to do continuous deployments by integrating it with your repository host.",
links: [
{ title: "Website", url: "https://www.netlify.com/" },
{ title: "Docs", url: "https://docs.netlify.com/" },
{ title: "CLI Docs", url: "https://cli.netlify.com/" },
],
},
],
todos: [
"Integrate Netlify with your repository host for continuous deployments at https://app.netlify.com/start. The Netlify CLI, mainly used for preview deployments, won't auto-detect Next.js until you do.",
],
} as const)
37 changes: 37 additions & 0 deletions packages/create-next-stack/src/main/plugins/vercel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { createPlugin } from "../plugin"

export const vercelPlugin = createPlugin({
id: "vercel",
name: "Vercel",
description: "Adds support for Vercel",
active: ({ flags }) => Boolean(flags["vercel"]),
devDependencies: {
vercel: {
name: "vercel",
version: "^30.2.2",
},
},
scripts: [
{
name: "deploy:vercel",
command: "vercel",
description: "Deploy a preview deployment to Vercel",
},
],
technologies: [
{
id: "vercel",
name: "Vercel",
description:
"Vercel is a modern hosting platform for websites and web apps. With zero configuration, it will build and deploy your site globally and serverlessly with a single command. It can also be set up to do continuous deployments by integrating it with your repository host.",
links: [
{ title: "Website", url: "https://vercel.com/" },
{ title: "Docs", url: "https://vercel.com/docs" },
{ title: "CLI Docs", url: "https://vercel.com/docs/cli" },
],
},
],
todos: [
"Integrate Vercel with your repository host for continuous deployments at https://vercel.com/new",
],
} as const)
4 changes: 4 additions & 0 deletions packages/create-next-stack/src/main/setup/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { framerMotionPlugin } from "../plugins/framer-motion"
import { githubActionsPlugin } from "../plugins/github-actions"
import { mantinePlugin } from "../plugins/mantine/mantine"
import { materialUIPlugin } from "../plugins/material-ui/material-ui"
import { netlifyPlugin } from "../plugins/netlify"
import { nextPlugin } from "../plugins/next"
import { npmPlugin } from "../plugins/npm"
import { plausiblePlugin } from "../plugins/plausible"
Expand All @@ -30,6 +31,7 @@ import { sassPlugin } from "../plugins/sass/sass"
import { styledComponentsPlugin } from "../plugins/styled-components"
import { tailwindCSSPlugin } from "../plugins/tailwind-css"
import { typescriptPlugin } from "../plugins/typescript"
import { vercelPlugin } from "../plugins/vercel"
import { yarnPlugin } from "../plugins/yarn"
import { steps } from "../steps"
import { printFinalMessages } from "./print-final-messages"
Expand Down Expand Up @@ -60,6 +62,8 @@ export const plugins: Plugin[] = [
reactIconsPlugin,
reactQueryPlugin,
plausiblePlugin,
vercelPlugin,
netlifyPlugin,
]

export const filterPlugins = (inputs: ValidCNSInputs): Plugin[] =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ test(
"--react-icons",
"--react-query",
"--plausible",
"--vercel",
"--netlify",
".",
])
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ test(
"--react-icons",
"--react-query",
"--plausible",
"--vercel",
"--netlify",
".",
])
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ test(
"--react-icons",
"--react-query",
"--plausible",
"--vercel",
"--netlify",
".",
])
},
Expand Down
2 changes: 2 additions & 0 deletions packages/create-next-stack/src/tests/e2e/tests/npm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ test(
"--react-icons",
"--react-query",
"--plausible",
"--vercel",
"--netlify",
".",
])

Expand Down
2 changes: 2 additions & 0 deletions packages/create-next-stack/src/tests/e2e/tests/pnpm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ test(
"--react-icons",
"--react-query",
"--plausible",
"--vercel",
"--netlify",
".",
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ test(
"--react-icons",
"--react-query",
"--plausible",
"--vercel",
"--netlify",
".",
])
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ test(
"--react-icons",
"--react-query",
"--plausible",
"--vercel",
"--netlify",
".",
])
},
Expand Down
2 changes: 2 additions & 0 deletions packages/create-next-stack/src/tests/e2e/tests/yarn.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ test(
"--react-icons",
"--react-query",
"--plausible",
"--vercel",
"--netlify",
".",
])

Expand Down

0 comments on commit bae8cd4

Please sign in to comment.