Skip to content

Commit d2a1e6f

Browse files
authored
Merge pull request #164 from akd-io/feature/132-support-react-icons
Add support for React Icons
2 parents c4ac4aa + 07edf68 commit d2a1e6f

24 files changed

+74
-5
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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
"test:small": "yarn build && node lib/tests/e2e/manual-test.js --debug --package-manager=pnpm --styling=css-modules",
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",
54+
"print:help": "yarn build && ./bin-test/run-prod --help",
55+
"print:version": "yarn build && ./bin-test/run-prod --help",
5456
"version": "oclif-dev readme && git add README.md",
5557
"format": "prettier --write --ignore-path=.prettierignore .",
5658
"format:check": "prettier --check --ignore-path=.prettierignore .",

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/react-icons.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { createPlugin } from "../plugin"
2+
3+
export const reactIconsPlugin = createPlugin({
4+
name: "React Icons",
5+
description: "Adds support for React Icons",
6+
active: ({ flags }) => Boolean(flags["react-icons"]),
7+
devDependencies: {
8+
"react-icons": { name: "react-icons", version: "^4.8.0" },
9+
},
10+
technologies: [
11+
{
12+
name: "React Icons",
13+
description:
14+
"React Icons is SVG icon library. It comprises icons from over 25 of the most popular icon libraries including Ant Design Icons, Bootstrap Icons, Feather, Font Awesome, and Material Design icons. It uses React component syntax, and utilizes ES6 imports to only bundle the icons your app is using.",
15+
links: [
16+
{ title: "Website", url: "https://react-icons.github.io/react-icons/" },
17+
{ title: "GitHub", url: "https://github.com/react-icons/react-icons" },
18+
],
19+
},
20+
],
21+
} as const)

src/main/setup/setup.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getDiffString } from "../helpers/diff-string"
55
import { inDebugMode } from "../helpers/in-debug-mode"
66
import { time } from "../helpers/time"
77
import { logDebug, logInfo } from "../logging"
8-
import { evalActive, evalShouldRun, Plugin } from "../plugin"
8+
import { Plugin, evalActive, evalShouldRun } from "../plugin"
99
import { chakraUIPlugin } from "../plugins/chakra-ui/chakra-ui"
1010
import { createNextStackPlugin } from "../plugins/create-next-stack/create-next-stack"
1111
import { cssModulesPlugin } from "../plugins/css-modules/css-modules"
@@ -22,6 +22,7 @@ import { pnpmPlugin } from "../plugins/pnpm"
2222
import { prettierPlugin } from "../plugins/prettier"
2323
import { reactPlugin } from "../plugins/react"
2424
import { reactHookFormPlugin } from "../plugins/react-hook-form"
25+
import { reactIconsPlugin } from "../plugins/react-icons"
2526
import { sassPlugin } from "../plugins/sass/sass"
2627
import { styledComponentsPlugin } from "../plugins/styled-components"
2728
import { tailwindCSSPlugin } from "../plugins/tailwind-css"
@@ -52,6 +53,7 @@ export const plugins: Plugin[] = [
5253
yarnPlugin,
5354
npmPlugin,
5455
githubActionsPlugin,
56+
reactIconsPlugin,
5557
]
5658

5759
export const filterPlugins = (inputs: ValidCNSInputs): Plugin[] =>

src/tests/e2e/tests/css-modules-with-sass/css-modules-with-sass-all-flags.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { logTestInfo } from "../../test-logging"
88
export const testCssModulesWithSassAllFlags = async (
99
createNextStackDir: string
1010
): Promise<void> => {
11+
logTestInfo(`Running test: ${testCssModulesWithSassAllFlags.name}`)
12+
1113
const { pathToProdCLI, runDirectory } = await prepareE2eTest(
1214
createNextStackDir
1315
)
@@ -21,6 +23,7 @@ export const testCssModulesWithSassAllFlags = async (
2123
"--formik",
2224
"--framer-motion",
2325
"--formatting-pre-commit-hook",
26+
"--react-icons",
2427
".",
2528
]
2629

src/tests/e2e/tests/css-modules-with-sass/css-modules-with-sass-only.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { logTestInfo } from "../../test-logging"
88
export const testCssModulesWithSassOnly = async (
99
createNextStackDir: string
1010
): Promise<void> => {
11+
logTestInfo(`Running test: ${testCssModulesWithSassOnly.name}`)
12+
1113
const { pathToProdCLI, runDirectory } = await prepareE2eTest(
1214
createNextStackDir
1315
)

0 commit comments

Comments
 (0)