Skip to content

Commit

Permalink
chore: 馃敡 maintenance
Browse files Browse the repository at this point in the history
Updated package versions and fixed errors that occured
  • Loading branch information
Can-Sahin committed Jul 13, 2021
1 parent 2bb4bc7 commit 2e1b814
Show file tree
Hide file tree
Showing 23 changed files with 3,503 additions and 3,542 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@
"contributions": [
"doc"
]
},
{
"login": "lourensdev",
"name": "Lourens de Villiers",
"avatar_url": "https://avatars.githubusercontent.com/u/5746141?v=4",
"profile": "https://github.com/lourensdev",
"contributions": [
"doc"
]
}
],
"contributorsPerLine": 8,
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const prettierOptions = JSON.parse(
);

module.exports = {
extends: ['react-app', 'prettier', 'prettier/react'],
extends: ['react-app', 'prettier'],
plugins: ['prettier'],
rules: {
'prettier/prettier': ['error', prettierOptions],
Expand Down
6 changes: 6 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

if yarn git-branch-is dev;
then yarn commitlint --edit $1;
fi
6 changes: 6 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn checkTs
yarn lint-staged
yarn verify-startingTemplate-changes
4 changes: 4 additions & 0 deletions .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn devmoji -e
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ with a focus on
---

The official [Create React App](https://github.com/facebook/create-react-app) template of the `discontinued` [React Boilerplate](https://github.com/react-boilerplate/react-boilerplate)
![](https://img.shields.io/github/stars/react-boilerplate/react-boilerplate?style=flat)

Start your `create-react-app` projects in seconds with the best, industry-standard tools and practices made ready for you.

**馃摎 Documentation:** [Gitbook](https://cansahin.gitbook.io/react-boilerplate-cra-template/)

**馃帹 Check the example app:** [Demonstrating the features](https://react-boilerplate.github.io/react-boilerplate-cra-template/)

**馃搨 Browse in VS Code:** [![Open in Visual Studio Code](https://open.vscode.dev/badges/open-in-vscode.svg)](https://open.vscode.dev/react-boilerplate/react-boilerplate-cra-template)

**馃摝 Package:** [npm](https://www.npmjs.com/package/cra-template-rb)

![version](https://img.shields.io/npm/v/cra-template-rb)
Expand Down Expand Up @@ -133,6 +134,7 @@ But wait... there's more!
<td align="center"><a href="https://github.com/Can-Sahin"><img src="https://avatars2.githubusercontent.com/u/33245689?s=80" width="80px;" alt=""/><br /><sub><b>Can Sahin</b></sub></a><br /><a href="https://github.com/react-boilerplate/react-boilerplate-cra-template/commits?author=Can-Sahin" title="Code">馃捇</a> <a href="https://github.com/react-boilerplate/react-boilerplate-cra-template/commits?author=Can-Sahin" title="Documentation">馃摉</a> <a href="#ideas-Can-Sahin" title="Ideas, Planning, & Feedback">馃</a> <a href="https://github.com/react-boilerplate/react-boilerplate-cra-template/pulls?q=is%3Apr+reviewed-by%3ACan-Sahin" title="Reviewed Pull Requests">馃憖</a> <a href="https://github.com/react-boilerplate/react-boilerplate-cra-template/commits?author=Can-Sahin" title="Tests">鈿狅笍</a></td>
<td align="center"><a href="https://github.com/receptiryaki"><img src="https://avatars0.githubusercontent.com/u/3495307?s=80" width="80px;" alt=""/><br /><sub><b>Recep Tiryaki</b></sub></a><br /><a href="https://github.com/react-boilerplate/react-boilerplate-cra-template/commits?author=receptiryaki" title="Code">馃捇</a> <a href="#ideas-receptiryaki" title="Ideas, Planning, & Feedback">馃</a> <a href="#design-receptiryaki" title="Design">馃帹</a></td>
<td align="center"><a href="https://github.com/mogsdad"><img src="https://avatars3.githubusercontent.com/u/1707731?s=80" width="80px;" alt=""/><br /><sub><b>David Bingham</b></sub></a><br /><a href="https://github.com/react-boilerplate/react-boilerplate-cra-template/commits?author=mogsdad" title="Documentation">馃摉</a></td>
<td align="center"><a href="https://github.com/lourensdev"><img src="https://avatars.githubusercontent.com/u/5746141?v=4?s=80" width="80px;" alt=""/><br /><sub><b>Lourens de Villiers</b></sub></a><br /><a href="https://github.com/react-boilerplate/react-boilerplate-cra-template/commits?author=lourensdev" title="Documentation">馃摉</a></td>
</tr>
</table>

Expand Down
18 changes: 5 additions & 13 deletions internals/scripts/clean.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import shell from 'shelljs';
import path from 'path';
import chalk from 'chalk';
import replace from 'replace-in-file';
import fs from 'fs';
const packageJson = require('../../package.json');

Expand All @@ -28,31 +27,24 @@ export function cleanAndSetup(opts: Options = {}) {

shell.exec('yarn run prettify -- src/*', { silent: true });

cleanPackageJsonFile();
modifyPackageJsonFile();

shell.echo(
chalk.green('Example app removed and setup completed. Happy Coding!!!'),
);
}

function cleanPackageJsonFile() {
function modifyPackageJsonFile() {
delete packageJson['eslintConfig'];
delete packageJson['dependencies']['replace-in-file'];
delete packageJson['scripts']['cleanAndSetup'];

packageJson['scripts']['prepare'] = 'husky install';

fs.writeFileSync('./package.json', JSON.stringify(packageJson));
shell.exec('yarn run prettify -- package.json', { silent: true });

try {
// Remove explanation from husky to enable it
replace.sync({
files: 'package.json',
from: /"husky\((.*?)\)"/g,
to: '"husky"',
});
} catch (error) {
console.error('Couldnt clean husky:', error);
}
shell.exec('yarn install', { silent: false });
}

(function () {
Expand Down
24 changes: 0 additions & 24 deletions internals/scripts/create-cra-app.script.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import shell from 'shelljs';
import { createNpmPackage, removeNpmPackage } from './create-npm-package';
import replace from 'replace-in-file';
import fs from 'fs';

interface Options {}

Expand All @@ -16,28 +14,6 @@ export function createCRA(opts: Options = {}) {
});

removeNpmPackage();

fixHuskyBug();
}

function fixHuskyBug() {
// husky changes directory to the example folder which we don't want
// https://github.com/typicode/husky#monorepos
// https://github.com/typicode/husky/issues/677
const huskyLocalPath = '.git/hooks/husky.local.sh';
if (!fs.existsSync(huskyLocalPath)) {
return;
}
const options = {
files: '.git/hooks/husky.local.sh',
from: /cd.*/g,
to: `cd "."`,
};
try {
replace.sync(options);
} catch (error) {
console.error('Error occurred:', error);
}
}

createCRA();
34 changes: 31 additions & 3 deletions internals/scripts/create-template-folder.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
import shell from 'shelljs';
import replace from 'replace-in-file';

import { shellEnableAbortOnFail, shellDisableAbortOnFail } from './utils';

interface Options {}

export function crateTemplateFolder(opts: Options = {}) {
const abortOnFailEnabled = shellEnableAbortOnFail();

const copyToTemplate = (path: string, isRecursive?: boolean) => {
const copyToTemplate = (
path: string,
isRecursive?: boolean,
modifyContent?: {
from: RegExp;
to: string;
},
) => {
const p = `template/${path}`;
if (isRecursive) {
shell.cp('-r', path, `template/${path}`);
shell.cp('-r', path, p);
} else {
shell.cp(path, `template/${path}`);
shell.cp(path, p);
}
if (modifyContent) {
try {
replace.sync({
files: p,
from: modifyContent.from,
to: modifyContent.to,
});
} catch (error) {
console.error('Couldnt modify content:', error);
}
}
};

Expand All @@ -19,6 +40,13 @@ export function crateTemplateFolder(opts: Options = {}) {

shell.mkdir('template');

// We want only pre-commit hook with custom script excluded
shell.mkdir('template/.husky');
copyToTemplate('.husky/pre-commit', false, {
from: /yarn verify-startingTemplate-changes/g,
to: '',
});

shell.mkdir('template/internals');
copyToTemplate('internals/generators', true);

Expand Down
3 changes: 2 additions & 1 deletion internals/startingTemplate/src/locales/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { ConvertedToObjectType, TranslationJsonType } from './types';
* This file is seperate from the './i18n.ts' simply to make the Hot Module Replacement work seamlessly.
* Your components can import this file in 'messages.ts' files which would ruin the HMR if this isn't a separate module
*/
export const translations: ConvertedToObjectType<TranslationJsonType> = {} as any;
export const translations: ConvertedToObjectType<TranslationJsonType> =
{} as any;

/*
* Converts the static JSON file into an object where keys are identical
Expand Down
8 changes: 6 additions & 2 deletions internals/startingTemplate/src/store/configureStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
* Create the store with dynamic reducers
*/

import { configureStore, getDefaultMiddleware } from '@reduxjs/toolkit';
import {
configureStore,
getDefaultMiddleware,
StoreEnhancer,
} from '@reduxjs/toolkit';
import { createInjectorsEnhancer } from 'redux-injectors';
import createSagaMiddleware from 'redux-saga';

Expand All @@ -21,7 +25,7 @@ export function configureAppStore() {
createReducer,
runSaga,
}),
];
] as StoreEnhancer[];

const store = configureStore({
reducer: createReducer(),
Expand Down
2 changes: 1 addition & 1 deletion internals/startingTemplate/src/utils/@reduxjs/toolkit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
export const createSlice = <
State,
CaseReducers extends SliceCaseReducers<State>,
Name extends RootStateKeyType
Name extends RootStateKeyType,
>(
options: CreateSliceOptions<State, CaseReducers, Name>,
) => {
Expand Down
2 changes: 1 addition & 1 deletion internals/startingTemplate/src/utils/loadable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type Unpromisify<T> = T extends Promise<infer P> ? P : never;

export const lazyLoad = <
T extends Promise<any>,
U extends React.ComponentType<any>
U extends React.ComponentType<any>,
>(
importFunc: () => T,
selectorFunc?: (s: Unpromisify<T>) => U,
Expand Down

0 comments on commit 2e1b814

Please sign in to comment.