Skip to content

Commit 451985c

Browse files
committed
Fixes and documentation for topcoder-lib-setup script
Fix for #15 and #12
1 parent 4369a3b commit 451985c

File tree

6 files changed

+88
-62
lines changed

6 files changed

+88
-62
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Topcoder React Utils Changelog
22

3+
### v0.4.3
4+
- Removes `adopt-dev-deps` script (use
5+
[`topcoder-lib-setup`](docs/topcoder-lib-setup-script.md) instead).
6+
37
### v0.4.2
48
Adds `topcoder-lib-setup` script, which should help to update our ReactJS
59
libraries in the host packages. Not mentioned in the docs as it still pending

README.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,34 @@ The [Topcoder](https://www.topcoder.com) collection of generic ReactJS
88
configurations, components and utilities to be shared between all internal and
99
external ReactJS projects developed by the Topcoder community.
1010

11-
### Content
11+
## Content
1212
- [Installation](#installation)
13-
- [Configurations](#configurations)
14-
- [Components](#components)
15-
- [Utilities](#utilities)
13+
- [Reference](#reference)
14+
- [Configurations](#configurations)
15+
- [Components](#components)
16+
- [NodeJS Scripts](#nodejs-scripts)
17+
- [Utilities](#utilities)
1618
- [Development](#development)
1719
- [License](#license)
1820

19-
### <a name="installation">Installation</a>
20-
Install this package as
21+
## Installation
22+
Install the package as
2123
```bash
2224
$ npm install --save topcoder-react-utils
25+
$ ./node_modules/.bin/topcoder-lib-setup
2326
```
24-
Import the global stylesheet into the root ReactJS component of your app:
27+
Then import the global stylesheet into the root ReactJS component of your app:
2528
```js
2629
import 'topcoder-react-utils/dist/style.css';
2730
```
2831

29-
You are done if you only use components and utilities provided by this
30-
package. If you are to use configurations to build or test your code, you
31-
also need to install all development dependencies into your own package:
32-
```
33-
$ ./node_modules/.bin/adopt-dev-deps topcoder-react-utils
32+
To upgrade this library to the latest version just execute again
33+
```bash
34+
$ ./node_modules/.bin/topcoder-lib-setup
3435
```
3536

36-
Installed dev dependencies will be stored into your `package.json`, thus
37-
further invokations of `npm install` will automatically install them. You
38-
only need to call `adopt-dev-deps` again if you update
39-
`topcoder-react-utils` to a newer version.
40-
41-
### <a name="configurations">Configurations</a>
37+
## Reference
38+
### Configurations
4239
- [**Babel Configurations**](docs/babel-config.md) &mdash; Standard
4340
configurations for [Babel](https://babeljs.io/);
4441
- [**ESLint Configurations**](docs/eslint-config.md) &mdash; Standard
@@ -50,7 +47,7 @@ only need to call `adopt-dev-deps` again if you update
5047
- [**Webpack Configurations**](docs/webpack-config.md) &mdash; Standard
5148
configurations for [Webpack](https://webpack.js.org/).
5249

53-
### <a name="components">Components</a>
50+
### Components
5451
- [**`Avatar`**](docs/avatar.md) &mdash; The standard component for user avatars;
5552
- [**`Button`**](docs/button.md) &mdash; Handles buttons and button-like links
5653
(components that look like regular buttons, but behave as links) in the same
@@ -62,7 +59,11 @@ only need to call `adopt-dev-deps` again if you update
6259
- [**`ScalableRect`**](docs/scalable-rect.md) &mdash; Container that keeps
6360
the specified aspect ratio regardless the width you set.
6461

65-
### <a name="utilities">Utilities</a>
62+
### NodeJS Scripts
63+
- [**topcoder-lib-setup**](docs/topcoder-lib-setup-script.md) &mdash; Helps to
64+
install and upgrade **topcoder-react-utils** and other similar libraries.
65+
66+
### Utilities
6667
- [**Client**](docs/client.md) &mdash; Client-side initialization code.
6768
- [**Config**](docs/config.md) &mdash; Isomorphic app config;
6869
- [**Global Styles**](docs/global-styles.md) &mdash; Global styles necessary for
@@ -81,7 +82,7 @@ only need to call `adopt-dev-deps` again if you update
8182
- [**Webpack**](docs/webpack-utils.md) &mdash; Various utils related to the
8283
Webpack bundling process.
8384

84-
### <a name="development">Development</a>
85+
## Development
8586
For convenient development you can link this package into your host package:
8687
1. Clone [`topcoder-react-utils`](https://github.com/topcoder-platform/topcoder-react-utils)
8788
to your machine, and checkout the branch you are going to work with;
@@ -118,5 +119,5 @@ any breaking changes into the codebase! Breaking changes should be done via
118119
`minor` or `major` update, and they should be documented in
119120
the [CHANGELOG](CHANGELOG.md).
120121

121-
### <a name="license">License</a>
122+
## License
122123
Topcoder React Utils is [MIT Licensed](LICENSE.md)

bin/adopt-dev-deps

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

bin/topcoder-lib-setup

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ const HELP = [{
4646
* into NPM's install command.
4747
*/
4848
function generateTargetPackage(entry) {
49-
if (entry[1].match(/^[^]/)) return `${entry[0]}@${entry[1].slice(1)}`;
49+
if (entry[1].match(/^https?:\/\//)) return entry[1];
50+
if (entry[1].match(/^[^~]/)) return `${entry[0]}@${entry[1].slice(1)}`;
5051
return `${entry[0]}@${entry[1]}`;
5152
}
5253

docs/topcoder-lib-setup-script.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# `topcoder-lib-setup` script
2+
3+
NodeJS script that helps to install and upgrade `topcoder-react-utils` and other
4+
similar NPM libraries maintained by Topcoder.
5+
6+
**Why?** &mdash; When library version is upgraded manually, it is difficult
7+
to ensure the same versions of common dependencies are used by the upgraded
8+
library and by its host codebase. In some situations the mismatch of exact
9+
versions leads to odd issues, difficult to track. This script solves this
10+
problem.
11+
12+
### Usage
13+
14+
From the host package's root directory call it as:
15+
```sh
16+
$ ./node_modules/.bin/topcoder-lib-setup [OPTION]... [LIBRARY]...
17+
```
18+
Where `[OPTIONS]...` is an optional, whitespace-separated list of options (see
19+
below); and `[LIBRARY]...` is an optional, whitespace-separated list of libraries
20+
to update. If no library names are given, `topcoder-react-utils` is assumed by
21+
default.
22+
23+
For each `library` specified in the `[LIBRARY]...` list, this script does the
24+
following:
25+
26+
- Installs the specified (if `library` contains `@x.y.z` semver suffix), or
27+
the latest (automatically appending `@latest` suffix to `library`) version
28+
of `library` as a regular dependency of the host code. Specifically, it does:
29+
```bash
30+
$ npm install --save library
31+
```
32+
33+
- Installs all dev dependencies of `library` into the host code as dev
34+
dependencies with exactly the same versions. Specifically, it generates
35+
a whitespace-separated list `devDeps` of dev dependencies, then executes
36+
```bash
37+
$ npm install --save-dev devDeps
38+
```
39+
40+
- Updates regular dependencies or the host package, that are also used by
41+
`library` to the same versions used by the library. Specifically, it generates
42+
a whitespace-separated list of dependencies, `deps`, which is an intersection
43+
of regular dependencies of `library` witht the set of regular dependencies of
44+
the host code; and the version of each dependency in the list is taken from
45+
the `library`'s `package.json`. Then it executes:
46+
```bash
47+
$ npm install --save deps
48+
```
49+
50+
Once the steps described above are completed for each library, the script
51+
executes `$ npm install` to ensure that any packages removed temporarily
52+
during those steps are installed back.
53+
54+
### Options
55+
| Option | Alias | Description |
56+
| --- | --- | --- |
57+
| `--help` | `-h` | Prints to standard output the basic usage instructions.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"bin": {
3-
"adopt-dev-deps": "./bin/adopt-dev-deps",
43
"topcoder-lib-setup": "./bin/topcoder-lib-setup"
54
},
65
"bugs": {
@@ -9,6 +8,8 @@
98
"dependencies": {
109
"babel-runtime": "^6.26.0",
1110
"body-parser": "^1.18.3",
11+
"command-line-args": "^5.0.2",
12+
"command-line-usage": "^5.0.5",
1213
"compression": "^1.7.2",
1314
"config": "^1.30.0",
1415
"cookie-parser": "^1.4.3",
@@ -56,8 +57,6 @@
5657
"babel-preset-env": "^1.7.0",
5758
"babel-preset-react": "^6.24.1",
5859
"babel-preset-stage-2": "^6.24.1",
59-
"command-line-args": "^5.0.2",
60-
"command-line-usage": "^5.0.5",
6160
"css-loader": "^0.28.11",
6261
"eslint": "^4.19.1",
6362
"eslint-config-airbnb": "^16.1.0",

0 commit comments

Comments
 (0)