Skip to content

Commit

Permalink
Cleanup around dependencies
Browse files Browse the repository at this point in the history
* Moved a bunch to `devDependencies` that should've been there in the
  first place
* Dropped `styled-components`; I mostly use MUI for styling, so
  switching to its default (`emotion`) makes things easier
* Who needs tests anyway
* Fixed most dependency warnings, rest are tracked in #12
  • Loading branch information
abesto committed Feb 5, 2022
1 parent 6f1139a commit 77b84e4
Show file tree
Hide file tree
Showing 15 changed files with 1,379 additions and 2,091 deletions.
24 changes: 0 additions & 24 deletions internals/generators/component/index.test.tsx.hbs

This file was deleted.

67 changes: 2 additions & 65 deletions internals/generators/component/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,17 @@
* Component Generator
*/

import { Actions, PlopGeneratorConfig } from 'node-plop';
import inquirer from 'inquirer';
import { Actions, PlopGeneratorConfig } from 'node-plop';

import { pathExists } from '../utils';
import { baseGeneratorPath } from '../paths';
import { pathExists } from '../utils';

inquirer.registerPrompt('directory', require('inquirer-directory'));

export enum ComponentProptNames {
componentName = 'componentName',
path = 'path',
wantMemo = 'wantMemo',
wantStyledComponents = 'wantStyledComponents',
wantTranslations = 'wantTranslations',
wantLoadable = 'wantLoadable',
wantTests = 'wantTests',
}

type Answers = { [P in ComponentProptNames]: string };
Expand All @@ -36,37 +31,6 @@ export const componentGenerator: PlopGeneratorConfig = {
message: 'Where do you want it to be created?',
basePath: `${baseGeneratorPath}`,
} as any,
{
type: 'confirm',
name: ComponentProptNames.wantMemo,
default: false,
message: 'Do you want to wrap your component in React.memo?',
},
{
type: 'confirm',
name: ComponentProptNames.wantStyledComponents,
default: true,
message: 'Do you want to use styled-components?',
},
{
type: 'confirm',
name: ComponentProptNames.wantTranslations,
default: false,
message:
'Do you want i18n translations (i.e. will this component use text)?',
},
{
type: 'confirm',
name: ComponentProptNames.wantLoadable,
default: false,
message: 'Do you want to load the component asynchronously?',
},
{
type: 'confirm',
name: ComponentProptNames.wantTests,
default: false,
message: 'Do you want to have tests?',
},
],
actions: data => {
const answers = data as Answers;
Expand All @@ -86,33 +50,6 @@ export const componentGenerator: PlopGeneratorConfig = {
},
];

if (answers.wantLoadable) {
actions.push({
type: 'add',
path: `${componentPath}/Loadable.ts`,
templateFile: './component/loadable.ts.hbs',
abortOnFail: true,
});
}

if (answers.wantTests) {
actions.push({
type: 'add',
path: `${componentPath}/__tests__/index.test.tsx`,
templateFile: './component/index.test.tsx.hbs',
abortOnFail: true,
});
}

if (answers.wantTranslations) {
actions.push({
type: 'add',
path: `${componentPath}/messages.ts`,
templateFile: './component/messages.ts.hbs',
abortOnFail: true,
});
}

