Skip to content

Instantly share code, notes, and snippets.

View BrianJenney's full-sized avatar

jenneyb BrianJenney

View GitHub Profile
@BrianJenney
BrianJenney / .babelrc
Created November 13, 2021 14:14
npm library starter
{
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": false
}
]
],
"plugins": ["@babel/plugin-transform-runtime"]
module.exports = (plop) => {
require('component-generator-library')(plop);
};
const path = require('path');
const templatesPath = path.resolve(__dirname, 'templates'); // this is the path to our templates
const consumerPath = process.cwd(); // returns the current working directory
module.exports = (plop) => {
plop.setGenerator('component', componentPrompts({ templatesPath, consumerPath }));
};
it('should show water bottles when a user navigates to `product/water-bottles`', () => {
const { findByText } = renderWithRouterMatch(
<ProductPage />,
{
path: '/:product',
route: '/water-bottles/'
},
{ store = {} }
);
import { createMemoryHistory } from 'history';
export const renderWithRouterMatch = (
Component,
{ path = '/', route = '/', history = createMemoryHistory({ initialEntries: [route] }) } = {},
{ store } = {}
) => ({
...render(
<BrowserRouter>
<Router history={history}>
import React from 'react';
import { renderWithRedux, createReduxStore } from './tests/testHelpers';
import Cart from './Cart';
describe('Cart', () => {
it('displays the monetary value of the cart items', () => {
const cart = {
items: [
{
variant_name: 'Water Jug',
export function renderWithRedux(component, { store } = {}) {
const rendered = render(
<BrowserRouter>
<ThemeProvider theme="bri">
<Provider store={store}>{component}</Provider>
</ThemeProvider>
</BrowserRouter>
);
// return the methods and properties from our custom render
const path = require('path');
const { useBabelRc, override } = require('customize-cra');
module.exports = override((config) => {
// we need the display names to NOT be mangled in order for our component library to work
// it uses the display name of a component to map it to the correct style rules
const updatedConfig = { ...config };
// use our node_modules and avoid duplicate react errors from deps that also use react
// when npm-linking
const npmLinkPaths = {
const https = require('https');
//////////// UPDATE THESE VALUES /////////////
const releaseBranch = 'release_branch';
const masterBranch = 'main';
const githubUsername = 'username';
const githubPassword = 'pw';
//////////////////////////////////////////////
// let's use a set so we don't count the same story/repo more than once
const stories = new Set();
/* logic for determing a button color based on the page location: */
// using conditional logic
const location = window.location.pathname;
let buttonColor = 'red';
if(location === 'signIn'){
buttonColor = 'yellow';