blaketarter / github-actions-demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crema App - Web 🌐

Build Status codecov License: MIT

This project includes configuration and tooling that conforms to Crema's baseline best-practices for a Web Application.

🧰 Tools Used

πŸ— Setup

  1. Install Node/NPM
  2. Install NVM (Node Version Manager)
  3. nvm install 'lts/*' && nvm use
  4. npm i (install project dependencies)
  5. Install the ESLint plugin for your editor VS Code
  6. Enable "Auto-Fix on Save" in settings.json:
{
  "eslint.autoFixOnSave": true,
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    { "language": "typescript", "autoFix": true },
    { "language": "typescriptreact", "autoFix": true }
  ]
}

πŸ‘Ÿ Run

Run the following scripts with npm run <SCRIPT_HERE>:

  • start - start app
  • new:component - generate a new component
  • new:util - generate a new util(ity)
  • test:analyze - run bundle analyzer
  • test:e2e - run end-to-end tests
  • test:lint:fix - run linter and fix if possible
  • test:lint - run linter
  • test:playground - run component playground (storybook)
  • test:unit:coverage - run unit tests with coverage
  • test:unit - run unit tests
  • test:visual:approve - approve visual changes
  • test:visual:update - update or create visual references
  • test:visual - run visual tests (loki)

These scripts are located in package.json and do not represent the entirety of available scripts, but are the most commonly used.

πŸ› Structure

The src directory is where the meat of your app is located. Below is a printout of its file-tree with a description for each part.

src
β”œβ”€β”€ assets // Fonts, Images, Etc.
β”‚   └── logo.svg
β”œβ”€β”€ components // Create a new one with `npm run new:component`
β”‚   └── App
β”‚       β”œβ”€β”€ __snapshots__ // Generated by Jest from `test.tsx`
β”‚       β”‚   └── test.tsx.snap
β”‚       β”œβ”€β”€ README.md // Documentation
β”‚       β”œβ”€β”€ index.css // Styles
β”‚       β”œβ”€β”€ index.tsx // Main Module Code
β”‚       β”œβ”€β”€ stories.tsx // Playground stories (npm run test:playground)
β”‚       └── test.tsx // Unit Tests (Jest)
β”œβ”€β”€ types // Centralize Type Definitions
β”‚   β”œβ”€β”€ Entity.ts // Base Type
β”‚   β”œβ”€β”€ EntityThing.ts // A Sub-Type
β”‚   β”œβ”€β”€ Id.ts // A Type Alias of `string`
β”‚   β”œβ”€β”€ MapStateToProps.ts // Includes our `State`
β”‚   β”œβ”€β”€ State.ts // Redux state interface
β”‚   └── Thing.ts // Silly example used by `EntityThing`
β”œβ”€β”€ utils // Create a new one with `npm run new:util`
β”‚   β”œβ”€β”€ mySpecialUtil
β”‚   β”‚   β”œβ”€β”€ __snapshots__ // Generated by Jest from `test.ts`
β”‚   β”‚   β”‚   └── test.tsx.snap
β”‚   β”‚   β”œβ”€β”€ README.md // Documentation
β”‚   β”‚   β”œβ”€β”€ index.tsx // Main Module Code
β”‚   β”‚   └── test.tsx // Unit Tests (Jest)
β”‚   β”œβ”€β”€ decoratorCentered // Used in stories.tsx
β”‚   └── shallowRender // Used to render components in test.tsx
β”œβ”€β”€ index.css // Root Styles
β”œβ”€β”€ index.tsx // Root Module
β”œβ”€β”€ react-app-env.d.ts // Definitions from create-react-app
└── serviceWorker.ts // Documentation

πŸ₯‡ Best Practices

  • Use the code generators:
    • npm run new:component
    • npm run new:util
    • When prompted for a name, prefer camelCase for utils and CamelCase for components
  • Fill out the README.md to describe what your code does
  • Run your unit tests npm run test:unit while working to see immediate feedback
  • If you get stuck at any point, just log an issue and we'll figure it out together πŸ‘­.

About

License:MIT License


Languages

Language:TypeScript 47.2%Language:JavaScript 21.8%Language:Perl 6 16.8%Language:HTML 8.9%Language:CSS 5.3%