actions.push({
type: 'prettify',
data: { path: `${actualComponentPath}/**` },
Expand Down
52 changes: 3 additions & 49 deletions internals/generators/component/index.tsx.hbs
Original file line number Diff line number Diff line change
@@ -1,56 +1,10 @@
/**
*
* {{ properCase componentName }}
*
*/
{{#if wantMemo}}
import React, { memo } from 'react';
{{else}}
import * as React from 'react';
{{/if}}
{{#if wantStyledComponents}}
import styled from 'styled-components/macro';
{{/if}}
{{#if wantTranslations}}
import { useTranslation } from 'react-i18next';
import { messages } from './messages';
{{/if}}

interface Props {}

{{#if wantMemo}}
export const {{ properCase componentName }} = memo((props: Props) => {
{{else}}
export function {{ properCase componentName }}(props: Props) {
{{/if}}
{{#if wantTranslations}}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { t, i18n } = useTranslation();
{{/if}}

return (
{{#if wantStyledComponents}}
<Div>
{{else}}
<div>
{{/if}}
{{#if wantTranslations}}
{t('')}
{/* {t(...messages.someThing())} */}
{{/if}}
{{#if wantStyledComponents}}
</Div>
{{else}}
</div>
{{/if}}
<>
</>
);

{{#if wantMemo}}
});
{{else}}
};
{{/if}}

{{#if wantStyledComponents}}
const Div = styled.div``;
{{/if}}
}
9 changes: 0 additions & 9 deletions internals/generators/component/loadable.ts.hbs

This file was deleted.

11 changes: 0 additions & 11 deletions internals/generators/component/messages.ts.hbs

This file was deleted.

76 changes: 27 additions & 49 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,22 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@emotion/react": "11.7.1",
"@emotion/styled": "11.6.0",
"@mui/icons-material": "5.3.1",
"@mui/material": "5.3.1",
"@mui/styled-engine-sc": "5.3.0",
"@mui/material": "5.4.0",
"@reduxjs/toolkit": "1.7.1",
"@testing-library/jest-dom": "5.16.1",
"@testing-library/react": "12.1.2",
"@types/fontfaceobserver": "2.1.0",
"@types/jest": "27.4.0",
"@types/node": "14.14.31",
"@types/react": "17.0.38",
"@types/react-dom": "17.0.11",
"@types/react-redux": "7.1.22",
"@types/react-router-dom": "5.3.2",
"@types/react-test-renderer": "17.0.1",
"@types/rimraf": "3.0.2",
"@types/shelljs": "0.8.11",
"@types/styled-components": "5.1.20",
"@types/testing-library__jest-dom": "5.14.2",
"@types/webpack": "5.28.0",
"@types/webpack-env": "1.16.3",
"chalk": "4.1.2",
"cross-env": "7.0.3",
"dayjs": "1.10.7",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-react-hooks": "4.3.0",
"file-saver": "2.0.5",
"fontfaceobserver": "2.1.0",
"husky": "7.0.4",
"inquirer": "7.3.3",
"inquirer-directory": "2.2.0",
"jest-styled-components": "7.0.8",
"lint-staged": "12.1.7",
"lz-string": "1.4.4",
"node-plop": "0.26.2",
"papaparse": "5.3.1",
"plop": "2.7.4",
"prettier": "2.5.1",
"raw.macro": "0.4.2",
"react": "17.0.2",
"react-app-polyfill": "3.0.0",
Expand All @@ -56,21 +34,39 @@
"rimraf": "3.0.2",
"serve": "13.0.2",
"shelljs": "0.8.5",
"styled-components": "5.3.3",
"ts-node": "10.4.0",
"typescript": "4.5.4",
"web-vitals": "2.1.2"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/plugin-syntax-flow": "^7.14.5",
"@babel/plugin-transform-react-jsx": "^7.14.9",
"@testing-library/react": "12.1.2",
"@types/file-saver": "2.0.5",
"@types/fontfaceobserver": "2.1.0",
"@types/node": "14.14.31",
"@types/react": "17.0.38",
"@types/react-dom": "17.0.11",
"@types/react-redux": "7.1.22",
"@types/react-router-dom": "5.3.3",
"@types/react-test-renderer": "17.0.1",
"@types/rimraf": "3.0.2",
"@types/shelljs": "0.8.11",
"@types/webpack": "5.28.0",
"@types/webpack-env": "1.16.3",
"autoprefixer": "10.4.2",
"eslint": "8.8.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-react-hooks": "4.3.0",
"postcss": "^8.1.0",
"prettier": "2.5.1",
"react-scripts": "5.0.0",
"stylelint": "14.2.0",
"stylelint-config-recommended": "6.0.0",
"stylelint-config-styled-components": "0.1.1",
"stylelint-processor-styled-components": "1.10.0"
},
"resolutions": {
"@mui/styled-engine": "npm:@mui/styled-engine-sc@latest"
"node-plop": "0.30.0",
"plop": "3.0.5"
},
"scripts": {
"start": "react-scripts start",
Expand Down Expand Up @@ -111,23 +107,5 @@
"*.{md,json}": [
"prettier --write"
]
},
"jest": {
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*/*.d.ts",
"!src/**/*/Loadable.{js,jsx,ts,tsx}",
"!src/**/*/messages.ts",
"!src/**/*/types.ts",
"!src/index.tsx"
],
"coverageThreshold": {
"global": {
"branches": 90,
"functions": 90,
"lines": 90,
"statements": 90
}
}
}
}
14 changes: 0 additions & 14 deletions src/app/__tests__/index.test.tsx

This file was deleted.

34 changes: 34 additions & 0 deletions src/app/components/Export.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import dayjs from 'dayjs';
import saveAs from 'file-saver';
import * as React from 'react';
import { useStore } from 'react-redux';
import { serialize } from 'store/saveload';

import DownloadIcon from '@mui/icons-material/Download';
import IconButton, { IconButtonProps } from '@mui/material/IconButton';
import Tooltip from '@mui/material/Tooltip';

function filename(): string {
return dayjs().format('YYYY-MM-DD-HH-mm-ss') + '.ams2career';
}

export function Export(props: IconButtonProps) {
const store = useStore();
return (
<Tooltip title="Export">
<IconButton
onClick={() =>
saveAs(
new Blob([serialize(store.getState())], {
type: 'application/octet-stream',
}),
filename(),
)
}
{...props}
>
<DownloadIcon />
</IconButton>
</Tooltip>
);
}
Loading

0 comments on commit 77b84e4

Please sign in to comment.