Skip to content

Commit e0d3edd

Browse files
wraithgarlukekarrys
authored andcommitted
fix: remove "ci-name" config
BREAKING CHANGE: the "ci-name" config has been removed The "ci" portion of the default "user-agent" will now only be derived from the environment and can not be manually overridden.
1 parent 0318f44 commit e0d3edd

File tree

3 files changed

+19
-43
lines changed

3 files changed

+19
-43
lines changed

workspaces/config/lib/definitions/definitions.js

+1-19
Original file line numberDiff line numberDiff line change
@@ -429,24 +429,6 @@ define('cert', {
429429
flatten,
430430
})
431431

432-
define('ci-name', {
433-
default: ciInfo.name ? ciInfo.name.toLowerCase().split(' ').join('-') : null,
434-
defaultDescription: `
435-
The name of the current CI system, or \`null\` when not on a known CI
436-
platform.
437-
`,
438-
type: [null, String],
439-
deprecated: `
440-
This config is deprecated and will not be changeable in future version of npm.
441-
`,
442-
description: `
443-
The name of a continuous integration system. If not set explicitly, npm
444-
will detect the current CI environment using the
445-
[\`ci-info\`](http://npm.im/ci-info) module.
446-
`,
447-
flatten,
448-
})
449-
450432
define('cidr', {
451433
default: null,
452434
type: [null, String, Array],
@@ -2204,7 +2186,7 @@ define('user-agent', {
22042186
`,
22052187
flatten (key, obj, flatOptions) {
22062188
const value = obj[key]
2207-
const ciName = obj['ci-name']
2189+
const ciName = ciInfo.name?.toLowerCase().split(' ').join('-') || null
22082190
let inWorkspaces = false
22092191
if (obj.workspaces || obj.workspace && obj.workspace.length) {
22102192
inWorkspaces = true

workspaces/config/tap-snapshots/test/type-description.js.test.cjs

-4
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ Object {
7979
null,
8080
Function String(),
8181
],
82-
"ci-name": Array [
83-
null,
84-
Function String(),
85-
],
8682
"cidr": Array [
8783
null,
8884
Function String(),

workspaces/config/test/definitions/definitions.js

+18-20
Original file line numberDiff line numberDiff line change
@@ -730,53 +730,51 @@ YYYY\r
730730
t.end()
731731
})
732732

733-
t.test('detect CI', t => {
734-
const defnNoCI = mockDefs({
735-
'ci-info': { isCI: false, name: null },
736-
})
737-
const defnCIFoo = mockDefs({
738-
'ci-info': { isCI: false, name: 'foo' },
739-
})
740-
t.equal(defnNoCI['ci-name'].default, null, 'null when not in CI')
741-
t.equal(defnCIFoo['ci-name'].default, 'foo', 'name of CI when in CI')
742-
t.end()
743-
})
744-
745733
t.test('user-agent', t => {
746734
const npmVersion = '1.2.3'
747735
const obj = {
748736
'npm-version': npmVersion,
749-
'user-agent': mockDefs()['user-agent'].default,
737+
'user-agent': mockDefs({
738+
'ci-info': { isCi: false, name: null },
739+
})['user-agent'].default,
750740
}
751741
const flat = {}
752742
const expectNoCI = `npm/${npmVersion} node/${process.version} ` +
753743
`${process.platform} ${process.arch} workspaces/false`
754-
mockDefs()['user-agent'].flatten('user-agent', obj, flat)
744+
mockDefs({
745+
'ci-info': { isCi: false, name: null },
746+
})['user-agent'].flatten('user-agent', obj, flat)
755747
t.equal(flat.userAgent, expectNoCI)
756748
t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set')
757749
t.not(obj['user-agent'], flat.userAgent, 'config user-agent template is not translated')
758750

759-
obj['ci-name'] = 'foo'
760-
obj['user-agent'] = mockDefs()['user-agent'].default
751+
obj['user-agent'] = mockDefs({
752+
'ci-info': { isCi: true, name: 'foo' },
753+
})['user-agent'].default
761754
const expectCI = `${expectNoCI} ci/foo`
762-
mockDefs()['user-agent'].flatten('user-agent', obj, flat)
755+
mockDefs({
756+
'ci-info': { isCi: true, name: 'foo' },
757+
})['user-agent'].flatten('user-agent', obj, flat)
763758
t.equal(flat.userAgent, expectCI)
764759
t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set')
765760
t.not(obj['user-agent'], flat.userAgent, 'config user-agent template is not translated')
766761

767-
delete obj['ci-name']
768762
obj.workspaces = true
769763
obj['user-agent'] = mockDefs()['user-agent'].default
770764
const expectWorkspaces = expectNoCI.replace('workspaces/false', 'workspaces/true')
771-
mockDefs()['user-agent'].flatten('user-agent', obj, flat)
765+
mockDefs({
766+
'ci-info': { isCi: false, name: null },
767+
})['user-agent'].flatten('user-agent', obj, flat)
772768
t.equal(flat.userAgent, expectWorkspaces)
773769
t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set')
774770
t.not(obj['user-agent'], flat.userAgent, 'config user-agent template is not translated')
775771

776772
delete obj.workspaces
777773
obj.workspace = ['foo']
778774
obj['user-agent'] = mockDefs()['user-agent'].default
779-
mockDefs()['user-agent'].flatten('user-agent', obj, flat)
775+
mockDefs({
776+
'ci-info': { isCi: false, name: null },
777+
})['user-agent'].flatten('user-agent', obj, flat)
780778
t.equal(flat.userAgent, expectWorkspaces)
781779
t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set')
782780
t.not(obj['user-agent'], flat.userAgent, 'config user-agent template is not translated')

0 commit comments

Comments
 (0)