Skip to content

Commit

Permalink
Merge pull request #184 from akd-io/release/0.2.3
Browse files Browse the repository at this point in the history
Release v0.2.3
  • Loading branch information
akd-io committed May 24, 2023
2 parents acdaa80 + 58e4dea commit 7e83148
Show file tree
Hide file tree
Showing 66 changed files with 2,952 additions and 395 deletions.
147 changes: 147 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Contributing

Hey there! We're excited that you're interested in contributing to Create Next Stack. This document should help you get set up locally and guide you through the process of contributing.

## Table of Contents

- [Getting Started](#getting-started)
- [Repository Overview](#repository-overview)
- [Creating a pull request](#creating-a-pull-request)
- [Adding support for a new technology](#adding-support-for-a-new-technology)
- [Writing a plugin](#writing-a-plugin)

## Getting Started

Before you start contributing, you'll need to get the project set up locally. Follow the steps below to get started.

1. Make sure you have the latest [Node.js](https://nodejs.org/en/) and [Git](https://git-scm.com/) installed.
2. Install [pnpm](https://pnpm.io/) using `npm i -g pnpm`.
3. Fork the repository on GitHub.
4. Clone your forked repository locally.
5. Install dependencies using `pnpm install`.
6. Build the project using `pnpm run build`.

## Repository Overview

This repository is a [monorepo](https://en.wikipedia.org/wiki/Monorepo) managed using [pnpm](https://pnpm.io/). This means that there are multiple packages in the repository, each with their own `package.json` file. The `package.json` file in the root of the repository is used to manage the packages in the repository.

You can see where the monorepo looks for packages in the `pnpm-workspace.yaml` file:

```yaml
packages:
- "packages/**"
- "website"
```

Packages that are published to npm are located inside the [`packages`](packages) directory. A single [`website`](website) package is located outside of the `packages` directory, as it is not published to npm. The `website` package is used to build the [create-next-stack.com](https://create-next-stack.com/).

You can find a list of generally useful npm scripts available in the root by checking out the root [`package.json`](package.json) file.

A couple of notable scripts that allow you to build, lint, and test the entire repository, or specific packages are:

- `build`
- `build:cli`
- `build:web`
- `lint`
- `lint:cli`
- `lint:web`
- `test`
- `test:cli`
- `test:web`

Each package has its own `package.json` file, which contains scripts specific to that package. The above list are just wrapper scripts that call the underlying packages' `build`, `test`, and `test` scripts.

Note that running scripts inside a specific package's directory will only run the script for that package. For example, running `pnpm run build` inside the `packages/create-next-stack` directory will run the `build` script specified in the `create-next-stack` package's `package.json` file.

## Creating a Pull Request

Make sure you are set up locally by following the [Getting Started](#getting-started) section above.

1. Create a new branch from `develop` with a descriptive name.
2. Make your changes.
3. Run tests using `pnpm test` to ensure they all pass.
4. [Submit a Pull Request](https://github.com/akd-io/create-next-stack/compare).

## Adding Support for a New Technology

Make sure you are set up locally by following the [Getting Started](#getting-started) section above.

1. Create a new branch from `develop` with a descriptive name.

- `git checkout -b feature/support-my-favorite-technology`

2. Useful npm scripts of `packages/create-next-stack` to run during development:

- `check-types:watch` - Runs TypeScript in watch mode to check types as you make changes. You can run this instead of `build:watch` while working on the CLI, as the e2e tests do just-in-time compilation via `ts-node`.
- `jest:watch` - Runs Jest in watch mode to run unit tests as you make changes.
- These tests were specifically made to ease the plugin authoring process, so don't forget this one.
- `test` - Runs e2e tests. Note that this will run all e2e tests, which can take quite a while.
- `lint` - Runs ESLint to lint the project.
- `test:manual`
- For example, `pnpm run test:manual --package-manager=pnpm --styling=emotion`.
- Sets up a new directory for a test run of the CLI, runs the CLI with the specified flags, and builds the generated Next app, and checks formatting and linting.
- This is useful for manually testing the CLI. Pass whatever flags to the CLI that you want to test. The `app_name` argument will be set automatically.
- `test:raw` - Runs the binary directly. Rarely used, but can be useful for manual tests where you want to be able to specify the `app_name` argument yourself.
- `clean` - Removes all generated files, including build files and the `create-next-stack-tests` directory created by the e2e tests.

3. Add a new .ts file for your plugin in the plugins directory at `packages\create-next-stack\src\main\plugins`

- See the [Writing a plugin section](#writing-a-plugin) below to learn how to write a Create Next Stack plugin.

4. Add new flags to the `create-next-stack` command in [`create-next-stack.ts`](packages\create-next-stack\src\main\commands\create-next-stack.ts).
5. Add the plugin to the `plugins` array in [`setup.ts`](packages/create-next-stack/src/main/setup/setup.ts).
6. Add potential plugin steps to the `steps` array in [`setup.ts`](packages/create-next-stack/src/main/setup/setup.ts). Steps are run top-to-bottom.
7. Update the [`README.md`](README.md):
- Add the technology to the technology list
- Update the `Usage` section by copy pasting the output of running `yarn print:help`
8. Consider expanding some of the e2e tests to include the new technology. See [`test.ts`](packages\create-next-stack\src\tests\e2e\test.ts) for current tests.
9. Run tests using `yarn test` to ensure they all pass.
10. Submit a Pull Request on GitHub.

## Writing a Plugin

Plugins aren't too scary. A Create Next Stack plugin consists of a simple TypeScript file that calls a `createPlugin()` function with JSON object.

See the [Framer Motion plugin](packages/create-next-stack/src/main/plugins/emotion.ts) for example. This plugin adds the `framer-motion` npm dependency to the generated Next.js project, as well as adding some documentation about the technology.

```typescript
export const framerMotionPlugin = createPlugin({
id: "framer-motion",
name: "Framer Motion",
description: "Adds support for Framer Motion",
active: ({ flags }) => Boolean(flags["framer-motion"]),
dependencies: {
"framer-motion": {
name: "framer-motion",
version: "^9.0.0",
},
},
technologies: [
{
id: "framerMotion",
name: "Framer Motion",
description:
"Framer Motion is a popular React animation library. It allows users to create both simple animations and complex gesture-based interactions. The library implements a declarative API, otherwise known as spring animations, which lets the developer define the animation's end state, letting the library handle the rest.",
links: [
{ title: "Website", url: "https://www.framer.com/motion/" },
{ title: "Docs", url: "https://www.framer.com/docs/" },
{ title: "GitHub", url: "https://github.com/framer/motion" },
],
},
],
} as const)
```

Below is a breakdown of the `createPlugin()` function's JSON object:

- The `name` property is the name of the plugin.
- The `description` property is a short description of the plugin.
- The `active` property is a function that returns a boolean indicating whether the plugin should be active. This function is passed the `flags` object, which contains all the flags passed to the `create-next-stack` command.
- The `dependencies` property is an object containing the npm dependencies that should be added to the generated Next.js project. The key and `name` property is the name of the dependency, and the `version` property is version of the dependency.
- The `technologies` property is an array of objects containing information about the technology. The `name` property is the name of the technology. The `description` property is a short description of the technology. The `links` property is an array of objects containing links to the technology's website, documentation, and GitHub repository.

Some of these properties are optional, and some are required. Some properties are used by the CLI, some are used by the website, and some both. It's not too important to know everywhere these properties are used. As long as we specify as many properties as possible, the CLI and website is going to find out how to use it.

For a complete list of properties that can be passed to the `createPlugin()` function, their explanations, and usage, see the [`Plugin` type definition](packages/create-next-stack/src/main/plugin.ts). You should find all the documentation you need there. If not, please [open an issue](https://github.com/akd-io/create-next-stack/issues/new).

For more examples, please take a look at the [existing plugins](packages/create-next-stack/src/main/plugins).
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Anders Kjær Damgaard

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
78 changes: 0 additions & 78 deletions packages/create-next-stack/CONTRIBUTING.md

This file was deleted.

69 changes: 28 additions & 41 deletions packages/create-next-stack/README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,36 @@
<img width="100%" src="assets/banner.png" alt="A screenshot of the Create Next Stack website">
# Create Next Stack

<p align="center">
<a aria-label="NPM version" href="https://www.npmjs.com/package/create-next-stack">
<img alt="" src="https://img.shields.io/npm/v/create-next-stack?style=flat-square">
</a>
<a aria-label="Build status" href="https://github.com/akd-io/create-next-stack/actions/workflows/main.yml?query=branch%3Adevelop">
<img alt="" src="https://img.shields.io/github/actions/workflow/status/akd-io/create-next-stack/main.yml?branch=develop&style=flat-square">
</a>
<p>
<a aria-label="Last commit" href="https://github.com/akd-io/create-next-stack/commits/develop">
<img alt="" src="https://img.shields.io/github/last-commit/akd-io/create-next-stack/develop?style=flat-square">
</a>
<a aria-label="License" href="https://github.com/akd-io/create-next-stack/blob/develop/LICENSE">
<a aria-label="License" href="https://github.com/akd-io/create-next-stack/blob/develop/packages/create-next-stack/LICENSE">
<img alt="" src="https://img.shields.io/npm/l/create-next-stack?color=44cc11&style=flat-square">
</a>
<a aria-label="Create Next Stack Website GitHub Repository" href="https://github.com/akd-io/create-next-stack-website">
<img alt="" src="https://img.shields.io/badge/Website-gray?style=flat-square&logo=github">
</a>
<a aria-label="GitHub Repo stars" href="https://github.com/akd-io/create-next-stack">
<img alt="" src="https://img.shields.io/github/stars/akd-io/create-next-stack?style=social">
<a aria-label="NPM version" href="https://www.npmjs.com/package/create-next-stack">
<img alt="" src="https://img.shields.io/npm/v/create-next-stack?style=flat-square">
</a>
<a aria-label="Community Discord" href="https://discord.gg/7Ns5WwGjjZ">
<img alt="" src="https://img.shields.io/badge/Discord-gray?style=flat-square&logo=discord">
</a>
<a aria-label="Twitter profile of the creator of Create Next Stack" href="https://twitter.com/akd_io">
<img alt="" src="https://img.shields.io/badge/Twitter-gray?style=flat-square&logo=twitter">
</a>
<a aria-label="GitHub Repo stars" href="https://github.com/akd-io/create-next-stack">
<img alt="" src="https://img.shields.io/github/stars/akd-io/create-next-stack?style=social">
</a>
</p>

[Create Next Stack](https://www.create-next-stack.com/) is a website and CLI tool used to easily set up the boilerplate of new [Next.js](https://github.com/vercel/next.js) apps.

Where [Create Next App](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) lets you choose a single template only, Create Next Stack lets you pick and choose an array of technologies often used alongside Next.js, and free you of the pain of making them work together.

This repository covers the CLI tool, while [create-next-stack-website](https://github.com/akd-io/create-next-stack-website) covers the site.

To get started, go to [create-next-stack.com](https://www.create-next-stack.com). Here you'll be able to choose the technologies you want to use and get the corresponding CLI command.

<p align="center">
<img width="600" alt="Screenshot of Create Next Stack running in a terminal" src="assets/screenshot.png">
</p>
To get started, go to [create-next-stack.com](https://www.create-next-stack.com).

## Supported technologies

The table below provides an overview of the technologies currently supported by Create Next Stack.

### Technologies table

| Name | Links |
| --------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Next.js](https://nextjs.org/) (Mandatory) | [Docs](https://nextjs.org/docs) - [Learn Next.js](https://nextjs.org/learn) - [GitHub repo](https://github.com/vercel/next.js) |
Expand Down Expand Up @@ -76,26 +62,27 @@ Below you see an overview of Create Next Stack's usage, including detailed infor

```
USAGE
$ create-next-stack [APPNAME]
$ create-next-stack [APP_NAME] [FLAGS]
ARGUMENTS
APPNAME The name of your app, optionally including a path prefix. Eg.: "my-app" or "path/to/my-app"
OPTIONS
-h, --help Shows the CLI help information.
-v, --version Shows the CLI version information.
--chakra Adds Chakra UI. (Component library) (Requires Emotion and Framer Motion)
--debug Show verbose error messages for debugging purposes.
--formatting-pre-commit-hook Adds a formatting pre-commit hook. (Requires Prettier)
--formik Adds Formik. (Form library)
--framer-motion Adds Framer Motion. (Animation library)
--github-actions Adds a GitHub Actions continuous integration workflow.
--material-ui Adds Material UI. (Component library)
--package-manager=(pnpm|yarn|npm) Sets the preferred package manager. (Required)
--prettier Adds Prettier. (Code formatting)
--react-hook-form Adds React Hook Form. (Form library)
--react-icons Adds React Icons. (Icon library)
--styling=<styling-method> Sets the preferred styling method. (Required) <styling-method> = emotion|styled-components|tailwind-css|css-modules|css-modules-with-sass
APP_NAME The name of your app, optionally including a path prefix. Eg.: "my-app" or "path/to/my-app"
FLAGS
-h, --help Shows the CLI help information.
-v, --version Shows the CLI version information.
--chakra Adds Chakra UI. (Component library) (Requires Emotion and Framer Motion)
--debug Show verbose error messages for debugging purposes.
--formatting-pre-commit-hook Adds a formatting pre-commit hook. (Requires Prettier)
--formik Adds Formik. (Form library)
--framer-motion Adds Framer Motion. (Animation library)
--github-actions Adds a GitHub Actions continuous integration workflow.
--material-ui Adds Material UI. (Component library)
--package-manager=<option> Sets the preferred package manager. (Required)
<options: pnpm|yarn|npm>
--prettier Adds Prettier. (Code formatting)
--react-hook-form Adds React Hook Form. (Form library)
--react-icons Adds React Icons. (Icon library)
--styling=<styling-method> Sets the preferred styling method. (Required) <styling-method> = emotion|styled-components|tailwind-css|css-modules|css-modules-with-sass
```

## Contributing
Expand Down
Binary file removed packages/create-next-stack/assets/banner.png
Binary file not shown.
Binary file not shown.
Binary file removed packages/create-next-stack/assets/required-icon.png
Binary file not shown.
Binary file removed packages/create-next-stack/assets/screenshot.png
Binary file not shown.
Loading

0 comments on commit 7e83148

Please sign in to comment.