Workaround getting the package version for the user-agent
This commit is contained in:
@@ -39,7 +39,7 @@
|
|||||||
"audit-moderate": "npm install && npm audit --json --audit-level=moderate > audit.json",
|
"audit-moderate": "npm install && npm audit --json --audit-level=moderate > audit.json",
|
||||||
"test": "cd ../../ && npm run test ./packages/artifact",
|
"test": "cd ../../ && npm run test ./packages/artifact",
|
||||||
"bootstrap": "cd ../../ && npm run bootstrap",
|
"bootstrap": "cd ../../ && npm run bootstrap",
|
||||||
"tsc-run": "tsc",
|
"tsc-run": "tsc && cp src/internal/shared/package-version.cjs lib/internal/shared/",
|
||||||
"tsc": "npm run bootstrap && npm run tsc-run",
|
"tsc": "npm run bootstrap && npm run tsc-run",
|
||||||
"gen:docs": "typedoc --plugin typedoc-plugin-markdown --out docs/generated src/artifact.ts --githubPages false --readme none"
|
"gen:docs": "typedoc --plugin typedoc-plugin-markdown --out docs/generated src/artifact.ts --githubPages false --readme none"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
// This file exists as a CommonJS module to read the version from package.json.
|
||||||
|
// In an ESM package, using `require()` directly in .ts files requires disabling
|
||||||
|
// ESLint rules and doesn't work reliably across all Node.js versions.
|
||||||
|
// By keeping this as a .cjs file, we can use require() naturally and export
|
||||||
|
// the version for the ESM modules to import.
|
||||||
|
const packageJson = require('../../../package.json')
|
||||||
|
module.exports = { version: packageJson.version }
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
import {version} from './package-version.cjs'
|
||||||
const packageJson = require('../../../package.json')
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensure that this User Agent String is used in all HTTP calls so that we can monitor telemetry between different versions of this package
|
* Ensure that this User Agent String is used in all HTTP calls so that we can monitor telemetry between different versions of this package
|
||||||
*/
|
*/
|
||||||
export function getUserAgentString(): string {
|
export function getUserAgentString(): string {
|
||||||
return `@actions/artifact-${packageJson.version}`
|
return `@actions/artifact-${version}`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user