Skip to content

Commit 01d8bab

Browse files
authored
Merge branch 'develop' into feature/add-test-live-script
2 parents a7db905 + 78ec69d commit 01d8bab

29 files changed

+221
-145
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
jobs:
88
build:
9-
name: "Build, lint, and test on Node ${{ matrix.node }} and ${{ matrix.os }}"
9+
name: "${{ matrix.os }}"
1010

1111
strategy:
1212
matrix:

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
4. Add new flags to the CLI in [`src/main/index.ts`](src/main/index.ts)
1212
5. Add the plugin to the `plugins` array in [`src/main/setup/setup.ts`](src/main/setup/setup.ts).
1313
6. Add potential plugin steps to the `steps` array in [`src/main/setup/setup.ts`](src/main/setup/setup.ts). Steps are run top-to-bottom.
14-
7. Update the `README.md`:
14+
7. Update the [`README.md`](README.md):
1515
- Add the technology to the technology list
16-
- Update the `Usage` section to include the new technology
16+
- Update the `Usage` section by copy pasting the output of running `yarn print:help`
1717
8. Consider expanding some of the e2e tests to include the new technology.
1818
9. Run tests using `yarn test` to ensure they all pass
1919
10. Submit a Pull Request on GitHub

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ The table below provides an overview of the technologies currently supported by
6868
| [Husky](https://typicode.github.io/husky/) | [Docs](https://typicode.github.io/husky/) - [GitHub repo](https://github.com/typicode/husky) |
6969
| [lint-staged](https://github.com/okonet/lint-staged) | [GitHub repo](https://github.com/okonet/lint-staged) |
7070
| [GitHub Actions](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) |
71+
| [React Icons](https://react-icons.github.io/react-icons/) | [GitHub repo](https://github.com/react-icons/react-icons) |
7172

7273
## Usage
7374

@@ -93,6 +94,7 @@ OPTIONS
9394
--package-manager=(pnpm|yarn|npm) Sets the preferred package manager. (Required)
9495
--prettier Adds Prettier. (Code formatting)
9596
--react-hook-form Adds React Hook Form. (Form library)
97+
--react-icons Adds React Icons. (Icon library)
9698
--styling=<styling-method> Sets the preferred styling method. (Required) <styling-method> = emotion|styled-components|tailwind-css|css-modules|css-modules-with-sass
9799
```
98100

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "create-next-stack",
33
"description": "Create Next Stack is a website and CLI tool used to easily set up the boilerplate of new Next.js apps.",
4-
"version": "0.2.0",
4+
"version": "0.2.1",
55
"author": "Anders Kjær Damgaard @akd-io",
66
"bugs": "https://github.com/akd-io/create-next-stack/issues",
77
"homepage": "https://github.com/akd-io/create-next-stack",
@@ -52,6 +52,8 @@
5252
"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
"test:live": "yarn build && node lib/tests/e2e/test-live.js",
55+
"print:help": "yarn build && ./bin-test/run-prod --help",
56+
"print:version": "yarn build && ./bin-test/run-prod --help",
5557
"version": "oclif-dev readme && git add README.md",
5658
"format": "prettier --write --ignore-path=.prettierignore .",
5759
"format:check": "prettier --check --ignore-path=.prettierignore .",

prod-assets/templates/LandingPage/LandingPageTemplate.tsx

Lines changed: 0 additions & 121 deletions
This file was deleted.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ 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", "pnpm"] as const
29+
export const packageManagerOptions = ["pnpm", "yarn", "npm"] as const
3030
export type PackageManager = typeof packageManagerOptions[number]
3131
export const writablePackageManagerOptions = packageManagerOptions as Writable<
3232
typeof packageManagerOptions

src/main/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ class CreateNextStack extends Command {
9292
"formatting-pre-commit-hook": flags.boolean({
9393
description: "Adds a formatting pre-commit hook. (Requires Prettier)",
9494
}),
95+
96+
// Icons
97+
"react-icons": flags.boolean({
98+
description: "Adds React Icons. (Icon library)",
99+
}),
95100
}
96101

97102
async run(): Promise<void> {

src/main/plugins/chakra-ui/chakra-ui.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,13 @@ export const chakraUIPlugin = createPlugin({
4040
slots: {
4141
app: {
4242
imports: endent`
43-
import { ChakraProvider, ColorModeProvider } from "@chakra-ui/react";
43+
import { ChakraProvider } from "@chakra-ui/react";
4444
import { chakraTheme } from "../chakra-theme";
4545
`,
4646
componentsStart: endent`
47-
<ChakraProvider resetCSS theme={chakraTheme}>
48-
<ColorModeProvider
49-
options={{
50-
initialColorMode: chakraTheme.config.initialColorMode,
51-
useSystemColorMode: chakraTheme.config.useSystemColorMode,
52-
}}
53-
>
47+
<ChakraProvider theme={chakraTheme}>
5448
`,
5549
componentsEnd: endent`
56-
</ColorModeProvider>
5750
</ChakraProvider>
5851
`,
5952
},

src/main/plugins/chakra-ui/setup/chakra-theme.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,10 @@ import endent from "endent"
33
export const chakraTheme = endent`
44
import { extendTheme, ThemeConfig } from "@chakra-ui/react";
55
6-
const colors = {
7-
brand: {
8-
900: "#1a365d",
9-
800: "#153e75",
10-
700: "#2a69ac",
11-
},
12-
};
13-
146
const config: ThemeConfig = {
157
initialColorMode: "light",
168
useSystemColorMode: false,
179
};
1810
19-
export const chakraTheme = extendTheme({ colors, config });
11+
export const chakraTheme = extendTheme({ config });
2012
`
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
import endent from "endent"
2+
import { ValidCNSInputs } from "../../../../../create-next-stack-types"
3+
import { getProjectNameOfPath } from "../../../../../helpers/get-project-name-of-path"
4+
5+
export const generateLandingPageTemplate = (inputs: ValidCNSInputs): string => {
6+
return endent`
7+
import Script from "next/script";
8+
import styles from "./LandingPageTemplate.module.css";
9+
import { Container } from "./components/Container";
10+
import { InlineCode } from "./components/InlineCode";
11+
import { Link } from "./components/Link";
12+
import { Paragraph } from "./components/Paragraph";
13+
import { Section } from "./components/Section";
14+
import { Subtitle } from "./components/Subtitle";
15+
import { TechnologyGrid } from "./components/TechnologyGrid";
16+
import { H1, H2 } from "./components/headings";
17+
import { technologies } from "./technologies";
18+
19+
const LandingPageTemplate = () => {
20+
const onConfettiLoad = () => {
21+
const key = "create-next-stack-hasShownConfetti-${encodeURI(
22+
getProjectNameOfPath(inputs.args.appName)
23+
)}";
24+
const hasShownConfetti = localStorage.getItem(key);
25+
if (hasShownConfetti != null) return;
26+
27+
const duration = 10 * 1000;
28+
const animationEnd = Date.now() + duration;
29+
30+
const randomInRange = (min: number, max: number) => {
31+
return Math.random() * (max - min) + min;
32+
};
33+
34+
(function frame() {
35+
const timeLeft = animationEnd - Date.now();
36+
37+
(window as any).confetti({
38+
particleCount: 1,
39+
startVelocity: 0,
40+
ticks: Math.max(200, 500 * (timeLeft / duration)),
41+
origin: {
42+
x: Math.random(),
43+
y: Math.random() - 0.2,
44+
},
45+
colors: [
46+
"#26ccff",
47+
"#a25afd",
48+
"#ff5e7e",
49+
"#88ff5a",
50+
"#fcff42",
51+
"#ffa62d",
52+
"#ff36ff",
53+
],
54+
shapes: ["square", "circle"],
55+
gravity: randomInRange(0.4, 0.6),
56+
scalar: randomInRange(0.8, 1.2),
57+
drift: randomInRange(-0.1, 0.1),
58+
});
59+
60+
if (timeLeft > 0) {
61+
requestAnimationFrame(frame);
62+
}
63+
})();
64+
65+
localStorage.setItem(key, "true");
66+
};
67+
68+
return (
69+
<div className={styles.landingPageTemplate}>
70+
<Script
71+
src="https://cdn.jsdelivr.net/npm/tsparticles-confetti@2.9.3/tsparticles.confetti.bundle.min.js"
72+
onLoad={onConfettiLoad}
73+
/>
74+
<style>
75+
{\`
76+
* {
77+
box-sizing: border-box;
78+
}
79+
80+
html,
81+
body {
82+
padding: 0;
83+
margin: 0;
84+
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto,
85+
Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue,
86+
sans-serif;
87+
line-height: 1.5;
88+
}
89+
\`}
90+
</style>
91+
<main>
92+
<Section>
93+
<Container center className={styles.headerSection}>
94+
<H1>
95+
<span className={styles.textGradient}>Your project is a go!</span>{" "}
96+
🎉
97+
</H1>
98+
<Subtitle>
99+
Get started by editing <InlineCode>pages/index.tsx</InlineCode>
100+
</Subtitle>
101+
</Container>
102+
</Section>
103+
<Section>
104+
<Container className={styles.technologyGridIntro}>
105+
<H2>Technologies</H2>
106+
<Paragraph>
107+
Below you will find an overview of your chosen technologies
108+
providing you helpful links and simple usage examples to get you
109+
started.
110+
</Paragraph>
111+
</Container>
112+
<Container wide>
113+
<TechnologyGrid
114+
technologies={technologies}
115+
className={styles.technologyGrid}
116+
/>
117+
</Container>
118+
</Section>
119+
</main>
120+
<footer>
121+
<Section>
122+
<Container center>
123+
<Paragraph>
124+
Generated by{" "}
125+
<Link href="https://github.com/akd-io/create-next-stack">
126+
Create Next Stack
127+
</Link>
128+
</Paragraph>
129+
</Container>
130+
</Section>
131+
</footer>
132+
</div>
133+
);
134+
};
135+
136+
export default LandingPageTemplate;
137+
`
138+
}

0 commit comments

Comments
 (0)