Skip to content

Commit 525654e

Browse files
wraithgarlukekarrys
authored andcommitted
feat: default access to public
BREAKING CHANGE: The default value of `access` is now `public`
1 parent bc21552 commit 525654e

File tree

3 files changed

+65
-6
lines changed

3 files changed

+65
-6
lines changed

workspaces/libnpmpublish/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ A couple of options of note:
4444
defaults to `latest`.
4545

4646
* `opts.access` - tells the registry whether this package should be
47-
published as public or restricted. Only applies to scoped packages, which
48-
default to restricted.
47+
published as `public` or `restricted`. Only applies to scoped
48+
packages. Defaults to `public`.
4949

5050
* `opts.token` - can be passed in and will be used as the authentication
5151
token for the registry. For other ways to pass in auth details, see the

workspaces/libnpmpublish/lib/publish.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ Remove the 'private' field from the package.json to publish it.`),
1717
// spec is used to pick the appropriate registry/auth combo
1818
const spec = npa.resolve(manifest.name, manifest.version)
1919
opts = {
20-
defaultTag: 'latest',
21-
// if scoped, restricted by default
22-
access: spec.scope ? 'restricted' : 'public',
20+
access: 'public',
2321
algorithms: ['sha512'],
22+
defaultTag: 'latest',
2423
...opts,
2524
spec,
2625
}

workspaces/libnpmpublish/test/publish.js

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,66 @@ t.test('basic publish', async t => {
7979
t.ok(ret, 'publish succeeded')
8080
})
8181

82-
t.test('scoped publish', async t => {
82+
t.test('scoped publish - default access', async t => {
83+
const manifest = {
84+
name: '@claudiahdz/libnpmpublish',
85+
version: '1.0.0',
86+
description: 'some stuff',
87+
}
88+
89+
const tarData = await pack(`file:${testDir}`, { ...OPTS })
90+
const shasum = crypto.createHash('sha1').update(tarData).digest('hex')
91+
const integrity = ssri.fromData(tarData, { algorithms: ['sha512'] })
92+
const packument = {
93+
_id: '@claudiahdz/libnpmpublish',
94+
name: '@claudiahdz/libnpmpublish',
95+
description: 'some stuff',
96+
'dist-tags': {
97+
latest: '1.0.0',
98+
},
99+
versions: {
100+
'1.0.0': {
101+
_id: '@claudiahdz/libnpmpublish@1.0.0',
102+
_nodeVersion: process.versions.node,
103+
_npmVersion: '6.13.7',
104+
name: '@claudiahdz/libnpmpublish',
105+
version: '1.0.0',
106+
description: 'some stuff',
107+
dist: {
108+
shasum,
109+
integrity: integrity.toString(),
110+
tarball: 'http://mock.reg/@claudiahdz/libnpmpublish/'
111+
+ '-/@claudiahdz/libnpmpublish-1.0.0.tgz',
112+
},
113+
},
114+
},
115+
access: 'public',
116+
_attachments: {
117+
'@claudiahdz/libnpmpublish-1.0.0.tgz': {
118+
content_type: 'application/octet-stream',
119+
data: tarData.toString('base64'),
120+
length: tarData.length,
121+
},
122+
},
123+
}
124+
125+
const srv = tnock(t, REG)
126+
srv.put('/@claudiahdz%2flibnpmpublish', body => {
127+
t.same(body, packument, 'posted packument matches expectations')
128+
return true
129+
}, {
130+
authorization: 'Bearer deadbeef',
131+
}).reply(201, {})
132+
133+
const ret = await publish(manifest, tarData, {
134+
...OPTS,
135+
npmVersion: '6.13.7',
136+
token: 'deadbeef',
137+
})
138+
t.ok(ret, 'publish succeeded')
139+
})
140+
141+
t.test('scoped publish - restricted access', async t => {
83142
const manifest = {
84143
name: '@claudiahdz/libnpmpublish',
85144
version: '1.0.0',
@@ -132,6 +191,7 @@ t.test('scoped publish', async t => {
132191

133192
const ret = await publish(manifest, tarData, {
134193
...OPTS,
194+
access: 'restricted',
135195
npmVersion: '6.13.7',
136196
token: 'deadbeef',
137197
})

0 commit comments

Comments
 (0)