Skip to content

Commit 15b6b0b

Browse files
committed
Merge branch 'develop' into feature/154-add-contributing-guidelines
2 parents 99d5602 + e7f71b3 commit 15b6b0b

27 files changed

+222
-90
lines changed

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ The table below provides an overview of the technologies currently supported by
5757
| [React](https://reactjs.org/) (Mandatory) | [Docs](https://reactjs.org/docs/getting-started.html) - [GitHub repo](https://github.com/facebook/react) |
5858
| [TypeScript](https://www.typescriptlang.org/) (Mandatory) | [Docs](https://www.typescriptlang.org/docs/) - [GitHub repo](https://github.com/microsoft/TypeScript) |
5959
| [ESLint](https://eslint.org/) (Mandatory) | [Configuration](https://eslint.org/docs/user-guide/configuring/) - [Rules](https://eslint.org/docs/rules/) - [GitHub Repo](https://github.com/eslint/eslint) |
60+
| [pnpm](https://pnpm.io/) | [Docs](https://pnpm.io/motivation) - [GitHub repo](https://github.com/pnpm/pnpm) |
6061
| [Yarn](https://yarnpkg.com/) | [CLI Docs](https://yarnpkg.com/cli) - [GitHub repo](https://github.com/yarnpkg/berry) |
6162
| [npm](https://www.npmjs.com/) | [CLI Docs](https://docs.npmjs.com/cli/) |
6263
| [Emotion](https://emotion.sh/docs/introduction) | [Docs](https://emotion.sh/docs/introduction) - [GitHub repo](https://github.com/emotion-js/emotion) |
@@ -86,19 +87,19 @@ ARGUMENTS
8687
APPNAME The name of your app, optionally including a path prefix. Eg.: "my-app" or "path/to/my-app"
8788
8889
OPTIONS
89-
-h, --help Shows the CLI help information.
90-
-v, --version Shows the CLI version information.
91-
--chakra Adds Chakra UI. (Component library) (Requires Emotion and Framer Motion)
92-
--debug Show verbose error messages for debugging purposes.
93-
--formatting-pre-commit-hook Adds a formatting pre-commit hook. (Requires Prettier)
94-
--formik Adds Formik. (Form library)
95-
--framer-motion Adds Framer Motion. (Animation library)
96-
--github-actions Adds a GitHub Actions continuous integration workflow.
97-
--material-ui Adds Material UI. (Component library)
98-
--package-manager=(yarn|npm) Sets the preferred package manager. (Required)
99-
--prettier Adds Prettier. (Code formatting)
100-
--react-hook-form Adds React Hook Form. (Form library)
101-
--styling=<styling-method> Sets the preferred styling method. (Required) <styling-method> = emotion|styled-components|tailwind-css|css-modules|css-modules-with-sass
90+
-h, --help Shows the CLI help information.
91+
-v, --version Shows the CLI version information.
92+
--chakra Adds Chakra UI. (Component library) (Requires Emotion and Framer Motion)
93+
--debug Show verbose error messages for debugging purposes.
94+
--formatting-pre-commit-hook Adds a formatting pre-commit hook. (Requires Prettier)
95+
--formik Adds Formik. (Form library)
96+
--framer-motion Adds Framer Motion. (Animation library)
97+
--github-actions Adds a GitHub Actions continuous integration workflow.
98+
--material-ui Adds Material UI. (Component library)
99+
--package-manager=(pnpm|yarn|npm) Sets the preferred package manager. (Required)
100+
--prettier Adds Prettier. (Code formatting)
101+
--react-hook-form Adds React Hook Form. (Form library)
102+
--styling=<styling-method> Sets the preferred styling method. (Required) <styling-method> = emotion|styled-components|tailwind-css|css-modules|css-modules-with-sass
102103
```
103104

104105
## Contributing

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
"test": "yarn build && yarn run test-only",
4949
"test-only": "node lib/tests/e2e/test.js",
5050
"test:manual": "yarn build && node lib/tests/e2e/manual-test.js --debug",
51-
"test:small": "yarn build && node lib/tests/e2e/manual-test.js --debug --package-manager=npm --styling=css-modules",
52-
"test:large": "yarn build && node lib/tests/e2e/manual-test.js --debug --package-manager=yarn --styling=emotion --react-hook-form --formik --prettier --formatting-pre-commit-hook --chakra --framer-motion --github-actions",
51+
"test:small": "yarn build && node lib/tests/e2e/manual-test.js --debug --package-manager=pnpm --styling=css-modules",
52+
"test:large": "yarn build && node lib/tests/e2e/manual-test.js --debug --package-manager=pnpm --styling=emotion --react-hook-form --formik --prettier --formatting-pre-commit-hook --chakra --framer-motion --github-actions",
5353
"test:cna": "yarn build && node lib/tests/e2e/test-cna.js",
5454
"version": "oclif-dev readme && git add README.md",
5555
"format": "prettier --write --ignore-path=.prettierignore .",

src/main/create-next-stack-types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ export type CreateNextStackArgs = UnknownObject // Change to ParserOutput["args"
2626
export type CreateNextStackFlags = Partial<CreateNextStackParserOutput["flags"]> // Change to CreateNextStackParserOutput["flags"] if it becomes strongly typed in the future. (Currently not a Partial.)
2727

2828
// Package manager flag:
29-
export const packageManagerOptions = ["yarn", "npm"] as const
30-
export type PackageManagerOption = typeof packageManagerOptions[number]
29+
export const packageManagerOptions = ["yarn", "npm", "pnpm"] as const
30+
export type PackageManager = typeof packageManagerOptions[number]
3131
export const writablePackageManagerOptions = packageManagerOptions as Writable<
3232
typeof packageManagerOptions
3333
>
@@ -67,7 +67,7 @@ export const validateArgs = (
6767

6868
// Valid Flags type and type guard
6969
export type ValidCreateNextStackFlags = CreateNextStackFlags & {
70-
"package-manager": PackageManagerOption
70+
"package-manager": PackageManager
7171
styling: StylingOption
7272
}
7373
export const validateFlags = (
Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
1-
import { PackageManagerOption } from "../create-next-stack-types"
1+
import { PackageManager } from "../create-next-stack-types"
22

3-
export const installCommand: Record<PackageManagerOption, string> = {
3+
export const installCommandMap: Record<PackageManager, string> = {
4+
pnpm: "pnpm install",
45
yarn: "yarn",
56
npm: "npm install",
67
}
78

8-
export const cleanInstallCommand: Record<PackageManagerOption, string> = {
9-
yarn: "yarn install",
9+
export const cleanInstallCommandMap: Record<PackageManager, string> = {
10+
pnpm: "pnpm install --frozen-lockfile",
11+
yarn: "yarn install --frozen-lockfile",
1012
npm: "npm ci",
1113
}
1214

13-
export const installSubCommand: Record<PackageManagerOption, string> = {
15+
export const installSubCommandMap: Record<PackageManager, string> = {
16+
pnpm: "add",
1417
yarn: "add",
1518
npm: "install",
1619
}
1720

18-
export const uninstallSubCommand: Record<PackageManagerOption, string> = {
21+
export const uninstallSubCommandMap: Record<PackageManager, string> = {
22+
pnpm: "remove",
1923
yarn: "remove",
2024
npm: "uninstall",
2125
}
2226

23-
export const runCommand: Record<PackageManagerOption, string> = {
27+
export const runCommandMap: Record<PackageManager, string> = {
28+
pnpm: "pnpm",
2429
yarn: "yarn",
2530
npm: "npm run",
2631
}
32+
33+
export const saveDevModifierMap: Record<PackageManager, string> = {
34+
pnpm: "--save-dev",
35+
yarn: "--dev",
36+
npm: "--save-dev",
37+
}
Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,44 @@
11
import endent from "endent"
22
import { ValidCNSInputs } from "../../../create-next-stack-types"
33
import { getProjectNameOfPath } from "../../../helpers/get-project-name-of-path"
4+
import { runCommandMap } from "../../../helpers/package-manager-utils"
45
import { generateScriptTableRows } from "./generate-script-table-rows"
56
import { generateTechnologyTableRows } from "./generate-technology-table-rows"
67

78
export const generateReadme = async (
89
inputs: ValidCNSInputs
9-
): Promise<string> => endent`
10-
# ${getProjectNameOfPath(inputs.args.appName)}
10+
): Promise<string> => {
11+
const { args, flags } = inputs
1112

12-
🎉 Congratulations, your project was successfully generated with [Create Next Stack](https://www.create-next-stack.com/)!
13+
const runCommand = runCommandMap[flags["package-manager"]]
1314

14-
To get started, run:
15+
return endent`
16+
# ${getProjectNameOfPath(args.appName)}
1517
16-
\`\`\`bash
17-
${inputs.flags["package-manager"] === "yarn" ? "yarn dev" : "npm run dev"}
18-
\`\`\`
18+
🎉 Congratulations, your project was successfully generated with [Create Next Stack](https://www.create-next-stack.com/)!
1919
20-
## Scripts
20+
To get started, run:
2121
22-
The table below provides names and descriptions of the npm scripts available in this project.
22+
\`\`\`bash
23+
${runCommand} dev
24+
\`\`\`
2325
24-
Each script is run using \`${
25-
inputs.flags["package-manager"] === "yarn" ? "yarn" : "npm run"
26-
} <script-name>\`. For example: \`${
27-
inputs.flags["package-manager"] === "yarn" ? "yarn" : "npm run"
28-
} dev\`.
26+
## Scripts
2927
30-
| Name | Description |
31-
| ---- | ----------- |
32-
${await generateScriptTableRows(inputs)}
28+
The table below provides names and descriptions of the npm scripts available in this project.
3329
34-
## Technologies
30+
Each script is run using \`${runCommand} <script-name>\`. For example: \`${runCommand} dev\`.
3531
36-
The table below gives an overview of the technologies used in this project, as well as places to learn more about them.
32+
| Name | Description |
33+
| ---- | ----------- |
34+
${await generateScriptTableRows(inputs)}
3735
38-
| Name | Links |
39-
| ---- | ----- |
40-
${await generateTechnologyTableRows(inputs)}
41-
`
36+
## Technologies
37+
38+
The table below gives an overview of the technologies used in this project, as well as places to learn more about them.
39+
40+
| Name | Links |
41+
| ---- | ----- |
42+
${await generateTechnologyTableRows(inputs)}
43+
`
44+
}

src/main/plugins/create-next-stack/create-next-stack.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { logWarning } from "../../logging"
1414
import { createPlugin } from "../../plugin"
1515
import { runCommand } from "../../run-command"
1616
import { getNameVersionCombo, install, uninstall } from "../../setup/packages"
17-
import { filterPlugins, plugins } from "../../setup/setup"
17+
import { filterPlugins } from "../../setup/setup"
1818
import { prettierPlugin } from "../prettier"
1919
import { generateApp } from "./add-content/pages/generate-app"
2020
import { generateDocument } from "./add-content/pages/generate-document"
@@ -123,7 +123,7 @@ export const createNextStackPlugin = createPlugin({
123123
]
124124
})
125125

126-
const devDeps = plugins.flatMap((plugin) => {
126+
const devDeps = filterPlugins(inputs).flatMap((plugin) => {
127127
return plugin.devDependencies != null
128128
? Object.values(plugin.devDependencies)
129129
: []
@@ -139,15 +139,15 @@ export const createNextStackPlugin = createPlugin({
139139
},
140140
uninstallTemporaryDependencies: {
141141
description: "uninstalling temporary dependencies",
142-
run: async ({ flags }) => {
143-
const tmpDeps = plugins.flatMap((plugin) => {
142+
run: async (inputs) => {
143+
const tmpDeps = filterPlugins(inputs).flatMap((plugin) => {
144144
return plugin.tmpDependencies != null
145145
? Object.values(plugin.tmpDependencies)
146146
: []
147147
})
148148

149149
if (tmpDeps.length > 0) {
150-
await uninstall(tmpDeps, flags["package-manager"])
150+
await uninstall(tmpDeps, inputs.flags["package-manager"])
151151
}
152152
},
153153
},

src/main/plugins/github-actions.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import path from "path"
33
import { ValidCNSInputs } from "../create-next-stack-types"
44
import { makeDirectory, writeFile } from "../helpers/io"
55
import {
6-
cleanInstallCommand,
7-
runCommand,
6+
cleanInstallCommandMap,
7+
runCommandMap,
88
} from "../helpers/package-manager-utils"
99
import { createPlugin, evalActive } from "../plugin"
1010
import { prettierPlugin } from "./prettier"
@@ -82,24 +82,24 @@ const generateCiYml = (inputs: ValidCNSInputs): string => {
8282
cache: "${packageManager}"
8383
8484
- name: "Install dependencies"
85-
run: ${cleanInstallCommand[packageManager]}
85+
run: ${cleanInstallCommandMap[packageManager]}
8686
8787
${
8888
evalActive(prettierPlugin.active, inputs)
8989
? endent`
9090
- name: "Check format"
91-
run: ${runCommand[packageManager]} format:check
91+
run: ${runCommandMap[packageManager]} format:check
9292
`
9393
: ""
9494
}
9595
9696
- name: "Lint"
97-
run: ${runCommand[packageManager]} lint
97+
run: ${runCommandMap[packageManager]} lint
9898
9999
- name: "Build"
100-
run: ${runCommand[packageManager]} build
100+
run: ${runCommandMap[packageManager]} build
101101
102102
- name: "Test"
103-
run: ${runCommand[packageManager]} test
103+
run: ${runCommandMap[packageManager]} test
104104
`
105105
}

src/main/plugins/next.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { generateNextConfig } from "./create-next-stack/add-next-config/generate
1111

1212
const createNextAppPackage: Package = {
1313
name: "create-next-app",
14-
version: "~13.2.3", // Note: Equivalent to 13.2.x. However, when used with npx, the version is interpreted exactly instead of as a range.
14+
version: "13.2.3",
1515
}
1616

1717
export const nextPlugin = createPlugin({
@@ -85,7 +85,7 @@ export const nextPlugin = createPlugin({
8585
}
8686

8787
await runCommand("npx", [
88-
getNameVersionCombo(createNextAppPackage), // Note: npx ignores version ranges. So the tilde in packages["create-next-app"] is ignored and the exact version is used.
88+
getNameVersionCombo(createNextAppPackage),
8989
...createNextAppArgs,
9090
])
9191

src/main/plugins/pnpm.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { createPlugin } from "../plugin"
2+
import { runCommand } from "../run-command"
3+
import { getNameVersionCombo } from "../setup/packages"
4+
5+
export const pnpmPlugin = createPlugin({
6+
name: "pnpm",
7+
description: "Adds support for pnpm",
8+
active: ({ flags }) => Boolean(flags["package-manager"] === "pnpm"),
9+
dependencies: { pnpm: { name: "pnpm", version: "latest" } },
10+
technologies: [
11+
{
12+
name: "pnpm",
13+
description:
14+
"pnpm is a JavaScript package manager compatible with the npm registry that performs better than Yarn and npm by using hard links and symlinks to allow package caching across projects.",
15+
links: [
16+
{ title: "Website", url: "https://pnpm.io/" },
17+
{ title: "Docs", url: "https://pnpm.io/motivation" },
18+
{ title: "GitHub", url: "https://github.com/pnpm/pnpm" },
19+
],
20+
},
21+
],
22+
steps: {
23+
updatePnpm: {
24+
description: "updating pnpm",
25+
run: async () => {
26+
await runCommand("npm", [
27+
"i",
28+
"-g",
29+
getNameVersionCombo(pnpmPlugin.dependencies.pnpm),
30+
])
31+
},
32+
},
33+
},
34+
} as const)

src/main/plugins/yarn.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const yarnPlugin = createPlugin({
66
name: "Yarn",
77
description: "Adds support for Yarn",
88
active: ({ flags }) => Boolean(flags["package-manager"] === "yarn"),
9-
dependencies: { yarn: { name: "yarn", version: "^1.0.0" } },
9+
dependencies: { yarn: { name: "yarn", version: "latest" } },
1010
technologies: [
1111
{
1212
name: "Yarn",

0 commit comments

Comments
 (0)