config.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. 'use strict'
  2. const pkg = require('./package.json')
  3. const figgyPudding = require('figgy-pudding')
  4. const silentLog = require('./silentlog.js')
  5. const AUTH_REGEX = /^(?:.*:)?(token|_authToken|username|_password|password|email|always-auth|_auth|otp)$/
  6. const SCOPE_REGISTRY_REGEX = /@.*:registry$/gi
  7. module.exports = figgyPudding({
  8. 'agent': {},
  9. 'algorithms': {},
  10. 'body': {},
  11. 'ca': {},
  12. 'cache': {},
  13. 'cert': {},
  14. 'fetch-retries': {},
  15. 'fetch-retry-factor': {},
  16. 'fetch-retry-maxtimeout': {},
  17. 'fetch-retry-mintimeout': {},
  18. 'force-auth': {},
  19. forceAuth: 'force-auth',
  20. 'gzip': {},
  21. 'headers': {},
  22. 'https-proxy': {},
  23. 'ignore-body': {},
  24. ignoreBody: 'ignore-body',
  25. 'integrity': {},
  26. 'is-from-ci': 'isFromCI',
  27. 'isFromCI': {
  28. default () {
  29. return (
  30. process.env['CI'] === 'true' ||
  31. process.env['TDDIUM'] ||
  32. process.env['JENKINS_URL'] ||
  33. process.env['bamboo.buildKey'] ||
  34. process.env['GO_PIPELINE_NAME']
  35. )
  36. }
  37. },
  38. 'key': {},
  39. 'local-address': {},
  40. 'log': {
  41. default: silentLog
  42. },
  43. 'map-json': 'mapJson',
  44. 'mapJSON': 'mapJson',
  45. 'mapJson': {},
  46. 'max-sockets': 'maxsockets',
  47. 'maxsockets': {
  48. default: 12
  49. },
  50. 'memoize': {},
  51. 'method': {
  52. default: 'GET'
  53. },
  54. 'no-proxy': {},
  55. 'noproxy': {},
  56. 'npm-session': 'npmSession',
  57. 'npmSession': {},
  58. 'offline': {},
  59. 'otp': {},
  60. 'prefer-offline': {},
  61. 'prefer-online': {},
  62. 'projectScope': {},
  63. 'project-scope': 'projectScope',
  64. 'Promise': {default: () => Promise},
  65. 'proxy': {},
  66. 'query': {},
  67. 'refer': {},
  68. 'referer': 'refer',
  69. 'registry': {
  70. default: 'https://registry.npmjs.org/'
  71. },
  72. 'retry': {},
  73. 'scope': {},
  74. 'spec': {},
  75. 'strict-ssl': {},
  76. 'timeout': {
  77. default: 0
  78. },
  79. 'user-agent': {
  80. default: `${
  81. pkg.name
  82. }@${
  83. pkg.version
  84. }/node@${
  85. process.version
  86. }+${
  87. process.arch
  88. } (${
  89. process.platform
  90. })`
  91. }
  92. }, {
  93. other (key) {
  94. return key.match(AUTH_REGEX) || key.match(SCOPE_REGISTRY_REGEX)
  95. }
  96. })