Skip to content
This repository has been archived by the owner on Mar 31, 2021. It is now read-only.

Commit

Permalink
chore(deps): upgrade deps to latest version (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
herberthenrique authored May 6, 2020
1 parent 41e2cdc commit 4e15db9
Show file tree
Hide file tree
Showing 11 changed files with 891 additions and 1,012 deletions.
36 changes: 20 additions & 16 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
const { node: baseConfig, overwritePresets } = require('@sumup/foundry/eslint');

const customConfig = {
overrides: [
{
files: ['files/**/*.js'],
rules: {
'notice/notice': 'off',
'import/no-unresolved': 'off',
'no-unused-vars': 'warn'
}
}
]
};

module.exports = overwritePresets(baseConfig, customConfig);
module.exports = require('@sumup/foundry/eslint')(
{
language: 'JavaScript',
environments: ['Node', 'Browser'],
frameworks: ['React', 'Emotion', 'Jest'],
openSource: true,
},
{
overrides: [
{
files: ['files/**/*.js'],
rules: {
'notice/notice': 'off',
'import/no-unresolved': 'off',
'no-unused-vars': 'warn',
},
},
],
},
);
2 changes: 1 addition & 1 deletion .huskyrc.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('@sumup/foundry/husky').base;
module.exports = require('@sumup/foundry/husky')();
2 changes: 1 addition & 1 deletion files/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
List,
Text,
theme as themes,
BaseStyles
BaseStyles,
} from '@sumup/circuit-ui';
import { ReactComponent as LogoIcon } from './assets/logo.svg';

Expand Down
1 change: 0 additions & 1 deletion files/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* global document */
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
Expand Down
8 changes: 4 additions & 4 deletions lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import * as util from './util';

const IS_DEBUGGING = util.isDebugging();

const getMessage = arg => (Array.isArray(arg) ? arg.join('\n') : arg);
const getMessage = (arg) => (Array.isArray(arg) ? arg.join('\n') : arg);

