uniwind-pro 1.8.1 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uniwind-pro",
3
- "version": "1.8.1",
3
+ "version": "1.9.0",
4
4
  "type": "module",
5
5
  "description": "Uniwind Pro CLI",
6
6
  "keywords": [
@@ -0,0 +1,37 @@
1
+ const PROVIDERS = [
2
+ ['GITHUB_ACTIONS', 'github-actions'],
3
+ ['EAS_BUILD', 'eas'],
4
+ ['CIRCLECI', 'circleci'],
5
+ ['BITRISE_IO', 'bitrise'],
6
+ ['CM_BUILD_ID', 'codemagic'],
7
+ ['GITLAB_CI', 'gitlab'],
8
+ ['BUILDKITE', 'buildkite'],
9
+ ['TF_BUILD', 'azure-pipelines'],
10
+ ['JENKINS_URL', 'jenkins'],
11
+ ['TRAVIS', 'travis'],
12
+ ['VERCEL', 'vercel'],
13
+ ['NETLIFY', 'netlify'],
14
+ ]
15
+
16
+ const isSet = (value) => value !== undefined && value !== '' && value !== 'false' && value !== '0'
17
+
18
+ export const detectCIProvider = (env = process.env) => {
19
+ const match = PROVIDERS.find(([name]) => isSet(env[name]))
20
+
21
+ if (match) {
22
+ return match[1]
23
+ }
24
+
25
+ return isSet(env.CI) ? 'unknown-ci' : null
26
+ }
27
+
28
+ export const ciRequestHeaders = (version, env = process.env) => {
29
+ const provider = detectCIProvider(env)
30
+ const headers = { 'User-Agent': `uniwind-pro/${version}` }
31
+
32
+ if (provider) {
33
+ headers['X-Uniwind-CI'] = provider
34
+ }
35
+
36
+ return headers
37
+ }
@@ -14,6 +14,7 @@ import {
14
14
  saveToCache,
15
15
  } from './cache.js'
16
16
  import { checkLatestVersion } from './checkLatestVersion.js'
17
+ import { ciRequestHeaders } from './ciProvider.js'
17
18
  import { buildDownloadError } from './errors.js'
18
19
  import { buildIntegrityError, fetchExpectedChecksum, hashFile } from './integrity.js'
19
20
 
@@ -163,7 +164,7 @@ export const downloadFromCI = async (licenseUUID) => {
163
164
  }
164
165
 
165
166
  const cdnUrl = `${INSTALLATION_URL}/ci/${packageVersion}/${licenseUUID}`
166
- const response = await fetch(cdnUrl)
167
+ const response = await fetch(cdnUrl, { headers: ciRequestHeaders(packageVersion) })
167
168
 
168
169
  await handleBannedResponse(response)
169
170