Skip to content

Commit 6d87050

Browse files
authored
Merge pull request #25 from Turbo87/chunk-numbers
tsup: Replace hash in chunk filename with sequence number
2 parents c57b171 + 66dcd25 commit 6d87050

File tree

4 files changed

+24
-19
lines changed

4 files changed

+24
-19
lines changed
File renamed without changes.

dist/main.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88

99

10-
var _chunkOLZEGNJMjs = require('./chunk-OLZEGNJM.js');
10+
var _chunk1js = require('./chunk1.js');
1111

1212
// src/main.ts
13-
var core2 = _chunkOLZEGNJMjs.__toESM.call(void 0, _chunkOLZEGNJMjs.require_core.call(void 0, ));
13+
var core2 = _chunk1js.__toESM.call(void 0, _chunk1js.require_core.call(void 0, ));
1414

1515
// src/registry_url.ts
16-
var core = _chunkOLZEGNJMjs.__toESM.call(void 0, _chunkOLZEGNJMjs.require_core.call(void 0, ));
16+
var core = _chunk1js.__toESM.call(void 0, _chunk1js.require_core.call(void 0, ));
1717
function getAudienceFromUrl(url) {
1818
const audience = url.replace(/^https?:\/\//, "");
1919
if (audience.startsWith("http://") || audience.startsWith("https://")) {
@@ -32,16 +32,16 @@ function getRegistryUrl() {
3232
}
3333

3434
// src/main.ts
35-
_chunkOLZEGNJMjs.runAction.call(void 0, run);
35+
_chunk1js.runAction.call(void 0, run);
3636
async function run() {
3737
checkPermissions();
3838
const registryUrl = getRegistryUrl();
3939
const audience = getAudienceFromUrl(registryUrl);
4040
const jwtToken = await getJwtToken(audience);
4141
const token = await requestTrustedPublishingToken(registryUrl, jwtToken);
4242
setTokenOutput(token);
43-
core2.saveState(_chunkOLZEGNJMjs.TOKEN_KEY, token);
44-
core2.saveState(_chunkOLZEGNJMjs.REGISTRY_URL_KEY, registryUrl);
43+
core2.saveState(_chunk1js.TOKEN_KEY, token);
44+
core2.saveState(_chunk1js.REGISTRY_URL_KEY, registryUrl);
4545
}
4646
function checkPermissions() {
4747
if (process.env.ACTIONS_ID_TOKEN_REQUEST_URL === void 0 || !process.env.ACTIONS_ID_TOKEN_REQUEST_URL) {
@@ -60,8 +60,8 @@ async function getJwtToken(audience) {
6060
return jwtToken;
6161
}
6262
async function requestTrustedPublishingToken(registryUrl, jwtToken) {
63-
const tokenUrl = _chunkOLZEGNJMjs.getTokensEndpoint.call(void 0, registryUrl);
64-
const userAgent = _chunkOLZEGNJMjs.getUserAgent.call(void 0, );
63+
const tokenUrl = _chunk1js.getTokensEndpoint.call(void 0, registryUrl);
64+
const userAgent = _chunk1js.getUserAgent.call(void 0, );
6565
core2.info(
6666
`Requesting token from: ${tokenUrl}. User agent: ${userAgent["User-Agent"]}`
6767
);
@@ -75,14 +75,14 @@ async function requestTrustedPublishingToken(registryUrl, jwtToken) {
7575
body: JSON.stringify({ jwt: jwtToken })
7676
});
7777
if (!response.ok) {
78-
await _chunkOLZEGNJMjs.throwHttpErrorMessage.call(void 0,
78+
await _chunk1js.throwHttpErrorMessage.call(void 0,
7979
"Failed to retrieve token from Cargo registry",
8080
response
8181
);
8282
}
8383
const tokenResponse = await response.json();
8484
if (!tokenResponse.token) {
85-
await _chunkOLZEGNJMjs.throwHttpErrorMessage.call(void 0,
85+
await _chunk1js.throwHttpErrorMessage.call(void 0,
8686
"Failed to retrieve token from the Cargo registry response body",
8787
response
8888
);
@@ -92,7 +92,7 @@ async function requestTrustedPublishingToken(registryUrl, jwtToken) {
9292
}
9393
function setTokenOutput(token) {
9494
core2.setSecret(token);
95-
core2.setOutput(_chunkOLZEGNJMjs.TOKEN_KEY, token);
95+
core2.setOutput(_chunk1js.TOKEN_KEY, token);
9696
}
9797

9898

dist/post.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77

88

99

10-
var _chunkOLZEGNJMjs = require('./chunk-OLZEGNJM.js');
10+
var _chunk1js = require('./chunk1.js');
1111

1212
// src/post.ts
13-
var core = _chunkOLZEGNJMjs.__toESM.call(void 0, _chunkOLZEGNJMjs.require_core.call(void 0, ));
14-
_chunkOLZEGNJMjs.runAction.call(void 0, cleanup);
13+
var core = _chunk1js.__toESM.call(void 0, _chunk1js.require_core.call(void 0, ));
14+
_chunk1js.runAction.call(void 0, cleanup);
1515
async function cleanup() {
16-
const token = core.getState(_chunkOLZEGNJMjs.TOKEN_KEY);
17-
const registryUrl = core.getState(_chunkOLZEGNJMjs.REGISTRY_URL_KEY);
16+
const token = core.getState(_chunk1js.TOKEN_KEY);
17+
const registryUrl = core.getState(_chunk1js.REGISTRY_URL_KEY);
1818
if (!token) {
1919
core.info("No token to revoke");
2020
return;
@@ -23,18 +23,18 @@ async function cleanup() {
2323
}
2424
async function revokeToken(registryUrl, token) {
2525
core.info("Revoking trusted publishing token");
26-
const tokensEndpoint = _chunkOLZEGNJMjs.getTokensEndpoint.call(void 0, registryUrl);
26+
const tokensEndpoint = _chunk1js.getTokensEndpoint.call(void 0, registryUrl);
2727
core.info(`Revoking token at: ${tokensEndpoint}`);
2828
const response = await fetch(tokensEndpoint, {
2929
method: "DELETE",
3030
headers: {
3131
/* eslint-disable @typescript-eslint/naming-convention */
3232
Authorization: `Bearer ${token}`,
33-
..._chunkOLZEGNJMjs.getUserAgent.call(void 0, )
33+
..._chunk1js.getUserAgent.call(void 0, )
3434
}
3535
});
3636
if (!response.ok) {
37-
await _chunkOLZEGNJMjs.throwHttpErrorMessage.call(void 0, "Failed to revoke token", response);
37+
await _chunk1js.throwHttpErrorMessage.call(void 0, "Failed to revoke token", response);
3838
}
3939
core.info("Token revoked successfully");
4040
}

tsup.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { defineConfig } from "tsup";
22

3+
let chunkNumber = 0;
4+
35
export default defineConfig({
46
entry: ["src/main.ts", "src/post.ts"],
57
format: ["cjs"],
@@ -10,4 +12,7 @@ export default defineConfig({
1012
target: "node20",
1113
clean: true,
1214
splitting: true,
15+
esbuildOptions(options) {
16+
options.chunkNames = `[name]${++chunkNumber}`;
17+
},
1318
});

0 commit comments

Comments
 (0)