const error = arg => {
const error = (arg) => {
const msg = getMessage(arg);

/* eslint-disable no-console */
Expand All @@ -32,13 +32,13 @@ const error = arg => {
/* eslint-enable no-console */
};

const log = arg => {
const log = (arg) => {
const msg = getMessage(arg);
// eslint-disable-next-line no-console
console.log(`\n${msg}`);
};

const debug = arg => {
const debug = (arg) => {
if (!IS_DEBUGGING) {
return;
}
Expand Down
13 changes: 6 additions & 7 deletions lib/spawn.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const IS_DEBUGGING = util.isDebugging();
const DEFAULT_OPTIONS = {
cwd: process.cwd(),
detached: true,
stdio: IS_DEBUGGING ? 'inherit' : 'pipe'
stdio: IS_DEBUGGING ? 'inherit' : 'pipe',
};

function getBufferContent(chunks) {
Expand All @@ -38,22 +38,22 @@ export default function asyncSpawn(cmd, args, options) {
logger.debug(
`Spawning: "${cmd} ${args.join(' ')}" in working directory "${
options.cwd
}".`
}".`,
);

return new Promise((resolve, reject) => {
const child = spawn(cmd, args, {
...DEFAULT_OPTIONS,
...options
...options,
});

if (child.stdout) {
child.stdout.on('data', chunk => {
child.stdout.on('data', (chunk) => {
stdout.push(chunk);
});
}

child.on('close', code => {
child.on('close', (code) => {
if (code !== 0) {
// eslint-disable-next-line no-console
const err = new Error(`${cmd} exited with an error (code ${code}).`);
Expand All @@ -65,9 +65,8 @@ export default function asyncSpawn(cmd, args, options) {
resolve(getBufferContent(stdout));
});

child.on('error', err => {
child.on('error', (err) => {
logger.error(err);
process.exit(1);
// eslint-disable-next-line no-param-reassign
err.log = getBufferContent(stdout);
reject(err);
Expand Down
2 changes: 1 addition & 1 deletion lint-staged.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
* limitations under the License.
*/

module.exports = require('@sumup/foundry/lint-staged').base;
module.exports = require('@sumup/foundry/lint-staged')();
60 changes: 30 additions & 30 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,64 +33,64 @@ const APP_NAME = process.argv[2];
const APP_PATH = resolve(WORKING_DIR, APP_NAME || '');
const DEPENDENCIES = [
// Our beautiful component library 💄
'@sumup/circuit-ui@^1.0.0',
'@sumup/circuit-ui@^1.8.0',
// CSS-in-JS 🚀
'@emotion/core@^10.0.10',
'emotion-theming@^10.0.10',
'@emotion/styled@^10.0.10'
'@emotion/styled@^10.0.10',
];
const DEV_DEPENDENCIES = [
// React ⚛️
'prop-types',
// The toolkit 🛠
'@sumup/foundry@^1.0.0',
'@sumup/foundry@^2.2.0',
// Testing 📏
'@testing-library/react@^9.0.0',
'@testing-library/react@^10.0.0',
'jest-emotion@^10.0.11',
'@testing-library/jest-dom@^4.2.0'
'@testing-library/jest-dom@^5.5.0',
];

const listrOptions = util.isDebugging()
? {
renderer: VerboseRenderer
renderer: VerboseRenderer,
}
: {};

const tasks = new Listr(
[
{
title: 'Running Create React App',
task: () => runCreateReactApp(APP_NAME)
task: () => runCreateReactApp(APP_NAME),
},
{
title: 'Install additional dependencies',
task: () => addDependencies()
task: () => addDependencies(),
},
{
title: 'Customize experience',
task: () =>
new Listr([
{
title: 'Set up SumUp Foundry',
task: () => setUpFoundry(APP_PATH)
task: () => setUpFoundry(APP_PATH),
},
{
title: 'Replace Create React App files',
task: () =>
Promise.all([deleteCraFiles(APP_PATH), copyReactFiles(APP_PATH)])
Promise.all([deleteCraFiles(APP_PATH), copyReactFiles(APP_PATH)]),
},
{
title: 'Customize package.json',
task: () => updatePackageJson(APP_PATH)
task: () => updatePackageJson(APP_PATH),
},
{
title: 'Update initial commit',
task: () => updateInitialCommit(APP_PATH)
}
])
}
task: () => updateInitialCommit(APP_PATH),
},
]),
},
],
listrOptions
listrOptions,
);

run();
Expand All @@ -101,9 +101,9 @@ async function run() {
'Please pass a name for your app. For example, try',
'\n',
chalk` yarn create sumup-react-app {italic.bold my-app}`,
'\n'
'\n',
]);
process.exit(1);
throw new Error('App name undefined');
}

logger.log(`
Expand Down Expand Up @@ -136,7 +136,7 @@ function runCreateReactApp(appName) {
async function addDependencies({
dependencies = DEPENDENCIES,
devDepenencies = DEV_DEPENDENCIES,
cwd = APP_PATH
cwd = APP_PATH,
} = {}) {
const cmd = 'yarn';
const args = ['add', ...dependencies];
Expand All @@ -161,7 +161,7 @@ function setUpFoundry(appPath, childProcessOptions = {}) {
'--plop',
'react',
'--lint-staged',
'--husky'
'--husky',
];
return spawn(cmd, args, { cwd: appPath, ...childProcessOptions });
}
Expand All @@ -174,9 +174,9 @@ function deleteCraFiles(appPath) {
'App.test.js',
'App.css',
'index.js',
'index.css'
'index.css',
];
const args = ['-rf', ...filesToDelete.map(file => `src/${file}`)];
const args = ['-rf', ...filesToDelete.map((file) => `src/${file}`)];
return spawn(cmd, args, { cwd: appPath });
}

Expand All @@ -187,12 +187,12 @@ function copyReactFiles(appPath, sourcePath = FILES_PATH) {
'App.spec.js',
'setupTests.js',
'index.js',
'assets'
'assets',
];
const args = [
'-r',
...filesToCopy.map(file => resolve(sourcePath, file)),
`${appPath}/src`
...filesToCopy.map((file) => resolve(sourcePath, file)),
`${appPath}/src`,
];
return spawn(cmd, args, { cwd: appPath });
}
Expand All @@ -202,14 +202,14 @@ async function updatePackageJson(appPath) {
const { default: packageJson } = await import(filepath);
const scripts = {
lint: "foundry run eslint 'src/**/*.js'",
'create-component': 'foundry run plop component'
'create-component': 'foundry run plop component',
};
const updatedPackageJson = {
...packageJson,
scripts: {
...packageJson.scripts,
...scripts
}
...scripts,
},
};

const fileContent = JSON.stringify(updatedPackageJson, null, 2);
Expand All @@ -225,7 +225,7 @@ async function updateInitialCommit(appPath) {
return spawn(
'git',
['commit', '--amend', '--no-verify', '-m', commitMsg],
options
options,
);
}

Expand All @@ -235,5 +235,5 @@ function handleErrors(err) {
logger.log('\n');
logger.log(err.log);
}
process.exit(1);
throw err;
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
"chalk": "^2.4.2",
"esm": "^3.2.25",
"listr": "^0.14.3",
"listr-verbose-renderer": "^0.5.0"
"listr-verbose-renderer": "^0.5.0",
"@sumup/foundry": "^2.2.0"
},
"devDependencies": {
"@sumup/foundry": "^2.0.0-beta",
"license-checker": "^25.0.1"
},
"husky": {
Expand Down
4 changes: 2 additions & 2 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2019, SumUp Ltd.
* Copyright 2020, SumUp Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand All @@ -13,4 +13,4 @@
* limitations under the License.
*/

module.exports = require('@sumup/foundry/prettier').base;
module.exports = require('@sumup/foundry/prettier')();
Loading

0 comments on commit 4e15db9

Please sign in to comment.