Skip to content
This repository was archived by the owner on Jan 19, 2022. It is now read-only.

Commit 529f6ed

Browse files
author
Michael Perrotte
committedFeb 27, 2020
feat: removed figgy-pudding as a dependency
BREAKING CHANGE
1 parent 57b0cb8 commit 529f6ed

File tree

3 files changed

+43
-43
lines changed

3 files changed

+43
-43
lines changed
 

‎index.js

+38-37
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,94 @@
11
'use strict'
22

33
const eu = encodeURIComponent
4-
const figgyPudding = require('figgy-pudding')
54
const getStream = require('get-stream')
65
const npmFetch = require('npm-registry-fetch')
76
const validate = require('aproba')
87

9-
const TeamConfig = figgyPudding({
10-
description: {},
11-
Promise: { default: () => Promise }
12-
})
13-
148
const cmd = module.exports = {}
159

16-
cmd.create = (entity, opts) => {
17-
opts = TeamConfig(opts)
10+
cmd.create = (entity, opts = { description: undefined }) => {
1811
return pwrap(opts, () => {
1912
const { scope, team } = splitEntity(entity)
2013
validate('SSO', [scope, team, opts])
21-
return npmFetch.json(`/-/org/${eu(scope)}/team`, opts.concat({
14+
const uri = `/-/org/${eu(scope)}/team`
15+
return npmFetch.json(uri, {
16+
...opts,
2217
method: 'PUT',
2318
scope,
2419
body: { name: team, description: opts.description }
25-
}))
20+
})
2621
})
2722
}
2823

29-
cmd.destroy = (entity, opts) => {
30-
opts = TeamConfig(opts)
24+
cmd.destroy = (entity, opts = {}) => {
3125
return pwrap(opts, () => {
3226
const { scope, team } = splitEntity(entity)
3327
validate('SSO', [scope, team, opts])
34-
return npmFetch.json(`/-/team/${eu(scope)}/${eu(team)}`, opts.concat({
28+
const uri = `/-/team/${eu(scope)}/${eu(team)}`
29+
return npmFetch.json(uri, {
30+
...opts,
3531
method: 'DELETE',
3632
scope
37-
}))
33+
})
3834
})
3935
}
4036

41-
cmd.add = (user, entity, opts) => {
42-
opts = TeamConfig(opts)
37+
cmd.add = (user, entity, opts = {}) => {
4338
return pwrap(opts, () => {
4439
const { scope, team } = splitEntity(entity)
4540
validate('SSO', [scope, team, opts])
46-
return npmFetch.json(`/-/team/${eu(scope)}/${eu(team)}/user`, opts.concat({
41+
const uri = `/-/team/${eu(scope)}/${eu(team)}/user`
42+
return npmFetch.json(uri, {
43+
...opts,
4744
method: 'PUT',
4845
scope,
4946
body: { user }
50-
}))
47+
})
5148
})
5249
}
5350

54-
cmd.rm = (user, entity, opts) => {
55-
opts = TeamConfig(opts)
51+
cmd.rm = (user, entity, opts = {}) => {
5652
return pwrap(opts, () => {
5753
const { scope, team } = splitEntity(entity)
5854
validate('SSO', [scope, team, opts])
59-
return npmFetch.json(`/-/team/${eu(scope)}/${eu(team)}/user`, opts.concat({
55+
const uri = `/-/team/${eu(scope)}/${eu(team)}/user`
56+
return npmFetch.json(uri, {
57+
...opts,
6058
method: 'DELETE',
6159
scope,
6260
body: { user }
63-
}))
61+
})
6462
})
6563
}
6664

67-
cmd.lsTeams = (scope, opts) => {
68-
opts = TeamConfig(opts)
69-
return pwrap(opts, () => getStream.array(cmd.lsTeams.stream(scope, opts)))
65+
cmd.lsTeams = (scope, opts = {}) => {
66+
return pwrap(opts, () => {
67+
return getStream.array(cmd.lsTeams.stream(scope, { ...opts }))
68+
})
7069
}
71-
cmd.lsTeams.stream = (scope, opts) => {
72-
opts = TeamConfig(opts)
70+
cmd.lsTeams.stream = (scope, opts = {}) => {
7371
validate('SO', [scope, opts])
74-
return npmFetch.json.stream(`/-/org/${eu(scope)}/team`, '.*', opts.concat({
72+
const uri = `/-/org/${eu(scope)}/team`
73+
return npmFetch.json.stream(uri, '.*', {
74+
...opts,
7575
query: { format: 'cli' }
76-
}))
76+
})
7777
}
7878

79-
cmd.lsUsers = (entity, opts) => {
80-
opts = TeamConfig(opts)
81-
return pwrap(opts, () => getStream.array(cmd.lsUsers.stream(entity, opts)))
79+
cmd.lsUsers = (entity, opts = {}) => {
80+
return pwrap(opts, () => {
81+
return getStream.array(cmd.lsUsers.stream(entity, { ...opts }))
82+
})
8283
}
83-
cmd.lsUsers.stream = (entity, opts) => {
84-
opts = TeamConfig(opts)
84+
cmd.lsUsers.stream = (entity, opts = {}) => {
8585
const { scope, team } = splitEntity(entity)
8686
validate('SSO', [scope, team, opts])
8787
const uri = `/-/team/${eu(scope)}/${eu(team)}/user`
88-
return npmFetch.json.stream(uri, '.*', opts.concat({
88+
return npmFetch.json.stream(uri, '.*', {
89+
...opts,
8990
query: { format: 'cli' }
90-
}))
91+
})
9192
}
9293

9394
cmd.edit = () => {
@@ -100,7 +101,7 @@ function splitEntity (entity = '') {
100101
}
101102

102103
function pwrap (opts, fn) {
103-
return new opts.Promise((resolve, reject) => {
104+
return new Promise((resolve, reject) => {
104105
fn().then(resolve, reject)
105106
})
106107
}

‎package.json

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"homepage": "https://npmjs.com/package/libnpmteam",
2626
"dependencies": {
2727
"aproba": "^2.0.0",
28-
"figgy-pudding": "^3.4.1",
2928
"get-stream": "^4.0.0",
3029
"npm-registry-fetch": "^4.0.0"
3130
},

‎test/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
'use strict'
22

3-
const figgyPudding = require('figgy-pudding')
43
const getStream = require('get-stream')
54
const { test } = require('tap')
65
const tnock = require('./fixtures/tnock.js')
76

87
const team = require('../index.js')
98

109
const REG = 'http://localhost:1337'
11-
const OPTS = figgyPudding({})({
10+
const OPTS = {
1211
registry: REG
13-
})
12+
}
1413

1514
test('create', t => {
1615
tnock(t, REG).put(
@@ -40,9 +39,10 @@ test('create w/ description', t => {
4039
name: 'cli',
4140
description: 'just some cool folx'
4241
}).reply(201, { name: 'cli' })
43-
return team.create('@foo:cli', OPTS.concat({
42+
return team.create('@foo:cli', {
43+
...OPTS,
4444
description: 'just some cool folx'
45-
})).then(ret => {
45+
}).then(ret => {
4646
t.deepEqual(ret, { name: 'cli' }, 'no desc in return')
4747
})
4848
})

0 commit comments

Comments
 (0)
This repository has been archived.