A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/npm/cli/commit/879303cd7c529a04d855f47d14dce433118ac626 below:

warn on invalid publishConfig (#8078) · npm/cli@879303c · GitHub

File tree Expand file treeCollapse file tree 9 files changed

+47

-9

lines changed

Filter options

Expand file treeCollapse file tree 9 files changed

+47

-9

lines changed Original file line number Diff line number Diff line change

@@ -366,6 +366,9 @@ ${defData}

366 366

const { content } = await pkgJson.normalize(this.npm.prefix).catch(() => ({ content: {} }))

367 367 368 368

if (content.publishConfig) {

369 +

for (const key in content.publishConfig) {

370 +

this.npm.config.checkUnknown('publishConfig', key)

371 +

}

369 372

const pkgPath = resolve(this.npm.prefix, 'package.json')

370 373

msg.push(`; "publishConfig" from ${pkgPath}`)

371 374

msg.push('; This set of config values will be used at publish-time.', '')

Original file line number Diff line number Diff line change

@@ -266,6 +266,11 @@ class Publish extends BaseCommand {

266 266

// corresponding `publishConfig` settings

267 267

const filteredPublishConfig = Object.fromEntries(

268 268

Object.entries(manifest.publishConfig).filter(([key]) => !(key in cliFlags)))

269 +

if (logWarnings) {

270 +

for (const key in filteredPublishConfig) {

271 +

this.npm.config.checkUnknown('publishConfig', key)

272 +

}

273 +

}

269 274

flatten(filteredPublishConfig, opts)

270 275

}

271 276

return manifest

Original file line number Diff line number Diff line change

@@ -145,6 +145,9 @@ class Unpublish extends BaseCommand {

145 145

// corresponding `publishConfig` settings

146 146

const filteredPublishConfig = Object.fromEntries(

147 147

Object.entries(manifest.publishConfig).filter(([key]) => !(key in cliFlags)))

148 +

for (const key in filteredPublishConfig) {

149 +

this.npm.config.checkUnknown('publishConfig', key)

150 +

}

148 151

flatten(filteredPublishConfig, opts)

149 152

}

150 153 Original file line number Diff line number Diff line change

@@ -413,6 +413,13 @@ color = {COLOR}

413 413

; "publishConfig" from {CWD}/prefix/package.json

414 414

; This set of config values will be used at publish-time.

415 415 416 -

_authToken = (protected)

416 +

//some.registry:_authToken = (protected)

417 +

other = "not defined"

417 418

registry = "https://some.registry"

418 419

`

420 + 421 +

exports[`test/lib/commands/config.js TAP config list with publishConfig local > warns about unknown config 1`] = `

422 +

Array [

423 +

"Unknown publishConfig config /"other/". This will stop working in the next major version of npm.",

424 +

]

425 +

`

Original file line number Diff line number Diff line change

@@ -290,6 +290,15 @@ exports[`test/lib/commands/publish.js TAP re-loads publishConfig.registry if add

290 290 291 291

exports[`test/lib/commands/publish.js TAP respects publishConfig.registry, runs appropriate scripts > new package version 1`] = `

292 292 293 +

> @npmcli/test-package@1.0.0 prepublishOnly

294 +

> touch scripts-prepublishonly

295 + 296 +

> @npmcli/test-package@1.0.0 publish

297 +

> touch scripts-publish

298 + 299 +

> @npmcli/test-package@1.0.0 postpublish

300 +

> touch scripts-postpublish

301 +

+ @npmcli/test-package@1.0.0

293 302

`

294 303 295 304

exports[`test/lib/commands/publish.js TAP restricted access > must match snapshot 1`] = `

Original file line number Diff line number Diff line change

@@ -164,16 +164,17 @@ t.test('config list with publishConfig', async t => {

164 164

prefixDir: {

165 165

'package.json': JSON.stringify({

166 166

publishConfig: {

167 +

other: 'not defined',

167 168

registry: 'https://some.registry',

168 -

_authToken: 'mytoken',

169 +

'//some.registry:_authToken': 'mytoken',

169 170

},

170 171

}),

171 172

},

172 173

...opts,

173 174

})

174 175 175 176

t.test('local', async t => {

176 -

const { npm, joinedOutput } = await loadMockNpmWithPublishConfig(t)

177 +

const { npm, logs, joinedOutput } = await loadMockNpmWithPublishConfig(t)

177 178 178 179

await npm.exec('config', ['list'])

179 180

@@ -182,6 +183,7 @@ t.test('config list with publishConfig', async t => {

182 183

t.match(output, 'registry = "https://some.registry"')

183 184 184 185

t.matchSnapshot(output, 'output matches snapshot')

186 +

t.matchSnapshot(logs.warn, 'warns about unknown config')

185 187

})

186 188 187 189

t.test('global', async t => {

Original file line number Diff line number Diff line change

@@ -29,11 +29,14 @@ t.test('respects publishConfig.registry, runs appropriate scripts', async t => {

29 29

publish: 'touch scripts-publish',

30 30

postpublish: 'touch scripts-postpublish',

31 31

},

32 -

publishConfig: { registry: alternateRegistry },

32 +

publishConfig: {

33 +

other: 'not defined',

34 +

registry: alternateRegistry,

35 +

},

33 36

}

34 -

const { npm, joinedOutput, prefix, registry } = await loadNpmWithRegistry(t, {

37 +

const { npm, joinedOutput, logs, prefix, registry } = await loadNpmWithRegistry(t, {

35 38

config: {

36 -

loglevel: 'silent',

39 +

loglevel: 'warn',

37 40

[`${alternateRegistry.slice(6)}/:_authToken`]: 'test-other-token',

38 41

},

39 42

prefixDir: {

@@ -49,6 +52,7 @@ t.test('respects publishConfig.registry, runs appropriate scripts', async t => {

49 52

t.equal(fs.existsSync(path.join(prefix, 'scripts-prepublish')), false, 'did not run prepublish')

50 53

t.equal(fs.existsSync(path.join(prefix, 'scripts-publish')), true, 'ran publish')

51 54

t.equal(fs.existsSync(path.join(prefix, 'scripts-postpublish')), true, 'ran postpublish')

55 +

t.same(logs.warn, ['Unknown publishConfig config "other". This will stop working in the next major version of npm.'])

52 56

})

53 57 54 58

t.test('re-loads publishConfig.registry if added during script process', async t => {

Original file line number Diff line number Diff line change

@@ -380,7 +380,7 @@ t.test('dryRun with no args', async t => {

380 380 381 381

t.test('publishConfig no spec', async t => {

382 382

const alternateRegistry = 'https://other.registry.npmjs.org'

383 -

const { joinedOutput, npm } = await loadMockNpm(t, {

383 +

const { logs, joinedOutput, npm } = await loadMockNpm(t, {

384 384

config: {

385 385

force: true,

386 386

'//other.registry.npmjs.org/:_authToken': 'test-other-token',

@@ -390,6 +390,7 @@ t.test('publishConfig no spec', async t => {

390 390

name: pkg,

391 391

version: '1.0.0',

392 392

publishConfig: {

393 +

other: 'not defined',

393 394

registry: alternateRegistry,

394 395

},

395 396

}, null, 2),

@@ -406,6 +407,10 @@ t.test('publishConfig no spec', async t => {

406 407

registry.unpublish({ manifest })

407 408

await npm.exec('unpublish', [])

408 409

t.equal(joinedOutput(), '- test-package')

410 +

t.same(logs.warn, [

411 +

'using --force Recommended protections disabled.',

412 +

'Unknown publishConfig config "other". This will stop working in the next major version of npm.',

413 +

])

409 414

})

410 415 411 416

t.test('prioritize CLI flags over publishConfig no spec', async t => {

Original file line number Diff line number Diff line change

@@ -584,14 +584,14 @@ class Config {

584 584

}

585 585

// Some defaults like npm-version are not user-definable and thus don't have definitions

586 586

if (where !== 'default') {

587 -

this.#checkUnknown(where, key)

587 +

this.checkUnknown(where, key)

588 588

}

589 589

conf.data[k] = v

590 590

}

591 591

}

592 592

}

593 593 594 -

#checkUnknown (where, key) {

594 +

checkUnknown (where, key) {

595 595

if (!this.definitions[key]) {

596 596

if (internalEnv.includes(key)) {

597 597

return

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4