Skip to content

Commit 63a3a47

Browse files
lukeedsapegin
authored andcommitted
Fix: Change some dependencies to smaller alternatives (styleguidist#1248)
1 parent 8554a3d commit 63a3a47

File tree

21 files changed

+89
-42
lines changed

21 files changed

+89
-42
lines changed

docs/Development.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Each component folder usually has several files:
7676

7777
For styles we use [JSS](http://cssinjs.org/), it allows users to customize their style guide and allows us to ensure styles isolations (thanks to [jss-isolate](http://cssinjs.org/jss-isolate/)). No user styles should affect Styleguidist UI and no Styleguidist styles should affect user components.
7878

79-
Use [classnames](https://github.com/JedWatson/classnames) to merge several class names or for conditional class names, import it as `cx` (`import cx from 'classnames'`).
79+
Use [clsx](https://github.com/lukeed/clsx) to merge several class names or for conditional class names, import it as `cx` (`import cx from 'clsx'`).
8080

8181
We use `Styled` higher-order component to allow theming (see [theme](Configuration.md#theme) and [style](Configuration.md#style) style guide config options). Use it like this:
8282

flow-typed/qss.js.flow

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare module 'qss' {
2+
declare type Params = { [key: string]: any };
3+
declare function decode(query: string): Params;
4+
declare function encode(obj: Params, prefix?: string): string;
5+
}

flow-typed/querystringify.js.flow

Lines changed: 0 additions & 5 deletions
This file was deleted.

package-lock.json

Lines changed: 26 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
"acorn-jsx": "^5.0.1",
3333
"ast-types": "^0.11.7",
3434
"buble": "0.19.4",
35-
"classnames": "^2.2.6",
3635
"clean-webpack-plugin": "^1.0.0",
3736
"clipboard-copy": "^2.0.1",
37+
"clsx": "^1.0.1",
3838
"common-dir": "^2.0.2",
3939
"copy-webpack-plugin": "^4.6.0",
4040
"core-js": "^2.6.0",
@@ -56,20 +56,20 @@
5656
"jss-global": "^3.0.0",
5757
"jss-isolate": "^5.1.0",
5858
"jss-nested": "^6.0.1",
59-
"kleur": "^2.0.2",
59+
"kleur": "^3.0.1",
6060
"leven": "^2.1.0",
6161
"listify": "^1.0.0",
6262
"loader-utils": "^1.1.0",
6363
"lodash": "^4.17.11",
6464
"lowercase-keys": "^1.0.1",
6565
"markdown-to-jsx": "^6.9.0",
6666
"mini-html-webpack-plugin": "^0.2.3",
67-
"minimist": "^1.2.0",
67+
"mri": "^1.1.4",
6868
"ora": "^3.0.0",
6969
"prismjs": "^1.15.0",
7070
"prop-types": "^15.6.2",
7171
"q-i": "^2.0.1",
72-
"querystringify": "^2.1.0",
72+
"qss": "^2.0.0",
7373
"react-dev-utils": "^6.1.1",
7474
"react-docgen": "3.0.0-rc.2",
7575
"react-docgen-annotation-resolver": "^1.0.0",

src/bin/styleguidist.js

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22
/* eslint-disable no-console */
3-
const minimist = require('minimist');
3+
const mri = require('mri');
44
const kleur = require('kleur');
55
const ora = require('ora');
66
const stringify = require('q-i').stringify;
@@ -13,7 +13,7 @@ const setupLogger = require('../scripts/logger');
1313
const consts = require('../scripts/consts');
1414
const StyleguidistError = require('../scripts/utils/error');
1515

16-
const argv = minimist(process.argv.slice(2));
16+
const argv = mri(process.argv.slice(2));
1717
const command = argv._[0];
1818

1919
// Do not show nasty stack traces for Styleguidist errors
@@ -27,7 +27,11 @@ process.on('uncaughtException', err => {
2727
consts.DOCS_CONFIG
2828
);
2929
} else if (err instanceof StyleguidistError) {
30-
console.error(kleur.bold.red(err.message));
30+
console.error(
31+
kleur()
32+
.bold()
33+
.red(err.message)
34+
);
3135
logger.debug(err.stack);
3236
} else {
3337
console.error(err.toString());
@@ -219,7 +223,11 @@ function printBuildInstructions(config) {
219223
* @param {string} linkUrl
220224
*/
221225
function printErrorWithLink(message, linkTitle, linkUrl) {
222-
console.error(`${kleur.bold.red(message)}\n\n${linkTitle}\n${kleur.underline(linkUrl)}\n`);
226+
console.error(
227+
`${kleur()
228+
.bold()
229+
.red(message)}\n\n${linkTitle}\n${kleur.underline(linkUrl)}\n`
230+
);
223231
}
224232

225233
/**
@@ -243,11 +251,32 @@ function printErrors(header, errors, originalErrors, type) {
243251
*/
244252
function printStatus(text, type) {
245253
if (type === 'success') {
246-
console.log(kleur.inverse.bold.green(' DONE ') + ' ' + text);
254+
console.log(
255+
kleur
256+
.inverse()
257+
.bold()
258+
.green(' DONE ') +
259+
' ' +
260+
text
261+
);
247262
} else if (type === 'error') {
248-
console.error(kleur.inverse.bold.red(' FAIL ') + ' ' + kleur.red(text));
263+
console.error(
264+
kleur
265+
.inverse()
266+
.bold()
267+
.red(' FAIL ') +
268+
' ' +
269+
kleur.red(text)
270+
);
249271
} else {
250-
console.error(kleur.inverse.bold.yellow(' WARN ') + ' ' + kleur.yellow(text));
272+
console.error(
273+
kleur
274+
.inverse()
275+
.bold()
276+
.yellow(' WARN ') +
277+
' ' +
278+
kleur.yellow(text)
279+
);
251280
}
252281
}
253282

src/client/rsg-components/ComponentsList/ComponentsListRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import cx from 'classnames';
3+
import cx from 'clsx';
44
import Link from 'rsg-components/Link';
55
import Styled from 'rsg-components/Styled';
66
import { getHash } from '../../utils/handleHash';

src/client/rsg-components/Heading/HeadingRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import cx from 'classnames';
3+
import cx from 'clsx';
44
import Styled from 'rsg-components/Styled';
55

66
const styles = ({ color, fontFamily, fontSize }) => ({

src/client/rsg-components/Link/LinkRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import cx from 'classnames';
3+
import cx from 'clsx';
44
import Styled from 'rsg-components/Styled';
55

66
const styles = ({ color }) => ({

src/client/rsg-components/Markdown/Blockquote/BlockquoteRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import cx from 'classnames';
3+
import cx from 'clsx';
44

55
import Styled from 'rsg-components/Styled';
66

src/client/rsg-components/Markdown/List/ListRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Children, cloneElement } from 'react';
22
import PropTypes from 'prop-types';
3-
import cx from 'classnames';
3+
import cx from 'clsx';
44
import Styled from 'rsg-components/Styled';
55

66
const styles = ({ space, color, fontFamily }) => ({

src/client/rsg-components/Markdown/Pre/PreRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import cx from 'classnames';
3+
import cx from 'clsx';
44
import Styled from 'rsg-components/Styled';
55
import prismTheme from '../../../styles/prismTheme';
66

src/client/rsg-components/Name/NameRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import Styled from 'rsg-components/Styled';
4-
import cx from 'classnames';
4+
import cx from 'clsx';
55

66
export const styles = ({ fontFamily, fontSize, color }) => ({
77
name: {

src/client/rsg-components/Playground/PlaygroundRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import cx from 'classnames';
3+
import cx from 'clsx';
44
import Styled from 'rsg-components/Styled';
55

66
export const styles = ({ space, color, borderRadius }) => ({

src/client/rsg-components/SectionHeading/SectionHeadingRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import cx from 'classnames';
3+
import cx from 'clsx';
44
import Heading from 'rsg-components/Heading';
55
import Styled from 'rsg-components/Styled';
66

src/client/rsg-components/StyleGuide/StyleGuideRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
33
import Logo from 'rsg-components/Logo';
44
import Markdown from 'rsg-components/Markdown';
55
import Styled from 'rsg-components/Styled';
6-
import cx from 'classnames';
6+
import cx from 'clsx';
77
import Ribbon from 'rsg-components/Ribbon';
88
import Version from 'rsg-components/Version';
99

src/client/rsg-components/TabButton/TabButtonRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import Styled from 'rsg-components/Styled';
4-
import cx from 'classnames';
4+
import cx from 'clsx';
55

66
export const styles = ({ space, color, fontFamily, fontSize, buttonTextTransform }) => ({
77
button: {

src/client/rsg-components/Text/TextRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import Styled from 'rsg-components/Styled';
4-
import cx from 'classnames';
4+
import cx from 'clsx';
55

66
export const styles = ({ fontFamily, fontSize, color }) => ({
77
text: {

src/client/rsg-components/ToolbarButton/ToolbarButtonRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import Styled from 'rsg-components/Styled';
4-
import cx from 'classnames';
4+
import cx from 'clsx';
55

66
export const styles = ({ space, color }) => ({
77
button: {

src/loaders/__tests__/examples-loader.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import qs from 'querystringify';
1+
import { encode } from 'qss';
22
import examplesLoader from '../examples-loader';
33

44
/* eslint-disable no-new-func */
@@ -9,7 +9,7 @@ const query = {
99
shouldShowDefaultExample: false,
1010
};
1111

12-
const getQuery = (options = {}) => `?${qs.stringify({ ...query, ...options })}`;
12+
const getQuery = (options = {}) => encode({ ...query, ...options }, '?');
1313

1414
it('should return valid, parsable JS', () => {
1515
const exampleMarkdown = `

src/loaders/utils/getExamples.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @flow
22
import path from 'path';
3-
import qs from 'querystringify';
3+
import { encode } from 'qss';
44
import requireIt from './requireIt';
55

66
const examplesLoader = path.resolve(__dirname, '../examples-loader.js');
@@ -26,5 +26,5 @@ module.exports = function getExamples(
2626
file: relativePath,
2727
shouldShowDefaultExample: !examplesFile && !!defaultExample,
2828
};
29-
return requireIt(`!!${examplesLoader}?${qs.stringify(query)}!${examplesFileToLoad}`);
29+
return requireIt(`!!${examplesLoader}?${encode(query)}!${examplesFileToLoad}`);
3030
};

0 commit comments

Comments
 (0)