diff --git a/workspaces/config/lib/definitions/definitions.js b/workspaces/config/lib/definitions/definitions.js index 6eb845c7e4bae..7f0edc7167a42 100644 --- a/workspaces/config/lib/definitions/definitions.js +++ b/workspaces/config/lib/definitions/definitions.js @@ -429,24 +429,6 @@ define('cert', { flatten, }) -define('ci-name', { - default: ciInfo.name ? ciInfo.name.toLowerCase().split(' ').join('-') : null, - defaultDescription: ` - The name of the current CI system, or \`null\` when not on a known CI - platform. - `, - type: [null, String], - deprecated: ` - This config is deprecated and will not be changeable in future version of npm. - `, - description: ` - The name of a continuous integration system. If not set explicitly, npm - will detect the current CI environment using the - [\`ci-info\`](http://npm.im/ci-info) module. - `, - flatten, -}) - define('cidr', { default: null, type: [null, String, Array], @@ -2204,7 +2186,7 @@ define('user-agent', { `, flatten (key, obj, flatOptions) { const value = obj[key] - const ciName = obj['ci-name'] + const ciName = ciInfo.name?.toLowerCase().split(' ').join('-') || null let inWorkspaces = false if (obj.workspaces || obj.workspace && obj.workspace.length) { inWorkspaces = true diff --git a/workspaces/config/tap-snapshots/test/type-description.js.test.cjs b/workspaces/config/tap-snapshots/test/type-description.js.test.cjs index 4ef28584bf993..8c93f851f94b5 100644 --- a/workspaces/config/tap-snapshots/test/type-description.js.test.cjs +++ b/workspaces/config/tap-snapshots/test/type-description.js.test.cjs @@ -79,10 +79,6 @@ Object { null, Function String(), ], - "ci-name": Array [ - null, - Function String(), - ], "cidr": Array [ null, Function String(), diff --git a/workspaces/config/test/definitions/definitions.js b/workspaces/config/test/definitions/definitions.js index 2c608870b51f1..a832f7da0b6cb 100644 --- a/workspaces/config/test/definitions/definitions.js +++ b/workspaces/config/test/definitions/definitions.js @@ -730,45 +730,41 @@ YYYY\r t.end() }) -t.test('detect CI', t => { - const defnNoCI = mockDefs({ - 'ci-info': { isCI: false, name: null }, - }) - const defnCIFoo = mockDefs({ - 'ci-info': { isCI: false, name: 'foo' }, - }) - t.equal(defnNoCI['ci-name'].default, null, 'null when not in CI') - t.equal(defnCIFoo['ci-name'].default, 'foo', 'name of CI when in CI') - t.end() -}) - t.test('user-agent', t => { const npmVersion = '1.2.3' const obj = { 'npm-version': npmVersion, - 'user-agent': mockDefs()['user-agent'].default, + 'user-agent': mockDefs({ + 'ci-info': { isCi: false, name: null }, + })['user-agent'].default, } const flat = {} const expectNoCI = `npm/${npmVersion} node/${process.version} ` + `${process.platform} ${process.arch} workspaces/false` - mockDefs()['user-agent'].flatten('user-agent', obj, flat) + mockDefs({ + 'ci-info': { isCi: false, name: null }, + })['user-agent'].flatten('user-agent', obj, flat) t.equal(flat.userAgent, expectNoCI) t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set') t.not(obj['user-agent'], flat.userAgent, 'config user-agent template is not translated') - obj['ci-name'] = 'foo' - obj['user-agent'] = mockDefs()['user-agent'].default + obj['user-agent'] = mockDefs({ + 'ci-info': { isCi: true, name: 'foo' }, + })['user-agent'].default const expectCI = `${expectNoCI} ci/foo` - mockDefs()['user-agent'].flatten('user-agent', obj, flat) + mockDefs({ + 'ci-info': { isCi: true, name: 'foo' }, + })['user-agent'].flatten('user-agent', obj, flat) t.equal(flat.userAgent, expectCI) t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set') t.not(obj['user-agent'], flat.userAgent, 'config user-agent template is not translated') - delete obj['ci-name'] obj.workspaces = true obj['user-agent'] = mockDefs()['user-agent'].default const expectWorkspaces = expectNoCI.replace('workspaces/false', 'workspaces/true') - mockDefs()['user-agent'].flatten('user-agent', obj, flat) + mockDefs({ + 'ci-info': { isCi: false, name: null }, + })['user-agent'].flatten('user-agent', obj, flat) t.equal(flat.userAgent, expectWorkspaces) t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set') t.not(obj['user-agent'], flat.userAgent, 'config user-agent template is not translated') @@ -776,7 +772,9 @@ t.test('user-agent', t => { delete obj.workspaces obj.workspace = ['foo'] obj['user-agent'] = mockDefs()['user-agent'].default - mockDefs()['user-agent'].flatten('user-agent', obj, flat) + mockDefs({ + 'ci-info': { isCi: false, name: null }, + })['user-agent'].flatten('user-agent', obj, flat) t.equal(flat.userAgent, expectWorkspaces) t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set') t.not(obj['user-agent'], flat.userAgent, 'config user-agent template is not translated')