Skip to content

Commit a351685

Browse files
authored
deps: move from @npmcli/ci-detect to ci-info (#5858)
See watson/ci-info#95 for more context on achieving parity between these two modules. This changes npm to use `ci-info` instead of `@npmcli/ci-detect`. Everything that npm currently flags as a CI environment should still be doing so, so there is no breaking change there. There is going to be a subtle difference in the `ci-name` config, which nothing in npm currently looks at anyways, as well as the ci name that shows up in the default `user-agent` string. Some providers will be slightly different (i.e. circle-ci vs circleci and cirrus vs cirrus-ci)
1 parent 3f13818 commit a351685

24 files changed

+515
-167
lines changed

DEPENDENCIES.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ graph LR;
3232
libnpmexec-->minify-registry-metadata;
3333
libnpmexec-->npm-package-arg;
3434
libnpmexec-->npmcli-arborist["@npmcli/arborist"];
35-
libnpmexec-->npmcli-ci-detect["@npmcli/ci-detect"];
3635
libnpmexec-->npmcli-eslint-config["@npmcli/eslint-config"];
3736
libnpmexec-->npmcli-run-script["@npmcli/run-script"];
3837
libnpmexec-->npmcli-template-oss["@npmcli/template-oss"];
@@ -113,7 +112,6 @@ graph LR;
113112
npm-->npm-registry-fetch;
114113
npm-->npm-user-validate;
115114
npm-->npmcli-arborist["@npmcli/arborist"];
116-
npm-->npmcli-ci-detect["@npmcli/ci-detect"];
117115
npm-->npmcli-config["@npmcli/config"];
118116
npm-->npmcli-docs["@npmcli/docs"];
119117
npm-->npmcli-eslint-config["@npmcli/eslint-config"];
@@ -353,11 +351,11 @@ graph LR;
353351
libnpmdiff-->tar;
354352
libnpmexec-->bin-links;
355353
libnpmexec-->chalk;
354+
libnpmexec-->ci-info;
356355
libnpmexec-->minify-registry-metadata;
357356
libnpmexec-->mkdirp;
358357
libnpmexec-->npm-package-arg;
359358
libnpmexec-->npmcli-arborist["@npmcli/arborist"];
360-
libnpmexec-->npmcli-ci-detect["@npmcli/ci-detect"];
361359
libnpmexec-->npmcli-eslint-config["@npmcli/eslint-config"];
362360
libnpmexec-->npmcli-run-script["@npmcli/run-script"];
363361
libnpmexec-->npmcli-template-oss["@npmcli/template-oss"];
@@ -476,6 +474,7 @@ graph LR;
476474
npm-->archy;
477475
npm-->cacache;
478476
npm-->chalk;
477+
npm-->ci-info;
479478
npm-->cli-columns;
480479
npm-->cli-table3;
481480
npm-->columnify;
@@ -519,7 +518,6 @@ graph LR;
519518
npm-->npm-registry-fetch;
520519
npm-->npm-user-validate;
521520
npm-->npmcli-arborist["@npmcli/arborist"];
522-
npm-->npmcli-ci-detect["@npmcli/ci-detect"];
523521
npm-->npmcli-config["@npmcli/config"];
524522
npm-->npmcli-docs["@npmcli/docs"];
525523
npm-->npmcli-eslint-config["@npmcli/eslint-config"];
@@ -783,4 +781,4 @@ packages higher up the chain.
783781
- @npmcli/git, make-fetch-happen, @npmcli/config, init-package-json
784782
- @npmcli/installed-package-contents, @npmcli/map-workspaces, cacache, npm-pick-manifest, @npmcli/run-script, read-package-json, promzard
785783
- @npmcli/docs, @npmcli/fs, npm-bundled, read-package-json-fast, unique-filename, npm-install-checks, npm-package-arg, npm-packlist, normalize-package-data, @npmcli/package-json, bin-links, nopt, npmlog, parse-conflict-json, read
786-
- @npmcli/eslint-config, @npmcli/template-oss, ignore-walk, semver, npm-normalize-package-bin, @npmcli/name-from-folder, json-parse-even-better-errors, fs-minipass, ssri, unique-slug, @npmcli/promise-spawn, hosted-git-info, proc-log, validate-npm-package-name, @npmcli/node-gyp, minipass-fetch, @npmcli/query, cmd-shim, read-cmd-shim, write-file-atomic, abbrev, are-we-there-yet, gauge, treeverse, minify-registry-metadata, ini, @npmcli/disparity-colors, @npmcli/ci-detect, mute-stream, npm-audit-report, npm-user-validate
784+
- @npmcli/eslint-config, @npmcli/template-oss, ignore-walk, semver, npm-normalize-package-bin, @npmcli/name-from-folder, json-parse-even-better-errors, fs-minipass, ssri, unique-slug, @npmcli/promise-spawn, hosted-git-info, proc-log, validate-npm-package-name, @npmcli/node-gyp, minipass-fetch, @npmcli/query, cmd-shim, read-cmd-shim, write-file-atomic, abbrev, are-we-there-yet, gauge, treeverse, minify-registry-metadata, ini, @npmcli/disparity-colors, mute-stream, npm-audit-report, npm-user-validate

lib/utils/config/definitions.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ module.exports = definitions
44
const Definition = require('./definition.js')
55

66
const { version: npmVersion } = require('../../../package.json')
7-
const ciDetect = require('@npmcli/ci-detect')
8-
const ciName = ciDetect()
7+
const ciInfo = require('ci-info')
98
const querystring = require('querystring')
109
const { isWindows } = require('../is-windows.js')
1110
const { join } = require('path')
@@ -433,7 +432,7 @@ define('cert', {
433432
})
434433

435434
define('ci-name', {
436-
default: ciName || null,
435+
default: ciInfo.name ? ciInfo.name.toLowerCase().split(' ').join('-') : null,
437436
defaultDescription: `
438437
The name of the current CI system, or \`null\` when not on a known CI
439438
platform.
@@ -442,7 +441,7 @@ define('ci-name', {
442441
description: `
443442
The name of a continuous integration system. If not set explicitly, npm
444443
will detect the current CI environment using the
445-
[\`@npmcli/ci-detect\`](http://npm.im/@npmcli/ci-detect) module.
444+
[\`ci-info\`](http://npm.im/@npmcli/ci-info) module.
446445
`,
447446
flatten,
448447
})
@@ -1597,7 +1596,7 @@ define('production', {
15971596
})
15981597

15991598
define('progress', {
1600-
default: !ciName,
1599+
default: !ciInfo.isCI,
16011600
defaultDescription: `
16021601
\`true\` unless running in a known CI system
16031602
`,

lib/utils/update-notifier.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Check daily for betas, and weekly otherwise.
44

55
const pacote = require('pacote')
6-
const ciDetect = require('@npmcli/ci-detect')
6+
const ciInfo = require('ci-info')
77
const semver = require('semver')
88
const chalk = require('chalk')
99
const { promisify } = require('util')
@@ -39,7 +39,7 @@ const updateNotifier = async (npm, spec = 'latest') => {
3939
// never check for updates in CI, when updating npm already, or opted out
4040
if (!npm.config.get('update-notifier') ||
4141
isGlobalNpmUpdate(npm) ||
42-
ciDetect()) {
42+
ciInfo.isCI) {
4343
return SKIP
4444
}
4545

node_modules/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
!/@npmcli/
1616
/@npmcli/*
1717
!/@npmcli/arborist
18-
!/@npmcli/ci-detect
1918
!/@npmcli/config
2019
!/@npmcli/disparity-colors
2120
!/@npmcli/fs
@@ -55,6 +54,7 @@
5554
!/cacache
5655
!/chalk
5756
!/chownr
57+
!/ci-info
5858
!/cidr-regex
5959
!/clean-stack
6060
!/cli-columns

node_modules/@npmcli/ci-detect/LICENSE

-15
This file was deleted.

node_modules/@npmcli/ci-detect/lib/index.js

-52
This file was deleted.

node_modules/@npmcli/ci-detect/package.json

-44
This file was deleted.

node_modules/ci-info/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016-2021 Thomas Watson Steen
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

node_modules/ci-info/index.d.ts

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/**
2+
* Returns a boolean. Will be `true` if the code is running on a CI server,
3+
* otherwise `false`.
4+
*
5+
* Some CI servers not listed here might still trigger the `ci.isCI`
6+
* boolean to be set to `true` if they use certain vendor neutral environment
7+
* variables. In those cases `ci.name` will be `null` and no vendor specific
8+
* boolean will be set to `true`.
9+
*/
10+
export const isCI: boolean;
11+
/**
12+
* Returns a boolean if PR detection is supported for the current CI server.
13+
* Will be `true` if a PR is being tested, otherwise `false`. If PR detection is
14+
* not supported for the current CI server, the value will be `null`.
15+
*/
16+
export const isPR: boolean | null;
17+
/**
18+
* Returns a string containing name of the CI server the code is running on. If
19+
* CI server is not detected, it returns `null`.
20+
*
21+
* Don't depend on the value of this string not to change for a specific vendor.
22+
* If you find your self writing `ci.name === 'Travis CI'`, you most likely want
23+
* to use `ci.TRAVIS` instead.
24+
*/
25+
export const name: string | null;
26+
27+
export const APPVEYOR: boolean;
28+
export const AZURE_PIPELINES: boolean;
29+
export const APPCIRCLE: boolean;
30+
export const BAMBOO: boolean;
31+
export const BITBUCKET: boolean;
32+
export const BITRISE: boolean;
33+
export const BUDDY: boolean;
34+
export const BUILDKITE: boolean;
35+
export const CIRCLE: boolean;
36+
export const CIRRUS: boolean;
37+
export const CODEBUILD: boolean;
38+
export const CODEMAGIC: boolean;
39+
export const CODEFRESH: boolean;
40+
export const CODESHIP: boolean;
41+
export const DRONE: boolean;
42+
export const DSARI: boolean;
43+
export const EAS: boolean;
44+
export const GERRIT: boolean;
45+
export const GITHUB_ACTIONS: boolean;
46+
export const GITLAB: boolean;
47+
export const GOCD: boolean;
48+
export const GOOGLE_CLOUD_BUILD: boolean;
49+
export const HEROKU: boolean;
50+
export const HUDSON: boolean;
51+
export const JENKINS: boolean;
52+
export const LAYERCI: boolean;
53+
export const MAGNUM: boolean;
54+
export const NETLIFY: boolean;
55+
export const NEVERCODE: boolean;
56+
export const RENDER: boolean;
57+
export const SAIL: boolean;
58+
export const SEMAPHORE: boolean;
59+
export const SCREWDRIVER: boolean;
60+
export const SHIPPABLE: boolean;
61+
export const SOLANO: boolean;
62+
export const STRIDER: boolean;
63+
export const TASKCLUSTER: boolean;
64+
export const TEAMCITY: boolean;
65+
export const TRAVIS: boolean;
66+
export const VERCEL: boolean;
67+
export const APPCENTER: boolean;
68+
export const XCODE_CLOUD: boolean;
69+
export const XCODE_SERVER: boolean;
70+
export const WOODPECKER: boolean;

0 commit comments

Comments
 (0)