Skip to content

Commit 6649708

Browse files
committed
Split library & cli (yarn workspaces) 🎉
1 parent ab034a6 commit 6649708

17 files changed

Lines changed: 193 additions & 125 deletions

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module.exports = {
2+
root: true,
23
extends: 'semistandard',
34
rules: {
45
'prefer-const': 'error',

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
node_modules
22
lib
3+
*.log
34
.tmp_*~
45
*#
56
.#*

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
language: node_js
22

33
script:
4-
- yarn run lint
5-
- yarn test
4+
- yarn workspaces run lint
5+
- yarn workspaces run test
66

77
node_js:
88
- 8
File renamed without changes.

Readme.md renamed to README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Based on gravatar specs - <https://en.gravatar.com/site/implement/hash/> and <ht
99

1010
### Runtime
1111

12-
- Node `>= 0.8`
12+
- Node `>=8`
1313

1414
### Development/Tests
1515

@@ -107,7 +107,7 @@ const profile2 = gravatar.profileUrl(email, {
107107
`gravatar` includes a simple command line interface. To use it, install globally:
108108

109109
```sh
110-
npm i -g gravatar
110+
npm i -g gravatar-cli
111111

112112
gravatar -h
113113
gravatar somebody@example.com
@@ -117,13 +117,12 @@ gravatar avatar somebody@example.com
117117

118118
gravatar profile -h
119119
gravatar profile somebody@example.com
120-
121120
```
122121

123122
## Running tests
124123

125124
```sh
126-
$ npm test
125+
$ yarn workspaces run test
127126
```
128127

129128
## To-Do

package.json

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,25 @@
11
{
2+
"private": true,
23
"name": "gravatar",
3-
"description": "Gravatar Node.js library",
4-
"keywords": [
5-
"gravatar",
6-
"avatar"
7-
],
8-
"version": "1.8.0",
9-
"author": "Emerson Macedo <emerleite@gmail.com>",
10-
"repository": {
11-
"type": "git",
12-
"url": "git://github.com/emerleite/node-gravatar.git"
13-
},
14-
"homepage": "https://github.com/emerleite/node-gravatar",
15-
"files": [
16-
"lib"
17-
],
18-
"dependencies": {
19-
"normalize-url": "^4.3.0",
20-
"yargs": "^13.2.4"
21-
},
4+
"dependencies": {},
225
"devDependencies": {
236
"@babel/core": "^7.4.5",
247
"@babel/plugin-proposal-object-rest-spread": "^7.4.4",
258
"@babel/preset-env": "^7.4.5",
26-
"email-validator": "^2.0.4",
279
"eslint": "^5.16.0",
2810
"eslint-config-semistandard": "^13.0.0",
2911
"eslint-config-standard": "^12.0.0",
3012
"eslint-plugin-import": "^2.17.3",
3113
"eslint-plugin-node": "^9.1.0",
3214
"eslint-plugin-promise": "^4.1.1",
3315
"eslint-plugin-standard": "^4.0.0",
34-
"mocha": "6.1.4",
35-
"nixt": "^0.5.1",
3616
"rollup": "^1.15.2",
3717
"rollup-plugin-babel": "^4.3.2",
3818
"rollup-plugin-commonjs": "^10.0.0",
39-
"rollup-plugin-node-resolve": "^5.0.1",
40-
"should": "13.2.3"
41-
},
42-
"main": "lib/gravatar.js",
43-
"module": "lib/gravatar.esm.js",
44-
"scripts": {
45-
"lint": "eslint .",
46-
"build": "rollup -c rollup.config.js",
47-
"pretest": "yarn run build",
48-
"test": "mocha -R spec"
49-
},
50-
"license": "MIT",
51-
"engines": {
52-
"node": ">=0.8.0"
19+
"rollup-plugin-node-resolve": "^5.0.1"
5320
},
54-
"bin": {
55-
"gravatar": "cli.js"
56-
}
21+
"workspaces": [
22+
"packages/gravatar",
23+
"packages/gravatar-cli"
24+
]
5725
}

packages/gravatar-cli/LICENSE.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# License
2+
3+
(The MIT License)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
"Software"), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

cli.js renamed to packages/gravatar-cli/cli.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
'use strict';
44

5-
const gravatar = require('./lib/gravatar');
65
const emailValidator = require('email-validator');
6+
const gravatar = require('gravatar');
77
const pkg = require('./package.json');
88

99
const options = {
@@ -24,13 +24,13 @@ const options = {
2424
};
2525

2626
const profileOptions = {
27-
format: {
28-
alias: 'f',
27+
f: {
28+
alias: 'format',
2929
describe: 'format of the requested profile url',
3030
choices: ['json', 'xml', 'qr', 'php', 'vcf']
3131
},
32-
callback: {
33-
alias: 'c',
32+
c: {
33+
alias: 'callback',
3434
describe: 'name of a callback function when using json profile url eg. doSomething'
3535
}
3636
};
@@ -40,7 +40,10 @@ const footer = `Useful Links:
4040
- https://en.gravatar.com/site/implement/profiles/
4141
- ${pkg.homepage}`;
4242

43-
const getOptions = argv => pick(argv, [...Object.keys(options), ...Object.keys(profileOptions)]);
43+
const getOptions = argv => pick(argv, [
44+
...Object.values(options).map(({ alias }) => alias),
45+
...Object.values(profileOptions).map(({ alias }) => alias)
46+
]);
4447

4548
const setUsage = function (yargs) {
4649
return yargs

packages/gravatar-cli/package.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "gravatar-cli",
3+
"description": "Gravatar Node.js CLI",
4+
"keywords": [
5+
"gravatar",
6+
"avatar",
7+
"cli"
8+
],
9+
"version": "1.8.0",
10+
"author": "Emerson Macedo <emerleite@gmail.com>",
11+
"repository": {
12+
"type": "git",
13+
"url": "git://github.com/emerleite/node-gravatar.git"
14+
},
15+
"homepage": "https://github.com/emerleite/node-gravatar",
16+
"files": [
17+
"cli.js"
18+
],
19+
"dependencies": {
20+
"gravatar": "^1.8.0"
21+
},
22+
"devDependencies": {
23+
"email-validator": "^2.0.4",
24+
"eslint": "^5.16.0",
25+
"mocha": "6.1.4",
26+
"nixt": "^0.5.1",
27+
"should": "13.2.3"
28+
},
29+
"scripts": {
30+
"lint": "eslint .",
31+
"test": "mocha -R spec"
32+
},
33+
"license": "MIT",
34+
"engines": {
35+
"node": ">=8"
36+
},
37+
"bin": {
38+
"gravatar": "cli.js"
39+
}
40+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'use strict';
2+
3+
/* eslint-env mocha */
4+
5+
require('should');
6+
const nixt = require('nixt');
7+
8+
describe('gravatar CLI', function () {
9+
describe('general: ', function () {
10+
it('accepts an email argument with options and writes gravatar URL to STDOUT', function (done) {
11+
nixt()
12+
.run('./cli.js zeke@sikelianos.com -p https -s 500 -d retro')
13+
.stdout('Gravatar (avatar):\nhttps://gravatar.com/avatar/8f344b1c4bdcfc28bd848e97e94c3523?size=500&default=retro')
14+
.end(done);
15+
});
16+
it('outputs usage if -h arg is present', function (done) {
17+
nixt()
18+
.run('./cli.js -h')
19+
.stdout(/Usage/)
20+
.end(done);
21+
});
22+
});
23+
24+
describe('avatar command: ', function () {
25+
it('accepts an email argument with options and writes gravatar URL to STDOUT', function (done) {
26+
nixt()
27+
.run('./cli.js avatar zeke@sikelianos.com -p https -s 500 -d retro')
28+
.stdout('Gravatar (avatar):\nhttps://gravatar.com/avatar/8f344b1c4bdcfc28bd848e97e94c3523?size=500&default=retro')
29+
.end(done);
30+
});
31+
});
32+
33+
describe('profile command: ', function () {
34+
it('accepts an email argument with options and writes gravatar profile URL to STDOUT', function (done) {
35+
nixt()
36+
.run('./cli.js profile zeke@sikelianos.com -p https -c doSomething')
37+
.stdout('Gravatar (profile):\nhttps://gravatar.com/8f344b1c4bdcfc28bd848e97e94c3523.json?callback=doSomething')
38+
.end(done);
39+
});
40+
});
41+
});

0 commit comments

Comments
 (0)