Skip to content

Commit 805b8f3

Browse files
authored
Merge pull request #15 from Turbo87/pkg-import
Read package version from `package.json` file
2 parents aebb08e + e8a8c39 commit 805b8f3

File tree

3 files changed

+90
-6
lines changed

3 files changed

+90
-6
lines changed

dist/main.js

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19851,6 +19851,46 @@ function getRegistryUrl() {
1985119851

1985219852
// src/utils.ts
1985319853
var core2 = __toESM(require_core());
19854+
19855+
// package.json
19856+
var package_default = {
19857+
name: "crates-io-auth-action",
19858+
version: "1.0.0",
19859+
description: "Get a temporary access token that you can use to interact with crates.io.",
19860+
private: true,
19861+
scripts: {
19862+
package: "tsup",
19863+
format: "npx prettier --write .",
19864+
lint: "npx eslint",
19865+
test: "vitest"
19866+
},
19867+
engines: {
19868+
node: ">=20"
19869+
},
19870+
repository: {
19871+
type: "git",
19872+
url: "git+https://github.com/rust-lang/crates-io-auth-action.git"
19873+
},
19874+
license: "MIT",
19875+
bugs: {
19876+
url: "https://github.com/rust-lang/crates-io-auth-action/issues"
19877+
},
19878+
homepage: "https://github.com/rust-lang/crates-io-auth-action#readme",
19879+
devDependencies: {
19880+
"@actions/core": "^1.11.1",
19881+
"@types/node": "^20",
19882+
eslint: "^9.28.0",
19883+
msw: "^2.10.2",
19884+
prettier: "^3.5.3",
19885+
tslib: "^2.8.1",
19886+
tsup: "^8.0.0",
19887+
typescript: "^5.8.3",
19888+
"typescript-eslint": "^8.34.0",
19889+
vitest: "^3.2.4"
19890+
}
19891+
};
19892+
19893+
// src/utils.ts
1985419894
var TOKEN_KEY = "token";
1985519895
var REGISTRY_URL_KEY = "registryUrl";
1985619896
function isErrorResponse(value) {
@@ -19893,8 +19933,9 @@ function getTokensEndpoint(registryUrl) {
1989319933
return `${registryUrl}/api/v1/trusted_publishing/tokens`;
1989419934
}
1989519935
function userAgentValue() {
19896-
const packageVersion = "1.0.0";
19897-
return `crates-io-auth-action/${packageVersion}`;
19936+
const packageName = package_default.name;
19937+
const packageVersion = package_default.version;
19938+
return `${packageName}/${packageVersion}`;
1989819939
}
1989919940
function getUserAgent() {
1990019941
const userAgent = userAgentValue();

dist/post.js

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19832,6 +19832,46 @@ var core2 = __toESM(require_core());
1983219832

1983319833
// src/utils.ts
1983419834
var core = __toESM(require_core());
19835+
19836+
// package.json
19837+
var package_default = {
19838+
name: "crates-io-auth-action",
19839+
version: "1.0.0",
19840+
description: "Get a temporary access token that you can use to interact with crates.io.",
19841+
private: true,
19842+
scripts: {
19843+
package: "tsup",
19844+
format: "npx prettier --write .",
19845+
lint: "npx eslint",
19846+
test: "vitest"
19847+
},
19848+
engines: {
19849+
node: ">=20"
19850+
},
19851+
repository: {
19852+
type: "git",
19853+
url: "git+https://github.com/rust-lang/crates-io-auth-action.git"
19854+
},
19855+
license: "MIT",
19856+
bugs: {
19857+
url: "https://github.com/rust-lang/crates-io-auth-action/issues"
19858+
},
19859+
homepage: "https://github.com/rust-lang/crates-io-auth-action#readme",
19860+
devDependencies: {
19861+
"@actions/core": "^1.11.1",
19862+
"@types/node": "^20",
19863+
eslint: "^9.28.0",
19864+
msw: "^2.10.2",
19865+
prettier: "^3.5.3",
19866+
tslib: "^2.8.1",
19867+
tsup: "^8.0.0",
19868+
typescript: "^5.8.3",
19869+
"typescript-eslint": "^8.34.0",
19870+
vitest: "^3.2.4"
19871+
}
19872+
};
19873+
19874+
// src/utils.ts
1983519875
var TOKEN_KEY = "token";
1983619876
var REGISTRY_URL_KEY = "registryUrl";
1983719877
function isErrorResponse(value) {
@@ -19874,8 +19914,9 @@ function getTokensEndpoint(registryUrl) {
1987419914
return `${registryUrl}/api/v1/trusted_publishing/tokens`;
1987519915
}
1987619916
function userAgentValue() {
19877-
const packageVersion = "1.0.0";
19878-
return `crates-io-auth-action/${packageVersion}`;
19917+
const packageName = package_default.name;
19918+
const packageVersion = package_default.version;
19919+
return `${packageName}/${packageVersion}`;
1987919920
}
1988019921
function getUserAgent() {
1988119922
const userAgent = userAgentValue();

src/utils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as core from "@actions/core";
2+
import packageJson from "../package.json";
23

34
export const TOKEN_KEY = "token";
45
export const REGISTRY_URL_KEY = "registryUrl";
@@ -77,8 +78,9 @@ export function getTokensEndpoint(registryUrl: string): string {
7778
}
7879

7980
function userAgentValue(): string {
80-
const packageVersion = "1.0.0";
81-
return `crates-io-auth-action/${packageVersion}`;
81+
const packageName: string = packageJson.name;
82+
const packageVersion: string = packageJson.version;
83+
return `${packageName}/${packageVersion}`;
8284
}
8385

8486
export function getUserAgent(): UserAgent {

0 commit comments

Comments
 (0)